space_packet_parser.parameters
ParameterType definitions
Classes
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> |
Module Contents
- class space_packet_parser.parameters.ParameterType(name: str, encoding: space_packet_parser.encodings.DataEncoding, unit: str | None = None)
Bases:
space_packet_parser.comparisons.AttrComparableAbstract base class for XTCE parameter types
- name
- encoding
- unit
- __repr__()
- classmethod from_parameter_type_xml_element(element: lxml.etree.Element, ns: dict) ParameterType
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: lxml.etree.Element, ns: dict) str | 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
- Returns:
Unit string or None if no units are defined
- Return type:
Union[str, None]
- static get_data_encoding(parameter_type_element: lxml.etree.Element, ns: dict) space_packet_parser.encodings.DataEncoding | 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
- Returns:
DataEncoding object or None if no data encoding is defined (which is probably an issue)
- Return type:
Union[DataEncoding, None]
- parse_value(packet: space_packet_parser.packets.CCSDSPacket, **kwargs) space_packet_parser.packets.ParameterDataTypes
Using the parameter type definition and associated data encoding, parse a value from a bit stream starting at the current cursor position.
- Parameters:
packet (CCSDSPacket) – Binary representation of the packet used to get the coming bits and any previously parsed data items to infer field lengths.
- Returns:
parsed_value – Resulting parsed parameter value
- Return type:
packets.ParameterDataTypes
- class space_packet_parser.parameters.StringParameterType(name: str, encoding: space_packet_parser.encodings.StringDataEncoding, unit: str | None = None)
Bases:
ParameterType<xtce:StringParameterType>
- encoding
- class space_packet_parser.parameters.IntegerParameterType(name: str, encoding: space_packet_parser.encodings.DataEncoding, unit: str | None = None)
Bases:
ParameterType<xtce:IntegerParameterType>
- class space_packet_parser.parameters.FloatParameterType(name: str, encoding: space_packet_parser.encodings.DataEncoding, unit: str | None = None)
Bases:
ParameterType<xtce:FloatParameterType>
- class space_packet_parser.parameters.EnumeratedParameterType(name: str, encoding: space_packet_parser.encodings.DataEncoding, enumeration: dict, unit: str | None = None)
Bases:
ParameterType<xtce:EnumeratedParameterType>
- enumeration
- __repr__()
- classmethod from_parameter_type_xml_element(element: lxml.etree.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: lxml.etree.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: space_packet_parser.packets.CCSDSPacket, **kwargs) space_packet_parser.packets.StrParameter
Using the parameter type definition and associated data encoding, parse a value from a bit stream starting at the current cursor position.
- Parameters:
packet (CCSDSPacket) – Binary representation of the packet used to get the coming bits and any previously parsed data items to infer field lengths.
- Returns:
derived_value – Resulting enum label associated with the (usually integer-)encoded data value.
- Return type:
- class space_packet_parser.parameters.BinaryParameterType(name: str, encoding: space_packet_parser.encodings.BinaryDataEncoding, unit: str | None = None)
Bases:
ParameterType<xtce:BinaryParameterType>
- encoding
- class space_packet_parser.parameters.BooleanParameterType(name: str, encoding: space_packet_parser.encodings.DataEncoding, unit: str | None = None)
Bases:
ParameterType<xtce:BooleanParameterType>
- parse_value(packet: space_packet_parser.packets.CCSDSPacket, **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 (CCSDSPacket) – Binary representation of the packet used to get the coming bits and any previously parsed data items to infer field lengths.
- Returns:
derived_value – Resulting boolean representation of the encoded raw value
- Return type:
- class space_packet_parser.parameters.TimeParameterType(name: str, encoding: space_packet_parser.encodings.DataEncoding, *, unit: str | None = None, epoch: str | None = None, offset_from: str | None = None)
Bases:
ParameterTypeAbstract class for time parameter types
- epoch
- offset_from
- classmethod from_parameter_type_xml_element(element: lxml.etree.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: lxml.etree.Element, ns: dict) str | 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
- Returns:
Unit string or None if no units are defined
- Return type:
Union[str, None]
- static get_time_unit_linear_scaler(parameter_type_element: lxml.etree.Element, ns: dict) space_packet_parser.calibrators.PolynomialCalibrator | 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
- Returns:
The PolynomialCalibrator, or None if we couldn’t create a valid calibrator from the XML element
- Return type:
Union[PolynomialCalibrator, None]
- static get_epoch(parameter_type_element: lxml.etree.Element, ns: dict) str | 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. None if the element was not found.
- Return type:
Union[str, None]
- static get_offset_from(parameter_type_element: lxml.etree.Element, ns: dict) str | 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. None if no OffsetFrom element was found.
- Return type:
Union[str, None]
- class space_packet_parser.parameters.AbsoluteTimeParameterType(name: str, encoding: space_packet_parser.encodings.DataEncoding, *, unit: str | None = None, epoch: str | None = None, offset_from: str | None = None)
Bases:
TimeParameterType<xtce:AbsoluteTimeParameterType>
- class space_packet_parser.parameters.RelativeTimeParameterType(name: str, encoding: space_packet_parser.encodings.DataEncoding, *, unit: str | None = None, epoch: str | None = None, offset_from: str | None = None)
Bases:
TimeParameterType<xtce:RelativeTimeParameterType>
- class space_packet_parser.parameters.Parameter
Bases:
space_packet_parser.packets.Parseable<xtce:Parameter>
- Parameters:
name (str) – Parameter name. Typically something like MSN__PARAMNAME
parameter_type (ParameterType) – Parameter type object that describes how the parameter is stored.
short_description (str) – Short description of parameter as parsed from XTCE
long_description (str) – Long description of parameter as parsed from XTCE
- name: str
- parameter_type: ParameterType
- short_description: str | None = None
- long_description: str | None = None
- parse(packet: space_packet_parser.packets.CCSDSPacket, **parse_value_kwargs) None
Parse this parameter from the packet data.
Parse the parameter and add it to the packet dictionary.