Opened 9 years ago

Last modified 5 years ago

#3721 new defect

Re: FMI 1.0 co-simulation API skeleton.

Reported by: michael.kobierski@… Owned by: adeas31
Priority: high Milestone: Future
Component: FMI 1.0 Version: v1.9.4-dev-nightly
Keywords: model-exchange Cc:

Description

https://trac.openmodelica.org/OpenModelica/changeset/e87391212dc31770541528ea6c64dcc6489fb04e/OMCompiler

There is a mistake with the structures which is apparent in FMUs created using the C runtime and FMI1 for model exchange.

The structure fmiCallbackFunctions and fmiStatus are currently as below.

    typedef struct {
      fmiCallbackLogger         logger;
      fmiCallbackAllocateMemory allocateMemory;
      fmiCallbackFreeMemory     freeMemory;
      fmiStepFinished           stepFinished;
    } fmiCallbackFunctions;

    typedef enum  {fmiOK,
                   fmiWarning,
                   fmiDiscard,
                   fmiError,
                   fmiFatal,
                   fmiPending} fmiStatus;

the fmiStepFinished ONLY exists in the standard for fmi1 co-simulation, yet this same structure is used even for FMUs created for model exchange. An application which supports FMI1 for model exchange will only have the first three callbacks, and this creates a problem when fmiCallbackFunctions is then passed (by value) to fmiInstantiateModel.

    DllExport fmiComponent fmiInstantiateModel(fmiString instanceName,
        fmiString GUID, fmiCallbackFunctions functions, fmiBoolean loggingOn);

A caller will observe that all logs will be created, because what likely happens is that their provided value of loggingOn gets used as a (maybe partially complete) function pointer for step finished, and the value of loggingOn is then some garbage.

These structure are however defined in FMI1 for co-simulation.

tl;dr There must be a mechanism to select the right callback structure depending on whether model-exchange or co-simulation is selected for fmi1 because they are not compatible.

As an aside, I know the CPP runtime is configured correctly for this, but it is not currently an option.

Change History (4)

comment:1 Changed 9 years ago by michael.kobierski@…

Hello, just to follow up, is there anything to be done about this?

comment:2 Changed 9 years ago by adeas31

  • Milestone changed from Future to 2.0.0

Not for release 1.9.4.
I will have a look at it after the release.

comment:3 Changed 5 years ago by lochel

  • Component changed from FMI to FMI 1.0

comment:4 Changed 5 years ago by lochel

  • Milestone changed from 2.0.0 to Future
Note: See TracTickets for help on using tickets.