From 2333bef670c23cee9f6784e52b4d8bcca8d3b691 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Fri, 17 Dec 2021 11:36:37 +0100 Subject: [PATCH] px4airframes doc: handle common outputs individually preparation for dynamic control allocation, where we won't have MAIN vs AUX anymore (at least for the generic frames). --- Tools/px4airframes/markdownout.py | 40 ++++++++++--------------------- 1 file changed, 13 insertions(+), 27 deletions(-) diff --git a/Tools/px4airframes/markdownout.py b/Tools/px4airframes/markdownout.py index d8ac5aeb33..5386404f71 100644 --- a/Tools/px4airframes/markdownout.py +++ b/Tools/px4airframes/markdownout.py @@ -72,38 +72,27 @@ div.frame_variant td, div.frame_variant th { # 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] += '
  • %s: %s
  • ' % (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 + 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) - 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]: + if has_common_outputs: + outputs_common = ''.join(['
  • {:}: {:}
  • '.format(k[0], k[1]) \ + for k in all_outputs if all_outputs[k] == num_configs]) result += '\n' result += ' \n' result += ' \n' result += ' \n' result += ' \n' - result += '\n \n\n' % (outputs_prev[0], outputs_prev[1]) + result += '\n \n\n' % (outputs_common) result += '
    Common Outputs
      %s%s
      %s
    \n' result += '\n\n' @@ -138,11 +127,8 @@ div.frame_variant td, div.frame_variant th { 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 += '
  • %s: %s
  • ' % (output_name, value) has_outputs = True