From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
02-24-2006 10:09 PM
02-24-2006 11:33 PM
Hi ,
i am afraid that this cannnot be done dynamically on the run while ur program is running.
To cluster size according to the 1D array size, click on the array to cluster function, select cluster size option in dropdown menu and enter the size.
hope this helps
Regards
Dev
02-27-2006 04:16 AM
02-27-2006 04:21 AM
We have two ears and one mouth so that we can listen twice as much as we speak.
Epictetus
02-27-2006 05:33 AM
Why do you want to dynamically control this?
There is no way to programmatically select a cluster element, so you would have to select it in advance, meaning that programmatically defining the cluster (even if it was possible) would not help you.
If you tell us what you actually want to accomplish, we could suggest another way to do this.
02-27-2006 05:38 AM
02-27-2006 06:40 AM - edited 02-27-2006 06:40 AM
Message Edité par Jean-Pierre Drolet le 02-27-2006 07:42 AM
LabVIEW, C'est LabVIEW
02-27-2006 09:59 AM
Clusters are like structs in c/c++ they are static representations of a data structure, if you have different sized structures they are not the same structure. You could make a few different cluster types (typedefs) and create a polymorphic function to take a 1d array and convert it to the approperate struct and return this or you can have a polymorphic vi which takes a 1d array and depending on the size updates only some of the fields in your struct (this is much like an overloaded constructor with different initializer signatures).
Paul
You can check out LAVA on scripting which can solve this difficult problem but this is a very advanced and difficult topic which is not suggested not supported by NI
02-27-2006 11:28 AM
I won't disagree with any of the previous posters, but would point out a conversion technique I just recently tried and found to work well for my own particular purposes. I've given the method a pretty good workout and not found any obvious flaws yet, but can't 100% guarantee the behavior in all settings.
Anyhow, I've got a fairly good sized project that includes quite a few similar but distinct clusters of booleans. Each has been turned into a typedef, complete with logical names for each cluster element. For some of the data processing I do, I need to iterate over each boolean element in a cluster, do some evaluations, and generate an output boolean cluster. I first structured the code to use the "Cluster to Array" primitive, then auto-index over the resulting array of booleans, perform the evaluations and auto-index an output array-of-booleans, then finally convert back using the "Array to Cluster" primitive. I, too, was kinda bothered by having to hardcode cluster sizes in there...
I found I could instead use the "Typecast" primitive to convert the output array back to my cluster. I simply fed the input cluster into the middle terminal to defin! the datatype. Then the output cluster is automatically the right size and right datatype.
This still is NOT an adjustable cluster size, but it had the following benefits:
1. If the size of my typedef'ed cluster changes during development by adding or removing boolean elements, none of the code breaks! I don't have to go searching through my code for all the "Array to Cluster" primitives, identifying the ones I need to inspect, and then manually changing the cluster size on them one at a time!
2. Some of my processing functions were quite similar to one another. This method allowed me to largely reuse code. I merely had to replace the input and output clusters with the appropriate new typedef. Again, no hardcoded cluster sizes hidden in "Array to Cluster" primitives, and no broken code.
Dunno if your situation is similar, but it gave me something similar to auto-sizing at programming time. (You should test the behavior when you feed arrays of the wrong size into the "Typecast" primitive. It worked for my app's needs, but you should make sure it's right for yours.)
-Kevin P.
02-27-2006 01:14 PM