LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

clear event queue

Solved!
Go to solution
Hi folks,

This is probably very easy but I haven't found an elegant solution:

I have some variable 'eventtrigger' change a couple of times a second. After running my program for a while - 'eventtrigger' has already been updated a couple of times - I start a subroutine which listens to 'eventtrigger' in an event structure. The problem is that all the updates of 'eventtrigger' that occurred before the subroutine was started are queued up, and so I'm not triggering on what's happening now but on outdated stuff.

So far I clear the event queue by having a do-nothing-but-trigger event structure triggered by 'eventtrigger' in a while loop, plus a timeout event that is just a bit shorter than it takes for 'eventtrigger' to be updated. I stop that while loop when there is a timeout event.

Surely there must be a better way to clear the events that happened before?

Cheers,

WEnte.

Just a remark, I also stumbled over http://forums.ni.com/ni/board/message?board.id=130&thread.id=5544 ... Browser incompatibilities? Are we back in 1998 (this page is best viewed with...)?
0 Kudos
Message 1 of 3
(3,773 Views)
Solution
Accepted by topic author WildEnte

I typically compare the actual value with the value from the event terminal and short out the event if they are not equal.

 

Here is a quick demo.

 

I am not sure how to apply it to your situation, because I don't know the details of your code. Still, maybe it can give you some ideas.

 

How does the event get triggered a few times per second? Is this via signaling properties?

Message 2 of 3
(3,772 Views)
Thanks for the hint. That solution is already a lot more elegant than what I'm currently doing, because it doesn't rely on any timeouts. But there should be some way to tell my event structure whether I want to trigger the oldest or the newest event. *sigh*

To answer your question: I read a number from some device over GPIB and write it into a signaling property node of an indicator (that's my data readout loop). In another loop, I set a voltage for some power supply, which will change my GPIB reading. Before making another change to another power supply, I want to wait for say 10 GPIB reading updates. The idea was to have an event structure in a 10 iteration for loop waiting for 10 updates of my signaling property node. But that loop never runs for any significant time, because there are still queued events from long long ago that trigger the event case immediately. .
0 Kudos
Message 3 of 3
(3,763 Views)