question

Afthab L avatar image
0 Likes"
Afthab L asked Afthab L commented

Divert X Boxes in a row

Hi,

I've created a model where the 30% of the boxes are diverted at the green conveyor. However, I would like the boxes when diverted to divert 3 at a time. I've added a code to the decision point as shown in the image.


1628753249873.png


My code is as follows:


The idea is to see if the label (direction) is for that 30% divert and then make the items behind it all have the same direction using a for loop. However, It doesn't seem to be working.


switch (item.Direction)
{
    case 1:
    {
    for (int index = 1; index <= 3; index++)
{
    item.next.labels[item.Direction].value =1;
        break;
    }
    
break;


    }
    case 2:
    {
        item.Direction=2;
        break;
    }
}

Any help would be appreciated. Thank you

Sorter Divert - 3 in a row.fsm

FlexSim 21.2.0
flexsim 21.2.0sorter
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
0 Likes"
Felix Möhlmann answered Afthab L commented

If you use "item.labels[X].value" to get the value of label, the X is the name (string) of that label. You are passing in the value of the label on the original item.

Also, your code would result in all subsequent items being diverted to direction 1. Once an item with direction == 1 arrives, the trigger will set the next items direction to 1. The trigger for that item will set the direction for the one after and so on.

I'd add a label to the Decision Point that gets increment each time you set the direction of an item in the code. Then add a condition, that the code should only run if that label is zero.

sorter-divert-3-in-a-row_1.fsm

This will result in much more than 30% of items to be diverted, as you overwrite the direction of items that would originally travel to direction 2 but not the other way around.


Just in case that is not wanted, I build a second variant. Here the direction label is not added beforehand. Instead, every 8th item (on average) and the two items after it, are diverted, resulting in seven items going to direction 2 and three to direction 1.

sorter-divert-3-in-a-row_1_alternative.fsm


· 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.

Afthab L avatar image Afthab L commented ·
This works, thank you so much!
0 Likes 0 ·

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.