LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Referencing parent cluster from cluster element reference

I have a cluster with one text ring and several string controls. Based on the ring value selected I disable/enable appropriate string controls through an event. In the example I have two clusters and two event conditions. In the VI I want to eventually develop there will be several instances of the cluster, and each cluster will have several controls, with events on some controls.

In the example, if I combine the two event conditions into one event case, then CtlRef gives reference to the text ring. But to enable/disable string controls I need the reference to the associated cluster. Is there a way to get a reference to the parent cluster based on the reference to an element in the cluster? 

Thank you. 

Girish

0 Kudos
Message 1 of 7
(800 Views)

Hi girish,

 

Yes there is a way, use property "Owner" on the Control and cast it to a Cluster:

raphschru_0-1693579568958.png

 

Regards,

Raphaël.

Message 2 of 7
(778 Views)

Perfect. Thank you very much. Is there a limit on how many conditions can be associated with an event case? I am assuming it is quite large. 

Girish

0 Kudos
Message 3 of 7
(773 Views)

You should have kept it all in the original discussion. I still don't understand why you think you need to jump through all these flaming hoops while herding cats. 😄

 

(... and you should NEVER (NEVER EVER!!!) attach new code with the same file name as completely different code attached earlier.)

 

If your cluster has some controls that should not be operated, they can be set to disabled so they act as indicators. If you would make the value change on all elements as I suggested, you already have the reference to the parent cluster and it is easy for the code to find which element has actually changed by comparing Oldval vs. Newval from the event data node. (See my earlier example).

 

If you dynamically enable/disable certain controls based on state, make sure not to confuse the user. There should always be a clear distinction who has control over the values (user vs code).

 

 

(Are you aware that index array is resizable? Why is there a wait in the while loop? You don't have a stop event, so the VI cannot be stopped directly , just aborted)

0 Kudos
Message 4 of 7
(761 Views)

There may be a (large) limit, but I guess the condition will become very hard to maintain before you reach it.

If you have lots of similar clusters (maybe 5+), I would suggest having a generic way of listing them and doing a dynamic registration like this:

 

raphschru_0-1693581065035.png

 

Here I used "Traverse for GObjects" from the scripting palette to get all Rings, but there are other ways to list controls like the "Controls[]" property of the Panel class.

 

Regards,

Raphaël.

0 Kudos
Message 5 of 7
(756 Views)

Here's what I would do.

 

altenbach_0-1693582525285.png

 

Of course in the development environment you should have some initialization code that sets the value and disable status of all items when the VI starts (not shown).

 

0 Kudos
Message 6 of 7
(741 Views)

Of course you want to embed the code into a subVI (this one even resets the ring, easy to chage back if desired).

 

altenbach_0-1693583853105.png

 

I assume you also want to later handle event if one of the "in" strings have changed. That can be done with a simple case structure inside the existing event. just keep it simple!

 

0 Kudos
Message 7 of 7
(721 Views)