improve TCS HK handling

This commit is contained in:
Robin Müller 2023-02-21 02:28:32 +01:00
parent d1f96cb83d
commit 5f082cd9fc
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
4 changed files with 50 additions and 5 deletions

View File

@ -5,3 +5,4 @@ class CtrlSetId(enum.IntEnum):
PRIMARY_SENSORS = 0
DEVICE_SENSORS = 1
SUS_TEMP_SENSORS = 2
HEATER_INFO = 4

View File

@ -32,6 +32,18 @@ class Heater(enum.IntEnum):
NUMBER_OF_SWITCHES = 8
HEATER_LOCATION = [
"OBC Board",
"PLOC Processing Board",
"ACS Board",
"PCDU PDU",
"Camera",
"Startracker",
"DRO",
"HPA",
]
class OpCode:
HEATER_CMD = ["switch_cmd"]
HEATER_EXT_CTRL = ["set_ext_ctrl"]

View File

@ -10,7 +10,11 @@ from tmtccmd.config.tmtc import (
)
from tmtccmd.tc import DefaultPusQueueHelper
from tmtccmd.tc.pus_200_fsfw_mode import Mode, create_announce_mode_recursive_command
from tmtccmd.tc.pus_3_fsfw_hk import make_sid, generate_one_hk_command
from tmtccmd.tc.pus_3_fsfw_hk import (
make_sid,
generate_one_hk_command,
create_request_one_diag_command,
)
class OpCodeSys:
@ -19,6 +23,7 @@ class OpCodeSys:
REQUEST_PRIMARY_TEMP_SET = ["temp"]
REQUEST_DEVICE_TEMP_SET = ["temp_devs"]
REQUEST_DEVICE_SUS_SET = ["temp_sus"]
REQUEST_HEATER_INFO = "heater_info"
ANNOUNCE_MODES = "announce_modes"
@ -28,6 +33,7 @@ class InfoSys:
REQUEST_PRIMARY_TEMP_SET = "Request HK set of primary sensor temperatures"
REQUEST_DEVICE_TEMP_SET = "Request HK set of device sensor temperatures"
REQUEST_DEVICE_SUS_SET = "Request HK set of the SUS temperatures"
REQUEST_HEATER_INFO = "Request heater information"
ANNOUNCE_MODES = "Announce Modes recursively"
@ -48,6 +54,13 @@ def pack_tcs_sys_commands(q: DefaultPusQueueHelper, op_code: str):
make_sid(TCS_CONTROLLER, CtrlSetId.SUS_TEMP_SENSORS)
)
)
if op_code == OpCodeSys.REQUEST_HEATER_INFO:
q.add_log_cmd(InfoSys.REQUEST_HEATER_INFO)
q.add_pus_tc(
create_request_one_diag_command(
make_sid(TCS_CONTROLLER, CtrlSetId.HEATER_INFO)
)
)
if op_code in OpCodeSys.OFF:
q.add_log_cmd(InfoSys.OFF)
pack_mode_cmd_with_info(TCS_SUBSYSTEM_ID, Mode.OFF, 0, q, InfoSys.OFF)
@ -72,6 +85,7 @@ def add_tcs_subsystem_cmds(defs: TmtcDefinitionWrapper):
keys=OpCodeSys.REQUEST_DEVICE_TEMP_SET, info=InfoSys.REQUEST_DEVICE_TEMP_SET
)
oce.add(keys=OpCodeSys.REQUEST_DEVICE_SUS_SET, info=InfoSys.REQUEST_DEVICE_SUS_SET)
oce.add(keys=OpCodeSys.REQUEST_HEATER_INFO, info=InfoSys.REQUEST_HEATER_INFO)
oce.add(keys=OpCodeSys.ANNOUNCE_MODES, info=InfoSys.ANNOUNCE_MODES)
defs.add_service(
name=CustomServiceList.TCS,

View File

@ -1,10 +1,16 @@
import logging
import pprint
import struct
from eive_tmtc.pus_tm.defs import PrintWrapper
from tmtccmd.fsfw import validity_buffer_list
from tmtccmd.util import ObjectIdU32
from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
from .defs import CtrlSetId
from .heater import HEATER_LOCATION
_LOGGER = logging.getLogger(__name__)
def handle_thermal_controller_hk_data(
@ -22,7 +28,10 @@ def handle_thermal_controller_hk_data(
pw.dlog("Received sensor temperature data")
# get all the floats
tm_data = struct.unpack("!fffffffffffffffffffff", hk_data[: 21 * 4])
fmt_str = "!fffffffffffffffffffff"
fmt_len = struct.calcsize(fmt_str)
tm_data = struct.unpack(fmt_str, hk_data[:fmt_len])
valid_list = validity_buffer_list(hk_data[fmt_len:], 21)
parsed_data = {
"SENSOR_PLOC_HEATSPREADER": tm_data[0],
"SENSOR_PLOC_MISSIONBOARD": tm_data[1],
@ -46,9 +55,8 @@ def handle_thermal_controller_hk_data(
"TMP1075 PL PCDU 1": tm_data[19],
"TMP1075 IF BOARD": tm_data[20],
}
printer.file_logger.info(str(parsed_data))
pp = pprint.PrettyPrinter(depth=4)
pp.pprint(parsed_data)
for idx, (k, v) in enumerate(parsed_data.items()):
print(f"{str(k).ljust(30)}: Valid: {valid_list[idx]}, Value: {v}")
elif set_id == CtrlSetId.DEVICE_SENSORS:
pw = PrintWrapper(printer)
pw.dlog("Received device temperature data")
@ -108,3 +116,13 @@ def handle_thermal_controller_hk_data(
printer.file_logger.info(str(parsed_data))
pp = pprint.PrettyPrinter(depth=4)
pp.pprint(parsed_data)
elif set_id == CtrlSetId.HEATER_INFO:
print("Heater Switch States")
for i in range(8):
print(
f"{HEATER_LOCATION[i].ljust(25)}: {'On' if hk_data[i] == 1 else 'Off'}"
)
current_draw = struct.unpack("!H", hk_data[8:10])[0]
print(f"Heater Power Channel Current Draw: {current_draw} mA")
else:
_LOGGER.warning(f"Unimplemented set ID {set_id}")