LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a "Get Cluster Names" VI?

I would like to get a list (array of strings) of the name of each item in a cluster so that I can print the "key=value" information in a log.
Is this do-able?
0 Kudos
Message 1 of 22
(25,067 Views)
Is this what you want?
Message 2 of 22
(25,061 Views)
TobyD beat me to it.

Yeah, he's exaclty right.
Here's an example code in 8.5
Van L
NI Applications Engineer
0 Kudos
Message 3 of 22
(24,994 Views)

Thanks very much.

I tried to take it to the next step by having the VI accept a reference to a cluster with no sucess. In that way I could get the cluster member names from any cluster.

Is this doable?

 

0 Kudos
Message 4 of 22
(24,981 Views)

You would need to use a generic cluster reference, as opposed to the strictly typed reference you probably have now. The easiest way is to right click the reference control to ignore the type, but you can also select the Cluster class from the class hierarchy.

Another option is to use OpenG's lvdata package, which includes a VI which accepts a cluster as a variant and analyzes the variant to get the element names.


___________________
Try to take over the world!
0 Kudos
Message 5 of 22
(24,974 Views)
I created another example code

Basically the same one I posted before but I deleted the cluster. Then I right clicked on the input of the Cluster properly node and created a control.

I turned this into a subVI and connected inputs and outputs.

Then you can use this in another VI and just wire another cluster reference into it

Hope this solves your problem
Van L
NI Applications Engineer
0 Kudos
Message 6 of 22
(24,973 Views)

The solutions presented is the way I have always done it in the past and it works on all the cRIOs I have used in the past. However, it does not work on RT Linux based cRIOs, like the 9068. Created consternation, as it works when run from the development environment, but when you compile it and run it on the cRIO, it suddenly does not work. I was working for weeks doing a new development, and only compiled and run it the day before I had to go to site, my experience in the past was always that if it runs from the development environment, it will work compiled on the cRIO. I am now working on a clumsy work-around, where I generate files with the strings, on my pc, and then on the RT Linux cRIO I read the strings from the files.

0 Kudos
Message 7 of 22
(11,520 Views)

GetClusterElementNames.png

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
Message 8 of 22
(11,510 Views)

Thank you for the quick reply, Yamaeda! 

I see the vi you used is under Cluster, Class, & Variant -> Variant -> Data Type Parsing

I have not used those before.

I'll quickly try it out, you may have saved me a few hours work!

Thanks again.

Message 9 of 22
(11,502 Views)

Sounds to me you want to store values in an ini file?

 

Perhaps this Configuration File Library is useful. It will even do exactly what you asked, but as its purpose is to do much more, it would be overkill.

Message 10 of 22
(11,499 Views)