LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

change a cluster element value

Solved!
Go to solution

I have an array of clusters and each cluster has dozens of controls in it. I want to go through all the array clusters and change the value of a specific control. Right now, I am using the value property node of the array to get a 1-d array of clusters, looping through it, unbundling each cluster, change value of one element, bundling it back into a cluster, and then giving it back to the array using the value property node again. This works fine but maybe there is a simpler way to do it. With the current method, it is probably using more RAM too because it has to copy all the data.

Message Edited by abdel2 on 12-24-2008 11:44 PM
0 Kudos
Message 1 of 8
(17,591 Views)

It would really help if you could attach a simplified version of your code so we understand what you are talking about.

 

A value property node gives the same as the original array of clusters, so I don't understand why you need to do this detour.

 

Don't forget the "in place element structure", it might just be the ticket here. 😉

0 Kudos
Message 2 of 8
(17,571 Views)

HI,

 

           I have attached the screen shot of the vi which replaces with a new value to the specified array of elements in the cluster. It is very similar to your requirement. Hope this may help you.

0 Kudos
Message 3 of 8
(17,561 Views)

(Please always attach an actual VI. It is very difficult to troubleshoot or edit a code image. ;))

 

Anyway, your use of value property nodes is completly misguided here, they just introduce additional overhead and complicate the code! Why???

 

All you need to do is (1) read fom the input terminal, (2) modify the array element using "replace array subset", and (3) write the result to the output.

If you want to also write it back to the control, use a local variable.

 

(Depending on the rest of the code, you might also want to keep the array of clusters in a shift register.)

 

Message Edited by altenbach on 12-25-2008 10:12 AM
0 Kudos
Message 4 of 8
(17,532 Views)

Sorry, I have attached part of the code. The blue line coming in from the right is the index of the array that was selected.

Both of the above diagrams work fine but I have to give value for all the elements in the cluster. This can get tedious if there are a lot of elements in the cluster. In my diagram I only have to wire one value and "bundle cluster" takes others values from the wired cluster. I noticed, if I modify the cluster, the for loop index does not wire to the correct element in the cluster (in this case a "#" element). I have to rewire it.

Is this a good way to change one element?

 

PS: Sorry about the diagram layout. I am using Labview 8.5 right now so I don't have the feature that automatically aligns everything properly.

Message Edited by abdel2 on 12-25-2008 03:29 PM
0 Kudos
Message 5 of 8
(17,515 Views)
Please attach the actual VI.
0 Kudos
Message 6 of 8
(17,509 Views)
Solution
Accepted by topic author abdel2

abdel2 wrote:

I noticed, if I modify the cluster, the for loop index does not wire to the correct element in the cluster (in this case a "#" element). I have to rewire it.


I have no idea what you mean by that. Can you give an example? Rewire it how? What's with all that song and dance with the value property nodes and "insert into array"?

 

Please attach a real VI containing a cluster with typical data as default values. Also include a cluster that contains the output you want. It is usually, easier to use "bundle by name" because the code is more readable, e.g. as follows.

 

Message Edited by altenbach on 12-25-2008 01:59 PM
0 Kudos
Message 7 of 8
(17,504 Views)

Since I was showing all the elements of the cluster and wiring a different value to only one of them. Modifying the actual cluster on the front panel obviously added or deleted some elements in the code. After doing that, the wire (loop index) did only point to the correct element.

Anyways, it doesn't matter. You code is exactly what I was looking for...using bundle by name instead of just bundle. Thanks!

0 Kudos
Message 8 of 8
(17,500 Views)