]> gerrit.simantics Code Review - simantics/fmil.git/blobdiff - org.simantics.fmil.core/native/FMILibrary/ThirdParty/FMI/default/FMI1/fmiModelFunctions.h
Add FMILibrary-2.0.3 to org.simantics.fmil.core\native.
[simantics/fmil.git] / org.simantics.fmil.core / native / FMILibrary / ThirdParty / FMI / default / FMI1 / fmiModelFunctions.h
diff --git a/org.simantics.fmil.core/native/FMILibrary/ThirdParty/FMI/default/FMI1/fmiModelFunctions.h b/org.simantics.fmil.core/native/FMILibrary/ThirdParty/FMI/default/FMI1/fmiModelFunctions.h
new file mode 100644 (file)
index 0000000..73b53e0
--- /dev/null
@@ -0,0 +1,210 @@
+#ifndef fmiModelFunctions_h\r
+#define fmiModelFunctions_h\r
+\r
+/* This header file must be utilized when compiling a model.\r
+   It defines all functions of the Model Execution Interface.\r
+   In order to have unique function names even if several models\r
+   are compiled together (e.g. for embedded systems), every "real" function name\r
+   is constructed by prepending the function name by\r
+   "MODEL_IDENTIFIER" + "_" where "MODEL_IDENTIFIER" is the short name\r
+   of the model used as the name of the zip-file where the model is stored.\r
+   Therefore, the typical usage is:\r
+\r
+      #define MODEL_IDENTIFIER MyModel\r
+      #include "fmiModelFunctions.h"\r
+\r
+   As a result, a function that is defined as "fmiGetDerivatives" in this header file,\r
+   is actually getting the name "MyModel_fmiGetDerivatives".\r
+\r
+   Revisions:\r
+   - Jan. 20, 2010: stateValueReferencesChanged added to struct fmiEventInfo (ticket #27)\r
+                    (by M. Otter, DLR)\r
+                    Added WIN32 pragma to define the struct layout (ticket #34)\r
+                    (by J. Mauss, QTronic)\r
+   - Jan.  4, 2010: Removed argument intermediateResults from fmiInitialize\r
+                    Renamed macro fmiGetModelFunctionsVersion to fmiGetVersion\r
+                    Renamed macro fmiModelFunctionsVersion to fmiVersion\r
+                    Replaced fmiModel by fmiComponent in decl of fmiInstantiateModel\r
+                    (by J. Mauss, QTronic)\r
+   - Dec. 17, 2009: Changed extension "me" to "fmi" (by Martin Otter, DLR).\r
+   - Dez. 14, 2009: Added eventInfo to meInitialize and added\r
+                    meGetNominalContinuousStates (by Martin Otter, DLR)\r
+   - Sept. 9, 2009: Added DllExport (according to Peter Nilsson's suggestion)\r
+                    (by A. Junghanns, QTronic)\r
+   - Sept. 9, 2009: Changes according to FMI-meeting on July 21:\r
+                    meInquireModelTypesVersion     -> meGetModelTypesPlatform\r
+                    meInquireModelFunctionsVersion -> meGetModelFunctionsVersion\r
+                    meSetStates                    -> meSetContinuousStates\r
+                    meGetStates                    -> meGetContinuousStates\r
+                    removal of meInitializeModelClass\r
+                    removal of meGetTime\r
+                    change of arguments of meInstantiateModel\r
+                    change of arguments of meCompletedIntegratorStep\r
+                    (by Martin Otter, DLR):\r
+   - July 19, 2009: Added "me" as prefix to file names (by Martin Otter, DLR).\r
+   - March 2, 2009: Changed function definitions according to the last design\r
+                    meeting with additional improvements (by Martin Otter, DLR).\r
+   - Dec. 3 , 2008: First version by Martin Otter (DLR) and Hans Olsson (Dynasim).\r
+\r
+\r
+   Copyright � 2008-2009, MODELISAR consortium. All rights reserved.\r
+   This file is licensed by the copyright holders under the BSD License\r
+   (http://www.opensource.org/licenses/bsd-license.html):\r
+\r
+   ----------------------------------------------------------------------------\r
+   Redistribution and use in source and binary forms, with or without\r
+   modification, are permitted provided that the following conditions are met:\r
+\r
+   - Redistributions of source code must retain the above copyright notice,\r
+     this list of conditions and the following disclaimer.\r
+   - Redistributions in binary form must reproduce the above copyright notice,\r
+     this list of conditions and the following disclaimer in the documentation\r
+     and/or other materials provided with the distribution.\r
+   - Neither the name of the copyright holders nor the names of its\r
+     contributors may be used to endorse or promote products derived\r
+     from this software without specific prior written permission.\r
+\r
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED\r
+   TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
+   PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR\r
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\r
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\r
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;\r
+   OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\r
+   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR\r
+   OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF\r
+   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+   ----------------------------------------------------------------------------\r
+\r
+   with the extension:\r
+\r
+   You may distribute or publicly perform any modification only under the\r
+   terms of this license.\r
+*/\r
+\r
+#include "fmiModelTypes.h"\r
+#include <stdlib.h>\r
+\r
+/* Export fmi functions on Windows */\r
+#ifdef _MSC_VER\r
+#define DllExport __declspec( dllexport )\r
+#else\r
+#define DllExport\r
+#endif\r
+\r
+/* Macros to construct the real function name\r
+   (prepend function name by MODEL_IDENTIFIER + "_") */\r
+\r
+#define fmiPaste(a,b)     a ## b\r
+#define fmiPasteB(a,b)    fmiPaste(a,b)\r
+#define fmiFullName(name) fmiPasteB(MODEL_IDENTIFIER, name)\r
+\r
+#define fmiGetModelTypesPlatform      fmiFullName(_fmiGetModelTypesPlatform)\r
+#define fmiGetVersion                 fmiFullName(_fmiGetVersion)\r
+#define fmiInstantiateModel           fmiFullName(_fmiInstantiateModel)\r
+#define fmiFreeModelInstance          fmiFullName(_fmiFreeModelInstance)\r
+#define fmiSetDebugLogging            fmiFullName(_fmiSetDebugLogging)\r
+#define fmiSetTime                    fmiFullName(_fmiSetTime)\r
+#define fmiSetContinuousStates        fmiFullName(_fmiSetContinuousStates)\r
+#define fmiCompletedIntegratorStep    fmiFullName(_fmiCompletedIntegratorStep)\r
+#define fmiSetReal                    fmiFullName(_fmiSetReal)\r
+#define fmiSetInteger                 fmiFullName(_fmiSetInteger)\r
+#define fmiSetBoolean                 fmiFullName(_fmiSetBoolean)\r
+#define fmiSetString                  fmiFullName(_fmiSetString)\r
+#define fmiInitialize                 fmiFullName(_fmiInitialize)\r
+#define fmiGetDerivatives             fmiFullName(_fmiGetDerivatives)\r
+#define fmiGetEventIndicators         fmiFullName(_fmiGetEventIndicators)\r
+#define fmiGetReal                    fmiFullName(_fmiGetReal)\r
+#define fmiGetInteger                 fmiFullName(_fmiGetInteger)\r
+#define fmiGetBoolean                 fmiFullName(_fmiGetBoolean)\r
+#define fmiGetString                  fmiFullName(_fmiGetString)\r
+#define fmiEventUpdate                fmiFullName(_fmiEventUpdate)\r
+#define fmiGetContinuousStates        fmiFullName(_fmiGetContinuousStates)\r
+#define fmiGetNominalContinuousStates fmiFullName(_fmiGetNominalContinuousStates)\r
+#define fmiGetStateValueReferences    fmiFullName(_fmiGetStateValueReferences)\r
+#define fmiTerminate                  fmiFullName(_fmiTerminate)\r
+\r
+\r
+/* Version number */\r
+#define fmiVersion "1.0"\r
+\r
+/* Inquire version numbers of header files */\r
+   DllExport const char* fmiGetModelTypesPlatform();\r
+   DllExport const char* fmiGetVersion();\r
+\r
+/* make sure all compiler use the same alignment policies for structures */\r
+#ifdef WIN32\r
+#pragma pack(push,8)\r
+#endif\r
+\r
+/* Type definitions */\r
+   typedef enum  {fmiOK,\r
+                  fmiWarning,\r
+                  fmiDiscard,\r
+                  fmiError,\r
+                  fmiFatal} fmiStatus;\r
+\r
+   typedef void  (*fmiCallbackLogger)        (fmiComponent c, fmiString instanceName, fmiStatus status,\r
+                                              fmiString category, fmiString message, ...);\r
+   typedef void* (*fmiCallbackAllocateMemory)(size_t nobj, size_t size);\r
+   typedef void  (*fmiCallbackFreeMemory)    (void* obj);\r
+\r
+   typedef struct {\r
+     fmiCallbackLogger         logger;\r
+     fmiCallbackAllocateMemory allocateMemory;\r
+     fmiCallbackFreeMemory     freeMemory;\r
+   } fmiCallbackFunctions;\r
+\r
+   typedef struct {\r
+      fmiBoolean iterationConverged;\r
+      fmiBoolean stateValueReferencesChanged;\r
+      fmiBoolean stateValuesChanged;\r
+      fmiBoolean terminateSimulation;\r
+      fmiBoolean upcomingTimeEvent;\r
+      fmiReal    nextEventTime;\r
+   } fmiEventInfo;\r
+\r
+/* reset alignment policy to the one set before reading this file */\r
+#ifdef WIN32\r
+#pragma pack(pop)\r
+#endif\r
+\r
+/* Creation and destruction of model instances and setting debug status */\r
+   DllExport fmiComponent fmiInstantiateModel (fmiString            instanceName,\r
+                                               fmiString            GUID,\r
+                                               fmiCallbackFunctions functions,\r
+                                               fmiBoolean           loggingOn);\r
+   DllExport void      fmiFreeModelInstance(fmiComponent c);\r
+   DllExport fmiStatus fmiSetDebugLogging  (fmiComponent c, fmiBoolean loggingOn);\r
+\r
+\r
+/* Providing independent variables and re-initialization of caching */\r
+   DllExport fmiStatus fmiSetTime                (fmiComponent c, fmiReal time);\r
+   DllExport fmiStatus fmiSetContinuousStates    (fmiComponent c, const fmiReal x[], size_t nx);\r
+   DllExport fmiStatus fmiCompletedIntegratorStep(fmiComponent c, fmiBoolean* callEventUpdate);\r
+   DllExport fmiStatus fmiSetReal                (fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiReal    value[]);\r
+   DllExport fmiStatus fmiSetInteger             (fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiInteger value[]);\r
+   DllExport fmiStatus fmiSetBoolean             (fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiBoolean value[]);\r
+   DllExport fmiStatus fmiSetString              (fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiString  value[]);\r
+\r
+\r
+/* Evaluation of the model equations */\r
+   DllExport fmiStatus fmiInitialize(fmiComponent c, fmiBoolean toleranceControlled,\r
+                                     fmiReal relativeTolerance, fmiEventInfo* eventInfo);\r
+\r
+   DllExport fmiStatus fmiGetDerivatives    (fmiComponent c, fmiReal derivatives[]    , size_t nx);\r
+   DllExport fmiStatus fmiGetEventIndicators(fmiComponent c, fmiReal eventIndicators[], size_t ni);\r
+\r
+   DllExport fmiStatus fmiGetReal   (fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiReal    value[]);\r
+   DllExport fmiStatus fmiGetInteger(fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiInteger value[]);\r
+   DllExport fmiStatus fmiGetBoolean(fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiBoolean value[]);\r
+   DllExport fmiStatus fmiGetString (fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiString  value[]);\r
+\r
+   DllExport fmiStatus fmiEventUpdate               (fmiComponent c, fmiBoolean intermediateResults, fmiEventInfo* eventInfo);\r
+   DllExport fmiStatus fmiGetContinuousStates       (fmiComponent c, fmiReal states[], size_t nx);\r
+   DllExport fmiStatus fmiGetNominalContinuousStates(fmiComponent c, fmiReal x_nominal[], size_t nx);\r
+   DllExport fmiStatus fmiGetStateValueReferences   (fmiComponent c, fmiValueReference vrx[], size_t nx);\r
+   DllExport fmiStatus fmiTerminate                 (fmiComponent c);\r
+\r
+#endif /* fmiModelFunctions_h */\r