All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.openmuc.openiec61850.internal.mms.asn1.ConfirmedServiceResponse Maven / Gradle / Ivy

Go to download

OpenIEC61850 is a library implementing the IEC 61850 MMS communication standard (client and server).

There is a newer version: 1.7.0
Show newest version
/**
 * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
 */

package org.openmuc.openiec61850.internal.mms.asn1;

import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;

import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
import org.openmuc.jasn1.ber.BerTag;

public class ConfirmedServiceResponse implements Serializable {

    private static final long serialVersionUID = 1L;

    public byte[] code = null;
    private GetNameListResponse getNameList = null;
    private ReadResponse read = null;
    private WriteResponse write = null;
    private GetVariableAccessAttributesResponse getVariableAccessAttributes = null;
    private DefineNamedVariableListResponse defineNamedVariableList = null;
    private GetNamedVariableListAttributesResponse getNamedVariableListAttributes = null;
    private DeleteNamedVariableListResponse deleteNamedVariableList = null;

    public ConfirmedServiceResponse() {
    }

    public ConfirmedServiceResponse(byte[] code) {
        this.code = code;
    }

    public void setGetNameList(GetNameListResponse getNameList) {
        this.getNameList = getNameList;
    }

    public GetNameListResponse getGetNameList() {
        return getNameList;
    }

    public void setRead(ReadResponse read) {
        this.read = read;
    }

    public ReadResponse getRead() {
        return read;
    }

    public void setWrite(WriteResponse write) {
        this.write = write;
    }

    public WriteResponse getWrite() {
        return write;
    }

    public void setGetVariableAccessAttributes(GetVariableAccessAttributesResponse getVariableAccessAttributes) {
        this.getVariableAccessAttributes = getVariableAccessAttributes;
    }

    public GetVariableAccessAttributesResponse getGetVariableAccessAttributes() {
        return getVariableAccessAttributes;
    }

    public void setDefineNamedVariableList(DefineNamedVariableListResponse defineNamedVariableList) {
        this.defineNamedVariableList = defineNamedVariableList;
    }

    public DefineNamedVariableListResponse getDefineNamedVariableList() {
        return defineNamedVariableList;
    }

    public void setGetNamedVariableListAttributes(
            GetNamedVariableListAttributesResponse getNamedVariableListAttributes) {
        this.getNamedVariableListAttributes = getNamedVariableListAttributes;
    }

    public GetNamedVariableListAttributesResponse getGetNamedVariableListAttributes() {
        return getNamedVariableListAttributes;
    }

    public void setDeleteNamedVariableList(DeleteNamedVariableListResponse deleteNamedVariableList) {
        this.deleteNamedVariableList = deleteNamedVariableList;
    }

    public DeleteNamedVariableListResponse getDeleteNamedVariableList() {
        return deleteNamedVariableList;
    }

    public int encode(BerByteArrayOutputStream os) throws IOException {

        if (code != null) {
            for (int i = code.length - 1; i >= 0; i--) {
                os.write(code[i]);
            }
            return code.length;
        }

        int codeLength = 0;
        if (deleteNamedVariableList != null) {
            codeLength += deleteNamedVariableList.encode(os, false);
            // write tag: CONTEXT_CLASS, CONSTRUCTED, 13
            os.write(0xAD);
            codeLength += 1;
            return codeLength;
        }

        if (getNamedVariableListAttributes != null) {
            codeLength += getNamedVariableListAttributes.encode(os, false);
            // write tag: CONTEXT_CLASS, CONSTRUCTED, 12
            os.write(0xAC);
            codeLength += 1;
            return codeLength;
        }

        if (defineNamedVariableList != null) {
            codeLength += defineNamedVariableList.encode(os, false);
            // write tag: CONTEXT_CLASS, PRIMITIVE, 11
            os.write(0x8B);
            codeLength += 1;
            return codeLength;
        }

        if (getVariableAccessAttributes != null) {
            codeLength += getVariableAccessAttributes.encode(os, false);
            // write tag: CONTEXT_CLASS, CONSTRUCTED, 6
            os.write(0xA6);
            codeLength += 1;
            return codeLength;
        }

        if (write != null) {
            codeLength += write.encode(os, false);
            // write tag: CONTEXT_CLASS, CONSTRUCTED, 5
            os.write(0xA5);
            codeLength += 1;
            return codeLength;
        }

        if (read != null) {
            codeLength += read.encode(os, false);
            // write tag: CONTEXT_CLASS, CONSTRUCTED, 4
            os.write(0xA4);
            codeLength += 1;
            return codeLength;
        }

        if (getNameList != null) {
            codeLength += getNameList.encode(os, false);
            // write tag: CONTEXT_CLASS, CONSTRUCTED, 1
            os.write(0xA1);
            codeLength += 1;
            return codeLength;
        }

        throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
    }

