The new standard for model exchange and co-simulation with Functional
Mockup Interface (FMI) allows export of pre-compiled models, i.e.,
C-code or binary code, from a tool for import in another tool, and vice
versa. The FMI standard is Modelica independent. Import and export works
both between different Modelica tools, or between certain non-Modelica
tools. OpenModelica supports FMI 1.0 & 2.0,

To export the FMU use the OpenModelica command
translateModelFMU(ModelName)
from command line interface, OMShell, OMNotebook or MDT.
The export FMU command is also integrated with OMEdit.
Select FMI > Export FMU the FMU package is generated in the
current directory of omc. You can use the cd() command to see the
current location. You can set which version of FMI to export through
OMEdit settings, see section FMI.

To export the bouncing ball example to an FMU, use the following commands:

After the command execution is complete you will see that a file
BouncingBall.fmu has been created. Its contents varies depending on the
current platform.
On the machine generating this documentation, the contents in
Listing 3 are generated (along with the C source code).

A log file for FMU creation is also generated named ModelName_FMU.log.
If there are some errors while creating FMU they will be shown in the
command line window and logged in this log file as well.

By default an FMU that can be used for both Model Exchange and
Co-Simulation is generated. We only support FMI 2.0 for Co-Simulation FMUs.

Currently the Co-Simulation FMU supports only the forward Euler solver
with root finding which does an Euler step of communicationStepSize
in fmi2DoStep. Events are checked for before and after the call to
fmi2GetDerivatives.

>>>list(OpenModelica.Scripting.importFMU,interfaceOnly=true)functionimportFMUinputStringfilename"the fmu file name";inputStringworkdir="<default>""The output directory for imported FMU files. <default> will put the files to current working directory.";inputIntegerloglevel=3"loglevel_nothing=0;loglevel_fatal=1;loglevel_error=2;loglevel_warning=3;loglevel_info=4;loglevel_verbose=5;loglevel_debug=6";inputBooleanfullPath=false"When true the full output path is returned otherwise only the file name.";inputBooleandebugLogging=false"When true the FMU's debug output is printed.";inputBooleangenerateInputConnectors=true"When true creates the input connector pins.";inputBooleangenerateOutputConnectors=true"When true creates the output connector pins.";outputStringgeneratedFileName"Returns the full path of the generated file.";endimportFMU;

The command could be used from command line interface, OMShell,
OMNotebook or MDT. The importFMU command is also integrated with OMEdit.
Select FMI > Import FMU the FMU package is extracted in the directory
specified by workdir, since the workdir parameter is optional so if its
not specified then the current directory of omc is used. You can use the
cd() command to see the current location.

The implementation supports FMI for Model Exchange 1.0 & 2.0 and FMI for
Co-Simulation 1.0 stand-alone. The support for FMI Co-Simulation is
still under development.

The FMI Import is currently a prototype. The prototype has been tested
in OpenModelica with several examples. It has also been tested with
example FMUs from FMUSDK and Dymola. A more fullfleged version for FMI
Import will be released in the near future.

When importing the model into OMEdit, roughly the following commands will be executed: