# Copyright 2024 Volvo Car Corporation # Licensed under Apache 2.0. """Module containing classes for generation of signal consistency check report.""" from pybuild.html_report import HtmlReport class SigConsHtmlReportBase(HtmlReport): """Generate html report from the signal consistency check result. (see :doc:`signal_interfaces`) Inherits :doc:`HtmlReport `. """ __intro = """

Table of contents

  1. Introduction
  2. Detailed unit information
  3. External signals
    1. Missing external signals
    2. Unused external signals
  4. Unit index

Introduction

This documents lists inconsistencies in the internal and external signal configuration.

""" _table_unused = """ """ _table_incons = """
Variable Configurations
""" _table_unknown = """
Variable Variable parameter Difference
""" def __init__(self, res_dict=None): """Initialize class instance. Args: res_dict (dict): result dict from the signal interface consistency check The dict shall have the following format:: { "sigs": { "ext": {"missing": {}, "unused": {}, "inconsistent_defs": {}}, "int": {"UNIT_NAME": {"missing": {}, "unused": {}, "multiple_defs": {} "inconsistent_defs": {}} } } """ super().__init__('Signal consistency report') @staticmethod def _set_to_str(set_): """Convert a set to a sorted string.""" out = "" for conf in sorted(set_): out += conf + ', ' return out[:-2] def _gen_missing_sigs(self, unit_data, out=''): """Generate the unit specific information for missing signal in a unit.""" out += self._table_unused for var in sorted(unit_data['missing'].keys()): configs = unit_data['missing'][var] out += ' \n' out += f' \n' out += f' \n' out += ' \n' out += ' \n' out += '
Variable Units
{var}{self._set_to_str(configs)}
\n' return out def _gen_unused_sigs(self, unit_data, out=''): """Generate the unit specific information for the unused signals wihtin a unit.""" out += self._table_unused for var in sorted(unit_data['unused'].keys()): configs = unit_data['unused'][var] out += ' \n' out += f' {var}\n' out += f' {self._set_to_str(configs)}\n' out += ' \n' out += ' \n' out += ' \n' return out def _gen_multiple_def_sigs(self, unit_data, out=''): """Generate unit specific information for the signals that are generated more than once.""" out += self._table_unused for var in sorted(unit_data['multiple_defs'].keys()): configs = unit_data['multiple_defs'][var] out += ' \n' out += f' {var}\n' out += f' {self._set_to_str(configs)}\n' out += ' \n' out += ' \n' out += ' \n' return out def _gen_ext_inconsistent_defs(self, unit, out=''): """Generate a report of inconsistent variable definition parameters. Report inconsistencies between the producing signal definition, and the signal definitions in the external interface definition. """ out += self._table_incons incons_unit = self._res_dict['sigs']['ext']['inconsistent_defs'][unit] for var in sorted(incons_unit.keys()): first_cells = f' \n {var}\n' for v_par, desc in incons_unit[var].items(): out += first_cells out += f' {v_par}\n' out += f' {desc}\n' out += ' \n' first_cells = ' \n \n' out += ' \n' out += ' \n' return out def _gen_int_inconsistent_defs(self, unit_data, out=''): """Generate a report of inconsistent variable definition parameters. Inconsistent for between the producing signal definition, and the consuming signal definitions for SPM internal signals. """ out += self._table_incons for var in sorted(unit_data['inconsistent_defs'].keys()): configs = unit_data['inconsistent_defs'][var] first_cells = f' \n {var}\n' for v_par, desc in configs.items(): out += first_cells out += f' {v_par}\n' out += f' {desc}\n' out += ' \n' first_cells = ' \n \n' out += ' \n' out += ' \n' return out