diff --git a/deps/tmtccmd b/deps/tmtccmd index 43a5e9e..bba516d 160000 --- a/deps/tmtccmd +++ b/deps/tmtccmd @@ -1 +1 @@ -Subproject commit 43a5e9ef3fa618c5296137dd76b4f25a1732b0f3 +Subproject commit bba516dd8920bf3accc10c5accbe697bb84c3789 diff --git a/gomspace/gomspace_pdu_definitions.py b/gomspace/gomspace_pdu_definitions.py index f695737..3f277b1 100644 --- a/gomspace/gomspace_pdu_definitions.py +++ b/gomspace/gomspace_pdu_definitions.py @@ -1,7 +1,7 @@ from gomspace.gomspace_common import TableEntry -class PDUConfigTable: +class PduConfigTable: out_en_0 = TableEntry(bytearray([0x00, 0x48]), TableEntry.uint8_size) out_en_1 = TableEntry(bytearray([0x00, 0x49]), TableEntry.uint8_size) out_en_2 = TableEntry(bytearray([0x00, 0x4A]), TableEntry.uint8_size) @@ -15,7 +15,19 @@ class PDUConfigTable: cur_lu_lim_0 = TableEntry(bytearray([0x00, 0xB8]), TableEntry.uint16_size) -class PDUHkTable: +PDU_CONFIG_LIST = [ + PduConfigTable.out_en_0, + PduConfigTable.out_en_1, + PduConfigTable.out_en_2, + PduConfigTable.out_en_3, + PduConfigTable.out_en_4, + PduConfigTable.out_en_5, + PduConfigTable.out_en_6, + PduConfigTable.out_en_7, +] + + +class PduHkTable: temperature = TableEntry(bytearray([0x00, 0x28]), TableEntry.uint16_size) # Ground WDT value (remaining seconds until reboot) wdt_gnd_left = TableEntry(bytearray([0x00, 0x80]), TableEntry.uint32_size) diff --git a/pus_tc/devs/pcdu.py b/pus_tc/devs/pcdu.py index a726869..05cbc13 100644 --- a/pus_tc/devs/pcdu.py +++ b/pus_tc/devs/pcdu.py @@ -29,32 +29,30 @@ def add_p60_cmds(defs: TmTcDefWrapper): def add_pdu1_cmds(defs: TmTcDefWrapper): oce = OpCodeEntry() - oce.add(keys=Pdu1OpCodes.TCS_BOARD_OFF.value, info="PDU1: Turn TCS board off") - oce.add(keys=Pdu1OpCodes.STAR_TRACKER_ON.value, info="PDU1: Turn star tracker on") - oce.add(keys=Pdu1OpCodes.STAR_TRACKER_OFF.value, info="PDU1: Turn star tracker off") - oce.add(keys=Pdu1OpCodes.SUS_NOMINAL_ON.value, info="PDU1: Turn SUS nominal on") - oce.add(keys=Pdu1OpCodes.SUS_NOMINAL_OFF.value, info="PDU1: Turn SUS nominal off") - oce.add(keys=Pdu1OpCodes.ACS_A_SIDE_ON.value, info="PDU1: Turn ACS A side on") - oce.add(keys=Pdu1OpCodes.ACS_A_SIDE_OFF.value, info="PDU1: Turn ACS A side off") - oce.add(keys=Pdu1OpCodes.SYRLINKS_ON.value, info="PDU1: Turn Syrlinks on") - oce.add(keys=Pdu1OpCodes.SYRLINKS_OFF.value, info="PDU1: Turn Syrlinks off") - oce.add(keys=Pdu1OpCodes.MGT_ON.value, info="PDU1: Turn MGT on") - oce.add(keys=Pdu1OpCodes.MGT_OFF.value, info="PDU1: Turn MGT off") - oce.add(keys=Pdu1OpCodes.PLOC_ON.value, info="PDU1: Turn PLOC on") - oce.add(keys=Pdu1OpCodes.PLOC_OFF.value, info="PDU1: Turn PLOC off") - oce.add(keys=Pdu1OpCodes.SCEX_ON.value, info="PDU1: Turn Solar Cell Experiment on") - oce.add( - keys=Pdu1OpCodes.SCEX_OFF.value, info="PDU1: Turn Solar Cell Experiment off" - ) + 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") 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( keys=GomspaceOpCodes.PRINT_SWITCH_V_I, info="PDU1: Print Switches, Voltages, Currents", ) - oce.add(keys=Pdu1OpCodes.TCS_BOARD_ON.value, info="PDU1: Turn TCS board on") oce.add(keys=GomspaceOpCodes.PRINT_LATCHUPS, info="PDU1: Print Latchups") - oce.add(keys=Pdu1OpCodes.TESTS.value, info="PDU1 Tests") + oce.add(keys=Pdu1OpCodes.TESTS, info="PDU1 Tests") oce.add(keys=GomspaceOpCodes.SET_PARAM, info="Set parameter") defs.add_service( name=CustomServiceList.PDU1.value, @@ -66,52 +64,50 @@ 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.value, info="PDU2: Turn ACS Side B on") - oce.add(keys=Pdu2OpCodes.ACS_SIDE_B_OFF.value, info="PDU2: Turn ACS Side B off") - oce.add(keys=Pdu2OpCodes.SUS_REDUNDANT_ON.value, info="PDU2: Turn SUS redundant on") + 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.SUS_REDUNDANT_OFF.value, info="PDU2: Turn SUS redundant off" - ) - oce.add(keys=Pdu2OpCodes.RW_ON.value, info="PDU2: Turn reaction wheels on") - oce.add(keys=Pdu2OpCodes.RW_OFF.value, info="PDU2: Turn reaction wheels off") - oce.add( - keys=Pdu2OpCodes.PL_PCDU_VBAT_NOM_ON.value, + 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.value, + 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.value, + 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.value, + keys=Pdu2OpCodes.PL_PCDU_VBAT_RED_OFF, info="PDU2: PL PCDU Switch Channel Redundant (1) off", ) oce.add( - keys=Pdu2OpCodes.TCS_HEATER_IN_ON.value, + keys=Pdu2OpCodes.TCS_HEATER_IN_ON, info="PDU2: Switch TCS Heater Input on", ) oce.add( - keys=Pdu2OpCodes.TCS_HEATER_IN_OFF.value, + keys=Pdu2OpCodes.TCS_HEATER_IN_OFF, info="PDU2: Switch TCS Heater Input off", ) oce.add( - keys=Pdu2OpCodes.SOLAR_ARRAY_DEPL_ON.value, + keys=Pdu2OpCodes.SOLAR_ARRAY_DEPL_ON, info="PDU2: Switch Solar Array Deployment On", ) oce.add( - keys=Pdu2OpCodes.SOLAR_ARRAY_DEPL_OFF.value, + keys=Pdu2OpCodes.SOLAR_ARRAY_DEPL_OFF, info="PDU2: Switch Solar Array Deployment Off", ) oce.add( - keys=Pdu2OpCodes.PL_CAMERA_ON.value, + keys=Pdu2OpCodes.PL_CAMERA_ON, info="PDU2: Turn payload camera on", ) oce.add( - keys=Pdu2OpCodes.PL_CAMERA_OFF.value, + keys=Pdu2OpCodes.PL_CAMERA_OFF, info="PDU2: Turn payload camera off", ) oce.add( diff --git a/pus_tc/devs/pdu1.py b/pus_tc/devs/pdu1.py index b6c8f56..de49c37 100644 --- a/pus_tc/devs/pdu1.py +++ b/pus_tc/devs/pdu1.py @@ -4,6 +4,7 @@ @date 17.12.2020 """ import gomspace.gomspace_common as gs +from pus_tc.devs.power import tcs_on_cmd, tcs_off_cmd from tmtccmd.tc import DefaultPusQueueHelper from tmtccmd.tc.pus_3_fsfw_hk import ( @@ -16,24 +17,24 @@ from gomspace.gomspace_pdu_definitions import * from config.object_ids import PDU_1_HANDLER_ID -class Pdu1OpCodes(enum.Enum): - TCS_BOARD_ON = "0" - TCS_BOARD_OFF = "1" - STAR_TRACKER_ON = "2" - STAR_TRACKER_OFF = "3" - SUS_NOMINAL_ON = "4" - SUS_NOMINAL_OFF = "5" - ACS_A_SIDE_ON = "6" - ACS_A_SIDE_OFF = "7" - SYRLINKS_ON = "8" - SYRLINKS_OFF = "9" - MGT_ON = "10" - MGT_OFF = "11" +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 = "12" - SCEX_OFF = "13" - PLOC_ON = "14" - PLOC_OFF = "15" + SCEX_ON = ["scex-on", "12"] + SCEX_OFF = ["scex-off", "13"] + PLOC_ON = ["ploc-on", "14"] + PLOC_OFF = ["ploc-off", "15"] TESTS = "32" @@ -58,173 +59,157 @@ 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 == Pdu1OpCodes.TCS_BOARD_ON.value: - q.add_log_cmd("PDU1: Turn TCS board on") - q.add_pus_tc( - pack_set_param_command( - objb, - PDUConfigTable.out_en_0.parameter_address, - PDUConfigTable.out_en_0.parameter_size, - Channel.on, - ) - ) - if op_code == Pdu1OpCodes.TCS_BOARD_OFF.value: - q.add_log_cmd("PDU1: Turn TCS board off") - 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 == Pdu1OpCodes.STAR_TRACKER_ON.value: + 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, + PduConfigTable.out_en_2.parameter_address, + PduConfigTable.out_en_2.parameter_size, Channel.on, ) ) - if op_code == Pdu1OpCodes.STAR_TRACKER_OFF.value: + 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, + PduConfigTable.out_en_2.parameter_address, + PduConfigTable.out_en_2.parameter_size, Channel.off, ) ) - if op_code == Pdu1OpCodes.SUS_NOMINAL_ON.value: + 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, + PduConfigTable.out_en_4.parameter_address, + PduConfigTable.out_en_4.parameter_size, Channel.on, ) ) - if op_code == Pdu1OpCodes.SUS_NOMINAL_OFF.value: + 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, + PduConfigTable.out_en_4.parameter_address, + PduConfigTable.out_en_4.parameter_size, Channel.off, ) ) - if op_code == Pdu1OpCodes.ACS_A_SIDE_ON.value: + 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, + PduConfigTable.out_en_7.parameter_address, + PduConfigTable.out_en_7.parameter_size, Channel.on, ) ) - if op_code == Pdu1OpCodes.ACS_A_SIDE_OFF.value: + 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, + PduConfigTable.out_en_7.parameter_address, + PduConfigTable.out_en_7.parameter_size, Channel.off, ) ) - if op_code == Pdu1OpCodes.SUS_NOMINAL_OFF.value: + 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, + PduConfigTable.out_en_4.parameter_address, + PduConfigTable.out_en_4.parameter_size, Channel.off, ) ) - if op_code == Pdu1OpCodes.SCEX_ON.value: + 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, + PduConfigTable.out_en_5.parameter_address, + PduConfigTable.out_en_5.parameter_size, Channel.on, ) ) - if op_code == Pdu1OpCodes.SCEX_OFF.value: + 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, + PduConfigTable.out_en_5.parameter_address, + PduConfigTable.out_en_5.parameter_size, Channel.off, ) ) - if op_code == Pdu1OpCodes.SYRLINKS_ON.value: + 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, + PduConfigTable.out_en_1.parameter_address, + PduConfigTable.out_en_1.parameter_size, Channel.on, ) ) - if op_code == Pdu1OpCodes.SYRLINKS_OFF.value: + 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, + PduConfigTable.out_en_1.parameter_address, + PduConfigTable.out_en_1.parameter_size, Channel.off, ) ) - if op_code == Pdu1OpCodes.MGT_ON.value: + 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, + PduConfigTable.out_en_3.parameter_address, + PduConfigTable.out_en_3.parameter_size, Channel.on, ) ) - if op_code == Pdu1OpCodes.MGT_OFF.value: + 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, + PduConfigTable.out_en_3.parameter_address, + PduConfigTable.out_en_3.parameter_size, Channel.off, ) ) - if op_code == Pdu1OpCodes.PLOC_ON.value: + 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, + PduConfigTable.out_en_6.parameter_address, + PduConfigTable.out_en_6.parameter_size, Channel.on, ) ) - if op_code == Pdu1OpCodes.PLOC_OFF.value: + 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, + PduConfigTable.out_en_6.parameter_address, + PduConfigTable.out_en_6.parameter_size, Channel.off, ) ) @@ -260,8 +245,8 @@ def pack_pdu1_commands(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code pack_get_param_command( objb, TableIds.hk, - PDUHkTable.temperature.parameter_address, - PDUHkTable.temperature.parameter_size, + PduHkTable.temperature.parameter_address, + PduHkTable.temperature.parameter_size, ) ) if PDU1TestProcedure.all or PDU1TestProcedure.turn_channel_2_on: @@ -269,8 +254,8 @@ def pack_pdu1_commands(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code q.add_pus_tc( pack_set_param_command( objb, - PDUConfigTable.out_en_2.parameter_address, - PDUConfigTable.out_en_2.parameter_size, + PduConfigTable.out_en_2.parameter_address, + PduConfigTable.out_en_2.parameter_size, Channel.on, ) ) @@ -279,8 +264,8 @@ def pack_pdu1_commands(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code q.add_pus_tc( pack_set_param_command( objb, - PDUConfigTable.out_en_2.parameter_address, - PDUConfigTable.out_en_2.parameter_size, + PduConfigTable.out_en_2.parameter_address, + PduConfigTable.out_en_2.parameter_size, Channel.off, ) ) @@ -289,8 +274,8 @@ def pack_pdu1_commands(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code q.add_pus_tc( pack_set_param_command( objb, - PDUConfigTable.out_en_3.parameter_address, - PDUConfigTable.out_en_3.parameter_size, + PduConfigTable.out_en_3.parameter_address, + PduConfigTable.out_en_3.parameter_size, Channel.on, ) ) @@ -299,8 +284,8 @@ def pack_pdu1_commands(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code q.add_pus_tc( pack_set_param_command( objb, - PDUConfigTable.out_en_3.parameter_address, - PDUConfigTable.out_en_3.parameter_size, + PduConfigTable.out_en_3.parameter_address, + PduConfigTable.out_en_3.parameter_size, Channel.off, ) ) diff --git a/pus_tc/devs/pdu2.py b/pus_tc/devs/pdu2.py index db70106..a5a8009 100644 --- a/pus_tc/devs/pdu2.py +++ b/pus_tc/devs/pdu2.py @@ -17,24 +17,26 @@ from gomspace.gomspace_pdu_definitions import * from config.object_ids import PDU_2_HANDLER_ID -class Pdu2OpCodes(enum.Enum): - ACS_SIDE_B_ON = "1" - ACS_SIDE_B_OFF = "2" - SUS_REDUNDANT_ON = "3" - SUS_REDUNDANT_OFF = "4" - RW_ON = "5" - RW_OFF = "6" - PL_PCDU_VBAT_NOM_ON = "7" - PL_PCDU_VBAT_NOM_OFF = "8" - PL_PCDU_VBAT_RED_ON = "9" - PL_PCDU_VBAT_RED_OFF = "10" - TCS_HEATER_IN_ON = "11" - TCS_HEATER_IN_OFF = "12" - SOLAR_ARRAY_DEPL_ON = "13" - SOLAR_ARRAY_DEPL_OFF = "14" - PL_CAMERA_ON = "15" - PL_CAMERA_OFF = "16" - # There is not really a point of the on command, the SW can not be commanded if the OBC is off +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" @@ -68,173 +70,173 @@ 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 == Pdu2OpCodes.ACS_SIDE_B_ON.value: + 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, + PduConfigTable.out_en_7.parameter_address, + PduConfigTable.out_en_7.parameter_size, Channel.on, ) ) - if op_code == Pdu2OpCodes.ACS_SIDE_B_OFF.value: + 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, + PduConfigTable.out_en_7.parameter_address, + PduConfigTable.out_en_7.parameter_size, Channel.off, ) ) - if op_code == Pdu2OpCodes.Q7S_OFF.value: + 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, + PduConfigTable.out_en_0.parameter_address, + PduConfigTable.out_en_0.parameter_size, Channel.off, ) ) - if op_code == Pdu2OpCodes.SUS_REDUNDANT_ON.value: + 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, + PduConfigTable.out_en_4.parameter_address, + PduConfigTable.out_en_4.parameter_size, Channel.on, ) ) - if op_code == Pdu2OpCodes.SUS_REDUNDANT_OFF.value: + 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, + PduConfigTable.out_en_4.parameter_address, + PduConfigTable.out_en_4.parameter_size, Channel.off, ) ) - if op_code == Pdu2OpCodes.RW_ON.value: + 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, + PduConfigTable.out_en_2.parameter_address, + PduConfigTable.out_en_2.parameter_size, Channel.on, ) ) - if op_code == Pdu2OpCodes.RW_OFF.value: + 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, + PduConfigTable.out_en_2.parameter_address, + PduConfigTable.out_en_2.parameter_size, Channel.off, ) ) - if op_code == Pdu2OpCodes.PL_PCDU_VBAT_NOM_ON.value: + 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, + PduConfigTable.out_en_1.parameter_address, + PduConfigTable.out_en_1.parameter_size, Channel.on, ) ) - if op_code == Pdu2OpCodes.PL_PCDU_VBAT_NOM_OFF.value: + 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, + PduConfigTable.out_en_1.parameter_address, + PduConfigTable.out_en_1.parameter_size, Channel.off, ) ) - if op_code == Pdu2OpCodes.PL_PCDU_VBAT_RED_ON.value: + 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, + PduConfigTable.out_en_6.parameter_address, + PduConfigTable.out_en_6.parameter_size, Channel.off, ) ) - if op_code == Pdu2OpCodes.PL_PCDU_VBAT_RED_OFF.value: + 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, + PduConfigTable.out_en_6.parameter_address, + PduConfigTable.out_en_6.parameter_size, Channel.off, ) ) - if op_code == Pdu2OpCodes.TCS_HEATER_IN_ON.value: + 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, + PduConfigTable.out_en_3.parameter_address, + PduConfigTable.out_en_3.parameter_size, Channel.on, ) ) - if op_code == Pdu2OpCodes.TCS_HEATER_IN_OFF.value: + 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, + PduConfigTable.out_en_3.parameter_address, + PduConfigTable.out_en_3.parameter_size, Channel.off, ) ) - if op_code == Pdu2OpCodes.SOLAR_ARRAY_DEPL_ON.value: + 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, + PduConfigTable.out_en_5.parameter_address, + PduConfigTable.out_en_5.parameter_size, Channel.on, ) ) - if op_code == Pdu2OpCodes.SOLAR_ARRAY_DEPL_OFF.value: + 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, + PduConfigTable.out_en_5.parameter_address, + PduConfigTable.out_en_5.parameter_size, Channel.off, ) ) - if op_code == Pdu2OpCodes.PL_CAMERA_ON.value: + 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, + PduConfigTable.out_en_8.parameter_address, + PduConfigTable.out_en_8.parameter_size, Channel.on, ) ) - if op_code == Pdu2OpCodes.PL_CAMERA_OFF.value: + 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, + PduConfigTable.out_en_8.parameter_address, + PduConfigTable.out_en_8.parameter_size, Channel.off, ) ) @@ -269,8 +271,8 @@ def pack_pdu2_commands(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code pack_get_param_command( objb, TableIds.hk, - PDUHkTable.wdt_gnd_left.parameter_address, - PDUHkTable.wdt_gnd_left.parameter_size, + PduHkTable.wdt_gnd_left.parameter_address, + PduHkTable.wdt_gnd_left.parameter_size, ) ) if PDU2TestProcedure.all or PDU2TestProcedure.gnd_wdt_reset: @@ -285,8 +287,8 @@ def pack_pdu2_commands(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code q.add_pus_tc( pack_set_param_command( objb, - PDUConfigTable.out_en_2.parameter_address, - PDUConfigTable.out_en_2.parameter_size, + PduConfigTable.out_en_2.parameter_address, + PduConfigTable.out_en_2.parameter_size, Channel.on, ) ) @@ -296,8 +298,8 @@ def pack_pdu2_commands(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code pack_get_param_command( objb, TableIds.hk, - PDUHkTable.temperature.parameter_address, - PDUHkTable.temperature.parameter_size, + PduHkTable.temperature.parameter_address, + PduHkTable.temperature.parameter_size, ) ) if PDU2TestProcedure.all or PDU2TestProcedure.read_channel_2_state: @@ -306,8 +308,8 @@ def pack_pdu2_commands(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code pack_get_param_command( objb, TableIds.config, - PDUConfigTable.out_en_2.parameter_address, - PDUConfigTable.out_en_2.parameter_size, + PduConfigTable.out_en_2.parameter_address, + PduConfigTable.out_en_2.parameter_size, ) ) if PDU2TestProcedure.all or PDU2TestProcedure.read_cur_lu_lim_0: @@ -316,8 +318,8 @@ def pack_pdu2_commands(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code pack_get_param_command( objb, TableIds.config, - PDUConfigTable.cur_lu_lim_0.parameter_address, - PDUConfigTable.cur_lu_lim_0.parameter_size, + PduConfigTable.cur_lu_lim_0.parameter_address, + PduConfigTable.cur_lu_lim_0.parameter_size, ) ) if PDU2TestProcedure.all or PDU2TestProcedure.channel_2_off: @@ -325,8 +327,8 @@ def pack_pdu2_commands(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code q.add_pus_tc( pack_set_param_command( objb, - PDUConfigTable.out_en_2.parameter_address, - PDUConfigTable.out_en_2.parameter_size, + PduConfigTable.out_en_2.parameter_address, + PduConfigTable.out_en_2.parameter_size, Channel.off, ) ) diff --git a/pus_tc/devs/power.py b/pus_tc/devs/power.py new file mode 100644 index 0000000..c663d68 --- /dev/null +++ b/pus_tc/devs/power.py @@ -0,0 +1,126 @@ +import enum + +from config.object_ids import PDU_1_HANDLER_ID +from gomspace.gomspace_common import pack_set_param_command, Channel +from gomspace.gomspace_pdu_definitions import PduConfigTable, PDU_CONFIG_LIST +from tmtccmd.tc import DefaultPusQueueHelper +from tmtccmd.util import ObjectIdU32 + + +class Pdu1OpCodes(enum.Enum): + 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 Pdu2OpCodes(enum.Enum): + ACS_SIDE_B_ON = "1" + ACS_SIDE_B_OFF = "2" + SUS_REDUNDANT_ON = "3" + SUS_REDUNDANT_OFF = "4" + RW_ON = "5" + RW_OFF = "6" + PL_PCDU_VBAT_NOM_ON = "7" + PL_PCDU_VBAT_NOM_OFF = "8" + PL_PCDU_VBAT_RED_ON = "9" + PL_PCDU_VBAT_RED_OFF = "10" + TCS_HEATER_IN_ON = "11" + TCS_HEATER_IN_OFF = "12" + SOLAR_ARRAY_DEPL_ON = "13" + SOLAR_ARRAY_DEPL_OFF = "14" + PL_CAMERA_ON = "15" + PL_CAMERA_OFF = "16" + # There is not really a point of the on command, the SW can not be commanded if the OBC is off + Q7S_OFF = "32" + + +class PowerChannels(enum.IntEnum): + TCS = (0,) + COM = (1,) + STR = (2,) + SUS_NOM = 3 + + +Pdu1Dict = {PowerChannels.TCS: (0, "tcs"), PowerChannels.STR: (2, "str")} + + +class PowerOpCodes: + TCS_ON = ["tcs-on"] + TCS_OFF = ["tcs-off"] + STAR_TRACKER_ON = ["str-on"] + STAR_TRACKER_OFF = ["str-off"] + + +Pdu1OpCodeList = [] + + +def get_power_obj_id(op_code: PowerOpCodes) -> ObjectIdU32: + pass + + +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.STAR_TRACKER_ON: + object_id = PDU_1_HANDLER_ID + + +def tcs_on_cmd(object_id: ObjectIdU32, q: DefaultPusQueueHelper): + generic_on_cmd(object_id, q, "PDU1: Turn TCS board on", 0) + + +def tcs_off_cmd(object_id: ObjectIdU32, q: DefaultPusQueueHelper): + generic_off_cmd(object_id, q, "PDU1: Turn TCS board off", 0) + + +def str_on_cmd(object_id: ObjectIdU32, q: DefaultPusQueueHelper): + generic_on_cmd(object_id, q, "PDU1: Turn Star Tracker on", 2) + + +def str_off_cmd(object_id: ObjectIdU32, q: DefaultPusQueueHelper): + generic_off_cmd(object_id, q, "PDU1: Turn Star Tracker off", 2) + + +def generic_on_cmd( + object_id: ObjectIdU32, q: DefaultPusQueueHelper, info_str: str, out_idx: int +): + q.add_log_cmd(info_str) + q.add_pus_tc( + pack_set_param_command( + object_id.as_bytes, + PDU_CONFIG_LIST[out_idx].parameter_address, + PDU_CONFIG_LIST[out_idx].parameter_size, + Channel.on, + ) + ) + + +def generic_off_cmd( + object_id: ObjectIdU32, q: DefaultPusQueueHelper, info_str: str, out_idx: int +): + q.add_log_cmd(info_str) + q.add_pus_tc( + pack_set_param_command( + object_id.as_bytes, + PDU_CONFIG_LIST[out_idx].parameter_address, + PDU_CONFIG_LIST[out_idx].parameter_size, + Channel.off, + ) + ) diff --git a/pus_tm/hk_handling.py b/pus_tm/hk_handling.py index 7b19a11..f2ea28a 100644 --- a/pus_tm/hk_handling.py +++ b/pus_tm/hk_handling.py @@ -46,9 +46,9 @@ def handle_hk_packet( named_obj_id = tm_packet.object_id if tm_packet.subservice == 25 or tm_packet.subservice == 26: hk_data = tm_packet.tm_data[8:] - tcp_server_sensor_temperatures.report_raw_hk_data( - object_id=named_obj_id, set_id=tm_packet.set_id, hk_data=hk_data - ) + # tcp_server_sensor_temperatures.report_raw_hk_data( + # object_id=named_obj_id, set_id=tm_packet.set_id, hk_data=hk_data + # ) printer.generic_hk_tm_print( content_type=HkContentType.HK, object_id=named_obj_id,