06-09-2006 09:06 AM
06-09-2006 10:32 AM
1... Use an occurrence. The DAQ thread triggers it AFTER it writes the file. The processing thread waits on occurrence, then opens the file and reads it.
2... Use a queue. The DAQ thread enqueues the file name (or path) it just wrote into a queue. The processing thread waits for names available - when it gets one, it does its thing.
3... Write the files with DENY READ permissions. The processing thread will then get an error if the file is still open from the DAQ thread.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
06-09-2006 11:09 AM
06-09-2006 01:06 PM
All functions are on the ADVANCED | SYNCHRONIZATION | QUEUE palette.
Use the OBTAIN QUEUE to create the queue. Set the DATA TYPE to a PATH constant. This creates a queue of paths. Pass the QUEUE REFNUM to both the DAQ VI, and the PROCESSING vi.
In the DAQ VI, when you write a file, take the PATH from the CLOSE FILE function and use ENQUEUE ELEMENT to put it into the queue (use the refnum you passed in).
In the processing thread, use DEQUEUE ELEMENT to fetch the path from the queue. You probably should use a timeout value of 1000 mSec or so. If you timed out, go check your PROGRAM RUNNING flag (so you can stop without waiting forever on the queue), and if you're not stopped, try again.
If the DEQUEUE ELEMENT returns WITHOUT a timeout, then open the path it gives you - the file is guaranteed to be closed, since you closed it before you enqueued it.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
06-09-2006 04:15 PM
06-10-2006 07:57 AM
Run your example finder and search for "queue".
You might also want to look for "occurrence" examples. The difference is that a queue can "pile up" things to process (more than one); an occurrence is simple a trigger notification thar something has happened, and cannot hold more than one.
Alternatively, when you NEW the file (to write to it in the DAQ thread), you could set the DENY MODE input to 0 (Deny R/W). This means that if your processing thread tries to open that same file WHILE YOU'RE STILL WRITING IT, it will get an error (sharing violation). You can react to that error, by waiting a while and trying again.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
06-12-2006 09:38 AM