Load non-group items

Load non-group items

oscar_c13
Not applicable
231 Views
5 Replies
Message 1 of 6

Load non-group items

oscar_c13
Not applicable

[ FlexSim 21.2.1 ]

Hello,
My question is related to https://answers.flexsim.com/questions/110158/load-all-items-from-queue.html

Imagine that you want to take all the elements of the queue, but removing those items that belong a group or a table. That it, in the attached model i want to take all the items except "tubo" and "tubo2". but whithout indicating that they are the ones that I don´t want to take exactly.
I would like to tell the program to take those items that don´t belong to the group "x" or those that don´t appear in the table "x" or that don´t belong to a list. I don´t know which is the best method.
I have explained?

I want to do this because in my model what is going to be in queue will depend on other factors. So I want to be able to make distinction between what I am interested in getting and what I am not.

lavar-1.fsm

0 Likes
Accepted solutions (1)
232 Views
5 Replies
Replies (5)
Message 2 of 6

moehlmann_fe
Advocate
Advocate
Accepted solution

All three suggestions are possible (List, Group, Table). The group is probably the least suited. since it's normally used as a fixed collection object, there are no pre-defined options to add and remove members and you'd have to use custom code to do that.

Lists would be the best in my opinion, since removing a row with a specific entry requires some custom code as well. (Table.deleteRow() with the command to find a row by key (see further below) as argument)

If you use a list, you'd "try" to pull the specific item from it, by referencing it in the query field of a "Pull from List" activity. Checking "Leave Entries On List" means the item will remain on the list, so it can be found by further attempts as well. Finally, activating the "Use Max Wait Timer" option allows the token to leave the activity through a different connector if it couldn't pull the item successfully.

For groups and tables you'd use a "Decide" activity set to conditional decide with the following commands.

Group:

Group("Groupname").isMember(Object)

Table:

Table("Tablename").getRowByKey(Object, col)  
// "col" is column in which the object reference would be written

All three options are demonstrated in the attached model.

lavar-1.1.fsm

0 Likes
Message 3 of 6

oscar_c13
Not applicable

Thanks, but I have doubts

I don´t understand how the list works in this case. I think what it does is look to see if the item is in the list. I it is, it does not take ir and if it is does take it. But, why does it do that?

1634813108304.png

In query you look for token.item, but in the push to list you didn´t put token.item

0 Likes
Message 4 of 6

moehlmann_fe
Advocate
Advocate

In the "On Wait Timer Fired" I release the token to connector 2, which leads into the "Load" activity. If the item could be found on the list, the wait timer wouldn't fire and the token instead gets released through the connector of rank 1, bypassing the loading.

1634815262062.png

"token.item" references a specific item in the queue. The label gets assigned in the "Run Sub Flow" activity. Instead of running the tokens one at a time and always taking the first item in the queue, they are now created all at once. Each one is assigned a different item in the queue via the "creationRank" parameter, since each item needs to be checked. (I actually posted a model in which the run sub flow is not configured correctly yet, sorry. I'll attach an updated file. The old one will not work if the items that should stay in the queue are not created last.)

In the "Pull from List" I want to check whether that specific item is part of the list, so the query is for the object referenced in "token.item".

lavar-1.2.fsm

0 Likes
Message 5 of 6

oscar_c13
Not applicable

And if the items weren´t created in the queue? but have been brhought there?

Then, you couldn´t use [creationRank]. How would it be done then?

0 Likes
Message 6 of 6

moehlmann_fe
Advocate
Advocate
"creationRank" is connected to the tokens that get created by the "Run Sub Flow" activity, not the items. The first token created by the activity will have a creationRank of 1 and thus be assigned the first item in the queue, the second will have rank 2 and so on.

The method should work regardless of how the items ended up in the queue and list/group/table.

0 Likes