Skip to content

Commit

Permalink
Merge pull request #211 from OxWearables/tz-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
angerhang authored Sep 28, 2022
2 parents 7b77e4c + b678413 commit 7b7083c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion accelerometer/java/AccelerometerParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public static void main(String[] args) {
} else if (accFile.toLowerCase().endsWith(".cwa.gz")) {
AxivityReader.readCwaGzEpochs(accFile, timeZone, timeShift, epochWriter, verbose);
} else if (accFile.toLowerCase().endsWith(".bin")) {
GENEActivReader.readGeneaEpochs(accFile, epochWriter, verbose);
GENEActivReader.readGeneaEpochs(accFile, timeZone, timeShift, epochWriter, verbose);
} else if (accFile.toLowerCase().endsWith(".gt3x")) {
ActigraphReader.readG3TXEpochs(accFile, epochWriter, verbose);
} else if (accFile.toLowerCase().endsWith(".csv") ||
Expand Down
15 changes: 13 additions & 2 deletions accelerometer/java/GENEActivReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ public class GENEActivReader extends DeviceReader {
*/
public static void readGeneaEpochs(
String accFile,
String timeZone,
int timeShift,
EpochWriter epochWriter,
Boolean verbose) {

setTimeSettings(timeZone, timeShift);

int fileHeaderSize = 59;
int linesToAxesCalibration = 47;
int pageHeaderSize = 9;
Expand Down Expand Up @@ -54,6 +58,11 @@ public static void readGeneaEpochs(
header = readLine(rawAccReader);
if (i == 3) {
blockTime = LocalDateTime.parse(header.split("Time:")[1], timeFmt);

if (pageCount == 1) {
setSessionStart(blockTime);
System.out.println("Session start: " + sessionStart);
}
} else if (i == 5) {
temperature = Double.parseDouble(header.split(":")[1]);
} else if (i == 8) {
Expand All @@ -69,6 +78,7 @@ public static void readGeneaEpochs(
dataBlock = readLine(rawAccReader);

// raw reading values
long t = 0; // Unix time in millis
int hexPosition = 0;
int xRaw = 0;
int yRaw = 0;
Expand Down Expand Up @@ -100,7 +110,8 @@ public static void readGeneaEpochs(
y = (yRaw * 100.0d - mfrOffset[1]) / mfrGain[1];
z = (zRaw * 100.0d - mfrOffset[2]) / mfrGain[2];

epochWriter.newValues(getEpochMillis(blockTime), x, y, z, temperature, errCounter);
t = zonedWithDSTCorrection(blockTime).toInstant().toEpochMilli();
epochWriter.newValues(t, x, y, z, temperature, errCounter);

hexPosition += 12;
blockTime = blockTime.plusNanos(secs2Nanos(1.0 / sampleFreq));
Expand Down Expand Up @@ -166,4 +177,4 @@ private static String readLine(BufferedReader fReader) {
}


}
}

0 comments on commit 7b7083c

Please sign in to comment.