2022-11-03 22:16:10 +01:00
|
|
|
import enum
|
|
|
|
from typing import Dict, Tuple
|
|
|
|
|
2022-11-29 16:53:29 +01:00
|
|
|
from eive_tmtc.config.object_ids import PL_SUBSYSTEM_ID
|
2022-11-03 22:16:10 +01:00
|
|
|
from spacepackets.ecss import PusTelecommand
|
2022-11-29 16:53:29 +01:00
|
|
|
from eive_tmtc.tmtc.common import pack_mode_cmd_with_info
|
2023-11-22 13:51:33 +01:00
|
|
|
from tmtccmd.config import CmdTreeNode
|
|
|
|
from tmtccmd.tmtc import DefaultPusQueueHelper
|
2023-11-10 19:23:06 +01:00
|
|
|
from tmtccmd.pus.s200_fsfw_mode import Subservice as ModeSubservice
|
2022-11-03 22:16:10 +01:00
|
|
|
|
|
|
|
|
2023-08-15 13:20:43 +02:00
|
|
|
class ModeId(enum.IntEnum):
|
2023-02-06 20:13:15 +01:00
|
|
|
OFF = 0
|
|
|
|
SUPV_ONLY = 10
|
|
|
|
MPSOC_STREAM = 11
|
|
|
|
CAM_STREAM = 12
|
|
|
|
EARTH_OBSV = 13
|
|
|
|
SCEX = 14
|
|
|
|
|
|
|
|
|
2023-01-16 14:13:06 +01:00
|
|
|
class OpCode(str, enum.Enum):
|
2022-11-03 22:16:10 +01:00
|
|
|
OFF = "off"
|
|
|
|
REPORT_ALL_MODES = "report_modes"
|
2024-04-09 11:32:57 +02:00
|
|
|
MPSOC_STREAM = "mode_mpsoc_stream"
|
|
|
|
CAM_STREAM = "mode_cam_stream"
|
|
|
|
EARTH_OBSV = "mode_eart_obsv"
|
2022-11-03 22:16:10 +01:00
|
|
|
|
|
|
|
|
|
|
|
class Info(str, enum.Enum):
|
|
|
|
OFF = "Off Command"
|
|
|
|
REPORT_ALL_MODES = "Report all modes"
|
2024-04-09 11:32:57 +02:00
|
|
|
MPSOC_STREAM = "MPSoC Stream Mode"
|
|
|
|
CAM_STREAM = "Camera Stream Mode"
|
|
|
|
EARTH_OBSV = "Earth Observation Mode"
|
2022-11-03 22:16:10 +01:00
|
|
|
|
|
|
|
|
|
|
|
HANDLER_LIST: Dict[str, Tuple[int, str]] = {
|
2023-02-06 20:22:36 +01:00
|
|
|
OpCode.OFF: (ModeId.OFF, Info.OFF),
|
2024-04-09 11:32:57 +02:00
|
|
|
OpCode.MPSOC_STREAM: (ModeId.MPSOC_STREAM, Info.MPSOC_STREAM),
|
2022-11-03 22:16:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-04-09 11:32:57 +02:00
|
|
|
def create_payload_subsystem_cmd(q: DefaultPusQueueHelper, cmd_str: str):
|
|
|
|
info_prefix = "Payload Subsystem"
|
2023-11-22 13:51:33 +01:00
|
|
|
if cmd_str == OpCode.REPORT_ALL_MODES:
|
2022-11-03 22:16:10 +01:00
|
|
|
q.add_log_cmd(f"{info_prefix}: {Info.REPORT_ALL_MODES}")
|
|
|
|
q.add_pus_tc(
|
|
|
|
PusTelecommand(
|
|
|
|
service=200,
|
2023-01-17 11:10:52 +01:00
|
|
|
subservice=ModeSubservice.TC_MODE_ANNOUNCE_RECURSIVE,
|
2022-11-03 22:16:10 +01:00
|
|
|
app_data=PL_SUBSYSTEM_ID,
|
|
|
|
)
|
|
|
|
)
|
2023-11-22 13:51:33 +01:00
|
|
|
mode_info_tup = HANDLER_LIST.get(cmd_str)
|
2024-04-09 11:32:57 +02:00
|
|
|
assert mode_info_tup is not None
|
2022-11-03 22:16:10 +01:00
|
|
|
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],
|
2024-04-09 11:32:57 +02:00
|
|
|
submode=0,
|
2022-11-03 22:16:10 +01:00
|
|
|
q=q,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2023-11-22 13:51:33 +01:00
|
|
|
def create_payload_subsystem_node() -> CmdTreeNode:
|
|
|
|
payload_node = CmdTreeNode("payload", "Payload Subsystem")
|
2024-04-09 11:32:57 +02:00
|
|
|
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)
|
2023-11-22 13:51:33 +01:00
|
|
|
return payload_node
|