diff --git a/pus_tm/system/tcs.py b/pus_tm/system/tcs.py index 1420c72..4b552e0 100644 --- a/pus_tm/system/tcs.py +++ b/pus_tm/system/tcs.py @@ -1,3 +1,4 @@ +import enum import struct from pus_tm.defs import PrintWrapper @@ -6,10 +7,16 @@ from tmtccmd.utility import ObjectId from tmtccmd.utility.tmtc_printer import FsfwTmTcPrinter +class SetIds(enum.IntEnum): + SENSOR_TEMPERATURE_SET = 0 + DEVICE_TEMPERATURE_SET = 1 + SUS_TEMPERATURE_SET = 2 + + def handle_thermal_controller_hk_data( object_id: ObjectId, printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes ): - if set_id == 0: + if set_id is SetIds.SENSOR_TEMPERATURE_SET: pw = PrintWrapper(printer) pw.dlog("Received sensor temperature data") @@ -25,7 +32,7 @@ def handle_thermal_controller_hk_data( print(parsed_data) tcp_server_sensor_temperatures.report_parsed_hk_data(object_id, set_id, parsed_data) - elif set_id == 1: + elif set_id is SetIds.DEVICE_TEMPERATURE_SET: pw = PrintWrapper(printer) pw.dlog("Received device temperature data") @@ -60,4 +67,28 @@ def handle_thermal_controller_hk_data( "MGM_1_TEMPERATURE": tm_data[25], "ADC_PL_PCDU_TEMPERATURE": tm_data[26], } + print(parsed_data) tcp_server_device_temperatures.report_parsed_hk_data(object_id, set_id, parsed_data) + elif set_id is SetIds.SUS_TEMPERATURE_SET: + pw = PrintWrapper(printer) + pw.dlog("Received SUS temperature data") + fmt_str = "!ffffffffffffffffff" + tm_data = struct.unpack(fmt_str, hk_data[:4 * 18]) + parsed_data = { + "SUS_0": tm_data[0], + "SUS_1": tm_data[1], + "SUS_2": tm_data[2], + "SUS_3": tm_data[3], + "SUS_4": tm_data[4], + "SUS_5": tm_data[5], + "SUS_6": tm_data[6], + "SUS_7": tm_data[7], + "SUS_8": tm_data[8], + "SUS_9": tm_data[9], + "SUS_10": tm_data[10], + "SUS_11": tm_data[11], + } + print(parsed_data) + # TODO: Forward data to space simulator + +