/
System.mo
1000 lines (834 loc) · 34.3 KB
/
System.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 System
" file: System.mo
package: System
description: This file contains runtime system specific function, which are implemented in C.
RCS: $Id$
This module contain a set of system calls, for e.g. compiling and
executing stuff, reading and writing files and so on."
public function removeFirstAndLastChar
input String inString;
output String outString;
external "C" outString=System_removeFirstAndLastChar(inString) annotation(Library = "omcruntime");
end removeFirstAndLastChar;
public function trim
"removes chars in charsToRemove from begin and end of inString"
input String inString;
input String charsToRemove;
output String outString;
external "C" outString=System_trim(inString,charsToRemove) annotation(Library = "omcruntime");
end trim;
public function trimWhitespace
"removes chars in ' \f\n\r\t\v' from begin and end of inString"
input String inString;
output String outString;
external "C" outString=System_trimWhitespace(inString) annotation(Library = "omcruntime");
end trimWhitespace;
public function trimChar
input String inString1;
input String inString2;
output String outString;
external "C" outString=System_trimChar(inString1,inString2) annotation(Library = "omcruntime");
end trimChar;
public function strcmp
"This function returns:
0 if inString1 == inString2
1 if inString1 > inString2
-1 if inString1 < inString2
This is different from what C strcmp
returns (negative values if <, positive values if >).
We fix negative values to -1 and positive to +1 so
we can pattern match on them directly in MetaModelica!"
input String inString1;
input String inString2;
output Integer outInteger;
external "C" outInteger=System_strcmp(inString1,inString2) annotation(Library = "omcruntime");
end strcmp;
public function stringFind "locates substring searchStr in str. If succeeds return position, otherwise return -1"
input String str;
input String searchStr;
output Integer outInteger;
external "C" outInteger=System_stringFind(str,searchStr) annotation(Library = "omcruntime");
end stringFind;
public function stringFindString "locates substring searchStr in str. If succeeds return the string, otherwise fail"
input String str;
input String searchStr;
output String outString;
external "C" outString=System_stringFindString(str,searchStr) annotation(Library = "omcruntime");
end stringFindString;
public function regex "Fails and sets Error.mo 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 "The maximum number of matches that will be returned";
input Boolean extended "Use POSIX extended or regular syntax";
input Boolean sensitive;
output Integer numMatches "0 means no match, else returns a number 1..maxMatches (1 if maxMatches<0)";
output list<String> strs "This list has length = maxMatches. Substrings that did not match are filled with the empty string";
external "C" strs=System_regex(str,re,maxMatches,extended,sensitive,numMatches) annotation(Library = "omcruntime");
end regex;
public function strncmp
input String inString1;
input String inString2;
input Integer len;
output Integer outInteger;
external "C" outInteger=System_strncmp(inString1,inString2,len) annotation(Library = "omcruntime");
end strncmp;
public function stringReplace
input String str;
input String source;
input String target;
output String res;
external "C" res=System_stringReplace(str,source,target) annotation(Library = "omcruntime");
end stringReplace;
public function toupper
input String inString;
output String outString;
external "C" outString=System_toupper(inString) annotation(Library = "omcruntime");
end toupper;
public function tolower
input String inString;
output String outString;
external "C" outString=System_tolower(inString) annotation(Library = "omcruntime");
end tolower;
public function strtok
input String string;
input String token;
output list<String> strings;
external "C" strings=System_strtok(string,token) annotation(Library = "omcruntime");
end strtok;
public function substring
input String inString;
input Integer start;
input Integer stop;
output String outString;
external "C" outString = System_substring(inString,start,stop) annotation(Library = "omcruntime");
end substring;
public function setCCompiler
input String inString;
external "C" SystemImpl__setCCompiler(inString) annotation(Library = "omcruntime");
end setCCompiler;
public function getCCompiler
output String outString;
external "C" outString=System_getCCompiler() annotation(Library = "omcruntime");
end getCCompiler;
public function setCFlags
input String inString;
external "C" SystemImpl__setCFlags(inString) annotation(Library = "omcruntime");
end setCFlags;
public function getCFlags
output String outString;
external "C" outString=System_getCFlags() annotation(Library = "omcruntime");
end getCFlags;
public function setCXXCompiler
input String inString;
external "C" SystemImpl__setCXXCompiler(inString) annotation(Library = "omcruntime");
end setCXXCompiler;
public function getCXXCompiler
output String outString;
external "C" outString=System_getCXXCompiler() annotation(Library = "omcruntime");
end getCXXCompiler;
public function setLinker
input String inString;
external "C" SystemImpl__setLinker(inString) annotation(Library = "omcruntime");
end setLinker;
public function getLinker
output String outString;
external "C" outString=System_getLinker() annotation(Library = "omcruntime");
end getLinker;
public function setLDFlags
input String inString;
external "C" SystemImpl__setLDFlags(inString) annotation(Library = "omcruntime");
end setLDFlags;
public function getLDFlags
output String outString;
external "C" outString=System_getLDFlags() annotation(Library = "omcruntime");
end getLDFlags;
public function getMakeCommand
output String outString;
external "C" outString=System_getMakeCommand() annotation(Library = "omcruntime");
end getMakeCommand;
public function getExeExt
output String outString;
external "C" outString=System_getExeExt() annotation(Library = "omcruntime");
end getExeExt;
public function getDllExt
output String outString;
external "C" outString=System_getDllExt() annotation(Library = "omcruntime");
end getDllExt;
public function loadLibrary
input String inLib;
input Boolean inPrintDebug;
output Integer outLibHandle;
external "C" outLibHandle=System_loadLibrary(inLib, inPrintDebug) annotation(Library = "omcruntime");
end loadLibrary;
public function lookupFunction
input Integer inLibHandle;
input String inFunc;
output Integer outFuncHandle;
external "C" outFuncHandle=System_lookupFunction(inLibHandle,inFunc) annotation(Library = "omcruntime");
end lookupFunction;
public function freeFunction
input Integer inFuncHandle;
input Boolean inPrintDebug;
external "C" System_freeFunction(inFuncHandle, inPrintDebug) annotation(Library = "omcruntime");
end freeFunction;
public function freeLibrary
input Integer inLibHandle;
input Boolean inPrintDebug;
external "C" System_freeLibrary(inLibHandle, inPrintDebug) annotation(Library = "omcruntime");
end freeLibrary;
public function writeFile
"This function will write to the file given by first argument the given string"
input String fileNameToWrite "a filename where to write the data";
input String stringToBeWritten "the data";
external "C" System_writeFile(fileNameToWrite,stringToBeWritten) annotation(Library = "omcruntime");
end writeFile;
public function appendFile
input String file;
input String data;
external "C" System_appendFile(file,data) annotation(Library = "omcruntime");
end appendFile;
public function readFile
"Does not fail. Returns strings describing the error instead."
input String inString;
output String outString;
external "C" outString = System_readFile(inString) annotation(Library = "omcruntime");
end readFile;
public function systemCall
input String inString;
output Integer outInteger;
external "C" outInteger=SystemImpl__systemCall(inString) annotation(Library = "omcruntime");
end systemCall;
public function systemCallParallel
input list<String> inStrings;
output list<Integer> outIntegers;
external "C" outIntegers=SystemImpl__systemCallParallel(inStrings) annotation(Library = "omcruntime");
end systemCallParallel;
public function spawnCall
input String path "The absolute path to the executable";
input String str "The list of arguments with executable";
output Integer outInteger;
external "C" outInteger=SystemImpl__spawnCall(path,str) annotation(Library = "omcruntime");
end spawnCall;
public function cd
input String inString;
output Integer outInteger;
external "C" outInteger=chdir(inString) annotation(Library = "omcruntime");
end cd;
public function pwd
output String outString;
external "C" outString=SystemImpl__pwd() annotation(Library = "omcruntime");
end pwd;
public function readEnv "Reads the environment variable given as string, fails if variable not found"
input String inString;
output String outString;
external "C" outString=System_readEnv(inString) annotation(Library = "omcruntime");
end readEnv;
public function setEnv ""
input String varName;
input String value;
input Boolean overwrite "is always true on Windows, so recommended to always call it using true";
output Integer outInteger;
external "C" outInteger=setenv(varName,value,overwrite) annotation(Library = "omcruntime");
end setEnv;
public function subDirectories
input String inString;
output list<String> outStringLst;
external "C" outStringLst=System_subDirectories(inString) annotation(Library = "omcruntime");
end subDirectories;
public function moFiles
input String inString;
output list<String> outStringLst;
external "C" outStringLst=System_moFiles(inString) annotation(Library = "omcruntime");
end moFiles;
public function getLoadModelPath
input String className;
input list<String> prios;
input list<String> mps;
output String dir;
output String name;
output Boolean isDir;
external "C" System_getLoadModelPath(className,prios,mps,dir,name,isDir) annotation(Library = "omcruntime");
end getLoadModelPath;
public function time
output Real outReal;
external "C" outReal=SystemImpl__time() annotation(Library = "omcruntime");
end time;
public function pathDelimiter
output String outString;
external "C" outString=System_pathDelimiter() annotation(Library = "omcruntime");
end pathDelimiter;
public function groupDelimiter
output String outString;
external "C" outString=System_groupDelimiter() annotation(Library = "omcruntime");
end groupDelimiter;
public function regularFileExists
input String inString;
output Boolean outBool;
external "C" outBool = SystemImpl__regularFileExists(inString) annotation(Library = "omcruntime");
end regularFileExists;
public function removeFile "Removes a file, returns 0 if suceeds, implemented using remove() in stdio.h"
input String fileName;
output Integer res;
external "C" res=System_removeFile(fileName) annotation(Library = "omcruntime");
end removeFile;
public function getPackageFileNames
input String inString1;
input String inString2;
output String outString;
external "C" outString=System_getPackageFileNames(inString1,inString2) annotation(Library = "omcruntime");
end getPackageFileNames;
public function directoryExists
input String inString;
output Boolean outBool;
external "C" outBool=SystemImpl__directoryExists(inString) annotation(Library = "omcruntime");
end directoryExists;
public function platform
output String outString;
external "C" outString=System_platform() annotation(Library = "omcruntime");
end platform;
public function getClassnamesForSimulation
output String outString;
external "C" outString=System_getClassnamesForSimulation() annotation(Library = "omcruntime");
end getClassnamesForSimulation;
public function setClassnamesForSimulation
input String inString;
external "C" System_setClassnamesForSimulation(inString) annotation(Library = "omcruntime");
end setClassnamesForSimulation;
public function getVariableValue
input Real timeStamp;
input list<Real> timeValues;
input list<Real> varValues;
output Real outValue;
external "C" outValue=System_getVariableValue(timeStamp,timeValues,varValues) annotation(Library = "omcruntime");
end getVariableValue;
public function getFileModificationTime
"@author adrpo
this system function returns the modification time of a file as a
SOME(Real) which represents the time elapsed since the
Epoch (00:00:00 UTC, January 1, 1970).
If the file does not exist or if there is an error the returned value
will be NONE.
"
input String fileName;
output Option<Real> outValue;
external "C" outValue=System_getFileModificationTime(fileName) annotation(Library = "omcruntime");
end getFileModificationTime;
public function getCurrentTime
"@author adrpo
this system function returns current time elapsed
since the Epoch (00:00:00 UTC, January 1, 1970)."
output Real outValue;
external "C" outValue=SystemImpl__getCurrentTime() annotation(Library = "omcruntime");
end getCurrentTime;
public function getCurrentDateTime
"@author Frenkel TUD
this system function returns current time elapsed
since the Epoch (00:00:00 UTC, January 1, 1970)."
output Integer sec;
output Integer min;
output Integer hour;
output Integer mday;
output Integer mon;
output Integer year;
external "C" System_getCurrentDateTime(sec,min,hour,mday,mon,year) annotation(Library = "omcruntime");
end getCurrentDateTime;
public function getCurrentTimeStr "
returns current time in format Www Mmm dd hh:mm:ss yyyy
using the asctime() function in time.h (libc)
"
output String timeStr;
external "C" timeStr=System_getCurrentTimeStr() annotation(Library = "omcruntime");
end getCurrentTimeStr;
public function isSameFile "Checks if two filenames points to the same file"
input String fileName1;
input String fileName2;
external "C" System_isSameFile(fileName1,fileName2) annotation(Library = "omcruntime");
end isSameFile;
public function isIdenticalFile "Checks if two filenames points to the exact same file"
input String fileName1;
input String fileName2;
output Boolean same;
external "C" same=System_isIdenticalFile(fileName1,fileName2) annotation(Library = "omcruntime");
end isIdenticalFile;
public function windowsNewline "returns /r/n, since MetaModelica has a bug for representing this as a literal"
output String str;
external "C" str=System_windowsNewline() annotation(Library = "omcruntime");
end windowsNewline;
public function os "Returns a string with the operating system name
For linux: 'linux'
For OSX: 'OSX'
For Windows : 'Windows_NT' (the name of env var OS )
"
output String str;
external "C" str = System_os() annotation(Library = "omcruntime");
end os;
public function compileCFile
input String inString;
external "C" System_compileCFile(inString) annotation(Library = "omcruntime");
end compileCFile;
public function readFileNoNumeric
input String inString;
output String outString;
external "C" outString=SystemImpl__readFileNoNumeric(inString) annotation(Library = "omcruntime");
end readFileNoNumeric;
public function setHasExpandableConnectors
"@author: adrpo
sets the external flag that signals the
presence of expandable connectors in a model"
input Boolean hasExpandable;
external "C" System_setHasExpandableConnectors(hasExpandable) annotation(Library = "omcruntime");
end setHasExpandableConnectors;
public function getHasExpandableConnectors
"@author: adrpo
retrieves the external flag that signals the
presence of expandable connectors in a model"
output Boolean hasExpandable;
external "C" hasExpandable=System_getHasExpandableConnectors() annotation(Library = "omcruntime");
end getHasExpandableConnectors;
public function setPartialInstantiation
"@author: adrpo
sets the external flag that signals the
presence of expandable connectors in a model"
input Boolean isPartialInstantiation;
external "C" System_setPartialInstantiation(isPartialInstantiation) annotation(Library = "omcruntime");
end setPartialInstantiation;
public function getPartialInstantiation
"@author: adrpo
retrieves the external flag that signals the
presence of expandable connectors in a model"
output Boolean isPartialInstantiation;
external "C" isPartialInstantiation=System_getPartialInstantiation() annotation(Library = "omcruntime");
end getPartialInstantiation;
public function setHasStreamConnectors
"@author: adrpo
sets the external flag that signals the
presence of stream connectors in a model"
input Boolean hasStream;
external "C" System_setHasStreamConnectors(hasStream) annotation(Library = "omcruntime");
end setHasStreamConnectors;
public function getHasStreamConnectors
"@author: adrpo
retrieves the external flag that signals the
presence of stream connectors in a model"
output Boolean hasStream;
external "C" hasStream=System_getHasStreamConnectors() annotation(Library = "omcruntime");
end getHasStreamConnectors;
public function setUsesCardinality
"Sets the external flag that signals the use of the cardinality operator."
input Boolean inUses;
external "C" System_setUsesCardinality(inUses) annotation(Library = "omcruntime");
end setUsesCardinality;
public function getUsesCardinality
"Retrieves the external flag that signals the use of the cardinality operator."
output Boolean outUses;
external "C" outUses=System_getUsesCardinality() annotation(Library = "omcruntime");
end getUsesCardinality;
public function setHasInnerOuterDefinitions
"@author: adrpo
sets the external flag that signals the presence
of inner/outer comoponent definitions in a model"
input Boolean hasInnerOuterDefinitions;
external "C" System_setHasInnerOuterDefinitions(hasInnerOuterDefinitions) annotation(Library = "omcruntime");
end setHasInnerOuterDefinitions;
public function getHasInnerOuterDefinitions
"@author: adrpo
retrieves the external flag that signals the presence
of inner/outer comoponent definitions in a model"
output Boolean hasInnerOuterDefinitions;
external "C" hasInnerOuterDefinitions=System_getHasInnerOuterDefinitions() annotation(Library = "omcruntime");
end getHasInnerOuterDefinitions;
public function tmpTick
"returns a tick that can be reset"
output Integer tickNo;
external "C" tickNo = SystemImpl_tmpTick() annotation(Library = "omcruntime");
end tmpTick;
public function tmpTickReset
"resets the tick so it restarts on start"
input Integer start;
external "C" SystemImpl_tmpTickReset(start) annotation(Library = "omcruntime");
end tmpTickReset;
public function parForTick
"returns a tick that can be reset. used to uniquely identify parallel for loops"
output Integer loopNo;
external "C" loopNo = SystemImpl_parForTick() annotation(Library = "omcruntime");
end parForTick;
public function parForTickReset
"Resets parfor loop id for second round"
input Integer start;
external "C" SystemImpl_parForTickReset(start) annotation(Library = "omcruntime");
end parForTickReset;
public function tmpTickIndex
"returns a tick that can be reset. TODO: remove me when bootstrapped (default argument index=0)"
input Integer index;
output Integer tickNo;
external "C" tickNo = SystemImpl_tmpTickIndex(index) annotation(Library = "omcruntime");
end tmpTickIndex;
public function tmpTickIndexReserve
"returns a tick that can be reset and reserves N values in it.
TODO: remove me when bootstrapped (default argument index=0)"
input Integer index;
input Integer reserve "current tick + reserve";
output Integer tickNo;
external "C" tickNo = SystemImpl_tmpTickIndexReserve(index,reserve) annotation(Library = "omcruntime");
end tmpTickIndexReserve;
public function tmpTickResetIndex
"resets the tick so it restarts on start. TODO: remove me when bootstrapped (default argument index=0)"
input Integer start;
input Integer index;
external "C" SystemImpl_tmpTickResetIndex(start,index) annotation(Library = "omcruntime");
end tmpTickResetIndex;
public function getRTLibs
"Returns a string containing the compiler flags used for real-time libraries"
output String libs;
external "C" libs=System_getRTLibs() annotation(Library = "omcruntime");
end getRTLibs;
public function getCorbaLibs
"Returns a string containing the compiler flags used for Corba libraries.
Needed for annotation(Library=\"OpenModelicaCorba\"), a library with special
semantics."
output String corbaLibs;
external "C" corbaLibs=System_getCorbaLibs() annotation(Library = "omcruntime");
end getCorbaLibs;
public function getRuntimeLibs
"Returns a string containing the compiler flags used for omcruntime libraries.
Needed for annotation(Library=\"omcruntime\"), a library with special semantics."
output list<String> libs;
external "C" libs=System_getRuntimeLibs() annotation(Library = "omcruntime");
end getRuntimeLibs;
public function userIsRoot
"Returns true if the current user is root.
Used by main to disable running omc as root as it is very dangerous.
Consider opening a socket and letting anyone run system() commands without authentication. As root."
output Boolean isRoot;
external "C" isRoot=System_userIsRoot() annotation(Library = "omcruntime");
end userIsRoot;
public function configureCommandLine
"Returns the date and command used to configure OpenModelica.
On the platforms that don't configure options, like OMDev, the returned string
is more generic and does not contain a date."
output String cmdLine;
external "C" cmdLine=System_configureCommandLine() annotation(Library = "omcruntime");
end configureCommandLine;
public function realtimeTick
"Tock returns the time since the last tock; undefined if tick was never called.
The clock index is 0-31. The function fails if the number is out of range."
input Integer clockIndex;
external "C" System_realtimeTick(clockIndex) annotation(Library = "omcruntime");
end realtimeTick;
public function realtimeTock
"Tock returns the time since the last tock, undefined if tick was never called.
The clock index is 0-31. The function fails if the number is out of range."
input Integer clockIndex;
output Real outTime;
external "C" outTime = System_realtimeTock(clockIndex) annotation(Library = "omcruntime");
end realtimeTock;
public function realtimeClear
"Clears the timer.
The clock index is 0-31. The function fails if the number is out of range."
input Integer clockIndex;
external "C" System_realtimeClear(clockIndex) annotation(Library = "omcruntime");
end realtimeClear;
public function realtimeNtick
"Returns the number of ticks since last clear.
The clock index is 0-31. The function fails if the number is out of range."
input Integer clockIndex;
output Integer n;
external "C" n = System_realtimeNtick(clockIndex) annotation(Library = "omcruntime");
end realtimeNtick;
function resetTimer
"@autor: adrpo
this function will reset the timer to 0."
external "C" System_resetTimer() annotation(Library = "omcruntime");
end resetTimer;
function startTimer
"@autor: adrpo
this function will start counting the time
that should be aggregated."
external "C" System_startTimer() annotation(Library = "omcruntime");
end startTimer;
function stopTimer
"@autor: adrpo
this function will stop counting the time
that should be aggregated."
external "C" System_stopTimer() annotation(Library = "omcruntime");
end stopTimer;
function getTimerIntervalTime
"@autor: adrpo
this function will return the time that
passed between the last [startTimer,stopTimer] interval.
Notice that if start/stop are called recursively this
function will return the time passed between the
corresponding intervals.
Example:
(start1,
(start2,
(start3, stop3) call getTimerIntervalTime -> (stop3-start3)
stop2) call getTimerIntervalTime -> (stop2-start2)
stop1) call getTimerIntervalTime -> (stop1-start1)"
output Real timerIntervalTime;
external "C" timerIntervalTime=System_getTimerIntervalTime() annotation(Library = "omcruntime");
end getTimerIntervalTime;
function getTimerCummulatedTime
"@autor: adrpo
this function will return the cummulated time
by adding all the interval times [startTimer,stopTimer].
Note that if you have recursive calls to start/stop
this function will not return the *correct* time.
Example:
Recursive:
(start1, (start2, (start3, stop3) stop2) stop1)
getTimerCummulatedTime =
stop3-start3 + stop2-start2 + stop1-start1.
Serial:
(start1, stop1) (start2, stop2) (start3, stop3)
getTimerCummulatedTime =
stop3-start3 + stop2-start2 + stop1-start1."
output Real timerCummulatedTime;
external "C" timerCummulatedTime=System_getTimerCummulatedTime() annotation(Library = "omcruntime");
end getTimerCummulatedTime;
function getTimerElapsedTime
"@autor: adrpo
this function will return the time
passed since the first call to startTimeer
Example:
(start1, (start2, (start3, stop3), stop2) ...
getTimerSinceFirstStartTime = timeNow-start1."
output Real timerElapsedTime;
external "C" timerElapsedTime=System_getTimerElapsedTime() annotation(Library = "omcruntime");
end getTimerElapsedTime;
function getTimerStackIndex
"@autor: adrpo
this function will return number of
times start/stop was called recursively.
You can use this function for pretty printing.
Example:
index 0
(start1, index 1
(start2, index 2
(start3, index 3
stop3), index 2
stop2) index 1
stop1) index 0"
output Integer stackIndex;
external "C" stackIndex=System_getTimerStackIndex() annotation(Library = "omcruntime");
end getTimerStackIndex;
public function getUUIDStr "creates the Globally Unique IDentifier and return it as String"
output String uuidStr;
external "C" uuidStr=System_getUUIDStr() annotation(Library = "omcruntime");
end getUUIDStr;
public function basename
"Returns the name of the file without any leading directory path.
See man 3 basename."
input String filename;
output String base;
// We need to strdup the input, so we can't use basename() directly
external "C" base = System_basename(filename) annotation(Library = "omcruntime");
end basename;
public function dirname
"Returns the name of the file without any leading directory path.
See man 3 dirname."
input String filename;
output String base;
// We need to strdup the input, so we can't use basename() directly
external "C" base = System_dirname(filename) annotation(Library = "omcruntime");
end dirname;
public function escapedString
"Because list() requires escape-sequences to be in the AST, we need to be
able to unescape them in some places of the code."
input String unescapedString;
input Boolean unescapeNewline;
output String escapedString;
external "C" escapedString=System_escapedString(unescapedString,unescapeNewline) annotation(Library = "omcruntime");
end escapedString;
public function unescapedString
"Because list() requires escape-sequences to be in the AST, we need to be
able to unescape them in some places of the code."
input String escapedString;
output String unescapedString;
external "C" unescapedString=System_unescapedString(escapedString) annotation(Library = "omcruntime");
end unescapedString;
public function unescapedStringLength
"Calculates the C string length of the input, if the input was used as a string
literal in C. For example unescapedStringLength('\"')=1, unescapedStringLength('ab')=2."
input String unescapedString;
output Integer length;
external "C" length=SystemImpl__unescapedStringLength(unescapedString) annotation(Library = "omcruntime");
end unescapedStringLength;
public function stringHashDjb2Mod
"Roughly the same as intMod(stringHashDjb2(str),mod); but works even when the size of an RML integer differs from OMC"
input String str;
input Integer mod;
output Integer hash;
external "builtin";
end stringHashDjb2Mod;
public function unquoteIdentifier
"Quoted identifiers, for example 'xyz' need to be translated into canonical form; for example _omcQuot_0x78797A"
input String str;
output String outStr;
external "C" outStr=System_unquoteIdentifier(str) annotation(Library = "omcruntime");
end unquoteIdentifier;
public function intMaxLit "Returns the maximum integer that can be represent using this version of the compiler"
output Integer outInt;
external "builtin" outInt=intMaxLit();
end intMaxLit;
public function realMaxLit "Returns the maximum integer that can be represent using this version of the compiler"
output Real outReal;
external "builtin" outReal=realMaxLit();
end realMaxLit;
public function uriToClassAndPath "Handles modelica:// and file:// URI's. The result is an absolute path on the local system.
The result depends on the current MODELICAPATH. Sets the error buffer on failure."
input String uri;
output String scheme "file:// or modelica://, in lower-case";
output String classname "empty if file:// is used";
output String pathname;
external "C" System_uriToClassAndPath(uri,scheme,classname,pathname) annotation(Library = "omcruntime");
end uriToClassAndPath;
public function modelicaPlatform "Returns the standardized platform name according to the Modelica specification:
win32 [Microsoft Windows 32 bit]
win64 [Microsoft Windows 64 bit]
linux32 [Linux Intel 32 bit]
linux64 [Linux Intel 64 bit]
Else, the openModelicaPlatform() is returned
"
output String platform;
external "C" platform=System_modelicaPlatform() annotation(Library = "omcruntime");
end modelicaPlatform;
public function openModelicaPlatform "
Returns uname -sm (with spaces replaced by dashes and only lower-case letters) on Unix platforms
mingw32 is returned for OMDEV
"
output String platform;
external "C" platform=System_openModelicaPlatform() annotation(Library = "omcruntime");
end openModelicaPlatform;
public function getGCStatus
output Integer used;
output Integer allocated;
external "C" System_getGCStatus(used,allocated) annotation(Library = "omcruntime");
end getGCStatus;
public function dgesv
"dgesv from LAPACK"
input list<list<Real>> A;
input list<Real> B;
output list<Real> X;
output Integer info;
external "C" info=SystemImpl__dgesv(A,B,X) annotation(Library = {"omcruntime","Lapack"});
end dgesv;
public function lpsolve55
"lpsolve55"
input list<list<Real>> A;
input list<Real> B;
input list<Integer> intIndices;
output list<Real> X;
output Integer info;
external "C" info=SystemImpl__lpsolve55(A,B,intIndices,X) annotation(Library = {"omcruntime"});
end lpsolve55;
public function reopenStandardStream
input Integer _stream "stdin,stdout,stderr";
input String filename;
output Boolean success;
external "C" success=SystemImpl__reopenStandardStream(_stream,filename) annotation(Library = {"omcruntime"});
end reopenStandardStream;
function iconv "The iconv() function converts one multibyte characters from one character
set to another.
See man (3) iconv for more information.
"
input String string;
input String from;
input String to;
output String result;
external "C" result=SystemImpl__iconv(string,from,to,true /* Print errors */) annotation(Library = {"omcruntime"});
end iconv;
function snprintff "sprintf format string that takes one double as argument"
input String format;
input Integer maxlen;
input Real val;
output String str;
external "C" str=System_snprintff(format,maxlen,val) annotation(Library = {"omcruntime"});
end snprintff;
public function realRand
"Returns a value in the intervals (0,1]"
output Real r;
external "C" r = SystemImpl__realRand() annotation(Library = {"omcruntime"});
end realRand;
public function intRand
"Returns a integer value in the interval (0,n].
The number of possible values is n, the maximum value n-1."
input Integer n;
output Integer i;
external "C" i = SystemImpl__intRand(n) annotation(Library = {"omcruntime"});
end intRand;
public function gettextInit
"Choose a locale for subsequent gettext calls. Prints warnings on failures."
input String locale := "" "Empty string choses automatically from the environment";
external "C" SystemImpl__gettextInit(locale) annotation(Library = {"omcruntime"});
end gettextInit;
public function gettext
"Translate a string from msgid to msgstr using the language of the chosen locale"
input String msgid;
output String msgstr;
external "C" msgstr = SystemImpl__gettext(msgid) annotation(Library = {"omcruntime"});
end gettext;
public function anyStringCode
"Takes any boxed input"
input Any any;
output String str;
replaceable type Any subtypeof Any;
external "C" str = anyStringCode(any);
end anyStringCode;
public function numBits
output Integer n;
external "C" n=architecture_numbits() annotation(Include="#define architecture_numbits() (8*sizeof(void*))");
end numBits;
public function realpath
input String path;
output String fullpath;
external "C" fullpath = System_realpath(path) annotation(Library = {"omcruntime"});
end realpath;
public function getSimulationHelpText
input Boolean detailed;
output String text;
external "C" text = System_getSimulationHelpText(detailed) annotation(Library = {"omcruntime"});
end getSimulationHelpText;
public function getTerminalWidth
output Integer width;
external "C" width = System_getTerminalWidth() annotation(Library = {"omcruntime"});
end getTerminalWidth;
end System;