space_packet_parser.csvdef
module for handling CSV-defined packet definitions
Module Contents
Classes
Object representation of a space csv definition of a CCSDS packet object |
Attributes
- space_packet_parser.csvdef.FlattenedContainer
- class space_packet_parser.csvdef.CsvPacketDefinition(csv_def_filepath: str or Path, add_checksum=False)
Object representation of a space csv definition of a CCSDS packet object
- 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.
- Return type:
dict
- read_and_format_csv_file()
Read in csv file and generate a list of RowTuples with each entry representing one row from the file. Also rename any columns to conform to the expected names if needed.
- Returns:
A list containing all the rows, in order, from the CSV definition file.
- Return type:
list of RowTuple
- fix_column_names(csv_reader)
Checks the names of some required columns and changes them to allow for uniform processing.
- Parameters:
csv_reader (csv.DictReader) – The DictReader generated from reading in the csv CCSDS definition.
- Returns:
The input DictReader with any non standard column names replaced.
- Return type:
csv.DictReader
- gen_flattened_containers()
Generates a dict of flattened containers from the csv definition.
- Returns:
A dict of FlattenedContainer namedtuples.
- Return type:
dict
- gen_flattened_container(container) FlattenedContainer
Convert the csv definition for a single container type into a FlattenedContainer containing the restrictions and entry list for this container type.
- Parameters:
container (list of RowTuple) – A list containing all the rows, in order, from the CSV definition pertaining to a single container type.
- Returns:
A namedtuple containing an entry list and restrictions. FlattenedContainer( entry_list=[Parameter, Parameter, …], restrictions={“ParameterName”: value, “OtherParamName”: value, …} )
- Return type:
FlattenedContainer
- gen_restrictions(container, pkt_apid_header_name='PKT_APID')
Determines and generates a dict of restrictions for a container type. Note: the only restriction currently supported is PKT_APID.
- Parameters:
container (dict of RowTuple) – A list containing all the rows, in order, from the CSV definition pertaining to a single container type.
pkt_apid_header_name (str) – The string used in the packet header describing the APID for the CCSDS packet.
- Returns:
A dict containing the restrictions for the container parameter
- Return type:
dict
- gen_entry_list(container: list)
Generates a list of Parameters for the given container. Each Parameter corresponds to one telemetry item for the container.
- Parameters:
container (list of RowTuple) – A list containing all the rows, in order, from the CSV definition pertaining to a single container type.
- Returns:
A list of Parameter objects with each Parameter corresponding to one telemetry item from the container input
- Return type:
list of Parameters
- static get_param_type_from_str(dtype, param_type_name, unit=None)
Determines the ParameterType to use for a given CSV data type format string.
- Parameters:
dtype (str) – A string defining the data encoding of a telemetry item. Examples: ‘U8’ - unsigned 8-bit integer ‘F16’ - 16-bit float ‘C64’ - 64 byte character array
param_type_name (str) – Name to be given to the created ParameterType
unit (str or None) – Name of the units for the created ParameterType
- Returns:
A ParameterType corresponding to the input variables
- Return type: