eive-tmtc/tmtc/acs_subsystem.py

72 lines
1.8 KiB
Python
Raw Normal View History

2022-10-04 14:12:33 +02:00
import enum
2022-10-04 14:46:00 +02:00
from typing import Tuple, Dict
2022-10-04 14:12:33 +02:00
2022-10-04 14:46:00 +02:00
from .common import pack_mode_cmd_with_info
from config.object_ids import ACS_SUBSYSTEM_ID
2022-10-04 14:12:33 +02:00
from config.definitions import CustomServiceList
from tmtccmd.config.tmtc import (
tmtc_definitions_provider,
TmtcDefinitionWrapper,
OpCodeEntry,
)
from tmtccmd.tc import service_provider
from tmtccmd.tc.decorator import ServiceProviderParams
class OpCodes(str, enum.Enum):
OFF = "off"
SAFE = "safe"
2022-10-04 14:46:00 +02:00
DETUMBLE = "detumble"
2022-10-04 14:12:33 +02:00
IDLE = "idle"
2022-10-04 14:46:00 +02:00
TARGET_PT = "target"
class AcsModes(enum.IntEnum):
OFF = 0
SAFE = 1
DETUMBLE = 2
IDLE = 3
TARGET_PT = 4
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"
2022-10-04 14:46:00 +02:00
TARGET_PT = "Target Pointing Mode Command"
HANDLER_LIST: Dict[str, Tuple[int, str]] = {
OpCodes.OFF: (AcsModes.OFF, Info.OFF),
OpCodes.IDLE: (AcsModes.IDLE, Info.IDLE),
OpCodes.SAFE: (AcsModes.SAFE, Info.SAFE),
OpCodes.DETUMBLE: (AcsModes.DETUMBLE, Info.DETUMBLE),
}
2022-10-04 14:12:33 +02:00
@service_provider(CustomServiceList.ACS_SS.value)
def build_acs_subsystem_cmd(p: ServiceProviderParams):
op_code = p.op_code
2022-10-04 14:46:00 +02:00
q = p.queue_helper
info_prefix = "ACS Subsystem"
mode_info_tup = HANDLER_LIST[op_code]
if mode_info_tup is None:
return
pack_mode_cmd_with_info(
object_id=ACS_SUBSYSTEM_ID,
info=f"{info_prefix}: {mode_info_tup[1]}",
submode=0,
mode=mode_info_tup[0],
q=q,
)
2022-10-04 14:12:33 +02:00
@tmtc_definitions_provider
def add_acs_subsystem_cmds(defs: TmtcDefinitionWrapper):
oce = OpCodeEntry()
oce.add(OpCodes.OFF, Info.OFF)
oce.add(OpCodes.SAFE, Info.SAFE)
oce.add(OpCodes.IDLE, Info.IDLE)
defs.add_service(CustomServiceList.ACS_SS, "ACS Subsystem", oce)