From 8b275bdca8cd533f703927950f907e9e8101fe5e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 11 Aug 2022 18:10:15 +0200 Subject: [PATCH] a lot of improvements --- config/definitions.py | 1 + deps/tmtccmd | 2 +- gomspace/gomspace_common.py | 3 +- gomspace/gomspace_pdu_definitions.py | 1 + pus_tc/cmd_definitions.py | 3 +- pus_tc/devs/acu.py | 2 +- pus_tc/devs/common_power.py | 418 +++++++++++++++++++++++++-- pus_tc/devs/p60dock.py | 10 +- pus_tc/devs/pdu1.py | 190 +----------- pus_tc/devs/pdu2.py | 206 +------------ pus_tc/devs/plpcdu.py | 1 - pus_tc/devs/power.py | 103 ++----- pus_tc/procedure_packer.py | 4 + tmtcc.py | 7 +- 14 files changed, 446 insertions(+), 505 deletions(-) diff --git a/config/definitions.py b/config/definitions.py index acd37ac..7086a79 100644 --- a/config/definitions.py +++ b/config/definitions.py @@ -16,6 +16,7 @@ class CustomServiceList(enum.Enum): P60DOCK = "p60dock" PDU1 = "pdu1" PDU2 = "pdu2" + POWER = "power" ACU = "acu" ACS = "acs" BPX_BATTERY = "bpx" diff --git a/deps/tmtccmd b/deps/tmtccmd index bba516d..f1e9e50 160000 --- a/deps/tmtccmd +++ b/deps/tmtccmd @@ -1 +1 @@ -Subproject commit bba516dd8920bf3accc10c5accbe697bb84c3789 +Subproject commit f1e9e504a356a1fddb008facaa13633610198653 diff --git a/gomspace/gomspace_common.py b/gomspace/gomspace_common.py index 2c90c47..aa1ffa7 100644 --- a/gomspace/gomspace_common.py +++ b/gomspace/gomspace_common.py @@ -36,9 +36,10 @@ class GomspaceOpCodes: SET_PARAM = ["set-param", "133"] -class Info: +class GsInfo: REQUEST_CORE_HK_ONCE = "Requesting Core HK once" REQUEST_AUX_HK_ONCE = "Requesting Aux HK once" + PRINT_SWITCH_V_I = "Print Switch V I Info" GET_PARAMETER = "Get parameter" SET_PARAMETER = "Set parameter" diff --git a/gomspace/gomspace_pdu_definitions.py b/gomspace/gomspace_pdu_definitions.py index 3f277b1..5699b92 100644 --- a/gomspace/gomspace_pdu_definitions.py +++ b/gomspace/gomspace_pdu_definitions.py @@ -24,6 +24,7 @@ PDU_CONFIG_LIST = [ PduConfigTable.out_en_5, PduConfigTable.out_en_6, PduConfigTable.out_en_7, + PduConfigTable.out_en_8, ] diff --git a/pus_tc/cmd_definitions.py b/pus_tc/cmd_definitions.py index e3c350f..783f1b9 100644 --- a/pus_tc/cmd_definitions.py +++ b/pus_tc/cmd_definitions.py @@ -2,7 +2,7 @@ from pus_tc.devs.scex import add_scex_cmds from pus_tc.system.proc import add_proc_cmds from pus_tc.devs.gps import add_gps_cmds -from pus_tc.devs.power import add_pcdu_cmds +from pus_tc.devs.power import add_pcdu_cmds, add_power_cmd_defs from pus_tc.devs.plpcdu import add_pl_pcdu_cmds from pus_tc.devs.rad_sensor import add_rad_sens_cmds from pus_tc.system.core import add_core_controller_definitions @@ -27,6 +27,7 @@ def get_eive_service_op_code_dict() -> TmTcDefWrapper: add_rad_sens_cmds(defs=def_wrapper) add_rw_cmds(defs=def_wrapper) add_ploc_mpsoc_cmds(defs=def_wrapper) + add_power_cmd_defs(defs=def_wrapper) add_ploc_supv_cmds(defs=def_wrapper) add_system_cmds(defs=def_wrapper) add_time_cmds(defs=def_wrapper) diff --git a/pus_tc/devs/acu.py b/pus_tc/devs/acu.py index cbd6cda..90df2ee 100644 --- a/pus_tc/devs/acu.py +++ b/pus_tc/devs/acu.py @@ -16,7 +16,7 @@ from tmtccmd.tc.pus_3_fsfw_hk import ( ) import gomspace.gomspace_common as gs from gomspace.gomspace_common import GomspaceOpCodes -from gomspace.gomspace_common import Info as GsInfo +from gomspace.gomspace_common import GsInfo as GsInfo from config.object_ids import ACU_HANDLER_ID from pus_tc.devs.p60dock import P60DockConfigTable from tmtccmd.tc.pus_8_funccmd import generate_action_command diff --git a/pus_tc/devs/common_power.py b/pus_tc/devs/common_power.py index 75b0981..b5f0376 100644 --- a/pus_tc/devs/common_power.py +++ b/pus_tc/devs/common_power.py @@ -1,10 +1,71 @@ import enum -from config.object_ids import PDU_1_HANDLER_ID -from gomspace.gomspace_common import pack_set_param_command, Channel +from config.object_ids import PDU_1_HANDLER_ID, PDU_2_HANDLER_ID +from gomspace.gomspace_common import ( + pack_set_param_command, + Channel, + GomspaceOpCodes, + GsInfo, + SetIds, +) from gomspace.gomspace_pdu_definitions import PDU_CONFIG_LIST +from tmtccmd.config import OpCodeEntry from tmtccmd.tc import DefaultPusQueueHelper -from tmtccmd.util import ObjectIdU32 +from tmtccmd.tc.pus_3_fsfw_hk import ( + make_sid, + generate_one_diag_command, + generate_one_hk_command, +) + + +class Pdu1ChIndex(enum.IntEnum): + TCS = 0 + SYRLINKS = 1 + STR = 2 + MGT = 3 + SUS_N = 4 + SCEX = 5 + PLOC = 6 + ACS_A = 7 + + +class Pdu1InfoBase: + TCS = "Switch TCS Board" + SYRLINKS = "Switch Syrlinks (COM)" + STR = "Switch Startracker" + MGT = "Switch Magnetorquer" + SUS_N = "Switch Sun Sensor Board Nominal" + SCEX = "Switch Solar Cell Experiment" + PLOC = "Switch Payload On-Board Computer" + ACS_A = "Switch ACS Board A-Side" + + +class Pdu2InfoBase: + PL_PCDU_BAT_NOM = "Switch PL PCDU Nominal Battery Channel" + RW = "Switch Reaction Wheel" + HEATER = "Switch Heater" + SUS_R = "Switch Sun Sensor Board Redundant" + SOLAR_ARRAY_DEPL = "Switch Solar Array Deployment" + PL_PCDU_BAT_RED = "Switch PL PCDU Redundant Battery Channel" + ACS_B = "Switch ACS Board B-Side" + PL_CAM = "Switch Payload Camera" + + +class PowerInfo: + INFO_CORE = "Core Information" + INFO_AUX = "Auxiliary Information" + INFO_ALL = "All Information" + + +class Pdu2ChIndex(enum.IntEnum): + PL_PCDU_BAT_NOM = 1 + RW = 2 + HEATER = 3 + SUS_R = 4 + SOLAR_ARRAY_DEPL = 5 + PL_PCDU_BAT_RED = 6 + ACS_B = 7 + PL_CAM = 8 class PowerOpCodes: @@ -17,10 +78,10 @@ class PowerOpCodes: STAR_TRACKER_OFF = ["str-off"] MGT_ON = ["mgt-on"] MGT_OFF = ["mgt-off"] - SUS_N_ON = ["sus-on"] - SUS_N_OFF = ["sus-off"] - SCEX_ON = ["sus-on"] - SCEX_OFF = ["sus-off"] + SUS_N_ON = ["sus-nom-on"] + SUS_N_OFF = ["sus-nom-off"] + SCEX_ON = ["scex-on"] + SCEX_OFF = ["scex-off"] PLOC_ON = ["ploc-on"] PLOC_OFF = ["ploc-off"] ACS_A_ON = ["acs-a-on"] @@ -41,51 +102,344 @@ class PowerOpCodes: PL_PCDU_VBAT_RED_OFF = ["plpcdu-vbat-red-off"] ACS_B_ON = ["acs-b-on"] ACS_B_OFF = ["acs-b-off"] + PL_CAM_ON = ["cam-on"] + PL_CAM_OFF = ["cam-off"] INFO_CORE = ["info"] INFO_AUX = ["info-aux"] INFO_ALL = ["info-all"] -def get_power_obj_id(op_code: PowerOpCodes) -> ObjectIdU32: - pass +def info_on_pdu1(base: str) -> str: + return "PDU1: " + base + " on" + + +def info_off_pdu1(base: str) -> str: + return "PDU1: " + base + " off" + + +def info_on_pdu2(base: str) -> str: + return "PDU2: " + base + " on" + + +def info_off_pdu2(base: str) -> str: + return "PDU2: " + base + " off" + + +def add_pdu1_common_defs(oce: OpCodeEntry): + oce.add(keys=PowerOpCodes.TCS_ON, info=info_on_pdu1(Pdu1InfoBase.TCS)) + oce.add(keys=PowerOpCodes.TCS_OFF, info=info_off_pdu1(Pdu1InfoBase.TCS)) + oce.add(keys=PowerOpCodes.STAR_TRACKER_ON, info=info_on_pdu1(Pdu1InfoBase.STR)) + oce.add(keys=PowerOpCodes.STAR_TRACKER_OFF, info=info_off_pdu1(Pdu1InfoBase.STR)) + oce.add(keys=PowerOpCodes.SUS_N_ON, info=info_on_pdu1(Pdu1InfoBase.SUS_N)) + oce.add(keys=PowerOpCodes.SUS_N_OFF, info=info_off_pdu1(Pdu1InfoBase.SUS_N)) + oce.add(keys=PowerOpCodes.ACS_A_ON, info=info_on_pdu1(Pdu1InfoBase.ACS_A)) + oce.add(keys=PowerOpCodes.ACS_A_OFF, info=info_off_pdu1(Pdu1InfoBase.ACS_A)) + oce.add(keys=PowerOpCodes.SYRLINKS_ON, info=info_on_pdu1(Pdu1InfoBase.SYRLINKS)) + oce.add(keys=PowerOpCodes.SYRLINKS_OFF, info=info_off_pdu1(Pdu1InfoBase.SYRLINKS)) + oce.add(keys=PowerOpCodes.MGT_ON, info=info_on_pdu1(Pdu1InfoBase.MGT)) + oce.add(keys=PowerOpCodes.MGT_OFF, info=info_off_pdu1(Pdu1InfoBase.MGT)) + oce.add(keys=PowerOpCodes.PLOC_ON, info=info_on_pdu1(Pdu1InfoBase.PLOC)) + oce.add(keys=PowerOpCodes.PLOC_OFF, info=info_off_pdu1(Pdu1InfoBase.PLOC)) + oce.add(keys=PowerOpCodes.SCEX_ON, info=info_on_pdu1(Pdu1InfoBase.SCEX)) + oce.add(keys=PowerOpCodes.SCEX_OFF, info=info_off_pdu1(Pdu1InfoBase.SCEX)) + + +def add_pdu2_common_defs(oce: OpCodeEntry): + oce.add(keys=PowerOpCodes.ACS_B_ON, info=info_on_pdu2(Pdu2InfoBase.ACS_B)) + oce.add(keys=PowerOpCodes.ACS_B_OFF, info=info_off_pdu2(Pdu2InfoBase.ACS_B)) + oce.add(keys=PowerOpCodes.SUS_R_ON, info=info_on_pdu2(Pdu2InfoBase.SUS_R)) + oce.add(keys=PowerOpCodes.SUS_R_OFF, info=info_off_pdu2(Pdu2InfoBase.SUS_R)) + oce.add(keys=PowerOpCodes.RW_ON, info=info_on_pdu2(Pdu2InfoBase.RW)) + oce.add(keys=PowerOpCodes.RW_OFF, info=info_off_pdu2(Pdu2InfoBase.RW)) + oce.add( + keys=PowerOpCodes.PL_PCDU_VBAT_NOM_ON, + info=info_on_pdu2(Pdu2InfoBase.PL_PCDU_BAT_NOM), + ) + oce.add( + keys=PowerOpCodes.PL_PCDU_VBAT_NOM_OFF, + info=info_off_pdu2(Pdu2InfoBase.PL_PCDU_BAT_NOM), + ) + oce.add( + keys=PowerOpCodes.PL_PCDU_VBAT_RED_ON, + info=info_on_pdu2(Pdu2InfoBase.PL_PCDU_BAT_RED), + ) + oce.add( + keys=PowerOpCodes.PL_PCDU_VBAT_RED_OFF, + info=info_off_pdu2(Pdu2InfoBase.PL_PCDU_BAT_RED), + ) + oce.add(keys=PowerOpCodes.HEATER_ON, info=info_on_pdu2(Pdu2InfoBase.HEATER)) + oce.add(keys=PowerOpCodes.HEATER_OFF, info=info_off_pdu2(Pdu2InfoBase.HEATER)) + oce.add( + keys=PowerOpCodes.SOLAR_ARRAY_DEPL_ON, + info=info_on_pdu2(Pdu2InfoBase.SOLAR_ARRAY_DEPL), + ) + oce.add( + keys=PowerOpCodes.SOLAR_ARRAY_DEPL_OFF, + info=info_off_pdu2(Pdu2InfoBase.SOLAR_ARRAY_DEPL), + ) + oce.add(keys=PowerOpCodes.PL_CAM_ON, info=info_on_pdu2(Pdu2InfoBase.PL_CAM)) + oce.add(keys=PowerOpCodes.PL_CAM_OFF, info=info_off_pdu2(Pdu2InfoBase.PL_CAM)) + + +def pdu1_cmds(q: DefaultPusQueueHelper, op_code: str): + if op_code in PowerOpCodes.TCS_ON: + tcs_on_cmd(q) + elif op_code in PowerOpCodes.TCS_OFF: + tcs_off_cmd(q) + elif op_code in PowerOpCodes.SYRLINKS_ON: + syrlinks_on_cmd(q) + elif op_code in PowerOpCodes.SYRLINKS_OFF: + syrlinks_off_cmd(q) + elif op_code in PowerOpCodes.STAR_TRACKER_ON: + startracker_on_cmd(q) + elif op_code in PowerOpCodes.STAR_TRACKER_OFF: + startracker_off_cmd(q) + elif op_code in PowerOpCodes.MGT_ON: + mgt_on_cmd(q) + elif op_code in PowerOpCodes.MGT_OFF: + mgt_off_cmd(q) + elif op_code in PowerOpCodes.SUS_N_ON: + sun_sensor_nominal_on_cmd(q) + elif op_code in PowerOpCodes.SUS_N_OFF: + sun_sensor_nominal_off_cmd(q) + elif op_code in PowerOpCodes.SCEX_ON: + solar_cell_experiment_on_cmd(q) + elif op_code in PowerOpCodes.SCEX_OFF: + solar_cell_experiment_off_cmd(q) + elif op_code in PowerOpCodes.PLOC_ON: + ploc_on_cmd(q) + elif op_code in PowerOpCodes.PLOC_OFF: + ploc_off_cmd(q) + elif op_code in PowerOpCodes.ACS_A_ON: + acs_board_a_on_cmd(q) + elif op_code in PowerOpCodes.ACS_A_OFF: + acs_board_a_off_cmd(q) + + +def pdu2_cmds(q: DefaultPusQueueHelper, op_code: str): + if op_code in PowerOpCodes.PL_PCDU_VBAT_NOM_ON: + pl_pcdu_bat_nom_on_cmd(q) + elif op_code in PowerOpCodes.PL_PCDU_VBAT_NOM_OFF: + pl_pcdu_bat_nom_off_cmd(q) + elif op_code in PowerOpCodes.RW_ON: + reaction_wheel_on_cmd(q) + elif op_code in PowerOpCodes.RW_OFF: + reaction_wheel_off_cmd(q) + elif op_code in PowerOpCodes.HEATER_ON: + heater_on_cmd(q) + elif op_code in PowerOpCodes.HEATER_OFF: + heater_off_cmd(q) + elif op_code in PowerOpCodes.SUS_R_ON: + sus_red_on_cmd(q) + elif op_code in PowerOpCodes.SUS_R_OFF: + sus_red_off_cmd(q) + elif op_code in PowerOpCodes.SOLAR_ARRAY_DEPL_ON: + solar_array_deployment_on_cmd(q) + elif op_code in PowerOpCodes.SOLAR_ARRAY_DEPL_OFF: + solar_array_deployment_off_cmd(q) + elif op_code in PowerOpCodes.PL_PCDU_VBAT_RED_ON: + pl_pcdu_bat_red_on_cmd(q) + elif op_code in PowerOpCodes.PL_PCDU_VBAT_RED_OFF: + pl_pcdu_bat_nom_off_cmd(q) + elif op_code in PowerOpCodes.ACS_B_ON: + acs_board_b_side_on_cmd(q) + elif op_code in PowerOpCodes.ACS_B_OFF: + acs_board_b_side_off_cmd(q) + elif op_code in PowerOpCodes.PL_CAM_ON: + payload_camera_on_cmd(q) + elif op_code in PowerOpCodes.PL_CAM_OFF: + payload_camera_off_cmd(q) + + +def pdu1_req_hk_cmds(q: DefaultPusQueueHelper, op_code: str): + if op_code in GomspaceOpCodes.REQUEST_CORE_HK_ONCE: + q.add_log_cmd(f"PDU1: {GsInfo.REQUEST_CORE_HK_ONCE}") + hk_sid = make_sid(object_id=PDU_1_HANDLER_ID, set_id=SetIds.PDU_1_CORE) + q.add_pus_tc(generate_one_diag_command(sid=hk_sid)) + if op_code in GomspaceOpCodes.REQUEST_AUX_HK_ONCE: + q.add_log_cmd(f"PDU1: {GsInfo.REQUEST_AUX_HK_ONCE}") + hk_sid = make_sid(object_id=PDU_1_HANDLER_ID, set_id=SetIds.PDU_1_AUX) + q.add_pus_tc(generate_one_hk_command(sid=hk_sid)) + + +def pdu2_req_hk_cmds(q: DefaultPusQueueHelper, op_code: str): + if op_code in GomspaceOpCodes.REQUEST_CORE_HK_ONCE: + q.add_log_cmd(f"PDU2: {GsInfo.REQUEST_CORE_HK_ONCE}") + hk_sid = make_sid(object_id=PDU_2_HANDLER_ID, set_id=SetIds.PDU_2_CORE) + q.add_pus_tc(generate_one_diag_command(sid=hk_sid)) + if op_code in GomspaceOpCodes.REQUEST_AUX_HK_ONCE: + q.add_log_cmd(f"PDU2: {GsInfo.REQUEST_AUX_HK_ONCE}") + hk_sid = make_sid(object_id=PDU_2_HANDLER_ID, set_id=SetIds.PDU_2_AUX) + q.add_pus_tc(generate_one_hk_command(sid=hk_sid)) def pack_power_commands(q: DefaultPusQueueHelper, op_code: str): - if op_code in PowerOpCodes.TCS_ON: - object_id = PDU_1_HANDLER_ID - tcs_on_cmd(object_id, q) - if op_code in PowerOpCodes.TCS_OFF: - object_id = PDU_1_HANDLER_ID - tcs_off_cmd(object_id, q) - if op_code in PowerOpCodes.STAR_TRACKER_ON: - object_id = PDU_1_HANDLER_ID - tcs_on_cmd(object_id, q) + pdu1_cmds(q, op_code) + pdu2_cmds(q, op_code) + if op_code in PowerOpCodes.INFO_CORE: + pdu1_req_hk_cmds(q, GomspaceOpCodes.REQUEST_CORE_HK_ONCE[0]) + pdu2_req_hk_cmds(q, GomspaceOpCodes.REQUEST_CORE_HK_ONCE[0]) + q.add_wait_seconds(3.0) + elif op_code in PowerOpCodes.INFO_AUX: + pdu1_req_hk_cmds(q, GomspaceOpCodes.REQUEST_AUX_HK_ONCE[0]) + pdu2_req_hk_cmds(q, GomspaceOpCodes.REQUEST_AUX_HK_ONCE[0]) + q.add_wait_seconds(3.0) + elif op_code in PowerOpCodes.INFO_ALL: + pdu1_req_hk_cmds(q, GomspaceOpCodes.REQUEST_CORE_HK_ONCE[0]) + pdu2_req_hk_cmds(q, GomspaceOpCodes.REQUEST_CORE_HK_ONCE[0]) + pdu1_req_hk_cmds(q, GomspaceOpCodes.REQUEST_AUX_HK_ONCE[0]) + pdu2_req_hk_cmds(q, GomspaceOpCodes.REQUEST_AUX_HK_ONCE[0]) + q.add_wait_seconds(3.0) -def tcs_on_cmd(object_id: ObjectIdU32, q: DefaultPusQueueHelper): - generic_on_cmd(object_id, q, "PDU1: Turn TCS board on", 0) +def tcs_on_cmd(q: DefaultPusQueueHelper): + generic_on_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.TCS, Pdu1ChIndex.TCS) -def tcs_off_cmd(object_id: ObjectIdU32, q: DefaultPusQueueHelper): - generic_off_cmd(object_id, q, "PDU1: Turn TCS board off", 0) +def tcs_off_cmd(q: DefaultPusQueueHelper): + generic_off_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.TCS, Pdu1ChIndex.TCS) -def str_on_cmd(object_id: ObjectIdU32, q: DefaultPusQueueHelper): - generic_on_cmd(object_id, q, "PDU1: Turn Star Tracker on", 2) +def syrlinks_on_cmd(q: DefaultPusQueueHelper): + generic_on_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.SYRLINKS, Pdu1ChIndex.SYRLINKS) -def str_off_cmd(object_id: ObjectIdU32, q: DefaultPusQueueHelper): - generic_off_cmd(object_id, q, "PDU1: Turn Star Tracker off", 2) +def syrlinks_off_cmd(q: DefaultPusQueueHelper): + generic_off_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.SYRLINKS, Pdu1ChIndex.SYRLINKS) + + +def startracker_on_cmd(q: DefaultPusQueueHelper): + generic_on_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.STR, Pdu1ChIndex.STR) + + +def startracker_off_cmd(q: DefaultPusQueueHelper): + generic_off_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.STR, Pdu1ChIndex.STR) + + +def mgt_on_cmd(q: DefaultPusQueueHelper): + generic_on_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.MGT, Pdu1ChIndex.MGT) + + +def mgt_off_cmd(q: DefaultPusQueueHelper): + generic_off_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.MGT, Pdu1ChIndex.MGT) + + +def sun_sensor_nominal_on_cmd(q: DefaultPusQueueHelper): + generic_on_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.SUS_N, 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) + + +def solar_cell_experiment_on_cmd(q: DefaultPusQueueHelper): + generic_on_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.SCEX, Pdu1ChIndex.SCEX) + + +def solar_cell_experiment_off_cmd(q: DefaultPusQueueHelper): + generic_off_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.SCEX, Pdu1ChIndex.SCEX) + + +def ploc_on_cmd(q: DefaultPusQueueHelper): + generic_on_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.PLOC, Pdu1ChIndex.PLOC) + + +def ploc_off_cmd(q: DefaultPusQueueHelper): + generic_off_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.PLOC, Pdu1ChIndex.PLOC) + + +def acs_board_a_on_cmd(q: DefaultPusQueueHelper): + generic_on_cmd(PDU_1_HANDLER_ID, q, Pdu1InfoBase.ACS_A, 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) + + +def pl_pcdu_bat_nom_on_cmd(q: DefaultPusQueueHelper): + generic_on_cmd( + PDU_2_HANDLER_ID, q, Pdu2InfoBase.PL_PCDU_BAT_NOM, Pdu2ChIndex.PL_PCDU_BAT_NOM + ) + + +def pl_pcdu_bat_nom_off_cmd(q: DefaultPusQueueHelper): + generic_off_cmd( + PDU_2_HANDLER_ID, q, Pdu2InfoBase.PL_PCDU_BAT_NOM, Pdu2ChIndex.PL_PCDU_BAT_NOM + ) + + +def reaction_wheel_on_cmd(q: DefaultPusQueueHelper): + generic_on_cmd(PDU_2_HANDLER_ID, q, Pdu2InfoBase.RW, Pdu2ChIndex.RW) + + +def reaction_wheel_off_cmd(q: DefaultPusQueueHelper): + generic_off_cmd(PDU_2_HANDLER_ID, q, Pdu2InfoBase.RW, Pdu2ChIndex.RW) + + +def heater_on_cmd(q: DefaultPusQueueHelper): + generic_on_cmd(PDU_2_HANDLER_ID, q, Pdu2InfoBase.HEATER, Pdu2ChIndex.HEATER) + + +def heater_off_cmd(q: DefaultPusQueueHelper): + generic_off_cmd(PDU_2_HANDLER_ID, q, Pdu2InfoBase.HEATER, Pdu2ChIndex.HEATER) + + +def sus_red_on_cmd(q: DefaultPusQueueHelper): + generic_on_cmd(PDU_2_HANDLER_ID, q, Pdu2InfoBase.SUS_R, Pdu2ChIndex.SUS_R) + + +def sus_red_off_cmd(q: DefaultPusQueueHelper): + generic_off_cmd(PDU_2_HANDLER_ID, q, Pdu2InfoBase.SUS_R, Pdu2ChIndex.SUS_R) + + +def solar_array_deployment_on_cmd(q: DefaultPusQueueHelper): + generic_on_cmd( + PDU_2_HANDLER_ID, q, Pdu2InfoBase.SOLAR_ARRAY_DEPL, Pdu2ChIndex.SOLAR_ARRAY_DEPL + ) + + +def solar_array_deployment_off_cmd(q: DefaultPusQueueHelper): + generic_off_cmd( + PDU_2_HANDLER_ID, q, Pdu2InfoBase.SOLAR_ARRAY_DEPL, Pdu2ChIndex.SOLAR_ARRAY_DEPL + ) + + +def pl_pcdu_bat_red_on_cmd(q: DefaultPusQueueHelper): + generic_on_cmd( + PDU_2_HANDLER_ID, q, Pdu2InfoBase.PL_PCDU_BAT_RED, Pdu2ChIndex.PL_PCDU_BAT_RED + ) + + +def pl_pcdu_bat_red_off_cmd(q: DefaultPusQueueHelper): + generic_off_cmd( + PDU_2_HANDLER_ID, q, Pdu2InfoBase.PL_PCDU_BAT_RED, Pdu2ChIndex.PL_PCDU_BAT_RED + ) + + +def acs_board_b_side_on_cmd(q: DefaultPusQueueHelper): + generic_on_cmd(PDU_2_HANDLER_ID, q, Pdu2InfoBase.ACS_B, Pdu2ChIndex.ACS_B) + + +def acs_board_b_side_off_cmd(q: DefaultPusQueueHelper): + generic_off_cmd(PDU_2_HANDLER_ID, q, Pdu2InfoBase.ACS_B, Pdu2ChIndex.ACS_B) + + +def payload_camera_on_cmd(q: DefaultPusQueueHelper): + generic_on_cmd(PDU_2_HANDLER_ID, q, Pdu2InfoBase.PL_CAM, Pdu2ChIndex.PL_CAM) + + +def payload_camera_off_cmd(q: DefaultPusQueueHelper): + generic_off_cmd(PDU_2_HANDLER_ID, q, Pdu2InfoBase.PL_CAM, Pdu2ChIndex.PL_CAM) def generic_on_cmd( - object_id: ObjectIdU32, q: DefaultPusQueueHelper, info_str: str, out_idx: int + object_id: bytes, q: DefaultPusQueueHelper, info_str: str, out_idx: int ): - q.add_log_cmd(info_str) + q.add_log_cmd(info_str + " on") q.add_pus_tc( pack_set_param_command( - object_id.as_bytes, + object_id, PDU_CONFIG_LIST[out_idx].parameter_address, PDU_CONFIG_LIST[out_idx].parameter_size, Channel.on, @@ -94,12 +448,12 @@ def generic_on_cmd( def generic_off_cmd( - object_id: ObjectIdU32, q: DefaultPusQueueHelper, info_str: str, out_idx: int + object_id: bytes, q: DefaultPusQueueHelper, info_str: str, out_idx: int ): - q.add_log_cmd(info_str) + q.add_log_cmd(info_str + " off") q.add_pus_tc( pack_set_param_command( - object_id.as_bytes, + object_id, PDU_CONFIG_LIST[out_idx].parameter_address, PDU_CONFIG_LIST[out_idx].parameter_size, Channel.off, diff --git a/pus_tc/devs/p60dock.py b/pus_tc/devs/p60dock.py index b668df7..6c95d28 100644 --- a/pus_tc/devs/p60dock.py +++ b/pus_tc/devs/p60dock.py @@ -19,7 +19,7 @@ class P60OpCodes: TEST = ["test", "0"] -class Info: +class P60Info: PREFIX = "P60 Dock" STACK_3V3_ON = f"{PREFIX}: Turn Stack 3V3 on" STACK_3V3_OFF = f"{PREFIX}: Turn Stack 3V3 off" @@ -85,7 +85,7 @@ class P60DockHkTable: def pack_p60dock_cmds(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str): objb = object_id.as_bytes if op_code in P60OpCodes.STACK_3V3_ON: - q.add_log_cmd(Info.STACK_3V3_ON) + q.add_log_cmd(GsInfo.STACK_3V3_ON) q.add_pus_tc( pack_set_param_command( objb, @@ -95,7 +95,7 @@ def pack_p60dock_cmds(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: ) ) if op_code in P60OpCodes.STACK_3V3_OFF: - q.add_log_cmd(Info.STACK_3V3_OFF) + q.add_log_cmd(GsInfo.STACK_3V3_OFF) q.add_pus_tc( pack_set_param_command( objb, @@ -105,7 +105,7 @@ def pack_p60dock_cmds(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: ) ) if op_code in P60OpCodes.STACK_5V_ON: - q.add_log_cmd(Info.STACK_5V_ON) + q.add_log_cmd(GsInfo.STACK_5V_ON) q.add_pus_tc( pack_set_param_command( objb, @@ -115,7 +115,7 @@ def pack_p60dock_cmds(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: ) ) if op_code in P60OpCodes.STACK_5V_OFF: - q.add_log_cmd(Info.STACK_5V_OFF) + q.add_log_cmd(GsInfo.STACK_5V_OFF) q.add_pus_tc( pack_set_param_command( objb, diff --git a/pus_tc/devs/pdu1.py b/pus_tc/devs/pdu1.py index 19b965d..4662b0e 100644 --- a/pus_tc/devs/pdu1.py +++ b/pus_tc/devs/pdu1.py @@ -4,7 +4,7 @@ @date 17.12.2020 """ import gomspace.gomspace_common as gs -from pus_tc.devs.common_power import tcs_on_cmd, tcs_off_cmd +from pus_tc.devs.common_power import pdu1_cmds, pdu1_req_hk_cmds from tmtccmd.tc import DefaultPusQueueHelper from tmtccmd.tc.pus_3_fsfw_hk import ( @@ -17,28 +17,6 @@ from gomspace.gomspace_pdu_definitions import * from config.object_ids import PDU_1_HANDLER_ID -class Pdu1OpCodes: - TCS_BOARD_ON = ["tcs-on", "0"] - TCS_BOARD_OFF = ["tcs-off", "1"] - STAR_TRACKER_ON = ["str-on", "2"] - STAR_TRACKER_OFF = ["str-off", "3"] - SUS_NOMINAL_ON = ["sus-nom-on", "4"] - SUS_NOMINAL_OFF = ["sum-nom-off", "5"] - ACS_A_SIDE_ON = ["acs-a-on", "6"] - ACS_A_SIDE_OFF = ["acs-a-off", "7"] - SYRLINKS_ON = ["syrlinks-on", "8"] - SYRLINKS_OFF = ["syrlinks-off", "9"] - MGT_ON = ["mgt-on", "10"] - MGT_OFF = ["mgt-off", "11"] - # Solar Cell Experiment - SCEX_ON = ["scex-on", "12"] - SCEX_OFF = ["scex-off", "13"] - PLOC_ON = ["ploc-on", "14"] - PLOC_OFF = ["ploc-off", "15"] - - TESTS = "32" - - class PDU1TestProcedure: """ @brief Use this class to define the tests to perform for the PDU2. @@ -59,168 +37,8 @@ class PDU1TestProcedure: def pack_pdu1_commands(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str): q.add_log_cmd("Commanding PDU1") objb = object_id.as_bytes - if op_code in Pdu1OpCodes.TCS_BOARD_ON: - tcs_on_cmd(object_id, q) - if op_code in Pdu1OpCodes.TCS_BOARD_OFF: - tcs_off_cmd(object_id, q) - if op_code in Pdu1OpCodes.STAR_TRACKER_ON: - q.add_log_cmd("PDU1: Turn star tracker on") - q.add_pus_tc( - pack_set_param_command( - objb, - PduConfigTable.out_en_2.parameter_address, - PduConfigTable.out_en_2.parameter_size, - Channel.on, - ) - ) - if op_code in Pdu1OpCodes.STAR_TRACKER_OFF: - q.add_log_cmd("PDU1: Turn star tracker off") - q.add_pus_tc( - pack_set_param_command( - objb, - PduConfigTable.out_en_2.parameter_address, - PduConfigTable.out_en_2.parameter_size, - Channel.off, - ) - ) - if op_code in Pdu1OpCodes.SUS_NOMINAL_ON: - q.add_log_cmd("PDU1: Turn SUS nominal on") - q.add_pus_tc( - pack_set_param_command( - objb, - PduConfigTable.out_en_4.parameter_address, - PduConfigTable.out_en_4.parameter_size, - Channel.on, - ) - ) - if op_code in Pdu1OpCodes.SUS_NOMINAL_OFF: - q.add_log_cmd("PDU1: Turn SUS nominal off") - q.add_pus_tc( - pack_set_param_command( - objb, - PduConfigTable.out_en_4.parameter_address, - PduConfigTable.out_en_4.parameter_size, - Channel.off, - ) - ) - if op_code in Pdu1OpCodes.ACS_A_SIDE_ON: - q.add_log_cmd("PDU1: Turn ACS Side A on") - q.add_pus_tc( - pack_set_param_command( - objb, - PduConfigTable.out_en_7.parameter_address, - PduConfigTable.out_en_7.parameter_size, - Channel.on, - ) - ) - if op_code in Pdu1OpCodes.ACS_A_SIDE_OFF: - q.add_log_cmd("PDU1: Turn ACS Side A off") - q.add_pus_tc( - pack_set_param_command( - objb, - PduConfigTable.out_en_7.parameter_address, - PduConfigTable.out_en_7.parameter_size, - Channel.off, - ) - ) - if op_code in Pdu1OpCodes.SUS_NOMINAL_OFF: - q.add_log_cmd("PDU1: Turn SUS nominal off") - q.add_pus_tc( - pack_set_param_command( - objb, - PduConfigTable.out_en_4.parameter_address, - PduConfigTable.out_en_4.parameter_size, - Channel.off, - ) - ) - if op_code in Pdu1OpCodes.SCEX_ON: - q.add_log_cmd("PDU1: Turn Solar Cell Experiment on") - q.add_pus_tc( - pack_set_param_command( - objb, - PduConfigTable.out_en_5.parameter_address, - PduConfigTable.out_en_5.parameter_size, - Channel.on, - ) - ) - if op_code in Pdu1OpCodes.SCEX_OFF: - q.add_log_cmd("PDU1: Turn Solar Cell Experiment off") - q.add_pus_tc( - pack_set_param_command( - objb, - PduConfigTable.out_en_5.parameter_address, - PduConfigTable.out_en_5.parameter_size, - Channel.off, - ) - ) - if op_code in Pdu1OpCodes.SYRLINKS_ON: - q.add_log_cmd("PDU1: Turn Syrlinks on") - q.add_pus_tc( - pack_set_param_command( - objb, - PduConfigTable.out_en_1.parameter_address, - PduConfigTable.out_en_1.parameter_size, - Channel.on, - ) - ) - if op_code in Pdu1OpCodes.SYRLINKS_OFF: - q.add_log_cmd("PDU1: Turn Syrlinks off") - q.add_pus_tc( - pack_set_param_command( - objb, - PduConfigTable.out_en_1.parameter_address, - PduConfigTable.out_en_1.parameter_size, - Channel.off, - ) - ) - if op_code in Pdu1OpCodes.MGT_ON: - q.add_log_cmd("PDU1: Turn MGT on") - q.add_pus_tc( - pack_set_param_command( - objb, - PduConfigTable.out_en_3.parameter_address, - PduConfigTable.out_en_3.parameter_size, - Channel.on, - ) - ) - if op_code in Pdu1OpCodes.MGT_OFF: - q.add_log_cmd("PDU1: Turn MGT off") - q.add_pus_tc( - pack_set_param_command( - objb, - PduConfigTable.out_en_3.parameter_address, - PduConfigTable.out_en_3.parameter_size, - Channel.off, - ) - ) - if op_code in Pdu1OpCodes.PLOC_ON: - q.add_log_cmd("PDU1: Turn PLOC on") - q.add_pus_tc( - pack_set_param_command( - objb, - PduConfigTable.out_en_6.parameter_address, - PduConfigTable.out_en_6.parameter_size, - Channel.on, - ) - ) - if op_code in Pdu1OpCodes.PLOC_OFF: - q.add_log_cmd("PDU1: Turn PLOC off") - q.add_pus_tc( - pack_set_param_command( - objb, - PduConfigTable.out_en_6.parameter_address, - PduConfigTable.out_en_6.parameter_size, - Channel.off, - ) - ) - if op_code in GomspaceOpCodes.REQUEST_CORE_HK_ONCE: - q.add_log_cmd(f"PDU1: {Info.REQUEST_CORE_HK_ONCE}") - hk_sid = make_sid(object_id=PDU_1_HANDLER_ID, set_id=SetIds.PDU_1_CORE) - q.add_pus_tc(generate_one_diag_command(sid=hk_sid)) - if op_code in GomspaceOpCodes.REQUEST_AUX_HK_ONCE: - q.add_log_cmd(f"PDU1: {Info.REQUEST_AUX_HK_ONCE}") - hk_sid = make_sid(object_id=PDU_1_HANDLER_ID, set_id=SetIds.PDU_1_AUX) - q.add_pus_tc(generate_one_hk_command(sid=hk_sid)) + pdu1_cmds(q, op_code) + pdu1_req_hk_cmds(q, op_code) if op_code in GomspaceOpCodes.PRINT_SWITCH_V_I: q.add_log_cmd("PDU1: Print Switches, Voltages, Currents") q.add_pus_tc( @@ -290,7 +108,7 @@ def pack_pdu1_commands(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code ) ) if op_code in GomspaceOpCodes.SET_PARAM: - q.add_log_cmd(f"PDU1: {Info.SET_PARAMETER}") + q.add_log_cmd(f"PDU1: {GsInfo.SET_PARAMETER}") memory_address = int(input("Specify memory address: 0x"), 16) memory_address = struct.pack("!H", memory_address) parameter_size = int(input("Specify parameter size: ")) diff --git a/pus_tc/devs/pdu2.py b/pus_tc/devs/pdu2.py index a5a8009..6ccd49d 100644 --- a/pus_tc/devs/pdu2.py +++ b/pus_tc/devs/pdu2.py @@ -12,34 +12,12 @@ from tmtccmd.tc.pus_3_fsfw_hk import ( generate_one_diag_command, make_sid, ) +from pus_tc.devs.common_power import pdu2_cmds, pdu2_req_hk_cmds from gomspace.gomspace_common import * from gomspace.gomspace_pdu_definitions import * from config.object_ids import PDU_2_HANDLER_ID -class Pdu2OpCodes: - ACS_SIDE_B_ON = ["acs-b-on", "1"] - ACS_SIDE_B_OFF = ["acs-b-off", "2"] - SUS_REDUNDANT_ON = ["sus-red-on", "3"] - SUS_REDUNDANT_OFF = ["sus-red-off", "4"] - RW_ON = ["rw-on", "5"] - RW_OFF = ["rw-off", "6"] - PL_PCDU_VBAT_NOM_ON = ["plpcdu-vbat-nom-on", "7"] - PL_PCDU_VBAT_NOM_OFF = ["plpcdu-vbat-nom-off", "8"] - PL_PCDU_VBAT_RED_ON = ["plpcdu-vbat-red-on", "9"] - PL_PCDU_VBAT_RED_OFF = ["plpcdu-vbt-red-off", "10"] - TCS_HEATER_IN_ON = ["tcs-heater-in-on", "11"] - TCS_HEATER_IN_OFF = ["tcs-heater-in-off", "12"] - SOLAR_ARRAY_DEPL_ON = ["sa-depl-on", "13"] - SOLAR_ARRAY_DEPL_OFF = ["sa-depl-off", "14"] - PL_CAMERA_ON = ["pl-cam-on", "15"] - PL_CAMERA_OFF = ["pl-cam-off", "16"] - # There is not really a point of the on command, the SW can not be commanded if the OBC is off. - # Actually, this command is dangerous and will probably be rejected by the OBC unless - # specifically configured to not reject it. - Q7S_OFF = "32" - - class PDU2TestProcedure: """ @brief Use this class to define the tests to perform for the PDU2. @@ -70,186 +48,10 @@ class PDU2TestProcedure: def pack_pdu2_commands(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str): q.add_log_cmd("Testing PDU2") objb = object_id.as_bytes - if op_code in Pdu2OpCodes.ACS_SIDE_B_ON: - q.add_log_cmd("PDU2: Turn ACS Side B on") - q.add_pus_tc( - pack_set_param_command( - objb, - PduConfigTable.out_en_7.parameter_address, - PduConfigTable.out_en_7.parameter_size, - Channel.on, - ) - ) - if op_code in Pdu2OpCodes.ACS_SIDE_B_OFF: - q.add_log_cmd("PDU2: Turn ACS Side B off") - q.add_pus_tc( - pack_set_param_command( - objb, - PduConfigTable.out_en_7.parameter_address, - PduConfigTable.out_en_7.parameter_size, - Channel.off, - ) - ) - if op_code in Pdu2OpCodes.Q7S_OFF: - q.add_log_cmd("Turning off Q7S OBC") - q.add_pus_tc( - pack_set_param_command( - objb, - PduConfigTable.out_en_0.parameter_address, - PduConfigTable.out_en_0.parameter_size, - Channel.off, - ) - ) - if op_code in Pdu2OpCodes.SUS_REDUNDANT_ON: - q.add_log_cmd("PDU2: Turn SUS redundant on") - q.add_pus_tc( - pack_set_param_command( - objb, - PduConfigTable.out_en_4.parameter_address, - PduConfigTable.out_en_4.parameter_size, - Channel.on, - ) - ) - if op_code in Pdu2OpCodes.SUS_REDUNDANT_OFF: - q.add_log_cmd("PDU2: Turn SUS redundant off") - q.add_pus_tc( - pack_set_param_command( - objb, - PduConfigTable.out_en_4.parameter_address, - PduConfigTable.out_en_4.parameter_size, - Channel.off, - ) - ) - if op_code in Pdu2OpCodes.RW_ON: - q.add_log_cmd("PDU2: Turn reaction wheels on") - q.add_pus_tc( - pack_set_param_command( - objb, - PduConfigTable.out_en_2.parameter_address, - PduConfigTable.out_en_2.parameter_size, - Channel.on, - ) - ) - if op_code in Pdu2OpCodes.RW_OFF: - q.add_log_cmd("PDU2: Turn reaction wheels off") - q.add_pus_tc( - pack_set_param_command( - objb, - PduConfigTable.out_en_2.parameter_address, - PduConfigTable.out_en_2.parameter_size, - Channel.off, - ) - ) - if op_code in Pdu2OpCodes.PL_PCDU_VBAT_NOM_ON: - q.add_log_cmd("PDU2: Turn PDU2 PL PCDU Channel 1 on") - q.add_pus_tc( - pack_set_param_command( - objb, - PduConfigTable.out_en_1.parameter_address, - PduConfigTable.out_en_1.parameter_size, - Channel.on, - ) - ) - if op_code in Pdu2OpCodes.PL_PCDU_VBAT_NOM_OFF: - q.add_log_cmd("PDU2: Turn PDU2 PL PCDU Channel 1 off") - q.add_pus_tc( - pack_set_param_command( - objb, - PduConfigTable.out_en_1.parameter_address, - PduConfigTable.out_en_1.parameter_size, - Channel.off, - ) - ) - if op_code in Pdu2OpCodes.PL_PCDU_VBAT_RED_ON: - q.add_log_cmd("PDU2: Turn PDU2 PL PCDU Channel 6 on") - q.add_pus_tc( - pack_set_param_command( - objb, - PduConfigTable.out_en_6.parameter_address, - PduConfigTable.out_en_6.parameter_size, - Channel.off, - ) - ) - if op_code in Pdu2OpCodes.PL_PCDU_VBAT_RED_OFF: - q.add_log_cmd("PDU2: Turn PDU2 PL PCDU Channel 6 off") - q.add_pus_tc( - pack_set_param_command( - objb, - PduConfigTable.out_en_6.parameter_address, - PduConfigTable.out_en_6.parameter_size, - Channel.off, - ) - ) - if op_code in Pdu2OpCodes.TCS_HEATER_IN_ON: - q.add_log_cmd("PDU2: Turn TCS Heater Input on") - q.add_pus_tc( - pack_set_param_command( - objb, - PduConfigTable.out_en_3.parameter_address, - PduConfigTable.out_en_3.parameter_size, - Channel.on, - ) - ) - if op_code in Pdu2OpCodes.TCS_HEATER_IN_OFF: - q.add_log_cmd("PDU2: Turn TCS Heater Input off") - q.add_pus_tc( - pack_set_param_command( - objb, - PduConfigTable.out_en_3.parameter_address, - PduConfigTable.out_en_3.parameter_size, - Channel.off, - ) - ) - if op_code in Pdu2OpCodes.SOLAR_ARRAY_DEPL_ON: - q.add_log_cmd("PDU2: Turn Solar Array Deployment On") - q.add_pus_tc( - pack_set_param_command( - objb, - PduConfigTable.out_en_5.parameter_address, - PduConfigTable.out_en_5.parameter_size, - Channel.on, - ) - ) - if op_code in Pdu2OpCodes.SOLAR_ARRAY_DEPL_OFF: - q.add_log_cmd("PDU2: Turn Solar Array Deployment Off") - q.add_pus_tc( - pack_set_param_command( - objb, - PduConfigTable.out_en_5.parameter_address, - PduConfigTable.out_en_5.parameter_size, - Channel.off, - ) - ) - if op_code in Pdu2OpCodes.PL_CAMERA_ON: - q.add_log_cmd("PDU2: Turn payload camera on") - q.add_pus_tc( - pack_set_param_command( - objb, - PduConfigTable.out_en_8.parameter_address, - PduConfigTable.out_en_8.parameter_size, - Channel.on, - ) - ) - if op_code in Pdu2OpCodes.PL_CAMERA_OFF: - q.add_log_cmd("PDU2: Turn payload camera off") - q.add_pus_tc( - pack_set_param_command( - objb, - PduConfigTable.out_en_8.parameter_address, - PduConfigTable.out_en_8.parameter_size, - Channel.off, - ) - ) - if op_code in GomspaceOpCodes.REQUEST_CORE_HK_ONCE: - q.add_log_cmd(f"PDU2: {Info.REQUEST_CORE_HK_ONCE}") - hk_sid = make_sid(object_id=PDU_2_HANDLER_ID, set_id=SetIds.PDU_2_CORE) - q.add_pus_tc(generate_one_diag_command(sid=hk_sid)) - if op_code in GomspaceOpCodes.REQUEST_AUX_HK_ONCE: - q.add_log_cmd(f"PDU2: {Info.REQUEST_AUX_HK_ONCE}") - hk_sid = make_sid(object_id=PDU_2_HANDLER_ID, set_id=SetIds.PDU_2_AUX) - q.add_pus_tc(generate_one_hk_command(sid=hk_sid)) + pdu2_cmds(q, op_code) + pdu2_req_hk_cmds(q, op_code) if op_code in GomspaceOpCodes.PRINT_SWITCH_V_I: - q.add_log_cmd("PDU2: Print Switches, Currents, Voltahes") + q.add_log_cmd(f"PDU2: {GsInfo.PRINT_SWITCH_V_I}") q.add_pus_tc( generate_action_command( object_id=objb, action_id=GomspaceDeviceActionIds.PRINT_SWITCH_V_I diff --git a/pus_tc/devs/plpcdu.py b/pus_tc/devs/plpcdu.py index 8410d83..bce1de7 100644 --- a/pus_tc/devs/plpcdu.py +++ b/pus_tc/devs/plpcdu.py @@ -225,7 +225,6 @@ def hpa_on_procedure(q: DefaultPusQueueHelper): f"Starting procedure to switch on PL PCDU HPA with DRO to X8 " f"delay of {delay_dro_to_x8} seconds" ) - q.add_pus_tc(generate_enable_tc_sched_cmd()) pl_pcdu_on = PusTelecommand( service=200, subservice=Subservices.TC_MODE_COMMAND, diff --git a/pus_tc/devs/power.py b/pus_tc/devs/power.py index 1dc4aa5..e67d1dc 100644 --- a/pus_tc/devs/power.py +++ b/pus_tc/devs/power.py @@ -1,20 +1,25 @@ -from pus_tc.devs.pdu1 import Pdu1OpCodes -from pus_tc.devs.pdu2 import Pdu2OpCodes - +from gomspace.gomspace_common import GsInfo +from pus_tc.devs.common_power import ( + PowerOpCodes, + Pdu1InfoBase, + Pdu2InfoBase, + add_pdu1_common_defs, + add_pdu2_common_defs, + PowerInfo, +) from config.definitions import CustomServiceList from tmtccmd.config import TmTcDefWrapper, OpCodeEntry -from pus_tc.devs.p60dock import P60OpCodes, GomspaceOpCodes, Info +from pus_tc.devs.p60dock import P60OpCodes, GomspaceOpCodes, P60Info from pus_tc.devs.acu import add_acu_cmds -from gomspace.gomspace_common import Info as GsInfo def add_p60_cmds(defs: TmTcDefWrapper): oce = OpCodeEntry() - oce.add(keys=P60OpCodes.STACK_3V3_ON, info=Info.STACK_3V3_ON) - oce.add(keys=P60OpCodes.STACK_3V3_OFF, info=Info.STACK_3V3_OFF) - oce.add(keys=P60OpCodes.STACK_5V_ON, info=Info.STACK_5V_ON) - oce.add(keys=P60OpCodes.STACK_5V_OFF, info=Info.STACK_5V_OFF) + oce.add(keys=P60OpCodes.STACK_3V3_ON, info=P60Info.STACK_3V3_ON) + oce.add(keys=P60OpCodes.STACK_3V3_OFF, info=P60Info.STACK_3V3_OFF) + oce.add(keys=P60OpCodes.STACK_5V_ON, info=P60Info.STACK_5V_ON) + oce.add(keys=P60OpCodes.STACK_5V_OFF, info=P60Info.STACK_5V_OFF) oce.add(keys=GomspaceOpCodes.REQUEST_CORE_HK_ONCE, info=GsInfo.REQUEST_CORE_HK_ONCE) oce.add(keys=GomspaceOpCodes.REQUEST_AUX_HK_ONCE, info=GsInfo.REQUEST_AUX_HK_ONCE) oce.add( @@ -28,24 +33,23 @@ def add_p60_cmds(defs: TmTcDefWrapper): ) +def add_power_cmd_defs(defs: TmTcDefWrapper): + oce = OpCodeEntry() + add_pdu1_common_defs(oce) + add_pdu2_common_defs(oce) + oce.add(keys=PowerOpCodes.INFO_ALL, info=PowerInfo.INFO_ALL) + oce.add(keys=PowerOpCodes.INFO_CORE, info=PowerInfo.INFO_CORE) + oce.add(keys=PowerOpCodes.INFO_AUX, info=PowerInfo.INFO_AUX) + defs.add_service( + name=CustomServiceList.POWER.value, + info="Power Subsystem", + op_code_entry=oce, + ) + + def add_pdu1_cmds(defs: TmTcDefWrapper): oce = OpCodeEntry() - oce.add(keys=Pdu1OpCodes.TCS_BOARD_ON, info="PDU1: Turn TCS board on") - oce.add(keys=Pdu1OpCodes.TCS_BOARD_OFF, info="PDU1: Turn TCS board off") - oce.add(keys=Pdu1OpCodes.STAR_TRACKER_ON, info="PDU1: Turn star tracker on") - oce.add(keys=Pdu1OpCodes.STAR_TRACKER_OFF, info="PDU1: Turn star tracker off") - oce.add(keys=Pdu1OpCodes.SUS_NOMINAL_ON, info="PDU1: Turn SUS nominal on") - oce.add(keys=Pdu1OpCodes.SUS_NOMINAL_OFF, info="PDU1: Turn SUS nominal off") - oce.add(keys=Pdu1OpCodes.ACS_A_SIDE_ON, info="PDU1: Turn ACS A side on") - oce.add(keys=Pdu1OpCodes.ACS_A_SIDE_OFF, info="PDU1: Turn ACS A side off") - oce.add(keys=Pdu1OpCodes.SYRLINKS_ON, info="PDU1: Turn Syrlinks on") - oce.add(keys=Pdu1OpCodes.SYRLINKS_OFF, info="PDU1: Turn Syrlinks off") - oce.add(keys=Pdu1OpCodes.MGT_ON, info="PDU1: Turn MGT on") - oce.add(keys=Pdu1OpCodes.MGT_OFF, info="PDU1: Turn MGT off") - oce.add(keys=Pdu1OpCodes.PLOC_ON, info="PDU1: Turn PLOC on") - oce.add(keys=Pdu1OpCodes.PLOC_OFF, info="PDU1: Turn PLOC off") - oce.add(keys=Pdu1OpCodes.SCEX_ON, info="PDU1: Turn Solar Cell Experiment on") - oce.add(keys=Pdu1OpCodes.SCEX_OFF, info="PDU1: Turn Solar Cell Experiment off") + add_pdu1_common_defs(oce) oce.add(keys=GomspaceOpCodes.REQUEST_CORE_HK_ONCE, info=GsInfo.REQUEST_CORE_HK_ONCE) oce.add(keys=GomspaceOpCodes.REQUEST_AUX_HK_ONCE, info=GsInfo.REQUEST_AUX_HK_ONCE) oce.add( @@ -53,7 +57,6 @@ def add_pdu1_cmds(defs: TmTcDefWrapper): info="PDU1: Print Switches, Voltages, Currents", ) oce.add(keys=GomspaceOpCodes.PRINT_LATCHUPS, info="PDU1: Print Latchups") - oce.add(keys=Pdu1OpCodes.TESTS, info="PDU1 Tests") oce.add(keys=GomspaceOpCodes.SET_PARAM, info="Set parameter") defs.add_service( name=CustomServiceList.PDU1.value, @@ -64,53 +67,7 @@ def add_pdu1_cmds(defs: TmTcDefWrapper): def add_pdu2_cmds(defs: TmTcDefWrapper): oce = OpCodeEntry() - oce.add(keys="0", info="PDU2 Tests") - oce.add(keys=Pdu2OpCodes.ACS_SIDE_B_ON, info="PDU2: Turn ACS Side B on") - oce.add(keys=Pdu2OpCodes.ACS_SIDE_B_OFF, info="PDU2: Turn ACS Side B off") - oce.add(keys=Pdu2OpCodes.SUS_REDUNDANT_ON, info="PDU2: Turn SUS redundant on") - oce.add(keys=Pdu2OpCodes.SUS_REDUNDANT_OFF, info="PDU2: Turn SUS redundant off") - oce.add(keys=Pdu2OpCodes.RW_ON, info="PDU2: Turn reaction wheels on") - oce.add(keys=Pdu2OpCodes.RW_OFF, info="PDU2: Turn reaction wheels off") - oce.add( - keys=Pdu2OpCodes.PL_PCDU_VBAT_NOM_ON, - info="PDU2: PL PCDU Switch Channel Nominal (1) on", - ) - oce.add( - keys=Pdu2OpCodes.PL_PCDU_VBAT_NOM_OFF, - info="PDU2: PL PCDU Switch Channel Nominal (1) off", - ) - oce.add( - keys=Pdu2OpCodes.PL_PCDU_VBAT_RED_ON, - info="PDU2: PL PCDU Switch Channel Redundant (1) on", - ) - oce.add( - keys=Pdu2OpCodes.PL_PCDU_VBAT_RED_OFF, - info="PDU2: PL PCDU Switch Channel Redundant (1) off", - ) - oce.add( - keys=Pdu2OpCodes.TCS_HEATER_IN_ON, - info="PDU2: Switch TCS Heater Input on", - ) - oce.add( - keys=Pdu2OpCodes.TCS_HEATER_IN_OFF, - info="PDU2: Switch TCS Heater Input off", - ) - oce.add( - keys=Pdu2OpCodes.SOLAR_ARRAY_DEPL_ON, - info="PDU2: Switch Solar Array Deployment On", - ) - oce.add( - keys=Pdu2OpCodes.SOLAR_ARRAY_DEPL_OFF, - info="PDU2: Switch Solar Array Deployment Off", - ) - oce.add( - keys=Pdu2OpCodes.PL_CAMERA_ON, - info="PDU2: Turn payload camera on", - ) - oce.add( - keys=Pdu2OpCodes.PL_CAMERA_OFF, - info="PDU2: Turn payload camera off", - ) + add_pdu2_common_defs(oce) oce.add( keys=GomspaceOpCodes.REQUEST_CORE_HK_ONCE, info=GsInfo.REQUEST_CORE_HK_ONCE, diff --git a/pus_tc/procedure_packer.py b/pus_tc/procedure_packer.py index 8218751..cd5e93c 100644 --- a/pus_tc/procedure_packer.py +++ b/pus_tc/procedure_packer.py @@ -2,6 +2,8 @@ """ from typing import cast +from pus_tc.devs.common_power import pack_power_commands +from pus_tc.devs.power import add_power_cmd_defs from pus_tc.devs.rtd import pack_rtd_commands from pus_tc.devs.scex import pack_scex_cmds from pus_tc.system.controllers import ( @@ -168,6 +170,8 @@ def handle_default_procedure( return pack_ploc_memory_dumper_cmd( object_id=object_id, q=queue_helper, op_code=op_code ) + if service == CustomServiceList.POWER.value: + return pack_power_commands(queue_helper, op_code) if service == CustomServiceList.ACS.value: return pack_acs_command(q=queue_helper, op_code=op_code) if service == CustomServiceList.GPS_CTRL.value: diff --git a/tmtcc.py b/tmtcc.py index 5c9fac3..d53ee74 100755 --- a/tmtcc.py +++ b/tmtcc.py @@ -217,9 +217,12 @@ def main(): LOGGER.info("TMTC Client in IDLE mode") time.sleep(3.0) elif state.request == BackendRequest.DELAY_LISTENER: - time.sleep(0.8) + time.sleep(0.5) elif state.request == BackendRequest.DELAY_CUSTOM: - time.sleep(state.next_delay.total_seconds()) + if state.next_delay.total_seconds() < 0.5: + time.sleep(state.next_delay.total_seconds()) + else: + time.sleep(0.5) elif state.request == BackendRequest.CALL_NEXT: pass except KeyboardInterrupt: