mirror of
https://github.com/eclipse-openvehicle-api/openvehicle-api.git
synced 2026-04-20 03:08:17 +00:00
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "model.h"
|
||||
|
||||
#define EPSILON (FIXED_SOLVER_STEP * 1e-6)
|
||||
|
||||
void doFixedStep(ModelInstance *comp, bool* stateEvent, bool* timeEvent);
|
||||
@@ -0,0 +1,272 @@
|
||||
#ifndef fmi2FunctionTypes_h
|
||||
#define fmi2FunctionTypes_h
|
||||
|
||||
#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.1
|
||||
|
||||
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 <stddef.h> for size_t definition
|
||||
- Mar. 27, 2014: Added #include "fmiTypesPlatform.h" (#179)
|
||||
- Mar. 26, 2014: Introduced function argument "void" for the functions (#171)
|
||||
fmiGetTypesPlatformTYPE and fmiGetVersionTYPE
|
||||
- Oct. 11, 2013: Functions of ModelExchange and CoSimulation merged:
|
||||
fmiInstantiateModelTYPE , fmiInstantiateSlaveTYPE -> fmiInstantiateTYPE
|
||||
fmiFreeModelInstanceTYPE, fmiFreeSlaveInstanceTYPE -> fmiFreeInstanceTYPE
|
||||
fmiEnterModelInitializationModeTYPE, fmiEnterSlaveInitializationModeTYPE -> fmiEnterInitializationModeTYPE
|
||||
fmiExitModelInitializationModeTYPE , fmiExitSlaveInitializationModeTYPE -> fmiExitInitializationModeTYPE
|
||||
fmiTerminateModelTYPE , fmiTerminateSlaveTYPE -> fmiTerminate
|
||||
fmiResetSlave -> fmiReset (now also for ModelExchange and not only for CoSimulation)
|
||||
Functions renamed
|
||||
fmiUpdateDiscreteStatesTYPE -> fmiNewDiscreteStatesTYPE
|
||||
Renamed elements of the enumeration fmiEventInfo
|
||||
upcomingTimeEvent -> nextEventTimeDefined // due to generic naming scheme: varDefined + var
|
||||
newUpdateDiscreteStatesNeeded -> newDiscreteStatesNeeded;
|
||||
- June 13, 2013: Changed type fmiEventInfo
|
||||
Functions removed:
|
||||
fmiInitializeModelTYPE
|
||||
fmiEventUpdateTYPE
|
||||
fmiCompletedEventIterationTYPE
|
||||
fmiInitializeSlaveTYPE
|
||||
Functions added:
|
||||
fmiEnterModelInitializationModeTYPE
|
||||
fmiExitModelInitializationModeTYPE
|
||||
fmiEnterEventModeTYPE
|
||||
fmiUpdateDiscreteStatesTYPE
|
||||
fmiEnterContinuousTimeModeTYPE
|
||||
fmiEnterSlaveInitializationModeTYPE;
|
||||
fmiExitSlaveInitializationModeTYPE;
|
||||
- Feb. 17, 2013: Added third argument to fmiCompletedIntegratorStepTYPE
|
||||
Changed function name "fmiTerminateType" to "fmiTerminateModelType" (due to #113)
|
||||
Changed function name "fmiGetNominalContinuousStateTYPE" to
|
||||
"fmiGetNominalsOfContinuousStatesTYPE"
|
||||
Removed fmiGetStateValueReferencesTYPE.
|
||||
- Nov. 14, 2011: First public Version
|
||||
|
||||
|
||||
Copyright (C) 2008-2011 MODELISAR consortium,
|
||||
2012-2019 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
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
- 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.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* make sure all compiler use the same alignment policies for structures */
|
||||
#if defined _MSC_VER || defined __GNUC__
|
||||
#pragma pack(push,8)
|
||||
#endif
|
||||
|
||||
/* Include stddef.h, in order that size_t etc. is defined */
|
||||
#include <stddef.h>
|
||||
|
||||
|
||||
/* Type definitions */
|
||||
typedef enum {
|
||||
fmi2OK,
|
||||
fmi2Warning,
|
||||
fmi2Discard,
|
||||
fmi2Error,
|
||||
fmi2Fatal,
|
||||
fmi2Pending
|
||||
} fmi2Status;
|
||||
|
||||
typedef enum {
|
||||
fmi2ModelExchange,
|
||||
fmi2CoSimulation
|
||||
} fmi2Type;
|
||||
|
||||
typedef enum {
|
||||
fmi2DoStepStatus,
|
||||
fmi2PendingStatus,
|
||||
fmi2LastSuccessfulTime,
|
||||
fmi2Terminated
|
||||
} fmi2StatusKind;
|
||||
|
||||
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 {
|
||||
fmi2CallbackLogger logger;
|
||||
fmi2CallbackAllocateMemory allocateMemory;
|
||||
fmi2CallbackFreeMemory freeMemory;
|
||||
fmi2StepFinished stepFinished;
|
||||
fmi2ComponentEnvironment componentEnvironment;
|
||||
} fmi2CallbackFunctions;
|
||||
|
||||
typedef struct {
|
||||
fmi2Boolean newDiscreteStatesNeeded;
|
||||
fmi2Boolean terminateSimulation;
|
||||
fmi2Boolean nominalsOfContinuousStatesChanged;
|
||||
fmi2Boolean valuesOfContinuousStatesChanged;
|
||||
fmi2Boolean nextEventTimeDefined;
|
||||
fmi2Real nextEventTime;
|
||||
} fmi2EventInfo;
|
||||
|
||||
|
||||
/* reset alignment policy to the one set before reading this file */
|
||||
#if defined _MSC_VER || defined __GNUC__
|
||||
#pragma pack(pop)
|
||||
#endif
|
||||
|
||||
|
||||
/* Define fmi2 function pointer types to simplify dynamic loading */
|
||||
|
||||
/***************************************************
|
||||
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 c,
|
||||
fmi2Boolean loggingOn,
|
||||
size_t nCategories,
|
||||
const fmi2String categories[]);
|
||||
|
||||
/* Creation and destruction of FMU instances and setting debug status */
|
||||
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 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 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 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 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[], size_t size);
|
||||
typedef fmi2Status fmi2DeSerializeFMUstateTYPE (fmi2Component c, const fmi2Byte serializedState[], size_t size, fmi2FMUstate* FMUstate);
|
||||
|
||||
/* Getting partial derivatives */
|
||||
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 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 c, fmi2Real time);
|
||||
typedef fmi2Status fmi2SetContinuousStatesTYPE(fmi2Component c, const fmi2Real x[], size_t nx);
|
||||
|
||||
/* Evaluation of the model equations */
|
||||
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);
|
||||
|
||||
|
||||
/***************************************************
|
||||
Types for Functions for FMI2 for Co-Simulation
|
||||
****************************************************/
|
||||
|
||||
/* Simulating the slave */
|
||||
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 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
|
||||
} /* end of extern "C" { */
|
||||
#endif
|
||||
|
||||
#endif /* fmi2FunctionTypes_h */
|
||||
|
||||
@@ -0,0 +1,328 @@
|
||||
#ifndef fmi2Functions_h
|
||||
#define fmi2Functions_h
|
||||
|
||||
/* This header file must be utilized when compiling a FMU.
|
||||
It defines all functions of the
|
||||
FMI 2.0.1 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
|
||||
is constructed by prepending the function name by "FMI2_FUNCTION_PREFIX".
|
||||
Therefore, the typical usage is:
|
||||
|
||||
#define FMI2_FUNCTION_PREFIX MyModel_
|
||||
#include "fmi2Functions.h"
|
||||
|
||||
As a result, a function that is defined as "fmi2GetDerivatives" in this header file,
|
||||
is actually getting the name "MyModel_fmi2GetDerivatives".
|
||||
|
||||
This only holds if the FMU is shipped in C source code, or is compiled in a
|
||||
static link library. For FMUs compiled in a DLL/sharedObject, the "actual" function
|
||||
names are used and "FMI2_FUNCTION_PREFIX" must not be defined.
|
||||
|
||||
Revisions:
|
||||
- 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:
|
||||
fmiInstantiateModel , fmiInstantiateSlave -> fmiInstantiate
|
||||
fmiFreeModelInstance, fmiFreeSlaveInstance -> fmiFreeInstance
|
||||
fmiEnterModelInitializationMode, fmiEnterSlaveInitializationMode -> fmiEnterInitializationMode
|
||||
fmiExitModelInitializationMode , fmiExitSlaveInitializationMode -> fmiExitInitializationMode
|
||||
fmiTerminateModel, fmiTerminateSlave -> fmiTerminate
|
||||
fmiResetSlave -> fmiReset (now also for ModelExchange and not only for CoSimulation)
|
||||
Functions renamed:
|
||||
fmiUpdateDiscreteStates -> fmiNewDiscreteStates
|
||||
- June 13, 2013: Functions removed:
|
||||
fmiInitializeModel
|
||||
fmiEventUpdate
|
||||
fmiCompletedEventIteration
|
||||
fmiInitializeSlave
|
||||
Functions added:
|
||||
fmiEnterModelInitializationMode
|
||||
fmiExitModelInitializationMode
|
||||
fmiEnterEventMode
|
||||
fmiUpdateDiscreteStates
|
||||
fmiEnterContinuousTimeMode
|
||||
fmiEnterSlaveInitializationMode;
|
||||
fmiExitSlaveInitializationMode;
|
||||
- Feb. 17, 2013: Portability improvements:
|
||||
o DllExport changed to FMI_Export
|
||||
o FUNCTION_PREFIX changed to FMI_FUNCTION_PREFIX
|
||||
o Allow undefined FMI_FUNCTION_PREFIX (meaning no prefix is used)
|
||||
Changed function name "fmiTerminate" to "fmiTerminateModel" (due to #113)
|
||||
Changed function name "fmiGetNominalContinuousState" to
|
||||
"fmiGetNominalsOfContinuousStates"
|
||||
Removed fmiGetStateValueReferences.
|
||||
- Nov. 14, 2011: Adapted to FMI 2.0:
|
||||
o Split into two files (fmiFunctions.h, fmiTypes.h) in order
|
||||
that code that dynamically loads an FMU can directly
|
||||
utilize the header files).
|
||||
o Added C++ encapsulation of C-part, in order that the header
|
||||
file can be directly utilized in C++ code.
|
||||
o fmiCallbackFunctions is passed as pointer to fmiInstantiateXXX
|
||||
o stepFinished within fmiCallbackFunctions has as first
|
||||
argument "fmiComponentEnvironment" and not "fmiComponent".
|
||||
o New functions to get and set the complete FMU state
|
||||
and to compute partial derivatives.
|
||||
- Nov. 4, 2010: Adapted to specification text:
|
||||
o fmiGetModelTypesPlatform renamed to fmiGetTypesPlatform
|
||||
o fmiInstantiateSlave: Argument GUID replaced by fmuGUID
|
||||
Argument mimetype replaced by mimeType
|
||||
o tabs replaced by spaces
|
||||
- Oct. 16, 2010: Functions for FMI for Co-simulation added
|
||||
- Jan. 20, 2010: stateValueReferencesChanged added to struct fmiEventInfo (ticket #27)
|
||||
(by M. Otter, DLR)
|
||||
Added WIN32 pragma to define the struct layout (ticket #34)
|
||||
(by J. Mauss, QTronic)
|
||||
- Jan. 4, 2010: Removed argument intermediateResults from fmiInitialize
|
||||
Renamed macro fmiGetModelFunctionsVersion to fmiGetVersion
|
||||
Renamed macro fmiModelFunctionsVersion to fmiVersion
|
||||
Replaced fmiModel by fmiComponent in decl of fmiInstantiateModel
|
||||
(by J. Mauss, QTronic)
|
||||
- Dec. 17, 2009: Changed extension "me" to "fmi" (by Martin Otter, DLR).
|
||||
- Dez. 14, 2009: Added eventInfo to meInitialize and added
|
||||
meGetNominalContinuousStates (by Martin Otter, DLR)
|
||||
- Sept. 9, 2009: Added DllExport (according to Peter Nilsson's suggestion)
|
||||
(by A. Junghanns, QTronic)
|
||||
- Sept. 9, 2009: Changes according to FMI-meeting on July 21:
|
||||
meInquireModelTypesVersion -> meGetModelTypesPlatform
|
||||
meInquireModelFunctionsVersion -> meGetModelFunctionsVersion
|
||||
meSetStates -> meSetContinuousStates
|
||||
meGetStates -> meGetContinuousStates
|
||||
removal of meInitializeModelClass
|
||||
removal of meGetTime
|
||||
change of arguments of meInstantiateModel
|
||||
change of arguments of meCompletedIntegratorStep
|
||||
(by Martin Otter, DLR):
|
||||
- July 19, 2009: Added "me" as prefix to file names (by Martin Otter, DLR).
|
||||
- March 2, 2009: Changed function definitions according to the last design
|
||||
meeting with additional improvements (by Martin Otter, DLR).
|
||||
- Dec. 3 , 2008: First version by Martin Otter (DLR) and Hans Olsson (Dynasim).
|
||||
|
||||
|
||||
Copyright (C) 2008-2011 MODELISAR consortium,
|
||||
2012-2019 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
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
- 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.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "fmi2TypesPlatform.h"
|
||||
#include "fmi2FunctionTypes.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
/*
|
||||
Export FMI2 API functions on Windows and under GCC.
|
||||
If custom linking is desired then the FMI2_Export must be
|
||||
defined before including this file. For instance,
|
||||
it may be set to __declspec(dllimport).
|
||||
*/
|
||||
#if !defined(FMI2_Export)
|
||||
#if !defined(FMI2_FUNCTION_PREFIX)
|
||||
#if defined _WIN32 || defined __CYGWIN__
|
||||
/* Note: both gcc & MSVC on Windows support this syntax. */
|
||||
#define FMI2_Export __declspec(dllexport)
|
||||
#else
|
||||
#if __GNUC__ >= 4
|
||||
#define FMI2_Export __attribute__ ((visibility ("default")))
|
||||
#else
|
||||
#define FMI2_Export
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
#define FMI2_Export
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Macros to construct the real function name
|
||||
(prepend function name by FMI2_FUNCTION_PREFIX) */
|
||||
#if defined(FMI2_FUNCTION_PREFIX)
|
||||
#define fmi2Paste(a,b) a ## b
|
||||
#define fmi2PasteB(a,b) fmi2Paste(a,b)
|
||||
#define fmi2FullName(name) fmi2PasteB(FMI2_FUNCTION_PREFIX, name)
|
||||
#else
|
||||
#define fmi2FullName(name) name
|
||||
#endif
|
||||
|
||||
/***************************************************
|
||||
Common Functions
|
||||
****************************************************/
|
||||
#define fmi2GetTypesPlatform fmi2FullName(fmi2GetTypesPlatform)
|
||||
#define fmi2GetVersion fmi2FullName(fmi2GetVersion)
|
||||
#define fmi2SetDebugLogging fmi2FullName(fmi2SetDebugLogging)
|
||||
#define fmi2Instantiate fmi2FullName(fmi2Instantiate)
|
||||
#define fmi2FreeInstance fmi2FullName(fmi2FreeInstance)
|
||||
#define fmi2SetupExperiment fmi2FullName(fmi2SetupExperiment)
|
||||
#define fmi2EnterInitializationMode fmi2FullName(fmi2EnterInitializationMode)
|
||||
#define fmi2ExitInitializationMode fmi2FullName(fmi2ExitInitializationMode)
|
||||
#define fmi2Terminate fmi2FullName(fmi2Terminate)
|
||||
#define fmi2Reset fmi2FullName(fmi2Reset)
|
||||
#define fmi2GetReal fmi2FullName(fmi2GetReal)
|
||||
#define fmi2GetInteger fmi2FullName(fmi2GetInteger)
|
||||
#define fmi2GetBoolean fmi2FullName(fmi2GetBoolean)
|
||||
#define fmi2GetString fmi2FullName(fmi2GetString)
|
||||
#define fmi2SetReal fmi2FullName(fmi2SetReal)
|
||||
#define fmi2SetInteger fmi2FullName(fmi2SetInteger)
|
||||
#define fmi2SetBoolean fmi2FullName(fmi2SetBoolean)
|
||||
#define fmi2SetString fmi2FullName(fmi2SetString)
|
||||
#define fmi2GetFMUstate fmi2FullName(fmi2GetFMUstate)
|
||||
#define fmi2SetFMUstate fmi2FullName(fmi2SetFMUstate)
|
||||
#define fmi2FreeFMUstate fmi2FullName(fmi2FreeFMUstate)
|
||||
#define fmi2SerializedFMUstateSize fmi2FullName(fmi2SerializedFMUstateSize)
|
||||
#define fmi2SerializeFMUstate fmi2FullName(fmi2SerializeFMUstate)
|
||||
#define fmi2DeSerializeFMUstate fmi2FullName(fmi2DeSerializeFMUstate)
|
||||
#define fmi2GetDirectionalDerivative fmi2FullName(fmi2GetDirectionalDerivative)
|
||||
|
||||
|
||||
/***************************************************
|
||||
Functions for FMI2 for Model Exchange
|
||||
****************************************************/
|
||||
#define fmi2EnterEventMode fmi2FullName(fmi2EnterEventMode)
|
||||
#define fmi2NewDiscreteStates fmi2FullName(fmi2NewDiscreteStates)
|
||||
#define fmi2EnterContinuousTimeMode fmi2FullName(fmi2EnterContinuousTimeMode)
|
||||
#define fmi2CompletedIntegratorStep fmi2FullName(fmi2CompletedIntegratorStep)
|
||||
#define fmi2SetTime fmi2FullName(fmi2SetTime)
|
||||
#define fmi2SetContinuousStates fmi2FullName(fmi2SetContinuousStates)
|
||||
#define fmi2GetDerivatives fmi2FullName(fmi2GetDerivatives)
|
||||
#define fmi2GetEventIndicators fmi2FullName(fmi2GetEventIndicators)
|
||||
#define fmi2GetContinuousStates fmi2FullName(fmi2GetContinuousStates)
|
||||
#define fmi2GetNominalsOfContinuousStates fmi2FullName(fmi2GetNominalsOfContinuousStates)
|
||||
|
||||
|
||||
/***************************************************
|
||||
Functions for FMI2 for Co-Simulation
|
||||
****************************************************/
|
||||
#define fmi2SetRealInputDerivatives fmi2FullName(fmi2SetRealInputDerivatives)
|
||||
#define fmi2GetRealOutputDerivatives fmi2FullName(fmi2GetRealOutputDerivatives)
|
||||
#define fmi2DoStep fmi2FullName(fmi2DoStep)
|
||||
#define fmi2CancelStep fmi2FullName(fmi2CancelStep)
|
||||
#define fmi2GetStatus fmi2FullName(fmi2GetStatus)
|
||||
#define fmi2GetRealStatus fmi2FullName(fmi2GetRealStatus)
|
||||
#define fmi2GetIntegerStatus fmi2FullName(fmi2GetIntegerStatus)
|
||||
#define fmi2GetBooleanStatus fmi2FullName(fmi2GetBooleanStatus)
|
||||
#define fmi2GetStringStatus fmi2FullName(fmi2GetStringStatus)
|
||||
|
||||
/* Version number */
|
||||
#define fmi2Version "2.0"
|
||||
|
||||
|
||||
/***************************************************
|
||||
Common Functions
|
||||
****************************************************/
|
||||
|
||||
/* Inquire version numbers of header files */
|
||||
FMI2_Export fmi2GetTypesPlatformTYPE fmi2GetTypesPlatform;
|
||||
FMI2_Export fmi2GetVersionTYPE fmi2GetVersion;
|
||||
FMI2_Export fmi2SetDebugLoggingTYPE fmi2SetDebugLogging;
|
||||
|
||||
/* Creation and destruction of FMU instances */
|
||||
FMI2_Export fmi2InstantiateTYPE fmi2Instantiate;
|
||||
FMI2_Export fmi2FreeInstanceTYPE fmi2FreeInstance;
|
||||
|
||||
/* Enter and exit initialization mode, terminate and reset */
|
||||
FMI2_Export fmi2SetupExperimentTYPE fmi2SetupExperiment;
|
||||
FMI2_Export fmi2EnterInitializationModeTYPE fmi2EnterInitializationMode;
|
||||
FMI2_Export fmi2ExitInitializationModeTYPE fmi2ExitInitializationMode;
|
||||
FMI2_Export fmi2TerminateTYPE fmi2Terminate;
|
||||
FMI2_Export fmi2ResetTYPE fmi2Reset;
|
||||
|
||||
/* Getting and setting variables values */
|
||||
FMI2_Export fmi2GetRealTYPE fmi2GetReal;
|
||||
FMI2_Export fmi2GetIntegerTYPE fmi2GetInteger;
|
||||
FMI2_Export fmi2GetBooleanTYPE fmi2GetBoolean;
|
||||
FMI2_Export fmi2GetStringTYPE fmi2GetString;
|
||||
|
||||
FMI2_Export fmi2SetRealTYPE fmi2SetReal;
|
||||
FMI2_Export fmi2SetIntegerTYPE fmi2SetInteger;
|
||||
FMI2_Export fmi2SetBooleanTYPE fmi2SetBoolean;
|
||||
FMI2_Export fmi2SetStringTYPE fmi2SetString;
|
||||
|
||||
/* Getting and setting the internal FMU state */
|
||||
FMI2_Export fmi2GetFMUstateTYPE fmi2GetFMUstate;
|
||||
FMI2_Export fmi2SetFMUstateTYPE fmi2SetFMUstate;
|
||||
FMI2_Export fmi2FreeFMUstateTYPE fmi2FreeFMUstate;
|
||||
FMI2_Export fmi2SerializedFMUstateSizeTYPE fmi2SerializedFMUstateSize;
|
||||
FMI2_Export fmi2SerializeFMUstateTYPE fmi2SerializeFMUstate;
|
||||
FMI2_Export fmi2DeSerializeFMUstateTYPE fmi2DeSerializeFMUstate;
|
||||
|
||||
/* Getting partial derivatives */
|
||||
FMI2_Export fmi2GetDirectionalDerivativeTYPE fmi2GetDirectionalDerivative;
|
||||
|
||||
|
||||
/***************************************************
|
||||
Functions for FMI2 for Model Exchange
|
||||
****************************************************/
|
||||
|
||||
/* Enter and exit the different modes */
|
||||
FMI2_Export fmi2EnterEventModeTYPE fmi2EnterEventMode;
|
||||
FMI2_Export fmi2NewDiscreteStatesTYPE fmi2NewDiscreteStates;
|
||||
FMI2_Export fmi2EnterContinuousTimeModeTYPE fmi2EnterContinuousTimeMode;
|
||||
FMI2_Export fmi2CompletedIntegratorStepTYPE fmi2CompletedIntegratorStep;
|
||||
|
||||
/* Providing independent variables and re-initialization of caching */
|
||||
FMI2_Export fmi2SetTimeTYPE fmi2SetTime;
|
||||
FMI2_Export fmi2SetContinuousStatesTYPE fmi2SetContinuousStates;
|
||||
|
||||
/* Evaluation of the model equations */
|
||||
FMI2_Export fmi2GetDerivativesTYPE fmi2GetDerivatives;
|
||||
FMI2_Export fmi2GetEventIndicatorsTYPE fmi2GetEventIndicators;
|
||||
FMI2_Export fmi2GetContinuousStatesTYPE fmi2GetContinuousStates;
|
||||
FMI2_Export fmi2GetNominalsOfContinuousStatesTYPE fmi2GetNominalsOfContinuousStates;
|
||||
|
||||
|
||||
/***************************************************
|
||||
Functions for FMI2 for Co-Simulation
|
||||
****************************************************/
|
||||
|
||||
/* Simulating the slave */
|
||||
FMI2_Export fmi2SetRealInputDerivativesTYPE fmi2SetRealInputDerivatives;
|
||||
FMI2_Export fmi2GetRealOutputDerivativesTYPE fmi2GetRealOutputDerivatives;
|
||||
|
||||
FMI2_Export fmi2DoStepTYPE fmi2DoStep;
|
||||
FMI2_Export fmi2CancelStepTYPE fmi2CancelStep;
|
||||
|
||||
/* Inquire slave status */
|
||||
FMI2_Export fmi2GetStatusTYPE fmi2GetStatus;
|
||||
FMI2_Export fmi2GetRealStatusTYPE fmi2GetRealStatus;
|
||||
FMI2_Export fmi2GetIntegerStatusTYPE fmi2GetIntegerStatus;
|
||||
FMI2_Export fmi2GetBooleanStatusTYPE fmi2GetBooleanStatus;
|
||||
FMI2_Export fmi2GetStringStatusTYPE fmi2GetStringStatus;
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end of extern "C" { */
|
||||
#endif
|
||||
|
||||
#endif /* fmi2Functions_h */
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
#ifndef fmi2TypesPlatform_h
|
||||
#define fmi2TypesPlatform_h
|
||||
|
||||
/* Standard header file to define the argument types of the
|
||||
functions of the Functional Mock-up Interface 2.0.1
|
||||
This header file must be utilized both by the model and
|
||||
by the simulation engine.
|
||||
|
||||
Revisions:
|
||||
- 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
|
||||
(because every state is defined in ScalarVariables).
|
||||
- March 20, 2012: Renamed from fmiPlatformTypes.h to fmiTypesPlatform.h
|
||||
- Nov. 14, 2011: Use the header file "fmiPlatformTypes.h" for FMI 2.0
|
||||
both for "FMI for model exchange" and for "FMI for co-simulation"
|
||||
New types "fmiComponentEnvironment", "fmiState", and "fmiByte".
|
||||
The implementation of "fmiBoolean" is change from "char" to "int".
|
||||
The #define "fmiPlatform" changed to "fmiTypesPlatform"
|
||||
(in order that #define and function call are consistent)
|
||||
- Oct. 4, 2010: Renamed header file from "fmiModelTypes.h" to fmiPlatformTypes.h"
|
||||
for the co-simulation interface
|
||||
- Jan. 4, 2010: Renamed meModelTypes_h to fmiModelTypes_h (by Mauss, QTronic)
|
||||
- Dec. 21, 2009: Changed "me" to "fmi" and "meModel" to "fmiComponent"
|
||||
according to meeting on Dec. 18 (by Martin Otter, DLR)
|
||||
- Dec. 6, 2009: Added meUndefinedValueReference (by Martin Otter, DLR)
|
||||
- Sept. 9, 2009: Changes according to FMI-meeting on July 21:
|
||||
Changed "version" to "platform", "standard" to "standard32",
|
||||
Added a precise definition of "standard32" as comment
|
||||
(by Martin Otter, DLR)
|
||||
- July 19, 2009: Added "me" as prefix to file names, added meTrue/meFalse,
|
||||
and changed meValueReferenced from int to unsigned int
|
||||
(by Martin Otter, DLR).
|
||||
- March 2, 2009: Moved enums and function pointer definitions to
|
||||
ModelFunctions.h (by Martin Otter, DLR).
|
||||
- Dec. 3, 2008 : First version by Martin Otter (DLR) and
|
||||
Hans Olsson (Dynasim).
|
||||
|
||||
|
||||
Copyright (C) 2008-2011 MODELISAR consortium,
|
||||
2012-2019 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
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
- 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.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* Platform (unique identification of this header file) */
|
||||
#define fmi2TypesPlatform "default"
|
||||
|
||||
/* Type definitions of variables passed as arguments
|
||||
Version "default" means:
|
||||
|
||||
fmi2Component : an opaque object pointer
|
||||
fmi2ComponentEnvironment: an opaque object pointer
|
||||
fmi2FMUstate : an opaque object pointer
|
||||
fmi2ValueReference : handle to the value of a variable
|
||||
fmi2Real : double precision floating-point data type
|
||||
fmi2Integer : basic signed integer data type
|
||||
fmi2Boolean : basic signed integer data type
|
||||
fmi2Char : character data type
|
||||
fmi2String : a pointer to a vector of fmi2Char characters
|
||||
('\0' terminated, UTF8 encoded)
|
||||
fmi2Byte : smallest addressable unit of the machine, typically one byte.
|
||||
*/
|
||||
typedef void* fmi2Component; /* Pointer to FMU instance */
|
||||
typedef void* fmi2ComponentEnvironment; /* Pointer to FMU environment */
|
||||
typedef void* fmi2FMUstate; /* Pointer to internal FMU state */
|
||||
typedef unsigned int fmi2ValueReference;
|
||||
typedef double fmi2Real ;
|
||||
typedef int fmi2Integer;
|
||||
typedef int fmi2Boolean;
|
||||
typedef char fmi2Char;
|
||||
typedef const fmi2Char* fmi2String;
|
||||
typedef char fmi2Byte;
|
||||
|
||||
/* Values for fmi2Boolean */
|
||||
#define fmi2True 1
|
||||
#define fmi2False 0
|
||||
|
||||
|
||||
#endif /* fmi2TypesPlatform_h */
|
||||
|
||||
254
examples/door_demo_example/fmu_Doors4ExampleFMU/include/model.h
Normal file
254
examples/door_demo_example/fmu_Doors4ExampleFMU/include/model.h
Normal file
@@ -0,0 +1,254 @@
|
||||
#pragma once
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if FMI_VERSION != 1 && FMI_VERSION != 2 && FMI_VERSION != 3
|
||||
#error FMI_VERSION must be one of 1, 2 or 3
|
||||
#endif
|
||||
|
||||
#define UNUSED(x) (void)(x)
|
||||
|
||||
#include <stddef.h> // for size_t
|
||||
#include <stdbool.h> // for bool
|
||||
#include <stdint.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if FMI_VERSION == 1
|
||||
|
||||
#define not_modelError (Instantiated| Initialized | Terminated)
|
||||
|
||||
typedef enum {
|
||||
Instantiated = 1 << 0,
|
||||
Initialized = 1 << 1,
|
||||
Terminated = 1 << 2,
|
||||
modelError = 1 << 3
|
||||
} ModelState;
|
||||
|
||||
#elif FMI_VERSION == 2
|
||||
|
||||
typedef enum {
|
||||
StartAndEnd = 1 << 0,
|
||||
Instantiated = 1 << 1,
|
||||
InitializationMode = 1 << 2,
|
||||
|
||||
// ME states
|
||||
EventMode = 1 << 3,
|
||||
ContinuousTimeMode = 1 << 4,
|
||||
|
||||
// CS states
|
||||
StepComplete = 1 << 5,
|
||||
StepInProgress = 1 << 6,
|
||||
StepFailed = 1 << 7,
|
||||
StepCanceled = 1 << 8,
|
||||
|
||||
Terminated = 1 << 9,
|
||||
modelError = 1 << 10,
|
||||
modelFatal = 1 << 11,
|
||||
} ModelState;
|
||||
|
||||
#else
|
||||
|
||||
typedef enum {
|
||||
StartAndEnd = 1 << 0,
|
||||
ConfigurationMode = 1 << 1,
|
||||
Instantiated = 1 << 2,
|
||||
InitializationMode = 1 << 3,
|
||||
EventMode = 1 << 4,
|
||||
ContinuousTimeMode = 1 << 5,
|
||||
StepMode = 1 << 6,
|
||||
ClockActivationMode = 1 << 7,
|
||||
StepDiscarded = 1 << 8,
|
||||
ReconfigurationMode = 1 << 9,
|
||||
IntermediateUpdateMode = 1 << 10,
|
||||
Terminated = 1 << 11,
|
||||
modelError = 1 << 12,
|
||||
modelFatal = 1 << 13,
|
||||
} ModelState;
|
||||
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
ModelExchange,
|
||||
CoSimulation,
|
||||
ScheduledExecution,
|
||||
} InterfaceType;
|
||||
|
||||
typedef enum {
|
||||
OK,
|
||||
Warning,
|
||||
Discard,
|
||||
Error,
|
||||
Fatal,
|
||||
Pending
|
||||
} Status;
|
||||
|
||||
#if FMI_VERSION < 3
|
||||
typedef void (*loggerType) (void* componentEnvironment, const char* instanceName, int status, const char* category, const char* message, ...);
|
||||
#else
|
||||
typedef void (*loggerType) (void* componentEnvironment, int status, const char* category, const char* message);
|
||||
#endif
|
||||
|
||||
typedef void (*lockPreemptionType) (void);
|
||||
typedef void (*unlockPreemptionType) (void);
|
||||
|
||||
|
||||
typedef void (*intermediateUpdateType) (void* instanceEnvironment,
|
||||
double intermediateUpdateTime,
|
||||
bool intermediateVariableSetRequested,
|
||||
bool intermediateVariableGetAllowed,
|
||||
bool intermediateStepFinished,
|
||||
bool canReturnEarly,
|
||||
bool* earlyReturnRequested,
|
||||
double* earlyReturnTime);
|
||||
|
||||
typedef void(*clockUpdateType) (void* instanceEnvironment);
|
||||
|
||||
typedef struct {
|
||||
|
||||
double startTime;
|
||||
double stopTime;
|
||||
double time;
|
||||
const char* instanceName;
|
||||
InterfaceType type;
|
||||
const char* resourceLocation;
|
||||
|
||||
Status status;
|
||||
|
||||
// callback functions
|
||||
loggerType logger;
|
||||
intermediateUpdateType intermediateUpdate;
|
||||
clockUpdateType clockUpdate;
|
||||
|
||||
lockPreemptionType lockPreemtion;
|
||||
unlockPreemptionType unlockPreemtion;
|
||||
|
||||
bool logEvents;
|
||||
bool logErrors;
|
||||
|
||||
void* componentEnvironment;
|
||||
ModelState state;
|
||||
|
||||
// event info
|
||||
bool newDiscreteStatesNeeded;
|
||||
bool terminateSimulation;
|
||||
bool nominalsOfContinuousStatesChanged;
|
||||
bool valuesOfContinuousStatesChanged;
|
||||
bool nextEventTimeDefined;
|
||||
double nextEventTime;
|
||||
bool clocksTicked;
|
||||
|
||||
bool isDirtyValues;
|
||||
|
||||
ModelData modelData;
|
||||
|
||||
#if NZ > 0
|
||||
// event indicators
|
||||
double z[NZ];
|
||||
#endif
|
||||
|
||||
// internal solver steps
|
||||
uint64_t nSteps;
|
||||
|
||||
// Co-Simulation
|
||||
bool earlyReturnAllowed;
|
||||
bool eventModeUsed;
|
||||
|
||||
} ModelInstance;
|
||||
|
||||
ModelInstance* createModelInstance(
|
||||
loggerType logger,
|
||||
intermediateUpdateType intermediateUpdate,
|
||||
void* componentEnvironment,
|
||||
const char* instanceName,
|
||||
const char* instantiationToken,
|
||||
const char* resourceLocation,
|
||||
bool loggingOn,
|
||||
InterfaceType interfaceType);
|
||||
|
||||
void freeModelInstance(ModelInstance* comp);
|
||||
|
||||
void reset(ModelInstance* comp);
|
||||
|
||||
|
||||
bool setStartValues(ModelInstance* comp);
|
||||
|
||||
Status calculateValues(ModelInstance* comp);
|
||||
|
||||
Status getFloat32(ModelInstance* comp, ValueReference vr, float values[], size_t nValues, size_t* index);
|
||||
Status getFloat64(ModelInstance* comp, ValueReference vr, double values[], size_t nValues, size_t* index);
|
||||
Status getInt8(ModelInstance* comp, ValueReference vr, int8_t values[], size_t nValues, size_t* index);
|
||||
Status getUInt8(ModelInstance* comp, ValueReference vr, uint8_t values[], size_t nValues, size_t* index);
|
||||
Status getInt16(ModelInstance* comp, ValueReference vr, int16_t values[], size_t nValues, size_t* index);
|
||||
Status getUInt16(ModelInstance* comp, ValueReference vr, uint16_t values[], size_t nValues, size_t* index);
|
||||
Status getInt32(ModelInstance* comp, ValueReference vr, int32_t values[], size_t nValues, size_t* index);
|
||||
Status getUInt32(ModelInstance* comp, ValueReference vr, uint32_t values[], size_t nValues, size_t* index);
|
||||
Status getInt64(ModelInstance* comp, ValueReference vr, int64_t values[], size_t nValues, size_t* index);
|
||||
Status getUInt64(ModelInstance* comp, ValueReference vr, uint64_t values[], size_t nValues, size_t* index);
|
||||
Status getBoolean(ModelInstance* comp, ValueReference vr, bool values[], size_t nValues, size_t* index);
|
||||
Status getString(ModelInstance* comp, ValueReference vr, const char* values[], size_t nValues, size_t* index);
|
||||
Status getBinary(ModelInstance* comp, ValueReference vr, size_t sizes[], const char* values[], size_t nValues, size_t* index);
|
||||
|
||||
Status setFloat32(ModelInstance* comp, ValueReference vr, const float values[], size_t nValues, size_t* index);
|
||||
Status setFloat64(ModelInstance* comp, ValueReference vr, const double values[], size_t nValues, size_t* index);
|
||||
Status setInt8(ModelInstance* comp, ValueReference vr, const int8_t values[], size_t nValues, size_t* index);
|
||||
Status setUInt8(ModelInstance* comp, ValueReference vr, const uint8_t values[], size_t nValues, size_t* index);
|
||||
Status setInt16(ModelInstance* comp, ValueReference vr, const int16_t values[], size_t nValues, size_t* index);
|
||||
Status setUInt16(ModelInstance* comp, ValueReference vr, const uint16_t values[], size_t nValues, size_t* index);
|
||||
Status setInt32(ModelInstance* comp, ValueReference vr, const int32_t values[], size_t nValues, size_t* index);
|
||||
Status setUInt32(ModelInstance* comp, ValueReference vr, const uint32_t values[], size_t nValues, size_t* index);
|
||||
Status setInt64(ModelInstance* comp, ValueReference vr, const int64_t values[], size_t nValues, size_t* index);
|
||||
Status setUInt64(ModelInstance* comp, ValueReference vr, const uint64_t values[], size_t nValues, size_t* index);
|
||||
Status setBoolean(ModelInstance* comp, ValueReference vr, const bool values[], size_t nValues, size_t* index);
|
||||
Status setString(ModelInstance* comp, ValueReference vr, const char* const values[], size_t nValues, size_t* index);
|
||||
Status setBinary(ModelInstance* comp, ValueReference vr, const size_t sizes[], const char* const values[], size_t nValues, size_t* index);
|
||||
|
||||
Status activateClock(ModelInstance* comp, ValueReference vr);
|
||||
Status getClock(ModelInstance* comp, ValueReference vr, bool* value);
|
||||
Status setClock(ModelInstance* comp, ValueReference vr, const bool* value);
|
||||
|
||||
Status getInterval(ModelInstance* comp, ValueReference vr, double* interval, int* qualifier);
|
||||
|
||||
Status activateModelPartition(ModelInstance* comp, ValueReference vr, double activationTime);
|
||||
|
||||
void getContinuousStates(ModelInstance* comp, double x[], size_t nx);
|
||||
void setContinuousStates(ModelInstance* comp, const double x[], size_t nx);
|
||||
void getDerivatives(ModelInstance* comp, double dx[], size_t nx);
|
||||
Status getOutputDerivative(ModelInstance* comp, ValueReference valueReference, int order, double* value);
|
||||
Status getPartialDerivative(ModelInstance* comp, ValueReference unknown, ValueReference known, double* partialDerivative);
|
||||
void getEventIndicators(ModelInstance* comp, double z[], size_t nz);
|
||||
void eventUpdate(ModelInstance* comp);
|
||||
//void updateEventTime(ModelInstance *comp);
|
||||
|
||||
bool invalidNumber(ModelInstance* comp, const char* f, const char* arg, size_t actual, size_t expected);
|
||||
bool invalidState(ModelInstance* comp, const char* f, int statesExpected);
|
||||
bool nullPointer(ModelInstance* comp, const char* f, const char* arg, const void* p);
|
||||
void logError(ModelInstance* comp, const char* message, ...);
|
||||
Status setDebugLogging(ModelInstance* comp, bool loggingOn, size_t nCategories, const char* const categories[]);
|
||||
void logEvent(ModelInstance* comp, const char* message, ...);
|
||||
void logError(ModelInstance* comp, const char* message, ...);
|
||||
|
||||
void* getFMUState(ModelInstance* comp);
|
||||
void setFMUState(ModelInstance* comp, void* FMUState);
|
||||
|
||||
// shorthand to access the variables
|
||||
#define M(v) (comp->modelData.v)
|
||||
|
||||
// "stringification" macros
|
||||
#define xstr(s) str(s)
|
||||
#define str(s) #s
|
||||
|
||||
// assert size of nValues for scalar variables
|
||||
#define ASSERT_NVALUES(N) do { \
|
||||
if (*index + (N) > nValues) { \
|
||||
logError(comp, "Expected nValues > %zu but was %zu.", *index, nValues); \
|
||||
return Error; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // end of extern "C"
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user