Fix timestamp of validation data
This commit is contained in:
@@ -529,10 +529,13 @@ public class SensorValidationActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
double averageHr = currentHrValidCount > 0 ? currentHrSum / currentHrValidCount : -1.0;
|
double averageHr = currentHrValidCount > 0 ? currentHrSum / currentHrValidCount : -1.0;
|
||||||
long timestampMillis = hrStartMillis + currentHrSecond * 1000L;
|
long timestampMillis = hrStartMillis + currentHrSecond * 1000L;
|
||||||
|
String timestampIso = timestampIsoLocal(timestampMillis);
|
||||||
String timestamp = new SimpleDateFormat("HH:mm:ss", Locale.UK).format(new Date(timestampMillis));
|
String timestamp = new SimpleDateFormat("HH:mm:ss", Locale.UK).format(new Date(timestampMillis));
|
||||||
|
|
||||||
hrPoints.add(new HeartRatePoint(
|
hrPoints.add(new HeartRatePoint(
|
||||||
hrPoints.size(),
|
hrPoints.size(),
|
||||||
|
timestampIso,
|
||||||
|
timestampMillis,
|
||||||
timestamp,
|
timestamp,
|
||||||
currentHrSecond,
|
currentHrSecond,
|
||||||
averageHr,
|
averageHr,
|
||||||
@@ -605,9 +608,11 @@ public class SensorValidationActivity extends AppCompatActivity {
|
|||||||
File file = new File(getOutputDir(), "validation_hr_" + timestampForFilename() + ".csv");
|
File file = new File(getOutputDir(), "validation_hr_" + timestampForFilename() + ".csv");
|
||||||
try {
|
try {
|
||||||
OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(file));
|
OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(file));
|
||||||
writer.write("point_index,time_hhmmss,elapsed_seconds,avg_hr_bpm,valid,valid_readings_in_second,total_readings_in_second\n");
|
writer.write("point_index,timestamp_iso,epoch_ms,time_hhmmss,elapsed_seconds,avg_hr_bpm,valid,valid_readings_in_second,total_readings_in_second\n");
|
||||||
for (HeartRatePoint point : hrPoints) {
|
for (HeartRatePoint point : hrPoints) {
|
||||||
writer.write(point.index + ","
|
writer.write(point.index + ","
|
||||||
|
+ point.timestampIso + ","
|
||||||
|
+ point.epochMillis + ","
|
||||||
+ point.timestampHhMmSs + ","
|
+ point.timestampHhMmSs + ","
|
||||||
+ point.elapsedSecond + ","
|
+ point.elapsedSecond + ","
|
||||||
+ (point.valid ? String.format(Locale.UK, "%.3f", point.averageHr) : "") + ","
|
+ (point.valid ? String.format(Locale.UK, "%.3f", point.averageHr) : "") + ","
|
||||||
@@ -625,6 +630,8 @@ public class SensorValidationActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
private static class HeartRatePoint {
|
private static class HeartRatePoint {
|
||||||
final int index;
|
final int index;
|
||||||
|
final String timestampIso;
|
||||||
|
final long epochMillis;
|
||||||
final String timestampHhMmSs;
|
final String timestampHhMmSs;
|
||||||
final int elapsedSecond;
|
final int elapsedSecond;
|
||||||
final double averageHr;
|
final double averageHr;
|
||||||
@@ -633,12 +640,16 @@ public class SensorValidationActivity extends AppCompatActivity {
|
|||||||
final int readingsInSecond;
|
final int readingsInSecond;
|
||||||
|
|
||||||
HeartRatePoint(int index,
|
HeartRatePoint(int index,
|
||||||
|
String timestampIso,
|
||||||
|
long epochMillis,
|
||||||
String timestampHhMmSs,
|
String timestampHhMmSs,
|
||||||
int elapsedSecond,
|
int elapsedSecond,
|
||||||
double averageHr,
|
double averageHr,
|
||||||
int validReadingsInSecond,
|
int validReadingsInSecond,
|
||||||
int readingsInSecond) {
|
int readingsInSecond) {
|
||||||
this.index = index;
|
this.index = index;
|
||||||
|
this.timestampIso = timestampIso;
|
||||||
|
this.epochMillis = epochMillis;
|
||||||
this.timestampHhMmSs = timestampHhMmSs;
|
this.timestampHhMmSs = timestampHhMmSs;
|
||||||
this.elapsedSecond = elapsedSecond;
|
this.elapsedSecond = elapsedSecond;
|
||||||
this.averageHr = averageHr;
|
this.averageHr = averageHr;
|
||||||
@@ -661,6 +672,11 @@ public class SensorValidationActivity extends AppCompatActivity {
|
|||||||
return new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.UK).format(new Date());
|
return new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.UK).format(new Date());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String timestampIsoLocal(long millis) {
|
||||||
|
// ISO-like local timestamp with timezone offset, for example: 2026-05-05T10:24:25.000+0000
|
||||||
|
return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.UK).format(new Date(millis));
|
||||||
|
}
|
||||||
|
|
||||||
private void saveRawCsv() {
|
private void saveRawCsv() {
|
||||||
if (lastResult == null) return;
|
if (lastResult == null) return;
|
||||||
File file = new File(getOutputDir(), "validation_raw_" + timestampForFilename() + ".csv");
|
File file = new File(getOutputDir(), "validation_raw_" + timestampForFilename() + ".csv");
|
||||||
|
|||||||
Reference in New Issue
Block a user