Skip to content

Commit

Permalink
Read model structure for FMI 3
Browse files Browse the repository at this point in the history
  • Loading branch information
robbr48 committed Feb 18, 2022
1 parent f520433 commit 8222df5
Show file tree
Hide file tree
Showing 5 changed files with 440 additions and 2 deletions.
61 changes: 61 additions & 0 deletions include/fmi4c.h
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,67 @@ FMIC_DLLEXPORT void fmi3GetClockType(fmiHandle *fmu,
FMIC_DLLEXPORT int fmi3GetNumberOfLogCategories(fmiHandle *fmu);
FMIC_DLLEXPORT void fmi3GetLogCategory(fmiHandle *fmu, int id, const char **name, const char **description);

FMIC_DLLEXPORT int fmi3GetNumberOfModelStructureOutputs(fmiHandle *fmu);
FMIC_DLLEXPORT void fmi3GetModelStructureOutput(fmiHandle *fmu,
int id,
fmi3ValueReference *vr,
int *numberOfDependencies,
bool *dependencyKindsDefined);
FMIC_DLLEXPORT fmi3ValueReference fmi3GetModelStructureOutputDependency(fmiHandle *fmu,
int outputId,
int dependencyId);
FMIC_DLLEXPORT fmi3ValueReference fmi3GetModelStructureOutputDependencyKind(fmiHandle *fmu,
int outputId,
int dependencyId);
FMIC_DLLEXPORT int fmi3GetNumberOfModelStructureContinuousStateDerivatives(fmiHandle *fmu);
FMIC_DLLEXPORT void fmi3GetModelStructureContinuousStateDerivative(fmiHandle *fmu,
int id,
fmi3ValueReference *vr,
int *numberOfDependencies,
bool *dependencyKindsDefined);
FMIC_DLLEXPORT fmi3ValueReference fmi3GetModelStructureContinuousStateDerivativeDependency(fmiHandle *fmu,
int derId,
int dependencyId);
FMIC_DLLEXPORT fmi3ValueReference fmi3GetModelStructureContinuousStateDerivativeDependencyKind(fmiHandle *fmu,
int derId,
int dependencyId);
FMIC_DLLEXPORT int fmi3GetNumberOfModelStructureClockedStates(fmiHandle *fmu);
FMIC_DLLEXPORT void fmi3GetModelStructureClockedState(fmiHandle *fmu,
int id,
fmi3ValueReference *vr,
int *numberOfDependencies,
bool *dependencyKindsDefined);
FMIC_DLLEXPORT fmi3ValueReference fmi3GetModelStructureClockedStateDependency(fmiHandle *fmu,
int clockId,
int dependencyId);
FMIC_DLLEXPORT fmi3ValueReference fmi3GetModelStructureClockedStateDependencyKind(fmiHandle *fmu,
int clockId,
int dependencyId);
FMIC_DLLEXPORT int fmi3GetNumberOfModelStructureInitialUnknowns(fmiHandle *fmu);
FMIC_DLLEXPORT void fmi3GetModelStructureInitialUnknown(fmiHandle *fmu,
int id,
fmi3ValueReference *vr,
int *numberOfDependencies,
bool *dependencyKindsDefined);
FMIC_DLLEXPORT fmi3ValueReference fmi3GetModelStructureInitialUnknownDependency(fmiHandle *fmu,
int unknownId,
int dependencyId);
FMIC_DLLEXPORT fmi3ValueReference fmi3ModelStructureGetInitialUnknownDependencyKind(fmiHandle *fmu,
int unknownId,
int dependencyId);
FMIC_DLLEXPORT int fmi3GetNumberOfModelStructureEventIndicators(fmiHandle *fmu);
FMIC_DLLEXPORT void fmi3GetModelStructureEventIndicator(fmiHandle *fmu,
int id,
fmi3ValueReference *vr,
int *numberOfDependencies,
bool *dependencyKindsDefined);
FMIC_DLLEXPORT fmi3ValueReference fmi3GetModelStructureEventIndicatorDependency(fmiHandle *fmu,
int indicatorId,
int dependencyId);
FMIC_DLLEXPORT fmi3ValueReference fmi3GetModelStructureEventIndicatorDependencyKind(fmiHandle *fmu,
int indicatorId,
int dependencyId);

FMIC_DLLEXPORT const char* fmi3GetModelIdentifier(fmiHandle* fmu);
FMIC_DLLEXPORT bool fmi3GetNeedsExecutionTool(fmiHandle* fmu);
FMIC_DLLEXPORT bool fmi3GetCanBeInstantiatedOnlyOncePerProcess(fmiHandle* fmu);
Expand Down
19 changes: 19 additions & 0 deletions include/fmi4c_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,14 @@ typedef struct {
const char* description;
} fmi3LogCategory;

typedef struct {
fmi3ValueReference valueReference;
int numberOfDependencies;
bool dependencyKindsDefined;
fmi3ValueReference *dependencies;
fmi3DependencyKind *dependencyKinds;
} fmi3ModelStructureElement;

typedef struct {
bool supportsModelExchange;
bool supportsCoSimulation;
Expand Down Expand Up @@ -674,6 +682,17 @@ typedef struct {

int numberOfLogCategories;
fmi3LogCategory *logCategories;

int numberOfOutputs;
int numberOfContinuousStateDerivatives;
int numberOfClockedStates;
int numberOfInitialUnknowns;
int numberOfEventIndicators;
fmi3ModelStructureElement *outputs;
fmi3ModelStructureElement *continuousStateDerivatives;
fmi3ModelStructureElement *clockedStates;
fmi3ModelStructureElement *initialUnknowns;
fmi3ModelStructureElement *eventIndicators;
} fmi3Data_t;


Expand Down
3 changes: 3 additions & 0 deletions include/fmi4c_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <stdbool.h>
#include <stdint.h>
#include "3rdparty/ezxml/ezxml.h"
#include "fmi4c_private.h"

const char* getFunctionName(const char* modelName, const char* functionName);

Expand All @@ -20,4 +21,6 @@ bool parseUInt32AttributeEzXml(ezxml_t element, const char* attributeName, uint3
bool parseUInt16AttributeEzXml(ezxml_t element, const char *attributeName, uint16_t* target);
bool parseUInt8AttributeEzXml(ezxml_t element, const char *attributeName, uint8_t *target);

bool parseModelStructureElement(fmi3ModelStructureElement *output, ezxml_t *element);

#endif // FMIC_UTILS_H
Loading

0 comments on commit 8222df5

Please sign in to comment.