question

Alessio Merlo avatar image
0 Likes"
Alessio Merlo asked Phil BoBo answered

endreplication vs OnRunStop trigger

Hi,

I have a simple question: why does the command "endreplication" not execute the model trigger "OnRunStop"? Is there an error in my code?

I attached picture and model with more details.

Thanks for the support.

FlexSim 17.0.0
onrunstopendreplication
endreplication.png (133.1 KiB)
endreplication.fsm (13.7 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

·
Phil BoBo avatar image
3 Likes"
Phil BoBo answered

endreplication() doesn't stop the model. It destroys all the pending events. In the Experimenter, when the simulation has no more events to process, the replication ends. In an interactive model session, if you were to generate an event after calling endreplication(), the simulation engine would process it. The model is still running, but it has no events to process.

OnRunStop also fires when you press the Stop button in the middle of running the model. That trigger fires whenever the model is stopped; not just at the end of a replication. You might want to put your code elsewhere, depending on what your code is doing.

If you want to stop the model in addition to ending the replication, call stop() and endreplication().

Whether that's how it should work could be debated, but that's how it does work currently.

5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.