Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

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)

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/

There are 0 guests and 0 other users also viewing this topic
You are here: