09-06-2009 01:25 PM
One tip I would register the event in the subVI, keep the registration and the event handling tight together.
Ton
09-06-2009 06:10 PM
Thanks Ton,
I'll have a look at this and double-check functionality...still getting to grips with all of this ..
cheers
Neil
09-07-2009 06:35 AM
TonP wrote:One tip I would register the event in the subVI, keep the registration and the event handling tight together.
Ton
Yes good point.
If you have to add or manipulate the events, only the sub-VI changes.
Ben
09-09-2009 07:50 AM
Thanks again for this. I've recoded and it works! My initial concern was that the 'lock front panel' selector option in the drop down (see above) might be associated with the 'front panel' of the wiring diagram within which it is placed. Evidently not!
I think the help you have provided here is important and that the specific example I have been working on here should probably be in the NI examples database: now that I can register front panel events in a calling vi and pass it into a sub-vi where all the work is done, I can reduce coding drastically (albeit at the expense of using some sophisticated aspectes of the Labview capability.)
For the record it is possible to create several calling vi's which may want to access the event sub-vi capability, create an array of references for the controls of each vi front panel and then concatenate the reference array inputs just prior for feed into the 'register for events' function. This way you can have several vi's whose front panel activities can all be detected by the single 'event handling' sub-vi pretty mind-blowing stuff!
Will post revised code for completeness ...soon as.
Thank you again.
Neil
Blueside
09-09-2009 10:22 AM
Blueside wrote:
This way you can have several vi's whose front panel activities can all be detected by the single 'event handling' sub-vi pretty mind-blowing stuff!
The other way around is possible as well, one event being handled in multiple event cases in several sub-VIs. That can be very handy as well.
Ton
09-09-2009 01:38 PM
Blueside wrote:Thanks again for this. I've recoded and it works! ...
For the record it is possible to create several calling vi's which may want to access the event sub-vi capability, create an array of references for the controls of each vi front panel and then concatenate the reference array inputs just prior for feed into the 'register for events' function. This way you can have several vi's whose front panel activities can all be detected by the single 'event handling' sub-vi pretty mind-blowing stuff!
Will post revised code for completeness ...soon as.
Thank you again.
Neil
Blueside
Glad it helped out.
Yes you can register for events from multiple places but I want to give you one "heads-up". You need one "register for event" for every event structure. Do NOT try yo branch the wire coing out of the "register for" node. This would have the same effect as splitting a queue ref wire to two readers of teh queue in that one will get the event and the other will miss it.
so
One "Register for Events" for every event structure recieving those events.
Have fun,
Ben
09-09-2009 02:43 PM
Ben wrote:This would have the same effect as splitting a queue ref wire to two readers of teh queue in that one will get the event and the other will miss it.
Just to clarify - the effect is actually worse, because you might get some events in both structure and some might disappear entirely.
The bottom line is as Ben said, though - one structure per node!
12-09-2009 03:13 PM
07-02-2010 07:35 AM
I know this is an oldish thread, but it contains some great tips and could use a bump anyway...so here goes.
Is there a way to register a bunch of events inside a subVI and then pass the Event Registration Refnum out to a parent VI?
I have tried this, but it only works when the subVI is kept open, i.e. during debugging I have the FP open when running it.
As per the LV help:
Registered events stay registered until you explicitly unregister them or until the VI that registered the events finishes running or you abort the VI. If the VI which registered for events was a subVI, events are unregistered when that VI's top-level VI finishes execution or is aborted. If you use the Run VI method to execute a subVI that registered for events, events are unregistered when the subVI finishes execution or is aborted.
How do I get the registered event to stay registered when done inside a subVI?
07-03-2010 02:10 PM
Based on your description, I think you might be misunderstanding this. Presumably, to register for an FP event in a subVI, the subVI's FP should be loaded (which is usually not done automatically when the subVI is loaded). The easiest way to do this is to create a property node for one of the controls in the subVI. The property node does not have to do anything, just be there. It's enough to load the FP and then hopefully the code should work.
The quote you provided from the help refers to actual execution. As long as the hierarchy where the original reference was created executes (or is in a run state), the reference remains valid. When it stops executing, the reference is automatically closed. This is true of all other references as well, BTW.
I don't think this is your case, however.
In any case, passing event registration refnums around is a BAD idea. Generally, Reg for Events nodes should be right next to the event structure getting the event reference. If you want to register for an event on a control in a subVI, pass the reference to the control out of the subVI and then register for it near each event structure where it's going to be used.
If this doesn't help, you should upload some example code.