From fe1bed900adb688cbd3906617c974188a43c5535 Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" Date: Thu, 1 Jul 2021 11:52:25 +0200 Subject: [PATCH] added mode commanding for radiation sensor --- config/definitions.py | 1 + config/hook_implementations.py | 8 +++++++ config/object_ids.py | 3 +++ pus_tc/rad_sensor.py | 38 ++++++++++++++++++++++++++++++++++ pus_tc/reaction_wheels.py | 7 +++---- pus_tc/tc_packer_hook.py | 7 ++++++- 6 files changed, 59 insertions(+), 5 deletions(-) create mode 100644 pus_tc/rad_sensor.py diff --git a/config/definitions.py b/config/definitions.py index a5e094b..f5ca0d0 100644 --- a/config/definitions.py +++ b/config/definitions.py @@ -27,3 +27,4 @@ class CustomServiceList(enum.Enum): REACTION_WHEEL_2 = "reaction_wheel_2" REACTION_WHEEL_3 = "reaction_wheel_3" REACTION_WHEEL_4 = "reaction_wheel_4" + RAD_SENSOR = "rad_sensor" diff --git a/config/hook_implementations.py b/config/hook_implementations.py index 4809a50..2e50d6e 100644 --- a/config/hook_implementations.py +++ b/config/hook_implementations.py @@ -74,6 +74,13 @@ class EiveHookObject(TmTcHookBase): } service_rw_tuple = ("Reaction Wheel", op_code_dict_srv_rw) + op_code_dict_srv_rad_sensor = { + "0": ("Radiation Sensor: Set mode on", {OpCodeDictKeys.TIMEOUT: 2.0}), + "1": ("Radiation Sensor: Set mode normal", {OpCodeDictKeys.TIMEOUT: 2.0}), + "2": ("Radiation Sensor: Set mode off", {OpCodeDictKeys.TIMEOUT: 2.0}), + } + service_rad_sensor_tuple = ("Radiation Sensor", op_code_dict_srv_rad_sensor) + service_op_code_dict[CustomServiceList.ACU.value] = service_acu_tuple service_op_code_dict[CustomServiceList.TMP1075_1.value] = service_tmp1075_1_tuple service_op_code_dict[CustomServiceList.TMP1075_2.value] = service_tmp1075_2_tuple @@ -86,6 +93,7 @@ class EiveHookObject(TmTcHookBase): service_op_code_dict[CustomServiceList.REACTION_WHEEL_2.value] = service_rw_tuple service_op_code_dict[CustomServiceList.REACTION_WHEEL_3.value] = service_rw_tuple service_op_code_dict[CustomServiceList.REACTION_WHEEL_4.value] = service_rw_tuple + service_op_code_dict[CustomServiceList.RAD_SENSOR.value] = service_rad_sensor_tuple return service_op_code_dict def get_json_config_file_path(self) -> str: diff --git a/config/object_ids.py b/config/object_ids.py index b3f36d8..92412fe 100644 --- a/config/object_ids.py +++ b/config/object_ids.py @@ -23,6 +23,8 @@ RW1_ID = bytes([0x44, 0x21, 0x00, 0x1]) RW2_ID = bytes([0x44, 0x21, 0x00, 0x2]) RW3_ID = bytes([0x44, 0x21, 0x00, 0x3]) RW4_ID = bytes([0x44, 0x21, 0x00, 0x4]) +RAD_SENSOR_ID = bytes([0x44, 0x32, 0x00, 0xA5]) + def get_object_ids() -> Dict[bytes, list]: object_id_dict = ({ @@ -41,5 +43,6 @@ def get_object_ids() -> Dict[bytes, list]: RW2_ID: "Reaction Wheel 2", RW3_ID: "Reaction Wheel 3", RW4_ID: "Reaction Wheel 4", + RAD_SENSOR_ID: "Radiation Sensor", }) return object_id_dict diff --git a/pus_tc/rad_sensor.py b/pus_tc/rad_sensor.py new file mode 100644 index 0000000..aa071c1 --- /dev/null +++ b/pus_tc/rad_sensor.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +""" +@file rad_sensor.py +@brief Tests for the radiation sensor handler +@author J. Meier +@date 01.07.2021 +""" +import struct +from tmtccmd.config.definitions import QueueCommands + +from tmtccmd.pus_tc.packer import TcQueueT +from tmtccmd.ecss.tc import PusTelecommand +from pus_tc.service_200_mode import pack_mode_data + + +def pack_rad_sensor_test_into(object_id: bytearray, tc_queue: TcQueueT, op_code: str) -> TcQueueT: + tc_queue.appendleft( + (QueueCommands.PRINT, + "Testing radiation sensor handler with object id: 0x" + object_id.hex()) + ) + + if op_code == "0": + tc_queue.appendleft((QueueCommands.PRINT, "Rad sensor: Switch to mode on")) + mode_data = pack_mode_data(object_id, 1, 0) + command = PusTelecommand(service=200, subservice=1, ssc=41, app_data=mode_data) + tc_queue.appendleft(command.pack_command_tuple()) + + if op_code == "1": + tc_queue.appendleft((QueueCommands.PRINT, "Rad sensor: Switch to mode normal")) + mode_data = pack_mode_data(object_id, 2, 0) + command = PusTelecommand(service=200, subservice=1, ssc=42, app_data=mode_data) + tc_queue.appendleft(command.pack_command_tuple()) + + if op_code == "2": + tc_queue.appendleft((QueueCommands.PRINT, "Rad sensor: Switch to mode off")) + mode_data = pack_mode_data(object_id, 0, 0) + command = PusTelecommand(service=200, subservice=1, ssc=42, app_data=mode_data) + tc_queue.appendleft(command.pack_command_tuple()) \ No newline at end of file diff --git a/pus_tc/reaction_wheels.py b/pus_tc/reaction_wheels.py index f20240d..02d6464 100644 --- a/pus_tc/reaction_wheels.py +++ b/pus_tc/reaction_wheels.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- """ -@file imtq.py -@brief Tests for the ISIS IMTQ (Magnettorquer) device handler +@file reaction_wheels.py +@brief Tests for the reaction wheel handler @author J. Meier -@date 25.03.2021 +@date 20.06.2021 """ import struct from tmtccmd.config.definitions import QueueCommands @@ -11,7 +11,6 @@ from tmtccmd.config.definitions import QueueCommands from tmtccmd.pus_tc.packer import TcQueueT from tmtccmd.ecss.tc import PusTelecommand from pus_tc.service_200_mode import pack_mode_data -from tmtccmd.pus_tc.service_3_housekeeping import make_sid, generate_one_hk_command class RwSetIds: diff --git a/pus_tc/tc_packer_hook.py b/pus_tc/tc_packer_hook.py index bfe33a5..56ea866 100644 --- a/pus_tc/tc_packer_hook.py +++ b/pus_tc/tc_packer_hook.py @@ -23,9 +23,11 @@ from pus_tc.tmp1075 import pack_tmp1075_test_into from pus_tc.ploc import pack_ploc_test_into from pus_tc.heater import pack_heater_test_into from pus_tc.reaction_wheels import pack_single_rw_test_into +from pus_tc.rad_sensor import pack_rad_sensor_test_into from config.definitions import CustomServiceList from config.object_ids import P60_DOCK_HANDLER, PDU_1_HANDLER_ID, PDU_2_HANDLER_ID, ACU_HANDLER_ID, \ - TMP_1075_1_HANDLER_ID, TMP_1075_2_HANDLER_ID, HEATER_ID, IMTQ_HANDLER_ID, PLOC_ID, RW1_ID, RW2_ID, RW3_ID, RW4_ID + TMP_1075_1_HANDLER_ID, TMP_1075_2_HANDLER_ID, HEATER_ID, IMTQ_HANDLER_ID, PLOC_ID, RW1_ID, RW2_ID, RW3_ID, RW4_ID, \ + RAD_SENSOR_ID LOGGER = get_console_logger() @@ -81,6 +83,9 @@ def pack_service_queue_user(service: Union[str, int], op_code: str, service_queu if service == CustomServiceList.REACTION_WHEEL_4.value: object_id = RW4_ID return pack_single_rw_test_into(object_id=object_id, tc_queue=service_queue, op_code=op_code) + if service == CustomServiceList.RAD_SENSOR.value: + object_id = RAD_SENSOR_ID + return pack_rad_sensor_test_into(object_id=object_id, tc_queue=service_queue, op_code=op_code) LOGGER.warning("Invalid Service !")