Skip to content
Andreas Nicolai edited this page Mar 14, 2019 · 22 revisions

FMICodeGenerator wiki

User Guide

The readme.md file (see main project page) holds an introduction to the tool and the usage.

API

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()

FMU Compliance Checker Testing Procedure

The FMUs created by the FMIGenerator are only backbones and lack specific functionality. To test the correct export, we will follow this procedure:

  1. define an FMU with given parameters and variables according to the defined test scenario (see below)
  2. generate the FMU directory with the FMIGenerator
  3. add C++-Code into FMU source stub
  4. build and deploy .fmu file
  5. run file through compliance checker

Test Scenarios

Here is a list of test scenarios to test and demonstrate the functionality of the FMIGenerator.