question

dcorral avatar image
0 Likes"
dcorral asked dcorral commented

Decide activity based on array value

I need some help in sending tokens to a connection based on if the array contains a certain value.


In the attached model, I have a schedule source for token. They then go through a subflow acquiring the resources they need. Some tokens may only have one resource, some have 2. After acquiring resources, they then go through a decide activity (Decide Array in the model). The decide activity is to find out if the tokens have the resource "x2." If they have the resource, then they have to go through a delay before continuing on. I am having trouble using the "If Array Contains Value" on the decide activity.


Any help would be appreciated. Thanks.

FlexSim 23.2.3
proces flowarraydecide activity
· 2
5 |100000

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

Emily Hardy avatar image Emily Hardy ♦ commented ·

Hi @dcorral,

It's hard to know how to help without looking at your model. To receive a more accurate solution, please post your model or a sample model that demonstrates your question.

If your model contains sensitive information, you could first toggle your post as private using the "make private" option under your question's "gear" menu. Private questions are visible only to site moderators. You can also contact your local FlexSim distributor for phone or email help.

0 Likes 0 ·
dcorral avatar image dcorral Emily Hardy ♦ commented ·

Hi @Emily Hardy and @Felix Möhlmann,

Forgot to attach the model. See attached.

Thanks!

resource loop.fsm

0 Likes 0 ·
resource-loop.fsm (45.9 KiB)

1 Answer

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

The values in the "resource" array will be pointers to the acquired objects. You need a pointer to the "x2" object, for example as a label on the token, to be able to compare the array values to it.

decide-by-array-example.fsm


· 2
5 |100000

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

Felix Möhlmann avatar image Felix Möhlmann commented ·

To check whether any of the acquired resources if part of the "x2" group you can use the following code. The structure is the same as the default "Value In Array" option, just the check in the if-condition is different.

Array array = token.resource?;
Group x2 = Group("x2"); for(int i = 1; i <= array.length; i++) {     if(x2.indexOf(array[i]) > 0)         return 1;     } return 2;

You also need to check if the token actually acquired something before sending it to the Release activity.

resource-loop_1.fsm

0 Likes 0 ·
resource-loop-1.fsm (46.7 KiB)
dcorral avatar image dcorral Felix Möhlmann commented ·
Worked great! thanks!
0 Likes 0 ·