eive-tmtc/eive_tmtc/tmtc/acs/subsystem.py
Robin Mueller d640d547bd
All checks were successful
EIVE/-/pipeline/head This commit looks good
OOF3
2023-11-22 13:51:33 +01:00

81 lines
2.7 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 Subservice as ModeSubservices
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
class CmdStr(str, enum.Enum):
OFF = "off"
SAFE = "safe"
DETUMBLE = "detumble"
IDLE = "idle"
PTG_TARGET = "ptg_target"
PTG_TARGET_NADIR = "ptg_nadir"
PTG_TARGET_GS = "ptg_target_gs"
PTG_TARGET_INERTIAL = "ptg_inertial"
REPORT_ALL_MODES = "all_modes"
class Info(str, enum.Enum):
OFF = "Off Command"
SAFE = "Safe Mode Command"
DETUMBLE = "Detumble Mode Command"
IDLE = "Idle Mode Command"
PTG_TARGET_NADIR = "Target Pointing Nadir"
PTG_TARGET = "Target Pointing"
PTG_TARGET_GS = "Target Pointing Ground Station"
PTG_TARGET_INERTIAL = "Target Pointing Inertial"
REPORT_ALL_MODES = "Report All Modes Recursively"
HANDLER_LIST: Dict[str, Tuple[int, int, str]] = {
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),
}
def build_acs_subsystem_cmd(q: DefaultPusQueueHelper, cmd_path: str):
info_prefix = "ACS Subsystem"
if cmd_path in CmdStr.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=ACS_SUBSYSTEM_ID,
)
)
mode_info_tup = HANDLER_LIST.get(cmd_path)
if mode_info_tup is None:
return
pack_mode_cmd_with_info(
object_id=ACS_SUBSYSTEM_ID,
info=f"{info_prefix}: {mode_info_tup[2]}",
mode=mode_info_tup[0],
submode=mode_info_tup[1],
q=q,
)
def create_acs_subsystem_node() -> CmdTreeNode:
node = CmdTreeNode("acs", "ACS Subsystem")
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