From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Queue Example Question

Solved!
Go to solution

Learning more about queues, can someone look at this example and explain why the string never gets dequeued? I followed other examples, but this doesn't work for some reason.

 

Thanks...

0 Kudos
Message 1 of 5
(3,237 Views)
Solution
Accepted by topic author QRP

Make the 1 case default.  It is very unlikey there will be exactly 1 element in the queue.  Plus, you are looking at the wrong value in the queue status.  You should be looking at the # Elements in Queue (on bottom of Queue Status).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 5
(3,227 Views)

Thanks. I should problably use the number of elements in the queue node and wire that to a > 0 condition into a true/false conditional box instead too. Thanks a lot.

0 Kudos
Message 3 of 5
(3,221 Views)

Looking at the example a little more, it would be better to not check the queue status.  Just use a Dequeue with a timeout.  If you didn't have a timeout, write to the string.  You should also be releasing the queue.

 

Attached is an edited version of your VI.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 5
(3,219 Views)

There are several things which create problems with your example.

 

1. The # pending remove is not the appropriate signal to use for the case structure.  Read the detailed help and see if you can figure why it is always zero.  Use the # elements in Queue instead.

 

2. So that you do not need to manually reset the stop button, use another local variable outside the lower loop to reset it to False after the loops stop.  Better would be to use a queue or notifier to send the stop command form one loop to the other.  Then you can use the Latch mechanical action to reset the button after it is read.

 

3. If your loops do not run at exactly the same rate, you may have problems with never dequeuing data.  This is particularly true if the dequeue loop is slower than the enqueue loop.  One of the ideas of the queue as a data transfer mechanism is that it allows the loops to run at different rates.  If they are going to run at exactly the same rate, you might as well just have one loop. Change the case to be "1.." rather than "1" so that it will run if the # elements in queue is >= 1. If the number is > 1, you may want to shorten the loop time for the next iteration to read the data faster.

 

Run your VI with Execution Highlighting turned on to see what is going on. Or put indicators or Probes at various points in the VI to watch the behavior.

 

Lynn

0 Kudos
Message 5 of 5
(3,212 Views)