07-12-2012 04:07 AM
Hi
i have multiple pcs saving to there own databases at the moment. I want them all to save to the same file (lvm) but obviously dont want them to conflict at the save.
I've found the attached VI which is one method i could use and it makes sense.
My question is what happens with this VI if it does find a pc saving to the file? Does it wait and retry or does it just skip the process?
Thanks
07-12-2012 04:47 AM
What happens when any of your applications crashes and the temporary file isnt deleted? Right you have to manually delete this crash survivor or nobody can save to the file ever again.
A much smoother way to deal with this collision detection is the VI "Deny Access.vi" found under "File I/O->Adv File Funcs". Its really great, It'll lock the file to your refnum and this session will be the only one able to write in your file. All other will get a warning, that the file is currently in use. Also it doesnt lock your database if an application with the lock crashes, the lock ceases to exist without the refnum or if labview crashlands;)
Sounds exactly like the thing you are looking for:)
07-12-2012 05:07 AM - edited 07-12-2012 05:10 AM
Couldn't open your example - our websense software does not allow zip files to be downloaded but LabVIEW VIs are allowed!
I have done something similar with a single Excel file being written to by up to 4 PCs running similar LabVIEW applications. I kept the chances of collision to a minimum by only opening the file when the application had data to write and close it again as soon as the data is written. The Excel was open for less than 5% of the total application run time. Collisions were still possible so to detect if the Excel file was already open by another application I just looked to see if the Excel file had been opened 'read only'. If this was the case the file was closed, the user informed, and reopened 3 seconds later for a retry
(See attached).
I have also tried to use the Shared Spreadsheet approach but have not perfected it yet.
Ken
07-12-2012 05:11 AM
Hi
thanks for both repsonses. Both excellent sugestions.
Ken, I think you are doing something very similar but i would imagine my percentage is even lower. That said i cant have the posibility of conflicts.
Can you possibly repost your code in V9 please? I've not got V11 yes but its in the post! Literally!
07-12-2012 05:18 AM
LabVIEW 9.0 version attached.
Can you not have conflicts even if is managed. If you open Excel File that is already opened it always opens read only. just keep trying until it is free - You could reduce teh retry time if the delay is an issue
Ken