LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Kill Waiting Task

An event case starts two sections of code.

 

The first section triggers some external circuitry and completes in about a minute.

 

The second section waits (blocks) and then handles any return triggers.

 

What is the standard / best-practices way to halt the blocking operation in the second section when the first section completes?

 

I had thought about maybe putting both sections in a subVI and simply calling Exit VI when the first section completes.  However, that could result in a half-handled return event.

0 Kudos
Message 1 of 12
(3,798 Views)

Could you use something like a notifier to communicate across the loops?

0 Kudos
Message 2 of 12
(3,789 Views)

I don't think a notifier would work.  The second loop spends nearly all of it's time blocked until a return event occurs.  It's not polling, it's waiting.

0 Kudos
Message 3 of 12
(3,782 Views)

Can you elaborate on how your example is different than the following:

 

notifier example.png

0 Kudos
Message 4 of 12
(3,773 Views)

What's it waiting on?  A queue, a notifier, an event, a TCP read, a serial read, something else?  That would help answer the question as to the best way to handle it.

0 Kudos
Message 5 of 12
(3,759 Views)

I'm using a Tektronix TDS 3014 scope to collect data.

 

When the system is monitoring, each "event" triggers acqusition of one second of data.  After that one second, the system retriggers.  While waiting for a trigger, the system is blocking on "VISA Read."

 

When I disable monitoring, how do I terminate the call to "VISA Read" which is currently blocking?

0 Kudos
Message 6 of 12
(3,742 Views)

Still trying to make sure I understand your system... what's the timeout value on the VISA Read?  It sounds to me like the VISA Read is constantly waiting even if there's no event.  Is that correct?  Can you modify your system so you don't start the VISA Read until an event occurs?  You don't need the VISA Read operation to be in progress when data arrives; VISA (or the serial subsystem) will buffer incoming data until you read it.

0 Kudos
Message 7 of 12
(3,738 Views)

The VISA Read returning is the indication that an event occurred.

 

My system is similar to a camera system with motion detection.  If the camera detects motion, the system records data for a particular length of time.

 

How do I kill the section of code which is blocking on the read for the next trigger (or in my example, the next detection of movement)?

 

 

0 Kudos
Message 8 of 12
(3,714 Views)

I don't think there's any way to kill a VISA Read that's waiting (although you could see if you can do it by closing the VISA resource elsewhere in the code, I've never tried that approach).  Instead you may need to change your architecture slightly.  Consider a system with a notifier with a relatively long timeout, followed by a VISA Read with a 0 timeout.  If you need to interrupt the wait, send a notification.  If the notifier times out, check the VISA Read.  If there's data, then your event occurred.  If not, go back to waiting on the notifier.

0 Kudos
Message 9 of 12
(3,677 Views)

In general, is there a way to explicitly kill / terminate a particular section of code regardless of if it is waiting or executing?

0 Kudos
Message 10 of 12
(3,669 Views)