eive-tmtc/eive_tmtc/tmtc/power/pdu2.py

376 lines
12 KiB
Python
Raw Normal View History

2020-12-29 11:29:03 +01:00
# -*- coding: utf-8 -*-
"""
@file tmtcc_tc_pdu2.py
@brief PDU2 tests
2021-12-02 08:01:18 +01:00
@details PDU2 is mounted on the X4 slot of the P60 dock
2020-12-29 11:29:03 +01:00
@author J. Meier
@date 17.12.2020
"""
2022-11-29 16:53:29 +01:00
from eive_tmtc.config.object_ids import PDU_2_HANDLER_ID
from eive_tmtc.tmtc.power.common_power import (
2022-10-18 10:44:32 +02:00
pack_common_gomspace_cmds,
2022-08-27 16:28:33 +02:00
req_hk_cmds,
PowerOpCodes,
generic_on_cmd,
generic_off_cmd,
2022-10-18 10:44:32 +02:00
add_gomspace_cmd_defs,
pack_common_power_cmds,
2023-01-12 14:18:18 +01:00
create_generic_on_cmd,
create_generic_off_cmd,
2023-01-12 15:48:49 +01:00
SetId,
2022-10-18 11:08:28 +02:00
add_common_power_defs,
2022-08-27 16:28:33 +02:00
)
2022-11-29 16:53:29 +01:00
from eive_tmtc.gomspace.gomspace_common import *
from eive_tmtc.gomspace.gomspace_pdu_definitions import *
2022-10-18 10:44:32 +02:00
from tmtccmd.config import OpCodeEntry, TmtcDefinitionWrapper
from tmtccmd.config.tmtc import tmtc_definitions_provider
2022-08-27 16:28:33 +02:00
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 Pdu2ChIndex(enum.IntEnum):
2022-09-01 16:58:31 +02:00
OBC = 0
2022-08-27 16:28:33 +02:00
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
2021-09-07 14:51:50 +02:00
2020-12-29 11:29:03 +01:00
class PDU2TestProcedure:
"""
@brief Use this class to define the tests to perform for the PDU2.
@details Setting all to True will run all tests.
Setting all to False will only run the tests set to True.
"""
2022-01-18 14:03:56 +01:00
2021-02-06 16:35:53 +01:00
all = False
2020-12-29 11:29:03 +01:00
reboot = False
read_gnd_wdt = False
gnd_wdt_reset = False
ping = False
2021-02-11 08:18:42 +01:00
channel_2_off = False # Reaction wheels 5V
2021-09-08 13:43:47 +02:00
read_temperature = False
2021-02-11 08:18:42 +01:00
read_channel_2_state = False # Reaction wheels 5V
2021-03-19 17:50:09 +01:00
read_cur_lu_lim_0 = False # OBC
2021-02-11 08:18:42 +01:00
channel_2_on = False # Reaction wheels 5V
2022-01-18 14:03:56 +01:00
invalid_table_id_test = (
False # Test to check if software properly handles invalid table ids
)
invalid_address_test = (
False # Test to check if software properly handles invalid addresses
)
2021-02-06 16:35:53 +01:00
invalid_parameter_size_test = False
2021-02-11 08:18:42 +01:00
request_hk_table = False
2020-12-29 11:29:03 +01:00
2022-08-08 16:32:18 +02:00
def pack_pdu2_commands(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str):
2022-07-04 15:22:53 +02:00
q.add_log_cmd("Testing PDU2")
2022-05-23 11:24:55 +02:00
objb = object_id.as_bytes
2022-08-11 18:10:15 +02:00
pdu2_cmds(q, op_code)
pdu2_req_hk_cmds(q, op_code)
2022-10-18 10:44:32 +02:00
pack_common_power_cmds("PDU2", object_id, q, op_code)
pack_common_gomspace_cmds("PDU2", object_id, q, op_code)
2020-12-29 11:29:03 +01:00
if PDU2TestProcedure.all or PDU2TestProcedure.reboot:
2022-07-04 15:22:53 +02:00
q.add_log_cmd("PDU2: Reboot")
q.add_pus_tc(pack_reboot_command(object_id))
2020-12-29 11:29:03 +01:00
if PDU2TestProcedure.all or PDU2TestProcedure.read_gnd_wdt:
2022-07-04 15:22:53 +02:00
q.add_log_cmd("PDU2: Reading ground watchdog timer value")
q.add_pus_tc(
pack_get_param_command(
objb,
2022-09-01 16:58:31 +02:00
TableIds.HK,
2022-08-11 14:45:24 +02:00
PduHkTable.wdt_gnd_left.parameter_address,
PduHkTable.wdt_gnd_left.parameter_size,
2022-07-04 15:22:53 +02:00
)
2021-09-07 14:51:50 +02:00
)
2020-12-29 11:29:03 +01:00
if PDU2TestProcedure.all or PDU2TestProcedure.gnd_wdt_reset:
2022-07-04 15:22:53 +02:00
q.add_log_cmd("PDU2: Testing ground watchdog reset")
q.add_pus_tc(pack_gnd_wdt_reset_command(object_id))
2020-12-29 11:29:03 +01:00
if PDU2TestProcedure.all or PDU2TestProcedure.ping:
2022-07-04 15:22:53 +02:00
q.add_log_cmd("PDU2: Ping Test")
2020-12-29 11:29:03 +01:00
ping_data = bytearray([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
2022-07-04 15:22:53 +02:00
q.add_pus_tc(pack_ping_command(object_id, ping_data))
2021-02-06 16:35:53 +01:00
if PDU2TestProcedure.all or PDU2TestProcedure.read_temperature:
2022-07-04 15:22:53 +02:00
q.add_log_cmd("PDU2: Testing temperature reading")
q.add_pus_tc(
pack_get_param_command(
objb,
2022-09-01 16:58:31 +02:00
TableIds.HK,
2022-08-11 14:45:24 +02:00
PduHkTable.temperature.parameter_address,
PduHkTable.temperature.parameter_size,
2022-07-04 15:22:53 +02:00
)
2021-09-07 14:51:50 +02:00
)
2020-12-29 11:29:03 +01:00
if PDU2TestProcedure.all or PDU2TestProcedure.read_channel_2_state:
2022-07-04 15:22:53 +02:00
q.add_log_cmd("PDU2: Reading output channel 2 state (TCS Heater)")
q.add_pus_tc(
pack_get_param_command(
objb,
2022-09-01 16:58:31 +02:00
TableIds.CONFIG,
2022-08-11 14:45:24 +02:00
PduConfigTable.out_en_2.parameter_address,
PduConfigTable.out_en_2.parameter_size,
2022-07-04 15:22:53 +02:00
)
2021-09-07 14:51:50 +02:00
)
2020-12-29 11:29:03 +01:00
if PDU2TestProcedure.all or PDU2TestProcedure.read_cur_lu_lim_0:
2022-07-04 15:22:53 +02:00
q.add_log_cmd("PDU2: Reading current limit value of output channel 0 (OBC)")
q.add_pus_tc(
pack_get_param_command(
objb,
2022-09-01 16:58:31 +02:00
TableIds.CONFIG,
2022-08-11 14:45:24 +02:00
PduConfigTable.cur_lu_lim_0.parameter_address,
PduConfigTable.cur_lu_lim_0.parameter_size,
2022-01-18 14:03:56 +01:00
)
2021-09-07 14:51:50 +02:00
)
2021-02-06 16:35:53 +01:00
if PDU2TestProcedure.all or PDU2TestProcedure.request_hk_table:
2022-07-04 15:22:53 +02:00
q.add_log_cmd("PDU2: Requesting housekeeping table")
q.add_pus_tc(pack_request_full_hk_table_command(object_id))
2022-08-27 16:28:33 +02:00
2022-10-18 10:44:32 +02:00
@tmtc_definitions_provider
def add_pdu2_cmds(defs: TmtcDefinitionWrapper):
oce = OpCodeEntry()
add_pdu2_common_defs(oce)
2022-10-18 11:08:28 +02:00
add_common_power_defs(oce)
2022-10-18 10:44:32 +02:00
add_gomspace_cmd_defs(oce)
oce.add(
keys=PowerOpCodes.PRINT_SWITCH_V_I,
info="PDU2: Print Switches, Voltages, Currents",
)
oce.add(
keys=PowerOpCodes.PRINT_LATCHUPS,
info="PDU2: Print Latchups",
)
defs.add_service(
name="pdu2",
info="PDU2 Device",
op_code_entry=oce,
)
2022-08-27 16:28:33 +02:00
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 info_on_pdu2(base: str) -> str:
return "PDU2: " + base + " on"
def info_off_pdu2(base: str) -> str:
return "PDU2: " + base + " off"
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 pdu2_req_hk_cmds(q: DefaultPusQueueHelper, op_code: str):
2023-01-12 15:48:49 +01:00
req_hk_cmds("PDU2", q, op_code, PDU_2_HANDLER_ID, [SetId.CORE, SetId.AUX])
2022-08-27 16:28:33 +02:00
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)
2023-01-12 14:18:18 +01:00
def create_reaction_wheel_on_cmd() -> PusTelecommand:
return create_generic_on_cmd(PDU_2_HANDLER_ID, Pdu2ChIndex.RW)
2022-08-27 16:28:33 +02:00
def reaction_wheel_off_cmd(q: DefaultPusQueueHelper):
generic_off_cmd(PDU_2_HANDLER_ID, q, Pdu2InfoBase.RW, Pdu2ChIndex.RW)
2023-01-12 14:18:18 +01:00
def create_reaction_wheel_off_cmd() -> PusTelecommand:
return create_generic_off_cmd(PDU_2_HANDLER_ID, Pdu2ChIndex.RW)
2022-08-27 16:28:33 +02:00
def heater_on_cmd(q: DefaultPusQueueHelper):
generic_on_cmd(PDU_2_HANDLER_ID, q, Pdu2InfoBase.HEATER, Pdu2ChIndex.HEATER)
2023-01-12 14:18:18 +01:00
def create_heater_on_cmd() -> PusTelecommand:
return create_generic_on_cmd(PDU_2_HANDLER_ID, Pdu2ChIndex.HEATER)
2022-08-27 16:28:33 +02:00
def heater_off_cmd(q: DefaultPusQueueHelper):
generic_off_cmd(PDU_2_HANDLER_ID, q, Pdu2InfoBase.HEATER, Pdu2ChIndex.HEATER)
2023-01-12 14:18:18 +01:00
def create_heater_off_cmd() -> PusTelecommand:
return create_generic_on_cmd(PDU_2_HANDLER_ID, Pdu2ChIndex.HEATER)
2022-08-27 16:28:33 +02:00
def sus_red_on_cmd(q: DefaultPusQueueHelper):
generic_on_cmd(PDU_2_HANDLER_ID, q, Pdu2InfoBase.SUS_R, Pdu2ChIndex.SUS_R)
2023-01-12 14:18:18 +01:00
def create_sus_red_on_cmd() -> PusTelecommand:
return create_generic_on_cmd(PDU_2_HANDLER_ID, Pdu2ChIndex.SUS_R)
2022-08-27 16:28:33 +02:00
def sus_red_off_cmd(q: DefaultPusQueueHelper):
generic_off_cmd(PDU_2_HANDLER_ID, q, Pdu2InfoBase.SUS_R, Pdu2ChIndex.SUS_R)
2023-01-12 14:18:18 +01:00
def create_sus_red_off_cmd() -> PusTelecommand:
return create_generic_off_cmd(PDU_2_HANDLER_ID, Pdu2ChIndex.SUS_R)
2022-08-27 16:28:33 +02:00
def solar_array_deployment_on_cmd(q: DefaultPusQueueHelper):
generic_on_cmd(
PDU_2_HANDLER_ID, q, Pdu2InfoBase.SOLAR_ARRAY_DEPL, Pdu2ChIndex.SOLAR_ARRAY_DEPL
)
2023-01-12 14:18:18 +01:00
def create_solar_array_deployment_on_cmd() -> PusTelecommand:
return create_generic_on_cmd(PDU_2_HANDLER_ID, Pdu2ChIndex.SOLAR_ARRAY_DEPL)
2022-08-27 16:28:33 +02:00
def solar_array_deployment_off_cmd(q: DefaultPusQueueHelper):
generic_off_cmd(
PDU_2_HANDLER_ID, q, Pdu2InfoBase.SOLAR_ARRAY_DEPL, Pdu2ChIndex.SOLAR_ARRAY_DEPL
)
2023-01-12 14:18:18 +01:00
def create_solar_array_deployment_off_cmd() -> PusTelecommand:
return create_generic_off_cmd(PDU_2_HANDLER_ID, Pdu2ChIndex.SOLAR_ARRAY_DEPL)
2022-08-27 16:28:33 +02:00
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
)
2023-01-12 14:18:18 +01:00
def create_pl_pcdu_bat_red_on_cmd() -> PusTelecommand:
return create_generic_on_cmd(PDU_2_HANDLER_ID, Pdu2ChIndex.PL_PCDU_BAT_RED)
2022-08-27 16:28:33 +02:00
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
)
2023-01-12 14:18:18 +01:00
def create_pl_pcdu_bat_red_off_cmd() -> PusTelecommand:
return create_generic_off_cmd(PDU_2_HANDLER_ID, Pdu2ChIndex.PL_PCDU_BAT_RED)
2022-08-27 16:28:33 +02:00
def acs_board_b_side_on_cmd(q: DefaultPusQueueHelper):
generic_on_cmd(PDU_2_HANDLER_ID, q, Pdu2InfoBase.ACS_B, Pdu2ChIndex.ACS_B)
2023-01-12 14:18:18 +01:00
def create_acs_board_b_side_on_cmd() -> PusTelecommand:
return create_generic_on_cmd(PDU_2_HANDLER_ID, Pdu2ChIndex.ACS_B)
2022-08-27 16:28:33 +02:00
def acs_board_b_side_off_cmd(q: DefaultPusQueueHelper):
generic_off_cmd(PDU_2_HANDLER_ID, q, Pdu2InfoBase.ACS_B, Pdu2ChIndex.ACS_B)
2023-01-12 14:18:18 +01:00
def create_acs_board_b_side_off_cmd() -> PusTelecommand:
return create_generic_off_cmd(PDU_2_HANDLER_ID, Pdu2ChIndex.ACS_B)
2022-08-27 16:28:33 +02:00
def payload_camera_on_cmd(q: DefaultPusQueueHelper):
generic_on_cmd(PDU_2_HANDLER_ID, q, Pdu2InfoBase.PL_CAM, Pdu2ChIndex.PL_CAM)
2023-01-12 14:18:18 +01:00
def create_payload_camera_on_cmd() -> PusTelecommand:
return create_generic_on_cmd(PDU_2_HANDLER_ID, Pdu2ChIndex.PL_CAM)
2022-08-27 16:28:33 +02:00
def payload_camera_off_cmd(q: DefaultPusQueueHelper):
generic_off_cmd(PDU_2_HANDLER_ID, q, Pdu2InfoBase.PL_CAM, Pdu2ChIndex.PL_CAM)
2023-01-12 14:18:18 +01:00
def create_payload_camera_off_cmd() -> PusTelecommand:
return create_generic_on_cmd(PDU_2_HANDLER_ID, Pdu2ChIndex.PL_CAM)