eive-tmtc/pus_tc/devs/pdu1.py

306 lines
12 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
2021-05-17 17:42:04 +02:00
from tmtccmd.config.definitions import QueueCommands
from tmtccmd.tc.packer import TcQueueT
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
2021-09-07 13:28:36 +02:00
class Pdu1OpCodes(enum.Enum):
2022-03-14 09:56:34 +01:00
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"
2022-02-04 17:05:27 +01:00
# Solar Cell Experiment
2022-03-14 09:56:34 +01:00
SCEX_ON = "12"
SCEX_OFF = "13"
2022-03-17 19:50:25 +01:00
PLOC_ON = "14"
PLOC_OFF = "15"
2022-03-14 09:56:34 +01:00
TESTS = "32"
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-05-23 11:24:55 +02:00
def pack_pdu1_commands(object_id: ObjectId, tc_queue: TcQueueT, op_code: str):
2021-08-11 16:49:32 +02:00
tc_queue.appendleft((QueueCommands.PRINT, "Commanding PDU1"))
2022-05-23 11:24:55 +02:00
objb = object_id.as_bytes
2021-10-12 17:50:20 +02:00
if op_code == Pdu1OpCodes.TCS_BOARD_ON.value:
tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Turn TCS board on"))
command = pack_set_param_command(
2022-05-23 11:24:55 +02:00
objb,
2022-01-18 14:03:56 +01:00
PDUConfigTable.out_en_0.parameter_address,
2022-03-14 11:04:40 +01:00
PDUConfigTable.out_en_0.parameter_size,
2022-01-18 14:03:56 +01:00
Channel.on,
2021-10-12 17:50:20 +02:00
)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == Pdu1OpCodes.TCS_BOARD_OFF.value:
tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Turn TCS board off"))
command = pack_set_param_command(
2022-05-23 11:24:55 +02:00
objb,
2022-01-18 14:03:56 +01:00
PDUConfigTable.out_en_0.parameter_address,
2022-03-14 11:04:40 +01:00
PDUConfigTable.out_en_0.parameter_size,
2022-01-18 14:03:56 +01:00
Channel.off,
2021-10-12 17:50:20 +02:00
)
tc_queue.appendleft(command.pack_command_tuple())
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"))
2021-10-12 17:50:20 +02:00
command = pack_set_param_command(
2022-05-23 11:24:55 +02:00
objb,
2022-01-18 14:03:56 +01:00
PDUConfigTable.out_en_2.parameter_address,
PDUConfigTable.out_en_2.parameter_size,
Channel.on,
2021-10-12 17:50:20 +02:00
)
2021-08-11 16:49:32 +02:00
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"))
2022-01-18 14:03:56 +01:00
command = pack_set_param_command(
2022-05-23 11:24:55 +02:00
objb,
2022-01-18 14:03:56 +01:00
PDUConfigTable.out_en_2.parameter_address,
PDUConfigTable.out_en_2.parameter_size,
Channel.off,
)
tc_queue.appendleft(command.pack_command_tuple())
2021-12-02 08:01:18 +01:00
if op_code == Pdu1OpCodes.SUS_NOMINAL_ON.value:
tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Turn SUS nominal on"))
2022-01-18 14:03:56 +01:00
command = pack_set_param_command(
2022-05-23 11:24:55 +02:00
objb,
2022-01-18 14:03:56 +01:00
PDUConfigTable.out_en_4.parameter_address,
PDUConfigTable.out_en_4.parameter_size,
Channel.on,
)
2021-12-02 08:01:18 +01:00
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(
2022-05-23 11:24:55 +02:00
objb,
2022-01-18 14:03:56 +01:00
PDUConfigTable.out_en_4.parameter_address,
PDUConfigTable.out_en_4.parameter_size,
Channel.off,
2021-09-17 13:06:53 +02:00
)
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(
2022-05-23 11:24:55 +02:00
objb,
2022-01-18 14:03:56 +01:00
PDUConfigTable.out_en_7.parameter_address,
PDUConfigTable.out_en_7.parameter_size,
Channel.on,
2021-09-07 13:28:36 +02:00
)
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(
2022-05-23 11:24:55 +02:00
objb,
2022-01-18 14:03:56 +01:00
PDUConfigTable.out_en_7.parameter_address,
PDUConfigTable.out_en_7.parameter_size,
Channel.off,
2021-09-07 13:28:36 +02:00
)
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(
2022-05-23 11:24:55 +02:00
objb,
2022-01-18 14:03:56 +01:00
PDUConfigTable.out_en_4.parameter_address,
PDUConfigTable.out_en_4.parameter_size,
Channel.off,
2021-09-16 11:50:25 +02:00
)
tc_queue.appendleft(command.pack_command_tuple())
2022-02-04 17:05:27 +01:00
if op_code == Pdu1OpCodes.SCEX_ON.value:
2022-02-27 16:17:24 +01:00
tc_queue.appendleft(
(QueueCommands.PRINT, "PDU1: Turn Solar Cell Experiment on")
)
2022-02-04 17:05:27 +01:00
command = pack_set_param_command(
2022-05-23 11:24:55 +02:00
objb,
2022-02-04 17:05:27 +01:00
PDUConfigTable.out_en_5.parameter_address,
PDUConfigTable.out_en_5.parameter_size,
Channel.on,
)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == Pdu1OpCodes.SCEX_OFF.value:
2022-02-27 16:17:24 +01:00
tc_queue.appendleft(
(QueueCommands.PRINT, "PDU1: Turn Solar Cell Experiment off")
)
2022-02-04 17:05:27 +01:00
command = pack_set_param_command(
2022-05-23 11:24:55 +02:00
objb,
2022-02-04 17:05:27 +01:00
PDUConfigTable.out_en_5.parameter_address,
PDUConfigTable.out_en_5.parameter_size,
Channel.off,
)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == Pdu1OpCodes.SYRLINKS_ON.value:
tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Turn Syrlinks on"))
command = pack_set_param_command(
2022-05-23 11:24:55 +02:00
objb,
2022-01-18 14:03:56 +01:00
PDUConfigTable.out_en_1.parameter_address,
PDUConfigTable.out_en_1.parameter_size,
Channel.on,
)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == Pdu1OpCodes.SYRLINKS_OFF.value:
tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Turn Syrlinks off"))
command = pack_set_param_command(
2022-05-23 11:24:55 +02:00
objb,
2022-01-18 14:03:56 +01:00
PDUConfigTable.out_en_1.parameter_address,
PDUConfigTable.out_en_1.parameter_size,
Channel.off,
)
tc_queue.appendleft(command.pack_command_tuple())
2022-01-27 14:53:10 +01:00
if op_code == Pdu1OpCodes.MGT_ON.value:
tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Turn MGT on"))
command = pack_set_param_command(
2022-05-23 11:24:55 +02:00
objb,
2022-01-27 14:53:10 +01:00
PDUConfigTable.out_en_3.parameter_address,
PDUConfigTable.out_en_3.parameter_size,
Channel.on,
)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == Pdu1OpCodes.MGT_OFF.value:
tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Turn MGT off"))
command = pack_set_param_command(
2022-05-23 11:24:55 +02:00
objb,
2022-01-27 14:53:10 +01:00
PDUConfigTable.out_en_3.parameter_address,
PDUConfigTable.out_en_3.parameter_size,
Channel.off,
)
tc_queue.appendleft(command.pack_command_tuple())
2022-03-17 19:50:25 +01:00
if op_code == Pdu1OpCodes.PLOC_ON.value:
tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Turn PLOC on"))
command = pack_set_param_command(
2022-05-23 11:24:55 +02:00
objb,
2022-03-17 19:50:25 +01:00
PDUConfigTable.out_en_6.parameter_address,
PDUConfigTable.out_en_6.parameter_size,
Channel.on,
)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == Pdu1OpCodes.PLOC_OFF.value:
tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Turn PLOC off"))
command = pack_set_param_command(
2022-05-23 11:24:55 +02:00
objb,
2022-03-17 19:50:25 +01:00
PDUConfigTable.out_en_6.parameter_address,
PDUConfigTable.out_en_6.parameter_size,
Channel.off,
)
tc_queue.appendleft(command.pack_command_tuple())
2022-04-08 14:46:01 +02:00
if op_code in GomspaceOpCodes.REQUEST_CORE_HK_ONCE:
2022-04-12 16:10:51 +02:00
tc_queue.appendleft((QueueCommands.PRINT, f"PDU1: {Info.REQUEST_CORE_HK_ONCE}"))
hk_sid = make_sid(object_id=PDU_1_HANDLER_ID, set_id=SetIds.PDU_1_CORE)
command = generate_one_diag_command(sid=hk_sid, ssc=0)
tc_queue.appendleft(command.pack_command_tuple())
if op_code in GomspaceOpCodes.REQUEST_AUX_HK_ONCE:
tc_queue.appendleft((QueueCommands.PRINT, f"PDU1: {Info.REQUEST_AUX_HK_ONCE}"))
hk_sid = make_sid(object_id=PDU_1_HANDLER_ID, set_id=SetIds.PDU_1_AUX)
command = generate_one_hk_command(sid=hk_sid, ssc=0)
tc_queue.appendleft(command.pack_command_tuple())
2022-04-04 18:46:52 +02:00
if op_code in GomspaceOpCodes.PRINT_SWITCH_V_I:
tc_queue.appendleft(
(QueueCommands.PRINT, "PDU1: Print Switches, Voltages, Currents")
)
command = generate_action_command(
2022-05-23 11:24:55 +02:00
object_id=objb, action_id=GomspaceDeviceActionIds.PRINT_SWITCH_V_I
)
tc_queue.appendleft(command.pack_command_tuple())
2022-04-04 18:46:52 +02:00
if op_code in GomspaceOpCodes.PRINT_LATCHUPS:
2022-03-16 18:44:28 +01:00
tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Print Latchups"))
2022-03-14 14:46:00 +01:00
command = generate_action_command(
2022-05-23 11:24:55 +02:00
object_id=objb, action_id=GomspaceDeviceActionIds.PRINT_LATCHUPS
2022-03-14 14:46:00 +01: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(
2022-05-23 11:24:55 +02:00
objb,
2022-01-18 14:03:56 +01:00
TableIds.hk,
PDUHkTable.temperature.parameter_address,
PDUHkTable.temperature.parameter_size,
2021-03-19 17:50:09 +01:00
)
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:
2022-01-18 14:03:56 +01: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(
2022-05-23 11:24:55 +02:00
objb,
2022-01-18 14:03:56 +01:00
PDUConfigTable.out_en_2.parameter_address,
PDUConfigTable.out_en_2.parameter_size,
Channel.on,
2021-09-07 14:51:50 +02:00
)
2021-04-18 16:35:18 +02:00
tc_queue.appendleft(command.pack_command_tuple())
if PDU1TestProcedure.all or PDU1TestProcedure.turn_channel_2_off:
2022-01-18 14:03:56 +01: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(
2022-05-23 11:24:55 +02:00
objb,
2022-01-18 14:03:56 +01:00
PDUConfigTable.out_en_2.parameter_address,
PDUConfigTable.out_en_2.parameter_size,
Channel.off,
2021-09-07 14:51:50 +02:00
)
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(
2022-05-23 11:24:55 +02:00
objb,
2022-01-18 14:03:56 +01:00
PDUConfigTable.out_en_3.parameter_address,
PDUConfigTable.out_en_3.parameter_size,
Channel.on,
2021-09-07 14:51:50 +02:00
)
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(
2022-05-23 11:24:55 +02:00
objb,
2022-01-18 14:03:56 +01:00
PDUConfigTable.out_en_3.parameter_address,
PDUConfigTable.out_en_3.parameter_size,
Channel.off,
2021-09-07 14:51:50 +02:00
)
2021-04-18 16:35:18 +02:00
tc_queue.appendleft(command.pack_command_tuple())
if op_code in GomspaceOpCodes.SET_PARAM:
tc_queue.appendleft(
(QueueCommands.PRINT, 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: "))
command = gs.pack_set_param_command(object_id.as_bytes, memory_address, parameter_size, parameter)
tc_queue.appendleft(command.pack_command_tuple())