06-20-2012
07:05 AM
- last edited on
04-30-2025
08:56 AM
by
Content Cleaner
Hi,
I've been following : http://zone.ni.com/reference/en-XX/help/371361H-01/lvconcepts/user_events/ but cannot seem to get it to work to trigger from a boolean generated event.
Any suggestions?
LV2011 Code attached
ds1
06-20-2012 07:12 AM
For me it is working. Maybe you could explain what is not working for you or rather what do you want to have?
Personally I prefer that boolean have the mechanical action "Switch When Released", but that's my 2 cents.
06-20-2012 07:25 AM
What exactly you want to achieve if you can explain then it would be good to get a clear solution. Do you really want to use the Register events design?. or you have opted since its given in the example?
06-20-2012 08:46 AM
Sorry, I wasn't really that clear. I wish to call this as a subVI. Passing e.g "WRITE CONTROL", "WRITE DAC" or "READ CONTROL" value change USER Event to this subVI and executing the required event
06-20-2012 08:59 AM
You've registered for a User Event. And you've generated the User Event. But both of those are kind of pointless considering you did put an event case in your event structure to handle the User Event.
06-20-2012 09:07 AM
OK perhaps I'm tacling this the wrong way. I wish to make some existing Event Structure VI's execute as subVI's where the the callers pass simulated button presses (boolean control value change events) to my subVI.
To do this would I have to duplicate every Event I wish to control and give it a USER EVENT or is there a way to register/generate a VALUE CHANGE event?
06-20-2012 09:19 AM
From the link I provided it suggests that they can share the event:
"To simulate user interaction with a front panel, you can create a user event that has event data items with the same names and data types as an existing user interface event. For example, you can create a user event called MyValChg by using a cluster of two Boolean fields named OldVal and NewVal, which are the same event data items the Value Change user interface event associates with a Boolean control. You can share the same Event structure case for the simulated MyValChg user event and a real Boolean Value Change event. The Event structure executes the event case if a Generate User Event function generates the user event or if a user changes the value of the control."
I just don't understand how. Perhaps this could be explained more clearly
06-20-2012 09:32 AM
A given event case can be shared among different events. See the attached modification of your VI where I added the User Event to the same case that handled the value change event.
06-20-2012 09:38 AM
Hi thanks!! I had just discovered this, I had in my head from previously that each case could only be handled by 1 event but I guess it makes sense that User Event can share.
So if I have several button I wish to control on the VI I need to register a new User Event for each one? I'm beginning to think I'd be better avoiding Event Structures if there is any chance I might need to use the VI as a SubVI. (i.e. always!)
06-20-2012 08:23 PM
Maybe, maybe not. Do all the boolean buttons do different things or similar things? Do you need a 1 to 1 relationship between each user event and each boolean button?
You can register for multiple user events for the different booleans at the same time.
If the boolean value change events are similar (perhaps same action on different buttons) you can use the CtlRef terminal inside the event structure to get a reference to the particular boolean that caused the event and work with that with various property nodes. Just figure out what things the different buttons and events have in common and group them in a logical way that allows you to combine events.
Another idea. You have the user event do nothing but fire the button's value change event where you put all the code doing the real work. Or vice versa. You just have one event case fire the other event case. If you do this just be careful that you don't create a loop where the user event fires the button's event which fires the user event which fires the button event ......
There are lots of way to use events and the event structure and pass information from a main VI to a subVI. User and/or dynamic events give you a higher level of flexibility then the events that are just defined statically during editing. You can pass references of controls to subVI's. Figure out what you need to do, then try the concept out in a simple VI to see how it works before building into your real VI.