Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
fmi2Functions.h
Go to the documentation of this file.
1#ifndef fmi2Functions_h
2#define fmi2Functions_h
3
4/* This header file must be utilized when compiling a FMU.
5 It defines all functions of the
6 FMI 2.0.1 Model Exchange and Co-Simulation Interface.
7
8 In order to have unique function names even if several FMUs
9 are compiled together (e.g. for embedded systems), every "real" function name
10 is constructed by prepending the function name by "FMI2_FUNCTION_PREFIX".
11 Therefore, the typical usage is:
12
13 #define FMI2_FUNCTION_PREFIX MyModel_
14 #include "fmi2Functions.h"
15
16 As a result, a function that is defined as "fmi2GetDerivatives" in this header file,
17 is actually getting the name "MyModel_fmi2GetDerivatives".
18
19 This only holds if the FMU is shipped in C source code, or is compiled in a
20 static link library. For FMUs compiled in a DLL/sharedObject, the "actual" function
21 names are used and "FMI2_FUNCTION_PREFIX" must not be defined.
22
23 Revisions:
24 - Sep. 29, 2019: License changed to 2-clause BSD License (without extensions)
25 - Apr. 9, 2014: All prefixes "fmi" renamed to "fmi2" (decision from April 8)
26 - Mar. 26, 2014: FMI_Export set to empty value if FMI_Export and FMI_FUNCTION_PREFIX
27 are not defined (#173)
28 - Oct. 11, 2013: Functions of ModelExchange and CoSimulation merged:
29 fmiInstantiateModel , fmiInstantiateSlave -> fmiInstantiate
30 fmiFreeModelInstance, fmiFreeSlaveInstance -> fmiFreeInstance
31 fmiEnterModelInitializationMode, fmiEnterSlaveInitializationMode -> fmiEnterInitializationMode
32 fmiExitModelInitializationMode , fmiExitSlaveInitializationMode -> fmiExitInitializationMode
33 fmiTerminateModel, fmiTerminateSlave -> fmiTerminate
34 fmiResetSlave -> fmiReset (now also for ModelExchange and not only for CoSimulation)
35 Functions renamed:
36 fmiUpdateDiscreteStates -> fmiNewDiscreteStates
37 - June 13, 2013: Functions removed:
38 fmiInitializeModel
39 fmiEventUpdate
40 fmiCompletedEventIteration
41 fmiInitializeSlave
42 Functions added:
43 fmiEnterModelInitializationMode
44 fmiExitModelInitializationMode
45 fmiEnterEventMode
46 fmiUpdateDiscreteStates
47 fmiEnterContinuousTimeMode
48 fmiEnterSlaveInitializationMode;
49 fmiExitSlaveInitializationMode;
50 - Feb. 17, 2013: Portability improvements:
51 o DllExport changed to FMI_Export
52 o FUNCTION_PREFIX changed to FMI_FUNCTION_PREFIX
53 o Allow undefined FMI_FUNCTION_PREFIX (meaning no prefix is used)
54 Changed function name "fmiTerminate" to "fmiTerminateModel" (due to #113)
55 Changed function name "fmiGetNominalContinuousState" to
56 "fmiGetNominalsOfContinuousStates"
57 Removed fmiGetStateValueReferences.
58 - Nov. 14, 2011: Adapted to FMI 2.0:
59 o Split into two files (fmiFunctions.h, fmiTypes.h) in order
60 that code that dynamically loads an FMU can directly
61 utilize the header files).
62 o Added C++ encapsulation of C-part, in order that the header
63 file can be directly utilized in C++ code.
64 o fmiCallbackFunctions is passed as pointer to fmiInstantiateXXX
65 o stepFinished within fmiCallbackFunctions has as first
66 argument "fmiComponentEnvironment" and not "fmiComponent".
67 o New functions to get and set the complete FMU state
68 and to compute partial derivatives.
69 - Nov. 4, 2010: Adapted to specification text:
70 o fmiGetModelTypesPlatform renamed to fmiGetTypesPlatform
71 o fmiInstantiateSlave: Argument GUID replaced by fmuGUID
72 Argument mimetype replaced by mimeType
73 o tabs replaced by spaces
74 - Oct. 16, 2010: Functions for FMI for Co-simulation added
75 - Jan. 20, 2010: stateValueReferencesChanged added to struct fmiEventInfo (ticket #27)
76 (by M. Otter, DLR)
77 Added WIN32 pragma to define the struct layout (ticket #34)
78 (by J. Mauss, QTronic)
79 - Jan. 4, 2010: Removed argument intermediateResults from fmiInitialize
80 Renamed macro fmiGetModelFunctionsVersion to fmiGetVersion
81 Renamed macro fmiModelFunctionsVersion to fmiVersion
82 Replaced fmiModel by fmiComponent in decl of fmiInstantiateModel
83 (by J. Mauss, QTronic)
84 - Dec. 17, 2009: Changed extension "me" to "fmi" (by Martin Otter, DLR).
85 - Dez. 14, 2009: Added eventInfo to meInitialize and added
86 meGetNominalContinuousStates (by Martin Otter, DLR)
87 - Sept. 9, 2009: Added DllExport (according to Peter Nilsson's suggestion)
88 (by A. Junghanns, QTronic)
89 - Sept. 9, 2009: Changes according to FMI-meeting on July 21:
90 meInquireModelTypesVersion -> meGetModelTypesPlatform
91 meInquireModelFunctionsVersion -> meGetModelFunctionsVersion
92 meSetStates -> meSetContinuousStates
93 meGetStates -> meGetContinuousStates
94 removal of meInitializeModelClass
95 removal of meGetTime
96 change of arguments of meInstantiateModel
97 change of arguments of meCompletedIntegratorStep
98 (by Martin Otter, DLR):
99 - July 19, 2009: Added "me" as prefix to file names (by Martin Otter, DLR).
100 - March 2, 2009: Changed function definitions according to the last design
101 meeting with additional improvements (by Martin Otter, DLR).
102 - Dec. 3 , 2008: First version by Martin Otter (DLR) and Hans Olsson (Dynasim).
103
104
105 Copyright (C) 2008-2011 MODELISAR consortium,
106 2012-2019 Modelica Association Project "FMI"
107 All rights reserved.
108
109 This file is licensed by the copyright holders under the 2-Clause BSD License
110 (https://opensource.org/licenses/BSD-2-Clause):
111
112 ----------------------------------------------------------------------------
113 Redistribution and use in source and binary forms, with or without
114 modification, are permitted provided that the following conditions are met:
115
116 - Redistributions of source code must retain the above copyright notice,
117 this list of conditions and the following disclaimer.
118
119 - Redistributions in binary form must reproduce the above copyright notice,
120 this list of conditions and the following disclaimer in the documentation
121 and/or other materials provided with the distribution.
122
123 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
124 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
125 TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
126 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
127 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
128 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
129 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
130 OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
131 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
132 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
133 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
134 ----------------------------------------------------------------------------
135*/
136
137#ifdef __cplusplus
138extern "C" {
139#endif
140
141#include "fmi2TypesPlatform.h"
142#include "fmi2FunctionTypes.h"
143#include <stdlib.h>
144
145
146/*
147 Export FMI2 API functions on Windows and under GCC.
148 If custom linking is desired then the FMI2_Export must be
149 defined before including this file. For instance,
150 it may be set to __declspec(dllimport).
151*/
152#if !defined(FMI2_Export)
153 #if !defined(FMI2_FUNCTION_PREFIX)
154 #if defined _WIN32 || defined __CYGWIN__
155 /* Note: both gcc & MSVC on Windows support this syntax. */
156 #define FMI2_Export __declspec(dllexport)
157 #else
158 #if __GNUC__ >= 4
159 #define FMI2_Export __attribute__ ((visibility ("default")))
160 #else
161 #define FMI2_Export
162 #endif
163 #endif
164 #else
165 #define FMI2_Export
166 #endif
167#endif
168
169/* Macros to construct the real function name
170 (prepend function name by FMI2_FUNCTION_PREFIX) */
171#if defined(FMI2_FUNCTION_PREFIX)
172 #define fmi2Paste(a,b) a ## b
173 #define fmi2PasteB(a,b) fmi2Paste(a,b)
174 #define fmi2FullName(name) fmi2PasteB(FMI2_FUNCTION_PREFIX, name)
175#else
176 #define fmi2FullName(name) name
177#endif
178
179/***************************************************
180Common Functions
181****************************************************/
182#define fmi2GetTypesPlatform fmi2FullName(fmi2GetTypesPlatform)
183#define fmi2GetVersion fmi2FullName(fmi2GetVersion)
184#define fmi2SetDebugLogging fmi2FullName(fmi2SetDebugLogging)
185#define fmi2Instantiate fmi2FullName(fmi2Instantiate)
186#define fmi2FreeInstance fmi2FullName(fmi2FreeInstance)
187#define fmi2SetupExperiment fmi2FullName(fmi2SetupExperiment)
188#define fmi2EnterInitializationMode fmi2FullName(fmi2EnterInitializationMode)
189#define fmi2ExitInitializationMode fmi2FullName(fmi2ExitInitializationMode)
190#define fmi2Terminate fmi2FullName(fmi2Terminate)
191#define fmi2Reset fmi2FullName(fmi2Reset)
192#define fmi2GetReal fmi2FullName(fmi2GetReal)
193#define fmi2GetInteger fmi2FullName(fmi2GetInteger)
194#define fmi2GetBoolean fmi2FullName(fmi2GetBoolean)
195#define fmi2GetString fmi2FullName(fmi2GetString)
196#define fmi2SetReal fmi2FullName(fmi2SetReal)
197#define fmi2SetInteger fmi2FullName(fmi2SetInteger)
198#define fmi2SetBoolean fmi2FullName(fmi2SetBoolean)
199#define fmi2SetString fmi2FullName(fmi2SetString)
200#define fmi2GetFMUstate fmi2FullName(fmi2GetFMUstate)
201#define fmi2SetFMUstate fmi2FullName(fmi2SetFMUstate)
202#define fmi2FreeFMUstate fmi2FullName(fmi2FreeFMUstate)
203#define fmi2SerializedFMUstateSize fmi2FullName(fmi2SerializedFMUstateSize)
204#define fmi2SerializeFMUstate fmi2FullName(fmi2SerializeFMUstate)
205#define fmi2DeSerializeFMUstate fmi2FullName(fmi2DeSerializeFMUstate)
206#define fmi2GetDirectionalDerivative fmi2FullName(fmi2GetDirectionalDerivative)
207
208
209/***************************************************
210Functions for FMI2 for Model Exchange
211****************************************************/
212#define fmi2EnterEventMode fmi2FullName(fmi2EnterEventMode)
213#define fmi2NewDiscreteStates fmi2FullName(fmi2NewDiscreteStates)
214#define fmi2EnterContinuousTimeMode fmi2FullName(fmi2EnterContinuousTimeMode)
215#define fmi2CompletedIntegratorStep fmi2FullName(fmi2CompletedIntegratorStep)
216#define fmi2SetTime fmi2FullName(fmi2SetTime)
217#define fmi2SetContinuousStates fmi2FullName(fmi2SetContinuousStates)
218#define fmi2GetDerivatives fmi2FullName(fmi2GetDerivatives)
219#define fmi2GetEventIndicators fmi2FullName(fmi2GetEventIndicators)
220#define fmi2GetContinuousStates fmi2FullName(fmi2GetContinuousStates)
221#define fmi2GetNominalsOfContinuousStates fmi2FullName(fmi2GetNominalsOfContinuousStates)
222
223
224/***************************************************
225Functions for FMI2 for Co-Simulation
226****************************************************/
227#define fmi2SetRealInputDerivatives fmi2FullName(fmi2SetRealInputDerivatives)
228#define fmi2GetRealOutputDerivatives fmi2FullName(fmi2GetRealOutputDerivatives)
229#define fmi2DoStep fmi2FullName(fmi2DoStep)
230#define fmi2CancelStep fmi2FullName(fmi2CancelStep)
231#define fmi2GetStatus fmi2FullName(fmi2GetStatus)
232#define fmi2GetRealStatus fmi2FullName(fmi2GetRealStatus)
233#define fmi2GetIntegerStatus fmi2FullName(fmi2GetIntegerStatus)
234#define fmi2GetBooleanStatus fmi2FullName(fmi2GetBooleanStatus)
235#define fmi2GetStringStatus fmi2FullName(fmi2GetStringStatus)
236
237/* Version number */
238#define fmi2Version "2.0"
239
240
241/***************************************************
242Common Functions
243****************************************************/
244
245/* Inquire version numbers of header files */
249
250/* Creation and destruction of FMU instances */
253
254/* Enter and exit initialization mode, terminate and reset */
260
261/* Getting and setting variables values */
266
271
272/* Getting and setting the internal FMU state */
279
280/* Getting partial derivatives */
282
283
284/***************************************************
285Functions for FMI2 for Model Exchange
286****************************************************/
287
288/* Enter and exit the different modes */
293
294/* Providing independent variables and re-initialization of caching */
297
298/* Evaluation of the model equations */
303
304
305/***************************************************
306Functions for FMI2 for Co-Simulation
307****************************************************/
308
309/* Simulating the slave */
312
315
316/* Inquire slave status */
322
323#ifdef __cplusplus
324} /* end of extern "C" { */
325#endif
326
327#endif /* fmi2Functions_h */
fmi2Status fmi2SetDebugLoggingTYPE(fmi2Component c, fmi2Boolean loggingOn, size_t nCategories, const fmi2String categories[])
fmi2Status fmi2TerminateTYPE(fmi2Component c)
fmi2Status fmi2SerializeFMUstateTYPE(fmi2Component c, fmi2FMUstate FMUstate, fmi2Byte[], size_t size)
fmi2Status fmi2CancelStepTYPE(fmi2Component c)
fmi2Status fmi2ResetTYPE(fmi2Component c)
void fmi2FreeInstanceTYPE(fmi2Component c)
fmi2Status fmi2SetContinuousStatesTYPE(fmi2Component c, const fmi2Real x[], size_t nx)
fmi2Status fmi2GetRealOutputDerivativesTYPE(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, const fmi2Integer order[], fmi2Real value[])
const char * fmi2GetTypesPlatformTYPE(void)
fmi2Status fmi2SetFMUstateTYPE(fmi2Component c, fmi2FMUstate FMUstate)
fmi2Status fmi2FreeFMUstateTYPE(fmi2Component c, fmi2FMUstate *FMUstate)
fmi2Status fmi2SetRealInputDerivativesTYPE(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, const fmi2Integer order[], const fmi2Real value[])
fmi2Status fmi2GetBooleanStatusTYPE(fmi2Component c, const fmi2StatusKind s, fmi2Boolean *value)
fmi2Status fmi2DeSerializeFMUstateTYPE(fmi2Component c, const fmi2Byte serializedState[], size_t size, fmi2FMUstate *FMUstate)
fmi2Status fmi2SerializedFMUstateSizeTYPE(fmi2Component c, fmi2FMUstate FMUstate, size_t *size)
fmi2Status fmi2EnterInitializationModeTYPE(fmi2Component c)
fmi2Status fmi2ExitInitializationModeTYPE(fmi2Component c)
fmi2Component fmi2InstantiateTYPE(fmi2String instanceName, fmi2Type fmuType, fmi2String fmuGUID, fmi2String fmuResourceLocation, const fmi2CallbackFunctions *functions, fmi2Boolean visible, fmi2Boolean loggingOn)
fmi2Status fmi2EnterContinuousTimeModeTYPE(fmi2Component c)
fmi2Status fmi2GetStatusTYPE(fmi2Component c, const fmi2StatusKind s, fmi2Status *value)
const char * fmi2GetVersionTYPE(void)
fmi2Status fmi2GetBooleanTYPE(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, fmi2Boolean value[])
fmi2Status fmi2SetStringTYPE(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, const fmi2String value[])
fmi2Status fmi2GetContinuousStatesTYPE(fmi2Component c, fmi2Real x[], size_t nx)
fmi2Status fmi2SetTimeTYPE(fmi2Component c, fmi2Real time)
fmi2Status fmi2GetFMUstateTYPE(fmi2Component c, fmi2FMUstate *FMUstate)
fmi2Status fmi2GetStringStatusTYPE(fmi2Component c, const fmi2StatusKind s, fmi2String *value)
fmi2Status fmi2DoStepTYPE(fmi2Component c, fmi2Real currentCommunicationPoint, fmi2Real communicationStepSize, fmi2Boolean noSetFMUStatePriorToCurrentPoint)
fmi2Status fmi2SetRealTYPE(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, const fmi2Real value[])
fmi2Status fmi2GetIntegerTYPE(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, fmi2Integer value[])
fmi2Status fmi2GetNominalsOfContinuousStatesTYPE(fmi2Component c, fmi2Real x_nominal[], size_t nx)
fmi2Status fmi2GetDerivativesTYPE(fmi2Component c, fmi2Real derivatives[], size_t nx)
fmi2Status fmi2GetDirectionalDerivativeTYPE(fmi2Component c, const fmi2ValueReference vUnknown_ref[], size_t nUnknown, const fmi2ValueReference vKnown_ref[], size_t nKnown, const fmi2Real dvKnown[], fmi2Real dvUnknown[])
fmi2Status fmi2NewDiscreteStatesTYPE(fmi2Component c, fmi2EventInfo *fmi2eventInfo)
fmi2Status fmi2GetStringTYPE(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, fmi2String value[])
fmi2Status fmi2SetBooleanTYPE(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, const fmi2Boolean value[])
fmi2Status fmi2SetupExperimentTYPE(fmi2Component c, fmi2Boolean toleranceDefined, fmi2Real tolerance, fmi2Real startTime, fmi2Boolean stopTimeDefined, fmi2Real stopTime)
fmi2Status fmi2SetIntegerTYPE(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, const fmi2Integer value[])
fmi2Status fmi2GetIntegerStatusTYPE(fmi2Component c, const fmi2StatusKind s, fmi2Integer *value)
fmi2Status fmi2GetRealTYPE(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, fmi2Real value[])
fmi2Status fmi2CompletedIntegratorStepTYPE(fmi2Component c, fmi2Boolean noSetFMUStatePriorToCurrentPoint, fmi2Boolean *enterEventMode, fmi2Boolean *terminateSimulation)
fmi2Status fmi2GetEventIndicatorsTYPE(fmi2Component c, fmi2Real eventIndicators[], size_t ni)
fmi2Status fmi2GetRealStatusTYPE(fmi2Component c, const fmi2StatusKind s, fmi2Real *value)
fmi2Status fmi2EnterEventModeTYPE(fmi2Component c)
#define fmi2GetStringStatus
#define fmi2GetNominalsOfContinuousStates
#define fmi2GetFMUstate
#define fmi2GetReal
#define fmi2SetRealInputDerivatives
#define fmi2SetContinuousStates
#define fmi2GetTypesPlatform
#define FMI2_Export
#define fmi2CompletedIntegratorStep
#define fmi2SerializeFMUstate
#define fmi2SerializedFMUstateSize
#define fmi2CancelStep
#define fmi2ExitInitializationMode
#define fmi2GetString
#define fmi2GetBoolean
#define fmi2GetBooleanStatus
#define fmi2DoStep
#define fmi2SetString
#define fmi2Terminate
#define fmi2FreeInstance
#define fmi2GetRealOutputDerivatives
#define fmi2FreeFMUstate
#define fmi2SetFMUstate
#define fmi2EnterInitializationMode
#define fmi2DeSerializeFMUstate
#define fmi2GetRealStatus
#define fmi2SetReal
#define fmi2NewDiscreteStates
#define fmi2EnterEventMode
#define fmi2GetContinuousStates
#define fmi2GetVersion
#define fmi2GetInteger
#define fmi2GetDerivatives
#define fmi2GetIntegerStatus
#define fmi2SetTime
#define fmi2GetEventIndicators
#define fmi2GetStatus
#define fmi2SetDebugLogging
#define fmi2Instantiate
#define fmi2GetDirectionalDerivative
#define fmi2SetInteger
#define fmi2SetBoolean
#define fmi2Reset
#define fmi2EnterContinuousTimeMode
#define fmi2SetupExperiment