04-18-2007 04:12 PM
@wpolk wrote:
Is that so different from inserting a subpanel?
Yes, because user events do not necessarily have to deal with UI elements and because the event can be handled for a control in the caller VI (or any other VI). You can even make the subVI reentrant and have it handle multiple controls.
See the attached for a very quick example of how a generic tool would look like. In this case, for example, I went with Ton's idea of picture controls and I made a generic process which will draw points in picture controls.
BTW, this quick example has some bugs in it. For example, it's slightly off. Also, it doesn't take the origin property into consideration. It also has a race condition, since the value of the image can be changed from elsewhere after it's read and before it's written, but this just shows the concept.
Some other nice things about user events:
The event refnum is typed, so it holds all the event data. That means (as Tomi mentioned) that you can use them to pass data around. See for example the stop event in my example which reads the value from the event structure terminals. You can create complex structures for this.
If you don't wire anything into the dynamic event terminal on the right side of the event structure, it will retain the same information it had when it entered your case. You can use this to do state machines where you don't have to wire your data cluster through events where it is not needed, because it will simply be passed through.
04-18-2007 08:46 PM
Excellent Nugget Ton. Right to the point and you sure pushed my knowledge.
Your example will be incorported into future designs I am sure. When I have done similar apps I was faced with the issue of CPU spinning away because of the events.
My use of dynamic event registration has been mostly DSC event.
I liked tst's example so much I made a couple of changes for Ton .
Thank you and feel free to post more when the inspiration hits you.
Ben
04-19-2007 05:11 AM
Another BTW - you can also use this to register the same event for several controls if you build their references into an array and wire that array into the registration node.
If you build a cluster out of those references, you will get a single event for each reference in the cluster.
05-13-2007 10:32 AM
Please see this thread for more discusions reagarding the nature of events.
Ben
05-13-2007 09:30 PM
@TonP wrote:
I was not fully sure this was necassary, I thought this only was needed for user events because you have to destroy those.
02-24-2008 03:12 PM
03-05-2008 07:13 AM
03-05-2008 07:25 AM
03-05-2008 07:35 AM
07-21-2008 07:53 AM