LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

iterate cluster elements

Solved!
Go to solution

Dear all,

I have a cluster with many elements of the same type. I want to manipulate any of them the same way, however keeping their labels. My solution does work, however, it is prone to mistakes from wrong wiring an its not actually scalable. do you have any better idea?

Thanks!

indexBundle.PNG

0 Kudos
Message 1 of 10
(6,245 Views)

Typecast Cluster.png

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 2 of 10
(6,238 Views)
Solution
Accepted by topic author OPCer

RubeGoldberg alarm! 😄

 

What's the problem with applying the math function on the cluster directly?

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 10
(6,229 Views)

I was for some reason totally convinced the numeric functions (add,....) woul only work on doubles. thanks for pointing this out!

 

0 Kudos
Message 4 of 10
(6,216 Views)

what if i didnt want to add but apply a digital filter?

cluster filter.PNG

assuming this cluster comes in every iteration with 4 new data elements .... and i have 10 clusters with total 50 data elments

0 Kudos
Message 5 of 10
(6,158 Views)

Hi OPC,

 

why did you create a new account?

 

what if i didnt want to add but apply a digital filter?

Then you should rethink your datatype design!

 

At first you should use type definitions with clusters - in your image you didn't do this.

 

And when you want to apply a filter to a variable number of data elements you should use an array. It doesn't make sense to use a cluster: you cannot create subVIs which accept any kind of cluster… (Well you could work with polymorphic VIs, but you would need to create a new one for each cluster.) Quick&easy approach: use an array for channel names and an array for values.

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 10
(6,137 Views)

thanks for your reply!

... account details lost Smiley Frustrated

 

>> Then you should rethink your datatype design!

I kind of do this for every new project i make, learning by doing

the reason why i didnt wnat to use an array in first place is because i want every channel to have its name, otherwise i will get totally lost. thats why I tried for this project to go with "bundle by name".

 

the filter i have in mind only accepts doubles, not arrays.

 

to be honest i am doing some guesswork to put together your recommendation. is that what you have in mind:

cluster filter2 .PNG

now if i want to do something specific to f D2, i do have to index array and count wires, right?

Thanks again!

 

 

0 Kudos
Message 7 of 10
(6,118 Views)

Hi OPC,

 

is that what you have in mind

You're halfway…

I would only use a cluster like you create on the right side of your image: two arrays holding names and values.

And use this cluster in the whole application: no need to bundle by name or convert cluster to array and back…

 

Btw. this is also halfway to using variant attributes aka key-value-pairs!

 

Also note that using a PtByPt-Filter like you do will result in garbage after filter…

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 10
(6,111 Views)

Using the Autotestware Cluster Toolkit 2.0.0.4 Cluster can contain elements of different types. VI can be modified to execute functions based on an element’s data type, name, or position in cluster.

iterate cluster elements.png

Download All
Message 9 of 10
(5,918 Views)

[edit : where is the delete button for dispensable posts?^^]

0 Kudos
Message 10 of 10
(5,830 Views)