From 7957ed844e6b2d143cf780d3cc5a3ba485a06e70 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 18 Oct 2022 14:08:12 +0200 Subject: [PATCH] update RW commands --- .run/RW1.run.xml | 24 ++++++++++++++++++++++++ tmtc/reaction_wheels.py | 29 +++++++++++++++++++++++++---- 2 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 .run/RW1.run.xml diff --git a/.run/RW1.run.xml b/.run/RW1.run.xml new file mode 100644 index 0000000..f5f1941 --- /dev/null +++ b/.run/RW1.run.xml @@ -0,0 +1,24 @@ + + + + + \ No newline at end of file diff --git a/tmtc/reaction_wheels.py b/tmtc/reaction_wheels.py index ce6a9ea..babb4bd 100644 --- a/tmtc/reaction_wheels.py +++ b/tmtc/reaction_wheels.py @@ -16,6 +16,8 @@ from tmtccmd.tc.pus_3_fsfw_hk import ( generate_one_hk_command, generate_one_diag_command, make_sid, + enable_periodic_hk_command_with_interval, + disable_periodic_hk_command ) from spacepackets.ecss.tc import PusTelecommand from tmtccmd.tc.pus_200_fsfw_modes import pack_mode_data, Modes, Subservices @@ -31,6 +33,8 @@ class OpCodesDevs: OFF = ["3", "off"] GET_STATUS = ["4", "status"] GET_TM = ["5", "tm"] + ENABLE_STATUS_HK = ["6", "enable_status_hk"] + DISABLE_STATUS_HK = ["7", "disable_status_hk"] class InfoDevs: @@ -40,6 +44,8 @@ class InfoDevs: OFF = "Set Off" GET_STATUS = "Get Status HK" GET_TM = "Get TM HK" + ENABLE_STATUS_HK = "Enable Status HK" + DISABLE_STATUS_HK = "Disable Status HK" class OpCodesAss: @@ -94,6 +100,8 @@ def add_rw_cmds(defs: TmtcDefinitionWrapper): oce.add(info=InfoDevs.NML, keys=OpCodesDevs.NML) oce.add(info=InfoDevs.GET_STATUS, keys=OpCodesDevs.GET_STATUS) oce.add(info=InfoDevs.GET_TM, keys=OpCodesDevs.GET_TM) + oce.add(info=InfoDevs.ENABLE_STATUS_HK, keys=OpCodesDevs.ENABLE_STATUS_HK) + oce.add(info=InfoDevs.DISABLE_STATUS_HK, keys=OpCodesDevs.DISABLE_STATUS_HK) defs.add_service( name=CustomServiceList.REACTION_WHEEL_1.value, info="Reaction Wheel 1", @@ -129,8 +137,8 @@ def pack_single_rw_test_into( object_id: bytes, rw_idx: int, q: DefaultPusQueueHelper, op_code: str ): if op_code in OpCodesDevs.SPEED: - speed = int(input("Specify speed [0.1 RPM]: ")) - ramp_time = int(input("Specify ramp time [ms]: ")) + speed = int(input("Specify speed [0.1 RPM, 0 or range [-65000, -1000] and [1000, 65000]: ")) + ramp_time = int(input("Specify ramp time [ms, range [10, 20000]]: ")) q.add_log_cmd(f"RW {rw_idx}: {InfoDevs.SPEED}") q.add_pus_tc(pack_set_speed_command(object_id, speed, ramp_time)) @@ -163,6 +171,19 @@ def pack_single_rw_test_into( sid=make_sid(object_id=object_id, set_id=RwSetIds.STATUS_SET_ID) ) ) + if op_code in OpCodesDevs.ENABLE_STATUS_HK: + q.add_log_cmd(f"RW {rw_idx}: {InfoDevs.ENABLE_STATUS_HK}") + interval = float(input("Please enter HK interval in floating point seconds: ")) + cmds = enable_periodic_hk_command_with_interval( + True, + make_sid(object_id, RwSetIds.STATUS_SET_ID), + interval + ) + for cmd in cmds: + q.add_pus_tc(cmd) + if op_code in OpCodesDevs.DISABLE_STATUS_HK: + q.add_log_cmd(f"RW {rw_idx}: {InfoDevs.DISABLE_STATUS_HK}") + q.add_pus_tc(disable_periodic_hk_command(True, make_sid(object_id, RwSetIds.STATUS_SET_ID))) def pack_rw_ass_cmds(q: DefaultPusQueueHelper, object_id: bytes, op_code: str): @@ -198,10 +219,10 @@ def pack_set_speed_command( ) -> PusTelecommand: """With this function a command is packed to set the speed of a reaction wheel :param object_id: The object id of the reaction wheel handler. - :param speed: Valid speeds are [-65000, -1000] and [1000, 65000]. Values are + :param speed: Valid speeds are 0, [-65000, -1000] and [1000, 65000]. Values are specified in 0.1 * RPM :param ramp_time_ms: The time after which the reaction wheel will reach the commanded speed. - Valid times are 10 - 10000 ms + Valid times are 10 - 20000 ms """ if speed > 0: if speed < 1000 or speed > 65000: