The way it currently works is boards are taken from the combiner and placed onto the entry queue. The purpose of the entry queue is that it holds the boards, which need to be placed on the racks. We can consider the previous to be Step 1.
An ASRS takes a board from the entry queue, one at a time, and places a board onto the testing rack. If a board has been successfully tested, the board's color changes to red. After the board has been tested, it is taken by the same ASRS onto the exit queue.
I'm trying to set up the wanted logic, which is:
If there are boards waiting to be removed from the rack and placed on the exit queue vs. boards on the entry queue waiting to be placed on the rack, we want to prioritize the boards waiting to be removed from the rack and placed on the exit queue.
This is what I have set up right now:
A "Decide" block in FlexSim. The Decide block contains some code that makes it decide which output to go to. There are 2 outputs:
Output 1: A subflow in which the ASRS takes the tested board to the exit queue.
Output 2: A subflow in which the ASRS takes a board from the entry queue into the testing rack.
When the board has been tested, it is assigned a token label of "DoneItem" using a source block after a given dwell time and then placed onto a list called "Pallets in POD".
Output 2 has an arrow pointing back to the "Decide" block creating a loop to constantly make the ASRS evaluate what to do next.
Here's the code I have inside the Decide block:
/** Custom Code */
Object current = param(1);
treenode activity = param(2);
Token token = param(3);
print("Reached the decide block");
// Check if the "DoneItem" label exists on the current token
if (objectexists(getlabel(token, "DoneItem"))) {
print("Tested board token exists, returning connector rank 1"); // Debug statement
return 1; // Assuming the connector leading to the "Move to Exit Queue" subflow is ranked 1
} else {
print("No tested board token exists, returning connector rank 2"); // Debug statement
return 2; // Assuming the connector leading to the "Move to Testing Rack" subflow is ranked 2
}
This works, in that the ASRS is able to retrieve boards from the entry queue and place them onto the testing rack. However, the code never hits the "if" statement, so the ASRS never takes the boards off of the testing rack and places them onto the exit queue. I'm confused, because when I check the items in the "Pallets in POD" list during the simulation period, there are definitely tokens with the label "DoneItem".
Would really appreciate any help.