01-22-2009 12:19 AM
In My Application i am having two VIs. Iin one VI I create a Queue and then I pass the Queue ref. to the other VI and run that VI Dynamically.
During run time any VI can stop irrespective of the status of other VI.
but as soon as i stop the VI which created the Queue. the queue ref. becomes invalid. and dynamic VI can not use the queue anymore
I want the queue to be disposed only after i explicitely call queue dispose function.
how can i achieve that
Tushar Jambhekar
tushar@jambhekar.com
Jambhekar Automation Solutions
LabVIEW Consultancy, LabVIEW Training
Rent a LabVIEW Developer, My Blog
Solved! Go to Solution.
01-22-2009 12:59 AM - edited 01-22-2009 01:02 AM
Hi Tushar,
You could create a "Functional Global" which wraps the Create Queue funtion and buffers the Queue reference in a shift register. The VI might have two modes of operation: CreateQueue and ReadReference. The Top-level VI would run it in the Create Mode, and the dynamically-called VI would just keep using the Read mode. Since this VI remains part of an executing VI even after the parent-process terminates, the Queue reference it allocates will stay valid.
Cheers!
01-22-2009 01:27 AM
Or you can create a named queue and not pass the reference but the name of the queue.
Ton
01-22-2009 01:30 AM
Hi there
in case you are using the Queue functions (and not the classic 7.x queue VIs) you can create several instances to a queue by calling "Obtain Queue" several times using the same name of the queue. So you don't need to pass a reference to the queue created by the master VI. To release a queue call "Release Queue" with "Force Destroy = FALSE". Then each instance of the queue will stay valid until the instance is released or all VIs using the queue stop to execute.
01-22-2009 02:23 AM
Use of LV2G works fine.
But passing Queue name to dynamic VI and obtaining ref to the same queue does not work. it works only till the main VI is running
Tushar Jambhekar
tushar@jambhekar.com
Jambhekar Automation Solutions
LabVIEW Consultancy, LabVIEW Training
Rent a LabVIEW Developer, My Blog
01-22-2009 02:43 AM - edited 01-22-2009 02:46 AM
Hi Tushnar,
I appreciate the Kudos!
In fairness to TonP - I wasn't familier with the method he described, so worked-up an example - which seems to work!?
In example (attached) I'd have expected an error in SubVI once parent terminated. Perhaps it's significant that the Queue reference is different (after cast to U32...)...
Cheers.
01-22-2009 09:23 AM
Resource (like queues) are "owned" by the VI that creates them. When a VI goes idle the resource associated with that Vi are cleaned up. So if a VI that creates a Queue goes idle, the queue is destroyed.
TO keep the queues alive you have to make sure the VI that created them nver goes idle.
Ben
01-22-2009 01:22 PM
Ben wrote:TO keep the queues alive you have to make sure the VI that created them nver goes idle.
That is why I never use subVIs.
Ton
01-22-2009 10:20 PM
Sorry, but this is not correct - for queues at least. You see the issue is that queues are not created or destroyed in your LV code. You'll note that rather than creating a queue you obtain a reference to one, and you don't destroy a queue, you release your reference to it (by default at least). LV does the queue creation and destruction in the background independent of your code.
Try creating two VIs putting unique data into a named queue and one that dequeues the data and displays it. Now start the first enqueueing VI running, start the second enqueueing VI and finally start the dequeueing VI. You should see the data flickering by from both enqueuing operations. Now stop the 1st enqueueing operation - the other two VIs keep running. Now restart the 1st enqueueing VI and stop the 2nd. Again, everything keeps running. Now stop both enqueueing VI - the dequeueing VI continues with no errors.
Only when ALL the references to a queue are released will LV destroy the queue.
Mike...
01-22-2009 10:25 PM
You're doing something wrong Tushar, if the queue name is passed correctly, it does work. I have build many, many systems that use this feature.
Mike...