eive-tmtc/eive_tmtc/tmtc/system.py

83 lines
2.6 KiB
Python
Raw Normal View History

2023-04-06 22:25:38 +02:00
import enum
2023-02-12 18:56:59 +01:00
from eive_tmtc.config.definitions import CustomServiceList
from eive_tmtc.tmtc.acs.subsystem import AcsMode
from tmtccmd.config.tmtc import (
tmtc_definitions_provider,
TmtcDefinitionWrapper,
OpCodeEntry,
)
from tmtccmd.tc import service_provider
from eive_tmtc.config.object_ids import EIVE_SYSTEM_ID
2023-02-21 01:30:24 +01:00
from tmtccmd.tc.pus_200_fsfw_mode import (
create_mode_command,
Mode,
create_announce_mode_recursive_command,
)
2023-04-06 22:25:38 +02:00
from tmtccmd.tc.pus_8_fsfw_funccmd import create_action_cmd
2023-02-12 18:56:59 +01:00
from tmtccmd.tc.decorator import ServiceProviderParams
2023-04-03 15:53:51 +02:00
class SystemMode:
BOOT = 5
SAFE = AcsMode.SAFE
IDLE = AcsMode.IDLE
2023-04-06 22:25:38 +02:00
class ActionId(enum.IntEnum):
EXECUTE_I2C_REBOOT = 10
2023-02-12 18:56:59 +01:00
class OpCode:
2023-04-03 15:53:51 +02:00
BOOT_MODE = "boot"
2023-02-12 18:56:59 +01:00
SAFE_MODE = "safe"
IDLE_MODE = "idle"
2023-02-21 01:30:24 +01:00
ANNOUNCE_MODES = "announce_modes"
2023-04-06 22:25:38 +02:00
REBOOT_I2C = "reboot_i2c"
2023-02-12 18:56:59 +01:00
class Info:
2023-04-03 15:53:51 +02:00
BOOT_MODE = "Command System into Boot Mode"
2023-02-12 18:56:59 +01:00
SAFE_MODE = "Command System into Safe Mode"
IDLE_MODE = "Command System into Idle Pointing Mode"
2023-02-21 01:30:24 +01:00
ANNOUNCE_MODES = "Announce mode recursively"
2023-04-06 22:25:38 +02:00
REBOOT_I2C = "Reboot I2C bus"
2023-02-12 18:56:59 +01:00
@service_provider(CustomServiceList.SYSTEM.value)
def build_system_cmds(p: ServiceProviderParams):
o = p.op_code
q = p.queue_helper
prefix = "EIVE System"
if o == OpCode.SAFE_MODE:
q.add_log_cmd(f"{prefix}: {Info.SAFE_MODE}")
2023-04-03 15:53:51 +02:00
q.add_pus_tc(create_mode_command(EIVE_SYSTEM_ID, SystemMode.SAFE, 0))
2023-02-12 18:56:59 +01:00
elif o == OpCode.IDLE_MODE:
q.add_log_cmd(f"{prefix}: {Info.IDLE_MODE}")
2023-04-03 15:53:51 +02:00
q.add_pus_tc(create_mode_command(EIVE_SYSTEM_ID, SystemMode.IDLE, 0))
2023-02-21 01:30:24 +01:00
elif o == OpCode.ANNOUNCE_MODES:
q.add_log_cmd(f"{prefix}: {Info.ANNOUNCE_MODES}")
q.add_pus_tc(create_announce_mode_recursive_command(EIVE_SYSTEM_ID))
2023-04-03 15:53:51 +02:00
elif o == OpCode.BOOT_MODE:
q.add_log_cmd(f"{prefix}: {Info.BOOT_MODE}")
2023-04-03 15:54:37 +02:00
q.add_pus_tc(create_mode_command(EIVE_SYSTEM_ID, SystemMode.BOOT, 0))
2023-04-06 22:25:38 +02:00
elif o == OpCode.REBOOT_I2C:
q.add_log_cmd(f"{prefix}: {Info.REBOOT_I2C}")
q.add_pus_tc(create_action_cmd(EIVE_SYSTEM_ID, ActionId.EXECUTE_I2C_REBOOT))
2023-02-12 18:56:59 +01:00
@tmtc_definitions_provider
def add_system_cmd_defs(defs: TmtcDefinitionWrapper):
oce = OpCodeEntry()
2023-04-03 15:53:51 +02:00
oce.add(keys=OpCode.BOOT_MODE, info=Info.BOOT_MODE)
2023-02-12 18:56:59 +01:00
oce.add(keys=OpCode.SAFE_MODE, info=Info.SAFE_MODE)
oce.add(keys=OpCode.IDLE_MODE, info=Info.IDLE_MODE)
2023-02-21 01:30:24 +01:00
oce.add(keys=OpCode.ANNOUNCE_MODES, info=Info.ANNOUNCE_MODES)
2023-04-06 22:25:38 +02:00
oce.add(keys=OpCode.REBOOT_I2C, info=Info.REBOOT_I2C)
2023-02-12 18:56:59 +01:00
defs.add_service(
name=CustomServiceList.SYSTEM.value,
info="EIVE system commands",
op_code_entry=oce,
)
pass