Search code examples
anylogic

SelectOutput5 is not triggering when condition is true


I want to use SelectOutput5 block in order to differentiate same agents according to machines which they have been assigned. As you can see the images, one of the example of my SelectOutput5 block's condition is;

agent.st2Tezgah == "M117";

However even though st2Tezgah parameter has M117 value in it, it does not trigger and it goes false section.

I check the parameter with traceln(agent.st2Tezgah) as you can see the image, the value is true.

Why SelectOutput5 does not trigger properly?

Flowchart

Code

Traceln

st2Tezgah parameter

DB

Result


Solution

  • Two things:

    1. Always compare strings using .equals("myString"), not ==.
    2. Make sure you do not set the st2Tezgah variable "just before" the SelectOutput5. Try having a delay (with 0 duration) before it and see if it works. If so, you need to learn about the difference of "on exit" and "on at exit" (subtle but important here)