question

Andre T6 avatar image
0 Likes"
Andre T6 asked Andre T6 commented

FIFO order with custom code and process flow

Hi everyone,
In my model, i want to make my crane to move item from the cluster to Queue2 in FIFO order with custom code in process flow, but it seems like there is something i miss in the code so that the model didn't work properly and the crane didn't move at all. I tried recreate the process flow but the crane still didn't move.

Can someone check where did i go wrong in the model?
FIFO Model.fsm

FlexSim 21.2.2
process flowcustom codecrane
fifo-model.fsm (56.6 KiB)
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

·
Felix Möhlmann avatar image
1 Like"
Felix Möhlmann answered Andre T6 commented

The queues are not set to push the items to the list, so the token can't pull anything from it. Change the "Use Transport" option from using the "STRE" object (which doesn't actually exist in the model as far as I can tell) to pushing the items to the list. This will also automatically write the priority and destination label to the item.

1633328675594.png

The "priority" label written to the item is not capitalized, but the list currently expects it to be. You also don't need an "Expression" field, a simple "Label" field will do. The capitalization of "priority" will also have to be removed from the query in the "Pull from List" activity.

1633328580123.png

In the unload activity the destination is given by "token.destination" (the default value), but the label is actually present on the item, so you have to use "token.item.destination".

Finally, there are some minor errors in your custom code.

- The names of the cluster queues contain a space in front if the number. In the find-commands, this space is missing.
- In line 11 you are trying to get the property "MaxContent2" of one of the queues. This doesn't exist. You surely mean to determine the "MaxContent" as in the line above.

(Note that currently "Queue1" is set to a higher priority than the cluster. I don't know if this is correct.)

fifo-model_1.fsm


1633328580123.png (15.4 KiB)
1633328675594.png (10.2 KiB)
fifo-model-1.fsm (58.0 KiB)
· 6
5 |100000

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

Andre T6 avatar image Andre T6 commented ·

Thanks for your detail explanation. That's really helpful

0 Likes 0 ·
Andre T6 avatar image Andre T6 commented ·

I tried to recreate this model, but why the crane didn't pick up the box from queue1 while queue1 have the higher priority than the other?


0 Likes 0 ·
Felix Möhlmann avatar image Felix Möhlmann Andre T6 commented ·

Hard to tell without looking at your model. Is the query in the "Pull from List" correct (label field added to list, lower case "p" in priority)? Do you get any error messages?

0 Likes 0 ·
Andre T6 avatar image Andre T6 Felix Möhlmann commented ·

I already fix it, and works the same as the one you give above. But when i simulate it for a long time, i notice that after cluster 2 and 4 empty, the crane won't send the box to cluster 1 and 3 after it (cluster 1 and 3 empty) and the entire system didn't in FIFO order anymore.

So I decided to add some code in the custom code.

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


int CurrContent = Model.find("Cluster 1").subnodes.length;
int CurrContent2 = Model.find("Cluster 3").subnodes.length;
int CurrContent3 = Model.find("Cluster 2").subnodes.length;
int CurrContent4 = Model.find("Cluster 4").subnodes.length;
int MaxContent = Model.find("Cluster 1").as(Object).getProperty("MaxContent");
int MaxContent2 = Model.find("Cluster 3").as(Object).getProperty("MaxContent");
int MaxContent3 = Model.find("Cluster 2").as(Object).getProperty("MaxContent");
int MaxContent4 = Model.find("Cluster 4").as(Object).getProperty("MaxContent");
int CurrContent5 = Model.find("Queue3").subnodes.length;
int stream = getstream(activity);
double randomnum = uniform(0.0, 40.0, stream);
double total = 0.0;

if (CurrContent5 < 6 ) {
token.item.destination = Model.find("Queue2");
}
else if(CurrContent < MaxContent){
token.item.destination = Model.find("Cluster 1");
}
else if(CurrContent2 < MaxContent2){
token.item.destination = Model.find("Cluster 3");
}
else if(CurrContent3 < MaxContent3){
token.item.destination = Model.find("Cluster 2");
}
else if(CurrContent4 < MaxContent4){
token.item.destination = Model.find("Cluster 4");
}
else{
total += 20;
if (randomnum <= total){
token.item.destination = Model.find("Cluster 2");
}
else{
token.item.destination = Model.find("Cluster 4");
}
}

But when i try it, seems like it didn't work and the box won't enter the cluster queue after a long time. Which line should i fix in here?

0 Likes 0 ·
Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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