-
Notifications
You must be signed in to change notification settings - Fork 26
Home
Andreas Nicolai edited this page Mar 14, 2019
·
22 revisions
The readme.md file (see main project page) holds an introduction to the tool and the usage.
To use the FMUCodeGenerator functionality from other software, you can use the Python-API provided by the Python library. Basically, you create an instance of class FMIGenerator()
, specify its attributes and call the member function generate()
. As simple as that :-)
# import FMIGenerator class and data types
from FMIGenerator import *
# create instance of FMIGenerator class
fmiGen = FMIGenerator()
# specify attributes
fmiGen.modelName = "MyFirstFMU"
fmiGen.description = "My first auto-generated FMU. Awesome, right?"
fmiGen.targetDir = "../fmus"
# 'targetDir' can be relative path to current working directory
# or an absolute file path
# add variables to export
v = VarDef("InputVar1", "continuous", "input", "exact", "Real")
# valueRef will be given automatically unless specified explicitely
v.startValue = 15
fmiGenerator.variables.append(v)
# now generate the FMU
fmiGen.generate()
The FMUs created by the FMIGenerator are only backbones and lack specific functionality. To test the correct export, we will follow this procedure:
- define an FMU with given parameters and variables according to the defined test scenario (see below)
- generate the FMU directory with the FMIGenerator
- add C++-Code into FMU source stub
- build and deploy
.fmu
file - run file through compliance checker
Here is a list of test scenarios to test and demonstrate the functionality of the FMIGenerator.
- Stateless P-controller: Tests the very basic functionality (if FMU is well formed and modelDescription is syntactically correct). No serialization is needed, so there cannot be anything wrong with that.
- Stateless digital controller with switching delay: Tests serialization functionality for a model with an internal state (or local variable).
- Lotka-Volterra (Predator-Prey) Model: Tests generation of state variables, derivatives, modelDescription formulation and serialization code.