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 Summary
Fields Modifier and Type Field Description static intMS_IN_DAYstatic intSEC_IN_DAY
-
Constructor Summary
Constructors Constructor Description CcsdsTime(int numDays, long picosecInDay)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(CcsdsTime o)static CcsdsTimefromCcsds(byte[] ds)P-field is implicit (not present, defaulted to 41 hex)static CcsdsTimefromCcsdsPico(byte[] ds)P-field is implicit (not present, defaulted to 42 hex)static CcsdsTimefromJavaMillisec(long javaTime)Converts a java time in millisecondsstatic CcsdsTimefromSle(ConditionalTime time)static CcsdsTimefromSle(Time time)Gets the time from the SLE time classstatic CcsdsTimefromUnix(long unixSeconds, int nanosec)Converts a UNIX time in seconds since 1970, nanoseconds in second (such as returned by gettitmeofday)byte[]getDaySegmented()P-field is implicit (not present, defaulted to 41 hex)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)intgetNumDays()longgetPicosecInDay()static CcsdsTimenow()Gets the current timelongtoJavaMillisec()Converts to java milliseconds.TimetoSle(int sleVersion)static TimetoSle(CcsdsTime time, int sleVersion)static ConditionalTimetoSleConditional(CcsdsTime time, int sleVersion)StringtoString()Formats the time with up to nanosecond resolutionStringtoStringPico()Converts to ISO8860 string with 12 digits picoseconds after dot
-
-
-
Field Detail
-
SEC_IN_DAY
public static final int SEC_IN_DAY
- See Also:
- Constant Field Values
-
MS_IN_DAY
public static final int MS_IN_DAY
- See Also:
- Constant Field Values
-
-
Method Detail
-
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)
-
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:
compareToin interfaceComparable<CcsdsTime>
-
toString
public String toString()
Formats the time with up to nanosecond resolution
-
toStringPico
public String toStringPico()
Converts to ISO8860 string with 12 digits picoseconds after dot- Returns:
-
-