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

ccsds.sle.transfer.service.rocf.outgoing.pdus.OcfOrNotification Maven / Gradle / Ivy

There is a newer version: 1.1.0
Show newest version
/**
 * This class file was automatically generated by jASN1 v1.11.2 (http://www.beanit.com)
 */

package ccsds.sle.transfer.service.rocf.outgoing.pdus;

import java.io.IOException;
import java.io.EOFException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.io.Serializable;
import com.beanit.jasn1.ber.*;
import com.beanit.jasn1.ber.types.*;
import com.beanit.jasn1.ber.types.string.*;

import ccsds.sle.transfer.service.bind.types.SleBindInvocation;
import ccsds.sle.transfer.service.bind.types.SleBindReturn;
import ccsds.sle.transfer.service.bind.types.SlePeerAbort;
import ccsds.sle.transfer.service.bind.types.SleUnbindInvocation;
import ccsds.sle.transfer.service.bind.types.SleUnbindReturn;
import ccsds.sle.transfer.service.common.pdus.SleAcknowledgement;
import ccsds.sle.transfer.service.common.pdus.SleScheduleStatusReportReturn;
import ccsds.sle.transfer.service.common.types.Credentials;
import ccsds.sle.transfer.service.common.types.IntUnsignedLong;
import ccsds.sle.transfer.service.common.types.InvokeId;
import ccsds.sle.transfer.service.common.types.SpaceLinkDataUnit;
import ccsds.sle.transfer.service.common.types.Time;
import ccsds.sle.transfer.service.rocf.structures.AntennaId;
import ccsds.sle.transfer.service.rocf.structures.CarrierLockStatus;
import ccsds.sle.transfer.service.rocf.structures.DiagnosticRocfGet;
import ccsds.sle.transfer.service.rocf.structures.DiagnosticRocfStart;
import ccsds.sle.transfer.service.rocf.structures.FrameSyncLockStatus;
import ccsds.sle.transfer.service.rocf.structures.LockStatus;
import ccsds.sle.transfer.service.rocf.structures.Notification;
import ccsds.sle.transfer.service.rocf.structures.RocfGetParameter;
import ccsds.sle.transfer.service.rocf.structures.RocfProductionStatus;
import ccsds.sle.transfer.service.rocf.structures.SymbolLockStatus;

public class OcfOrNotification implements BerType, Serializable {

	private static final long serialVersionUID = 1L;

	public byte[] code = null;
	private RocfTransferDataInvocation annotatedOcf = null;
	private RocfSyncNotifyInvocation syncNotification = null;
	
	public OcfOrNotification() {
	}

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

	public void setAnnotatedOcf(RocfTransferDataInvocation annotatedOcf) {
		this.annotatedOcf = annotatedOcf;
	}

	public RocfTransferDataInvocation getAnnotatedOcf() {
		return annotatedOcf;
	}

	public void setSyncNotification(RocfSyncNotifyInvocation syncNotification) {
		this.syncNotification = syncNotification;
	}

	public RocfSyncNotifyInvocation getSyncNotification() {
		return syncNotification;
	}

	public int encode(OutputStream reverseOS) throws IOException {

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

		int codeLength = 0;
		if (syncNotification != null) {
			codeLength += syncNotification.encode(reverseOS, false);
			// write tag: CONTEXT_CLASS, CONSTRUCTED, 1
			reverseOS.write(0xA1);
			codeLength += 1;
			return codeLength;
		}
		
		if (annotatedOcf != null) {
			codeLength += annotatedOcf.encode(reverseOS, false);
			// write tag: CONTEXT_CLASS, CONSTRUCTED, 0
			reverseOS.write(0xA0);
			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, 0)) {
			annotatedOcf = new RocfTransferDataInvocation();
			codeLength += annotatedOcf.decode(is, false);
			return codeLength;
		}

		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
			syncNotification = new RocfSyncNotifyInvocation();
			codeLength += syncNotification.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 {
		ReverseByteArrayOutputStream reverseOS = new ReverseByteArrayOutputStream(encodingSizeGuess);
		encode(reverseOS);
		code = reverseOS.getArray();
	}

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

	public void appendAsString(StringBuilder sb, int indentLevel) {

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

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

		sb.append("");
	}

}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy