From 4982b9614516dde101c3e44c60a612b3bfd8d6fe Mon Sep 17 00:00:00 2001 From: DELL <DELL@WIN-3EOIPEE9ML1> Date: 星期三, 21 二月 2024 16:26:06 +0800 Subject: [PATCH] 新增IEDScout调试工具功能 --- iec61850_forFoShanAES_Model/src/org/openmuc/openiec61850/BdaUnicodeString.java | 224 ++++++++++++++++++++++++++++---------------------------- 1 files changed, 112 insertions(+), 112 deletions(-) diff --git a/iec61850_forFoShanAES_Model/src/org/openmuc/openiec61850/BdaUnicodeString.java b/iec61850_forFoShanAES_Model/src/org/openmuc/openiec61850/BdaUnicodeString.java index f3221f6..69ef587 100644 --- a/iec61850_forFoShanAES_Model/src/org/openmuc/openiec61850/BdaUnicodeString.java +++ b/iec61850_forFoShanAES_Model/src/org/openmuc/openiec61850/BdaUnicodeString.java @@ -1,112 +1,112 @@ -/* - * Copyright 2011-17 Fraunhofer ISE, energy & meteo Systems GmbH and other contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.openmuc.openiec61850; - -import org.openmuc.openiec61850.internal.mms.asn1.Data; -import org.openmuc.openiec61850.internal.mms.asn1.Integer32; -import org.openmuc.openiec61850.internal.mms.asn1.MMSString; -import org.openmuc.openiec61850.internal.mms.asn1.TypeDescription; - -public final class BdaUnicodeString extends BasicDataAttribute { - - private byte[] value; - private final int maxLength; - - public BdaUnicodeString(ObjectReference objectReference, Fc fc, String sAddr, int maxLength, boolean dchg, - boolean dupd) { - super(objectReference, fc, sAddr, dchg, dupd); - basicType = BdaType.UNICODE_STRING; - this.maxLength = maxLength; - setDefault(); - } - - public byte[] getValue() { - return value; - } - - public void setValue(byte[] value) { - if (value == null || value.length > maxLength) { - throw new IllegalArgumentException( - "Value was null or UNICODE_STRING value size exceeds maxLength of " + maxLength); - } - this.value = value; - } - - @Override - void setValueFrom(BasicDataAttribute bda) { - byte[] srcValue = ((BdaUnicodeString) bda).getValue(); - if (value.length != srcValue.length) { - value = new byte[srcValue.length]; - } - System.arraycopy(srcValue, 0, value, 0, srcValue.length); - } - - public int getMaxLength() { - return maxLength; - } - - @Override - public void setDefault() { - value = new byte[0]; - } - - @Override - public BdaUnicodeString copy() { - BdaUnicodeString copy = new BdaUnicodeString(objectReference, fc, sAddr, maxLength, dchg, dupd); - byte[] valueCopy = new byte[value.length]; - System.arraycopy(value, 0, valueCopy, 0, value.length); - copy.setValue(valueCopy); - if (mirror == null) { - copy.mirror = this; - } - else { - copy.mirror = mirror; - } - return copy; - } - - @Override - Data getMmsDataObj() { - Data data = new Data(); - data.setMMSString(new MMSString(value)); - return data; - } - - @Override - void setValueFromMmsDataObj(Data data) throws ServiceError { - if (data.getMMSString() == null) { - throw new ServiceError(ServiceError.TYPE_CONFLICT, "expected type: mms_string/unicode_string"); - } - value = data.getMMSString().value; - } - - @Override - TypeDescription getMmsTypeSpec() { - TypeDescription typeDescription = new TypeDescription(); - typeDescription.setMMSString(new Integer32(maxLength * -1)); - return typeDescription; - } - - @Override - public String toString() { - if (value == null) { - return getReference().toString() + ": null"; - } - return getReference().toString() + ": " + new String(value); - } - -} +/* + * Copyright 2011-17 Fraunhofer ISE, energy & meteo Systems GmbH and other contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.openmuc.openiec61850; + +import org.openmuc.openiec61850.internal.mms.asn1.Data; +import org.openmuc.openiec61850.internal.mms.asn1.Integer32; +import org.openmuc.openiec61850.internal.mms.asn1.MMSString; +import org.openmuc.openiec61850.internal.mms.asn1.TypeDescription; + +public final class BdaUnicodeString extends BasicDataAttribute { + + private byte[] value; + private final int maxLength; + + public BdaUnicodeString(ObjectReference objectReference, Fc fc, String sAddr, int maxLength, boolean dchg, + boolean dupd) { + super(objectReference, fc, sAddr, dchg, dupd); + basicType = BdaType.UNICODE_STRING; + this.maxLength = maxLength; + setDefault(); + } + + public byte[] getValue() { + return value; + } + + public void setValue(byte[] value) { + if (value == null || value.length > maxLength) { + throw new IllegalArgumentException( + "Value was null or UNICODE_STRING value size exceeds maxLength of " + maxLength); + } + this.value = value; + } + + @Override + void setValueFrom(BasicDataAttribute bda) { + byte[] srcValue = ((BdaUnicodeString) bda).getValue(); + if (value.length != srcValue.length) { + value = new byte[srcValue.length]; + } + System.arraycopy(srcValue, 0, value, 0, srcValue.length); + } + + public int getMaxLength() { + return maxLength; + } + + @Override + public void setDefault() { + value = new byte[0]; + } + + @Override + public BdaUnicodeString copy() { + BdaUnicodeString copy = new BdaUnicodeString(objectReference, fc, sAddr, maxLength, dchg, dupd); + byte[] valueCopy = new byte[value.length]; + System.arraycopy(value, 0, valueCopy, 0, value.length); + copy.setValue(valueCopy); + if (mirror == null) { + copy.mirror = this; + } + else { + copy.mirror = mirror; + } + return copy; + } + + @Override + Data getMmsDataObj() { + Data data = new Data(); + data.setMMSString(new MMSString(value)); + return data; + } + + @Override + void setValueFromMmsDataObj(Data data) throws ServiceError { + if (data.getMMSString() == null) { + throw new ServiceError(ServiceError.TYPE_CONFLICT, "expected type: mms_string/unicode_string"); + } + value = data.getMMSString().value; + } + + @Override + TypeDescription getMmsTypeSpec() { + TypeDescription typeDescription = new TypeDescription(); + typeDescription.setMMSString(new Integer32(maxLength * -1)); + return typeDescription; + } + + @Override + public String toString() { + if (value == null) { + return getReference().toString() + ": null"; + } + return getReference().toString() + ": " + new String(value); + } + +} -- Gitblit v1.9.1