From 2d79f6f484b51cf5fe6b04722a50d8b8d5653afb Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 12 Feb 2023 18:56:59 +0100 Subject: [PATCH] add EIVE system cmds --- eive_tmtc/config/definitions.py | 2 +- eive_tmtc/config/object_ids.py | 1 + eive_tmtc/pus_tc/cmd_definitions.py | 20 ------------ eive_tmtc/pus_tc/procedure_packer.py | 13 -------- eive_tmtc/tmtc/__init__.py | 1 + eive_tmtc/tmtc/system.py | 47 ++++++++++++++++++++++++++++ 6 files changed, 50 insertions(+), 34 deletions(-) create mode 100644 eive_tmtc/tmtc/system.py diff --git a/eive_tmtc/config/definitions.py b/eive_tmtc/config/definitions.py index 803f086..44daa19 100644 --- a/eive_tmtc/config/definitions.py +++ b/eive_tmtc/config/definitions.py @@ -71,6 +71,6 @@ class CustomServiceList(str, enum.Enum): RTD = "rtd" TMP1075 = "tcs_tmp" TVTTESTPROCEDURE = "tvtestproc" - CONTROLLERS = "controllers" SCEX = "scex" TM_STORE = "tm_store" + SYSTEM = "system" diff --git a/eive_tmtc/config/object_ids.py b/eive_tmtc/config/object_ids.py index f948260..a95f994 100644 --- a/eive_tmtc/config/object_ids.py +++ b/eive_tmtc/config/object_ids.py @@ -126,6 +126,7 @@ SUS_5_N_LOC_XFYMZB_PT_ZB = bytes([0x44, 0x12, 0x00, 0x37]) SUS_11_R_LOC_XBYMZB_PT_ZB = bytes([0x44, 0x12, 0x00, 0x43]) # System and Assembly Objects +EIVE_SYSTEM_ID = bytes([0x73, 0x01, 0x00, 0x00]) ACS_SUBSYSTEM_ID = bytes([0x73, 0x01, 0x00, 0x01]) PL_SUBSYSTEM_ID = bytes([0x73, 0x01, 0x00, 0x02]) TCS_SUBSYSTEM_ID = bytes([0x73, 0x01, 0x00, 0x03]) diff --git a/eive_tmtc/pus_tc/cmd_definitions.py b/eive_tmtc/pus_tc/cmd_definitions.py index aa98a9e..950796a 100644 --- a/eive_tmtc/pus_tc/cmd_definitions.py +++ b/eive_tmtc/pus_tc/cmd_definitions.py @@ -94,23 +94,3 @@ def add_str_cmds(defs: TmtcDefinitionWrapper): oce.add("70", "Star Tracker: Disable timestamp generation") oce.add("71", "Star Tracker: Enable timestamp generation") defs.add_service(CustomServiceList.STAR_TRACKER.value, "Star Tracker", oce) - - -@tmtc_definitions_provider -def add_system_cmds(defs: TmtcDefinitionWrapper): - import eive_tmtc.pus_tc.system.controllers as controllers - - oce = OpCodeEntry() - oce.add( - keys=controllers.OpCode.THERMAL_CONTROLLER, - info=controllers.Info.THERMAL_CONTROLLER, - ) - oce.add( - keys=controllers.OpCode.CORE_CONTROLLER, - info=controllers.Info.CORE_CONTROLLER, - ) - defs.add_service( - name=CustomServiceList.CONTROLLERS.value, - info="Controllers", - op_code_entry=oce, - ) diff --git a/eive_tmtc/pus_tc/procedure_packer.py b/eive_tmtc/pus_tc/procedure_packer.py index 14f82f6..4cc54f2 100644 --- a/eive_tmtc/pus_tc/procedure_packer.py +++ b/eive_tmtc/pus_tc/procedure_packer.py @@ -6,10 +6,6 @@ from typing import cast from eive_tmtc.tmtc.power.power import pack_power_commands from eive_tmtc.tmtc.tcs.rtd import pack_rtd_commands from eive_tmtc.tmtc.payload.scex import pack_scex_cmds -from eive_tmtc.pus_tc.system.controllers import ( - pack_cmd_ctrl_to_prompted_mode, - get_object_from_op_code, -) from eive_tmtc.tmtc.tcs.subsystem import pack_tcs_sys_commands from tmtccmd import DefaultProcedureInfo, TcHandlerBase from tmtccmd.config import CoreServiceList @@ -194,15 +190,6 @@ def handle_default_procedure( return pack_tcs_sys_commands(q=queue_helper, op_code=op_code) if service == CustomServiceList.RW_ASSEMBLY.value: return pack_rw_ass_cmds(q=queue_helper, object_id=RW_ASSEMBLY, op_code=op_code) - if service == CustomServiceList.CONTROLLERS.value: - from tmtcc import TcHandler - - tc_handler = cast(TcHandler, tc_base) - return pack_cmd_ctrl_to_prompted_mode( - q=queue_helper, - object_id=get_object_from_op_code(op_code), - gui=tc_handler.gui, - ) if service == CustomServiceList.SCEX.value: return pack_scex_cmds( ServiceProviderParams( diff --git a/eive_tmtc/tmtc/__init__.py b/eive_tmtc/tmtc/__init__.py index 4ec6c35..8c57d8f 100644 --- a/eive_tmtc/tmtc/__init__.py +++ b/eive_tmtc/tmtc/__init__.py @@ -3,3 +3,4 @@ from .solar_array_deployment import add_sa_depl_cmds from .test import add_test_defs from .time import add_time_cmds from .health import add_health_cmd_defs +from .system import add_system_cmd_defs diff --git a/eive_tmtc/tmtc/system.py b/eive_tmtc/tmtc/system.py new file mode 100644 index 0000000..497c102 --- /dev/null +++ b/eive_tmtc/tmtc/system.py @@ -0,0 +1,47 @@ +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 +from tmtccmd.tc.pus_200_fsfw_mode import create_mode_command, Mode +from tmtccmd.tc.decorator import ServiceProviderParams + + +class OpCode: + SAFE_MODE = "safe" + IDLE_MODE = "idle" + + +class Info: + SAFE_MODE = "Command System into Safe Mode" + IDLE_MODE = "Command System into Idle Pointing Mode" + + +@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}") + q.add_pus_tc(create_mode_command(EIVE_SYSTEM_ID, AcsMode.SAFE, 0)) + elif o == OpCode.IDLE_MODE: + q.add_log_cmd(f"{prefix}: {Info.IDLE_MODE}") + q.add_pus_tc(create_mode_command(EIVE_SYSTEM_ID, AcsMode.IDLE, 0)) + + +@tmtc_definitions_provider +def add_system_cmd_defs(defs: TmtcDefinitionWrapper): + oce = OpCodeEntry() + oce.add(keys=OpCode.SAFE_MODE, info=Info.SAFE_MODE) + oce.add(keys=OpCode.IDLE_MODE, info=Info.IDLE_MODE) + defs.add_service( + name=CustomServiceList.SYSTEM.value, + info="EIVE system commands", + op_code_entry=oce, + ) + pass