12-26-2013 12:38 AM - edited 12-26-2013 12:59 AM
Hi all,
I am following the help to learn how to use cluster to reduce the number of input/output but it is pretty confusing that how to tell which element is which. Does it follow the order we added to the cluster or not? I set a cluster contains 4 DBL numbers as a input to my subvi. I name the elements of each DBL as A, B, C, D. In the main code, I create a cluster contains 4 DBL and trying to feed that cluster into the subvi. But how can I tell which number I feed in the main code is A, B, C and D?
For example, I create a subvi with only one cluster input. The cluster has 4 DBL numbers named A, B, C and D.
Now if want to feed a cluster into that subvi, I have to create a cluster and link the 4 numbers into that cluster. But if I use bundle cluster, I have to link the number in order so to fill A, B, C and D. But if that subVI was created by someone else, how can one tell the order of elements in the expected cluster?
Solved! Go to Solution.
12-26-2013 01:00 AM - edited 12-26-2013 01:02 AM
First of all, you should give the cluster elements in the subVI control the same names (A,B,C,D) as used in the calling VI and also ensure that the cluster order is the same. If you are unsure bout the cluster order, you can reorder the elements (right-click) and select the desired order. And yes, the initial cluster order is the order in which you added the elements.
Typically it is best to make the cluster a typedef and re-used it everywhere. This way changes to the typdef are propagated to all places where it is used.
It is often more self-documenting and cleaner to use bundle and unbundle by name. Wire a typedef diagram constant to the top of "bundle by name" to make the labels available.
12-26-2013 01:04 AM
@altenbach wrote:
First of all, you should give the cluster elements in the subVI control the same names (A,B,C,D) as used in the calling VI and also ensure that the cluster order is the same. If you are unsure bout the cluster order, you can reorder the elements (right-click) and select the desired order. And yes, the initial cluster order is the order in which you added the elements.
Typically it is best to make the cluster a typedef and re-used it everywhere. This way changes to the typdef are propagated to all places where it is used.
It is often more self-documenting and cleaner to use bundle and unbundle by name. Wire a typedef diagram constant to the top of "bundle by name" to make the labels available.
Thanks for your quick reply. What do you mean to make the cluster a typedef?
12-26-2013 01:14 AM - edited 12-26-2013 01:18 AM
@dragondriver wrote:
Now if want to feed a cluster into that subvi, I have to create a cluster and link the 4 numbers into that cluster. But if I use bundle cluster, I have to link the number in order so to fill A, B, C and D. But if that subVI was created by someone else, how can one tell the order of elements in the expected cluster?
Easiest would be to place the subVI first, then right-click the cluste connector and "create constant". Now insert a "bundle by name" into the new wire and pick the desired cluster inputs.
Here's how it would look like for the termination cluster input of nonlinear fit.
12-26-2013 01:16 AM
@altenbach wrote:
@dragondriver wrote:
Now if want to feed a cluster into that subvi, I have to create a cluster and link the 4 numbers into that cluster. But if I use bundle cluster, I have to link the number in order so to fill A, B, C and D. But if that subVI was created by someone else, how can one tell the order of elements in the expected cluster?
Easiest would be to place the subVI first, then right-click the cluste connector and "create constant". Now insert a "bundle by name" into the new wire and plick the desired cluster inputs.
Here's how it would look like for the termination cluster input of nonlinear fit.
Thanks. using typedef is a good idea 🙂
12-26-2013 01:17 AM
dragondriver wrote: What do you mean to make the cluster a typedef?
This will of course only work for your own subVIs, but learn about type definition here
12-26-2013 01:32 AM
@dragondriver wrote:
Easiest would be to place the subVI first, then right-click the cluste connector and "create constant". Now insert a "bundle by name" into the new wire and plick the desired cluster inputs.
Here's how it would look like for the termination cluster input of nonlinear fit.
Thanks. using typedef is a good idea 🙂
the above has nothing to do with typedefs. 😉