org.openmuc.jdlms.internal.asn1.cosem.UnconfirmedWriteRequest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jdlms Show documentation
Show all versions of jdlms Show documentation
jDLMS is a library implementing the DLMS/COSEM (IEC 62056) communication standard.
The newest version!
/**
* This class file was automatically generated by the AXDR compiler that is part of jDLMS (http://www.openmuc.org)
*/
package org.openmuc.jdlms.internal.asn1.cosem;
import java.io.IOException;
import java.io.InputStream;
import org.openmuc.jdlms.internal.asn1.axdr.AxdrType;
import org.openmuc.jdlms.internal.asn1.axdr.types.AxdrSequenceOf;
import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
public class UnconfirmedWriteRequest implements AxdrType {
public static class SubSeqOfVariableAccessSpecification extends AxdrSequenceOf {
@Override
protected VariableAccessSpecification createListElement() {
return new VariableAccessSpecification();
}
protected SubSeqOfVariableAccessSpecification(int length) {
super(length);
}
public SubSeqOfVariableAccessSpecification() {
} // Call empty base constructor
}
public static class SubSeqOfListOfData extends AxdrSequenceOf {
@Override
protected Data createListElement() {
return new Data();
}
protected SubSeqOfListOfData(int length) {
super(length);
}
public SubSeqOfListOfData() {
} // Call empty base constructor
}
public byte[] code = null;
public SubSeqOfVariableAccessSpecification variableAccessSpecification = null;
public SubSeqOfListOfData listOfData = null;
public UnconfirmedWriteRequest() {
}
public UnconfirmedWriteRequest(byte[] code) {
this.code = code;
}
public UnconfirmedWriteRequest(SubSeqOfVariableAccessSpecification variableAccessSpecification,
SubSeqOfListOfData listOfData) {
this.variableAccessSpecification = variableAccessSpecification;
this.listOfData = listOfData;
}
@Override
public int encode(ReverseByteArrayOutputStream axdrOStream) throws IOException {
int codeLength;
if (code != null) {
codeLength = code.length;
for (int i = code.length - 1; i >= 0; i--) {
axdrOStream.write(code[i]);
}
}
else {
codeLength = 0;
codeLength += listOfData.encode(axdrOStream);
codeLength += variableAccessSpecification.encode(axdrOStream);
}
return codeLength;
}
@Override
public int decode(InputStream iStream) throws IOException {
int codeLength = 0;
variableAccessSpecification = new SubSeqOfVariableAccessSpecification();
codeLength += variableAccessSpecification.decode(iStream);
listOfData = new SubSeqOfListOfData();
codeLength += listOfData.decode(iStream);
return codeLength;
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
ReverseByteArrayOutputStream axdrOStream = new ReverseByteArrayOutputStream(encodingSizeGuess);
encode(axdrOStream);
code = axdrOStream.getArray();
}
@Override
public String toString() {
return "sequence: {" + "variableAccessSpecification: " + variableAccessSpecification + ", listOfData: "
+ listOfData + "}";
}
}