- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Calling OpenModelica externally in C...
Calling OpenModelica externally in C program
Calling OpenModelica externally in C program
Hi
We need to call OpenModelica externally to obtain the results for an optimization problem. We are using a optimization package in C++ and we need to get the inputs for each iteration from OpenModelica simulation results.
So is there any way to call openModelica externally from a C code???
Thanks
John
Re: Calling OpenModelica externally in C program
Yes, in many different ways:
You can use OpenModelica as a CORBA server (see trunk/Compiler/runtime/omc_communication.idl for interface)
You can use OpenModelica as a server using sockets
You can use OpenModelica as a script (system("omc myScript.mos") from C-code)
You can generate executables using buildModel(myModelName) and then use system("myModelName") in C. (You can also change myModelName_init.txt to change input parameters between runs)
- sjoelund.se
- 1700 Posts
Re: Calling OpenModelica externally in C program
As far as I can understand your issue, the best strategy would be to integrate your C++ code in the runtime of OpenModelica
(c_runtime directory in the Subversion).
Then you can link the runtime with your code and with the generated code for the model and get the results directly via C calls.
This way you don't need to start executables and it would work much faster.
Cheers,
Adrian Pop/
- adrpo
- 885 Posts
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Calling OpenModelica externally in C...