Class FixedSizeTimeDecoder

java.lang.Object
org.yamcs.time.FixedSizeTimeDecoder
All Implemented Interfaces:
TimeDecoder

public class FixedSizeTimeDecoder extends Object implements TimeDecoder
Decodes time on a fixed number of bytes.

Parameters are the size in bytes of the encoded time as well as a multiplier.

The multiplier is used to convert the extracted value to milliseconds in the decode(byte[], int)} method. The multiplier is not used in the decodeRaw(byte[], int) method.

  • Constructor Details

    • FixedSizeTimeDecoder

      public FixedSizeTimeDecoder(ByteOrder byteOrder, int size, double multiplier)
      Parameters:
      byteOrder - byte order of the encoded integer value
      size - how many bytes to be used to decode the time. Has to be maximum 8, otherwise a IllegalArgumentException will be thrown
      multiplier - the multiplier to convert the extracted value to milliseconds.
  • 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)
      Description copied from interface: TimeDecoder
      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 - - where to read the data from
      offset - - offset in the buffer where the decoding will begin
      Returns:
      time