From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using independent VI programs as sub-VIs

Hi, I would like to know how you go about using event-based, and independently working, VI's as sub-VIs in an overarching parent VI?

 

Background:

Basically I have created stand-alone event-based VIs that control various pieces of equipment (one VI program for each piece of equipment), as was required at the time. Now I want to develop a parent VI for a system that integrates all of the equipment, using the functionality of the previously developed VIs (as sub-VIs), but events maybe triggered programmatically (eg a button press may send a Numeric to one subVI and a String to another subVI at the same time). But I want to retain the full working functionality of the sub-VIs on their own, so the equipment can still be used stand-alone, without the parent VI, if required.

 

Progress so far:

I set up an example to demonstrate and test, as attached. SubVI is a stand-alone VI that acts on user inputs to produce outputs. I want to use this in a parent VI to control this now - and I would think the best way would be to pass down references of controls to the subVI through an added cluster and dynamically register these and trigger the same events as the corresponding subVI controls. ParentVI_3 does this fine, but as it stands cannot read the outputs on the fly, and is basically just a different representation of the under-lying SubVI.

So what happens when you require different things to happen in the parent VI. In ParentVI_2 one button press is required to be passed directly to the SubVI and another button iterates a Numeric (in a parent event) which is passed to the SubVI. But this VI doesn't work.

 

Any guidance on on how to work the VIs in this way and how to read the outputs (preferably without having to send down multiple parentVI indicator references) would be greatly appreciated and please feel free to alter the attached VIs. Thanks!

Download All
0 Kudos
Message 1 of 3
(2,106 Views)

Check out the Actor Framework.  Examples and code are posted liberally around this forum.  If you want an older architecture, I posted a series on this topic you can find here.  The link is the last post, which has links to all the other posts.  Let us know if you need more info.

0 Kudos
Message 2 of 3
(2,088 Views)

Thanks for the input! With the info on the older architecture and also from this post that I found, I was able to come up with 2 ways of solving this.

 

In ParentVI_4, I feed down references of the parent's controls/indicators for the SubVI to act on directly - but this obviously requires extra code and dynamic event registration in the SubVI. In ParentVI_5, the parent obtains the references to the SubVI controls/indicators and writes value (signaling) down to trigger the SubVIs events as well as triggering read events - and this does not require any change in SubVI code (other than ensuring all SubVI Boolean controls are non-latching).

 

I've included the VIs here, in case you have any more advice. I'm guessing the method I used in ParentVI_5 is best? But a question I do have - is there a way of doing this without having to open the SubVI FP? I guess the opening of the FP deteriorates performance?

 

Thanks!

Download All
0 Kudos
Message 3 of 3
(2,034 Views)