changes for updated tmtccmd
This commit is contained in:
@ -3,11 +3,12 @@
|
||||
@details Template configuration file. Copy this folder to the TMTC commander root and adapt
|
||||
it to your needs.
|
||||
"""
|
||||
import csv
|
||||
import copy
|
||||
import os.path
|
||||
from tmtccmd.pus.obj_id import ObjectId, ObjectIdDictT
|
||||
from tmtccmd.pus.obj_id import ObjectIdDictT
|
||||
from tmtccmd.utility.fsfw import parse_fsfw_objects_csv
|
||||
from tmtccmd.utility.logger import get_console_logger
|
||||
|
||||
LOGGER = get_console_logger()
|
||||
DEFAULT_OBJECTS_CSV_PATH = "config/objects.csv"
|
||||
__OBJECT_ID_DICT = None
|
||||
|
||||
@ -73,15 +74,11 @@ class ObjectInfo:
|
||||
|
||||
def get_object_ids() -> ObjectIdDictT:
|
||||
global __OBJECT_ID_DICT
|
||||
if __OBJECT_ID_DICT is None and os.path.exists(DEFAULT_OBJECTS_CSV_PATH):
|
||||
__OBJECT_ID_DICT = dict()
|
||||
obj_id = ObjectId(object_id=0)
|
||||
with open(DEFAULT_OBJECTS_CSV_PATH) as csvfile:
|
||||
csv_reader = csv.reader(csvfile, delimiter=";")
|
||||
for row in csv_reader:
|
||||
obj_id.id = int(row[0], 16)
|
||||
obj_id.name = row[1]
|
||||
__OBJECT_ID_DICT.update(
|
||||
{obj_id.as_bytes: copy.copy(obj_id)}
|
||||
)
|
||||
if not os.path.exists(DEFAULT_OBJECTS_CSV_PATH):
|
||||
LOGGER.warning(f"No Objects CSV file found at {DEFAULT_OBJECTS_CSV_PATH}")
|
||||
if __OBJECT_ID_DICT is None:
|
||||
if os.path.exists(DEFAULT_OBJECTS_CSV_PATH):
|
||||
__OBJECT_ID_DICT = parse_fsfw_objects_csv(csv_file=DEFAULT_OBJECTS_CSV_PATH)
|
||||
else:
|
||||
__OBJECT_ID_DICT = dict()
|
||||
return __OBJECT_ID_DICT
|
||||
|
Reference in New Issue
Block a user