09-01-2023 09:14 AM
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
09-01-2023 09:47 AM
09-01-2023 09:54 AM
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
09-01-2023 10:11 AM - edited 09-01-2023 10:18 AM
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)
09-01-2023 10:14 AM
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:
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.
09-01-2023 10:35 AM - edited 09-01-2023 10:37 AM
Here's what I would do.
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).
09-01-2023 10:59 AM - edited 09-01-2023 11:05 AM
Of course you want to embed the code into a subVI (this one even resets the ring, easy to chage back if desired).
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!