109 lines
3.9 KiB
Python
109 lines
3.9 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""PDU1 is mounted on the X2 slot of the P60 dock
|
|
@author J. Meier
|
|
@date 17.12.2020
|
|
"""
|
|
import gomspace.gomspace_common as gs
|
|
from tmtc.power.common_power import pdu1_cmds, pdu1_req_hk_cmds
|
|
|
|
from gomspace.gomspace_common import *
|
|
from gomspace.gomspace_pdu_definitions import *
|
|
|
|
|
|
class PDU1TestProcedure:
|
|
"""
|
|
@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.
|
|
"""
|
|
|
|
all = False
|
|
reboot = False
|
|
ping = False
|
|
read_temperature = False
|
|
turn_channel_2_on = False # Star Tracker connected to this channel (5V)
|
|
turn_channel_2_off = False
|
|
turn_channel_3_on = False # MTQ connected to this channel (5V)
|
|
turn_channel_3_off = False
|
|
|
|
|
|
def pack_pdu1_commands(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str):
|
|
q.add_log_cmd("Commanding PDU1")
|
|
objb = object_id.as_bytes
|
|
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(
|
|
make_fsfw_action_cmd(
|
|
object_id=objb, action_id=GomspaceDeviceActionIds.PRINT_SWITCH_V_I
|
|
)
|
|
)
|
|
if op_code in GomspaceOpCodes.PRINT_LATCHUPS:
|
|
q.add_log_cmd("PDU1: Print Latchups")
|
|
q.add_pus_tc(
|
|
make_fsfw_action_cmd(
|
|
object_id=objb, action_id=GomspaceDeviceActionIds.PRINT_LATCHUPS
|
|
)
|
|
)
|
|
if op_code in GomspaceOpCodes.SET_PARAM:
|
|
q.add_log_cmd(f"PDU1: {GsInfo.SET_PARAMETER}")
|
|
prompt_and_pack_set_param_command(q, object_id)
|
|
if op_code in GomspaceOpCodes.GET_PARAM:
|
|
q.add_log_cmd(f"PDU1: {GsInfo.GET_PARAMETER}")
|
|
gs.prompt_and_pack_get_param_command(q, object_id)
|
|
if PDU1TestProcedure.all or PDU1TestProcedure.ping:
|
|
q.add_log_cmd("PDU1: Ping Test")
|
|
ping_data = bytearray([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
|
|
q.add_pus_tc(pack_ping_command(object_id, ping_data))
|
|
if PDU1TestProcedure.all or PDU1TestProcedure.read_temperature:
|
|
q.add_log_cmd("PDU1: Testing temperature reading")
|
|
q.add_pus_tc(
|
|
pack_get_param_command(
|
|
objb,
|
|
TableIds.hk,
|
|
PduHkTable.temperature.parameter_address,
|
|
PduHkTable.temperature.parameter_size,
|
|
)
|
|
)
|
|
if PDU1TestProcedure.all or PDU1TestProcedure.turn_channel_2_on:
|
|
q.add_log_cmd("PDU1: Turn channel 2 on (Star Tracker)")
|
|
q.add_pus_tc(
|
|
pack_set_param_command(
|
|
objb,
|
|
PduConfigTable.out_en_2.parameter_address,
|
|
PduConfigTable.out_en_2.parameter_size,
|
|
Channel.on,
|
|
)
|
|
)
|
|
if PDU1TestProcedure.all or PDU1TestProcedure.turn_channel_2_off:
|
|
q.add_log_cmd("PDU1: Turn channel 2 off (Star Tracker)")
|
|
q.add_pus_tc(
|
|
pack_set_param_command(
|
|
objb,
|
|
PduConfigTable.out_en_2.parameter_address,
|
|
PduConfigTable.out_en_2.parameter_size,
|
|
Channel.off,
|
|
)
|
|
)
|
|
if PDU1TestProcedure.all or PDU1TestProcedure.turn_channel_3_on:
|
|
q.add_log_cmd("PDU1: Turn channel 3 on (MTQ)")
|
|
q.add_pus_tc(
|
|
pack_set_param_command(
|
|
objb,
|
|
PduConfigTable.out_en_3.parameter_address,
|
|
PduConfigTable.out_en_3.parameter_size,
|
|
Channel.on,
|
|
)
|
|
)
|
|
if PDU1TestProcedure.all or PDU1TestProcedure.turn_channel_3_off:
|
|
q.add_log_cmd("PDU1: Turn channel 3 off (MTQ)")
|
|
q.add_pus_tc(
|
|
pack_set_param_command(
|
|
objb,
|
|
PduConfigTable.out_en_3.parameter_address,
|
|
PduConfigTable.out_en_3.parameter_size,
|
|
Channel.off,
|
|
)
|
|
)
|