Linux GNU 11.4.0 Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 71.3% 749 / 0 / 1051
Functions: -% 0 / 1 / 1
Branches: 62.2% 102 / 0 / 164

build_cmake/OMCompiler/Compiler/generated-mo/Template/CodegenFMU3.mo
Line Branch Exec Source
1 encapsulated package CodegenFMU3
2 "
3 file: CodegenFMU3.mo
4 package: CodegenFMU3
5 description: Generated by Susan.
6 "
7
8 public import Tpl;
9
10 public import SimCodeVar;
11 public import HashTableCrefSimVar;
12 public import SimCode;
13 public import SimCodeFunction;
14 public import SimCodeCodegenUtil;
15 public import SimCodeFunctionUtil;
16 public import BackendDAE;
17 public import System;
18 public import Autoconf;
19 protected import Absyn;
20 protected import AbsynUtil;
21 public import MMath;
22 public import DAE;
23 public import ClassInf;
24 public import ClassInfUtil;
25 protected import SCode;
26 protected import SCodeDump;
27 public import StringUtil;
28 public import Util;
29 public import List;
30 public import ComponentReferenceBasics;
31 public import ComponentReference;
32 public import Expression;
33 protected import ExpressionDump;
34 public import ExpressionBasics;
35 public import Config;
36 public import Testsuite;
37 public import Flags;
38 public import FlagsUtil;
39 public import Settings;
40 public import Patternm;
41 public import Error;
42 public import Values;
43 public import ValuesUtil;
44 public import DAEDump;
45 public import Algorithm;
46 protected import ElementSource;
47 public import DAEUtil;
48 public import TypesDump;
49 public import Types;
50 public import HashTableCrIListArray;
51 public import BackendVariable;
52 public import HpcOmSimCode;
53 public import HpcOmCodegenUtil;
54 public import FMI;
55 public import CodegenUtil;
56 public import CodegenUtilSimulation;
57 public import CodegenC;
58 public import CodegenFMUCommon;
59
60 protected function fun_51
61 input Tpl.Text in_txt;
62 input Boolean in_mArg;
63 input list<String> in_a_sourceFiles;
64 input SimCode.SimCode in_a_simCode;
65
66 output Tpl.Text out_txt;
67 algorithm
68 out_txt :=
69 match(in_txt, in_mArg, in_a_sourceFiles, in_a_simCode)
70 local
71 Tpl.Text txt;
72 list<String> a_sourceFiles;
73 SimCode.SimCode a_simCode;
74
75 case ( txt,
76 false,
77 _,
78 _ )
79 then txt;
80
81 case ( txt,
82 _,
83 a_sourceFiles,
84 a_simCode )
85 algorithm
86 14 txt := ModelExchange3(txt, a_simCode, a_sourceFiles);
87 then txt;
88 end match;
89 end fun_51;
90
91 protected function fun_52
92 input Tpl.Text in_txt;
93 input Boolean in_mArg;
94 input list<String> in_a_sourceFiles;
95 input SimCode.SimCode in_a_simCode;
96
97 output Tpl.Text out_txt;
98 algorithm
99 out_txt :=
100 match(in_txt, in_mArg, in_a_sourceFiles, in_a_simCode)
101 local
102 Tpl.Text txt;
103 list<String> a_sourceFiles;
104 SimCode.SimCode a_simCode;
105
106 case ( txt,
107 false,
108 _,
109 _ )
110 then txt;
111
112 case ( txt,
113 _,
114 a_sourceFiles,
115 a_simCode )
116 algorithm
117 2 txt := CoSimulation3(txt, a_simCode, a_sourceFiles);
118 then txt;
119 end match;
120 end fun_52;
121
122 protected function fun_53
123 input Tpl.Text in_txt;
124 input Boolean in_mArg;
125 input list<String> in_a_sourceFiles;
126 input SimCode.SimCode in_a_simCode;
127
128 output Tpl.Text out_txt;
129 algorithm
130 out_txt :=
131 match(in_txt, in_mArg, in_a_sourceFiles, in_a_simCode)
132 local
133 Tpl.Text txt;
134 list<String> a_sourceFiles;
135 SimCode.SimCode a_simCode;
136
137 case ( txt,
138 false,
139 _,
140 _ )
141 then txt;
142
143 case ( txt,
144 _,
145 a_sourceFiles,
146 a_simCode )
147 algorithm
148 ✗ txt := ScheduledExecution3(txt, a_simCode, a_sourceFiles);
149 then txt;
150 end match;
151 end fun_53;
152
153 protected function fun_54
154 input Tpl.Text in_txt;
155 input Boolean in_mArg;
156
157 output Tpl.Text out_txt;
158 algorithm
159 out_txt :=
160 match(in_txt, in_mArg)
161 local
162 Tpl.Text txt;
163
164 case ( txt,
165 false )
166 algorithm
167 16 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
168 "<LogCategories>\n",
169 " <Category name=\"logEvents\" />\n",
170 " <Category name=\"logSingularLinearSystems\" />\n",
171 " <Category name=\"logNonlinearSystems\" />\n",
172 " <Category name=\"logDynamicStateSelection\" />\n",
173 " <Category name=\"logStatusWarning\" />\n",
174 " <Category name=\"logStatusDiscard\" />\n",
175 " <Category name=\"logStatusError\" />\n",
176 " <Category name=\"logStatusFatal\" />\n",
177 " <Category name=\"logStatusPending\" />\n",
178 " <Category name=\"logAll\" />\n",
179 " <Category name=\"logFmi3Call\" />\n",
180 "</LogCategories>"
181 }, false));
182 then txt;
183
184 case ( txt,
185 _ )
186 algorithm
187 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
188 "<LogCategories>\n",
189 " <Category name=\"logEvents\" description=\"logEvents\" />\n",
190 " <Category name=\"logSingularLinearSystems\" description=\"logSingularLinearSystems\" />\n",
191 " <Category name=\"logNonlinearSystems\" description=\"logNonlinearSystems\" />\n",
192 " <Category name=\"logDynamicStateSelection\" description=\"logDynamicStateSelection\" />\n",
193 " <Category name=\"logStatusWarning\" description=\"logStatusWarning\" />\n",
194 " <Category name=\"logStatusDiscard\" description=\"logStatusDiscard\" />\n",
195 " <Category name=\"logStatusError\" description=\"logStatusError\" />\n",
196 " <Category name=\"logStatusFatal\" description=\"logStatusFatal\" />\n",
197 " <Category name=\"logStatusPending\" description=\"logStatusPending\" />\n",
198 " <Category name=\"logAll\" description=\"logAll\" />\n",
199 " <Category name=\"logFmi3Call\" description=\"logFmi3Call\" />\n",
200 "</LogCategories>"
201 }, false));
202 then txt;
203 end match;
204 end fun_54;
205
206 public function fmiModelDescription
207 input Tpl.Text in_txt;
208 input SimCode.SimCode in_a_simCode;
209 input String in_a_guid;
210 input String in_a_FMUType;
211 input list<String> in_a_sourceFiles;
212
213 output Tpl.Text out_txt;
214 algorithm
215 out_txt :=
216 match(in_txt, in_a_simCode, in_a_guid, in_a_FMUType, in_a_sourceFiles)
217 local
218 Tpl.Text txt;
219 String a_guid;
220 String a_FMUType;
221 list<String> a_sourceFiles;
222 Option<SimCode.SimulationSettings> i_simulationSettingsOpt;
223 SimCode.SimCode i_simCode;
224 Boolean ret_3;
225 Boolean ret_2;
226 Boolean ret_1;
227 Boolean ret_0;
228
229 case ( txt,
230 (i_simCode as SimCode.SIMCODE(simulationSettingsOpt = i_simulationSettingsOpt)),
231 a_guid,
232 a_FMUType,
233 a_sourceFiles )
234 algorithm
235 16 txt := Tpl.writeTok(txt, Tpl.ST_LINE("<fmiModelDescription\n"));
236 16 txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
237 16 txt := fmiModelDescriptionAttributes(txt, i_simCode, a_guid);
238 16 txt := Tpl.writeTok(txt, Tpl.ST_LINE(">\n"));
239 16 ret_0 := FMI.isFMIMEType(a_FMUType);
240 16 txt := fun_51(txt, ret_0, a_sourceFiles, i_simCode);
241 16 txt := Tpl.softNewLine(txt);
242 16 ret_1 := FMI.isFMICSType(a_FMUType);
243 16 txt := fun_52(txt, ret_1, a_sourceFiles, i_simCode);
244 16 txt := Tpl.softNewLine(txt);
245 16 ret_2 := FMI.isFMISEType(a_FMUType);
246 16 txt := fun_53(txt, ret_2, a_sourceFiles, i_simCode);
247 16 txt := Tpl.softNewLine(txt);
248 16 txt := CodegenFMUCommon.UnitDefinitions(txt, i_simCode);
249 16 txt := Tpl.softNewLine(txt);
250 16 txt := TypeDefinitions3(txt, i_simCode);
251 16 txt := Tpl.softNewLine(txt);
252 16 ret_3 := Flags.isSet(Flags.FMU_EXPERIMENTAL);
253 16 txt := fun_54(txt, ret_3);
254 16 txt := Tpl.softNewLine(txt);
255 16 txt := DefaultExperiment3(txt, i_simulationSettingsOpt);
256 16 txt := Tpl.softNewLine(txt);
257 16 txt := fmiModelVariablesAndStructure3(txt, i_simCode, a_FMUType);
258 16 txt := Tpl.softNewLine(txt);
259 16 txt := fmiOpenModelicaAnnotations(txt, i_simCode);
260 16 txt := Tpl.softNewLine(txt);
261 16 txt := Tpl.popBlock(txt);
262 16 txt := Tpl.writeTok(txt, Tpl.ST_STRING("</fmiModelDescription>"));
263 then txt;
264
265 case ( txt,
266 _,
267 _,
268 _,
269 _ )
270 then txt;
271 end match;
272 end fmiModelDescription;
273
274 protected function fun_56
275 input Tpl.Text in_txt;
276 input SimCode.SimCode in_mArg;
277 input String in_a_FMUType;
278
279 output Tpl.Text out_txt;
280 algorithm
281 out_txt :=
282 match(in_txt, in_mArg, in_a_FMUType)
283 local
284 Tpl.Text txt;
285 String a_FMUType;
286 Option<SimCode.FmiModelStructure> i_viewStructure;
287 SimCode.SimCode i_view;
288 String ret_3;
289 Tpl.Text l_0__;
290 Tpl.Text l_structure;
291 Tpl.Text l_variables;
292
293 case ( txt,
294 (i_view as SimCode.SIMCODE(modelStructure = i_viewStructure)),
295 a_FMUType )
296 algorithm
297 16 l_variables := fmiModelVariables3(Tpl.emptyTxt, i_view, a_FMUType);
298 16 l_structure := modelStructure3(Tpl.emptyTxt, i_view, i_viewStructure);
299 16 ret_3 := SimCodeCodegenUtil.clearFMI3VariableAliases();
300 16 l_0__ := Tpl.writeStr(Tpl.emptyTxt, ret_3);
301 16 txt := Tpl.writeText(txt, l_variables);
302 16 txt := Tpl.softNewLine(txt);
303 16 txt := Tpl.writeText(txt, l_structure);
304 then txt;
305
306 case ( txt,
307 _,
308 _ )
309 then txt;
310 end match;
311 end fun_56;
312
313 public function fmiModelVariablesAndStructure3
314 input Tpl.Text txt;
315 input SimCode.SimCode a_simCode;
316 input String a_FMUType;
317
318 output Tpl.Text out_txt;
319 protected
320 SimCode.SimCode ret_2;
321 String ret_1;
322 Tpl.Text l_0__;
323 algorithm
324 16 ret_1 := SimCodeCodegenUtil.cacheFMI3VariableAliases(a_simCode);
325 16 l_0__ := Tpl.writeStr(Tpl.emptyTxt, ret_1);
326 16 ret_2 := SimCodeCodegenUtil.fmi3ArrayView(a_simCode);
327 16 out_txt := fun_56(txt, ret_2, a_FMUType);
328 end fmiModelVariablesAndStructure3;
329
330 protected function fun_58
331 input Tpl.Text in_txt;
332 input Boolean in_mArg;
333 input Tpl.Text in_a_visualization;
334 input Tpl.Text in_a_figures;
335
336 output Tpl.Text out_txt;
337 algorithm
338 out_txt :=
339 match(in_txt, in_mArg, in_a_visualization, in_a_figures)
340 local
341 Tpl.Text txt;
342 Tpl.Text a_visualization;
343 Tpl.Text a_figures;
344
345 case ( txt,
346 false,
347 a_visualization,
348 a_figures )
349 algorithm
350 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
351 "<Annotations>\n",
352 " <Annotation type=\"org.openmodelica\">\n"
353 }, true));
354 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(4));
355 ✗ txt := Tpl.writeText(txt, a_figures);
356 ✗ txt := Tpl.softNewLine(txt);
357 ✗ txt := Tpl.writeText(txt, a_visualization);
358 ✗ txt := Tpl.softNewLine(txt);
359 ✗ txt := Tpl.popBlock(txt);
360 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
361 " </Annotation>\n",
362 "</Annotations>"
363 }, false));
364 then txt;
365
366 case ( txt,
367 _,
368 _,
369 _ )
370 then txt;
371 end match;
372 end fun_58;
373
374 public function fmiOpenModelicaAnnotations
375 input Tpl.Text txt;
376 input SimCode.SimCode a_simCode;
377
378 output Tpl.Text out_txt;
379 protected
380 Boolean ret_4;
381 Boolean ret_3;
382 Boolean ret_2;
383 Tpl.Text l_visualization;
384 Tpl.Text l_figures;
385 algorithm
386 16 l_figures := fmiFiguresBody(Tpl.emptyTxt, a_simCode);
387 16 l_visualization := fmiVisualizationElement(Tpl.emptyTxt, a_simCode);
388
2/4
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 16 times.
16 ret_2 := stringEq(Tpl.textString(l_figures), "");
389
2/4
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 16 times.
16 ret_3 := stringEq(Tpl.textString(l_visualization), "");
390 16 ret_4 := boolAnd(ret_2, ret_3);
391 16 out_txt := fun_58(txt, ret_4, l_visualization, l_figures);
392 end fmiOpenModelicaAnnotations;
393
394 protected function lm_60
395 input output Tpl.Text txt;
396 input list<SimCode.FmiFigure> items;
397 algorithm
398 ✗ for lstElt_60 in items loop
399 txt := match lstElt_60
400 local
401 SimCode.FmiFigure i_f;
402
403 case i_f
404 algorithm
405 ✗ txt := Figure3(txt, i_f);
406 ✗ txt := Tpl.nextIter(txt);
407 then txt;
408 end match;
409 end for;
410 end lm_60;
411
412 public function fmiFiguresBody
413 input Tpl.Text in_txt;
414 input SimCode.SimCode in_a_simCode;
415
416 output Tpl.Text out_txt;
417 algorithm
418 out_txt :=
419 match(in_txt, in_a_simCode)
420 local
421 Tpl.Text txt;
422 list<SimCode.FmiFigure> i_figures;
423
424 case ( txt,
425 SimCode.SIMCODE(fmiFigures = {}) )
426 then txt;
427
428 case ( txt,
429 SimCode.SIMCODE(fmiFigures = i_figures) )
430 algorithm
431 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("<Figures version=\"1\">\n"));
432 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
433 ✗ txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
434 ✗ txt := lm_60(txt, i_figures);
435 ✗ txt := Tpl.popIter(txt);
436 ✗ txt := Tpl.softNewLine(txt);
437 ✗ txt := Tpl.popBlock(txt);
438 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("</Figures>"));
439 then txt;
440
441 case ( txt,
442 _ )
443 then txt;
444 end match;
445 end fmiFiguresBody;
446
447 protected function fun_62
448 input Tpl.Text in_txt;
449 input Boolean in_mArg;
450 input Tpl.Text in_a_resource;
451
452 output Tpl.Text out_txt;
453 algorithm
454 out_txt :=
455 match(in_txt, in_mArg, in_a_resource)
456 local
457 Tpl.Text txt;
458 Tpl.Text a_resource;
459 String ret_0;
460
461 case ( txt,
462 false,
463 a_resource )
464 algorithm
465 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("<Visualization version=\"1\" file=\""));
466 ✗ ret_0 := Util.escapeModelicaStringToXmlString(Tpl.textString(a_resource));
467 ✗ txt := Tpl.writeStr(txt, ret_0);
468 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\"/>"));
469 then txt;
470
471 case ( txt,
472 _,
473 _ )
474 then txt;
475 end match;
476 end fun_62;
477
478 public function fmiVisualizationElement
479 input Tpl.Text txt;
480 input SimCode.SimCode a_simCode;
481
482 output Tpl.Text out_txt;
483 protected
484 Boolean ret_2;
485 String ret_1;
486 Tpl.Text l_resource;
487 algorithm
488 16 ret_1 := SimCodeCodegenUtil.getFMI3VisualizationResource(a_simCode);
489 16 l_resource := Tpl.writeStr(Tpl.emptyTxt, ret_1);
490
2/4
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 16 times.
16 ret_2 := stringEq(Tpl.textString(l_resource), "");
491 16 out_txt := fun_62(txt, ret_2, l_resource);
492 end fmiVisualizationElement;
493
494 protected function fun_64
495 input Tpl.Text in_txt;
496 input Boolean in_a_preferred;
497
498 output Tpl.Text out_txt;
499 algorithm
500 out_txt :=
501 match(in_txt, in_a_preferred)
502 local
503 Tpl.Text txt;
504
505 case ( txt,
506 false )
507 then txt;
508
509 case ( txt,
510 _ )
511 algorithm
512 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" preferred=\"true\""));
513 then txt;
514 end match;
515 end fun_64;
516
517 protected function fun_65
518 input Tpl.Text in_txt;
519 input Boolean in_mArg;
520 input String in_a_caption;
521
522 output Tpl.Text out_txt;
523 algorithm
524 out_txt :=
525 match(in_txt, in_mArg, in_a_caption)
526 local
527 Tpl.Text txt;
528 String a_caption;
529 String ret_0;
530
531 case ( txt,
532 false,
533 _ )
534 then txt;
535
536 case ( txt,
537 _,
538 a_caption )
539 algorithm
540 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
541 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" <Caption>"));
542 ✗ ret_0 := Util.escapeModelicaStringToXmlString(a_caption);
543 ✗ txt := Tpl.writeStr(txt, ret_0);
544 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("</Caption>"));
545 then txt;
546 end match;
547 end fun_65;
548
549 protected function lm_66
550 input output Tpl.Text txt;
551 input list<SimCode.FmiPlot> items;
552 algorithm
553 ✗ for lstElt_66 in items loop
554 txt := match lstElt_66
555 local
556 SimCode.FmiPlot i_p;
557
558 case i_p
559 algorithm
560 ✗ txt := FigurePlot3(txt, i_p);
561 ✗ txt := Tpl.nextIter(txt);
562 then txt;
563 end match;
564 end for;
565 end lm_66;
566
567 public function Figure3
568 input Tpl.Text in_txt;
569 input SimCode.FmiFigure in_a_figure;
570
571 output Tpl.Text out_txt;
572 algorithm
573 out_txt :=
574 match(in_txt, in_a_figure)
575 local
576 Tpl.Text txt;
577 list<SimCode.FmiPlot> i_plots;
578 String i_caption;
579 Boolean i_preferred;
580 String i_group;
581 String i_title;
582 Boolean ret_5;
583 Boolean ret_4;
584 Tpl.Text l_captionElt;
585 Tpl.Text l_prefAttr;
586 Tpl.Text l_groupAttr;
587 Tpl.Text l_titleAttr;
588
589 case ( txt,
590 SimCode.FMI_FIGURE(title = i_title, group = i_group, preferred = i_preferred, caption = i_caption, plots = i_plots) )
591 algorithm
592 ✗ l_titleAttr := figureStrAttr(Tpl.emptyTxt, "title", i_title);
593 ✗ l_groupAttr := figureStrAttr(Tpl.emptyTxt, "group", i_group);
594 ✗ l_prefAttr := fun_64(Tpl.emptyTxt, i_preferred);
595 ✗ ret_4 := stringEq(i_caption, "");
596 ✗ ret_5 := boolNot(ret_4);
597 ✗ l_captionElt := fun_65(Tpl.emptyTxt, ret_5, i_caption);
598 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("<Figure"));
599 ✗ txt := Tpl.writeText(txt, l_titleAttr);
600 ✗ txt := Tpl.writeText(txt, l_groupAttr);
601 ✗ txt := Tpl.writeText(txt, l_prefAttr);
602 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(">\n"));
603 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
604 ✗ txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
605 ✗ txt := lm_66(txt, i_plots);
606 ✗ txt := Tpl.popIter(txt);
607 ✗ txt := Tpl.writeText(txt, l_captionElt);
608 ✗ txt := Tpl.softNewLine(txt);
609 ✗ txt := Tpl.popBlock(txt);
610 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("</Figure>"));
611 then txt;
612
613 case ( txt,
614 _ )
615 then txt;
616 end match;
617 end Figure3;
618
619 protected function lm_68
620 input output Tpl.Text txt;
621 input list<SimCode.FmiCurve> items;
622 algorithm
623 ✗ for lstElt_68 in items loop
624 txt := match lstElt_68
625 local
626 SimCode.FmiCurve i_c;
627
628 case i_c
629 algorithm
630 ✗ txt := FigureCurve3(txt, i_c);
631 ✗ txt := Tpl.nextIter(txt);
632 then txt;
633 end match;
634 end for;
635 end lm_68;
636
637 protected function fun_69
638 input Tpl.Text in_txt;
639 input Option<String> in_a_terminal;
640
641 output Tpl.Text out_txt;
642 algorithm
643 out_txt :=
644 match(in_txt, in_a_terminal)
645 local
646 Tpl.Text txt;
647 String i_t;
648 String ret_0;
649
650 case ( txt,
651 SOME(i_t) )
652 algorithm
653 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
654 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" <TerminalRef terminal=\""));
655 ✗ ret_0 := Util.escapeModelicaStringToXmlString(i_t);
656 ✗ txt := Tpl.writeStr(txt, ret_0);
657 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\"/>"));
658 then txt;
659
660 case ( txt,
661 _ )
662 then txt;
663 end match;
664 end fun_69;
665
666 public function FigurePlot3
667 input Tpl.Text in_txt;
668 input SimCode.FmiPlot in_a_plot;
669
670 output Tpl.Text out_txt;
671 algorithm
672 out_txt :=
673 match(in_txt, in_a_plot)
674 local
675 Tpl.Text txt;
676 Option<String> i_terminal;
677 list<SimCode.FmiCurve> i_curves;
678 SimCode.FmiFigureAxis i_yAxis;
679 SimCode.FmiFigureAxis i_xAxis;
680 String i_title;
681 Tpl.Text l_termRef;
682 Tpl.Text l_curveElts;
683 Tpl.Text l_yAxisElt;
684 Tpl.Text l_xAxisElt;
685 Tpl.Text l_titleAttr;
686
687 case ( txt,
688 SimCode.FMI_PLOT(title = i_title, xAxis = i_xAxis, yAxis = i_yAxis, curves = i_curves, terminal = i_terminal) )
689 algorithm
690 ✗ l_titleAttr := figureStrAttr(Tpl.emptyTxt, "title", i_title);
691 ✗ l_xAxisElt := FigureAxis3(Tpl.emptyTxt, "x", i_xAxis);
692 ✗ l_yAxisElt := FigureAxis3(Tpl.emptyTxt, "y", i_yAxis);
693 ✗ l_curveElts := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
694 ✗ l_curveElts := lm_68(l_curveElts, i_curves);
695 ✗ l_curveElts := Tpl.popIter(l_curveElts);
696 ✗ l_termRef := fun_69(Tpl.emptyTxt, i_terminal);
697 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("<Plot"));
698 ✗ txt := Tpl.writeText(txt, l_titleAttr);
699 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(">\n"));
700 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
701 ✗ txt := Tpl.writeText(txt, l_xAxisElt);
702 ✗ txt := Tpl.writeText(txt, l_yAxisElt);
703 ✗ txt := Tpl.writeText(txt, l_curveElts);
704 ✗ txt := Tpl.writeText(txt, l_termRef);
705 ✗ txt := Tpl.softNewLine(txt);
706 ✗ txt := Tpl.popBlock(txt);
707 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("</Plot>"));
708 then txt;
709
710 case ( txt,
711 _ )
712 then txt;
713 end match;
714 end FigurePlot3;
715
716 protected function fun_71
717 input Tpl.Text in_txt;
718 input Option<Real> in_a_min;
719
720 output Tpl.Text out_txt;
721 algorithm
722 out_txt :=
723 match(in_txt, in_a_min)
724 local
725 Tpl.Text txt;
726 Real i_r;
727
728 case ( txt,
729 SOME(i_r) )
730 algorithm
731 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(1));
732 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("min=\""));
733 ✗ txt := Tpl.writeStr(txt, realString(i_r));
734 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\""));
735 ✗ txt := Tpl.popBlock(txt);
736 then txt;
737
738 case ( txt,
739 _ )
740 then txt;
741 end match;
742 end fun_71;
743
744 protected function fun_72
745 input Tpl.Text in_txt;
746 input Option<Real> in_a_max;
747
748 output Tpl.Text out_txt;
749 algorithm
750 out_txt :=
751 match(in_txt, in_a_max)
752 local
753 Tpl.Text txt;
754 Real i_r;
755
756 case ( txt,
757 SOME(i_r) )
758 algorithm
759 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(1));
760 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("max=\""));
761 ✗ txt := Tpl.writeStr(txt, realString(i_r));
762 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\""));
763 ✗ txt := Tpl.popBlock(txt);
764 then txt;
765
766 case ( txt,
767 _ )
768 then txt;
769 end match;
770 end fun_72;
771
772 protected function fun_73
773 input Tpl.Text in_txt;
774 input Boolean in_a_logScale;
775
776 output Tpl.Text out_txt;
777 algorithm
778 out_txt :=
779 match(in_txt, in_a_logScale)
780 local
781 Tpl.Text txt;
782
783 case ( txt,
784 false )
785 then txt;
786
787 case ( txt,
788 _ )
789 algorithm
790 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" scale=\"Log\""));
791 then txt;
792 end match;
793 end fun_73;
794
795 protected function fun_74
796 input Tpl.Text in_txt;
797 input Boolean in_mArg;
798 input Tpl.Text in_a_body;
799 input String in_a_role;
800
801 output Tpl.Text out_txt;
802 algorithm
803 out_txt :=
804 match(in_txt, in_mArg, in_a_body, in_a_role)
805 local
806 Tpl.Text txt;
807 Tpl.Text a_body;
808 String a_role;
809
810 case ( txt,
811 false,
812 a_body,
813 a_role )
814 algorithm
815 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("<Axis role=\""));
816 ✗ txt := Tpl.writeStr(txt, a_role);
817 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\""));
818 ✗ txt := Tpl.writeText(txt, a_body);
819 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("/>"));
820 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
821 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" "));
822 then txt;
823
824 case ( txt,
825 _,
826 _,
827 _ )
828 then txt;
829 end match;
830 end fun_74;
831
832 protected function fun_75
833 input Tpl.Text in_txt;
834 input SimCode.FmiFigureAxis in_a_axis;
835 input String in_a_role;
836
837 output Tpl.Text out_txt;
838 algorithm
839 out_txt :=
840 match(in_txt, in_a_axis, in_a_role)
841 local
842 Tpl.Text txt;
843 String a_role;
844 Boolean i_logScale;
845 Option<Real> i_max;
846 Option<Real> i_min;
847 String i_unit;
848 String i_label;
849 Boolean ret_6;
850 Tpl.Text l_body;
851 Tpl.Text l_scaleAttr;
852 Tpl.Text l_maxAttr;
853 Tpl.Text l_minAttr;
854 Tpl.Text l_unitAttr;
855 Tpl.Text l_labelAttr;
856
857 case ( txt,
858 SimCode.FMI_FIGURE_AXIS(label = i_label, unit = i_unit, min = i_min, max = i_max, logScale = i_logScale),
859 a_role )
860 algorithm
861 ✗ l_labelAttr := figureStrAttr(Tpl.emptyTxt, "label", i_label);
862 ✗ l_unitAttr := figureStrAttr(Tpl.emptyTxt, "unit", i_unit);
863 ✗ l_minAttr := fun_71(Tpl.emptyTxt, i_min);
864 ✗ l_maxAttr := fun_72(Tpl.emptyTxt, i_max);
865 ✗ l_scaleAttr := fun_73(Tpl.emptyTxt, i_logScale);
866 ✗ l_body := Tpl.writeText(Tpl.emptyTxt, l_labelAttr);
867 ✗ l_body := Tpl.writeText(l_body, l_unitAttr);
868 ✗ l_body := Tpl.writeText(l_body, l_minAttr);
869 ✗ l_body := Tpl.writeText(l_body, l_maxAttr);
870 ✗ l_body := Tpl.writeText(l_body, l_scaleAttr);
871 ✗ ret_6 := stringEq(Tpl.textString(l_body), "");
872 ✗ txt := fun_74(txt, ret_6, l_body, a_role);
873 then txt;
874
875 case ( txt,
876 _,
877 _ )
878 then txt;
879 end match;
880 end fun_75;
881
882 public function FigureAxis3
883 input Tpl.Text txt;
884 input String a_role;
885 input SimCode.FmiFigureAxis a_axis;
886
887 output Tpl.Text out_txt;
888 algorithm
889 ✗ out_txt := fun_75(txt, a_axis, a_role);
890 end FigureAxis3;
891
892 protected function fun_77
893 input Tpl.Text in_txt;
894 input Option<DAE.ComponentRef> in_a_xVariable;
895
896 output Tpl.Text out_txt;
897 algorithm
898 out_txt :=
899 match(in_txt, in_a_xVariable)
900 local
901 Tpl.Text txt;
902 DAE.ComponentRef i_x;
903
904 case ( txt,
905 SOME(i_x) )
906 algorithm
907 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(1));
908 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("x=\""));
909 ✗ txt := figureCrefName(txt, i_x);
910 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\""));
911 ✗ txt := Tpl.popBlock(txt);
912 then txt;
913
914 case ( txt,
915 _ )
916 then txt;
917 end match;
918 end fun_77;
919
920 public function FigureCurve3
921 input Tpl.Text in_txt;
922 input SimCode.FmiCurve in_a_curve;
923
924 output Tpl.Text out_txt;
925 algorithm
926 out_txt :=
927 match(in_txt, in_a_curve)
928 local
929 Tpl.Text txt;
930 String i_legend;
931 Option<DAE.ComponentRef> i_xVariable;
932 DAE.ComponentRef i_yVariable;
933 Tpl.Text l_legendAttr;
934 Tpl.Text l_xAttr;
935 Tpl.Text l_yAttr;
936
937 case ( txt,
938 SimCode.FMI_CURVE(yVariable = i_yVariable, xVariable = i_xVariable, legend = i_legend) )
939 algorithm
940 ✗ l_yAttr := Tpl.pushBlock(Tpl.emptyTxt, Tpl.BT_INDENT(1));
941 ✗ l_yAttr := Tpl.writeTok(l_yAttr, Tpl.ST_STRING("y=\""));
942 ✗ l_yAttr := figureCrefName(l_yAttr, i_yVariable);
943 ✗ l_yAttr := Tpl.writeTok(l_yAttr, Tpl.ST_STRING("\""));
944 ✗ l_yAttr := Tpl.popBlock(l_yAttr);
945 ✗ l_xAttr := fun_77(Tpl.emptyTxt, i_xVariable);
946 ✗ l_legendAttr := figureStrAttr(Tpl.emptyTxt, "legend", i_legend);
947 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("<Curve"));
948 ✗ txt := Tpl.writeText(txt, l_yAttr);
949 ✗ txt := Tpl.writeText(txt, l_xAttr);
950 ✗ txt := Tpl.writeText(txt, l_legendAttr);
951 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("/>"));
952 then txt;
953
954 case ( txt,
955 _ )
956 then txt;
957 end match;
958 end FigureCurve3;
959
960 public function figureCrefName
961 input Tpl.Text txt;
962 input DAE.ComponentRef a_cref;
963
964 output Tpl.Text out_txt;
965 protected
966 String ret_2;
967 String ret_1;
968 Tpl.Text txt_0;
969 algorithm
970 ✗ txt_0 := CodegenUtil.crefStrNoUnderscore(Tpl.emptyTxt, a_cref);
971 ✗ ret_1 := System.stringReplace(Tpl.textString(txt_0), "$", "_D_");
972 ✗ ret_2 := Util.escapeModelicaStringToXmlString(ret_1);
973 ✗ out_txt := Tpl.writeStr(txt, ret_2);
974 end figureCrefName;
975
976 protected function fun_80
977 input Tpl.Text in_txt;
978 input Boolean in_mArg;
979 input String in_a_name;
980 input String in_a_value;
981
982 output Tpl.Text out_txt;
983 algorithm
984 out_txt :=
985 match(in_txt, in_mArg, in_a_name, in_a_value)
986 local
987 Tpl.Text txt;
988 String a_name;
989 String a_value;
990 String ret_0;
991
992 case ( txt,
993 false,
994 a_name,
995 a_value )
996 algorithm
997 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(1));
998 ✗ txt := Tpl.writeStr(txt, a_name);
999 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("=\""));
1000 ✗ ret_0 := Util.escapeModelicaStringToXmlString(a_value);
1001 ✗ txt := Tpl.writeStr(txt, ret_0);
1002 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\""));
1003 ✗ txt := Tpl.popBlock(txt);
1004 then txt;
1005
1006 case ( txt,
1007 _,
1008 _,
1009 _ )
1010 then txt;
1011 end match;
1012 end fun_80;
1013
1014 public function figureStrAttr
1015 input Tpl.Text txt;
1016 input String a_name;
1017 input String a_value;
1018
1019 output Tpl.Text out_txt;
1020 protected
1021 Boolean ret_0;
1022 algorithm
1023 ✗ ret_0 := stringEq(a_value, "");
1024 ✗ out_txt := fun_80(txt, ret_0, a_name, a_value);
1025 end figureStrAttr;
1026
1027 protected function fun_82
1028 input Tpl.Text in_txt;
1029 input list<String> in_a_sourceFiles;
1030 input SimCode.SimCode in_a_simCode;
1031 input String in_a_fileNamePrefixHash;
1032
1033 output Tpl.Text out_txt;
1034 algorithm
1035 out_txt :=
1036 match(in_txt, in_a_sourceFiles, in_a_simCode, in_a_fileNamePrefixHash)
1037 local
1038 Tpl.Text txt;
1039 SimCode.SimCode a_simCode;
1040 String a_fileNamePrefixHash;
1041 list<String> i_sourceFiles;
1042 Tpl.Text txt_1;
1043 Tpl.Text txt_0;
1044
1045 case ( txt,
1046 {},
1047 _,
1048 _ )
1049 then txt;
1050
1051 case ( txt,
1052 i_sourceFiles,
1053 a_simCode,
1054 a_fileNamePrefixHash )
1055 algorithm
1056 2 txt_0 := fmiBuildDescription(Tpl.emptyTxt, a_simCode, i_sourceFiles);
1057 2 txt_1 := Tpl.writeStr(Tpl.emptyTxt, a_fileNamePrefixHash);
1058 2 txt_1 := Tpl.writeTok(txt_1, Tpl.ST_STRING(".fmutmp/sources/buildDescription.xml"));
1059 2 Tpl.textFile(txt_0, Tpl.textString(txt_1));
1060 then txt;
1061 end match;
1062 end fun_82;
1063
1064 public function fmiBuildDescriptionFile
1065 input Tpl.Text txt;
1066 input SimCode.SimCode a_simCode;
1067 input list<String> a_sourceFiles;
1068 input String a_fileNamePrefixHash;
1069
1070 output Tpl.Text out_txt;
1071 algorithm
1072 15 out_txt := fun_82(txt, a_sourceFiles, a_simCode, a_fileNamePrefixHash);
1073 end fmiBuildDescriptionFile;
1074
1075 protected function fun_84
1076 input Tpl.Text in_txt;
1077 input Boolean in_mArg;
1078 input String in_a_file;
1079
1080 output Tpl.Text out_txt;
1081 algorithm
1082 out_txt :=
1083 match(in_txt, in_mArg, in_a_file)
1084 local
1085 Tpl.Text txt;
1086 String a_file;
1087
1088 case ( txt,
1089 false,
1090 _ )
1091 then txt;
1092
1093 case ( txt,
1094 _,
1095 a_file )
1096 algorithm
1097 120 txt := Tpl.writeTok(txt, Tpl.ST_STRING("<SourceFile name=\""));
1098 120 txt := Tpl.writeStr(txt, a_file);
1099 120 txt := Tpl.writeTok(txt, Tpl.ST_STRING("\"/>"));
1100 then txt;
1101 end match;
1102 end fun_84;
1103
1104 protected function lm_85
1105 input output Tpl.Text txt;
1106 input list<String> items;
1107 algorithm
1108
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 2 times.
150 for lstElt_85 in items loop
1109 txt := match lstElt_85
1110 local
1111 String i_file;
1112 Boolean ret_1;
1113 Boolean ret_0;
1114
1115 case i_file
1116 algorithm
1117 148 ret_0 := StringUtil.endsWith(i_file, ".rs");
1118 148 ret_1 := boolNot(ret_0);
1119 148 txt := fun_84(txt, ret_1, i_file);
1120 148 txt := Tpl.nextIter(txt);
1121 then txt;
1122 end match;
1123 end for;
1124 end lm_85;
1125
1126 public function fmiBuildDescription
1127 input Tpl.Text in_txt;
1128 input SimCode.SimCode in_a_simCode;
1129 input list<String> in_a_sourceFiles;
1130
1131 output Tpl.Text out_txt;
1132 algorithm
1133 out_txt :=
1134 match(in_txt, in_a_simCode, in_a_sourceFiles)
1135 local
1136 Tpl.Text txt;
1137 list<String> a_sourceFiles;
1138 SimCode.SimCode i_simCode;
1139 Tpl.Text l_modelIdentifier;
1140
1141 case ( txt,
1142 (i_simCode as SimCode.SIMCODE(modelInfo = _)),
1143 a_sourceFiles )
1144 algorithm
1145 2 l_modelIdentifier := CodegenUtilSimulation.modelNamePrefix(Tpl.emptyTxt, i_simCode);
1146 2 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
1147 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n",
1148 "<fmiBuildDescription fmiVersion=\"3.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"https://raw.githubusercontent.com/modelica/fmi-standard/v3.0.2/schema/fmi3BuildDescription.xsd\">\n"
1149 }, true));
1150 2 txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
1151 2 txt := Tpl.writeTok(txt, Tpl.ST_STRING("<BuildConfiguration modelIdentifier=\""));
1152 2 txt := Tpl.writeText(txt, l_modelIdentifier);
1153 2 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
1154 "\">\n",
1155 " <SourceFileSet language=\"C17\">\n"
1156 }, true));
1157 2 txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(4));
1158 2 txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
1159 2 txt := lm_85(txt, a_sourceFiles);
1160 2 txt := Tpl.popIter(txt);
1161 2 txt := Tpl.softNewLine(txt);
1162 2 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
1163 "<PreprocessorDefinition name=\"FMI2_OVERRIDE_FUNCTION_PREFIX\"/>\n",
1164 "<PreprocessorDefinition name=\"FMI3_OVERRIDE_FUNCTION_PREFIX\"/>\n",
1165 "<IncludeDirectory name=\".\"/>\n",
1166 "<IncludeDirectory name=\"fmi\"/>\n"
1167 }, true));
1168 2 txt := Tpl.popBlock(txt);
1169 2 txt := Tpl.writeTok(txt, Tpl.ST_LINE(" </SourceFileSet>\n"));
1170 2 txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
1171 2 txt := rustSourceFileSet(txt, a_sourceFiles);
1172 2 txt := Tpl.softNewLine(txt);
1173 2 txt := Tpl.popBlock(txt);
1174 2 txt := Tpl.writeTok(txt, Tpl.ST_LINE("</BuildConfiguration>\n"));
1175 2 txt := Tpl.popBlock(txt);
1176 2 txt := Tpl.writeTok(txt, Tpl.ST_STRING("</fmiBuildDescription>"));
1177 then txt;
1178
1179 case ( txt,
1180 _,
1181 _ )
1182 then txt;
1183 end match;
1184 end fmiBuildDescription;
1185
1186 protected function fun_87
1187 input Tpl.Text in_txt;
1188 input Boolean in_mArg;
1189 input String in_a_file;
1190
1191 output Tpl.Text out_txt;
1192 algorithm
1193 out_txt :=
1194 match(in_txt, in_mArg, in_a_file)
1195 local
1196 Tpl.Text txt;
1197 String a_file;
1198
1199 case ( txt,
1200 false,
1201 _ )
1202 then txt;
1203
1204 case ( txt,
1205 _,
1206 a_file )
1207 algorithm
1208 28 txt := Tpl.writeTok(txt, Tpl.ST_STRING("<SourceFile name=\""));
1209 28 txt := Tpl.writeStr(txt, a_file);
1210 28 txt := Tpl.writeTok(txt, Tpl.ST_STRING("\"/>"));
1211 then txt;
1212 end match;
1213 end fun_87;
1214
1215 protected function lm_88
1216 input output Tpl.Text txt;
1217 input list<String> items;
1218 algorithm
1219
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 2 times.
150 for lstElt_88 in items loop
1220 txt := match lstElt_88
1221 local
1222 String i_file;
1223 Boolean ret_0;
1224
1225 case i_file
1226 algorithm
1227 148 ret_0 := StringUtil.endsWith(i_file, ".rs");
1228 148 txt := fun_87(txt, ret_0, i_file);
1229 148 txt := Tpl.nextIter(txt);
1230 then txt;
1231 end match;
1232 end for;
1233 end lm_88;
1234
1235 protected function fun_89
1236 input Tpl.Text in_txt;
1237 input Boolean in_mArg;
1238 input Tpl.Text in_a_files;
1239
1240 output Tpl.Text out_txt;
1241 algorithm
1242 out_txt :=
1243 match(in_txt, in_mArg, in_a_files)
1244 local
1245 Tpl.Text txt;
1246 Tpl.Text a_files;
1247
1248 case ( txt,
1249 true,
1250 _ )
1251 then txt;
1252
1253 case ( txt,
1254 _,
1255 a_files )
1256 algorithm
1257 2 txt := Tpl.writeTok(txt, Tpl.ST_LINE("<SourceFileSet language=\"Rust2024\" compiler=\"cargo\" compilerOptions=\"rustc --release --manifest-path rust/SimulationRuntime/rust/Cargo.toml -p openmodelica_simulation_runtime --lib --crate-type staticlib\">\n"));
1258 2 txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
1259 2 txt := Tpl.writeText(txt, a_files);
1260 2 txt := Tpl.softNewLine(txt);
1261 2 txt := Tpl.popBlock(txt);
1262 2 txt := Tpl.writeTok(txt, Tpl.ST_STRING("</SourceFileSet>"));
1263 then txt;
1264 end match;
1265 end fun_89;
1266
1267 public function rustSourceFileSet
1268 input Tpl.Text txt;
1269 input list<String> a_sourceFiles;
1270
1271 output Tpl.Text out_txt;
1272 protected
1273 Boolean ret_1;
1274 Tpl.Text l_files;
1275 algorithm
1276 2 l_files := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
1277 2 l_files := lm_88(l_files, a_sourceFiles);
1278 2 l_files := Tpl.popIter(l_files);
1279 2 ret_1 := Tpl.isEmpty(l_files);
1280 2 out_txt := fun_89(txt, ret_1, l_files);
1281 end rustSourceFileSet;
1282
1283 protected function fun_91
1284 input Tpl.Text in_txt;
1285 input list<SimCode.FmiTerminal> in_mArg;
1286 input String in_a_fileNamePrefixHash;
1287
1288 output Tpl.Text out_txt;
1289 algorithm
1290 out_txt :=
1291 match(in_txt, in_mArg, in_a_fileNamePrefixHash)
1292 local
1293 Tpl.Text txt;
1294 String a_fileNamePrefixHash;
1295 list<SimCode.FmiTerminal> i_terminals;
1296 Tpl.Text txt_1;
1297 Tpl.Text txt_0;
1298
1299 case ( txt,
1300 {},
1301 _ )
1302 then txt;
1303
1304 case ( txt,
1305 i_terminals,
1306 a_fileNamePrefixHash )
1307 algorithm
1308 8 txt_0 := fmiTerminalsAndIcons(Tpl.emptyTxt, i_terminals);
1309 8 txt_1 := Tpl.writeStr(Tpl.emptyTxt, a_fileNamePrefixHash);
1310 8 txt_1 := Tpl.writeTok(txt_1, Tpl.ST_STRING(".fmutmp/terminalsAndIcons/terminalsAndIcons.xml"));
1311 8 Tpl.textFile(txt_0, Tpl.textString(txt_1));
1312 then txt;
1313 end match;
1314 end fun_91;
1315
1316 public function fmiTerminalsAndIconsFile
1317 input Tpl.Text txt;
1318 input SimCode.SimCode a_simCode;
1319 input String a_fileNamePrefixHash;
1320
1321 output Tpl.Text out_txt;
1322 protected
1323 list<SimCode.FmiTerminal> ret_0;
1324 algorithm
1325 15 ret_0 := SimCodeCodegenUtil.getFMI3Terminals(a_simCode);
1326 15 out_txt := fun_91(txt, ret_0, a_fileNamePrefixHash);
1327 end fmiTerminalsAndIconsFile;
1328
1329 protected function lm_93
1330 input output Tpl.Text txt;
1331 input list<SimCode.FmiTerminal> items;
1332 algorithm
1333
2/2
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 8 times.
138 for lstElt_93 in items loop
1334 txt := match lstElt_93
1335 local
1336 SimCode.FmiTerminal i_t;
1337
1338 case i_t
1339 algorithm
1340 130 txt := Terminal3(txt, i_t);
1341 130 txt := Tpl.nextIter(txt);
1342 then txt;
1343 end match;
1344 end for;
1345 end lm_93;
1346
1347 public function fmiTerminalsAndIcons
1348 input Tpl.Text txt;
1349 input list<SimCode.FmiTerminal> a_terminals;
1350
1351 output Tpl.Text out_txt;
1352 algorithm
1353 8 out_txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
1354 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n",
1355 "<fmiTerminalsAndIcons fmiVersion=\"3.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"https://raw.githubusercontent.com/modelica/fmi-standard/v3.0.2/schema/fmi3TerminalsAndIcons.xsd\">\n",
1356 " <Terminals>\n"
1357 }, true));
1358 8 out_txt := Tpl.pushBlock(out_txt, Tpl.BT_INDENT(4));
1359 8 out_txt := Tpl.pushIter(out_txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
1360 8 out_txt := lm_93(out_txt, a_terminals);
1361 8 out_txt := Tpl.popIter(out_txt);
1362 8 out_txt := Tpl.softNewLine(out_txt);
1363 8 out_txt := Tpl.popBlock(out_txt);
1364 8 out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING_LIST({
1365 " </Terminals>\n",
1366 "</fmiTerminalsAndIcons>"
1367 }, false));
1368 end fmiTerminalsAndIcons;
1369
1370 protected function fun_95
1371 input Tpl.Text in_txt;
1372 input Boolean in_a_isExpandable;
1373
1374 output Tpl.Text out_txt;
1375 algorithm
1376 out_txt :=
1377 match(in_txt, in_a_isExpandable)
1378 local
1379 Tpl.Text txt;
1380
1381 case ( txt,
1382 false )
1383 algorithm
1384 130 txt := Tpl.writeTok(txt, Tpl.ST_STRING("plug"));
1385 then txt;
1386
1387 case ( txt,
1388 _ )
1389 algorithm
1390 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("bus"));
1391 then txt;
1392 end match;
1393 end fun_95;
1394
1395 protected function fun_96
1396 input Tpl.Text in_txt;
1397 input Boolean in_mArg;
1398 input String in_a_terminalKind;
1399
1400 output Tpl.Text out_txt;
1401 algorithm
1402 out_txt :=
1403 match(in_txt, in_mArg, in_a_terminalKind)
1404 local
1405 Tpl.Text txt;
1406 String a_terminalKind;
1407 String ret_0;
1408
1409 case ( txt,
1410 false,
1411 a_terminalKind )
1412 algorithm
1413 126 txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(1));
1414 126 txt := Tpl.writeTok(txt, Tpl.ST_STRING("terminalKind=\""));
1415 126 ret_0 := Util.escapeModelicaStringToXmlString(a_terminalKind);
1416 126 txt := Tpl.writeStr(txt, ret_0);
1417 126 txt := Tpl.writeTok(txt, Tpl.ST_STRING("\""));
1418 126 txt := Tpl.popBlock(txt);
1419 then txt;
1420
1421 case ( txt,
1422 _,
1423 _ )
1424 then txt;
1425 end match;
1426 end fun_96;
1427
1428 protected function lm_97
1429 input output Tpl.Text txt;
1430 input list<SimCode.FmiTerminalMember> items;
1431 algorithm
1432
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 130 times.
506 for lstElt_97 in items loop
1433 txt := match lstElt_97
1434 local
1435 SimCode.FmiTerminalMember i_m;
1436
1437 case i_m
1438 algorithm
1439 376 txt := TerminalMember3(txt, i_m);
1440 376 txt := Tpl.nextIter(txt);
1441 then txt;
1442 end match;
1443 end for;
1444 end lm_97;
1445
1446 public function Terminal3
1447 input Tpl.Text in_txt;
1448 input SimCode.FmiTerminal in_a_terminal;
1449
1450 output Tpl.Text out_txt;
1451 algorithm
1452 out_txt :=
1453 match(in_txt, in_a_terminal)
1454 local
1455 Tpl.Text txt;
1456 list<SimCode.FmiTerminalMember> i_members;
1457 String i_name;
1458 String i_terminalKind;
1459 Boolean i_isExpandable;
1460 String ret_3;
1461 Boolean ret_2;
1462 Tpl.Text l_kindAttr;
1463 Tpl.Text l_rule;
1464
1465 case ( txt,
1466 SimCode.FMI_TERMINAL(isExpandable = i_isExpandable, terminalKind = i_terminalKind, name = i_name, members = i_members) )
1467 algorithm
1468 130 l_rule := fun_95(Tpl.emptyTxt, i_isExpandable);
1469
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 126 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
130 ret_2 := stringEq(i_terminalKind, "");
1470 130 l_kindAttr := fun_96(Tpl.emptyTxt, ret_2, i_terminalKind);
1471 130 txt := Tpl.writeTok(txt, Tpl.ST_STRING("<Terminal name=\""));
1472 130 ret_3 := Util.escapeModelicaStringToXmlString(i_name);
1473 130 txt := Tpl.writeStr(txt, ret_3);
1474 130 txt := Tpl.writeTok(txt, Tpl.ST_STRING("\" matchingRule=\""));
1475 130 txt := Tpl.writeText(txt, l_rule);
1476 130 txt := Tpl.writeTok(txt, Tpl.ST_STRING("\""));
1477 130 txt := Tpl.writeText(txt, l_kindAttr);
1478 130 txt := Tpl.writeTok(txt, Tpl.ST_LINE(">\n"));
1479 130 txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
1480 130 txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
1481 130 txt := lm_97(txt, i_members);
1482 130 txt := Tpl.popIter(txt);
1483 130 txt := Tpl.softNewLine(txt);
1484 130 txt := Tpl.popBlock(txt);
1485 130 txt := Tpl.writeTok(txt, Tpl.ST_STRING("</Terminal>"));
1486 then txt;
1487
1488 case ( txt,
1489 _ )
1490 then txt;
1491 end match;
1492 end Terminal3;
1493
1494 public function TerminalMember3
1495 input Tpl.Text in_txt;
1496 input SimCode.FmiTerminalMember in_a_member;
1497
1498 output Tpl.Text out_txt;
1499 algorithm
1500 out_txt :=
1501 match(in_txt, in_a_member)
1502 local
1503 Tpl.Text txt;
1504 String i_variableKind;
1505 String i_memberName;
1506 DAE.ComponentRef i_variable;
1507 String ret_4;
1508 String ret_3;
1509 String ret_2;
1510 Tpl.Text txt_1;
1511 Tpl.Text l_varName;
1512
1513 case ( txt,
1514 SimCode.FMI_TERMINAL_MEMBER(variable = i_variable, memberName = i_memberName, variableKind = i_variableKind) )
1515 algorithm
1516 376 txt_1 := CodegenUtil.crefStrNoUnderscore(Tpl.emptyTxt, i_variable);
1517 376 ret_2 := System.stringReplace(Tpl.textString(txt_1), "$", "_D_");
1518 376 ret_3 := Util.escapeModelicaStringToXmlString(ret_2);
1519 376 l_varName := Tpl.writeStr(Tpl.emptyTxt, ret_3);
1520 376 txt := Tpl.writeTok(txt, Tpl.ST_STRING("<TerminalMemberVariable variableName=\""));
1521 376 txt := Tpl.writeText(txt, l_varName);
1522 376 txt := Tpl.writeTok(txt, Tpl.ST_STRING("\" memberName=\""));
1523 376 ret_4 := Util.escapeModelicaStringToXmlString(i_memberName);
1524 376 txt := Tpl.writeStr(txt, ret_4);
1525 376 txt := Tpl.writeTok(txt, Tpl.ST_STRING("\" variableKind=\""));
1526 376 txt := Tpl.writeStr(txt, i_variableKind);
1527 376 txt := Tpl.writeTok(txt, Tpl.ST_STRING("\"/>"));
1528 then txt;
1529
1530 case ( txt,
1531 _ )
1532 then txt;
1533 end match;
1534 end TerminalMember3;
1535
1536 protected function fun_100
1537 input Tpl.Text in_txt;
1538 input Boolean in_mArg;
1539 input Tpl.Text in_a_author;
1540
1541 output Tpl.Text out_txt;
1542 algorithm
1543 out_txt :=
1544 match(in_txt, in_mArg, in_a_author)
1545 local
1546 Tpl.Text txt;
1547 Tpl.Text a_author;
1548 String ret_0;
1549
1550 case ( txt,
1551 false,
1552 a_author )
1553 algorithm
1554 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("author=\""));
1555 ✗ ret_0 := Util.escapeModelicaStringToXmlString(Tpl.textString(a_author));
1556 ✗ txt := Tpl.writeStr(txt, ret_0);
1557 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\""));
1558 then txt;
1559
1560 case ( txt,
1561 _,
1562 _ )
1563 then txt;
1564 end match;
1565 end fun_100;
1566
1567 protected function fun_101
1568 input Tpl.Text in_txt;
1569 input Boolean in_mArg;
1570 input Tpl.Text in_a_copyright;
1571
1572 output Tpl.Text out_txt;
1573 algorithm
1574 out_txt :=
1575 match(in_txt, in_mArg, in_a_copyright)
1576 local
1577 Tpl.Text txt;
1578 Tpl.Text a_copyright;
1579 String ret_0;
1580
1581 case ( txt,
1582 false,
1583 a_copyright )
1584 algorithm
1585 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("copyright=\""));
1586 ✗ ret_0 := Util.escapeModelicaStringToXmlString(Tpl.textString(a_copyright));
1587 ✗ txt := Tpl.writeStr(txt, ret_0);
1588 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\""));
1589 then txt;
1590
1591 case ( txt,
1592 _,
1593 _ )
1594 then txt;
1595 end match;
1596 end fun_101;
1597
1598 protected function fun_102
1599 input Tpl.Text in_txt;
1600 input Boolean in_mArg;
1601 input Tpl.Text in_a_license;
1602
1603 output Tpl.Text out_txt;
1604 algorithm
1605 out_txt :=
1606 match(in_txt, in_mArg, in_a_license)
1607 local
1608 Tpl.Text txt;
1609 Tpl.Text a_license;
1610 String ret_0;
1611
1612 case ( txt,
1613 false,
1614 a_license )
1615 algorithm
1616 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("license=\""));
1617 ✗ ret_0 := Util.escapeModelicaStringToXmlString(Tpl.textString(a_license));
1618 ✗ txt := Tpl.writeStr(txt, ret_0);
1619 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\""));
1620 then txt;
1621
1622 case ( txt,
1623 _,
1624 _ )
1625 then txt;
1626 end match;
1627 end fun_102;
1628
1629 public function fmiModelDescriptionAttributes
1630 input Tpl.Text in_txt;
1631 input SimCode.SimCode in_a_simCode;
1632 input String in_a_guid;
1633
1634 output Tpl.Text out_txt;
1635 algorithm
1636 out_txt :=
1637 match(in_txt, in_a_simCode, in_a_guid)
1638 local
1639 Tpl.Text txt;
1640 String a_guid;
1641 SimCode.SimCode i_simCode;
1642 String i_modelInfo_license;
1643 String i_modelInfo_copyright;
1644 String i_modelInfo_version;
1645 String i_modelInfo_author;
1646 String i_modelInfo_description;
1647 Absyn.Path i_modelInfo_name;
1648 String ret_20;
1649 String ret_19;
1650 Boolean ret_18;
1651 Boolean ret_17;
1652 Boolean ret_16;
1653 String ret_15;
1654 String ret_14;
1655 String ret_13;
1656 Tpl.Text l_numberOfEventIndicators;
1657 Tpl.Text l_variableNamingConvention;
1658 Util.DateTime ret_10;
1659 Tpl.Text l_generationDateAndTime;
1660 String ret_8;
1661 Tpl.Text l_generationTool;
1662 Tpl.Text l_license;
1663 Tpl.Text l_copyright;
1664 Tpl.Text l_version;
1665 Tpl.Text l_author;
1666 Tpl.Text l_description;
1667 Tpl.Text l_modelName;
1668 Tpl.Text l_fmiVersion;
1669
1670 case ( txt,
1671 (i_simCode as SimCode.SIMCODE(modelInfo = SimCode.MODELINFO(varInfo = SimCode.VARINFO(numZeroCrossings = _), vars = SimCodeVar.SIMVARS(stateVars = _), name = i_modelInfo_name, description = i_modelInfo_description, author = i_modelInfo_author, version = i_modelInfo_version, copyright = i_modelInfo_copyright, license = i_modelInfo_license))),
1672 a_guid )
1673 algorithm
1674 16 l_fmiVersion := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("3.0"));
1675 16 l_modelName := CodegenUtil.dotPath(Tpl.emptyTxt, i_modelInfo_name);
1676 16 l_description := Tpl.writeStr(Tpl.emptyTxt, i_modelInfo_description);
1677 16 l_author := Tpl.writeStr(Tpl.emptyTxt, i_modelInfo_author);
1678 16 l_version := Tpl.writeStr(Tpl.emptyTxt, i_modelInfo_version);
1679 16 l_copyright := Tpl.writeStr(Tpl.emptyTxt, i_modelInfo_copyright);
1680 16 l_license := Tpl.writeStr(Tpl.emptyTxt, i_modelInfo_license);
1681 16 l_generationTool := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("OpenModelica Compiler "));
1682 16 ret_8 := Settings.getVersionNr();
1683 16 l_generationTool := Tpl.writeStr(l_generationTool, ret_8);
1684 16 ret_10 := Util.getCurrentDateTime();
1685 16 l_generationDateAndTime := CodegenFMUCommon.xsdateTime(Tpl.emptyTxt, ret_10);
1686 16 l_variableNamingConvention := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("structured"));
1687 16 l_numberOfEventIndicators := CodegenFMUCommon.getNumberOfEventIndicators(Tpl.emptyTxt, i_simCode);
1688 16 txt := Tpl.writeTok(txt, Tpl.ST_STRING("fmiVersion=\""));
1689 16 txt := Tpl.writeText(txt, l_fmiVersion);
1690 16 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
1691 "\"\n",
1692 "modelName=\""
1693 }, false));
1694 16 ret_13 := Util.escapeModelicaStringToXmlString(Tpl.textString(l_modelName));
1695 16 txt := Tpl.writeStr(txt, ret_13);
1696 16 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
1697 "\"\n",
1698 "instantiationToken=\"{"
1699 }, false));
1700 16 txt := Tpl.writeStr(txt, a_guid);
1701 16 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
1702 "}\"\n",
1703 "description=\""
1704 }, false));
1705 16 ret_14 := Util.escapeModelicaStringToXmlString(Tpl.textString(l_description));
1706 16 txt := Tpl.writeStr(txt, ret_14);
1707 16 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
1708 "\"\n",
1709 "version=\""
1710 }, false));
1711 16 ret_15 := Util.escapeModelicaStringToXmlString(Tpl.textString(l_version));
1712 16 txt := Tpl.writeStr(txt, ret_15);
1713 16 txt := Tpl.writeTok(txt, Tpl.ST_LINE("\"\n"));
1714
2/4
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 16 times.
16 ret_16 := stringEq(Tpl.textString(l_author), "");
1715 16 txt := fun_100(txt, ret_16, l_author);
1716 16 txt := Tpl.softNewLine(txt);
1717
2/4
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 16 times.
16 ret_17 := stringEq(Tpl.textString(l_copyright), "");
1718 16 txt := fun_101(txt, ret_17, l_copyright);
1719 16 txt := Tpl.softNewLine(txt);
1720
2/4
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 16 times.
16 ret_18 := stringEq(Tpl.textString(l_license), "");
1721 16 txt := fun_102(txt, ret_18, l_license);
1722 16 txt := Tpl.softNewLine(txt);
1723 16 txt := Tpl.writeTok(txt, Tpl.ST_STRING("generationTool=\""));
1724 16 ret_19 := Util.escapeModelicaStringToXmlString(Tpl.textString(l_generationTool));
1725 16 txt := Tpl.writeStr(txt, ret_19);
1726 16 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
1727 "\"\n",
1728 "generationDateAndTime=\""
1729 }, false));
1730 16 ret_20 := Util.escapeModelicaStringToXmlString(Tpl.textString(l_generationDateAndTime));
1731 16 txt := Tpl.writeStr(txt, ret_20);
1732 16 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
1733 "\"\n",
1734 "variableNamingConvention=\""
1735 }, false));
1736 16 txt := Tpl.writeText(txt, l_variableNamingConvention);
1737 16 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
1738 "\"\n",
1739 "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n",
1740 "xsi:noNamespaceSchemaLocation=\"https://raw.githubusercontent.com/modelica/fmi-standard/main/schema/fmi3ModelDescription.xsd\""
1741 }, false));
1742 then txt;
1743
1744 case ( txt,
1745 _,
1746 _ )
1747 then txt;
1748 end match;
1749 end fmiModelDescriptionAttributes;
1750
1751 protected function fun_104
1752 input Tpl.Text in_txt;
1753 input Boolean in_mArg;
1754
1755 output Tpl.Text out_txt;
1756 algorithm
1757 out_txt :=
1758 match(in_txt, in_mArg)
1759 local
1760 Tpl.Text txt;
1761
1762 case ( txt,
1763 false )
1764 algorithm
1765 13 txt := Tpl.writeTok(txt, Tpl.ST_STRING("providesDirectionalDerivatives=\"false\""));
1766 then txt;
1767
1768 case ( txt,
1769 _ )
1770 algorithm
1771 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING("providesDirectionalDerivatives=\"true\""));
1772 then txt;
1773 end match;
1774 end fun_104;
1775
1776 protected function fun_105
1777 input Tpl.Text in_txt;
1778 input SimCode.SimCode in_a_simCode;
1779
1780 output Tpl.Text out_txt;
1781 algorithm
1782 out_txt :=
1783 match(in_txt, in_a_simCode)
1784 local
1785 Tpl.Text txt;
1786 SimCode.SimCode i_simCode;
1787 Boolean ret_1;
1788 Tpl.Text l_modelIdentifier;
1789
1790 case ( txt,
1791 (i_simCode as SimCode.SIMCODE(modelInfo = _)) )
1792 algorithm
1793 14 l_modelIdentifier := CodegenUtilSimulation.modelNamePrefix(Tpl.emptyTxt, i_simCode);
1794 14 txt := Tpl.writeTok(txt, Tpl.ST_LINE("<ModelExchange\n"));
1795 14 txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
1796 14 txt := Tpl.writeTok(txt, Tpl.ST_STRING("modelIdentifier=\""));
1797 14 txt := Tpl.writeText(txt, l_modelIdentifier);
1798 14 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
1799 "\"\n",
1800 "needsExecutionTool=\"false\"\n",
1801 "canBeInstantiatedOnlyOncePerProcess=\"false\"\n",
1802 "canGetAndSetFMUState=\"true\"\n",
1803 "canSerializeFMUState=\"true\"\n"
1804 }, true));
1805 14 ret_1 := SimCodeCodegenUtil.providesDirectionalDerivative(i_simCode);
1806 14 txt := fun_104(txt, ret_1);
1807 14 txt := Tpl.softNewLine(txt);
1808 14 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
1809 "providesAdjointDerivatives=\"false\"\n",
1810 "providesPerElementDependencies=\"false\"\n",
1811 "needsCompletedIntegratorStep=\"true\"/>"
1812 }, false));
1813 14 txt := Tpl.popBlock(txt);
1814 then txt;
1815
1816 case ( txt,
1817 _ )
1818 then txt;
1819 end match;
1820 end fun_105;
1821
1822 public function ModelExchange3
1823 input Tpl.Text txt;
1824 input SimCode.SimCode a_simCode;
1825 input list<String> a_sourceFiles;
1826
1827 output Tpl.Text out_txt;
1828 algorithm
1829 14 out_txt := fun_105(txt, a_simCode);
1830 end ModelExchange3;
1831
1832 protected function fun_107
1833 input Tpl.Text in_txt;
1834 input Boolean in_mArg;
1835
1836 output Tpl.Text out_txt;
1837 algorithm
1838 out_txt :=
1839 match(in_txt, in_mArg)
1840 local
1841 Tpl.Text txt;
1842
1843 case ( txt,
1844 false )
1845 algorithm
1846 2 txt := Tpl.writeTok(txt, Tpl.ST_STRING("providesDirectionalDerivatives=\"false\""));
1847 then txt;
1848
1849 case ( txt,
1850 _ )
1851 algorithm
1852 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("providesDirectionalDerivatives=\"true\""));
1853 then txt;
1854 end match;
1855 end fun_107;
1856
1857 protected function fun_108
1858 input Tpl.Text in_txt;
1859 input SimCode.SimCode in_a_simCode;
1860
1861 output Tpl.Text out_txt;
1862 algorithm
1863 out_txt :=
1864 match(in_txt, in_a_simCode)
1865 local
1866 Tpl.Text txt;
1867 SimCode.SimCode i_simCode;
1868 Boolean ret_2;
1869 String ret_1;
1870 Tpl.Text l_modelIdentifier;
1871
1872 case ( txt,
1873 (i_simCode as SimCode.SIMCODE(modelInfo = _)) )
1874 algorithm
1875 2 l_modelIdentifier := CodegenUtilSimulation.modelNamePrefix(Tpl.emptyTxt, i_simCode);
1876 2 txt := Tpl.writeTok(txt, Tpl.ST_LINE("<CoSimulation\n"));
1877 2 txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
1878 2 txt := Tpl.writeTok(txt, Tpl.ST_STRING("modelIdentifier=\""));
1879 2 ret_1 := Util.escapeModelicaStringToXmlString(Tpl.textString(l_modelIdentifier));
1880 2 txt := Tpl.writeStr(txt, ret_1);
1881 2 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
1882 "\"\n",
1883 "needsExecutionTool=\"false\"\n",
1884 "canHandleVariableCommunicationStepSize=\"true\"\n",
1885 "canBeInstantiatedOnlyOncePerProcess=\"false\"\n",
1886 "maxOutputDerivativeOrder=\"1\"\n",
1887 "providesIntermediateUpdate=\"false\"\n",
1888 "mightReturnEarlyFromDoStep=\"true\"\n",
1889 "canReturnEarlyAfterIntermediateUpdate=\"false\"\n",
1890 "hasEventMode=\"true\"\n",
1891 "providesEvaluateDiscreteStates=\"false\"\n",
1892 "recommendedIntermediateInputSmoothness=\"0\"\n",
1893 "canGetAndSetFMUState=\"true\"\n",
1894 "canSerializeFMUState=\"true\"\n"
1895 }, true));
1896 2 ret_2 := SimCodeCodegenUtil.providesDirectionalDerivative(i_simCode);
1897 2 txt := fun_107(txt, ret_2);
1898 2 txt := Tpl.softNewLine(txt);
1899 2 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
1900 "providesAdjointDerivatives=\"false\"\n",
1901 "providesPerElementDependencies=\"false\"/>"
1902 }, false));
1903 2 txt := Tpl.popBlock(txt);
1904 then txt;
1905
1906 case ( txt,
1907 _ )
1908 then txt;
1909 end match;
1910 end fun_108;
1911
1912 public function CoSimulation3
1913 input Tpl.Text txt;
1914 input SimCode.SimCode a_simCode;
1915 input list<String> a_sourceFiles;
1916
1917 output Tpl.Text out_txt;
1918 algorithm
1919 2 out_txt := fun_108(txt, a_simCode);
1920 end CoSimulation3;
1921
1922 protected function fun_110
1923 input Tpl.Text in_txt;
1924 input Boolean in_mArg;
1925
1926 output Tpl.Text out_txt;
1927 algorithm
1928 out_txt :=
1929 match(in_txt, in_mArg)
1930 local
1931 Tpl.Text txt;
1932
1933 case ( txt,
1934 false )
1935 algorithm
1936 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("providesDirectionalDerivatives=\"false\""));
1937 then txt;
1938
1939 case ( txt,
1940 _ )
1941 algorithm
1942 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("providesDirectionalDerivatives=\"true\""));
1943 then txt;
1944 end match;
1945 end fun_110;
1946
1947 protected function fun_111
1948 input Tpl.Text in_txt;
1949 input SimCode.SimCode in_a_simCode;
1950
1951 output Tpl.Text out_txt;
1952 algorithm
1953 out_txt :=
1954 match(in_txt, in_a_simCode)
1955 local
1956 Tpl.Text txt;
1957 SimCode.SimCode i_simCode;
1958 Boolean ret_2;
1959 String ret_1;
1960 Tpl.Text l_modelIdentifier;
1961
1962 case ( txt,
1963 (i_simCode as SimCode.SIMCODE(modelInfo = _)) )
1964 algorithm
1965 ✗ l_modelIdentifier := CodegenUtilSimulation.modelNamePrefix(Tpl.emptyTxt, i_simCode);
1966 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("<ScheduledExecution\n"));
1967 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
1968 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("modelIdentifier=\""));
1969 ✗ ret_1 := Util.escapeModelicaStringToXmlString(Tpl.textString(l_modelIdentifier));
1970 ✗ txt := Tpl.writeStr(txt, ret_1);
1971 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
1972 "\"\n",
1973 "needsExecutionTool=\"false\"\n",
1974 "canBeInstantiatedOnlyOncePerProcess=\"false\"\n",
1975 "canGetAndSetFMUState=\"true\"\n",
1976 "canSerializeFMUState=\"true\"\n"
1977 }, true));
1978 ✗ ret_2 := SimCodeCodegenUtil.providesDirectionalDerivative(i_simCode);
1979 ✗ txt := fun_110(txt, ret_2);
1980 ✗ txt := Tpl.softNewLine(txt);
1981 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
1982 "providesAdjointDerivatives=\"false\"\n",
1983 "providesPerElementDependencies=\"false\"/>"
1984 }, false));
1985 ✗ txt := Tpl.popBlock(txt);
1986 then txt;
1987
1988 case ( txt,
1989 _ )
1990 then txt;
1991 end match;
1992 end fun_111;
1993
1994 public function ScheduledExecution3
1995 input Tpl.Text txt;
1996 input SimCode.SimCode a_simCode;
1997 input list<String> a_sourceFiles;
1998
1999 output Tpl.Text out_txt;
2000 algorithm
2001 ✗ out_txt := fun_111(txt, a_simCode);
2002 end ScheduledExecution3;
2003
2004 public function DefaultExperiment3
2005 input Tpl.Text in_txt;
2006 input Option<SimCode.SimulationSettings> in_a_simulationSettingsOpt;
2007
2008 output Tpl.Text out_txt;
2009 algorithm
2010 out_txt :=
2011 match(in_txt, in_a_simulationSettingsOpt)
2012 local
2013 Tpl.Text txt;
2014 Real i_stepSize;
2015 Real i_tolerance;
2016 Real i_stopTime;
2017 Real i_startTime;
2018
2019 case ( txt,
2020 SOME(SimCode.SIMULATION_SETTINGS(startTime = i_startTime, stopTime = i_stopTime, tolerance = i_tolerance, stepSize = i_stepSize)) )
2021 algorithm
2022 16 txt := Tpl.writeTok(txt, Tpl.ST_STRING("<DefaultExperiment startTime=\""));
2023 16 txt := Tpl.writeStr(txt, realString(i_startTime));
2024 16 txt := Tpl.writeTok(txt, Tpl.ST_STRING("\" stopTime=\""));
2025 16 txt := Tpl.writeStr(txt, realString(i_stopTime));
2026 16 txt := Tpl.writeTok(txt, Tpl.ST_STRING("\" tolerance=\""));
2027 16 txt := Tpl.writeStr(txt, realString(i_tolerance));
2028 16 txt := Tpl.writeTok(txt, Tpl.ST_STRING("\" stepSize=\""));
2029 16 txt := Tpl.writeStr(txt, realString(i_stepSize));
2030 16 txt := Tpl.writeTok(txt, Tpl.ST_STRING("\"/>"));
2031 then txt;
2032
2033 case ( txt,
2034 _ )
2035 then txt;
2036 end match;
2037 end DefaultExperiment3;
2038
2039 protected function lm_114
2040 input output Tpl.Text txt;
2041 input list<SimCodeVar.SimVar> items;
2042 algorithm
2043
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 16 times.
20 for lstElt_114 in items loop
2044 txt := match lstElt_114
2045 local
2046 SimCodeVar.SimVar i_var;
2047
2048 case i_var
2049 algorithm
2050 4 txt := TypeDefinition3(txt, i_var);
2051 4 txt := Tpl.nextIter(txt);
2052 then txt;
2053 end match;
2054 end for;
2055 end lm_114;
2056
2057 protected function fun_115
2058 input Tpl.Text in_txt;
2059 input Boolean in_mArg;
2060 input Tpl.Text in_a_types;
2061
2062 output Tpl.Text out_txt;
2063 algorithm
2064 out_txt :=
2065 match(in_txt, in_mArg, in_a_types)
2066 local
2067 Tpl.Text txt;
2068 Tpl.Text a_types;
2069
2070 case ( txt,
2071 false,
2072 _ )
2073 then txt;
2074
2075 case ( txt,
2076 _,
2077 a_types )
2078 algorithm
2079 2 txt := Tpl.writeTok(txt, Tpl.ST_LINE("<TypeDefinitions>\n"));
2080 2 txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
2081 2 txt := Tpl.writeText(txt, a_types);
2082 2 txt := Tpl.softNewLine(txt);
2083 2 txt := Tpl.popBlock(txt);
2084 2 txt := Tpl.writeTok(txt, Tpl.ST_STRING("</TypeDefinitions>"));
2085 then txt;
2086 end match;
2087 end fun_115;
2088
2089 protected function fun_116
2090 input Tpl.Text in_txt;
2091 input SimCode.ModelInfo in_a_modelInfo;
2092
2093 output Tpl.Text out_txt;
2094 algorithm
2095 out_txt :=
2096 match(in_txt, in_a_modelInfo)
2097 local
2098 Tpl.Text txt;
2099 SimCodeVar.SimVars i_vars;
2100 Boolean ret_3;
2101 Boolean ret_2;
2102 list<SimCodeVar.SimVar> ret_1;
2103 Tpl.Text l_types;
2104
2105 case ( txt,
2106 SimCode.MODELINFO(vars = (i_vars as SimCodeVar.SIMVARS(stateVars = _))) )
2107 algorithm
2108 16 ret_1 := SimCodeCodegenUtil.getEnumerationTypes(i_vars);
2109 16 l_types := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2110 16 l_types := lm_114(l_types, ret_1);
2111 16 l_types := Tpl.popIter(l_types);
2112
3/4
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14 times.
16 ret_2 := stringEq(Tpl.textString(l_types), "");
2113 16 ret_3 := boolNot(ret_2);
2114 16 txt := fun_115(txt, ret_3, l_types);
2115 then txt;
2116
2117 case ( txt,
2118 _ )
2119 then txt;
2120 end match;
2121 end fun_116;
2122
2123 public function TypeDefinitions3
2124 input Tpl.Text in_txt;
2125 input SimCode.SimCode in_a_simCode;
2126
2127 output Tpl.Text out_txt;
2128 algorithm
2129 out_txt :=
2130 match(in_txt, in_a_simCode)
2131 local
2132 Tpl.Text txt;
2133 SimCode.ModelInfo i_modelInfo;
2134
2135 case ( txt,
2136 SimCode.SIMCODE(modelInfo = i_modelInfo) )
2137 algorithm
2138 16 txt := fun_116(txt, i_modelInfo);
2139 then txt;
2140
2141 case ( txt,
2142 _ )
2143 then txt;
2144 end match;
2145 end TypeDefinitions3;
2146
2147 protected function lm_118
2148 input output Tpl.Text txt;
2149 input list<String> items;
2150 algorithm
2151
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 4 times.
25 for lstElt_118 in items loop
2152 txt := match lstElt_118
2153 local
2154 Integer x_i0;
2155 String i_name;
2156
2157 case i_name
2158 algorithm
2159 21 x_i0 := Tpl.getIteri_i0(txt);
2160 21 txt := Tpl.writeTok(txt, Tpl.ST_STRING("<Item name=\""));
2161 21 txt := Tpl.writeStr(txt, i_name);
2162 21 txt := Tpl.writeTok(txt, Tpl.ST_STRING("\" value=\""));
2163 21 txt := Tpl.writeStr(txt, intString(x_i0));
2164 21 txt := Tpl.writeTok(txt, Tpl.ST_STRING("\"/>"));
2165 21 txt := Tpl.nextIter(txt);
2166 then txt;
2167 end match;
2168 end for;
2169 end lm_118;
2170
2171 public function TypeDefinition3
2172 input Tpl.Text in_txt;
2173 input SimCodeVar.SimVar in_a_simVar;
2174
2175 output Tpl.Text out_txt;
2176 algorithm
2177 out_txt :=
2178 match(in_txt, in_a_simVar)
2179 local
2180 Tpl.Text txt;
2181 list<String> i_names;
2182 Absyn.Path i_path;
2183 String ret_1;
2184 String ret_0;
2185
2186 case ( txt,
2187 SimCodeVar.SIMVAR(type_ = DAE.T_ENUMERATION(path = i_path, names = i_names)) )
2188 algorithm
2189 4 txt := Tpl.writeTok(txt, Tpl.ST_STRING("<EnumerationType name=\""));
2190 4 ret_0 := AbsynUtil.pathString(i_path, ".", false, false);
2191 4 txt := Tpl.writeStr(txt, ret_0);
2192 4 txt := Tpl.writeTok(txt, Tpl.ST_STRING("\" quantity=\""));
2193 4 ret_1 := AbsynUtil.pathString(i_path, ".", false, false);
2194 4 txt := Tpl.writeStr(txt, ret_1);
2195 4 txt := Tpl.writeTok(txt, Tpl.ST_LINE("\">\n"));
2196 4 txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
2197 4 txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(1, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2198 4 txt := lm_118(txt, i_names);
2199 4 txt := Tpl.popIter(txt);
2200 4 txt := Tpl.softNewLine(txt);
2201 4 txt := Tpl.popBlock(txt);
2202 4 txt := Tpl.writeTok(txt, Tpl.ST_STRING("</EnumerationType>"));
2203 then txt;
2204
2205 case ( txt,
2206 _ )
2207 then txt;
2208 end match;
2209 end TypeDefinition3;
2210
2211 protected function lm_120
2212 input output Tpl.Text txt;
2213 input list<SimCodeVar.SimVar> items;
2214 input Tpl.Text a_numScalarStates;
2215 input SimCode.SimCode a_simCode;
2216 algorithm
2217
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 16 times.
43 for lstElt_120 in items loop
2218 txt := match lstElt_120
2219 local
2220 SimCodeVar.SimVar i_var;
2221
2222 case i_var
2223 algorithm
2224 27 txt := Variable3(txt, i_var, a_simCode, Tpl.textString(a_numScalarStates));
2225 27 txt := Tpl.nextIter(txt);
2226 then txt;
2227 end match;
2228 end for;
2229 end lm_120;
2230
2231 protected function lm_121
2232 input output Tpl.Text txt;
2233 input list<SimCodeVar.SimVar> items;
2234 input Tpl.Text a_numScalarStates;
2235 input SimCode.SimCode a_simCode;
2236 algorithm
2237
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 16 times.
43 for lstElt_121 in items loop
2238 txt := match lstElt_121
2239 local
2240 SimCodeVar.SimVar i_var;
2241
2242 case i_var
2243 algorithm
2244 27 txt := Variable3(txt, i_var, a_simCode, Tpl.textString(a_numScalarStates));
2245 27 txt := Tpl.nextIter(txt);
2246 then txt;
2247 end match;
2248 end for;
2249 end lm_121;
2250
2251 protected function lm_122
2252 input output Tpl.Text txt;
2253 input list<SimCodeVar.SimVar> items;
2254 input Tpl.Text a_numScalarStates;
2255 input SimCode.SimCode a_simCode;
2256 algorithm
2257
2/2
✓ Branch 0 taken 1068 times.
✓ Branch 1 taken 16 times.
1084 for lstElt_122 in items loop
2258 txt := match lstElt_122
2259 local
2260 SimCodeVar.SimVar i_var;
2261
2262 case i_var
2263 algorithm
2264 1068 txt := Variable3(txt, i_var, a_simCode, Tpl.textString(a_numScalarStates));
2265 1068 txt := Tpl.nextIter(txt);
2266 then txt;
2267 end match;
2268 end for;
2269 end lm_122;
2270
2271 protected function lm_123
2272 input output Tpl.Text txt;
2273 input list<SimCodeVar.SimVar> items;
2274 input Tpl.Text a_numScalarStates;
2275 input SimCode.SimCode a_simCode;
2276 algorithm
2277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 for lstElt_123 in items loop
2278 txt := match lstElt_123
2279 local
2280 SimCodeVar.SimVar i_var;
2281
2282 case i_var
2283 algorithm
2284 ✗ txt := Variable3(txt, i_var, a_simCode, Tpl.textString(a_numScalarStates));
2285 ✗ txt := Tpl.nextIter(txt);
2286 then txt;
2287 end match;
2288 end for;
2289 end lm_123;
2290
2291 protected function lm_124
2292 input output Tpl.Text txt;
2293 input list<SimCodeVar.SimVar> items;
2294 input Tpl.Text a_numScalarStates;
2295 input SimCode.SimCode a_simCode;
2296 algorithm
2297
2/2
✓ Branch 0 taken 671 times.
✓ Branch 1 taken 16 times.
687 for lstElt_124 in items loop
2298 txt := match lstElt_124
2299 local
2300 SimCodeVar.SimVar i_var;
2301
2302 case i_var
2303 algorithm
2304 671 txt := Variable3(txt, i_var, a_simCode, Tpl.textString(a_numScalarStates));
2305 671 txt := Tpl.nextIter(txt);
2306 then txt;
2307 end match;
2308 end for;
2309 end lm_124;
2310
2311 protected function lm_125
2312 input output Tpl.Text txt;
2313 input list<SimCodeVar.SimVar> items;
2314 input Tpl.Text a_numScalarStates;
2315 input SimCode.SimCode a_simCode;
2316 algorithm
2317
2/2
✓ Branch 0 taken 1272 times.
✓ Branch 1 taken 16 times.
1288 for lstElt_125 in items loop
2318 txt := match lstElt_125
2319 local
2320 SimCodeVar.SimVar i_var;
2321
2322 case i_var
2323 algorithm
2324 1272 txt := Variable3(txt, i_var, a_simCode, Tpl.textString(a_numScalarStates));
2325 1272 txt := Tpl.nextIter(txt);
2326 then txt;
2327 end match;
2328 end for;
2329 end lm_125;
2330
2331 protected function lm_126
2332 input output Tpl.Text txt;
2333 input list<SimCodeVar.SimVar> items;
2334 input Tpl.Text a_numScalarStates;
2335 input SimCode.SimCode a_simCode;
2336 algorithm
2337
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 16 times.
65 for lstElt_126 in items loop
2338 txt := match lstElt_126
2339 local
2340 SimCodeVar.SimVar i_var;
2341
2342 case i_var
2343 algorithm
2344 49 txt := Variable3(txt, i_var, a_simCode, Tpl.textString(a_numScalarStates));
2345 49 txt := Tpl.nextIter(txt);
2346 then txt;
2347 end match;
2348 end for;
2349 end lm_126;
2350
2351 protected function lm_127
2352 input output Tpl.Text txt;
2353 input list<SimCodeVar.SimVar> items;
2354 input Tpl.Text a_numScalarStates;
2355 input SimCode.SimCode a_simCode;
2356 algorithm
2357
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 16 times.
53 for lstElt_127 in items loop
2358 txt := match lstElt_127
2359 local
2360 SimCodeVar.SimVar i_var;
2361
2362 case i_var
2363 algorithm
2364 37 txt := Variable3(txt, i_var, a_simCode, Tpl.textString(a_numScalarStates));
2365 37 txt := Tpl.nextIter(txt);
2366 then txt;
2367 end match;
2368 end for;
2369 end lm_127;
2370
2371 protected function lm_128
2372 input output Tpl.Text txt;
2373 input list<SimCodeVar.SimVar> items;
2374 input Tpl.Text a_numScalarStates;
2375 input SimCode.SimCode a_simCode;
2376 algorithm
2377
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 16 times.
67 for lstElt_128 in items loop
2378 txt := match lstElt_128
2379 local
2380 SimCodeVar.SimVar i_var;
2381
2382 case i_var
2383 algorithm
2384 51 txt := Variable3(txt, i_var, a_simCode, Tpl.textString(a_numScalarStates));
2385 51 txt := Tpl.nextIter(txt);
2386 then txt;
2387 end match;
2388 end for;
2389 end lm_128;
2390
2391 protected function lm_129
2392 input output Tpl.Text txt;
2393 input list<SimCodeVar.SimVar> items;
2394 input Tpl.Text a_numScalarStates;
2395 input SimCode.SimCode a_simCode;
2396 algorithm
2397
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 16 times.
17 for lstElt_129 in items loop
2398 txt := match lstElt_129
2399 local
2400 SimCodeVar.SimVar i_var;
2401
2402 case i_var
2403 algorithm
2404 1 txt := Variable3(txt, i_var, a_simCode, Tpl.textString(a_numScalarStates));
2405 1 txt := Tpl.nextIter(txt);
2406 then txt;
2407 end match;
2408 end for;
2409 end lm_129;
2410
2411 protected function lm_130
2412 input output Tpl.Text txt;
2413 input list<SimCodeVar.SimVar> items;
2414 input Tpl.Text a_numScalarStates;
2415 input SimCode.SimCode a_simCode;
2416 algorithm
2417
2/2
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 16 times.
125 for lstElt_130 in items loop
2418 txt := match lstElt_130
2419 local
2420 SimCodeVar.SimVar i_var;
2421
2422 case i_var
2423 algorithm
2424 109 txt := Variable3(txt, i_var, a_simCode, Tpl.textString(a_numScalarStates));
2425 109 txt := Tpl.nextIter(txt);
2426 then txt;
2427 end match;
2428 end for;
2429 end lm_130;
2430
2431 protected function lm_131
2432 input output Tpl.Text txt;
2433 input list<SimCodeVar.SimVar> items;
2434 input Tpl.Text a_numScalarStates;
2435 input SimCode.SimCode a_simCode;
2436 algorithm
2437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 for lstElt_131 in items loop
2438 txt := match lstElt_131
2439 local
2440 SimCodeVar.SimVar i_var;
2441
2442 case i_var
2443 algorithm
2444 ✗ txt := Variable3(txt, i_var, a_simCode, Tpl.textString(a_numScalarStates));
2445 ✗ txt := Tpl.nextIter(txt);
2446 then txt;
2447 end match;
2448 end for;
2449 end lm_131;
2450
2451 protected function lm_132
2452 input output Tpl.Text txt;
2453 input list<SimCodeVar.SimVar> items;
2454 input Tpl.Text a_numScalarStates;
2455 input SimCode.SimCode a_simCode;
2456 algorithm
2457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 for lstElt_132 in items loop
2458 txt := match lstElt_132
2459 local
2460 SimCodeVar.SimVar i_var;
2461
2462 case i_var
2463 algorithm
2464 ✗ txt := Variable3(txt, i_var, a_simCode, Tpl.textString(a_numScalarStates));
2465 ✗ txt := Tpl.nextIter(txt);
2466 then txt;
2467 end match;
2468 end for;
2469 end lm_132;
2470
2471 protected function lm_133
2472 input output Tpl.Text txt;
2473 input list<SimCodeVar.SimVar> items;
2474 input Tpl.Text a_numScalarStates;
2475 input SimCode.SimCode a_simCode;
2476 algorithm
2477
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 16 times.
54 for lstElt_133 in items loop
2478 txt := match lstElt_133
2479 local
2480 SimCodeVar.SimVar i_var;
2481
2482 case i_var
2483 algorithm
2484 38 txt := Variable3(txt, i_var, a_simCode, Tpl.textString(a_numScalarStates));
2485 38 txt := Tpl.nextIter(txt);
2486 then txt;
2487 end match;
2488 end for;
2489 end lm_133;
2490
2491 protected function lm_134
2492 input output Tpl.Text txt;
2493 input list<SimCodeVar.SimVar> items;
2494 input Tpl.Text a_numScalarStates;
2495 input SimCode.SimCode a_simCode;
2496 algorithm
2497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 for lstElt_134 in items loop
2498 txt := match lstElt_134
2499 local
2500 SimCodeVar.SimVar i_var;
2501
2502 case i_var
2503 algorithm
2504 ✗ txt := Variable3(txt, i_var, a_simCode, Tpl.textString(a_numScalarStates));
2505 ✗ txt := Tpl.nextIter(txt);
2506 then txt;
2507 end match;
2508 end for;
2509 end lm_134;
2510
2511 protected function lm_135
2512 input output Tpl.Text txt;
2513 input list<SimCodeVar.SimVar> items;
2514 input Tpl.Text a_numScalarStates;
2515 input SimCode.SimCode a_simCode;
2516 algorithm
2517
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 16 times.
17 for lstElt_135 in items loop
2518 txt := match lstElt_135
2519 local
2520 SimCodeVar.SimVar i_var;
2521
2522 case i_var
2523 algorithm
2524 1 txt := Variable3(txt, i_var, a_simCode, Tpl.textString(a_numScalarStates));
2525 1 txt := Tpl.nextIter(txt);
2526 then txt;
2527 end match;
2528 end for;
2529 end lm_135;
2530
2531 protected function lm_136
2532 input output Tpl.Text txt;
2533 input list<SimCode.FmiClock> items;
2534 input String a_FMUType;
2535 algorithm
2536
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 16 times.
17 for lstElt_136 in items loop
2537 txt := match lstElt_136
2538 local
2539 SimCode.FmiClock i_clk;
2540
2541 case i_clk
2542 algorithm
2543 1 txt := Clock3(txt, i_clk, a_FMUType);
2544 1 txt := Tpl.nextIter(txt);
2545 then txt;
2546 end match;
2547 end for;
2548 end lm_136;
2549
2550 protected function fun_137
2551 input Tpl.Text in_txt;
2552 input Boolean in_mArg;
2553 input SimCode.SimCode in_a_simCode;
2554
2555 output Tpl.Text out_txt;
2556 algorithm
2557 out_txt :=
2558 match(in_txt, in_mArg, in_a_simCode)
2559 local
2560 Tpl.Text txt;
2561 SimCode.SimCode a_simCode;
2562
2563 case ( txt,
2564 false,
2565 _ )
2566 then txt;
2567
2568 case ( txt,
2569 _,
2570 a_simCode )
2571 algorithm
2572 14 txt := DaeModeVariables3(txt, a_simCode);
2573 then txt;
2574 end match;
2575 end fun_137;
2576
2577 protected function fun_138
2578 input Tpl.Text in_txt;
2579 input SimCode.ModelInfo in_a_modelInfo;
2580 input String in_a_FMUType;
2581 input SimCode.SimCode in_a_simCode;
2582
2583 output Tpl.Text out_txt;
2584 algorithm
2585 out_txt :=
2586 match(in_txt, in_a_modelInfo, in_a_FMUType, in_a_simCode)
2587 local
2588 Tpl.Text txt;
2589 String a_FMUType;
2590 SimCode.SimCode a_simCode;
2591 list<SimCodeVar.SimVar> i_vars_extObjVars;
2592 list<SimCodeVar.SimVar> i_vars_stringAliasVars;
2593 list<SimCodeVar.SimVar> i_vars_stringParamVars;
2594 list<SimCodeVar.SimVar> i_vars_stringAlgVars;
2595 list<SimCodeVar.SimVar> i_vars_boolAliasVars;
2596 list<SimCodeVar.SimVar> i_vars_boolParamVars;
2597 list<SimCodeVar.SimVar> i_vars_boolAlgVars;
2598 list<SimCodeVar.SimVar> i_vars_intAliasVars;
2599 list<SimCodeVar.SimVar> i_vars_intParamVars;
2600 list<SimCodeVar.SimVar> i_vars_intAlgVars;
2601 list<SimCodeVar.SimVar> i_vars_aliasVars;
2602 list<SimCodeVar.SimVar> i_vars_paramVars;
2603 list<SimCodeVar.SimVar> i_vars_discreteAlgVars;
2604 list<SimCodeVar.SimVar> i_vars_algVars;
2605 list<SimCodeVar.SimVar> i_vars_derivativeVars;
2606 list<SimCodeVar.SimVar> i_vars_stateVars;
2607 list<SimCodeVar.SimVar> i_stateVars;
2608 Boolean ret_3;
2609 list<SimCode.FmiClock> ret_2;
2610 Integer ret_1;
2611 Tpl.Text l_numScalarStates;
2612
2613 case ( txt,
2614 SimCode.MODELINFO(vars = SimCodeVar.SIMVARS(stateVars = (i_vars_stateVars as i_stateVars), derivativeVars = i_vars_derivativeVars, algVars = i_vars_algVars, discreteAlgVars = i_vars_discreteAlgVars, paramVars = i_vars_paramVars, aliasVars = i_vars_aliasVars, intAlgVars = i_vars_intAlgVars, intParamVars = i_vars_intParamVars, intAliasVars = i_vars_intAliasVars, boolAlgVars = i_vars_boolAlgVars, boolParamVars = i_vars_boolParamVars, boolAliasVars = i_vars_boolAliasVars, stringAlgVars = i_vars_stringAlgVars, stringParamVars = i_vars_stringParamVars, stringAliasVars = i_vars_stringAliasVars, extObjVars = i_vars_extObjVars)),
2615 a_FMUType,
2616 a_simCode )
2617 algorithm
2618 16 ret_1 := SimCodeCodegenUtil.numScalarElems(i_stateVars);
2619 16 l_numScalarStates := Tpl.writeStr(Tpl.emptyTxt, intString(ret_1));
2620 16 txt := Tpl.writeTok(txt, Tpl.ST_LINE("<ModelVariables>\n"));
2621 16 txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
2622 16 txt := TimeVariable3(txt, a_simCode);
2623 16 txt := Tpl.softNewLine(txt);
2624 16 txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2625 16 txt := lm_120(txt, i_vars_stateVars, l_numScalarStates, a_simCode);
2626 16 txt := Tpl.popIter(txt);
2627 16 txt := Tpl.softNewLine(txt);
2628 16 txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2629 16 txt := lm_121(txt, i_vars_derivativeVars, l_numScalarStates, a_simCode);
2630 16 txt := Tpl.popIter(txt);
2631 16 txt := Tpl.softNewLine(txt);
2632 16 txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2633 16 txt := lm_122(txt, i_vars_algVars, l_numScalarStates, a_simCode);
2634 16 txt := Tpl.popIter(txt);
2635 16 txt := Tpl.softNewLine(txt);
2636 16 txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2637 16 txt := lm_123(txt, i_vars_discreteAlgVars, l_numScalarStates, a_simCode);
2638 16 txt := Tpl.popIter(txt);
2639 16 txt := Tpl.softNewLine(txt);
2640 16 txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2641 16 txt := lm_124(txt, i_vars_paramVars, l_numScalarStates, a_simCode);
2642 16 txt := Tpl.popIter(txt);
2643 16 txt := Tpl.softNewLine(txt);
2644 16 txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2645 16 txt := lm_125(txt, i_vars_aliasVars, l_numScalarStates, a_simCode);
2646 16 txt := Tpl.popIter(txt);
2647 16 txt := Tpl.softNewLine(txt);
2648 16 txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2649 16 txt := lm_126(txt, i_vars_intAlgVars, l_numScalarStates, a_simCode);
2650 16 txt := Tpl.popIter(txt);
2651 16 txt := Tpl.softNewLine(txt);
2652 16 txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2653 16 txt := lm_127(txt, i_vars_intParamVars, l_numScalarStates, a_simCode);
2654 16 txt := Tpl.popIter(txt);
2655 16 txt := Tpl.softNewLine(txt);
2656 16 txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2657 16 txt := lm_128(txt, i_vars_intAliasVars, l_numScalarStates, a_simCode);
2658 16 txt := Tpl.popIter(txt);
2659 16 txt := Tpl.softNewLine(txt);
2660 16 txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2661 16 txt := lm_129(txt, i_vars_boolAlgVars, l_numScalarStates, a_simCode);
2662 16 txt := Tpl.popIter(txt);
2663 16 txt := Tpl.softNewLine(txt);
2664 16 txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2665 16 txt := lm_130(txt, i_vars_boolParamVars, l_numScalarStates, a_simCode);
2666 16 txt := Tpl.popIter(txt);
2667 16 txt := Tpl.softNewLine(txt);
2668 16 txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2669 16 txt := lm_131(txt, i_vars_boolAliasVars, l_numScalarStates, a_simCode);
2670 16 txt := Tpl.popIter(txt);
2671 16 txt := Tpl.softNewLine(txt);
2672 16 txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2673 16 txt := lm_132(txt, i_vars_stringAlgVars, l_numScalarStates, a_simCode);
2674 16 txt := Tpl.popIter(txt);
2675 16 txt := Tpl.softNewLine(txt);
2676 16 txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2677 16 txt := lm_133(txt, i_vars_stringParamVars, l_numScalarStates, a_simCode);
2678 16 txt := Tpl.popIter(txt);
2679 16 txt := Tpl.softNewLine(txt);
2680 16 txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2681 16 txt := lm_134(txt, i_vars_stringAliasVars, l_numScalarStates, a_simCode);
2682 16 txt := Tpl.popIter(txt);
2683 16 txt := Tpl.softNewLine(txt);
2684 16 txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2685 16 txt := lm_135(txt, i_vars_extObjVars, l_numScalarStates, a_simCode);
2686 16 txt := Tpl.popIter(txt);
2687 16 txt := Tpl.softNewLine(txt);
2688 16 ret_2 := SimCodeCodegenUtil.getFMI3Clocks(a_simCode);
2689 16 txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2690 16 txt := lm_136(txt, ret_2, a_FMUType);
2691 16 txt := Tpl.popIter(txt);
2692 16 txt := Tpl.softNewLine(txt);
2693 16 txt := EventIndicatorVariables3(txt, a_simCode);
2694 16 txt := Tpl.softNewLine(txt);
2695 16 ret_3 := FMI.isFMIMEType(a_FMUType);
2696 16 txt := fun_137(txt, ret_3, a_simCode);
2697 16 txt := Tpl.softNewLine(txt);
2698 16 txt := Tpl.popBlock(txt);
2699 16 txt := Tpl.writeTok(txt, Tpl.ST_STRING("</ModelVariables>"));
2700 then txt;
2701
2702 case ( txt,
2703 _,
2704 _,
2705 _ )
2706 then txt;
2707 end match;
2708 end fun_138;
2709
2710 public function fmiModelVariables3
2711 input Tpl.Text in_txt;
2712 input SimCode.SimCode in_a_simCode;
2713 input String in_a_FMUType;
2714
2715 output Tpl.Text out_txt;
2716 algorithm
2717 out_txt :=
2718 match(in_txt, in_a_simCode, in_a_FMUType)
2719 local
2720 Tpl.Text txt;
2721 String a_FMUType;
2722 SimCode.SimCode i_simCode;
2723 SimCode.ModelInfo i_modelInfo;
2724
2725 case ( txt,
2726 (i_simCode as SimCode.SIMCODE(modelInfo = i_modelInfo)),
2727 a_FMUType )
2728 algorithm
2729 16 txt := fun_138(txt, i_modelInfo, a_FMUType, i_simCode);
2730 then txt;
2731
2732 case ( txt,
2733 _,
2734 _ )
2735 then txt;
2736 end match;
2737 end fmiModelVariables3;
2738
2739 protected function lm_140
2740 input output Tpl.Text txt;
2741 input list<SimCodeVar.SimVar> items;
2742 input Tpl.Text a_daeModeVR;
2743 algorithm
2744 ✗ for lstElt_140 in items loop
2745 txt := match lstElt_140
2746 local
2747 SimCodeVar.SimVar i_var;
2748
2749 case i_var
2750 algorithm
2751 ✗ txt := DaeResidualVariable3(txt, i_var, Tpl.textString(a_daeModeVR));
2752 ✗ txt := Tpl.nextIter(txt);
2753 then txt;
2754 end match;
2755 end for;
2756 end lm_140;
2757
2758 public function DaeModeVariables3
2759 input Tpl.Text in_txt;
2760 input SimCode.SimCode in_a_simCode;
2761
2762 output Tpl.Text out_txt;
2763 algorithm
2764 out_txt :=
2765 match(in_txt, in_a_simCode)
2766 local
2767 Tpl.Text txt;
2768 list<SimCodeVar.SimVar> i_dmd_residualVars;
2769 SimCode.SimCode i_simCode;
2770 String ret_1;
2771 Tpl.Text l_daeModeVR;
2772
2773 case ( txt,
2774 (i_simCode as SimCode.SIMCODE(daeModeData = SOME(SimCode.DAEMODEDATA(residualVars = i_dmd_residualVars)))) )
2775 algorithm
2776 ✗ ret_1 := SimCodeCodegenUtil.getFMI3DaeModeValueReference(i_simCode);
2777 ✗ l_daeModeVR := Tpl.writeStr(Tpl.emptyTxt, ret_1);
2778 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("<Boolean name=\"_D_daeMode\" valueReference=\""));
2779 ✗ txt := Tpl.writeText(txt, l_daeModeVR);
2780 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("\" causality=\"structuralParameter\" variability=\"fixed\" start=\"false\" description=\"Set to true to enable DAE mode as defined by FMI-LS-DAE.\"/>\n"));
2781 ✗ txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2782 ✗ txt := lm_140(txt, i_dmd_residualVars, l_daeModeVR);
2783 ✗ txt := Tpl.popIter(txt);
2784 then txt;
2785
2786 case ( txt,
2787 _ )
2788 then txt;
2789 end match;
2790 end DaeModeVariables3;
2791
2792 public function DaeResidualVariable3
2793 input Tpl.Text in_txt;
2794 input SimCodeVar.SimVar in_a_simVar;
2795 input String in_a_daeModeVR;
2796
2797 output Tpl.Text out_txt;
2798 algorithm
2799 out_txt :=
2800 match(in_txt, in_a_simVar, in_a_daeModeVR)
2801 local
2802 Tpl.Text txt;
2803 String a_daeModeVR;
2804 Integer i_index;
2805 DAE.ComponentRef i_name;
2806 Integer ret_6;
2807 Integer ret_5;
2808 Integer ret_4;
2809 String ret_3;
2810 String ret_2;
2811 Tpl.Text txt_1;
2812 Tpl.Text l_nm;
2813
2814 case ( txt,
2815 SimCodeVar.SIMVAR(name = i_name, index = i_index),
2816 a_daeModeVR )
2817 algorithm
2818 ✗ txt_1 := CodegenUtil.crefStrNoUnderscore(Tpl.emptyTxt, i_name);
2819 ✗ ret_2 := System.stringReplace(Tpl.textString(txt_1), "$", "_D_");
2820 ✗ ret_3 := Util.escapeModelicaStringToXmlString(ret_2);
2821 ✗ l_nm := Tpl.writeStr(Tpl.emptyTxt, ret_3);
2822 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("<Float64 name=\""));
2823 ✗ txt := Tpl.writeText(txt, l_nm);
2824 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\" valueReference=\""));
2825 ✗ ret_4 := stringInt(a_daeModeVR);
2826 ✗ ret_5 := intAdd(1, i_index);
2827 ✗ ret_6 := intAdd(ret_4, ret_5);
2828 ✗ txt := Tpl.writeStr(txt, intString(ret_6));
2829 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\" causality=\"local\" variability=\"continuous\" initial=\"calculated\" description=\"DAE-mode residual "));
2830 ✗ txt := Tpl.writeStr(txt, intString(i_index));
2831 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\"/>"));
2832 then txt;
2833
2834 case ( txt,
2835 _,
2836 _ )
2837 then txt;
2838 end match;
2839 end DaeResidualVariable3;
2840
2841 protected function fun_143
2842 input Tpl.Text in_txt;
2843 input Option<SimCode.FmiModelStructure> in_a_modelStructure;
2844 input SimCode.SimCode in_a_simCode;
2845
2846 output Tpl.Text out_txt;
2847 algorithm
2848 out_txt :=
2849 match(in_txt, in_a_modelStructure, in_a_simCode)
2850 local
2851 Tpl.Text txt;
2852 SimCode.SimCode a_simCode;
2853 SimCode.FmiInitialUnknowns i_fmistruct_fmiInitialUnknowns;
2854 SimCode.FmiOutputs i_fmistruct_fmiOutputs;
2855
2856 case ( txt,
2857 SOME(SimCode.FMIMODELSTRUCTURE(fmiOutputs = i_fmistruct_fmiOutputs, fmiInitialUnknowns = i_fmistruct_fmiInitialUnknowns)),
2858 a_simCode )
2859 algorithm
2860 ✗ txt := ModelStructureOutputs3(txt, a_simCode, i_fmistruct_fmiOutputs);
2861 ✗ txt := Tpl.softNewLine(txt);
2862 ✗ txt := ModelStructureInitialUnknowns3(txt, a_simCode, i_fmistruct_fmiInitialUnknowns);
2863 then txt;
2864
2865 case ( txt,
2866 _,
2867 _ )
2868 then txt;
2869 end match;
2870 end fun_143;
2871
2872 protected function lm_144
2873 input output Tpl.Text txt;
2874 input list<tuple<String, String>> items;
2875 algorithm
2876 ✗ for lstElt_144 in items loop
2877 txt := match lstElt_144
2878 local
2879 String i_dependencyAttributes;
2880 String i_vr;
2881
2882 case (i_vr, i_dependencyAttributes)
2883 algorithm
2884 ✗ txt := DaeResidual3(txt, i_vr, i_dependencyAttributes);
2885 ✗ txt := Tpl.nextIter(txt);
2886 then txt;
2887 end match;
2888 end for;
2889 end lm_144;
2890
2891 protected function lm_145
2892 input output Tpl.Text txt;
2893 input list<SimCodeVar.SimVar> items;
2894 input SimCode.SimCode a_simCode;
2895 algorithm
2896 ✗ for lstElt_145 in items loop
2897 txt := match lstElt_145
2898 local
2899 SimCodeVar.SimVar i_var;
2900 String ret_0;
2901
2902 case i_var
2903 algorithm
2904 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("<AlgebraicVariable valueReference=\""));
2905 ✗ ret_0 := SimCodeCodegenUtil.getFMI3ValueReference(i_var, a_simCode);
2906 ✗ txt := Tpl.writeStr(txt, ret_0);
2907 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\"/>"));
2908 ✗ txt := Tpl.nextIter(txt);
2909 then txt;
2910 end match;
2911 end for;
2912 end lm_145;
2913
2914 public function fmiLsDaeManifest
2915 input Tpl.Text in_txt;
2916 input SimCode.SimCode in_a_simCode;
2917
2918 output Tpl.Text out_txt;
2919 algorithm
2920 out_txt :=
2921 match(in_txt, in_a_simCode)
2922 local
2923 Tpl.Text txt;
2924 list<SimCodeVar.SimVar> i_dmd_algebraicVars;
2925 Option<SimCode.FmiModelStructure> i_modelStructure;
2926 SimCode.SimCode i_simCode;
2927 String ret_9;
2928 String ret_8;
2929 String ret_7;
2930 Tpl.Text l_0___1;
2931 list<tuple<String, String>> ret_5;
2932 Tpl.Text l_residuals;
2933 Tpl.Text l_indicators;
2934 Tpl.Text l_structure;
2935 String ret_1;
2936 Tpl.Text l_0__;
2937
2938 case ( txt,
2939 (i_simCode as SimCode.SIMCODE(daeModeData = SOME(SimCode.DAEMODEDATA(algebraicVars = i_dmd_algebraicVars)), modelStructure = i_modelStructure)) )
2940 algorithm
2941 ✗ ret_1 := SimCodeCodegenUtil.cacheFMI3ValueReferences(i_simCode);
2942 ✗ l_0__ := Tpl.writeStr(Tpl.emptyTxt, ret_1);
2943 ✗ l_structure := fun_143(Tpl.emptyTxt, i_modelStructure, i_simCode);
2944 ✗ l_indicators := EventIndicators3(Tpl.emptyTxt, i_simCode);
2945 ✗ ret_5 := SimCodeCodegenUtil.fmi3DaeResiduals(i_simCode);
2946 ✗ l_residuals := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2947 ✗ l_residuals := lm_144(l_residuals, ret_5);
2948 ✗ l_residuals := Tpl.popIter(l_residuals);
2949 ✗ ret_7 := SimCodeCodegenUtil.clearFMI3ValueReferences();
2950 ✗ l_0___1 := Tpl.writeStr(Tpl.emptyTxt, ret_7);
2951 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
2952 "<fmiDAEManifest\n",
2953 " xmlns:fmi-ls=\"http://fmi-standard.org/fmi-ls-manifest\"\n",
2954 " fmi-ls:fmi-ls-name=\"org.fmi-standard.fmi-ls-dae\"\n"
2955 }, true));
2956 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
2957 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("fmi-ls:fmi-ls-version=\""));
2958 ✗ ret_8 := SimCodeCodegenUtil.fmiLsDaeVersion();
2959 ✗ txt := Tpl.writeStr(txt, ret_8);
2960 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
2961 "\"\n",
2962 "fmi-ls:fmi-ls-description=\"Layered standard for DAE support in FMI.\">\n",
2963 "<EnableDAEParameter valueReference=\""
2964 }, false));
2965 ✗ ret_9 := SimCodeCodegenUtil.getFMI3DaeModeValueReference(i_simCode);
2966 ✗ txt := Tpl.writeStr(txt, ret_9);
2967 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
2968 "\"/>\n",
2969 "<AlgebraicVariables>\n"
2970 }, true));
2971 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
2972 ✗ txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2973 ✗ txt := lm_145(txt, i_dmd_algebraicVars, i_simCode);
2974 ✗ txt := Tpl.popIter(txt);
2975 ✗ txt := Tpl.softNewLine(txt);
2976 ✗ txt := Tpl.popBlock(txt);
2977 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
2978 "</AlgebraicVariables>\n",
2979 "<ModelStructure>\n"
2980 }, true));
2981 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
2982 ✗ txt := Tpl.writeText(txt, l_structure);
2983 ✗ txt := Tpl.softNewLine(txt);
2984 ✗ txt := Tpl.writeText(txt, l_indicators);
2985 ✗ txt := Tpl.softNewLine(txt);
2986 ✗ txt := Tpl.writeText(txt, l_residuals);
2987 ✗ txt := Tpl.softNewLine(txt);
2988 ✗ txt := Tpl.popBlock(txt);
2989 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("</ModelStructure>\n"));
2990 ✗ txt := Tpl.popBlock(txt);
2991 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("</fmiDAEManifest>"));
2992 then txt;
2993
2994 case ( txt,
2995 _ )
2996 then txt;
2997 end match;
2998 end fmiLsDaeManifest;
2999
3000 public function DaeResidual3
3001 input Tpl.Text txt;
3002 input String a_vr;
3003 input String a_dependencyAttributes;
3004
3005 output Tpl.Text out_txt;
3006 algorithm
3007 ✗ out_txt := Tpl.writeTok(txt, Tpl.ST_STRING("<Residual valueReference=\""));
3008 ✗ out_txt := Tpl.writeStr(out_txt, a_vr);
3009 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("\""));
3010 ✗ out_txt := Tpl.writeStr(out_txt, a_dependencyAttributes);
3011 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("/>"));
3012 end DaeResidual3;
3013
3014 protected function lm_148
3015 input output Tpl.Text txt;
3016 input list<Integer> items;
3017 input Tpl.Text a_timeVR;
3018 algorithm
3019
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
5 for lstElt_148 in items loop
3020 txt := match lstElt_148
3021 local
3022 Integer i_i;
3023 Integer ret_3;
3024 Integer ret_2;
3025 Integer ret_1;
3026 Integer ret_0;
3027
3028 case i_i
3029 algorithm
3030 3 txt := Tpl.writeTok(txt, Tpl.ST_STRING("<Float64 name=\"__zc_"));
3031 3 ret_0 := intSub(i_i, 1);
3032 3 txt := Tpl.writeStr(txt, intString(ret_0));
3033 3 txt := Tpl.writeTok(txt, Tpl.ST_STRING("\" valueReference=\""));
3034 3 ret_1 := stringInt(Tpl.textString(a_timeVR));
3035 3 ret_2 := intAdd(ret_1, i_i);
3036 3 txt := Tpl.writeStr(txt, intString(ret_2));
3037 3 txt := Tpl.writeTok(txt, Tpl.ST_STRING("\" causality=\"local\" variability=\"continuous\" initial=\"calculated\" description=\"event indicator "));
3038 ret_3 := intSub(i_i, 1);
3039 3 txt := Tpl.writeStr(txt, intString(ret_3));
3040 3 txt := Tpl.writeTok(txt, Tpl.ST_STRING("\"/>"));
3041 3 txt := Tpl.nextIter(txt);
3042 then txt;
3043 end match;
3044 end for;
3045 end lm_148;
3046
3047 protected function fun_149
3048 input Tpl.Text in_txt;
3049 input Boolean in_mArg;
3050 input Tpl.Text in_a_timeVR;
3051 input Tpl.Text in_a_n;
3052
3053 output Tpl.Text out_txt;
3054 algorithm
3055 out_txt :=
3056 match(in_txt, in_mArg, in_a_timeVR, in_a_n)
3057 local
3058 Tpl.Text txt;
3059 Tpl.Text a_timeVR;
3060 Tpl.Text a_n;
3061 list<Integer> ret_1;
3062 Integer ret_0;
3063
3064 case ( txt,
3065 false,
3066 _,
3067 _ )
3068 then txt;
3069
3070 case ( txt,
3071 _,
3072 a_timeVR,
3073 a_n )
3074 algorithm
3075 2 ret_0 := stringInt(Tpl.textString(a_n));
3076 2 ret_1 := List.intRange(ret_0);
3077 2 txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
3078 2 txt := lm_148(txt, ret_1, a_timeVR);
3079 2 txt := Tpl.popIter(txt);
3080 then txt;
3081 end match;
3082 end fun_149;
3083
3084 public function EventIndicatorVariables3
3085 input Tpl.Text txt;
3086 input SimCode.SimCode a_simCode;
3087
3088 output Tpl.Text out_txt;
3089 protected
3090 Boolean ret_4;
3091 Integer ret_3;
3092 String ret_2;
3093 Tpl.Text l_timeVR;
3094 Tpl.Text l_n;
3095 algorithm
3096 16 l_n := CodegenFMUCommon.getNumberOfEventIndicators(Tpl.emptyTxt, a_simCode);
3097 16 ret_2 := SimCodeCodegenUtil.getFMI3TimeValueReference(a_simCode);
3098 16 l_timeVR := Tpl.writeStr(Tpl.emptyTxt, ret_2);
3099 16 ret_3 := stringInt(Tpl.textString(l_n));
3100 16 ret_4 := intGt(ret_3, 0);
3101 16 out_txt := fun_149(txt, ret_4, l_timeVR, l_n);
3102 end EventIndicatorVariables3;
3103
3104 public function TimeVariable3
3105 input Tpl.Text txt;
3106 input SimCode.SimCode a_simCode;
3107
3108 output Tpl.Text out_txt;
3109 protected
3110 String ret_0;
3111 algorithm
3112 16 out_txt := Tpl.writeTok(txt, Tpl.ST_STRING("<Float64 name=\"time\" valueReference=\""));
3113 16 ret_0 := SimCodeCodegenUtil.getFMI3TimeValueReference(a_simCode);
3114 16 out_txt := Tpl.writeStr(out_txt, ret_0);
3115 16 out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("\" causality=\"independent\" variability=\"continuous\" description=\"Simulation time\"/>"));
3116 end TimeVariable3;
3117
3118 protected function fun_152
3119 input Tpl.Text in_txt;
3120 input DAE.Type in_a_arrayElementType;
3121 input DAE.ComponentRef in_a_name;
3122 input String in_a_numScalarStates;
3123 input SimCode.SimCode in_a_simCode;
3124 input SimCodeVar.SimVar in_a_simVar;
3125
3126 output Tpl.Text out_txt;
3127 algorithm
3128 out_txt :=
3129 match(in_txt, in_a_arrayElementType, in_a_name, in_a_numScalarStates, in_a_simCode, in_a_simVar)
3130 local
3131 Tpl.Text txt;
3132 DAE.ComponentRef a_name;
3133 String a_numScalarStates;
3134 SimCode.SimCode a_simCode;
3135 SimCodeVar.SimVar a_simVar;
3136 Absyn.Path i_path;
3137 String ret_0;
3138
3139 case ( txt,
3140 DAE.T_REAL(varLst = _),
3141 _,
3142 a_numScalarStates,
3143 a_simCode,
3144 a_simVar )
3145 algorithm
3146 183 txt := Tpl.writeTok(txt, Tpl.ST_STRING("<Float64 "));
3147 183 txt := VariableCommonAttributes3(txt, a_simVar, a_simCode);
3148 183 txt := DerivativeAttribute3(txt, a_simVar, a_simCode, a_numScalarStates);
3149 183 txt := ArrayStartString3(txt, a_simVar);
3150 183 txt := CodegenFMUCommon.MinString2(txt, a_simVar);
3151 183 txt := CodegenFMUCommon.MaxString2(txt, a_simVar);
3152 183 txt := CodegenFMUCommon.NominalString2(txt, a_simVar);
3153 183 txt := CodegenFMUCommon.UnitString3(txt, a_simVar, a_simCode);
3154 183 txt := CodegenFMUCommon.relativeQuantity(txt, a_simVar);
3155 183 txt := Tpl.writeTok(txt, Tpl.ST_STRING(">"));
3156 183 txt := Dimensions3(txt, a_simVar);
3157 183 txt := Tpl.writeTok(txt, Tpl.ST_STRING("</Float64>"));
3158 then txt;
3159
3160 case ( txt,
3161 DAE.T_INTEGER(varLst = _),
3162 _,
3163 _,
3164 a_simCode,
3165 a_simVar )
3166 algorithm
3167 33 txt := Tpl.writeTok(txt, Tpl.ST_STRING("<Int32 "));
3168 33 txt := VariableCommonAttributes3(txt, a_simVar, a_simCode);
3169 33 txt := ArrayStartString3(txt, a_simVar);
3170 33 txt := CodegenFMUCommon.MinString2(txt, a_simVar);
3171 33 txt := CodegenFMUCommon.MaxString2(txt, a_simVar);
3172 33 txt := Tpl.writeTok(txt, Tpl.ST_STRING(">"));
3173 33 txt := Dimensions3(txt, a_simVar);
3174 33 txt := Tpl.writeTok(txt, Tpl.ST_STRING("</Int32>"));
3175 then txt;
3176
3177 case ( txt,
3178 DAE.T_BOOL(varLst = _),
3179 _,
3180 _,
3181 a_simCode,
3182 a_simVar )
3183 algorithm
3184 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("<Boolean "));
3185 ✗ txt := VariableCommonAttributes3(txt, a_simVar, a_simCode);
3186 ✗ txt := ArrayStartString3(txt, a_simVar);
3187 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(">"));
3188 ✗ txt := Dimensions3(txt, a_simVar);
3189 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("</Boolean>"));
3190 then txt;
3191
3192 case ( txt,
3193 DAE.T_STRING(varLst = _),
3194 _,
3195 _,
3196 a_simCode,
3197 a_simVar )
3198 algorithm
3199 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("<String "));
3200 ✗ txt := VariableCommonAttributes3(txt, a_simVar, a_simCode);
3201 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(">"));
3202 ✗ txt := Dimensions3(txt, a_simVar);
3203 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("</String>"));
3204 then txt;
3205
3206 case ( txt,
3207 DAE.T_ENUMERATION(path = i_path),
3208 _,
3209 _,
3210 a_simCode,
3211 a_simVar )
3212 algorithm
3213 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("<Enumeration "));
3214 ✗ txt := VariableCommonAttributes3(txt, a_simVar, a_simCode);
3215 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("declaredType=\""));
3216 ✗ ret_0 := AbsynUtil.pathString(i_path, ".", false, false);
3217 ✗ txt := Tpl.writeStr(txt, ret_0);
3218 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\""));
3219 ✗ txt := ArrayStartString3(txt, a_simVar);
3220 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(">"));
3221 ✗ txt := Dimensions3(txt, a_simVar);
3222 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("</Enumeration>"));
3223 then txt;
3224
3225 case ( txt,
3226 _,
3227 a_name,
3228 _,
3229 _,
3230 _ )
3231 algorithm
3232 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("<!-- UNKNOWN_ARRAY_TYPE "));
3233 ✗ txt := CodegenUtil.crefStr(txt, a_name);
3234 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" -->"));
3235 then txt;
3236 end match;
3237 end fun_152;
3238
3239 protected function fun_153
3240 input Tpl.Text in_txt;
3241 input Boolean in_mArg;
3242 input DAE.ComponentRef in_a_name;
3243 input String in_a_numScalarStates;
3244 input SimCode.SimCode in_a_simCode;
3245 input SimCodeVar.SimVar in_a_simVar;
3246 input DAE.Type in_a_arrayElementType;
3247
3248 output Tpl.Text out_txt;
3249 algorithm
3250 out_txt :=
3251 match(in_txt, in_mArg, in_a_name, in_a_numScalarStates, in_a_simCode, in_a_simVar, in_a_arrayElementType)
3252 local
3253 Tpl.Text txt;
3254 DAE.ComponentRef a_name;
3255 String a_numScalarStates;
3256 SimCode.SimCode a_simCode;
3257 SimCodeVar.SimVar a_simVar;
3258 DAE.Type a_arrayElementType;
3259
3260 case ( txt,
3261 false,
3262 a_name,
3263 a_numScalarStates,
3264 a_simCode,
3265 a_simVar,
3266 a_arrayElementType )
3267 algorithm
3268 216 txt := fun_152(txt, a_arrayElementType, a_name, a_numScalarStates, a_simCode, a_simVar);
3269 then txt;
3270
3271 case ( txt,
3272 _,
3273 _,
3274 _,
3275 _,
3276 _,
3277 _ )
3278 then txt;
3279 end match;
3280 end fun_153;
3281
3282 protected function fun_154
3283 input Tpl.Text in_txt;
3284 input DAE.Type in_a_type__;
3285 input DAE.ComponentRef in_a_name;
3286 input String in_a_numScalarStates;
3287 input SimCode.SimCode in_a_simCode;
3288 input SimCodeVar.SimVar in_a_simVar;
3289
3290 output Tpl.Text out_txt;
3291 algorithm
3292 out_txt :=
3293 match(in_txt, in_a_type__, in_a_name, in_a_numScalarStates, in_a_simCode, in_a_simVar)
3294 local
3295 Tpl.Text txt;
3296 DAE.ComponentRef a_name;
3297 String a_numScalarStates;
3298 SimCode.SimCode a_simCode;
3299 SimCodeVar.SimVar a_simVar;
3300 Absyn.Path i_path;
3301 String ret_0;
3302
3303 case ( txt,
3304 DAE.T_REAL(varLst = _),
3305 _,
3306 a_numScalarStates,
3307 a_simCode,
3308 a_simVar )
3309 algorithm
3310 841 txt := Tpl.writeTok(txt, Tpl.ST_STRING("<Float64 "));
3311 841 txt := VariableCommonAttributes3(txt, a_simVar, a_simCode);
3312 841 txt := DerivativeAttribute3(txt, a_simVar, a_simCode, a_numScalarStates);
3313 841 txt := CodegenFMUCommon.StartString2(txt, a_simVar);
3314 841 txt := CodegenFMUCommon.MinString2(txt, a_simVar);
3315 841 txt := CodegenFMUCommon.MaxString2(txt, a_simVar);
3316 841 txt := CodegenFMUCommon.NominalString2(txt, a_simVar);
3317 841 txt := CodegenFMUCommon.UnitString3(txt, a_simVar, a_simCode);
3318 841 txt := CodegenFMUCommon.relativeQuantity(txt, a_simVar);
3319 841 txt := CloseWithAliases3(txt, "Float64", a_simVar, a_simCode);
3320 then txt;
3321
3322 case ( txt,
3323 DAE.T_INTEGER(varLst = _),
3324 _,
3325 _,
3326 a_simCode,
3327 a_simVar )
3328 algorithm
3329 42 txt := Tpl.writeTok(txt, Tpl.ST_STRING("<Int32 "));
3330 42 txt := VariableCommonAttributes3(txt, a_simVar, a_simCode);
3331 42 txt := CodegenFMUCommon.StartString2(txt, a_simVar);
3332 42 txt := CodegenFMUCommon.MinString2(txt, a_simVar);
3333 42 txt := CodegenFMUCommon.MaxString2(txt, a_simVar);
3334 42 txt := CloseWithAliases3(txt, "Int32", a_simVar, a_simCode);
3335 then txt;
3336
3337 case ( txt,
3338 DAE.T_BOOL(varLst = _),
3339 _,
3340 _,
3341 a_simCode,
3342 a_simVar )
3343 algorithm
3344 107 txt := Tpl.writeTok(txt, Tpl.ST_STRING("<Boolean "));
3345 107 txt := VariableCommonAttributes3(txt, a_simVar, a_simCode);
3346 107 txt := CodegenFMUCommon.StartString2(txt, a_simVar);
3347 107 txt := CloseWithAliases3(txt, "Boolean", a_simVar, a_simCode);
3348 then txt;
3349
3350 case ( txt,
3351 DAE.T_STRING(varLst = _),
3352 _,
3353 _,
3354 a_simCode,
3355 a_simVar )
3356 algorithm
3357 12 txt := Tpl.writeTok(txt, Tpl.ST_STRING("<String "));
3358 12 txt := VariableCommonAttributes3(txt, a_simVar, a_simCode);
3359 12 txt := Tpl.writeTok(txt, Tpl.ST_STRING(">"));
3360 12 txt := StringStartChild3(txt, a_simVar);
3361 12 txt := AliasElements3(txt, a_simVar, a_simCode);
3362 12 txt := Tpl.writeTok(txt, Tpl.ST_STRING("</String>"));
3363 then txt;
3364
3365 case ( txt,
3366 DAE.T_ENUMERATION(path = i_path),
3367 _,
3368 _,
3369 a_simCode,
3370 a_simVar )
3371 algorithm
3372 7 txt := Tpl.writeTok(txt, Tpl.ST_STRING("<Enumeration "));
3373 7 txt := VariableCommonAttributes3(txt, a_simVar, a_simCode);
3374 7 txt := Tpl.writeTok(txt, Tpl.ST_STRING("declaredType=\""));
3375 7 ret_0 := AbsynUtil.pathString(i_path, ".", false, false);
3376 7 txt := Tpl.writeStr(txt, ret_0);
3377 7 txt := Tpl.writeTok(txt, Tpl.ST_STRING("\""));
3378 7 txt := CodegenFMUCommon.StartString2(txt, a_simVar);
3379 7 txt := CodegenFMUCommon.MinString2(txt, a_simVar);
3380 7 txt := CodegenFMUCommon.MaxString2(txt, a_simVar);
3381 7 txt := CloseWithAliases3(txt, "Enumeration", a_simVar, a_simCode);
3382 then txt;
3383
3384 case ( txt,
3385 _,
3386 a_name,
3387 _,
3388 _,
3389 _ )
3390 algorithm
3391 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("<!-- UNKNOWN_TYPE "));
3392 ✗ txt := CodegenUtil.crefStr(txt, a_name);
3393 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" -->"));
3394 then txt;
3395 end match;
3396 end fun_154;
3397
3398 protected function fun_155
3399 input Tpl.Text in_txt;
3400 input Boolean in_mArg;
3401 input DAE.ComponentRef in_a_name;
3402 input String in_a_numScalarStates;
3403 input SimCode.SimCode in_a_simCode;
3404 input SimCodeVar.SimVar in_a_simVar;
3405 input DAE.Type in_a_type__;
3406
3407 output Tpl.Text out_txt;
3408 algorithm
3409 out_txt :=
3410 match(in_txt, in_mArg, in_a_name, in_a_numScalarStates, in_a_simCode, in_a_simVar, in_a_type__)
3411 local
3412 Tpl.Text txt;
3413 DAE.ComponentRef a_name;
3414 String a_numScalarStates;
3415 SimCode.SimCode a_simCode;
3416 SimCodeVar.SimVar a_simVar;
3417 DAE.Type a_type__;
3418
3419 case ( txt,
3420 false,
3421 a_name,
3422 a_numScalarStates,
3423 a_simCode,
3424 a_simVar,
3425 a_type__ )
3426 algorithm
3427 1009 txt := fun_154(txt, a_type__, a_name, a_numScalarStates, a_simCode, a_simVar);
3428 then txt;
3429
3430 case ( txt,
3431 _,
3432 _,
3433 _,
3434 _,
3435 _,
3436 _ )
3437 then txt;
3438 end match;
3439 end fun_155;
3440
3441 protected function fun_156
3442 input Tpl.Text in_txt;
3443 input Boolean in_mArg;
3444 input DAE.ComponentRef in_a_name;
3445 input String in_a_numScalarStates;
3446 input SimCode.SimCode in_a_simCode;
3447 input SimCodeVar.SimVar in_a_simVar;
3448 input DAE.Type in_a_type__;
3449 input Option<DAE.ComponentRef> in_a_exportVar;
3450
3451 output Tpl.Text out_txt;
3452 algorithm
3453 out_txt :=
3454 match(in_txt, in_mArg, in_a_name, in_a_numScalarStates, in_a_simCode, in_a_simVar, in_a_type__, in_a_exportVar)
3455 local
3456 Tpl.Text txt;
3457 DAE.ComponentRef a_name;
3458 String a_numScalarStates;
3459 SimCode.SimCode a_simCode;
3460 SimCodeVar.SimVar a_simVar;
3461 DAE.Type a_type__;
3462 Option<DAE.ComponentRef> a_exportVar;
3463 Boolean ret_1;
3464 Boolean ret_0;
3465
3466 case ( txt,
3467 false,
3468 a_name,
3469 a_numScalarStates,
3470 a_simCode,
3471 a_simVar,
3472 a_type__,
3473 a_exportVar )
3474 algorithm
3475
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2326 times.
✓ Branch 2 taken 1009 times.
✓ Branch 3 taken 1317 times.
2326 ret_0 := isSome(a_exportVar);
3476 2326 ret_1 := boolNot(ret_0);
3477 2326 txt := fun_155(txt, ret_1, a_name, a_numScalarStates, a_simCode, a_simVar, a_type__);
3478 then txt;
3479
3480 case ( txt,
3481 _,
3482 _,
3483 _,
3484 _,
3485 _,
3486 _,
3487 _ )
3488 then txt;
3489 end match;
3490 end fun_156;
3491
3492 protected function fun_157
3493 input Tpl.Text in_txt;
3494 input Boolean in_mArg;
3495 input String in_a_numScalarStates;
3496 input SimCode.SimCode in_a_simCode;
3497 input SimCodeVar.SimVar in_a_simVar;
3498 input DAE.Type in_a_type__;
3499 input Option<DAE.ComponentRef> in_a_exportVar;
3500 input DAE.ComponentRef in_a_name;
3501
3502 output Tpl.Text out_txt;
3503 algorithm
3504 out_txt :=
3505 match(in_txt, in_mArg, in_a_numScalarStates, in_a_simCode, in_a_simVar, in_a_type__, in_a_exportVar, in_a_name)
3506 local
3507 Tpl.Text txt;
3508 String a_numScalarStates;
3509 SimCode.SimCode a_simCode;
3510 SimCodeVar.SimVar a_simVar;
3511 DAE.Type a_type__;
3512 Option<DAE.ComponentRef> a_exportVar;
3513 DAE.ComponentRef a_name;
3514 Boolean ret_1;
3515 Tpl.Text txt_0;
3516
3517 case ( txt,
3518 false,
3519 a_numScalarStates,
3520 a_simCode,
3521 a_simVar,
3522 a_type__,
3523 a_exportVar,
3524 a_name )
3525 algorithm
3526 2326 txt_0 := CodegenUtil.crefStr(Tpl.emptyTxt, a_name);
3527
3/4
✓ Branch 1 taken 31 times.
✓ Branch 2 taken 2295 times.
✓ Branch 5 taken 31 times.
✗ Branch 6 not taken.
2326 ret_1 := stringEq(Tpl.textString(txt_0), "der($dummy)");
3528 2326 txt := fun_156(txt, ret_1, a_name, a_numScalarStates, a_simCode, a_simVar, a_type__, a_exportVar);
3529 then txt;
3530
3531 case ( txt,
3532 _,
3533 _,
3534 _,
3535 _,
3536 _,
3537 _,
3538 _ )
3539 then txt;
3540 end match;
3541 end fun_157;
3542
3543 protected function fun_158
3544 input Tpl.Text in_txt;
3545 input Boolean in_mArg;
3546 input String in_a_numScalarStates;
3547 input SimCode.SimCode in_a_simCode;
3548 input SimCodeVar.SimVar in_a_simVar;
3549 input DAE.Type in_a_type__;
3550 input Option<DAE.ComponentRef> in_a_exportVar;
3551 input DAE.ComponentRef in_a_name;
3552
3553 output Tpl.Text out_txt;
3554 algorithm
3555 out_txt :=
3556 match(in_txt, in_mArg, in_a_numScalarStates, in_a_simCode, in_a_simVar, in_a_type__, in_a_exportVar, in_a_name)
3557 local
3558 Tpl.Text txt;
3559 String a_numScalarStates;
3560 SimCode.SimCode a_simCode;
3561 SimCodeVar.SimVar a_simVar;
3562 DAE.Type a_type__;
3563 Option<DAE.ComponentRef> a_exportVar;
3564 DAE.ComponentRef a_name;
3565 Boolean ret_1;
3566 Tpl.Text txt_0;
3567
3568 case ( txt,
3569 false,
3570 a_numScalarStates,
3571 a_simCode,
3572 a_simVar,
3573 a_type__,
3574 a_exportVar,
3575 a_name )
3576 algorithm
3577 2326 txt_0 := CodegenUtil.crefStr(Tpl.emptyTxt, a_name);
3578
3/4
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 2296 times.
✓ Branch 5 taken 30 times.
✗ Branch 6 not taken.
2326 ret_1 := stringEq(Tpl.textString(txt_0), "$dummy");
3579 2326 txt := fun_157(txt, ret_1, a_numScalarStates, a_simCode, a_simVar, a_type__, a_exportVar, a_name);
3580 then txt;
3581
3582 case ( txt,
3583 _,
3584 _,
3585 _,
3586 _,
3587 _,
3588 _,
3589 _ )
3590 then txt;
3591 end match;
3592 end fun_158;
3593
3594 public function Variable3
3595 input Tpl.Text in_txt;
3596 input SimCodeVar.SimVar in_a_simVar;
3597 input SimCode.SimCode in_a_simCode;
3598 input String in_a_numScalarStates;
3599
3600 output Tpl.Text out_txt;
3601 algorithm
3602 out_txt :=
3603 match(in_txt, in_a_simVar, in_a_simCode, in_a_numScalarStates)
3604 local
3605 Tpl.Text txt;
3606 SimCode.SimCode a_simCode;
3607 String a_numScalarStates;
3608 DAE.Type i_type__;
3609 DAE.ComponentRef i_name;
3610 DAE.Type i_arrayElementType;
3611 Option<DAE.ComponentRef> i_exportVar;
3612 SimCodeVar.SimVar i_simVar;
3613 Boolean ret_2;
3614 Boolean ret_1;
3615 Boolean ret_0;
3616
3617 case ( txt,
3618 (i_simVar as SimCodeVar.SIMVAR(name = _, type_ = DAE.T_COMPLEX(complexClassType = ClassInf.EXTERNAL_OBJ(path = _)))),
3619 a_simCode,
3620 _ )
3621 algorithm
3622 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING("<Binary "));
3623 1 txt := BinaryVariableAttributes3(txt, i_simVar, a_simCode);
3624 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING("/>"));
3625 then txt;
3626
3627 case ( txt,
3628 (i_simVar as SimCodeVar.SIMVAR(name = i_name, exportVar = i_exportVar, type_ = DAE.T_ARRAY(ty = i_arrayElementType))),
3629 a_simCode,
3630 a_numScalarStates )
3631 algorithm
3632
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
✓ Branch 2 taken 216 times.
✗ Branch 3 not taken.
216 ret_0 := isSome(i_exportVar);
3633 216 ret_1 := boolNot(ret_0);
3634 216 txt := fun_153(txt, ret_1, i_name, a_numScalarStates, a_simCode, i_simVar, i_arrayElementType);
3635 then txt;
3636
3637 case ( txt,
3638 (i_simVar as SimCodeVar.SIMVAR(name = i_name, exportVar = i_exportVar, type_ = i_type__)),
3639 a_simCode,
3640 a_numScalarStates )
3641 algorithm
3642 3134 ret_2 := SimCodeCodegenUtil.isFMI3NestableAlias(i_simVar);
3643 3134 txt := fun_158(txt, ret_2, a_numScalarStates, a_simCode, i_simVar, i_type__, i_exportVar, i_name);
3644 then txt;
3645
3646 case ( txt,
3647 _,
3648 _,
3649 _ )
3650 then txt;
3651 end match;
3652 end Variable3;
3653
3654 protected function fun_160
3655 input Tpl.Text in_txt;
3656 input Boolean in_mArg;
3657 input String in_a_tag;
3658 input Tpl.Text in_a_kids;
3659
3660 output Tpl.Text out_txt;
3661 algorithm
3662 out_txt :=
3663 match(in_txt, in_mArg, in_a_tag, in_a_kids)
3664 local
3665 Tpl.Text txt;
3666 String a_tag;
3667 Tpl.Text a_kids;
3668
3669 case ( txt,
3670 false,
3671 a_tag,
3672 a_kids )
3673 algorithm
3674 198 txt := Tpl.writeTok(txt, Tpl.ST_STRING(">"));
3675 198 txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
3676 198 txt := Tpl.writeText(txt, a_kids);
3677 198 txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
3678 198 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" </"));
3679 198 txt := Tpl.writeStr(txt, a_tag);
3680 198 txt := Tpl.writeTok(txt, Tpl.ST_STRING(">"));
3681 then txt;
3682
3683 case ( txt,
3684 _,
3685 _,
3686 _ )
3687 algorithm
3688 799 txt := Tpl.writeTok(txt, Tpl.ST_STRING("/>"));
3689 then txt;
3690 end match;
3691 end fun_160;
3692
3693 public function CloseWithAliases3
3694 input Tpl.Text txt;
3695 input String a_tag;
3696 input SimCodeVar.SimVar a_simVar;
3697 input SimCode.SimCode a_simCode;
3698
3699 output Tpl.Text out_txt;
3700 protected
3701 Boolean ret_1;
3702 Tpl.Text l_kids;
3703 algorithm
3704 997 l_kids := AliasElements3(Tpl.emptyTxt, a_simVar, a_simCode);
3705
3/4
✓ Branch 1 taken 799 times.
✓ Branch 2 taken 198 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 799 times.
997 ret_1 := stringEq(Tpl.textString(l_kids), "");
3706 997 out_txt := fun_160(txt, ret_1, a_tag, l_kids);
3707 end CloseWithAliases3;
3708
3709 protected function lm_162
3710 input output Tpl.Text txt;
3711 input list<SimCodeVar.SimVar> items;
3712 algorithm
3713
2/2
✓ Branch 0 taken 802 times.
✓ Branch 1 taken 198 times.
1000 for lstElt_162 in items loop
3714 txt := match lstElt_162
3715 local
3716 SimCodeVar.SimVar i_a;
3717
3718 case i_a
3719 algorithm
3720 802 txt := AliasElement3(txt, i_a);
3721 802 txt := Tpl.nextIter(txt);
3722 then txt;
3723 end match;
3724 end for;
3725 end lm_162;
3726
3727 protected function fun_163
3728 input Tpl.Text in_txt;
3729 input list<SimCodeVar.SimVar> in_mArg;
3730
3731 output Tpl.Text out_txt;
3732 algorithm
3733 out_txt :=
3734 match(in_txt, in_mArg)
3735 local
3736 Tpl.Text txt;
3737 list<SimCodeVar.SimVar> i_aliases;
3738
3739 case ( txt,
3740 {} )
3741 then txt;
3742
3743 case ( txt,
3744 i_aliases )
3745 algorithm
3746 198 txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
3747 198 txt := lm_162(txt, i_aliases);
3748 198 txt := Tpl.popIter(txt);
3749 then txt;
3750 end match;
3751 end fun_163;
3752
3753 public function AliasElements3
3754 input Tpl.Text in_txt;
3755 input SimCodeVar.SimVar in_a_simVar;
3756 input SimCode.SimCode in_a_simCode;
3757
3758 output Tpl.Text out_txt;
3759 algorithm
3760 out_txt :=
3761 match(in_txt, in_a_simVar, in_a_simCode)
3762 local
3763 Tpl.Text txt;
3764 SimCode.SimCode a_simCode;
3765 SimCodeVar.SimVar i_simVar;
3766 list<SimCodeVar.SimVar> ret_0;
3767
3768 case ( txt,
3769 (i_simVar as SimCodeVar.SIMVAR(name = _)),
3770 a_simCode )
3771 algorithm
3772 1009 ret_0 := SimCodeCodegenUtil.getFMI3VariableAliases(a_simCode, i_simVar);
3773 1009 txt := fun_163(txt, ret_0);
3774 then txt;
3775
3776 case ( txt,
3777 _,
3778 _ )
3779 then txt;
3780 end match;
3781 end AliasElements3;
3782
3783 protected function fun_165
3784 input Tpl.Text in_txt;
3785 input String in_a_comment;
3786
3787 output Tpl.Text out_txt;
3788 algorithm
3789 out_txt :=
3790 match(in_txt, in_a_comment)
3791 local
3792 Tpl.Text txt;
3793 String i_comment;
3794 String ret_0;
3795
3796 case ( txt,
3797 "" )
3798 then txt;
3799
3800 case ( txt,
3801 i_comment )
3802 algorithm
3803 798 txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(1));
3804 798 txt := Tpl.writeTok(txt, Tpl.ST_STRING("description=\""));
3805 798 ret_0 := Util.escapeModelicaStringToXmlString(i_comment);
3806 798 txt := Tpl.writeStr(txt, ret_0);
3807 798 txt := Tpl.writeTok(txt, Tpl.ST_STRING("\""));
3808 798 txt := Tpl.popBlock(txt);
3809 then txt;
3810 end match;
3811 end fun_165;
3812
3813 public function AliasElement3
3814 input Tpl.Text in_txt;
3815 input SimCodeVar.SimVar in_a_aliasVar;
3816
3817 output Tpl.Text out_txt;
3818 algorithm
3819 out_txt :=
3820 match(in_txt, in_a_aliasVar)
3821 local
3822 Tpl.Text txt;
3823 String i_comment;
3824 Option<DAE.ComponentRef> i_exportVar;
3825 Tpl.Text l_desc;
3826 String ret_4;
3827 String ret_3;
3828 Tpl.Text txt_2;
3829 DAE.ComponentRef ret_1;
3830 Tpl.Text l_nm;
3831
3832 case ( txt,
3833 SimCodeVar.SIMVAR(exportVar = i_exportVar, comment = i_comment) )
3834 algorithm
3835 802 ret_1 := Util.getOption(i_exportVar);
3836 802 txt_2 := CodegenUtil.crefStrNoUnderscore(Tpl.emptyTxt, ret_1);
3837 802 ret_3 := System.stringReplace(Tpl.textString(txt_2), "$", "_D_");
3838 802 ret_4 := Util.escapeModelicaStringToXmlString(ret_3);
3839 802 l_nm := Tpl.writeStr(Tpl.emptyTxt, ret_4);
3840 802 l_desc := fun_165(Tpl.emptyTxt, i_comment);
3841 802 txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(4));
3842 802 txt := Tpl.writeTok(txt, Tpl.ST_STRING("<Alias name=\""));
3843 802 txt := Tpl.writeText(txt, l_nm);
3844 802 txt := Tpl.writeTok(txt, Tpl.ST_STRING("\""));
3845 802 txt := Tpl.writeText(txt, l_desc);
3846 802 txt := Tpl.writeTok(txt, Tpl.ST_STRING("/>"));
3847 802 txt := Tpl.popBlock(txt);
3848 then txt;
3849
3850 case ( txt,
3851 _ )
3852 then txt;
3853 end match;
3854 end AliasElement3;
3855
3856 protected function fun_167
3857 input Tpl.Text in_txt;
3858 input Boolean in_mArg;
3859
3860 output Tpl.Text out_txt;
3861 algorithm
3862 out_txt :=
3863 match(in_txt, in_mArg)
3864 local
3865 Tpl.Text txt;
3866
3867 case ( txt,
3868 false )
3869 algorithm
3870 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING("output"));
3871 then txt;
3872
3873 case ( txt,
3874 _ )
3875 algorithm
3876 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("input"));
3877 then txt;
3878 end match;
3879 end fun_167;
3880
3881 protected function fun_168
3882 input Tpl.Text in_txt;
3883 input Boolean in_mArg;
3884 input String in_a_intervalDecimal;
3885
3886 output Tpl.Text out_txt;
3887 algorithm
3888 out_txt :=
3889 match(in_txt, in_mArg, in_a_intervalDecimal)
3890 local
3891 Tpl.Text txt;
3892 String a_intervalDecimal;
3893
3894 case ( txt,
3895 false,
3896 _ )
3897 then txt;
3898
3899 case ( txt,
3900 _,
3901 a_intervalDecimal )
3902 algorithm
3903 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(1));
3904 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("intervalDecimal=\""));
3905 ✗ txt := Tpl.writeStr(txt, a_intervalDecimal);
3906 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\""));
3907 ✗ txt := Tpl.popBlock(txt);
3908 then txt;
3909 end match;
3910 end fun_168;
3911
3912 protected function fun_169
3913 input Tpl.Text in_txt;
3914 input Boolean in_a_supportsFraction;
3915
3916 output Tpl.Text out_txt;
3917 algorithm
3918 out_txt :=
3919 match(in_txt, in_a_supportsFraction)
3920 local
3921 Tpl.Text txt;
3922
3923 case ( txt,
3924 false )
3925 then txt;
3926
3927 case ( txt,
3928 _ )
3929 algorithm
3930 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" supportsFraction=\"true\""));
3931 then txt;
3932 end match;
3933 end fun_169;
3934
3935 protected function fun_170
3936 input Tpl.Text in_txt;
3937 input Boolean in_mArg;
3938 input String in_a_intervalCounter;
3939
3940 output Tpl.Text out_txt;
3941 algorithm
3942 out_txt :=
3943 match(in_txt, in_mArg, in_a_intervalCounter)
3944 local
3945 Tpl.Text txt;
3946 String a_intervalCounter;
3947
3948 case ( txt,
3949 false,
3950 _ )
3951 then txt;
3952
3953 case ( txt,
3954 _,
3955 a_intervalCounter )
3956 algorithm
3957 1 txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(1));
3958 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING("intervalCounter=\""));
3959 1 txt := Tpl.writeStr(txt, a_intervalCounter);
3960 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING("\""));
3961 1 txt := Tpl.popBlock(txt);
3962 then txt;
3963 end match;
3964 end fun_170;
3965
3966 protected function fun_171
3967 input Tpl.Text in_txt;
3968 input Boolean in_mArg;
3969 input String in_a_resolution;
3970
3971 output Tpl.Text out_txt;
3972 algorithm
3973 out_txt :=
3974 match(in_txt, in_mArg, in_a_resolution)
3975 local
3976 Tpl.Text txt;
3977 String a_resolution;
3978
3979 case ( txt,
3980 false,
3981 _ )
3982 then txt;
3983
3984 case ( txt,
3985 _,
3986 a_resolution )
3987 algorithm
3988 1 txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(1));
3989 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING("resolution=\""));
3990 1 txt := Tpl.writeStr(txt, a_resolution);
3991 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING("\""));
3992 1 txt := Tpl.popBlock(txt);
3993 then txt;
3994 end match;
3995 end fun_171;
3996
3997 public function Clock3
3998 input Tpl.Text in_txt;
3999 input SimCode.FmiClock in_a_clock;
4000 input String in_a_FMUType;
4001
4002 output Tpl.Text out_txt;
4003 algorithm
4004 out_txt :=
4005 match(in_txt, in_a_clock, in_a_FMUType)
4006 local
4007 Tpl.Text txt;
4008 String a_FMUType;
4009 String i_intervalVariability;
4010 Integer i_valueReference;
4011 String i_resolution;
4012 String i_intervalCounter;
4013 Boolean i_supportsFraction;
4014 String i_intervalDecimal;
4015 String i_name;
4016 Boolean ret_14;
4017 Boolean ret_13;
4018 Tpl.Text l_res;
4019 Boolean ret_11;
4020 Boolean ret_10;
4021 Tpl.Text l_counter;
4022 Tpl.Text l_fraction;
4023 Boolean ret_7;
4024 Boolean ret_6;
4025 Tpl.Text l_intervalDec;
4026 String ret_4;
4027 String ret_3;
4028 Tpl.Text l_nm;
4029 Boolean ret_1;
4030 Tpl.Text l_causality;
4031
4032 case ( txt,
4033 SimCode.FMI_CLOCK(name = i_name, intervalDecimal = i_intervalDecimal, supportsFraction = i_supportsFraction, intervalCounter = i_intervalCounter, resolution = i_resolution, valueReference = i_valueReference, intervalVariability = i_intervalVariability),
4034 a_FMUType )
4035 algorithm
4036 1 ret_1 := FMI.isFMISEType(a_FMUType);
4037 1 l_causality := fun_167(Tpl.emptyTxt, ret_1);
4038 1 ret_3 := System.stringReplace(i_name, "$", "_D_");
4039 1 ret_4 := Util.escapeModelicaStringToXmlString(ret_3);
4040 1 l_nm := Tpl.writeStr(Tpl.emptyTxt, ret_4);
4041
2/4
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 time.
1 ret_6 := stringEq(i_intervalDecimal, "");
4042 1 ret_7 := boolNot(ret_6);
4043 1 l_intervalDec := fun_168(Tpl.emptyTxt, ret_7, i_intervalDecimal);
4044 1 l_fraction := fun_169(Tpl.emptyTxt, i_supportsFraction);
4045
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 ret_10 := stringEq(i_intervalCounter, "");
4046 1 ret_11 := boolNot(ret_10);
4047 1 l_counter := fun_170(Tpl.emptyTxt, ret_11, i_intervalCounter);
4048
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 ret_13 := stringEq(i_resolution, "");
4049 1 ret_14 := boolNot(ret_13);
4050 1 l_res := fun_171(Tpl.emptyTxt, ret_14, i_resolution);
4051 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING("<Clock name=\""));
4052 1 txt := Tpl.writeText(txt, l_nm);
4053 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING("\" valueReference=\""));
4054 1 txt := Tpl.writeStr(txt, intString(i_valueReference));
4055 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING("\" causality=\""));
4056 1 txt := Tpl.writeText(txt, l_causality);
4057 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING("\" intervalVariability=\""));
4058 1 txt := Tpl.writeStr(txt, i_intervalVariability);
4059 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING("\""));
4060 1 txt := Tpl.writeText(txt, l_intervalDec);
4061 1 txt := Tpl.writeText(txt, l_fraction);
4062 1 txt := Tpl.writeText(txt, l_counter);
4063 1 txt := Tpl.writeText(txt, l_res);
4064 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING("/>"));
4065 then txt;
4066
4067 case ( txt,
4068 _,
4069 _ )
4070 then txt;
4071 end match;
4072 end Clock3;
4073
4074 public function ArrayStartString3
4075 input Tpl.Text in_txt;
4076 input SimCodeVar.SimVar in_a_simVar;
4077
4078 output Tpl.Text out_txt;
4079 algorithm
4080 out_txt :=
4081 match(in_txt, in_a_simVar)
4082 local
4083 Tpl.Text txt;
4084 SimCodeVar.SimVar i_simVar;
4085
4086 case ( txt,
4087 SimCodeVar.SIMVAR(aliasvar = SimCodeVar.ALIAS(varName = _)) )
4088 then txt;
4089
4090 case ( txt,
4091 (i_simVar as SimCodeVar.SIMVAR(varKind = BackendDAE.STATE(index = _))) )
4092 algorithm
4093 3 txt := arrayStartAttr(txt, i_simVar);
4094 then txt;
4095
4096 case ( txt,
4097 (i_simVar as SimCodeVar.SIMVAR(initial_ = SOME(SimCodeVar.EXACT()))) )
4098 algorithm
4099 52 txt := arrayStartAttr(txt, i_simVar);
4100 then txt;
4101
4102 case ( txt,
4103 (i_simVar as SimCodeVar.SIMVAR(initial_ = SOME(SimCodeVar.APPROX()))) )
4104 algorithm
4105 ✗ txt := arrayStartAttr(txt, i_simVar);
4106 then txt;
4107
4108 case ( txt,
4109 (i_simVar as SimCodeVar.SIMVAR(causality = SOME(SimCodeVar.INPUT()))) )
4110 algorithm
4111 ✗ txt := arrayStartAttr(txt, i_simVar);
4112 then txt;
4113
4114 case ( txt,
4115 _ )
4116 then txt;
4117 end match;
4118 end ArrayStartString3;
4119
4120 protected function fun_174
4121 input Tpl.Text in_txt;
4122 input Boolean in_mArg;
4123 input Tpl.Text in_a_s;
4124
4125 output Tpl.Text out_txt;
4126 algorithm
4127 out_txt :=
4128 match(in_txt, in_mArg, in_a_s)
4129 local
4130 Tpl.Text txt;
4131 Tpl.Text a_s;
4132
4133 case ( txt,
4134 false,
4135 a_s )
4136 algorithm
4137 55 txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(1));
4138 55 txt := Tpl.writeTok(txt, Tpl.ST_STRING("start=\""));
4139 55 txt := Tpl.writeText(txt, a_s);
4140 55 txt := Tpl.writeTok(txt, Tpl.ST_STRING("\""));
4141 55 txt := Tpl.popBlock(txt);
4142 then txt;
4143
4144 case ( txt,
4145 _,
4146 _ )
4147 then txt;
4148 end match;
4149 end fun_174;
4150
4151 public function arrayStartAttr
4152 input Tpl.Text txt;
4153 input SimCodeVar.SimVar a_simVar;
4154
4155 output Tpl.Text out_txt;
4156 protected
4157 Boolean ret_2;
4158 String ret_1;
4159 Tpl.Text l_s;
4160 algorithm
4161 55 ret_1 := SimCodeCodegenUtil.getFMI3ArrayStart(a_simVar);
4162 55 l_s := Tpl.writeStr(Tpl.emptyTxt, ret_1);
4163
1/4
✗ Branch 1 not taken.
✓ Branch 2 taken 55 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
55 ret_2 := stringEq(Tpl.textString(l_s), "");
4164 55 out_txt := fun_174(txt, ret_2, l_s);
4165 end arrayStartAttr;
4166
4167 protected function lm_176
4168 input output Tpl.Text txt;
4169 input list<String> items;
4170 algorithm
4171
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 216 times.
456 for lstElt_176 in items loop
4172 txt := match lstElt_176
4173 local
4174 String i_d;
4175
4176 case i_d
4177 algorithm
4178 240 txt := Tpl.writeTok(txt, Tpl.ST_STRING("<Dimension start=\""));
4179 240 txt := Tpl.writeStr(txt, i_d);
4180 240 txt := Tpl.writeTok(txt, Tpl.ST_STRING("\"/>"));
4181 240 txt := Tpl.nextIter(txt);
4182 then txt;
4183 end match;
4184 end for;
4185 end lm_176;
4186
4187 public function Dimensions3
4188 input Tpl.Text in_txt;
4189 input SimCodeVar.SimVar in_a_simVar;
4190
4191 output Tpl.Text out_txt;
4192 algorithm
4193 out_txt :=
4194 match(in_txt, in_a_simVar)
4195 local
4196 Tpl.Text txt;
4197 list<String> i_dims;
4198
4199 case ( txt,
4200 SimCodeVar.SIMVAR(numArrayElement = i_dims) )
4201 algorithm
4202 216 txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING("")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
4203 216 txt := lm_176(txt, i_dims);
4204 216 txt := Tpl.popIter(txt);
4205 then txt;
4206
4207 case ( txt,
4208 _ )
4209 then txt;
4210 end match;
4211 end Dimensions3;
4212
4213 public function FmiInitialAttribute3
4214 input Tpl.Text in_txt;
4215 input SimCodeVar.SimVar in_a_simVar;
4216
4217 output Tpl.Text out_txt;
4218 algorithm
4219 out_txt :=
4220 match(in_txt, in_a_simVar)
4221 local
4222 Tpl.Text txt;
4223 SimCodeVar.SimVar i_simVar;
4224 String ret_0;
4225
4226 case ( txt,
4227 SimCodeVar.SIMVAR(varKind = BackendDAE.STATE(index = _), isFixed = true) )
4228 algorithm
4229 26 txt := Tpl.writeTok(txt, Tpl.ST_STRING("exact"));
4230 then txt;
4231
4232 case ( txt,
4233 SimCodeVar.SIMVAR(varKind = BackendDAE.STATE(index = _)) )
4234 algorithm
4235 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING("approx"));
4236 then txt;
4237
4238 case ( txt,
4239 i_simVar )
4240 algorithm
4241 1198 ret_0 := SimCodeCodegenUtil.getFmiInitialAttributeStr(i_simVar);
4242 1198 txt := Tpl.writeStr(txt, ret_0);
4243 then txt;
4244 end match;
4245 end FmiInitialAttribute3;
4246
4247 protected function fun_179
4248 input Tpl.Text in_txt;
4249 input String in_a_comment;
4250
4251 output Tpl.Text out_txt;
4252 algorithm
4253 out_txt :=
4254 match(in_txt, in_a_comment)
4255 local
4256 Tpl.Text txt;
4257 String i_comment;
4258 String ret_0;
4259
4260 case ( txt,
4261 "" )
4262 then txt;
4263
4264 case ( txt,
4265 i_comment )
4266 algorithm
4267 1167 txt := Tpl.writeTok(txt, Tpl.ST_STRING("description=\""));
4268 1167 ret_0 := Util.escapeModelicaStringToXmlString(i_comment);
4269 1167 txt := Tpl.writeStr(txt, ret_0);
4270 1167 txt := Tpl.writeTok(txt, Tpl.ST_STRING("\" "));
4271 then txt;
4272 end match;
4273 end fun_179;
4274
4275 protected function fun_180
4276 input Tpl.Text in_txt;
4277 input Boolean in_mArg;
4278 input Tpl.Text in_a_caus;
4279
4280 output Tpl.Text out_txt;
4281 algorithm
4282 out_txt :=
4283 match(in_txt, in_mArg, in_a_caus)
4284 local
4285 Tpl.Text txt;
4286 Tpl.Text a_caus;
4287
4288 case ( txt,
4289 false,
4290 _ )
4291 then txt;
4292
4293 case ( txt,
4294 _,
4295 a_caus )
4296 algorithm
4297 618 txt := Tpl.writeTok(txt, Tpl.ST_STRING("causality=\""));
4298 618 txt := Tpl.writeText(txt, a_caus);
4299 618 txt := Tpl.writeTok(txt, Tpl.ST_STRING("\" "));
4300 then txt;
4301 end match;
4302 end fun_180;
4303
4304 protected function fun_181
4305 input Tpl.Text in_txt;
4306 input Boolean in_mArg;
4307 input Tpl.Text in_a_variability__;
4308
4309 output Tpl.Text out_txt;
4310 algorithm
4311 out_txt :=
4312 match(in_txt, in_mArg, in_a_variability__)
4313 local
4314 Tpl.Text txt;
4315 Tpl.Text a_variability__;
4316
4317 case ( txt,
4318 false,
4319 _ )
4320 then txt;
4321
4322 case ( txt,
4323 _,
4324 a_variability__ )
4325 algorithm
4326 659 txt := Tpl.writeTok(txt, Tpl.ST_STRING("variability=\""));
4327 659 txt := Tpl.writeText(txt, a_variability__);
4328 659 txt := Tpl.writeTok(txt, Tpl.ST_STRING("\" "));
4329 then txt;
4330 end match;
4331 end fun_181;
4332
4333 protected function fun_182
4334 input Tpl.Text in_txt;
4335 input Boolean in_mArg;
4336 input Tpl.Text in_a_initial;
4337
4338 output Tpl.Text out_txt;
4339 algorithm
4340 out_txt :=
4341 match(in_txt, in_mArg, in_a_initial)
4342 local
4343 Tpl.Text txt;
4344 Tpl.Text a_initial;
4345
4346 case ( txt,
4347 false,
4348 _ )
4349 then txt;
4350
4351 case ( txt,
4352 _,
4353 a_initial )
4354 algorithm
4355 175 txt := Tpl.writeTok(txt, Tpl.ST_STRING("initial=\""));
4356 175 txt := Tpl.writeText(txt, a_initial);
4357 175 txt := Tpl.writeTok(txt, Tpl.ST_STRING("\" "));
4358 then txt;
4359 end match;
4360 end fun_182;
4361
4362 public function VariableCommonAttributes3
4363 input Tpl.Text in_txt;
4364 input SimCodeVar.SimVar in_a_simVar;
4365 input SimCode.SimCode in_a_simCode;
4366
4367 output Tpl.Text out_txt;
4368 algorithm
4369 out_txt :=
4370 match(in_txt, in_a_simVar, in_a_simCode)
4371 local
4372 Tpl.Text txt;
4373 SimCode.SimCode a_simCode;
4374 Option<SimCodeVar.Causality> i_causality;
4375 Option<SimCodeVar.Variability> i_variability;
4376 String i_comment;
4377 SimCodeVar.SimVar i_simVar;
4378 Option<DAE.ComponentRef> i_exportVar;
4379 Boolean ret_16;
4380 Boolean ret_15;
4381 Boolean ret_14;
4382 Boolean ret_13;
4383 Boolean ret_12;
4384 Boolean ret_11;
4385 Tpl.Text l_initial;
4386 Tpl.Text l_caus;
4387 Tpl.Text l_variability__;
4388 Tpl.Text l_description;
4389 String ret_6;
4390 Tpl.Text l_valueReference;
4391 String ret_4;
4392 String ret_3;
4393 Tpl.Text txt_2;
4394 DAE.ComponentRef ret_1;
4395 Tpl.Text l_name;
4396
4397 case ( txt,
4398 (i_simVar as SimCodeVar.SIMVAR(exportVar = i_exportVar, comment = i_comment, variability = i_variability, causality = i_causality)),
4399 a_simCode )
4400 algorithm
4401 1225 ret_1 := Util.getOption(i_exportVar);
4402 1225 txt_2 := CodegenUtil.crefStrNoUnderscore(Tpl.emptyTxt, ret_1);
4403 1225 ret_3 := System.stringReplace(Tpl.textString(txt_2), "$", "_D_");
4404 1225 ret_4 := Util.escapeModelicaStringToXmlString(ret_3);
4405 1225 l_name := Tpl.writeStr(Tpl.emptyTxt, ret_4);
4406 1225 ret_6 := SimCodeCodegenUtil.getFMI3ValueReference(i_simVar, a_simCode);
4407 1225 l_valueReference := Tpl.writeStr(Tpl.emptyTxt, ret_6);
4408 1225 l_description := fun_179(Tpl.emptyTxt, i_comment);
4409 1225 l_variability__ := CodegenFMUCommon.getVariability2(Tpl.emptyTxt, i_variability);
4410 1225 l_caus := CodegenFMUCommon.getCausality2(Tpl.emptyTxt, i_causality);
4411 1225 l_initial := FmiInitialAttribute3(Tpl.emptyTxt, i_simVar);
4412 1225 txt := Tpl.writeTok(txt, Tpl.ST_STRING("name=\""));
4413 1225 txt := Tpl.writeText(txt, l_name);
4414 1225 txt := Tpl.writeTok(txt, Tpl.ST_STRING("\" valueReference=\""));
4415 1225 txt := Tpl.writeText(txt, l_valueReference);
4416 1225 txt := Tpl.writeTok(txt, Tpl.ST_STRING("\" "));
4417 1225 txt := Tpl.writeText(txt, l_description);
4418
3/4
✓ Branch 1 taken 607 times.
✓ Branch 2 taken 618 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 607 times.
1225 ret_11 := stringEq(Tpl.textString(l_caus), "");
4419 1225 ret_12 := boolNot(ret_11);
4420 1225 txt := fun_180(txt, ret_12, l_caus);
4421
3/4
✓ Branch 1 taken 566 times.
✓ Branch 2 taken 659 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 566 times.
1225 ret_13 := stringEq(Tpl.textString(l_variability__), "");
4422 1225 ret_14 := boolNot(ret_13);
4423 1225 txt := fun_181(txt, ret_14, l_variability__);
4424
3/4
✓ Branch 1 taken 1050 times.
✓ Branch 2 taken 175 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1050 times.
1225 ret_15 := stringEq(Tpl.textString(l_initial), "");
4425 1225 ret_16 := boolNot(ret_15);
4426 1225 txt := fun_182(txt, ret_16, l_initial);
4427 then txt;
4428
4429 case ( txt,
4430 _,
4431 _ )
4432 then txt;
4433 end match;
4434 end VariableCommonAttributes3;
4435
4436 protected function fun_184
4437 input Tpl.Text in_txt;
4438 input String in_a_comment;
4439
4440 output Tpl.Text out_txt;
4441 algorithm
4442 out_txt :=
4443 match(in_txt, in_a_comment)
4444 local
4445 Tpl.Text txt;
4446 String i_comment;
4447 String ret_0;
4448
4449 case ( txt,
4450 "" )
4451 then txt;
4452
4453 case ( txt,
4454 i_comment )
4455 algorithm
4456 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("description=\""));
4457 ✗ ret_0 := Util.escapeModelicaStringToXmlString(i_comment);
4458 ✗ txt := Tpl.writeStr(txt, ret_0);
4459 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\" "));
4460 then txt;
4461 end match;
4462 end fun_184;
4463
4464 public function BinaryVariableAttributes3
4465 input Tpl.Text in_txt;
4466 input SimCodeVar.SimVar in_a_simVar;
4467 input SimCode.SimCode in_a_simCode;
4468
4469 output Tpl.Text out_txt;
4470 algorithm
4471 out_txt :=
4472 match(in_txt, in_a_simVar, in_a_simCode)
4473 local
4474 Tpl.Text txt;
4475 SimCode.SimCode a_simCode;
4476 String i_comment;
4477 SimCodeVar.SimVar i_simVar;
4478 DAE.ComponentRef i_name;
4479 Tpl.Text l_description;
4480 String ret_5;
4481 Tpl.Text l_valueReference;
4482 String ret_3;
4483 String ret_2;
4484 Tpl.Text txt_1;
4485 Tpl.Text l_nm;
4486
4487 case ( txt,
4488 (i_simVar as SimCodeVar.SIMVAR(name = i_name, comment = i_comment)),
4489 a_simCode )
4490 algorithm
4491 1 txt_1 := CodegenUtil.crefStrNoUnderscore(Tpl.emptyTxt, i_name);
4492 1 ret_2 := System.stringReplace(Tpl.textString(txt_1), "$", "_D_");
4493 1 ret_3 := Util.escapeModelicaStringToXmlString(ret_2);
4494 1 l_nm := Tpl.writeStr(Tpl.emptyTxt, ret_3);
4495 1 ret_5 := SimCodeCodegenUtil.getFMI3ValueReference(i_simVar, a_simCode);
4496 1 l_valueReference := Tpl.writeStr(Tpl.emptyTxt, ret_5);
4497 1 l_description := fun_184(Tpl.emptyTxt, i_comment);
4498 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING("name=\""));
4499 1 txt := Tpl.writeText(txt, l_nm);
4500 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING("\" valueReference=\""));
4501 1 txt := Tpl.writeText(txt, l_valueReference);
4502 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING("\" "));
4503 1 txt := Tpl.writeText(txt, l_description);
4504 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING("causality=\"local\" variability=\"fixed\""));
4505 then txt;
4506
4507 case ( txt,
4508 _,
4509 _ )
4510 then txt;
4511 end match;
4512 end BinaryVariableAttributes3;
4513
4514 public function DerivativeAttribute3
4515 input Tpl.Text in_txt;
4516 input SimCodeVar.SimVar in_a_simVar;
4517 input SimCode.SimCode in_a_simCode;
4518 input String in_a_numScalarStates;
4519
4520 output Tpl.Text out_txt;
4521 algorithm
4522 out_txt :=
4523 match(in_txt, in_a_simVar, in_a_simCode, in_a_numScalarStates)
4524 local
4525 Tpl.Text txt;
4526 SimCode.SimCode a_simCode;
4527 String a_numScalarStates;
4528 SimCodeVar.SimVar i_simVar;
4529 Integer ret_3;
4530 Integer ret_2;
4531 Integer ret_1;
4532 String ret_0;
4533
4534 case ( txt,
4535 (i_simVar as SimCodeVar.SIMVAR(varKind = BackendDAE.STATE_DER())),
4536 a_simCode,
4537 a_numScalarStates )
4538 algorithm
4539 27 txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(1));
4540 27 txt := Tpl.writeTok(txt, Tpl.ST_STRING("derivative=\""));
4541 27 ret_0 := SimCodeCodegenUtil.getFMI3ValueReference(i_simVar, a_simCode);
4542 27 ret_1 := stringInt(ret_0);
4543 27 ret_2 := stringInt(a_numScalarStates);
4544 27 ret_3 := intSub(ret_1, ret_2);
4545 27 txt := Tpl.writeStr(txt, intString(ret_3));
4546 27 txt := Tpl.writeTok(txt, Tpl.ST_STRING("\""));
4547 27 txt := Tpl.popBlock(txt);
4548 then txt;
4549
4550 case ( txt,
4551 _,
4552 _,
4553 _ )
4554 then txt;
4555 end match;
4556 end DerivativeAttribute3;
4557
4558 public function StringStartChild3
4559 input Tpl.Text in_txt;
4560 input SimCodeVar.SimVar in_a_simVar;
4561
4562 output Tpl.Text out_txt;
4563 algorithm
4564 out_txt :=
4565 match(in_txt, in_a_simVar)
4566 local
4567 Tpl.Text txt;
4568 DAE.Exp i_e;
4569
4570 case ( txt,
4571 SimCodeVar.SIMVAR(aliasvar = SimCodeVar.ALIAS(varName = _)) )
4572 then txt;
4573
4574 case ( txt,
4575 SimCodeVar.SIMVAR(initialValue = SOME((i_e as DAE.SCONST(string = _)))) )
4576 algorithm
4577 12 txt := Tpl.writeTok(txt, Tpl.ST_STRING("<Start value=\""));
4578 12 txt := CodegenUtil.initValXml(txt, i_e, "");
4579 12 txt := Tpl.writeTok(txt, Tpl.ST_STRING("\"/>"));
4580 then txt;
4581
4582 case ( txt,
4583 SimCodeVar.SIMVAR(causality = SOME(SimCodeVar.INPUT())) )
4584 algorithm
4585 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("<Start value=\"\"/>"));
4586 then txt;
4587
4588 case ( txt,
4589 _ )
4590 then txt;
4591 end match;
4592 end StringStartChild3;
4593
4594 protected function fun_188
4595 input Tpl.Text in_txt;
4596 input Option<SimCode.FmiModelStructure> in_a_fmiModelStructure;
4597 input SimCode.SimCode in_a_simCode;
4598
4599 output Tpl.Text out_txt;
4600 algorithm
4601 out_txt :=
4602 match(in_txt, in_a_fmiModelStructure, in_a_simCode)
4603 local
4604 Tpl.Text txt;
4605 SimCode.SimCode a_simCode;
4606 SimCode.FmiInitialUnknowns i_fmistruct_fmiInitialUnknowns;
4607 SimCode.FmiDerivatives i_fmistruct_fmiDerivatives;
4608 SimCode.FmiOutputs i_fmistruct_fmiOutputs;
4609 String ret_7;
4610 Tpl.Text l_0___1;
4611 Tpl.Text l_indicators;
4612 Tpl.Text l_initials;
4613 Tpl.Text l_derivatives;
4614 Tpl.Text l_outputs;
4615 String ret_1;
4616 Tpl.Text l_0__;
4617
4618 case ( txt,
4619 SOME(SimCode.FMIMODELSTRUCTURE(fmiOutputs = i_fmistruct_fmiOutputs, fmiDerivatives = i_fmistruct_fmiDerivatives, fmiInitialUnknowns = i_fmistruct_fmiInitialUnknowns)),
4620 a_simCode )
4621 algorithm
4622 16 ret_1 := SimCodeCodegenUtil.cacheFMI3ValueReferences(a_simCode);
4623 16 l_0__ := Tpl.writeStr(Tpl.emptyTxt, ret_1);
4624 16 l_outputs := ModelStructureOutputs3(Tpl.emptyTxt, a_simCode, i_fmistruct_fmiOutputs);
4625 16 l_derivatives := ModelStructureDerivatives3(Tpl.emptyTxt, a_simCode, i_fmistruct_fmiDerivatives);
4626 16 l_initials := ModelStructureInitialUnknowns3(Tpl.emptyTxt, a_simCode, i_fmistruct_fmiInitialUnknowns);
4627 16 l_indicators := EventIndicators3(Tpl.emptyTxt, a_simCode);
4628 16 ret_7 := SimCodeCodegenUtil.clearFMI3ValueReferences();
4629 16 l_0___1 := Tpl.writeStr(Tpl.emptyTxt, ret_7);
4630 16 txt := Tpl.writeTok(txt, Tpl.ST_LINE("<ModelStructure>\n"));
4631 16 txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
4632 16 txt := Tpl.writeText(txt, l_outputs);
4633 16 txt := Tpl.softNewLine(txt);
4634 16 txt := Tpl.writeText(txt, l_derivatives);
4635 16 txt := Tpl.softNewLine(txt);
4636 16 txt := Tpl.writeText(txt, l_initials);
4637 16 txt := Tpl.softNewLine(txt);
4638 16 txt := Tpl.writeText(txt, l_indicators);
4639 16 txt := Tpl.softNewLine(txt);
4640 16 txt := Tpl.popBlock(txt);
4641 16 txt := Tpl.writeTok(txt, Tpl.ST_STRING("</ModelStructure>"));
4642 then txt;
4643
4644 case ( txt,
4645 _,
4646 a_simCode )
4647 algorithm
4648 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("<ModelStructure>\n"));
4649 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
4650 ✗ txt := EventIndicators3(txt, a_simCode);
4651 ✗ txt := Tpl.softNewLine(txt);
4652 ✗ txt := Tpl.popBlock(txt);
4653 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("</ModelStructure>"));
4654 then txt;
4655 end match;
4656 end fun_188;
4657
4658 public function modelStructure3
4659 input Tpl.Text txt;
4660 input SimCode.SimCode a_simCode;
4661 input Option<SimCode.FmiModelStructure> a_fmiModelStructure;
4662
4663 output Tpl.Text out_txt;
4664 algorithm
4665 16 out_txt := fun_188(txt, a_fmiModelStructure, a_simCode);
4666 end modelStructure3;
4667
4668 protected function lm_190
4669 input output Tpl.Text txt;
4670 input list<SimCode.FmiUnknown> items;
4671 input SimCode.SimCode a_simCode;
4672 algorithm
4673
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 6 times.
13 for lstElt_190 in items loop
4674 txt := match lstElt_190
4675 local
4676 SimCode.FmiUnknown i_u;
4677
4678 case i_u
4679 algorithm
4680 7 txt := FmiUnknown3(txt, a_simCode, i_u, "Output");
4681 7 txt := Tpl.nextIter(txt);
4682 then txt;
4683 end match;
4684 end for;
4685 end lm_190;
4686
4687 protected function fun_191
4688 input Tpl.Text in_txt;
4689 input SimCode.FmiOutputs in_a_fmiOutputs;
4690 input SimCode.SimCode in_a_simCode;
4691
4692 output Tpl.Text out_txt;
4693 algorithm
4694 out_txt :=
4695 match(in_txt, in_a_fmiOutputs, in_a_simCode)
4696 local
4697 Tpl.Text txt;
4698 SimCode.SimCode a_simCode;
4699 list<SimCode.FmiUnknown> i_fmiUnknownsList;
4700
4701 case ( txt,
4702 SimCode.FMIOUTPUTS(fmiUnknownsList = {}),
4703 _ )
4704 then txt;
4705
4706 case ( txt,
4707 SimCode.FMIOUTPUTS(fmiUnknownsList = i_fmiUnknownsList),
4708 a_simCode )
4709 algorithm
4710 6 txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
4711 6 txt := lm_190(txt, i_fmiUnknownsList, a_simCode);
4712 6 txt := Tpl.popIter(txt);
4713 then txt;
4714
4715 case ( txt,
4716 _,
4717 _ )
4718 then txt;
4719 end match;
4720 end fun_191;
4721
4722 public function ModelStructureOutputs3
4723 input Tpl.Text txt;
4724 input SimCode.SimCode a_simCode;
4725 input SimCode.FmiOutputs a_fmiOutputs;
4726
4727 output Tpl.Text out_txt;
4728 algorithm
4729 16 out_txt := fun_191(txt, a_fmiOutputs, a_simCode);
4730 end ModelStructureOutputs3;
4731
4732 protected function lm_193
4733 input output Tpl.Text txt;
4734 input list<SimCode.FmiUnknown> items;
4735 input SimCode.SimCode a_simCode;
4736 algorithm
4737
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 16 times.
43 for lstElt_193 in items loop
4738 txt := match lstElt_193
4739 local
4740 SimCode.FmiUnknown i_u;
4741
4742 case i_u
4743 algorithm
4744 27 txt := FmiUnknown3(txt, a_simCode, i_u, "ContinuousStateDerivative");
4745 27 txt := Tpl.nextIter(txt);
4746 then txt;
4747 end match;
4748 end for;
4749 end lm_193;
4750
4751 protected function fun_194
4752 input Tpl.Text in_txt;
4753 input SimCode.FmiDerivatives in_a_fmiDerivatives;
4754 input SimCode.SimCode in_a_simCode;
4755
4756 output Tpl.Text out_txt;
4757 algorithm
4758 out_txt :=
4759 match(in_txt, in_a_fmiDerivatives, in_a_simCode)
4760 local
4761 Tpl.Text txt;
4762 SimCode.SimCode a_simCode;
4763 list<SimCode.FmiUnknown> i_fmiUnknownsList;
4764
4765 case ( txt,
4766 SimCode.FMIDERIVATIVES(fmiUnknownsList = {}),
4767 _ )
4768 then txt;
4769
4770 case ( txt,
4771 SimCode.FMIDERIVATIVES(fmiUnknownsList = i_fmiUnknownsList),
4772 a_simCode )
4773 algorithm
4774 16 txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
4775 16 txt := lm_193(txt, i_fmiUnknownsList, a_simCode);
4776 16 txt := Tpl.popIter(txt);
4777 then txt;
4778
4779 case ( txt,
4780 _,
4781 _ )
4782 then txt;
4783 end match;
4784 end fun_194;
4785
4786 public function ModelStructureDerivatives3
4787 input Tpl.Text txt;
4788 input SimCode.SimCode a_simCode;
4789 input SimCode.FmiDerivatives a_fmiDerivatives;
4790
4791 output Tpl.Text out_txt;
4792 algorithm
4793 16 out_txt := fun_194(txt, a_fmiDerivatives, a_simCode);
4794 end ModelStructureDerivatives3;
4795
4796 protected function lm_196
4797 input output Tpl.Text txt;
4798 input list<SimCode.FmiUnknown> items;
4799 input SimCode.SimCode a_simCode;
4800 algorithm
4801
2/2
✓ Branch 0 taken 476 times.
✓ Branch 1 taken 16 times.
492 for lstElt_196 in items loop
4802 txt := match lstElt_196
4803 local
4804 SimCode.FmiUnknown i_u;
4805
4806 case i_u
4807 algorithm
4808 476 txt := FmiUnknown3(txt, a_simCode, i_u, "InitialUnknown");
4809 476 txt := Tpl.nextIter(txt);
4810 then txt;
4811 end match;
4812 end for;
4813 end lm_196;
4814
4815 protected function fun_197
4816 input Tpl.Text in_txt;
4817 input SimCode.FmiInitialUnknowns in_a_fmiInitialUnknowns;
4818 input SimCode.SimCode in_a_simCode;
4819
4820 output Tpl.Text out_txt;
4821 algorithm
4822 out_txt :=
4823 match(in_txt, in_a_fmiInitialUnknowns, in_a_simCode)
4824 local
4825 Tpl.Text txt;
4826 SimCode.SimCode a_simCode;
4827 list<SimCode.FmiUnknown> i_fmiUnknownsList;
4828
4829 case ( txt,
4830 SimCode.FMIINITIALUNKNOWNS(fmiUnknownsList = {}),
4831 _ )
4832 then txt;
4833
4834 case ( txt,
4835 SimCode.FMIINITIALUNKNOWNS(fmiUnknownsList = i_fmiUnknownsList),
4836 a_simCode )
4837 algorithm
4838 16 txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
4839 16 txt := lm_196(txt, i_fmiUnknownsList, a_simCode);
4840 16 txt := Tpl.popIter(txt);
4841 then txt;
4842
4843 case ( txt,
4844 _,
4845 _ )
4846 then txt;
4847 end match;
4848 end fun_197;
4849
4850 public function ModelStructureInitialUnknowns3
4851 input Tpl.Text txt;
4852 input SimCode.SimCode a_simCode;
4853 input SimCode.FmiInitialUnknowns a_fmiInitialUnknowns;
4854
4855 output Tpl.Text out_txt;
4856 algorithm
4857 16 out_txt := fun_197(txt, a_fmiInitialUnknowns, a_simCode);
4858 end ModelStructureInitialUnknowns3;
4859
4860 protected function fun_199
4861 input Tpl.Text in_txt;
4862 input SimCode.FmiUnknown in_a_fmiUnknown;
4863 input SimCode.SimCode in_a_simCode;
4864 input String in_a_element;
4865
4866 output Tpl.Text out_txt;
4867 algorithm
4868 out_txt :=
4869 match(in_txt, in_a_fmiUnknown, in_a_simCode, in_a_element)
4870 local
4871 Tpl.Text txt;
4872 SimCode.SimCode a_simCode;
4873 String a_element;
4874 SimCode.FmiUnknown i_fmiUnknown;
4875 Integer i_index;
4876 String ret_1;
4877 String ret_0;
4878
4879 case ( txt,
4880 (i_fmiUnknown as SimCode.FMIUNKNOWN(index = i_index)),
4881 a_simCode,
4882 a_element )
4883 algorithm
4884 510 txt := Tpl.writeTok(txt, Tpl.ST_STRING("<"));
4885 510 txt := Tpl.writeStr(txt, a_element);
4886 510 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" valueReference=\""));
4887 510 ret_0 := SimCodeCodegenUtil.getFMI3ValueReferenceFromFMIIndex(a_simCode, i_index);
4888 510 txt := Tpl.writeStr(txt, ret_0);
4889 510 txt := Tpl.writeTok(txt, Tpl.ST_STRING("\""));
4890 510 ret_1 := SimCodeCodegenUtil.fmi3UnknownDependencyAttributes(a_simCode, i_fmiUnknown);
4891 510 txt := Tpl.writeStr(txt, ret_1);
4892 510 txt := Tpl.writeTok(txt, Tpl.ST_STRING("/>"));
4893 then txt;
4894
4895 case ( txt,
4896 _,
4897 _,
4898 _ )
4899 then txt;
4900 end match;
4901 end fun_199;
4902
4903 public function FmiUnknown3
4904 input Tpl.Text txt;
4905 input SimCode.SimCode a_simCode;
4906 input SimCode.FmiUnknown a_fmiUnknown;
4907 input String a_element;
4908
4909 output Tpl.Text out_txt;
4910 algorithm
4911 510 out_txt := fun_199(txt, a_fmiUnknown, a_simCode, a_element);
4912 end FmiUnknown3;
4913
4914 protected function lm_201
4915 input output Tpl.Text txt;
4916 input list<Integer> items;
4917 input Tpl.Text a_timeVR;
4918 algorithm
4919
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
5 for lstElt_201 in items loop
4920 txt := match lstElt_201
4921 local
4922 Integer i_i;
4923 Integer ret_1;
4924 Integer ret_0;
4925
4926 case i_i
4927 algorithm
4928 3 txt := Tpl.writeTok(txt, Tpl.ST_STRING("<EventIndicator valueReference=\""));
4929 3 ret_0 := stringInt(Tpl.textString(a_timeVR));
4930 3 ret_1 := intAdd(ret_0, i_i);
4931 3 txt := Tpl.writeStr(txt, intString(ret_1));
4932 3 txt := Tpl.writeTok(txt, Tpl.ST_STRING("\"/>"));
4933 3 txt := Tpl.nextIter(txt);
4934 then txt;
4935 end match;
4936 end for;
4937 end lm_201;
4938
4939 protected function fun_202
4940 input Tpl.Text in_txt;
4941 input Boolean in_mArg;
4942 input Tpl.Text in_a_timeVR;
4943 input Tpl.Text in_a_n;
4944
4945 output Tpl.Text out_txt;
4946 algorithm
4947 out_txt :=
4948 match(in_txt, in_mArg, in_a_timeVR, in_a_n)
4949 local
4950 Tpl.Text txt;
4951 Tpl.Text a_timeVR;
4952 Tpl.Text a_n;
4953 list<Integer> ret_1;
4954 Integer ret_0;
4955
4956 case ( txt,
4957 false,
4958 _,
4959 _ )
4960 then txt;
4961
4962 case ( txt,
4963 _,
4964 a_timeVR,
4965 a_n )
4966 algorithm
4967 2 ret_0 := stringInt(Tpl.textString(a_n));
4968 2 ret_1 := List.intRange(ret_0);
4969 2 txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
4970 2 txt := lm_201(txt, ret_1, a_timeVR);
4971 2 txt := Tpl.popIter(txt);
4972 then txt;
4973 end match;
4974 end fun_202;
4975
4976 public function EventIndicators3
4977 input Tpl.Text txt;
4978 input SimCode.SimCode a_simCode;
4979
4980 output Tpl.Text out_txt;
4981 protected
4982 Boolean ret_4;
4983 Integer ret_3;
4984 String ret_2;
4985 Tpl.Text l_timeVR;
4986 Tpl.Text l_n;
4987 algorithm
4988 16 l_n := CodegenFMUCommon.getNumberOfEventIndicators(Tpl.emptyTxt, a_simCode);
4989 16 ret_2 := SimCodeCodegenUtil.getFMI3TimeValueReference(a_simCode);
4990 16 l_timeVR := Tpl.writeStr(Tpl.emptyTxt, ret_2);
4991 16 ret_3 := stringInt(Tpl.textString(l_n));
4992 16 ret_4 := intGt(ret_3, 0);
4993 16 out_txt := fun_202(txt, ret_4, l_timeVR, l_n);
4994 end EventIndicators3;
4995
4996 annotation(__OpenModelica_Interface="codegen_fmu");
4997 end CodegenFMU3;
4998