question

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

Need assistance in my custom code

Hi,
I want to move my item in queue 2 or 3 (item that arrive first) into queue 5 when the content in queue 6 is less than 5 and moving item from queue 1 to queue 2/3/4 (in fifo order). But when i try to do that, the crane just moving the item from queue 1 to queue 5 when the content in queue 6 is less than 5.
How do i fix this?

FIFO Model1.fsm

FlexSim 21.2.2
process flowcustom codecrane
fifo-model1.fsm (89.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

·
David Chan avatar image
0 Likes"
David Chan answered Ryan Clark commented
@Andre T6 Not sure this is what you are looking for. Your logic in the if statement need to bracket properly.
if(CurrContent2 < 5){
    token.item.destination = Model.find("Queue5");
}
else 
{
    if(CurrContent < MaxContent)


    {
        token.item.destination = Model.find("Queue4");
    }
    else
    {
    total += 50;
        if (randomnum <= total)
        {
            token.item.destination = Model.find("Queue2");
        }
        else
        {
            token.item.destination = Model.find("Queue3");
        }
    }
}
· 16
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 ·
@David Chan I'm sorry for my late comment.

My custom code almost look like the one you create above, and have the same result, which is taking the item from queue 1 and send it directly to queue 5 when currcontent2<5. But what i want to do is when the currcontent 2<5,an item taken from queue2 or queue3 (because it come first/ fifo order) and send it to queue5 until currcontent2 >5 and after currcontent2 > 5, the item that has been stack in queue1 will be taken to queue4

0 Likes 0 ·
Ryan Clark avatar image Ryan Clark Andre T6 commented ·
Hi @Andre T6,

The problem with this logic is that the only items that use this Custom Code activity are items currently located in Queue1. This doesn't allow you to change that logic to move an item from Queue2 or Queue3 instead.

I would recommend that you rethink your logic on which items you are pulling from the list and set the destination accordingly.

I hope this helps! Let us know if you have further questions!

0 Likes 0 ·
Andre T6 avatar image Andre T6 Ryan Clark commented ·
Thanks I will try changing my process flow
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.