LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Running Independent VI's

I've tired to have one vi open a second vi and then close the first vi leaving the second vi running. I can't seem to get this to work using the second vi opening a vi reference too itself as I was led to believe. Can anyone provide help or an example?
0 Kudos
Message 1 of 5
(2,392 Views)
I didn't try it with "itself reference", but using VI server seems to be a perfect solution for running independent VIs.

Hope this helps.
Download All
0 Kudos
Message 2 of 5
(2,392 Views)
I've attached an example of how I have done it. Use the VI server in to open and run the second vi from the frist then use it to close the FP of the first.

Hope it helps
Brian
0 Kudos
Message 3 of 5
(2,392 Views)


The examples submitted by other contributors work because the front panel of the second VI is opened. This condition is sufficient to keep second VI in memory when first VI stops and closes.


However, if the second VI would not have its panel opened, it would be aborted when first VI stops because LabVIEW releases a VI from memory when its panel is closed and no running VI has reference opened to it. That is why you have been told that second VI must open a reference to itself in order to stay in memory when first VI stops.


The problem you probably have is a race condition: first VI opens a reference to run second VI but it exits too soon, before second VI has time to open a reference to itself. The solution is that first VI waits
some time to make sure that second VI opens it self-reference.


Instead of waiting a fix time which could sometime be not enough, I do the following: second VI opens a reference to itself and writes it on a front panel refnum indicator named "Self Ref". First VI, after running second VI, polls "Self Ref" value (using "Get Control Value" on second VI) and test it until it returns a valid refnum ("Not a Path/Refnum" node).


That being said I have read that in LabVIEW 6.1 there is an option on "Open VI Reference" node to open another VI, detach it from first VI and automatically close the refnum when second VI stops. I have not 6.1 yet to test it but it seems to neatly address and solve this issue.




LabVIEW, C'est LabVIEW

Message 4 of 5
(2,392 Views)
This an in-depth answer and explains a phenomenon I encountered. I wanted to use a sub-VI for some interactive manipulations of a related image window via the front panel.
To un-clutter the screen I close the panel of the calling vi just before the subvi is called and re-open it at return. If you abort the sub-vi, every LV window is closed and you are back at the main launcher.
Gabi
7.1 -- 2013
CLA
0 Kudos
Message 5 of 5
(2,392 Views)