eive-tmtc/eive_tmtc/tmtc/acs/acs_board.py

175 lines
4.7 KiB
Python
Raw Normal View History

import enum
2022-07-04 17:59:09 +02:00
2022-10-04 14:12:33 +02:00
from tmtccmd.config.tmtc import (
2023-11-29 17:27:24 +01:00
CmdTreeNode,
2022-10-04 14:12:33 +02:00
OpCodeEntry,
2023-11-22 14:13:00 +01:00
TmtcDefinitionWrapper,
tmtc_definitions_provider,
2022-10-04 14:12:33 +02:00
)
2023-11-10 19:23:06 +01:00
from tmtccmd.pus.s200_fsfw_mode import Mode
2023-11-22 14:13:00 +01:00
from tmtccmd.tmtc import DefaultPusQueueHelper
2023-11-22 14:13:00 +01:00
from eive_tmtc.config.definitions import CustomServiceList
from eive_tmtc.config.object_ids import ACS_BOARD_ASS_ID
2022-11-29 16:53:29 +01:00
from eive_tmtc.tmtc.common import pack_mode_cmd_with_info
2022-05-19 13:20:22 +02:00
2022-03-07 11:07:54 +01:00
class AcsOpCodes:
2022-10-04 14:12:33 +02:00
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"]
2023-01-16 14:13:06 +01:00
class DualSideSubmode(enum.IntEnum):
A_SIDE = 0
B_SIDE = 1
DUAL_SIDE = 2
2024-01-25 10:22:04 +01:00
def pack_acs_board_command(q: DefaultPusQueueHelper, cmd_str: str):
2023-11-22 10:17:05 +01:00
if cmd_str in AcsOpCodes.ACS_ASS_A_SIDE:
2022-10-04 14:46:00 +02:00
pack_mode_cmd_with_info(
2022-03-22 10:14:22 +01:00
object_id=ACS_BOARD_ASS_ID,
2023-01-16 15:05:33 +01:00
mode=Mode.NORMAL,
2023-01-16 14:13:06 +01:00
submode=DualSideSubmode.A_SIDE,
2022-07-04 17:59:09 +02:00
q=q,
2022-03-22 09:54:57 +01:00
info="Switching to ACS board assembly A side",
)
2023-11-22 10:17:05 +01:00
if cmd_str in AcsOpCodes.ACS_ASS_B_SIDE:
2022-10-04 14:46:00 +02:00
pack_mode_cmd_with_info(
2022-03-22 10:14:22 +01:00
object_id=ACS_BOARD_ASS_ID,
2023-01-16 15:05:33 +01:00
mode=Mode.NORMAL,
2023-01-16 14:13:06 +01:00
submode=DualSideSubmode.B_SIDE,
2022-07-04 17:59:09 +02:00
q=q,
2022-03-22 09:54:57 +01:00
info="Switching to ACS board assembly B side",
)
2023-11-22 10:17:05 +01:00
if cmd_str in AcsOpCodes.ACS_ASS_DUAL_MODE:
2022-10-04 14:46:00 +02:00
pack_mode_cmd_with_info(
2022-03-22 10:14:22 +01:00
object_id=ACS_BOARD_ASS_ID,
2023-01-16 15:05:33 +01:00
mode=Mode.NORMAL,
2023-01-16 14:13:06 +01:00
submode=DualSideSubmode.DUAL_SIDE,
2022-07-04 17:59:09 +02:00
q=q,
2022-03-22 09:54:57 +01:00
info="Switching to ACS board assembly dual mode",
)
2023-11-22 10:17:05 +01:00
if cmd_str in AcsOpCodes.ACS_ASS_A_ON:
2022-10-04 14:46:00 +02:00
pack_mode_cmd_with_info(
2022-03-22 10:14:22 +01:00
object_id=ACS_BOARD_ASS_ID,
2023-01-16 15:05:33 +01:00
mode=Mode.ON,
2023-01-16 14:13:06 +01:00
submode=DualSideSubmode.A_SIDE,
2022-07-04 17:59:09 +02:00
q=q,
2022-03-22 09:54:57 +01:00
info="Switching ACS board assembly A side on",
)
2023-11-22 10:17:05 +01:00
if cmd_str in AcsOpCodes.ACS_ASS_B_ON:
2022-10-04 14:46:00 +02:00
pack_mode_cmd_with_info(
2022-03-22 10:14:22 +01:00
object_id=ACS_BOARD_ASS_ID,
2023-01-16 15:05:33 +01:00
mode=Mode.ON,
2023-01-16 14:13:06 +01:00
submode=DualSideSubmode.B_SIDE,
2022-07-04 17:59:09 +02:00
q=q,
2022-03-22 09:54:57 +01:00
info="Switching ACS board assembly B side on",
)
2023-11-22 10:17:05 +01:00
if cmd_str in AcsOpCodes.ACS_ASS_DUAL_ON:
2022-10-04 14:46:00 +02:00
pack_mode_cmd_with_info(
2022-03-22 10:14:22 +01:00
object_id=ACS_BOARD_ASS_ID,
2023-01-16 15:05:33 +01:00
mode=Mode.ON,
2023-01-16 14:13:06 +01:00
submode=DualSideSubmode.B_SIDE,
2022-07-04 17:59:09 +02:00
q=q,
2022-03-22 09:54:57 +01:00
info="Switching ACS board assembly dual side on",
)
2023-11-22 10:17:05 +01:00
if cmd_str in AcsOpCodes.ACS_ASS_OFF:
2022-10-04 14:46:00 +02:00
pack_mode_cmd_with_info(
2022-03-22 10:14:22 +01:00
object_id=ACS_BOARD_ASS_ID,
2023-01-16 15:05:33 +01:00
mode=Mode.OFF,
2022-03-22 09:54:57 +01:00
submode=0,
2022-07-04 17:59:09 +02:00
q=q,
2022-03-22 09:54:57 +01:00
info="Switching to ACS board assembly off",
)
2022-03-22 10:14:22 +01:00
2023-11-29 17:27:24 +01:00
def create_acs_board_node() -> CmdTreeNode:
node = CmdTreeNode("acs_brd", "ACS Board", hide_children_which_are_leaves=True)
node.add_child(
CmdTreeNode(
2024-01-25 10:22:04 +01:00
AcsOpCodes.ACS_ASS_A_SIDE[1],
2023-11-29 17:27:24 +01:00
"Switch to ACS board A side",
)
)
node.add_child(
CmdTreeNode(
2024-01-25 10:22:04 +01:00
AcsOpCodes.ACS_ASS_B_SIDE[1],
2023-11-29 17:27:24 +01:00
"Switch to ACS board B side",
)
)
node.add_child(
CmdTreeNode(
2024-01-25 10:22:04 +01:00
AcsOpCodes.ACS_ASS_DUAL_MODE[1],
2023-11-29 17:27:24 +01:00
"Switch to ACS board dual mode",
)
)
node.add_child(
CmdTreeNode(
2024-01-25 10:22:04 +01:00
AcsOpCodes.ACS_ASS_A_ON[1],
2023-11-29 17:27:24 +01:00
"Switch ACS board A side on",
)
)
node.add_child(
CmdTreeNode(
2024-01-25 10:22:04 +01:00
AcsOpCodes.ACS_ASS_B_ON[1],
2023-11-29 17:27:24 +01:00
"Switch ACS board B side on",
)
)
node.add_child(
CmdTreeNode(
2024-01-25 10:22:04 +01:00
AcsOpCodes.ACS_ASS_DUAL_ON[1],
2023-11-29 17:27:24 +01:00
"Switch ACS board dual mode on",
)
)
node.add_child(
CmdTreeNode(
2024-01-25 10:22:04 +01:00
AcsOpCodes.ACS_ASS_OFF[1],
2023-11-29 17:27:24 +01:00
"Switch off ACS board",
)
)
return node
2022-10-04 14:12:33 +02:00
@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,
)