/
ModelicaBuiltin.mo
1225 lines (1041 loc) · 37.2 KB
/
ModelicaBuiltin.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.
*
*/
function der "type for builtin operator der has unit type parameter to be able to express that
derivative of expression means an addition of 1/s on the unit dimension"
input Real x(unit="'p");
output Real dx(unit="'p/s");
external "builtin";
end der;
function initial
output Boolean isInitial;
annotation(__OpenModelica_Impure = true);
external "builtin";
end initial;
function terminal
output Boolean isTerminal;
annotation(__OpenModelica_Impure = true);
external "builtin";
end terminal;
type AssertionLevel_ = enumeration(error, warning);
function assert
input Boolean condition;
input String message;
input AssertionLevel_ level;
external "builtin";
end assert;
function constrain
input Real i1;
input Real i2;
input Real i3;
output Real o1;
external "builtin";
end constrain;
function sample
input Real start;
input Real interval;
// Implement it like this?
// parameter input Real start(fixed=false);
// parameter input Real interval(fixed=false);
output Boolean isSample;
annotation(__OpenModelica_Impure = true);
external "builtin";
end sample;
function ceil
input Real x;
output Real y;
external "builtin";
end ceil;
function floor
input Real x;
output Real y;
external "builtin";
end floor;
function integer
input Real x;
output Integer y;
external "builtin";
end integer;
function sqrt
input Real x(unit="'p");
output Real y(unit="'p(1/2)");
external "builtin";
end sqrt;
function sign
input Real v;
output Integer _sign;
external "builtin";
/* We do this with external "builtin" for now. But maybe we should inline it instead...
annotation(__OpenModelica_EarlyInline = true);
algorithm
_sign := noEvent(if v > 0 then 1 else if v < 0 then -1 else 0);
*/
end sign;
function identity
input Integer arraySize;
output Integer[arraySize,arraySize] outArray;
external "builtin";
end identity;
function semiLinear
input Real x;
input Real positiveSlope;
input Real negativeSlope;
output Real result;
external "builtin";
end semiLinear;
function edge
input Boolean b;
output Boolean edgeEvent;
// TODO: Ceval parameters? Needed to remove the builtin handler
external "builtin";
end edge;
function sin
input Real x;
output Real y;
external "builtin";
end sin;
function cos
input Real x;
output Real y;
external "builtin";
end cos;
function tan
input Real x;
output Real y;
external "builtin";
end tan;
function sinh
input Real x;
output Real y;
external "builtin";
end sinh;
function cosh
input Real x;
output Real y;
external "builtin";
end cosh;
function tanh
input Real x;
output Real y;
external "builtin";
end tanh;
function asin
input Real x;
output Real y;
external "builtin";
end asin;
function acos
input Real x;
output Real y;
external "builtin";
end acos;
function atan
input Real x;
output Real y;
external "builtin";
end atan;
function atan2
input Real x1;
input Real x2;
output Real y;
external "builtin";
end atan2;
function exp
input Real x(unit="1");
output Real y(unit="1");
external "builtin";
end exp;
function log
input Real x(unit="1");
output Real y(unit="1");
external "builtin";
end log;
function log10
input Real x(unit="1");
output Real y(unit="1");
external "builtin";
end log10;
function homotopy
input Real actual;
input Real simplified;
output Real outValue;
external "builtin";
end homotopy;
// Dummy functions that can't be properly defined in Modelica, but used by
// SCodeFlatten to define which builtin functions exist (SCodeFlatten doesn't
// care how the functions are defined, only if they exist or not).
function div
/* Real or Integer in/output */
external "builtin";
end div;
function mod
/* Real or Integer in/output */
external "builtin";
end mod;
function rem
/* Real or Integer in/output */
external "builtin";
end rem;
function delay
external "builtin";
end delay;
function abs
/* Real or Integer in/output */
external "builtin";
end abs;
function min
external "builtin";
end min;
function max
external "builtin";
end max;
function sum
external "builtin";
end sum;
function product
external "builtin";
end product;
function transpose
external "builtin";
end transpose;
function outerProduct
external "builtin";
end outerProduct;
function symmetric
external "builtin";
end symmetric;
function cross
external "builtin";
end cross;
function skew
external "builtin";
end skew;
function smooth
external "builtin";
end smooth;
function diagonal
external "builtin";
end diagonal;
function cardinality
external "builtin";
end cardinality;
function array
external "builtin";
end array;
function zeros
external "builtin";
end zeros;
function ones
external "builtin";
end ones;
function fill
external "builtin";
end fill;
function linspace
external "builtin";
end linspace;
function noEvent
external "builtin";
end noEvent;
function pre
external "builtin";
end pre;
function change
external "builtin";
end change;
function reinit
external "builtin";
end reinit;
function ndims
external "builtin";
end ndims;
function size
external "builtin";
end size;
function scalar
external "builtin";
end scalar;
function vector
external "builtin";
end vector;
function matrix
external "builtin";
end matrix;
function cat
external "builtin";
end cat;
function rooted "Not standard Modelica"
external "builtin";
end rooted;
function actualStream
external "builtin";
end actualStream;
function inStream
external "builtin";
end inStream;
encapsulated package Connections
function branch
external "builtin";
end branch;
function root
external "builtin";
end root;
function potentialRoot
external "builtin";
end potentialRoot;
function isRoot
external "builtin";
end isRoot;
end Connections;
encapsulated package Subtask
type SamplingType = enumeration(Disabled, Continuous, Periodic);
function decouple
external "builtin";
end decouple;
function activated
external "builtin";
end activated;
function lastInterval
external "builtin";
end lastInterval;
end Subtask;
function print "Not standard Modelica, but very useful for debugging."
input String str;
annotation(__OpenModelica_Impure = true);
external "builtin";
end print;
function classDirectory "Not standard Modelica"
output String str;
external "builtin";
end classDirectory;
/* Actually contains more...
record SimulationResult
String resultFile;
String simulationOptions;
String messages;
end SimulationResult; */
encapsulated package OpenModelica
type Code "Code quoting is not a uniontype yet because that would require enabling MetaModelica extensions in the regular compiler.
Besides, it has special semantics."
type TypeName "A path, for example the name of a class, e.g. A.B.C or .A.B" end TypeName;
type VariableName "A variable name, e.g. a.b or a[1].b[3].c" end VariableName;
type VariableNames "An array of variable names, e.g. {a.b,a[1].b[3].c}, or a single VariableName" end VariableNames;
end Code;
package Scripting
import OpenModelica.Code.TypeName;
import OpenModelica.Code.VariableName;
import OpenModelica.Code.VariableNames;
record CheckSettingsResult
String OPENMODELICAHOME,OPENMODELICALIBRARY,OMC_PATH;
Boolean OMC_FOUND;
String MODELICAUSERCFLAGS,WORKING_DIRECTORY;
Boolean CREATE_FILE_WORKS,REMOVE_FILE_WORKS;
String OS, SYSTEM_INFO,SENDDATALIBS,C_COMPILER;
Boolean C_COMPILER_RESPONDING;
String CONFIGURE_CMDLINE;
end CheckSettingsResult;
function checkSettings "Display some diagnostics"
output CheckSettingsResult result;
external "builtin";
end checkSettings;
function loadFile "load file (*.mo) and merge it with the loaded AST"
input String fileName;
output Boolean success;
external "builtin";
end loadFile;
function system "Similar to system(3). Executes the given command in the system shell."
input String callStr "String to call: bash -c $callStr";
output Integer retval "Return value of the system call; usually 0 on success";
external "builtin";
end system;
function saveAll "save the entire loaded AST to file"
input String fileName;
output Boolean success;
external "builtin";
end saveAll;
function help "display the OpenModelica help text"
output String helpText;
annotation(__OpenModelica_EarlyInline = true);
algorithm
helpText := readFile(getInstallationDirectoryPath() + "/share/doc/omc/omc_helptext.txt");
end help;
function clear
output Boolean success;
external "builtin";
end clear;
function clearVariables
output Boolean success;
external "builtin";
end clearVariables;
function enableSendData
input Boolean enabled;
output Boolean success;
external "builtin";
end enableSendData;
function setDataPort
input Integer port;
output Boolean success;
external "builtin";
end setDataPort;
function generateHeader
input String fileName;
output Boolean success;
external "builtin";
end generateHeader;
function generateSeparateCode
output Boolean success;
external "builtin";
end generateSeparateCode;
function setLinker
input String linker;
output Boolean success;
external "builtin";
end setLinker;
function setLinkerFlags
input String linkerFlags;
output Boolean success;
external "builtin";
end setLinkerFlags;
function setCompiler
input String compiler;
output Boolean success;
external "builtin";
end setCompiler;
function verifyCompiler
output Boolean compilerWorks;
external "builtin";
end verifyCompiler;
function setCompilerPath
input String compilerPath;
output Boolean success;
external "builtin";
end setCompilerPath;
function getCompileCommand
output String compileCommand;
external "builtin";
end getCompileCommand;
function setCompileCommand
input String compileCommand;
output Boolean success;
external "builtin";
end setCompileCommand;
function setPlotCommand
input String plotCommand;
output Boolean success;
external "builtin";
end setPlotCommand;
function getSettings
output String settings;
annotation(__OpenModelica_EarlyInline = true);
algorithm
settings :=
"Compile command: " + getCompileCommand() + "\n" +
"Temp folder path: " + getTempDirectoryPath() + "\n" +
"Installation folder: " + getInstallationDirectoryPath() + "\n" +
"Modelica path: " + getModelicaPath() + "\n";
end getSettings;
function setTempDirectoryPath
input String tempDirectoryPath;
output Boolean success;
external "builtin";
end setTempDirectoryPath;
function getTempDirectoryPath
output String tempDirectoryPath;
external "builtin";
end getTempDirectoryPath;
function getEnvironmentVar
input String var;
output String value "returns empty string on failure";
external "builtin";
end getEnvironmentVar;
function setEnvironmentVar
input String var;
input String value;
output Boolean success;
external "builtin";
end setEnvironmentVar;
function appendEnvironmentVar
input String var;
input String value;
output String result "returns \"error\" if the variable could not be appended";
annotation(__OpenModelica_EarlyInline = true);
algorithm
result := if setEnvironmentVar(var,getEnvironmentVar(var)+value) then getEnvironmentVar(var) else "error";
end appendEnvironmentVar;
function setInstallationDirectoryPath "Sets the OPENMODELICAHOME environment variable. Use this method instead of setEnvironmentVar"
input String installationDirectoryPath;
output Boolean success;
external "builtin";
end setInstallationDirectoryPath;
function getInstallationDirectoryPath "This returns OPENMODELICAHOME if it is set; on some platforms the default path is returned if it is not set."
output String installationDirectoryPath;
external "builtin";
end getInstallationDirectoryPath;
function setModelicaPath "The Modelica Library Path - MODELICAPATH in the language specification; OPENMODELICALIBRARY in OpenModelica."
input String modelicaPath;
output Boolean success;
external "builtin";
end setModelicaPath;
function getModelicaPath "The Modelica Library Path - MODELICAPATH in the language specification; OPENMODELICALIBRARY in OpenModelica."
output String modelicaPath;
external "builtin";
end getModelicaPath;
function setCompilerFlags
input String compilerFlags;
output Boolean success;
external "builtin";
end setCompilerFlags;
function setDebugFlags "example input: failtrace,-noevalfunc"
input String debugFlags;
output Boolean success;
annotation(__OpenModelica_EarlyInline = true);
algorithm
success := setCommandLineOptions("+d=" + debugFlags);
end setDebugFlags;
function setPreOptModules "example input: removeSimpleEquations,removeParameterEqns,expandDerOperator"
input String modules;
output Boolean success;
annotation(__OpenModelica_EarlyInline = true);
algorithm
success := setCommandLineOptions("+preOptModules=" + modules);
end setPreOptModules;
function setPastOptModules "example input: lateInline,inlineArrayEqn,removeSimpleEquations,removeAliasEquations"
input String modules;
output Boolean success;
annotation(__OpenModelica_EarlyInline = true);
algorithm
success := setCommandLineOptions("+pastOptModules=" + modules);
end setPastOptModules;
function setCommandLineOptions
"The input is a regular command-line flag given to OMC, e.g. +d=failtrace or +g=MetaModelica"
input String option;
output Boolean success;
external "builtin";
end setCommandLineOptions;
function getVersion
"Returns the version of the Modelica compiler"
output String version;
external "builtin";
end getVersion;
function readFile
"The contents of the given file are returned.
Note that if the function fails, the error message is returned as a string instead of multiple output or similar."
input String fileName;
output String contents;
external "builtin";
end readFile;
function readFileShowLineNumbers "Prefixes each line in the file with <n>:, where n is the line number"
input String fileName;
output String out;
protected
String line;
Integer num:=1;
algorithm
out := "";
for line in strtok(readFile(fileName),"\n") loop
out := out + String(num) + ": " + line + "\n";
num := num + 1;
end for;
end readFileShowLineNumbers;
function readFilePostprocessLineDirective "
Searches lines for the #modelicaLine directive. If it is found, all lines up
until the next #modelicaLine or #endModelicaLine are put on a single file,
following a #line linenumber \"filename\" line.
This causes GCC to output an executable that we can set breakpoints in and
debug.
Note: You could use a stack to keep track of start/end of #modelicaLine and
match them up. But this is not really desirable since that will cause extra
breakpoints for the same line (you would get breakpoints before and after
each case if you break on a match-expression, etc).
"
input String fileName;
output String out;
protected
constant String regexStart := "^ *..#modelicaLine";
constant String regexEnd := "^ *..#endModelicaLine";
constant String regexSplit := "^ *..#modelicaLine .([A-Za-z.]*):([0-9]*):[0-9]*-[0-9]*:[0-9]*...$";
constant Integer numInRegex := 3;
String str,line,currentModelicaFileName;
Integer lineNumInOutputFile:=1,numMatches:=0;
Boolean insideModelicaLine:=false;
String splitLine[numInRegex] := {"","",""};
algorithm
str := readFile(fileName);
out := "";
for line in strtok(str,"\n") loop
(numMatches,splitLine) := regex(line,regexSplit,numInRegex);
if numMatches == 3 then
insideModelicaLine := true;
out := out + "#line " + splitLine[3] + " \"" + splitLine[2] + "\"\n";
lineNumInOutputFile := lineNumInOutputFile + 1;
elseif regexBool(line,regexEnd) then
insideModelicaLine := false;
out := out + "\n" + "#line " + String(lineNumInOutputFile+1) + " \"" + fileName + "\"\n";
lineNumInOutputFile := lineNumInOutputFile + 3;
elseif insideModelicaLine then
out := out + " " + line;
else
out := out + line + "\n";
lineNumInOutputFile := lineNumInOutputFile + 1;
end if;
end for;
end readFilePostprocessLineDirective;
function regex "Sets the error buffer and returns -1 if the regex does not compile.
The returned result is the same as POSIX regex():
The first value is the complete matched string
The rest are the substrings that you wanted.
For example:
regex(lorem,\" \\([A-Za-z]*\\) \\([A-Za-z]*\\) \",maxMatches=3)
=> {\" ipsum dolor \",\"ipsum\",\"dolor\"}
This means if you have n groups, you want maxMatches=n+1
"
input String str;
input String re;
input Integer maxMatches := 1 "The maximum number of matches that will be returned";
input Boolean extended := true "Use POSIX extended or regular syntax";
input Boolean caseInsensitive := false;
output Integer numMatches "-1 is an error, 0 means no match, else returns a number 1..maxMatches";
output String matchedSubstrings[maxMatches] "unmatched strings are returned as empty";
external "builtin";
end regex;
function regexBool "Returns true if the string matches the regular expression"
input String str;
input String re;
input Boolean extended := true "Use POSIX extended or regular syntax";
input Boolean caseInsensitive := false;
output Boolean matches;
protected
Integer numMatches;
algorithm
numMatches := regex(str,re,0,extended,caseInsensitive);
matches := numMatches == 1;
end regexBool;
function readFileNoNumeric
"Returns the contents of the file, with anything resembling a (real) number stripped out, and at the end adding:
Filter count from number domain: n.
This should probably be changed to multiple outputs; the filtered string and an integer.
Does anyone use this API call?"
input String fileName;
output String contents;
external "builtin";
end readFileNoNumeric;
function getErrorString
"[file.mo:n:n-n:n:b] Error: message"
output String errorString;
external "builtin";
end getErrorString;
function getMessagesString
"see getErrorString()"
output String messagesString;
external "builtin" messagesString=getErrorString();
end getMessagesString;
function getMessagesStringInternal
"{{[file.mo:n:n-n:n:b] Error: message, TRANSLATION, Error, code}}"
output String messagesString;
external "builtin";
end getMessagesStringInternal;
function clearMessages "Clears the error buffer"
output Boolean success;
external "builtin";
end clearMessages;
function runScript "Runs the mos-script specified by the filename."
input String fileName "*.mos";
output String result;
external "builtin";
end runScript;
function echo "echo(false) disables Interactive output, echo(true) enables it again."
input Boolean setEcho;
output Boolean newEcho;
external "builtin";
end echo;
function getClassesInModelicaPath "MathCore-specific or not? Who knows!"
output String classesInModelicaPath;
external "builtin";
end getClassesInModelicaPath;
function strictRMLCheck "Checks if any loaded function"
output String message "empty if there was no problem";
external "builtin";
end strictRMLCheck;
/* These don't influence anything...
function getClassNamesForSimulation
output String classNamesForSimulation;
external "builtin";
end getClassNamesForSimulation;
function setClassNamesForSimulation
input String classNamesForSimulation;
output Boolean success;
external "builtin";
end setClassNamesForSimulation;
*/
function getAnnotationVersion
output String annotationVersion;
external "builtin";
end getAnnotationVersion;
function setAnnotationVersion
input String annotationVersion;
output Boolean success;
annotation(__OpenModelica_EarlyInline = true);
algorithm
success := setCommandLineOptions("+annotationVersion=" + annotationVersion);
end setAnnotationVersion;
function getNoSimplify
output Boolean noSimplify;
external "builtin";
end getNoSimplify;
function setNoSimplify
input Boolean noSimplify;
output Boolean success;
external "builtin";
end setNoSimplify;
function getVectorizationLimit
output Integer vectorizationLimit;
external "builtin";
end getVectorizationLimit;
function setVectorizationLimit
input Integer vectorizationLimit;
output Boolean success;
annotation(__OpenModelica_EarlyInline = true);
algorithm
success := setCommandLineOptions("+v=" + String(vectorizationLimit));
end setVectorizationLimit;
function setShowAnnotations
input Boolean show;
output Boolean success;
external "builtin";
end setShowAnnotations;
function getShowAnnotations
output Boolean show;
external "builtin";
end getShowAnnotations;
function setOrderConnections
input Boolean orderConnections;
output Boolean success;
annotation(__OpenModelica_EarlyInline = true);
algorithm
success := setCommandLineOptions("+orderConnections=" + String(orderConnections));
end setOrderConnections;
function getOrderConnections
output Boolean orderConnections;
external "builtin";
end getOrderConnections;
function getAstAsCorbaString "Print the whole AST on the CORBA format for records, e.g.
record Absyn.PROGRAM
classes = ...,
within_ = ...,
globalBuildTimes = ...
end Absyn.PROGRAM;"
input String fileName := "<interactive>";
output String result "returns the string if fileName is interactive; else it returns ok or error depending on if writing the file succeeded";
external "builtin";
end getAstAsCorbaString;
function cd "change directory to the given path (which may be either relative or absolute)
returns the new working directory on success or a message on failure
if the given path is the empty string, the function simply returns the current working directory
"
input String newWorkingDirectory := "";
output String workingDirectory;
external "builtin";
end cd;
function checkModel
input TypeName className;
output String result;
external "builtin";
end checkModel;
function checkAllModelsRecursive
input TypeName className;
output String result;
external "builtin";
end checkAllModelsRecursive;
function typeOf
input VariableName variableName;
output String result;
external "builtin";
end typeOf;
function instantiateModel
input TypeName className;
output String result;
external "builtin";
end instantiateModel;
function generateCode "The input is a function name for which C-code is generated and compiled into a dll/so"
input TypeName className;
output Boolean success;
external "builtin";
end generateCode;
function loadModel "Parses the getModelicaPath(), and finds the package to load. If the input is Modelica.XXX, the complete Modelica AST is loaded."
input TypeName className;
output Boolean success;
external "builtin";
end loadModel;
function deleteFile "Deletes a file with the given name"
input String fileName;
output Boolean success;
external "builtin";
end deleteFile;
function saveModel
input String fileName;
input TypeName className;
output Boolean success;
external "builtin";
end saveModel;
function saveTotalModel
input String fileName;
input TypeName className;
output Boolean success;
external "builtin";
end saveTotalModel;
function save
input TypeName className;
output Boolean success;
external "builtin";
end save;
function translateGraphics
input TypeName className;
output String result;
external "builtin";
end translateGraphics;
function readSimulationResult "Reads a result file, returning a matrix corresponding to the variables and size given."
input String filename;
input VariableNames variables;
input Integer size := 0 "0=read any size... If the size is not the same as the result-file, this function fails";
output Real result[:,:];
external "builtin";
end readSimulationResult;
function readSimulationResultSize "The number of intervals that are present in the output file"
input String fileName;
output Integer sz;
external "builtin";
end readSimulationResultSize;
function readSimulationResultVars "Returns the variables in the simulation file; you can use val() and plot() commands using these names"
input String fileName;
output String[:] vars;
external "builtin";
end readSimulationResultVars;