FMI4cpp

FMI4cpp is a brand new FMI 2.0 implementation for C++.  It has been written from the ground up in modern C++. The API is very similar to FMI4j.

All dependencies are available through vcpkg.

#include <fmicpp/fmicpp.hpp>

using namespace fmicpp::fmi2::import;

int main() {

    Fmu fmu("path/to/fmu.fmu");
    auto slave = fmu.asCoSimulationFmu().newInstance();
    
    slave->init();
    
    double stop = 10.0;
    double stepSize = 1.0/100;
    
    double t;
    while ( (t = slave->getSimulationTime()) <= stop) {
    
        fmi2Status status = slave->doStep(stepSize);
        if (status != fmi2OK) {
            break;
        }
    
    }
    
    slave->terminate();
    
}

https://github.com/SFI-Mechatronics/FMI4cpp

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.