Skip to content

Commit

Permalink
Implement {get|set}UInt64() (#126)
Browse files Browse the repository at this point in the history
fixes #125
  • Loading branch information
t-sommer authored Aug 9, 2021
1 parent adfaa5b commit 40c590b
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 8 deletions.
2 changes: 1 addition & 1 deletion LinearTransform/model.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Status setUInt64(ModelInstance* comp, ValueReference vr, const uint64_t *value,
return Error;
}

int v = value[(*index)++];
const uint64_t v = value[(*index)++];

switch (vr) {
case vr_m:
Expand Down
4 changes: 3 additions & 1 deletion include/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,17 @@ void setStartValues(ModelInstance *comp);
void calculateValues(ModelInstance *comp);

Status getFloat64 (ModelInstance* comp, ValueReference vr, double *value, size_t *index);
Status getInt32 (ModelInstance* comp, ValueReference vr, int32_t *value, size_t *index);
Status getUInt16 (ModelInstance* comp, ValueReference vr, uint16_t *value, size_t *index);
Status getInt32 (ModelInstance* comp, ValueReference vr, int32_t *value, size_t *index);
Status getUInt64 (ModelInstance* comp, ValueReference vr, uint64_t *value, size_t *index);
Status getBoolean (ModelInstance* comp, ValueReference vr, bool *value, size_t *index);
Status getString (ModelInstance* comp, ValueReference vr, const char **value, size_t *index);
Status getBinary (ModelInstance* comp, ValueReference vr, size_t size[], const char* value[], size_t *index);

Status setFloat64 (ModelInstance* comp, ValueReference vr, const double *value, size_t *index);
Status setUInt16 (ModelInstance* comp, ValueReference vr, const uint16_t *value, size_t *index);
Status setInt32 (ModelInstance* comp, ValueReference vr, const int32_t *value, size_t *index);
Status setUInt64 (ModelInstance* comp, ValueReference vr, const uint64_t *value, size_t *index);
Status setBoolean (ModelInstance* comp, ValueReference vr, const bool *value, size_t *index);
Status setString (ModelInstance* comp, ValueReference vr, const char* const *value, size_t *index);
Status setBinary (ModelInstance* comp, ValueReference vr, const size_t size[], const char *const value[], size_t *index);
Expand Down
20 changes: 20 additions & 0 deletions src/cosimulation.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,16 @@ Status getInt32(ModelInstance* comp, ValueReference vr, int *value, size_t *inde
}
#endif

#ifndef GET_UINT64
Status getUInt64(ModelInstance* comp, ValueReference vr, uint64_t *value, size_t *index) {
UNUSED(comp)
UNUSED(vr)
UNUSED(value)
UNUSED(index)
return Error;
}
#endif

#ifndef GET_BOOLEAN
Status getBoolean(ModelInstance* comp, ValueReference vr, bool *value, size_t *index) {
UNUSED(comp)
Expand Down Expand Up @@ -321,6 +331,16 @@ Status setInt32(ModelInstance* comp, ValueReference vr, const int *value, size_t
}
#endif

#ifndef SET_UINT64
Status setUInt64(ModelInstance* comp, ValueReference vr, const uint64_t *value, size_t *index) {
UNUSED(comp)
UNUSED(vr)
UNUSED(value)
UNUSED(index)
return Error;
}
#endif

#ifndef SET_BOOLEAN
Status setBoolean(ModelInstance* comp, ValueReference vr, const bool *value, size_t *index) {
UNUSED(comp)
Expand Down
35 changes: 29 additions & 6 deletions src/fmi3Functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -466,9 +466,23 @@ fmi3Status fmi3GetInt64(fmi3Instance instance,
}

fmi3Status fmi3GetUInt64(fmi3Instance instance,
const fmi3ValueReference valueReferences[], size_t nValueReferences,
fmi3UInt64 values[], size_t nValues) {
NOT_IMPLEMENTED
const fmi3ValueReference vr[], size_t nvr,
fmi3UInt64 value[], size_t nValues) {

ASSERT_STATE(GetUInt64)

if (nvr > 0 && nullPointer(S, "fmi3GetUInt64", "valueReferences", vr))
return fmi3Error;

if (nValues > 0 && nullPointer(S, "fmi3GetUInt64", "values", value))
return fmi3Error;

if (nvr > 0 && S->isDirtyValues) {
calculateValues(S);
S->isDirtyValues = false;
}

GET_VARIABLES(UInt64)
}

fmi3Status fmi3GetBoolean(fmi3Instance instance, const fmi3ValueReference vr[], size_t nvr, fmi3Boolean value[], size_t nValues) {
Expand Down Expand Up @@ -594,9 +608,18 @@ fmi3Status fmi3SetInt64(fmi3Instance instance,
}

fmi3Status fmi3SetUInt64(fmi3Instance instance,
const fmi3ValueReference valueReferences[], size_t nValueReferences,
const fmi3UInt64 values[], size_t nValues) {
NOT_IMPLEMENTED
const fmi3ValueReference vr[], size_t nvr,
const fmi3UInt64 value[], size_t nValues) {

ASSERT_STATE(SetUInt64)

if (nvr > 0 && nullPointer(S, "fmi3SetUInt64", "vr[]", vr))
return fmi3Error;

if (nvr > 0 && nullPointer(S, "fmi3SetUInt64", "value[]", value))
return fmi3Error;

SET_VARIABLES(UInt64)
}

fmi3Status fmi3SetBoolean(fmi3Instance instance, const fmi3ValueReference vr[], size_t nvr, const fmi3Boolean value[], size_t nValues) {
Expand Down

0 comments on commit 40c590b

Please sign in to comment.