02-23-2006 02:38 PM
02-23-2006 03:10 PM
02-23-2006 03:42 PM
03-11-2006 10:36 AM
03-13-2006 10:42 AM
Hi Kjell,
If you'd like an example of using Queues and an Event Structure together, you might consider looking at a template. Templates are like regular VIs, but when you open one up, you only open an instance of that template file rather than the template itself.
You can browse to the templates by selecting File >> New from LabVIEW (note: not File >> New VI). From the template dialog that pops up, browse to VI >> From Template >> Frameworks >> Design Patterns >> Producer Consumer Design Pattern (Events). The template can run when you open it, but it won't really do anything special. It does show an example of setting up Events and Queues together, though.
03-15-2006 01:26 PM - edited 03-15-2006 01:26 PM
Message Edited by Kjell-Edmund on 03-15-2006 01:57 PM
03-15-2006 02:26 PM
Here's a method that has worked reliably for me, though it frankly doesn't rank very high on my "elegance meter."
Your UI Event-handling loop catches an exit condition and puts an "exit" message in the producer-consumer message queue.
Your consumer loop receives the "exit" message and manages a graceful shutdown of DAQ tasks, etc.
After all done, it then Releases it's message queue with the "force destroy?" input set to TRUE, then stops execution.
The next time the UI Event-handling loop checks a status on the message queue, the error cluster will have an error asserted because the queue has been destroyed. This error can cause your Event loop to exit.
If you have additional queues for data-passing, you can apply similar reasoning to handle them gracefully.
-Kevin P.