FMI Library: part of JModelica.org
FMI Library: part of JModelica.org
Version:
1.0.1
Date:
30 August 2012

Summary

FMI library is intended as a foundation for applications interfacing FMUs (Functional Mockup Units) that follow FMI Standard. See <http://functional-mockup-interface.org/>

The test codes provided with the library can serve as starting point for the development of custom applications. See Section Automatic tests for details.

Configuring and building

CMake (see <http://www.cmake.org/>) is used to generate the native build scripts for the library. It is recommended to use "cmake-gui" on Windows or "ccmake <FMIL source dir>" to configure the build.

To build from a terminal command line on Linux or Mac with default settings use:

        mkdir build-fmil; cd build-fmil
        cmake <path to FMI 
        L source>
        make install test

To build in MSYS terminal with g++/gcc on Windows:

        mkdir build-fmil; cd build-fmil
        cmake -G "MSYS Makefiles" <path to FMIL source>
        make install test

The primary targets of the library build script are:

The following build configuration options are provided:

Automatic tests

The FMI library comes with a number of automatic tests. Building of the test is controlled by FMILIB_BUILD_TESTS configuration option. The test porgrams are also intended as examples of library usage.
The tests can be run in Visual Studio by building project RUN_TESTS. For Makefile based configurations (MSYS, Linux, Mac OSx) run 'make test'.
Output from the test programs and test logs can be found in the testfolder and Testing folders in the build directory.

The supplied tests are:

Using logs

In the text below we consider an FMU importing application (referenced as an 'application') that uses the FMIL. The library is designed to send log messages to a logger callback function jm_logger_f provided as a part of jm_callbacks structure in the call to fmi_import_allocate_context(). The logging/error reporting functions within FMIL support following modes:

  1. An importing application relies on default logging functions provided by FMIL and only chooses the log-level
  2. An application provides a callback for reporting error messages according to jm_callbacks.h (jm_logger_f)
    • Only errors from FMIL can be propagated to this callback in a thread-safe manner for FMI1. Imported FMUs may still use the default callback provided by the library. This is since logger function in FMI 1.0 standard is context independent. The non-thread safe implementation on the FMI1 callback can be found in fmi1_import_convenience.h fmi1_log_forwarding().
      In FMI 2 we will be able to utilize fmiComponentEnvironment to forward messages from the default fmi2 logger function as provided by the library to the use defined jm_logger_f function. The default implementation can take care of replacing variable names, etc.
  3. An importing application provides logging function according to the specific FMI standard version.
    • Errors from FMIL may be forwarded to this callback. There is a function that translates calls according to jm_callbacks.h jm_logger_f into calls according to fmi_functions.h fmi_callbacks_logger_ft (see fmi1_import_convenience.h fmi1_import_init_logger() that is used to setup 'forwarding').
      Setting of the callback can only be done at the stage where FMU standard is known.
  4. An importing application may choose not to use logging function but rely on return codes and jm_get_last_error()
    • jm_logger function should be set to NULL
    • Errors from a FMI 1.0 fmu1 cannot be handled this way in a thread-safe way (see point 2 above). It will work fine with FMI 2.0.

License

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MODELON AB BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Acknowledgements

The FMI Library utilizes contains code from third party tools and packages. The respective copyright information and licenses are listed with URL references to the full texts.