The Functional Mock-up Interface (FMI) standard addresses the exchange and joint execution of models for co-simulation. It mainly is applied for system level simulation of complex systems. CREATE Statecharts can be exported as Functional Mock-up Units (FMUs) and as such can participate in FMI based simulations. As FMUs provide binary executables and only bundle source code or models as an option FMUs can be provided to other parties without exposing inellectual property. Concretely itemis CREATE supports FMI 2.0 for Co-Simulation FMU export. By the support of the FMI standard CREATE Statecharts are interoperable with a wide range of simulation tools .
The FMU export is implemented by a itemis CREATE code generator. The generator supports building FMUs for Windows, Linux and MacOS 64Bit platforms. The generator builds a complete FMU and relies on Eclipse C development infrastructure. So as a precondition you have to make sure that CDT features are installed. For Windows platform the Cygwin toolchain must be installed.
If the code generator is not yet installed then simply install the “ itemis CREATE FMU Code Generator”. Follow the steps in How to Install More Code Generators .
If everything is in place a FMU can be created in a few simple steps:
GenenratorModel for yakindu::c::fmu {
statechart machine {
feature Outlet {
targetProject = "example"
targetFolder = "src"
}
}
}
The generated FMU includes a XML based descriptor which defines the elements which are visible in the FMUs interface. This descriptor is derived from the statechart’s interface by applying standard mapping rules. Currently, the FMU generator has the following functional constraints:
It is planned to support statechart events and state mapping in future versions of the generator.
All variables you declare in your statechart will be used as FMU input variables by default. To define FMU output variables you need to specify the readonly modifier for the variable. Here is an example for declaring FMU input/output variables:
Default Domain:
interface IO:
var x: integer = 0 //input variable
var y: boolean = true //input variable
var readonly z: real = 5.2 //output variable
C/C++ Domain:
interface IO:
var x: int8_t = 0 //input variable
var y: bool = true //input variable
var readonly z: double = 5.2 //output variable
For a quick start simply install the following example: FMU Generator Example