02-17-2017 09:58 AM
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
Solved! Go to Solution.
02-17-2017 12:34 PM
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.
02-19-2017 01:28 PM - edited 02-19-2017 01:31 PM
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:
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.
02-23-2017 08:23 AM
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
02-23-2017 12:46 PM
So you fixed it?