question

Roel VDB avatar image
0 Likes"
Roel VDB asked Matthew Gillespie edited

Decision based on content Queue

Hello,

I'm trying to figure out how to take a decision (using Process Flow), based on the content of a Queue.

Situation:

In the attached model the operator has a specified task sequence to:

- check if Queue2, connected to the processor, is empty, if this is the case an item is generated in Queue1 and this has to be transported to Queue2 by the operator. Same for Queue3 and 4: if Queue3 contains an item, this has to be transported to Queue4. In case there is no item in Queue3 the operator can continue his task by going directly to the next cell.

- similar to the first cell, the operator has to check if Queue6 is empty, if this is the case an item will be generated in Queue5 and has to be transported to Queue6 by the operator. If not, the operator must check if there is an item in Queue7. If this is the case he has to transport it to Queue8, if not he can continue to travel to processor3.

- after doing this task sequence he will travel back to the first cell and check the status of Queue2 again and the sequence restarts.

Unfortunately I don't know the correct syntax to check if a Queue is empty. (I hope this can be solved easily by using default Process Flow logic rather than making a complete script or custom code, since I'm a newbie)

For example for the first decision, I tried to use: getvarnum(Queue2, "Queue2.subnodes.length")>0 as condition but this doesn't seem to work. Can someone help me out?

Thanks.

machining-cells.fsm

FlexSim 17.1.2
decision content queue
machining-cells.fsm (34.0 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.

Matthew Gillespie avatar image
0 Likes"
Matthew Gillespie answered Matthew Gillespie edited

Once you have a reference to your queue object, for example:

Object Queue2 = model().find("Queue2");

To get the number of items in an object use

Queue2.subnodes.length

to check if the queue is empty just add a comparison

Queue2.subnodes.length > 0

The getvarnum command is not used the way you're trying to use it. The second parameter in quotes should be the name of a variable, for example:

getvarnum(Queue2, "maxcontent")		//This will return the maxcontent setting of the queue

Anyway, you don't need to use the getvarnum command here, just use the code above.

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

Roel VDB avatar image Roel VDB commented ·

Hello Matthew,

First of all thanks for your help.

But I'm getting an error now, saying that Queue2 is an undefined variable. What do I have to do to declare this variable?

0 Likes 0 ·
screenshot.jpg (57.7 KiB)
TOTH-EM avatar image TOTH-EM Roel VDB commented ·

Use model.find("Queue2") instead of Queue2.

So you should have something like this:

model.find("Queue2").subnodes.length

0 Likes 0 ·
Steven Hamoen avatar image
0 Likes"
Steven Hamoen answered

@Roel VDB Queue2 has to be an object to let this construction work. You can do 2 things. The first is to add an Assign Labels activity and make a label and call it Queue2 (or any other name) and use the sampler to select Queue2. That way you have a label with an object pointer and you can write:

token.Queue2.subnodes.length 

And you will see that if you start to write it, Flexsim will give you option for what fits behind the dot.

Other option is to use the construction:

model().find("Queue2").subnodes.length

This is a bit longer but you don't have to use the extra Assign label activity

Personally I would prefer option 1 because then you have a pointer to Queue2 everywhere in your process flow.

5 |100000

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