08-31-2021 07:11 AM
I am using a filesystemwatcher event to load a tdms file when it is saved from another process. Occasionally I get an error that seems like the file is being loaded before it is actually finished saving. It seems like the error that is happening is because of incomplete information in the file. If I wait and try the file again a minute later it seems fine.
Is there a way to insure that a file is finished saving before loading? I'd rather load the file right after it is completed being saved rather than set a timer.
08-31-2021 07:18 AM
What's the other process? A different application? If so, is it one that you can modify to help accomplish this task?
Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.
08-31-2021 07:24 AM
It is a different VI that is collecting data on a manufacturing process. I am using the standard TDMS Open, Write, Close pattern.
08-31-2021 07:30 AM
If it's a different VI in the same application, then why not just have the collection VI tell the loading VI when it's done making the TDMS file? There are many ways to do this.
Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.
08-31-2021 07:30 AM
Hi flycast,
@flycast wrote:
Occasionally I get an error that seems like the file is being loaded before it is actually finished saving.
Some pseudocode:
REPEAT
error := OpenFile(file)
IF error THEN wait(2s)
UNTIL not(error)
Seems simple to implement!
When accessing files you will need to take into account processing time of the TDMS file creation (like creating the TDMS index file) or the time needed by the OS to finish file writes on the actual file storage device…
08-31-2021 07:38 AM
I've never really considered what it takes on a lower level to write a file. I would expect that a empty file is created and then a stream is used to actually write the data. If I am using a file watcher on file creation it's probably notifying on the initial creating but not when it is finished writing.
08-31-2021 07:43 AM
Hi flycast,
@flycast wrote:
I've never really considered what it takes on a lower level to write a file. I would expect that a empty file is created and then a stream is used to actually write the data.
With TDMS you most often also get a separate index file, which will be created/written on closing the TDMS file. This part also will take its time…
@flycast wrote:
If I am using a file watcher on file creation it's probably notifying on the initial creating but not when it is finished writing.
That's my experience from watching Excel files: Excel creates a filewatcher event upon opening a XLS(X) file, but not on closing it. (Infact Excel will update the file creation/change timestamps already upon opening the file…)
08-31-2021 08:17 AM
@FireFist-Redhawk - In general what would these ways be?
08-31-2021 08:56 AM
@flycast wrote:
@FireFist-Redhawk - In general what would these ways be?
An FGV would be the simplest way. There are also queues, notifiers, and user events, any one of which could be used.
Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.
08-31-2021 08:58 AM
@FireFist-Redhawk wrote:
What's the other process? A different application? If so, is it one that you can modify to help accomplish this task?
@flycast wrote:
It is a different VI that is collecting data on a manufacturing process. I am using the standard TDMS Open, Write, Close pattern.
Hmm... If both if these are LabVIEW then why not just roll them into one program instead of using the filesystemwatcher?