| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480 |
- #ifndef BUILDFMU
- /* needed for source code export */
- #include "conf.h"
- #endif
- #include "fmiFunctions_.h"
- #include "fmiFunctions_fwd.h"
- /* This file contains wrappers for all FMI functions and is provided in
- the Dymola distribution instead of the actual implementation. This is
- necessary to avoid exposing the latter. */
- DYMOLA_STATIC void __enableResultStoring(fmiComponent c);
- /***************************************************
- Common Functions
- ****************************************************/
- /* For 2.0 this is common, for 1.0 it belongs to Co-sim interface only */
- #ifdef FMI_2
- const char* fmiGetTypesPlatform()
- {
- return fmiGetTypesPlatform_();
- }
- #endif
- /* ------------------------------------------------------ */
- const char* fmiGetVersion()
- {
- return fmiGetVersion_();
- }
- /* ------------------------------------------------------ */
- fmiStatus fmiSetDebugLogging(fmiComponent c, fmiBoolean loggingOn
- #ifdef FMI_2
- , size_t nCategories, const fmiString categories[]
- #endif
- )
- {
- return fmiSetDebugLogging_(c, loggingOn
- #ifdef FMI_2
- , nCategories, categories
- #endif
- );
- }
- /* ------------------------------------------------------ */
- fmiStatus fmiGetReal(fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiReal value[])
- {
- return fmiGetReal_(c, vr, nvr, value);
- }
- /* ------------------------------------------------------ */
- fmiStatus fmiGetInteger(fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiInteger value[])
- {
- return fmiGetInteger_(c, vr, nvr, value);
- }
- /* ------------------------------------------------------ */
- fmiStatus fmiGetBoolean(fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiBoolean value[])
- {
- return fmiGetBoolean_(c, vr, nvr, value);
- }
- /* ------------------------------------------------------ */
- fmiStatus fmiGetString(fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiString value[])
- {
- return fmiGetString_(c, vr, nvr, value);
- }
- /* ------------------------------------------------------ */
- fmiStatus fmiSetReal(fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiReal value[])
- {
- return fmiSetReal_(c, vr, nvr, value);
- }
- /* ------------------------------------------------------ */
- fmiStatus fmiSetInteger(fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiInteger value[])
- {
- return fmiSetInteger_(c, vr, nvr, value);
- }
- /* ------------------------------------------------------ */
- fmiStatus fmiSetBoolean(fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiBoolean value[])
- {
- return fmiSetBoolean_(c, vr, nvr, value);
- }
- /* ------------------------------------------------------ */
- fmiStatus fmiSetString(fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiString value[])
- {
- return fmiSetString_(c, vr, nvr, value);
- }
- #ifdef FMI_2
- /* ------------------------------------------------------ */
- fmiStatus fmiGetFMUstate(fmiComponent c, fmiFMUstate* FMUstate)
- {
- return fmiGetFMUstate_(c, FMUstate);
- }
- /* ------------------------------------------------------ */
- fmiStatus fmiSetFMUstate(fmiComponent c, fmiFMUstate FMUstate)
- {
- return fmiSetFMUstate_(c, FMUstate);
- }
- /* ------------------------------------------------------ */
- fmiStatus fmiFreeFMUstate(fmiComponent c, fmiFMUstate* FMUstate)
- {
- return fmiFreeFMUstate_(c, FMUstate);
- }
- /* ------------------------------------------------------ */
- fmiStatus fmiSerializedFMUstateSize(fmiComponent c, fmiFMUstate FMUstate, size_t *size)
- {
- return fmiSerializedFMUstateSize_(c, FMUstate, size);
- }
- /* ------------------------------------------------------ */
- fmiStatus fmiSerializeFMUstate(fmiComponent c, fmiFMUstate FMUstate, fmiByte serializedState[], size_t size)
- {
- return fmiSerializeFMUstate_(c, FMUstate, serializedState, size);
- }
- /* ------------------------------------------------------ */
- fmiStatus fmiDeSerializeFMUstate(fmiComponent c, const fmiByte serializedState[], size_t size, fmiFMUstate* FMUstate)
- {
- return fmiDeSerializeFMUstate_(c, serializedState, size, FMUstate);
- }
- /* ------------------------------------------------------ */
- fmiStatus fmiGetDirectionalDerivative(fmiComponent c,
- const fmiValueReference v_ref[],
- size_t nv,
- const fmiValueReference z_ref[],
- size_t nz,
- const fmiReal dv[],
- fmiReal dz[])
- {
- return fmiGetDirectionalDerivative_(c, v_ref, nv, z_ref, nz, dv, dz);
- }
- fmiComponent fmiInstantiate(fmiString instanceName, fmiType fmuType, fmiString fmuGUID, fmiString fmuResourceLocation, const fmiCallbackFunctions* functions, fmiBoolean visible, fmiBoolean loggingOn)
- {
- fmiComponent comp = fmiInstantiate_(instanceName, fmuType, fmuGUID, fmuResourceLocation, functions, visible, loggingOn);
- #ifndef FMU_SOURCE_CODE_EXPORT
- if (comp != NULL) {
- /* determine whether to store results or not */
- #include "dsmodel_fmuconf.h"
- }
- #endif /* FMU_SOURCE_CODE_EXPORT */
- return comp;
- }
- void fmiFreeInstance(fmiComponent c)
- {
- fmiFreeInstance_(c);
- }
- fmiStatus fmiSetupExperiment(fmiComponent c,
- fmiBoolean relativeToleranceDefined,
- fmiReal relativeTolerance,
- fmiReal tStart,
- fmiBoolean tStopDefined,
- fmiReal tStop)
- {
- return fmiSetupExperiment_(c, relativeToleranceDefined, relativeTolerance, tStart, tStopDefined, tStop);
- }
- fmiStatus fmiEnterInitializationMode(fmiComponent c)
- {
- return fmiEnterInitializationMode_(c);
- }
- fmiStatus fmiExitInitializationMode(fmiComponent c)
- {
- return fmiExitInitializationMode_(c);
- }
- fmiStatus fmiTerminate(fmiComponent c)
- {
- return fmiTerminate_(c);
- }
- fmiStatus fmiReset(fmiComponent c)
- {
- return fmiReset_(c);
- }
- #endif /* FMI_2 */
- /***************************************************
- Functions for FMI for Model Exchange
- ****************************************************/
- #ifndef FMU_SKIP_MODEL_EXCHANGE
- /* For 2.0 this is replaced by a common function fmiGetTypesPlatform. */
- #ifndef FMI_2
- const char* fmiGetModelTypesPlatform()
- {
- return fmiGetModelTypesPlatform_();
- }
- #endif
- #ifndef FMI_2
- fmiComponent fmiInstantiateModel(fmiString instanceName,
- fmiString GUID,
- fmiMECallbackFunctions functions,
- fmiBoolean loggingOn)
- {
- fmiComponent comp = fmiInstantiateModel_(instanceName, GUID, functions, loggingOn);
- #ifndef FMU_SOURCE_CODE_EXPORT
- if (comp != NULL) {
- /* determine whether to store results or not */
- #include "dsmodel_fmuconf.h"
- }
- #endif /* FMU_SOURCE_CODE_EXPORT */
- return comp;
- }
- #endif
- #ifndef FMI_2
- /* ------------------------------------------------------ */
- void fmiFreeModelInstance(fmiComponent c)
- {
- fmiFreeModelInstance_(c);
- }
- #endif
- /* ------------------------------------------------------ */
- fmiStatus fmiSetTime(fmiComponent c, fmiReal time)
- {
- return fmiSetTime_(c, time);
- }
- /* ------------------------------------------------------ */
- fmiStatus fmiSetContinuousStates(fmiComponent c, const fmiReal x[], size_t nx)
- {
- return fmiSetContinuousStates_(c, x, nx);
- }
- /* ------------------------------------------------------ */
- #ifdef FMI_2
- /* ------------------------------------------------------ */
- fmiStatus fmiEnterEventMode(fmiComponent c)
- {
- return fmiEnterEventMode_(c);
- }
- /* ------------------------------------------------------ */
- fmiStatus fmiNewDiscreteStates(fmiComponent c, fmiEventInfo* eventInfo)
- {
- return fmiNewDiscreteStates_(c, eventInfo);
- }
- /* ------------------------------------------------------ */
- fmiStatus fmiEnterContinuousTimeMode(fmiComponent c)
- {
- return fmiEnterContinuousTimeMode_(c);
- }
- /* ------------------------------------------------------ */
- fmiStatus fmiGetNominalsOfContinuousStates(fmiComponent c, fmiReal x_nominal[], size_t nx)
- {
- return fmiGetNominalsOfContinuousStates_(c, x_nominal, nx);
- }
- #else /* FMI_2 */
- /* ------------------------------------------------------ */
- fmiStatus fmiInitialize(fmiComponent c,
- fmiBoolean toleranceControlled,
- fmiReal relativeTolerance,
- fmiEventInfo* eventInfo)
- {
- return fmiInitialize_(c, toleranceControlled, relativeTolerance, eventInfo);
- }
- /* ------------------------------------------------------ */
- fmiStatus fmiEventUpdate(fmiComponent c, fmiBoolean intermediateResults, fmiEventInfo* eventInfo)
- {
- return fmiEventUpdate_(c, intermediateResults, eventInfo);
- }
- /* ------------------------------------------------------ */
- fmiStatus fmiTerminate(fmiComponent c)
- {
- return fmiTerminate_(c);
- }
- /* ------------------------------------------------------ */
- fmiStatus fmiGetStateValueReferences(fmiComponent c, fmiValueReference vrx[], size_t nx)
- {
- return fmiGetStateValueReferences_(c, vrx, nx);
- }
- /* ------------------------------------------------------ */
- fmiStatus fmiGetNominalContinuousStates(fmiComponent c, fmiReal x_nominal[], size_t nx)
- {
- return fmiGetNominalContinuousStates_(c, x_nominal, nx);
- }
- #endif /* FMI_2 */
- /* ------------------------------------------------------ */
- #ifdef FMI_2
- fmiStatus fmiCompletedIntegratorStep(fmiComponent c,
- fmiBoolean noSetFMUStatePriorToCurrentPoint,
- fmiBoolean* enterEventMode,
- fmiBoolean* terminateSimulation)
- {
- return fmiCompletedIntegratorStep_(c, noSetFMUStatePriorToCurrentPoint, enterEventMode, terminateSimulation);
- }
- #else /* FMI_2 */
- fmiStatus fmiCompletedIntegratorStep(fmiComponent c, fmiBoolean* callEventUpdate)
- {
- return fmiCompletedIntegratorStep_(c, callEventUpdate);
- }
- #endif /* FMI_2 */
- /* ------------------------------------------------------ */
- fmiStatus fmiGetDerivatives(fmiComponent c, fmiReal derivatives[], size_t nx)
- {
- return fmiGetDerivatives_(c, derivatives, nx);
- }
- /* ------------------------------------------------------ */
- fmiStatus fmiGetEventIndicators(fmiComponent c, fmiReal eventIndicators[], size_t ni)
- {
- return fmiGetEventIndicators_(c, eventIndicators, ni);
- }
- /* ------------------------------------------------------ */
- fmiStatus fmiGetContinuousStates(fmiComponent c, fmiReal states[], size_t nx)
- {
- return fmiGetContinuousStates_(c, states, nx);
- }
- #endif /* FMU_SKIP_MODEL_EXCHANGE */
- /***************************************************
- Functions for FMI for Co-Simulation
- ****************************************************/
- #ifndef FMU_SKIP_CO_SIM
- /* For 2.0 this is common, for 1.0 it belongs to Co-sim interface only */
- #ifndef FMI_2
- const char* fmiGetTypesPlatform()
- {
- return fmiGetTypesPlatform_();
- }
- #endif
- #ifndef FMI_2
- fmiComponent fmiInstantiateSlave(fmiString instanceName,
- fmiString fmuGUID,
- fmiString fmuLocation,
- fmiString mimeType,
- fmiReal timeout,
- fmiBoolean visible,
- fmiBoolean interactive,
- fmiCallbackFunctions functions,
- fmiBoolean loggingOn)
- {
- fmiComponent c = fmiInstantiateSlave_(instanceName,
- fmuGUID,
- fmuLocation,
- mimeType,
- timeout,
- visible,
- interactive,
- functions,
- loggingOn);
- #ifdef GenerateResultInNonDymosim
- __enableResultStoring(c);
- #endif
- return c;
- }
- #endif /* FMI_2 */
- #ifndef FMI_2
- /* ------------------------------------------------------ */
- void fmiFreeSlaveInstance(fmiComponent c)
- {
- fmiFreeSlaveInstance_(c);
- }
- #endif
- /* ------------------------------------------------------ */
- #ifndef FMI_2
- fmiStatus fmiInitializeSlave(fmiComponent c,
- fmiReal tStart,
- fmiBoolean StopTimeDefined,
- fmiReal tStop)
- {
- return fmiInitializeSlave_(c, tStart, StopTimeDefined, tStop);
- }
- /* ------------------------------------------------------ */
- fmiStatus fmiTerminateSlave(fmiComponent c)
- {
- return fmiTerminateSlave_(c);
- }
- /* ------------------------------------------------------ */
- fmiStatus fmiResetSlave(fmiComponent c)
- {
- return fmiResetSlave_(c);
- }
- #endif
- /* ------------------------------------------------------ */
- fmiStatus fmiSetRealInputDerivatives(fmiComponent c,
- const fmiValueReference vr[],
- size_t nvr,
- const fmiInteger order[],
- const fmiReal value[])
- {
- return fmiSetRealInputDerivatives_(c, vr, nvr, order, value);
- }
- /* ------------------------------------------------------ */
- fmiStatus fmiGetRealOutputDerivatives(fmiComponent c,
- const fmiValueReference vr[],
- size_t nvr,
- const fmiInteger order[],
- fmiReal value[])
- {
- return fmiGetRealOutputDerivatives_(c, vr, nvr, order, value);
- }
- /* ------------------------------------------------------ */
- fmiStatus fmiDoStep(fmiComponent c,
- fmiReal currentCommunicationPoint,
- fmiReal communicationStepSize,
- /* For 1.0: newStep,
- For 2.0: noSetFMUStatePriorToCurrentPoint */ fmiBoolean genericBool)
- {
- return fmiDoStep_(c, currentCommunicationPoint, communicationStepSize, genericBool);
- }
- /* ------------------------------------------------------ */
- fmiStatus fmiCancelStep(fmiComponent c)
- {
- return fmiCancelStep_(c);
- }
- /* ------------------------------------------------------ */
- fmiStatus fmiGetStatus(fmiComponent c, const fmiStatusKind s, fmiStatus* value)
- {
- return fmiGetStatus_(c, s, value);
- }
- /* ------------------------------------------------------ */
- fmiStatus fmiGetRealStatus(fmiComponent c, const fmiStatusKind s, fmiReal* value)
- {
- return fmiGetRealStatus_(c, s, value);
- }
- /* ------------------------------------------------------ */
- fmiStatus fmiGetIntegerStatus(fmiComponent c, const fmiStatusKind s, fmiInteger* value)
- {
- return fmiGetIntegerStatus_(c, s, value);
- }
- /* ------------------------------------------------------ */
- fmiStatus fmiGetBooleanStatus(fmiComponent c, const fmiStatusKind s, fmiBoolean* value)
- {
- return fmiGetBooleanStatus_(c, s, value);
- }
- /* ------------------------------------------------------ */
- fmiStatus fmiGetStringStatus(fmiComponent c, const fmiStatusKind s, fmiString* value)
- {
- return fmiGetStringStatus_(c, s, value);
- }
- #endif /* FMU_SKIP_CO_SIM */
|