LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Create a new file when a certain data log file exceeds a maximum file limit

Scenario:

 

I'm logging temperature data from the four channels of my NI 9219. The VI runs indefinitely and I can stop the program by clicking the stop button.

 

 

1. How can I set the maximum file size of my data_log.txt  to be just  200 kB?

2. Once the maximum file size is reached, I want to create another file (same max file size) in order to continue the data logging, and rename it to let's say data_log1.txt.

 

Do you have any idea on how to implement this?

0 Kudos
Message 1 of 5
(5,133 Views)

Hi,

 

I'm guessing your acquisition happens in a while loop, right?

You can use the iteration terminal (the blue "i" square) to decide when to create a new log file.

I would suggest I define a maximum number of lines per log file and then what you have to do when the iteration terminal reaches a multiple of that max number of line you create a new file. File name can be generated using the date and time.

 

Maybe post you code or a screen shot of it if you need more help to implement that.


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 2 of 5
(5,105 Views)

I remember seeing something similar on one of the Project Templates that NI distributed with LabVIEW 2012 (I assume its still there in 2015).  In developing the (I think) Data Acquisition with Logging (or something similar) Project from a Template, they wrote Errors to an Error Log, which had a user-defined Maximum Size.  After every write, the file size was checked, and if it was bigger than the Max, the file was rewritten starting at the second half (so the first half was thrown away).

 

You could easily adapt this technique to write to a maximum size, and when you exceed the size (or just before you exceed the size), close the current file and open another one.

 

I just checked the Projects shown in LabVIEW 2015 when you click "Create Project" -- I think you want to look at how the Error Logs are handled in "Continuous Measurement and Logging".

 

Bob Schor

0 Kudos
Message 3 of 5
(5,073 Views)

Please find attached Vi. Let me know if it helps.

Message 4 of 5
(4,019 Views)

I think the Get File Size function is what you are looking for...

gfs.png

 Check the file size periodically and create a new file when necessary  

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 5 of 5
(4,014 Views)