Search code examples
javatimeoutdelayanylogic

Anylogic: How to stop timeout in a delay block with condition?


I have a collection that counts the number of passengers that enter on a boat at the port. The max capacity of the boat is 1750 and it's scheduled to leave the port every 120 minutes, I would like to end the timeout and let the boat leave the port if the boat reaches the max capacity earlier than 120 minutes.

I've used a delay block, but if I choose Type -> "Specified time" I cannot stop the delay and if I choose Type -> "Until stopDelay is called" I cannot set a specific timeout.

Is Delay the right block to use? How can I set the condition above?

Thanks a lot in advance.

Click to see passengers and boat flow


Solution

  • Use a Wait block and manually trigger wait.free(myBoat) when either of the conditions is met. The timeout can be done with an event (or better a Dynamic Event). The other condition is driven from your passengers so they would need to call the free() method.