LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Updating cluster values, is there a better way?


Mark Yedinak wrote:

B O B wrote:

I believe the issue lies with the cluster size setting on the array to cluster function:

 

2009-11-25_140233.png

Right-click and select cluster size, then set this to 15 for your VI.  Let us know if this works!

 

-Bob




Preferred architecture aside, 17 is actually the correct size here, you will notice that he is using Replace Array Element and not autoindexing an array.  Hopefully he fixed the bug I pointed out since he should be using a SR with this method.  Not really necessary if he follows my example.

 

 The cluster order is not what he expects, but that shouldn't cause an error (I don't think).  In fact the only way I could get the same error was by setting the cluster size to 15.  With only a screenshot and not the code, it is just guesswork (my guess is that the cluster size is not what he thinks it is).

 

For the record, I agree in principle with the TypeDef argument, almost always a good idea for clusters.  However, adding complexity because you are having trouble with the simple case is usually a recipe for trouble.  Myself, I tend to stick to good old-fashioned arrays and if I need to I index with a text ring or enum instead of bundle/unbundle by name.

 

Message 21 of 29
(1,828 Views)

Good catch, I agree a shift register is necessary for the current architecture; I believe the default size for the array to cluster function is 8 or 9 elements.

 

Mark - I agree with your architecture example, there are several flaws with the current algorithm which your example resolves.  Great contribution!

 

I talked with one of the LabVIEW PSEs and will try to track down the AE assigned to this thread to ask them to file CARs for the lack of support/documentation for typecasting certain data types.

 

-Bob

 

 

0 Kudos
Message 22 of 29
(1,820 Views)

Well thanks for all the replies, but I have to leave this issue for now as I just got handed some "real" work...

 

I am sticking with my old ugly code for now as the examples were certainly more elegent...

 

I am not sure if they are "better" if months from now I can not remeber what it is doing or why I did that.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 23 of 29
(1,816 Views)

Darin.K wrote:

Mark Yedinak wrote:

B O B wrote:

I believe the issue lies with the cluster size setting on the array to cluster function:

 

2009-11-25_140233.png

Right-click and select cluster size, then set this to 15 for your VI.  Let us know if this works!

 

-Bob




Preferred architecture aside, 17 is actually the correct size here, you will notice that he is using Replace Array Element and not autoindexing an array.  Hopefully he fixed the bug I pointed out since he should be using a SR with this method.  Not really necessary if he follows my example.

 

 The cluster order is not what he expects, but that shouldn't cause an error (I don't think).  In fact the only way I could get the same error was by setting the cluster size to 15.  With only a screenshot and not the code, it is just guesswork (my guess is that the cluster size is not what he thinks it is).

 

For the record, I agree in principle with the TypeDef argument, almost always a good idea for clusters.  However, adding complexity because you are having trouble with the simple case is usually a recipe for trouble.  Myself, I tend to stick to good old-fashioned arrays and if I need to I index with a text ring or enum instead of bundle/unbundle by name.

 


I agree that keeping things simple has its advantages. However, too simple can be a problem too. Since he was trying to bundle a set of items that all have a specific meaning and context, the cluster is a better approach since it is self documenting. An array of references to log files can be difficult to keep track of. Which log file was at which index? What happens when I need to add or delete log files? Do I need to go through all of the code and find my magic numbers for the indices to specific log files? If he wants to always use an array then I would at least define an ENUM that helped to track which array element was which thing.

 

Of course this could also be handled using an action action or an array of clusters. Overall I don't believe the suggestion I posted is overly complicated and it does help make the code more readable (when accessing specific elements at other points in the code) and maintainable.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 24 of 29
(1,816 Views)

B O B wrote:

Good catch, I agree a shift register is necessary for the current architecture; I believe the default size for the array to cluster function is 8 or 9 elements.

 

Mark - I agree with your architecture example, there are several flaws with the current algorithm which your example resolves.  Great contribution!

 

I talked with one of the LabVIEW PSEs and will try to track down the AE assigned to this thread to ask them to file CARs for the lack of support/documentation for typecasting certain data types.

 

-Bob

 

 


It is very interesting, the list of unsupported types is growing:  Anything with pictures, anything with paths, 2+dimensional arrays, VISA resources, etc.  Not that I've wanted to Type Cast these things, but sometimes there are little tricks you can play (like the labels).  I always thought of the Type Cast as a shortcut for Flatten/Unflatten.  My feeling is that it is mostly a documentation thing, I am okay with most of the behavior.  Why a picture of all things is not supported I don't understand.   Thanks for some good info on this getaway day.

0 Kudos
Message 25 of 29
(1,807 Views)

Mark Yedinak wrote:


  Myself, I tend to stick to good old-fashioned arrays and if I need to I index with a text ring or enum instead of bundle/unbundle by name.

 


  If he wants to always use an array then I would at least define an ENUM that helped to track which array element was which thing.

 

 


I believe we are in furious agreement.

 

I do like your suggestion, and while not overly complex, is certainly more complex than a simple flatten/unflatten, which turns out to be more complex than the simple Type Cast I imagined.  I just wanted to make sure that we sorted out the simple case before moving on up.  I am here to fix his problem today, your here to keep him from having problems like this in the first place.  Smiley Wink

 

 

 

 

0 Kudos
Message 26 of 29
(1,787 Views)

Darin.K wrote:

It is very interesting, the list of unsupported types is growing:  Anything with pictures, anything with paths, 2+dimensional arrays, VISA resources, etc.  Not that I've wanted to Type Cast these things, but sometimes there are little tricks you can play (like the labels).  I always thought of the Type Cast as a shortcut for Flatten/Unflatten.


A type cast takes a bit pattern in memory and reinterpets it as the new data type. I haven't checked the documentation, but if memory serves, all these data types have pointers in them pointing to another location in memory (2D arrays definitely and I'm pretty sure paths and VISA resources are strings and the picture wire is also basically a string) - This means you can't simply use the bits, because the actual data is found elsewhere in memory and you have to follow the pointer.


___________________
Try to take over the world!
Message 27 of 29
(1,763 Views)

Get the Control[] property of the cluster and you can easily loop through all fields, especially as you have a nice array of paths to start out with (which can be built from 2 simple nested loops, one 1-5 and one with the 3 names).

 

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 28 of 29
(1,747 Views)

Something like this should work. Also note my simplified creation of your 2 arrays.

/Y

 

Cluster

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 29 of 29
(1,745 Views)