318 lines
11 KiB
Python
318 lines
11 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 tmtccmd.tc import QueueHelper
|
|
from tmtccmd.tc.pus_3_fsfw_hk import (
|
|
generate_one_hk_command,
|
|
make_sid,
|
|
generate_one_diag_command,
|
|
)
|
|
from gomspace.gomspace_common import *
|
|
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"
|
|
# Solar Cell Experiment
|
|
SCEX_ON = "12"
|
|
SCEX_OFF = "13"
|
|
PLOC_ON = "14"
|
|
PLOC_OFF = "15"
|
|
|
|
TESTS = "32"
|
|
|
|
|
|
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: QueueHelper, 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:
|
|
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 == Pdu1OpCodes.STAR_TRACKER_OFF.value:
|
|
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 == Pdu1OpCodes.SUS_NOMINAL_ON.value:
|
|
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 == Pdu1OpCodes.SUS_NOMINAL_OFF.value:
|
|
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 == Pdu1OpCodes.ACS_A_SIDE_ON.value:
|
|
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 == Pdu1OpCodes.ACS_A_SIDE_OFF.value:
|
|
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 == Pdu1OpCodes.SUS_NOMINAL_OFF.value:
|
|
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 == Pdu1OpCodes.SCEX_ON.value:
|
|
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 == Pdu1OpCodes.SCEX_OFF.value:
|
|
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 == Pdu1OpCodes.SYRLINKS_ON.value:
|
|
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 == Pdu1OpCodes.SYRLINKS_OFF.value:
|
|
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 == Pdu1OpCodes.MGT_ON.value:
|
|
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 == Pdu1OpCodes.MGT_OFF.value:
|
|
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 == Pdu1OpCodes.PLOC_ON.value:
|
|
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 == Pdu1OpCodes.PLOC_OFF.value:
|
|
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))
|
|
if op_code in GomspaceOpCodes.PRINT_SWITCH_V_I:
|
|
q.add_log_cmd("PDU1: Print Switches, Voltages, Currents")
|
|
q.add_pus_tc(
|
|
generate_action_command(
|
|
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(
|
|
generate_action_command(
|
|
object_id=objb, action_id=GomspaceDeviceActionIds.PRINT_LATCHUPS
|
|
)
|
|
)
|
|
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,
|
|
)
|
|
)
|
|
if op_code in GomspaceOpCodes.SET_PARAM:
|
|
q.add_log_cmd(f"PDU1: {Info.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: "))
|
|
parameter = int(input("Specify parameter: "))
|
|
q.add_pus_tc(
|
|
gs.pack_set_param_command(
|
|
object_id.as_bytes, memory_address, parameter_size, parameter
|
|
)
|
|
)
|