eive-tmtc/pus_tc/system/acs.py

84 lines
2.8 KiB
Python

import enum
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
class AcsOpCodes:
ACS_ASS_A_SIDE = ["0", "a"]
ACS_ASS_B_SIDE = ["1", "b"]
ACS_ASS_DUAL_MODE = ["2", "d"]
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):
if op_code in AcsOpCodes.ACS_ASS_A_SIDE:
tc_queue.appendleft(
(QueueCommands.PRINT, "Switching to ACS board assembly A side")
)
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")
)
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")
)
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())