eive-tmtc/eive_tmtc/tmtc/payload/subsystem.py
Robin Mueller 11d7ad0f8d
All checks were successful
EIVE/-/pipeline/head This commit looks good
start fixing PLOC tree
2024-04-09 11:32:57 +02:00

80 lines
2.4 KiB
Python

import enum
from typing import Dict, Tuple
from eive_tmtc.config.object_ids import PL_SUBSYSTEM_ID
from spacepackets.ecss import PusTelecommand
from eive_tmtc.tmtc.common import pack_mode_cmd_with_info
from tmtccmd.config import CmdTreeNode
from tmtccmd.tmtc import DefaultPusQueueHelper
from tmtccmd.pus.s200_fsfw_mode import Subservice as ModeSubservice
class ModeId(enum.IntEnum):
OFF = 0
SUPV_ONLY = 10
MPSOC_STREAM = 11
CAM_STREAM = 12
EARTH_OBSV = 13
SCEX = 14
class OpCode(str, enum.Enum):
OFF = "off"
REPORT_ALL_MODES = "report_modes"
MPSOC_STREAM = "mode_mpsoc_stream"
CAM_STREAM = "mode_cam_stream"
EARTH_OBSV = "mode_eart_obsv"
class Info(str, enum.Enum):
OFF = "Off Command"
REPORT_ALL_MODES = "Report all modes"
MPSOC_STREAM = "MPSoC Stream Mode"
CAM_STREAM = "Camera Stream Mode"
EARTH_OBSV = "Earth Observation Mode"
HANDLER_LIST: Dict[str, Tuple[int, str]] = {
OpCode.OFF: (ModeId.OFF, Info.OFF),
OpCode.MPSOC_STREAM: (ModeId.MPSOC_STREAM, Info.MPSOC_STREAM),
}
def create_payload_subsystem_cmd(q: DefaultPusQueueHelper, cmd_str: str):
info_prefix = "Payload Subsystem"
if cmd_str == OpCode.REPORT_ALL_MODES:
q.add_log_cmd(f"{info_prefix}: {Info.REPORT_ALL_MODES}")
q.add_pus_tc(
PusTelecommand(
service=200,
subservice=ModeSubservice.TC_MODE_ANNOUNCE_RECURSIVE,
app_data=PL_SUBSYSTEM_ID,
)
)
mode_info_tup = HANDLER_LIST.get(cmd_str)
assert mode_info_tup is not None
if mode_info_tup is None:
return
pack_mode_cmd_with_info(
object_id=PL_SUBSYSTEM_ID,
info=f"{info_prefix}: {mode_info_tup[1]}",
mode=mode_info_tup[0],
submode=0,
q=q,
)
def create_payload_subsystem_node() -> CmdTreeNode:
payload_node = CmdTreeNode("payload", "Payload Subsystem")
subsystem_node = CmdTreeNode("subsystem", "Subsystem Commands")
subsystem_node.add_child(CmdTreeNode(OpCode.OFF, Info.OFF))
subsystem_node.add_child(CmdTreeNode(OpCode.MPSOC_STREAM, Info.MPSOC_STREAM))
subsystem_node.add_child(CmdTreeNode(OpCode.EARTH_OBSV, Info.EARTH_OBSV))
subsystem_node.add_child(CmdTreeNode(OpCode.CAM_STREAM, Info.CAM_STREAM))
subsystem_node.add_child(
CmdTreeNode(OpCode.REPORT_ALL_MODES, Info.REPORT_ALL_MODES)
)
payload_node.add_child(subsystem_node)
return payload_node