Decision based on content Queue

Decision based on content Queue

roel_vdb
Not applicable
220 Views
4 Replies
Message 1 of 5

Decision based on content Queue

roel_vdb
Not applicable

[ FlexSim 17.1.2 ]

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

0 Likes
Accepted solutions (1)
221 Views
4 Replies
Replies (4)
Message 2 of 5

Matthew_Gillespie
Autodesk
Autodesk
Accepted solution

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.



Matthew Gillespie
FlexSim Software Developer

0 Likes
Message 3 of 5

roel_vdb
Not applicable

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?

6984-screenshot.jpg

0 Likes
Message 4 of 5

SCHamoen
Advisor
Advisor

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

0 Likes
Message 5 of 5

touijer_o
Not applicable

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

So you should have something like this:

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

0 Likes