Skip to content

Commit 5a4f957

Browse files
authored
Fix event handling w/o early return (#424)
fixes #421 fixes #425 fixes #236
1 parent c7bec6f commit 5a4f957

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/fmi3Functions.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,12 +1341,20 @@ fmi3Status fmi3DoStep(fmi3Instance instance,
13411341

13421342
while (true) {
13431343

1344-
nextCommunicationPointReached = S->time + FIXED_SOLVER_STEP > nextCommunicationPoint;
1344+
const fmi3Float64 nextSolverStepTime = S->time + FIXED_SOLVER_STEP;
1345+
nextCommunicationPointReached = nextSolverStepTime > nextCommunicationPoint;
13451346

1346-
if (nextCommunicationPointReached) {
1347+
if (nextCommunicationPointReached || (*eventHandlingNeeded && S->earlyReturnAllowed)) {
13471348
break;
13481349
}
13491350

1351+
#ifdef EVENT_UPDATE
1352+
if (*eventHandlingNeeded) {
1353+
eventUpdate(S);
1354+
*eventHandlingNeeded = fmi3False;
1355+
}
1356+
#endif
1357+
13501358
bool stateEvent, timeEvent;
13511359

13521360
CALL(doFixedStep(S, &stateEvent, &timeEvent));

0 commit comments

Comments
 (0)