FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
0167 — An FMU does not tell the master that a model asked to stop
ID 0167
Class KNOWN-LIMITATION
Severity 1
Status ready

Models: —

Found: 2026-10-25 implementation of r2-run-status (follow-up of FHSIM-0160)

Ruling (owner, 2026-10-25): a model stop in an FMU reports terminated. FMI 2: fmi2DoStep returns fmi2Discard and fmi2GetBooleanStatus(fmi2Terminated) is true. FMI 3: terminateSimulation = true. A separate later change.

Evidence

FhsimSlaveCoreStep.cpp DoStep: after FHSIM-0160 a model stop ends the engine step early without an exception, so fpSimulate answers true with reached < requested; ThrowIfContextFailed_ finds no recorded exception and the step is reported as a short step (Discard, with the warning "FhSim failed to perform step...").

Effect

A master sees a Discard and may retry the step; the engine does not step further, so the retry reaches the same time. The master is not told that the model wants the simulation to end.

Possible fix

Detect the stop in the DLL context (a flag set where FhSim::Step returns after SimulationStopRequested) and report it through the FMI terminate status in the FMI 2 and FMI 3 wrappers.

Test that would prove it

An FMU of a model that calls Exit; the step answers the terminate status.

Risk

Masters differ in how they treat the terminate status.