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.
- powertrain_build/__init__.py +40 -40
- powertrain_build/__main__.py +6 -6
- powertrain_build/a2l.py +582 -582
- powertrain_build/a2l_merge.py +650 -650
- powertrain_build/a2l_templates.py +717 -717
- powertrain_build/build.py +985 -985
- powertrain_build/build_defs.py +309 -309
- powertrain_build/build_proj_config.py +690 -690
- powertrain_build/check_interface.py +575 -575
- powertrain_build/cli.py +141 -141
- powertrain_build/config.py +542 -542
- powertrain_build/core.py +395 -395
- powertrain_build/core_dummy.py +343 -343
- powertrain_build/create_conversion_table.py +73 -73
- powertrain_build/dids.py +916 -916
- powertrain_build/dummy.py +157 -157
- powertrain_build/dummy_spm.py +252 -252
- powertrain_build/environmentcheck.py +52 -52
- powertrain_build/ext_dbg.py +255 -255
- powertrain_build/ext_var.py +327 -327
- powertrain_build/feature_configs.py +301 -301
- powertrain_build/gen_allsysteminfo.py +227 -227
- powertrain_build/gen_label_split.py +449 -449
- powertrain_build/handcode_replacer.py +124 -124
- powertrain_build/html_report.py +133 -133
- powertrain_build/interface/__init__.py +4 -4
- powertrain_build/interface/application.py +511 -511
- powertrain_build/interface/base.py +500 -500
- powertrain_build/interface/csp_api.py +490 -490
- powertrain_build/interface/device_proxy.py +677 -677
- powertrain_build/interface/ems.py +67 -67
- powertrain_build/interface/export_global_vars.py +121 -121
- powertrain_build/interface/generate_adapters.py +132 -132
- powertrain_build/interface/generate_hi_interface.py +87 -87
- powertrain_build/interface/generate_service.py +69 -69
- powertrain_build/interface/generate_wrappers.py +147 -147
- powertrain_build/interface/generation_utils.py +142 -142
- powertrain_build/interface/hal.py +194 -194
- powertrain_build/interface/model_yaml_verification.py +348 -348
- powertrain_build/interface/service.py +296 -296
- powertrain_build/interface/simulink.py +249 -249
- powertrain_build/interface/update_call_sources.py +180 -180
- powertrain_build/interface/update_model_yaml.py +186 -186
- powertrain_build/interface/zone_controller.py +362 -362
- powertrain_build/lib/__init__.py +4 -4
- powertrain_build/lib/helper_functions.py +127 -127
- powertrain_build/lib/logger.py +55 -55
- powertrain_build/matlab_scripts/CodeGen/BuildAutomationPyBuild.m +78 -78
- powertrain_build/matlab_scripts/CodeGen/Generate_A2L.m +154 -154
- powertrain_build/matlab_scripts/CodeGen/generateTLUnit.m +239 -239
- powertrain_build/matlab_scripts/CodeGen/getAsilClassification.m +28 -28
- powertrain_build/matlab_scripts/CodeGen/modelConfiguredForTL.m +28 -28
- powertrain_build/matlab_scripts/CodeGen/moveDefOutports.m +88 -88
- powertrain_build/matlab_scripts/CodeGen/parseCalMeasData.m +410 -410
- powertrain_build/matlab_scripts/CodeGen/parseCoreIdentifiers.m +139 -139
- powertrain_build/matlab_scripts/CodeGen/parseDIDs.m +141 -141
- powertrain_build/matlab_scripts/CodeGen/parseInPorts.m +106 -106
- powertrain_build/matlab_scripts/CodeGen/parseIncludeConfigs.m +25 -25
- powertrain_build/matlab_scripts/CodeGen/parseModelInfo.m +38 -38
- powertrain_build/matlab_scripts/CodeGen/parseNVM.m +81 -81
- powertrain_build/matlab_scripts/CodeGen/parseOutPorts.m +120 -120
- powertrain_build/matlab_scripts/CodeGen/parsePreProcBlks.m +23 -23
- powertrain_build/matlab_scripts/CodeGen/struct2JSON.m +128 -128
- powertrain_build/matlab_scripts/CodeGen/updateCodeSwConfig.m +31 -31
- powertrain_build/matlab_scripts/Init_PyBuild.m +91 -91
- powertrain_build/matlab_scripts/__init__.py +2 -2
- powertrain_build/matlab_scripts/helperFunctions/Get_Full_Name.m +46 -46
- powertrain_build/matlab_scripts/helperFunctions/Get_SrcLines.m +12 -12
- powertrain_build/matlab_scripts/helperFunctions/Init_Models.m +78 -78
- powertrain_build/matlab_scripts/helperFunctions/Init_Projects.m +67 -67
- powertrain_build/matlab_scripts/helperFunctions/Read_Units.m +34 -34
- powertrain_build/matlab_scripts/helperFunctions/SetProjectTimeSamples.m +26 -26
- powertrain_build/matlab_scripts/helperFunctions/Strip_Suffix.m +16 -16
- powertrain_build/matlab_scripts/helperFunctions/followLink.m +118 -118
- powertrain_build/matlab_scripts/helperFunctions/getCodeSwitches.m +50 -50
- powertrain_build/matlab_scripts/helperFunctions/getConsumerBlocks.m +30 -30
- powertrain_build/matlab_scripts/helperFunctions/getDefBlock.m +39 -39
- powertrain_build/matlab_scripts/helperFunctions/getDefOutport.m +58 -58
- powertrain_build/matlab_scripts/helperFunctions/getDstBlocks.m +19 -19
- powertrain_build/matlab_scripts/helperFunctions/getDstLines.m +13 -13
- powertrain_build/matlab_scripts/helperFunctions/getInterfaceSignals.m +37 -37
- powertrain_build/matlab_scripts/helperFunctions/getName.m +37 -37
- powertrain_build/matlab_scripts/helperFunctions/getPath.m +6 -6
- powertrain_build/matlab_scripts/helperFunctions/getProperValue.m +21 -21
- powertrain_build/matlab_scripts/helperFunctions/getSrcBlocks.m +19 -19
- powertrain_build/matlab_scripts/helperFunctions/getSrcLines.m +13 -13
- powertrain_build/matlab_scripts/helperFunctions/loadLibraries.m +10 -10
- powertrain_build/matlab_scripts/helperFunctions/loadjson.m +6 -6
- powertrain_build/matlab_scripts/helperFunctions/modifyEnumStructField.m +21 -21
- powertrain_build/matlab_scripts/helperFunctions/removeConfigDuplicates.m +31 -31
- powertrain_build/matlab_scripts/helperFunctions/sortSystemByClass.m +26 -26
- powertrain_build/matlab_scripts/helperFunctions/tl_getfast.m +89 -89
- powertrain_build/matlab_scripts/helperFunctions/topLevelSystem.m +20 -20
- powertrain_build/matlab_scripts/helperFunctions/updateModels.m +131 -131
- powertrain_build/memory_section.py +224 -224
- powertrain_build/nvm_def.py +729 -729
- powertrain_build/problem_logger.py +86 -86
- powertrain_build/pt_matlab.py +430 -430
- powertrain_build/pt_win32.py +144 -144
- powertrain_build/replace_compu_tab_ref.py +105 -105
- powertrain_build/rte_dummy.py +254 -254
- powertrain_build/sched_funcs.py +209 -207
- powertrain_build/signal.py +7 -7
- powertrain_build/signal_if_html_rep.py +221 -221
- powertrain_build/signal_if_html_rep_all.py +302 -302
- powertrain_build/signal_incons_html_rep.py +180 -180
- powertrain_build/signal_incons_html_rep_all.py +366 -366
- powertrain_build/signal_incons_html_rep_base.py +168 -168
- powertrain_build/signal_inconsistency_check.py +641 -641
- powertrain_build/signal_interfaces.py +864 -864
- powertrain_build/templates/Index_SigCheck_All.html +22 -22
- powertrain_build/templates/Index_SigIf_All.html +19 -19
- powertrain_build/types.py +218 -218
- powertrain_build/unit_configs.py +419 -419
- powertrain_build/user_defined_types.py +660 -660
- powertrain_build/versioncheck.py +66 -66
- powertrain_build/wrapper.py +512 -512
- powertrain_build/xlrd_csv.py +87 -87
- powertrain_build/zone_controller/__init__.py +4 -4
- powertrain_build/zone_controller/calibration.py +176 -176
- powertrain_build/zone_controller/composition_yaml.py +880 -878
- {powertrain_build-1.13.1.dist-info → powertrain_build-1.13.3.dev3.dist-info}/METADATA +100 -100
- powertrain_build-1.13.3.dev3.dist-info/RECORD +130 -0
- {powertrain_build-1.13.1.dist-info → powertrain_build-1.13.3.dev3.dist-info}/WHEEL +1 -1
- {powertrain_build-1.13.1.dist-info → powertrain_build-1.13.3.dev3.dist-info}/licenses/LICENSE +202 -202
- powertrain_build-1.13.3.dev3.dist-info/pbr.json +1 -0
- powertrain_build-1.13.1.dist-info/RECORD +0 -130
- powertrain_build-1.13.1.dist-info/pbr.json +0 -1
- {powertrain_build-1.13.1.dist-info → powertrain_build-1.13.3.dev3.dist-info}/entry_points.txt +0 -0
- {powertrain_build-1.13.1.dist-info → powertrain_build-1.13.3.dev3.dist-info}/licenses/AUTHORS +0 -0
- {powertrain_build-1.13.1.dist-info → powertrain_build-1.13.3.dev3.dist-info}/licenses/NOTICE +0 -0
- {powertrain_build-1.13.1.dist-info → powertrain_build-1.13.3.dev3.dist-info}/top_level.txt +0 -0
|
@@ -1,224 +1,224 @@
|
|
|
1
|
-
# Copyright 2024 Volvo Car Corporation
|
|
2
|
-
# Licensed under Apache 2.0.
|
|
3
|
-
|
|
4
|
-
# -*- coding: utf-8 -*-
|
|
5
|
-
"""Module containing cvc classes for VCC - defines and includes for memory sections."""
|
|
6
|
-
|
|
7
|
-
import time
|
|
8
|
-
from pathlib import Path
|
|
9
|
-
from powertrain_build import build_defs
|
|
10
|
-
from powertrain_build.problem_logger import ProblemLogger
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class MemorySection(ProblemLogger):
|
|
14
|
-
"""Handle headers for CVC_* definitions."""
|
|
15
|
-
|
|
16
|
-
calibration_definitions = [
|
|
17
|
-
'CVC_CAL',
|
|
18
|
-
'CVC_CAL_ASIL_A',
|
|
19
|
-
'CVC_CAL_ASIL_B',
|
|
20
|
-
'CVC_CAL_ASIL_C',
|
|
21
|
-
'CVC_CAL_ASIL_D',
|
|
22
|
-
'CVC_CAL_MERGEABLE_ASIL_A',
|
|
23
|
-
'CVC_CAL_MERGEABLE_ASIL_B',
|
|
24
|
-
'CVC_CAL_MERGEABLE_ASIL_C',
|
|
25
|
-
'CVC_CAL_MERGEABLE_ASIL_D'
|
|
26
|
-
]
|
|
27
|
-
measurable_definitions = [
|
|
28
|
-
'CVC_DISP',
|
|
29
|
-
'CVC_DISP_ASIL_A',
|
|
30
|
-
'CVC_DISP_ASIL_B',
|
|
31
|
-
'CVC_DISP_ASIL_C',
|
|
32
|
-
'CVC_DISP_ASIL_D'
|
|
33
|
-
]
|
|
34
|
-
|
|
35
|
-
def __init__(self, build_cfg, unit_cfg):
|
|
36
|
-
super().__init__()
|
|
37
|
-
self.build_cfg = build_cfg
|
|
38
|
-
self.unit_cfg = unit_cfg
|
|
39
|
-
self.mem_map_config = self.build_cfg.get_memory_map_config()
|
|
40
|
-
self.include_header_guards = self.mem_map_config['includeHeaderGuards']
|
|
41
|
-
self.mem_map_include = f'#include "{self.mem_map_config["memMapPrefix"]}_MemMap.h"\n'
|
|
42
|
-
self.xcp_enabled = self.build_cfg.get_xcp_enabled()
|
|
43
|
-
self.use_volatile_globals = self.build_cfg.get_use_volatile_globals()
|
|
44
|
-
|
|
45
|
-
@staticmethod
|
|
46
|
-
def _get_mem_map_section(section):
|
|
47
|
-
return 'STOP' if section == 'END' else section
|
|
48
|
-
|
|
49
|
-
@staticmethod
|
|
50
|
-
def _get_header(section_file):
|
|
51
|
-
section_file_header_guard = section_file.split('.')[0].upper()
|
|
52
|
-
return [
|
|
53
|
-
f'#ifndef {section_file_header_guard}_H\n',
|
|
54
|
-
f'#define {section_file_header_guard}_H\n\n'
|
|
55
|
-
]
|
|
56
|
-
|
|
57
|
-
@staticmethod
|
|
58
|
-
def _get_footer(section_file):
|
|
59
|
-
section_file_header_guard = section_file.split('.')[0].upper()
|
|
60
|
-
return [f'\n#endif /* {section_file_header_guard}_H */\n']
|
|
61
|
-
|
|
62
|
-
def _get_calibration_rte_macro_expansion(self, section_file):
|
|
63
|
-
macros = self._get_header(section_file)
|
|
64
|
-
swc_name = self.build_cfg.get_composition_config("softwareComponentName")
|
|
65
|
-
macros.append(f'#include "Rte_{swc_name}.h"\n')
|
|
66
|
-
|
|
67
|
-
config = self.unit_cfg.get_per_cfg_unit_cfg()
|
|
68
|
-
valid_configs = ["outports", "local_vars", "calib_consts"]
|
|
69
|
-
for valid_config in valid_configs:
|
|
70
|
-
for signal_name, unit_info in config.get(valid_config, {}).items():
|
|
71
|
-
define_str = f'#define {signal_name} Rte_CData_{swc_name}_{signal_name}()'
|
|
72
|
-
if signal_name.startswith("m") and not signal_name.endswith("_r") and not signal_name.endswith("_c"):
|
|
73
|
-
define_str += f"->dt_{signal_name}"
|
|
74
|
-
define_str += "\n"
|
|
75
|
-
for info in unit_info.values(): # Should be length 1 for cal
|
|
76
|
-
if "CVC_CAL" in info["class"]:
|
|
77
|
-
macros.append(define_str)
|
|
78
|
-
|
|
79
|
-
macros.extend(self._get_footer(section_file))
|
|
80
|
-
|
|
81
|
-
return macros
|
|
82
|
-
|
|
83
|
-
def _get_cal(self, section):
|
|
84
|
-
cvc_undefines = [f'#undef {definition}\n' for definition in self.calibration_definitions]
|
|
85
|
-
if section == 'START':
|
|
86
|
-
volatile_string = 'volatile' if self.use_volatile_globals else ''
|
|
87
|
-
cvc_defines = [f'#define {definition} {volatile_string}\n' for definition in self.calibration_definitions]
|
|
88
|
-
else:
|
|
89
|
-
cvc_defines = []
|
|
90
|
-
section_type = 'cal' if self.xcp_enabled else 'disp'
|
|
91
|
-
memory_section_handling = [
|
|
92
|
-
self.mem_map_config['projectDefines'][self._get_mem_map_section(section)][section_type] + '\n'
|
|
93
|
-
]
|
|
94
|
-
if self.mem_map_config['includeMemMapForCalibration'] or not self.xcp_enabled:
|
|
95
|
-
memory_section_handling.append(self.mem_map_include)
|
|
96
|
-
return cvc_undefines, cvc_defines, memory_section_handling
|
|
97
|
-
|
|
98
|
-
def _get_disp(self, section):
|
|
99
|
-
cvc_undefines = [f'#undef {definition}\n' for definition in self.measurable_definitions]
|
|
100
|
-
if section == 'START':
|
|
101
|
-
volatile_string = 'volatile' if self.use_volatile_globals else ''
|
|
102
|
-
cvc_defines = [f'#define {definition} {volatile_string}\n' for definition in self.measurable_definitions]
|
|
103
|
-
else:
|
|
104
|
-
cvc_defines = []
|
|
105
|
-
memory_section_handling = [
|
|
106
|
-
self.mem_map_config['projectDefines'][self._get_mem_map_section(section)]['disp'] + '\n',
|
|
107
|
-
self.mem_map_include
|
|
108
|
-
]
|
|
109
|
-
return cvc_undefines, cvc_defines, memory_section_handling
|
|
110
|
-
|
|
111
|
-
def _get_code(self, section):
|
|
112
|
-
cvc_undefines = []
|
|
113
|
-
cvc_defines = []
|
|
114
|
-
memory_section_handling = [
|
|
115
|
-
self.mem_map_config['projectDefines'][self._get_mem_map_section(section)]['code'] + '\n',
|
|
116
|
-
self.mem_map_include
|
|
117
|
-
]
|
|
118
|
-
return cvc_undefines, cvc_defines, memory_section_handling
|
|
119
|
-
|
|
120
|
-
def _get_const(self, section):
|
|
121
|
-
cvc_undefines = []
|
|
122
|
-
cvc_defines = []
|
|
123
|
-
memory_section_handling = [
|
|
124
|
-
self.mem_map_config['projectDefines'][self._get_mem_map_section(section)]['const'] + '\n',
|
|
125
|
-
self.mem_map_include
|
|
126
|
-
]
|
|
127
|
-
return cvc_undefines, cvc_defines, memory_section_handling
|
|
128
|
-
|
|
129
|
-
def _get_nvm(self, section):
|
|
130
|
-
cvc_undefines = []
|
|
131
|
-
cvc_defines = []
|
|
132
|
-
memory_section_handling = [
|
|
133
|
-
self.mem_map_config['projectDefines'][self._get_mem_map_section(section)]['nvm'] + '\n',
|
|
134
|
-
self.mem_map_include
|
|
135
|
-
]
|
|
136
|
-
return cvc_undefines, cvc_defines, memory_section_handling
|
|
137
|
-
|
|
138
|
-
def _get_rest(self):
|
|
139
|
-
cvc_undefines = []
|
|
140
|
-
cvc_defines = []
|
|
141
|
-
memory_section_handling = [
|
|
142
|
-
self.mem_map_include
|
|
143
|
-
]
|
|
144
|
-
return cvc_undefines, cvc_defines, memory_section_handling
|
|
145
|
-
|
|
146
|
-
def _get_predecl(self):
|
|
147
|
-
cvc_undefines = []
|
|
148
|
-
cvc_defines = []
|
|
149
|
-
memory_section_handling = []
|
|
150
|
-
return cvc_undefines, cvc_defines, memory_section_handling
|
|
151
|
-
|
|
152
|
-
def generate_cvc_header(self, section, section_file):
|
|
153
|
-
"""Generate CVC headers.
|
|
154
|
-
|
|
155
|
-
Args:
|
|
156
|
-
section (str): Name of the CVC section
|
|
157
|
-
section_file (str): Name of the header file
|
|
158
|
-
Returns:
|
|
159
|
-
lines_to_write (list(str)): Lines to write to given section file.
|
|
160
|
-
"""
|
|
161
|
-
header = self._get_header(section_file) if self.include_header_guards else []
|
|
162
|
-
footer = self._get_footer(section_file) if self.include_header_guards else []
|
|
163
|
-
if '_CAL_' in section_file:
|
|
164
|
-
cvc_undefines, cvc_defines, memory_section_handling = self._get_cal(section)
|
|
165
|
-
elif '_DISP_' in section_file:
|
|
166
|
-
cvc_undefines, cvc_defines, memory_section_handling = self._get_disp(section)
|
|
167
|
-
elif not section_file.startswith('PREDECL_'):
|
|
168
|
-
if section_file.startswith('CVC_CAL') or section_file.startswith('CVC_DISP'):
|
|
169
|
-
self.critical('Should not find CVC_CAL/DISP here. Check logic. File: %s.', section_file)
|
|
170
|
-
elif section_file.startswith('CVC_CODE'):
|
|
171
|
-
cvc_undefines, cvc_defines, memory_section_handling = self._get_code(section)
|
|
172
|
-
use_rte_macro_expansion = self.build_cfg.get_code_generation_config("useCalibrationRteMacroExpansion")
|
|
173
|
-
if section == 'START' and use_rte_macro_expansion:
|
|
174
|
-
memory_section_handling.extend(self._get_calibration_rte_macro_expansion(section_file))
|
|
175
|
-
# header and footer are part of the extension
|
|
176
|
-
header = []
|
|
177
|
-
footer = []
|
|
178
|
-
elif section_file.startswith('CVC_CONST'):
|
|
179
|
-
cvc_undefines, cvc_defines, memory_section_handling = self._get_const(section)
|
|
180
|
-
else:
|
|
181
|
-
cvc_undefines, cvc_defines, memory_section_handling = self._get_rest()
|
|
182
|
-
else:
|
|
183
|
-
cvc_undefines, cvc_defines, memory_section_handling = self._get_predecl()
|
|
184
|
-
|
|
185
|
-
return header + cvc_undefines + cvc_defines + memory_section_handling + footer
|
|
186
|
-
|
|
187
|
-
def generate_required_header_files(self):
|
|
188
|
-
"""Generate required header files to delivery folder.
|
|
189
|
-
|
|
190
|
-
Generate required header files such as memory protection files.
|
|
191
|
-
NOTE: Currently, only one ASIL level can be selected for an SWC.
|
|
192
|
-
"""
|
|
193
|
-
self.info('******************************************************')
|
|
194
|
-
self.info('Start generating required header files')
|
|
195
|
-
start_time = time.time()
|
|
196
|
-
src_dst_dir = self.build_cfg.get_src_code_dst_dir()
|
|
197
|
-
for section_dict in build_defs.PREDECL_EXTRA.values():
|
|
198
|
-
for section_file in section_dict.values():
|
|
199
|
-
header = self._get_header(section_file) if self.include_header_guards else []
|
|
200
|
-
footer = self._get_footer(section_file) if self.include_header_guards else []
|
|
201
|
-
with Path(src_dst_dir, section_file).open('w', encoding="utf-8") as header_file_handler:
|
|
202
|
-
header_file_handler.writelines(header + footer)
|
|
203
|
-
|
|
204
|
-
for asil_dict in build_defs.ASIL_LEVEL_MAP.values():
|
|
205
|
-
for type_dict in asil_dict.values():
|
|
206
|
-
for section_dict in type_dict.values():
|
|
207
|
-
for section, section_file in section_dict.items():
|
|
208
|
-
lines_to_write = self.generate_cvc_header(section, section_file)
|
|
209
|
-
with Path(src_dst_dir, section_file).open('w', encoding="utf-8") as header_file_handler:
|
|
210
|
-
header_file_handler.writelines(lines_to_write)
|
|
211
|
-
|
|
212
|
-
for nvm_type, nvm_dict in build_defs.NVM_LEVEL_MAP.items():
|
|
213
|
-
for section_dict in nvm_dict.values():
|
|
214
|
-
for section, section_file in section_dict.items():
|
|
215
|
-
section_config = self.mem_map_config['projectDefines'][self._get_mem_map_section(section)]
|
|
216
|
-
if "nvm" in section_config:
|
|
217
|
-
lines_to_write = self._get_nvm(section)[2]
|
|
218
|
-
else:
|
|
219
|
-
lines_to_write = []
|
|
220
|
-
header = self._get_header(section_file) if self.include_header_guards else []
|
|
221
|
-
footer = self._get_footer(section_file) if self.include_header_guards else []
|
|
222
|
-
with Path(src_dst_dir, section_file).open('w', encoding="utf-8") as header_file_handler:
|
|
223
|
-
header_file_handler.writelines(header + lines_to_write + footer)
|
|
224
|
-
self.info('Finished generating required header files (in %4.2f s)', time.time() - start_time)
|
|
1
|
+
# Copyright 2024 Volvo Car Corporation
|
|
2
|
+
# Licensed under Apache 2.0.
|
|
3
|
+
|
|
4
|
+
# -*- coding: utf-8 -*-
|
|
5
|
+
"""Module containing cvc classes for VCC - defines and includes for memory sections."""
|
|
6
|
+
|
|
7
|
+
import time
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
from powertrain_build import build_defs
|
|
10
|
+
from powertrain_build.problem_logger import ProblemLogger
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class MemorySection(ProblemLogger):
|
|
14
|
+
"""Handle headers for CVC_* definitions."""
|
|
15
|
+
|
|
16
|
+
calibration_definitions = [
|
|
17
|
+
'CVC_CAL',
|
|
18
|
+
'CVC_CAL_ASIL_A',
|
|
19
|
+
'CVC_CAL_ASIL_B',
|
|
20
|
+
'CVC_CAL_ASIL_C',
|
|
21
|
+
'CVC_CAL_ASIL_D',
|
|
22
|
+
'CVC_CAL_MERGEABLE_ASIL_A',
|
|
23
|
+
'CVC_CAL_MERGEABLE_ASIL_B',
|
|
24
|
+
'CVC_CAL_MERGEABLE_ASIL_C',
|
|
25
|
+
'CVC_CAL_MERGEABLE_ASIL_D'
|
|
26
|
+
]
|
|
27
|
+
measurable_definitions = [
|
|
28
|
+
'CVC_DISP',
|
|
29
|
+
'CVC_DISP_ASIL_A',
|
|
30
|
+
'CVC_DISP_ASIL_B',
|
|
31
|
+
'CVC_DISP_ASIL_C',
|
|
32
|
+
'CVC_DISP_ASIL_D'
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
def __init__(self, build_cfg, unit_cfg):
|
|
36
|
+
super().__init__()
|
|
37
|
+
self.build_cfg = build_cfg
|
|
38
|
+
self.unit_cfg = unit_cfg
|
|
39
|
+
self.mem_map_config = self.build_cfg.get_memory_map_config()
|
|
40
|
+
self.include_header_guards = self.mem_map_config['includeHeaderGuards']
|
|
41
|
+
self.mem_map_include = f'#include "{self.mem_map_config["memMapPrefix"]}_MemMap.h"\n'
|
|
42
|
+
self.xcp_enabled = self.build_cfg.get_xcp_enabled()
|
|
43
|
+
self.use_volatile_globals = self.build_cfg.get_use_volatile_globals()
|
|
44
|
+
|
|
45
|
+
@staticmethod
|
|
46
|
+
def _get_mem_map_section(section):
|
|
47
|
+
return 'STOP' if section == 'END' else section
|
|
48
|
+
|
|
49
|
+
@staticmethod
|
|
50
|
+
def _get_header(section_file):
|
|
51
|
+
section_file_header_guard = section_file.split('.')[0].upper()
|
|
52
|
+
return [
|
|
53
|
+
f'#ifndef {section_file_header_guard}_H\n',
|
|
54
|
+
f'#define {section_file_header_guard}_H\n\n'
|
|
55
|
+
]
|
|
56
|
+
|
|
57
|
+
@staticmethod
|
|
58
|
+
def _get_footer(section_file):
|
|
59
|
+
section_file_header_guard = section_file.split('.')[0].upper()
|
|
60
|
+
return [f'\n#endif /* {section_file_header_guard}_H */\n']
|
|
61
|
+
|
|
62
|
+
def _get_calibration_rte_macro_expansion(self, section_file):
|
|
63
|
+
macros = self._get_header(section_file)
|
|
64
|
+
swc_name = self.build_cfg.get_composition_config("softwareComponentName")
|
|
65
|
+
macros.append(f'#include "Rte_{swc_name}.h"\n')
|
|
66
|
+
|
|
67
|
+
config = self.unit_cfg.get_per_cfg_unit_cfg()
|
|
68
|
+
valid_configs = ["outports", "local_vars", "calib_consts"]
|
|
69
|
+
for valid_config in valid_configs:
|
|
70
|
+
for signal_name, unit_info in config.get(valid_config, {}).items():
|
|
71
|
+
define_str = f'#define {signal_name} Rte_CData_{swc_name}_{signal_name}()'
|
|
72
|
+
if signal_name.startswith("m") and not signal_name.endswith("_r") and not signal_name.endswith("_c"):
|
|
73
|
+
define_str += f"->dt_{signal_name}"
|
|
74
|
+
define_str += "\n"
|
|
75
|
+
for info in unit_info.values(): # Should be length 1 for cal
|
|
76
|
+
if "CVC_CAL" in info["class"]:
|
|
77
|
+
macros.append(define_str)
|
|
78
|
+
|
|
79
|
+
macros.extend(self._get_footer(section_file))
|
|
80
|
+
|
|
81
|
+
return macros
|
|
82
|
+
|
|
83
|
+
def _get_cal(self, section):
|
|
84
|
+
cvc_undefines = [f'#undef {definition}\n' for definition in self.calibration_definitions]
|
|
85
|
+
if section == 'START':
|
|
86
|
+
volatile_string = 'volatile' if self.use_volatile_globals else ''
|
|
87
|
+
cvc_defines = [f'#define {definition} {volatile_string}\n' for definition in self.calibration_definitions]
|
|
88
|
+
else:
|
|
89
|
+
cvc_defines = []
|
|
90
|
+
section_type = 'cal' if self.xcp_enabled else 'disp'
|
|
91
|
+
memory_section_handling = [
|
|
92
|
+
self.mem_map_config['projectDefines'][self._get_mem_map_section(section)][section_type] + '\n'
|
|
93
|
+
]
|
|
94
|
+
if self.mem_map_config['includeMemMapForCalibration'] or not self.xcp_enabled:
|
|
95
|
+
memory_section_handling.append(self.mem_map_include)
|
|
96
|
+
return cvc_undefines, cvc_defines, memory_section_handling
|
|
97
|
+
|
|
98
|
+
def _get_disp(self, section):
|
|
99
|
+
cvc_undefines = [f'#undef {definition}\n' for definition in self.measurable_definitions]
|
|
100
|
+
if section == 'START':
|
|
101
|
+
volatile_string = 'volatile' if self.use_volatile_globals else ''
|
|
102
|
+
cvc_defines = [f'#define {definition} {volatile_string}\n' for definition in self.measurable_definitions]
|
|
103
|
+
else:
|
|
104
|
+
cvc_defines = []
|
|
105
|
+
memory_section_handling = [
|
|
106
|
+
self.mem_map_config['projectDefines'][self._get_mem_map_section(section)]['disp'] + '\n',
|
|
107
|
+
self.mem_map_include
|
|
108
|
+
]
|
|
109
|
+
return cvc_undefines, cvc_defines, memory_section_handling
|
|
110
|
+
|
|
111
|
+
def _get_code(self, section):
|
|
112
|
+
cvc_undefines = []
|
|
113
|
+
cvc_defines = []
|
|
114
|
+
memory_section_handling = [
|
|
115
|
+
self.mem_map_config['projectDefines'][self._get_mem_map_section(section)]['code'] + '\n',
|
|
116
|
+
self.mem_map_include
|
|
117
|
+
]
|
|
118
|
+
return cvc_undefines, cvc_defines, memory_section_handling
|
|
119
|
+
|
|
120
|
+
def _get_const(self, section):
|
|
121
|
+
cvc_undefines = []
|
|
122
|
+
cvc_defines = []
|
|
123
|
+
memory_section_handling = [
|
|
124
|
+
self.mem_map_config['projectDefines'][self._get_mem_map_section(section)]['const'] + '\n',
|
|
125
|
+
self.mem_map_include
|
|
126
|
+
]
|
|
127
|
+
return cvc_undefines, cvc_defines, memory_section_handling
|
|
128
|
+
|
|
129
|
+
def _get_nvm(self, section):
|
|
130
|
+
cvc_undefines = []
|
|
131
|
+
cvc_defines = []
|
|
132
|
+
memory_section_handling = [
|
|
133
|
+
self.mem_map_config['projectDefines'][self._get_mem_map_section(section)]['nvm'] + '\n',
|
|
134
|
+
self.mem_map_include
|
|
135
|
+
]
|
|
136
|
+
return cvc_undefines, cvc_defines, memory_section_handling
|
|
137
|
+
|
|
138
|
+
def _get_rest(self):
|
|
139
|
+
cvc_undefines = []
|
|
140
|
+
cvc_defines = []
|
|
141
|
+
memory_section_handling = [
|
|
142
|
+
self.mem_map_include
|
|
143
|
+
]
|
|
144
|
+
return cvc_undefines, cvc_defines, memory_section_handling
|
|
145
|
+
|
|
146
|
+
def _get_predecl(self):
|
|
147
|
+
cvc_undefines = []
|
|
148
|
+
cvc_defines = []
|
|
149
|
+
memory_section_handling = []
|
|
150
|
+
return cvc_undefines, cvc_defines, memory_section_handling
|
|
151
|
+
|
|
152
|
+
def generate_cvc_header(self, section, section_file):
|
|
153
|
+
"""Generate CVC headers.
|
|
154
|
+
|
|
155
|
+
Args:
|
|
156
|
+
section (str): Name of the CVC section
|
|
157
|
+
section_file (str): Name of the header file
|
|
158
|
+
Returns:
|
|
159
|
+
lines_to_write (list(str)): Lines to write to given section file.
|
|
160
|
+
"""
|
|
161
|
+
header = self._get_header(section_file) if self.include_header_guards else []
|
|
162
|
+
footer = self._get_footer(section_file) if self.include_header_guards else []
|
|
163
|
+
if '_CAL_' in section_file:
|
|
164
|
+
cvc_undefines, cvc_defines, memory_section_handling = self._get_cal(section)
|
|
165
|
+
elif '_DISP_' in section_file:
|
|
166
|
+
cvc_undefines, cvc_defines, memory_section_handling = self._get_disp(section)
|
|
167
|
+
elif not section_file.startswith('PREDECL_'):
|
|
168
|
+
if section_file.startswith('CVC_CAL') or section_file.startswith('CVC_DISP'):
|
|
169
|
+
self.critical('Should not find CVC_CAL/DISP here. Check logic. File: %s.', section_file)
|
|
170
|
+
elif section_file.startswith('CVC_CODE'):
|
|
171
|
+
cvc_undefines, cvc_defines, memory_section_handling = self._get_code(section)
|
|
172
|
+
use_rte_macro_expansion = self.build_cfg.get_code_generation_config("useCalibrationRteMacroExpansion")
|
|
173
|
+
if section == 'START' and use_rte_macro_expansion:
|
|
174
|
+
memory_section_handling.extend(self._get_calibration_rte_macro_expansion(section_file))
|
|
175
|
+
# header and footer are part of the extension
|
|
176
|
+
header = []
|
|
177
|
+
footer = []
|
|
178
|
+
elif section_file.startswith('CVC_CONST'):
|
|
179
|
+
cvc_undefines, cvc_defines, memory_section_handling = self._get_const(section)
|
|
180
|
+
else:
|
|
181
|
+
cvc_undefines, cvc_defines, memory_section_handling = self._get_rest()
|
|
182
|
+
else:
|
|
183
|
+
cvc_undefines, cvc_defines, memory_section_handling = self._get_predecl()
|
|
184
|
+
|
|
185
|
+
return header + cvc_undefines + cvc_defines + memory_section_handling + footer
|
|
186
|
+
|
|
187
|
+
def generate_required_header_files(self):
|
|
188
|
+
"""Generate required header files to delivery folder.
|
|
189
|
+
|
|
190
|
+
Generate required header files such as memory protection files.
|
|
191
|
+
NOTE: Currently, only one ASIL level can be selected for an SWC.
|
|
192
|
+
"""
|
|
193
|
+
self.info('******************************************************')
|
|
194
|
+
self.info('Start generating required header files')
|
|
195
|
+
start_time = time.time()
|
|
196
|
+
src_dst_dir = self.build_cfg.get_src_code_dst_dir()
|
|
197
|
+
for section_dict in build_defs.PREDECL_EXTRA.values():
|
|
198
|
+
for section_file in section_dict.values():
|
|
199
|
+
header = self._get_header(section_file) if self.include_header_guards else []
|
|
200
|
+
footer = self._get_footer(section_file) if self.include_header_guards else []
|
|
201
|
+
with Path(src_dst_dir, section_file).open('w', encoding="utf-8") as header_file_handler:
|
|
202
|
+
header_file_handler.writelines(header + footer)
|
|
203
|
+
|
|
204
|
+
for asil_dict in build_defs.ASIL_LEVEL_MAP.values():
|
|
205
|
+
for type_dict in asil_dict.values():
|
|
206
|
+
for section_dict in type_dict.values():
|
|
207
|
+
for section, section_file in section_dict.items():
|
|
208
|
+
lines_to_write = self.generate_cvc_header(section, section_file)
|
|
209
|
+
with Path(src_dst_dir, section_file).open('w', encoding="utf-8") as header_file_handler:
|
|
210
|
+
header_file_handler.writelines(lines_to_write)
|
|
211
|
+
|
|
212
|
+
for nvm_type, nvm_dict in build_defs.NVM_LEVEL_MAP.items():
|
|
213
|
+
for section_dict in nvm_dict.values():
|
|
214
|
+
for section, section_file in section_dict.items():
|
|
215
|
+
section_config = self.mem_map_config['projectDefines'][self._get_mem_map_section(section)]
|
|
216
|
+
if "nvm" in section_config:
|
|
217
|
+
lines_to_write = self._get_nvm(section)[2]
|
|
218
|
+
else:
|
|
219
|
+
lines_to_write = []
|
|
220
|
+
header = self._get_header(section_file) if self.include_header_guards else []
|
|
221
|
+
footer = self._get_footer(section_file) if self.include_header_guards else []
|
|
222
|
+
with Path(src_dst_dir, section_file).open('w', encoding="utf-8") as header_file_handler:
|
|
223
|
+
header_file_handler.writelines(header + lines_to_write + footer)
|
|
224
|
+
self.info('Finished generating required header files (in %4.2f s)', time.time() - start_time)
|