Merge pull request #3 from mz-automation/develop

support for INT128 type and some fixes
pull/4/head
sfeuerhahn 8 years ago committed by GitHub
commit 370ce99967
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,92 @@
/*
* 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.jasn1.ber.types.BerInteger;
import org.openmuc.openiec61850.internal.mms.asn1.Data;
import org.openmuc.openiec61850.internal.mms.asn1.TypeDescription;
import org.openmuc.openiec61850.internal.mms.asn1.Unsigned8;
public final class BdaInt128 extends BasicDataAttribute {
private long value;
public BdaInt128(ObjectReference objectReference, Fc fc, String sAddr, boolean dchg, boolean dupd) {
super(objectReference, fc, sAddr, dchg, dupd);
basicType = BdaType.INT128;
setDefault();
}
public void setValue(long value) {
this.value = value;
}
@Override
void setValueFrom(BasicDataAttribute bda) {
value = ((BdaInt128) bda).getValue();
}
public long getValue() {
return value;
}
@Override
public void setDefault() {
value = 0;
}
@Override
public BdaInt128 copy() {
BdaInt128 copy = new BdaInt128(objectReference, fc, sAddr, dchg, dupd);
copy.setValue(value);
if (mirror == null) {
copy.mirror = this;
}
else {
copy.mirror = mirror;
}
return copy;
}
@Override
Data getMmsDataObj() {
Data data = new Data();
data.setInteger(new BerInteger(value));
return data;
}
@Override
void setValueFromMmsDataObj(Data data) throws ServiceError {
if (data.getInteger() == null) {
throw new ServiceError(ServiceError.TYPE_CONFLICT, "expected type: integer");
}
value = data.getInteger().value.longValue();
}
@Override
TypeDescription getMmsTypeSpec() {
TypeDescription typeDescription = new TypeDescription();
typeDescription.setInteger(new Unsigned8(128));
return typeDescription;
}
@Override
public String toString() {
return getReference().toString() + ": " + value;
}
}

@ -28,6 +28,7 @@ public enum BdaType {
INT16,
INT32,
INT64,
INT128,
INT8U,
INT16U,
INT32U,

@ -215,6 +215,8 @@ final class DataDefinitionResParser {
return new BdaInt32(ref, fc, null, false, false);
case 64:
return new BdaInt64(ref, fc, null, false, false);
case 128:
return new BdaInt128(ref, fc, null, false, false);
}
}
else if (mmsTypeSpec.getUnsigned() != null) {

@ -679,19 +679,19 @@ final class SclParser {
false));
}
children.add(new BdaOctetString(new ObjectReference(reportObjRef.toString() + ".Owner"), fc, "", 64, false, false));
rcb = new Brcb(reportObjRef, children);
}
else {
children.add(new BdaOctetString(new ObjectReference(reportObjRef.toString() + ".Owner"), fc, "", 64, false, false));
rcb = new Urcb(reportObjRef, children);
}
// ignoring owner because it cannot be specified in SCL file
rcbInstances.add(rcb);
}
return rcbInstances;
@ -907,6 +907,17 @@ final class SclParser {
}
return bda;
}
else if (bType.equals("INT128")) {
BdaInt128 bda = new BdaInt128(new ObjectReference(ref), fc, sAddr, dchg, dupd);
if (val != null) {
try {
bda.setValue(Long.parseLong(val));
} catch (NumberFormatException e) {
throw new SclParseException("invalid INT128 configured value: " + val);
}
}
return bda;
}
else if (bType.equals("INT8U")) {
BdaInt8U bda = new BdaInt8U(new ObjectReference(ref), fc, sAddr, dchg, dupd);
if (val != null) {
@ -983,7 +994,7 @@ final class SclParser {
Integer.parseInt(dattr.getbType().substring(5)), dchg, dupd);
if (val != null) {
// TODO
throw new SclParseException("parsing configured value for octet string is not supported yet.");
//throw new SclParseException("parsing configured value for octet string is not supported yet.");
}
return bda;
}

@ -30,8 +30,8 @@ import org.openmuc.openiec61850.Urcb;
public class ReportingTest implements ClientEventListener {
private static final String PREEXISTING_DATASET_REFERENCE = "ied1lDevice1/LLN0.dataset1";
private static final String CREATED_DATASET_REFERENCE = "ied1lDevice1/LLN0.datasetnew";
private static final String PREEXISTING_DATASET_REFERENCE = "ied1lDevice1/LLN0$dataset1";
private static final String CREATED_DATASET_REFERENCE = "ied1lDevice1/LLN0$datasetnew";
private static final String CHANGING_SERVER_DA_REFERENCE_1 = "ied1lDevice1/MMXU1.W.phsA.cVal.mag.f";
private static final String CHANGING_SERVER_DA_REFERENCE_2 = "ied1lDevice1/DSCH1.SchdAbsTm.sptestval1";
private static final int PORT = 54321;

Loading…
Cancel
Save