question

ana.pc2 avatar image
0 Likes"
ana.pc2 asked ana.pc2 edited

Routing Restriction based on 2 labels

Hello everybody,


I am trying to route a item from a queue to a specific combiner(I have 3 combiners - based on values on table). My problem is that the item can only go to the specific combiner if the item has the same labels (SB and B_Type) as the combiner (SB and B_P_Type), if the item is not posible to go to the combiner, the idea will be to skip the item and check another one in the queue until find a match and route that match.

I need both checks statements to move the item. If there is no match, it will stay there and try to find the match in the queue (if the match it is not still there, I guess it will keep checking everytime a new item arrives to the queue).

I am using the code in the queue "Almacen_UA" (on another queues too but once I fix it there, I can manage for the rest)


The code is:

  1. /**Custom Code*/
  2. Object item = param(1);
  3. Object current = ownerobject(c);
  4.  
  5. // Define the "Routes" table.
  6. Variant tableID = "Routes";
  7. Table table = Table(tableID.as(string));
  8.  
  9. // Set the row and column of table row and column to read.
  10. Variant row = item.SB_Type;
  11. Variant col = 3;
  12.  
  13. // Set Destination variable from the table.
  14. string Destination = table[row][col];
  15.  
  16. // Loop through the output ports of current
  17. for(int x=1; x <= current.outObjects.length; x++)
  18. {
  19. // Set DestTo to the object that output port x goes to.
  20. Object DestTo = current.outObjects[x];
  21.  
  22.  
  23. // If they are the same, then return x (output port of processor).
  24. if(Destination == getname(DestTo))
  25. {
  26. if (current.outObjects[x].SB_P_Type == item.SB_Type)
  27. {
  28. if (current.outObjects[x].B_P_Type == item.B_Type)
  29. {
  30. return x;
  31. }
  32. }
  33.  
  34. }
  35. }
  36.  
  37. }


Right now, it is sending everything no matter the label of SB_Type and B_Type (the item label) with SB_P and B_P_Type (the combiner label) -.- so I don't know what I am missing...


I hope it makes sense my problem! Any help is appreciate :D

Thanks,

Ana.

FlexSim 20.1.1
queuecombinerflexsim 20.1.1routelabel logic
initial-bc.fsm (41.3 KiB)
· 4
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
1 Like"
tannerp answered ana.pc2 edited

@Ana PC2,

You can achieve everything from your custom code block using Process Flow, and it's significantly easier to control and visualize what's going on. I'd highly recommend learning Process Flow and practicing the use of lists. These things make up a majority of what experienced FlexSim users use to build models.

That said, I created a simple demo that uses Process Flow to pull items from a list based on two criteria. The first is that the Type of the item has to match the Type of the combiner. The second is that the "AnotherLabel" label on the item must match the combiner's label of the same name. This is highlighted in the image below. The "Puller" is the token, and the token receives the labels in the "Assign Labels" activity also shown in the image below.

pull from list using Process Flow.fsm


· 3
5 |100000

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