eive-tmtc/eive_tmtc/tmtc/power/subsystem.py

63 lines
1.8 KiB
Python
Raw Normal View History

2023-10-09 15:43:03 +02:00
import enum
2023-11-22 13:51:33 +01:00
from typing import Dict, Tuple
2023-10-09 15:43:03 +02:00
from spacepackets.ecss import PusTelecommand
from tmtccmd.config.tmtc import (
2023-11-22 13:51:33 +01:00
CmdTreeNode,
2023-10-09 15:43:03 +02:00
)
2023-11-22 13:51:33 +01:00
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
2023-10-09 15:43:03 +02:00
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),
}
2023-11-22 13:51:33 +01:00
def build_eps_subsystem_cmd(q: DefaultPusQueueHelper, cmd_str: str):
2023-10-09 15:43:03 +02:00
info_prefix = "EPS Subsystem"
2023-11-22 13:51:33 +01:00
if cmd_str in OpCode.REPORT_ALL_MODES:
2023-10-09 15:43:03 +02:00
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,
)
)
2023-11-22 13:51:33 +01:00
mode_info_tup = HANDLER_LIST.get(cmd_str)
2023-10-09 15:43:03 +02:00
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,
)
2023-11-22 13:51:33 +01:00
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