See: Description
Class | Description |
---|---|
FMIMACodeGenerator |
Generate a Functional Mockup Interface Master Algorithm (FMIMA) description of a model.
|
FMIMACodeGeneratorAdapter |
Base class for a Functional Mockup Interface Master Algorithm code
generator adapter.
|
FMIMAHybridCodeGenerator |
Generate a Functional Mockup Interface Master Algorithm (FMIMA) description of a model.
|
Generate code for the Functional Mockup Unit Master Algorithm (FMIMA).
Two master algorithms are available:
This code generator use the algorithm defined in
David Broman, Christopher Brooks, Lev Greenberg, Edward A. Lee, Michael Masin, Stavros Tripakis and Michael Wetter, "Determinate Composition of FMUs for Co-Simulation," EECS Department
University of California, Berkeley
Technical Report No. UCB/EECS-2013-153
August 18, 2013. Which is a version of a EMSOFT '13 paper.
The only difference among FMI 2.0 CoSimulation MA and FMI Hybrid MA is the representation of time. In the FMI Hybrid MA, time is represented as an integer, where all the FMUs must agree on the same time precision.
The Hybrid FMUs are located in $PTII/ptolemy/actor/lib/fmi/fmus/Hybrid*
The ptolemy.cg
has a lot of classes, but the FMIMA work consists of only a few classes.
The easist way to work with the code is to look for the fmima
directories and then the .java
files
bash-3.2$ cd $PTII/ptolemy/cg bash-3.2$ find . -name fmima ./adapter/generic/program/procedural/fmima ./kernel/generic/program/procedural/fmima bash-3.2$ find ./adapter/generic/program/procedural/fmima -name "*.java" ./adapter/generic/program/procedural/fmima/adapters/ptolemy/actor/Director.java ./adapter/generic/program/procedural/fmima/adapters/ptolemy/actor/lib/fmi/FMUImport.java ./adapter/generic/program/procedural/fmima/adapters/ptolemy/actor/TypedCompositeActor.java ./adapter/generic/program/procedural/fmima/test/junit/JUnitTclTest.java bash-3.2$ find ./kernel/generic/program/procedural/fmima -name "*.java" ./kernel/generic/program/procedural/fmima/FMIMACodeGenerator.java ./kernel/generic/program/procedural/fmima/FMIMACodeGeneratorAdapter.java ./kernel/generic/program/procedural/fmima/test/junit/JUnitTclTest.java bash-3.2$
The main entry point is $PTII/ptolemy/cg/kernel/generic/program/procedural/fmima/FMIMACodeGenerator.java
. When the code generator is invoked, that class is instantiated.
Run $PTII/bin/ptcg -help
to see other command line arguments.
Below is the command to run a sample model:
$PTII/bin/ptcg -language fmima $PTII/ptolemy/cg/kernel/generic/program/procedural/fmima/test/auto/emsoft2013.xml
$PTII/bin/ptcg -language fmima -dialect hybrid $PTII/ptolemy/cg/kernel/generic/program/procedural/fmima/test/auto/Test4.xml
In Test4.c you can find the MA, while in results.cv there is the output of the simulation. The output show all the interface signals of all the FMUs and therefore it is a little bit hard to read at a first glance. However the name of the signals are self-explanatory and you can easily understand the signal traces.
In a nut shell, the code iterates through the model, finding actors and attributes. An adapter class is searched for that will handle each actor and attribute. If an adapter is not found, then an adapter for the parent class of the actor or attribute is searched for.
$PTII/ptolemy/cg/kernel/generic/program/procedural/fmima/FMIMACodeGenerator.java
$PTII/ptolemy/actor/lib/fmi/ma/includes/
and shared/
$PTII/ptolemy/cg/adapter/generic/program/procedural/fmima/adapters/ptolemy/actor/TypedCompositeActor.c