Skip to content

Commit

Permalink
px4airframes doc: handle common outputs individually
Browse files Browse the repository at this point in the history
preparation for dynamic control allocation, where we won't have MAIN vs
AUX anymore (at least for the generic frames).
  • Loading branch information
bkueng committed Dec 17, 2021
1 parent 95a0fb1 commit e535990
Showing 1 changed file with 14 additions and 28 deletions.
42 changes: 14 additions & 28 deletions Tools/px4airframes/markdownout.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,38 +72,27 @@ def __init__(self, groups, board, image_path):

# check if all outputs are equal for the group: if so, show them
# only once
outputs_prev = ['', ''] # split into MAINx and others (AUXx)
outputs_match = [True, True]
all_outputs = {}
num_configs = len(group.GetParams())
for param in group.GetParams():
if not self.IsExcluded(param, board):
outputs_current = ['', '']
for output_name in param.GetOutputCodes():
value = param.GetOutputValue(output_name)
if output_name.lower().startswith('main'):
idx = 0
else:
idx = 1
outputs_current[idx] += '<li><b>%s</b>: %s</li>' % (output_name, value)
for i in range(2):
if len(outputs_current[i]) != 0:
if outputs_prev[i] == '':
outputs_prev[i] = outputs_current[i]
elif outputs_current[i] != outputs_prev[i]:
outputs_match[i] = False

for i in range(2):
if len(outputs_prev[i]) == 0:
outputs_match[i] = False
if not outputs_match[i]:
outputs_prev[i] = ''

if outputs_match[0] or outputs_match[1]:
key_value_pair = (output_name, value)
if key_value_pair not in all_outputs:
all_outputs[key_value_pair] = 0
all_outputs[key_value_pair] += 1
has_common_outputs = any(all_outputs[k] == num_configs for k in all_outputs)

if has_common_outputs:
outputs_common = ''.join(['<li><b>{:}</b>: {:}</li>'.format(k[0], k[1]) \
for k in all_outputs if all_outputs[k] == num_configs])
result += '<table>\n'
result += ' <thead>\n'
result += ' <tr><th>Common Outputs</th></tr>\n'
result += ' </thead>\n'
result += ' <tbody>\n'
result += '<tr>\n <td><ul>%s%s</ul></td>\n</tr>\n' % (outputs_prev[0], outputs_prev[1])
result += '<tr>\n <td><ul>%s</ul></td>\n</tr>\n' % (outputs_common)
result += '</tbody></table>\n'

result += '</div>\n\n'
Expand Down Expand Up @@ -138,11 +127,8 @@ def __init__(self, groups, board, image_path):
for output_name in param.GetOutputCodes():
value = param.GetOutputValue(output_name)
valstrs = value.split(";")
if output_name.lower().startswith('main'):
idx = 0
else:
idx = 1
if not outputs_match[idx]:
key_value_pair = (output_name, value)
if all_outputs[key_value_pair] < num_configs:
outputs += '<li><b>%s</b>: %s</li>' % (output_name, value)
has_outputs = True

Expand Down

0 comments on commit e535990

Please sign in to comment.