11-03-2014 12:48 AM - edited 11-03-2014 12:49 AM
Ok I'm not sure if this is a dumb question or not...
I was just trying out some stuff and stumbeled on this problem...
So i created a sample (not the exact)
In qqq_Main.vi just press PressMe
(it opens up a subVI qqq.vi)
Ther are two stop buttons "Stop1" and "Stop2".
To close the SubVI either press "Stop2"
or press "Stop1" and then "Stop2"
with the latter method of closing the Stop2 value change is registered outside the while loop, and after the SubVI closes shouldnt this be Cleared???(Or should we manually clear it??)
Due to this not clearing, the second time I press "PressMe" the Stop2 Value change even gets triggered before pressing anything
Solved! Go to Solution.
11-03-2014 01:45 AM
Hey,
to be honest, I do not really understand what you're trying to achieve.
Some hints:
Oli
11-03-2014 01:47 AM
I can't look at your code at the moment, but based on your description it sounds like the system is working as designed. I'm assuming you're doing a completely static registration of the events (i.e. opening the event configuration dialog and selecting the controls and the event).
The first thing to clear up is your use of the term "registered". In this case it's a problem, because registering in the context of events means requesting to receive the event when it happens.
Now that you know that, it's important to understand when the registration is actually happening, because that's what determines which events are stored in the queue. When you use this type of static registration, the registration happens as soon as the VI the event structure is in goes into run mode (note - this doesn't mean the VI is actually running, just that's it's running or reserved for running) and the unregistration only happens when the VI leaves run mode. That's why you get events in the queue from the previous run of the VI - the VI is still in run mode, so the event is added to the queue and still waiting in the queue until the event structure runs again.
You can work around something like this by switching to dynamic registration of events, where you can unregister to clear the queue at the end of the VI, but that requires more code. Also, in LV 2013 there were some features added to events which might allow to do this statically (I didn't study all the additions closely, so I'm not sure if this is possible for static registration).
There's a good presentation about events from NIWeek 2013 by Jack Dunaway. You can find the details of how to download the video here - http://lavag.org/topic/16091-ni-week-2012-videos/
11-03-2014 02:01 AM
Ok now I get it.... I thought that the "static registration of the events" would be started only when the VI would open and gets cleared up when the VI closes.