this is hardcore

This commit is contained in:
Robin Müller 2023-11-22 10:51:26 +01:00
parent b3920524ab
commit ba24faefa9
Signed by: muellerr
GPG Key ID: A649FB78196E3849
5 changed files with 31 additions and 19 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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())

View File

@ -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"))