03-21-2011 11:02 AM
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.
03-21-2011 11:17 AM
Could you use something like a notifier to communicate across the loops?
03-21-2011 11:36 AM
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.
03-21-2011 11:55 AM
Can you elaborate on how your example is different than the following:
03-21-2011 12:02 PM
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.
03-21-2011 01:31 PM
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?
03-21-2011 01:39 PM
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.
03-22-2011 07:49 AM - edited 03-22-2011 07:54 AM
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)?
03-22-2011 01:28 PM
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.
03-22-2011 01:36 PM
In general, is there a way to explicitly kill / terminate a particular section of code regardless of if it is waiting or executing?