LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Merging Reference Clusters

Solved!
Go to solution

Hello,

 

I have a code with several SubVIs, each one with multiple objects. I would like to group all objects' references in one single source in order to have access to objects' properties by means of property nodes in other VIs. Since I have one Reference Cluster (which is populated with real references as SubVI run) for each SubVI, I would like to merge all these reference clusters into one. Nevertheless, when I do that I lose all labels of the objects. Is there a way to merge multiple reference clusters into one and keep objects labels?

 

See attached picture for information. I just used an example how dynamic events can be used to trigger events across VIs (dynamic events are crucial for my code). Method A shows the regular way to get the references from two different reference clusters. As you can see the labels are kept.

 

On method B I try to make things easier, and instead of having multiples "unbundle by name", I just convert the clusters to arrays, use a build array function to concatenate all references into one single array, and them convert the array back to a cluster. Nevertheless, by doing that labels are not kept.

 

Thanks.

 

Dan07

 

Grouping Reference Clusters.jpg

0 Kudos
Message 1 of 11
(4,645 Views)

Method B is expected behavior. Once you cast your cluster into an array, you lose all information except the value for each element. This is how arrays work.

So the "issue" you have is not with the array to cluster, but with the cluster to array!

 

Nevertheless, for readability purpose, you can create your specific wrapper for this.

Essentially, you wrap the array to cluster into a subVI where you pass a cluster prototype and fill the values using the array elements.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 11
(4,637 Views)
Norbert_B,

Could you provide me with an example on how to get that?

Thanks.
0 Kudos
Message 3 of 11
(4,632 Views)

use  Bundle by name function next to the array  to build the cluster.

 

Bundle by name.png

 

 

elements 0 to m-1 will be your references .Input Cluster will be your expected cluster constant with label names for controls.

0 Kudos
Message 4 of 11
(4,614 Views)

Frabto

 

I can't do that because I don't have all objects in one single VI. I have multiple SubVIs, each one with a set of objects. I created a reference cluster for each one of the SubVIs and they are all "strict typedef". I just want to merge all these references clusters into one, but keep the labels in order to use unbundle by name function to have access to the references.

 

FInd below a updated picture. I am considering getting all the labels from the references (since it is a common property for indicators and controls, and because of that I can use a property node inside a for loop) and use this array of labels to feed the cluster with all references. But I don't know how to achieve that.

 

Thanks.

 

Dan07

 

References - Updated.jpg

0 Kudos
Message 5 of 11
(4,592 Views)

I'd recommend you use a functional global variable or Action Engine to store all of your references in the master cluster.  You would have multiple initialize cases where you initialize only particular elements with the references, one for each subVI where you do this.  And then you have the default "Get" case where it returns the master cluster with all the references populated.

Message 6 of 11
(4,581 Views)

I am with Ravens Fan re: Implementing a GUI Controller based on an Action Engine core.

 

YOu can find images of GUI controller design pattens in this album and I believe I talked a bit in this thread  about how I implement and use them.

 

But if you are focused on the image you posted, I THINK a strategic "type cast" applied to the cluster wire (after the array to cluster ) will cast the cluster to what ever names you use in the prototype (top input) of the type cast. Please note that you will have to edit the prototype everytime you add more refs which would NOT be the case if you used a GUI Controller.

 

Have fun,

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 7 of 11
(4,575 Views)

Ben,

 

Let I tell you the whole story. I used to have one single front panel with all the objects. Following your advice I created a GUI refs (strict typedef) and use it to access my references into several SubVIs, by means of unbundle by name function. Everything was working great, but I decided to split my big front panel into small parts (VIs) and because of that the objects are not all at the same place as before. Then, I created several GUI refs (strict typedef), one for each set ob objects of each VI and now I just need to merge all these GUI refs into one, keeping the label names.

 

Keeping the labels is crucial for me because I have several SubVIs with unbundle by name functions getting the references from the old GUI ref. Since I didn't change the labels of the objects (I just spreaded them over multiple Vis instead of leaving everything into one single front panel), I will be able to use my unbundle by names functions as they are right now. I need to find a way to merge several GUI refs (strict typedef) into one, keeping the labels of the objects.

 

Please, provide me with a simple example showing how to merge two (for example) GUI refs clusters (strict typedefs) into one. It is not necessary to be done on "runtime" since I can just run the code to merge the GUI refs, and them convert the indicator with all refs to a control and use it as a Reference Cluster (strict typedef).

 

Thanks a lot.

 

Dan07.

0 Kudos
Message 8 of 11
(4,557 Views)

Dont know if its  a lame answer.

 

Ctrl Merge.png

 

There are limitations:

 

1.The number of controls  cannot be varied in runtime.( as size is required in array to cluster function)

2.Labels has to be manually typed in the reference cluster.

 

Message 9 of 11
(4,527 Views)

@Frabto wrote:

Dont know if its  a lame answer.

 

Ctrl Merge.png

 

There are limitations:

 

1.The number of controls  cannot be varied in runtime.( as size is required in array to cluster function)

2.Labels has to be manually typed in the reference cluster.

 


 

 

Nice interpretation of my suggestion Frabto!

 

Dan,

 

Does the image from Frabto help you?

 

Take care,

 

Ben

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 10 of 11
(4,509 Views)