Search code examples
modelicaopenmodelica

Embedding externally generated C-code within OpenModelica models


We are working with a tool that generates C-code. For example, the C-code could be for the logic: "if a sensor is activated, turn on the LED bulb". The code can be saved into a function that can be called from outside. What is the best way to embed this kind of external C-code into the rest of the Modelica model? How can we compile this code along with the rest of the .mo files preferably using OM Shell script and omc?


Solution

  • You can directly put C code in external functions or link with a library.

    See:

    As examples see some of our tests from the testsuite:

    Simple example:

    Some advanced libraries: