That happens to be what I am working on except that aspects of the data are saved to file at set intervals. This is the WriteData class for what it is worth.
// The FileRecorder writes/appends the interval data to the recorder tab delineated text file.
//
class FileRecorder{
String _filePathName;
String[] _textLine = new String[1];
void setFilePathName(String theFName){
_filePathName = theFName;
println("File record name is " + _filePathName);
}
void writeHeadLineTAB(){
_textLine[0] = "Date" + TAB + "Time" + TAB ;
_textLine[0] = _textLine[0] +"Sensor#" + TAB + "CurrentTemp" + TAB + "Height" + TAB ;
_textLine[0] = _textLine[0] + "IntervalMaxTemp" + TAB + "IntervalMinTemp" + TAB ;
_textLine[0] = _textLine[0] + "SessionMaxTemp" + TAB +"TimeSMax" + TAB + "DateSMax" + TAB ;
_textLine[0] = _textLine[0] + "SessionMinTemp" + TAB +"TimeSMin" + TAB + "DateSMin" + TAB ;
_textLine[0] = _textLine[0] + "SensorAddr" ;
if (_filePathName != null){
saveStrings(savePath(_filePathName), _textLine);
println("Wrote headline to " + savePath(_filePathName));
println(_textLine[0]);
}
}
void writeIntervalLines(){
PrintWriter pw = null;
for (int i = qtySensr-1; i > -1; i = i-1)
{
fill(0,255,0); // flash color when writing file
text("Record filename is " + savePath(theRecordFileName), edge,40);
String dataLine = Sensors[i].intervalRprt();
dataLine = dataLine.replaceAll(" ","\t");
println(dataLine);
if (savePath(_filePathName) != null){
try
{
pw = new PrintWriter(new BufferedWriter(new FileWriter(savePath(_filePathName), true))); // true means: "append"
pw.println(dataLine);
}
catch (IOException e){
// Report problem or handle it
e.printStackTrace();
}
finally{
if (pw != null){
pw.close();
}
}
}
}
fill(0,0,0);
}
}