LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

flush a event handling queue after an specific event occured

Solved!
Go to solution

Dear all, I try to handle events with a FGV. The task is to flush the Event Handling Queue after a specific Event occured. before this specific Message, the Event Handler feed hisself with the same message like in a infinity loop. My Solution is on the picture.

Sometimes it works but sometimes the proramm gets back to the loop. There are many asynchronous called indext subvis that communicate with a FGV with each other.

 

With kind regards

Sönke

0 Kudos
Message 1 of 5
(3,205 Views)

I used - successfully - FGVs to pass data back and forth between multiple loops running simultaneously.  I was careful to avoid logic races with this scheme (each loop writing to its own unique name space, only reading a common space), as you can imagine it is probably impossible to debug what came from where, when.  It'll be a while trying to track the actual sequence using executuion highlighting...

 

My guess by your description of the intermittent behavior is that two or more of your code operations are writing to a common space; one operation negating the effect of the other, i.e. your "flush" gets coincidently "filled" by some other part of your code, rendering the flush ineffective.  Check your code, ensure you dont leave open this possibility.

0 Kudos
Message 2 of 5
(3,169 Views)

Sönke,

     Please do us a favor and attach the actual VI instead of a picture of your VI.  With a real VI, we can (a) tell what Version of LabVIEW you are using, (b) look at other Case elements that aren't visible, (c) edit your code, (d) get LabVIEW to show us the Help for functions we might not recognize, and even (e) try running your code to see how it behaves.

 

     I'm not sure I understand the logic of what you are trying to accomplish.  Without worrying about how you want to accomplish it, can you describe what you want to accomplish?  I gather it involves User Events, and something about an Infinite Loop.  Hmm, sometime asking a question (as I just did) gives one an idea.  Tell me if this is correct:

  • You have an Event Structure with User Events.  One User Event, when called, executes some code and puts another call to this User Event on the Event Queue, creating what you call an "Infinite Loop".
  • You want a different User Event to "break" this process, thinking to do this by flushing the User Event Queue.

     If this is correct, I have another idea of what you might do.  Let's call the User Event that "calls itself" DoSomething.  Let's call the User Event that breaks the cycle StopLoop.

 

     Put a Shift Register in your Event Loop that is initialized to False.  When StopLoop is called, it changes the value on the Shift Register to True (meaning "Stop the Loop").  In your handling of the DoSomething Event, before calling "DoSomething", you check the value of the StopLoop Shift Register, and only call DoSomething again if the Shift Register value is False.  No Queues to flush, you just prevent the further Enqueuing of DoSomething.

 

Bob Schor

 

P.S. -- You and also prevent the DoSomething case from doing anything by simply ignoring all of its code, including the re-enqueuing of DoSomething, if StopLoop is True.

0 Kudos
Message 3 of 5
(3,133 Views)
Solution
Accepted by topic author Soenke

Dear Bob,

thank you for your Ideas,

In my Opinion a global Access Control that locks the state of the device via a global variable is a good idea.

With kind regards

Sönke

0 Kudos
Message 4 of 5
(3,094 Views)

So you fixed it?

 

 

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 5 of 5
(3,085 Views)