mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-03 07:28:54 +08:00
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:
@@ -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 = []
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user