Commit 7d1c474c authored by Robin Mueller's avatar Robin Mueller
Browse files

moving window parsing init

parent 403bdd15
...@@ -7,11 +7,13 @@ EVENT_ENTRY_SEVERITY_IDX = 1 ...@@ -7,11 +7,13 @@ EVENT_ENTRY_SEVERITY_IDX = 1
EVENT_ENTRY_INFO_IDX = 2 EVENT_ENTRY_INFO_IDX = 2
EVENT_SOURCE_FILE_IDX = 3 EVENT_SOURCE_FILE_IDX = 3
FSFW_EVENT_HEADER_INCLUDE = "#include <fsfw/events/Event.h>" FSFW_EVENT_HEADER_INCLUDE = "#include <fsfw/events/Event.h>"
DEFAULT_MOVING_WINDOWS_SIZE = 7
class SubsystemDefinitionParser(FileParser): class SubsystemDefinitionParser(FileParser):
def __init__(self, file_list): def __init__(self, file_list):
super().__init__(file_list) super().__init__(file_list)
self.moving_window_center_idx = 3
def _handle_file_parsing(self, file_name: str, *args, **kwargs): def _handle_file_parsing(self, file_name: str, *args, **kwargs):
file = open(file_name, "r") file = open(file_name, "r")
...@@ -20,6 +22,13 @@ class SubsystemDefinitionParser(FileParser): ...@@ -20,6 +22,13 @@ class SubsystemDefinitionParser(FileParser):
if match: if match:
self.mib_table.update({match.group(1): [match.group(2)]}) self.mib_table.update({match.group(1): [match.group(2)]})
def _handle_file_parsing_moving_window(
self, file_name: str, current_line: int, moving_window_size: int, moving_window: list,
*args, **kwargs):
match = re.search(r'([A-Z0-9_]*) = ([0-9]{1,2})', moving_window[self.moving_window_center_idx])
if match:
self.mib_table.update({match.group(1): [match.group(2)]})
def _post_parsing_operation(self): def _post_parsing_operation(self):
pass pass
...@@ -29,8 +38,8 @@ class EventParser(FileParser): ...@@ -29,8 +38,8 @@ class EventParser(FileParser):
super().__init__(file_list) super().__init__(file_list)
self.interfaces = interface_list self.interfaces = interface_list
self.count = 0 self.count = 0
self.myId = 0 self.my_id = 0
self.currentId = 0 self.current_id = 0
self.last_lines = ["", "", ""] self.last_lines = ["", "", ""]
def _handle_file_parsing(self, file_name: str, *args: any, **kwargs): def _handle_file_parsing(self, file_name: str, *args: any, **kwargs):
...@@ -48,6 +57,11 @@ class EventParser(FileParser): ...@@ -48,6 +57,11 @@ class EventParser(FileParser):
total_count += self.count total_count += self.count
self.count = 0 self.count = 0
def _handle_file_parsing_moving_window(
self, file_name: str, current_line: int, moving_window_size: int, moving_window: list,
*args, **kwargs):
pass
def _post_parsing_operation(self): def _post_parsing_operation(self):
pass pass
...@@ -58,9 +72,9 @@ class EventParser(FileParser): ...@@ -58,9 +72,9 @@ class EventParser(FileParser):
twolines = '' twolines = ''
match1 = re.search(r"SUBSYSTEM_ID[\s]*=[\s]*SUBSYSTEM_ID::([A-Z_0-9]*);", twolines) match1 = re.search(r"SUBSYSTEM_ID[\s]*=[\s]*SUBSYSTEM_ID::([A-Z_0-9]*);", twolines)
if match1: if match1:
self.currentId = self.interfaces[match1.group(1)][0] self.current_id = self.interfaces[match1.group(1)][0]
# print( "Current ID: " + str(currentId) ) # print( "Current ID: " + str(currentId) )
self.myId = self.return_number_from_string(self.currentId) self.my_id = self.return_number_from_string(self.current_id)
match = re.search( match = re.search(
r"(//)?[\t ]*static const(?:expr)? Event[\s]*([A-Z_0-9]*)[\s]*=[\s]*" r"(//)?[\t ]*static const(?:expr)? Event[\s]*([A-Z_0-9]*)[\s]*=[\s]*"
r"MAKE_EVENT\(([0-9]{1,2}),[\s]*severity::([A-Z]*)\);[\t ]*(//!<)?([^\n]*)", twolines) r"MAKE_EVENT\(([0-9]{1,2}),[\s]*severity::([A-Z]*)\);[\t ]*(//!<)?([^\n]*)", twolines)
...@@ -72,7 +86,7 @@ class EventParser(FileParser): ...@@ -72,7 +86,7 @@ class EventParser(FileParser):
if match.group(6): if match.group(6):
description = self.clean_up_description(match.group(6)) description = self.clean_up_description(match.group(6))
string_to_add = match.group(2) string_to_add = match.group(2)
full_id = (self.myId * 100) + self.return_number_from_string(match.group(3)) full_id = (self.my_id * 100) + self.return_number_from_string(match.group(3))
severity = match.group(4) severity = match.group(4)
if full_id in self.mib_table: if full_id in self.mib_table:
# print("EventParser: Duplicate Event " + hex(full_id) + " from " + file_name + # print("EventParser: Duplicate Event " + hex(full_id) + " from " + file_name +
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment