eive-tmtc/pus_tc/system/acs.py

72 lines
2.7 KiB
Python
Raw Normal View History

import enum
2022-03-07 11:07:54 +01:00
from tmtccmd.tc.definitions import TcQueueT, QueueCommands
from spacepackets.ecss.tc import PusTelecommand
from tmtccmd.tc.service_200_mode import pack_mode_data, Modes, Subservices
from config.object_ids import ACS_BOARD_ASS_ID
2022-03-07 11:07:54 +01:00
class AcsOpCodes:
ACS_ASS_A_SIDE = ["0", "a"]
ACS_ASS_B_SIDE = ["1", "b"]
ACS_ASS_DUAL_MODE = ["2", "d"]
2022-03-07 17:02:44 +01:00
ACS_ASS_OFF = ["3", "off"]
ACS_ASS_A_ON = ["4", "ao"]
ACS_ASS_B_ON = ["5", "bo"]
ACS_ASS_DUAL_ON = ["6", "do"]
class AcsBoardSubmodes(enum.IntEnum):
A_SIDE = 0
B_SIDE = 1
DUAL_SIDE = 2
def pack_acs_command(tc_queue: TcQueueT, op_code: str):
2022-03-07 11:07:54 +01:00
if op_code in AcsOpCodes.ACS_ASS_A_SIDE:
2022-03-07 11:26:44 +01:00
tc_queue.appendleft(
(QueueCommands.PRINT, "Switching to ACS board assembly A side")
)
2022-03-07 17:02:44 +01:00
command_acs_board(mode=Modes.NORMAL, submode=AcsBoardSubmodes.A_SIDE, tc_queue=tc_queue)
if op_code in AcsOpCodes.ACS_ASS_B_SIDE:
tc_queue.appendleft(
(QueueCommands.PRINT, "Switching to ACS board assembly B side")
)
command_acs_board(mode=Modes.NORMAL, submode=AcsBoardSubmodes.B_SIDE, tc_queue=tc_queue)
if op_code in AcsOpCodes.ACS_ASS_DUAL_MODE:
tc_queue.appendleft(
(QueueCommands.PRINT, "Switching to ACS board assembly dual mode")
)
command_acs_board(mode=Modes.NORMAL, submode=AcsBoardSubmodes.DUAL_SIDE, tc_queue=tc_queue)
if op_code in AcsOpCodes.ACS_ASS_A_ON:
tc_queue.appendleft(
(QueueCommands.PRINT, "Switching ACS board assembly A side on")
)
command_acs_board(mode=Modes.ON, submode=AcsBoardSubmodes.A_SIDE, tc_queue=tc_queue)
if op_code in AcsOpCodes.ACS_ASS_B_ON:
tc_queue.appendleft(
(QueueCommands.PRINT, "Switching ACS board assembly B side on")
)
command_acs_board(mode=Modes.ON, submode=AcsBoardSubmodes.B_SIDE, tc_queue=tc_queue)
if op_code in AcsOpCodes.ACS_ASS_DUAL_ON:
tc_queue.appendleft(
(QueueCommands.PRINT, "Switching ACS board assembly dual side on")
)
2022-03-07 17:02:44 +01:00
command_acs_board(mode=Modes.ON, submode=AcsBoardSubmodes.B_SIDE, tc_queue=tc_queue)
if op_code in AcsOpCodes.ACS_ASS_OFF:
tc_queue.appendleft(
(QueueCommands.PRINT, "Switching to ACS board assembly off")
2022-03-07 11:07:54 +01:00
)
2022-03-07 17:02:44 +01:00
command_acs_board(mode=Modes.OFF, submode=0, tc_queue=tc_queue)
def command_acs_board(mode: Modes, submode: int, tc_queue: TcQueueT):
mode_data = pack_mode_data(
object_id=ACS_BOARD_ASS_ID,
mode=mode,
submode=submode,
)
cmd = PusTelecommand(
service=200, subservice=Subservices.COMMAND_MODE_COMMAND, app_data=mode_data
)
tc_queue.appendleft(cmd.pack_command_tuple())