05-28-2015 01:09 PM
Hey All,
I am wondering if there is a better way to handle controls while in an event structure. Here is a common scenario:
I have multiple controls on the front panel (buttons, slides, etc...) I use button 'A' to enter an event case that contains a while loop. What i want is for all controls EXCEPT button 'A' to be disabled, because i am using button 'A' as the while loop stop condition (as well as the event case action). Since the event case automatically disables the controls until the case has finished I go in and uncheck this, that then leaves me with a mess of property nodes so that all controls besides button 'A' are disabled. Once the user has stopped the loop by using button 'A', i again need to deal with property nodes to re-enable all of the controls on the front panel.
Is there a cleaner, more efficient way to handle things like this?
05-28-2015 01:15 PM - edited 05-28-2015 01:17 PM
I suspect others will soon reply suggesting to change your architecture to producer consumer, mast slave, QSM etc but to reply to your question as stated, you may want to concider dynamic event registration.
Dynamic Event registration will let you control what is regestered for events when and if you re-register an event against a constant yu can effectively shut off the event.... Asuming the user has not punched 12 controls at the same time.
Ben
05-28-2015 02:48 PM - edited 05-28-2015 02:49 PM
You can write a quick sub VI that disables all controls on the calling VI's front panel, then explicity enable the ones you want. That control reference is returned in the event structure.
Obligitory state machine / QMH comment.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
05-28-2015 03:04 PM
Wow, that dynamic event registration is really cool. Thanks for the link to it (even though this isn't my thread).
For bulk disabling controls, I created a VI that does it with references. Pass in an array of control references and disable/enable them in an autoindexed for loop. It cleans up the BD a lot but you still have to wire up the proper references to the VI, which could be cumbersome depending on the number of controls you have.
05-28-2015 03:12 PM - edited 05-28-2015 03:14 PM
I recently wanted to do this as well. In this .vi you can pass in an array of strings with the names of the controls that you want to enable or disable.
05-28-2015 03:16 PM
aputman - that's a pretty cool icon!
05-28-2015 03:17 PM
@Gregory wrote:
I recently wanted to do this as well. In this .vi you can pass in an array of strings with the names of the controls that you want to enable or disable.
I like the reference thing better. What happens if you change the names of the controls?
05-28-2015 03:20 PM
Well, I think we both know the answer to that 😛 Good point though, it could be a lot of work if you change the control names!
05-28-2015 03:23 PM
I usually make a typedef'd cluster of control references to do this. That way you can add a new reference to the typedef and all instances get updated, too.
05-28-2015 03:25 PM
How do you get the reference into a typedef? I only know how to right click on a control and create reference.