LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Dimensions of cluster

Hi,

 

I´m looking for a possibility to get the dimensions of a cluster.

Background:

I do have a complex cluster that might change its strucuture. If i add a new element to this cluster, lets say this element is another cluster with elements, I will get kind of a deep structure with 3-4 dimensions, right?

Then I could use these Information for writing a VI that extracts my cluster in its elements.

 

My Idea:

If I use the context help on the defined cluster i can see the content of the cluster, so what i thought is getting this information as a string and then search for EOL/CR/LF signs or however it is shown in the string ( or maybe convert to hex and search for the hex-code). By now I couldnt find a solution. I tried it with OpenG: Get default data from variant (see attached picture). I do get the text, but i cant "work" with it.

 

0 Kudos
Message 1 of 9
(5,309 Views)

How about using the Controls[] Property on the Cluster and then recursing on each Control you find that has a ClassName property of Cluster?

0 Kudos
Message 2 of 9
(5,289 Views)

Or you can get the cluster toolkit from VIPM made by Autotestware.  Quite a large library of tools for clusters so I'm sure there is something in it to help you out. 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 3 of 9
(5,275 Views)

Normally I love to recommend OpenG but in this case there are native functions that can do it for you.  Use the Variant to Data function and turn a cluster into an array of variants, then you can iterate over all elements and use the native Variant functions Get Type Information.vi to get the data types and names (and values if you want)

 

Example_VI.png

Message 4 of 9
(5,264 Views)

That could be what I´m looking for. Unfortunately I´m using LV 2014 ( sorry, forgot to mention that) and i couldnt find this "get type information" function.

However i tried it in a different way that does return the same (data-types missing, doesnt work so far).  See attached picture: Array 1 and 2 basically do the same thing, array 3 returns the elements of the highest level.

But that is my problem, i still dont get the data of lower levels. If one if these highest level elements is a cluster, i need to know how many levels/dimensions are in that cluster. Wiring this number to a for-loop should make it possible to dynamically extract the content of the cluster.

 

@aputman: Thanks for that one, i´ll try to download the toolkit this weekend.

 

@Taki1999: Could you explain your suggestion a bit more? I had a look at the available properties, but i couldnt find a property that would match my requirements. LV2014.JPG

 

0 Kudos
Message 5 of 9
(5,203 Views)

So the Get Type Information VI I used was put on the palette in 2015, but was buried in vi.lib for several versions.  I'd recommend installing the Hidden Gems package if you haven't already, I think it is in the normal list in VIPM.  All it does is put some of the useful features in vi.lib on the palette, it doesn't actually install any new functions.  Once installed there is a Variant palette, and it has a function similar to the Get Type Information in 2015.  The benefit of this is this will run in an environment that doesn't have OpenG, or the hidden gems installed, since they are installed with LabVIEW just not on the palette.  I did some testing and the NI version is generally faster than the OpenG method of getting variant information.

0 Kudos
Message 6 of 9
(5,177 Views)

Recursive Cluster Depth.png

Here's my idea for getting the depth. I'm pretty sloppy with my recursion sometimes but this looked like it was working. Cluster Depth VI looks like this:

Recursive Cluster Depth VI.png

 

0 Kudos
Message 7 of 9
(5,170 Views)

That only works if you have a reference to the cluster, instead of just the data type.  Still it could be modified to work with the data type instead.

0 Kudos
Message 8 of 9
(5,152 Views)

This is from the Cluster toolkit.  Function is called Get Cluster Element Data Types (Nested).

 

Example_VI.png

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 9 of 9
(5,147 Views)