I have this recording function that updates every 5 sec and records data as such:
void SaveToFile ()
{ //table.clearRows();
//newRow.setInt("MACH ID", table.getRowCount() - 1);
for (int i=1; i<=10; i++)
{TableRow newRow = table.addRow();
newRow.setString("MACH ID", Mach_Name[i]);
newRow.setString("CUMM UPTIME", HuUpTime[i]);
newRow.setInt("UPTIME %", round (Pr[i]));
newRow.setInt("CYCLES", Cycles[i]);
newRow.setString("LAST TIME", TimeStampArr[i]);
newRow.setString("DATE", DateStamp);
}
////////////////////////
//println("ROW COUNT= " + table.getRowCount());
Filename = "/data/"+"Infinity_Report_"+"Perpetual_V_09" + ".csv"; //DateStamp
saveTable(table, Filename);
//println("Settings Saved");
}
This is monitoring the uptime of a machine. Every day I would generate a new file but now my needs have changed.
I would like to write in the same file this data and move to a new set of rows after midnight.
If I keep âClearRowsâ it deletes the previous daysâŚ
I want to keep them.
Is it possible to start clearing and re-writing only from this row to this row? ( I would increment that with each date change)/
Thanks
Mitch
Iâm sorry I donât understand.
- Not a new file every day â so, one file. ok
- donât delete previous days, keep them. ok
- a new âset of rowsâ after midnight. ?
I donât understand what âset of rowsâ is. Normally, if you use addRow, you add a row. There is only one file, and you donât delete previous rows, you keep them, so this seems like what you want:
1 this is row one
2 this is row two
...
99 this is row ninety-nine
But that is the simplest thing to do, and it seems like you want something else. Could you explain a bit more what you want?
Jeremy , thanks for your help.
I know my explanations are all overâŚ
So:
I dont want o make new files, just one and the file would have a new entry each day.
Stuff would appear like this on the CSV:
MACH ID |
CUMM UPTIME |
UPTIME % |
CYCLES |
LAST TIME |
DATE |
31 |
|
0 |
0 |
|
8_29_2021 |
200 |
|
0 |
0 |
|
8_29_2021 |
700 |
|
0 |
0 |
|
8_29_2021 |
POD1 |
|
0 |
0 |
|
8_29_2021 |
POD2 |
|
0 |
0 |
|
8_29_2021 |
BHX1 |
|
0 |
0 |
|
8_29_2021 |
BHX2 |
|
0 |
0 |
|
8_29_2021 |
EDG1 |
|
0 |
0 |
|
8_29_2021 |
EDG2 |
|
0 |
0 |
|
8_29_2021 |
10 |
|
0 |
0 |
|
8_29_2021 |
31 |
|
0 |
0 |
|
8_30_2021 |
200 |
|
0 |
0 |
|
8_30_2021 |
700 |
|
0 |
0 |
|
8_30_2021 |
POD1 |
|
0 |
0 |
|
8_30_2021 |
POD2 |
|
0 |
0 |
|
8_30_2021 |
BHX1 |
|
0 |
0 |
|
8_30_2021 |
BHX2 |
|
0 |
0 |
|
8_30_2021 |
EDG1 |
|
0 |
0 |
|
8_30_2021 |
EDG2 |
|
0 |
0 |
|
8_30_2021 |
10 |
|
0 |
0 |
|
8_30_2021 |
Each day would create a new set of rows in the same file over and over âŚ
Hope I clarified a bitâŚ
Thanks
mitch
Okay, got it. You are updating every five seconds â do you save your file to disk every 5 seconds, or once per day?
If every five seconds, do you want it like this:
- today.log â updates every five seconds
- history.log â adds a copy of today.log once per day
or do you want it like this:
- history.log â last 10 rows change every five seconds, and at midnight, 10 new rows appear and start changing
I decided to record once a day at 6 pm so I went:
cur_hrs = hour();
if (HourPrev !=cur_hrs ) // && Counting)
{HourPrev =cur_hrs;
if (HourPrev == 18 )
println ("Recorded at " + cur_hrs);
SaveToFile ();
}
I wonder if thats gonna work reliably and dont do only one entry per dayâŚ
Thanks a lot,
Suggestions welcome.
1 Like
It depends on how reliable you need the logging to be, and how the log will be used. Most logs write to disk more often than once a day â but maybe that is all you want or need? I donât know your requirements for the Table in your problem, or the âInfinity_Reportâ on disk, so I donât know what to suggest.