plate-shuffling-2.fsm
@Thao B
I took your model and modified it a little to get the behavior I think that you want. Before I get into what I did, I want to point out that I made a simplifying assumption that you don't really want the Crane to start picking up plates until all the materials have arrived. I decided to do this because since the arrival schedule had the different Types arriving so close to each other, if I start looking for the right plate as soon as the model starts things have changed enough in terms of the queue's contents that the "wrong" plate is grabbed first.
The approach I took relies on two Lists and a short set of process flow activities. I have a List for the plates that helps me find which plate should be picked up by the Crane, and a List that helps me find a Queue location where the shuffled plates can be stored while the crane works its way down to the right plate. To make this work, you'll notice that I removed the connections from the upstream queues to the downstream queue, because I want to define my own logic in process flow rather than try to make the standard object logic do what I want.
If you look under Toolbox>Global Lists>PlateList you'll see that there are 3 field definitions at the top that are the basis for the search criteria I use for the Crane to find a plate. Type and Grade, are just labels like how you were using them on Queue5. NumberOfMoves is a simple expression to find how close a plate is to the top of the stack, because I'm assuming that what you want is that the Crane move the least number of plates from any given queue to get to the plate that you really want. In the QueuesList the only thing that isn't a default option is under the General tab I add the 4 storage Queues to list as initial content.
In the Process Flow the basic idea is to create a single token that represents the Crane, which reads the materials table and then searches the PlateList for a matching plate. It uses a query that says we want a plate that is the same Type and Grade as what the current table row says, and sorts the plates that match by the number of moves it would take to get to the plate.
If the Matching Plate isn't already on top of the stack, then the Crane moves 1 plate at a time evaluating if the plate we want is on top yet after each move. The token pulls from the QueueList in order to find the Queue with the least number of plates in it so we can store the shuffled plates there. The query for this Pull also includes a filtering clause that excludes the Queue were the plate is currently located.
Once the plate we want is on top of it's stack it is take to Queue5, and this process loops until we've moved every plate from the table.
