diff --git a/libraryincludes/fmi2FunctionTypes.h b/libraryincludes/fmi2FunctionTypes.h index ae65c34..ba341bd 100644 --- a/libraryincludes/fmi2FunctionTypes.h +++ b/libraryincludes/fmi2FunctionTypes.h @@ -4,9 +4,12 @@ #include "fmi2TypesPlatform.h" /* This header file must be utilized when compiling an FMU or an FMI master. - It declares data and function types for FMI 2.0 + It declares data and function types for FMI 2.0.4 Revisions: + - Sep. 30, 2019: License changed to 2-clause BSD License (without extensions) + - Jul. 5, 2019: Remove const modifier from fields of fmi2CallbackFunctions (#216) + - Sep. 6, 2018: Parameter names added to function prototypes - Apr. 9, 2014: all prefixes "fmi" renamed to "fmi2" (decision from April 8) - Apr. 3, 2014: Added #include for size_t definition - Mar. 27, 2014: Added #include "fmiTypesPlatform.h" (#179) @@ -46,11 +49,12 @@ - Nov. 14, 2011: First public Version - Copyright © 2011 MODELISAR consortium, - 2012-2013 Modelica Association Project "FMI" - All rights reserved. - This file is licensed by the copyright holders under the BSD 2-Clause License - (http://www.opensource.org/licenses/bsd-license.html): + Copyright (C) 2008-2011 MODELISAR consortium, + 2012-2022 Modelica Association Project "FMI" + All rights reserved. + + This file is licensed by the copyright holders under the 2-Clause BSD License + (https://opensource.org/licenses/BSD-2-Clause): ---------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -58,12 +62,10 @@ - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - - Neither the name of the copyright holders nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED @@ -77,13 +79,6 @@ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- - - with the extension: - - You may distribute or publicly perform any modification only under the - terms of this license. - (Note, this means that if you distribute a modified file, - the modified file must also be provided under this license). */ #ifdef __cplusplus @@ -121,21 +116,27 @@ typedef enum { fmi2Terminated } fmi2StatusKind; -typedef void (*fmi2CallbackLogger) (fmi2ComponentEnvironment, fmi2String, fmi2Status, fmi2String, fmi2String, ...); -typedef void* (*fmi2CallbackAllocateMemory)(size_t, size_t); -typedef void (*fmi2CallbackFreeMemory) (void*); -typedef void (*fmi2StepFinished) (fmi2ComponentEnvironment, fmi2Status); +typedef void (*fmi2CallbackLogger) (fmi2ComponentEnvironment componentEnvironment, + fmi2String instanceName, + fmi2Status status, + fmi2String category, + fmi2String message, + ...); +typedef void* (*fmi2CallbackAllocateMemory)(size_t nobj, size_t size); +typedef void (*fmi2CallbackFreeMemory) (void* obj); +typedef void (*fmi2StepFinished) (fmi2ComponentEnvironment componentEnvironment, + fmi2Status status); typedef struct { - const fmi2CallbackLogger logger; - const fmi2CallbackAllocateMemory allocateMemory; - const fmi2CallbackFreeMemory freeMemory; - const fmi2StepFinished stepFinished; - const fmi2ComponentEnvironment componentEnvironment; + fmi2CallbackLogger logger; + fmi2CallbackAllocateMemory allocateMemory; + fmi2CallbackFreeMemory freeMemory; + fmi2StepFinished stepFinished; + fmi2ComponentEnvironment componentEnvironment; } fmi2CallbackFunctions; typedef struct { - fmi2Boolean newDiscreteStatesNeeded; + fmi2Boolean newDiscreteStatesNeeded; fmi2Boolean terminateSimulation; fmi2Boolean nominalsOfContinuousStatesChanged; fmi2Boolean valuesOfContinuousStatesChanged; @@ -157,64 +158,83 @@ Types for Common Functions ****************************************************/ /* Inquire version numbers of header files and setting logging status */ - typedef const char* fmi2GetTypesPlatformTYPE(void); - typedef const char* fmi2GetVersionTYPE(void); - typedef fmi2Status fmi2SetDebugLoggingTYPE(fmi2Component, fmi2Boolean, size_t, const fmi2String[]); + typedef const char* fmi2GetTypesPlatformTYPE(void); + typedef const char* fmi2GetVersionTYPE(void); + typedef fmi2Status fmi2SetDebugLoggingTYPE(fmi2Component c, + fmi2Boolean loggingOn, + size_t nCategories, + const fmi2String categories[]); /* Creation and destruction of FMU instances and setting debug status */ - typedef fmi2Component fmi2InstantiateTYPE (fmi2String, fmi2Type, fmi2String, fmi2String, const fmi2CallbackFunctions*, fmi2Boolean, fmi2Boolean); - typedef void fmi2FreeInstanceTYPE(fmi2Component); + typedef fmi2Component fmi2InstantiateTYPE(fmi2String instanceName, + fmi2Type fmuType, + fmi2String fmuGUID, + fmi2String fmuResourceLocation, + const fmi2CallbackFunctions* functions, + fmi2Boolean visible, + fmi2Boolean loggingOn); + typedef void fmi2FreeInstanceTYPE(fmi2Component c); /* Enter and exit initialization mode, terminate and reset */ - typedef fmi2Status fmi2SetupExperimentTYPE (fmi2Component, fmi2Boolean, fmi2Real, fmi2Real, fmi2Boolean, fmi2Real); - typedef fmi2Status fmi2EnterInitializationModeTYPE(fmi2Component); - typedef fmi2Status fmi2ExitInitializationModeTYPE (fmi2Component); - typedef fmi2Status fmi2TerminateTYPE (fmi2Component); - typedef fmi2Status fmi2ResetTYPE (fmi2Component); + typedef fmi2Status fmi2SetupExperimentTYPE (fmi2Component c, + fmi2Boolean toleranceDefined, + fmi2Real tolerance, + fmi2Real startTime, + fmi2Boolean stopTimeDefined, + fmi2Real stopTime); + typedef fmi2Status fmi2EnterInitializationModeTYPE(fmi2Component c); + typedef fmi2Status fmi2ExitInitializationModeTYPE (fmi2Component c); + typedef fmi2Status fmi2TerminateTYPE (fmi2Component c); + typedef fmi2Status fmi2ResetTYPE (fmi2Component c); /* Getting and setting variable values */ - typedef fmi2Status fmi2GetRealTYPE (fmi2Component, const fmi2ValueReference[], size_t, fmi2Real []); - typedef fmi2Status fmi2GetIntegerTYPE(fmi2Component, const fmi2ValueReference[], size_t, fmi2Integer[]); - typedef fmi2Status fmi2GetBooleanTYPE(fmi2Component, const fmi2ValueReference[], size_t, fmi2Boolean[]); - typedef fmi2Status fmi2GetStringTYPE (fmi2Component, const fmi2ValueReference[], size_t, fmi2String []); + typedef fmi2Status fmi2GetRealTYPE (fmi2Component c, const fmi2ValueReference vr[], size_t nvr, fmi2Real value[]); + typedef fmi2Status fmi2GetIntegerTYPE(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, fmi2Integer value[]); + typedef fmi2Status fmi2GetBooleanTYPE(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, fmi2Boolean value[]); + typedef fmi2Status fmi2GetStringTYPE (fmi2Component c, const fmi2ValueReference vr[], size_t nvr, fmi2String value[]); - typedef fmi2Status fmi2SetRealTYPE (fmi2Component, const fmi2ValueReference[], size_t, const fmi2Real []); - typedef fmi2Status fmi2SetIntegerTYPE(fmi2Component, const fmi2ValueReference[], size_t, const fmi2Integer[]); - typedef fmi2Status fmi2SetBooleanTYPE(fmi2Component, const fmi2ValueReference[], size_t, const fmi2Boolean[]); - typedef fmi2Status fmi2SetStringTYPE (fmi2Component, const fmi2ValueReference[], size_t, const fmi2String []); + typedef fmi2Status fmi2SetRealTYPE (fmi2Component c, const fmi2ValueReference vr[], size_t nvr, const fmi2Real value[]); + typedef fmi2Status fmi2SetIntegerTYPE(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, const fmi2Integer value[]); + typedef fmi2Status fmi2SetBooleanTYPE(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, const fmi2Boolean value[]); + typedef fmi2Status fmi2SetStringTYPE (fmi2Component c, const fmi2ValueReference vr[], size_t nvr, const fmi2String value[]); /* Getting and setting the internal FMU state */ - typedef fmi2Status fmi2GetFMUstateTYPE (fmi2Component, fmi2FMUstate*); - typedef fmi2Status fmi2SetFMUstateTYPE (fmi2Component, fmi2FMUstate); - typedef fmi2Status fmi2FreeFMUstateTYPE (fmi2Component, fmi2FMUstate*); - typedef fmi2Status fmi2SerializedFMUstateSizeTYPE(fmi2Component, fmi2FMUstate, size_t*); - typedef fmi2Status fmi2SerializeFMUstateTYPE (fmi2Component, fmi2FMUstate, fmi2Byte[], size_t); - typedef fmi2Status fmi2DeSerializeFMUstateTYPE (fmi2Component, const fmi2Byte[], size_t, fmi2FMUstate*); + typedef fmi2Status fmi2GetFMUstateTYPE (fmi2Component c, fmi2FMUstate* FMUstate); + typedef fmi2Status fmi2SetFMUstateTYPE (fmi2Component c, fmi2FMUstate FMUstate); + typedef fmi2Status fmi2FreeFMUstateTYPE (fmi2Component c, fmi2FMUstate* FMUstate); + typedef fmi2Status fmi2SerializedFMUstateSizeTYPE(fmi2Component c, fmi2FMUstate FMUstate, size_t* size); + typedef fmi2Status fmi2SerializeFMUstateTYPE (fmi2Component c, fmi2FMUstate FMUstate, fmi2Byte serializedState[], size_t size); + typedef fmi2Status fmi2DeSerializeFMUstateTYPE (fmi2Component c, const fmi2Byte serializedState[], size_t size, fmi2FMUstate* FMUstate); /* Getting partial derivatives */ - typedef fmi2Status fmi2GetDirectionalDerivativeTYPE(fmi2Component, const fmi2ValueReference[], size_t, - const fmi2ValueReference[], size_t, - const fmi2Real[], fmi2Real[]); + typedef fmi2Status fmi2GetDirectionalDerivativeTYPE(fmi2Component c, + const fmi2ValueReference vUnknown_ref[], size_t nUnknown, + const fmi2ValueReference vKnown_ref[], size_t nKnown, + const fmi2Real dvKnown[], + fmi2Real dvUnknown[]); /*************************************************** Types for Functions for FMI2 for Model Exchange ****************************************************/ /* Enter and exit the different modes */ - typedef fmi2Status fmi2EnterEventModeTYPE (fmi2Component); - typedef fmi2Status fmi2NewDiscreteStatesTYPE (fmi2Component, fmi2EventInfo*); - typedef fmi2Status fmi2EnterContinuousTimeModeTYPE(fmi2Component); - typedef fmi2Status fmi2CompletedIntegratorStepTYPE(fmi2Component, fmi2Boolean, fmi2Boolean*, fmi2Boolean*); + typedef fmi2Status fmi2EnterEventModeTYPE (fmi2Component c); + typedef fmi2Status fmi2NewDiscreteStatesTYPE (fmi2Component c, fmi2EventInfo* fmi2eventInfo); + typedef fmi2Status fmi2EnterContinuousTimeModeTYPE(fmi2Component c); + typedef fmi2Status fmi2CompletedIntegratorStepTYPE(fmi2Component c, + fmi2Boolean noSetFMUStatePriorToCurrentPoint, + fmi2Boolean* enterEventMode, + fmi2Boolean* terminateSimulation); /* Providing independent variables and re-initialization of caching */ - typedef fmi2Status fmi2SetTimeTYPE (fmi2Component, fmi2Real); - typedef fmi2Status fmi2SetContinuousStatesTYPE(fmi2Component, const fmi2Real[], size_t); + typedef fmi2Status fmi2SetTimeTYPE (fmi2Component c, fmi2Real time); + typedef fmi2Status fmi2SetContinuousStatesTYPE(fmi2Component c, const fmi2Real x[], size_t nx); /* Evaluation of the model equations */ - typedef fmi2Status fmi2GetDerivativesTYPE (fmi2Component, fmi2Real[], size_t); - typedef fmi2Status fmi2GetEventIndicatorsTYPE (fmi2Component, fmi2Real[], size_t); - typedef fmi2Status fmi2GetContinuousStatesTYPE (fmi2Component, fmi2Real[], size_t); - typedef fmi2Status fmi2GetNominalsOfContinuousStatesTYPE(fmi2Component, fmi2Real[], size_t); + typedef fmi2Status fmi2GetDerivativesTYPE (fmi2Component c, fmi2Real derivatives[], size_t nx); + typedef fmi2Status fmi2GetEventIndicatorsTYPE (fmi2Component c, fmi2Real eventIndicators[], size_t ni); + typedef fmi2Status fmi2GetContinuousStatesTYPE (fmi2Component c, fmi2Real x[], size_t nx); + typedef fmi2Status fmi2GetNominalsOfContinuousStatesTYPE(fmi2Component c, fmi2Real x_nominal[], size_t nx); /*************************************************** @@ -222,18 +242,26 @@ Types for Functions for FMI2 for Co-Simulation ****************************************************/ /* Simulating the slave */ - typedef fmi2Status fmi2SetRealInputDerivativesTYPE (fmi2Component, const fmi2ValueReference [], size_t, const fmi2Integer [], const fmi2Real []); - typedef fmi2Status fmi2GetRealOutputDerivativesTYPE(fmi2Component, const fmi2ValueReference [], size_t, const fmi2Integer [], fmi2Real []); - - typedef fmi2Status fmi2DoStepTYPE (fmi2Component, fmi2Real, fmi2Real, fmi2Boolean); - typedef fmi2Status fmi2CancelStepTYPE (fmi2Component); + typedef fmi2Status fmi2SetRealInputDerivativesTYPE (fmi2Component c, + const fmi2ValueReference vr[], size_t nvr, + const fmi2Integer order[], + const fmi2Real value[]); + typedef fmi2Status fmi2GetRealOutputDerivativesTYPE(fmi2Component c, + const fmi2ValueReference vr[], size_t nvr, + const fmi2Integer order[], + fmi2Real value[]); + typedef fmi2Status fmi2DoStepTYPE (fmi2Component c, + fmi2Real currentCommunicationPoint, + fmi2Real communicationStepSize, + fmi2Boolean noSetFMUStatePriorToCurrentPoint); + typedef fmi2Status fmi2CancelStepTYPE(fmi2Component c); /* Inquire slave status */ - typedef fmi2Status fmi2GetStatusTYPE (fmi2Component, const fmi2StatusKind, fmi2Status* ); - typedef fmi2Status fmi2GetRealStatusTYPE (fmi2Component, const fmi2StatusKind, fmi2Real* ); - typedef fmi2Status fmi2GetIntegerStatusTYPE(fmi2Component, const fmi2StatusKind, fmi2Integer*); - typedef fmi2Status fmi2GetBooleanStatusTYPE(fmi2Component, const fmi2StatusKind, fmi2Boolean*); - typedef fmi2Status fmi2GetStringStatusTYPE (fmi2Component, const fmi2StatusKind, fmi2String* ); + typedef fmi2Status fmi2GetStatusTYPE (fmi2Component c, const fmi2StatusKind s, fmi2Status* value); + typedef fmi2Status fmi2GetRealStatusTYPE (fmi2Component c, const fmi2StatusKind s, fmi2Real* value); + typedef fmi2Status fmi2GetIntegerStatusTYPE(fmi2Component c, const fmi2StatusKind s, fmi2Integer* value); + typedef fmi2Status fmi2GetBooleanStatusTYPE(fmi2Component c, const fmi2StatusKind s, fmi2Boolean* value); + typedef fmi2Status fmi2GetStringStatusTYPE (fmi2Component c, const fmi2StatusKind s, fmi2String* value); #ifdef __cplusplus diff --git a/libraryincludes/fmi2Functions.h b/libraryincludes/fmi2Functions.h index ab142fc..8f72820 100644 --- a/libraryincludes/fmi2Functions.h +++ b/libraryincludes/fmi2Functions.h @@ -3,7 +3,7 @@ /* This header file must be utilized when compiling a FMU. It defines all functions of the - FMI 2.0 Model Exchange and Co-Simulation Interface. + FMI 2.0.4 Model Exchange and Co-Simulation Interface. In order to have unique function names even if several FMUs are compiled together (e.g. for embedded systems), every "real" function name @@ -21,7 +21,9 @@ names are used and "FMI2_FUNCTION_PREFIX" must not be defined. Revisions: - - Apr. 9, 2014: all prefixes "fmi" renamed to "fmi2" (decision from April 8) + - Sep. 13, 2022: Provide FMI2_OVERRIDE_FUNCTION_PREFIX functionality + - Sep. 29, 2019: License changed to 2-clause BSD License (without extensions) + - Apr. 9, 2014: All prefixes "fmi" renamed to "fmi2" (decision from April 8) - Mar. 26, 2014: FMI_Export set to empty value if FMI_Export and FMI_FUNCTION_PREFIX are not defined (#173) - Oct. 11, 2013: Functions of ModelExchange and CoSimulation merged: @@ -100,11 +102,13 @@ meeting with additional improvements (by Martin Otter, DLR). - Dec. 3 , 2008: First version by Martin Otter (DLR) and Hans Olsson (Dynasim). - Copyright � 2008-2011 MODELISAR consortium, - 2012-2013 Modelica Association Project "FMI" - All rights reserved. - This file is licensed by the copyright holders under the BSD 2-Clause License - (http://www.opensource.org/licenses/bsd-license.html): + + Copyright (C) 2008-2011 MODELISAR consortium, + 2012-2022 Modelica Association Project "FMI" + All rights reserved. + + This file is licensed by the copyright holders under the 2-Clause BSD License + (https://opensource.org/licenses/BSD-2-Clause): ---------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -112,12 +116,10 @@ - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - - Neither the name of the copyright holders nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED @@ -131,13 +133,6 @@ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- - - with the extension: - - You may distribute or publicly perform any modification only under the - terms of this license. - (Note, this means that if you distribute a modified file, - the modified file must also be provided under this license). */ #ifdef __cplusplus @@ -148,6 +143,15 @@ extern "C" { #include "fmi2FunctionTypes.h" #include +/* +Allow override of FMI2_FUNCTION_PREFIX: If FMI2_OVERRIDE_FUNCTION_PREFIX +is defined, then FMI2_ACTUAL_FUNCTION_PREFIX will be used, if defined, +or no prefix if undefined. Otherwise FMI2_FUNCTION_PREFIX will be used, +if defined. +*/ +#if !defined(FMI2_OVERRIDE_FUNCTION_PREFIX) && defined(FMI2_FUNCTION_PREFIX) + #define FMI2_ACTUAL_FUNCTION_PREFIX FMI2_FUNCTION_PREFIX +#endif /* Export FMI2 API functions on Windows and under GCC. @@ -156,7 +160,7 @@ extern "C" { it may be set to __declspec(dllimport). */ #if !defined(FMI2_Export) - #if !defined(FMI2_FUNCTION_PREFIX) + #if !defined(FMI2_ACTUAL_FUNCTION_PREFIX) #if defined _WIN32 || defined __CYGWIN__ /* Note: both gcc & MSVC on Windows support this syntax. */ #define FMI2_Export __declspec(dllexport) @@ -174,10 +178,10 @@ extern "C" { /* Macros to construct the real function name (prepend function name by FMI2_FUNCTION_PREFIX) */ -#if defined(FMI2_FUNCTION_PREFIX) +#if defined(FMI2_ACTUAL_FUNCTION_PREFIX) #define fmi2Paste(a,b) a ## b #define fmi2PasteB(a,b) fmi2Paste(a,b) - #define fmi2FullName(name) fmi2PasteB(FMI2_FUNCTION_PREFIX, name) + #define fmi2FullName(name) fmi2PasteB(FMI2_ACTUAL_FUNCTION_PREFIX, name) #else #define fmi2FullName(name) name #endif @@ -331,4 +335,3 @@ Functions for FMI2 for Co-Simulation #endif #endif /* fmi2Functions_h */ - diff --git a/libraryincludes/fmi2TypesPlatform.h b/libraryincludes/fmi2TypesPlatform.h index a8771d6..41db733 100644 --- a/libraryincludes/fmi2TypesPlatform.h +++ b/libraryincludes/fmi2TypesPlatform.h @@ -2,12 +2,13 @@ #define fmi2TypesPlatform_h /* Standard header file to define the argument types of the - functions of the Functional Mock-up Interface 2.0. + functions of the Functional Mock-up Interface 2.0.4 This header file must be utilized both by the model and by the simulation engine. Revisions: - - Apr. 9, 2014: all prefixes "fmi" renamed to "fmi2" (decision from April 8) + - Sep. 29, 2019: License changed to 2-clause BSD License (without extensions) + - Apr. 9, 2014: All prefixes "fmi" renamed to "fmi2" (decision from April 8) - Mar 31, 2014: New datatype fmiChar introduced. - Feb. 17, 2013: Changed fmiTypesPlatform from "standard32" to "default". Removed fmiUndefinedValueReference since no longer needed @@ -38,11 +39,12 @@ Hans Olsson (Dynasim). - Copyright © 2008-2011 MODELISAR consortium, - 2012-2013 Modelica Association Project "FMI" - All rights reserved. - This file is licensed by the copyright holders under the BSD 2-Clause License - (http://www.opensource.org/licenses/bsd-license.html): + Copyright (C) 2008-2011 MODELISAR consortium, + 2012-2022 Modelica Association Project "FMI" + All rights reserved. + + This file is licensed by the copyright holders under the 2-Clause BSD License + (https://opensource.org/licenses/BSD-2-Clause): ---------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -50,12 +52,10 @@ - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - - Neither the name of the copyright holders nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED @@ -69,13 +69,6 @@ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- - - with the extension: - - You may distribute or publicly perform any modification only under the - terms of this license. - (Note, this means that if you distribute a modified file, - the modified file must also be provided under this license). */ /* Platform (unique identification of this header file) */