LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Event structure not clearing the Queue after it exits the SubVI

Solved!
Go to solution

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

Download All
0 Kudos
Message 1 of 4
(2,506 Views)

Hey,

 

 

to be honest, I do not really understand what you're trying to achieve.

 

Some hints:

  • the way you are determining the stop condition of the event loop is stange: you are always or-ing the new value from the button change event with bool default value.
  • when pressing either of your stop buttons, an event will be fired, but neither of the controls will be set back due to their mechanical functions and usage within the data flow
  • On the second loop, since you are polling the control, this has nothing to do with the events registered for the while loop.

Oli

0 Kudos
Message 2 of 4
(2,484 Views)
Solution
Accepted by topic author karthik9

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/


___________________
Try to take over the world!
Message 3 of 4
(2,482 Views)

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.

0 Kudos
Message 4 of 4
(2,465 Views)