eive-tmtc/pus_tc/devs/pdu2.py

325 lines
13 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
"""
2021-05-17 17:42:04 +02:00
from tmtccmd.config.definitions import QueueCommands
from tmtccmd.tc.packer import TcQueueT
from tmtccmd.tc.service_3_housekeeping import generate_one_hk_command, make_sid
2020-12-29 11:29:03 +01:00
from gomspace.gomspace_common import *
from gomspace.gomspace_pdu_definitions import *
from config.object_ids import PDU_2_HANDLER_ID
2021-09-07 14:51:50 +02:00
class Pdu2OpCodes(enum.Enum):
ACS_SIDE_B_ON = "1"
ACS_SIDE_B_OFF = "2"
2021-09-16 14:51:24 +02:00
SUS_REDUNDANT_ON = "3"
SUS_REDUNDANT_OFF = "4"
RW_ON = "5"
RW_OFF = "6"
2022-03-16 18:44:28 +01:00
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"
2022-01-18 14:03:56 +01:00
# There is not really a point of the on command, the SW can not be commanded if the OBC is off
2022-03-14 11:04:40 +01:00
Q7S_OFF = "32"
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-01-18 14:03:56 +01:00
def pack_pdu2_commands(object_id: bytearray, tc_queue: TcQueueT, op_code: str):
2021-02-09 12:35:10 +01:00
tc_queue.appendleft((QueueCommands.PRINT, "Testing PDU2"))
2020-12-29 11:29:03 +01:00
2021-09-07 14:51:50 +02:00
if op_code == Pdu2OpCodes.ACS_SIDE_B_ON.value:
2021-08-17 11:49:37 +02:00
tc_queue.appendleft((QueueCommands.PRINT, "PDU2: Turn ACS Side B on"))
2021-09-07 15:45:05 +02:00
command = pack_set_param_command(
2022-01-18 14:03:56 +01:00
object_id,
PDUConfigTable.out_en_7.parameter_address,
PDUConfigTable.out_en_7.parameter_size,
Channel.on,
2021-09-07 15:45:05 +02:00
)
2021-08-17 11:49:37 +02:00
tc_queue.appendleft(command.pack_command_tuple())
return tc_queue
2021-09-07 14:51:50 +02:00
if op_code == Pdu2OpCodes.ACS_SIDE_B_OFF.value:
2021-08-17 11:49:37 +02:00
tc_queue.appendleft((QueueCommands.PRINT, "PDU2: Turn ACS Side B off"))
2021-09-07 15:45:05 +02:00
command = pack_set_param_command(
2022-01-18 14:03:56 +01:00
object_id,
PDUConfigTable.out_en_7.parameter_address,
PDUConfigTable.out_en_7.parameter_size,
Channel.off,
2021-09-07 15:45:05 +02:00
)
2021-08-17 11:49:37 +02:00
tc_queue.appendleft(command.pack_command_tuple())
return tc_queue
2022-01-18 14:03:56 +01:00
if op_code == Pdu2OpCodes.Q7S_OFF.value:
tc_queue.appendleft((QueueCommands.PRINT, "Turning off Q7S OBC"))
command = pack_set_param_command(
object_id,
PDUConfigTable.out_en_0.parameter_address,
PDUConfigTable.out_en_0.parameter_size,
Channel.off,
)
tc_queue.appendleft(command.pack_command_tuple())
2021-09-16 14:51:24 +02:00
if op_code == Pdu2OpCodes.SUS_REDUNDANT_ON.value:
tc_queue.appendleft((QueueCommands.PRINT, "PDU2: Turn SUS redundant on"))
2022-01-18 14:03:56 +01:00
command = pack_set_param_command(
object_id,
PDUConfigTable.out_en_4.parameter_address,
PDUConfigTable.out_en_4.parameter_size,
Channel.on,
)
tc_queue.appendleft(command.pack_command_tuple())
2021-09-16 14:51:24 +02:00
if op_code == Pdu2OpCodes.SUS_REDUNDANT_OFF.value:
tc_queue.appendleft((QueueCommands.PRINT, "PDU2: Turn SUS redundant off"))
2022-01-18 14:03:56 +01:00
command = pack_set_param_command(
object_id,
PDUConfigTable.out_en_4.parameter_address,
PDUConfigTable.out_en_4.parameter_size,
Channel.off,
)
tc_queue.appendleft(command.pack_command_tuple())
2021-09-16 14:51:24 +02:00
if op_code == Pdu2OpCodes.RW_ON.value:
tc_queue.appendleft((QueueCommands.PRINT, "PDU2: Turn reaction wheels on"))
2021-09-15 18:48:28 +02:00
command = pack_set_param_command(
2022-01-18 14:03:56 +01:00
object_id,
PDUConfigTable.out_en_2.parameter_address,
PDUConfigTable.out_en_2.parameter_size,
Channel.on,
2021-09-15 18:48:28 +02:00
)
tc_queue.appendleft(command.pack_command_tuple())
2021-09-16 14:51:24 +02:00
if op_code == Pdu2OpCodes.RW_OFF.value:
tc_queue.appendleft((QueueCommands.PRINT, "PDU2: Turn reaction wheels off"))
2022-01-18 14:03:56 +01:00
command = pack_set_param_command(
object_id,
PDUConfigTable.out_en_2.parameter_address,
PDUConfigTable.out_en_2.parameter_size,
Channel.off,
)
2021-09-15 18:48:28 +02:00
tc_queue.appendleft(command.pack_command_tuple())
2022-03-16 18:44:28 +01:00
if op_code == Pdu2OpCodes.PL_PCDU_VBAT_NOM_ON.value:
tc_queue.appendleft(
(QueueCommands.PRINT, "PDU2: Turn PDU2 PL PCDU Channel 1 on")
)
command = pack_set_param_command(
object_id,
PDUConfigTable.out_en_1.parameter_address,
PDUConfigTable.out_en_1.parameter_size,
Channel.on,
)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == Pdu2OpCodes.PL_PCDU_VBAT_NOM_OFF.value:
tc_queue.appendleft(
(QueueCommands.PRINT, "PDU2: Turn PDU2 PL PCDU Channel 1 off")
)
command = pack_set_param_command(
object_id,
PDUConfigTable.out_en_1.parameter_address,
PDUConfigTable.out_en_1.parameter_size,
Channel.off,
)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == Pdu2OpCodes.PL_PCDU_VBAT_RED_ON.value:
tc_queue.appendleft(
(QueueCommands.PRINT, "PDU2: Turn PDU2 PL PCDU Channel 6 on")
)
command = pack_set_param_command(
object_id,
PDUConfigTable.out_en_6.parameter_address,
PDUConfigTable.out_en_6.parameter_size,
Channel.off,
)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == Pdu2OpCodes.PL_PCDU_VBAT_RED_OFF.value:
tc_queue.appendleft(
(QueueCommands.PRINT, "PDU2: Turn PDU2 PL PCDU Channel 6 off")
)
command = pack_set_param_command(
object_id,
PDUConfigTable.out_en_6.parameter_address,
PDUConfigTable.out_en_6.parameter_size,
Channel.off,
)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == Pdu2OpCodes.TCS_HEATER_IN_ON.value:
tc_queue.appendleft((QueueCommands.PRINT, "PDU2: Turn TCS Heater Input on"))
command = pack_set_param_command(
object_id,
PDUConfigTable.out_en_3.parameter_address,
PDUConfigTable.out_en_3.parameter_size,
Channel.on,
)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == Pdu2OpCodes.TCS_HEATER_IN_OFF.value:
tc_queue.appendleft((QueueCommands.PRINT, "PDU2: Turn TCS Heater Input off"))
command = pack_set_param_command(
object_id,
PDUConfigTable.out_en_3.parameter_address,
PDUConfigTable.out_en_3.parameter_size,
Channel.off,
)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == Pdu2OpCodes.SOLAR_ARRAY_DEPL_ON.value:
tc_queue.appendleft(
(QueueCommands.PRINT, "PDU2: Turn Solar Array Deployment On")
)
command = pack_set_param_command(
object_id,
PDUConfigTable.out_en_5.parameter_address,
PDUConfigTable.out_en_5.parameter_size,
Channel.on,
)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == Pdu2OpCodes.SOLAR_ARRAY_DEPL_OFF.value:
tc_queue.appendleft(
(QueueCommands.PRINT, "PDU2: Turn Solar Array Deployment Off")
)
command = pack_set_param_command(
object_id,
PDUConfigTable.out_en_5.parameter_address,
PDUConfigTable.out_en_5.parameter_size,
Channel.off,
)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == GomspaceOpCodes.REQUEST_HK_ONCE.value:
tc_queue.appendleft((QueueCommands.PRINT, "PDU2: Requesting HK Table Once"))
hk_sid = make_sid(object_id=PDU_2_HANDLER_ID, set_id=SetIds.PDU_2)
command = generate_one_hk_command(sid=hk_sid, ssc=0)
tc_queue.appendleft(command.pack_command_tuple())
2021-09-20 11:47:04 +02:00
if op_code == GomspaceOpCodes.PRINT_SWITCH_V_I.value:
2022-01-18 14:03:56 +01:00
tc_queue.appendleft(
(QueueCommands.PRINT, "PDU2: Print Switches, Currents, Voltahes")
)
2021-09-16 14:51:24 +02:00
command = generate_action_command(
2021-09-20 11:47:04 +02:00
object_id=object_id, action_id=GomspaceDeviceActionIds.PRINT_SWITCH_V_I
2021-09-07 14:51:50 +02:00
)
tc_queue.appendleft(command.pack_command_tuple())
2022-03-14 15:13:39 +01:00
if op_code == GomspaceOpCodes.PRINT_LATCHUPS.value:
2022-03-16 18:44:28 +01:00
tc_queue.appendleft((QueueCommands.PRINT, "PDU2: Print Latchups"))
2022-03-14 14:46:00 +01:00
command = generate_action_command(
object_id=object_id, action_id=GomspaceDeviceActionIds.PRINT_LATCHUPS
)
tc_queue.appendleft(command.pack_command_tuple())
2020-12-29 11:29:03 +01:00
if PDU2TestProcedure.all or PDU2TestProcedure.reboot:
2021-02-09 12:35:10 +01:00
tc_queue.appendleft((QueueCommands.PRINT, "PDU2: Reboot"))
2021-08-17 11:49:37 +02:00
command = pack_reboot_command(object_id)
2020-12-29 11:29:03 +01:00
tc_queue.appendleft(command.pack_command_tuple())
if PDU2TestProcedure.all or PDU2TestProcedure.read_gnd_wdt:
2022-01-18 14:03:56 +01:00
tc_queue.appendleft(
(QueueCommands.PRINT, "PDU2: Reading ground watchdog timer value")
)
2021-09-07 14:51:50 +02:00
command = pack_get_param_command(
2022-01-18 14:03:56 +01:00
object_id,
TableIds.hk,
PDUHkTable.wdt_gnd_left.parameter_address,
PDUHkTable.wdt_gnd_left.parameter_size,
2021-09-07 14:51:50 +02:00
)
2020-12-29 11:29:03 +01:00
tc_queue.appendleft(command.pack_command_tuple())
if PDU2TestProcedure.all or PDU2TestProcedure.gnd_wdt_reset:
2022-01-18 14:03:56 +01:00
tc_queue.appendleft(
(QueueCommands.PRINT, "PDU2: Testing ground watchdog reset")
)
2021-08-17 11:49:37 +02:00
command = pack_gnd_wdt_reset_command(object_id)
2020-12-29 11:29:03 +01:00
tc_queue.appendleft(command.pack_command_tuple())
if PDU2TestProcedure.all or PDU2TestProcedure.ping:
2021-02-09 12:35:10 +01:00
tc_queue.appendleft((QueueCommands.PRINT, "PDU2: Ping Test"))
2020-12-29 11:29:03 +01:00
ping_data = bytearray([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
2021-08-17 11:49:37 +02:00
command = pack_ping_command(object_id, ping_data)
2020-12-29 11:29:03 +01:00
tc_queue.appendleft(command.pack_command_tuple())
if PDU2TestProcedure.all or PDU2TestProcedure.channel_2_on:
2021-09-07 14:51:50 +02:00
tc_queue.appendleft(
2022-01-18 14:03:56 +01:00
(
QueueCommands.PRINT,
"PDU2: Testing setting output channel 2 on (TCS Heater)",
)
)
command = pack_set_param_command(
object_id,
PDUConfigTable.out_en_2.parameter_address,
PDUConfigTable.out_en_2.parameter_size,
Channel.on,
2021-09-07 14:51:50 +02:00
)
2020-12-29 11:29:03 +01:00
tc_queue.appendleft(command.pack_command_tuple())
2021-02-06 16:35:53 +01:00
if PDU2TestProcedure.all or PDU2TestProcedure.read_temperature:
2021-09-08 13:43:47 +02:00
tc_queue.appendleft((QueueCommands.PRINT, "PDU2: Testing temperature reading"))
2021-09-07 14:51:50 +02:00
command = pack_get_param_command(
2022-01-18 14:03:56 +01:00
object_id,
TableIds.hk,
PDUHkTable.temperature.parameter_address,
PDUHkTable.temperature.parameter_size,
2021-09-07 14:51:50 +02:00
)
2020-12-29 11:29:03 +01:00
tc_queue.appendleft(command.pack_command_tuple())
if PDU2TestProcedure.all or PDU2TestProcedure.read_channel_2_state:
2021-09-07 14:51:50 +02:00
tc_queue.appendleft(
(QueueCommands.PRINT, "PDU2: Reading output channel 2 state (TCS Heater)")
)
command = pack_get_param_command(
2022-01-18 14:03:56 +01:00
object_id,
TableIds.config,
PDUConfigTable.out_en_2.parameter_address,
PDUConfigTable.out_en_2.parameter_size,
2021-09-07 14:51:50 +02:00
)
2020-12-29 11:29:03 +01:00
tc_queue.appendleft(command.pack_command_tuple())
if PDU2TestProcedure.all or PDU2TestProcedure.read_cur_lu_lim_0:
2021-09-07 14:51:50 +02:00
tc_queue.appendleft(
2022-01-18 14:03:56 +01:00
(
QueueCommands.PRINT,
"PDU2: Reading current limit value of output channel 0 (OBC)",
)
2021-09-07 14:51:50 +02:00
)
command = pack_get_param_command(
2022-01-18 14:03:56 +01:00
object_id,
TableIds.config,
PDUConfigTable.cur_lu_lim_0.parameter_address,
PDUConfigTable.cur_lu_lim_0.parameter_size,
2021-09-07 14:51:50 +02:00
)
2020-12-29 11:29:03 +01:00
tc_queue.appendleft(command.pack_command_tuple())
if PDU2TestProcedure.all or PDU2TestProcedure.channel_2_off:
2022-01-18 14:03:56 +01:00
tc_queue.appendleft(
(QueueCommands.PRINT, "PDU2: Testing setting output channel 2 off")
)
command = pack_set_param_command(
object_id,
PDUConfigTable.out_en_2.parameter_address,
PDUConfigTable.out_en_2.parameter_size,
Channel.off,
)
2020-12-29 11:29:03 +01:00
tc_queue.appendleft(command.pack_command_tuple())
2021-02-06 16:35:53 +01:00
if PDU2TestProcedure.all or PDU2TestProcedure.request_hk_table:
2022-01-18 14:03:56 +01:00
tc_queue.appendleft(
(QueueCommands.PRINT, "PDU2: Requesting housekeeping table")
)
2021-08-17 11:49:37 +02:00
command = pack_request_full_hk_table_command(object_id)
2021-02-06 16:35:53 +01:00
tc_queue.appendleft(command.pack_command_tuple())