63 lines
1.8 KiB
Python
63 lines
1.8 KiB
Python
import enum
|
|
from typing import Dict, Tuple
|
|
|
|
from spacepackets.ecss import PusTelecommand
|
|
from tmtccmd.config.tmtc import (
|
|
CmdTreeNode,
|
|
)
|
|
from tmtccmd.pus.s200_fsfw_mode import Mode
|
|
from tmtccmd.pus.s200_fsfw_mode import Subservice as ModeSubservices
|
|
from tmtccmd.tmtc import DefaultPusQueueHelper
|
|
|
|
from eive_tmtc.config.object_ids import EPS_SUBSYSTEM_ID
|
|
from eive_tmtc.tmtc.common import pack_mode_cmd_with_info
|
|
|
|
|
|
class OpCode(str, enum.Enum):
|
|
OFF = "off"
|
|
NML = "normal"
|
|
REPORT_ALL_MODES = "all_modes"
|
|
|
|
|
|
class Info(str, enum.Enum):
|
|
OFF = "Off Mode Command"
|
|
NML = "Normal Mode Command"
|
|
REPORT_ALL_MODES = "Report All Modes Recursively"
|
|
|
|
|
|
HANDLER_LIST: Dict[str, Tuple[int, int, str]] = {
|
|
OpCode.OFF: (Mode.OFF, 0, Info.OFF),
|
|
OpCode.NML: (Mode.NORMAL, 0, Info.NML),
|
|
}
|
|
|
|
|
|
def build_eps_subsystem_cmd(q: DefaultPusQueueHelper, cmd_str: str):
|
|
info_prefix = "EPS Subsystem"
|
|
if cmd_str in OpCode.REPORT_ALL_MODES:
|
|
q.add_log_cmd(f"{info_prefix}: {Info.REPORT_ALL_MODES}")
|
|
q.add_pus_tc(
|
|
PusTelecommand(
|
|
service=200,
|
|
subservice=ModeSubservices.TC_MODE_ANNOUNCE_RECURSIVE,
|
|
app_data=EPS_SUBSYSTEM_ID,
|
|
)
|
|
)
|
|
mode_info_tup = HANDLER_LIST.get(cmd_str)
|
|
if mode_info_tup is None:
|
|
return
|
|
pack_mode_cmd_with_info(
|
|
object_id=EPS_SUBSYSTEM_ID,
|
|
info=f"{info_prefix}: {mode_info_tup[2]}",
|
|
mode=mode_info_tup[0],
|
|
submode=mode_info_tup[1],
|
|
q=q,
|
|
)
|
|
|
|
|
|
def create_eps_subsystem_node() -> CmdTreeNode:
|
|
eps_node = CmdTreeNode("eps", "EPS Subsystem")
|
|
for cmd_str, (_, _, info) in HANDLER_LIST.items():
|
|
eps_node.add_child(CmdTreeNode(cmd_str, info))
|
|
eps_node.add_child(CmdTreeNode(OpCode.REPORT_ALL_MODES, Info.REPORT_ALL_MODES))
|
|
return eps_node
|