2022-10-04 14:12:33 +02:00
|
|
|
import enum
|
2023-11-22 13:51:33 +01:00
|
|
|
from typing import Dict, Tuple
|
2022-10-04 14:12:33 +02:00
|
|
|
|
2022-10-10 10:44:45 +02:00
|
|
|
from spacepackets.ecss import PusTelecommand
|
2022-10-04 14:12:33 +02:00
|
|
|
from tmtccmd.config.tmtc import (
|
2023-11-22 13:51:33 +01:00
|
|
|
CmdTreeNode,
|
2022-10-04 14:12:33 +02:00
|
|
|
)
|
2023-11-10 19:23:06 +01:00
|
|
|
from tmtccmd.pus.s200_fsfw_mode import Subservice as ModeSubservices
|
2023-11-22 13:51:33 +01:00
|
|
|
from tmtccmd.tmtc import DefaultPusQueueHelper
|
|
|
|
|
|
|
|
from eive_tmtc.config.object_ids import ACS_SUBSYSTEM_ID
|
|
|
|
from eive_tmtc.tmtc.acs.defs import AcsMode, SafeSubmode
|
|
|
|
from eive_tmtc.tmtc.common import pack_mode_cmd_with_info
|
2022-10-04 14:12:33 +02:00
|
|
|
|
|
|
|
|
2023-11-22 13:51:33 +01:00
|
|
|
class CmdStr(str, enum.Enum):
|
2022-10-04 14:12:33 +02:00
|
|
|
OFF = "off"
|
|
|
|
SAFE = "safe"
|
2022-10-04 14:46:00 +02:00
|
|
|
DETUMBLE = "detumble"
|
2022-10-04 14:12:33 +02:00
|
|
|
IDLE = "idle"
|
2023-02-03 10:47:18 +01:00
|
|
|
PTG_TARGET = "ptg_target"
|
|
|
|
PTG_TARGET_NADIR = "ptg_nadir"
|
|
|
|
PTG_TARGET_GS = "ptg_target_gs"
|
|
|
|
PTG_TARGET_INERTIAL = "ptg_inertial"
|
2022-10-10 10:44:45 +02:00
|
|
|
REPORT_ALL_MODES = "all_modes"
|
2022-10-04 14:46:00 +02:00
|
|
|
|
|
|
|
|
2022-10-04 14:12:33 +02:00
|
|
|
class Info(str, enum.Enum):
|
|
|
|
OFF = "Off Command"
|
|
|
|
SAFE = "Safe Mode Command"
|
2022-10-04 14:46:00 +02:00
|
|
|
DETUMBLE = "Detumble Mode Command"
|
2022-10-04 14:12:33 +02:00
|
|
|
IDLE = "Idle Mode Command"
|
2023-02-03 10:47:18 +01:00
|
|
|
PTG_TARGET_NADIR = "Target Pointing Nadir"
|
|
|
|
PTG_TARGET = "Target Pointing"
|
|
|
|
PTG_TARGET_GS = "Target Pointing Ground Station"
|
|
|
|
PTG_TARGET_INERTIAL = "Target Pointing Inertial"
|
2022-10-10 10:44:45 +02:00
|
|
|
REPORT_ALL_MODES = "Report All Modes Recursively"
|
2022-10-04 14:46:00 +02:00
|
|
|
|
|
|
|
|
2023-03-10 13:37:17 +01:00
|
|
|
HANDLER_LIST: Dict[str, Tuple[int, int, str]] = {
|
2023-11-22 13:51:33 +01:00
|
|
|
CmdStr.OFF: (AcsMode.OFF, 0, Info.OFF),
|
|
|
|
CmdStr.SAFE: (AcsMode.SAFE, SafeSubmode.DEFAULT, Info.SAFE),
|
|
|
|
CmdStr.DETUMBLE: (AcsMode.SAFE, SafeSubmode.DETUMBLE, Info.DETUMBLE),
|
|
|
|
CmdStr.IDLE: (AcsMode.IDLE, 0, Info.IDLE),
|
|
|
|
CmdStr.PTG_TARGET: (AcsMode.PTG_TARGET, 0, Info.PTG_TARGET),
|
|
|
|
CmdStr.PTG_TARGET_GS: (AcsMode.PTG_TARGET_GS, 0, Info.PTG_TARGET_GS),
|
|
|
|
CmdStr.PTG_TARGET_NADIR: (AcsMode.PTG_NADIR, 0, Info.PTG_TARGET_NADIR),
|
|
|
|
CmdStr.PTG_TARGET_INERTIAL: (AcsMode.PTG_INERTIAL, 0, Info.PTG_TARGET_INERTIAL),
|
2022-10-04 14:46:00 +02:00
|
|
|
}
|
2022-10-04 14:12:33 +02:00
|
|
|
|
|
|
|
|
2023-11-22 13:51:33 +01:00
|
|
|
def build_acs_subsystem_cmd(q: DefaultPusQueueHelper, cmd_path: str):
|
2022-10-04 14:46:00 +02:00
|
|
|
info_prefix = "ACS Subsystem"
|
2023-11-22 13:51:33 +01:00
|
|
|
if cmd_path in CmdStr.REPORT_ALL_MODES:
|
2022-10-10 10:44:45 +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=ACS_SUBSYSTEM_ID,
|
|
|
|
)
|
|
|
|
)
|
2023-11-22 13:51:33 +01:00
|
|
|
mode_info_tup = HANDLER_LIST.get(cmd_path)
|
2022-10-04 14:46:00 +02:00
|
|
|
if mode_info_tup is None:
|
|
|
|
return
|
|
|
|
pack_mode_cmd_with_info(
|
|
|
|
object_id=ACS_SUBSYSTEM_ID,
|
2023-03-10 13:37:17 +01:00
|
|
|
info=f"{info_prefix}: {mode_info_tup[2]}",
|
2022-10-04 14:46:00 +02:00
|
|
|
mode=mode_info_tup[0],
|
2023-03-10 13:37:17 +01:00
|
|
|
submode=mode_info_tup[1],
|
2022-10-04 14:46:00 +02:00
|
|
|
q=q,
|
|
|
|
)
|
2022-10-04 14:12:33 +02:00
|
|
|
|
|
|
|
|
2023-11-22 13:51:33 +01:00
|
|
|
def create_acs_subsystem_node() -> CmdTreeNode:
|
2023-11-22 18:39:12 +01:00
|
|
|
node = CmdTreeNode("acs", "ACS Subsystem", hide_children_which_are_leaves=True)
|
2023-11-22 13:51:33 +01:00
|
|
|
for cmd_str, (_, _, info) in HANDLER_LIST.items():
|
|
|
|
node.add_child(CmdTreeNode(cmd_str, info))
|
|
|
|
node.add_child(CmdTreeNode(CmdStr.REPORT_ALL_MODES, Info.REPORT_ALL_MODES))
|
|
|
|
return node
|