V3.0.1 - Changed data log format
This commit is contained in:
@@ -1,7 +1,10 @@
|
|||||||
OpenSeizureDetector Android App - Change Log
|
OpenSeizureDetector Android App - Change Log
|
||||||
============================================
|
============================================
|
||||||
|
|
||||||
V3.0.0 - 15feb2019
|
V3.0.1 - 21feb201
|
||||||
|
- Simplified data log output to CSV format for easier processing, and had it log every update rather than one point per minute.
|
||||||
|
|
||||||
|
V3.0.0 - 15feb2019
|
||||||
- Updated for Android V9
|
- Updated for Android V9
|
||||||
- Added explicity statement of use of SMS permission in notification
|
- Added explicity statement of use of SMS permission in notification
|
||||||
- Updated to use dynamic permissions
|
- Updated to use dynamic permissions
|
||||||
|
|||||||
BIN
app/release/app-release-3.0.1.apk
Normal file
BIN
app/release/app-release-3.0.1.apk
Normal file
Binary file not shown.
@@ -1 +1 @@
|
|||||||
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":49,"versionName":"3.0.0","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
|
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":50,"versionName":"3.0.1","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="uk.org.openseizuredetector"
|
package="uk.org.openseizuredetector"
|
||||||
android:versionCode="49"
|
android:versionCode="50"
|
||||||
android:versionName="3.0.0"
|
android:versionName="3.0.1"
|
||||||
>
|
>
|
||||||
<!--android:allowBackup="false"-->
|
<!--android:allowBackup="false"-->
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,8 @@ public class SdData implements Parcelable {
|
|||||||
public boolean mHRAlarmActive = false;
|
public boolean mHRAlarmActive = false;
|
||||||
public double mHRThreshMin = 40.0;
|
public double mHRThreshMin = 40.0;
|
||||||
public double mHRTreshMax = 150.0;
|
public double mHRTreshMax = 150.0;
|
||||||
public int rawData[];
|
public double rawData[];
|
||||||
|
int mNsamp = 0;
|
||||||
|
|
||||||
/* Analysis results */
|
/* Analysis results */
|
||||||
public Time dataTime = null;
|
public Time dataTime = null;
|
||||||
@@ -90,7 +91,7 @@ public class SdData implements Parcelable {
|
|||||||
|
|
||||||
public SdData() {
|
public SdData() {
|
||||||
simpleSpec = new int[10];
|
simpleSpec = new int[10];
|
||||||
rawData = new int[N_RAW_DATA];
|
rawData = new double[N_RAW_DATA];
|
||||||
dataTime = new Time(Time.getCurrentTimezone());
|
dataTime = new Time(Time.getCurrentTimezone());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,6 +193,30 @@ public class SdData implements Parcelable {
|
|||||||
return (retval);
|
return (retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String toCSVString(boolean includeRawData) {
|
||||||
|
String retval;
|
||||||
|
retval = "";
|
||||||
|
if (dataTime != null) {
|
||||||
|
retval = dataTime.format("%d-%m-%Y %H:%M:%S");
|
||||||
|
}else{
|
||||||
|
retval = "00-00-00 00:00:00";
|
||||||
|
}
|
||||||
|
for (int i = 0; i < simpleSpec.length; i++) {
|
||||||
|
retval = retval + ", " + simpleSpec[i];
|
||||||
|
}
|
||||||
|
retval = retval + ", " + specPower;
|
||||||
|
retval = retval + ", " + roiPower;
|
||||||
|
retval = retval + ", " + mSampleFreq;
|
||||||
|
retval = retval + ", " + alarmPhrase;
|
||||||
|
if (includeRawData) {
|
||||||
|
for (int i = 0; i< mNsamp;i++) {
|
||||||
|
retval = retval + ", " + rawData[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return(retval);
|
||||||
|
}
|
||||||
|
|
||||||
public int describeContents() {
|
public int describeContents() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,12 +108,6 @@ public class SdDataSourceGarmin extends SdDataSource {
|
|||||||
|
|
||||||
private int mAlarmCount;
|
private int mAlarmCount;
|
||||||
|
|
||||||
// raw data storage for SD_MODE_RAW
|
|
||||||
private int MAX_RAW_DATA = 500;
|
|
||||||
public double[] mAccData = new double[MAX_RAW_DATA];
|
|
||||||
int mNSamp = 0;
|
|
||||||
|
|
||||||
|
|
||||||
public SdDataSourceGarmin(Context context, Handler handler,
|
public SdDataSourceGarmin(Context context, Handler handler,
|
||||||
SdDataReceiver sdDataReceiver) {
|
SdDataReceiver sdDataReceiver) {
|
||||||
super(context, handler, sdDataReceiver);
|
super(context, handler, sdDataReceiver);
|
||||||
@@ -386,9 +380,10 @@ public class SdDataSourceGarmin extends SdDataSource {
|
|||||||
Log.v(TAG, "Received " + accelVals.length() + " acceleration values");
|
Log.v(TAG, "Received " + accelVals.length() + " acceleration values");
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < accelVals.length(); i++) {
|
for (i = 0; i < accelVals.length(); i++) {
|
||||||
mAccData[i] = accelVals.getInt(i);
|
mSdData.rawData[i] = accelVals.getInt(i);
|
||||||
}
|
}
|
||||||
mNSamp = accelVals.length();
|
mSdData.mNsamp = accelVals.length();
|
||||||
|
//mNSamp = accelVals.length();
|
||||||
mWatchAppRunningCheck = true;
|
mWatchAppRunningCheck = true;
|
||||||
doAnalysis();
|
doAnalysis();
|
||||||
if (mSdData.haveSettings == false) {
|
if (mSdData.haveSettings == false) {
|
||||||
@@ -437,8 +432,8 @@ public class SdDataSourceGarmin extends SdDataSource {
|
|||||||
private void doAnalysis() {
|
private void doAnalysis() {
|
||||||
// FIXME - Use specified sampleFreq, not this hard coded one
|
// FIXME - Use specified sampleFreq, not this hard coded one
|
||||||
mSampleFreq = 25;
|
mSampleFreq = 25;
|
||||||
double freqRes = 1.0*mSampleFreq/mNSamp;
|
double freqRes = 1.0*mSampleFreq/mSdData.mNsamp;
|
||||||
Log.v(TAG,"doAnalysis(): mSampleFreq="+mSampleFreq+" mNSamp="+mNSamp+": freqRes="+freqRes);
|
Log.v(TAG,"doAnalysis(): mSampleFreq="+mSampleFreq+" mNSamp="+mSdData.mNsamp+": freqRes="+freqRes);
|
||||||
// Set the frequency bounds for the analysis in fft output bin numbers.
|
// Set the frequency bounds for the analysis in fft output bin numbers.
|
||||||
int nMin = (int)(mAlarmFreqMin/freqRes);
|
int nMin = (int)(mAlarmFreqMin/freqRes);
|
||||||
int nMax = (int)(mAlarmFreqMax /freqRes);
|
int nMax = (int)(mAlarmFreqMax /freqRes);
|
||||||
@@ -448,15 +443,16 @@ public class SdDataSourceGarmin extends SdDataSource {
|
|||||||
int nFreqCutoff = (int)(mFreqCutoff /freqRes);
|
int nFreqCutoff = (int)(mFreqCutoff /freqRes);
|
||||||
Log.v(TAG,"mFreqCutoff = "+mFreqCutoff+", nFreqCutoff="+nFreqCutoff);
|
Log.v(TAG,"mFreqCutoff = "+mFreqCutoff+", nFreqCutoff="+nFreqCutoff);
|
||||||
|
|
||||||
DoubleFFT_1D fftDo = new DoubleFFT_1D(mNSamp);
|
DoubleFFT_1D fftDo = new DoubleFFT_1D(mSdData.mNsamp);
|
||||||
double[] fft = new double[mNSamp * 2];
|
double[] fft = new double[mSdData.mNsamp * 2];
|
||||||
System.arraycopy(mAccData, 0, fft, 0, mNSamp);
|
///System.arraycopy(mAccData, 0, fft, 0, mNsamp);
|
||||||
|
System.arraycopy(mSdData.rawData, 0, fft, 0, mSdData.mNsamp);
|
||||||
fftDo.realForward(fft);
|
fftDo.realForward(fft);
|
||||||
|
|
||||||
// Calculate the whole spectrum power (well a value equivalent to it that avoids square root calculations
|
// Calculate the whole spectrum power (well a value equivalent to it that avoids square root calculations
|
||||||
// and zero any readings that are above the frequency cutoff.
|
// and zero any readings that are above the frequency cutoff.
|
||||||
double specPower = 0;
|
double specPower = 0;
|
||||||
for (int i = 1; i < mNSamp / 2; i++) {
|
for (int i = 1; i < mSdData.mNsamp / 2; i++) {
|
||||||
if (i <= nFreqCutoff) {
|
if (i <= nFreqCutoff) {
|
||||||
specPower = specPower + getMagnitude(fft,i);
|
specPower = specPower + getMagnitude(fft,i);
|
||||||
} else {
|
} else {
|
||||||
@@ -464,7 +460,7 @@ public class SdDataSourceGarmin extends SdDataSource {
|
|||||||
fft[2*i+1] = 0.;
|
fft[2*i+1] = 0.;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
specPower = specPower/mNSamp/2;
|
specPower = specPower/mSdData.mNsamp/2;
|
||||||
|
|
||||||
// Calculate the Region of Interest power and power ratio.
|
// Calculate the Region of Interest power and power ratio.
|
||||||
double roiPower = 0;
|
double roiPower = 0;
|
||||||
@@ -622,22 +618,6 @@ public class SdDataSourceGarmin extends SdDataSource {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void makeTestData() {
|
|
||||||
int sampleFreq = 25; // Hz
|
|
||||||
int samplePeriod = 5; // sec
|
|
||||||
int accDataPos = 0;
|
|
||||||
|
|
||||||
double signalFreq = 5; // Hz
|
|
||||||
double signalAmp = 500; // mG
|
|
||||||
|
|
||||||
for (int i = 0; i < samplePeriod * sampleFreq; i++) {
|
|
||||||
double t = 1.0*i / sampleFreq;
|
|
||||||
double r = 2.0*Math.PI*t*signalFreq;
|
|
||||||
mAccData[accDataPos] = (signalAmp*(Math.sin(r)));
|
|
||||||
Log.v(TAG, "i=" + i + ", t="+t+", r="+r+", a="+ mAccData[accDataPos]);
|
|
||||||
accDataPos++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class SdDataBroadcastReceiver extends BroadcastReceiver {
|
public class SdDataBroadcastReceiver extends BroadcastReceiver {
|
||||||
//private String TAG = "SdDataBroadcastReceiver";
|
//private String TAG = "SdDataBroadcastReceiver";
|
||||||
|
|||||||
@@ -269,13 +269,15 @@ public class SdServer extends Service implements SdDataReceiver, SdLocationRecei
|
|||||||
if (dataLogTimer == null) {
|
if (dataLogTimer == null) {
|
||||||
Log.v(TAG, "onStartCommand(): starting dataLog timer");
|
Log.v(TAG, "onStartCommand(): starting dataLog timer");
|
||||||
mUtil.writeToSysLogFile("SdServer.onStartCommand() - starting dataLog timer");
|
mUtil.writeToSysLogFile("SdServer.onStartCommand() - starting dataLog timer");
|
||||||
dataLogTimer = new Timer();
|
/*dataLogTimer = new Timer();
|
||||||
dataLogTimer.schedule(new TimerTask() {
|
dataLogTimer.schedule(new TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
Log.v(TAG,"dataLogTimer.run()");
|
||||||
logData();
|
logData();
|
||||||
}
|
}
|
||||||
}, 0, 1000 * 60);
|
}, 0, 1000 * 60);
|
||||||
|
*/
|
||||||
} else {
|
} else {
|
||||||
Log.v(TAG, "onStartCommand(): dataLog timer already running.");
|
Log.v(TAG, "onStartCommand(): dataLog timer already running.");
|
||||||
mUtil.writeToSysLogFile("SdServer.onStartCommand() - dataLog timer already running???");
|
mUtil.writeToSysLogFile("SdServer.onStartCommand() - dataLog timer already running???");
|
||||||
@@ -340,14 +342,14 @@ public class SdServer extends Service implements SdDataReceiver, SdLocationRecei
|
|||||||
stopLatchTimer();
|
stopLatchTimer();
|
||||||
|
|
||||||
// Stop the status timer
|
// Stop the status timer
|
||||||
if (dataLogTimer != null) {
|
/*if (dataLogTimer != null) {
|
||||||
Log.v(TAG, "stop(): cancelling Data logger timer");
|
Log.v(TAG, "stop(): cancelling Data logger timer");
|
||||||
mUtil.writeToSysLogFile("onDestroy() - cancelling data log timer");
|
mUtil.writeToSysLogFile("onDestroy() - cancelling data log timer");
|
||||||
dataLogTimer.cancel();
|
dataLogTimer.cancel();
|
||||||
dataLogTimer.purge();
|
dataLogTimer.purge();
|
||||||
dataLogTimer = null;
|
dataLogTimer = null;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -489,7 +491,6 @@ public class SdServer extends Service implements SdDataReceiver, SdLocationRecei
|
|||||||
if (mLogAlarms) {
|
if (mLogAlarms) {
|
||||||
Log.v(TAG, "WARNING - Logging to SD Card");
|
Log.v(TAG, "WARNING - Logging to SD Card");
|
||||||
writeAlarmToSD();
|
writeAlarmToSD();
|
||||||
logData();
|
|
||||||
} else {
|
} else {
|
||||||
Log.v(TAG, "WARNING");
|
Log.v(TAG, "WARNING");
|
||||||
}
|
}
|
||||||
@@ -503,7 +504,6 @@ public class SdServer extends Service implements SdDataReceiver, SdLocationRecei
|
|||||||
if (mLogAlarms) {
|
if (mLogAlarms) {
|
||||||
Log.v(TAG, "***ALARM*** - Logging to SD Card");
|
Log.v(TAG, "***ALARM*** - Logging to SD Card");
|
||||||
writeAlarmToSD();
|
writeAlarmToSD();
|
||||||
logData();
|
|
||||||
} else {
|
} else {
|
||||||
Log.v(TAG, "***ALARM***");
|
Log.v(TAG, "***ALARM***");
|
||||||
}
|
}
|
||||||
@@ -533,7 +533,6 @@ public class SdServer extends Service implements SdDataReceiver, SdLocationRecei
|
|||||||
if (mLogAlarms) {
|
if (mLogAlarms) {
|
||||||
Log.v(TAG, "***FALL*** - Logging to SD Card");
|
Log.v(TAG, "***FALL*** - Logging to SD Card");
|
||||||
writeAlarmToSD();
|
writeAlarmToSD();
|
||||||
logData();
|
|
||||||
showNotification(2);
|
showNotification(2);
|
||||||
} else {
|
} else {
|
||||||
Log.v(TAG, "***FALL***");
|
Log.v(TAG, "***FALL***");
|
||||||
@@ -561,7 +560,6 @@ public class SdServer extends Service implements SdDataReceiver, SdLocationRecei
|
|||||||
if (mLogAlarms) {
|
if (mLogAlarms) {
|
||||||
Log.v(TAG, "***HEART RATE*** - Logging to SD Card");
|
Log.v(TAG, "***HEART RATE*** - Logging to SD Card");
|
||||||
writeAlarmToSD();
|
writeAlarmToSD();
|
||||||
logData();
|
|
||||||
} else {
|
} else {
|
||||||
Log.v(TAG, "***HEART RATE***");
|
Log.v(TAG, "***HEART RATE***");
|
||||||
}
|
}
|
||||||
@@ -597,6 +595,8 @@ public class SdServer extends Service implements SdDataReceiver, SdLocationRecei
|
|||||||
mSdData = sdData;
|
mSdData = sdData;
|
||||||
if (webServer != null) webServer.setSdData(mSdData);
|
if (webServer != null) webServer.setSdData(mSdData);
|
||||||
Log.v(TAG, "onSdDataReceived() - setting mSdData to " + mSdData.toString());
|
Log.v(TAG, "onSdDataReceived() - setting mSdData to " + mSdData.toString());
|
||||||
|
|
||||||
|
logData();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called by SdDataSource when a fault condition is detected.
|
// Called by SdDataSource when a fault condition is detected.
|
||||||
@@ -1096,7 +1096,7 @@ public class SdServer extends Service implements SdDataReceiver, SdLocationRecei
|
|||||||
* in which case writes to alarm log file.
|
* in which case writes to alarm log file.
|
||||||
*/
|
*/
|
||||||
public void writeToSD(boolean alarm) {
|
public void writeToSD(boolean alarm) {
|
||||||
Log.v(TAG, "writeToSD(" + alarm + ")");
|
//Log.v(TAG, "writeToSD(" + alarm + ")");
|
||||||
Time tnow = new Time(Time.getCurrentTimezone());
|
Time tnow = new Time(Time.getCurrentTimezone());
|
||||||
tnow.setToNow();
|
tnow.setToNow();
|
||||||
String dateStr = tnow.format("%Y-%m-%d");
|
String dateStr = tnow.format("%Y-%m-%d");
|
||||||
@@ -1115,8 +1115,13 @@ public class SdServer extends Service implements SdDataReceiver, SdLocationRecei
|
|||||||
FileWriter of = new FileWriter(mUtil.getDataStorageDir().toString()
|
FileWriter of = new FileWriter(mUtil.getDataStorageDir().toString()
|
||||||
+ "/" + fname, true);
|
+ "/" + fname, true);
|
||||||
if (mSdData != null) {
|
if (mSdData != null) {
|
||||||
Log.v(TAG, "writing mSdData.toString()");
|
if (alarm) {
|
||||||
of.append(mSdData.toString() + "\n");
|
//Log.v(TAG, "writeToSD() - logging mSdData.toString()");
|
||||||
|
of.append(mSdData.toString() + "\n");
|
||||||
|
} else {
|
||||||
|
//Log.v(TAG, "writeToSD() - logging mSdData.toCSVString()");
|
||||||
|
of.append(mSdData.toCSVString(true) + "\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
of.close();
|
of.close();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
|||||||
Reference in New Issue
Block a user