powertrain-build 1.13.1__py3-none-any.whl → 1.13.3.dev3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. powertrain_build/__init__.py +40 -40
  2. powertrain_build/__main__.py +6 -6
  3. powertrain_build/a2l.py +582 -582
  4. powertrain_build/a2l_merge.py +650 -650
  5. powertrain_build/a2l_templates.py +717 -717
  6. powertrain_build/build.py +985 -985
  7. powertrain_build/build_defs.py +309 -309
  8. powertrain_build/build_proj_config.py +690 -690
  9. powertrain_build/check_interface.py +575 -575
  10. powertrain_build/cli.py +141 -141
  11. powertrain_build/config.py +542 -542
  12. powertrain_build/core.py +395 -395
  13. powertrain_build/core_dummy.py +343 -343
  14. powertrain_build/create_conversion_table.py +73 -73
  15. powertrain_build/dids.py +916 -916
  16. powertrain_build/dummy.py +157 -157
  17. powertrain_build/dummy_spm.py +252 -252
  18. powertrain_build/environmentcheck.py +52 -52
  19. powertrain_build/ext_dbg.py +255 -255
  20. powertrain_build/ext_var.py +327 -327
  21. powertrain_build/feature_configs.py +301 -301
  22. powertrain_build/gen_allsysteminfo.py +227 -227
  23. powertrain_build/gen_label_split.py +449 -449
  24. powertrain_build/handcode_replacer.py +124 -124
  25. powertrain_build/html_report.py +133 -133
  26. powertrain_build/interface/__init__.py +4 -4
  27. powertrain_build/interface/application.py +511 -511
  28. powertrain_build/interface/base.py +500 -500
  29. powertrain_build/interface/csp_api.py +490 -490
  30. powertrain_build/interface/device_proxy.py +677 -677
  31. powertrain_build/interface/ems.py +67 -67
  32. powertrain_build/interface/export_global_vars.py +121 -121
  33. powertrain_build/interface/generate_adapters.py +132 -132
  34. powertrain_build/interface/generate_hi_interface.py +87 -87
  35. powertrain_build/interface/generate_service.py +69 -69
  36. powertrain_build/interface/generate_wrappers.py +147 -147
  37. powertrain_build/interface/generation_utils.py +142 -142
  38. powertrain_build/interface/hal.py +194 -194
  39. powertrain_build/interface/model_yaml_verification.py +348 -348
  40. powertrain_build/interface/service.py +296 -296
  41. powertrain_build/interface/simulink.py +249 -249
  42. powertrain_build/interface/update_call_sources.py +180 -180
  43. powertrain_build/interface/update_model_yaml.py +186 -186
  44. powertrain_build/interface/zone_controller.py +362 -362
  45. powertrain_build/lib/__init__.py +4 -4
  46. powertrain_build/lib/helper_functions.py +127 -127
  47. powertrain_build/lib/logger.py +55 -55
  48. powertrain_build/matlab_scripts/CodeGen/BuildAutomationPyBuild.m +78 -78
  49. powertrain_build/matlab_scripts/CodeGen/Generate_A2L.m +154 -154
  50. powertrain_build/matlab_scripts/CodeGen/generateTLUnit.m +239 -239
  51. powertrain_build/matlab_scripts/CodeGen/getAsilClassification.m +28 -28
  52. powertrain_build/matlab_scripts/CodeGen/modelConfiguredForTL.m +28 -28
  53. powertrain_build/matlab_scripts/CodeGen/moveDefOutports.m +88 -88
  54. powertrain_build/matlab_scripts/CodeGen/parseCalMeasData.m +410 -410
  55. powertrain_build/matlab_scripts/CodeGen/parseCoreIdentifiers.m +139 -139
  56. powertrain_build/matlab_scripts/CodeGen/parseDIDs.m +141 -141
  57. powertrain_build/matlab_scripts/CodeGen/parseInPorts.m +106 -106
  58. powertrain_build/matlab_scripts/CodeGen/parseIncludeConfigs.m +25 -25
  59. powertrain_build/matlab_scripts/CodeGen/parseModelInfo.m +38 -38
  60. powertrain_build/matlab_scripts/CodeGen/parseNVM.m +81 -81
  61. powertrain_build/matlab_scripts/CodeGen/parseOutPorts.m +120 -120
  62. powertrain_build/matlab_scripts/CodeGen/parsePreProcBlks.m +23 -23
  63. powertrain_build/matlab_scripts/CodeGen/struct2JSON.m +128 -128
  64. powertrain_build/matlab_scripts/CodeGen/updateCodeSwConfig.m +31 -31
  65. powertrain_build/matlab_scripts/Init_PyBuild.m +91 -91
  66. powertrain_build/matlab_scripts/__init__.py +2 -2
  67. powertrain_build/matlab_scripts/helperFunctions/Get_Full_Name.m +46 -46
  68. powertrain_build/matlab_scripts/helperFunctions/Get_SrcLines.m +12 -12
  69. powertrain_build/matlab_scripts/helperFunctions/Init_Models.m +78 -78
  70. powertrain_build/matlab_scripts/helperFunctions/Init_Projects.m +67 -67
  71. powertrain_build/matlab_scripts/helperFunctions/Read_Units.m +34 -34
  72. powertrain_build/matlab_scripts/helperFunctions/SetProjectTimeSamples.m +26 -26
  73. powertrain_build/matlab_scripts/helperFunctions/Strip_Suffix.m +16 -16
  74. powertrain_build/matlab_scripts/helperFunctions/followLink.m +118 -118
  75. powertrain_build/matlab_scripts/helperFunctions/getCodeSwitches.m +50 -50
  76. powertrain_build/matlab_scripts/helperFunctions/getConsumerBlocks.m +30 -30
  77. powertrain_build/matlab_scripts/helperFunctions/getDefBlock.m +39 -39
  78. powertrain_build/matlab_scripts/helperFunctions/getDefOutport.m +58 -58
  79. powertrain_build/matlab_scripts/helperFunctions/getDstBlocks.m +19 -19
  80. powertrain_build/matlab_scripts/helperFunctions/getDstLines.m +13 -13
  81. powertrain_build/matlab_scripts/helperFunctions/getInterfaceSignals.m +37 -37
  82. powertrain_build/matlab_scripts/helperFunctions/getName.m +37 -37
  83. powertrain_build/matlab_scripts/helperFunctions/getPath.m +6 -6
  84. powertrain_build/matlab_scripts/helperFunctions/getProperValue.m +21 -21
  85. powertrain_build/matlab_scripts/helperFunctions/getSrcBlocks.m +19 -19
  86. powertrain_build/matlab_scripts/helperFunctions/getSrcLines.m +13 -13
  87. powertrain_build/matlab_scripts/helperFunctions/loadLibraries.m +10 -10
  88. powertrain_build/matlab_scripts/helperFunctions/loadjson.m +6 -6
  89. powertrain_build/matlab_scripts/helperFunctions/modifyEnumStructField.m +21 -21
  90. powertrain_build/matlab_scripts/helperFunctions/removeConfigDuplicates.m +31 -31
  91. powertrain_build/matlab_scripts/helperFunctions/sortSystemByClass.m +26 -26
  92. powertrain_build/matlab_scripts/helperFunctions/tl_getfast.m +89 -89
  93. powertrain_build/matlab_scripts/helperFunctions/topLevelSystem.m +20 -20
  94. powertrain_build/matlab_scripts/helperFunctions/updateModels.m +131 -131
  95. powertrain_build/memory_section.py +224 -224
  96. powertrain_build/nvm_def.py +729 -729
  97. powertrain_build/problem_logger.py +86 -86
  98. powertrain_build/pt_matlab.py +430 -430
  99. powertrain_build/pt_win32.py +144 -144
  100. powertrain_build/replace_compu_tab_ref.py +105 -105
  101. powertrain_build/rte_dummy.py +254 -254
  102. powertrain_build/sched_funcs.py +209 -207
  103. powertrain_build/signal.py +7 -7
  104. powertrain_build/signal_if_html_rep.py +221 -221
  105. powertrain_build/signal_if_html_rep_all.py +302 -302
  106. powertrain_build/signal_incons_html_rep.py +180 -180
  107. powertrain_build/signal_incons_html_rep_all.py +366 -366
  108. powertrain_build/signal_incons_html_rep_base.py +168 -168
  109. powertrain_build/signal_inconsistency_check.py +641 -641
  110. powertrain_build/signal_interfaces.py +864 -864
  111. powertrain_build/templates/Index_SigCheck_All.html +22 -22
  112. powertrain_build/templates/Index_SigIf_All.html +19 -19
  113. powertrain_build/types.py +218 -218
  114. powertrain_build/unit_configs.py +419 -419
  115. powertrain_build/user_defined_types.py +660 -660
  116. powertrain_build/versioncheck.py +66 -66
  117. powertrain_build/wrapper.py +512 -512
  118. powertrain_build/xlrd_csv.py +87 -87
  119. powertrain_build/zone_controller/__init__.py +4 -4
  120. powertrain_build/zone_controller/calibration.py +176 -176
  121. powertrain_build/zone_controller/composition_yaml.py +880 -878
  122. {powertrain_build-1.13.1.dist-info → powertrain_build-1.13.3.dev3.dist-info}/METADATA +100 -100
  123. powertrain_build-1.13.3.dev3.dist-info/RECORD +130 -0
  124. {powertrain_build-1.13.1.dist-info → powertrain_build-1.13.3.dev3.dist-info}/WHEEL +1 -1
  125. {powertrain_build-1.13.1.dist-info → powertrain_build-1.13.3.dev3.dist-info}/licenses/LICENSE +202 -202
  126. powertrain_build-1.13.3.dev3.dist-info/pbr.json +1 -0
  127. powertrain_build-1.13.1.dist-info/RECORD +0 -130
  128. powertrain_build-1.13.1.dist-info/pbr.json +0 -1
  129. {powertrain_build-1.13.1.dist-info → powertrain_build-1.13.3.dev3.dist-info}/entry_points.txt +0 -0
  130. {powertrain_build-1.13.1.dist-info → powertrain_build-1.13.3.dev3.dist-info}/licenses/AUTHORS +0 -0
  131. {powertrain_build-1.13.1.dist-info → powertrain_build-1.13.3.dev3.dist-info}/licenses/NOTICE +0 -0
  132. {powertrain_build-1.13.1.dist-info → powertrain_build-1.13.3.dev3.dist-info}/top_level.txt +0 -0
