LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Indexing clusters that are different sizes

Solved!
Go to solution

Hi all,

 

I am trying to accomplish a simple task, but I do not know if there is a simple solution or not. Here is my problem:

 

I have a main cluster that is made up of additional clusters (let's call them sub-clusters). These subclusters vary in size, ranging from 1 boolean element to 8 boolean elements.

 

Is there a simple way to index each sub-cluster inside a for loop? When I use the property node, the value of the sub-clusters is a variant which I would need to convert back to cluster datatype. I'm having trouble doing so b/c 'Variant to Data' requires a known cluster size to be defined. Since the sub-clusters vary in size, I cannot specify a fixed size. As is, I get ERROR 91 during the variant to dattype conversion process.

 

Thanks for the help!

0 Kudos
Message 1 of 7
(2,975 Views)

I would probably be using a cluster of boolean arrays at this point, but since you asked you can do this with a little help from a VI buried within vi.lib:

 

22493iF457E3E5192933CB

0 Kudos
Message 2 of 7
(2,965 Views)

I'm not sure what your final objective is, but I am guessing that you are wanting to get the boolean values from different clusters and combine them to form a digital waveform.  Would the following example not work?

 

22495iF3B63FE1480499D6 

- tbob

Inventor of the WORM Global
0 Kudos
Message 3 of 7
(2,958 Views)

Hi Darin,

 

That is exactly what I am trying to accomplish. However, when I tried using the same approach, I notice that the 'Variant to Data' always produces a False. The number of elements being processed from each sub-cluster is correct, but I'm not getting the right values.

 

Hi tbob,

 

Your example works, but the main cluster I am working with contains 20+ sub-clusters. Unbundling each sub-cluster would involve using a lot of wires / whitespace. I wanted a simpler approach, such as by using for loops and property nodes if possible.

 

Thanks.

0 Kudos
Message 4 of 7
(2,946 Views)
Solution
Accepted by Newbie217

Ha Ha, I used a pretty lame test case.

 

I was writing it out the brute force way when I thought of the vi.lib VI.  Here is the other way to do it in this case.

 

22509i1AA2E4DAEAF87923

Message 5 of 7
(2,934 Views)

Or something more straight with GetClusterInfo.vi from vi.lib/Utility/VariantDataType

22525iC6A534CC2F8893D5

0 Kudos
Message 6 of 7
(2,921 Views)

Two posts that I watch out for during the day are the one I try to make while running out of the office and the one I make at night while trying to keep the kids distracted.  You went two-for-two on this one.

 

Just use a Boolean array constant as the datatype for Variant to Data instead of the Cluster constant.  I get dinged with so many errors with mismatched variants that I forget which cross conversions actually work....

 

A little caffeine goes a long way....

0 Kudos
Message 7 of 7
(2,889 Views)