eive-tmtc/pus_tc/devs/pdu1.py

121 lines
4.3 KiB
Python
Raw Normal View History

2020-12-29 11:29:03 +01:00
# -*- coding: utf-8 -*-
"""PDU1 is mounted on the X2 slot of the P60 dock
2020-12-29 11:29:03 +01:00
@author J. Meier
@date 17.12.2020
"""
import gomspace.gomspace_common as gs
2022-08-11 18:10:15 +02:00
from pus_tc.devs.common_power import pdu1_cmds, pdu1_req_hk_cmds
2022-07-04 15:22:53 +02:00
2022-08-08 16:32:18 +02:00
from tmtccmd.tc import DefaultPusQueueHelper
from tmtccmd.tc.pus_3_fsfw_hk import (
generate_one_hk_command,
make_sid,
generate_one_diag_command,
)
2020-12-29 11:29:03 +01:00
from gomspace.gomspace_common import *
from gomspace.gomspace_pdu_definitions import *
2022-03-14 09:56:34 +01:00
from config.object_ids import PDU_1_HANDLER_ID
2020-12-29 11:29:03 +01:00
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.
"""
2022-01-18 14:03:56 +01:00
2021-02-09 12:35:10 +01:00
all = False
2020-12-29 11:29:03 +01:00
reboot = False
ping = False
read_temperature = False
2022-01-18 14:03:56 +01:00
turn_channel_2_on = False # Star Tracker connected to this channel (5V)
2021-04-18 18:52:47 +02:00
turn_channel_2_off = False
turn_channel_3_on = False # MTQ connected to this channel (5V)
2021-08-11 17:14:30 +02:00
turn_channel_3_off = False
2020-12-29 11:29:03 +01:00
2022-08-08 16:32:18 +02:00
def pack_pdu1_commands(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str):
2022-07-04 15:22:53 +02:00
q.add_log_cmd("Commanding PDU1")
2022-05-23 11:24:55 +02:00
objb = object_id.as_bytes
2022-08-11 18:10:15 +02:00
pdu1_cmds(q, op_code)
pdu1_req_hk_cmds(q, op_code)
2022-04-04 18:46:52 +02:00
if op_code in GomspaceOpCodes.PRINT_SWITCH_V_I:
2022-07-04 15:22:53 +02:00
q.add_log_cmd("PDU1: Print Switches, Voltages, Currents")
q.add_pus_tc(
2022-08-22 11:47:12 +02:00
make_fsfw_action_cmd(
2022-07-04 15:22:53 +02:00
object_id=objb, action_id=GomspaceDeviceActionIds.PRINT_SWITCH_V_I
)
)
2022-04-04 18:46:52 +02:00
if op_code in GomspaceOpCodes.PRINT_LATCHUPS:
2022-07-04 15:22:53 +02:00
q.add_log_cmd("PDU1: Print Latchups")
q.add_pus_tc(
2022-08-22 11:47:12 +02:00
make_fsfw_action_cmd(
2022-07-04 15:22:53 +02:00
object_id=objb, action_id=GomspaceDeviceActionIds.PRINT_LATCHUPS
)
2022-03-14 14:46:00 +01:00
)
2020-12-29 11:29:03 +01:00
if PDU1TestProcedure.all or PDU1TestProcedure.ping:
2022-07-04 15:22:53 +02:00
q.add_log_cmd("PDU1: 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))
2020-12-29 11:29:03 +01:00
if PDU1TestProcedure.all or PDU1TestProcedure.read_temperature:
2022-07-04 15:22:53 +02:00
q.add_log_cmd("PDU1: Testing temperature reading")
q.add_pus_tc(
pack_get_param_command(
objb,
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-03-19 17:50:09 +01:00
)
2021-04-18 16:35:18 +02:00
if PDU1TestProcedure.all or PDU1TestProcedure.turn_channel_2_on:
2022-07-04 15:22:53 +02:00
q.add_log_cmd("PDU1: Turn channel 2 on (Star Tracker)")
q.add_pus_tc(
pack_set_param_command(
objb,
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
Channel.on,
)
2022-01-18 14:03:56 +01:00
)
2021-04-18 16:35:18 +02:00
if PDU1TestProcedure.all or PDU1TestProcedure.turn_channel_2_off:
2022-07-04 15:22:53 +02:00
q.add_log_cmd("PDU1: Turn channel 2 off (Star Tracker)")
q.add_pus_tc(
pack_set_param_command(
objb,
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
Channel.off,
)
2021-09-07 14:51:50 +02:00
)
2021-04-18 18:52:47 +02:00
if PDU1TestProcedure.all or PDU1TestProcedure.turn_channel_3_on:
2022-07-04 15:22:53 +02:00
q.add_log_cmd("PDU1: Turn channel 3 on (MTQ)")
q.add_pus_tc(
pack_set_param_command(
objb,
2022-08-11 14:45:24 +02:00
PduConfigTable.out_en_3.parameter_address,
PduConfigTable.out_en_3.parameter_size,
2022-07-04 15:22:53 +02:00
Channel.on,
)
2021-09-07 14:51:50 +02:00
)
2021-04-18 18:52:47 +02:00
if PDU1TestProcedure.all or PDU1TestProcedure.turn_channel_3_off:
2022-07-04 15:22:53 +02:00
q.add_log_cmd("PDU1: Turn channel 3 off (MTQ)")
q.add_pus_tc(
pack_set_param_command(
objb,
2022-08-11 14:45:24 +02:00
PduConfigTable.out_en_3.parameter_address,
PduConfigTable.out_en_3.parameter_size,
2022-07-04 15:22:53 +02:00
Channel.off,
)
2021-09-07 14:51:50 +02:00
)
if op_code in GomspaceOpCodes.SET_PARAM:
2022-08-11 18:10:15 +02:00
q.add_log_cmd(f"PDU1: {GsInfo.SET_PARAMETER}")
memory_address = int(input("Specify memory address: 0x"), 16)
2022-07-04 15:22:53 +02:00
memory_address = struct.pack("!H", memory_address)
parameter_size = int(input("Specify parameter size: "))
parameter = int(input("Specify parameter: "))
2022-07-04 15:22:53 +02:00
q.add_pus_tc(
gs.pack_set_param_command(
object_id.as_bytes, memory_address, parameter_size, parameter
)
)