LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Important to know if disk drive is spinning.

I'm transferring information between labview and programs that are not
able to communicate directly with labview. Data is passed back and
forth by one program writing to disk and the other reading it. This is
inelegant, but not much data has to be transferred; nor does this happen
very often.

I would like to ensure that a disk write from one program is complete
before I have the other program start a read on the newly-written data.
Does Labview have any way of checking if the hard drive is currently
being written to? I guess I could put in a conservative time delay, but
perhaps there's a way to safely shave down a window of safety
dead-time...

Using:
LV 5.1
Windows98
PII PC.

Any general advice on how
to ensure that don't trip over myself in
reading a file that is written by one machine and then read by another?

Thanks.


Sent via Deja.com
http://www.deja.com/
0 Kudos
Message 1 of 5
(2,556 Views)
While there might be a way to check for disk activity, that would not be
the best solution. For example, if the hard drive was working on the
Windows swap file after it wrote your file, then your program would be
waiting for quite a while.

Here is a solution I used: Before the first program (the one writing
the data file) starts writing, it creates a lockfile. The lockfile just
has to exist while the data file is being written. When the data file
is completed, delete the lockfile.

On the other program, it waits in a loop for the lockfile to become
available. It then goes into another loop to wait for the lockfile to
be deleted (then it can't be opened). Once the lockfile is deleted,
that program can safely read the data file.

I've used this method,
and it works well. The only reason I had to stop
using it was because there was a problem in the network communication,
and I was getting bad data files.

If you are using two different Labview programs, you can use some of the
synchronization VI's in version 5.0 and above.



Sent via Deja.com
http://www.deja.com/
0 Kudos
Message 2 of 5
(2,556 Views)
Thanks for the reply.

Hm. Is this lockfile feature an option that is explicitly executed in
the programs you use, or is it a phenomenon that automatically occurs at
the (WIN/DOS) OS level to prevent simultaneous multiple reads/writes to
a file from different programs? If it's at the OS level than that's
great. If not, I have a bit of tweaking to do in my programs. 🙂

Thanks,
ke

In article <95rm9c$drj$1@nnrp1.deja.com>,
l0rdv4der@my-deja.com wrote:

> Here is a solution I used: Before the first program (the one writing
> the data file) starts writing, it creates a lockfile. The lockfile
just
> has to exist while the data file is being written. When the data file
> is completed, delete the lockfile.
>
> On the other program, it waits in a lo
op for the lockfile to become
> available. It then goes into another loop to wait for the lockfile to
> be deleted (then it can't be opened). Once the lockfile is deleted,
> that program can safely read the data file.
>

>
> Sent via Deja.com
> http://www.deja.com/
>


Sent via Deja.com
http://www.deja.com/
0 Kudos
Message 4 of 5
(2,556 Views)
Unfortunately, the lockfile is not at the OS level. I wish it was
myself. However, there are certain permissions you can set on a file
that are at the OS level. You can specify that a file can only be open
by one program at a time. I don't use them, and they might not work,
or be very useful, but they do exist.

The nice thing about using the lockfile is that it's OS independent.
All OS's allow you to create files, so there's no problem if you ever
have to use a different platform for your application.


Sent via Deja.com
http://www.deja.com/
0 Kudos
Message 5 of 5
(2,556 Views)
LabVIEW's "Open File" function in the File I/O -> Advanced File
Functions palette has a parameter to deny other applications read and
write access as long as the file reference is open. I don't know what
languages you are using to write your other applications, so I can't
say whether they have the same option to deny reading by another app.

Another way that you can set up your reader is by reading the size of
the file. When the file size stops increasing over a certain period of
time, then you can make a logical assumption that the other program has
stopped writing.

ej

In article <95rlgu$d6n$1@nnrp1.deja.com>,
ken_eric@my-deja.com wrote:
> I'm transferring information between labview and programs that are not
> able to communicate directly with labview. Data is passed ba
ck and
> forth by one program writing to disk and the other reading it. This is
> inelegant, but not much data has to be transferred; nor does this
happen
> very often.
>
> I would like to ensure that a disk write from one program is complete
> before I have the other program start a read on the newly-written
data.
> Does Labview have any way of checking if the hard drive is currently
> being written to? I guess I could put in a conservative time delay,
but
> perhaps there's a way to safely shave down a window of safety
> dead-time...
>
> Using:
> LV 5.1
> Windows98
> PII PC.
>
> Any general advice on how to ensure that don't trip over myself in
> reading a file that is written by one machine and then read by
another?
>
> Thanks.
>
> Sent via Deja.com
> http://www.deja.com/
>


Sent via Deja.com
http://www.deja.com/
0 Kudos
Message 3 of 5
(2,556 Views)