Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
source
OBSW MOD GENERATOR CORE
Commits
7d1c474c
Commit
7d1c474c
authored
Apr 30, 2021
by
Robin Mueller
Browse files
moving window parsing init
parent
403bdd15
Changes
1
Hide whitespace changes
Inline
Side-by-side
events/event_parser.py
View file @
7d1c474c
...
...
@@ -7,11 +7,13 @@ EVENT_ENTRY_SEVERITY_IDX = 1
EVENT_ENTRY_INFO_IDX
=
2
EVENT_SOURCE_FILE_IDX
=
3
FSFW_EVENT_HEADER_INCLUDE
=
"#include <fsfw/events/Event.h>"
DEFAULT_MOVING_WINDOWS_SIZE
=
7
class
SubsystemDefinitionParser
(
FileParser
):
def
__init__
(
self
,
file_list
):
super
().
__init__
(
file_list
)
self
.
moving_window_center_idx
=
3
def
_handle_file_parsing
(
self
,
file_name
:
str
,
*
args
,
**
kwargs
):
file
=
open
(
file_name
,
"r"
)
...
...
@@ -20,6 +22,13 @@ class SubsystemDefinitionParser(FileParser):
if
match
:
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
):
pass
...
...
@@ -29,8 +38,8 @@ class EventParser(FileParser):
super
().
__init__
(
file_list
)
self
.
interfaces
=
interface_list
self
.
count
=
0
self
.
my
I
d
=
0
self
.
current
I
d
=
0
self
.
my
_i
d
=
0
self
.
current
_i
d
=
0
self
.
last_lines
=
[
""
,
""
,
""
]
def
_handle_file_parsing
(
self
,
file_name
:
str
,
*
args
:
any
,
**
kwargs
):
...
...
@@ -48,6 +57,11 @@ class EventParser(FileParser):
total_count
+=
self
.
count
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
):
pass
...
...
@@ -58,9 +72,9 @@ class EventParser(FileParser):
twolines
=
''
match1
=
re
.
search
(
r
"SUBSYSTEM_ID[\s]*=[\s]*SUBSYSTEM_ID::([A-Z_0-9]*);"
,
twolines
)
if
match1
:
self
.
current
I
d
=
self
.
interfaces
[
match1
.
group
(
1
)][
0
]
self
.
current
_i
d
=
self
.
interfaces
[
match1
.
group
(
1
)][
0
]
# print( "Current ID: " + str(currentId) )
self
.
my
I
d
=
self
.
return_number_from_string
(
self
.
current
I
d
)
self
.
my
_i
d
=
self
.
return_number_from_string
(
self
.
current
_i
d
)
match
=
re
.
search
(
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
)
...
...
@@ -72,7 +86,7 @@ class EventParser(FileParser):
if
match
.
group
(
6
):
description
=
self
.
clean_up_description
(
match
.
group
(
6
))
string_to_add
=
match
.
group
(
2
)
full_id
=
(
self
.
my
I
d
*
100
)
+
self
.
return_number_from_string
(
match
.
group
(
3
))
full_id
=
(
self
.
my
_i
d
*
100
)
+
self
.
return_number_from_string
(
match
.
group
(
3
))
severity
=
match
.
group
(
4
)
if
full_id
in
self
.
mib_table
:
# print("EventParser: Duplicate Event " + hex(full_id) + " from " + file_name +
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment