LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Populating cluster with references

Solved!
Go to solution

Hello

 

I've been using "reference clusters" (strict type def) and they make life much easier when you have a Main VI with couple controls and indicators, and want to change a property of one of these objects from a SubVI. Everything works great when I have all objects in one single VI and want to populate the cluster with the "real" and valid references.

 

Nevertheless, when I have couple objects in many different VIs and want to populate one single cluster with the references, I am getting errors. What is the best way to get that?

 

Find attached two ZIP files: First Method.zip and Second Method.zip

 

Unzip First Method.zip to a folder and open VI_1_First_Method.vi. Run the vi and keep your eyes on the white gauge. Everything is working great and VI_2_First_Method is changing the background color of the white gauge.

 

Unzip Second Method.zip to another folder and open Populate_with_real_references_Second_Method.vi. Take a look at the block diagram. How do I populate the Cluster_Second_Method.ctl with "real" references from objects in VI_1_Second_Method.vi, VI_2_Second_Method.vi and VI_3_Second_Method.vi ??

 

Thanks a lot.

 

Dan07

Download All
0 Kudos
Message 1 of 16
(6,427 Views)

Does anyone have suggestions?

 

Thanks.

0 Kudos
Message 2 of 16
(6,387 Views)

Find_Control.PNG

 

I first used a static ref (brose to sub-VI once you drop it on digram) to get a ref to the FP and then get a ref to all controls on the FP of the first sub-VI. Then I iterate thru all comparing the label and when I match I terminate the for loop and cast the control as the proper type. The output wire in then availabel for wiring to the cluster.

 

If you are not familiar with navigating using control refs then this Nugget may give you some ideas.

 

Ben

 

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 3 of 16
(6,378 Views)

Ben

 

Your approach will work great with small codes but not with large ones. I was thinking about using one single for loop and feed this loop with all references. The problem is to put references of different classes into the same array. Find attached a VI that looks crazy but has one possible solution for this problem.

 

Thanks.

 

Dan07.

 

 

Populate - Problem.jpg

0 Kudos
Message 4 of 16
(6,362 Views)

Dan your solution will not work since you are typecasting the specific control back down ot a generic control.  You would have to adjust them back to their specific class.

 

You could put your cluster in your loop shift register and update the cluster instead of building the array.

0 Kudos
Message 5 of 16
(6,357 Views)

Hello Matthew

 

I know that my idea is a little crazy, but how can I put the cluster into the shift register? I can't use the "bundle by name" as a array, I mean: index 0, then index 1, and so on. I can't see that working. Could you draw a draft for me?

 

Thanks a lot.

 

Dan07.

0 Kudos
Message 6 of 16
(6,354 Views)

Here is your VI reworked for your example.  Note, I startAll controls instead of All Objects.  Sicne you were bundling your control refs, they were all demoted to generic control refs as well.  So, I don't make the object the specific calss until I've decided where it belongs.

 

ScreenHunter_01 Oct. 27 18.10.jpg

0 Kudos
Message 7 of 16
(6,343 Views)

Hello Matthew

 

Your code is great, but is this example I have only 6 controls. In a large VI with many controls, I would have to have many cases in the case structure, and I would have to create one by one and put the right specific class constant inside. I know that this kind of approach will work, but I trying to figure out a way that I don't have to create cases by myself. Suggestions?

 

Thanks a lot!

 

Dan07

0 Kudos
Message 8 of 16
(6,337 Views)
Solution
Accepted by dan07
Message 9 of 16
(6,334 Views)
I am on my way for dinner now but as soon as I get back home I will run the vi. Thanks a lot! You are great!!

Dan07.
0 Kudos
Message 10 of 16
(6,332 Views)