Skip to content

Commit c9077b7

Browse files
Fix some issues related to termination request form FMUs
- Termination requests from completedIntegratorStep were not handled. - Unnecessary change to System::time in event-related termination with CVODE. refs #1515
1 parent 0d9505d commit c9077b7

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/OMSimulatorLib/SystemSC.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,13 @@ oms_status_enu_t oms::SystemSC::doStepEuler(double stopTime)
680680
{
681681
fmistatus = fmi2_completedIntegratorStep(fmus[i]->getFMU(), fmi2True, &callEventUpdate[i], &terminateSimulation[i]);
682682
if (fmi2OK != fmistatus) return logError_FMUCall("fmi2_completedIntegratorStep", fmus[i]);
683+
684+
if(terminateSimulation[i])
685+
{
686+
logInfo("Simulation terminated by FMU " + std::string(fmus[i]->getFullCref()) + " at time " + std::to_string(time));
687+
getModel().setStopTime(time);
688+
terminated = true;
689+
}
683690
}
684691

685692
logDebug("integrate normally to the end time if no events are ahead");
@@ -716,6 +723,13 @@ oms_status_enu_t oms::SystemSC::doStepEuler(double stopTime)
716723
fmistatus = fmi2_completedIntegratorStep(fmus[i]->getFMU(), fmi2True, &callEventUpdate[i], &terminateSimulation[i]);
717724
if (fmi2OK != fmistatus) return logError_FMUCall("fmi2_completedIntegratorStep", fmus[i]);
718725

726+
if(terminateSimulation[i])
727+
{
728+
logInfo("Simulation terminated by FMU " + std::string(fmus[i]->getFullCref()) + " at time " + std::to_string(time));
729+
getModel().setStopTime(time);
730+
terminated = true;
731+
}
732+
719733
fmistatus = fmi2_enterEventMode(fmus[i]->getFMU());
720734
if (fmi2OK != fmistatus) logError_FMUCall("fmi2_enterEventMode", fmus[i]);
721735

@@ -868,6 +882,12 @@ oms_status_enu_t oms::SystemSC::doStepCVODE(double stopTime)
868882
fmistatus = fmi2_completedIntegratorStep(fmus[i]->getFMU(), fmi2True, &callEventUpdate[i], &terminateSimulation[i]);
869883
if (fmi2OK != fmistatus) return logError_FMUCall("fmi2_completedIntegratorStep", fmus[i]);
870884

885+
if (terminateSimulation[i])
886+
{
887+
logInfo("Simulation terminated by FMU " + std::string(fmus[i]->getFullCref()) + " at time " + std::to_string(time));
888+
getModel().setStopTime(time);
889+
}
890+
871891
immediateEvent = immediateEvent || callEventUpdate[i];
872892
}
873893

@@ -907,7 +927,6 @@ oms_status_enu_t oms::SystemSC::doStepCVODE(double stopTime)
907927
{
908928
logInfo("Simulation terminated by FMU " + std::string(fmus[i]->getFullCref()) + " at time " + std::to_string(time));
909929
getModel().setStopTime(time);
910-
time = end_time;
911930
}
912931
}
913932

0 commit comments

Comments
 (0)