Skip to content

Commit

Permalink
Add API functions for getting start values of all variable types
Browse files Browse the repository at this point in the history
  • Loading branch information
robbr48 committed Mar 29, 2022
1 parent 8222df5 commit 5ff22a1
Show file tree
Hide file tree
Showing 2 changed files with 138 additions and 0 deletions.
18 changes: 18 additions & 0 deletions include/fmi4c.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
120 changes: 120 additions & 0 deletions src/fmi4c.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5ff22a1

Please sign in to comment.