LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programatically Opening and Closing VI problems

Solved!
Go to solution

So, for a larger project I would like to be able to programatically open and close a VI through a main VI. Attached to here is not the full project but some example code for you guys to see. In the code I can open the VI through the first one easily enough, but when I try to close the VI through the other VI, it all just locks up. Nothing happens and the CLOSE button stays in a TRUE state even though I've programmed it to return to FALSE in the case structure. 

 

So....I have no idea. I've tried a number of variations of the code and the program never works. When I had this code inserted into my main project, it even returned an Error 1039 code when I tried to close the VI through the main project. So, what do you guys think?

0 Kudos
Message 1 of 4
(3,094 Views)

Some comments:

  • If your Open and Close buttons have Mechanical Action "Latch When Released", you won't need to use a Local Variable to "turn them off".  This type of Boolean behavior is the design intent of "Latch When Released".
  • What do you want your sub-VI to do?  Do you want it to "Pop Up", as though it were a Dialog Box that asks you for some data, you "fill in the blanks", hit <CR> (or some other exit criterion) and it finishes, passing you back the data?  If so, just make the sub-VI as a Dialog Box and call it -- it will run, "do its thing", and when it exits, will hand you back the values it collected.
  • Do you, instead, want the sub-VI to run independently, doing various things until either it decides to Quit or you tell it to quit?  There are better ways in LabVIEW 2012 to do this (Start Asynchronous Call comes to mind) -- using VI Server is sort of a "blunt instrument".
  • I have a problem using Abort VI to stop a VI.  A (bad) analogy is using a Sledge Hammer to kill a fly -- you can do it, but there may be other damage done by using an "inappropriate tool".  Better is figuring out how to send a "Stop" signal into your sub-VI (perhaps by passing in a Reference or a Queue you can use to send in a signal).

Bob Schor

0 Kudos
Message 2 of 4
(3,063 Views)
Solution
Accepted by topic author ShogunOrta

You run it with "wait until done" thus the upper case will not complete until the subVI is done. The while loop cannot go to the next iteration until this happens.and the lower case structure can never be reached. Use execution highlighting to see what happens.

 

(I am sure you are aware of latch action and greedy loops. I guess in the real program there is a lot more code)

0 Kudos
Message 3 of 4
(3,062 Views)

Yep, that seemed to be the problem. Thanks!

0 Kudos
Message 4 of 4
(2,984 Views)