Visit the LabVIEW Wiki Application Design & Architecture Portal
Tags |
(This content has not been tagged yet)
|
![]() |
Jun 28 2003, 05:30 PM
Post
#1
|
|||
![]() Confucius say: Crowded elevator always smell different to midget Admin ![]() Posts: 2363 Joined: 13-October 02 From: Planet Earth Member No.: 2 Using LabVIEW Since:1994 LV:8.5 ,8.2.1 ,7.1.1
My Blog
My Gallery
|
In another post, Jim Kring suggested using callback vi's in his own development.:
QUOTE I have figured out one use for this: defining a callback VI that will be called by reference. Take a look at the ActiveX Event Callback examples. This design pattern actually looks pretty useful. I think that I will explore the possibilities of using callback VIs in my own reuse tools and components. The first thing I thought was that there is no mention of using callbacks outside of activex so this is probably not possible is it? The labview documentation limits callbacks to activex. Why?--- Now, if only the LabVIEW documentation would have done us the favor of mentioning this... QUOTE event source ref accepts an ActiveX automation reference. Click the down arrow next to this input and select the type of event you want to generate, such as Mouse Down or Double Click. References must be to local objects. You cannot wire a reference to a remote object. I did some digging and experimenting and realized you can create a callback for any event. Now that's cool! Check out the attached example. Now the next step is to figure out how to assign callback vi's dynamically. :wink:
Attached File(s)
--------------------
|
||
|
|
|||
| Ad |
Jun 28 2003, 05:30 PM
Post
#
|
||
|
|
|
||
|
|
|||
Jun 28 2003, 06:51 PM
Post
#2
|
|||
![]() Confucius say: Crowded elevator always smell different to midget Admin ![]() Posts: 2363 Joined: 13-October 02 From: Planet Earth Member No.: 2 Using LabVIEW Since:1994 LV:8.5 ,8.2.1 ,7.1.1
My Blog
My Gallery
|
Someone asked me how would I pass data back to the caller.
Well, it is really simple since you would use the user parameter. I've attached a modified version with data sent back to caller. This would be the easiest method, however you can wire anything into this even a queue reference if you please. then data can be tossed onto a queue.
Attached File(s)
--------------------
|
||
|
|
|||
Jun 28 2003, 08:15 PM
Post
#3
|
|||
|
Changing the world, one VI at a time. JKI ![]() Posts: 1692 Joined: 22-October 02 From: San Francisco, CA Member No.: 17 Using LabVIEW Since:1995 LV:8.2.1 ,8.5 ,7.1.1
My Blog
My Gallery
|
QUOTE I did some digging and experimenting and realized you can create a callback for any event. Now that's cool! Check out the attached example. Now the next step is to figure out how to assign callback vi's dynamically. :wink: It also works with User Events. Check out the attached example. The event userdata includes a notifier for sending a response back. This pattern is going to make plug-in architectures and components that expect callback VIs very powerful. -Jim
Attached File(s)
--------------------
|
||
|
|
|||
Jun 28 2003, 08:22 PM
Post
#4
|
|||
|
Changing the world, one VI at a time. JKI ![]() Posts: 1692 Joined: 22-October 02 From: San Francisco, CA Member No.: 17 Using LabVIEW Since:1995 LV:8.2.1 ,8.5 ,7.1.1
My Blog
My Gallery
|
The "Register Event Callback" node is only found on the ActiveX palette, but it works for all event types including VI Server Events (Application, VI, Control) and User Events. Does this mean that it is a platform dependent feature? I really doubt it -- it seams to be LabVIEW native. NI, what's the deal?
--------------------
|
||
|
|
|||
Jun 28 2003, 08:26 PM
Post
#5
|
|||
|
Changing the world, one VI at a time. JKI ![]() Posts: 1692 Joined: 22-October 02 From: San Francisco, CA Member No.: 17 Using LabVIEW Since:1995 LV:8.2.1 ,8.5 ,7.1.1
My Blog
My Gallery
|
QUOTE Now the next step is to figure out how to assign callback vi's dynamically. :wink: This shouldn't be too hard. However, I believe that the callback VI framework requires the reference must be strictly typed and the VI must be reentrant. --------------------
|
||
|
|
|||
Jun 28 2003, 08:27 PM
Post
#6
|
|||
|
Changing the world, one VI at a time. JKI ![]() Posts: 1692 Joined: 22-October 02 From: San Francisco, CA Member No.: 17 Using LabVIEW Since:1995 LV:8.2.1 ,8.5 ,7.1.1
My Blog
My Gallery
|
QUOTE The "Register Event Callback" node is only found on the ActiveX palette, but it works for all event types including VI Server Events (Application, VI, Control) and User Events. Does this mean that it is a platform dependent feature? I really doubt it -- it seams to be LabVIEW native. NI, what's the deal? According to NI's documentation for the Register Event Callback
QUOTE LabVIEW Documentation: event source ref accepts an ActiveX automation reference. Click the down arrow next to this input and select the type of event you want to generate, such as Mouse Down or Double Click. References must be to local objects. You cannot wire a reference to a remote object. Is this a bug or a hidden feature? --------------------
|
||
|
|
|||
Jun 28 2003, 10:50 PM
Post
#7
|
|||
![]() Confucius say: Crowded elevator always smell different to midget Admin ![]() Posts: 2363 Joined: 13-October 02 From: Planet Earth Member No.: 2 Using LabVIEW Since:1994 LV:8.5 ,8.2.1 ,7.1.1
My Blog
My Gallery
|
Someone emailed me the following:
QUOTE I had an interesting discussion over email with someone from NI about the callbacks in general, and the impression I got was that they implemented them to make ActiveX events cleaner, but they weren't really a big fan of them with regards to how they're nearly the opposite of data flow programming. That would lead me to believe it's the somewhat typical reaction NI has to LabView features they don't really like, they'll add them in but not disclose them at all, hoping people simply don't notice. Some more discussion at NIWeek is expected... --------------------
|
||
|
|
|||
Jun 30 2003, 03:16 PM
Post
#8
|
|||
|
More Active NI ![]() Posts: 46 Joined: 30-June 03 From: Austin, TX Member No.: 131 Using LabVIEW Since:1999 LV:5.1 ,. ,.
|
QUOTE The "Register Event Callback" node is only found on the ActiveX palette, but it works for all event types including VI Server Events (Application, VI, Control) and User Events. Does this mean that it is a platform dependent feature? I really doubt it -- it seams to be LabVIEW native. NI, what's the deal? So I had to come join the fray. I guess this could be called kind of a "hidden" feature. We did intend to make it possible to use this functionality with non-ActiveX events. The idea was that, if you are already using this method for handling ActiveX events, you probably don't want to have to use the Event structure to handle all other events - you'd want to be able to have a common architecture. We waffled on this a bit, and made the decision late in the game to make this functionality available. That explains the fact that documentation does not mention that it can be used for all events. I'll pretend not to be offended that no one read it, but in the article I wrote for DevZone that talks about the new events features, it does mention that the callback interface is available for all events. But it was a minor point, so I won't hold it against y'all Nope, not platform-dependent. Yup, meant for it to be there. However, most users should stick to the Event Structure. It is much more straight-forward, and generally easier to use. J
|
||
|
|
|||
![]() ![]() |
| Time is now: 22nd November 2008 - 03:18 AM |