question

Lucas Antonio Risso avatar image
2 Likes"
Lucas Antonio Risso asked Matthew Gillespie converted comment to answer

Unitary release on a Queue

The model that I am working on presents the following situation. A queue has been accumulating several flow items because its output is closed. I want it to release a single item as soon as it receives a message. How can I create a logic to do this without using the process flow? Currently, when a message is received it is being released all the items.

Thank you for your attention.

FlexSim 16.0.1
queueitem releaseports controlwithout process flow
· 3
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 Matthew Gillespie ♦♦ commented ·

What are you releasing to and what is sending the message?

0 Likes 0 ·
Lucas Antonio Risso avatar image Lucas Antonio Risso Matthew Gillespie ♦♦ commented ·

I am releasing an "artifiicial" item, that will be the reference to establish the right path of the parts in order to obtain the assembly section... A queue is sending the message based on the reading of a label...

0 Likes 0 ·
Lucas Antonio Risso avatar image Lucas Antonio Risso commented ·

Thank you everyone for the help, the comments were very useful for me!

0 Likes 0 ·
Brandon Peterson avatar image
4 Likes"
Brandon Peterson answered Brandon Peterson edited

Lucas,

If you only want to release 1 every time then you can include the following code in the exit trigger of the Queue:

closeoutput(current);

This will close the output after every item leaves the Queue and only allow one to exit every time the openoutput() command is called for the Queue.

If you want to be able to specify a number that will be released you can do the following:

Keep a label on the Queue called ReleaseNum and set it to zero on reset. Then in the exit trigger of the Queue include the following code to reduce the number left to release by one and possibly close the output again:

inc(label(current, "ReleaseNum"), -1);
if(!getlabel(current, "ReleaseNum"))
	closeoutput(current);

The last thing that you need to do is set ReleaseNum label on the queue to the number of items you want to release before you call openoutput() on the Queue.

All of the code in the examples above could also easily be done with pick list options if you want to use them.

I have included a sample model for you.queue-release-demo-v2016.fsm

Good Luck,

Brandon


5 |100000

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

Joerg Vogel avatar image
2 Likes"
Joerg Vogel answered

If you don't depend on the closeoutput function, maybe you can use in the "flow" tab the function "send to" the picklist item "do not release item". Then all items stay in the Queue, but you can send any item you exactly identify to any existing port. The function is "releaseitem(obj item, port)"

releaseitem(rank(current,3),1); // rank(current,3) identifies the 3rd item in the Queue, the "1" is the port the item goes to. 
5 |100000

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

Jeff Nordgren avatar image
1 Like"
Jeff Nordgren answered Mischa Spelt commented

If you'd attached more model I could have given you a more specific answer for your model.

What I would do when the queue receives a message would be to open its output ports. Then, in the OnExit trigger, I would again close the output ports. That should only let out one flowitem.

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

Lucas Antonio Risso avatar image Lucas Antonio Risso commented ·

I tried exactly in this way, it didn't work.

0 Likes 0 ·
Mischa Spelt avatar image Mischa Spelt Lucas Antonio Risso commented ·

Then either you have a bug in the OnExit that keeps the ports open, or some other part of your model immediately fires the code that opens the ports again. Please see the attached model, where the queue releases a new item to the processor 10 seconds after the previous item has fallen into the sink (triggers are on the Queue and the Sink).openportafter10s.fsm

1 Like 1 ·
Regan Blackett avatar image
-1 Like"
Regan Blackett answered Brandon Peterson commented

I might do it this way: Upon receiving the message, do a moveobject() of the first ranked flowitem (or which ever one you want to leave to the queue) into the desired object, bypassing ports all together.

Something like this:

moveobject(first(current), outobject(current, 1));
· 3
5 |100000

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

Lucas Antonio Risso avatar image Lucas Antonio Risso commented ·

Where should I include this command? On code snippet? Thanks in advance for your attention

0 Likes 0 ·
Regan Blackett avatar image Regan Blackett ♦ Lucas Antonio Risso commented ·

Put my command in the OnMessage trigger of whatever object you have receiving your message and it should work fine.

0 Likes 0 ·
Brandon Peterson avatar image Brandon Peterson ♦ commented ·

Using the moveobject() command also bypasses much of the default code in the objects and can cause unexpected behavior later in the model run. I would recommend an all or nothing approach when using the moveobject() command. I either don't use it all or make sure that I move every object that way. This insures that I don't get surprised later.

0 Likes 0 ·