Skip to content

Commit

Permalink
Fix event handling w/o early return (#424)
Browse files Browse the repository at this point in the history
fixes #421
fixes #425
fixes #236
  • Loading branch information
PTaeuberDS authored Jan 12, 2024
1 parent c7bec6f commit 5a4f957
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/fmi3Functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -1341,12 +1341,20 @@ fmi3Status fmi3DoStep(fmi3Instance instance,

while (true) {

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

if (nextCommunicationPointReached) {
if (nextCommunicationPointReached || (*eventHandlingNeeded && S->earlyReturnAllowed)) {
break;
}

#ifdef EVENT_UPDATE
if (*eventHandlingNeeded) {
eventUpdate(S);
*eventHandlingNeeded = fmi3False;
}
#endif

bool stateEvent, timeEvent;

CALL(doFixedStep(S, &stateEvent, &timeEvent));
Expand Down

0 comments on commit 5a4f957

Please sign in to comment.