LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

passing queue to dynamically called VI

Solved!
Go to solution

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

0 Kudos
Message 1 of 18
(5,067 Views)
Solution
Accepted by topic author Tushar_Jambhekar

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!

Message Edited by tbd on 01-22-2009 01:02 AM
"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
Message 2 of 18
(5,062 Views)

Or you can create a named queue and not pass the reference but the name of the queue.

 

Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
Message 3 of 18
(5,052 Views)

 

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.

Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
Download All
0 Kudos
Message 4 of 18
(5,050 Views)

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

0 Kudos
Message 5 of 18
(5,038 Views)

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.

 

Message Edited by tbd on 01-22-2009 02:46 AM
"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
Download All
0 Kudos
Message 6 of 18
(5,030 Views)

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 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 7 of 18
(4,993 Views)

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

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 8 of 18
(4,976 Views)

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


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 9 of 18
(4,962 Views)

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


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 10 of 18
(4,959 Views)