LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

breaking out of an event structure

Hi,

 

 I am using a kiethley device to do current measurements. I have coded my program using event structures inside a while loop, so that when I press Run, the measurements start and another event with "cancel" if I do not want to do any more measurements.  Now if half way during the measurements I want to abort, I cant click on "cancel" since the RUN event is being run. 

Even if I try putting another Cancel outside the event structure with a boolean OR to the conditional terminal of the while loop, it still does not work..

Is there any way to abort from all structures, whether it be while loops or event structures? 

0 Kudos
Message 1 of 4
(2,626 Views)

The right way to do this is to restructure your code.  In general an event structure should not contain that will take a while to execute; instead, you should put that code into a separate loop and use a queue or notifier to trigger it from an event.  That way your event structure can continue to process events while the procedure is running.  Of course, if you need to be able to interrupt the other loop, you'll need to put some code there too so that it can process any new notifications.

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

Ahh, I see,

Could you instruct me on how to go about doing that?

How would i connect the queue or notifier to the measurement loop? If I understand what you are saying correctly,  I should put my Kiethley measurement code in a while or for loop and put the Run button in the event structure, because I want my measurement to start when I press the Run button. But how would I then tell the measurement loop to trigger only when the RUN event is satisfied?

Thank You for your help.

0 Kudos
Message 3 of 4
(2,618 Views)

Take a look at the producer/consumer examples. You could also search the forums since there are lots of examples posted here.

 

Basically, the producer loop (the one with the event structure) will only process things like button presses, user events (a bit more of an advanced topic), UI events (application close) or quick periodic tasks in the timeout event. The consumer loop generally contains a state machine. This is important since you want to abort a running process. You will need to break your processing up to various states that are reasonably short in duration which will also allow you to check if an abort has occurred.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 4 of 4
(2,613 Views)