space_packet_parser.xtcedef
Module for parsing XTCE xml files to specify packet format
Module Contents
Classes
Generic class that provides a notion of equality based on all non-callable, non-dunder attributes |
|
<xtce:MatchCriteriaType> |
|
<xtce:Comparison> |
|
<xtce:Condition> |
|
<xtce:BooleanExpression> |
|
<xtce:DiscreteLookup> |
|
Abstract base class for XTCE calibrators |
|
<xtce:SplineCalibrator> |
|
<xtce:PolynomialCalibrator> |
|
<xtce:MathOperationCalibrator> |
|
<xtce:ContextCalibrator> |
|
Abstract base class for XTCE data encodings |
|
<xtce:StringDataEncoding> |
|
Abstract class that is inherited by IntegerDataEncoding and FloatDataEncoding |
|
<xtce:IntegerDataEncoding> |
|
<xtce:FloatDataEncoding> |
|
<xtce:BinaryDataEncoding> |
|
Abstract base class for XTCE parameter types |
|
<xtce:StringParameterType> |
|
<xtce:IntegerParameterType> |
|
<xtce:FloatParameterType> |
|
<xtce:EnumeratedParameterType> |
|
<xtce:BinaryParameterType> |
|
<xtce:BooleanParameterType> |
|
Abstract class for time parameter types |
|
<xtce:AbsoluteTimeParameterType> |
|
<xtce:RelativeTimeParameterType> |
|
<xtce:Parameter> |
|
<xtce:SequenceContainer> |
|
Object representation of the XTCE definition of a CCSDS packet object |
Attributes
- space_packet_parser.xtcedef.logger
- exception space_packet_parser.xtcedef.ElementNotFoundError
Bases:
Exception
Exception for missing XML element
- exception space_packet_parser.xtcedef.ComparisonError
Bases:
Exception
Exception for problems performing comparisons
- exception space_packet_parser.xtcedef.FormatStringError
Bases:
Exception
Error indicating a problem determining how to parse a variable length string.
- exception space_packet_parser.xtcedef.DynamicLengthBinaryParameterError
Bases:
Exception
Exception to raise when we try to parse a dynamic length binary field as fixed length
- exception space_packet_parser.xtcedef.CalibrationError
Bases:
Exception
For errors encountered during value calibration
- class space_packet_parser.xtcedef.AttrComparable
Generic class that provides a notion of equality based on all non-callable, non-dunder attributes
- __eq__(other)
Return self==value.
- class space_packet_parser.xtcedef.MatchCriteria
Bases:
AttrComparable
<xtce:MatchCriteriaType> This class stores criteria for performing logical operations based on parameter values Classes that inherit from this ABC include those that represent <xtce:Comparison>, <xtce:ComparisonList>, <xtce:BooleanExpression> (not supported), and <xtce:CustomAlgorithm> (not supported)
- _valid_operators
- abstract classmethod from_match_criteria_xml_element(element: xml.etree.ElementTree.Element, ns: dict)
Abstract classmethod to create a match criteria object from an XML element.
- Parameters:
element (ElementTree.Element) – XML element
ns (dict) – XML namespace dict
- Return type:
cls
- abstract evaluate(parsed_data: dict, current_parsed_value: int or float = None) bool
Evaluate match criteria down to a boolean.
- Parameters:
parsed_data (dict) – Dictionary of parsed parameter data so far. Used to evaluate truthyness of the match criteria.
current_parsed_value (any, Optional) – Uncalibrated value that is currently being matched (e.g. as a candidate for calibration). Used to resolve comparisons that reference their own raw value as a condition.
- Returns:
Truthyness of this match criteria based on parsed_data values.
- Return type:
bool
- class space_packet_parser.xtcedef.Comparison(required_value: any, referenced_parameter: str, operator: str = '==', use_calibrated_value: bool = True)
Bases:
MatchCriteria
<xtce:Comparison>
- __repr__()
Return repr(self).
- _validate()
Validate state as logically consistent.
- Return type:
None
- classmethod from_match_criteria_xml_element(element: xml.etree.ElementTree.Element, ns: dict)
Create
- Parameters:
element (ElementTree.Element) – XML element
ns (dict) – XML namespace dict
- Return type:
cls
- evaluate(parsed_data: dict, current_parsed_value: int or float = None) bool
Evaluate comparison down to a boolean. If the parameter to compare is not present in the parsed_data dict, we assume that we are comparing against the current raw value in current_parsed_value.
- Parameters:
parsed_data (dict) – Dictionary of parsed parameter data so far. Used to evaluate truthyness of the match criteria.
current_parsed_value (int or float) – Optional. Uncalibrated value that is currently a candidate for calibration and so has not yet been added to the parsed_data dict. Used to resolve calibrator conditions that reference their own raw value as a comparate.
- Returns:
Truthyness of this match criteria based on parsed_data values.
- Return type:
bool
- class space_packet_parser.xtcedef.Condition(left_param: str, operator: str, right_param: str = None, right_value=None, left_use_calibrated_value: bool = True, right_use_calibrated_value: bool = True)
Bases:
MatchCriteria
<xtce:Condition> Note: This xtce model doesn’t actually inherit from MatchCriteria in the UML model but it’s functionally close enough that we inherit the class here.
- _validate()
Check that the instantiated object actually makes logical sense.
- Return type:
None
- static _parse_parameter_instance_ref(element: xml.etree.ElementTree.Element)
Parse an xtce:ParameterInstanceRef element
- Parameters:
element (ElementTree.Element) – xtce:ParameterInstanceRef element
- Returns:
parameter_name (str) – Name of referenced parameter
use_calibrated_value (bool) – Whether to use the calibrated form of the referenced parameter
- classmethod from_match_criteria_xml_element(element: xml.etree.ElementTree.Element, ns: dict)
Classmethod to create a Condition object from an XML element.
- Parameters:
element (ElementTree.Element) – XML element
ns (dict) – XML namespace dict
- Return type:
cls
- evaluate(parsed_data: dict, current_parsed_value: int or float = None) bool
Evaluate match criteria down to a boolean.
- Parameters:
parsed_data (dict) – Dictionary of parsed parameter data so far. Used to evaluate truthyness of the match criteria.
current_parsed_value (int or float, Optional) – Current value being parsed. NOTE: This is currently ignored. See the TODO item below.
- Returns:
Truthyness of this match criteria based on parsed_data values.
- Return type:
bool
- space_packet_parser.xtcedef.Anded
- space_packet_parser.xtcedef.Ored
- class space_packet_parser.xtcedef.BooleanExpression(expression: Condition or Anded or Ored)
Bases:
MatchCriteria
<xtce:BooleanExpression>
- classmethod from_match_criteria_xml_element(element: xml.etree.ElementTree.Element, ns: dict)
Abstract classmethod to create a match criteria object from an XML element.
- Parameters:
element (ElementTree.Element) – XML element
ns (dict) – XML namespace dict
- Return type:
cls
- evaluate(parsed_data: dict, current_parsed_value: int or float = None) bool
Evaluate the criteria in the BooleanExpression down to a single boolean.
- Parameters:
parsed_data (dict) – Dictionary of parsed parameter data so far. Used to evaluate truthyness of the match criteria.
current_parsed_value (int or float, Optional) – Current value being parsed.
- Returns:
Truthyness of this match criteria based on parsed_data values.
- Return type:
bool
- class space_packet_parser.xtcedef.DiscreteLookup(match_criteria: list, lookup_value: int or float)
Bases:
AttrComparable
<xtce:DiscreteLookup>
- classmethod from_discrete_lookup_xml_element(element: xml.etree.ElementTree.Element, ns: dict)
Create a DiscreteLookup object from an <xtce:DiscreteLookup> XML element
- Parameters:
element (ElementTree.Element) – <xtce:DiscreteLookup> XML element from which to parse the DiscreteLookup object.
ns (dict) – Namespace dict for XML parsing
- Return type:
cls
- evaluate(parsed_data: dict, current_parsed_value: int or float = None)
Evaluate the lookup to determine if it is valid.
- Parameters:
parsed_data (dict) – Data parsed so far (for referencing during criteria evaluation).
current_parsed_value (int or float, Optional) – If referenced parameter in criterion isn’t in parsed_data dict, we assume we are comparing against this currently parsed value.
- Returns:
Return the lookup value if the match criteria evaluate true. Return None otherwise.
- Return type:
any
- class space_packet_parser.xtcedef.Calibrator
Bases:
AttrComparable
Abstract base class for XTCE calibrators
- classmethod from_calibrator_xml_element(element: xml.etree.ElementTree.Element, ns: dict)
Abstract classmethod to create a default_calibrator object from an XML element.
- Parameters:
element (ElementTree.Element) – XML element
ns (dict) – XML namespace dict
- Return type:
cls
- abstract calibrate(uncalibrated_value: int)
Takes an integer-encoded value and returns a calibrated version.
- Returns:
Calibrated value
- Return type:
int or float
- space_packet_parser.xtcedef.SplinePoint
- class space_packet_parser.xtcedef.SplineCalibrator(points: list, order: int = 0, extrapolate: bool = False)
Bases:
Calibrator
<xtce:SplineCalibrator>
- _order_mapping
- classmethod from_calibrator_xml_element(element: xml.etree.ElementTree.Element, ns: dict)
Create a spline default_calibrator object from an <xtce:SplineCalibrator> XML element.
- calibrate(uncalibrated_value: float)
Take an integer-encoded value and returns a calibrated version according to the spline points.
- Parameters:
uncalibrated_value (float) – Query point.
- Returns:
Calibrated value
- Return type:
float
- _zero_order_spline_interp(query_point: float)
Abstraction for zero order spline interpolation. If extrapolation is set to a truthy value, we use the nearest point to extrapolate outside the range of the given spline points. Within the range of spline points, we use nearest lower point interpolation.
- Parameters:
query_point (float) – Query point.
- Returns:
Calibrated value.
- Return type:
float
- _first_order_spline_interp(query_point: float)
Abstraction for first order spline interpolation. If extrapolation is set to a truthy value, we use the end points to make a linear function and use it to extrapolate.
- Parameters:
query_point (float) – Query point.
- Returns:
Calibrated value.
- Return type:
float
- space_packet_parser.xtcedef.PolynomialCoefficient
- class space_packet_parser.xtcedef.PolynomialCalibrator(coefficients: list)
Bases:
Calibrator
<xtce:PolynomialCalibrator>
- classmethod from_calibrator_xml_element(element: xml.etree.ElementTree.Element, ns: dict)
Create a polynomial default_calibrator object from an <xtce:PolynomialCalibrator> XML element.
- Parameters:
element (ElementTree.Element) – <xtce:PolynomialCalibrator> XML element
ns (dict) – Namespace dict
- calibrate(uncalibrated_value: float)
Evaluate the polynomial defined by object coefficients at the specified uncalibrated point.
- Parameters:
uncalibrated_value (float) – Query point.
- Returns:
Calibrated value
- Return type:
float
- class space_packet_parser.xtcedef.MathOperationCalibrator
Bases:
Calibrator
<xtce:MathOperationCalibrator>
- err_msg = 'The MathOperationCalibrator element is not supported in this package but pull requests are welcome!'
- abstract classmethod from_calibrator_xml_element(element: xml.etree.ElementTree.Element, ns: dict)
Create a math operation default_calibrator from an <xtce:MathOperationCalibrator> XML element.
- abstract calibrate(uncalibrated_value: int)
Stub
- Parameters:
uncalibrated_value –
- class space_packet_parser.xtcedef.ContextCalibrator(match_criteria: list, calibrator: Calibrator)
Bases:
AttrComparable
<xtce:ContextCalibrator>
- static get_context_match_criteria(element: xml.etree.ElementTree.Element, ns: dict)
Parse contextual requirements from a Comparison, ComparisonList, or BooleanExpression
- Parameters:
element (ElementTree.Element) – <xtce:ContextCalibrator> XML element from which to parse the ContextCalibrator object.
ns (dict) – Namespace dict for XML parsing
- Returns:
List of Comparisons that can be evaluated to determine whether this calibrator should be used.
- Return type:
list
- classmethod from_context_calibrator_xml_element(element: xml.etree.ElementTree.Element, ns: dict)
Create a ContextCalibrator object from an <xtce:ContextCalibrator> XML element
- Parameters:
element (ElementTree.Element) – <xtce:ContextCalibrator> XML element from which to parse the ContextCalibrator object.
ns (dict) – Namespace dict for XML parsing
- Return type:
cls
- calibrate(parsed_value)
Wrapper method for the internal Calibrator.calibrate
- Parameters:
parsed_value (int or float) – Uncalibrated value.
- Returns:
Calibrated value
- Return type:
int or float
- class space_packet_parser.xtcedef.DataEncoding
Bases:
AttrComparable
Abstract base class for XTCE data encodings
- classmethod from_data_encoding_xml_element(element: xml.etree.ElementTree.Element, ns: dict)
Abstract classmethod to create a data encoding object from an XML element.
- Parameters:
element (ElementTree.Element) – XML element
ns (dict) – XML namespace dict
- Return type:
cls
- static get_default_calibrator(data_encoding_element: xml.etree.ElementTree.Element, ns: dict)
Gets the default_calibrator for the data encoding element
- Parameters:
data_encoding_element (ElementTree.Element) – The data encoding element which should contain the default_calibrator
ns (dict) – XML namespace dict
- Return type:
- static get_context_calibrators(data_encoding_element: xml.etree.ElementTree.Element, ns: dict) list or None
Get the context default_calibrator(s) for the data encoding element
- Parameters:
data_encoding_element (ElementTree.Element) – XML element
ns (dict) – XML namespace dict
- Returns:
List of ContextCalibrator objects.
- Return type:
list
- static _get_linear_adjuster(parent_element: xml.etree.ElementTree.Element, ns: dict) callable or None
Examine a parent (e.g. a <xtce:DynamicValue>) element and find a LinearAdjustment if present, creating and returning a function that evaluates the adjustment.
- Parameters:
parent_element (ElementTree.Element) – Parent element which may contain a LinearAdjustment
ns (dict) – XML namespace dict
- Returns:
adjuster – Function object that adjusts a SizeInBits value by a linear function
- Return type:
callable
- abstract _get_format_string(packet_data: bitstring.ConstBitStream, parsed_data: dict)
Infer a bitstring format string, possibly using previously parsed data. This is called by parse_value only so it’s private.
- Parameters:
parsed_data (dict) – Dictionary of previously parsed data items for use in determining the format string if necessary.
- Returns:
Format string in the bitstring format. e.g. uint:16
- Return type:
str
- abstract parse_value(packet_data: bitstring.ConstBitStream, parsed_data: dict, **kwargs)
Parse a value from packet data, possibly using previously parsed data items to inform parsing.
- Parameters:
packet_data (bitstring.ConstBitStream) – Binary data coming up next in the packet.
parsed_data (dict) – Previously parsed data items from which to infer parsing details (e.g. length of a field).
- Returns:
any – Raw value
any – Calibrated value
- class space_packet_parser.xtcedef.StringDataEncoding(encoding: str = 'utf-8', termination_character: str = None, fixed_length: int = None, leading_length_size: int = None, dynamic_length_reference: str = None, use_calibrated_value: bool = True, discrete_lookup_length: list = None, length_linear_adjuster: callable = None)
Bases:
DataEncoding
<xtce:StringDataEncoding>
- _get_format_string(packet_data: bitstring.ConstBitStream, parsed_data: dict)
Infer a bitstring format string
- Parameters:
parsed_data (dict) – Dictionary of previously parsed data items for use in determining the format string if necessary.
packet_data (bitstring.ConstBitStream) – Packet data, which can be used to determine the string length from a leading value or from a termination character.
- Returns:
str or None – Format string in the bitstring format. e.g. uint:16
int or None – Number of bits to skip after parsing the string
- parse_value(packet_data: bitstring.ConstBitStream, parsed_data: dict, **kwargs)
Parse a value from packet data, possibly using previously parsed data items to inform parsing.
- Parameters:
packet_data (bitstring.ConstBitStream) – Binary data coming up next in the packet.
parsed_data (dict, Optional) – Previously parsed data items from which to infer parsing details (e.g. length of a field).
- Returns:
any – Parsed value
any – Calibrated value
- classmethod from_data_encoding_xml_element(element: xml.etree.ElementTree.Element, ns: dict)
Create a data encoding object from an <xtce:StringDataEncoding> XML element. Strings in XTCE can be described in three ways:
Using a termination character that marks the end of the string.
Using a fixed length, which may be derived from referenced parameter either directly or via a discrete lookup table.
Using a leading size field that describes the size of the following string.
- Parameters:
element (ElementTree.Element) – XML element
ns (dict) – XML namespace dict
- Return type:
cls
- class space_packet_parser.xtcedef.NumericDataEncoding(size_in_bits: int, encoding: str, default_calibrator: Calibrator = None, context_calibrators: list = None)
Bases:
DataEncoding
Abstract class that is inherited by IntegerDataEncoding and FloatDataEncoding
- parse_value(packet_data: bitstring.ConstBitStream, parsed_data: dict, **kwargs)
Parse a value from packet data, possibly using previously parsed data items to inform parsing.
- Parameters:
packet_data (bitstring.ConstBitStream) – Binary data coming up next in the packet.
parsed_data (dict, Optional) – Previously parsed data items from which to infer parsing details (e.g. length of a field).
- Returns:
any – Parsed value
any – Calibrated value
- class space_packet_parser.xtcedef.IntegerDataEncoding(size_in_bits: int, encoding: str, default_calibrator: Calibrator = None, context_calibrators: list = None)
Bases:
NumericDataEncoding
<xtce:IntegerDataEncoding>
- _get_format_string(packet_data: bitstring.ConstBitStream, parsed_data: dict)
Infer a bitstring format string
- Returns:
Format string in the bitstring format. e.g. uint:16
- Return type:
str
- classmethod from_data_encoding_xml_element(element: xml.etree.ElementTree.Element, ns: dict)
Create a data encoding object from an <xtce:IntegerDataEncoding> XML element.
- Parameters:
element (ElementTree.Element) – XML element
ns (dict) – XML namespace dict
- Return type:
cls
- class space_packet_parser.xtcedef.FloatDataEncoding(size_in_bits: int, encoding: str = 'IEEE-754', default_calibrator: Calibrator = None, context_calibrators: list = None)
Bases:
NumericDataEncoding
<xtce:FloatDataEncoding>
- _supported_encodings = ['IEEE-754', 'MIL-1750A']
- _get_format_string(packet_data: bitstring.ConstBitStream, parsed_data: dict)
Infer a bitstring format string
- Returns:
Format string in the bitstring format. e.g. uint:16
- Return type:
str
- classmethod from_data_encoding_xml_element(element: xml.etree.ElementTree.Element, ns: dict)
Create a data encoding object from an <xtce:FloatDataEncoding> XML element.
- Parameters:
element (ElementTree.Element) – XML element
ns (dict) – XML namespace dict
- Return type:
cls
- class space_packet_parser.xtcedef.BinaryDataEncoding(fixed_size_in_bits: int = None, size_reference_parameter: str = None, use_calibrated_value: bool = True, size_discrete_lookup_list: list = None, linear_adjuster: callable = None)
Bases:
DataEncoding
<xtce:BinaryDataEncoding>
- _get_format_string(packet_data: bitstring.ConstBitStream, parsed_data: dict)
Infer a bitstring format string
- Returns:
Format string in the bitstring format. e.g. bin:1024
- Return type:
str or None
- parse_value(packet_data: bitstring.ConstBitStream, parsed_data: dict, word_size: int = None, **kwargs)
Parse a value from packet data, possibly using previously parsed data items to inform parsing.
- Parameters:
packet_data (bitstring.ConstBitStream) – Binary data coming up next in the packet.
parsed_data (dict, Optional) – Previously parsed data items from which to infer parsing details (e.g. length of a field).
word_size (int, Optional) – Word size for encoded data. This is used to ensure that the cursor ends up at the end of the last word and ready to parse the next data field.
- Returns:
any – Parsed value
any – Calibrated value
- classmethod from_data_encoding_xml_element(element: xml.etree.ElementTree.Element, ns: dict)
Create a data encoding object from an <xtce:BinaryDataEncoding> XML element.
- Parameters:
element (ElementTree.Element) – XML element
ns (dict) – XML namespace dict
- Return type:
cls
- class space_packet_parser.xtcedef.ParameterType(name: str, encoding: DataEncoding, unit: str = None)
Bases:
AttrComparable
Abstract base class for XTCE parameter types
- __repr__()
Return repr(self).
- classmethod from_parameter_type_xml_element(element: xml.etree.ElementTree.Element, ns: dict)
Create a *ParameterType from an <xtce:*ParameterType> XML element.
- Parameters:
element (ElementTree.Element) – The XML element from which to create the object.
ns (dict) – XML namespace dict
- Return type:
- static get_units(parameter_type_element: xml.etree.ElementTree.Element, ns: dict) str or None
Finds the units associated with a parameter type element and parsed them to return a unit string. We assume only one <xtce:Unit> but this could be extended to support multiple units. See section 4.3.2.2.4 of CCSDS 660.1-G-1
- Parameters:
parameter_type_element (ElementTree.Element) – The parameter type element
ns (dict) – XML namespace dictionary
- Return type:
str or None
- static get_data_encoding(parameter_type_element: xml.etree.ElementTree.Element, ns: dict) DataEncoding or None
Finds the data encoding XML element associated with a parameter type XML element and parses it, returning an object representation of the data encoding.
- Parameters:
parameter_type_element (ElementTree.Element) – The parameter type element
ns (dict) – XML namespace dictionary
- Return type:
DataEncoding or None
- parse_value(packet_data: bitstring.ConstBitStream, parsed_data: dict, **kwargs)
Using the parameter type definition and associated data encoding, parse a value from a bit stream starting at the current cursor position.
- Parameters:
packet_data (bitstring.ConstBitStream) – Binary packet data with cursor at the beginning of this parameter’s data field.
parsed_data (dict) – Previously parsed data to inform parsing.
- Returns:
parsed_value – Resulting parsed data value.
- Return type:
any
- class space_packet_parser.xtcedef.StringParameterType(name: str, encoding: StringDataEncoding, unit: str = None)
Bases:
ParameterType
<xtce:StringParameterType>
- class space_packet_parser.xtcedef.IntegerParameterType(name: str, encoding: DataEncoding, unit: str = None)
Bases:
ParameterType
<xtce:IntegerParameterType>
- class space_packet_parser.xtcedef.FloatParameterType(name: str, encoding: DataEncoding, unit: str = None)
Bases:
ParameterType
<xtce:FloatParameterType>
- class space_packet_parser.xtcedef.EnumeratedParameterType(name: str, encoding: DataEncoding, enumeration: dict, unit: str or None = None)
Bases:
ParameterType
<xtce:EnumeratedParameterType>
- __repr__()
Return repr(self).
- classmethod from_parameter_type_xml_element(element: xml.etree.ElementTree.Element, ns: dict)
Create an EnumeratedParameterType from an <xtce:EnumeratedParameterType> XML element. Overrides ParameterType.from_parameter_type_xml_element
- Parameters:
element (ElementTree.Element) – The XML element from which to create the object.
ns (dict) – XML namespace dict
- Return type:
- static get_enumeration_list_contents(element: xml.etree.ElementTree.Element, ns: dict) dict
Finds the <xtce:EnumerationList> element child of an <xtce:EnumeratedParameterType> and parses it, returning a dict. This method is confusingly named as if it might return a list. Sorry, XML and python semantics are not always compatible. It’s called an enumeration list because the XML element is called <xtce:EnumerationList> but it contains key value pairs, so it’s best represeneted as a dict.
- Parameters:
element (ElementTree.Element) – The XML element from which to search for EnumerationList tags
ns (dict) – XML namespace dict
- Return type:
dict
- parse_value(packet_data: bitstring.ConstBitStream, parsed_data: dict, **kwargs)
Using the parameter type definition and associated data encoding, parse a value from a bit stream starting at the current cursor position.
- Parameters:
packet_data (bitstring.ConstBitStream) – Binary packet data with cursor at the beginning of this parameter’s data field.
parsed_data (dict) – Previously parsed data
- Returns:
parsed_value (int) – Raw encoded value
derived_value (str) – Resulting enum label associated with the (usually integer-)encoded data value.
- class space_packet_parser.xtcedef.BinaryParameterType(name: str, encoding: BinaryDataEncoding, unit: str = None)
Bases:
ParameterType
<xtce:BinaryParameterType>
- class space_packet_parser.xtcedef.BooleanParameterType(name: str, encoding: DataEncoding, unit: str = None)
Bases:
ParameterType
<xtce:BooleanParameterType>
- parse_value(packet_data: bitstring.ConstBitStream, parsed_data: dict, **kwargs)
Using the parameter type definition and associated data encoding, parse a value from a bit stream starting at the current cursor position.
- Parameters:
packet_data (bitstring.ConstBitStream) – Binary packet data with cursor at the beginning of this parameter’s data field.
parsed_data (dict) – Previously parsed data
- Returns:
parsed_value (int) – Raw encoded value
derived_value (str) – Resulting boolean representation of the encoded raw value
- class space_packet_parser.xtcedef.TimeParameterType(name: str, encoding: DataEncoding, unit: str = None, epoch: str = None, offset_from: str = None)
Bases:
ParameterType
Abstract class for time parameter types
- classmethod from_parameter_type_xml_element(element: xml.etree.ElementTree.Element, ns: dict)
Create a *TimeParameterType from an <xtce:*TimeParameterType> XML element.
- Parameters:
element (ElementTree.Element) – The XML element from which to create the object.
ns (dict) – XML namespace dict
- Return type:
- static get_units(parameter_type_element: xml.etree.ElementTree.Element, ns: dict) str or None
Finds the units associated with a parameter type element and parsed them to return a unit string. We assume only one <xtce:Unit> but this could be extended to support multiple units. See section 4.3.2.2.4 of CCSDS 660.1-G-1
- Parameters:
parameter_type_element (ElementTree.Element) – The parameter type element
ns (dict) – XML namespace dictionary
- Return type:
str or None
- static get_time_unit_linear_scaler(parameter_type_element: xml.etree.ElementTree.Element, ns: dict) PolynomialCalibrator or None
Finds the linear calibrator associated with the Encoding element for the parameter type element. See section 4.3.2.4.8.3 of CCSDS 660.1-G-2
- Parameters:
parameter_type_element (ElementTree.Element) – The parameter type element
ns (dict) – XML namespace dictionary
- Return type:
PolynomialCalibrator or None
- static get_epoch(parameter_type_element: xml.etree.ElementTree.Element, ns: dict) str or None
Finds the epoch associated with a parameter type element and parses them to return an epoch string. See section 4.3.2.4.9 of CCSDS 660.1-G-2
- Parameters:
parameter_type_element (ElementTree.Element) – The parameter type element
ns (dict) – XML namespace dictionary
- Returns:
The epoch string, which may be a datetime string or a named epoch such as TAI.
- Return type:
str or None
- static get_offset_from(parameter_type_element: xml.etree.ElementTree.Element, ns: dict) str or None
Finds the parameter referenced in OffsetFrom in a parameter type element and returns the name of the referenced parameter (which must be of type TimeParameterType). See section 4.3.2.4.9 of CCSDS 660.1-G-1
- Parameters:
parameter_type_element (ElementTree.Element) – The parameter type element
ns (dict) – XML namespace dictionary
- Returns:
The named of the referenced parameter.
- Return type:
str or None
- class space_packet_parser.xtcedef.AbsoluteTimeParameterType(name: str, encoding: DataEncoding, unit: str = None, epoch: str = None, offset_from: str = None)
Bases:
TimeParameterType
<xtce:AbsoluteTimeParameterType>
- class space_packet_parser.xtcedef.RelativeTimeParameterType(name: str, encoding: DataEncoding, unit: str = None, epoch: str = None, offset_from: str = None)
Bases:
TimeParameterType
<xtce:RelativeTimeParameterType>
- class space_packet_parser.xtcedef.Parameter(name: str, parameter_type: ParameterType, short_description: str = None, long_description: str = None)
Bases:
AttrComparable
<xtce:Parameter>
- __repr__()
Return repr(self).
- class space_packet_parser.xtcedef.SequenceContainer(name: str, entry_list: list, short_description: str = None, long_description: str = None, base_container_name: str = None, restriction_criteria: list = None, abstract: bool = False, inheritors: list = None)
Bases:
AttrComparable
<xtce:SequenceContainer>
- __repr__()
Return repr(self).
- space_packet_parser.xtcedef.FlattenedContainer
- class space_packet_parser.xtcedef.XtcePacketDefinition(xtce_document: str or Path, ns: dict = None)
Object representation of the XTCE definition of a CCSDS packet object
- property named_containers
Property accessor that returns the dict cache of SequenceContainer objects
- property named_parameters
Property accessor that returns the dict cache of Parameter objects
- property named_parameter_types
Property accessor that returns the dict cache of ParameterType objects
- property flattened_containers
Accesses a flattened, generic representation of non-abstract packet definitions along with their aggregated inheritance restrictions.
- Returns:
A modified form of the _sequence_container_cache, flattened out to eliminate nested sequence containers and with all restriction logic aggregated together for easy comparisons. { “PacketNameA”: { FlattenedContainer( entry_list=[Parameter, Parameter, …], restrictions={“ParameterName”: value, “OtherParamName”: value, …} ) }, “PacketNameB”: { FlattenedContainer( entry_list=[Parameter, Parameter, …], restrictions={“ParameterName”: value, “OtherParamName”: value, …} ) }, … }
- Return type:
dict
- property container_set
ContainerSet> element, containing all the sequence container elements.
- Type:
Property that returns the <xtce
- property parameter_type_set
ParameterTypeSet> element, containing all parameter type elements.
- Type:
Property that returns the <xtce
- property parameter_set
ParameterSet> element, containing all parameter elements.
- Type:
Property that returns the <xtce
- _default_namespace
- _tag_to_type_template
- __getitem__(item)
- parse_sequence_container_contents(sequence_container: xml.etree.ElementTree.Element) SequenceContainer
Parses the list of parameters in a SequenceContainer element, recursively parsing nested SequenceContainers to build an entry list of parameters that flattens the nested structure to derive a sequential ordering of expected parameters for each SequenceContainer. Note that this also stores entry lists for containers that are not intended to stand alone.
- Parameters:
sequence_container (ElementTree.Element) – The SequenceContainer element to parse.
- Returns:
SequenceContainer containing an entry_list of SequenceContainers and Parameters in the order expected in a packet.
- Return type:
- static _is_abstract_container(container_element: xml.etree.ElementTree.Element) bool
Determine in a SequenceContainer element is abstract
- Parameters:
container_element (ElementTree.Element) – SequenceContainer element to examine
- Returns:
True if SequenceContainer element has the attribute abstract=true. False otherwise.
- Return type:
bool
- _find_container(name: str) xml.etree.ElementTree.Element
Finds an XTCE container <xtce:SequenceContainer> by name.
- Parameters:
name (str) – Name of the container to find
- Return type:
ElementTree.Element
- _find_parameter(name: str) xml.etree.ElementTree.Element
Finds an XTCE Parameter in the tree.
- Parameters:
name (str) – Name of the parameter to find
- Return type:
ElementTree.Element
- _find_parameter_type(name: str) xml.etree.ElementTree.Element
Finds an XTCE ParameterType in the tree.
- Parameters:
name (str) – Name of the parameter type to find
- Return type:
ElementTree.Element
- _get_container_base_container(container_element: xml.etree.ElementTree.Element) Tuple[xml.etree.ElementTree.Element, list]
Examines the container_element and returns information about its inheritance.
- Parameters:
container_element (ElementTree.Element) – The container element for which to find its base container.
- Returns:
ElementTree.Element – The base container element of the input container_element.
list – The restriction criteria for the inheritance.