Is there a way to send a message directly to the current agent performing an action? For example, I want to use a wait for message transition to stop my agent in populations forklifts from progressing prior to leaving a certain block. In this case I would like the forklifts to progress to a service block and wait in the queue. Once they leave the queue, I want to send a message to the agent to let them know it's OK to progress to the next state. In this instance the agent would leave the service block, go through the exit block, and the next state would pick the agent up with main.enter1.take(this); and move the agent to a sink.
I cannot figure out any way to send the message to the correct agent. Does it make a difference if I send the message to any agent in the population, or does it have to be the agent that is currently leaving the block and in the state chart? Here is how I picture the situation.
Alternately perhaps it is OK to send the message to any random agent in the population? I am not sure if the current agent has to be the one receiving the message. Keep in mind I only want the current agent to react to the message at the time of leaving the block
Picture of Sending Message to Random Agent in Population.
I have tried sending a message to the current agent by writing in the On exit field of the service block the following code:
send("I'm Ready", agent);
But the agent does not advance states as expected. Elsewhere I have in an On enter field:
Forklift fl=findFirst(forklifts,f->f.inState(f.idle));
if(fl!=null){
send(agent,fl);
}
This code does successfully send a message to the state chart, but I again, I don't feel like I have a need for the findFirst function here.
Could the issue be that I simply need to add a line somewhere in my state chart with the fireEvent function?
Update: SOLVED
I have figured it out! To access the forklift agent I used the following code successfully:
Forklift fa=agent.flLink.getConnectedAgent();
send("Go", fa);
traceln("Message Sent");
I will leave this post up to help others that might have the same question.
Update: SOLVED
I have figured it out! To access the forklift agent I used the following code successfully:
Forklift fa=agent.flLink.getConnectedAgent();
send("Go", fa);
traceln("Message Sent");
This is because the agent in the process flow was of type Pallet and the Agent type I was trying to send a message to was of type Forklift; therefore, I was sending a message to the pallet agent and the forklift agent did not see the message. I will leave this post up to help others that might have the same question.