From ecae444ee3f2dd324c172d4d8085146872464d47 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 12 Jan 2023 14:11:30 +0100 Subject: [PATCH] some refactoring for PCDU cmds --- eive_tmtc/tmtc/power/common_power.py | 28 ++++--- eive_tmtc/tmtc/power/pdu1.py | 117 +++++++++++++++++++++++---- 2 files changed, 117 insertions(+), 28 deletions(-) diff --git a/eive_tmtc/tmtc/power/common_power.py b/eive_tmtc/tmtc/power/common_power.py index 224b7f9..4c44fe8 100644 --- a/eive_tmtc/tmtc/power/common_power.py +++ b/eive_tmtc/tmtc/power/common_power.py @@ -273,12 +273,14 @@ def generic_on_cmd( object_id: bytes, q: DefaultPusQueueHelper, info_str: str, out_idx: int ): q.add_log_cmd(info_str + " on") - q.add_pus_tc( - pack_set_u8_param_command( - object_id, - OUT_ENABLE_LIST[out_idx].parameter_address, - Channel.on, - ) + q.add_pus_tc(create_generic_on_cmd(object_id, out_idx)) + + +def create_generic_on_cmd(object_id: bytes, out_idx: int): + return pack_set_u8_param_command( + object_id, + OUT_ENABLE_LIST[out_idx].parameter_address, + Channel.on, ) @@ -286,12 +288,14 @@ def generic_off_cmd( object_id: bytes, q: DefaultPusQueueHelper, info_str: str, out_idx: int ): q.add_log_cmd(info_str + " off") - q.add_pus_tc( - pack_set_u8_param_command( - object_id, - OUT_ENABLE_LIST[out_idx].parameter_address, - Channel.off, - ) + q.add_pus_tc(create_generic_off_cmd(object_id, out_idx)) + + +def create_generic_off_cmd(object_id: bytes, out_idx: int): + return pack_set_u8_param_command( + object_id, + OUT_ENABLE_LIST[out_idx].parameter_address, + Channel.off, ) diff --git a/eive_tmtc/tmtc/power/pdu1.py b/eive_tmtc/tmtc/power/pdu1.py index 90cd142..0b3819e 100644 --- a/eive_tmtc/tmtc/power/pdu1.py +++ b/eive_tmtc/tmtc/power/pdu1.py @@ -12,6 +12,8 @@ from eive_tmtc.tmtc.power.common_power import ( generic_on_cmd, generic_off_cmd, add_gomspace_cmd_defs, + create_generic_on_cmd, + create_generic_off_cmd, pack_common_power_cmds, GomspaceOpCodes, GsInfo, @@ -173,65 +175,148 @@ def add_pdu1_cmds(defs: TmtcDefinitionWrapper): ) +PDU1_DICT = { + Pdu1ChIndex.TCS: Pdu1InfoBase.TCS, + Pdu1ChIndex.STR: Pdu1InfoBase.STR, + Pdu1ChIndex.SYRLINKS: Pdu1InfoBase.SYRLINKS, + Pdu1ChIndex.MGT: Pdu1InfoBase.MGT, + Pdu1ChIndex.SCEX: Pdu1InfoBase.SCEX, + Pdu1ChIndex.ACS_A: Pdu1InfoBase.ACS_A, + Pdu1ChIndex.SUS_N: Pdu1InfoBase.SUS_N, +} + + +def pdu1_on_cmd(idx: Pdu1ChIndex, q: DefaultPusQueueHelper): + generic_on_cmd(PDU_1_HANDLER_ID, q, PDU1_DICT[idx], idx) + + +def pdu1_off_cmd(idx: Pdu1ChIndex, q: DefaultPusQueueHelper): + generic_off_cmd(PDU_1_HANDLER_ID, q, PDU1_DICT[idx], idx) + + def tcs_on_cmd(q: DefaultPusQueueHelper): - generic_on_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.TCS, Pdu1ChIndex.TCS) + pdu1_on_cmd(Pdu1ChIndex.TCS, q) + + +def create_tcs_on_cmd() -> PusTelecommand: + return create_generic_on_cmd(PDU_1_HANDLER_ID, Pdu1ChIndex.TCS) def tcs_off_cmd(q: DefaultPusQueueHelper): - generic_off_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.TCS, Pdu1ChIndex.TCS) + pdu1_off_cmd(Pdu1ChIndex.TCS, q) + + +def create_tcs_off_cmd() -> PusTelecommand: + return create_generic_off_cmd(PDU_1_HANDLER_ID, Pdu1ChIndex.TCS) def syrlinks_on_cmd(q: DefaultPusQueueHelper): - generic_on_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.SYRLINKS, Pdu1ChIndex.SYRLINKS) + pdu1_on_cmd(Pdu1ChIndex.SYRLINKS, q) + + +def create_syrlinks_on_cmd() -> PusTelecommand: + return create_generic_on_cmd(PDU_1_HANDLER_ID, Pdu1ChIndex.SYRLINKS) def syrlinks_off_cmd(q: DefaultPusQueueHelper): - generic_off_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.SYRLINKS, Pdu1ChIndex.SYRLINKS) + pdu1_off_cmd(Pdu1ChIndex.SYRLINKS, q) + + +def create_syrlinks_off_cmd() -> PusTelecommand: + return create_generic_off_cmd(PDU_1_HANDLER_ID, Pdu1ChIndex.SYRLINKS) def startracker_on_cmd(q: DefaultPusQueueHelper): - generic_on_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.STR, Pdu1ChIndex.STR) + pdu1_on_cmd(Pdu1ChIndex.STR, q) + + +def create_startracker_on_cmd() -> PusTelecommand: + return create_generic_on_cmd(PDU_1_HANDLER_ID, Pdu1ChIndex.STR) def startracker_off_cmd(q: DefaultPusQueueHelper): - generic_off_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.STR, Pdu1ChIndex.STR) + pdu1_on_cmd(Pdu1ChIndex.STR, q) + + +def create_startracker_off_cmd() -> PusTelecommand: + return create_generic_off_cmd(PDU_1_HANDLER_ID, Pdu1ChIndex.STR) def mgt_on_cmd(q: DefaultPusQueueHelper): - generic_on_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.MGT, Pdu1ChIndex.MGT) + pdu1_on_cmd(Pdu1ChIndex.MGT, q) + + +def create_mgt_on_cmd() -> PusTelecommand: + return create_generic_on_cmd(PDU_1_HANDLER_ID, Pdu1ChIndex.MGT) def mgt_off_cmd(q: DefaultPusQueueHelper): - generic_off_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.MGT, Pdu1ChIndex.MGT) + pdu1_off_cmd(Pdu1ChIndex.MGT, q) + + +def create_mgt_off_cmd() -> PusTelecommand: + return create_generic_on_cmd(PDU_1_HANDLER_ID, Pdu1ChIndex.MGT) def sun_sensor_nominal_on_cmd(q: DefaultPusQueueHelper): - generic_on_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.SUS_N, Pdu1ChIndex.SUS_N) + pdu1_on_cmd(Pdu1ChIndex.SUS_N, q) + + +def create_sun_sensor_nominal_on_cmd() -> PusTelecommand: + return create_generic_on_cmd(PDU_1_HANDLER_ID, Pdu1ChIndex.SUS_N) def sun_sensor_nominal_off_cmd(q: DefaultPusQueueHelper): - generic_off_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.SUS_N, Pdu1ChIndex.SUS_N) + pdu1_off_cmd(Pdu1ChIndex.SUS_N, q) + + +def create_sun_sensor_nominal_off_cmd() -> PusTelecommand: + return create_generic_off_cmd(PDU_1_HANDLER_ID, Pdu1ChIndex.SUS_N) def solar_cell_experiment_on_cmd(q: DefaultPusQueueHelper): - generic_on_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.SCEX, Pdu1ChIndex.SCEX) + pdu1_on_cmd(Pdu1ChIndex.SCEX, q) + + +def create_solar_cell_experiment_on_cmd() -> PusTelecommand: + return create_generic_on_cmd(PDU_1_HANDLER_ID, Pdu1ChIndex.SCEX) def solar_cell_experiment_off_cmd(q: DefaultPusQueueHelper): - generic_off_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.SCEX, Pdu1ChIndex.SCEX) + pdu1_off_cmd(Pdu1ChIndex.SCEX, q) + + +def create_solar_cell_experiment_off_cmd() -> PusTelecommand: + return create_generic_off_cmd(PDU_1_HANDLER_ID, Pdu1ChIndex.SCEX) def ploc_on_cmd(q: DefaultPusQueueHelper): - generic_on_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.PLOC, Pdu1ChIndex.PLOC) + pdu1_on_cmd(Pdu1ChIndex.PLOC, q) + + +def create_ploc_on_cmd() -> PusTelecommand: + return create_generic_on_cmd(PDU_1_HANDLER_ID, Pdu1ChIndex.PLOC) def ploc_off_cmd(q: DefaultPusQueueHelper): - generic_off_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.PLOC, Pdu1ChIndex.PLOC) + pdu1_off_cmd(Pdu1ChIndex.PLOC, q) + + +def create_ploc_off_cmd() -> PusTelecommand: + return create_generic_off_cmd(PDU_1_HANDLER_ID, Pdu1ChIndex.PLOC) def acs_board_a_on_cmd(q: DefaultPusQueueHelper): - generic_on_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.ACS_A, Pdu1ChIndex.ACS_A) + pdu1_on_cmd(Pdu1ChIndex.ACS_A, q) + + +def create_acs_board_a_on_cmd() -> PusTelecommand: + return create_generic_on_cmd(PDU_1_HANDLER_ID, Pdu1ChIndex.ACS_A) def acs_board_a_off_cmd(q: DefaultPusQueueHelper): - generic_on_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.ACS_A, Pdu1ChIndex.ACS_A) + pdu1_off_cmd(Pdu1ChIndex.ACS_A, q) + + +def create_acs_board_a_off_cmd() -> PusTelecommand: + return create_generic_off_cmd(PDU_1_HANDLER_ID, Pdu1ChIndex.ACS_A)