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,410 +1,410 @@
1
- % Copyright 2024 Volvo Car Corporation
2
- % Licensed under Apache 2.0.
3
-
4
- function [ allVariables ] = parseCalMeasData( system )
5
- % parseCalMeasData Parse calibration measurement data
6
- %
7
- % See also parseModelInfo
8
-
9
- allVariables=struct;
10
- evalin('base', [system '_par']);
11
- allVariables.local_vars=struct;
12
- allVariables.calib_consts=struct;
13
-
14
- tmp=sortSystemByClass(system);
15
-
16
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
17
- % Measurable variables
18
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
19
- blocksTmp=tmp.CVC_DISP;
20
- % find all TL_Outports (should not be included in measurement variables
21
- % as they should be included in the outports key
22
- outports = find_system(topLevelSystem(system), 'FindAll', 'on', ...
23
- 'LookUnderMasks', 'all', 'MaskType', 'TL_Outport');
24
- blocks = setdiff(blocksTmp, outports);
25
- allVariables = Create_Standard_Struct(system, allVariables, blocks, 'local_vars', 'output');
26
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
27
-
28
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
29
- % Cal variables
30
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31
- blocks=tmp.CVC_CAL;
32
- allVariables = Create_Standard_Struct(system, allVariables, blocks, 'calib_consts', 'output');
33
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
34
-
35
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
36
- % Prelookups
37
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38
- blocks=find_system(get_param(system,'handle'), 'lookundermasks', 'on', 'masktype', 'TL_IndexSearch');
39
- allVariables = Create_Standard_Struct(system, allVariables, blocks, 'calib_consts', 'input');
40
-
41
- blocks=find_system(get_param(system,'handle'), 'lookundermasks', 'on', 'masktype', 'TL_PreLookup');
42
- allVariables = Create_Standard_Struct(system, allVariables, blocks, 'calib_consts', 'input');
43
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
44
-
45
-
46
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
47
- % Lookups
48
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
49
- blocks=find_system(get_param(system,'handle'), 'lookundermasks', 'on', 'regexp', 'on', 'masktype', 'TL_Interpolation.*');
50
- allVariables = Create_Standard_Struct(system, allVariables, blocks, 'calib_consts', 'table');
51
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
52
-
53
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
54
- % Stateflow
55
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
56
- stateflow=find_system(get_param(system, 'handle'), 'FindAll', 'on', ...
57
- 'lookundermasks', 'on', 'masktype', 'Stateflow');
58
- for i=1:length(stateflow)
59
- allVariables = Create_Struct_SFlow(system, allVariables, stateflow(i));
60
- end
61
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
62
-
63
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
64
- % CustomCode blocks
65
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
66
- customCode=find_system(get_param(system, 'handle'), 'FindAll', 'on', ...
67
- 'lookundermasks', 'on', 'masktype', 'TL_CustomCode');
68
- for i=1:length(customCode)
69
- allVariables = createStructCustCode(system, allVariables, customCode(i));
70
- end
71
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
72
-
73
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
74
- % TCM specific blocks
75
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
76
-
77
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
78
- % Lookup1D
79
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
80
- blocks = find_system(get_param(system, 'handle'), 'lookundermasks', 'on', ...
81
- 'masktype','TL_Lookup1D');
82
- allVariables = Create_Standard_Struct(system, allVariables, blocks, 'calib_consts', 'input');
83
- allVariables = Create_Standard_Struct(system, allVariables, blocks, 'calib_consts', 'table');
84
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
85
-
86
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
87
- % Lookup2D
88
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
89
- blocks = find_system(get_param(system,'handle'),'lookundermasks','on','masktype','TL_Lookup2D');
90
- allVariables = Create_Standard_Struct(system, allVariables, blocks, 'calib_consts', 'row');
91
- allVariables = Create_Standard_Struct(system, allVariables, blocks, 'calib_consts', 'col');
92
- allVariables = Create_Standard_Struct(system, allVariables, blocks, 'calib_consts', 'table');
93
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
94
- end
95
-
96
- function allVariables = Create_Standard_Struct(systemIn, allVariables, ...
97
- blocks, structName, field)
98
-
99
- if ~isempty(blocks)
100
- TLFields={'type', 'unit', 'description', 'max', 'min', 'lsb', ...
101
- 'offset', 'class'};
102
- system = regexprep(systemIn,'(\w+?)(__.*){0,1}','$1');
103
- for block = blocks'
104
- class=tl_getfast(block, [field '.class']);
105
- if ~isempty(class) && ~strcmp(class, 'default')
106
- name=tl_getfast(block, [field '.name']);
107
- res = regexp(name, '(\$[SD])', 'match', 'once');
108
- if ~isempty(res)
109
- o = sprintf('Warning %s in block <a href = "matlab:Hilite_This_System(''%s'')">%s</a>', ...
110
- res, getPath(block), getName(block));
111
- disp(o)
112
- %hilite_system(block)
113
- else
114
- variableName=Get_Full_Name(block, name, system);
115
- if sum(isstrprop(variableName, 'wspace')) > 0
116
- o = sprintf('Illegal characters in the name property in block <a href = "matlab:Hilite_This_System(''%s'')">%s</a>', ...
117
- getPath(block), getName(block));
118
- disp(o)
119
- error('aborting')
120
- end
121
- %VariableName = VariableName(isstrprop(VariableName, 'wspace') == 0);
122
- if ~isempty(variableName)
123
- for tlField = TLFields
124
- tmp_tlField = tlField{1};
125
- if ismember(get_param(block, 'masktype'), ...
126
- {'TL_RelationalOperator', 'TL_LogicalOperator'}) && ...
127
- ismember(tmp_tlField , {'max', 'min', 'lsb', 'offset'})
128
- allVariables.(structName).(variableName).(tmp_tlField) = '-';
129
- elseif ismember(get_param(block, 'masktype'), {'TL_BitwiseOperator'}) ...
130
- && ismember(tmp_tlField , {'max', 'min', 'lsb', 'offset', 'unit'})
131
- allVariables.(structName).(variableName).(tmp_tlField) = '-';
132
- else
133
- Value=tl_getfast(block, [field '.' tmp_tlField]);
134
- if iscell(Value)
135
- Value = Value{1};
136
- end
137
- if strcmp(Value, 'IMPLICIT_ENUM')
138
- Value = getEnumName(block);
139
- end
140
- allVariables.(structName).(variableName).(tmp_tlField) = checkValue(Value);
141
- end
142
- end
143
- allVariables.(structName).(variableName).handle = getPath(block);
144
- consumerBlks = getConsumerBlocks(block);
145
- if isempty(consumerBlks)
146
- allVariables.(structName).(variableName).configs = getCodeSwitches(block);
147
- else
148
- codeSwTmp = {};
149
- for j=1:length(consumerBlks)
150
- consBlk = consumerBlks(j);
151
- codeSwTmp{j} = getCodeSwitches(consBlk);
152
- end
153
- allVariables.(structName).(variableName).configs = removeConfigDuplicates(codeSwTmp);
154
- end
155
- if ismember(get_param(block, 'masktype'), {'TL_IndexSearch', 'TL_Interpolation', 'TL_Lookup1D', 'TL_Lookup2D'}) ...
156
- && ~strcmp(field,'output')
157
- [inputValueRef, errorFlag, ~] = tl_get(block, [field '.value']);
158
- if errorFlag > 0
159
- inputValueRef = tl_getfast(block, [field '.value']);
160
- end
161
- InputValue=evalin('base', inputValueRef);
162
- VarSize=size(InputValue);
163
- allVariables.(structName).(variableName).width = VarSize;
164
- elseif strcmp(get_param(block, 'masktype'), 'TL_Constant') && strcmp(field,'output')
165
- ConstantValue=evalin('base', tl_getfast(block, [field '.value']));
166
- VarSize=size(ConstantValue);
167
- if VarSize(2) == 1
168
- allVariables.(structName).(variableName).width = 1;
169
- else
170
- allVariables.(structName).(variableName).width = VarSize;
171
- end
172
- elseif strcmp(get_param(block, 'masktype'), 'TL_IndexSearch') && strcmp(field, 'output')
173
- if tl_getfast(block, 'outputmode') == 2
174
- VarSize = [1,2];
175
- else
176
- VarSize = 1;
177
- end
178
- allVariables.(structName).(variableName).width = VarSize;
179
- else
180
- allVariables.(structName).(variableName).width = 1;
181
- end
182
- allVariables.(structName).(variableName) = modifyEnumStructField(allVariables.(structName).(variableName));
183
- if length(variableName) > 63
184
- % Can't store the full name as a struct key as matlab only supports key lengths < 64
185
- o = sprintf('Warning variable name %s is longer than 63 chars, consider shortening it.', variableName);
186
- disp(o)
187
- allVariables.(structName).(variableName).unshortenedName = variableName;
188
- end
189
- end
190
- end
191
- end
192
- end
193
- end
194
- end
195
-
196
- function allVariables = Create_Struct_SFlow(system, allVariables, sFlow)
197
- configs = getCodeSwitches(sFlow);
198
- % Handle stateflow outports
199
- tmp_SFObj = get_param(sFlow, 'Object');
200
- chartObj = tmp_SFObj.find('-isa', 'Stateflow.Chart');
201
- sfDataArr = chartObj.find('-isa', 'Stateflow.Data');
202
- idArr = arrayfun(@(x) x.Id, sfDataArr);
203
- sfHandles = tl_get_sfobjects(sFlow, {'SF Output', 'SF Local'});
204
- for i=1:length(sfHandles)
205
- SfHandle = sfHandles(i);
206
- idx = idArr == SfHandle;
207
- sfData = sfDataArr(idx);
208
- tlClass = tl_get(SfHandle, 'class');
209
- if checkClass(tlClass, sFlow, sfData)
210
- continue % do nothing, if NVM, default class, or name error. NVM is handled elsewhere
211
- end
212
- tlName = tl_get(SfHandle, 'name');
213
- res = regexp(tlName, '(\$[SDCB])', 'tokens');
214
- if isempty(res)
215
- allVariables = copyFields(system, allVariables, sFlow, SfHandle, configs, sfData.port);
216
- else
217
- err_msg = res{1}{1};
218
- if isnan(sfData.port)
219
- port = '';
220
- else
221
- port = [':' num2str(sfData.port)];
222
- end
223
- o = sprintf('Warning %s in <a href = "matlab:Hilite_This_System(''%s'')">%s - %s (%s%s)</a>', ...
224
- err_msg, getPath(sFlow), get_param(sFlow, 'name'), sfData.name, sfData.scope, port);
225
- disp(o)
226
- end
227
- end
228
- end
229
-
230
- function allVariables = createStructCustCode(system, allVariables, custCodeBlk)
231
- custFields={'type', 'unit', 'description', 'max', 'min', 'lsb', ...
232
- 'offset', 'class'};
233
- parTypes = {'state', 'work', 'param', 'input', 'output'};
234
- structName = {'local_vars', 'local_vars', 'calib_consts', 'local_vars', 'local_vars'};
235
- numTypes = cellfun(@(x) tl_get(custCodeBlk, ['num' x 's']), parTypes, 'uni', false);
236
- for pti = 1:length(parTypes)
237
- pType = parTypes{pti};
238
- for idx=1:numTypes{pti}
239
- class = tl_get(custCodeBlk, [pType '(' num2str(idx) ').class']);
240
- if ~ismember(class, {'default', 'STATIC_LOCAL_MACRO'})
241
- name = tl_get(custCodeBlk, [pType '(' num2str(idx) ').name']);
242
- if ~ismember(pType, {'output'}) && ~isempty(regexp(name, '\$L', 'once'))
243
- error('Can not use $L macro in non output parameters')
244
- end
245
- if ~isempty(regexp(name, '\$S', 'once'))
246
- error('Can not use $S macro in name.')
247
- end
248
- varName = getSignalName(system, custCodeBlk, name, idx);
249
- for fldidx = 1:length(custFields)
250
- fld = custFields{fldidx};
251
- value = val2str(tl_get(custCodeBlk, [ pType '(' num2str(idx) ').' fld ]));
252
- if strcmp(value, 'IMPLICIT_ENUM')
253
- allVariables.(structName{pti}).(varName).(fld) = getEnumName(custCodeBlk);
254
- else
255
- allVariables.(structName{pti}).(varName).(fld) = value;
256
- end
257
- end
258
- if strcmp(pType, 'param')
259
- inputValue=evalin('base', tl_get(custCodeBlk, [pType '(' num2str(idx) ').value']));
260
- varSize=size(inputValue);
261
- allVariables.(structName{pti}).(varName).width = varSize;
262
- else
263
- %TODO: Check width parameter?
264
- allVariables.(structName{pti}).(varName).width = 1;
265
- end
266
- allVariables.(structName{pti}).(varName) = modifyEnumStructField(allVariables.(structName{pti}).(varName));
267
- allVariables.(structName{pti}).(varName).handle = getPath(custCodeBlk);
268
- allVariables.(structName{pti}).(varName).configs = getCodeSwitches(custCodeBlk);
269
- end
270
- end
271
- end
272
- end
273
-
274
- function allVariables = copyFields(system, allVariables, sFlow, sfHandle, configs, outPortNbr)
275
-
276
- sfFields={'type', 'unit', 'description', 'max', 'min', 'lsb', ...
277
- 'offset', 'class'};
278
-
279
- variableName = getSfSignalName(system, sFlow, sfHandle, outPortNbr);
280
- allVariables.local_vars.(variableName).configs = configs;
281
-
282
- for j=1:length(sfFields)
283
- fieldName = sfFields{j};
284
- value = tl_get(sfHandle, fieldName);
285
- if strcmp(value, 'IMPLICIT_ENUM')
286
- value = getEnumName(sfHandle);
287
- end
288
- allVariables.local_vars.(variableName).(fieldName) = checkValue(value);
289
- end
290
-
291
- allVariables.local_vars.(variableName) = modifyEnumStructField(allVariables.local_vars.(variableName));
292
- end
293
-
294
- function value = val2str(val_in)
295
- if ~ischar(val_in)
296
- if isnan(val_in)
297
- value = '-';
298
- elseif isempty(val_in)
299
- value = '-';
300
- else
301
- value = num2str(val_in);
302
- end
303
- else
304
- value=val_in;
305
- end
306
- end
307
-
308
- function newStr = stripIllegalChar(value)
309
- % replace all non word characters with space
310
- newStr = regexprep(value, '(?![\w/]).', ' ');
311
- end
312
-
313
- function newVal = checkValue(value)
314
- if ischar(value)
315
- newVal=strtrim(value);
316
- elseif isnan(value)
317
- newVal='-';
318
- elseif length(value) > 1
319
- newVal = {};
320
- for i=1:length(value)
321
- newVal{i} = checkValue(value(i));
322
- end
323
- else
324
- newVal=value;
325
- end
326
- end
327
-
328
- function nok = checkClass(tlClass, sFlow, sfData)
329
- if regexp(tlClass, '(?:default|CVC_DISP_NVM)')
330
- nok = 1;
331
- return % do nothing, NVM is handled elsewhere
332
- end
333
- if isempty(strfind(tlClass, 'CVC_DISP'))
334
- if isnan(sfData.port)
335
- port = '';
336
- else
337
- port = [':' num2str(sfData.port)];
338
- end
339
- o = sprintf('Warning - <a href = "matlab:Hilite_This_System(''%s'')">unknown class %s in %s - %s (%s%s)</a>', ...
340
- getPath(sFlow), tlClass, get_param(sFlow, 'name'), sfData.name, sfData.scope, port);
341
- disp(o)
342
- nok = 0;
343
- return
344
- end
345
- nok = 0;
346
- end
347
-
348
- function name = getSfSignalName(systemIn, block, sfHandle, outPortNbr)
349
- % function to get the name of a in/out-port of a block.
350
- macro = tl_get(sfHandle, 'name');
351
- system = getTLModelName(systemIn);
352
- nameTmp = macro;
353
- res = regexp(macro, '\$O', 'tokens');
354
- if ~isempty(res)
355
- tmp_SFObj = get_param(block, 'Object');
356
- chartObj = tmp_SFObj.find('-isa', 'Stateflow.Chart');
357
- sfData = chartObj.find('-isa', 'Stateflow.Data');
358
- idArr = arrayfun(@(x) x.Id, sfData);
359
- idx = idArr == sfHandle;
360
- nameTmp = regexprep(nameTmp,'\$O', sfData(idx).name);
361
- end
362
- res = regexp(macro, '\$L', 'tokens');
363
- if ~isempty(res)
364
- slPortHandles = get_param(block, 'PortHandles');
365
- ph = slPortHandles.Outport(outPortNbr);
366
- signal = get_param(get_param(ph, 'line'), 'name');
367
- if isempty(signal)
368
- %TODO: Consider removing the turning on of the propagated
369
- % signals
370
- if strcmp(get_param(ph, 'ShowPropagatedSignals'), 'off')
371
- set_param(ph, 'ShowPropagatedSignals', 'on')
372
- end
373
- signal = get_param(ph, 'PropagatedSignals');
374
- if isempty(signal)
375
- error('signal') % fix warning
376
- end
377
- end
378
- nameTmp = regexprep(nameTmp,'\$L', signal);
379
- end
380
- nameTmp = regexprep(nameTmp,'\$B', get_param(block, 'Name'));
381
- nameTmp = regexprep(nameTmp,'\$N', system);
382
- name = regexprep(nameTmp,' ', '');
383
- end
384
-
385
- function name = getSignalName(systemIn, block, macro, outPortNbr)
386
- % function to get the name of a in/out-port of a block.
387
- res = regexp(macro, '(\$L)', 'tokens');
388
- system = regexprep(systemIn,'(\w+?)(__.*){0,1}','$1');
389
- nameTmp = macro;
390
- if ~isempty(res)
391
- slPortHandles = get_param(block, 'PortHandles');
392
- ph = slPortHandles.Outport(outPortNbr);
393
- signal = get_param(get_param(ph, 'line'), 'name');
394
- if isempty(signal)
395
- %TODO: Consider removing the turning on of the propagated
396
- % signals
397
- if strcmp(get_param(ph, 'ShowPropagatedSignals'), 'off')
398
- set_param(ph, 'ShowPropagatedSignals', 'on')
399
- end
400
- signal = get_param(ph, 'PropagatedSignals');
401
- if isempty(signal)
402
- error('signal') % fix warning
403
- end
404
- end
405
- nameTmp = regexprep(nameTmp,'\$L', signal);
406
- end
407
- nameTmp = regexprep(nameTmp,'\$B', get_param(block, 'Name'));
408
- nameTmp = regexprep(nameTmp,'\$N', system);
409
- name = regexprep(nameTmp,' ', '');
410
- end
1
+ % Copyright 2024 Volvo Car Corporation
2
+ % Licensed under Apache 2.0.
3
+
4
+ function [ allVariables ] = parseCalMeasData( system )
5
+ % parseCalMeasData Parse calibration measurement data
6
+ %
7
+ % See also parseModelInfo
8
+
9
+ allVariables=struct;
10
+ evalin('base', [system '_par']);
11
+ allVariables.local_vars=struct;
12
+ allVariables.calib_consts=struct;
13
+
14
+ tmp=sortSystemByClass(system);
15
+
16
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
17
+ % Measurable variables
18
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
19
+ blocksTmp=tmp.CVC_DISP;
20
+ % find all TL_Outports (should not be included in measurement variables
21
+ % as they should be included in the outports key
22
+ outports = find_system(topLevelSystem(system), 'FindAll', 'on', ...
23
+ 'LookUnderMasks', 'all', 'MaskType', 'TL_Outport');
24
+ blocks = setdiff(blocksTmp, outports);
25
+ allVariables = Create_Standard_Struct(system, allVariables, blocks, 'local_vars', 'output');
26
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
27
+
28
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
29
+ % Cal variables
30
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31
+ blocks=tmp.CVC_CAL;
32
+ allVariables = Create_Standard_Struct(system, allVariables, blocks, 'calib_consts', 'output');
33
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
34
+
35
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
36
+ % Prelookups
37
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38
+ blocks=find_system(get_param(system,'handle'), 'lookundermasks', 'on', 'masktype', 'TL_IndexSearch');
39
+ allVariables = Create_Standard_Struct(system, allVariables, blocks, 'calib_consts', 'input');
40
+
41
+ blocks=find_system(get_param(system,'handle'), 'lookundermasks', 'on', 'masktype', 'TL_PreLookup');
42
+ allVariables = Create_Standard_Struct(system, allVariables, blocks, 'calib_consts', 'input');
43
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
44
+
45
+
46
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
47
+ % Lookups
48
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
49
+ blocks=find_system(get_param(system,'handle'), 'lookundermasks', 'on', 'regexp', 'on', 'masktype', 'TL_Interpolation.*');
50
+ allVariables = Create_Standard_Struct(system, allVariables, blocks, 'calib_consts', 'table');
51
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
52
+
53
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
54
+ % Stateflow
55
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
56
+ stateflow=find_system(get_param(system, 'handle'), 'FindAll', 'on', ...
57
+ 'lookundermasks', 'on', 'masktype', 'Stateflow');
58
+ for i=1:length(stateflow)
59
+ allVariables = Create_Struct_SFlow(system, allVariables, stateflow(i));
60
+ end
61
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
62
+
63
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
64
+ % CustomCode blocks
65
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
66
+ customCode=find_system(get_param(system, 'handle'), 'FindAll', 'on', ...
67
+ 'lookundermasks', 'on', 'masktype', 'TL_CustomCode');
68
+ for i=1:length(customCode)
69
+ allVariables = createStructCustCode(system, allVariables, customCode(i));
70
+ end
71
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
72
+
73
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
74
+ % TCM specific blocks
75
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
76
+
77
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
78
+ % Lookup1D
79
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
80
+ blocks = find_system(get_param(system, 'handle'), 'lookundermasks', 'on', ...
81
+ 'masktype','TL_Lookup1D');
82
+ allVariables = Create_Standard_Struct(system, allVariables, blocks, 'calib_consts', 'input');
83
+ allVariables = Create_Standard_Struct(system, allVariables, blocks, 'calib_consts', 'table');
84
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
85
+
86
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
87
+ % Lookup2D
88
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
89
+ blocks = find_system(get_param(system,'handle'),'lookundermasks','on','masktype','TL_Lookup2D');
90
+ allVariables = Create_Standard_Struct(system, allVariables, blocks, 'calib_consts', 'row');
91
+ allVariables = Create_Standard_Struct(system, allVariables, blocks, 'calib_consts', 'col');
92
+ allVariables = Create_Standard_Struct(system, allVariables, blocks, 'calib_consts', 'table');
93
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
94
+ end
95
+
96
+ function allVariables = Create_Standard_Struct(systemIn, allVariables, ...
97
+ blocks, structName, field)
98
+
99
+ if ~isempty(blocks)
100
+ TLFields={'type', 'unit', 'description', 'max', 'min', 'lsb', ...
101
+ 'offset', 'class'};
102
+ system = regexprep(systemIn,'(\w+?)(__.*){0,1}','$1');
103
+ for block = blocks'
104
+ class=tl_getfast(block, [field '.class']);
105
+ if ~isempty(class) && ~strcmp(class, 'default')
106
+ name=tl_getfast(block, [field '.name']);
107
+ res = regexp(name, '(\$[SD])', 'match', 'once');
108
+ if ~isempty(res)
109
+ o = sprintf('Warning %s in block <a href = "matlab:Hilite_This_System(''%s'')">%s</a>', ...
110
+ res, getPath(block), getName(block));
111
+ disp(o)
112
+ %hilite_system(block)
113
+ else
114
+ variableName=Get_Full_Name(block, name, system);
115
+ if sum(isstrprop(variableName, 'wspace')) > 0
116
+ o = sprintf('Illegal characters in the name property in block <a href = "matlab:Hilite_This_System(''%s'')">%s</a>', ...
117
+ getPath(block), getName(block));
118
+ disp(o)
119
+ error('aborting')
120
+ end
121
+ %VariableName = VariableName(isstrprop(VariableName, 'wspace') == 0);
122
+ if ~isempty(variableName)
123
+ for tlField = TLFields
124
+ tmp_tlField = tlField{1};
125
+ if ismember(get_param(block, 'masktype'), ...
126
+ {'TL_RelationalOperator', 'TL_LogicalOperator'}) && ...
127
+ ismember(tmp_tlField , {'max', 'min', 'lsb', 'offset'})
128
+ allVariables.(structName).(variableName).(tmp_tlField) = '-';
129
+ elseif ismember(get_param(block, 'masktype'), {'TL_BitwiseOperator'}) ...
130
+ && ismember(tmp_tlField , {'max', 'min', 'lsb', 'offset', 'unit'})
131
+ allVariables.(structName).(variableName).(tmp_tlField) = '-';
132
+ else
133
+ Value=tl_getfast(block, [field '.' tmp_tlField]);
134
+ if iscell(Value)
135
+ Value = Value{1};
136
+ end
137
+ if strcmp(Value, 'IMPLICIT_ENUM')
138
+ Value = getEnumName(block);
139
+ end
140
+ allVariables.(structName).(variableName).(tmp_tlField) = checkValue(Value);
141
+ end
142
+ end
143
+ allVariables.(structName).(variableName).handle = getPath(block);
144
+ consumerBlks = getConsumerBlocks(block);
145
+ if isempty(consumerBlks)
146
+ allVariables.(structName).(variableName).configs = getCodeSwitches(block);
147
+ else
148
+ codeSwTmp = {};
149
+ for j=1:length(consumerBlks)
150
+ consBlk = consumerBlks(j);
151
+ codeSwTmp{j} = getCodeSwitches(consBlk);
152
+ end
153
+ allVariables.(structName).(variableName).configs = removeConfigDuplicates(codeSwTmp);
154
+ end
155
+ if ismember(get_param(block, 'masktype'), {'TL_IndexSearch', 'TL_Interpolation', 'TL_Lookup1D', 'TL_Lookup2D'}) ...
156
+ && ~strcmp(field,'output')
157
+ [inputValueRef, errorFlag, ~] = tl_get(block, [field '.value']);
158
+ if errorFlag > 0
159
+ inputValueRef = tl_getfast(block, [field '.value']);
160
+ end
161
+ InputValue=evalin('base', inputValueRef);
162
+ VarSize=size(InputValue);
163
+ allVariables.(structName).(variableName).width = VarSize;
164
+ elseif strcmp(get_param(block, 'masktype'), 'TL_Constant') && strcmp(field,'output')
165
+ ConstantValue=evalin('base', tl_getfast(block, [field '.value']));
166
+ VarSize=size(ConstantValue);
167
+ if VarSize(2) == 1
168
+ allVariables.(structName).(variableName).width = 1;
169
+ else
170
+ allVariables.(structName).(variableName).width = VarSize;
171
+ end
172
+ elseif strcmp(get_param(block, 'masktype'), 'TL_IndexSearch') && strcmp(field, 'output')
173
+ if tl_getfast(block, 'outputmode') == 2
174
+ VarSize = [1,2];
175
+ else
176
+ VarSize = 1;
177
+ end
178
+ allVariables.(structName).(variableName).width = VarSize;
179
+ else
180
+ allVariables.(structName).(variableName).width = 1;
181
+ end
182
+ allVariables.(structName).(variableName) = modifyEnumStructField(allVariables.(structName).(variableName));
183
+ if length(variableName) > 63
184
+ % Can't store the full name as a struct key as matlab only supports key lengths < 64
185
+ o = sprintf('Warning variable name %s is longer than 63 chars, consider shortening it.', variableName);
186
+ disp(o)
187
+ allVariables.(structName).(variableName).unshortenedName = variableName;
188
+ end
189
+ end
190
+ end
191
+ end
192
+ end
193
+ end
194
+ end
195
+
196
+ function allVariables = Create_Struct_SFlow(system, allVariables, sFlow)
197
+ configs = getCodeSwitches(sFlow);
198
+ % Handle stateflow outports
199
+ tmp_SFObj = get_param(sFlow, 'Object');
200
+ chartObj = tmp_SFObj.find('-isa', 'Stateflow.Chart');
201
+ sfDataArr = chartObj.find('-isa', 'Stateflow.Data');
202
+ idArr = arrayfun(@(x) x.Id, sfDataArr);
203
+ sfHandles = tl_get_sfobjects(sFlow, {'SF Output', 'SF Local'});
204
+ for i=1:length(sfHandles)
205
+ SfHandle = sfHandles(i);
206
+ idx = idArr == SfHandle;
207
+ sfData = sfDataArr(idx);
208
+ tlClass = tl_get(SfHandle, 'class');
209
+ if checkClass(tlClass, sFlow, sfData)
210
+ continue % do nothing, if NVM, default class, or name error. NVM is handled elsewhere
211
+ end
212
+ tlName = tl_get(SfHandle, 'name');
213
+ res = regexp(tlName, '(\$[SDCB])', 'tokens');
214
+ if isempty(res)
215
+ allVariables = copyFields(system, allVariables, sFlow, SfHandle, configs, sfData.port);
216
+ else
217
+ err_msg = res{1}{1};
218
+ if isnan(sfData.port)
219
+ port = '';
220
+ else
221
+ port = [':' num2str(sfData.port)];
222
+ end
223
+ o = sprintf('Warning %s in <a href = "matlab:Hilite_This_System(''%s'')">%s - %s (%s%s)</a>', ...
224
+ err_msg, getPath(sFlow), get_param(sFlow, 'name'), sfData.name, sfData.scope, port);
225
+ disp(o)
226
+ end
227
+ end
228
+ end
229
+
230
+ function allVariables = createStructCustCode(system, allVariables, custCodeBlk)
231
+ custFields={'type', 'unit', 'description', 'max', 'min', 'lsb', ...
232
+ 'offset', 'class'};
233
+ parTypes = {'state', 'work', 'param', 'input', 'output'};
234
+ structName = {'local_vars', 'local_vars', 'calib_consts', 'local_vars', 'local_vars'};
235
+ numTypes = cellfun(@(x) tl_get(custCodeBlk, ['num' x 's']), parTypes, 'uni', false);
236
+ for pti = 1:length(parTypes)
237
+ pType = parTypes{pti};
238
+ for idx=1:numTypes{pti}
239
+ class = tl_get(custCodeBlk, [pType '(' num2str(idx) ').class']);
240
+ if ~ismember(class, {'default', 'STATIC_LOCAL_MACRO'})
241
+ name = tl_get(custCodeBlk, [pType '(' num2str(idx) ').name']);
242
+ if ~ismember(pType, {'output'}) && ~isempty(regexp(name, '\$L', 'once'))
243
+ error('Can not use $L macro in non output parameters')
244
+ end
245
+ if ~isempty(regexp(name, '\$S', 'once'))
246
+ error('Can not use $S macro in name.')
247
+ end
248
+ varName = getSignalName(system, custCodeBlk, name, idx);
249
+ for fldidx = 1:length(custFields)
250
+ fld = custFields{fldidx};
251
+ value = val2str(tl_get(custCodeBlk, [ pType '(' num2str(idx) ').' fld ]));
252
+ if strcmp(value, 'IMPLICIT_ENUM')
253
+ allVariables.(structName{pti}).(varName).(fld) = getEnumName(custCodeBlk);
254
+ else
255
+ allVariables.(structName{pti}).(varName).(fld) = value;
256
+ end
257
+ end
258
+ if strcmp(pType, 'param')
259
+ inputValue=evalin('base', tl_get(custCodeBlk, [pType '(' num2str(idx) ').value']));
260
+ varSize=size(inputValue);
261
+ allVariables.(structName{pti}).(varName).width = varSize;
262
+ else
263
+ %TODO: Check width parameter?
264
+ allVariables.(structName{pti}).(varName).width = 1;
265
+ end
266
+ allVariables.(structName{pti}).(varName) = modifyEnumStructField(allVariables.(structName{pti}).(varName));
267
+ allVariables.(structName{pti}).(varName).handle = getPath(custCodeBlk);
268
+ allVariables.(structName{pti}).(varName).configs = getCodeSwitches(custCodeBlk);
269
+ end
270
+ end
271
+ end
272
+ end
273
+
274
+ function allVariables = copyFields(system, allVariables, sFlow, sfHandle, configs, outPortNbr)
275
+
276
+ sfFields={'type', 'unit', 'description', 'max', 'min', 'lsb', ...
277
+ 'offset', 'class'};
278
+
279
+ variableName = getSfSignalName(system, sFlow, sfHandle, outPortNbr);
280
+ allVariables.local_vars.(variableName).configs = configs;
281
+
282
+ for j=1:length(sfFields)
283
+ fieldName = sfFields{j};
284
+ value = tl_get(sfHandle, fieldName);
285
+ if strcmp(value, 'IMPLICIT_ENUM')
286
+ value = getEnumName(sfHandle);
287
+ end
288
+ allVariables.local_vars.(variableName).(fieldName) = checkValue(value);
289
+ end
290
+
291
+ allVariables.local_vars.(variableName) = modifyEnumStructField(allVariables.local_vars.(variableName));
292
+ end
293
+
294
+ function value = val2str(val_in)
295
+ if ~ischar(val_in)
296
+ if isnan(val_in)
297
+ value = '-';
298
+ elseif isempty(val_in)
299
+ value = '-';
300
+ else
301
+ value = num2str(val_in);
302
+ end
303
+ else
304
+ value=val_in;
305
+ end
306
+ end
307
+
308
+ function newStr = stripIllegalChar(value)
309
+ % replace all non word characters with space
310
+ newStr = regexprep(value, '(?![\w/]).', ' ');
311
+ end
312
+
313
+ function newVal = checkValue(value)
314
+ if ischar(value)
315
+ newVal=strtrim(value);
316
+ elseif isnan(value)
317
+ newVal='-';
318
+ elseif length(value) > 1
319
+ newVal = {};
320
+ for i=1:length(value)
321
+ newVal{i} = checkValue(value(i));
322
+ end
323
+ else
324
+ newVal=value;
325
+ end
326
+ end
327
+
328
+ function nok = checkClass(tlClass, sFlow, sfData)
329
+ if regexp(tlClass, '(?:default|CVC_DISP_NVM)')
330
+ nok = 1;
331
+ return % do nothing, NVM is handled elsewhere
332
+ end
333
+ if isempty(strfind(tlClass, 'CVC_DISP'))
334
+ if isnan(sfData.port)
335
+ port = '';
336
+ else
337
+ port = [':' num2str(sfData.port)];
338
+ end
339
+ o = sprintf('Warning - <a href = "matlab:Hilite_This_System(''%s'')">unknown class %s in %s - %s (%s%s)</a>', ...
340
+ getPath(sFlow), tlClass, get_param(sFlow, 'name'), sfData.name, sfData.scope, port);
341
+ disp(o)
342
+ nok = 0;
343
+ return
344
+ end
345
+ nok = 0;
346
+ end
347
+
348
+ function name = getSfSignalName(systemIn, block, sfHandle, outPortNbr)
349
+ % function to get the name of a in/out-port of a block.
350
+ macro = tl_get(sfHandle, 'name');
351
+ system = getTLModelName(systemIn);
352
+ nameTmp = macro;
353
+ res = regexp(macro, '\$O', 'tokens');
354
+ if ~isempty(res)
355
+ tmp_SFObj = get_param(block, 'Object');
356
+ chartObj = tmp_SFObj.find('-isa', 'Stateflow.Chart');
357
+ sfData = chartObj.find('-isa', 'Stateflow.Data');
358
+ idArr = arrayfun(@(x) x.Id, sfData);
359
+ idx = idArr == sfHandle;
360
+ nameTmp = regexprep(nameTmp,'\$O', sfData(idx).name);
361
+ end
362
+ res = regexp(macro, '\$L', 'tokens');
363
+ if ~isempty(res)
364
+ slPortHandles = get_param(block, 'PortHandles');
365
+ ph = slPortHandles.Outport(outPortNbr);
366
+ signal = get_param(get_param(ph, 'line'), 'name');
367
+ if isempty(signal)
368
+ %TODO: Consider removing the turning on of the propagated
369
+ % signals
370
+ if strcmp(get_param(ph, 'ShowPropagatedSignals'), 'off')
371
+ set_param(ph, 'ShowPropagatedSignals', 'on')
372
+ end
373
+ signal = get_param(ph, 'PropagatedSignals');
374
+ if isempty(signal)
375
+ error('signal') % fix warning
376
+ end
377
+ end
378
+ nameTmp = regexprep(nameTmp,'\$L', signal);
379
+ end
380
+ nameTmp = regexprep(nameTmp,'\$B', get_param(block, 'Name'));
381
+ nameTmp = regexprep(nameTmp,'\$N', system);
382
+ name = regexprep(nameTmp,' ', '');
383
+ end
384
+
385
+ function name = getSignalName(systemIn, block, macro, outPortNbr)
386
+ % function to get the name of a in/out-port of a block.
387
+ res = regexp(macro, '(\$L)', 'tokens');
388
+ system = regexprep(systemIn,'(\w+?)(__.*){0,1}','$1');
389
+ nameTmp = macro;
390
+ if ~isempty(res)
391
+ slPortHandles = get_param(block, 'PortHandles');
392
+ ph = slPortHandles.Outport(outPortNbr);
393
+ signal = get_param(get_param(ph, 'line'), 'name');
394
+ if isempty(signal)
395
+ %TODO: Consider removing the turning on of the propagated
396
+ % signals
397
+ if strcmp(get_param(ph, 'ShowPropagatedSignals'), 'off')
398
+ set_param(ph, 'ShowPropagatedSignals', 'on')
399
+ end
400
+ signal = get_param(ph, 'PropagatedSignals');
401
+ if isempty(signal)
402
+ error('signal') % fix warning
403
+ end
404
+ end
405
+ nameTmp = regexprep(nameTmp,'\$L', signal);
406
+ end
407
+ nameTmp = regexprep(nameTmp,'\$B', get_param(block, 'Name'));
408
+ nameTmp = regexprep(nameTmp,'\$N', system);
409
+ name = regexprep(nameTmp,' ', '');
410
+ end