LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to extract element label from cluster

Solved!
Go to solution

Hi,

i have cluster indicator contained three set of boolean array.how to extract each array by its  text label.actually i have attached a VI where i have string array(control) and cluster(indicator). i want to read 2'nd column of array control and compare to cluster array using text label and turn on particular led in cluster one by one.

 

eg: suppose i read Led_a_1_3  then i want to turn on led 3 in cluster array name Led_a_1.

0 Kudos
Message 1 of 9
(3,406 Views)

Hi Risuraj,

 

get the references of the cluster elements.

Use those references to read the labels of the elements.

Now you are able to find your "array LED_a_1".

Use the reference to read/change the array value…

 

Other option:

Create a large case structure, containing a case for each array label. Now you can use the array label to call the appropriate case and set/change array values using (Un)Bundle(ByName) inside this case…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 9
(3,395 Views)

Hi,

get the references of the cluster elements.

Use those references to read the labels of the elements.

Now you are able to find your "array LED_a_1".

Use the reference to read/change the array value…

can u share me VI file(remember cluster is indicator not a control)

 

0 Kudos
Message 3 of 9
(3,377 Views)
Solution
Accepted by topic author Risuraj

I believe something like this is what was suggested:

 

Cluster Control References.png

 

_______________________________________________________________
"Computers are useless. They can only give you answers." - Pablo Picasso
0 Kudos
Message 4 of 9
(3,358 Views)

Hi,

i have attached a Vi where i am able to get text label of array but same time i want to take value also for associated text label.

Note:-My indicator cluster having boolean,string and boolean (1D and 2D)array indicator.at least for each how to get value.

0 Kudos
Message 5 of 9
(3,299 Views)
Solution
Accepted by topic author Risuraj

Hi Risuraj,

 


@Risuraj wrote:

i have attached a Vi where i am able to get text label of array but same time i want to take value also for associated text label.

Which "associated text label" are you talking about?

 


@Risuraj wrote:

My indicator cluster having boolean,string and boolean (1D and 2D)array indicator.at least for each how to get value.


It's always the same approach: read the value as variant, then convert to specific datatype - as you already do for "DPS1_J4":

(Replace the string constant by a control. No error handling included…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 9
(3,287 Views)

You need to make a seperate case for each datatype. Here's one possibility.

 

(Or course there are probably better ways since the labels cannot change at runtime. It seems like a nightmare to keep track of all these names and make necessary downstream changes if the next programmer decides the rename one of the cluster elements)

 

 

0 Kudos
Message 7 of 9
(3,270 Views)

what actually i want to do. i have "28p loco " is the cluster indicator consist of 1D boolean array,2D boolean array and other data type.

suppose i have one string "DPS1_J4_1" reading from some file.i want to match this string with cluster indicator text label.whenever i found string has matched.that time i have to turn on the array indicator inside the cluster.

 

 

eg:DPS1_J4_1 is matched with text label i have to identify that text-label element inside the cluster indicator  and turn first led from  DPS1_J4_1 array.what ever be the last value of string that particular led need be turn on.

0 Kudos
Message 8 of 9
(3,255 Views)

Hi Risuraj,

 


@Risuraj wrote:

what actually i want to do. i have "28p loco " is the cluster indicator consist of 1D boolean array,2D boolean array and other data type.

suppose i have one string "DPS1_J4_1" reading from some file.i want to match this string with cluster indicator text label.whenever i found string has matched.that time i have to turn on the array indicator inside the cluster.


Then you REALLY should rethink your data management!

Why do you want to rely on some indicator on your frontpanel? An indicator is a data sink - it should not be used as data source or data storage!

 

Create a data structure in memory. Handle the data by their labels. Use a FGV (or OOP or other means like those CVT implementations) to restrict access on the data to your own routines. Create a VI that reads the data and sets the FP indicator to show the user the current settings.

I recommend variant attributes (or maps in LV2019+) to implement your data handling! This will be so much better (scalable, error proof, etc.) than your current approach!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 9
(3,250 Views)