question

mattias avatar image
0 Likes"
mattias asked mattias commented

Stop simulation when battery level reaches zero

Hello!

I have a basic model that I want to stop when either one of the AGVs' battery levels reaches zero. In other words, stop the model run without having to press the red button with the condition mentioned before.

Do you have any tips or tricks to solve that? I have linked the model for reference. AGVs tutorial 4.1-4.4 AGV charging test.fsm

FlexSim 24.1.0
agvstop model run
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

·
Felix Möhlmann avatar image
1 Like"
Felix Möhlmann answered mattias commented

Place an event-triggered source into the AGV Process Flow that listens for the "On AGV Battery Level Change" event and set it to trigger when the battery level reaches/passes 0.

Then use a Custom Code activity to make the created token stop the simulation. Either use the option "End the Model Run" under "Control" (and set "Experimenting Only" to "no"). Or simply type stop() into a code snippet if you don't plan on using this for experimenter runs.

1710950102973.png


1710950102973.png (42.8 KiB)
· 3
5 |100000

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

mattias avatar image mattias commented ·
Hello @Felix Möhlmann!


I get it to work when I use the custom code "stop()". However, it does not work when I try to use the "End the Model Run". Is it because of the "Condition" in the "End the Model Run" or am I missing something? Sidenote, I am going to use experiments in the future where I have to use the condition of stopping the model when an AGV runs out of battery.

Thank you for answering!

0 Likes 0 ·
Felix Möhlmann avatar image Felix Möhlmann mattias commented ·

The condition should be set to true (or any non-zero value). It is important that you use this option. The experimenter will (to my knowledge) ignore the stop() command.

capture1.png

1 Like 1 ·
capture1.png (9.3 KiB)
mattias avatar image mattias Felix Möhlmann commented ·
It works like a charm, thank you!
0 Likes 0 ·

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.