From 4a654857ce9b07b59985d2e86720a8ba28cbc88d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 4 Jul 2022 18:14:51 +0200 Subject: [PATCH] only tmtc defs remaining --- config/hook_implementations.py | 29 +++++----------- pus_tc/cmd_definitions.py | 58 ++++++++++++++----------------- pus_tc/system/core.py | 8 ++--- tmtcc.py | 62 +++++++++++++++------------------- 4 files changed, 65 insertions(+), 92 deletions(-) diff --git a/config/hook_implementations.py b/config/hook_implementations.py index 26f4560..3959114 100644 --- a/config/hook_implementations.py +++ b/config/hook_implementations.py @@ -1,30 +1,24 @@ -from typing import Union +from typing import Optional from config.definitions import SPACE_PACKET_IDS -from tmtccmd.config.definitions import ( - ServiceOpCodeDictT, -) -from tmtccmd.tc.definitions import TcQueueT +from tmtccmd import TmTcCfgHookBase, CcsdsTmtcBackend +from tmtccmd.com_if import ComInterface +from tmtccmd.config import TmTcDefWrapper from tmtccmd.utility.retval import RetvalDictT from tmtccmd.utility.obj_id import ObjectIdDictT -from tmtccmd.com_if.com_interface_base import CommunicationInterface -from tmtccmd.core.backend import TmTcHandler -from tmtccmd.config.hook import TmTcHookBase from config.retvals import get_retval_dict from pus_tc.cmd_definitions import get_eive_service_op_code_dict -class EiveHookObject(TmTcHookBase): +class EiveHookObject(TmTcCfgHookBase): def __init__(self, json_cfg_path: str): super().__init__(json_cfg_path=json_cfg_path) - def get_service_op_code_dictionary(self) -> ServiceOpCodeDictT: + def get_tmtc_definitions(self) -> TmTcDefWrapper: return get_eive_service_op_code_dict() - def assign_communication_interface( - self, com_if_key: str - ) -> Union[CommunicationInterface, None]: + def assign_communication_interface(self, com_if_key: str) -> Optional[ComInterface]: from tmtccmd.config.com_if import create_communication_interface_default return create_communication_interface_default( @@ -33,18 +27,11 @@ class EiveHookObject(TmTcHookBase): space_packet_ids=SPACE_PACKET_IDS, ) - def perform_mode_operation(self, tmtc_backend: TmTcHandler, mode: int): + def perform_mode_operation(self, tmtc_backend: CcsdsTmtcBackend, mode: int): from config.custom_mode_op import custom_mode_operation custom_mode_operation(mode=mode, tmtc_backend=tmtc_backend) - def pack_service_queue(self, service: int, op_code: str, service_queue: TcQueueT): - from pus_tc.procedure_packer import pack_service_queue_user - - pack_service_queue_user( - service=service, op_code=op_code, service_queue=service_queue - ) - def get_object_ids(self) -> ObjectIdDictT: from config.object_ids import get_object_ids diff --git a/pus_tc/cmd_definitions.py b/pus_tc/cmd_definitions.py index 061884f..c35dbaa 100644 --- a/pus_tc/cmd_definitions.py +++ b/pus_tc/cmd_definitions.py @@ -1,12 +1,4 @@ from pus_tc.system.proc import add_proc_cmds -from tmtccmd.config import ( - add_op_code_entry, - add_service_op_code_entry, - generate_op_code_options, - ServiceOpCodeDictT, - OpCodeDictKeys, -) -from tmtccmd.config.globals import get_default_service_op_code_dict from pus_tc.devs.gps import add_gps_cmds from pus_tc.devs.pcdu import add_pcdu_cmds @@ -19,34 +11,36 @@ from pus_tc.devs.reaction_wheels import add_rw_cmds from pus_tc.devs.bpx_batt import BpxOpCodes from config.definitions import CustomServiceList +from tmtccmd.config import TmTcDefWrapper +from tmtccmd.config.globals import get_default_tmtc_defs -def get_eive_service_op_code_dict() -> ServiceOpCodeDictT: - service_op_code_dict = get_default_service_op_code_dict() - add_bpx_cmd_definitions(cmd_dict=service_op_code_dict) - add_core_controller_definitions(cmd_dict=service_op_code_dict) - add_pl_pcdu_cmds(cmd_dict=service_op_code_dict) - add_pcdu_cmds(cmd_dict=service_op_code_dict) - specify_rtd_cmds(cmd_dict=service_op_code_dict) - add_imtq_cmds(cmd_dict=service_op_code_dict) - add_rad_sens_cmds(cmd_dict=service_op_code_dict) - add_rw_cmds(cmd_dict=service_op_code_dict) - add_ploc_mpsoc_cmds(cmd_dict=service_op_code_dict) - add_ploc_supv_cmds(cmd_dict=service_op_code_dict) - add_system_cmds(cmd_dict=service_op_code_dict) - add_time_cmds(cmd_dict=service_op_code_dict) - add_syrlinks_cmds(cmd_dict=service_op_code_dict) - add_gps_cmds(cmd_dict=service_op_code_dict) - add_str_cmds(cmd_dict=service_op_code_dict) - add_ccsds_cmds(cmd_dict=service_op_code_dict) - add_pdec_cmds(cmd_dict=service_op_code_dict) - add_heater_cmds(cmd_dict=service_op_code_dict) - add_tmp_sens_cmds(cmd_dict=service_op_code_dict) - add_proc_cmds(cmd_dict=service_op_code_dict) - return service_op_code_dict +def get_eive_service_op_code_dict() -> TmTcDefWrapper: + def_wrapper = get_default_tmtc_defs() + add_bpx_cmd_definitions(cmd_dict=def_wrapper) + add_core_controller_definitions(defs=def_wrapper) + add_pl_pcdu_cmds(cmd_dict=def_wrapper) + add_pcdu_cmds(cmd_dict=def_wrapper) + specify_rtd_cmds(cmd_dict=def_wrapper) + add_imtq_cmds(cmd_dict=def_wrapper) + add_rad_sens_cmds(cmd_dict=def_wrapper) + add_rw_cmds(cmd_dict=def_wrapper) + add_ploc_mpsoc_cmds(cmd_dict=def_wrapper) + add_ploc_supv_cmds(cmd_dict=def_wrapper) + add_system_cmds(cmd_dict=def_wrapper) + add_time_cmds(cmd_dict=def_wrapper) + add_syrlinks_cmds(cmd_dict=def_wrapper) + add_gps_cmds(cmd_dict=def_wrapper) + add_str_cmds(cmd_dict=def_wrapper) + add_ccsds_cmds(cmd_dict=def_wrapper) + add_pdec_cmds(cmd_dict=def_wrapper) + add_heater_cmds(cmd_dict=def_wrapper) + add_tmp_sens_cmds(cmd_dict=def_wrapper) + add_proc_cmds(cmd_dict=def_wrapper) + return def_wrapper -def add_tmp_sens_cmds(cmd_dict: ServiceOpCodeDictT): +def add_tmp_sens_cmds(defs: TmTcDefWrapper): op_code_dict = { "0": ("TMP1075 Tests", {OpCodeDictKeys.TIMEOUT: 2.2}), } diff --git a/pus_tc/system/core.py b/pus_tc/system/core.py index 01ecca5..3531534 100644 --- a/pus_tc/system/core.py +++ b/pus_tc/system/core.py @@ -1,9 +1,7 @@ import enum from config.definitions import CustomServiceList -from tmtccmd.config import add_op_code_entry, add_service_op_code_entry -from tmtccmd.config.definitions import QueueCommands, ServiceOpCodeDictT -from tmtccmd.tc.definitions import TcQueueT +from tmtccmd.config import TmTcDefWrapper from tmtccmd.tc import QueueHelper from tmtccmd.tc.pus_8_funccmd import generate_action_command @@ -67,7 +65,7 @@ class Copy(enum.IntEnum): NONE = 2 -def add_core_controller_definitions(cmd_dict: ServiceOpCodeDictT): +def add_core_controller_definitions(defs: TmTcDefWrapper): od = dict() add_op_code_entry(op_code_dict=od, keys=OpCodes.REBOOT_XSC, info=Info.REBOOT_XSC) add_op_code_entry(op_code_dict=od, keys=OpCodes.REBOOT_FULL, info=Info.REBOOT_FULL) @@ -117,7 +115,7 @@ def add_core_controller_definitions(cmd_dict: ServiceOpCodeDictT): info="Reset reboot counter 1 1", ) add_service_op_code_entry( - srv_op_code_dict=cmd_dict, + srv_op_code_dict=defs, name=CustomServiceList.CORE.value, info="Core Controller", op_code_entry=od, diff --git a/tmtcc.py b/tmtcc.py index 827b640..4d53773 100644 --- a/tmtcc.py +++ b/tmtcc.py @@ -4,29 +4,6 @@ import sys import time import traceback -from spacepackets.ecss import PusVerificator -from tmtccmd import get_console_logger, TcHandlerBase, BackendBase -from tmtccmd.com_if import ComInterface - -from deps.tmtccmd.tmtccmd.logging.pus import ( - RawTmtcTimedLogWrapper, - RegularTmtcLogWrapper, - TimedLogWhen, -) -from deps.tmtccmd.tmtccmd.pus import VerificationWrapper -from deps.tmtccmd.tmtccmd.tm import SpecificApidHandlerBase, GenericApidHandlerBase -from deps.tmtccmd.tmtccmd.utility.tmtc_printer import FsfwTmTcPrinter -from tmtccmd.core import BackendRequest -from tmtccmd.logging import get_current_time_string -from tmtccmd.pus import FileSeqCountProvider -from tmtccmd.tc import ( - ProcedureHelper, - FeedWrapper, - TcProcedureType, - QueueEntryHelper, - TcQueueEntryType, -) - try: import spacepackets except ImportError as error: @@ -38,17 +15,7 @@ except ImportError as error: sys.exit(1) try: - import tmtccmd.runner as tmtccmd - from tmtccmd.logging.pus import create_tmtc_logger - from tmtccmd.ccsds.handler import ApidHandler, CcsdsTmHandler - from tmtccmd.config import SetupArgs, default_json_path, SetupWrapper - from tmtccmd.config.args import ( - create_default_args_parser, - add_default_tmtccmd_args, - parse_default_input_arguments, - SetupParams, - ArgParserWrapper, - ) + import tmtccmd except ImportError as error: run_tmtc_commander = None initialize_tmtc_commander = None @@ -57,6 +24,33 @@ except ImportError as error: print("Python tmtccmd submodule could not be imported") sys.exit(1) +from spacepackets.ecss import PusVerificator +from tmtccmd import get_console_logger, TcHandlerBase, BackendBase +from tmtccmd.com_if import ComInterface + +from tmtccmd.logging.pus import ( + RawTmtcTimedLogWrapper, + RegularTmtcLogWrapper, + TimedLogWhen, +) +from tmtccmd.pus import VerificationWrapper +from tmtccmd.tm import SpecificApidHandlerBase, GenericApidHandlerBase, CcsdsTmHandler +from tmtccmd.utility.tmtc_printer import FsfwTmTcPrinter +from tmtccmd.core import BackendRequest +from tmtccmd.logging import get_current_time_string +from tmtccmd.pus import FileSeqCountProvider +from tmtccmd.tc import ( + ProcedureHelper, + FeedWrapper, + TcProcedureType, + QueueEntryHelper, + TcQueueEntryType, +) +from tmtccmd.config import default_json_path, SetupWrapper +from tmtccmd.config.args import ( + SetupParams, + ArgParserWrapper, +) from config import __version__ from config.definitions import PUS_APID from config.hook_implementations import EiveHookObject