/
CevalScript.mo
4194 lines (3821 loc) · 170 KB
/
CevalScript.mo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* This file is part of OpenModelica.
*
* Copyright (c) 1998-CurrentYear, Linköping University,
* Department of Computer and Information Science,
* SE-58183 Linköping, Sweden.
*
* All rights reserved.
*
* THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3
* AND THIS OSMC PUBLIC LICENSE (OSMC-PL).
* ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S
* ACCEPTANCE OF THE OSMC PUBLIC LICENSE.
*
* The OpenModelica software and the Open Source Modelica
* Consortium (OSMC) Public License (OSMC-PL) are obtained
* from Linköping University, either from the above address,
* from the URLs: http://www.ida.liu.se/projects/OpenModelica or
* http://www.openmodelica.org, and in the OpenModelica distribution.
* GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.
*
* This program is distributed WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
* IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS
* OF OSMC-PL.
*
* See the full OSMC Public License conditions for more details.
*
*/
encapsulated package CevalScript
" file: CevalScript.mo
package: CevalScript
description: Constant propagation of expressions
RCS: $Id$
This module handles scripting.
Input:
Env: Environment with bindings
Exp: Expression to evaluate
Bool flag determines whether the current instantiation is implicit
InteractiveSymbolTable is optional, and used in interactive mode, e.g. from OMShell
Output:
Value: The evaluated value
InteractiveSymbolTable: Modified symbol table
Subscript list : Evaluates subscripts and generates constant expressions."
// public imports
public import Absyn;
public import BackendDAE;
public import Ceval;
public import DAE;
public import Env;
public import Error;
public import Interactive;
public import Dependency;
public import Values;
// protected imports
protected import AbsynDep;
protected import BackendDump;
protected import BackendDAECreate;
protected import BackendDAEOptimize;
protected import BackendDAEUtil;
protected import BackendEquation;
protected import BackendVariable;
protected import ClassInf;
protected import ClassLoader;
protected import DAEQuery;
protected import DAEUtil;
protected import DAEDump;
protected import Debug;
protected import Dump;
protected import Expression;
protected import Inst;
protected import InnerOuter;
protected import List;
protected import Lookup;
protected import MetaUtil;
protected import OptManager;
protected import Prefix;
protected import Parser;
protected import Print;
protected import Refactor;
protected import RTOpts;
protected import SCodeDump;
protected import SCodeFlatten;
protected import SimCode;
protected import System;
protected import Static;
protected import SCode;
protected import SCodeUtil;
protected import Settings;
protected import SimulationResults;
protected import Tpl;
protected import Types;
protected import Unparsing;
protected import Util;
protected import ValuesUtil;
protected import XMLDump;
protected import ComponentReference;
public constant Integer RT_CLOCK_SIMULATE_TOTAL = 8;
public constant Integer RT_CLOCK_SIMULATE_SIMULATION = 9;
public constant Integer RT_CLOCK_BUILD_MODEL = 10;
public constant Integer RT_CLOCK_EXECSTAT_MAIN = Inst.RT_CLOCK_EXECSTAT_MAIN;
public constant Integer RT_CLOCK_EXECSTAT_BACKEND_MODULES = BackendDAE.RT_CLOCK_EXECSTAT_BACKEND_MODULES;
protected constant DAE.Type simulationResultType_rtest = (DAE.T_COMPLEX(ClassInf.RECORD(Absyn.IDENT("SimulationResult")),{
DAE.TYPES_VAR("resultFile",DAE.ATTR(SCode.NOT_FLOW(),SCode.NOT_STREAM(),SCode.VAR(),Absyn.BIDIR(),Absyn.NOT_INNER_OUTER()),SCode.PUBLIC(),DAE.T_STRING_DEFAULT,DAE.UNBOUND(),NONE()),
DAE.TYPES_VAR("simulationOptions",DAE.ATTR(SCode.NOT_FLOW(),SCode.NOT_STREAM(),SCode.VAR(),Absyn.BIDIR(),Absyn.NOT_INNER_OUTER()),SCode.PUBLIC(),DAE.T_STRING_DEFAULT,DAE.UNBOUND(),NONE()),
DAE.TYPES_VAR("messages",DAE.ATTR(SCode.NOT_FLOW(),SCode.NOT_STREAM(),SCode.VAR(),Absyn.BIDIR(),Absyn.NOT_INNER_OUTER()),SCode.PUBLIC(),DAE.T_STRING_DEFAULT,DAE.UNBOUND(),NONE())
},NONE(),NONE()),NONE());
protected constant DAE.Type simulationResultType_full = (DAE.T_COMPLEX(ClassInf.RECORD(Absyn.IDENT("SimulationResult")),{
DAE.TYPES_VAR("resultFile",DAE.ATTR(SCode.NOT_FLOW(),SCode.NOT_STREAM(),SCode.VAR(),Absyn.BIDIR(),Absyn.NOT_INNER_OUTER()),SCode.PUBLIC(),DAE.T_STRING_DEFAULT,DAE.UNBOUND(),NONE()),
DAE.TYPES_VAR("simulationOptions",DAE.ATTR(SCode.NOT_FLOW(),SCode.NOT_STREAM(),SCode.VAR(),Absyn.BIDIR(),Absyn.NOT_INNER_OUTER()),SCode.PUBLIC(),DAE.T_STRING_DEFAULT,DAE.UNBOUND(),NONE()),
DAE.TYPES_VAR("messages",DAE.ATTR(SCode.NOT_FLOW(),SCode.NOT_STREAM(),SCode.VAR(),Absyn.BIDIR(),Absyn.NOT_INNER_OUTER()),SCode.PUBLIC(),DAE.T_STRING_DEFAULT,DAE.UNBOUND(),NONE()),
DAE.TYPES_VAR("timeFrontend",DAE.ATTR(SCode.NOT_FLOW(),SCode.NOT_STREAM(),SCode.VAR(),Absyn.BIDIR(),Absyn.NOT_INNER_OUTER()),SCode.PUBLIC(),DAE.T_REAL_DEFAULT,DAE.UNBOUND(),NONE()),
DAE.TYPES_VAR("timeBackend",DAE.ATTR(SCode.NOT_FLOW(),SCode.NOT_STREAM(),SCode.VAR(),Absyn.BIDIR(),Absyn.NOT_INNER_OUTER()),SCode.PUBLIC(),DAE.T_REAL_DEFAULT,DAE.UNBOUND(),NONE()),
DAE.TYPES_VAR("timeSimCode",DAE.ATTR(SCode.NOT_FLOW(),SCode.NOT_STREAM(),SCode.VAR(),Absyn.BIDIR(),Absyn.NOT_INNER_OUTER()),SCode.PUBLIC(),DAE.T_REAL_DEFAULT,DAE.UNBOUND(),NONE()),
DAE.TYPES_VAR("timeTemplates",DAE.ATTR(SCode.NOT_FLOW(),SCode.NOT_STREAM(),SCode.VAR(),Absyn.BIDIR(),Absyn.NOT_INNER_OUTER()),SCode.PUBLIC(),DAE.T_REAL_DEFAULT,DAE.UNBOUND(),NONE()),
DAE.TYPES_VAR("timeCompile",DAE.ATTR(SCode.NOT_FLOW(),SCode.NOT_STREAM(),SCode.VAR(),Absyn.BIDIR(),Absyn.NOT_INNER_OUTER()),SCode.PUBLIC(),DAE.T_REAL_DEFAULT,DAE.UNBOUND(),NONE()),
DAE.TYPES_VAR("timeSimulation",DAE.ATTR(SCode.NOT_FLOW(),SCode.NOT_STREAM(),SCode.VAR(),Absyn.BIDIR(),Absyn.NOT_INNER_OUTER()),SCode.PUBLIC(),DAE.T_REAL_DEFAULT,DAE.UNBOUND(),NONE()),
DAE.TYPES_VAR("timeTotal",DAE.ATTR(SCode.NOT_FLOW(),SCode.NOT_STREAM(),SCode.VAR(),Absyn.BIDIR(),Absyn.NOT_INNER_OUTER()),SCode.PUBLIC(),DAE.T_REAL_DEFAULT,DAE.UNBOUND(),NONE())
},NONE(),NONE()),NONE());
//these are in reversed order than above
protected constant list<tuple<String,Values.Value>> zeroAdditionalSimulationResultValues =
{ ("timeTotal", Values.REAL(0.0)),
("timeSimulation", Values.REAL(0.0)),
("timeCompile", Values.REAL(0.0)),
("timeTemplates", Values.REAL(0.0)),
("timeSimCode", Values.REAL(0.0)),
("timeBackend", Values.REAL(0.0)),
("timeFrontend", Values.REAL(0.0))
};
public
uniontype SimulationOptions "these are the simulation/buildModel* options"
record SIMULATION_OPTIONS "simulation/buildModel* options"
DAE.Exp startTime "start time, default 0.0";
DAE.Exp stopTime "stop time, default 1.0";
DAE.Exp numberOfIntervals "number of intervals, default 500";
DAE.Exp stepSize "stepSize, default (stopTime-startTime)/numberOfIntervals";
DAE.Exp tolerance "tolerance, default 1e-6";
DAE.Exp method "method, default 'dassl'";
DAE.Exp fileNamePrefix "file name prefix, default ''";
DAE.Exp storeInTemp "store in temp, default false";
DAE.Exp noClean "no cleaning, default false";
DAE.Exp options "options, default ''";
DAE.Exp outputFormat "output format, default 'plt'";
DAE.Exp variableFilter "variable filter, regex does whole string matching, i.e. it becomes ^.*$ in the runtime";
DAE.Exp measureTime "Enables time measurements, default false";
DAE.Exp cflags "Compiler flags, in addition to MODELICAUSERCFLAGS";
end SIMULATION_OPTIONS;
end SimulationOptions;
public constant DAE.Exp defaultStartTime = DAE.RCONST(0.0) "default startTime";
public constant DAE.Exp defaultStopTime = DAE.RCONST(1.0) "default stopTime";
public constant DAE.Exp defaultNumberOfIntervals = DAE.ICONST(500) "default numberOfIntervals";
public constant DAE.Exp defaultStepSize = DAE.RCONST(0.002) "default stepSize";
public constant DAE.Exp defaultTolerance = DAE.RCONST(1e-6) "default tolerance";
public constant DAE.Exp defaultMethod = DAE.SCONST("dassl") "default method";
public constant DAE.Exp defaultFileNamePrefix = DAE.SCONST("") "default fileNamePrefix";
public constant DAE.Exp defaultStoreInTemp = DAE.BCONST(false) "default storeInTemp";
public constant DAE.Exp defaultNoClean = DAE.BCONST(false) "default noClean";
public constant DAE.Exp defaultOptions = DAE.SCONST("") "default options";
public constant DAE.Exp defaultOutputFormat = DAE.SCONST("mat") "default outputFormat";
public constant DAE.Exp defaultVariableFilter = DAE.SCONST(".*") "default variableFilter; does whole string matching, i.e. it becomes ^.*$ in the runtime";
public constant DAE.Exp defaultMeasureTime = DAE.BCONST(false) "time measurement disabled by default";
public constant DAE.Exp defaultCflags = DAE.SCONST("") "default compiler flags";
public constant SimulationOptions defaultSimulationOptions =
SIMULATION_OPTIONS(
defaultStartTime,
defaultStopTime,
defaultNumberOfIntervals,
defaultStepSize,
defaultTolerance,
defaultMethod,
defaultFileNamePrefix,
defaultStoreInTemp,
defaultNoClean,
defaultOptions,
defaultOutputFormat,
defaultVariableFilter,
defaultMeasureTime,
defaultCflags
) "default simulation options";
public constant list<String> simulationOptionsNames =
{
"startTime",
"stopTime",
"numberOfIntervals",
"tolerance",
"method",
"fileNamePrefix",
"storeInTemp",
"noClean",
"options",
"outputFormat",
"variableFilter",
"measureTime",
"cflags"
} "names of simulation options";
public function getSimulationResultType
output DAE.Type t;
algorithm
t := Util.if_(RTOpts.getRunningTestsuite(), simulationResultType_rtest, simulationResultType_full);
end getSimulationResultType;
public function createSimulationResult
input String resultFile;
input String options;
input String message;
input list<tuple<String,Values.Value>> inAddResultValues "additional values in reversed order; expected values see in CevalScript.simulationResultType_full";
output Values.Value res;
protected
list<tuple<String,Values.Value>> resultValues;
list<Values.Value> vals;
list<String> fields;
Boolean isTestType;
algorithm
resultValues := listReverse(inAddResultValues);
//TODO: maybe we should test if the fields are the ones in simulationResultType_full
fields := Util.if_(RTOpts.getRunningTestsuite(), {},
List.map(resultValues, Util.tuple21));
vals := Util.if_(RTOpts.getRunningTestsuite(), {},
List.map(resultValues, Util.tuple22));
res := Values.RECORD(Absyn.IDENT("SimulationResult"),
Values.STRING(resultFile)::Values.STRING(options)::Values.STRING(message)::vals,
"resultFile"::"simulationOptions"::"messages"::fields,-1);
end createSimulationResult;
public function createSimulationResultFailure
input String message;
input String options;
output Values.Value res;
protected
list<Values.Value> vals;
list<String> fields;
algorithm
res := createSimulationResult("", options, message, zeroAdditionalSimulationResultValues);
end createSimulationResultFailure;
protected function buildCurrentSimulationResultExp
output DAE.Exp outExp;
protected
DAE.ComponentRef cref;
algorithm
cref := ComponentReference.makeCrefIdent("currentSimulationResult",DAE.ET_OTHER(),{});
outExp := Expression.makeCrefExp(cref,DAE.ET_OTHER());
end buildCurrentSimulationResultExp;
protected function cevalCurrentSimulationResultExp
input Env.Cache cache;
input Env.Env env;
input String inputFilename;
input Interactive.SymbolTable st;
input Ceval.Msg msg;
output Env.Cache outCache;
output String filename;
algorithm
(outCache,filename) := match (cache,env,inputFilename,st,msg)
case (_,_,"<default>",_,_)
equation
(cache,Values.STRING(filename),_) = Ceval.ceval(cache,env,buildCurrentSimulationResultExp(),true,SOME(st),msg);
then (cache,filename);
else (cache,inputFilename);
end match;
end cevalCurrentSimulationResultExp;
public function buildSimulationOptions
"@author: adrpo
builds a SimulationOptions record from the given input"
input DAE.Exp startTime "start time, default 0.0";
input DAE.Exp stopTime "stop time, default 1.0";
input DAE.Exp numberOfIntervals "number of intervals, default 500";
input DAE.Exp stepSize "stepSize, default (stopTime-startTime)/numberOfIntervals";
input DAE.Exp tolerance "tolerance, default 1e-6";
input DAE.Exp method "method, default 'dassl'";
input DAE.Exp fileNamePrefix "file name prefix, default ''";
input DAE.Exp storeInTemp "store in temp, default false";
input DAE.Exp noClean "no cleaning, default false";
input DAE.Exp options "options, default ''";
input DAE.Exp outputFormat "output format, default 'plt'";
input DAE.Exp variableFilter;
input DAE.Exp measureTime;
input DAE.Exp cflags;
output SimulationOptions outSimulationOptions;
algorithm
outSimulationOptions :=
SIMULATION_OPTIONS(
startTime,
stopTime,
numberOfIntervals,
stepSize,
tolerance,
method,
fileNamePrefix,
storeInTemp,
noClean,
options,
outputFormat,
variableFilter,
measureTime,
cflags
);
end buildSimulationOptions;
public function getSimulationOption
"@author: adrpo
get the value from simulation option"
input SimulationOptions inSimOpt;
input String optionName;
output DAE.Exp outOptionValue;
algorithm
outOptionValue := matchcontinue(inSimOpt, optionName)
local
DAE.Exp e; String name, msg;
case (SIMULATION_OPTIONS(startTime = e), "startTime") then e;
case (SIMULATION_OPTIONS(stopTime = e), "stopTime") then e;
case (SIMULATION_OPTIONS(numberOfIntervals = e), "numberOfIntervals") then e;
case (SIMULATION_OPTIONS(stepSize = e), "stepSize") then e;
case (SIMULATION_OPTIONS(tolerance = e), "tolerance") then e;
case (SIMULATION_OPTIONS(method = e), "method") then e;
case (SIMULATION_OPTIONS(fileNamePrefix = e), "fileNamePrefix") then e;
case (SIMULATION_OPTIONS(storeInTemp = e), "storeInTemp") then e;
case (SIMULATION_OPTIONS(options = e), "options") then e;
case (SIMULATION_OPTIONS(noClean = e), "noClean") then e;
case (SIMULATION_OPTIONS(outputFormat = e), "outputFormat") then e;
case (SIMULATION_OPTIONS(variableFilter = e), "variableFilter") then e;
case (SIMULATION_OPTIONS(measureTime = e), "measureTime") then e;
case (SIMULATION_OPTIONS(cflags = e), "cflags") then e;
case (_, name)
equation
msg = "Unknown simulation option: " +& name;
Error.addCompilerWarning(msg);
then
fail();
end matchcontinue;
end getSimulationOption;
public function buildSimulationOptionsFromModelExperimentAnnotation
"@author: adrpo
retrieve annotation(experiment(....)) values and build a SimulationOptions object to return"
input Interactive.SymbolTable inSymTab;
input Absyn.Path inModelPath;
input String inFileNamePrefix;
output SimulationOptions outSimOpt;
algorithm
outSimOpt := matchcontinue (inSymTab, inModelPath, inFileNamePrefix)
local
SimulationOptions defaults, simOpt,methodbyflag;
String experimentAnnotationStr;
list<Absyn.NamedArg> named;
String msg;
Boolean methodflag;
// search inside annotation(experiment(...))
case (inSymTab, inModelPath, inFileNamePrefix)
equation
defaults = setFileNamePrefixInSimulationOptions(defaultSimulationOptions, inFileNamePrefix);
experimentAnnotationStr =
Interactive.getNamedAnnotation(
inModelPath,
Interactive.getSymbolTableAST(inSymTab),
"experiment",
Interactive.getExperimentAnnotationString);
// parse the string we get back, either {} or {StopTime=5, Tolerance = 0.10};
// jump to next case if the annotation is empty
false = stringEq(experimentAnnotationStr, "{}");
// get rid of '{' and '}'
experimentAnnotationStr = System.stringReplace(experimentAnnotationStr, "{", "");
experimentAnnotationStr = System.stringReplace(experimentAnnotationStr, "}", "");
Interactive.ISTMTS({Interactive.IEXP(exp = Absyn.CALL(functionArgs = Absyn.FUNCTIONARGS(_, named)))}, _)
= Parser.parsestringexp("experiment(" +& experimentAnnotationStr +& ");\n", "<experiment>");
simOpt = populateSimulationOptions(defaults, named);
then
simOpt;
// if we fail, just use the defaults
case (inSymTab, inModelPath, inFileNamePrefix)
equation
defaults = setFileNamePrefixInSimulationOptions(defaultSimulationOptions, inFileNamePrefix);
then
defaults;
end matchcontinue;
end buildSimulationOptionsFromModelExperimentAnnotation;
protected function setFileNamePrefixInSimulationOptions
input SimulationOptions inSimOpt;
input String inFileNamePrefix;
output SimulationOptions outSimOpt;
protected
DAE.Exp startTime, stopTime, numberOfIntervals, stepSize, tolerance, method, fileNamePrefix, storeInTemp, noClean, options, outputFormat, variableFilter, measureTime, cflags;
algorithm
SIMULATION_OPTIONS(startTime, stopTime, numberOfIntervals, stepSize, tolerance, method, _, storeInTemp, noClean, options, outputFormat, variableFilter, measureTime, cflags) := inSimOpt;
outSimOpt := SIMULATION_OPTIONS(startTime, stopTime, numberOfIntervals, stepSize, tolerance, method, DAE.SCONST(inFileNamePrefix), storeInTemp, noClean, options, outputFormat, variableFilter, measureTime, cflags);
end setFileNamePrefixInSimulationOptions;
protected function getConst
"@author: adrpo
Tranform a literal Absyn.Exp to DAE.Exp with the given DAE.ExpType"
input Absyn.Exp inAbsynExp;
input DAE.ExpType inExpType;
output DAE.Exp outExp;
algorithm
outExp := matchcontinue(inAbsynExp, inExpType)
local
Integer i; Real r;
Absyn.Exp exp;
case (Absyn.INTEGER(i), DAE.ET_INT()) then DAE.ICONST(i);
case (Absyn.REAL(r), DAE.ET_REAL()) then DAE.RCONST(r);
case (Absyn.INTEGER(i), DAE.ET_REAL()) equation r = intReal(i); then DAE.RCONST(r);
case (Absyn.REAL(r), DAE.ET_INT()) equation i = realInt(r); then DAE.ICONST(i);
case (exp, _)
equation
print("CevalScript.getConst: Not handled exp: " +& Dump.printExpStr(exp) +& "\n");
then
fail();
end matchcontinue;
end getConst;
protected function populateSimulationOptions
"@auhtor: adrpo
populate simulation options"
input SimulationOptions inSimOpt;
input list<Absyn.NamedArg> inExperimentSettings;
output SimulationOptions outSimOpt;
algorithm
outSimOpt := matchcontinue(inSimOpt, inExperimentSettings)
local
Absyn.Exp exp;
list<Absyn.NamedArg> rest;
SimulationOptions simOpt;
DAE.Exp startTime;
DAE.Exp stopTime;
DAE.Exp numberOfIntervals;
DAE.Exp stepSize;
DAE.Exp tolerance;
DAE.Exp method;
DAE.Exp fileNamePrefix;
DAE.Exp storeInTemp;
DAE.Exp noClean;
DAE.Exp options;
DAE.Exp outputFormat;
DAE.Exp variableFilter, measureTime, cflags;
Real rStepSize, rStopTime, rStartTime;
Integer iNumberOfIntervals;
String name,msg;
case (inSimOpt, {}) then inSimOpt;
case (SIMULATION_OPTIONS(startTime, stopTime, numberOfIntervals, stepSize, tolerance, method, fileNamePrefix, storeInTemp, noClean, options, outputFormat, variableFilter, measureTime, cflags),
Absyn.NAMEDARG(argName = "Tolerance", argValue = exp)::rest)
equation
tolerance = getConst(exp, DAE.ET_REAL());
simOpt = populateSimulationOptions(
SIMULATION_OPTIONS(startTime,stopTime,numberOfIntervals,stepSize,tolerance,method,
fileNamePrefix,storeInTemp,noClean,options,outputFormat,variableFilter,measureTime,cflags),
rest);
then
simOpt;
case (SIMULATION_OPTIONS(startTime, stopTime, numberOfIntervals, stepSize, tolerance, method, fileNamePrefix, storeInTemp, noClean, options, outputFormat, variableFilter, measureTime, cflags),
Absyn.NAMEDARG(argName = "StartTime", argValue = exp)::rest)
equation
startTime = getConst(exp, DAE.ET_REAL());
simOpt = populateSimulationOptions(
SIMULATION_OPTIONS(startTime,stopTime,numberOfIntervals,stepSize,tolerance,method,
fileNamePrefix,storeInTemp,noClean,options,outputFormat,variableFilter,measureTime,cflags),
rest);
then
simOpt;
case (SIMULATION_OPTIONS(startTime, stopTime, numberOfIntervals, stepSize, tolerance, method, fileNamePrefix, storeInTemp, noClean, options, outputFormat, variableFilter, measureTime, cflags),
Absyn.NAMEDARG(argName = "StopTime", argValue = exp)::rest)
equation
stopTime = getConst(exp, DAE.ET_REAL());
simOpt = populateSimulationOptions(
SIMULATION_OPTIONS(startTime,stopTime,numberOfIntervals,stepSize,tolerance,method,
fileNamePrefix,storeInTemp,noClean,options,outputFormat,variableFilter,measureTime,cflags),
rest);
then
simOpt;
case (SIMULATION_OPTIONS(startTime, stopTime, numberOfIntervals, stepSize, tolerance, method, fileNamePrefix, storeInTemp, noClean, options, outputFormat, variableFilter, measureTime, cflags),
Absyn.NAMEDARG(argName = "NumberOfIntervals", argValue = exp)::rest)
equation
numberOfIntervals = getConst(exp, DAE.ET_INT());
simOpt = populateSimulationOptions(
SIMULATION_OPTIONS(startTime,stopTime,numberOfIntervals,stepSize,tolerance,method,
fileNamePrefix,storeInTemp,noClean,options,outputFormat,variableFilter,measureTime,cflags),
rest);
then
simOpt;
case (SIMULATION_OPTIONS(startTime, stopTime, numberOfIntervals, stepSize, tolerance, method, fileNamePrefix, storeInTemp, noClean, options, outputFormat, variableFilter, measureTime, cflags),
Absyn.NAMEDARG(argName = "Interval", argValue = exp)::rest)
equation
DAE.RCONST(rStepSize) = getConst(exp, DAE.ET_REAL());
// a bit different for Interval, handle it LAST!!!!
SIMULATION_OPTIONS(startTime,stopTime,numberOfIntervals,stepSize,tolerance,method,
fileNamePrefix,storeInTemp,noClean,options,outputFormat,variableFilter,measureTime,cflags) =
populateSimulationOptions(inSimOpt, rest);
DAE.RCONST(rStartTime) = startTime;
DAE.RCONST(rStopTime) = stopTime;
iNumberOfIntervals = realInt(realDiv(realSub(rStopTime, rStartTime), rStepSize));
numberOfIntervals = DAE.ICONST(iNumberOfIntervals);
stepSize = DAE.RCONST(rStepSize);
simOpt = SIMULATION_OPTIONS(startTime,stopTime,numberOfIntervals,stepSize,tolerance,method,
fileNamePrefix,storeInTemp,noClean,options,outputFormat,variableFilter,measureTime,cflags);
then
simOpt;
case (SIMULATION_OPTIONS(startTime, stopTime, numberOfIntervals, stepSize, tolerance, method, fileNamePrefix, storeInTemp, noClean, options, outputFormat, variableFilter, measureTime, cflags),
Absyn.NAMEDARG(argName = name, argValue = exp)::rest)
equation
msg = "Ignoring unknown experiment annotation option: " +& name +& " = " +& Dump.printExpStr(exp);
Error.addCompilerWarning(msg);
simOpt = populateSimulationOptions(inSimOpt, rest);
then
simOpt;
end matchcontinue;
end populateSimulationOptions;
protected function simOptionsAsString
"@author: adrpo
Gets the simulation options as string"
input list<Values.Value> vals;
output String str;
algorithm
str := matchcontinue vals
local
list<String> simOptsValues;
list<Values.Value> lst;
case _::lst
equation
// build a list with the values
simOptsValues = List.map(lst, ValuesUtil.valString);
// trim " from strings!
simOptsValues = List.map2(simOptsValues, System.stringReplace, "\"", "\'");
str = Util.buildMapStr(simulationOptionsNames, simOptsValues, " = ", ", ");
then
str;
// on failure
case (_::lst)
equation
// build a list with the values
simOptsValues = List.map(lst, ValuesUtil.valString);
// trim " from strings!
simOptsValues = List.map2(simOptsValues, System.stringReplace, "\"", "\'");
str = stringDelimitList(simOptsValues, ", ");
then
str;
end matchcontinue;
end simOptionsAsString;
protected function loadModel
input list<tuple<Absyn.Path,list<String>>> modelsToLoad;
input String modelicaPath;
input Absyn.Program p;
input Boolean forceLoad;
output Absyn.Program pnew;
output Boolean success;
algorithm
(pnew,success) := matchcontinue (modelsToLoad,modelicaPath,p,forceLoad)
local
Absyn.Path path;
String pathStr,versions;
list<String> strings;
Boolean b,b1,b2;
case ({},_,p,_) then (p,true);
case ((path,strings)::modelsToLoad,modelicaPath,p,forceLoad)
equation
b = checkModelLoaded(path,strings,p,forceLoad);
pnew = Debug.bcallret3(not b, ClassLoader.loadClass, path, strings, modelicaPath, Absyn.PROGRAM({},Absyn.TOP(),Absyn.dummyTimeStamp));
p = Interactive.updateProgram(pnew, p);
(p,b1) = loadModel(Interactive.getUsesAnnotation(pnew),modelicaPath,p,false);
(p,b2) = loadModel(modelsToLoad,modelicaPath,p,forceLoad);
then (p,b1 and b2);
case ((path,strings)::_,modelicaPath,p,_)
equation
pathStr = Absyn.pathString(path);
versions = stringDelimitList(strings,",");
Error.addMessage(Error.LOAD_MODEL,{pathStr,versions,modelicaPath});
then (p,false);
end matchcontinue;
end loadModel;
protected function checkModelLoaded
input Absyn.Path path;
input list<String> validVersions;
input Absyn.Program p;
input Boolean forceLoad;
output Boolean loaded;
algorithm
loaded := matchcontinue (path,validVersions,p,forceLoad)
local
Absyn.Class cdef;
String str1,str2;
Option<String> ostr2;
case (_,_,_,true) then false;
case (path,{str1},p,false)
equation
cdef = Interactive.getPathedClassInProgram(path,p);
ostr2 = Interactive.getNamedAnnotationInClass(cdef,"version",Interactive.getAnnotationStringValueOrFail);
checkValidVersion(path,str1,ostr2);
then true;
else false;
end matchcontinue;
end checkModelLoaded;
protected function checkValidVersion
input Absyn.Path path;
input String version;
input Option<String> actualVersion;
algorithm
_ := matchcontinue (path,version,actualVersion)
local
String pathStr,str1,str2;
case (_,str1,SOME(str2))
equation
true = stringEq(str1,str2);
then ();
case (path,str1,SOME(str2))
equation
pathStr = Absyn.pathString(path);
Error.addMessage(Error.LOAD_MODEL_DIFFERENT_VERSIONS,{pathStr,str1,str2});
then ();
case (path,str1,NONE())
equation
pathStr = Absyn.pathString(path);
Error.addMessage(Error.LOAD_MODEL_DIFFERENT_VERSIONS,{pathStr,str1,"unknown"});
then ();
end matchcontinue;
end checkValidVersion;
public function cevalInteractiveFunctions
"function cevalInteractiveFunctions
This function evaluates the functions
defined in the interactive environment."
input Env.Cache inCache;
input Env.Env inEnv;
input DAE.Exp inExp "expression to evaluate";
input Interactive.SymbolTable inSymbolTable;
input Ceval.Msg msg;
output Env.Cache outCache;
output Values.Value outValue;
output Interactive.SymbolTable outInteractiveSymbolTable;
algorithm
(outCache,outValue,outInteractiveSymbolTable) := matchcontinue (inCache,inEnv,inExp,inSymbolTable,msg)
local
Env.Cache cache;
Env.Env env;
DAE.Exp exp;
list<DAE.Exp> eLst;
list<Values.Value> valLst;
String name;
Values.Value value;
Real t1,t2,time;
Interactive.SymbolTable st;
Option<Interactive.SymbolTable> stOpt;
// This needs to be first because otherwise it takes 0 time to get the value :)
case (cache,env,DAE.CALL(path = Absyn.IDENT(name = "timing"),expLst = {exp}),st,msg)
equation
t1 = System.time();
(cache,value,SOME(st)) = Ceval.ceval(cache,env, exp, true, SOME(st),msg);
t2 = System.time();
time = t2 -. t1;
then
(cache,Values.REAL(time),st);
case (cache,env,DAE.CALL(path=Absyn.IDENT(name),attr=DAE.CALL_ATTR(builtin=true),expLst=eLst),st,msg)
equation
(cache,valLst,stOpt) = Ceval.cevalList(cache,env,eLst,true,SOME(st),msg);
st = Util.getOptionOrDefault(stOpt, st);
(cache,value,st) = cevalInteractiveFunctions2(cache,env,name,valLst,st,msg);
then
(cache,value,st);
end matchcontinue;
end cevalInteractiveFunctions;
protected function cevalInteractiveFunctions2
"function cevalInteractiveFunctions
This function evaluates the functions
defined in the interactive environment."
input Env.Cache inCache;
input Env.Env inEnv;
input String inFunctionName;
input list<Values.Value> inVals;
input Interactive.SymbolTable inSt;
input Ceval.Msg msg;
output Env.Cache outCache;
output Values.Value outValue;
output Interactive.SymbolTable outInteractiveSymbolTable;
algorithm
(outCache,outValue,outInteractiveSymbolTable) := matchcontinue (inCache,inEnv,inFunctionName,inVals,inSt,msg)
local
String functionName;
list<Values.Value> vals;
Absyn.Path path,p1,classpath,className;
SCode.Program scodeP,sp;
Option<list<SCode.Element>> fp;
list<Env.Frame> env;
SCode.Element c;
String s1,str,str1,str2,str3,re,token,varid,cmd,executable,executable1,method_str,outputFormat_str,initfilename,cit,pd,executableSuffixedExe,sim_call,result_file,filename_1,filename,omhome_1,plotCmd,tmpPlotFile,call,str_1,mp,pathstr,name,cname,fileNamePrefix_s,errMsg,errorStr,uniqueStr,interpolation,title,xLabel,yLabel,filename2,varNameStr,xml_filename,xml_contents,visvar_str,pwd,omhome,omlib,omcpath,os,platform,usercflags,senddata,res,workdir,gcc,confcmd,touch_file,uname,filenameprefix,compileDir;
DAE.ComponentRef cr,cref,classname;
Interactive.SymbolTable newst,st_1,st;
Absyn.Program p,pnew,newp,ptot;
list<Interactive.InstantiatedClass> ic,ic_1;
list<Interactive.Variable> iv;
list<Interactive.CompiledCFunction> cf;
DAE.Type tp;
Absyn.Class absynClass;
DAE.DAElist dae;
BackendDAE.BackendDAE daelow,optdae;
BackendDAE.Variables vars;
BackendDAE.EquationArray eqnarr;
array<BackendDAE.MultiDimEquation> ae;
list<DAE.Exp> expVars,options;
array<list<Integer>> m,mt;
Option<array<list<Integer>>> om,omt;
Option<list<tuple<Integer, Integer, BackendDAE.Equation>>> jac;
Values.Value ret_val,simValue,size_value,value,v,cvar,cvar2,xRange,yRange,xRange1,xRange2,yRange1,yRange2;
DAE.Exp exp,size_expression,bool_exp,storeInTemp,translationLevel,addOriginalIncidenceMatrix,addSolvingInfo,addMathMLCode,dumpResiduals,varName,varTimeStamp;
Absyn.ComponentRef cr_1;
Integer size,length,resI,timeStampI,i,n;
list<String> vars_1,vars_2,args,strings,strVars,strs,visvars;
Real t1,t2,time,timeTotal,timeSimulation,timeStamp,val,x1,x2,y1,y2;
Interactive.Statements istmts;
Boolean bval, b, externalWindow, legend, grid, logX, logY, points, gcc_res, omcfound, rm_res, touch_res, uname_res, extended, insensitive,ifcpp;
Env.Cache cache;
list<Interactive.LoadedFile> lf;
AbsynDep.Depends aDep;
Absyn.ComponentRef crefCName;
list<tuple<String,Values.Value>> resultValues;
list<Real> timeStamps,realVals;
list<DAE.Exp> expLst;
list<tuple<String,list<String>>> deps;
Absyn.CodeNode codeNode;
list<Values.Value> cvars,vals2;
DAE.FunctionTree funcs;
list<Absyn.Path> paths;
list<Absyn.Class> classes;
Absyn.Within within_;
BackendDAE.EqSystem syst;
BackendDAE.Shared shared;
case (cache,env,"parseString",{Values.STRING(str1),Values.STRING(str2)},st,msg)
equation
Absyn.PROGRAM(classes=classes,within_=within_) = Parser.parsestring(str1,str2);
paths = List.map(classes,Absyn.className);
paths = List.map1r(paths,Absyn.joinWithinPath,within_);
vals = List.map(paths,ValuesUtil.makeCodeTypeName);
then (cache,ValuesUtil.makeArray(vals),st);
case (cache,env,"parseString",_,st,msg)
then (cache,ValuesUtil.makeArray({}),st);
/* Does not exist in the env...
case (cache,env,"lookupClass",{Values.CODE(Absyn.C_TYPENAME(path))},(st as Interactive.SYMBOLTABLE(ast = p)),msg)
equation
ptot = Dependency.getTotalProgram(path,p);
scodeP = SCodeUtil.translateAbsyn2SCode(ptot);
(cache,env) = Inst.makeEnvFromProgram(cache, scodeP, Absyn.IDENT(""));
(cache,c,env) = Lookup.lookupClass(cache,env, path, true);
SOME(p1) = Env.getEnvPath(env);
s1 = Absyn.pathString(p1);
Print.printBuf("Found class ");
Print.printBuf(s1);
Print.printBuf("\n\n");
str = Print.getString();
then
(cache,Values.STRING(str),st);
*/
case (cache,env,"codeToString",{Values.CODE(codeNode)},st,msg)
equation
str = Dump.printCodeStr(codeNode);
then (cache,Values.STRING(str),st);
case (cache,env,"typeOf",{Values.CODE(Absyn.C_VARIABLENAME(Absyn.CREF_IDENT(name = varid)))},(st as Interactive.SYMBOLTABLE(lstVarVal = iv)),msg)
equation
tp = Interactive.getTypeOfVariable(varid, iv);
str = Types.unparseType(tp);
then
(cache,Values.STRING(str),st);
case (cache,env,"clear",{},st,msg)
then (cache,Values.BOOL(true),Interactive.emptySymboltable);
case (cache,env,"clearVariables",{},
(st as Interactive.SYMBOLTABLE(
ast = p,
depends = aDep,
explodedAst = fp,
instClsLst = ic,
compiledFunctions = cf,
loadedFiles = lf)),msg)
equation
newst = Interactive.SYMBOLTABLE(p,aDep,fp,ic,{},cf,lf);
then
(cache,Values.BOOL(true),newst);
// Note: This is not the environment caches, passed here as cache, but instead the cached instantiated classes.
case (cache,env,"clearCache",{},
(st as Interactive.SYMBOLTABLE(
ast = p,depends=aDep,explodedAst = fp,instClsLst = ic,
lstVarVal = iv,compiledFunctions = cf,
loadedFiles = lf)),msg)
equation
newst = Interactive.SYMBOLTABLE(p,aDep,fp,{},iv,cf,lf);
then
(cache,Values.BOOL(true),newst);
case (cache,env,"regex",{Values.STRING(str),Values.STRING(re),Values.INTEGER(i),Values.BOOL(extended),Values.BOOL(insensitive)},st,msg)
equation
(n,strs) = System.regex(str,re,i,extended,insensitive);
vals = List.map(strs,ValuesUtil.makeString);
v = Values.ARRAY(vals,{i});
then
(cache,Values.TUPLE({Values.INTEGER(n),v}),st);
case (cache,env,"regex",{Values.STRING(str),Values.STRING(re),Values.INTEGER(i),Values.BOOL(extended),Values.BOOL(insensitive)},st,msg)
equation
strs = List.fill("",i);
vals = List.map(strs,ValuesUtil.makeString);
v = Values.ARRAY(vals,{i});
then
(cache,Values.TUPLE({Values.INTEGER(-1),v}),st);
case (cache,env,"list",{Values.CODE(Absyn.C_TYPENAME(Absyn.IDENT("AllLoadedClasses")))},(st as Interactive.SYMBOLTABLE(ast = p)),msg)
equation
str = Dump.unparseStr(p,false);
then
(cache,Values.STRING(str),st);
case (cache,env,"list",{Values.CODE(Absyn.C_TYPENAME(path))},(st as Interactive.SYMBOLTABLE(ast = p)),msg)
equation
absynClass = Interactive.getPathedClassInProgram(path, p);
str = Dump.unparseStr(Absyn.PROGRAM({absynClass},Absyn.TOP(),Absyn.TIMESTAMP(0.0,0.0)),false) ;
then
(cache,Values.STRING(str),st);
case (cache,env,"list",_,st,msg) then (cache,Values.STRING(""),st);
case (cache,env,"jacobian",{Values.CODE(Absyn.C_TYPENAME(path))},
(st as Interactive.SYMBOLTABLE(
ast = p,depends=aDep,explodedAst = fp,instClsLst = ic,
lstVarVal = iv,compiledFunctions = cf,
loadedFiles = lf)),msg)
equation
ptot = Dependency.getTotalProgram(path,p);
scodeP = SCodeUtil.translateAbsyn2SCode(ptot);
(cache, env, _, dae) = Inst.instantiateClass(cache, InnerOuter.emptyInstHierarchy, scodeP, path);
dae = DAEUtil.transformationsBeforeBackend(cache,dae);
ic_1 = Interactive.addInstantiatedClass(ic, Interactive.INSTCLASS(path,dae,env));
funcs = Env.getFunctionTree(cache);
daelow = BackendDAECreate.lower(dae, funcs, false) "no dummy state" ;
(optdae as BackendDAE.DAE({syst},shared)) = BackendDAEUtil.preOptimiseBackendDAE(daelow,funcs,NONE());
(syst,m,mt) = BackendDAEUtil.getIncidenceMatrixfromOption(syst,shared);
vars = BackendVariable.daeVars(syst);
eqnarr = BackendEquation.daeEqns(syst);
ae = BackendEquation.daeArrayEqns(optdae);
jac = BackendDAEUtil.calculateJacobian(vars, eqnarr, ae, m, mt,false);
res = BackendDump.dumpJacobianStr(jac);
then
(cache,Values.STRING(res),Interactive.SYMBOLTABLE(p,aDep,fp,ic_1,iv,cf,lf));
case (cache,env,"translateModel",{Values.CODE(Absyn.C_TYPENAME(className)),Values.STRING(filenameprefix)},st,msg)
equation
(cache,ret_val,st_1,_,_,_,_) = translateModel(cache, env, className, st, filenameprefix, true, NONE());
then
(cache,ret_val,st_1);
case (cache,env,"translateModel",_,st,msg)
then (cache,Values.STRING("There were errors during translation. Use getErrorString() to see them."),st);
/*case (cache,env,"translateModelCPP",{Values.CODE(Absyn.C_TYPENAME(className)),Values.STRING(filenameprefix)},st,msg)
equation
(cache,ret_val,st_1,_,_,_,_) = translateModelCPP(cache,env, className, st, filenameprefix,true,NONE());
then
(cache,ret_val,st_1);*/
case (cache,env,"translateModelFMU",{Values.CODE(Absyn.C_TYPENAME(className)),Values.STRING(filenameprefix)},st,msg)
equation
(cache,ret_val,st_1) = translateModelFMU(cache, env, className, st, filenameprefix, true, NONE());
then
(cache,ret_val,st_1);
case (cache,env,"exportDAEtoMatlab",{Values.CODE(Absyn.C_TYPENAME(className)),Values.STRING(filenameprefix)},st,msg)
equation
(cache,ret_val,st_1,_) = getIncidenceMatrix(cache,env, className, st, msg, filenameprefix);
then
(cache,ret_val,st_1);
case (cache,env,"checkModel",{Values.CODE(Absyn.C_TYPENAME(className))},st,msg)
equation
OptManager.setOption("checkModel", true);
(cache,ret_val,st_1) = checkModel(cache, env, className, st, msg);
OptManager.setOption("checkModel", false);
then
(cache,ret_val,st_1);
case (cache,env,"checkAllModelsRecursive",{Values.CODE(Absyn.C_TYPENAME(className))},st,msg)
equation
(cache,ret_val,st_1) = checkAllModelsRecursive(cache, env, className, st, msg);
then
(cache,ret_val,st_1);
case (cache,env,"translateGraphics",{Values.CODE(Absyn.C_TYPENAME(className))},st,msg)
equation
(cache,ret_val,st_1) = translateGraphics(cache,env, className, st, msg);
then
(cache,ret_val,st_1);
case (cache,env,"setCompileCommand",{Values.STRING(cmd)},st,msg)
equation
// cmd = Util.rawStringToInputString(cmd);
Settings.setCompileCommand(cmd);
then
(cache,Values.BOOL(true),st);
case (cache,env,"getCompileCommand",{},st,msg)
equation
res = Settings.getCompileCommand();
then
(cache,Values.STRING(res),st);
case (cache,env,"setPlotCommand",{Values.STRING(cmd)},st,msg)
then
(cache,Values.BOOL(false),st);
case (cache,env,"setTempDirectoryPath",{Values.STRING(cmd)},st,msg)
equation
// cmd = Util.rawStringToInputString(cmd);
Settings.setTempDirectoryPath(cmd);
then
(cache,Values.BOOL(true),st);
case (cache,env,"getTempDirectoryPath",{},st,msg)
equation
res = Settings.getTempDirectoryPath();
then
(cache,Values.STRING(res),st);
case (cache,env,"setEnvironmentVar",{Values.STRING(varid),Values.STRING(str)},st,msg)
equation
b = 0 == System.setEnv(varid,str,true);
then
(cache,Values.BOOL(b),st);
case (cache,env,"getEnvironmentVar",{Values.STRING(varid)},st,msg)
equation
res = Util.makeValueOrDefault(System.readEnv, varid, "");
then
(cache,Values.STRING(res),st);
case (cache,env,"setInstallationDirectoryPath",{Values.STRING(cmd)},st,msg)
equation
// cmd = Util.rawStringToInputString(cmd);
Settings.setInstallationDirectoryPath(cmd);
then
(cache,Values.BOOL(true),st);
case (cache,env,"getInstallationDirectoryPath",{},st,msg)
equation
res = Settings.getInstallationDirectoryPath();
then
(cache,Values.STRING(res),st);
case (cache,env,"getModelicaPath",{},st,msg)