Skip to content

Commit

Permalink
Fix getting and setting of Clocks (#631)
Browse files Browse the repository at this point in the history
fixes #628
fixes #629
fixes #630
  • Loading branch information
t-sommer authored Dec 3, 2024
1 parent 0124e8e commit 155aa0c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 3 additions & 1 deletion fmusim/FMIRecorder.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,9 @@ FMIStatus FMISample(FMIInstance* instance, double time, FMIRecorder* recorder) {

CALL(FMICalloc(&values, info->nValues, FMISizeOfVariableType(type, recorder->instance->fmiMajorVersion)));

CALL(FMIGetValues(recorder->instance, type, info->valueReferences, info->nVariables, row->sizes, values, info->nValues));
if (type != FMIClockType) { // skip clocks
CALL(FMIGetValues(recorder->instance, type, info->valueReferences, info->nVariables, row->sizes, values, info->nValues));
}

if (type == FMIBinaryType) {

Expand Down
16 changes: 15 additions & 1 deletion fmusim/FMIStaticInput.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,22 @@ FMIStatus FMIApplyInput(FMIInstance* instance, const FMIStaticInput* input, doub
const size_t nValues = input->nValues[j];
const void* values = input->values[j];

if (nValues == 0) continue;
if (nValues == 0) {
continue;
}

if (variable->type == FMIClockType) {

if (instance->state == FMIInitializationModeState) {
continue; // don't set clocks in Initialization Mode
}

if (!*((bool*)values)) {
continue; // don't set inactive clocks
}

}

CALL(FMISetValues(instance, type, &vr, 1, NULL, values, nValues));
}
}
Expand Down

0 comments on commit 155aa0c

Please sign in to comment.