Added extra debugging information to log file in the event of an exception during analysis.
This commit is contained in:
BIN
app/release/app-release-3.6.1g.apk
Normal file
BIN
app/release/app-release-3.6.1g.apk
Normal file
Binary file not shown.
Binary file not shown.
@@ -11,8 +11,8 @@
|
||||
"type": "SINGLE",
|
||||
"filters": [],
|
||||
"properties": [],
|
||||
"versionCode": 79,
|
||||
"versionName": "3.6.1f",
|
||||
"versionCode": 80,
|
||||
"versionName": "3.6.1g",
|
||||
"enabled": true,
|
||||
"outputFile": "app-release.apk"
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="uk.org.openseizuredetector"
|
||||
android:versionCode="79"
|
||||
android:versionName="3.6.1f">
|
||||
android:versionCode="80"
|
||||
android:versionName="3.6.1g">
|
||||
<!-- android:allowBackup="false" -->
|
||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
||||
|
||||
@@ -45,6 +45,7 @@ import java.util.TimerTask;
|
||||
|
||||
interface SdDataReceiver {
|
||||
public void onSdDataReceived(SdData sdData);
|
||||
|
||||
public void onSdDataFault(SdData sdData);
|
||||
}
|
||||
|
||||
@@ -97,7 +98,6 @@ public abstract class SdDataSource {
|
||||
private int ACCEL_SCALE_FACTOR = 1000; // Amount by which to reduce analysis results to scale to be comparable to analysis on Pebble.
|
||||
|
||||
|
||||
|
||||
private int mAlarmCount;
|
||||
protected String mBleDeviceAddr;
|
||||
protected String mBleDeviceName;
|
||||
@@ -114,6 +114,7 @@ public abstract class SdDataSource {
|
||||
|
||||
/**
|
||||
* Returns the SdData object stored by this class.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public SdData getSdData() {
|
||||
@@ -233,9 +234,13 @@ public abstract class SdDataSource {
|
||||
}
|
||||
}
|
||||
|
||||
public void startPebbleApp() { Log.v(TAG,"startPebbleApp()"); }
|
||||
public void startPebbleApp() {
|
||||
Log.v(TAG, "startPebbleApp()");
|
||||
}
|
||||
|
||||
public void acceptAlarm() { Log.v(TAG,"acceptAlarm()"); }
|
||||
public void acceptAlarm() {
|
||||
Log.v(TAG, "acceptAlarm()");
|
||||
}
|
||||
|
||||
// Force the data stored in this datasource to update in line with the JSON string encoded data provided.
|
||||
// Used by webServer to update the GarminDatasource.
|
||||
@@ -246,6 +251,7 @@ public abstract class SdDataSource {
|
||||
String watchFwVersion;
|
||||
String sdVersion;
|
||||
String sdName;
|
||||
JSONArray accelVals = null;
|
||||
Log.v(TAG, "updateFromJSON - " + jsonStr);
|
||||
|
||||
try {
|
||||
@@ -268,8 +274,12 @@ public abstract class SdDataSource {
|
||||
// if we get 'null' HR (For example if the heart rate is not working)
|
||||
mMute = 0;
|
||||
}
|
||||
JSONArray accelVals = dataObject.getJSONArray("data");
|
||||
Log.v(TAG, "Received " + accelVals.length() + " acceleration values");
|
||||
accelVals = dataObject.getJSONArray("data");
|
||||
Log.v(TAG, "Received " + accelVals.length() + " acceleration values, rawData Length is " + mSdData.rawData.length);
|
||||
if (accelVals.length() > mSdData.rawData.length) {
|
||||
mUtil.writeToSysLogFile("ERROR: Received " + accelVals.length() + " acceleration values, but rawData storage length is "
|
||||
+ mSdData.rawData.length);
|
||||
}
|
||||
int i;
|
||||
for (i = 0; i < accelVals.length(); i++) {
|
||||
mSdData.rawData[i] = accelVals.getInt(i);
|
||||
@@ -318,6 +328,11 @@ public abstract class SdDataSource {
|
||||
Log.e(TAG, "updateFromJSON - Error Parsing JSON String - " + jsonStr + " - " + e.toString());
|
||||
mUtil.writeToSysLogFile("updateFromJSON - Error Parsing JSON String - " + jsonStr + " - " + e.toString());
|
||||
mUtil.writeToSysLogFile("updateFromJSON: Exception at Line Number: " + e.getCause().getStackTrace()[0].getLineNumber() + ", " + e.getCause().getStackTrace()[0].toString());
|
||||
if (accelVals == null) {
|
||||
mUtil.writeToSysLogFile("updateFromJSON: accelVals is null when exception thrown");
|
||||
} else {
|
||||
mUtil.writeToSysLogFile("updateFromJSON: Received " + accelVals.length() + " acceleration values");
|
||||
}
|
||||
e.printStackTrace();
|
||||
retVal = "ERROR";
|
||||
}
|
||||
@@ -326,6 +341,7 @@ public abstract class SdDataSource {
|
||||
|
||||
/**
|
||||
* Calculate the magnitude of entry i in the fft array fft
|
||||
*
|
||||
* @param fft
|
||||
* @param i
|
||||
* @return magnitude ( Re*Re + Im*Im )
|
||||
@@ -341,21 +357,26 @@ public abstract class SdDataSource {
|
||||
* and populate the output data structure mSdData
|
||||
*/
|
||||
protected void doAnalysis() {
|
||||
int nMin = 0;
|
||||
int nMax = 0;
|
||||
int nFreqCutoff = 0;
|
||||
double[] fft = null;
|
||||
try {
|
||||
// FIXME - Use specified sampleFreq, not this hard coded one
|
||||
mSampleFreq = 25;
|
||||
double freqRes = 1.0 * mSampleFreq / mSdData.mNsamp;
|
||||
Log.v(TAG, "doAnalysis(): mSampleFreq=" + mSampleFreq + " mNSamp=" + mSdData.mNsamp + ": freqRes=" + freqRes);
|
||||
// Set the frequency bounds for the analysis in fft output bin numbers.
|
||||
int nMin = (int)(mAlarmFreqMin/freqRes);
|
||||
int nMax = (int)(mAlarmFreqMax /freqRes);
|
||||
nMin = (int) (mAlarmFreqMin / freqRes);
|
||||
nMax = (int) (mAlarmFreqMax / freqRes);
|
||||
Log.v(TAG, "doAnalysis(): mAlarmFreqMin=" + mAlarmFreqMin + ", nMin=" + nMin
|
||||
+ ", mAlarmFreqMax=" + mAlarmFreqMax + ", nMax=" + nMax);
|
||||
// Calculate the bin number of the cutoff frequency
|
||||
int nFreqCutoff = (int)(mFreqCutoff /freqRes);
|
||||
nFreqCutoff = (int) (mFreqCutoff / freqRes);
|
||||
Log.v(TAG, "mFreqCutoff = " + mFreqCutoff + ", nFreqCutoff=" + nFreqCutoff);
|
||||
|
||||
DoubleFFT_1D fftDo = new DoubleFFT_1D(mSdData.mNsamp);
|
||||
double[] fft = new double[mSdData.mNsamp * 2];
|
||||
fft = new double[mSdData.mNsamp * 2];
|
||||
///System.arraycopy(mAccData, 0, fft, 0, mNsamp);
|
||||
System.arraycopy(mSdData.rawData, 0, fft, 0, mSdData.mNsamp);
|
||||
fftDo.realForward(fft);
|
||||
@@ -417,6 +438,17 @@ public abstract class SdDataSource {
|
||||
|
||||
// Because we have received data, set flag to show watch app running.
|
||||
mWatchAppRunningCheck = true;
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "doAnalysis - Exception during Analysis");
|
||||
mUtil.writeToSysLogFile("doAnalysis - Exception during analysis - " + e.toString());
|
||||
mUtil.writeToSysLogFile("doAnalysis: Exception at Line Number: " + e.getCause().getStackTrace()[0].getLineNumber() + ", " + e.getCause().getStackTrace()[0].toString());
|
||||
mUtil.writeToSysLogFile("doAnalysis: mSdData.mNsamp="+mSdData.mNsamp);
|
||||
mUtil.writeToSysLogFile("doAnalysis: alarmFreqMin="+mAlarmFreqMin+" nMin="+nMin);
|
||||
mUtil.writeToSysLogFile("doAnalysis: alarmFreqMax="+mAlarmFreqMax+" nMax="+nMax);
|
||||
mUtil.writeToSysLogFile("doAnalysis: nFreqCutoff.="+nFreqCutoff);
|
||||
mUtil.writeToSysLogFile("doAnalysis: fft.length="+fft.length);
|
||||
mWatchAppRunningCheck = false;
|
||||
}
|
||||
|
||||
// Check this data to see if it represents an alarm state.
|
||||
alarmCheck();
|
||||
@@ -500,13 +532,11 @@ public abstract class SdDataSource {
|
||||
mSdData.mHRFaultStanding = true;
|
||||
mSdData.mHRAlarmStanding = false;
|
||||
}
|
||||
}
|
||||
else if ((mSdData.mHR > mSdData.mHRThreshMax) || (mSdData.mHR < mSdData.mHRThreshMin)) {
|
||||
} else if ((mSdData.mHR > mSdData.mHRThreshMax) || (mSdData.mHR < mSdData.mHRThreshMin)) {
|
||||
Log.i(TAG, "Heart Rate Abnormal - " + mSdData.mHR + " bpm");
|
||||
mSdData.mHRFaultStanding = false;
|
||||
mSdData.mHRAlarmStanding = true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
mSdData.mHRFaultStanding = false;
|
||||
mSdData.mHRAlarmStanding = false;
|
||||
}
|
||||
@@ -770,9 +800,9 @@ public abstract class SdDataSource {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Display a Toast message on screen.
|
||||
*
|
||||
* @param msg - message to display.
|
||||
*/
|
||||
public void showToast(String msg) {
|
||||
@@ -781,7 +811,6 @@ public abstract class SdDataSource {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class SdDataBroadcastReceiver extends BroadcastReceiver {
|
||||
//private String TAG = "SdDataBroadcastReceiver";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user