10-13-2009 10:01 PM
Objective: To create a 3 step wizard-like interface utilizing a tab control. The middle tab in the tab control needs to contain the front panel of separate "processing" VI. The processing VI uses the data collected from the previous tab's controls as input parameters. The third tab needs to receive one or more values computed by the processing VI.
EXAMPLE:
Step 1 (ie: Tab1) collects some settings from the user and has a "Next" button. When the user clicks the "NEXT" button, the tab control changes to the second tab.
Step 2 (ie: Tab 2) The second tab contains a subpanel into which we have loaded our "processing" VI. The "processing" VI has an elaborate front panel. We loaded the "processing" VI into a subpanel in order to display the processing VI's front panel. When the "processing" VI completes, we want to switch to Step 3 (ie: Tab 3) passing several result values into Tab 3's controls.
Passing data in/out of a subvi seems very easy, but I'm unable to work out how to pass data in/out of a VI loaded into a subpanel. Any assistance with creating the above user interface structure /logic would be appreciated. We are not stuck on the above architecture just the sequence of events. If there is something that is more appropriate just let me know.
10-14-2009 04:32 AM
> ..but I'm unable to work out how to pass data in/out of a VI loaded into a subpanel
In order to interact with the controls and indicators on a subpanel, you have to get a reference to them. Then you can read or write them using property nodes. If you get a reference to the subvi itself, you can use methods to set or get values.
Check out the example called Subpanel Templates. It shows one way to get a reference to a control using a vi called LoadandRun_byName*. There is also a vi called FindControlByName* that returns a control/indicator reference. Look at the block diagram of FindControlByName* to see how it finds the references. You can make a version of this vi that gives you the references that you need. Note: Check the LoadandRun_byName* vi if you have questions about how to get the subvi reference.
*It's not easy to find these vis. They are located at:
Program Files\National Instruments\LabVIEW 2009\examples\general\controls\
So in your application you can use property nodes to write the data fron "Tab 1" when you go to "Tab 2" and then write the data from "Tab 2" to "Tab 3" when you go to "Tab 3".
Whether this is the best implementation for your application depends on a few factors. The advantage of this approach is that you can use your subvi without making changes to it. The disadvantage is that you are dynamically calling the subvi.
Some of the down sides of dynamically called vis are:
Not automaticallcy included in builds so you
Property nodes are much slower than wires, but if you are in human time (i.e. user interface stuff), this shouldn't be an issue.
10-14-2009 04:47 AM
Oops .. Somehow my reply got posted before I was done with it. Dang.
The path in that one should have been:
Program Files\National Instruments\LabVIEW 2009\examples\general\controls\subpanel.llb
And the last two paragraphs should have been:
Some of the down sides of dynamically called vis are:
I hope this helps,
steve
10-14-2009 05:48 AM
I would advise avoiding the setting of controls in the subVI route, not because it doesn't work, but because it's ugly and has a potential for breaking. There are various other ways of passing data between VIs.
Global variables are the easiest, but have race conditions potential (altough if you have a single writer for each value, this is less of an issue). LV2 globals are another. Queues and notifiers (obtained by name) are another. I don't have a specific example, but it's fairly simple - you push the data into the queue in the caller, then read it out in the subVI.