Hello
I have a problem in a model. The general idea is a source2 creating pallets and filling 4 random racks. Then another source1 creating orders (boxes) with a label "NumPallets" which tells the number of pallets (1 minimun or 2 maximum) of the order. This created order goes to a separator in which the boxes are split by the number of pallets (if the number of pallets is 1 it creates 1 box but if it is 2, 2 boxes are created). Then this boxes goes to a queue with an onEntry trigger with this code:
int rnd=0; treenode yourRack1= centerobject(current, 1); treenode yourRack2= centerobject(current, 2); treenode yourRack3= centerobject(current, 3); treenode yourRack4= centerobject(current, 4); rnd=duniform(1,4,0); if (content(yourRack1)>0) { if (rnd==1) { openoutput(yourRack1); closeoutput(yourRack2); closeoutput(yourRack3); closeoutput(yourRack4); } } if (content(yourRack2)>0) { if (rnd==2) { openoutput(yourRack2); closeoutput(yourRack1); closeoutput(yourRack3); closeoutput(yourRack4); } } if (content(yourRack3)>0) { if (rnd==3) { openoutput(yourRack3); closeoutput(yourRack2); closeoutput(yourRack1); closeoutput(yourRack4); } } if (content(yourRack4)>0) { if (rnd==4) { openoutput(yourRack4); closeoutput(yourRack2); closeoutput(yourRack3); closeoutput(yourRack1); } }
The code generates a random number from 1 to 4 and depends on this number is the center port which opens and the others close. On each of the racks there are 2 triggers on exit and on reset which close all ports if the condition is true.
The idea is when a box enters to this queue1, a pallet from the racks have to go out to the queue2. At the end the total number of boxes in queue1 (pallets orders) must be the same of queue2 (real pallets that have to go out).
It happens when the interarrival time of the pallets is like 30 secs (forum-1-ok.fsm) but does not happens when the interarrival tiem of the pallets is like 200 secs or more (forum-2-ng.fsm). Maybe it can be solved by substituting my code with a "round robin if available" code but I really do not understand it.
Can you help me please? I attached the two models. Thank you so much