From a7504c01571b6b26baf72d0de8a4bcfb9f4902fd Mon Sep 17 00:00:00 2001 From: Torsten Sommer Date: Mon, 2 Dec 2024 09:16:45 +0100 Subject: [PATCH 1/4] Fix comment for eventEncountered in FMI3CSSimulation.c --- fmusim/FMI3CSSimulation.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fmusim/FMI3CSSimulation.c b/fmusim/FMI3CSSimulation.c index 152908a8..1aba4e4b 100644 --- a/fmusim/FMI3CSSimulation.c +++ b/fmusim/FMI3CSSimulation.c @@ -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 From 1412c77ee147fe3824725480abd5ee8bda3f5335 Mon Sep 17 00:00:00 2001 From: Torsten Sommer Date: Tue, 3 Dec 2024 12:33:27 +0100 Subject: [PATCH 2/4] Don't set inactive Clocks fixes #630 --- fmusim/FMIStaticInput.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fmusim/FMIStaticInput.c b/fmusim/FMIStaticInput.c index f1cd250c..e475357b 100644 --- a/fmusim/FMIStaticInput.c +++ b/fmusim/FMIStaticInput.c @@ -296,8 +296,14 @@ 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 && !*((bool*)values)) { + continue; // don't set inactive clocks + } + CALL(FMISetValues(instance, type, &vr, 1, NULL, values, nValues)); } } From af92424559b9ae770fde0ed39e66949f672da7cf Mon Sep 17 00:00:00 2001 From: Torsten Sommer Date: Tue, 3 Dec 2024 12:41:55 +0100 Subject: [PATCH 3/4] Don't set Clocks in Initialization Mode fixes #629 --- fmusim/FMIStaticInput.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/fmusim/FMIStaticInput.c b/fmusim/FMIStaticInput.c index e475357b..b2d1080d 100644 --- a/fmusim/FMIStaticInput.c +++ b/fmusim/FMIStaticInput.c @@ -300,8 +300,16 @@ FMIStatus FMIApplyInput(FMIInstance* instance, const FMIStaticInput* input, doub continue; } - if (variable->type == FMIClockType && !*((bool*)values)) { - continue; // don't set inactive clocks + 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)); From a3a9e172543a6b4ca1eb18db401bfae35b5b5422 Mon Sep 17 00:00:00 2001 From: Torsten Sommer Date: Tue, 3 Dec 2024 16:42:55 +0100 Subject: [PATCH 4/4] Skip clocks in FMISample() fixes #628 --- fmusim/FMIRecorder.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fmusim/FMIRecorder.c b/fmusim/FMIRecorder.c index 267ef1cf..98da1fb0 100644 --- a/fmusim/FMIRecorder.c +++ b/fmusim/FMIRecorder.c @@ -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) {