question

dantasvagner avatar image
0 Likes"
dantasvagner asked Felix Möhlmann answered

Changing multiple label slots at a time

Hello,

I need to simulate the impact of having only one resource (forklift or operator) in an aisle of my warehouse at a time: when an item is identified for picking, the entire aisle should be blocked while the resource travels, loads, and unloads the item; once the task is completed, the aisle should be unblocked and available for further picking.


To implement this, I started with a standard scenario (without any aisle traffic restrictions), where I assigned a slot label called "alleebloquee" (blockedaisle) with a value of 0 to all the racks. I then added two custom scripts to my process flow:

  • Code "Find aisle": After identifying the item to be picked, this code assigns the corresponding aisle label to the token.
  • Code "Block aisle": This code is supposed to change the "alleebloquee" label to 1 for all slots in the same aisle (in that case, token.aisle).

So far, the first custom code, "Find aisle," works as expected. However, the second part, "Block aisle," is not working correctly: the "alleebloquee" labels for all slots in the aisle remain set to 0.


Can anyone help me identify what needs to be fixed in my "Block aisle" code?


Thanks in advance!


Model file: 181224 - Exercice_CIBLE_v1.fsm


Custom code (i) - Find aisle:

cppCopier le code/**Custom Code*/
Object current = param(1);

treenode activity = param(2);

Token token = param(3);

treenode processFlow = ownerobject(activity);

// First, you get the correct StorageItem
Storage.Item StorageItem = Storage.Item(token.pallet);

// From there, you can access the slot where it is stored
Storage.Slot StorageSlot = StorageItem.currentSlot;

// Then get the position of that slot
token.aisle = StorageSlot.aisleID;

Custom code (ii) - Block aisle:

cppCopier le code/**Custom Code*/
Object current = param(1);
treenode activity = param(2);
Token token = param(3);
treenode processFlow = ownerobject(activity);

Array slots = Storage.system.querySlots(""); // Get all slots in the system

for (int n = slots.length; n > 0; n--) 
{
    treenode slot = slots[n - 1]; // Access each slot in the array

    if (slot.aisleID == token.aisle) // Compare the aisle of the slot with that of the token
    {
        // Update the "alleebloquee" label for the slot
        slot.alleebloquee = 1;  // Set to 1 or another value as needed
    }
}
FlexSim 24.0.6
custom codelabel slots
· 1
5 |100000

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

Joerg Vogel avatar image Joerg Vogel commented ·

@dantasvagner, won't it be easier to change the Aisle ID to a value that is not available in your system. You store a default value in a label. Once the aisle gets available you change it to a valid default value back?

0 Likes 0 ·

1 Answer

Felix Möhlmann avatar image
0 Likes"
Felix Möhlmann answered

You need to cast the slot as the correct class (Storage.Slot). If it's a treenode the compiler thinks that "aisleID" is supposed to be a label.

With that said, you can already limit the query result to only slots from that aisle. That makes the check obsolete anyway.

Array slots = Storage.system.querySlots("WHERE slot.aisleID == $1", 0, token.aisle); // Obtenir les slots du système
for (int n = slots.length; n > 0; n--) {     Storage.Slot slot = slots[n]; // Accéder à chaque slot du tableau     slot.alleebloquee = 1;  // Vous pouvez définir 1 ou une autre valeur selon votre besoin }

181224-exercice-cible-v1_1.fsm


5 |100000

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