ghorwin / FMICodeGenerator

A Code Generator that creates native C/C++ code to build Functional Mock-Up Units (FMU) with support for FMI version 2.0 (rollback)
BSD 3-Clause "New" or "Revised" License
51 stars 25 forks source link

State handling in FMUs #34

Open ghorwin opened 3 years ago

ghorwin commented 3 years ago

FMICodeGenerator should handle and maintain states properly.

With "states", we need to distinguish between a) just regular states and b) integrated continuous variables.

a) This is handled already automatically. Whenever you store a value in any of the data maps

m_boolVar
m_realVar
m_integerVar
m_stringVar

these are stored and maintained in the FMU instance class object from one doStep() call to the next. Also, these states are stored in calls to serializeFMUstate() and restored in deserializeFMUstate(). Even if the master copies the FMU state and stores it into a file and later re-creates the FMU instance and restores data back from external memory - these states are restored as well.

b) support for continues variables is pending - for now a workaround would be to "reuse" the m_realVar map, but for larger fields this would be bad for performance. The plan is to add some integration library (CVODE?) into the code generator and then provide some integration functionality inside the FMU as well.