Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I continuously write to a file and each hour it rewrites itself?

Im having a really hard time. I am trying to continuously stream data into a file and then each hour have it dump itself and start the file over again. I am a beginner and cannot figure this one out.
0 Kudos
Message 1 of 8
(4,433 Views)

what are you streaming to file? how much data B/sec? what type of data binary/ascii? What else is the program doing Data acq/ time critical analysis and control.  Usually I send my data to a second thread for file streaming and buffering.  Do you want a new file each hour or do you just want to overwrite the file each hour? Sorry for all the questions but these are all valid considerations when thinking about how to architect the data streaming.

 

Paul

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
Message 2 of 8
(4,419 Views)
First off, thank you for your help. I really appreciate it.

I am streaming 2 peices of numeric data to a log file. Preferably an excel spreadsheet. I am taking data each second for an hour then I want to totally rewrite the file. Dump the past one. I also want to include a time stamp on the data which I can pull from the rest of my program. I beleive I have achieved this task but please let me know suggestions. Im sure there is an easier way then what I have done.
0 Kudos
Message 3 of 8
(4,408 Views)

with such low bandwidth data this simplifies the streaming since you will not have to worry about data latancies of writing the data so you can have the data write to file inside of your data collection loop if you would like.  Just format teh following string "%s\t%f\%f\r\n", time stamp,  data1, data2.  Then write the string to file using the append to true.  Before each write check the system clock and test if more than 1 hour has passed since the last new file (a shift reg is nice here) if so set the append to false (this will rewrite the file from the begining).  If you have to scale with lots of data (100KB+/sec or appending to large files) this approach should be changed to optomize for speed.

Paul

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
Message 4 of 8
(4,404 Views)


@Loue wrote:
Im having a really hard time. I am trying to continuously stream data into a file and then each hour have it dump itself and start the file over again. I am a beginner and cannot figure this one out.


New Problem

I got it to write the data for an hour, each second but now I want it to loop and write over each point in sucession. ex: 1,2,3,4,5,6,7.. then it goes back and replaces 1,2,... I have no idea how I would tackle this one.

Thanks again
0 Kudos
Message 5 of 8
(4,403 Views)

Hi,

I was curious which ADE you are using. I noticed that a shift register was mentioned in the forum, so I am assuming that you are programming in LabVIEW, but I just wanted to make sure.

Regards,
Hal L.

0 Kudos
Message 6 of 8
(4,382 Views)

sorry I assumed Labview (forgot this is the ctr/timer board not the labview board) a shift register is translated to any language as a (un-named) local variable to a loop.

 

Paul

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 7 of 8
(4,374 Views)
Hello,
 
Some time ago I wrote and example program with precisely that functionality, and more - it's more general actually since you can specify the file creation periodicity.
 
Here's a link to that document on the web:
 
 
I hope this helps!
 
Best Regards,
 
JLS
Best,
JLS
Sixclear
Message 8 of 8
(4,365 Views)