10-07-2008 02:19 PM
Hi, I have a simple wish: Under LabVIEW 8.2 (Windows), I wish to pass some parameters to a SubVI, and then the SubVI should run in background, that is: continue without halting the main VI.
If I just call the VI, the main VI is halted, and if I call by VI reference, I cannot pass parameters to the SubVI.
What is the best solution to this ?
10-07-2008 02:42 PM - edited 10-07-2008 02:43 PM
You could pass parameters to the subvi using an Action Engine. See here
http://forums.ni.com/ni/board/message?board.id=170&thread.id=240328&view=by_date_ascending&page=1
PS Sorry for the weird spacing, dont know what is causing that
10-07-2008 02:43 PM - edited 10-07-2008 02:45 PM
Jan Nielsen wrote:... and if I call by VI reference, I cannot pass parameters to the SubVI.
What is the best solution to this ?
Please clarify.
A Call by Reference allows you to pass values to the VI. See here.
I'll assume you meant to write that the VI hangs until the sub-VI call completes.
I that case you can use an Invoke node >>> Run (set Wait until Done input to false) VI AFTER you have used invoke node >>> ctrl Val.Set to specify your parameters.
Ben
PS JM, Kudos to you for citing my Nugget.
10-07-2008 02:48 PM - edited 10-07-2008 02:49 PM
Hi Jan,
If I understand your situation correctly, what you want to do is run the vi dynamically. A search of the forum will show lots a examples I am sure as well as if you search for "dynamic" in the LV examples. But one possible method I show in the attached image. You first set a front panel control value by name, then run the vi, show the window (in my case set the transparency of the window) and then close the reference. Something similar should work for you hopefully. Hope this helps.
cheers,
--Russ
10-07-2008 03:46 PM
Thanks Russ, I have tried the method you describe, however I get this error when trying to run the VI:
Error 1000 - Possible reason(s): LabVIEW: The VI is not in a state compatible with this operation.
Method Name: Run VI VI Path: C:\LabVIEW-programmer\DB Monitering\Double_Shell_Call.vi
Do you have any hints what is wrong ?
10-07-2008 03:54 PM
Jan Nielsen wrote:...
Error 1000 - Possible reason(s): LabVIEW: The VI is not in a state compatible with this operation.
...
Do you have any hints what is wrong ?
I believe that error will be returned if the target VI is reserved to run due to it being in the hiarchy of an already running VI.
Ben
10-08-2008 06:55 AM
In addition to Ben's point, I think you also need to have it closed in your development enviornment.
To find some examples in the forum and on DevZone, try 'Launcher' as keyword.
Felix
10-09-2008 02:10 AM
Thanks a lot everyone, now it is almost working.
I have one last question. I am calling a SubVI that does a task, then waits 10 secs., then does another task - using Russ' dynamic method as above, with an Invoke Node. But I am not opening the Front Panel of the SubVI since I don't need this.
Now, if I have a Close Reference last - as in Russ' example - the last task is never run. So I think, the Close Reference makes the thread "disappear".
If instead I wire a True constant to the Auto Dispose Ref in the Run VI Invoke Node, the task is run.
Will this be OK or will I have the references "hanging" ?
10-09-2008 02:53 AM
Auto Dispose Ref = TRUE means that LabView determines if the ref is not needed any more. You will go fine with that.
Auto Dispose Ref = FALSE means, that you tell LabVIEW when to dispose the reference using the Close.vi. That's why your module never run. A common use case for that is to launch a VI and pass the reference to the vi (now holding the reference to itself). When the VI is don, it closes the reference of itself to unload.
Felix
10-11-2008 01:47 PM
Thanks everyone, all is OK now.
BR, Jan