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,67 +1,67 @@
|
|
|
1
|
-
# Copyright 2024 Volvo Car Corporation
|
|
2
|
-
# Licensed under Apache 2.0.
|
|
3
|
-
|
|
4
|
-
"""Module for extraction Energy Management System"""
|
|
5
|
-
import os
|
|
6
|
-
|
|
7
|
-
from powertrain_build.interface.base import BaseApplication, Signal
|
|
8
|
-
from powertrain_build.lib import logger
|
|
9
|
-
from powertrain_build.signal_interfaces import CsvSignalInterfaces
|
|
10
|
-
from powertrain_build.build_proj_config import BuildProjConfig
|
|
11
|
-
|
|
12
|
-
LOGGER = logger.create_logger(__file__)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class CsvEMS(BaseApplication, CsvSignalInterfaces):
|
|
16
|
-
"""Supplier part of the ECM"""
|
|
17
|
-
def __init__(self):
|
|
18
|
-
self._signals = {}
|
|
19
|
-
self.interfaces = {}
|
|
20
|
-
self._insignals = None
|
|
21
|
-
self._outsignals = None
|
|
22
|
-
self.projects = {}
|
|
23
|
-
|
|
24
|
-
def parse_definition(self, definition):
|
|
25
|
-
"""Read the interface files.
|
|
26
|
-
|
|
27
|
-
Args:
|
|
28
|
-
definition (Path): Path to ProjectCfg.json
|
|
29
|
-
"""
|
|
30
|
-
self.build_cfg = BuildProjConfig(os.path.normpath(str(definition)))
|
|
31
|
-
CsvSignalInterfaces.__init__(self, self.build_cfg, [])
|
|
32
|
-
self.projects[self.build_cfg.name] = self.build_cfg
|
|
33
|
-
self.config_path = self.build_cfg.get_if_cfg_dir()
|
|
34
|
-
self.name = self.build_cfg.name # Set name for CsvSignalInterfaces
|
|
35
|
-
self._parse_io_cnfg(self.config_path)
|
|
36
|
-
self.name = 'Supplier_' + self.build_cfg.name # set name for BaseApplication
|
|
37
|
-
|
|
38
|
-
def _get_signals(self):
|
|
39
|
-
"""Look through interfaces and create Signal objects"""
|
|
40
|
-
self._insignals = set()
|
|
41
|
-
self._outsignals = set()
|
|
42
|
-
for interface_name, data in self.interfaces.items():
|
|
43
|
-
for signal_name, signal_data in data.items():
|
|
44
|
-
if signal_data['IOType'] == '-':
|
|
45
|
-
# Signal is inactive
|
|
46
|
-
continue
|
|
47
|
-
if signal_name in self._signals:
|
|
48
|
-
signal = self._signals[signal_name]
|
|
49
|
-
else:
|
|
50
|
-
signal = Signal(signal_name, self)
|
|
51
|
-
self._signals.update({signal_name: signal})
|
|
52
|
-
if 'output' in interface_name.lower():
|
|
53
|
-
# outport from ECM. Inport in EMS (from SPM)
|
|
54
|
-
self._insignals.add(signal_name)
|
|
55
|
-
signal.consumers = interface_name
|
|
56
|
-
else:
|
|
57
|
-
signal.producers = interface_name
|
|
58
|
-
self._outsignals.add(signal_name)
|
|
59
|
-
|
|
60
|
-
def get_signal_properties(self, signal):
|
|
61
|
-
"""Find properties for a signal from interface files"""
|
|
62
|
-
for interface_name, interface_data in self.interfaces.items():
|
|
63
|
-
if signal.name in interface_data.keys():
|
|
64
|
-
properties = interface_data[signal.name]
|
|
65
|
-
properties['interface'] = interface_name
|
|
66
|
-
return properties
|
|
67
|
-
return {}
|
|
1
|
+
# Copyright 2024 Volvo Car Corporation
|
|
2
|
+
# Licensed under Apache 2.0.
|
|
3
|
+
|
|
4
|
+
"""Module for extraction Energy Management System"""
|
|
5
|
+
import os
|
|
6
|
+
|
|
7
|
+
from powertrain_build.interface.base import BaseApplication, Signal
|
|
8
|
+
from powertrain_build.lib import logger
|
|
9
|
+
from powertrain_build.signal_interfaces import CsvSignalInterfaces
|
|
10
|
+
from powertrain_build.build_proj_config import BuildProjConfig
|
|
11
|
+
|
|
12
|
+
LOGGER = logger.create_logger(__file__)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class CsvEMS(BaseApplication, CsvSignalInterfaces):
|
|
16
|
+
"""Supplier part of the ECM"""
|
|
17
|
+
def __init__(self):
|
|
18
|
+
self._signals = {}
|
|
19
|
+
self.interfaces = {}
|
|
20
|
+
self._insignals = None
|
|
21
|
+
self._outsignals = None
|
|
22
|
+
self.projects = {}
|
|
23
|
+
|
|
24
|
+
def parse_definition(self, definition):
|
|
25
|
+
"""Read the interface files.
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
definition (Path): Path to ProjectCfg.json
|
|
29
|
+
"""
|
|
30
|
+
self.build_cfg = BuildProjConfig(os.path.normpath(str(definition)))
|
|
31
|
+
CsvSignalInterfaces.__init__(self, self.build_cfg, [])
|
|
32
|
+
self.projects[self.build_cfg.name] = self.build_cfg
|
|
33
|
+
self.config_path = self.build_cfg.get_if_cfg_dir()
|
|
34
|
+
self.name = self.build_cfg.name # Set name for CsvSignalInterfaces
|
|
35
|
+
self._parse_io_cnfg(self.config_path)
|
|
36
|
+
self.name = 'Supplier_' + self.build_cfg.name # set name for BaseApplication
|
|
37
|
+
|
|
38
|
+
def _get_signals(self):
|
|
39
|
+
"""Look through interfaces and create Signal objects"""
|
|
40
|
+
self._insignals = set()
|
|
41
|
+
self._outsignals = set()
|
|
42
|
+
for interface_name, data in self.interfaces.items():
|
|
43
|
+
for signal_name, signal_data in data.items():
|
|
44
|
+
if signal_data['IOType'] == '-':
|
|
45
|
+
# Signal is inactive
|
|
46
|
+
continue
|
|
47
|
+
if signal_name in self._signals:
|
|
48
|
+
signal = self._signals[signal_name]
|
|
49
|
+
else:
|
|
50
|
+
signal = Signal(signal_name, self)
|
|
51
|
+
self._signals.update({signal_name: signal})
|
|
52
|
+
if 'output' in interface_name.lower():
|
|
53
|
+
# outport from ECM. Inport in EMS (from SPM)
|
|
54
|
+
self._insignals.add(signal_name)
|
|
55
|
+
signal.consumers = interface_name
|
|
56
|
+
else:
|
|
57
|
+
signal.producers = interface_name
|
|
58
|
+
self._outsignals.add(signal_name)
|
|
59
|
+
|
|
60
|
+
def get_signal_properties(self, signal):
|
|
61
|
+
"""Find properties for a signal from interface files"""
|
|
62
|
+
for interface_name, interface_data in self.interfaces.items():
|
|
63
|
+
if signal.name in interface_data.keys():
|
|
64
|
+
properties = interface_data[signal.name]
|
|
65
|
+
properties['interface'] = interface_name
|
|
66
|
+
return properties
|
|
67
|
+
return {}
|
|
@@ -1,121 +1,121 @@
|
|
|
1
|
-
# Copyright 2024 Volvo Car Corporation
|
|
2
|
-
# Licensed under Apache 2.0.
|
|
3
|
-
|
|
4
|
-
"""Module to export information of global variables from powertrain_build projects."""
|
|
5
|
-
|
|
6
|
-
import argparse
|
|
7
|
-
import os
|
|
8
|
-
import sys
|
|
9
|
-
from typing import Dict, List, Optional, Tuple
|
|
10
|
-
|
|
11
|
-
from ruamel.yaml import YAML
|
|
12
|
-
|
|
13
|
-
from powertrain_build.build_proj_config import BuildProjConfig
|
|
14
|
-
from powertrain_build.feature_configs import FeatureConfigs
|
|
15
|
-
from powertrain_build.unit_configs import UnitConfigs
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
PARSER_HELP = "Export global variables."
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
def get_global_variables(project_config_path: str) -> Dict:
|
|
22
|
-
"""Get global variables connected to PyBuild project.
|
|
23
|
-
|
|
24
|
-
Args:
|
|
25
|
-
project_config_path (str): Path to ProjectCfg.json file.
|
|
26
|
-
Returns:
|
|
27
|
-
(Dict): Dict containing project name and its global variables (name, type).
|
|
28
|
-
"""
|
|
29
|
-
project_name, project_unit_config = _get_project_data(project_config_path)
|
|
30
|
-
|
|
31
|
-
variable_types = ["outports", "local_vars", "calib_consts", "nvm"]
|
|
32
|
-
variables = []
|
|
33
|
-
for variable_type in variable_types:
|
|
34
|
-
if variable_type not in project_unit_config:
|
|
35
|
-
continue
|
|
36
|
-
|
|
37
|
-
variables_info = [
|
|
38
|
-
{"name": variable, "type": _get_variable_type(variable_info)}
|
|
39
|
-
for variable, variable_info in project_unit_config[variable_type].items()
|
|
40
|
-
]
|
|
41
|
-
variables.extend(variables_info)
|
|
42
|
-
return {"name": project_name, "variables": variables}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
def _get_variable_type(variable_info: Dict) -> str:
|
|
46
|
-
"""Get variable type from variable info.
|
|
47
|
-
|
|
48
|
-
Args:
|
|
49
|
-
variable_info (Dict): Dictionary with the variable info.
|
|
50
|
-
|
|
51
|
-
Returns:
|
|
52
|
-
str: Variable type.
|
|
53
|
-
"""
|
|
54
|
-
unit_name = list(variable_info.keys())[0] # Getting any unit name, since variable type should be the same
|
|
55
|
-
return variable_info[unit_name]["type"]
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
def _get_project_data(project_config_path: str) -> Tuple[str, Dict]:
|
|
59
|
-
"""Gets data for a powertrain-build project.
|
|
60
|
-
|
|
61
|
-
Args:
|
|
62
|
-
project_config_path (str): Path to ProjectCfg.json file.
|
|
63
|
-
Returns:
|
|
64
|
-
project_name (str): Name of PyBuild project.
|
|
65
|
-
project_unit_config (dict): Dict mapping variable types to variables and their data.
|
|
66
|
-
"""
|
|
67
|
-
build_cfg = BuildProjConfig(os.path.normpath(project_config_path))
|
|
68
|
-
feature_cfg = FeatureConfigs(build_cfg)
|
|
69
|
-
unit_cfg = UnitConfigs(build_cfg, feature_cfg)
|
|
70
|
-
project_unit_config = unit_cfg.get_per_cfg_unit_cfg()
|
|
71
|
-
return build_cfg.name, project_unit_config
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
def _export_yaml(data: Dict, file_path: str) -> None:
|
|
75
|
-
"""Exports data from dictionary to a yaml file.
|
|
76
|
-
|
|
77
|
-
Args:
|
|
78
|
-
data (Dict): Dictionary with data.
|
|
79
|
-
file_path (str): Path of the file to export data.
|
|
80
|
-
"""
|
|
81
|
-
with open(file_path, "w", encoding="utf-8") as yaml_file:
|
|
82
|
-
yaml = YAML()
|
|
83
|
-
yaml.default_flow_style = False
|
|
84
|
-
yaml.dump(data, yaml_file)
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
def export_global_vars(args: argparse.Namespace):
|
|
88
|
-
"""Exports global variables as yaml file."""
|
|
89
|
-
global_variables = get_global_variables(args.project_config)
|
|
90
|
-
_export_yaml(global_variables, args.output_file)
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
def _main(argv: Optional[List[str]] = None):
|
|
94
|
-
"""Main function for CLI."""
|
|
95
|
-
parser = argparse.ArgumentParser(description=PARSER_HELP)
|
|
96
|
-
configure_parser(parser)
|
|
97
|
-
args = parser.parse_args(argv)
|
|
98
|
-
args.func(args)
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
def configure_parser(parser: argparse.ArgumentParser):
|
|
102
|
-
"""Configures the argument parser for the script.
|
|
103
|
-
|
|
104
|
-
Args:
|
|
105
|
-
parser (argparse.ArgumentParser): Argument parser.
|
|
106
|
-
"""
|
|
107
|
-
parser.add_argument(
|
|
108
|
-
"--project-config",
|
|
109
|
-
help="Project root configuration file.",
|
|
110
|
-
required=True,
|
|
111
|
-
)
|
|
112
|
-
parser.add_argument(
|
|
113
|
-
"--output-file",
|
|
114
|
-
help="Output file to export global variables.",
|
|
115
|
-
required=True,
|
|
116
|
-
)
|
|
117
|
-
parser.set_defaults(func=export_global_vars)
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
if __name__ == "__main__":
|
|
121
|
-
sys.exit(_main(sys.argv[1:]))
|
|
1
|
+
# Copyright 2024 Volvo Car Corporation
|
|
2
|
+
# Licensed under Apache 2.0.
|
|
3
|
+
|
|
4
|
+
"""Module to export information of global variables from powertrain_build projects."""
|
|
5
|
+
|
|
6
|
+
import argparse
|
|
7
|
+
import os
|
|
8
|
+
import sys
|
|
9
|
+
from typing import Dict, List, Optional, Tuple
|
|
10
|
+
|
|
11
|
+
from ruamel.yaml import YAML
|
|
12
|
+
|
|
13
|
+
from powertrain_build.build_proj_config import BuildProjConfig
|
|
14
|
+
from powertrain_build.feature_configs import FeatureConfigs
|
|
15
|
+
from powertrain_build.unit_configs import UnitConfigs
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
PARSER_HELP = "Export global variables."
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def get_global_variables(project_config_path: str) -> Dict:
|
|
22
|
+
"""Get global variables connected to PyBuild project.
|
|
23
|
+
|
|
24
|
+
Args:
|
|
25
|
+
project_config_path (str): Path to ProjectCfg.json file.
|
|
26
|
+
Returns:
|
|
27
|
+
(Dict): Dict containing project name and its global variables (name, type).
|
|
28
|
+
"""
|
|
29
|
+
project_name, project_unit_config = _get_project_data(project_config_path)
|
|
30
|
+
|
|
31
|
+
variable_types = ["outports", "local_vars", "calib_consts", "nvm"]
|
|
32
|
+
variables = []
|
|
33
|
+
for variable_type in variable_types:
|
|
34
|
+
if variable_type not in project_unit_config:
|
|
35
|
+
continue
|
|
36
|
+
|
|
37
|
+
variables_info = [
|
|
38
|
+
{"name": variable, "type": _get_variable_type(variable_info)}
|
|
39
|
+
for variable, variable_info in project_unit_config[variable_type].items()
|
|
40
|
+
]
|
|
41
|
+
variables.extend(variables_info)
|
|
42
|
+
return {"name": project_name, "variables": variables}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _get_variable_type(variable_info: Dict) -> str:
|
|
46
|
+
"""Get variable type from variable info.
|
|
47
|
+
|
|
48
|
+
Args:
|
|
49
|
+
variable_info (Dict): Dictionary with the variable info.
|
|
50
|
+
|
|
51
|
+
Returns:
|
|
52
|
+
str: Variable type.
|
|
53
|
+
"""
|
|
54
|
+
unit_name = list(variable_info.keys())[0] # Getting any unit name, since variable type should be the same
|
|
55
|
+
return variable_info[unit_name]["type"]
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def _get_project_data(project_config_path: str) -> Tuple[str, Dict]:
|
|
59
|
+
"""Gets data for a powertrain-build project.
|
|
60
|
+
|
|
61
|
+
Args:
|
|
62
|
+
project_config_path (str): Path to ProjectCfg.json file.
|
|
63
|
+
Returns:
|
|
64
|
+
project_name (str): Name of PyBuild project.
|
|
65
|
+
project_unit_config (dict): Dict mapping variable types to variables and their data.
|
|
66
|
+
"""
|
|
67
|
+
build_cfg = BuildProjConfig(os.path.normpath(project_config_path))
|
|
68
|
+
feature_cfg = FeatureConfigs(build_cfg)
|
|
69
|
+
unit_cfg = UnitConfigs(build_cfg, feature_cfg)
|
|
70
|
+
project_unit_config = unit_cfg.get_per_cfg_unit_cfg()
|
|
71
|
+
return build_cfg.name, project_unit_config
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def _export_yaml(data: Dict, file_path: str) -> None:
|
|
75
|
+
"""Exports data from dictionary to a yaml file.
|
|
76
|
+
|
|
77
|
+
Args:
|
|
78
|
+
data (Dict): Dictionary with data.
|
|
79
|
+
file_path (str): Path of the file to export data.
|
|
80
|
+
"""
|
|
81
|
+
with open(file_path, "w", encoding="utf-8") as yaml_file:
|
|
82
|
+
yaml = YAML()
|
|
83
|
+
yaml.default_flow_style = False
|
|
84
|
+
yaml.dump(data, yaml_file)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def export_global_vars(args: argparse.Namespace):
|
|
88
|
+
"""Exports global variables as yaml file."""
|
|
89
|
+
global_variables = get_global_variables(args.project_config)
|
|
90
|
+
_export_yaml(global_variables, args.output_file)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def _main(argv: Optional[List[str]] = None):
|
|
94
|
+
"""Main function for CLI."""
|
|
95
|
+
parser = argparse.ArgumentParser(description=PARSER_HELP)
|
|
96
|
+
configure_parser(parser)
|
|
97
|
+
args = parser.parse_args(argv)
|
|
98
|
+
args.func(args)
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def configure_parser(parser: argparse.ArgumentParser):
|
|
102
|
+
"""Configures the argument parser for the script.
|
|
103
|
+
|
|
104
|
+
Args:
|
|
105
|
+
parser (argparse.ArgumentParser): Argument parser.
|
|
106
|
+
"""
|
|
107
|
+
parser.add_argument(
|
|
108
|
+
"--project-config",
|
|
109
|
+
help="Project root configuration file.",
|
|
110
|
+
required=True,
|
|
111
|
+
)
|
|
112
|
+
parser.add_argument(
|
|
113
|
+
"--output-file",
|
|
114
|
+
help="Output file to export global variables.",
|
|
115
|
+
required=True,
|
|
116
|
+
)
|
|
117
|
+
parser.set_defaults(func=export_global_vars)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
if __name__ == "__main__":
|
|
121
|
+
sys.exit(_main(sys.argv[1:]))
|
|
@@ -1,132 +1,132 @@
|
|
|
1
|
-
# Copyright 2024 Volvo Car Corporation
|
|
2
|
-
# Licensed under Apache 2.0.
|
|
3
|
-
|
|
4
|
-
# -*- coding: utf-8 -*-
|
|
5
|
-
"""Python module used for calculating interfaces for CSP"""
|
|
6
|
-
import argparse
|
|
7
|
-
import sys
|
|
8
|
-
from pathlib import Path
|
|
9
|
-
from os import path
|
|
10
|
-
from typing import List, Optional
|
|
11
|
-
|
|
12
|
-
from powertrain_build.interface.hal import HALA
|
|
13
|
-
from powertrain_build.interface.device_proxy import DPAL
|
|
14
|
-
from powertrain_build.interface.service import ServiceFramework
|
|
15
|
-
from powertrain_build.interface import simulink
|
|
16
|
-
from powertrain_build.lib import logger
|
|
17
|
-
from powertrain_build.interface import generation_utils
|
|
18
|
-
from powertrain_build.lib.helper_functions import deep_json_update
|
|
19
|
-
|
|
20
|
-
LOGGER = logger.create_logger("CSP adapters")
|
|
21
|
-
|
|
22
|
-
PARSER_HELP = "Generate adapters"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
def configure_parser(parser: argparse.ArgumentParser):
|
|
26
|
-
generation_utils.add_base_args(parser)
|
|
27
|
-
parser.add_argument(
|
|
28
|
-
"--dp-interface",
|
|
29
|
-
help="Add dp interface to adapter specification",
|
|
30
|
-
action="store_true"
|
|
31
|
-
)
|
|
32
|
-
parser.add_argument(
|
|
33
|
-
"--hal-interface",
|
|
34
|
-
help="Add dp interface to adapter specification",
|
|
35
|
-
action="store_true"
|
|
36
|
-
)
|
|
37
|
-
parser.add_argument(
|
|
38
|
-
"--service-interface",
|
|
39
|
-
help="Add sfw interface to adapter specification",
|
|
40
|
-
action="store_true"
|
|
41
|
-
)
|
|
42
|
-
parser.add_argument(
|
|
43
|
-
"output",
|
|
44
|
-
help="Output file with interface specifications",
|
|
45
|
-
type=Path
|
|
46
|
-
)
|
|
47
|
-
parser.add_argument(
|
|
48
|
-
"--update-config",
|
|
49
|
-
help="Update project config file with path to adapter specifications",
|
|
50
|
-
action="store_true"
|
|
51
|
-
)
|
|
52
|
-
parser.set_defaults(func=generate_adapters)
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
def main(argv: Optional[List[str]] = None):
|
|
56
|
-
""" Main function for stand alone execution.
|
|
57
|
-
Mostly useful for testing and generation of dummy hal specifications
|
|
58
|
-
"""
|
|
59
|
-
parser = argparse.ArgumentParser(description=PARSER_HELP)
|
|
60
|
-
configure_parser(parser)
|
|
61
|
-
args = parser.parse_args(argv)
|
|
62
|
-
args.func(args)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
def generate_adapters(args: argparse.Namespace):
|
|
66
|
-
app = generation_utils.process_app(args.config)
|
|
67
|
-
adapters(args, app)
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
def update_project_config(args):
|
|
71
|
-
""" Update project config file with relative location to adapter specification file, linux styled path.
|
|
72
|
-
|
|
73
|
-
Args:
|
|
74
|
-
args (Namespace): Arguments from command line
|
|
75
|
-
"""
|
|
76
|
-
config_dir = Path(args.config).resolve().parents[0]
|
|
77
|
-
output_dir = Path(args.output).resolve().parents[0]
|
|
78
|
-
rel_dir = Path(path.relpath(output_dir, config_dir))
|
|
79
|
-
rel_path = rel_dir / Path(args.output).name
|
|
80
|
-
rel_path_linux = rel_path.as_posix()
|
|
81
|
-
deep_json_update(
|
|
82
|
-
args.config,
|
|
83
|
-
{'ProjectInfo': {'adapterSpec': rel_path_linux}}
|
|
84
|
-
)
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
def adapters(args, app):
|
|
88
|
-
""" Generate specification for adapter generation.
|
|
89
|
-
|
|
90
|
-
Args:
|
|
91
|
-
args (Namespace): Arguments from command line
|
|
92
|
-
app (Application): Application to generate specification for
|
|
93
|
-
"""
|
|
94
|
-
|
|
95
|
-
if args.dp_interface:
|
|
96
|
-
dp = DPAL(app)
|
|
97
|
-
dp_interface = generation_utils.get_interface(app, dp)
|
|
98
|
-
else:
|
|
99
|
-
dp_interface = {}
|
|
100
|
-
|
|
101
|
-
if args.hal_interface:
|
|
102
|
-
hala = HALA(app)
|
|
103
|
-
hal_interface = generation_utils.get_interface(app, hala)
|
|
104
|
-
else:
|
|
105
|
-
hal_interface = {}
|
|
106
|
-
|
|
107
|
-
if args.service_interface:
|
|
108
|
-
sfw = ServiceFramework(app)
|
|
109
|
-
sfw_interface = generation_utils.get_interface(app, sfw)
|
|
110
|
-
method_interface = generation_utils.get_method_interface(app)
|
|
111
|
-
else:
|
|
112
|
-
sfw_interface = {}
|
|
113
|
-
method_interface = {}
|
|
114
|
-
|
|
115
|
-
interface_data_types = app.pybuild['user_defined_types'].get_interface_data_types()
|
|
116
|
-
|
|
117
|
-
adapters = simulink.get_interface(
|
|
118
|
-
interface_data_types,
|
|
119
|
-
dp_interface,
|
|
120
|
-
hal_interface,
|
|
121
|
-
sfw_interface,
|
|
122
|
-
method_interface
|
|
123
|
-
)
|
|
124
|
-
|
|
125
|
-
generation_utils.write_to_file(adapters, args.output, is_yaml=True)
|
|
126
|
-
|
|
127
|
-
if args.update_config:
|
|
128
|
-
update_project_config(args)
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
if __name__ == "__main__":
|
|
132
|
-
main(sys.argv[1:])
|
|
1
|
+
# Copyright 2024 Volvo Car Corporation
|
|
2
|
+
# Licensed under Apache 2.0.
|
|
3
|
+
|
|
4
|
+
# -*- coding: utf-8 -*-
|
|
5
|
+
"""Python module used for calculating interfaces for CSP"""
|
|
6
|
+
import argparse
|
|
7
|
+
import sys
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
from os import path
|
|
10
|
+
from typing import List, Optional
|
|
11
|
+
|
|
12
|
+
from powertrain_build.interface.hal import HALA
|
|
13
|
+
from powertrain_build.interface.device_proxy import DPAL
|
|
14
|
+
from powertrain_build.interface.service import ServiceFramework
|
|
15
|
+
from powertrain_build.interface import simulink
|
|
16
|
+
from powertrain_build.lib import logger
|
|
17
|
+
from powertrain_build.interface import generation_utils
|
|
18
|
+
from powertrain_build.lib.helper_functions import deep_json_update
|
|
19
|
+
|
|
20
|
+
LOGGER = logger.create_logger("CSP adapters")
|
|
21
|
+
|
|
22
|
+
PARSER_HELP = "Generate adapters"
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def configure_parser(parser: argparse.ArgumentParser):
|
|
26
|
+
generation_utils.add_base_args(parser)
|
|
27
|
+
parser.add_argument(
|
|
28
|
+
"--dp-interface",
|
|
29
|
+
help="Add dp interface to adapter specification",
|
|
30
|
+
action="store_true"
|
|
31
|
+
)
|
|
32
|
+
parser.add_argument(
|
|
33
|
+
"--hal-interface",
|
|
34
|
+
help="Add dp interface to adapter specification",
|
|
35
|
+
action="store_true"
|
|
36
|
+
)
|
|
37
|
+
parser.add_argument(
|
|
38
|
+
"--service-interface",
|
|
39
|
+
help="Add sfw interface to adapter specification",
|
|
40
|
+
action="store_true"
|
|
41
|
+
)
|
|
42
|
+
parser.add_argument(
|
|
43
|
+
"output",
|
|
44
|
+
help="Output file with interface specifications",
|
|
45
|
+
type=Path
|
|
46
|
+
)
|
|
47
|
+
parser.add_argument(
|
|
48
|
+
"--update-config",
|
|
49
|
+
help="Update project config file with path to adapter specifications",
|
|
50
|
+
action="store_true"
|
|
51
|
+
)
|
|
52
|
+
parser.set_defaults(func=generate_adapters)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def main(argv: Optional[List[str]] = None):
|
|
56
|
+
""" Main function for stand alone execution.
|
|
57
|
+
Mostly useful for testing and generation of dummy hal specifications
|
|
58
|
+
"""
|
|
59
|
+
parser = argparse.ArgumentParser(description=PARSER_HELP)
|
|
60
|
+
configure_parser(parser)
|
|
61
|
+
args = parser.parse_args(argv)
|
|
62
|
+
args.func(args)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def generate_adapters(args: argparse.Namespace):
|
|
66
|
+
app = generation_utils.process_app(args.config)
|
|
67
|
+
adapters(args, app)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def update_project_config(args):
|
|
71
|
+
""" Update project config file with relative location to adapter specification file, linux styled path.
|
|
72
|
+
|
|
73
|
+
Args:
|
|
74
|
+
args (Namespace): Arguments from command line
|
|
75
|
+
"""
|
|
76
|
+
config_dir = Path(args.config).resolve().parents[0]
|
|
77
|
+
output_dir = Path(args.output).resolve().parents[0]
|
|
78
|
+
rel_dir = Path(path.relpath(output_dir, config_dir))
|
|
79
|
+
rel_path = rel_dir / Path(args.output).name
|
|
80
|
+
rel_path_linux = rel_path.as_posix()
|
|
81
|
+
deep_json_update(
|
|
82
|
+
args.config,
|
|
83
|
+
{'ProjectInfo': {'adapterSpec': rel_path_linux}}
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def adapters(args, app):
|
|
88
|
+
""" Generate specification for adapter generation.
|
|
89
|
+
|
|
90
|
+
Args:
|
|
91
|
+
args (Namespace): Arguments from command line
|
|
92
|
+
app (Application): Application to generate specification for
|
|
93
|
+
"""
|
|
94
|
+
|
|
95
|
+
if args.dp_interface:
|
|
96
|
+
dp = DPAL(app)
|
|
97
|
+
dp_interface = generation_utils.get_interface(app, dp)
|
|
98
|
+
else:
|
|
99
|
+
dp_interface = {}
|
|
100
|
+
|
|
101
|
+
if args.hal_interface:
|
|
102
|
+
hala = HALA(app)
|
|
103
|
+
hal_interface = generation_utils.get_interface(app, hala)
|
|
104
|
+
else:
|
|
105
|
+
hal_interface = {}
|
|
106
|
+
|
|
107
|
+
if args.service_interface:
|
|
108
|
+
sfw = ServiceFramework(app)
|
|
109
|
+
sfw_interface = generation_utils.get_interface(app, sfw)
|
|
110
|
+
method_interface = generation_utils.get_method_interface(app)
|
|
111
|
+
else:
|
|
112
|
+
sfw_interface = {}
|
|
113
|
+
method_interface = {}
|
|
114
|
+
|
|
115
|
+
interface_data_types = app.pybuild['user_defined_types'].get_interface_data_types()
|
|
116
|
+
|
|
117
|
+
adapters = simulink.get_interface(
|
|
118
|
+
interface_data_types,
|
|
119
|
+
dp_interface,
|
|
120
|
+
hal_interface,
|
|
121
|
+
sfw_interface,
|
|
122
|
+
method_interface
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
generation_utils.write_to_file(adapters, args.output, is_yaml=True)
|
|
126
|
+
|
|
127
|
+
if args.update_config:
|
|
128
|
+
update_project_config(args)
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
if __name__ == "__main__":
|
|
132
|
+
main(sys.argv[1:])
|