eive-tmtc/eive_tmtc/tmtc/acs/acs_board.py
Robin Mueller 3d007c32a3
All checks were successful
EIVE/-/pipeline/head This commit looks good
various fixes for ACS subsystem
2024-01-25 10:22:04 +01:00

175 lines
4.7 KiB
Python

import enum
from tmtccmd.config.tmtc import (
CmdTreeNode,
OpCodeEntry,
TmtcDefinitionWrapper,
tmtc_definitions_provider,
)
from tmtccmd.pus.s200_fsfw_mode import Mode
from tmtccmd.tmtc import DefaultPusQueueHelper
from eive_tmtc.config.definitions import CustomServiceList
from eive_tmtc.config.object_ids import ACS_BOARD_ASS_ID
from eive_tmtc.tmtc.common import pack_mode_cmd_with_info
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 DualSideSubmode(enum.IntEnum):
A_SIDE = 0
B_SIDE = 1
DUAL_SIDE = 2
def pack_acs_board_command(q: DefaultPusQueueHelper, cmd_str: str):
if cmd_str in AcsOpCodes.ACS_ASS_A_SIDE:
pack_mode_cmd_with_info(
object_id=ACS_BOARD_ASS_ID,
mode=Mode.NORMAL,
submode=DualSideSubmode.A_SIDE,
q=q,
info="Switching to ACS board assembly A side",
)
if cmd_str in AcsOpCodes.ACS_ASS_B_SIDE:
pack_mode_cmd_with_info(
object_id=ACS_BOARD_ASS_ID,
mode=Mode.NORMAL,
submode=DualSideSubmode.B_SIDE,
q=q,
info="Switching to ACS board assembly B side",
)
if cmd_str in AcsOpCodes.ACS_ASS_DUAL_MODE:
pack_mode_cmd_with_info(
object_id=ACS_BOARD_ASS_ID,
mode=Mode.NORMAL,
submode=DualSideSubmode.DUAL_SIDE,
q=q,
info="Switching to ACS board assembly dual mode",
)
if cmd_str in AcsOpCodes.ACS_ASS_A_ON:
pack_mode_cmd_with_info(
object_id=ACS_BOARD_ASS_ID,
mode=Mode.ON,
submode=DualSideSubmode.A_SIDE,
q=q,
info="Switching ACS board assembly A side on",
)
if cmd_str in AcsOpCodes.ACS_ASS_B_ON:
pack_mode_cmd_with_info(
object_id=ACS_BOARD_ASS_ID,
mode=Mode.ON,
submode=DualSideSubmode.B_SIDE,
q=q,
info="Switching ACS board assembly B side on",
)
if cmd_str in AcsOpCodes.ACS_ASS_DUAL_ON:
pack_mode_cmd_with_info(
object_id=ACS_BOARD_ASS_ID,
mode=Mode.ON,
submode=DualSideSubmode.B_SIDE,
q=q,
info="Switching ACS board assembly dual side on",
)
if cmd_str in AcsOpCodes.ACS_ASS_OFF:
pack_mode_cmd_with_info(
object_id=ACS_BOARD_ASS_ID,
mode=Mode.OFF,
submode=0,
q=q,
info="Switching to ACS board assembly off",
)
def create_acs_board_node() -> CmdTreeNode:
node = CmdTreeNode("acs_brd", "ACS Board", hide_children_which_are_leaves=True)
node.add_child(
CmdTreeNode(
AcsOpCodes.ACS_ASS_A_SIDE[1],
"Switch to ACS board A side",
)
)
node.add_child(
CmdTreeNode(
AcsOpCodes.ACS_ASS_B_SIDE[1],
"Switch to ACS board B side",
)
)
node.add_child(
CmdTreeNode(
AcsOpCodes.ACS_ASS_DUAL_MODE[1],
"Switch to ACS board dual mode",
)
)
node.add_child(
CmdTreeNode(
AcsOpCodes.ACS_ASS_A_ON[1],
"Switch ACS board A side on",
)
)
node.add_child(
CmdTreeNode(
AcsOpCodes.ACS_ASS_B_ON[1],
"Switch ACS board B side on",
)
)
node.add_child(
CmdTreeNode(
AcsOpCodes.ACS_ASS_DUAL_ON[1],
"Switch ACS board dual mode on",
)
)
node.add_child(
CmdTreeNode(
AcsOpCodes.ACS_ASS_OFF[1],
"Switch off ACS board",
)
)
return node
@tmtc_definitions_provider
def add_acs_board_cmds(defs: TmtcDefinitionWrapper):
oce = OpCodeEntry()
oce.add(
keys=AcsOpCodes.ACS_ASS_A_SIDE,
info="Switch to ACS board A side",
)
oce.add(
keys=AcsOpCodes.ACS_ASS_B_SIDE,
info="Switch to ACS board B side",
)
oce.add(
keys=AcsOpCodes.ACS_ASS_DUAL_MODE,
info="Switch to ACS board dual mode",
)
oce.add(
keys=AcsOpCodes.ACS_ASS_A_ON,
info="Switch ACS board A side on",
)
oce.add(
keys=AcsOpCodes.ACS_ASS_B_ON,
info="Switch ACS board B side on",
)
oce.add(
keys=AcsOpCodes.ACS_ASS_DUAL_ON,
info="Switch ACS board dual mode on",
)
oce.add(
keys=AcsOpCodes.ACS_ASS_OFF,
info="Switch off ACS board",
)
defs.add_service(
name=CustomServiceList.ACS_BRD_ASS.value,
info="ACS Board Assemblie",
op_code_entry=oce,
)