LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

What is the best way of converting a Top Level VI into a 'sub vi' - or function ( without duplicating programming)

Hi,

 

General question here about design architecture, which i keep running into, but haven't found a really good solution.  If i write a 'Top Level VI' to do something, what is the best way of converting it into a subVI - which is call-able from other VIs, while still allowing the top level VI to have synchronised feedback/indicator updates.

 

I guess the point is that when something is a top level VI you write gui logic about what happens when someone clicks buttons or whatever - which you don't want in the 'sub vi' version.

 

I did at one point try having a hidden boolean button that was an input to the subVI which would let the VI know if it was supposed to be doing the front panel stuff - or simply running as a subVI.  This isn't really ideal though - since it would be better to be able to hive off the grizzly useful stuff from the fluffy - front panel updating stuff - having them together makes the VIs rather untidy.  More annoyingly though, if you have the front panel version of it running - say waiting for you to hit 'go', it breaks all the other VIs that use it as a sub vi - since they can't compile when a sub vi is already running.

 

Another possibility that i tried was to basically duplicate the vi so that there was a backend part, and a front end part - and when i click 'go' the backend part is called as a sub vi.  The problem with this is that it really limits the interface that the user gets - since none of the controls on the front panel update with the results untill the sub vi is over.  I guess again i could solve this by passing references to some of the controls to update them in the subvi - but this doesn't really seem like the ideal situation if the subvi is called by something else without the same types of controls etc.

 

One final idea i had was to essentially paste all the controls in the VI into a global variable file, and make the sub vi update them, and the front panel VI read from them.  This seems to 'work' - although clearly it is a work around rather than a proper solution - since i spend loads of time worrying about how i update cluster variables in the global - reading and writing.

 

Does anyone have any guidance on what they do to solve this problem?

 

JP

 

 

 

 

 

 

 

 

 

0 Kudos
Message 1 of 2
(1,899 Views)

You could run a subvis in a Subpanel on your top level.  Lets you see the current data while the subvi is running.


--Using LV8.2, 8.6, 2009, 2012--
0 Kudos
Message 2 of 2
(1,893 Views)