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,120 +1,120 @@
|
|
|
1
|
-
% Copyright 2024 Volvo Car Corporation
|
|
2
|
-
% Licensed under Apache 2.0.
|
|
3
|
-
|
|
4
|
-
function outPorts = parseOutPorts(root_subsystem)
|
|
5
|
-
% parseOutPorts Parse which block data shall be stored per block.
|
|
6
|
-
%
|
|
7
|
-
% See also parseModelInfo
|
|
8
|
-
outPorts = struct();
|
|
9
|
-
info = {'description', 'type', 'unit', 'offset', 'lsb', 'min', 'max', 'class', 'width'};
|
|
10
|
-
|
|
11
|
-
normalOutPorts = parseTLOutports(root_subsystem, info);
|
|
12
|
-
normalFields = fieldnames(normalOutPorts);
|
|
13
|
-
for idx = 1:length(normalFields)
|
|
14
|
-
outPorts.(normalFields{idx}) = normalOutPorts.(normalFields{idx});
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
busOutPorts = parseTLBusOutports(root_subsystem, info);
|
|
18
|
-
busFields = fieldnames(busOutPorts);
|
|
19
|
-
for idx = 1:length(busFields)
|
|
20
|
-
outPorts.(busFields{idx}) = busOutPorts.(busFields{idx});
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
function outports = parseTLOutports(root_subsystem, info)
|
|
25
|
-
out_ports = find_system(root_subsystem, 'FindAll', 'on', 'LookUnderMasks', 'all', 'MaskType', 'TL_Outport');
|
|
26
|
-
outports = struct();
|
|
27
|
-
tmpOutport = struct();
|
|
28
|
-
for i=1:length(out_ports)
|
|
29
|
-
outp = out_ports(i);
|
|
30
|
-
def_blk = getDefBlock(outp);
|
|
31
|
-
tmpOutport.handle = getPath(outp);
|
|
32
|
-
tmpOutport.name = getName(outp);
|
|
33
|
-
tmpOutport.configs = getCodeSwitches(def_blk);
|
|
34
|
-
for idx=1:length(info)
|
|
35
|
-
tmpValue = tl_get(outp, ['output.' info{idx}]);
|
|
36
|
-
tmpOutport.(info{idx}) = getProperValue(outp, tmpValue);
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
tmpOutport = modifyEnumStructField(tmpOutport);
|
|
40
|
-
|
|
41
|
-
if strcmp(tmpOutport.name, fields(outports))
|
|
42
|
-
printf('Warning: outport %s is already defined', tmpOutport.name);
|
|
43
|
-
printf(' signal will not be added again to the output signal');
|
|
44
|
-
else
|
|
45
|
-
outports.(tmpOutport.name) = tmpOutport;
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
function busOutPorts = parseTLBusOutports(root_subsystem, info)
|
|
51
|
-
foundBusOutPorts = find_system(root_subsystem, 'FindAll', 'on', 'LookUnderMasks', 'all', 'MaskType', 'TL_BusOutport');
|
|
52
|
-
busOutPorts = struct();
|
|
53
|
-
tmpOutport = struct();
|
|
54
|
-
for idx=1:length(foundBusOutPorts)
|
|
55
|
-
outp = foundBusOutPorts(idx);
|
|
56
|
-
busCreator = getDefBlock(outp);
|
|
57
|
-
defBlocks = getBusSrcBlocks(outp, busCreator);
|
|
58
|
-
if ismember('BusCreator', get_param(defBlocks, 'BlockType'))
|
|
59
|
-
faultyOutport = [get(outp, 'path') '/' get(outp, 'name')];
|
|
60
|
-
error('Nestled bus creators are currently not supported, see %s.', faultyOutport)
|
|
61
|
-
end
|
|
62
|
-
config = getBusConfig(defBlocks);
|
|
63
|
-
for idy = 1:tl_get(outp, 'numoutputs')
|
|
64
|
-
tmpOutport.handle = getPath(outp);
|
|
65
|
-
tmpOutport.name = tl_get(outp, ['output(' num2str(idy) ').signalname']);
|
|
66
|
-
tmpOutport.configs = config;
|
|
67
|
-
for idz=1:length(info)
|
|
68
|
-
tmpValue = tl_get(outp, ['output(' num2str(idy) ').' info{idz}]);
|
|
69
|
-
tmpOutport.(info{idz}) = getProperValue(outp, tmpValue);
|
|
70
|
-
end
|
|
71
|
-
% TODO Fix later, cannot set width in TL_BusOutport:s due to "matrix unified output".
|
|
72
|
-
tmpOutport.width = 1;
|
|
73
|
-
|
|
74
|
-
tmpOutport = modifyEnumStructField(tmpOutport);
|
|
75
|
-
|
|
76
|
-
busParts = split(tmpOutport.name, '.');
|
|
77
|
-
if ~ismember(busParts{1}, fields(busOutPorts))
|
|
78
|
-
busOutPorts.(busParts{1}) = struct();
|
|
79
|
-
busOutPorts.(busParts{1}).(busParts{2}) = tmpOutport;
|
|
80
|
-
elseif ~ismember(busParts{2}, fields(busOutPorts.(busParts{1})))
|
|
81
|
-
busOutPorts.(busParts{1}).(busParts{2}) = tmpOutport;
|
|
82
|
-
else
|
|
83
|
-
printf('Warning: outport %s is already defined', tmpOutport.name);
|
|
84
|
-
printf(' signal will not be added again to the output signal');
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
function defBlocks = getBusSrcBlocks(busOutPort, bus_creator)
|
|
91
|
-
defBlocks = [];
|
|
92
|
-
if ~strcmp(get_param(bus_creator, 'BlockType'), 'BusCreator')
|
|
93
|
-
faultyOutport = [get(busOutPort, 'path') '/' get(busOutPort, 'name')];
|
|
94
|
-
error('Source block of a TL_BusOutport must be a bus creator, see %s.', faultyOutport)
|
|
95
|
-
end
|
|
96
|
-
srcBlocks = getSrcBlocks(bus_creator);
|
|
97
|
-
tmpSrcPorts = get(getSrcLines(bus_creator), 'SrcPortHandle');
|
|
98
|
-
|
|
99
|
-
if iscell(tmpSrcPorts)
|
|
100
|
-
srcPorts = cell2mat(tmpSrcPorts);
|
|
101
|
-
else
|
|
102
|
-
srcPorts = tmpSrcPorts;
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
for idx = 1:length(srcBlocks)
|
|
106
|
-
defBlocks(end+1) = getDefBlock(srcBlocks(idx), srcPorts(idx));
|
|
107
|
-
end
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
function busConfig = getBusConfig(defBlocks)
|
|
111
|
-
busConfig = {'all'};
|
|
112
|
-
for idx = 1:length(defBlocks)
|
|
113
|
-
defConfig = getCodeSwitches(defBlocks(idx));
|
|
114
|
-
isValidConfig = iscell(defConfig) && length(defConfig) == 1 && strcmp(defConfig{1}, 'all');
|
|
115
|
-
if ~isValidConfig
|
|
116
|
-
faultyBlockPath = [get(defBlocks(idx), 'path') '/' get(defBlocks(idx), 'name')];
|
|
117
|
-
error('All members of a bus outport must be active, %s is not.', faultyBlockPath)
|
|
118
|
-
end
|
|
119
|
-
end
|
|
120
|
-
end
|
|
1
|
+
% Copyright 2024 Volvo Car Corporation
|
|
2
|
+
% Licensed under Apache 2.0.
|
|
3
|
+
|
|
4
|
+
function outPorts = parseOutPorts(root_subsystem)
|
|
5
|
+
% parseOutPorts Parse which block data shall be stored per block.
|
|
6
|
+
%
|
|
7
|
+
% See also parseModelInfo
|
|
8
|
+
outPorts = struct();
|
|
9
|
+
info = {'description', 'type', 'unit', 'offset', 'lsb', 'min', 'max', 'class', 'width'};
|
|
10
|
+
|
|
11
|
+
normalOutPorts = parseTLOutports(root_subsystem, info);
|
|
12
|
+
normalFields = fieldnames(normalOutPorts);
|
|
13
|
+
for idx = 1:length(normalFields)
|
|
14
|
+
outPorts.(normalFields{idx}) = normalOutPorts.(normalFields{idx});
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
busOutPorts = parseTLBusOutports(root_subsystem, info);
|
|
18
|
+
busFields = fieldnames(busOutPorts);
|
|
19
|
+
for idx = 1:length(busFields)
|
|
20
|
+
outPorts.(busFields{idx}) = busOutPorts.(busFields{idx});
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
function outports = parseTLOutports(root_subsystem, info)
|
|
25
|
+
out_ports = find_system(root_subsystem, 'FindAll', 'on', 'LookUnderMasks', 'all', 'MaskType', 'TL_Outport');
|
|
26
|
+
outports = struct();
|
|
27
|
+
tmpOutport = struct();
|
|
28
|
+
for i=1:length(out_ports)
|
|
29
|
+
outp = out_ports(i);
|
|
30
|
+
def_blk = getDefBlock(outp);
|
|
31
|
+
tmpOutport.handle = getPath(outp);
|
|
32
|
+
tmpOutport.name = getName(outp);
|
|
33
|
+
tmpOutport.configs = getCodeSwitches(def_blk);
|
|
34
|
+
for idx=1:length(info)
|
|
35
|
+
tmpValue = tl_get(outp, ['output.' info{idx}]);
|
|
36
|
+
tmpOutport.(info{idx}) = getProperValue(outp, tmpValue);
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
tmpOutport = modifyEnumStructField(tmpOutport);
|
|
40
|
+
|
|
41
|
+
if strcmp(tmpOutport.name, fields(outports))
|
|
42
|
+
printf('Warning: outport %s is already defined', tmpOutport.name);
|
|
43
|
+
printf(' signal will not be added again to the output signal');
|
|
44
|
+
else
|
|
45
|
+
outports.(tmpOutport.name) = tmpOutport;
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
function busOutPorts = parseTLBusOutports(root_subsystem, info)
|
|
51
|
+
foundBusOutPorts = find_system(root_subsystem, 'FindAll', 'on', 'LookUnderMasks', 'all', 'MaskType', 'TL_BusOutport');
|
|
52
|
+
busOutPorts = struct();
|
|
53
|
+
tmpOutport = struct();
|
|
54
|
+
for idx=1:length(foundBusOutPorts)
|
|
55
|
+
outp = foundBusOutPorts(idx);
|
|
56
|
+
busCreator = getDefBlock(outp);
|
|
57
|
+
defBlocks = getBusSrcBlocks(outp, busCreator);
|
|
58
|
+
if ismember('BusCreator', get_param(defBlocks, 'BlockType'))
|
|
59
|
+
faultyOutport = [get(outp, 'path') '/' get(outp, 'name')];
|
|
60
|
+
error('Nestled bus creators are currently not supported, see %s.', faultyOutport)
|
|
61
|
+
end
|
|
62
|
+
config = getBusConfig(defBlocks);
|
|
63
|
+
for idy = 1:tl_get(outp, 'numoutputs')
|
|
64
|
+
tmpOutport.handle = getPath(outp);
|
|
65
|
+
tmpOutport.name = tl_get(outp, ['output(' num2str(idy) ').signalname']);
|
|
66
|
+
tmpOutport.configs = config;
|
|
67
|
+
for idz=1:length(info)
|
|
68
|
+
tmpValue = tl_get(outp, ['output(' num2str(idy) ').' info{idz}]);
|
|
69
|
+
tmpOutport.(info{idz}) = getProperValue(outp, tmpValue);
|
|
70
|
+
end
|
|
71
|
+
% TODO Fix later, cannot set width in TL_BusOutport:s due to "matrix unified output".
|
|
72
|
+
tmpOutport.width = 1;
|
|
73
|
+
|
|
74
|
+
tmpOutport = modifyEnumStructField(tmpOutport);
|
|
75
|
+
|
|
76
|
+
busParts = split(tmpOutport.name, '.');
|
|
77
|
+
if ~ismember(busParts{1}, fields(busOutPorts))
|
|
78
|
+
busOutPorts.(busParts{1}) = struct();
|
|
79
|
+
busOutPorts.(busParts{1}).(busParts{2}) = tmpOutport;
|
|
80
|
+
elseif ~ismember(busParts{2}, fields(busOutPorts.(busParts{1})))
|
|
81
|
+
busOutPorts.(busParts{1}).(busParts{2}) = tmpOutport;
|
|
82
|
+
else
|
|
83
|
+
printf('Warning: outport %s is already defined', tmpOutport.name);
|
|
84
|
+
printf(' signal will not be added again to the output signal');
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
function defBlocks = getBusSrcBlocks(busOutPort, bus_creator)
|
|
91
|
+
defBlocks = [];
|
|
92
|
+
if ~strcmp(get_param(bus_creator, 'BlockType'), 'BusCreator')
|
|
93
|
+
faultyOutport = [get(busOutPort, 'path') '/' get(busOutPort, 'name')];
|
|
94
|
+
error('Source block of a TL_BusOutport must be a bus creator, see %s.', faultyOutport)
|
|
95
|
+
end
|
|
96
|
+
srcBlocks = getSrcBlocks(bus_creator);
|
|
97
|
+
tmpSrcPorts = get(getSrcLines(bus_creator), 'SrcPortHandle');
|
|
98
|
+
|
|
99
|
+
if iscell(tmpSrcPorts)
|
|
100
|
+
srcPorts = cell2mat(tmpSrcPorts);
|
|
101
|
+
else
|
|
102
|
+
srcPorts = tmpSrcPorts;
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
for idx = 1:length(srcBlocks)
|
|
106
|
+
defBlocks(end+1) = getDefBlock(srcBlocks(idx), srcPorts(idx));
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
function busConfig = getBusConfig(defBlocks)
|
|
111
|
+
busConfig = {'all'};
|
|
112
|
+
for idx = 1:length(defBlocks)
|
|
113
|
+
defConfig = getCodeSwitches(defBlocks(idx));
|
|
114
|
+
isValidConfig = iscell(defConfig) && length(defConfig) == 1 && strcmp(defConfig{1}, 'all');
|
|
115
|
+
if ~isValidConfig
|
|
116
|
+
faultyBlockPath = [get(defBlocks(idx), 'path') '/' get(defBlocks(idx), 'name')];
|
|
117
|
+
error('All members of a bus outport must be active, %s is not.', faultyBlockPath)
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
% Copyright 2024 Volvo Car Corporation
|
|
2
|
-
% Licensed under Apache 2.0.
|
|
3
|
-
|
|
4
|
-
function out = parsePreProcBlks(model)
|
|
5
|
-
% parsePreProcBlks Find all preprocessor blocks in the model
|
|
6
|
-
%
|
|
7
|
-
% See also parseModelInfo
|
|
8
|
-
preProcessorBlks = find_system(model, 'FindAll', 'on', 'RegExp', 'on', ...
|
|
9
|
-
'LookUnderMasks', 'all', 'MaskType', 'TL_PreProcessorIf');
|
|
10
|
-
blks = {};
|
|
11
|
-
for sbh=preProcessorBlks'
|
|
12
|
-
ports = get_param(sbh, 'PortHandles');
|
|
13
|
-
l=get_param(ports.Inport, 'Line');
|
|
14
|
-
blk = get_param(l, 'SrcBlockHandle');
|
|
15
|
-
if strcmp(get_param(blk, 'blocktype'), 'Inport')
|
|
16
|
-
tmp=get_param(get_param(blk,'parent'), 'linehandles');
|
|
17
|
-
blk=get_param(tmp.Inport(str2num(get_param(blk, 'port'))), 'srcblockhandle');
|
|
18
|
-
end
|
|
19
|
-
if_exp = tl_get(sbh, 'ifexpression');
|
|
20
|
-
blks = [strrep(if_exp,'u1',get_param(blk, 'const_name')); blks];
|
|
21
|
-
end
|
|
22
|
-
out = unique(blks);
|
|
23
|
-
end
|
|
1
|
+
% Copyright 2024 Volvo Car Corporation
|
|
2
|
+
% Licensed under Apache 2.0.
|
|
3
|
+
|
|
4
|
+
function out = parsePreProcBlks(model)
|
|
5
|
+
% parsePreProcBlks Find all preprocessor blocks in the model
|
|
6
|
+
%
|
|
7
|
+
% See also parseModelInfo
|
|
8
|
+
preProcessorBlks = find_system(model, 'FindAll', 'on', 'RegExp', 'on', ...
|
|
9
|
+
'LookUnderMasks', 'all', 'MaskType', 'TL_PreProcessorIf');
|
|
10
|
+
blks = {};
|
|
11
|
+
for sbh=preProcessorBlks'
|
|
12
|
+
ports = get_param(sbh, 'PortHandles');
|
|
13
|
+
l=get_param(ports.Inport, 'Line');
|
|
14
|
+
blk = get_param(l, 'SrcBlockHandle');
|
|
15
|
+
if strcmp(get_param(blk, 'blocktype'), 'Inport')
|
|
16
|
+
tmp=get_param(get_param(blk,'parent'), 'linehandles');
|
|
17
|
+
blk=get_param(tmp.Inport(str2num(get_param(blk, 'port'))), 'srcblockhandle');
|
|
18
|
+
end
|
|
19
|
+
if_exp = tl_get(sbh, 'ifexpression');
|
|
20
|
+
blks = [strrep(if_exp,'u1',get_param(blk, 'const_name')); blks];
|
|
21
|
+
end
|
|
22
|
+
out = unique(blks);
|
|
23
|
+
end
|
|
@@ -1,128 +1,128 @@
|
|
|
1
|
-
% Copyright 2024 Volvo Car Corporation
|
|
2
|
-
% Licensed under Apache 2.0.
|
|
3
|
-
|
|
4
|
-
function res = struct2JSON(struct, outputFileName)
|
|
5
|
-
% A function that a strcut and file name as arguments,
|
|
6
|
-
% and outputs the matlab struct as a JSON file in UTF-8 encoding
|
|
7
|
-
fp = fopen(outputFileName, 'w', 'n', 'UTF-8');
|
|
8
|
-
if fp > 0
|
|
9
|
-
res = recursiveStringGen('', struct, '', 1);
|
|
10
|
-
fwrite(fp,res);
|
|
11
|
-
fclose(fp);
|
|
12
|
-
else
|
|
13
|
-
disp(['could not open file ' outputFileName])
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
function res = recursiveStringGen(elementName, element, str, indentLevel)
|
|
18
|
-
%function that outputs a string with a json format from a struct
|
|
19
|
-
%Note the NaN value is not according to JSON standard, but the
|
|
20
|
-
%python importer seems to handle it anyway
|
|
21
|
-
if isstruct(element)
|
|
22
|
-
subElementNames = fields(element);
|
|
23
|
-
subElemsLen = length(subElementNames);
|
|
24
|
-
|
|
25
|
-
if subElemsLen == 0
|
|
26
|
-
str = sprintf('%s{}', str);
|
|
27
|
-
else
|
|
28
|
-
str = sprintf('%s{\n', str);
|
|
29
|
-
for idx=1:subElemsLen
|
|
30
|
-
subElementName = subElementNames{idx};
|
|
31
|
-
subElement = element.(subElementName);
|
|
32
|
-
if isfield(subElement, 'unshortenedName')
|
|
33
|
-
% When element name length is > 63, it can't be stored as a struct key, instead the
|
|
34
|
-
% full name is stored as a subelement with the key 'unshortenedName'.
|
|
35
|
-
subElementName = subElement.('unshortenedName')
|
|
36
|
-
subElement = rmfield(subElement, 'unshortenedName')
|
|
37
|
-
end
|
|
38
|
-
if ismember(elementName, {'inports', 'outports'})
|
|
39
|
-
% TL_In-/Out-ports have a depth of 1, which TL_BusIn-/Out-ports have a depth of 2.
|
|
40
|
-
% Bus ports should be reduced to a depth of 1, where each member is
|
|
41
|
-
% field with the new name Bus.Member.
|
|
42
|
-
subElementFields = fields(subElement);
|
|
43
|
-
if ~ismember('name', subElementFields)
|
|
44
|
-
subElements = subElement;
|
|
45
|
-
for idy=1:length(subElementFields)
|
|
46
|
-
subElementNameNew = [subElementName '.' subElementFields{idy}];
|
|
47
|
-
subElement = subElements.(subElementFields{idy});
|
|
48
|
-
str = [str indent(['"' subElementNameNew '": '], indentLevel)];
|
|
49
|
-
str = recursiveStringGen(subElementNameNew, subElement, str, indentLevel + 1);
|
|
50
|
-
if idy ~= length(subElementFields)
|
|
51
|
-
str = sprintf('%s,\n', str);
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
else
|
|
55
|
-
str = [str indent(['"' subElementName '": '], indentLevel)];
|
|
56
|
-
str = recursiveStringGen(subElementName, subElement, str, indentLevel + 1);
|
|
57
|
-
end
|
|
58
|
-
else
|
|
59
|
-
str = [str indent(['"' subElementName '": '], indentLevel)];
|
|
60
|
-
str = recursiveStringGen(subElementName, subElement, str, indentLevel + 1);
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
if idx ~= subElemsLen
|
|
64
|
-
str = sprintf('%s,\n', str);
|
|
65
|
-
else
|
|
66
|
-
str = sprintf('%s}', str);
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
res = str;
|
|
71
|
-
return
|
|
72
|
-
elseif iscell(element)
|
|
73
|
-
elemLen = length(element);
|
|
74
|
-
if elemLen == 0
|
|
75
|
-
str = sprintf('%s[]', str);
|
|
76
|
-
else
|
|
77
|
-
str = sprintf('%s[\n', str);
|
|
78
|
-
for idx=1:elemLen
|
|
79
|
-
str = [str indent('', indentLevel)];
|
|
80
|
-
str = recursiveStringGen('', element{idx}, str, indentLevel + 1);
|
|
81
|
-
if idx ~= elemLen
|
|
82
|
-
str = sprintf('%s,\n', str);
|
|
83
|
-
else
|
|
84
|
-
str = sprintf('%s]', str);
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
res = str;
|
|
89
|
-
return
|
|
90
|
-
elseif ischar(element)
|
|
91
|
-
% replace line feeds with spaces, and " with '
|
|
92
|
-
% as this is not supported inn JSON
|
|
93
|
-
elemTmp = strrep(element,'"','''');
|
|
94
|
-
newline = sprintf('\n');
|
|
95
|
-
elemTmp = strrep(elemTmp, newline, ' ');
|
|
96
|
-
% replace single \ with \\, as a single \ is interpreted as escape
|
|
97
|
-
elemTmp = regexprep(elemTmp, '(?<!\\)\\(?!\\)', '\\\\');
|
|
98
|
-
str = [str '"' elemTmp '"'];
|
|
99
|
-
res = str;
|
|
100
|
-
return
|
|
101
|
-
elseif isscalar(element)
|
|
102
|
-
str = [str num2str(element)];
|
|
103
|
-
res = str;
|
|
104
|
-
return
|
|
105
|
-
elseif isvector(element)
|
|
106
|
-
tmp = regexprep(num2str(element(1,:)),'\s+',', ');
|
|
107
|
-
str = [str '[' tmp ']'];
|
|
108
|
-
res = str;
|
|
109
|
-
return
|
|
110
|
-
elseif ismatrix(element)
|
|
111
|
-
if isempty(element)
|
|
112
|
-
str = [str '""'];
|
|
113
|
-
else
|
|
114
|
-
str = [str 'Not Implemented'];
|
|
115
|
-
end
|
|
116
|
-
res = str;
|
|
117
|
-
return
|
|
118
|
-
end
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
function outStr = indent(str, indentLevel)
|
|
122
|
-
%function that returns a string with 2 spaces per indent level
|
|
123
|
-
tmp = '';
|
|
124
|
-
for i=1:indentLevel
|
|
125
|
-
tmp = [tmp ' '];
|
|
126
|
-
end
|
|
127
|
-
outStr = [tmp str];
|
|
128
|
-
end
|
|
1
|
+
% Copyright 2024 Volvo Car Corporation
|
|
2
|
+
% Licensed under Apache 2.0.
|
|
3
|
+
|
|
4
|
+
function res = struct2JSON(struct, outputFileName)
|
|
5
|
+
% A function that a strcut and file name as arguments,
|
|
6
|
+
% and outputs the matlab struct as a JSON file in UTF-8 encoding
|
|
7
|
+
fp = fopen(outputFileName, 'w', 'n', 'UTF-8');
|
|
8
|
+
if fp > 0
|
|
9
|
+
res = recursiveStringGen('', struct, '', 1);
|
|
10
|
+
fwrite(fp,res);
|
|
11
|
+
fclose(fp);
|
|
12
|
+
else
|
|
13
|
+
disp(['could not open file ' outputFileName])
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
function res = recursiveStringGen(elementName, element, str, indentLevel)
|
|
18
|
+
%function that outputs a string with a json format from a struct
|
|
19
|
+
%Note the NaN value is not according to JSON standard, but the
|
|
20
|
+
%python importer seems to handle it anyway
|
|
21
|
+
if isstruct(element)
|
|
22
|
+
subElementNames = fields(element);
|
|
23
|
+
subElemsLen = length(subElementNames);
|
|
24
|
+
|
|
25
|
+
if subElemsLen == 0
|
|
26
|
+
str = sprintf('%s{}', str);
|
|
27
|
+
else
|
|
28
|
+
str = sprintf('%s{\n', str);
|
|
29
|
+
for idx=1:subElemsLen
|
|
30
|
+
subElementName = subElementNames{idx};
|
|
31
|
+
subElement = element.(subElementName);
|
|
32
|
+
if isfield(subElement, 'unshortenedName')
|
|
33
|
+
% When element name length is > 63, it can't be stored as a struct key, instead the
|
|
34
|
+
% full name is stored as a subelement with the key 'unshortenedName'.
|
|
35
|
+
subElementName = subElement.('unshortenedName')
|
|
36
|
+
subElement = rmfield(subElement, 'unshortenedName')
|
|
37
|
+
end
|
|
38
|
+
if ismember(elementName, {'inports', 'outports'})
|
|
39
|
+
% TL_In-/Out-ports have a depth of 1, which TL_BusIn-/Out-ports have a depth of 2.
|
|
40
|
+
% Bus ports should be reduced to a depth of 1, where each member is
|
|
41
|
+
% field with the new name Bus.Member.
|
|
42
|
+
subElementFields = fields(subElement);
|
|
43
|
+
if ~ismember('name', subElementFields)
|
|
44
|
+
subElements = subElement;
|
|
45
|
+
for idy=1:length(subElementFields)
|
|
46
|
+
subElementNameNew = [subElementName '.' subElementFields{idy}];
|
|
47
|
+
subElement = subElements.(subElementFields{idy});
|
|
48
|
+
str = [str indent(['"' subElementNameNew '": '], indentLevel)];
|
|
49
|
+
str = recursiveStringGen(subElementNameNew, subElement, str, indentLevel + 1);
|
|
50
|
+
if idy ~= length(subElementFields)
|
|
51
|
+
str = sprintf('%s,\n', str);
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
else
|
|
55
|
+
str = [str indent(['"' subElementName '": '], indentLevel)];
|
|
56
|
+
str = recursiveStringGen(subElementName, subElement, str, indentLevel + 1);
|
|
57
|
+
end
|
|
58
|
+
else
|
|
59
|
+
str = [str indent(['"' subElementName '": '], indentLevel)];
|
|
60
|
+
str = recursiveStringGen(subElementName, subElement, str, indentLevel + 1);
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
if idx ~= subElemsLen
|
|
64
|
+
str = sprintf('%s,\n', str);
|
|
65
|
+
else
|
|
66
|
+
str = sprintf('%s}', str);
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
res = str;
|
|
71
|
+
return
|
|
72
|
+
elseif iscell(element)
|
|
73
|
+
elemLen = length(element);
|
|
74
|
+
if elemLen == 0
|
|
75
|
+
str = sprintf('%s[]', str);
|
|
76
|
+
else
|
|
77
|
+
str = sprintf('%s[\n', str);
|
|
78
|
+
for idx=1:elemLen
|
|
79
|
+
str = [str indent('', indentLevel)];
|
|
80
|
+
str = recursiveStringGen('', element{idx}, str, indentLevel + 1);
|
|
81
|
+
if idx ~= elemLen
|
|
82
|
+
str = sprintf('%s,\n', str);
|
|
83
|
+
else
|
|
84
|
+
str = sprintf('%s]', str);
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
res = str;
|
|
89
|
+
return
|
|
90
|
+
elseif ischar(element)
|
|
91
|
+
% replace line feeds with spaces, and " with '
|
|
92
|
+
% as this is not supported inn JSON
|
|
93
|
+
elemTmp = strrep(element,'"','''');
|
|
94
|
+
newline = sprintf('\n');
|
|
95
|
+
elemTmp = strrep(elemTmp, newline, ' ');
|
|
96
|
+
% replace single \ with \\, as a single \ is interpreted as escape
|
|
97
|
+
elemTmp = regexprep(elemTmp, '(?<!\\)\\(?!\\)', '\\\\');
|
|
98
|
+
str = [str '"' elemTmp '"'];
|
|
99
|
+
res = str;
|
|
100
|
+
return
|
|
101
|
+
elseif isscalar(element)
|
|
102
|
+
str = [str num2str(element)];
|
|
103
|
+
res = str;
|
|
104
|
+
return
|
|
105
|
+
elseif isvector(element)
|
|
106
|
+
tmp = regexprep(num2str(element(1,:)),'\s+',', ');
|
|
107
|
+
str = [str '[' tmp ']'];
|
|
108
|
+
res = str;
|
|
109
|
+
return
|
|
110
|
+
elseif ismatrix(element)
|
|
111
|
+
if isempty(element)
|
|
112
|
+
str = [str '""'];
|
|
113
|
+
else
|
|
114
|
+
str = [str 'Not Implemented'];
|
|
115
|
+
end
|
|
116
|
+
res = str;
|
|
117
|
+
return
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
function outStr = indent(str, indentLevel)
|
|
122
|
+
%function that returns a string with 2 spaces per indent level
|
|
123
|
+
tmp = '';
|
|
124
|
+
for i=1:indentLevel
|
|
125
|
+
tmp = [tmp ' '];
|
|
126
|
+
end
|
|
127
|
+
outStr = [tmp str];
|
|
128
|
+
end
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
% Copyright 2024 Volvo Car Corporation
|
|
2
|
-
% Licensed under Apache 2.0.
|
|
3
|
-
|
|
4
|
-
function updateCodeSwConfig(RootFolder, model_path)
|
|
5
|
-
% updateCodeSwConfig(RootFolder, model_path)
|
|
6
|
-
%
|
|
7
|
-
% Executes 'py -3.6 -m powertrain_build.config models' for the model.
|
|
8
|
-
% This script reads the .json, .c and .h-files and looks for configs for
|
|
9
|
-
% the variables that already have a config in the json.
|
|
10
|
-
%
|
|
11
|
-
% Arguments:
|
|
12
|
-
% RootFolder: Pull path to pt_pcc
|
|
13
|
-
% model_path: Path to the model to regenerate config for.
|
|
14
|
-
old_pythonpath = getenv('PYTHONPATH');
|
|
15
|
-
|
|
16
|
-
if ~isempty(getenv('PYTOOLS_ACTIVATE'))
|
|
17
|
-
[~, out]=system(['CALL %PYTOOLS_ACTIVATE% & python -m powertrain_build.config models "' model_path '"']);
|
|
18
|
-
elseif ~isempty(getenv('CALLING_PYTHON'))
|
|
19
|
-
% Local run using calling python version
|
|
20
|
-
fprintf('\nUsing calling python: %s\n', getenv('CALLING_PYTHON'));
|
|
21
|
-
setenv('PYTHONPATH', RootFolder)
|
|
22
|
-
[~, out]=system(['%CALLING_PYTHON% -m powertrain_build.config models "' model_path '"']);
|
|
23
|
-
else
|
|
24
|
-
% Local run
|
|
25
|
-
fprintf('\nUsing python version 3.6\n');
|
|
26
|
-
setenv('PYTHONPATH', RootFolder)
|
|
27
|
-
[~, out]=system(['py -3.6 -m powertrain_build.config models "' model_path '"']);
|
|
28
|
-
end
|
|
29
|
-
disp(out)
|
|
30
|
-
setenv('PYTHONPATH', old_pythonpath)
|
|
31
|
-
end
|
|
1
|
+
% Copyright 2024 Volvo Car Corporation
|
|
2
|
+
% Licensed under Apache 2.0.
|
|
3
|
+
|
|
4
|
+
function updateCodeSwConfig(RootFolder, model_path)
|
|
5
|
+
% updateCodeSwConfig(RootFolder, model_path)
|
|
6
|
+
%
|
|
7
|
+
% Executes 'py -3.6 -m powertrain_build.config models' for the model.
|
|
8
|
+
% This script reads the .json, .c and .h-files and looks for configs for
|
|
9
|
+
% the variables that already have a config in the json.
|
|
10
|
+
%
|
|
11
|
+
% Arguments:
|
|
12
|
+
% RootFolder: Pull path to pt_pcc
|
|
13
|
+
% model_path: Path to the model to regenerate config for.
|
|
14
|
+
old_pythonpath = getenv('PYTHONPATH');
|
|
15
|
+
|
|
16
|
+
if ~isempty(getenv('PYTOOLS_ACTIVATE'))
|
|
17
|
+
[~, out]=system(['CALL %PYTOOLS_ACTIVATE% & python -m powertrain_build.config models "' model_path '"']);
|
|
18
|
+
elseif ~isempty(getenv('CALLING_PYTHON'))
|
|
19
|
+
% Local run using calling python version
|
|
20
|
+
fprintf('\nUsing calling python: %s\n', getenv('CALLING_PYTHON'));
|
|
21
|
+
setenv('PYTHONPATH', RootFolder)
|
|
22
|
+
[~, out]=system(['%CALLING_PYTHON% -m powertrain_build.config models "' model_path '"']);
|
|
23
|
+
else
|
|
24
|
+
% Local run
|
|
25
|
+
fprintf('\nUsing python version 3.6\n');
|
|
26
|
+
setenv('PYTHONPATH', RootFolder)
|
|
27
|
+
[~, out]=system(['py -3.6 -m powertrain_build.config models "' model_path '"']);
|
|
28
|
+
end
|
|
29
|
+
disp(out)
|
|
30
|
+
setenv('PYTHONPATH', old_pythonpath)
|
|
31
|
+
end
|