LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Good way to make VI into sub-VI while keeping the functionality

Hello,

Sorry if this is a naive question. I'm trying to convert a VI into a subVI, but I'm unsure of what to do about button operated functions. For context this is essentially a VI used for controlling a camera that I would like to integrate into a larger control scheme. For example, I have a button to press that will take a picture and then labview will do some other stuff to it. Is there a good way to convert the VI into a subVI while still maintaining this level of control?

Thanks

0 Kudos
Message 1 of 6
(1,366 Views)

Hi daines,

 


@daines13 wrote:
Is there a good way to convert the VI into a subVI while still maintaining this level of control?

As soon as you call your "VI" from another VI it becomes a "subVI": there is no (explicit) conversion required…

 

All you need to think of is to show the frontpanel of your (sub)VI upon calling it: open the VI properties dialog (Ctrl-I) and set the frontpanel properties as needed!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(1,349 Views)

They are all just VIs.

 

The only distinction is that SubVIs typically have connector panes assigned, while toplevel VIs don't. For debugging purposes, you can often even run subVI directly. 

 

The first decision you need to make is if the subVI should be interactive or if you just want to call it using values of controls on the front panel of the caller. If the subVI should show the front panel, you need to decide if it should block the dataflow of the caller or run independently. If it should run in the background, you need to ensure that it completes and returns results to the caller without user interaction.

 

Once we know what you are actually trying to do in more detail, we can give more specific advice.

0 Kudos
Message 3 of 6
(1,311 Views)

@altenbach wrote:

They are all just VIs.

 

The only distinction is that SubVIs typically have connector panes assigned, while toplevel VIs don't. For debugging purposes, you can often even run subVI directly. 

 

The first decision you need to make is if the subVI should be interactive or if you just want to call it using values of controls on the front panel of the caller. If the subVI should show the front panel, you need to decide if it should block the dataflow of the caller or run independently. If it should run in the background, you need to ensure that it completes and returns results to the caller without user interaction.

 

Once we know what you are actually trying to do in more detail, we can give more specific advice.


I'm going to get lexically nit-picky (or maybe white-space-and-case-picky) here.  A "sub VI" is a VI that is called by another VI.  A "SubVI" is the block diagram object that calls a "sub VI"

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 4 of 6
(1,295 Views)

Back in the days where LLBs were still used, there was actually an option to designate "toplevel" for specific VIs, so we can conclude that everything else in there is not. 😄

(On a side note, it would be cool of e.g. windows explorer would show VIs without connector pane assigned with a different icon and type. There are the ones we typically want to open. 😄 )

0 Kudos
Message 5 of 6
(1,251 Views)

Everyone seemed to miss this important bit of information...

 


@daines13 wrote:

Hello,

 I'm unsure of what to do about button operated functions.

 


As you rightly conclude, Front Panel buttons do not belong on sub-vi. Unless of course, you are exposing (displaying) the sub-vi that contains the button, you know, like a dialog box.

The other option would be to determine if the vi is being called by an upper level VI and then simply skip the button functionality.

Third option would be to "press the button" from your calling vi. (It is an option, not a great one, but still an option)

 

Maybe others will offer more solutions?

---------------------------------------------
Former Certified LabVIEW Developer (CLD)
0 Kudos
Message 6 of 6
(1,240 Views)