From 140c827ce75dbf5cc46f8cdd71f5825abc8b0bb6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 1 Dec 2022 11:14:28 +0100 Subject: [PATCH] that should do the job --- eive_tmtc/config/definitions.py | 4 ++++ eive_tmtc/config/events.py | 21 +++++++++++++++++++++ eive_tmtc/config/object_ids.py | 4 +++- eive_tmtc/config/retvals.py | 4 +++- eive_tmtc/pus_tc/system/proc.py | 6 +++++- eive_tmtc/pus_tm/event_handler.py | 20 +++----------------- 6 files changed, 39 insertions(+), 20 deletions(-) create mode 100644 eive_tmtc/config/events.py diff --git a/eive_tmtc/config/definitions.py b/eive_tmtc/config/definitions.py index bb5b701..6a849ea 100644 --- a/eive_tmtc/config/definitions.py +++ b/eive_tmtc/config/definitions.py @@ -9,6 +9,10 @@ import enum from spacepackets import PacketType from spacepackets.ccsds import PacketId from spacepackets.util import UnsignedByteField +from pathlib import Path + +EIVE_TMTC_ROOT = Path(__file__).parent +PACKAGE_ROOT = EIVE_TMTC_ROOT.parent PUS_APID = 0x65 CFDP_APID = 0x66 diff --git a/eive_tmtc/config/events.py b/eive_tmtc/config/events.py new file mode 100644 index 0000000..f1cc723 --- /dev/null +++ b/eive_tmtc/config/events.py @@ -0,0 +1,21 @@ +import os + +from eive_tmtc.config.definitions import EIVE_TMTC_ROOT +from tmtccmd import get_console_logger +from tmtccmd.fsfw import parse_fsfw_events_csv +from tmtccmd.pus.pus_5_event import EventDictT + +LOGGER = get_console_logger() +DEFAULT_EVENTS_CSV_PATH = EIVE_TMTC_ROOT / "/config/events.csv" +__EVENT_DICT = None + + +def get_event_dict() -> EventDictT: + global __EVENT_DICT + if __EVENT_DICT is None: + if os.path.exists(DEFAULT_EVENTS_CSV_PATH): + __EVENT_DICT = parse_fsfw_events_csv(DEFAULT_EVENTS_CSV_PATH) + else: + LOGGER.warning(f"No Event CSV file found at {DEFAULT_EVENTS_CSV_PATH}") + __EVENT_DICT = dict() + return __EVENT_DICT diff --git a/eive_tmtc/config/object_ids.py b/eive_tmtc/config/object_ids.py index c8e6478..150ba17 100644 --- a/eive_tmtc/config/object_ids.py +++ b/eive_tmtc/config/object_ids.py @@ -4,13 +4,15 @@ it to your needs. """ import os.path + +from eive_tmtc.config.definitions import EIVE_TMTC_ROOT from tmtccmd.util.obj_id import ObjectIdDictT from tmtccmd.fsfw import parse_fsfw_objects_csv from tmtccmd.logging import get_console_logger LOGGER = get_console_logger() -DEFAULT_OBJECTS_CSV_PATH = "eive_tmtc/config/objects.csv" +DEFAULT_OBJECTS_CSV_PATH = EIVE_TMTC_ROOT / "config/objects.csv" __OBJECT_ID_DICT = None diff --git a/eive_tmtc/config/retvals.py b/eive_tmtc/config/retvals.py index 18e1469..47d9529 100644 --- a/eive_tmtc/config/retvals.py +++ b/eive_tmtc/config/retvals.py @@ -1,8 +1,10 @@ import os + +from eive_tmtc.config.definitions import EIVE_TMTC_ROOT from tmtccmd.fsfw import parse_fsfw_returnvalues_csv, RetvalDictT from tmtccmd.logging import get_console_logger -DEFAULT_RETVAL_CSV_NAME = "eive_tmtc/config/returnvalues.csv" +DEFAULT_RETVAL_CSV_NAME = EIVE_TMTC_ROOT / "config/returnvalues.csv" __RETVAL_DICT = None LOGGER = get_console_logger() diff --git a/eive_tmtc/pus_tc/system/proc.py b/eive_tmtc/pus_tc/system/proc.py index fc701a4..86e4d2b 100644 --- a/eive_tmtc/pus_tc/system/proc.py +++ b/eive_tmtc/pus_tc/system/proc.py @@ -33,7 +33,11 @@ from eive_tmtc.pus_tc.devs.gps import SetIds as GpsSetIds from eive_tmtc.tmtc.acs.imtq import ImtqSetIds from eive_tmtc.pus_tc.devs.sus import SetIds from eive_tmtc.pus_tc.devs.star_tracker import SetIds as StrSetIds -from eive_tmtc.tmtc.acs.reaction_wheels import RwSetIds, rw_speed_up_cmd_consec, rw_speed_down_cmd_consec +from eive_tmtc.tmtc.acs.reaction_wheels import ( + RwSetIds, + rw_speed_up_cmd_consec, + rw_speed_down_cmd_consec, +) from eive_tmtc.pus_tc.system.controllers import ( pack_cmd_ctrl_to_off, pack_cmd_ctrl_to_nml, diff --git a/eive_tmtc/pus_tm/event_handler.py b/eive_tmtc/pus_tm/event_handler.py index cdd6d40..add971a 100644 --- a/eive_tmtc/pus_tm/event_handler.py +++ b/eive_tmtc/pus_tm/event_handler.py @@ -1,6 +1,6 @@ -import logging -import os.path from datetime import datetime + +from eive_tmtc.config.events import get_event_dict from eive_tmtc.config.object_ids import get_object_ids from eive_tmtc.pus_tm.defs import PrintWrapper from eive_tmtc.pus_tm.verification_handler import generic_retval_printout @@ -10,23 +10,9 @@ from tmtccmd.tc.pus_200_fsfw_modes import Modes from tmtccmd.tm import Service5Tm from tmtccmd.logging import get_console_logger from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter -from tmtccmd.fsfw import parse_fsfw_events_csv, EventDictT, EventInfo - +from tmtccmd.fsfw import EventInfo LOGGER = get_console_logger() -DEFAULT_EVENTS_CSV_PATH = "eive_tmtc/config/events.csv" -__EVENT_DICT = None - - -def get_event_dict() -> EventDictT: - global __EVENT_DICT - if __EVENT_DICT is None: - if os.path.exists(DEFAULT_EVENTS_CSV_PATH): - __EVENT_DICT = parse_fsfw_events_csv(DEFAULT_EVENTS_CSV_PATH) - else: - LOGGER.warning(f"No Event CSV file found at {DEFAULT_EVENTS_CSV_PATH}") - __EVENT_DICT = dict() - return __EVENT_DICT def handle_event_packet(raw_tm: bytes, printer: FsfwTmTcPrinter):