]> gerrit.simantics Code Review - simantics/fmil.git/blob - org.simantics.fmil.core/native/FMILibrary/ThirdParty/FMI/standard32/FMI1/fmiFunctions.h
Add FMILibrary-2.0.3 to org.simantics.fmil.core\native.
[simantics/fmil.git] / org.simantics.fmil.core / native / FMILibrary / ThirdParty / FMI / standard32 / FMI1 / fmiFunctions.h
1 #ifndef fmiFunctions_h\r
2 #define fmiFunctions_h\r
3 \r
4 /* This header file must be utilized when compiling a FMU.\r
5    It defines all functions of Co-Simulation Interface.\r
6    In order to have unique function names even if several FMUs\r
7    are compiled together (e.g. for embedded systems), every "real" function name\r
8    is constructed by prepending the function name by\r
9    "MODEL_IDENTIFIER" + "_" where "MODEL_IDENTIFIER" is the short name\r
10    of the model used as the name of the zip-file where the model is stored.\r
11    Therefore, the typical usage is:\r
12 \r
13       #define MODEL_IDENTIFIER MyModel\r
14       #include "fmiFunctions.h"\r
15 \r
16    As a result, a function that is defined as "fmiGetDerivatives" in this header file,\r
17    is actually getting the name "MyModel_fmiGetDerivatives".\r
18 \r
19    Revisions:\r
20    - November 4, 2010: Adapted to specification text:\r
21                        o fmiGetModelTypesPlatform renamed to fmiGetTypesPlatform\r
22                        o fmiInstantiateSlave: Argument GUID     replaced by fmuGUID\r
23                                               Argument mimetype replaced by mimeType\r
24                        o tabs replaced by spaces\r
25    - October 16, 2010: First public Version\r
26 \r
27 \r
28    Copyright © 2008-2010, MODELISAR consortium. All rights reserved.\r
29    This file is licensed by the copyright holders under the BSD License\r
30    (http://www.opensource.org/licenses/bsd-license.html):\r
31 \r
32    ----------------------------------------------------------------------------\r
33    Redistribution and use in source and binary forms, with or without\r
34    modification, are permitted provided that the following conditions are met:\r
35 \r
36    - Redistributions of source code must retain the above copyright notice,\r
37      this list of conditions and the following disclaimer.\r
38    - Redistributions in binary form must reproduce the above copyright notice,\r
39      this list of conditions and the following disclaimer in the documentation\r
40      and/or other materials provided with the distribution.\r
41    - Neither the name of the copyright holders nor the names of its\r
42      contributors may be used to endorse or promote products derived\r
43      from this software without specific prior written permission.\r
44 \r
45    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
46    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED\r
47    TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
48    PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR\r
49    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\r
50    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\r
51    PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;\r
52    OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\r
53    WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR\r
54    OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF\r
55    ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
56    ----------------------------------------------------------------------------\r
57 */\r
58 \r
59 #include "fmiPlatformTypes.h"\r
60 #include <stdlib.h>\r
61 \r
62 /* Export fmi functions on Windows */\r
63 #ifdef _MSC_VER\r
64 #define DllExport __declspec( dllexport )\r
65 #else\r
66 #define DllExport\r
67 #endif\r
68 \r
69 /* Macros to construct the real function name\r
70    (prepend function name by MODEL_IDENTIFIER + "_") */\r
71 \r
72 #define fmiPaste(a,b)     a ## b\r
73 #define fmiPasteB(a,b)    fmiPaste(a,b)\r
74 #define fmiFullName(name) fmiPasteB(MODEL_IDENTIFIER, name)\r
75 \r
76 /***************************************************\r
77 Common Functions\r
78 ****************************************************/\r
79 #define fmiGetTypesPlatform fmiFullName(_fmiGetTypesPlatform)\r
80 #define fmiGetVersion       fmiFullName(_fmiGetVersion)\r
81 #define fmiSetDebugLogging  fmiFullName(_fmiSetDebugLogging)\r
82 \r
83 /*Data Exchange*/\r
84 #define fmiSetReal               fmiFullName(_fmiSetReal)\r
85 #define fmiSetInteger            fmiFullName(_fmiSetInteger)\r
86 #define fmiSetBoolean            fmiFullName(_fmiSetBoolean)\r
87 #define fmiSetString             fmiFullName(_fmiSetString)\r
88 \r
89 #define fmiGetReal               fmiFullName(_fmiGetReal)\r
90 #define fmiGetInteger            fmiFullName(_fmiGetInteger)\r
91 #define fmiGetBoolean            fmiFullName(_fmiGetBoolean)\r
92 #define fmiGetString             fmiFullName(_fmiGetString)\r
93 \r
94 /***************************************************\r
95 Functions for FMI for Co-Simulation\r
96 ****************************************************/\r
97 #define fmiInstantiateSlave         fmiFullName(_fmiInstantiateSlave)\r
98 #define fmiInitializeSlave          fmiFullName(_fmiInitializeSlave)\r
99 #define fmiTerminateSlave           fmiFullName(_fmiTerminateSlave)\r
100 #define fmiResetSlave               fmiFullName(_fmiResetSlave)\r
101 #define fmiFreeSlaveInstance        fmiFullName(_fmiFreeSlaveInstance)\r
102 #define fmiSetRealInputDerivatives  fmiFullName(_fmiSetRealInputDerivatives)\r
103 #define fmiGetRealOutputDerivatives fmiFullName(_fmiGetRealOutputDerivatives)\r
104 #define fmiDoStep                   fmiFullName(_fmiDoStep)\r
105 #define fmiCancelStep               fmiFullName(_fmiCancelStep)\r
106 #define fmiGetStatus                fmiFullName(_fmiGetStatus)\r
107 #define fmiGetRealStatus            fmiFullName(_fmiGetRealStatus)\r
108 #define fmiGetIntegerStatus         fmiFullName(_fmiGetIntegerStatus)\r
109 #define fmiGetBooleanStatus         fmiFullName(_fmiGetBooleanStatus)\r
110 #define fmiGetStringStatus          fmiFullName(_fmiGetStringStatus)\r
111 \r
112 /* Version number */\r
113 #define fmiVersion "1.0"\r
114 \r
115 /* make sure all compiler use the same alignment policies for structures */\r
116 #ifdef WIN32\r
117 #pragma pack(push,8)\r
118 #endif\r
119 \r
120 \r
121 /* Type definitions */\r
122      typedef enum {fmiOK,\r
123                    fmiWarning,\r
124                    fmiDiscard,\r
125                    fmiError,\r
126                    fmiFatal,\r
127                    fmiPending} fmiStatus;\r
128 \r
129      typedef void  (*fmiCallbackLogger) (fmiComponent c, fmiString instanceName, fmiStatus status,\r
130                                          fmiString category, fmiString message, ...);\r
131      typedef void* (*fmiCallbackAllocateMemory)(size_t nobj, size_t size);\r
132      typedef void  (*fmiCallbackFreeMemory)    (void* obj);\r
133      typedef void  (*fmiStepFinished)          (fmiComponent c, fmiStatus status);\r
134 \r
135      typedef struct {\r
136      fmiCallbackLogger         logger;\r
137      fmiCallbackAllocateMemory allocateMemory;\r
138      fmiCallbackFreeMemory     freeMemory;\r
139      fmiStepFinished           stepFinished;\r
140      } fmiCallbackFunctions;\r
141 \r
142    typedef struct {\r
143       fmiBoolean iterationConverged;\r
144       fmiBoolean stateValueReferencesChanged;\r
145       fmiBoolean stateValuesChanged;\r
146       fmiBoolean terminateSimulation;\r
147       fmiBoolean upcomingTimeEvent;\r
148       fmiReal    nextEventTime;\r
149    } fmiEventInfo;\r
150 \r
151 /* reset alignment policy to the one set before reading this file */\r
152 #ifdef WIN32\r
153 #pragma pack(pop)\r
154 #endif\r
155 \r
156 /***************************************************\r
157 Common Functions\r
158 ****************************************************/\r
159 \r
160 /* Inquire version numbers of header files */\r
161    DllExport const char* fmiGetTypesPlatform();\r
162    DllExport const char* fmiGetVersion();\r
163 \r
164    DllExport fmiStatus fmiSetDebugLogging  (fmiComponent c, fmiBoolean loggingOn);\r
165 \r
166 /* Data Exchange Functions*/\r
167    DllExport fmiStatus fmiGetReal   (fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiReal    value[]);\r
168    DllExport fmiStatus fmiGetInteger(fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiInteger value[]);\r
169    DllExport fmiStatus fmiGetBoolean(fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiBoolean value[]);\r
170    DllExport fmiStatus fmiGetString (fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiString  value[]);\r
171 \r
172    DllExport fmiStatus fmiSetReal    (fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiReal    value[]);\r
173    DllExport fmiStatus fmiSetInteger (fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiInteger value[]);\r
174    DllExport fmiStatus fmiSetBoolean (fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiBoolean value[]);\r
175    DllExport fmiStatus fmiSetString  (fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiString  value[]);\r
176 \r
177 /***************************************************\r
178 Functions for FMI for Co-Simulation\r
179 ****************************************************/\r
180 \r
181 /* Creation and destruction of slave instances and setting debug status */\r
182    DllExport fmiComponent fmiInstantiateSlave(fmiString  instanceName,\r
183                                               fmiString  fmuGUID,\r
184                                               fmiString  fmuLocation,\r
185                                               fmiString  mimeType,\r
186                                               fmiReal    timeout,\r
187                                               fmiBoolean visible,\r
188                                               fmiBoolean interactive,\r
189                                               fmiCallbackFunctions functions,\r
190                                               fmiBoolean loggingOn);\r
191 \r
192    DllExport fmiStatus fmiInitializeSlave(fmiComponent c,\r
193                                           fmiReal      tStart,\r
194                                           fmiBoolean   StopTimeDefined,\r
195                                           fmiReal      tStop);\r
196 \r
197    DllExport fmiStatus fmiTerminateSlave   (fmiComponent c);\r
198    DllExport fmiStatus fmiResetSlave       (fmiComponent c);\r
199    DllExport void      fmiFreeSlaveInstance(fmiComponent c);\r
200 \r
201    DllExport fmiStatus fmiSetRealInputDerivatives(fmiComponent c,\r
202                                                   const  fmiValueReference vr[],\r
203                                                   size_t nvr,\r
204                                                   const  fmiInteger order[],\r
205                                                   const  fmiReal value[]);\r
206 \r
207    DllExport fmiStatus fmiGetRealOutputDerivatives(fmiComponent c,\r
208                                                    const   fmiValueReference vr[],\r
209                                                    size_t  nvr,\r
210                                                    const   fmiInteger order[],\r
211                                                    fmiReal value[]);\r
212 \r
213    DllExport fmiStatus fmiCancelStep(fmiComponent c);\r
214    DllExport fmiStatus fmiDoStep    (fmiComponent c,\r
215                                      fmiReal      currentCommunicationPoint,\r
216                                      fmiReal      communicationStepSize,\r
217                                      fmiBoolean   newStep);\r
218 \r
219 \r
220    typedef enum {fmiDoStepStatus,\r
221                  fmiPendingStatus,\r
222                  fmiLastSuccessfulTime} fmiStatusKind;\r
223 \r
224    DllExport fmiStatus fmiGetStatus       (fmiComponent c, const fmiStatusKind s, fmiStatus*  value);\r
225    DllExport fmiStatus fmiGetRealStatus   (fmiComponent c, const fmiStatusKind s, fmiReal*    value);\r
226    DllExport fmiStatus fmiGetIntegerStatus(fmiComponent c, const fmiStatusKind s, fmiInteger* value);\r
227    DllExport fmiStatus fmiGetBooleanStatus(fmiComponent c, const fmiStatusKind s, fmiBoolean* value);\r
228    DllExport fmiStatus fmiGetStringStatus (fmiComponent c, const fmiStatusKind s, fmiString*  value);\r
229 \r
230 \r
231 #endif // fmiFunctions_h\r