Package org.yamcs.sle

Class CcsdsTime

java.lang.Object
org.yamcs.sle.CcsdsTime
All Implemented Interfaces:
Comparable<CcsdsTime>

public class CcsdsTime extends Object implements Comparable<CcsdsTime>
CCSDS time storing the number of days since 1958 and the number of picoseconds in the day
  • Field Details

  • Constructor Details

    • CcsdsTime

      public CcsdsTime(int numDays, long picosecInDay)
  • Method Details

    • fromCcsds

      public static CcsdsTime fromCcsds(byte[] ds)
      P-field is implicit (not present, defaulted to 41 hex)

      T-field:

      • 2 octets: number of days since 1958/01/01 00:00:00
      • 4 octets: number of milliseconds of the day
      • 2 octets: number of microseconds of the millisecond (set to 0 if not used)
      Parameters:
      ds -
      Returns:
    • fromCcsdsPico

      public static CcsdsTime fromCcsdsPico(byte[] ds)
      P-field is implicit (not present, defaulted to 42 hex)

      T-field:

      • 2 octets: number of days since 1958/01/01 00:00:00
      • 4 octets: number of milliseconds of the day
      • 4 octets: number of picoseconds of the millisecond (set to 0 if not used)
      Parameters:
      ds -
      Returns:
    • now

      public static CcsdsTime now()
      Gets the current time
      Returns:
      the current time
    • fromJavaMillisec

      public static CcsdsTime fromJavaMillisec(long javaTime)
      Converts a java time in milliseconds
      Parameters:
      javaTime -
      Returns:
    • fromUnix

      public static CcsdsTime fromUnix(long unixSeconds, int nanosec)
      Converts a UNIX time in seconds since 1970, nanoseconds in second (such as returned by gettitmeofday)
      Parameters:
      unixSeconds - seconds since 1-Jan-1970 00:00:00 (without leap seconds)
      nanosec - nanoseconds in second
      Returns:
    • getDaySegmented

      public byte[] getDaySegmented()
      P-field is implicit (not present, defaulted to 41 hex)

      T-field:

      • 2 octets: number of days since 1958/01/01 00:00:00
      • 4 octets: number of milliseconds of the day
      • 2 octets: number of microseconds of the millisecond (set to 0 if not used)
    • getDaySegmentedPico

      public byte[] getDaySegmentedPico()

      T-field:

      • 2 octets: number of days since 1958/01/01 00:00:00
      • 4 octets: number of milliseconds of the day
      • 4 octets: number of picoseconds of the millisecond (set to 0 if not used)
    • getPicosecInDay

      public long getPicosecInDay()
    • getNumDays

      public int getNumDays()
    • toSle

      public Time toSle(int sleVersion)
    • fromSle

      public static CcsdsTime fromSle(Time time)
      Gets the time from the SLE time class
      Parameters:
      time -
      Returns:
    • fromSle

      public static CcsdsTime fromSle(ConditionalTime time)
    • toSle

      public static Time toSle(CcsdsTime time, int sleVersion)
    • toSleConditional

      public static ConditionalTime toSleConditional(CcsdsTime time, int sleVersion)
    • toJavaMillisec

      public long toJavaMillisec()
      Converts to java milliseconds. Note: this loses precision.
      Returns:
      the java milliseconds since 1970.
    • compareTo

      public int compareTo(CcsdsTime o)
      Specified by:
      compareTo in interface Comparable<CcsdsTime>
    • toString

      public String toString()
      Formats the time with up to nanosecond resolution
      Overrides:
      toString in class Object
    • toStringPico

      public String toStringPico()
      Converts to ISO8860 string with 12 digits picoseconds after dot
      Returns: