LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using Progress Bar when reading binary files

hello experts,
I'm writing data to file in a while loop, closing the file outside the while loop, then opening the file in another while loop and reading the data. I'd like to know how I can wire a "progress bar" to the "read binary file vi" so I know when i'm going to reach the end of the file. Can this be done?
 
Thanks
Alv
 
0 Kudos
Message 1 of 14
(5,018 Views)
Open the file out of the loop, get the file size then read n bytes at a time passing the current offset through a shift register back to the start
of read position, dont forger to initialize this register to 0.  On each itteration update the progress bar which is the bytes read so far (shift register wire) by the file size to get the value of the progress (some number between 0 and 1, multiply by 100 for percent) perform the read loop until eof.
 
Paul
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 2 of 14
(4,995 Views)

Ok, call me a big dummy. Still confused. Open File vi outside the while loop with a  indicator of the file size, then read the number of bytes/time, passing the current offset through a shift register back to the start of read position. Not sure what you mean here, The pos offset (0) wired to shift register (initialized to 0) right?, then wire the right side of shift register back to the start (read binary vi) of read position.

On the Iteration update, multiply # bytes read X file size = progress.

0 Kudos
Message 3 of 14
(4,976 Views)

Sorry I was assuming a character file not a binary file, I will have to look at the binary files when I am infornt of labview  (not on this machine right now)

Paul

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 4 of 14
(4,956 Views)
Hey Alv,

try my example. It's rather simple without any error checking, but should give you an idea...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 14
(4,948 Views)

Any chance you could explain whats going on. ex, Why are you dividing by 200?

thanks for you help.

0 Kudos
Message 6 of 14
(4,928 Views)
Hello Alv,

that's just for demonstration. Look at the changed example.

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 14
(4,909 Views)
This is a great idea. Another question though, is it possible to use the Open file vi in place of the Open/create/replace vi in this application? Take a look at my example code.
0 Kudos
Message 8 of 14
(4,886 Views)
Hello Alv,

I think "Open" works the same as "Open/Create/Replace". Only (big) difference is: you need an additional operation to get the filesize ("EOF" or "File/Dir Info" from file/advanced-palette) if you still want to have a progress bar.

Comments on your example: why do you close and open the file multiple times? (Close after first loop, open and close in both cases of the last case structure). And to select a case depending on the tab control: just wire the tab control to the case...


Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 9 of 14
(4,879 Views)

Ok, I think I'm onboard now. I've incorporated your ideas and I think everythings working ok now. I put the example togehter real quick to incorporate your idea. Sorry for the opening and closing of files.

Take a look at my revised example. This is basically what I'm doing in my application at work, writing multiple channels of data to file, closing the file outside the while loop and doing my analysis after opening the file (I had to do this due to buffer problems).  I wanted to incorporate the process bar since I didn't know when the EOF was near. You've been extremely helpful. Thanks.

Alv

0 Kudos
Message 10 of 14
(4,862 Views)