some minor updates and bugfixes
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import re
|
||||
import os
|
||||
from typing import List
|
||||
|
||||
from fsfwgen.parserbase.parser import FileParser
|
||||
@ -49,12 +50,13 @@ class SubsystemDefinitionParser(FileParser):
|
||||
|
||||
|
||||
class EventParser(FileParser):
|
||||
def __init__(self, file_list, interface_list):
|
||||
def __init__(self, file_list: List[str], interface_list):
|
||||
super().__init__(file_list)
|
||||
self.interfaces = interface_list
|
||||
self.count = 0
|
||||
self.my_id = 0
|
||||
self.current_id = 0
|
||||
self.obsw_root_path = None
|
||||
self.last_lines = ["", "", ""]
|
||||
self.moving_window_center_idx = 3
|
||||
|
||||
@ -180,7 +182,7 @@ class EventParser(FileParser):
|
||||
def _post_parsing_operation(self):
|
||||
pass
|
||||
|
||||
def __handle_line_reading(self, line, file_name):
|
||||
def __handle_line_reading(self, line, file_name: str):
|
||||
if not self.last_lines[0] == "\n":
|
||||
twolines = self.last_lines[0] + " " + line.strip()
|
||||
else:
|
||||
@ -213,6 +215,8 @@ class EventParser(FileParser):
|
||||
# print("EventParser: Duplicate Event " + hex(full_id) + " from " + file_name +
|
||||
# " was already in " + self.mib_table[full_id][3])
|
||||
pass
|
||||
if self.obsw_root_path is not None:
|
||||
file_name = os.path.relpath(file_name, self.obsw_root_path)
|
||||
self.mib_table.update(
|
||||
{full_id: (string_to_add, severity, description, file_name)}
|
||||
)
|
||||
@ -285,7 +289,7 @@ def write_translation_source_file(
|
||||
definitions = ""
|
||||
|
||||
function = (
|
||||
"const char* translateEvents(Event event) {\n switch( (event & 0xFFFF) ) {\n"
|
||||
"const char *translateEvents(Event event) {\n switch((event & 0xFFFF)) {\n"
|
||||
)
|
||||
for entry in event_list:
|
||||
event_id = entry[0]
|
||||
@ -294,8 +298,11 @@ def write_translation_source_file(
|
||||
f"const char *{event_value[EVENT_ENTRY_NAME_IDX]}_STRING "
|
||||
f'= "{event_value[EVENT_ENTRY_NAME_IDX]}";\n'
|
||||
)
|
||||
function += f" case({event_id}):\n return {event_value[EVENT_ENTRY_NAME_IDX]}_STRING;\n"
|
||||
function += ' default:\n return "UNKNOWN_EVENT";\n'
|
||||
function += (
|
||||
f" case ({event_id}):\n "
|
||||
f"return {event_value[EVENT_ENTRY_NAME_IDX]}_STRING;\n"
|
||||
)
|
||||
function += ' default:\n return "UNKNOWN_EVENT";\n'
|
||||
outputfile.write(
|
||||
f"/**\n * @brief Auto-generated event translation file. "
|
||||
f"Contains {len(event_list)} translations.\n"
|
||||
@ -313,7 +320,7 @@ def write_translation_header_file(filename: str = "translateEvents.h"):
|
||||
f"#ifndef FSFWCONFIG_EVENTS_TRANSLATEEVENTS_H_\n"
|
||||
f"#define FSFWCONFIG_EVENTS_TRANSLATEEVENTS_H_\n\n"
|
||||
f"{FSFW_EVENT_HEADER_INCLUDE}\n\n"
|
||||
f"const char * translateEvents(Event event);\n\n"
|
||||
f"const char *translateEvents(Event event);\n\n"
|
||||
f"#endif /* FSFWCONFIG_EVENTS_TRANSLATEEVENTS_H_ */\n"
|
||||
)
|
||||
|
||||
|
Reference in New Issue
Block a user