LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamically Select Cluster Element By Name?

I'm using a cluster as a map for a matrix switch. The cluster contains several arrays (strings), the name of each array corresponds to one of the resources hooked up to the matrix and the elements of a given array are the switch closures. For example, I might have one array named "voltmeter" and the values are something like "A1","A2","A3" ..etc.

I want to retrieve the elements from the individual arrays based on a passed in resource name and a pin number (array element). So for instance, if the user passed in a resource name of "voltmeter" I would need to unbundle the cluster, retrieve the element named "voltmeter", and then index the resutlting array...simple, right?

Unfortunately I just can't figure out how the heck to dynamically select the elements of a cluster. I've fooled around with properyt nodes, the controls[] property, etc, but I just can't seem to find the right magic.

Is there a way to do this?

Thanks,

..glen
0 Kudos
Message 1 of 4
(6,191 Views)

In this Nugget I talk about manipulating various data types in LV including clusters. Try looking over that Nugget for ideas. It is not an out-of-box solution to your challenge but it demonstrates a lot of 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 2 of 4
(6,185 Views)

Hey,

 

I just stumbled upon this very old topic because of a similar problem. Due to the fact that no solution was posted here I would like to add my solution. In this solution I wanted to select a cluster element by a Enum that contains all cluster element names. The VI used to convert the Enum values into string is from the OpenG package.

 

So if somebody is still looking for a solution to this problem, here is mine:diagram.jpg

 

 

Best Regards

Jenso

Message 3 of 4
(5,068 Views)

There are multiple ways of doing this today.  Using OpenG is fine if you know you will have it installed, but I prefer a native solution if one is possible.  Here is my quick attempt which does the same thing of setting the control named String to abcd.  If this is done in 2017 you can even take advantage of VIMs and have the type propagation happen in the VI.  Otherwise there are a few experimental XNodes (undocumented use with caution) that can do similar work.

 

Example_VI_BD.png

0 Kudos
Message 4 of 4
(5,055 Views)