LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

passing and defining clusters

Hello Labview forum,

I wish to pass a cluster of input parameters to a number of different subVIs.  However, whenever I change my mind of the cluster composition, add another element, I have to go the all the subVIs that use it and redefine it there too.
Is there a way to get around this so I only have to redefine the cluster once?

I can think of 2 possible ways of achieving this but am not sure how or whether labview does them?
   1) Define a a cluster in a central location.  All subVIs look at this definition.
   2) Pass the cluster by reference and the subVIs can then unbundle components by name.

Any ideas?

Regards,
Jamie
Using Labview version 8.0
0 Kudos
Message 1 of 8
(3,872 Views)

Hi Jamie,

      You're describing a "typedef" Smiley Wink  After you create the cluster, select it and, while it's selected, choose Edit\Customize control.  When the control editor opens, change the "typedef status" pull-down-menu from "Control" to Type Def. - then File\save.  Whenever you need a copy of the control, right-click on the front-panel (or diagram) and select the ".ctl" file you saved.  Now all the copies will be updated by changing the (one) typedef. Smiley Happy

Cheers! 

Message Edited by tbd on 02-02-2007 02:08 AM

"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
Message 2 of 8
(3,870 Views)
Thanks tbd,

I have create 2 typedef controls for 2 different clusters I have.
However, one of them has undesirable behaviour and I don't know why.

When I load the VI, cluster A's elements are all set to 0 instead of my default values.  Also, if I change the values and save the VI, the cluster's values get reset to 0.  In the saved control the cluster has the desired default values so this isn't the problem's cause.
Also, the VI now always has an asterix in the title bar, usually indicating changes have been made since the last save.  However, even after I click save, the asterix is still there.

On the other hand, cluster B has my desired qualities where it remembers default values and loads to them.

How can I fix cluster A?

Regards,
Jamie

PS
Another bit of strange behaviour I noticed was when I right click on the control in the VI front panel, there is the option to open the typedef.  However, if I have already opened the typedef for the other cluster control, then the option is no longer available.
Using Labview version 8.0
0 Kudos
Message 3 of 8
(3,828 Views)
Hi Jamie,


When I load the VI, cluster A's elements are all set to 0 instead of my default values.  Also, if I change the values and save the VI, the cluster's values get reset to 0.


After opening the VI, set your desired values in cluster-A then right-click on the border of cluster-A and select "Make current values default".  Close the VI and open it again - the default values should be there.  If not, please post your VI!  Smiley Happy

Note: there's a bug in LabVIEW (at least in 6.1 and 7.1) related to setting a default-value for clusters!  If the cluster type-def is changed, "default" cluster values can be corrupted!  For this reason, I'd advise against using default values with typed-clusters. Smiley Wink


Another bit of strange behaviour I noticed was when I right click on the control in the VI front panel, there is the option to open the typedef.  However, if I have already opened the typedef for the other cluster control, then the option is no longer available.

This is normal!  We're only allowed to edit one type-def "thread" at a time.  You'll eventually notice that if a "parent" cluster type-def contains a "child" type-def, then we are allowed to open/edit one child at a time.  This brings-up another quirk associated with type-defs.  If you open/edit a child type-def independently of a parent type-def, the parent may become broken until opened and saved. Smiley Surprised

I don't know what's going-on with the asterisk!

Hope it helps!

Message Edited by Dr.Ivel on 02-15-2007 12:27 AM

0 Kudos
Message 4 of 8
(3,817 Views)


@Jamieg wrote:
Thanks tbd,

I have create 2 typedef controls for 2 different clusters I have.
However, one of them has undesirable behaviour and I don't know why.

When I load the VI, cluster A's elements are all set to 0 instead of my default values.  Also, if I change the values and save the VI, the cluster's values get reset to 0.  In the saved control the cluster has the desired default values so this isn't the problem's cause.
Also, the VI now always has an asterix in the title bar, usually indicating changes have been made since the last save.  However, even after I click save, the asterix is still there.

On the other hand, cluster B has my desired qualities where it remembers default values and loads to them.

How can I fix cluster A?

Regards,
Jamie

PS
Another bit of strange behaviour I noticed was when I right click on the control in the VI front panel, there is the option to open the typedef.  However, if I have already opened the typedef for the other cluster control, then the option is no longer available.


The default data is associated with the VI not with the typedef. You usually don't want the default data to change in all VIs when you make modifications to the typedef. But as Dr. Ivel said there has been a bug in older LabVIEW versions where modifying the cluster typedef made all controls loose their default data and return to LabVIEW's default default data. Means they revert to empty strings, 0 for numbers, etc.

Rolf Kalbermatter
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 5 of 8
(3,805 Views)
Thanks for your help all.

As I'm using Labview 8, lets inform everyone that the bug of typedef clusters losing their user defined default parameters identified in labview versions 6.1 and 7.1 has made its way to labview 8.

Cheers,
Jamie
Using Labview version 8.0
0 Kudos
Message 6 of 8
(3,762 Views)

I feel like Oliver Twist asking for "more" when I post counter to Rolf but here goes.... Smiley Surprised

The loss of the defaults fo a type-def'd constants on the diagram is "by design" and not a bug.

There is a check in the VI Analyzer that looks for type-def'd constants that are NOT the default and warns you if it find them.

I would prefer the "design" be different than it is but....

The proper way to do this is to use "Bundle by name" to set the non-default values as required. You can put this in a sub-VI and re-use that set of settings if need be.

Ben

PS : please forgive me Rolf! Smiley Wink

Message Edited by Ben on 03-01-2007 07:50 AM

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 7 of 8
(3,750 Views)
Hi Jamie,
      I think you make a good point!  Not to disturb the slumbering of "Giants" (who I continue to learn from ;^) ) but as of 8.2 LabVIEW still doesn't handle cluster typdef changes well!  We can change the names and types of numeric types in a cluster typedef and LabVIEW will go right ahead and assign our Default-values as if nothing had changed.  It seems LabVIEW does figure-out more radical type-changes - at which point our Default-values are no longer applied.
 
I think a VI should break if defaults have been assigned to a cluster but the type-def changes.  I don't think LabVIEW should apply old data to new types, or, essentially, modify the source-code by silently removing defaults assigned to some cluster-elements that haven't changed! Smiley Surprised
 
We use typedefs because we DON'T want to have to edit source-code everywhere the type is used.  It's not safe to use Default values for typedef'd Clusters; the most obvious alternative is to explicitly assign the defaults - like Ben said! Smiley Happy
"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
0 Kudos
Message 8 of 8
(3,716 Views)