diff --git a/config/definitions.py b/config/definitions.py index d6a75f9..882fd97 100644 --- a/config/definitions.py +++ b/config/definitions.py @@ -47,3 +47,4 @@ class CustomServiceList(enum.Enum): SUS_ASS = "sus-ass" TCS_ASS = "tcs-ass" TIME = "time" + CONTROLLERS = "controllers" diff --git a/config/object_ids.py b/config/object_ids.py index e678f9c..99c5b9b 100644 --- a/config/object_ids.py +++ b/config/object_ids.py @@ -27,6 +27,7 @@ ACU_HANDLER_ID = bytes([0x44, 0x25, 0x00, 0x03]) BPX_HANDLER_ID = bytes([0x44, 0x26, 0x00, 0x00]) # Thermal Object IDs +THERMAL_CONTROLLER_ID = bytes([0x43, 0x40, 0x00, 0x01]) HEATER_ID = bytes([0x44, 0x41, 0x00, 0xA4]) TMP_1075_1_HANDLER_ID = bytes([0x44, 0x42, 0x00, 0x04]) TMP_1075_2_HANDLER_ID = bytes([0x44, 0x42, 0x00, 0x05]) diff --git a/pus_tc/cmd_definitions.py b/pus_tc/cmd_definitions.py index 3db7e9d..1bec4da 100644 --- a/pus_tc/cmd_definitions.py +++ b/pus_tc/cmd_definitions.py @@ -944,6 +944,7 @@ def add_ploc_supv_cmds(cmd_dict: ServiceOpCodeDictT): def add_system_cmds(cmd_dict: ServiceOpCodeDictT): from pus_tc.system.acs import AcsOpCodes, SusOpCodes import pus_tc.system.tcs as tcs + import pus_tc.system.controllers as controllers default_opts = generate_op_code_options( enter_listener_mode=False, custom_timeout=8.0 @@ -1049,3 +1050,23 @@ def add_system_cmds(cmd_dict: ServiceOpCodeDictT): info="TCS Board Assembly", op_code_entry=op_code_dict, ) + + op_code_dict = dict() + add_op_code_entry( + op_code_dict=op_code_dict, + keys=controllers.OpCodes.THERMAL_CONTROLLER_NORMAL, + info=controllers.Info.THERMAL_CONTROLLER_NORMAL, + options=default_opts, + ) + add_op_code_entry( + op_code_dict=op_code_dict, + keys=controllers.OpCodes.THERMAL_CONTROLLER_OFF, + info=controllers.Info.THERMAL_CONTROLLER_OFF, + options=default_opts, + ) + add_service_op_code_entry( + srv_op_code_dict=cmd_dict, + name=CustomServiceList.CONTROLLERS.value, + info="Controllers", + op_code_entry=op_code_dict, + ) diff --git a/pus_tc/system/acs.py b/pus_tc/system/acs.py index ea97734..7d3eb48 100644 --- a/pus_tc/system/acs.py +++ b/pus_tc/system/acs.py @@ -3,8 +3,7 @@ from tmtccmd.tc.definitions import TcQueueT from tmtccmd.tc.pus_200_fsfw_modes import Modes from config.object_ids import ACS_BOARD_ASS_ID, SUS_BOARD_ASS_ID -from .common import command_assembly - +from .common import command_mode class AcsOpCodes: ACS_ASS_A_SIDE = ["0", "acs-a"] @@ -31,7 +30,7 @@ class DualSideSubmodes(enum.IntEnum): def pack_acs_command(tc_queue: TcQueueT, op_code: str): if op_code in AcsOpCodes.ACS_ASS_A_SIDE: - command_assembly( + command_mode( object_id=ACS_BOARD_ASS_ID, mode=Modes.NORMAL, submode=DualSideSubmodes.A_SIDE, @@ -39,7 +38,7 @@ def pack_acs_command(tc_queue: TcQueueT, op_code: str): info="Switching to ACS board assembly A side", ) if op_code in AcsOpCodes.ACS_ASS_B_SIDE: - command_assembly( + command_mode( object_id=ACS_BOARD_ASS_ID, mode=Modes.NORMAL, submode=DualSideSubmodes.B_SIDE, @@ -47,7 +46,7 @@ def pack_acs_command(tc_queue: TcQueueT, op_code: str): info="Switching to ACS board assembly B side", ) if op_code in AcsOpCodes.ACS_ASS_DUAL_MODE: - command_assembly( + command_mode( object_id=ACS_BOARD_ASS_ID, mode=Modes.NORMAL, submode=DualSideSubmodes.DUAL_SIDE, @@ -55,7 +54,7 @@ def pack_acs_command(tc_queue: TcQueueT, op_code: str): info="Switching to ACS board assembly dual mode", ) if op_code in AcsOpCodes.ACS_ASS_A_ON: - command_assembly( + command_mode( object_id=ACS_BOARD_ASS_ID, mode=Modes.ON, submode=DualSideSubmodes.A_SIDE, @@ -63,7 +62,7 @@ def pack_acs_command(tc_queue: TcQueueT, op_code: str): info="Switching ACS board assembly A side on", ) if op_code in AcsOpCodes.ACS_ASS_B_ON: - command_assembly( + command_mode( object_id=ACS_BOARD_ASS_ID, mode=Modes.ON, submode=DualSideSubmodes.B_SIDE, @@ -71,7 +70,7 @@ def pack_acs_command(tc_queue: TcQueueT, op_code: str): info="Switching ACS board assembly B side on", ) if op_code in AcsOpCodes.ACS_ASS_DUAL_ON: - command_assembly( + command_mode( object_id=ACS_BOARD_ASS_ID, mode=Modes.ON, submode=DualSideSubmodes.B_SIDE, @@ -79,7 +78,7 @@ def pack_acs_command(tc_queue: TcQueueT, op_code: str): info="Switching ACS board assembly dual side on", ) if op_code in AcsOpCodes.ACS_ASS_OFF: - command_assembly( + command_mode( object_id=ACS_BOARD_ASS_ID, mode=Modes.OFF, submode=0, @@ -90,7 +89,7 @@ def pack_acs_command(tc_queue: TcQueueT, op_code: str): def pack_sus_cmds(tc_queue: TcQueueT, op_code: str): if op_code in SusOpCodes.SUS_ASS_NOM_SIDE: - command_assembly( + command_mode( object_id=SUS_BOARD_ASS_ID, mode=Modes.NORMAL, submode=DualSideSubmodes.A_SIDE, @@ -98,7 +97,7 @@ def pack_sus_cmds(tc_queue: TcQueueT, op_code: str): info="Switching to SUS board to nominal side", ) if op_code in SusOpCodes.SUS_ASS_RED_SIDE: - command_assembly( + command_mode( object_id=SUS_BOARD_ASS_ID, mode=Modes.NORMAL, submode=DualSideSubmodes.B_SIDE, @@ -106,7 +105,7 @@ def pack_sus_cmds(tc_queue: TcQueueT, op_code: str): info="Switching to SUS board to redundant side", ) if op_code in SusOpCodes.SUS_ASS_OFF: - command_assembly( + command_mode( object_id=SUS_BOARD_ASS_ID, mode=Modes.OFF, submode=0, @@ -114,7 +113,7 @@ def pack_sus_cmds(tc_queue: TcQueueT, op_code: str): info="Switching SUS board off", ) if op_code in SusOpCodes.SUS_ASS_DUAL_MODE: - command_assembly( + command_mode( object_id=SUS_BOARD_ASS_ID, mode=Modes.NORMAL, submode=DualSideSubmodes.DUAL_SIDE, diff --git a/pus_tc/system/common.py b/pus_tc/system/common.py index 55ae7b3..c712ea3 100644 --- a/pus_tc/system/common.py +++ b/pus_tc/system/common.py @@ -3,7 +3,7 @@ from spacepackets.ecss.tc import PusTelecommand from tmtccmd.tc.pus_200_fsfw_modes import pack_mode_data, Modes, Subservices -def command_assembly( +def command_mode( object_id: bytes, mode: Modes, submode: int, tc_queue: TcQueueT, info: str ): tc_queue.appendleft((QueueCommands.PRINT, info)) diff --git a/pus_tc/system/controllers.py b/pus_tc/system/controllers.py new file mode 100644 index 0000000..183d1ec --- /dev/null +++ b/pus_tc/system/controllers.py @@ -0,0 +1,35 @@ +from tmtccmd.tc.definitions import TcQueueT, QueueCommands +from tmtccmd.tc.pus_200_fsfw_modes import Modes + +from .common import command_mode +import config.object_ids as obj_ids + + +class OpCodes: + THERMAL_CONTROLLER_NORMAL = ["0", "thermal-normal"] + THERMAL_CONTROLLER_OFF = ["1", "thermal-off"] + + +class Info: + THERMAL_CONTROLLER_NORMAL = "Switching Thermal Controller into normal" + THERMAL_CONTROLLER_OFF = "Switching Thermal Controller off" + + +def pack_controller_commands(tc_queue: TcQueueT, op_code: str): + if op_code in OpCodes.THERMAL_CONTROLLER_NORMAL: + command_mode( + object_id=obj_ids.THERMAL_CONTROLLER_ID, + mode=Modes.NORMAL, + submode=0, + tc_queue=tc_queue, + info=Info.THERMAL_CONTROLLER_NORMAL, + ) + if op_code in OpCodes.THERMAL_CONTROLLER_OFF: + command_mode( + object_id=obj_ids.THERMAL_CONTROLLER_ID, + mode=Modes.OFF, + submode=0, + tc_queue=tc_queue, + info=Info.THERMAL_CONTROLLER_OFF, + ) + diff --git a/pus_tc/system/tcs.py b/pus_tc/system/tcs.py index 5b98ddc..47ab31d 100644 --- a/pus_tc/system/tcs.py +++ b/pus_tc/system/tcs.py @@ -1,7 +1,7 @@ from tmtccmd.tc.definitions import TcQueueT, QueueCommands from tmtccmd.tc.pus_200_fsfw_modes import Modes -from .common import command_assembly +from .common import command_mode from config.object_ids import TCS_BOARD_ASS_ID @@ -17,7 +17,7 @@ class Info: def pack_tcs_sys_commands(tc_queue: TcQueueT, op_code: str): if op_code in OpCodes.TCS_BOARD_ASS_NORMAL: - command_assembly( + command_mode( object_id=TCS_BOARD_ASS_ID, mode=Modes.NORMAL, submode=0, @@ -25,7 +25,7 @@ def pack_tcs_sys_commands(tc_queue: TcQueueT, op_code: str): info=Info.TCS_BOARD_ASS_NORMAL, ) if op_code in OpCodes.TCS_BOARD_ASS_OFF: - command_assembly( + command_mode( object_id=TCS_BOARD_ASS_ID, mode=Modes.OFF, submode=0, diff --git a/pus_tc/tc_packer_hook.py b/pus_tc/tc_packer_hook.py index e999f59..52046cb 100644 --- a/pus_tc/tc_packer_hook.py +++ b/pus_tc/tc_packer_hook.py @@ -41,6 +41,7 @@ from pus_tc.system.acs import pack_acs_command, pack_sus_cmds from pus_tc.devs.plpcdu import pack_pl_pcdu_commands from pus_tc.devs.str_img_helper import pack_str_img_helper_command from pus_tc.system.tcs import pack_tcs_sys_commands +from pus_tc.system.controllers import pack_controller_commands from config.definitions import CustomServiceList from config.object_ids import ( P60_DOCK_HANDLER, @@ -239,6 +240,8 @@ def pack_service_queue_user( return pack_rw_ass_cmds( tc_queue=service_queue, object_id=RW_ASSEMBLY, op_code=op_code ) + if service == CustomServiceList.CONTROLLERS.value: + return pack_controller_commands(tc_queue=service_queue, op_code=op_code) LOGGER.warning("Invalid Service !")