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

71 lines
2.0 KiB
Python
Raw Normal View History

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.definitions import CustomServiceList
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
2022-11-03 22:16:10 +01:00
from tmtccmd.config import TmtcDefinitionWrapper, OpCodeEntry
from tmtccmd.config.tmtc import tmtc_definitions_provider
from tmtccmd.tc import service_provider
from tmtccmd.tc.decorator import ServiceProviderParams
2023-01-31 12:56:13 +01:00
from tmtccmd.tc.pus_200_fsfw_mode import Subservice as ModeSubservice
2022-11-03 22:16:10 +01:00
2023-02-06 20:13:15 +01:00
class ModeId:
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"
class Info(str, enum.Enum):
OFF = "Off Command"
REPORT_ALL_MODES = "Report all modes"
HANDLER_LIST: Dict[str, Tuple[int, str]] = {
2023-02-06 20:22:36 +01:00
OpCode.OFF: (ModeId.OFF, Info.OFF),
2022-11-03 22:16:10 +01:00
}
@service_provider(CustomServiceList.PL_SS)
def build_acs_subsystem_cmd(p: ServiceProviderParams):
op_code = p.op_code
q = p.queue_helper
info_prefix = "ACS Subsystem"
2023-01-16 14:13:06 +01:00
if op_code in 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,
)
)
mode_info_tup = HANDLER_LIST.get(op_code)
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]}",
submode=0,
mode=mode_info_tup[0],
q=q,
)
@tmtc_definitions_provider
def add_payload_subsystem_cmds(defs: TmtcDefinitionWrapper):
oce = OpCodeEntry()
2023-01-16 14:13:06 +01:00
oce.add(OpCode.OFF, Info.OFF)
oce.add(OpCode.REPORT_ALL_MODES, Info.REPORT_ALL_MODES)
2022-11-03 22:16:10 +01:00
defs.add_service(CustomServiceList.PL_SS, "Payload Subsystem", oce)