Giter VIP home page Giter VIP logo

fmiwrapper's Introduction

FmiWrapper

Simplified interface to call fmi2 models (see http://fmi-standard.org/) from different languages.

Usage

The core of this function is located in the c_wrapper directory. fmi_wrapper.h provides the simplified interface which can be exported to a shared library. The easiest way to build the library is to use cmake.

Additionally the VisualStudio solution provides a wrapper for .NET written in C#. By using the simplified interface PInvoke can be used to call into the FmiWrapper.dll which will load the FMU for you. The FmuInstance takes care of the unmanaged resources and ensures that they are freed on dispose or destruction. The FmiWrapper_Net project references the native project and automatically copies the FmiWrapper.dll generated from the build. In order to compile the project do not use the Any-CPU configuration but specify x86 or x64.

The FmiWrapperConsole is a .net-core console application for testing the capabilities of the wrapper and the fmu. Note that currently the path to the binary is hard-coded to use the win64 DLL. Make sure to compile the application for x64!

Build notes

  • Written in C99
  • Comments for doxygen using qt format
  • Built of the C-Wrapper has been tested with CMake + Visual Studio 2017 & 2019 / mingw-w64 / gcc 5.4.0

fmiwrapper's People

Contributors

tuebel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

fmiwrapper's Issues

System.AccessViolationException

Hi Tuebel,
I'm not able to run the FmiWrapper_net on my system because of the System.AccessViolationException on the Instantiate method. I thank you for help.

fmu.GetInteger(...) not working

Hi Tim,
I'm facing some issues with the FmiWrapper. The outputs of the function GetInteger seems to not working. I don't know if you could help me on that. I checked in Modellica and everything is ok.
But in C# the integer output never changes..

Thanks and Regards

Jules

FMU is not instancing

Dear,

Below, you can find a piece of code that I use for instancing my models (build by AMESIM).
Why I'm able to load FMU: simple_multiplier3 and is FMU: Linked_Parameter_FMU not loading?

            // Create the instance
            string modelIdentifier = fmd.CoSimulation.modelIdentifier;
            string guid = fmd.guid.ToString();
            Console.WriteLine($"{modelIdentifier} - {guid}");

Linked_Parameter_FMU.zip
simple_multiplier3.zip

            using (var fmu = new FmuInstance(modelIdentifier + ".dll"))
            {
                // Setup
                fmu.Log += Fmu_Log;
                fmu.StepFinished += Fmu_StepFinished;
                fmu.Instantiate(modelIdentifier + "_Instance", Fmi2Type.fmi2CoSimulation, guid, "", false, true);
                Console.WriteLine("Types platform: " + fmu.GetTypesPlatform());
                Console.WriteLine("Version: " + fmu.GetVersion());
                fmu.SetupExperiment(false, 0, 0, true, 1000);
                fmu.EnterInitializationMode();
                fmu.ExitInitializationMode();


               // Simulate
                SimulateHEV(fmu);

                // Terminate the fmu
                fmu.Terminate();
            }

fatal error GC

Hallo Tim,
ich kann mit dem FMU nur 2 maximal 3 male rechnen. ich bekomme die folgende Fehlermeldung (attached file
fatalError
)

Danke für deine Rückmeldung
freundliche Grüßen

Jules

How to use ModelExchange's model

Hi Tuebel,
Now, I can use Co-Simulation's Model in my C# App by your wrapper.
And I want to use ModelExchange's Model, Does this wrapper support ModelExchange's model ?

Thanks.

fmu.DoStep doesn't work with negative numbers

i'm trying to solve a timeserie of numbers from -1000 till 1000, but get only errors:
Instance name: simple_multiplier_Instance, status: fmi2OK, category: debug, message: simple_multiplier_fmi2SetReal, #r134217728# = 1008.000000 (input variable 0)
Instance name: simple_multiplier_Instance, status: fmi2OK, category: debug, message: simple_multiplier_fmi2SetReal called at t= 0.000000000000000000e+00 with 1 value(s)
input Real values: 1008
Instance name: simple_multiplier_Instance, status: fmi2Error, category: stepping, message: simple_multiplier_fmi2DoStep: Current communication point (1008.000000) does not match last evaluation time (0.000000) within tolerance 0.000000. Time rollback is not allowed
Instance name: simple_multiplier_Instance, status: fmi2OK, category: debug, message: simple_multiplier_fmi2GetReal, #r268435456# = 0.000000 (output variable 0)
Instance name: simple_multiplier_Instance, status: fmi2OK, category: debug, message: simple_multiplier_fmi2GetReal called at t= 0.000000000000000000e+00 with 1 value(s)

We use fmu.SetReal(setRealVr, setRealValues); and fmu.GetReal(getRealVr, getRealValues);

Thanks in advance,

Failed to open file (null)/BouncingBall_info.json for reading => FmiFunctions.Instantiate

hello

we are using modelica and exorting the testdata BouncingBall (any would do) and getting error during initation:

assert | debug | Failed to open file (null)/BouncingBall_info.json for reading: No such file or directory
getBestJumpBuffer got mmc_jumper=0000000000000000, globalJumpBuffer=0000000000000000

the .fmu is loaded corrctly and is valid via fmu-checker:
FMI Version
2.0
FMI Type
Model Exchange, Co-Simulation
Model Name
BouncingBall
Platforms
c-code, win64
Continuous States
2
Event Indicators
3
Model Variables
10
Generation Date
2021-12-22T10:27:37Z
Generation Tool
OpenModelica Compiler OpenModelica v1.18.0 (64-bit)

The file its crying about can be located in the fmu/resource

//regards

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.