java.lang.Object
org.yamcs.tctm.ccsds.time.CucTimeDecoder
- All Implemented Interfaces:
TimeDecoder
Decoder for CCSDS Unsegmented time Code as specified in
TIME CODE FORMATS, CCSDS 301.0-B-4, Nov 2010
The time code is composed by
- P-Field (preamble field) 8 or 16 bits optional
- T-Field - up to 7+10 bytes (although it could be longer for custom codes)
-
Constructor Summary
ConstructorsConstructorDescriptionCucTimeDecoder(int pfield1) CucTimeDecoder(int pfield1, int pfield2) Constructor for decoder. -
Method Summary
Modifier and TypeMethodDescriptionlongdecode(byte[] buf, int offset) Decodes the time from the binary buffer and returns the time in milliseconds.longAssuming that the basic time unit is second, return the number of milliseconds.longdecodeRaw(byte[] buf, int offset) Returns the time in an unspecified unit.longDecodes the time in the highest available resolution.toString()
-
Constructor Details
-
CucTimeDecoder
public CucTimeDecoder(int pfield1) -
CucTimeDecoder
public CucTimeDecoder(int pfield1, int pfield2) Constructor for decoder.- Parameters:
pfield1- first octet of the pfield -1 means is part of the packet, other values means it is pre-defined (implicit)pfield2- second octet of the pfield - used if the first bit of pfield1 (seen as one byte) is 1
-
-
Method Details
-
decode
public long decode(byte[] buf, int offset) Description copied from interface:TimeDecoderDecodes the time from the binary buffer and returns the time in milliseconds. The value returned can be either absolute or relative (this has to be known by the caller)It is assumed that the buffer will contain enough data; if not, an
ArrayIndexOutOfBoundsExceptionwill be thrown.- Specified by:
decodein interfaceTimeDecoder- Parameters:
buf- - where to read the data fromoffset- - offset in the buffer where the decoding will begin- Returns:
- decoded time in milliseconds
-
decodeRaw
public long decodeRaw(byte[] buf, int offset) Returns the time in an unspecified unit.Can be used when the on-board time is free running.
It is assumed that the buffer will contain enough data; if not, an
ArrayIndexOutOfBoundsExceptionwill be thrown.- Specified by:
decodeRawin interfaceTimeDecoder- Parameters:
buf- the time will be read from this buffer at the given offset.offset- offset in the buffer where to read the time from- Returns:
- time
-
decode
Assuming that the basic time unit is second, return the number of milliseconds. -
decodeRaw
Decodes the time in the highest available resolution.If the length of the basicTime and fractional time is greater than 8, an exception is thrown.
-
toString
-