eive-tmtc/pus_tc/pdu1.py

141 lines
6.7 KiB
Python
Raw Normal View History

2020-12-29 11:29:03 +01:00
# -*- coding: utf-8 -*-
2021-09-17 13:06:53 +02:00
"""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-09-07 13:28:36 +02:00
import enum
2021-05-17 17:42:04 +02:00
from tmtccmd.config.definitions import QueueCommands
2020-12-29 11:29:03 +01:00
from tmtccmd.tc.packer import TcQueueT
2021-10-01 10:55:56 +02:00
from spacepackets.ecss.tc import PusTelecommand
2020-12-29 11:29:03 +01:00
from gomspace.gomspace_common import *
2021-03-19 17:39:52 +01:00
from pus_tc.p60dock import P60DockConfigTable
2020-12-29 11:29:03 +01:00
from gomspace.gomspace_pdu_definitions import *
2021-09-07 13:28:36 +02:00
class Pdu1OpCodes(enum.Enum):
STAR_TRACKER_ON = "1"
2021-09-17 13:06:53 +02:00
SUS_NOMINAL_ON = "3"
2021-09-07 13:28:36 +02:00
STAR_TRACKER_OFF = "4"
2021-09-17 13:06:53 +02:00
SUS_NOMINAL_OFF = "5"
2021-09-07 13:28:36 +02:00
ACS_A_SIDE_ON = "6"
ACS_A_SIDE_OFF = "7"
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.
"""
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
2021-04-18 18:52:47 +02:00
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)
2021-08-11 17:14:30 +02:00
turn_channel_3_off = False
2020-12-29 11:29:03 +01:00
2021-09-17 13:06:53 +02:00
def pack_pdu1_commands(object_id: bytearray, tc_queue: TcQueueT, op_code: str):
2021-08-11 16:49:32 +02:00
tc_queue.appendleft((QueueCommands.PRINT, "Commanding PDU1"))
2021-09-07 13:28:36 +02:00
if op_code == Pdu1OpCodes.STAR_TRACKER_ON.value:
2021-08-11 16:49:32 +02:00
tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Turn star tracker on"))
command = pack_set_param_command(object_id, PDUConfigTable.out_en_2.parameter_address,
PDUConfigTable.out_en_2.parameter_size, Channel.on)
tc_queue.appendleft(command.pack_command_tuple())
2021-09-17 13:06:53 +02:00
if op_code == Pdu1OpCodes.SUS_NOMINAL_ON.value:
2021-08-12 17:17:28 +02:00
tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Turn SUS nominal on"))
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-07 13:28:36 +02:00
if op_code == Pdu1OpCodes.STAR_TRACKER_OFF.value:
2021-08-16 10:03:40 +02:00
tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Turn star tracker off"))
command = pack_set_param_command(object_id, PDUConfigTable.out_en_2.parameter_address,
PDUConfigTable.out_en_2.parameter_size, Channel.off)
tc_queue.appendleft(command.pack_command_tuple())
2021-09-17 13:06:53 +02:00
if op_code == Pdu1OpCodes.SUS_NOMINAL_OFF.value:
tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Turn SUS nominal off"))
2021-09-17 13:06:53 +02: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-07 13:28:36 +02:00
if op_code == Pdu1OpCodes.ACS_A_SIDE_ON.value:
2021-08-17 10:37:13 +02:00
tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Turn ACS Side A on"))
2021-09-07 13:28:36 +02:00
command = pack_set_param_command(
object_id, PDUConfigTable.out_en_7.parameter_address,
PDUConfigTable.out_en_7.parameter_size, Channel.on
)
2021-08-17 10:37:13 +02:00
tc_queue.appendleft(command.pack_command_tuple())
2021-09-07 13:28:36 +02:00
if op_code == Pdu1OpCodes.ACS_A_SIDE_OFF.value:
2021-08-17 10:37:13 +02:00
tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Turn ACS Side A off"))
2021-09-07 13:28:36 +02:00
command = pack_set_param_command(
object_id, PDUConfigTable.out_en_7.parameter_address,
PDUConfigTable.out_en_7.parameter_size, Channel.off
)
2021-09-07 14:51:50 +02:00
tc_queue.appendleft(command.pack_command_tuple())
2021-09-20 11:21:53 +02:00
if op_code == Pdu1OpCodes.SUS_NOMINAL_ON.value:
tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Turn SUS nominal on"))
2021-09-16 11:50:25 +02: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-20 11:21:53 +02:00
if op_code == Pdu1OpCodes.SUS_NOMINAL_OFF.value:
tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Turn SUS nominal off"))
2021-09-16 11:50:25 +02: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-20 11:47:04 +02:00
if op_code == GomspaceOpCodes.PRINT_SWITCH_V_I.value:
tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Print Switches, Voltages, Currents"))
2021-09-20 11:21:53 +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-20 11:21:53 +02:00
)
tc_queue.appendleft(command.pack_command_tuple())
2020-12-29 11:29:03 +01:00
if PDU1TestProcedure.all or PDU1TestProcedure.ping:
2021-03-19 17:50:09 +01:00
tc_queue.appendleft((QueueCommands.PRINT, "PDU1: 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-11 16:49:32 +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 PDU1TestProcedure.all or PDU1TestProcedure.read_temperature:
2021-09-08 13:43:47 +02:00
tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Testing temperature reading"))
2021-03-19 17:50:09 +01:00
command = pack_get_param_command(
2021-08-11 16:49:32 +02:00
object_id, TableIds.hk, PDUHkTable.temperature.parameter_address,
2021-03-19 17:50:09 +01:00
PDUHkTable.temperature.parameter_size
)
2020-12-29 11:29:03 +01:00
tc_queue.appendleft(command.pack_command_tuple())
2021-04-18 16:35:18 +02:00
if PDU1TestProcedure.all or PDU1TestProcedure.turn_channel_2_on:
2021-04-18 18:52:47 +02:00
tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Turn channel 2 on (Star Tracker)"))
2021-09-07 14:51:50 +02:00
command = pack_set_param_command(
object_id, PDUConfigTable.out_en_2.parameter_address,
PDUConfigTable.out_en_2.parameter_size, Channel.on
)
2021-04-18 16:35:18 +02:00
tc_queue.appendleft(command.pack_command_tuple())
if PDU1TestProcedure.all or PDU1TestProcedure.turn_channel_2_off:
2021-04-18 18:52:47 +02:00
tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Turn channel 2 off (Star Tracker)"))
2021-09-07 14:51:50 +02:00
command = pack_set_param_command(
object_id, PDUConfigTable.out_en_2.parameter_address,
PDUConfigTable.out_en_2.parameter_size, Channel.off
)
2021-04-18 18:52:47 +02:00
tc_queue.appendleft(command.pack_command_tuple())
if PDU1TestProcedure.all or PDU1TestProcedure.turn_channel_3_on:
tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Turn channel 3 on (MTQ)"))
2021-09-07 14:51:50 +02:00
command = pack_set_param_command(
object_id, PDUConfigTable.out_en_3.parameter_address,
PDUConfigTable.out_en_3.parameter_size, Channel.on
)
2021-04-18 18:52:47 +02:00
tc_queue.appendleft(command.pack_command_tuple())
if PDU1TestProcedure.all or PDU1TestProcedure.turn_channel_3_off:
tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Turn channel 3 off (MTQ)"))
2021-09-07 14:51:50 +02:00
command = pack_set_param_command(
object_id, PDUConfigTable.out_en_3.parameter_address,
PDUConfigTable.out_en_3.parameter_size, Channel.off
)
2021-04-18 16:35:18 +02:00
tc_queue.appendleft(command.pack_command_tuple())