eive-tmtc/pus_tc/system/acs.py

124 lines
3.9 KiB
Python

import enum
from tmtccmd.tc.definitions import TcQueueT
from tmtccmd.tc.pus_200_fsfw_modes import Modes
from config.object_ids import ACS_BOARD_ASS_ID, SUS_BOARD_ASS_ID
from .common import command_assembly
class AcsOpCodes:
ACS_ASS_A_SIDE = ["0", "acs-a"]
ACS_ASS_B_SIDE = ["1", "acs-b"]
ACS_ASS_DUAL_MODE = ["2", "acs-d"]
ACS_ASS_OFF = ["3", "acs-off"]
ACS_ASS_A_ON = ["4", "acs-ao"]
ACS_ASS_B_ON = ["5", "acs-bo"]
ACS_ASS_DUAL_ON = ["6", "acs-do"]
class SusOpCodes:
SUS_ASS_NOM_SIDE = ["0", "sus-nom"]
SUS_ASS_RED_SIDE = ["1", "sus-red"]
SUS_ASS_DUAL_MODE = ["2", "sus-d"]
SUS_ASS_OFF = ["3", "sus-off"]
class DualSideSubmodes(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:
command_assembly(
object_id=ACS_BOARD_ASS_ID,
mode=Modes.NORMAL,
submode=DualSideSubmodes.A_SIDE,
tc_queue=tc_queue,
info="Switching to ACS board assembly A side",
)
if op_code in AcsOpCodes.ACS_ASS_B_SIDE:
command_assembly(
object_id=ACS_BOARD_ASS_ID,
mode=Modes.NORMAL,
submode=DualSideSubmodes.B_SIDE,
tc_queue=tc_queue,
info="Switching to ACS board assembly B side",
)
if op_code in AcsOpCodes.ACS_ASS_DUAL_MODE:
command_assembly(
object_id=ACS_BOARD_ASS_ID,
mode=Modes.NORMAL,
submode=DualSideSubmodes.DUAL_SIDE,
tc_queue=tc_queue,
info="Switching to ACS board assembly dual mode",
)
if op_code in AcsOpCodes.ACS_ASS_A_ON:
command_assembly(
object_id=ACS_BOARD_ASS_ID,
mode=Modes.ON,
submode=DualSideSubmodes.A_SIDE,
tc_queue=tc_queue,
info="Switching ACS board assembly A side on",
)
if op_code in AcsOpCodes.ACS_ASS_B_ON:
command_assembly(
object_id=ACS_BOARD_ASS_ID,
mode=Modes.ON,
submode=DualSideSubmodes.B_SIDE,
tc_queue=tc_queue,
info="Switching ACS board assembly B side on",
)
if op_code in AcsOpCodes.ACS_ASS_DUAL_ON:
command_assembly(
object_id=ACS_BOARD_ASS_ID,
mode=Modes.ON,
submode=DualSideSubmodes.B_SIDE,
tc_queue=tc_queue,
info="Switching ACS board assembly dual side on",
)
if op_code in AcsOpCodes.ACS_ASS_OFF:
command_assembly(
object_id=ACS_BOARD_ASS_ID,
mode=Modes.OFF,
submode=0,
tc_queue=tc_queue,
info="Switching to ACS board assembly off",
)
def pack_sus_cmds(tc_queue: TcQueueT, op_code: str):
if op_code in SusOpCodes.SUS_ASS_NOM_SIDE:
command_assembly(
object_id=SUS_BOARD_ASS_ID,
mode=Modes.NORMAL,
submode=DualSideSubmodes.A_SIDE,
tc_queue=tc_queue,
info="Switching to SUS board to nominal side",
)
if op_code in SusOpCodes.SUS_ASS_RED_SIDE:
command_assembly(
object_id=SUS_BOARD_ASS_ID,
mode=Modes.NORMAL,
submode=DualSideSubmodes.B_SIDE,
tc_queue=tc_queue,
info="Switching to SUS board to redundant side",
)
if op_code in SusOpCodes.SUS_ASS_OFF:
command_assembly(
object_id=SUS_BOARD_ASS_ID,
mode=Modes.OFF,
submode=0,
tc_queue=tc_queue,
info="Switching SUS board off",
)
if op_code in SusOpCodes.SUS_ASS_DUAL_MODE:
command_assembly(
object_id=SUS_BOARD_ASS_ID,
mode=Modes.NORMAL,
submode=DualSideSubmodes.DUAL_SIDE,
tc_queue=tc_queue,
info="Switching to SUS board to dual side",
)