added event and obj ID parsing

This commit is contained in:
Robin Mueller
2022-03-04 11:56:42 +01:00
parent 47f982e4f7
commit 2e0cd0fcf4
7 changed files with 93 additions and 43 deletions

View File

@ -3,7 +3,14 @@
@details Template configuration file. Copy this folder to the TMTC commander root and adapt
it to your needs.
"""
from typing import Dict
import csv
import copy
import os.path
from tmtccmd.pus.obj_id import ObjectId, ObjectIdDictT
DEFAULT_OBJECTS_CSV_PATH = "config/objects.csv"
__OBJECT_ID_DICT = None
# Core Object IDs
CORE_CONTROLLER_ID = bytes([0x43, 0x00, 0x00, 0x03])
@ -59,31 +66,22 @@ PLOC_MPSOC_ID = bytes([0x44, 0x33, 0x00, 0x15])
PL_PCDU_ID = bytes([0x44, 0x30, 0x00, 0x00])
def get_object_ids() -> Dict[bytes, list]:
object_id_dict = {
PUS_SERVICE_17_ID: "PUS Service 17",
TEST_DEVICE_ID: "Test Device",
P60_DOCK_HANDLER: "P60",
PDU_1_HANDLER_ID: "PCDU PDU1 Handler",
PDU_2_HANDLER_ID: "PCDU PDU2 Handler",
ACU_HANDLER_ID: "ACU Handler",
TMP_1075_1_HANDLER_ID: "TMP 1075 Handler 1",
TMP_1075_2_HANDLER_ID: "TMP 1075 Handler 2",
HEATER_ID: "Heater",
PCDU_HANDLER_ID: "PCDU",
SOLAR_ARRAY_DEPLOYMENT_ID: "Solar Array Deployment",
RW1_ID: "Reaction Wheel 1",
RW2_ID: "Reaction Wheel 2",
RW3_ID: "Reaction Wheel 3",
RW4_ID: "Reaction Wheel 4",
GPS_HANDLER_0_ID: "GPS 0",
GPS_HANDLER_1_ID: "GPS 1",
RAD_SENSOR_ID: "Radiation Sensor",
PLOC_SUPV_ID: "PLOC Supervisor",
PLOC_MPSOC_ID: "PLOC MPSoC",
CORE_CONTROLLER_ID: "Core Controller",
CCSDS_HANDLER_ID: "CCSDS Handler",
PDEC_HANDLER_ID: "PDEC Handler",
STAR_TRACKER_ID: "Star Tracker Handler",
}
return object_id_dict
class ObjectInfo:
id: int = 0
name: str = ""
def get_object_ids() -> ObjectIdDictT:
global __OBJECT_ID_DICT
if __OBJECT_ID_DICT is None and os.path.exists(DEFAULT_OBJECTS_CSV_PATH):
__OBJECT_ID_DICT = dict()
obj_id = ObjectId(object_id=0)
with open(DEFAULT_OBJECTS_CSV_PATH) as csvfile:
csv_reader = csv.reader(csvfile, delimiter=";")
for row in csv_reader:
obj_id.id = int(row[0], 16)
obj_id.name = row[1]
__OBJECT_ID_DICT.update(
{obj_id.as_bytes: copy.copy(obj_id)}
)
return __OBJECT_ID_DICT