07-20-2012 11:17 AM
Hi all,
New user and first time poster.
The problem:
I'm attempting to use the "build cluster array" VI and then using the "index array" VI to retrieve a specific cluster, thus acting as a multiplexer of sorts. BUT my clusters are of multiple data types, and it seems that only the last cluster inserted into the array is stored or available. I feel like there should be an easy way to accomplish this task, perhaps with varients but I'm not seeing it. Any help - hopefully in as descriptive and step-by-step way as possible because im very new to this language - would be greatly appreciated,
Thanks,
Kurt
07-20-2012 11:29 AM
You can build an array of variants, in which each element is actually a different data type wrapped in a variant envelope. You cannot, however, use "Build Cluster Array" to do it. Build Cluster Array lets you build a cluster of arrays, where every array has the same type and dimension but may have a different length. Instead, you could use "To Variant" to convert each cluster to a variant, and then wire those variants to Build Array.
If you post your code it may be easier to provide more specific advice.
07-20-2012 11:52 AM
Thanks for the quick reply,
I just tried to convert each individual cluster to a variant then added each of these variant elements to an array, of which im hoping to select one of the elements, but I don't know how to "de-variant" the element to get back my cluster. Im trying to use the "variant to data" VI but im not sure what to connect to the data type input, my guess was a cluster constant (created from the original 24 element cluster)...alas that didn't work.
07-20-2012 12:44 PM
You do need to use Variant to Data, but, not surprisingly, the type input needs to match the type of the data. That means it needs to be the same type as the original input cluster. Since you started with a bunch of different cluster types and combined them into an array of variants, when you try to get the data back you'll need a separate case for each of the original cluster types. LabVIEW is strictly-typed and doesn't work well with generic data. If you could post your code, and a description of what you're trying to accomplish, we might be able to suggest a better approach.
07-20-2012 02:32 PM
I guess I wasn't specific enough but each original cluster is the exact same size and contains the same order and combination of data types they just refer to different front panel controls and thus can have different values. I just want to select one of these identically structured clusters and pass it through based on a dequeued channel number. What do I wire to the "Variant to Data" type input - the cluster type right - which is all the same 24 element cluster, but how?
07-20-2012 02:45 PM
Please, please, please attach your code, or at least a screenshot of it. I can't figure out what you mean by "refer to different front panel controls." Do you mean that's where they obtain their values? If all the clusters are identical, there's no need for variants at all, you just need to use build array to build an array of them.
07-20-2012 03:25 PM
^this is the Variant method which should still work, I simplified it abit, but as you can see the inputs are all the same cluster and I want the channel to select what cluster to use and unbundle.
Thanks again for the help nathand
07-20-2012 03:26 PM - edited 07-20-2012 03:27 PM
If Inputs, Inputs 2, etc are all identical, then remove all the Variant to Data functions (EDIT and the Variant to Data function) and it will work exactly as you want.
07-20-2012 03:54 PM
^ So I guess heres my question again with a visual
I've clearly asked for the ( 0 ) element in the array which should return "inputs" not "inputs 4" which is what's shown in the picture (returning BatterID Ch3). Is there a 2D array i should be using?
07-20-2012 04:26 PM
You're misunderstanding what's happening here. The names are taken from Inputs (because it's the first element), but the values will be the data you expect. Does this make sense to you?