Class XTCECcsdsCucTimeHandler
- java.lang.Object
-
- org.xtce.toolkit.XTCECcsdsCucTimeHandler
-
- All Implemented Interfaces:
XTCEAbsoluteTimeType
public class XTCECcsdsCucTimeHandler extends Object implements XTCEAbsoluteTimeType
This class implements CCSDS CUC time to support AbsoluteTimeDataType elements in an XTCE document.CCSDS CUC time format is composed of three identification fields. These are the P-FIELD, the T-FIELD, and an optional second P-FIELD providing additional information to the first. This implementation supports the capability of the first P-FIELD and the T-FIELD only. The default number of octets is 7 where 4 octets are used for the seconds and 3 octets are used for the seconds fraction. This corresponds to bits 4,5,6,7 of the P-FIELD definition. The default epoch is TAI, although any epoch can be specified.
This class is applicable to AbsoluteTimeType XTCE specifications when three conditions are met by the XML document:
- Encoding size in bits of the type element is equal to the sum of the octet sizes for the seconds and fraction seconds (default 56=7).
- Encoding is Unsigned Integer
- Epoch of the type element is equal to "TAI", "1958-01-01", or the custom epoch specified. All midnight GMT assumed.
Although the CCSDS specification carries as low as 2^-24 second counts, the basic demo Java implementation here uses the basic libraries and will only act as far as the milliseconds. A production grade version of this would need a better underlying time library.
- Author:
- dovereem
-
-
Constructor Summary
Constructors Constructor Description XTCECcsdsCucTimeHandler()Default constructor to initialize a handler with the default time format and time zone.XTCECcsdsCucTimeHandler(String timeFormat, String timeZone, String epoch, int numSecBytes, int numFracBytes)Constructor that permits changing the default time format and the time zone information.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetCalibratedFromUncalibrated(String uncalValue)Retrieve the EU calibrated value of this time item, which can be a Parameter or Argument, when given the uncalibrated value.BitSetgetRawFromUncalibrated(String uncalValue)Retrieve the raw binary bits for encoding of this time item, which can be a Parameter or Argument, when given the uncalibrated value.StringgetUncalibratedFromCalibrated(String euValue)Retrieve the uncalibrated value for this time item, which can be a Parameter or Argument, when given the EU calibrated value.StringgetUncalibratedFromRaw(BitSet rawValue)Retrieve the uncalibrated value of this time item, which can be a Parameter or Argument, when given the raw binary value.booleanisApplicable(AbsoluteTimeDataType instance)Method to determine if an XTCE AbsoluteTimeType, either Parameter or Argument, is handled by this implementation of the interface.
-
-
-
Constructor Detail
-
XTCECcsdsCucTimeHandler
public XTCECcsdsCucTimeHandler()
Default constructor to initialize a handler with the default time format and time zone.The default time output format is UTC ISO8601 text. This is in the form of YYYY-MM-dd HH:MM:ss.SSS
-
XTCECcsdsCucTimeHandler
public XTCECcsdsCucTimeHandler(String timeFormat, String timeZone, String epoch, int numSecBytes, int numFracBytes)
Constructor that permits changing the default time format and the time zone information.- Parameters:
timeFormat- String containing the time format string suitable for the Java SimpleDateFormat formatter.timeZone- String containing the time zone identifier string, suitable for the TimeZone.getTimeZone method in Java.epoch- String containing the epoch date in the form "yyyy-MM-dd" or the string "TAI".numSecBytes- integer containing the number of bytes to use for the seconds field in the CCSDS CUC T-FIELD high bytes.numFracBytes- integer containing the number of bytes to use for the fractional seconds field in the CCSDS CUC T-FIELD low bytes.
-
-
Method Detail
-
isApplicable
public boolean isApplicable(AbsoluteTimeDataType instance)
Method to determine if an XTCE AbsoluteTimeType, either Parameter or Argument, is handled by this implementation of the interface.This method returns true when three conditions are met by the XML that is represented by the JAXB AbsoluteTimeDataType object instance passed by the caller:
- Encoding size in bits of the type element is equal to the sum of the octet sizes for the seconds and fraction seconds (default 56=7).
- Encoding is Unsigned Integer
- Epoch of the type element is equal to "TAI", "1958-01-01", or the custom epoch specified. All midnight GMT assumed.
- Specified by:
isApplicablein interfaceXTCEAbsoluteTimeType- Parameters:
instance- AbsoluteTimeDataType object from the JAXB representation of the XTCE XML document.- Returns:
- boolean indicating if this handler supports/implements handling for the user provided Absolute Time Type, as specified in the XML.
-
getUncalibratedFromRaw
public String getUncalibratedFromRaw(BitSet rawValue)
Retrieve the uncalibrated value of this time item, which can be a Parameter or Argument, when given the raw binary value.This conversion uses only system time capabilities, and as a result is not leap second corrected.
- Specified by:
getUncalibratedFromRawin interfaceXTCEAbsoluteTimeType- Parameters:
rawValue- BitSet containing the raw binary value that would be encoded on the wire or bitfield. The raw binary is always expected to be in the order read from the stream.- Returns:
- String containing the integral microseconds since epoch.
-
getCalibratedFromUncalibrated
public String getCalibratedFromUncalibrated(String uncalValue)
Retrieve the EU calibrated value of this time item, which can be a Parameter or Argument, when given the uncalibrated value.The uncalibrated input string contains an integral number of microseconds since the UNIX epoch. The output string is the UTC string in the form of ISO8601 (YYYY-MM-DD HH:MM:SS.sssss). The timezone is always UTC/GMT.
- Specified by:
getCalibratedFromUncalibratedin interfaceXTCEAbsoluteTimeType- Parameters:
uncalValue- String containing the uncalibrated value that is derived from the encoded value on the wire or bitfield.- Returns:
- String containing the proper EU calibrated representation of the uncalibrated value provided by the caller.
- Throws:
NumberFormatException- in the event that the uncalibrated value cannot be converted to an integral number.
-
getRawFromUncalibrated
public BitSet getRawFromUncalibrated(String uncalValue)
Retrieve the raw binary bits for encoding of this time item, which can be a Parameter or Argument, when given the uncalibrated value.This conversion uses only system time capabilities, and as a result is not leap second corrected.
- Specified by:
getRawFromUncalibratedin interfaceXTCEAbsoluteTimeType- Parameters:
uncalValue- String containing the uncalibrated representation of the value.- Returns:
- BitSet containing the raw bits.
- Throws:
NumberFormatException- in the event that the uncalibrated value cannot be converted to an integral number.
-
getUncalibratedFromCalibrated
public String getUncalibratedFromCalibrated(String euValue)
Retrieve the uncalibrated value for this time item, which can be a Parameter or Argument, when given the EU calibrated value.The uncalibrated output string contains an integral number of microseconds since the UNIX epoch. The input string is the UTC string in the form of ISO8601 (YYYY-MM-DD HH:MM:SS.sssss).
- Specified by:
getUncalibratedFromCalibratedin interfaceXTCEAbsoluteTimeType- Parameters:
euValue- String containing a value of this item represented in EU/calibrated form.- Returns:
- String containing the uncalibrated value.
- Throws:
RuntimeException- in the event that a checked exception is caught by this function, with the parsing error text copied.
-
-