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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. powertrain_build/__init__.py +40 -40
  2. powertrain_build/__main__.py +6 -6
  3. powertrain_build/a2l.py +582 -582
  4. powertrain_build/a2l_merge.py +650 -650
  5. powertrain_build/a2l_templates.py +717 -717
  6. powertrain_build/build.py +985 -985
  7. powertrain_build/build_defs.py +309 -309
  8. powertrain_build/build_proj_config.py +690 -690
  9. powertrain_build/check_interface.py +575 -575
  10. powertrain_build/cli.py +141 -141
  11. powertrain_build/config.py +542 -542
  12. powertrain_build/core.py +395 -395
  13. powertrain_build/core_dummy.py +343 -343
  14. powertrain_build/create_conversion_table.py +73 -73
  15. powertrain_build/dids.py +916 -916
  16. powertrain_build/dummy.py +157 -157
  17. powertrain_build/dummy_spm.py +252 -252
  18. powertrain_build/environmentcheck.py +52 -52
  19. powertrain_build/ext_dbg.py +255 -255
  20. powertrain_build/ext_var.py +327 -327
  21. powertrain_build/feature_configs.py +301 -301
  22. powertrain_build/gen_allsysteminfo.py +227 -227
  23. powertrain_build/gen_label_split.py +449 -449
  24. powertrain_build/handcode_replacer.py +124 -124
  25. powertrain_build/html_report.py +133 -133
  26. powertrain_build/interface/__init__.py +4 -4
  27. powertrain_build/interface/application.py +511 -511
  28. powertrain_build/interface/base.py +500 -500
  29. powertrain_build/interface/csp_api.py +490 -490
  30. powertrain_build/interface/device_proxy.py +677 -677
  31. powertrain_build/interface/ems.py +67 -67
  32. powertrain_build/interface/export_global_vars.py +121 -121
  33. powertrain_build/interface/generate_adapters.py +132 -132
  34. powertrain_build/interface/generate_hi_interface.py +87 -87
  35. powertrain_build/interface/generate_service.py +69 -69
  36. powertrain_build/interface/generate_wrappers.py +147 -147
  37. powertrain_build/interface/generation_utils.py +142 -142
  38. powertrain_build/interface/hal.py +194 -194
  39. powertrain_build/interface/model_yaml_verification.py +348 -348
  40. powertrain_build/interface/service.py +296 -296
  41. powertrain_build/interface/simulink.py +249 -249
  42. powertrain_build/interface/update_call_sources.py +180 -180
  43. powertrain_build/interface/update_model_yaml.py +186 -186
  44. powertrain_build/interface/zone_controller.py +362 -362
  45. powertrain_build/lib/__init__.py +4 -4
  46. powertrain_build/lib/helper_functions.py +127 -127
  47. powertrain_build/lib/logger.py +55 -55
  48. powertrain_build/matlab_scripts/CodeGen/BuildAutomationPyBuild.m +78 -78
  49. powertrain_build/matlab_scripts/CodeGen/Generate_A2L.m +154 -154
  50. powertrain_build/matlab_scripts/CodeGen/generateTLUnit.m +239 -239
  51. powertrain_build/matlab_scripts/CodeGen/getAsilClassification.m +28 -28
  52. powertrain_build/matlab_scripts/CodeGen/modelConfiguredForTL.m +28 -28
  53. powertrain_build/matlab_scripts/CodeGen/moveDefOutports.m +88 -88
  54. powertrain_build/matlab_scripts/CodeGen/parseCalMeasData.m +410 -410
  55. powertrain_build/matlab_scripts/CodeGen/parseCoreIdentifiers.m +139 -139
  56. powertrain_build/matlab_scripts/CodeGen/parseDIDs.m +141 -141
  57. powertrain_build/matlab_scripts/CodeGen/parseInPorts.m +106 -106
  58. powertrain_build/matlab_scripts/CodeGen/parseIncludeConfigs.m +25 -25
  59. powertrain_build/matlab_scripts/CodeGen/parseModelInfo.m +38 -38
  60. powertrain_build/matlab_scripts/CodeGen/parseNVM.m +81 -81
  61. powertrain_build/matlab_scripts/CodeGen/parseOutPorts.m +120 -120
  62. powertrain_build/matlab_scripts/CodeGen/parsePreProcBlks.m +23 -23
  63. powertrain_build/matlab_scripts/CodeGen/struct2JSON.m +128 -128
  64. powertrain_build/matlab_scripts/CodeGen/updateCodeSwConfig.m +31 -31
  65. powertrain_build/matlab_scripts/Init_PyBuild.m +91 -91
  66. powertrain_build/matlab_scripts/__init__.py +2 -2
  67. powertrain_build/matlab_scripts/helperFunctions/Get_Full_Name.m +46 -46
  68. powertrain_build/matlab_scripts/helperFunctions/Get_SrcLines.m +12 -12
  69. powertrain_build/matlab_scripts/helperFunctions/Init_Models.m +78 -78
  70. powertrain_build/matlab_scripts/helperFunctions/Init_Projects.m +67 -67
  71. powertrain_build/matlab_scripts/helperFunctions/Read_Units.m +34 -34
  72. powertrain_build/matlab_scripts/helperFunctions/SetProjectTimeSamples.m +26 -26
  73. powertrain_build/matlab_scripts/helperFunctions/Strip_Suffix.m +16 -16
  74. powertrain_build/matlab_scripts/helperFunctions/followLink.m +118 -118
  75. powertrain_build/matlab_scripts/helperFunctions/getCodeSwitches.m +50 -50
  76. powertrain_build/matlab_scripts/helperFunctions/getConsumerBlocks.m +30 -30
  77. powertrain_build/matlab_scripts/helperFunctions/getDefBlock.m +39 -39
  78. powertrain_build/matlab_scripts/helperFunctions/getDefOutport.m +58 -58
  79. powertrain_build/matlab_scripts/helperFunctions/getDstBlocks.m +19 -19
  80. powertrain_build/matlab_scripts/helperFunctions/getDstLines.m +13 -13
  81. powertrain_build/matlab_scripts/helperFunctions/getInterfaceSignals.m +37 -37
  82. powertrain_build/matlab_scripts/helperFunctions/getName.m +37 -37
  83. powertrain_build/matlab_scripts/helperFunctions/getPath.m +6 -6
  84. powertrain_build/matlab_scripts/helperFunctions/getProperValue.m +21 -21
  85. powertrain_build/matlab_scripts/helperFunctions/getSrcBlocks.m +19 -19
  86. powertrain_build/matlab_scripts/helperFunctions/getSrcLines.m +13 -13
  87. powertrain_build/matlab_scripts/helperFunctions/loadLibraries.m +10 -10
  88. powertrain_build/matlab_scripts/helperFunctions/loadjson.m +6 -6
  89. powertrain_build/matlab_scripts/helperFunctions/modifyEnumStructField.m +21 -21
  90. powertrain_build/matlab_scripts/helperFunctions/removeConfigDuplicates.m +31 -31
  91. powertrain_build/matlab_scripts/helperFunctions/sortSystemByClass.m +26 -26
  92. powertrain_build/matlab_scripts/helperFunctions/tl_getfast.m +89 -89
  93. powertrain_build/matlab_scripts/helperFunctions/topLevelSystem.m +20 -20
  94. powertrain_build/matlab_scripts/helperFunctions/updateModels.m +131 -131
  95. powertrain_build/memory_section.py +224 -224
  96. powertrain_build/nvm_def.py +729 -729
  97. powertrain_build/problem_logger.py +86 -86
  98. powertrain_build/pt_matlab.py +430 -430
  99. powertrain_build/pt_win32.py +144 -144
  100. powertrain_build/replace_compu_tab_ref.py +105 -105
  101. powertrain_build/rte_dummy.py +254 -254
  102. powertrain_build/sched_funcs.py +209 -207
  103. powertrain_build/signal.py +7 -7
  104. powertrain_build/signal_if_html_rep.py +221 -221
  105. powertrain_build/signal_if_html_rep_all.py +302 -302
  106. powertrain_build/signal_incons_html_rep.py +180 -180
  107. powertrain_build/signal_incons_html_rep_all.py +366 -366
  108. powertrain_build/signal_incons_html_rep_base.py +168 -168
  109. powertrain_build/signal_inconsistency_check.py +641 -641
  110. powertrain_build/signal_interfaces.py +864 -864
  111. powertrain_build/templates/Index_SigCheck_All.html +22 -22
  112. powertrain_build/templates/Index_SigIf_All.html +19 -19
  113. powertrain_build/types.py +218 -218
  114. powertrain_build/unit_configs.py +419 -419
  115. powertrain_build/user_defined_types.py +660 -660
  116. powertrain_build/versioncheck.py +66 -66
  117. powertrain_build/wrapper.py +512 -512
  118. powertrain_build/xlrd_csv.py +87 -87
  119. powertrain_build/zone_controller/__init__.py +4 -4
  120. powertrain_build/zone_controller/calibration.py +176 -176
  121. powertrain_build/zone_controller/composition_yaml.py +880 -878
  122. {powertrain_build-1.13.1.dist-info → powertrain_build-1.13.3.dev3.dist-info}/METADATA +100 -100
  123. powertrain_build-1.13.3.dev3.dist-info/RECORD +130 -0
  124. {powertrain_build-1.13.1.dist-info → powertrain_build-1.13.3.dev3.dist-info}/WHEEL +1 -1
  125. {powertrain_build-1.13.1.dist-info → powertrain_build-1.13.3.dev3.dist-info}/licenses/LICENSE +202 -202
  126. powertrain_build-1.13.3.dev3.dist-info/pbr.json +1 -0
  127. powertrain_build-1.13.1.dist-info/RECORD +0 -130
  128. powertrain_build-1.13.1.dist-info/pbr.json +0 -1
  129. {powertrain_build-1.13.1.dist-info → powertrain_build-1.13.3.dev3.dist-info}/entry_points.txt +0 -0
  130. {powertrain_build-1.13.1.dist-info → powertrain_build-1.13.3.dev3.dist-info}/licenses/AUTHORS +0 -0
  131. {powertrain_build-1.13.1.dist-info → powertrain_build-1.13.3.dev3.dist-info}/licenses/NOTICE +0 -0
  132. {powertrain_build-1.13.1.dist-info → powertrain_build-1.13.3.dev3.dist-info}/top_level.txt +0 -0
