question

Robert F2 avatar image
0 Likes"
Robert F2 asked tannerp answered

3 conditional output ports

Hi everyone,

I am having trouble making the logic for sending an item to a port based on 3 different conditions.

Condition (1) - Send item to Queue1 as long as Queue1 is empty.

Condition (2) - Send item to Queue2 if Queue1 is not empty.

Condition (3) - Send every 10th item to Queue3.

The send to port strategy I am using is a Conditional Port with added custom logic, but clearly I am not doing this correctly. Can anyone offer tips on how to create this logic?

FlexSim 20.0.0
flexsim 20.0.0conditional portmultiple ports
flexanswers.png (339.3 KiB)
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

·
tannerp avatar image
0 Likes"
tannerp answered tannerp edited

@Robert F2,

The way I understand your logic, I think Condition 3 should take precedence over other two conditions. Right now, however, it is only evaluating for Condition 3 if the other condition is not met. I would re-write the logic like this:

if(Math.fmod(current.stats.output.value, 10) == 0) //If condition 3 is met, Queue3
     return 3;
else if(current.outObjects[1].subnodes.length != 0) //If Queue1 is not empty, Queue2
     return 2;

return 1; //Else Queue1

This means that it first checks to see if the item is the 10th item. If so, it will send it to Queue3. If not, it will evaluate whether Queue1 is empty. If Queue1 is empty, it will send to Queue1. Otherwise, it will send to Queue2.

In summary, it's important that Condition 3 is evaluated first. Then conditions 1 and 2 can be evaluated in whatever order makes the most sense to you.

5 |100000

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

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.