@@ -1,366 +1,366 @@
1
- # Copyright 2024 Volvo Car Corporation
2
- # Licensed under Apache 2.0.
3
-
4
- """Module containing classes for generation of signal consistency check report."""
5
- import json
6
-
7
- from powertrain_build.signal_incons_html_rep_base import SigConsHtmlReportBase
8
-
9
-
10
- class SigConsHtmlReportAll(SigConsHtmlReportBase):
11
- """Generate html report from the signal consistency check result.
12
-
13
- (see :doc:`signal_interfaces`)
14
-
15
- Inherits :doc:`HtmlReport <html_report>`.
16
- """
17
-
18
- __intro_all = """<h2 id="introduction">Introduction</h2>
19
- <p>This documents lists inconsistencies in the internal and external signal configuration.</p>
20
- """
21
- __table_incons = """ <table id="inconsistent">
22
- <thead>
23
- <tr>
24
- <th>Variable</th>
25
- <th>Variable parameter</th>
26
- <th>Difference</th>
27
- <th>Configurations</th>
28
- </tr>
29
- </thead>
30
- <tbody>"""
31
-
32
- __toc_ext_sig = """<h2 class="nocount">Table of contents</h2>'
33
- <ol>
34
- <li><a href="#ext_sigs">External signals</a>
35
- <ol>
36
- <li><a href="#ext_missing">Missing external signals</a></li>
37
- <li><a href="#ext_unused">Unused external signals</a></li>
38
- </ol></li>
39
- <h2 id="ext_sigs">Signals missing and unused in the interface definition</h2>\n
40
- """
41
-
42
- _toc_unit_details = """<h2 class="nocount">Table of contents</h2>
43
- <ol>
44
- <li><a href="#unit_details">Detailed unit information</a></li>
45
- <li><a href="#unit_index">Unit index</a></li>
46
- </ol>
47
- """
48
-
49
- def __init__(self, res_dicts=None):
50
- """Initialize class instance.
51
-
52
- Args:
53
- res_dict (dict): result dict from the signal interface consistency check
54
-
55
- The dict shall have the following format::
56
-
57
- {
58
- "sigs": { "ext": {"missing": {},
59
- "unused": {},
60
- "inconsistent_defs": {}},
61
- "int": {"UNIT_NAME": {"missing": {},
62
- "unused": {},
63
- "multiple_defs": {}
64
- "inconsistent_defs": {}}
65
- },
66
- "never_active_signals": {
67
- "UNIT_NAME": [signal_one, ...]
68
- }
69
- }
70
- """
71
- super().__init__(res_dicts)
72
- self.set_res_dict(res_dicts)
73
-
74
- def _gen_unit_toc(self):
75
- """Generate a unit TOC for the unit with signal inconsistencies.
76
-
77
- Hyperlinks to more in depth unit information.
78
- """
79
- self._out_all_unit_toc = {}
80
- for prj, units in self._all_units.items():
81
- out = ' <h2 id="unit_index">Unit index</h2>\n'
82
- for unit in sorted(units):
83
- out += f' <div><a href="#{unit}">{unit}</a></div>\n'
84
- self._out_all_unit_toc.update({prj: out})
85
-
86
- def _gen_units(self):
87
- """Generate all the information regarding all the units."""
88
- self._out_all_units = {}
89
- self._prj = ''
90
- for prj, units in self._all_units.items():
91
- out = ' <h2 id="unit_details">Detailed Unit Information</h2>\n'
92
- for unit in sorted(units):
93
- out += self._gen_unit(prj, unit)
94
- self._out_all_units.update({prj: out})
95
- return self._out_all_units
96
-
97
- def _gen_unit(self, project, unit):
98
- """Generate the html-report for the unit specific information."""
99
- unit_data_all = {}
100
- out = f' <h3 id="{unit}">{unit}</h3>\n'
101
- if project in self._int_units_all and unit in self._int_units_all[project]:
102
- for prj, res_dict in self._res_dict_all.items():
103
- if unit in res_dict['sigs']['int']:
104
- unit_data = res_dict['sigs']['int'][unit]
105
- unit_data_all.update({prj: unit_data})
106
- _res_dict = self._res_dict_all.get(project)
107
- unit_data = _res_dict['sigs']['int'][unit]
108
- out += ' <h4>Missing signals</h4>\n' \
109
- ' <p>Inports whose signals are not generated in the ' \
110
- 'listed configuration(s).</p>'
111
- out += self._gen_missing_sigs(unit_data, unit_data_all)
112
- out += ' <h4>Unused signals</h4>\n' \
113
- ' <p>Outports that are generated, but not used in the ' \
114
- 'listed configuration(s).</p>'
115
- out += self._gen_unused_sigs(unit_data, unit_data_all)
116
- out += ' <h4>Multiple defined signals</h4>\n' \
117
- ' <p>Outports that are generated more than once in ' \
118
- 'the listed configuration(s).</p>'
119
- out += self._gen_multiple_def_sigs(unit_data, unit_data_all)
120
- out += ' <h4>Internal signal inconsistencies</h4>\n' \
121
- ' <p>Inports that have different variable definitions ' \
122
- 'than the producing outport.</p>'
123
- out += self._gen_int_inconsistent_defs(unit_data, unit_data_all)
124
- if project in self._ext_units_all and unit in self._ext_units_all[project]:
125
- out += self._gen_unit_ext(project, unit)
126
- if project in self._res_dict_all and \
127
- 'never_active_signals' in self._res_dict_all[project] and \
128
- unit in self._res_dict_all[project]['never_active_signals']:
129
- out += ' <h4>Never active signals</h4>\n' \
130
- ' <p>Never active signals will not appear in generated .c file, ' \
131
- 'signals probablty lead to terminators in Simulink model.</p>'
132
- out += self._gen_never_active_sigs(self._res_dict_all[project]['never_active_signals'][unit])
133
- return out
134
-
135
- def _gen_unit_ext(self, project, unit):
136
- out = ''
137
- self._unit_data_all = {}
138
- if unit in self._res_dict_all[project]['sigs']['ext']['inconsistent_defs'].keys():
139
- out += ' <h4>External signal inconsistencies</h4>\n' \
140
- ' <p>In-/Out-ports that have different variable definitions ' \
141
- 'than in the interface definition file.</p>'
142
- out += self._gen_ext_inconsistent_defs(project, unit)
143
- return out
144
-
145
- def _gen_signals_table(self, unit_data, unit_data_all, key, out=''):
146
- """Generate the unit specific information for KEY in a unit."""
147
-
148
- if key not in unit_data:
149
- return out
150
-
151
- out += self._table_unused
152
- for var in sorted(unit_data[key]):
153
- configs_str = ""
154
- for unit_data_cfg in unit_data_all.values():
155
- if key in unit_data_cfg and var in unit_data_cfg[key]:
156
- configs = unit_data_cfg[key][var]
157
- configs_str += f" {self._set_to_str(configs)}"
158
- out += ' <tr>\n'
159
- out += f' <td>{var}</td>\n'
160
- out += f' <td>{configs_str}</td>\n'
161
- out += ' </tr>\n'
162
- out += ' </tbody>\n'
163
- out += ' </table>\n'
164
- return out
165
-
166
- def _gen_missing_sigs(self, unit_data, unit_data_all, out=''):
167
- """Generate the unit specific information for missing signal in a unit."""
168
- return self._gen_signals_table(unit_data, unit_data_all, key='missing', out=out)
169
-
170
- def _gen_unused_sigs(self, unit_data, unit_data_all, out=''):
171
- """Generate the unit specific information for the unused signals wihtin a unit."""
172
- return self._gen_signals_table(unit_data, unit_data_all, key='unused', out=out)
173
-
174
- def _gen_multiple_def_sigs(self, unit_data, unit_data_all, out=''):
175
- """Generate unit specific information for the signals that are generated more than once."""
176
- return self._gen_signals_table(unit_data, unit_data_all, key='multiple_defs', out=out)
177
-
178
- def _gen_never_active_sigs(self, never_active_signals):
179
- """Generate unit specific information for the signals that are never active."""
180
- out = self._table_unused
181
- for signal in never_active_signals:
182
- out += ' <tr>\n'
183
- out += f' <td>{signal}</td>\n'
184
- out += ' <td></td>\n'
185
- out += ' </tr>\n'
186
- out += ' </tbody>\n'
187
- out += ' </table>\n'
188
- return out
189
-
190
- def _gen_ext_inconsistent_defs(self, project, unit, out=''):
191
- """Generate a report of inconsistent variable definition parameters.
192
-
193
- Report inconsistencies between the producing signal definition, and the
194
- signal definitions in the external interface definition.
195
- """
196
- inconsistent_defs_key = 'inconsistent_defs'
197
- if inconsistent_defs_key not in self._res_dict_all[project]['sigs']['ext']:
198
- return out
199
-
200
- out += self.__table_incons
201
- incons_unit = self._res_dict_all[project]['sigs']['ext'][inconsistent_defs_key][unit]
202
- for var in sorted(incons_unit.keys()):
203
- first_cells = f'\n <tr>\n <td>{var}</td>\n'
204
- for v_par, desc in incons_unit[var].items():
205
- out += first_cells
206
- out += f' <td>{v_par}</td>\n'
207
- out += f' <td>{desc}</td>\n'
208
- out += f' <td>{project}</td>\n'
209
- out += ' </tr>\n'
210
- first_cells = ' <tr>\n <td></td>\n'
211
- out += ' </tbody>\n'
212
- out += ' </table>\n'
213
- return out
214
-
215
- def _gen_int_inconsistent_defs(self, unit_data, unit_data_all, out=''):
216
- """Generate a report of inconsistent variable definition parameters.
217
-
218
- Inconsistent for between the producing signal definition, and the
219
- consuming signal definitions for SPM internal signals.
220
- """
221
- inconsistent_defs_key = 'inconsistent_defs'
222
- if inconsistent_defs_key not in unit_data:
223
- return out
224
-
225
- out += self.__table_incons
226
- for var in sorted(unit_data[inconsistent_defs_key].keys()):
227
- configs_str = ""
228
- for prj_cfg in unit_data_all.keys():
229
- configs_str += f" {prj_cfg}"
230
- first_cells = f'\n <tr>\n <td>{var}</td>\n'
231
- configs = unit_data[inconsistent_defs_key][var]
232
- for v_par, desc in configs.items():
233
- out += first_cells
234
- out += f' <td>{v_par}</td>\n'
235
- out += f' <td>{desc}</td>\n'
236
- out += f' <td>{configs_str}</td>\n'
237
- out += ' </tr>\n'
238
- first_cells = ' <tr>\n <td></td>\n'
239
- out += ' </tbody>\n'
240
- out += ' </table>\n'
241
- return out
242
-
243
- def _gen_ext_signals_report(self, type_, comment):
244
- """Generate report for external signals."""
245
- out = f' <h3 id="ext_{type_}">{type_.capitalize()} external signals</h3>\n'
246
- out += f'<p>{comment}</p>'
247
- try:
248
- res_dict = self._res_dict_all.get(self._prj)
249
- out += self._table_unused
250
- ext_data = res_dict['sigs']['ext'][type_]
251
- for var in sorted(ext_data.keys()):
252
- configs_str = ""
253
- for res_dict_cfg in self._res_dict_all.values():
254
- if type_ in res_dict_cfg['sigs']['ext']:
255
- ext_data_cfg = res_dict_cfg['sigs']['ext'][type_]
256
- configs = ext_data_cfg[var]
257
- configs_str += " " + self._set_to_str(configs)
258
- out += ' <tr>\n'
259
- out += f' <td>{var}</td>\n'
260
- out += f' <td>{configs_str}</td>\n'
261
- out += ' </tr>\n'
262
- out += ' </tbody>\n'
263
- out += ' </table>\n'
264
- except KeyError:
265
- pass
266
- return out
267
-
268
- def set_res_dict(self, res_dicts):
269
- """Set the result dictionary used to generate the html-report.
270
-
271
- Args:
272
- res_dicts (dict): result dict from the signal interface consistency check
273
-
274
- See class constructor for dict structure.
275
- """
276
- # nesting defaultdicts is bad so we use this hack
277
- regular_res_dicts = json.loads(json.dumps(res_dicts))
278
- self._res_dict_all = regular_res_dicts
279
- self._ext_units_all = {}
280
- self._int_units_all = {}
281
- self._all_units = {}
282
- for prj, res_dict in self._res_dict_all.items():
283
- _ext_units = set()
284
- _int_units = set()
285
- _units_with_never_active_signals = set()
286
- if res_dict is not None and 'sigs' in res_dict:
287
- if 'ext' in res_dict['sigs'] and 'inconsistent_defs' in res_dict['sigs']['ext']:
288
- _ext_units = set(res_dict['sigs']['ext']['inconsistent_defs'].keys())
289
- self._ext_units_all.update({prj: _ext_units})
290
- if 'int' in res_dict['sigs']:
291
- _int_units = set(res_dict['sigs']['int'].keys())
292
- self._int_units_all.update({prj: _int_units})
293
- if 'never_active_signals' in res_dict:
294
- _units_with_never_active_signals = res_dict['never_active_signals'].keys()
295
- self._all_units[prj] = _ext_units | _int_units | _units_with_never_active_signals
296
-
297
- def _gen_contents_intro(self):
298
- """Generate report contents from the signal interfaces data."""
299
- html = []
300
- html += self.__intro_all
301
- return ''.join(html)
302
-
303
- def _gen_contents_toc_ext_sig(self):
304
- """Generate report contents from the signal interfaces data.
305
-
306
- Specialises HtmlReport.gen_contents()
307
- """
308
- html = []
309
- html += self.__toc_ext_sig
310
- return ''.join(html)
311
-
312
- def _gen_contents_toc_unit_details(self):
313
- """Generate report contents from the signal interfaces data.
314
-
315
- Specialises HtmlReport.gen_contents()
316
- """
317
- html = []
318
- html += self._toc_unit_details
319
- return ''.join(html)
320
-
321
- def _gen_contents_ext_signals(self):
322
- """Generate report contents from the signal inconsistency check result dictionary."""
323
- html = []
324
- html += self._gen_contents_toc_ext_sig()
325
- html += self._gen_ext_signals_report('missing', 'Signals not generated by '
326
- 'Vcc SW, but are defined in '
327
- 'the Interface definition to be '
328
- 'generated')
329
- html += self._gen_ext_signals_report('unused', 'Signals defined to be generated by '
330
- 'supplier SW, but are not used '
331
- 'by VCC SW')
332
- return ''.join(html)
333
-
334
- def _generate_report_string_intro(self):
335
- """Generate a html report as string."""
336
- html = []
337
- html += self._gen_header()
338
- html += self._gen_contents_intro()
339
- html += self._gen_end()
340
- return ''.join(html)
341
-
342
- def _generate_report_string_ext_signals(self):
343
- """Generate a html report as string."""
344
- html = []
345
- html += self._gen_header()
346
- html += self._gen_contents_ext_signals()
347
- html += self._gen_end()
348
- return ''.join(html)
349
-
350
- def generate_report_file_signal_check(self, filename):
351
- """Generate a html report and save to file."""
352
- filename_intro = filename + '_intro.html'
353
- with open(filename_intro, 'w', encoding="utf-8") as fhndl:
354
- fhndl.write(self._generate_report_string_intro())
355
-
356
- self._gen_units()
357
- self._gen_unit_toc()
358
- for key, out in self._out_all_units.items():
359
- html = []
360
- html += self._gen_header()
361
- html += self._gen_contents_toc_unit_details()
362
- html += out
363
- html += self._out_all_unit_toc.get(key, '')
364
- html += self._gen_end()
365
- with open(f'{filename}_{key}.html', 'w', encoding="utf-8") as fhndl:
366
- fhndl.write(''.join(html))
1
+ # Copyright 2024 Volvo Car Corporation
2
+ # Licensed under Apache 2.0.
3
+
4
+ """Module containing classes for generation of signal consistency check report."""
5
+ import json
6
+
7
+ from powertrain_build.signal_incons_html_rep_base import SigConsHtmlReportBase
8
+
9
+
10
+ class SigConsHtmlReportAll(SigConsHtmlReportBase):
11
+ """Generate html report from the signal consistency check result.
12
+
13
+ (see :doc:`signal_interfaces`)
14
+
15
+ Inherits :doc:`HtmlReport <html_report>`.
16
+ """
17
+
18
+ __intro_all = """<h2 id="introduction">Introduction</h2>
19
+ <p>This documents lists inconsistencies in the internal and external signal configuration.</p>
20
+ """
21
+ __table_incons = """ <table id="inconsistent">
22
+ <thead>
23
+ <tr>
24
+ <th>Variable</th>
25
+ <th>Variable parameter</th>
26
+ <th>Difference</th>
27
+ <th>Configurations</th>
28
+ </tr>
29
+ </thead>
30
+ <tbody>"""
31
+
32
+ __toc_ext_sig = """<h2 class="nocount">Table of contents</h2>'
33
+ <ol>
34
+ <li><a href="#ext_sigs">External signals</a>
35
+ <ol>
36
+ <li><a href="#ext_missing">Missing external signals</a></li>
37
+ <li><a href="#ext_unused">Unused external signals</a></li>
38
+ </ol></li>
39
+ <h2 id="ext_sigs">Signals missing and unused in the interface definition</h2>\n
40
+ """
41
+
42
+ _toc_unit_details = """<h2 class="nocount">Table of contents</h2>
43
+ <ol>
44
+ <li><a href="#unit_details">Detailed unit information</a></li>
45
+ <li><a href="#unit_index">Unit index</a></li>
46
+ </ol>
47
+ """
48
+
49
+ def __init__(self, res_dicts=None):
50
+ """Initialize class instance.
51
+
52
+ Args:
53
+ res_dict (dict): result dict from the signal interface consistency check
54
+
55
+ The dict shall have the following format::
56
+
57
+ {
58
+ "sigs": { "ext": {"missing": {},
59
+ "unused": {},
60
+ "inconsistent_defs": {}},
61
+ "int": {"UNIT_NAME": {"missing": {},
62
+ "unused": {},
63
+ "multiple_defs": {}
64
+ "inconsistent_defs": {}}
65
+ },
66
+ "never_active_signals": {
67
+ "UNIT_NAME": [signal_one, ...]
68
+ }
69
+ }
70
+ """
71
+ super().__init__(res_dicts)
72
+ self.set_res_dict(res_dicts)
73
+
74
+ def _gen_unit_toc(self):
75
+ """Generate a unit TOC for the unit with signal inconsistencies.
76
+
77
+ Hyperlinks to more in depth unit information.
78
+ """
79
+ self._out_all_unit_toc = {}
80
+ for prj, units in self._all_units.items():
81
+ out = ' <h2 id="unit_index">Unit index</h2>\n'
82
+ for unit in sorted(units):
83
+ out += f' <div><a href="#{unit}">{unit}</a></div>\n'
84
+ self._out_all_unit_toc.update({prj: out})
85
+
86
+ def _gen_units(self):
87
+ """Generate all the information regarding all the units."""
88
+ self._out_all_units = {}
89
+ self._prj = ''
90
+ for prj, units in self._all_units.items():
91
+ out = ' <h2 id="unit_details">Detailed Unit Information</h2>\n'
92
+ for unit in sorted(units):
93
+ out += self._gen_unit(prj, unit)
94
+ self._out_all_units.update({prj: out})
95
+ return self._out_all_units
96
+
97
+ def _gen_unit(self, project, unit):
98
+ """Generate the html-report for the unit specific information."""
99
+ unit_data_all = {}
100
+ out = f' <h3 id="{unit}">{unit}</h3>\n'
101
+ if project in self._int_units_all and unit in self._int_units_all[project]:
102
+ for prj, res_dict in self._res_dict_all.items():
103
+ if unit in res_dict['sigs']['int']:
104
+ unit_data = res_dict['sigs']['int'][unit]
105
+ unit_data_all.update({prj: unit_data})
106
+ _res_dict = self._res_dict_all.get(project)
107
+ unit_data = _res_dict['sigs']['int'][unit]
108
+ out += ' <h4>Missing signals</h4>\n' \
109
+ ' <p>Inports whose signals are not generated in the ' \
110
+ 'listed configuration(s).</p>'
111
+ out += self._gen_missing_sigs(unit_data, unit_data_all)
112
+ out += ' <h4>Unused signals</h4>\n' \
113
+ ' <p>Outports that are generated, but not used in the ' \
114
+ 'listed configuration(s).</p>'
115
+ out += self._gen_unused_sigs(unit_data, unit_data_all)
116
+ out += ' <h4>Multiple defined signals</h4>\n' \
117
+ ' <p>Outports that are generated more than once in ' \
118
+ 'the listed configuration(s).</p>'
119
+ out += self._gen_multiple_def_sigs(unit_data, unit_data_all)
120
+ out += ' <h4>Internal signal inconsistencies</h4>\n' \
121
+ ' <p>Inports that have different variable definitions ' \
122
+ 'than the producing outport.</p>'
123
+ out += self._gen_int_inconsistent_defs(unit_data, unit_data_all)
124
+ if project in self._ext_units_all and unit in self._ext_units_all[project]:
125
+ out += self._gen_unit_ext(project, unit)
126
+ if project in self._res_dict_all and \
127
+ 'never_active_signals' in self._res_dict_all[project] and \
128
+ unit in self._res_dict_all[project]['never_active_signals']:
129
+ out += ' <h4>Never active signals</h4>\n' \
130
+ ' <p>Never active signals will not appear in generated .c file, ' \
131
+ 'signals probablty lead to terminators in Simulink model.</p>'
132
+ out += self._gen_never_active_sigs(self._res_dict_all[project]['never_active_signals'][unit])
133
+ return out
134
+
135
+ def _gen_unit_ext(self, project, unit):
136
+ out = ''
137
+ self._unit_data_all = {}
138
+ if unit in self._res_dict_all[project]['sigs']['ext']['inconsistent_defs'].keys():
139
+ out += ' <h4>External signal inconsistencies</h4>\n' \
140
+ ' <p>In-/Out-ports that have different variable definitions ' \
141
+ 'than in the interface definition file.</p>'
142
+ out += self._gen_ext_inconsistent_defs(project, unit)
143
+ return out
144
+
145
+ def _gen_signals_table(self, unit_data, unit_data_all, key, out=''):
146
+ """Generate the unit specific information for KEY in a unit."""
147
+
148
+ if key not in unit_data:
149
+ return out
150
+
151
+ out += self._table_unused
152
+ for var in sorted(unit_data[key]):
153
+ configs_str = ""
154
+ for unit_data_cfg in unit_data_all.values():
155
+ if key in unit_data_cfg and var in unit_data_cfg[key]:
156
+ configs = unit_data_cfg[key][var]
157
+ configs_str += f" {self._set_to_str(configs)}"
158
+ out += ' <tr>\n'
159
+ out += f' <td>{var}</td>\n'
160
+ out += f' <td>{configs_str}</td>\n'
161
+ out += ' </tr>\n'
162
+ out += ' </tbody>\n'
163
+ out += ' </table>\n'
164
+ return out
165
+
166
+ def _gen_missing_sigs(self, unit_data, unit_data_all, out=''):
167
+ """Generate the unit specific information for missing signal in a unit."""
168
+ return self._gen_signals_table(unit_data, unit_data_all, key='missing', out=out)
169
+
170
+ def _gen_unused_sigs(self, unit_data, unit_data_all, out=''):
171
+ """Generate the unit specific information for the unused signals wihtin a unit."""
172
+ return self._gen_signals_table(unit_data, unit_data_all, key='unused', out=out)
173
+
174
+ def _gen_multiple_def_sigs(self, unit_data, unit_data_all, out=''):
175
+ """Generate unit specific information for the signals that are generated more than once."""
176
+ return self._gen_signals_table(unit_data, unit_data_all, key='multiple_defs', out=out)
177
+
178
+ def _gen_never_active_sigs(self, never_active_signals):
179
+ """Generate unit specific information for the signals that are never active."""
180
+ out = self._table_unused
181
+ for signal in never_active_signals:
182
+ out += ' <tr>\n'
183
+ out += f' <td>{signal}</td>\n'
184
+ out += ' <td></td>\n'
185
+ out += ' </tr>\n'
186
+ out += ' </tbody>\n'
187
+ out += ' </table>\n'
188
+ return out
189
+
190
+ def _gen_ext_inconsistent_defs(self, project, unit, out=''):
191
+ """Generate a report of inconsistent variable definition parameters.
192
+
193
+ Report inconsistencies between the producing signal definition, and the
194
+ signal definitions in the external interface definition.
195
+ """
196
+ inconsistent_defs_key = 'inconsistent_defs'
197
+ if inconsistent_defs_key not in self._res_dict_all[project]['sigs']['ext']:
198
+ return out
199
+
200
+ out += self.__table_incons
201
+ incons_unit = self._res_dict_all[project]['sigs']['ext'][inconsistent_defs_key][unit]
202
+ for var in sorted(incons_unit.keys()):
203
+ first_cells = f'\n <tr>\n <td>{var}</td>\n'
204
+ for v_par, desc in incons_unit[var].items():
205
+ out += first_cells
206
+ out += f' <td>{v_par}</td>\n'
207
+ out += f' <td>{desc}</td>\n'
208
+ out += f' <td>{project}</td>\n'
209
+ out += ' </tr>\n'
210
+ first_cells = ' <tr>\n <td></td>\n'
211
+ out += ' </tbody>\n'
212
+ out += ' </table>\n'
213
+ return out
214
+
215
+ def _gen_int_inconsistent_defs(self, unit_data, unit_data_all, out=''):
216
+ """Generate a report of inconsistent variable definition parameters.
217
+
218
+ Inconsistent for between the producing signal definition, and the
219
+ consuming signal definitions for SPM internal signals.
220
+ """
221
+ inconsistent_defs_key = 'inconsistent_defs'
222
+ if inconsistent_defs_key not in unit_data:
223
+ return out
224
+
225
+ out += self.__table_incons
226
+ for var in sorted(unit_data[inconsistent_defs_key].keys()):
227
+ configs_str = ""
228
+ for prj_cfg in unit_data_all.keys():
229
+ configs_str += f" {prj_cfg}"
230
+ first_cells = f'\n <tr>\n <td>{var}</td>\n'
231
+ configs = unit_data[inconsistent_defs_key][var]
232
+ for v_par, desc in configs.items():
233
+ out += first_cells
234
+ out += f' <td>{v_par}</td>\n'
235
+ out += f' <td>{desc}</td>\n'
236
+ out += f' <td>{configs_str}</td>\n'
237
+ out += ' </tr>\n'
238
+ first_cells = ' <tr>\n <td></td>\n'
239
+ out += ' </tbody>\n'
240
+ out += ' </table>\n'
241
+ return out
242
+
243
+ def _gen_ext_signals_report(self, type_, comment):
244
+ """Generate report for external signals."""
245
+ out = f' <h3 id="ext_{type_}">{type_.capitalize()} external signals</h3>\n'
246
+ out += f'<p>{comment}</p>'
247
+ try:
248
+ res_dict = self._res_dict_all.get(self._prj)
249
+ out += self._table_unused
250
+ ext_data = res_dict['sigs']['ext'][type_]
251
+ for var in sorted(ext_data.keys()):
252
+ configs_str = ""
253
+ for res_dict_cfg in self._res_dict_all.values():
254
+ if type_ in res_dict_cfg['sigs']['ext']:
255
+ ext_data_cfg = res_dict_cfg['sigs']['ext'][type_]
256
+ configs = ext_data_cfg[var]
257
+ configs_str += " " + self._set_to_str(configs)
258
+ out += ' <tr>\n'
259
+ out += f' <td>{var}</td>\n'
260
+ out += f' <td>{configs_str}</td>\n'
261
+ out += ' </tr>\n'
262
+ out += ' </tbody>\n'
263
+ out += ' </table>\n'
264
+ except KeyError:
265
+ pass
266
+ return out
267
+
268
+ def set_res_dict(self, res_dicts):
269
+ """Set the result dictionary used to generate the html-report.
270
+
271
+ Args:
272
+ res_dicts (dict): result dict from the signal interface consistency check
273
+
274
+ See class constructor for dict structure.
275
+ """
276
+ # nesting defaultdicts is bad so we use this hack
277
+ regular_res_dicts = json.loads(json.dumps(res_dicts))
278
+ self._res_dict_all = regular_res_dicts
279
+ self._ext_units_all = {}
280
+ self._int_units_all = {}
281
+ self._all_units = {}
282
+ for prj, res_dict in self._res_dict_all.items():
283
+ _ext_units = set()
284
+ _int_units = set()
285
+ _units_with_never_active_signals = set()
286
+ if res_dict is not None and 'sigs' in res_dict:
287
+ if 'ext' in res_dict['sigs'] and 'inconsistent_defs' in res_dict['sigs']['ext']:
288
+ _ext_units = set(res_dict['sigs']['ext']['inconsistent_defs'].keys())
289
+ self._ext_units_all.update({prj: _ext_units})
290
+ if 'int' in res_dict['sigs']:
291
+ _int_units = set(res_dict['sigs']['int'].keys())
292
+ self._int_units_all.update({prj: _int_units})
293
+ if 'never_active_signals' in res_dict:
294
+ _units_with_never_active_signals = res_dict['never_active_signals'].keys()
295
+ self._all_units[prj] = _ext_units | _int_units | _units_with_never_active_signals
296
+
297
+ def _gen_contents_intro(self):
298
+ """Generate report contents from the signal interfaces data."""
299
+ html = []
300
+ html += self.__intro_all
301
+ return ''.join(html)
302
+
303
+ def _gen_contents_toc_ext_sig(self):
304
+ """Generate report contents from the signal interfaces data.
305
+
306
+ Specialises HtmlReport.gen_contents()
307
+ """
308
+ html = []
309
+ html += self.__toc_ext_sig
310
+ return ''.join(html)
311
+
312
+ def _gen_contents_toc_unit_details(self):
313
+ """Generate report contents from the signal interfaces data.
314
+
315
+ Specialises HtmlReport.gen_contents()
316
+ """
317
+ html = []
318
+ html += self._toc_unit_details
319
+ return ''.join(html)
320
+
321
+ def _gen_contents_ext_signals(self):
322
+ """Generate report contents from the signal inconsistency check result dictionary."""
323
+ html = []
324
+ html += self._gen_contents_toc_ext_sig()
325
+ html += self._gen_ext_signals_report('missing', 'Signals not generated by '
326
+ 'Vcc SW, but are defined in '
327
+ 'the Interface definition to be '
328
+ 'generated')
329
+ html += self._gen_ext_signals_report('unused', 'Signals defined to be generated by '
330
+ 'supplier SW, but are not used '
331
+ 'by VCC SW')
332
+ return ''.join(html)
333
+
334
+ def _generate_report_string_intro(self):
335
+ """Generate a html report as string."""
336
+ html = []
337
+ html += self._gen_header()
338
+ html += self._gen_contents_intro()
339
+ html += self._gen_end()
340
+ return ''.join(html)
341
+
342
+ def _generate_report_string_ext_signals(self):
343
+ """Generate a html report as string."""
344
+ html = []
345
+ html += self._gen_header()
346
+ html += self._gen_contents_ext_signals()
347
+ html += self._gen_end()
348
+ return ''.join(html)
349
+
350
+ def generate_report_file_signal_check(self, filename):
351
+ """Generate a html report and save to file."""
352
+ filename_intro = filename + '_intro.html'
353
+ with open(filename_intro, 'w', encoding="utf-8") as fhndl:
354
+ fhndl.write(self._generate_report_string_intro())
355
+
356
+ self._gen_units()
357
+ self._gen_unit_toc()
358
+ for key, out in self._out_all_units.items():
359
+ html = []
360
+ html += self._gen_header()
361
+ html += self._gen_contents_toc_unit_details()
362
+ html += out
363
+ html += self._out_all_unit_toc.get(key, '')
364
+ html += self._gen_end()
365
+ with open(f'{filename}_{key}.html', 'w', encoding="utf-8") as fhndl:
366
+ fhndl.write(''.join(html))