ait.core.server.plugins.apid_routing module

Implements a plugin which routes CCSDS packets by APID

class ait.core.server.plugins.apid_routing.APIDRouter(inputs=None, outputs=None, zmq_args=None, routing_table=None, default_topic=None)

Bases: ait.core.server.plugin.Plugin

Routes CCSDS packets by APID according to a routing table defined by a yaml file. Arguments to the range operator are inclusive. (i.e. range[40,50] adds APIDs 40-50 inclusive to the topic, not 40-49) The exclude operator must come after the range operator.

example in config.yaml:

  • plugin:

    name: ait.core.server.plugins.apid_routing.APIDRouter inputs:

    • AOS_to_CCSDS

    default_topic: default_ccsds_tlm_topic routing_table:

    path: packet_routing_table.yaml

example routing table .yaml file:

output_topics:
  • telem_topic_1:
    • 1
    • 2
  • telem_stream_1:
    • 3
    • 4
    • range:
      • 40
      • 50
    • exclude:
      • 43
  • telem_topic_2:
    • 5
    • range:
      • 12
      • 19
    • exclude:
      • 14
      • 18
  • GUI_input_stream:
    • range:
      • 1
      • 100
    • exclude:
      • 87
  • DataArchive:
    • range:
      • 1
      • 138
__init__(inputs=None, outputs=None, zmq_args=None, routing_table=None, default_topic=None)

Constructor

Params:

inputs: names of inbound streams plugin receives data from outputs: names of outbound streams plugin sends its data to zmq_args: dict containing the follow keys:

zmq_context zmq_proxy_xsub_url zmq_proxy_xpub_url

Defaults to empty dict. Default values assigned during instantiation of parent class.

**kwargs: (optional) Dependent on requirements of child class.

add_range_to_table(routing_table, range_array, topic_name)

Adds a range of APIDs to the routing table. The range_array argument is an array of form [beginning, end]. This function is inclusive of all values. I.e. if range_array is [5, 9], APIDs 5-9 inclusive will be added (not 5-8).

Parameters:
  • routing_table (dict) – routing table to be updated
  • range_array (list) – list containing beginning and end values for entries to update
  • topic_name (string) – topic name to add to entries in routing table
Returns:

updated routing table

Return type:

dict

add_topic_to_table(routing_table, apid, topic_name)

Returns an updated table with the topic_name added to the entry for the specified APID

Parameters:
  • routing_table (dict) – routing table to be updated
  • apid (int) – entry in routing table
  • topic_name (string) – topic name to add to entry in routing table
Returns:

updated routing table

Return type:

dict

get_packet_apid(packet)

Returns the APID (as integer) for a given packet (bytearray) Assumes that the APID is the last 11 bits of the first two bytes

Parameters:packet (bytes, bytearray) – CCSDS packet as bytes
Returns:packet APID
Return type:int
load_table_yaml(routing_table_path, tlm_dict)

Reads a .yaml file and returns a dictionary of format {apid1: [streams], apid2: [streams]}

Parameters:
  • routing_table_path (string) – path to yaml file containing routing table
  • tlm_dict – AIT telemetry dictionary
Returns:

routing table

Return type:

dict

process(input_data)

publishes incoming CCSDS packets to the routes specified in the routing table

Parameters:input_data (bytes, bytearray) – CCSDS packet as bytes
remove_from_table(routing_table, apid_array, topic_name)

Removes a topic name from all the APIDs in the apid_array argument.

Parameters:
  • routing_table (dict) – routing table to be updated
  • apid_array (list) – list containing entries to update
  • topic_name (string) – topic name to remove from entries in routing table
Returns:

updated routing table

Return type:

dict