commander preflight checks: new structure using events interface

- Reporter class that keeps track of results (list of events + whether
  arming is possible + health).
  And only reports when one or more checks change.
This commit is contained in:
Beat Küng
2022-08-25 22:02:15 -04:00
committed by Daniel Agar
parent 04f7df3848
commit 07afcf4586
9 changed files with 1033 additions and 2 deletions
+2
View File
@@ -25,6 +25,8 @@ class JsonOutput():
event_obj = {}
event_obj['name'] = e.name
event_obj['message'] = e.message
if e.type is not None:
event_obj['type'] = e.type
if e.description is not None:
event_obj['description'] = e.description
args = []
+4 -1
View File
@@ -23,6 +23,7 @@ class Event(object):
self.message = None
self.description = None
self.group = "default"
self.type = None
self._arguments = []
@staticmethod
@@ -130,6 +131,8 @@ class SourceParser(object):
if not event.group in known_groups:
raise Exception("Unknown event group: '{}'\nKnown groups: {}\n" \
"If this is not a typo, add the new group to the script".format(event.group, known_groups))
elif tag == "type":
event.type = value.strip()
elif tag.startswith("arg"):
arg_index = int(tag[3:])-1
arg_name = value.strip()
@@ -237,7 +240,7 @@ class SourceParser(object):
event.group = "health"
else:
event.group = "arming_check"
event.prepend_arguments([('common::navigation_mode_category_t', 'modes'),
event.prepend_arguments([('navigation_mode_group_t', 'modes'),
('uint8_t', 'health_component_index')])
else:
raise Exception("unknown event method call: {}, args: {}".format(call, args))