@@ -1,89 +1,89 @@
1
- % Copyright 2024 Volvo Car Corporation
2
- % Licensed under Apache 2.0.
3
-
4
- function Ans = tl_get(Handles,Field)
5
-
6
- if isempty(Handles)
7
- Ans=[];
8
- return;
9
- end
10
-
11
- if iscell(Handles)
12
- for i=1:length(Handles)
13
- HTemp(i,1)=get_param(Handles{i},'handle');
14
- end
15
- Handles=HTemp;
16
- elseif ischar(Handles)
17
- Handles=get_param(Handles,'handle');
18
- end
19
-
20
- Dot=strfind(Field,'.');
21
-
22
- if ~isempty(Dot)
23
- Before=Field(1:Dot-1);
24
- After=Field(Dot+1:end);
25
- end
26
-
27
-
28
-
29
- if length(Handles)==1
30
- Tmp = Read_Block_Data(Handles);
31
- if ~isempty(Dot)
32
- Ans=Tmp.(Before).(After);
33
- else
34
- Ans=Tmp.(Field);
35
- end
36
- else
37
- Ans={};
38
- for i=1:length(Handles)
39
- Tmp = Read_Block_Data(Handles(i));
40
- if ~isempty(Dot)
41
- Ans{i,1}=Tmp.(Before).(After);
42
- else
43
- Ans{i,1}=Tmp.(Field);
44
- end
45
- end
46
- end
47
-
48
-
49
- function Data = Read_Block_Data(Handle)
50
-
51
-
52
- BlockType = get_param(Handle, 'MaskType');
53
- DataStr = get_param(Handle, 'data');
54
- Data = eval(DataStr, '[]');
55
- if ~isempty(tl_manage_blockset('GetDataDescription',BlockType))
56
- Data = tl_supplement_data_struct(Data, BlockType);
57
- end
58
-
59
- switch get_param(Handle,'masktype')
60
- case 'TL_Constant'
61
- Data.output.value=get_param(Handle,'value');
62
- case 'TL_IndexSearch'
63
- Data.input.value=get_param(Handle,'bpData');
64
- case 'TL_Prelookup'
65
- Data.input.value=get_param(Handle,'BreakpointsData');
66
- case 'TL_Interpolation'
67
- Data.table.value=get_param(Handle,'table');
68
- case 'TL_Interpolation_n-D'
69
- Data.table.value=get_param(Handle,'Table');
70
- end
71
-
72
-
73
- if strcmp(BlockType,'TL_Rescaler')
74
- Data.output.value=tl_get(Handle,'output.value');
75
- end
76
-
77
-
78
-
79
- try
80
- Data.output.width=str2double(get_param(Handle,'PortDimensions'));
81
- catch
82
- end
83
-
84
-
85
-
86
-
87
-
88
-
89
-
1
+ % Copyright 2024 Volvo Car Corporation
2
+ % Licensed under Apache 2.0.
3
+
4
+ function Ans = tl_get(Handles,Field)
5
+
6
+ if isempty(Handles)
7
+ Ans=[];
8
+ return;
9
+ end
10
+
11
+ if iscell(Handles)
12
+ for i=1:length(Handles)
13
+ HTemp(i,1)=get_param(Handles{i},'handle');
14
+ end
15
+ Handles=HTemp;
16
+ elseif ischar(Handles)
17
+ Handles=get_param(Handles,'handle');
18
+ end
19
+
20
+ Dot=strfind(Field,'.');
21
+
22
+ if ~isempty(Dot)
23
+ Before=Field(1:Dot-1);
24
+ After=Field(Dot+1:end);
25
+ end
26
+
27
+
28
+
29
+ if length(Handles)==1
30
+ Tmp = Read_Block_Data(Handles);
31
+ if ~isempty(Dot)
32
+ Ans=Tmp.(Before).(After);
33
+ else
34
+ Ans=Tmp.(Field);
35
+ end
36
+ else
37
+ Ans={};
38
+ for i=1:length(Handles)
39
+ Tmp = Read_Block_Data(Handles(i));
40
+ if ~isempty(Dot)
41
+ Ans{i,1}=Tmp.(Before).(After);
42
+ else
43
+ Ans{i,1}=Tmp.(Field);
44
+ end
45
+ end
46
+ end
47
+
48
+
49
+ function Data = Read_Block_Data(Handle)
50
+
51
+
52
+ BlockType = get_param(Handle, 'MaskType');
53
+ DataStr = get_param(Handle, 'data');
54
+ Data = eval(DataStr, '[]');
55
+ if ~isempty(tl_manage_blockset('GetDataDescription',BlockType))
56
+ Data = tl_supplement_data_struct(Data, BlockType);
57
+ end
58
+
59
+ switch get_param(Handle,'masktype')
60
+ case 'TL_Constant'
61
+ Data.output.value=get_param(Handle,'value');
62
+ case 'TL_IndexSearch'
63
+ Data.input.value=get_param(Handle,'bpData');
64
+ case 'TL_Prelookup'
65
+ Data.input.value=get_param(Handle,'BreakpointsData');
66
+ case 'TL_Interpolation'
67
+ Data.table.value=get_param(Handle,'table');
68
+ case 'TL_Interpolation_n-D'
69
+ Data.table.value=get_param(Handle,'Table');
70
+ end
71
+
72
+
73
+ if strcmp(BlockType,'TL_Rescaler')
74
+ Data.output.value=tl_get(Handle,'output.value');
75
+ end
76
+
77
+
78
+
79
+ try
80
+ Data.output.width=str2double(get_param(Handle,'PortDimensions'));
81
+ catch
82
+ end
83
+
84
+
85
+
86
+
87
+
88
+
89
+
@@ -1,21 +1,21 @@
1
- % Copyright 2024 Volvo Car Corporation
2
- % Licensed under Apache 2.0.
3
-
4
- function topLevelSystem = topLevelSystem(model)
5
- %Function which returns a string to the top level target link subsystem
6
- %Takes one argument, which is the model names
7
- tlFncs = find_system(model, 'FindAll', 'on', 'LookUnderMasks', 'all', ...
8
- 'Regexp' ,'on', 'MaskType', 'TL_Function');
9
-
10
- funcParents = get_param(tlFncs, 'Parent');
11
- if ~iscell(funcParents)
12
- funcParents = {funcParents};
13
- end
14
- lenFncs = cellfun(@(p)length(p), funcParents);
15
- if ~isempty(lenFncs)
16
- topLevelIdx = lenFncs == min(lenFncs(:));
17
- topLevelSystem = funcParents{topLevelIdx};
18
- else
19
- error('did not find any TL_Function blocks')
20
- end
1
+ % Copyright 2024 Volvo Car Corporation
2
+ % Licensed under Apache 2.0.
3
+
4
+ function topLevelSystem = topLevelSystem(model)
5
+ %Function which returns a string to the top level target link subsystem
6
+ %Takes one argument, which is the model names
7
+ tlFncs = find_system(model, 'FindAll', 'on', 'LookUnderMasks', 'all', ...
8
+ 'Regexp' ,'on', 'MaskType', 'TL_Function');
9
+
10
+ funcParents = get_param(tlFncs, 'Parent');
11
+ if ~iscell(funcParents)
12
+ funcParents = {funcParents};
13
+ end
14
+ lenFncs = cellfun(@(p)length(p), funcParents);
15
+ if ~isempty(lenFncs)
16
+ topLevelIdx = lenFncs == min(lenFncs(:));
17
+ topLevelSystem = funcParents{topLevelIdx};
18
+ else
19
+ error('did not find any TL_Function blocks')
20
+ end
21
21
  end