    public int decode(InputStream is) throws IOException {
        return decode(is, null);
    }

    public int decode(InputStream is, BerTag berTag) throws IOException {

        int codeLength = 0;
        BerTag passedTag = berTag;

        if (berTag == null) {
            berTag = new BerTag();
            codeLength += berTag.decode(is);
        }

        if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
            getNameList = new GetNameListResponse();
            codeLength += getNameList.decode(is, false);
            return codeLength;
        }

        if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 4)) {
            read = new ReadResponse();
            codeLength += read.decode(is, false);
            return codeLength;
        }

        if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 5)) {
            write = new WriteResponse();
            codeLength += write.decode(is, false);
            return codeLength;
        }

        if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 6)) {
            getVariableAccessAttributes = new GetVariableAccessAttributesResponse();
            codeLength += getVariableAccessAttributes.decode(is, false);
            return codeLength;
        }

        if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 11)) {
            defineNamedVariableList = new DefineNamedVariableListResponse();
            codeLength += defineNamedVariableList.decode(is, false);
            return codeLength;
        }

        if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 12)) {
            getNamedVariableListAttributes = new GetNamedVariableListAttributesResponse();
            codeLength += getNamedVariableListAttributes.decode(is, false);
            return codeLength;
        }

        if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 13)) {
            deleteNamedVariableList = new DeleteNamedVariableListResponse();
            codeLength += deleteNamedVariableList.decode(is, false);
            return codeLength;
        }

        if (passedTag != null) {
            return 0;
        }

        throw new IOException("Error decoding CHOICE: Tag " + berTag + " matched to no item.");
    }

    public void encodeAndSave(int encodingSizeGuess) throws IOException {
        BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
        encode(os);
        code = os.getArray();
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        appendAsString(sb, 0);
        return sb.toString();
    }

    public void appendAsString(StringBuilder sb, int indentLevel) {

        if (getNameList != null) {
            sb.append("getNameList: ");
            getNameList.appendAsString(sb, indentLevel + 1);
            return;
        }

        if (read != null) {
            sb.append("read: ");
            read.appendAsString(sb, indentLevel + 1);
            return;
        }

        if (write != null) {
            sb.append("write: ");
            write.appendAsString(sb, indentLevel + 1);
            return;
        }

        if (getVariableAccessAttributes != null) {
            sb.append("getVariableAccessAttributes: ");
            getVariableAccessAttributes.appendAsString(sb, indentLevel + 1);
            return;
        }

        if (defineNamedVariableList != null) {
            sb.append("defineNamedVariableList: ").append(defineNamedVariableList);
            return;
        }

        if (getNamedVariableListAttributes != null) {
            sb.append("getNamedVariableListAttributes: ");
            getNamedVariableListAttributes.appendAsString(sb, indentLevel + 1);
            return;
        }

        if (deleteNamedVariableList != null) {
            sb.append("deleteNamedVariableList: ");
            deleteNamedVariableList.appendAsString(sb, indentLevel + 1);
            return;
        }

        sb.append("");
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy