From ba24faefa93fc852d6622a52d9377df0502e5e45 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 22 Nov 2023 10:51:26 +0100 Subject: [PATCH] this is hardcore --- eive_tmtc/config/hook.py | 19 ++++++++----------- eive_tmtc/pus_tc/procedure_packer.py | 3 ++- eive_tmtc/tmtc/__init__.py | 1 - eive_tmtc/tmtc/acs/acs_ctrl.py | 25 ++++++++++++++++++++----- eive_tmtc/tmtc/time.py | 2 +- 5 files changed, 31 insertions(+), 19 deletions(-) diff --git a/eive_tmtc/config/hook.py b/eive_tmtc/config/hook.py index 222fdd7..f088ded 100644 --- a/eive_tmtc/config/hook.py +++ b/eive_tmtc/config/hook.py @@ -1,14 +1,15 @@ from typing import Optional -from eive_tmtc.config.definitions import SPACE_PACKET_IDS -from eive_tmtc.tmtc.time import create_time_node -from tmtccmd import HookBase, CcsdsTmtcBackend +from tmtccmd import CcsdsTmtcBackend, HookBase from tmtccmd.com import ComInterface from tmtccmd.config import CmdTreeNode - -from eive_tmtc.config.retvals import get_retval_dict from tmtccmd.util import ObjectIdDictT, RetvalDictT +from eive_tmtc.config.definitions import SPACE_PACKET_IDS +from eive_tmtc.config.retvals import get_retval_dict +from eive_tmtc.tmtc.time import create_time_node +from eive_tmtc.tmtc.acs.acs_ctrl import create_acs_ctrl_node + class EiveHookObject(HookBase): def __init__(self, json_cfg_path: str): @@ -40,10 +41,6 @@ class EiveHookObject(HookBase): gyro_devs = CmdTreeNode("gyro_devs", "Gyro Devices") acs_brd_assy_node.add_child(mgm_devs) acs_brd_assy_node.add_child(gyro_devs) - acs_ctrl = CmdTreeNode("acs_ctrl", "ACS Controller") - acs_ctrl.add_child(mode_node) - acs_ctrl.add_child(action_node) - acs_ctrl.add_child(param_node) rws = CmdTreeNode("rws", "Reaction Wheel Devices") rw_assy = CmdTreeNode("rw_assy", "Reaction Wheel Assembly") rw_1 = CmdTreeNode("rw_1", "Reaction Wheel 1") @@ -66,7 +63,7 @@ class EiveHookObject(HookBase): gnss_devs = CmdTreeNode("gnss", "GNSS Devices") acs_node.add_child(acs_brd_assy_node) - acs_node.add_child(acs_ctrl) + acs_node.add_child(create_acs_ctrl_node()) acs_node.add_child(mode_node) acs_node.add_child(rws) acs_node.add_child(mgt) @@ -130,8 +127,8 @@ class EiveHookObject(HookBase): def get_communication_interface(self, com_if_key: str) -> Optional[ComInterface]: from tmtccmd.config.com import ( - create_com_interface_default, create_com_interface_cfg_default, + create_com_interface_default, ) assert self.cfg_path is not None diff --git a/eive_tmtc/pus_tc/procedure_packer.py b/eive_tmtc/pus_tc/procedure_packer.py index 8ba9dd2..308c1bb 100644 --- a/eive_tmtc/pus_tc/procedure_packer.py +++ b/eive_tmtc/pus_tc/procedure_packer.py @@ -2,9 +2,10 @@ """ import logging from typing import cast -from build.lib.build.lib.eive_tmtc.tmtc.acs.acs_ctrl import pack_acs_ctrl_command from eive_tmtc.tmtc.acs.gyros import handle_gyr_cmd + +from eive_tmtc.tmtc.acs.acs_ctrl import pack_acs_ctrl_command from eive_tmtc.tmtc.acs.mgms import handle_mgm_cmd from eive_tmtc.tmtc.power.power import pack_power_commands from eive_tmtc.tmtc.tcs.ctrl import pack_tcs_ctrl_commands diff --git a/eive_tmtc/tmtc/__init__.py b/eive_tmtc/tmtc/__init__.py index 618cee5..2c6f4c8 100644 --- a/eive_tmtc/tmtc/__init__.py +++ b/eive_tmtc/tmtc/__init__.py @@ -1,7 +1,6 @@ from .payload.subsystem import add_payload_subsystem_cmds 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 from .tm_store import add_persistent_tm_store_cmd_defs diff --git a/eive_tmtc/tmtc/acs/acs_ctrl.py b/eive_tmtc/tmtc/acs/acs_ctrl.py index 46275fe..06e635f 100644 --- a/eive_tmtc/tmtc/acs/acs_ctrl.py +++ b/eive_tmtc/tmtc/acs/acs_ctrl.py @@ -5,9 +5,10 @@ import math import socket import struct from socket import AF_INET -from typing import Tuple +from typing import Dict, Tuple from tmtccmd.config.tmtc import ( + CmdTreeNode, OpCodeEntry, TmtcDefinitionWrapper, tmtc_definitions_provider, @@ -34,8 +35,6 @@ from tmtccmd.pus.tc.s3_fsfw_hk import ( generate_one_hk_command, make_sid, ) -from tmtccmd.tmtc import service_provider -from tmtccmd.tmtc.decorator import ServiceProviderParams from tmtccmd.tmtc.queue import DefaultPusQueueHelper from eive_tmtc.config.definitions import CustomServiceList @@ -211,6 +210,19 @@ if PERFORM_MGM_CALIBRATION: CALIBR_SOCKET.connect(CALIBRATION_ADDR) +def create_acs_ctrl_node() -> CmdTreeNode: + # Zip the two classes together into a dictionary + op_code_strs = [ + getattr(OpCodes, key)[0] for key in dir(OpCodes) if not key.startswith("__") + ] + info_strs = [getattr(Info, key) for key in dir(OpCodes) if not key.startswith("__")] + combined_dict = dict(zip(op_code_strs, info_strs)) + acs_ctrl = CmdTreeNode("acs_ctrl", "ACS Controller") + for op_code, info in combined_dict.items(): + acs_ctrl.add_child(CmdTreeNode(op_code, info)) + return acs_ctrl + + @tmtc_definitions_provider def acs_cmd_defs(defs: TmtcDefinitionWrapper): oce = OpCodeEntry() @@ -656,7 +668,7 @@ def set_acs_ctrl_param_vector(q: DefaultPusQueueHelper): domain_id=sid, unique_id=pid, parameters=param, - ).pack() + ) ) ) else: @@ -847,7 +859,7 @@ def handle_raw_mgm_data(pw: PrintWrapper, hk_data: bytes): pw.dlog(f"Raw Data: {hk_data.hex(sep=',')}") return - def unpack_float_tuple(idx: int) -> (tuple, int): + def unpack_float_tuple(idx: int) -> Tuple[tuple, int]: f_tuple = struct.unpack( float_tuple_fmt_str, hk_data[idx : idx + struct.calcsize(float_tuple_fmt_str)], @@ -1248,6 +1260,9 @@ def perform_mgm_calibration( # noqa C901: Complexity okay pw: PrintWrapper, mgm_tuple: Tuple ): # noqa C901: Complexity okay global CALIBR_SOCKET, CALIBRATION_ADDR + if not PERFORM_MGM_CALIBRATION: + return + assert CALIBR_SOCKET is not None try: declare_api_cmd = "declare_api_version 2" CALIBR_SOCKET.sendall(f"{declare_api_cmd}\n".encode()) diff --git a/eive_tmtc/tmtc/time.py b/eive_tmtc/tmtc/time.py index 23f9b90..1e7fdc7 100644 --- a/eive_tmtc/tmtc/time.py +++ b/eive_tmtc/tmtc/time.py @@ -47,7 +47,7 @@ def pack_time_management_cmd(q: DefaultPusQueueHelper, cmd_str: str): ) -def return_time_node() -> CmdTreeNode: +def create_time_node() -> CmdTreeNode: time_node = CmdTreeNode("time", "Time Management") time_node.add_child(CmdTreeNode(CmdStr.SET_CURRENT_TIME, "Set current time")) time_node.add_child(CmdTreeNode(CmdStr.DUMP_TIME, "Dumpy current time"))