Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fix for genea native dst support #211

Merged
merged 1 commit into from
Sep 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
}


}
}