LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling a VI to run in the background

Hey, can anyone help me with this:

I have a vi which is eseentially a sequence (though I do not use a sequence
primitive). At one point during my sequence, I need to launch another VI
that goes and does its own thing. Then, the calling VI (the original one)
has to finish a few steps, while the other VI is doing its own thing. I
have no experience using the 'VI Control' primitives on the controls
pallete, so if anyone has experience with this, could you please help me
out?

Essentially, I need to run two VI's at once. I know how to do that in terms
of making each while loop have a 'Wait for Milliseconds' within the loop so
that the currently executing loop does not hog the processor, I just don't
know how to launc
h another VI to run in the background from within a VI.
The only way that I have done this in the past is to call a VI as a
subroutine, have it do its task, and then return to the calling VI.

Any ideas?

Thanks,

Wes

wesramm@hotmail.com
0 Kudos
Message 1 of 3
(8,305 Views)
Wes,

Apart from calling a VI as a sub-vi you can use VI Server to call another VI. The VI you are calling can be on the same machine or could be called remotely from another machine.

There are a few examples on using VI Server you may find helpful. If you go to the Resource Library in NI Developer Zone http://zone.ni.com/libraries/ and then go to LabVIEW-Connectvity-VI Server you should find quite a few examples.

One that is pretty simple and useful is titled - Programmatically Opening and Running One VI from Another Using VI Server

In the diagram of the This.vi you'll see that there is an invoke node that is calling a Run VI method, the parameter for the method is Wait Until Done. By setting this to true you can ensure that the VI you are calling completes executi
on before the next VI (with flow being controlled through the error cluster) executes. If you set it to false the VI will go off and run and you can continue doing things independently.

Do be careful in case you are getting into situations where you might be calling the same VI again before the previous call has completed. If that is a possibility mark the VI as re-entrant, this is wether you're using VI server or just calling the same sub-vi multiple times in another VI. If you don't set the VI up to be re-entrant you run the risk of the same data space being used for different calls.

Regards,
Kamran
An
0 Kudos
Message 2 of 3
(8,305 Views)
You can easily do this with the VI server functions located in the Function palette under application control. First, use Open VI Reference to obtain refnum to VI in question (put path to VI in the vi path input), then use an invoke node with the method set to Run VI and then use a Close VI reference so that the refnum is destroyed. This will start the VI running and then the caller will forget about it. VI Server can also be used to exchange information between VIs and even edit the VIs programmatically as long as the called VI is not running while the editing is done. Hope this was helpful
0 Kudos
Message 3 of 3
(8,305 Views)