From 5ff22a18de05f1cc12d32ff7cdc04ed216a29530 Mon Sep 17 00:00:00 2001 From: Robert Braun Date: Tue, 29 Mar 2022 16:13:30 +0200 Subject: [PATCH] Add API functions for getting start values of all variable types --- include/fmi4c.h | 18 ++++++++ src/fmi4c.c | 120 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 138 insertions(+) diff --git a/include/fmi4c.h b/include/fmi4c.h index a2caa61..ebc56a5 100644 --- a/include/fmi4c.h +++ b/include/fmi4c.h @@ -61,6 +61,9 @@ FMIC_DLLEXPORT const char* fmi1GetVariableQuantity(fmi1VariableHandle* var); FMIC_DLLEXPORT const char* fmi1GetVariableUnit(fmi1VariableHandle* var); FMIC_DLLEXPORT const char* fmi1GetVariableDisplayUnit(fmi1VariableHandle* var); FMIC_DLLEXPORT fmi1Real fmi1GetVariableStartReal(fmi1VariableHandle* var); +FMIC_DLLEXPORT fmi1Integer fmi1GetVariableStartInteger(fmi1VariableHandle* var); +FMIC_DLLEXPORT fmi1Boolean fmi1GetVariableStartBoolean(fmi1VariableHandle* var); +FMIC_DLLEXPORT fmi1String fmi1GetVariableStartString(fmi1VariableHandle* var); FMIC_DLLEXPORT long fmi1GetVariableValueReference(fmi1VariableHandle* var); FMIC_DLLEXPORT fmi1Causality fmi1GetVariableCausality(fmi1VariableHandle* var); FMIC_DLLEXPORT fmi1Variability fmi1GetVariableVariability(fmi1VariableHandle* var); @@ -134,6 +137,9 @@ FMIC_DLLEXPORT const char* fmi2GetVariableQuantity(fmi2VariableHandle* var); FMIC_DLLEXPORT const char* fmi2GetVariableUnit(fmi2VariableHandle* var); FMIC_DLLEXPORT const char* fmi2GetVariableDisplayUnit(fmi2VariableHandle* var); FMIC_DLLEXPORT fmi2Real fmi2GetVariableStartReal(fmi2VariableHandle* var); +FMIC_DLLEXPORT fmi2Integer fmi2GetVariableStartInteger(fmi2VariableHandle* var); +FMIC_DLLEXPORT fmi2Boolean fmi2GetVariableStartBoolean(fmi2VariableHandle* var); +FMIC_DLLEXPORT fmi2String fmi2GetVariableStartString(fmi2VariableHandle* var); FMIC_DLLEXPORT long fmi2GetVariableValueReference(fmi2VariableHandle* var); FMIC_DLLEXPORT fmi2Causality fmi2GetVariableCausality(fmi2VariableHandle* var); FMIC_DLLEXPORT fmi2Variability fmi2GetVariableVariability(fmi2VariableHandle* var); @@ -270,6 +276,18 @@ FMIC_DLLEXPORT const char *fmi3GetVariableQuantity(fmi3VariableHandle* var); FMIC_DLLEXPORT const char *fmi3GetVariableUnit(fmi3VariableHandle* var); FMIC_DLLEXPORT char *fmi3GetVariableDisplayUnit(fmi3VariableHandle* var); FMIC_DLLEXPORT fmi3Float64 fmi3GetVariableStartFloat64(fmi3VariableHandle* var); +FMIC_DLLEXPORT fmi3Float32 fmi3GetVariableStartFloat32(fmi3VariableHandle *var); +FMIC_DLLEXPORT fmi3Int64 fmi3GetVariableStartInt64(fmi3VariableHandle *var); +FMIC_DLLEXPORT fmi3Int32 fmi3GetVariableStartInt32(fmi3VariableHandle *var); +FMIC_DLLEXPORT fmi3Int16 fmi3GetVariableStartInt16(fmi3VariableHandle *var); +FMIC_DLLEXPORT fmi3Int8 fmi3GetVariableStartInt8(fmi3VariableHandle *var); +FMIC_DLLEXPORT fmi3UInt64 fmi3GetVariableStartUInt64(fmi3VariableHandle *var); +FMIC_DLLEXPORT fmi3UInt32 fmi3GetVariableStartUInt32(fmi3VariableHandle *var); +FMIC_DLLEXPORT fmi3UInt16 fmi3GetVariableStartUInt16(fmi3VariableHandle *var); +FMIC_DLLEXPORT fmi3UInt8 fmi3GetVariableStartUInt8(fmi3VariableHandle *var); +FMIC_DLLEXPORT fmi3Boolean fmi3GetVariableStartBoolean(fmi3VariableHandle *var); +FMIC_DLLEXPORT fmi3String fmi3GetVariableStartString(fmi3VariableHandle *var); +FMIC_DLLEXPORT fmi3Binary fmi3GetVariableStartBinary(fmi3VariableHandle *var); FMIC_DLLEXPORT fmi3ValueReference fmi3GetVariableValueReference(fmi3VariableHandle* var); FMIC_DLLEXPORT const char* fmi3ModelName(fmiHandle *fmu); diff --git a/src/fmi4c.c b/src/fmi4c.c index 3db92b4..ad9a011 100644 --- a/src/fmi4c.c +++ b/src/fmi4c.c @@ -1013,6 +1013,11 @@ bool parseModelDescriptionFmi3(fmiHandle *fmu) if(modelVariablesElement) { for(ezxml_t varElement = modelVariablesElement->child; varElement; varElement = varElement->next) { fmi3VariableHandle var; + var.name = NULL; + var.description = NULL; + var.quantity = NULL; + var.unit = NULL; + var.displayUnit = NULL; var.canHandleMultipleSetPerTimeInstant = false; //Default value if attribute not defined parseStringAttributeEzXml(varElement, "name", &var.name); @@ -2386,6 +2391,84 @@ fmi3Float64 fmi3GetVariableStartFloat64(fmi3VariableHandle *var) return var->startFloat64; } +fmi3Float32 fmi3GetVariableStartFloat32(fmi3VariableHandle *var) +{ + TRACEFUNC + return var->startFloat32; +} + +fmi3Int64 fmi3GetVariableStartInt64(fmi3VariableHandle *var) +{ + TRACEFUNC + return var->startInt64; +} + +fmi3Int32 fmi3GetVariableStartInt32(fmi3VariableHandle *var) +{ + TRACEFUNC + return var->startInt32; +} + +fmi3Int16 fmi3GetVariableStartInt16(fmi3VariableHandle *var) +{ + TRACEFUNC + return var->startInt16; +} + +fmi3Int8 fmi3GetVariableStartInt8(fmi3VariableHandle *var) +{ + TRACEFUNC + return var->startInt8; +} + +fmi3UInt64 fmi3GetVariableStartUInt64(fmi3VariableHandle *var) +{ + TRACEFUNC + return var->startUInt64; +} + +fmi3UInt32 fmi3GetVariableStartUInt32(fmi3VariableHandle *var) +{ + TRACEFUNC + return var->startUInt32; +} + +fmi3UInt16 fmi3GetVariableStartUInt16(fmi3VariableHandle *var) +{ + TRACEFUNC + return var->startUInt16; +} + +fmi3UInt8 fmi3GetVariableStartUInt8(fmi3VariableHandle *var) +{ + TRACEFUNC + return var->startUInt8; +} + +fmi3Boolean fmi3GetVariableStartBoolean(fmi3VariableHandle *var) +{ + TRACEFUNC + return var->startBoolean; +} + +fmi3String fmi3GetVariableStartString(fmi3VariableHandle *var) +{ + TRACEFUNC + return var->startString; +} + +fmi3Binary fmi3GetVariableStartBinary(fmi3VariableHandle *var) +{ + TRACEFUNC + return var->startBinary; +} + +fmi3Boolean fmi3GetVariableStartEnumeration(fmi3VariableHandle *var) +{ + TRACEFUNC + return var->startEnumeration; +} + fmi3ValueReference fmi3GetVariableValueReference(fmi3VariableHandle *var) { TRACEFUNC @@ -2973,6 +3056,25 @@ fmi2Real fmi2GetVariableStartReal(fmi2VariableHandle *var) return var->startReal; } + +fmi2Integer fmi2GetVariableStartInteger(fmi2VariableHandle *var) +{ + TRACEFUNC + return var->startInteger; +} + +fmi2Boolean fmi2GetVariableStartBoolean(fmi2VariableHandle *var) +{ + TRACEFUNC + return var->startBoolean; +} + +fmi2String fmi2GetVariableStartString(fmi2VariableHandle *var) +{ + TRACEFUNC + return var->startString; +} + long fmi2GetVariableValueReference(fmi2VariableHandle *var) { TRACEFUNC @@ -3877,6 +3979,24 @@ fmi1Real fmi1GetVariableStartReal(fmi1VariableHandle *var) return var->startReal; } +fmi1Integer fmi1GetVariableStartInteger(fmi1VariableHandle *var) +{ + TRACEFUNC + return var->startInteger; +} + +fmi1Boolean fmi1GetVariableStartBoolean(fmi1VariableHandle *var) +{ + TRACEFUNC + return var->startBoolean; +} + +fmi1String fmi1GetVariableStartString(fmi1VariableHandle *var) +{ + TRACEFUNC + return var->startString; +} + long fmi1GetVariableValueReference(fmi1VariableHandle *var) { TRACEFUNC