I'm starting to use Anylogic for a simulation class, and for this I need to model the following behaviour: there's a stream of agents that enter a FIFO queue, and then enter into a server (that I modeled with a delay block), one at a time. The agents have two states (call them A and B), and if an agent reaches the end of the queue in state A, it has to wait until it returns to state B to go into the service.
I think a wait block with capacity for one agent, between the queue and the delay block could potentially solve this situation. But I don't know how to make the wait block to free the agent as soon as it changes state.
Other methods are welcome. I just need the agent to be retained before the delay block as long as it is in the state A, but not any longer. Thanks in advance.