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.

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:

  1. 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:

  1. inc(label(current, "ReleaseNum"), -1);
  2. if(!getlabel(current, "ReleaseNum"))
  3. 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)"

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

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:

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