LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Live-update by reference in nested subVIs

Solved!
Go to solution

Hi

 

So I've been struggling for a few hours now with this seemingly simple task. I want to live-update a front-panel element in a Main.vi caling a subVI which is in turn calling another subVI.

But each of the nested VIs should also be ready to be used as standalone VI (i.e. run with live-updating Slide based on the subVI1 containing the actual program logic).

Here's what I have:

 

itchy00_5-1678134879414.png

 

But how do I connect "Slide SubVI2" in subVI2 to that same reference??

 

At the moment the reference from Main is passed "through" subVI2 to subVI1 and the sliders in Main and subVI1 will update simultaneously. I just can't seem to figure out how to do also update the value of Slide SubVI2 at the same time.

 

Of course I could introduce another reference in SubVI2 to Slide subVI2. Pass that reference to SubVI1 as well as a second control input. And then have a second Value Property Node in subVI1 for that additional slide refnum.

 

Is there really no way to make two different front panel elements "point" to the same reference?

 

 

I appreciate any help here 🙂

 

Thanks in advance!

Download All
0 Kudos
Message 1 of 7
(1,421 Views)
Solution
Accepted by itchy00

You could make some complicated logic using "call chain" to see if "Main" called "subVI2" or "subVI2" is running standalone. But I don't think that's a good way to do it, or worth the effort.

 

Usually I only worry about front panel updates in something that is part of the user interface, like "Main". In sub VI's where computations happen I would probably use simple numeric indicators. 

 

Also, the best way to pass data between a Main VI and Sub VI is via inputs and outputs. You should think for a while if you really have a good reason to do it another way, like via references.

 

Finally, if I do have something similar to your example, where there is a sub VI a couple levels deep that has to run for more than a second or so, I will usually make that VI a pop-up to tell the user what is going on.

0 Kudos
Message 2 of 7
(1,416 Views)

Hi Gregory,

 

thank for the opinion and hints.

Yeah I was thinking about pop-up yesterday. Maybe that's going to be the way I'll do it in the end.

I agree that a super complicated chain structure could lead to a lot of confusion some time later.

 

The thing I'm trying to do here is some data loading of quite large files.

So the deepest VI (subVI1 here) is a data loader processing individual files, which takes some time. There is a progress indicator (numeric or slide) in a for-loop showing the progress of processing of such a single file.

 

The second VI (subVI2) loops over files in the folder. Calling subVI1 in a for-loop file after file. So subVI2 has the info of how many files to process in total and then goes on to proceed file after file.

 

What I want to see in the MainVI is a progress bar filling up as the data is being loaded. But not on a file-list level (counting processed files) but live-updating a progress bar while the subVI1 is running over the individual files.

 

As far as I know the only way of passing a live-update progress indicator (numeric indicator, slide, whatever) from within the for-loop of a running subVI to the caller is using a reference. Or am I thinking in a completely wrong direction here (which might well have happend as I got lost in my own confusion here, haha 😄)

 

Anyway, I'll implement the pop-up Userinterface and just see if I can well live with that solution. Thx

 

0 Kudos
Message 3 of 7
(1,374 Views)

There are other ways to share data if your VIs are running asynchronously. That would mean that Main.vi launches SubVI and then gets on with other tasks. But, if you want Main.vi to wait on SubVI (as you do by simply putting the SubVI on the block diagram) then you are more limited. 

 

If you don't like the look of the pop up, you can actually insert the panel of SubVI into Main.vi using subpanels

 

I would probably go with with one of these 2 options. But, if you really want to stick with updating by reference, you could simply convert your reference input into an array. Then in your lowest level VI you will loop over the array to update all of the indicators.

0 Kudos
Message 4 of 7
(1,355 Views)
Solution
Accepted by itchy00

@itchy00 wrote:

But how do I connect "Slide SubVI2" in subVI2 to that same reference??

You don't.

 

At the moment the reference from Main is passed "through" subVI2 to subVI1 and the sliders in Main and subVI1 will update simultaneously. I just can't seem to figure out how to do also update the value of Slide SubVI2 at the same time.

Build an array of control references. And as you nest deeper. (it's ofcourse a silly construction, but as food for thought)

 

Of course I could introduce another reference in SubVI2 to Slide subVI2. Pass that reference to SubVI1 as well as a second control input. And then have a second Value Property Node in subVI1 for that additional slide refnum.

Close. Build an array of references, add sub2 ref to the array in that vi, and let have a loop in sub 3 that updates all.

 

Is there really no way to make two different front panel elements "point" to the same reference?

No, since it's a reference to the control, not the data. 


I think the correct solution is to create some User event that the last one fires and the others listen to.

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 5 of 7
(1,329 Views)

Okay thanks!

 

The User-event-and-listener idea sounds actually like a very nice construct!!

I'll have to read a little bit into that to understand exactly what you mean and how to do that in LV😅 .... but seems that is a concept I should definitely get to know!

0 Kudos
Message 6 of 7
(1,323 Views)

Usually the are good and easy examples you can find through Help -> Find examples, but not so much for User Event. Check out these two.

UserEvent.pngUserEventExample.png

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 7 of 7
(1,317 Views)