@@ -1,131 +1,131 @@
1
- % Copyright 2024 Volvo Car Corporation
2
- % Licensed under Apache 2.0.
3
-
4
- function errorOccurred = updateModels(mode, rootFolder, modelList)
5
- bdclose('all')
6
- evalin('base', 'global Vc');
7
- global Vc;
8
- startdir = pwd;
9
- % Load nvmram lists
10
- nvmStructs = [rootFolder '/Projects/*/conf.local/nvm_structs.json'];
11
- NVMData = struct();
12
- for file=dir(nvmStructs)'
13
- disp(['Loading NVM data from ' file.folder]);
14
- tmp_nvm=loadjson(fullfile(file.folder, file.name));
15
- for block=tmp_nvm
16
- if ~isempty(block(1).signals)
17
- for var=block(1).signals
18
- NVMData.(var(1).name) = var(1);
19
- end
20
- end
21
- end
22
- end
23
-
24
- tlmodels = false;
25
- for i=1:length(modelList)
26
- [modelFolder, modelName, ~] = fileparts(modelList{i});
27
- % Check if model is configured to use TargetLink or not.
28
- isTLModel = modelConfiguredForTL(rootFolder, modelFolder, modelName);
29
- % Save if any of the models was a TargetLink model
30
- tlmodels = tlmodels || isTLModel;
31
- end
32
-
33
- % Load par-files, add *Const manually if not already in the list
34
- % This is required since they can contain constants used by other models
35
- modelListPar = modelList;
36
- if all(cellfun(@isempty, regexp(modelList,'Models/Common/\w*Const/\w*Const.mdl','match')))
37
- commonConstModels = dir('Models/Common/*Const/*Const.mdl');
38
- for i=1:length(commonConstModels)
39
- modelName = [commonConstModels(i).folder '/' commonConstModels(i).name]
40
- modelListPar = [{strrep(modelName, rootFolder, "")}, modelListPar];
41
- end
42
- end
43
-
44
- for i=1:length(modelListPar)
45
- [modelFolder, modelName, ~] = fileparts(modelListPar{i});
46
- end
47
-
48
- for i=1:length(modelListPar)
49
- [modelFolder, modelName, ~] = fileparts(modelListPar{i});
50
- modelFolder = strip(convertStringsToChars(modelFolder), '\');
51
- par_f_path = strip(join([modelFolder '\' modelName '_par.m'],''), '\');
52
- if ~isfile(par_f_path)
53
- error('Invalid par file path: "%s"', par_f_path);
54
- end
55
-
56
- % Set all model sample times to 0.01
57
- clear tmp; % tmp is used by many par_files, and not always cleaned up
58
- run(par_f_path);
59
- tok = regexp(modelName, '([A-Z]\w*?)([A-Z]\w*?)([A-Z]\w*?){0,1}(?:__.*?){0,1}$','tokens');
60
- if ~isempty(tok{1}{3})
61
- Vc.(tok{1}{2}).(tok{1}{3}).ts = 0.01;
62
- else
63
- Vc.(tok{1}{2}).ts = 0.01;
64
- end
65
- disp(['Loaded: ' par_f_path])
66
- cd(startdir);
67
- end
68
-
69
- % Update the model and generate code
70
- errorOccurred = false;
71
- interfaceSignals = getInterfaceSignals(rootFolder);
72
- for i=1:length(modelList)
73
- cd(startdir);
74
- if ~isfile(modelList{i})
75
- error('Invalid model path: "%s"', modelList{i});
76
- end
77
-
78
- [modelFolder, modelName, ~] = fileparts(modelList{i});
79
- cd([rootFolder '/' modelFolder]);
80
-
81
- % Would like to avoid this duplication, but not sure how.
82
- ssp = strsplit(modelList{i}, '/');
83
- % SSP is desired in the path "Models/<SSP>/<MODEL>/<MDL.mdl>, hence end-2.
84
- ssp = ssp(end-2);
85
- ssp = ssp{1};
86
- disp(ssp)
87
-
88
- isTLModel = modelConfiguredForTL(rootFolder, modelFolder, modelName);
89
-
90
- fprintf('\nStart generation of unitCfg for model %s\n', modelName);
91
- try
92
- fprintf('\nrootFolder: %s, modelName: %s, ssp: %s\n', rootFolder, modelName, ssp);
93
-
94
- switch mode
95
- case 'update'
96
- disp(['Updating: ' modelName]);
97
- updateModel(rootFolder, modelName, ssp, NVMData, interfaceSignals);
98
- case 'codegen'
99
- disp(['Generating: ' modelName]);
100
- if isTLModel
101
- if ~exist('dsdd_manage_project', 'file')
102
- error('TargetLink not installed. Cannot generate code for models configured with TargetLink');
103
- end
104
- generateTLUnit(rootFolder, modelName, ssp);
105
- else
106
- generateECUnit(rootFolder, modelName, ssp)
107
- end
108
- otherwise
109
- fprintf('\n Unsupported mode: %s\n', mode);
110
- errorOccurred = true;
111
- break;
112
- end
113
- catch err
114
- fprintf('\nError: %s\n', err.getReport());
115
- errorOccurred = true;
116
- end
117
-
118
- fprintf('\nFinished generation of unitCfg for model %s\n', modelName);
119
- cd(startdir);
120
- end
121
-
122
- if tlmodels
123
- % Throw away any local changes to DD0
124
- dsdd('Close', 'save', 0);
125
- end
126
-
127
- % Add final success message if no errors occurred
128
- if ~errorOccurred
129
- fprintf('\n%s\n', 'Matlab task succeeded!');
130
- end
131
- end
1
+ % Copyright 2024 Volvo Car Corporation
2
+ % Licensed under Apache 2.0.
3
+
4
+ function errorOccurred = updateModels(mode, rootFolder, modelList)
5
+ bdclose('all')
6
+ evalin('base', 'global Vc');
7
+ global Vc;
8
+ startdir = pwd;
9
+ % Load nvmram lists
10
+ nvmStructs = [rootFolder '/Projects/*/conf.local/nvm_structs.json'];
11
+ NVMData = struct();
12
+ for file=dir(nvmStructs)'
13
+ disp(['Loading NVM data from ' file.folder]);
14
+ tmp_nvm=loadjson(fullfile(file.folder, file.name));
15
+ for block=tmp_nvm
16
+ if ~isempty(block(1).signals)
17
+ for var=block(1).signals
18
+ NVMData.(var(1).name) = var(1);
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+ tlmodels = false;
25
+ for i=1:length(modelList)
26
+ [modelFolder, modelName, ~] = fileparts(modelList{i});
27
+ % Check if model is configured to use TargetLink or not.
28
+ isTLModel = modelConfiguredForTL(rootFolder, modelFolder, modelName);
29
+ % Save if any of the models was a TargetLink model
30
+ tlmodels = tlmodels || isTLModel;
31
+ end
32
+
33
+ % Load par-files, add *Const manually if not already in the list
34
+ % This is required since they can contain constants used by other models
35
+ modelListPar = modelList;
36
+ if all(cellfun(@isempty, regexp(modelList,'Models/Common/\w*Const/\w*Const.mdl','match')))
37
+ commonConstModels = dir('Models/Common/*Const/*Const.mdl');
38
+ for i=1:length(commonConstModels)
39
+ modelName = [commonConstModels(i).folder '/' commonConstModels(i).name]
40
+ modelListPar = [{strrep(modelName, rootFolder, "")}, modelListPar];
41
+ end
42
+ end
43
+
44
+ for i=1:length(modelListPar)
45
+ [modelFolder, modelName, ~] = fileparts(modelListPar{i});
46
+ end
47
+
48
+ for i=1:length(modelListPar)
49
+ [modelFolder, modelName, ~] = fileparts(modelListPar{i});
50
+ modelFolder = strip(convertStringsToChars(modelFolder), '\');
51
+ par_f_path = strip(join([modelFolder '\' modelName '_par.m'],''), '\');
52
+ if ~isfile(par_f_path)
53
+ error('Invalid par file path: "%s"', par_f_path);
54
+ end
55
+
56
+ % Set all model sample times to 0.01
57
+ clear tmp; % tmp is used by many par_files, and not always cleaned up
58
+ run(par_f_path);
59
+ tok = regexp(modelName, '([A-Z]\w*?)([A-Z]\w*?)([A-Z]\w*?){0,1}(?:__.*?){0,1}$','tokens');
60
+ if ~isempty(tok{1}{3})
61
+ Vc.(tok{1}{2}).(tok{1}{3}).ts = 0.01;
62
+ else
63
+ Vc.(tok{1}{2}).ts = 0.01;
64
+ end
65
+ disp(['Loaded: ' par_f_path])
66
+ cd(startdir);
67
+ end
68
+
69
+ % Update the model and generate code
70
+ errorOccurred = false;
71
+ interfaceSignals = getInterfaceSignals(rootFolder);
72
+ for i=1:length(modelList)
73
+ cd(startdir);
74
+ if ~isfile(modelList{i})
75
+ error('Invalid model path: "%s"', modelList{i});
76
+ end
77
+
78
+ [modelFolder, modelName, ~] = fileparts(modelList{i});
79
+ cd([rootFolder '/' modelFolder]);
80
+
81
+ % Would like to avoid this duplication, but not sure how.
82
+ ssp = strsplit(modelList{i}, '/');
83
+ % SSP is desired in the path "Models/<SSP>/<MODEL>/<MDL.mdl>, hence end-2.
84
+ ssp = ssp(end-2);
85
+ ssp = ssp{1};
86
+ disp(ssp)
87
+
88
+ isTLModel = modelConfiguredForTL(rootFolder, modelFolder, modelName);
89
+
90
+ fprintf('\nStart generation of unitCfg for model %s\n', modelName);
91
+ try
92
+ fprintf('\nrootFolder: %s, modelName: %s, ssp: %s\n', rootFolder, modelName, ssp);
93
+
94
+ switch mode
95
+ case 'update'
96
+ disp(['Updating: ' modelName]);
97
+ updateModel(rootFolder, modelName, ssp, NVMData, interfaceSignals);
98
+ case 'codegen'
99
+ disp(['Generating: ' modelName]);
100
+ if isTLModel
101
+ if ~exist('dsdd_manage_project', 'file')
102
+ error('TargetLink not installed. Cannot generate code for models configured with TargetLink');
103
+ end
104
+ generateTLUnit(rootFolder, modelName, ssp);
105
+ else
106
+ generateECUnit(rootFolder, modelName, ssp)
107
+ end
108
+ otherwise
109
+ fprintf('\n Unsupported mode: %s\n', mode);
110
+ errorOccurred = true;
111
+ break;
112
+ end
113
+ catch err
114
+ fprintf('\nError: %s\n', err.getReport());
115
+ errorOccurred = true;
116
+ end
117
+
118
+ fprintf('\nFinished generation of unitCfg for model %s\n', modelName);
119
+ cd(startdir);
120
+ end
121
+
122
+ if tlmodels
123
+ % Throw away any local changes to DD0
124
+ dsdd('Close', 'save', 0);
125
+ end
126
+
127
+ % Add final success message if no errors occurred
128
+ if ~errorOccurred
129
+ fprintf('\n%s\n', 'Matlab task succeeded!');
130
+ end
131
+ end