eive-tmtc/pus_tm/system/tcs.py

95 lines
3.9 KiB
Python
Raw Normal View History

2022-06-01 11:59:45 +02:00
import enum
2022-05-19 13:20:22 +02:00
import struct
from pus_tm.defs import PrintWrapper
2022-06-01 10:47:57 +02:00
from pus_tm.tcp_server_objects import *
2022-05-19 13:20:22 +02:00
from tmtccmd.utility import ObjectId
from tmtccmd.utility.tmtc_printer import FsfwTmTcPrinter
2022-06-01 11:59:45 +02:00
class SetIds(enum.IntEnum):
SENSOR_TEMPERATURE_SET = 0
DEVICE_TEMPERATURE_SET = 1
SUS_TEMPERATURE_SET = 2
2022-05-19 13:20:22 +02:00
def handle_thermal_controller_hk_data(
object_id: ObjectId, printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes
):
2022-06-01 11:59:45 +02:00
if set_id is SetIds.SENSOR_TEMPERATURE_SET:
2022-05-19 13:20:22 +02:00
pw = PrintWrapper(printer)
2022-06-01 10:47:57 +02:00
pw.dlog("Received sensor temperature data")
2022-05-19 13:20:22 +02:00
# get all the floats
2022-06-01 10:47:57 +02:00
tm_data = struct.unpack("!ffffffffffffffffff", hk_data[:18 * 4])
2022-05-31 11:44:08 +02:00
parsed_data = {"SENSOR_PLOC_HEATSPREADER": tm_data[0], "SENSOR_PLOC_MISSIONBOARD": tm_data[1],
"SENSOR_4K_CAMERA": tm_data[2], "SENSOR_DAC_HEATSPREADER": tm_data[3],
"SENSOR_STARTRACKER": tm_data[4], "SENSOR_RW1": tm_data[5], "SENSOR_DRO": tm_data[6],
"SENSOR_SCEX": tm_data[7], "SENSOR_X8": tm_data[8], "SENSOR_HPA": tm_data[9],
"SENSOR_TX_MODUL": tm_data[10], "SENSOR_MPA": tm_data[11], "SENSOR_ACU": tm_data[12],
"SENSOR_PLPCDU_HEATSPREADER": tm_data[13], "SENSOR_TCS_BOARD": tm_data[14],
"SENSOR_MAGNETTORQUER": tm_data[15], "TMP1075 1": tm_data[16], "TMP1075 2": tm_data[17]}
print(parsed_data)
2022-06-01 10:47:57 +02:00
tcp_server_sensor_temperatures.report_parsed_hk_data(object_id, set_id, parsed_data)
2022-06-01 11:59:45 +02:00
elif set_id is SetIds.DEVICE_TEMPERATURE_SET:
2022-06-01 10:47:57 +02:00
pw = PrintWrapper(printer)
pw.dlog("Received device temperature data")
fmt_str = "!fffffiiiiffffhhhhhhhfffffff"
tm_data = struct.unpack(fmt_str, hk_data[:90])
parsed_data = {
"Q7S_TEMPERATURE": tm_data[0],
"BATTERY_TEMPERATURE_1": tm_data[1],
"BATTERY_TEMPERATURE_2": tm_data[2],
"BATTERY_TEMPERATURE_3": tm_data[3],
"BATTERY_TEMPERATURE_4": tm_data[4],
"RW_1_TEMPERATURE": tm_data[5],
"RW_2_TEMPERATURE": tm_data[6],
"RW_3_TEMPERATURE": tm_data[7],
"RW_4_TEMPERATURE": tm_data[8],
"STARTRACKER_TEMPERATURE": tm_data[9],
"SYRLINKS_POWER_AMPLIFIER_TEMPERATURE": tm_data[10],
"SYRLINKS_BASEBAND_BOARD_TEMPERATURE": tm_data[11],
"MGT_TEMPERATURE": tm_data[12],
"ACU_TEMPERATURE_1": tm_data[13],
"ACU_TEMPERATURE_2": tm_data[14],
"ACU_TEMPERATURE_3": tm_data[15],
"PDU1_TEMPERATURE": tm_data[16],
"PDU2_TEMPERATURE": tm_data[17],
"P60DOCK_TEMPERATURE_1": tm_data[18],
"P60DOCK_TEMPERATURE_2": tm_data[19],
"GYRO_0_TEMPERATURE": tm_data[20],
"GYRO_1_TEMPERATURE": tm_data[21],
"GYRO_2_TEMPERATURE": tm_data[22],
"GYRO_3_TEMPERATURE": tm_data[23],
"MGM_0_TEMPERATURE": tm_data[24],
"MGM_1_TEMPERATURE": tm_data[25],
"ADC_PL_PCDU_TEMPERATURE": tm_data[26],
}
2022-06-01 11:59:45 +02:00
print(parsed_data)
2022-06-01 10:47:57 +02:00
tcp_server_device_temperatures.report_parsed_hk_data(object_id, set_id, parsed_data)
2022-06-01 11:59:45 +02:00
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