Class CucTimeDecoder

java.lang.Object
org.yamcs.tctm.ccsds.time.CucTimeDecoder
All Implemented Interfaces:
TimeDecoder

public class CucTimeDecoder extends Object implements 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 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: TimeDecoder
      Decodes 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 ArrayIndexOutOfBoundsException will be thrown.

      Specified by:
      decode in interface TimeDecoder
      Parameters:
      buf - - where to read the data from
      offset - - 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 ArrayIndexOutOfBoundsException will be thrown.

      Specified by:
      decodeRaw in interface TimeDecoder
      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

      public long decode(ByteSupplier s)
      Assuming that the basic time unit is second, return the number of milliseconds.
    • decodeRaw

      public long decodeRaw(ByteSupplier s)
      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

      public String toString()
      Overrides:
      toString in class Object