I have external data logging software that is exporting data to multiple text files (sequentially numbered) during a looped calibration process that I am running with LabVIEW control. The export data function can take anything from 1 second to 2 minutes depending on the number of data points being recorded then exported.
What is the best way with LabVIEW to check the status of these text files being written? The idea is that as soon as the text file has completely been written, I want to import this data into LabVIEW for analysis.
At the moment my method is as follows:
I am finding the last file to be created in a folder then looping the File/Directory Info.vi every two seconds and comparing if the file size has changed during that period. When the filesize doesn't change, I know that it is complete.
Even if the size of a file is not changed between two file size check, it does not mean the write operation has finished, and that external application completed operation on this file. Data usually written in a buffered manner to files, so it can be that between two test the file size did not changed, but there is still data in memory waiting to be written to the file.
You could just try to open the file using LabVIEW at a frequency which is appropriate for your application. In principle, if that external data logging software did not complete the file, LabVIEW will not have the right to open it, thus it will produce an error for you. If so, just handle this error, and a bit later try to open the same file again...
To monitor whether a new file appeared yet in the target folder, without polling, you can use Event based trick, see here: http://forums.ni.com/t5/Example-Program-Drafts/Event-based-File-and-Folder-Watcher/ta-p/3502878