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

org.yamcs.algo.RemainingBinaryDecoder Maven / Gradle / Ivy

There is a newer version: 5.10.9
Show newest version
package org.yamcs.algo;

import org.yamcs.algorithms.AlgorithmExecutionContext;
import org.yamcs.mdb.AbstractDataDecoder;
import org.yamcs.mdb.ContainerProcessingContext;
import org.yamcs.parameter.Value;
import org.yamcs.utils.BitBuffer;
import org.yamcs.utils.ValueUtility;
import org.yamcs.xtce.CustomAlgorithm;
import org.yamcs.xtce.DataEncoding;

/**
 * A decoder that returns a binary value containing all of the remaining bytes.
 * 

* An example where this may be useful is a packet that contains an arbitrarily sized blob of data with no length * indication. *

* The following XTCE snippet illustrates intended usage. * *

 * <BinaryParameterType name="outputData">
 *   <BinaryDataEncoding>
 *     <SizeInBits>
 *       <DynamicValue>
 *         <ParameterInstanceRef parameterRef="_yamcs_ignore"/>
 *       </DynamicValue>
 *     </SizeInBits>
 *     <FromBinaryTransformAlgorithm name="org_yamcs_algo_RemainingBinaryDecoder">
 *       <AlgorithmText language="java">org.yamcs.algo.RemainingBinaryDecoder</AlgorithmText>
 *     </FromBinaryTransformAlgorithm>
 *   </BinaryDataEncoding>
 * </BinaryParameterType>
 * 
*/ public class RemainingBinaryDecoder extends AbstractDataDecoder { public RemainingBinaryDecoder(CustomAlgorithm alg, AlgorithmExecutionContext ctx) { // Constructor required } @Override public Value extractRaw(DataEncoding de, ContainerProcessingContext pcontext, BitBuffer buffer) { var b = new byte[buffer.remainingBytes()]; buffer.getByteArray(b); return ValueUtility.getBinaryValue(b); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy