Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix getting and setting of Clocks #631

Merged
merged 4 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fmusim/FMI3CSSimulation.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ FMIStatus FMI3CSSimulate(const FMISimulationSettings* s) {
time, // currentCommunicationPoint
stepSize, // communicationStepSize
fmi3True, // noSetFMUStatePriorToCurrentPoint
&eventEncountered, // eventEncountered
&eventEncountered, // eventHandlingNeeded
&terminateSimulation, // terminateSimulation
&earlyReturn, // earlyReturn
&lastSuccessfulTime // lastSuccessfulTime
Expand Down
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