10-25-2013 03:26 AM
Hello everybody,
I have developed a Producer/Consumer architecture (using queues) in order to acquire data from a spectrum recorder instrument.
The VI is working well, as expected, but I need to acquire data during a very long time (for example 8 hours). For this reason I added a "Time control" into a´n external While loop: if the stop time is < actual time stamp, I repeat the complete acquisition.......
All is fine, but at certain times I get the error 1 "Release Queue" (see attachment)....I don't understand why, because I followed the instructions in order to use queue functions, and each queue (I have 2 queues, 1for frequency, and 1 for level) is relöeased at the end of each acquisition.
How can I avoid this error ?
Thanks for your help.
Paola.
10-25-2013 03:42 AM
Paola,
you really do have a huge monitor, do you?
Looking into the VI (which should be cleaned up for less wire bends and SIZE!), i see that you do not use proper error handling. Which release queue function creates the error?
Issue 5 is creating the error. I assume that the error occurs ALWAYS.
You create a queue, flush it (no elements in it). The you are using this amount of flushed elements (0) to feed a for-loop enqueuing elements. This loop never executes. As you pass the queue reference in tunnels (instead of shift register), you delete your queue reference. The you try to release a NULL queue, which naturally has to throw an error!
These are just my 8 cents, hope they help,
Norbert
10-25-2013 04:34 AM
Hi Norbert,
first of all thank you for your answer. I'm quite new in Labview, and it's only 2 months that I'm programming with it ... Of course, I agree with you, ths VI should be cleaned at least for the visualization !
Thank you for your help.
Paola
10-25-2013 04:50 AM
Paola,
if you look into the producer/consumer template provided by LV, you will see that the consumer loop terminal is connected to the error cluster. In case an error occurs during waiting for dequeue (as e.g. the queue is released by the producer), the "dequeue" function will throw an error which terminates the consumer as well.
Use a single queue as 1:1 data flow from one producer to ONE consumer. If data consists of more than a single data type, use clusters or variant data type for the queue (bundle and unbundle "by name")
You have to limit the maximum available/provided memory. Using the concept of a "ring buffer" fits to most applications in that case. Pre-allocate an array with the "buffer size" and then replace single elements/blocks using "replace array subset". Most likely, you will have to handle your own "write index" (aka. "write pointer"). If data really grows unlimited, using log files is the only appropriate answer.
You could use a wait function and wire the output "millisecond timer value" to the outest loop instead of using a timeout event encapsulating your complete code. Using statemachine, you would start with an "initialize" state containing that simple wait.
Yes, you understood that hint with shift register correctly for the while loop. Still, you missed it for the two for-loops in the producer. THESE are the offending code pieces...... (so you will still get the error!)
Yes. If you need maximum execution performance, you still contain a wait function, configured for '0' ms. This makes sure that the compiled code behaves more "cooperative" than with leaving the waiting out of the code.
I was talking about the global called "Session Data".
Norbert
10-25-2013 06:48 AM - edited 10-25-2013 06:51 AM
The big issue I see in there is that you are not creating your queues. You have them setup to NOT create if not found. Remove those FALSE booleans to the Obtain Queues. And you also have a wire going from the consumer loop to the producer loop. How is that even working? You must be looking for a value of 0 or else you would be stuck in an endless loop.
10-25-2013 07:12 AM
@crossrulz wrote:
[...] You have them setup to NOT create if not found. Remove those FALSE booleans to the Obtain Queues. And you also have a wire going from the consumer loop to the producer loop. [...]
Wow, nice catch....must have overlooked this 😞
Norbert
10-25-2013 07:21 AM
Hi,
yes, you are rigth. I removed the enqueue function in the for loop, and it is still working in fact......I'm checking and trying to improve this structure.
The False boolean have been already there (since I'm using some functions prepared by the supplier of the device) and I left them like this......even if I agree with you, they should be TRUE. Anyway, it is working like this, even with FALSE boolean. I will have a look on this also.
Thanks!
Paola