Opened 10 years ago

Last modified 10 years ago

#3238 closed defect

Export FMI2 with Cpp runtime — at Version 3

Reported by: Rüdiger Franke Owned by: Rüdiger Franke
Priority: high Milestone: 1.9.3
Component: Cpp Run-time Version: trunk
Keywords: Cc: Marcus Walther, Volker Waurich, Niklas Worschech

Description (last modified by Rüdiger Franke)

The FMI export of +simCodeTarget=Cpp needs to be maintained to work again. Moreover it should be upgraded to support FMI2.0.

Find attached an initial version of FMU2 export. It is proposed to be added to the svn trunc besides the existing FMU folder under:

   SimulationRuntime/cpp/Include/FMU2

The code is derived from the existing C++ FMU export. So far it works for simple models, like a double integrator, including repeated evaluations for trajectory optimization and parameter estimation.

It is still a bit cumbersome to create such an FMU. It works with the following steps:

  1. translateModelFMU(<model>, version="2.0") to get the modelDescription.xml file for FMI2.0
  2. setCommandLineOptions("+simCodeTarget=Cpp") and translateModelFMU(<model>, version="2.0") to get the C++ code
  3. generate the regular simulation executable of the Cpp runtime to get the C++ files updated
  4. adapt OMCpp<model>FMU.cpp to include FMU2/FMU2Wrapper.cpp and FMU2/FMU2Interface.cpp and to create an FMU2Wrapper instead of FMU/FMUWrapper.cpp, FMU/FMULibInterface.cpp, FMUWrapper, respectively
  5. fix and extend the generated <model>_FMU.makefile (SUITESPARSE_INCLUDE, see #3232, remove misspelled -l: LDFLAGS, add the four source files OMCpp<model>CalcHelperMain{2,3,4,5}.cpp
  6. more sophisticated models seem to also need more link libraries ... I didn't identify which ones so far

Can someone confirm that this initial version can be added to the svn as a starting point?
Note that the only difference between FMI1 and FMI2 are three names in the generated OMCpp<model>FMU.cpp.

Moreover: help for fixing translateModelFMU so that the result of the above steps is achieved with on call is appreciated. This would also fix the root cause of #3234.

Change History (4)

by Rüdiger Franke, 10 years ago

Attachment: FMU2.tgz added

comment:1 by Niklas Worschech, 10 years ago

that is ok, you can add your modifications to the svn.

comment:2 by Rüdiger Franke, 10 years ago

Owner: changed from Adeel Asghar to Rüdiger Franke
Status: newassigned

comment:3 by Rüdiger Franke, 10 years ago

Description: modified (diff)
Status: assignedaccepted
Summary: Export FMI2 from Cpp runtimeExport FMI2 with Cpp runtime
Note: See TracTickets for help on using tickets.