@@ -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
@@ -884,6 +898,12 @@ oms_status_enu_t oms::SystemSC::doStepCVODE(double stopTime)
884898 fmistatus = fmi2_completedIntegratorStep (fmus[i]->getFMU (), fmi2True, &callEventUpdate[i], &terminateSimulation[i]);
885899 if (fmi2OK != fmistatus) return logError_FMUCall (" fmi2_completedIntegratorStep" , fmus[i]);
886900
901+ if (terminateSimulation[i])
902+ {
903+ logInfo (" Simulation terminated by FMU " + std::string (fmus[i]->getFullCref ()) + " at time " + std::to_string (time));
904+ getModel ().setStopTime (time);
905+ }
906+
887907 immediateEvent = immediateEvent || callEventUpdate[i];
888908 }
889909
@@ -923,7 +943,6 @@ oms_status_enu_t oms::SystemSC::doStepCVODE(double stopTime)
923943 {
924944 logInfo (" Simulation terminated by FMU " + std::string (fmus[i]->getFullCref ()) + " at time " + std::to_string (time));
925945 getModel ().setStopTime (time);
926- time = end_time;
927946 }
928947 }
929948
0 commit comments