LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to set multple values in cluster with local variable?

Solved!
Go to solution

Hello all,

 

Ok, I've made my way through Labview for everyone, and have some basic concepts down. I can see with a cluster, if acting directly upon it, you can unbundle, change values, rebundle, etc.

 

I'm trying something a bit more complex...and just not sure how to get started on this.

 

I have a drop down menu ring. I have set this up as a typedef, with 4 values.  I have used this typedef 7 times, plus some LED bools, in a cluster. I have made this cluster a typedef.

 

So, in my main vi I"m starting to design, I've set up an example posted here....and in it, I have two instantiations of the cluster typedef, Left Selector and Right Selector.

 

I have dropped into this vi, a copy of the menu ring typedef (same typedef as in the clusters, same values)....called reset all tubes.

 

I'm trying now, to figure out how, with an event on the change of value for 'reset all tubes'....that I can start with the left selector, and change all the tubes (these are the menu ring selector)  to the same value as what has been selected with the 'reset all tubes' menu ring.

 

I've created a local variable for the left selector. It is set to read values. (I'll be doing the same with the right one too, but just starting with the left).

 

In examples I've seen where directly accessing a cluster, you could unbundle the cluster...loop through and change the values...maybe pull out all of the 'tubes' into an array and move through that to update the values.  And when you bundle or unbundle the cluster...you can see the values, etc, when you stretch them out on the block diagram.

 

With the local variable..I can't see to 'stretch' it out like I was expecting..so I can access the values for the 'tubes'...and set them all to the value of the 'reset all tubes' ring menu value.

 

Can someone put me on the path on the best way to do this....or is there a structure of component I'm missing here ?  Am I on the right track to begin with here?

 

This would seem pretty basic to me, but I'm just missing something here on how to start...

 

Thank you in advance,

 

cayenne

0 Kudos
Message 1 of 8
(3,260 Views)

Hello all,

 

I've been trying to work this out...and I think I'm getting closer?

 

I'm bringing in my cluster into the event of a value change for 'reset all tubes'.

 

In there, I'm unbundling by name, to just select the tubes 1-7. I'm building an array from that. I've attached a size of array component to this.

 

I put this into a for loop, using the size of array as the count terninal.  I'm feeding the value of the 'reset all tubes' control into the for loop.

 

I'm trying at this point, to use a Replace Array Subset (also have tried the Insert Into Array) to try to loop through the array replacing each value with the 'Reset All Tubes" control value.

 

I can hook the value into the Replace Array Subset, I can hook the index of the For Loop into the Replace Array Subset, but I get errors trying to hook the array coming into the For Loop into the Replace Array Subset.

 

Help says it is expecting an array...but it gives me an error about trying to put a scalar type into an array of that type...but I don't see how that is happening, since the output of the Build Array should be an array, right?

 

I've attached my updated vi for this....any suggestions?

 

I figure once I get this update loop done, I'm closer to writing to the Left Selector local variable....

 

Any suggestions?

 

Thanks in advance,

 

cayenne

0 Kudos
Message 2 of 8
(3,248 Views)

Ok, found one error...in the For loop, I changed the tunnel to a shift register, and that took care of the broken wire error.....I'm not 100% sure why, but I think I partially understand that.

 

Anyway, still working, but could someone tell me if I have to go the cluster to array.....interate throught he array to change the like values...then somehow (I don't know how yet) put those array values into the cluster variable?

 

 

Thank you,

 

cayenne

0 Kudos
Message 3 of 8
(3,243 Views)

Down-convert your code to 8.5.

-----------------------------------------------------------------------------------------
Reese, (former CLAD, future CLD)

Some people call me the Space Cowboy!
Some call me the gangster of love.
Some people call me MoReese!
...I'm right here baby, right here, right here, right here at home
0 Kudos
Message 4 of 8
(3,237 Views)
Solution
Accepted by cayenne

You can't do this with a for loop the way the cluster is structured, but why make it so complicated?  Just bundle the new value into the cluster as shown below:

bundle to local var.PNG

If you do want to use a for loop, consider restructuring your cluster.  Group the ring and a boolean into a cluster, then drop 7 of those into the selector cluster.  Then you can use "cluster to array" and "array to cluster" since all elements in the outer cluster will be of the same type.

 

Also, be careful using rings as type definitions.  You probably want to use an enumeration instead.  The items in a ring do not update when you update the type definition because they're considered to be cosmetic; the items in an enumeration type definition do update, because the items in an enumeration are considered part of the data type.

Message 5 of 8
(3,230 Views)

@nathand wrote:

You can't do this with a for loop the way the cluster is structured, but why make it so complicated?  Just bundle the new value into the cluster as shown below:

bundle to local var.PNG

If you do want to use a for loop, consider restructuring your cluster.  Group the ring and a boolean into a cluster, then drop 7 of those into the selector cluster.  Then you can use "cluster to array" and "array to cluster" since all elements in the outer cluster will be of the same type.

 

Also, be careful using rings as type definitions.  You probably want to use an enumeration instead.  The items in a ring do not update when you update the type definition because they're considered to be cosmetic; the items in an enumeration type definition do update, because the items in an enumeration are considered part of the data type.


Oh my goodness!!

 

What was MUCH easier than I was trying to make it!!

 

I was attempting to do this reset, in an incremental fashion, as that later, I'm going to need to change values in this cluster by individual elements....and was using this as a way to try to understand how to iterate between cluster elements, and change the values of each one.

 

This solution works much better for this 'reset' all solution.

 

One question on this....with regard to the enum vs the ring menu.

 

I was actually going to go with the enum, however, I could not find a way to make it LOOK like the ring menu...with the arrow to the side that a user would know to click to present the menu list of choices.

 

I see with the enum, that you can remove the increment/decrement indicator.....and if the user clicks the control, it will indeed pop up a menu of choices...but there is no 'arrow' on that control to indicate to the user that it is a menu choice there.....

 

Is there a way to make and enum look like a ring with the "drop down menu" control look?

 

Again, thank you !!

 

This helps!

 

C

 

 

0 Kudos
Message 6 of 8
(3,224 Views)

cayenne wrote:

I was actually going to go with the enum, however, I could not find a way to make it LOOK like the ring menu...with the arrow to the side that a user would know to click to present the menu list of choices.


As annoying as it sometimes can be in LabVIEW, it's a bad idea to let aesthetics determine your data types.  I usually use a System enumeration, it looks more like a drop-down menu.

Message 7 of 8
(3,212 Views)

@nathand wrote:

cayenne wrote:

I was actually going to go with the enum, however, I could not find a way to make it LOOK like the ring menu...with the arrow to the side that a user would know to click to present the menu list of choices.


As annoying as it sometimes can be in LabVIEW, it's a bad idea to let aesthetics determine your data types.  I usually use a System enumeration, it looks more like a drop-down menu.


LOL..ok, thank you for the great input!!!

 

I"ll go back and mark your original answer as solving this problem.

 

Again, MUCH appreciated!

 

C

0 Kudos
Message 8 of 8
(3,208 Views)