Linux GNU 11.4.0 Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 11.8% 18 / 0 / 152
Functions: 11.9% 18 / 1 / 152
Branches: 0.0% 0 / 0 / 44

OMCompiler/Compiler/Util/OMSimulatorExt.mo
Line Branch Exec Source
1 /*
2 * This file is part of OpenModelica.
3 *
4 * Copyright (c) 1998-2026, Open Source Modelica Consortium (OSMC),
5 * c/o Linköpings universitet, Department of Computer and Information Science,
6 * SE-58183 Linköping, Sweden.
7 *
8 * All rights reserved.
9 *
10 * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF AGPL VERSION 3 LICENSE OR
11 * THIS OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.8.
12 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES
13 * RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GNU AGPL
14 * VERSION 3, ACCORDING TO RECIPIENTS CHOICE.
15 *
16 * The OpenModelica software and the OSMC (Open Source Modelica Consortium)
17 * Public License (OSMC-PL) are obtained from OSMC, either from the above
18 * address, from the URLs:
19 * http://www.openmodelica.org or
20 * https://github.com/OpenModelica/ or
21 * http://www.ida.liu.se/projects/OpenModelica,
22 * and in the OpenModelica distribution.
23 *
24 * GNU AGPL version 3 is obtained from:
25 * https://www.gnu.org/licenses/licenses.html#GPL
26 *
27 * This program is distributed WITHOUT ANY WARRANTY; without
28 * even the implied warranty of MERCHANTABILITY or FITNESS
29 * FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
30 * IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL.
31 *
32 * See the full OSMC Public License conditions for more details.
33 *
34 */
35
36 encapsulated package OMSimulatorExt
37 " file: OMSimulatorExt.mo
38 package: OMSimulatorExt
39 description: This file contains OMSimulatorExt wrapper functions which are implemented in C and Linked through DLL.
40 "
41 public function statusToString
42 input Integer status;
43 output String outstring;
44 algorithm
45 ✗ if(status==0) then
46 outstring:="ok";
47 elseif(status==1) then
48 outstring:="warning";
49 elseif(status==2) then
50 outstring:="discard";
51 elseif(status==3) then
52 outstring:="error";
53 elseif(status==4) then
54 outstring:="fatal";
55 elseif(status==5) then
56 outstring:="pending";
57 else
58 outstring:="unknown_status";
59 end if;
60 end statusToString;
61
62 ✗ public function loadOMSimulator
63 output Integer status;
64 external "C" status = OMSimulator_loadDLL() annotation(Library = "omcruntime");
65 end loadOMSimulator;
66
67 3 public function unloadOMSimulator
68 output Integer status;
69 external "C" status = OMSimulator_unloadDLL() annotation(Library = "omcruntime");
70 end unloadOMSimulator;
71
72 3 public function oms_getVersion "Returns the version number of this release"
73 output String outString;
74 external "C" outString = OMSimulator_oms_getVersion() annotation(Library = "omcruntime");
75 end oms_getVersion;
76
77 ✗ function oms_addBus
78 input String cref;
79 output Integer status;
80 external "C" status = OMSimulator_oms_addBus(cref) annotation(Library = "omcruntime");
81 end oms_addBus;
82
83 ✗ function oms_addConnection
84 input String crefA;
85 input String crefB;
86 output Integer status;
87 external "C" status = OMSimulator_oms_addConnection(crefA,crefB) annotation(Library = "omcruntime");
88 end oms_addConnection;
89
90 5 function oms_addConnector
91 input String cref;
92 input Integer causality;
93 input Integer type_;
94 output Integer status;
95 external "C" status = OMSimulator_oms_addConnector(cref,causality,type_) annotation(Library = "omcruntime");
96 end oms_addConnector;
97
98 ✗ function oms_addConnectorToBus
99 input String busCref;
100 input String connectorCref;
101 output Integer status;
102 external "C" status = OMSimulator_oms_addConnectorToBus(busCref,connectorCref) annotation(Library = "omcruntime");
103 end oms_addConnectorToBus;
104
105 ✗ function oms_addConnectorToTLMBus
106 input String busCref;
107 input String connectorCref;
108 input String type_;
109 output Integer status;
110 external "C" status = OMSimulator_oms_addConnectorToTLMBus(busCref,connectorCref,type_) annotation(Library = "omcruntime");
111 end oms_addConnectorToTLMBus;
112
113 ✗ function oms_addDynamicValueIndicator
114 input String signal;
115 input String lower;
116 input String upper;
117 input Real stepSize;
118 output Integer status;
119 external "C" status = OMSimulator_oms_addDynamicValueIndicator(signal,lower,upper,stepSize) annotation(Library = "omcruntime");
120 end oms_addDynamicValueIndicator;
121
122 ✗ function oms_addEventIndicator
123 input String signal;
124 output Integer status;
125 external "C" status = OMSimulator_oms_addEventIndicator(signal) annotation(Library = "omcruntime");
126 end oms_addEventIndicator;
127
128 ✗ function oms_addExternalModel
129 input String cref;
130 input String path;
131 input String startscript;
132 output Integer status;
133 external "C" status = OMSimulator_oms_addExternalModel(cref,path,startscript) annotation(Library = "omcruntime");
134 end oms_addExternalModel;
135
136 ✗ function oms_addSignalsToResults
137 input String cref;
138 input String regex;
139 output Integer status;
140 external "C" status = OMSimulator_oms_addSignalsToResults(cref,regex) annotation(Library = "omcruntime");
141 end oms_addSignalsToResults;
142
143 ✗ function oms_addStaticValueIndicator
144 input String signal;
145 input Real lower;
146 input Real upper;
147 input Real stepSize;
148 output Integer status;
149 external "C" status = OMSimulator_oms_addStaticValueIndicator(signal,lower,upper,stepSize) annotation(Library = "omcruntime");
150 end oms_addStaticValueIndicator;
151
152 ✗ function oms_addSubModel
153 input String cref;
154 input String fmuPath;
155 output Integer status;
156 external "C" status = OMSimulator_oms_addSubModel(cref,fmuPath) annotation(Library = "omcruntime");
157 end oms_addSubModel;
158
159 5 function oms_addSystem
160 input String cref;
161 input Integer type_;
162 output Integer status;
163 external "C" status = OMSimulator_oms_addSystem(cref,type_) annotation(Library = "omcruntime");
164 end oms_addSystem;
165
166 3 function oms_addTimeIndicator
167 input String signal;
168 output Integer status;
169 external "C" status = OMSimulator_oms_addTimeIndicator(signal) annotation(Library = "omcruntime");
170 end oms_addTimeIndicator;
171
172 ✗ function oms_addTLMBus
173 input String cref;
174 input Integer domain;
175 input Integer dimensions;
176 input Integer interpolation;
177 output Integer status;
178 external "C" status = OMSimulator_oms_addTLMBus(cref,domain,dimensions,interpolation) annotation(Library = "omcruntime");
179 end oms_addTLMBus;
180
181 ✗ function oms_addTLMConnection
182 input String crefA;
183 input String crefB;
184 input Real delay;
185 input Real alpha;
186 input Real linearimpedance;
187 input Real angularimpedance;
188 output Integer status;
189 external "C" status = OMSimulator_oms_addTLMConnection(crefA,crefB,delay,alpha,linearimpedance,angularimpedance) annotation(Library = "omcruntime");
190 end oms_addTLMConnection;
191
192 ✗ function oms_compareSimulationResults
193 input String filenameA;
194 input String filenameB;
195 input String var;
196 input Real relTol;
197 input Real absTol;
198 output Integer status;
199 external "C" status = OMSimulator_oms_compareSimulationResults(filenameA,filenameB,var,relTol,absTol) annotation(Library = "omcruntime");
200 end oms_compareSimulationResults;
201
202 ✗ function oms_copySystem
203 input String source;
204 input String target;
205 output Integer status;
206 external "C" status = OMSimulator_oms_copySystem(source,target) annotation(Library = "omcruntime");
207 end oms_copySystem;
208
209 ✗ function oms_delete
210 input String cref;
211 output Integer status;
212 external "C" status = OMSimulator_oms_delete(cref) annotation(Library = "omcruntime");
213 end oms_delete;
214
215 3 function oms_deleteConnection
216 input String crefA;
217 input String crefB;
218 output Integer status;
219 external "C" status = OMSimulator_oms_deleteConnection(crefA,crefB) annotation(Library = "omcruntime");
220 end oms_deleteConnection;
221
222 ✗ function oms_deleteConnectorFromBus
223 input String busCref;
224 input String connectorCref;
225 output Integer status;
226 external "C" status = OMSimulator_oms_deleteConnectorFromBus(busCref,connectorCref) annotation(Library = "omcruntime");
227 end oms_deleteConnectorFromBus;
228
229 ✗ function oms_deleteConnectorFromTLMBus
230 input String busCref;
231 input String connectorCref;
232 output Integer status;
233 external "C" status = OMSimulator_oms_deleteConnectorFromTLMBus(busCref,connectorCref) annotation(Library = "omcruntime");
234 end oms_deleteConnectorFromTLMBus;
235
236 ✗ function oms_export
237 input String cref;
238 input String filename;
239 output Integer status;
240 external "C" status = OMSimulator_oms_export(cref,filename) annotation(Library = "omcruntime");
241 end oms_export;
242
243 ✗ function oms_exportDependencyGraphs
244 input String cref;
245 input String initialization;
246 input String event;
247 input String simulation;
248 output Integer status;
249 external "C" status = OMSimulator_oms_exportDependencyGraphs(cref,initialization,event,simulation) annotation(Library = "omcruntime");
250 end oms_exportDependencyGraphs;
251
252 ✗ function oms_exportSnapshot
253 input String cref;
254 output String contents;
255 output Integer status;
256 external "C" status = OMSimulator_oms_exportSnapshot(cref,contents) annotation(Library = "omcruntime");
257 end oms_exportSnapshot;
258
259 ✗ function oms_extractFMIKind
260 input String filename;
261 output Integer kind;
262 output Integer status;
263 external "C" status = OMSimulator_oms_extractFMIKind(filename,kind) annotation(Library = "omcruntime");
264 end oms_extractFMIKind;
265
266 ✗ function oms_getBoolean
267 input String cref;
268 output Boolean value;
269 output Integer status;
270 external "C" status = OMSimulator_oms_getBoolean(cref,value) annotation(Library = "omcruntime");
271 end oms_getBoolean;
272
273 ✗ function oms_getFixedStepSize
274 input String cref;
275 output Real stepSize;
276 output Integer status;
277 external "C" status = OMSimulator_oms_getFixedStepSize(cref,stepSize) annotation(Library = "omcruntime");
278 end oms_getFixedStepSize;
279
280 ✗ function oms_getInteger
281 input String cref;
282 output Integer value;
283 output Integer status;
284 external "C" status = OMSimulator_oms_getInteger(cref,value) annotation(Library = "omcruntime");
285 end oms_getInteger;
286
287 ✗ function oms_getModelState
288 input String cref;
289 output Integer modelState;
290 output Integer status;
291 external "C" status = OMSimulator_oms_getModelState(cref,modelState) annotation(Library = "omcruntime");
292 end oms_getModelState;
293
294 ✗ function oms_getReal
295 input String cref;
296 output Real value;
297 output Integer status;
298 external "C" status = OMSimulator_oms_getReal(cref,value) annotation(Library = "omcruntime");
299 end oms_getReal;
300
301
0/2
✗ Branch 1 not taken.
✗ Branch 2 not taken.
14 function oms_getSolver
302 input String cref;
303 output Integer solver;
304 output Integer status;
305 external "C" status = OMSimulator_oms_getSolver(cref,solver) annotation(Library = "omcruntime");
306 end oms_getSolver;
307
308 ✗ function oms_getStartTime
309 input String cref;
310 output Real startTime;
311 output Integer status;
312 external "C" status = OMSimulator_oms_getStartTime(cref,startTime) annotation(Library = "omcruntime");
313 end oms_getStartTime;
314
315 ✗ function oms_getStopTime
316 input String cref;
317 output Real stopTime;
318 output Integer status;
319 external "C" status = OMSimulator_oms_getStopTime(cref,stopTime) annotation(Library = "omcruntime");
320 end oms_getStopTime;
321
322 ✗ function oms_getSubModelPath
323 input String cref;
324 output String path;
325 output Integer status;
326 external "C" status = OMSimulator_oms_getSubModelPath(cref,path) annotation(Library = "omcruntime");
327 end oms_getSubModelPath;
328
329 ✗ function oms_getSystemType
330 input String cref;
331 output Integer type_;
332 output Integer status;
333 external "C" status = OMSimulator_oms_getSystemType(cref,type_) annotation(Library = "omcruntime");
334 end oms_getSystemType;
335
336 ✗ function oms_getTolerance
337 input String cref;
338 output Real absoluteTolerance;
339 output Real relativeTolerance;
340 output Integer status;
341 external "C" status = OMSimulator_oms_getTolerance(cref,absoluteTolerance,relativeTolerance) annotation(Library = "omcruntime");
342 end oms_getTolerance;
343
344 ✗ function oms_getVariableStepSize
345 input String cref;
346 output Real initialStepSize;
347 output Real minimumStepSize;
348 output Real maximumStepSize;
349 output Integer status;
350 external "C" status = OMSimulator_oms_getVariableStepSize(cref,initialStepSize,minimumStepSize,maximumStepSize) annotation(Library = "omcruntime");
351 end oms_getVariableStepSize;
352
353 ✗ function oms_faultInjection
354 input String signal;
355 input Integer faultType;
356 input Real faultValue;
357 output Integer status;
358 external "C" status = OMSimulator_oms_faultInjection(signal,faultType,faultValue) annotation(Library = "omcruntime");
359 end oms_faultInjection;
360
361 ✗ function oms_importFile
362 input String filename;
363 output String cref;
364 output Integer status;
365 external "C" status = OMSimulator_oms_importFile(filename,cref) annotation(Library = "omcruntime");
366 end oms_importFile;
367
368 ✗ function oms_importSnapshot
369 input String cref;
370 input String snapshot;
371 output Integer status;
372 external "C" status = OMSimulator_oms_importSnapshot(cref,snapshot) annotation(Library = "omcruntime");
373 end oms_importSnapshot;
374
375 ✗ function oms_initialize
376 input String cref;
377 output Integer status;
378 external "C" status = OMSimulator_oms_initialize(cref) annotation(Library = "omcruntime");
379 end oms_initialize;
380
381 3 function oms_instantiate
382 input String cref;
383 output Integer status;
384 external "C" status = OMSimulator_oms_instantiate(cref) annotation(Library = "omcruntime");
385 end oms_instantiate;
386
387
0/2
✗ Branch 1 not taken.
✗ Branch 2 not taken.
3 function oms_list
388 input String cref;
389 output String contents;
390 output Integer status;
391 external "C" status = OMSimulator_oms_list(cref,contents) annotation(Library = "omcruntime");
392 end oms_list;
393
394 ✗ function oms_listUnconnectedConnectors
395 input String cref;
396 output String contents;
397 output Integer status;
398 external "C" status = OMSimulator_oms_listUnconnectedConnectors(cref,contents) annotation(Library = "omcruntime");
399 end oms_listUnconnectedConnectors;
400
401 ✗ function oms_loadSnapshot
402 input String cref;
403 input String snapshot;
404 output String newCref;
405 output Integer status;
406 external "C" status = OMSimulator_oms_loadSnapshot(cref,snapshot,newCref) annotation(Library = "omcruntime");
407 end oms_loadSnapshot;
408
409 ✗ function oms_newModel
410 input String cref;
411 output Integer status;
412 external "C" status = OMSimulator_oms_newModel(cref) annotation(Library = "omcruntime");
413 end oms_newModel;
414
415 3 function oms_removeSignalsFromResults
416 input String cref;
417 input String regex;
418 output Integer status;
419 external "C" status = OMSimulator_oms_removeSignalsFromResults(cref,regex) annotation(Library = "omcruntime");
420 end oms_removeSignalsFromResults;
421
422 ✗ function oms_rename
423 input String cref;
424 input String newCref;
425 output Integer status;
426 external "C" status = OMSimulator_oms_rename(cref,newCref) annotation(Library = "omcruntime");
427 end oms_rename;
428
429 ✗ function oms_reset
430 input String cref;
431 output Integer status;
432 external "C" status = OMSimulator_oms_reset(cref) annotation(Library = "omcruntime");
433 end oms_reset;
434
435 ✗ function oms_RunFile
436 input String filename;
437 output Integer status;
438 external "C" status = OMSimulator_oms_RunFile(filename) annotation(Library = "omcruntime");
439 end oms_RunFile;
440
441 ✗ function oms_setBoolean
442 input String cref;
443 input Boolean value;
444 output Integer status;
445 external "C" status = OMSimulator_oms_setBoolean(cref,value) annotation(Library = "omcruntime");
446 end oms_setBoolean;
447
448 ✗ function oms_setCommandLineOption
449 input String cmd;
450 output Integer status;
451 external "C" status = OMSimulator_oms_setCommandLineOption(cmd) annotation(Library = "omcruntime");
452 end oms_setCommandLineOption;
453
454 3 function oms_setFixedStepSize
455 input String cref;
456 input Real stepSize;
457 output Integer status;
458 external "C" status = OMSimulator_oms_setFixedStepSize(cref,stepSize) annotation(Library = "omcruntime");
459 end oms_setFixedStepSize;
460
461 ✗ function oms_setInteger
462 input String cref;
463 input Integer value;
464 output Integer status;
465 external "C" status = OMSimulator_oms_setInteger(cref,value) annotation(Library = "omcruntime");
466 end oms_setInteger;
467
468 ✗ function oms_setLogFile
469 input String filename;
470 output Integer status;
471 external "C" status = OMSimulator_oms_setLogFile(filename) annotation(Library = "omcruntime");
472 end oms_setLogFile;
473
474 2 function oms_setLoggingInterval
475 input String cref;
476 input Real loggingInterval;
477 output Integer status;
478 external "C" status = OMSimulator_oms_setLoggingInterval(cref,loggingInterval) annotation(Library = "omcruntime");
479 end oms_setLoggingInterval;
480
481 ✗ function oms_setLoggingLevel
482 input Integer logLevel;
483 output Integer status;
484 external "C" status = OMSimulator_oms_setLoggingLevel(logLevel) annotation(Library = "omcruntime");
485 end oms_setLoggingLevel;
486
487 ✗ function oms_setReal
488 input String cref;
489 input Real value;
490 output Integer status;
491 external "C" status = OMSimulator_oms_setReal(cref,value) annotation(Library = "omcruntime");
492 end oms_setReal;
493
494 3 function oms_setRealInputDerivative
495 input String cref;
496 input Real value;
497 output Integer status;
498 external "C" status = OMSimulator_oms_setRealInputDerivative(cref,value) annotation(Library = "omcruntime");
499 end oms_setRealInputDerivative;
500
501 ✗ function oms_setResultFile
502 input String cref;
503 input String filename;
504 input Integer bufferSize;
505 output Integer status;
506 external "C" status = OMSimulator_oms_setResultFile(cref,filename,bufferSize) annotation(Library = "omcruntime");
507 end oms_setResultFile;
508
509 1 function oms_setSignalFilter
510 input String cref;
511 input String regex;
512 output Integer status;
513 external "C" status = OMSimulator_oms_setSignalFilter(cref,regex) annotation(Library = "omcruntime");
514 end oms_setSignalFilter;
515
516 ✗ function oms_setSolver
517 input String cref;
518 input Integer solver;
519 output Integer status;
520 external "C" status = OMSimulator_oms_setSolver(cref,solver) annotation(Library = "omcruntime");
521 end oms_setSolver;
522
523 ✗ function oms_setStartTime
524 input String cref;
525 input Real startTime;
526 output Integer status;
527 external "C" status = OMSimulator_oms_setStartTime(cref,startTime) annotation(Library = "omcruntime");
528 end oms_setStartTime;
529
530 ✗ function oms_setStopTime
531 input String cref;
532 input Real stopTime;
533 output Integer status;
534 external "C" status = OMSimulator_oms_setStopTime(cref,stopTime) annotation(Library = "omcruntime");
535 end oms_setStopTime;
536
537 1 function oms_setTempDirectory
538 input String newTempDir;
539 output Integer status;
540 external "C" status = OMSimulator_oms_setTempDirectory(newTempDir) annotation(Library = "omcruntime");
541 end oms_setTempDirectory;
542
543 3 function oms_setTLMPositionAndOrientation
544 input String cref;
545 input Real x1;
546 input Real x2;
547 input Real x3;
548 input Real A11;
549 input Real A12;
550 input Real A13;
551 input Real A21;
552 input Real A22;
553 input Real A23;
554 input Real A31;
555 input Real A32;
556 input Real A33;
557 output Integer status;
558 external "C" status = OMSimulator_oms_setTLMPositionAndOrientation(cref,x1,x2,x3,A11,A12,A13,A21,A22,A23,A31,A32,A33) annotation(Library = "omcruntime");
559 end oms_setTLMPositionAndOrientation;
560
561 ✗ function oms_setTLMSocketData
562 input String cref;
563 input String address;
564 input Integer managerPort;
565 input Integer monitorPort;
566 output Integer status;
567 external "C" status = OMSimulator_oms_setTLMSocketData(cref,address,managerPort,monitorPort) annotation(Library = "omcruntime");
568 end oms_setTLMSocketData;
569
570 ✗ function oms_setTolerance
571 input String cref;
572 input Real absoluteTolerance;
573 input Real relativeTolerance;
574 output Integer status;
575 external "C" status = OMSimulator_oms_setTolerance(cref,absoluteTolerance,relativeTolerance) annotation(Library = "omcruntime");
576 end oms_setTolerance;
577
578 ✗ function oms_setVariableStepSize
579 input String cref;
580 input Real initialStepSize;
581 input Real minimumStepSize;
582 input Real maximumStepSize;
583 output Integer status;
584 external "C" status = OMSimulator_oms_setVariableStepSize(cref,initialStepSize,minimumStepSize,maximumStepSize) annotation(Library = "omcruntime");
585 end oms_setVariableStepSize;
586
587 1 function oms_setWorkingDirectory
588 input String newWorkingDir;
589 output Integer status;
590 external "C" status = OMSimulator_oms_setWorkingDirectory(newWorkingDir) annotation(Library = "omcruntime");
591 end oms_setWorkingDirectory;
592
593 ✗ function oms_simulate
594 input String cref;
595 output Integer status;
596 external "C" status = OMSimulator_oms_simulate(cref) annotation(Library = "omcruntime");
597 end oms_simulate;
598
599 3 function oms_stepUntil
600 input String cref;
601 input Real stopTime;
602 output Integer status;
603 external "C" status = OMSimulator_oms_stepUntil(cref,stopTime) annotation(Library = "omcruntime");
604 end oms_stepUntil;
605
606 ✗ function oms_terminate
607 input String cref;
608 output Integer status;
609 external "C" status = OMSimulator_oms_terminate(cref) annotation(Library = "omcruntime");
610 end oms_terminate;
611
612 annotation(__OpenModelica_Interface="util");
613 end OMSimulatorExt;
614