02-23-2012 09:38 AM
Importing the snippet should work fine in 2010. Save the image to your HD first or rebuild the code yourself.
If the word "dynamic" confuses you, just ignore it and use "at run time" instead.
The key for dynamic events is the register for events node - this determines which events you will be able to select in the event structure. Each row in the node is a single event, which you select based on the input to that row. The wire that comes out of the nodes holds the types of dynamic events the event structure will be able to process and once you wire it into the structure, you can select those events. At run time, the events are only registered when the node executes.
I can't really think of an example which will be much simpler than the one I posted. Look at that and at the other shipping examples.
02-23-2012 09:49 AM
Go back and look at Ton's example again.
He dynamicly turn the events on and off. he turns them on by registering them for real controls. He turns them off by registering them against a constant.
That can not be done using static events.
Ben
02-23-2012 12:54 PM
Thank You NIquist!! That "article" as I would put it, answered some and brought more questions to my mind. But, it is clicking in a little bit.
Again, in the true sense, I still do not see the absolute need for dynamic or "run-time" registration. The example that is used for dynamic registration there in the article doesn't quite explain it . And honestly, I don't know if there are any keywords that would wire my brain in the right direction.
I can understand static events. You have some application,vi or control on the front panel that the event structure monitors and any change generates an event as coded in the event structure. I get that part and no qualms about it.
When I look at the code for dynamic event registration, I see that the reference of the control/vi/application is sent to the Register for events function. Am I to understand that this facilitates handling events or generating events in subvi's as well and this is one of the purposes of dynamic registration?
In the example for dynamic registration in the article, I see a reference of string is wired to register the event of any change in value of the string. Now, why can't that be done directly but editing events to handle the control for change in value? What makes it dynamic when references are passed?
Although, I get the second example where modifying an event registration can be done dynamically, where it shows that the value change of numeric changes registration to numeric 2 and from there on, only value change in numeric 2 results in an event generated. Still, this has been coded before the program runs, a.k.a. static, but I can see how the registration is changed during run-time "dynamic" . It is I guess how you look at it, and I am trying to look at it the right way.
02-23-2012 01:02 PM
@tst, I ran the program you sent. It does look to me like the name suggests IS for numeric 2. Even though the type is numeric, No event is triggered for numeric 1. Am I missing something here?
02-23-2012 01:02 PM
VeeJay wrote:
Again, in the true sense, I still do not see the absolute need for dynamic or "run-time" registration.
There is no "absolute need". There are places where dynamic events are useful and places where they are unneeded.
Am I to understand that this facilitates handling events or generating events in subvi's as well and this is one of the purposes of dynamic registration?
Yes, handling events in subVIs is one use of dynamic events.
In the example for dynamic registration in the article, I see a reference of string is wired to register the event of any change in value of the string. Now, why can't that be done directly but editing events to handle the control for change in value?
It could be done directly, but you wanted a simple example and NI gave you what is probably the simplest example - using a dynamic event as a direct replacement for a static one.
02-23-2012 01:04 PM
@VeeJay wrote:
@tst, I ran the program you sent. It does look to me like the name suggests IS for numeric 2. Even though the type is numeric, No event is triggered for numeric 1. Am I missing something here?
Like the comment says, ignore the name. The event is registered for whichever control comes through the select primitive. That depends on the value of the boolean when you run the VI.
02-23-2012 01:08 PM - edited 02-23-2012 01:11 PM
@tst wrote:
@VeeJay wrote:
@tst, I ran the program you sent. It does look to me like the name suggests IS for numeric 2. Even though the type is numeric, No event is triggered for numeric 1. Am I missing something here?
Like the comment says, ignore the name. The event is registered for whichever control comes through the select primitive. That depends on the value of the boolean when you run the VI.
I ignored the name. Whether I selected TRUE or FALSE on the Boolean, only Numeric2 triggers an event and increments its value. Nothing happens on Numeric1. So, the event structure handles only events from Numeric2??
Numeric1 changes value just like any other control. Only when I click on the '+" sign on the control
Numeric2 changes value whether I click on the increase button, or the entire area of the control. it always increases by 1. And also whether boolean is TRUE or FALSE. hmmmmmmm...!!!
02-23-2012 01:11 PM
@tst wrote:
VeeJay wrote:
Again, in the true sense, I still do not see the absolute need for dynamic or "run-time" registration.
There is no "absolute need". There are places where dynamic events are useful and places where they are unneeded.
Am I to understand that this facilitates handling events or generating events in subvi's as well and this is one of the purposes of dynamic registration?
Yes, handling events in subVIs is one use of dynamic events.
...
Maybe those examples are just too simply and fail to illustrate the use.
Try looking at teh Docking example I posted at the end of this thread.
That example shows how VI's running in sub-panels can be "undocked" from the sub panel so you can view it in a seperate window. TO get it to work, I used daemons running in the background watching the buttons used for each sub-panel. Each daemon watched a unique set of buttons but the code uesed in each daemon were the same.
By using Dynamic Events I could let each daemon register for events for different controls.
Dig into that example to see how dynamic event can be used.
I will also use dynamci events in sub-VI to monitor the controls associated with a particular mode the applicatino is running in as shown here.
I hope that helps illustrate some uses,
Ben
02-23-2012 01:18 PM
VeeJay wrote:I ignored the name. Whether I selected TRUE or FALSE on the Boolean, only Numeric2 triggers an event and increments its value. Nothing happens on Numeric1. So, the event structure handles only events from Numeric2??
The boolean read and the registration only happen when the VI starts running (run it in highlight exec to see it). If you want it to work on numeric 1, you need to stop the VI, set the boolean to T and then run the VI.
As an exercise, modify the VI so that changing the value of the boolean while the VI runs also changes which numeric is affected by the event.
02-23-2012 01:36 PM
Ok so here is what I have modified. And it works. So in effect, dynamic registration is forward thinking in a way, Yeaaa???
Please see the file attached. In what cases would dynamic registration be beneficial? or scenerios ? and Please not the obvious answer 🙂 Any unique but general use would be awesome. Thanks!