Merge branch 'V4.0.x' into V4.1.x
This commit is contained in:
@@ -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="113"
|
||||
android:versionName="4.1.1">
|
||||
android:versionCode="114"
|
||||
android:versionName="4.1.2a">
|
||||
<!-- android:allowBackup="false" -->
|
||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
||||
|
||||
Binary file not shown.
BIN
app/src/main/assets/cnn_v0.22.tflite
Normal file
BIN
app/src/main/assets/cnn_v0.22.tflite
Normal file
Binary file not shown.
@@ -24,6 +24,7 @@ package uk.org.openseizuredetector;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
import android.database.DatabaseUtils;
|
||||
import android.database.SQLException;
|
||||
@@ -32,6 +33,8 @@ import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.CountDownTimer;
|
||||
import android.os.Handler;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.text.format.Time;
|
||||
import android.util.Log;
|
||||
|
||||
import org.json.JSONArray;
|
||||
@@ -63,6 +66,20 @@ import java.util.HashMap;
|
||||
* - Query the local database to return all datapoints within +/- EventDuration/2 minutes of the event.
|
||||
* - Upload the datapoints, linking them to the new eventID.
|
||||
* - Mark all the uploaded datapoints as uploaded.
|
||||
*
|
||||
* Event statuses:
|
||||
* 0 - OK
|
||||
* 1 - WARNING
|
||||
* 2 - ALARM
|
||||
* 3 - FALL
|
||||
* 4 - FAULT
|
||||
* 5 - Manual Alarm
|
||||
* 6 - NDA (Normal Daily Activities)
|
||||
*
|
||||
* NDA Timer creates an event periodically to record Normal Daily Activities (NDA),
|
||||
* irrespective of the alarm state. This will upload a lot of data, so it will only run
|
||||
* for 24 hours after being activated before shutting down requring the user to re-select
|
||||
* the option to log NDA to re-start it.
|
||||
*/
|
||||
public class LogManager {
|
||||
static final private String TAG = "LogManager";
|
||||
@@ -74,6 +91,11 @@ public class LogManager {
|
||||
private String mAuthToken;
|
||||
static private SQLiteDatabase mOsdDb = null; // SQLite Database for data and log entries.
|
||||
private RemoteLogTimer mRemoteLogTimer;
|
||||
private boolean mLogNDA;
|
||||
public NDATimer mNDATimer;
|
||||
private long mNDATimerStartTime; // milliseconds
|
||||
public double mNDATimeRemaining; // hours
|
||||
public double mNDALogPeriodHours = 24.0; // hours
|
||||
private static Context mContext;
|
||||
private OsdUtil mUtil;
|
||||
public static WebApiConnection mWac;
|
||||
@@ -90,6 +112,7 @@ public class LogManager {
|
||||
private long mAutoPrunePeriod = 3600; // Prune the database every hour
|
||||
private boolean mAutoPruneDb;
|
||||
private AutoPruneTimer mAutoPruneTimer;
|
||||
private SdData mSdSettingsData;
|
||||
|
||||
public interface CursorCallback {
|
||||
void accept(Cursor retVal);
|
||||
@@ -102,7 +125,9 @@ public class LogManager {
|
||||
public LogManager(Context context,
|
||||
boolean logRemote, boolean logRemoteMobile, String authToken,
|
||||
long eventDuration, long remoteLogPeriod,
|
||||
boolean autoPruneDb, long dataRetentionPeriod) {
|
||||
boolean logNDA,
|
||||
boolean autoPruneDb, long dataRetentionPeriod,
|
||||
SdData sdSettingsData) {
|
||||
Log.d(TAG, "LogManger Constructor");
|
||||
mContext = context;
|
||||
Handler handler = new Handler();
|
||||
@@ -114,9 +139,12 @@ public class LogManager {
|
||||
mAutoPruneDb = autoPruneDb;
|
||||
mDataRetentionPeriod = dataRetentionPeriod;
|
||||
mRemoteLogPeriod = remoteLogPeriod;
|
||||
mLogNDA = logNDA;
|
||||
mSdSettingsData = sdSettingsData;
|
||||
Log.v(TAG, "mLogRemote=" + mLogRemote);
|
||||
Log.v(TAG, "mLogRemoteMobile=" + mLogRemoteMobile);
|
||||
Log.v(TAG, "mEventDuration=" + mEventDuration);
|
||||
Log.v(TAG, "mLogNDA=" + mLogNDA);
|
||||
Log.v(TAG, "mAutoPruneDb=" + mAutoPruneDb);
|
||||
Log.v(TAG, "mDataRetentionPeriod=" + mDataRetentionPeriod);
|
||||
Log.v(TAG, "mRemoteLogPeriod=" + mRemoteLogPeriod);
|
||||
@@ -146,6 +174,13 @@ public class LogManager {
|
||||
Log.i(TAG, "AutoPruneDB is not set - not starting Auto Prune Timer");
|
||||
}
|
||||
|
||||
if (mLogNDA) {
|
||||
Log.i(TAG, "Starting Normal Daily Activity Log Timer");
|
||||
startNDATimer();
|
||||
} else {
|
||||
Log.i(TAG, "mLogNDA is false - not starting Normal Daily Activity Log timer");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -325,17 +360,6 @@ public class LogManager {
|
||||
// Expects dataTime to be in format: SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Log.d(TAG, "createLocalEvent() - dataTime=" + dataTime + ", status=" + status + ", dataJSON="+dataJSON);
|
||||
// Write Event to database
|
||||
//String SQLStr = "INSERT INTO " + mEventsTableName
|
||||
// + "(dataTime, status, type, subtype, notes, dataJSON)"
|
||||
// + " VALUES("
|
||||
// + "'" + dataTime + "',"
|
||||
// + status + ","
|
||||
// + "'" + type + "',"
|
||||
// + "'" + subType + "',"
|
||||
// + "'" + desc + "',"
|
||||
// + "'" + dataJSON + "'"
|
||||
// + ")";
|
||||
//mOsdDb.execSQL(SQLStr);
|
||||
ContentValues values = new ContentValues();
|
||||
values.put("dataTime", dataTime);
|
||||
values.put("status", status);
|
||||
@@ -345,7 +369,7 @@ public class LogManager {
|
||||
values.put("dataJSON", dataJSON);
|
||||
|
||||
long newRowId = mOsdDb.insert(mEventsTableName, null, values);
|
||||
Log.d(TAG, "Created Row ID"+newRowId);
|
||||
Log.d(TAG, "createLocalEvent(): Created Row ID"+newRowId);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -556,7 +580,7 @@ public class LogManager {
|
||||
|
||||
// Do not try to upload very recent events so that we have chance to record the post-event data before uploading it.
|
||||
long currentDateMillis = new Date().getTime();
|
||||
long endDateMillis = currentDateMillis - 1000 * mEventDuration;
|
||||
long endDateMillis = currentDateMillis - 1000 * mEventDuration / 2;
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String endDateStr = dateFormat.format(new Date(endDateMillis));
|
||||
String whereClauseUploaded = "uploaded is null";
|
||||
@@ -732,21 +756,41 @@ public class LogManager {
|
||||
|
||||
|
||||
private String getEventWhereClause(boolean includeWarnings) {
|
||||
/**
|
||||
* * Event statuses:
|
||||
* * 0 - OK
|
||||
* * 1 - WARNING
|
||||
* * 2 - ALARM
|
||||
* * 3 - FALL
|
||||
* * 4 - FAULT
|
||||
* * 5 - Manual Alarm
|
||||
* * 6 - NDA (Normal Daily Activities)
|
||||
*/
|
||||
String whereClause;
|
||||
if (includeWarnings) {
|
||||
whereClause = "Status in (?, ?, ?, ?)";
|
||||
whereClause = "Status in (?, ?, ?, ?, ?)";
|
||||
} else {
|
||||
whereClause = "Status in (?, ?, ?)";
|
||||
whereClause = "Status in (?, ?, ?, ?)";
|
||||
}
|
||||
return (whereClause);
|
||||
}
|
||||
|
||||
private String[] getEventWhereArgs(boolean includeWarnings) {
|
||||
/**
|
||||
* * Event statuses:
|
||||
* * 0 - OK
|
||||
* * 1 - WARNING
|
||||
* * 2 - ALARM
|
||||
* * 3 - FALL
|
||||
* * 4 - FAULT
|
||||
* * 5 - Manual Alarm
|
||||
* * 6 - NDA (Normal Daily Activities)
|
||||
*/
|
||||
String[] whereArgs;
|
||||
if (includeWarnings) {
|
||||
whereArgs = new String[]{"1", "2", "3", "5"};
|
||||
whereArgs = new String[]{"1", "2", "3", "5", "6"};
|
||||
} else {
|
||||
whereArgs = new String[]{"2", "3", "5"};
|
||||
whereArgs = new String[]{"2", "3", "5", "6"};
|
||||
}
|
||||
return (whereArgs);
|
||||
}
|
||||
@@ -1010,6 +1054,7 @@ public class LogManager {
|
||||
// Stop the timers and shutdown the remote API connection.
|
||||
stopRemoteLogTimer();
|
||||
stopAutoPruneTimer();
|
||||
stopNDATimer();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1039,6 +1084,71 @@ public class LogManager {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Start the timer that will log Normal Daily Activity continuously.
|
||||
*/
|
||||
private void startNDATimer() {
|
||||
if (mNDATimer != null) {
|
||||
Log.i(TAG, "startNDATimer -timer already running - cancelling it");
|
||||
mNDATimer.cancel();
|
||||
mNDATimer = null;
|
||||
}
|
||||
Log.i(TAG, "startNDATimer() - starting NDATimer");
|
||||
// We set the timer to timeout after the event duration, so that we record all data
|
||||
// without a gap.
|
||||
mNDATimer =
|
||||
new NDATimer(mEventDuration * 1000, 1000, mNDALogPeriodHours);
|
||||
mNDATimer.start();
|
||||
|
||||
// If we do not have a stored start time for NDA logging, set it to current time
|
||||
// and store it.
|
||||
SharedPreferences SP = PreferenceManager
|
||||
.getDefaultSharedPreferences(mContext);
|
||||
mNDATimerStartTime = SP.getLong("NDATimerStartTime", 0);
|
||||
if (mNDATimerStartTime == 0) {
|
||||
Time timeNow = new Time(Time.getCurrentTimezone());
|
||||
timeNow.setToNow();
|
||||
mNDATimerStartTime = timeNow.toMillis(true);
|
||||
SharedPreferences.Editor editor = SP.edit();
|
||||
editor.putLong("NDATimerStartTime", mNDATimerStartTime);
|
||||
editor.putBoolean("LogNDA", true);
|
||||
editor.apply();
|
||||
}
|
||||
Time timeNow = new Time(Time.getCurrentTimezone());
|
||||
timeNow.setToNow();
|
||||
long tNow = timeNow.toMillis(true);
|
||||
long tDiffMillis = (tNow - mNDATimerStartTime);
|
||||
mNDATimeRemaining = mNDALogPeriodHours - tDiffMillis / (3600.*1000.);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Cancel the Normal Daily Actity Log timer
|
||||
*/
|
||||
public void stopNDATimer() {
|
||||
if (mNDATimer != null) {
|
||||
Log.i(TAG, "stopNDATimer(): cancelling Normal Daily Activity timer");
|
||||
mNDATimer.cancel();
|
||||
mNDATimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void disableNDATimer() {
|
||||
SharedPreferences SP = PreferenceManager
|
||||
.getDefaultSharedPreferences(mContext);
|
||||
SharedPreferences.Editor editor = SP.edit();
|
||||
editor.putBoolean("LogNDA", false);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public void enableNDATimer() {
|
||||
SharedPreferences SP = PreferenceManager
|
||||
.getDefaultSharedPreferences(mContext);
|
||||
SharedPreferences.Editor editor = SP.edit();
|
||||
editor.putBoolean("LogNDA", true);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
/*
|
||||
* Start the timer that will Auto Prune the database
|
||||
@@ -1068,6 +1178,21 @@ public class LogManager {
|
||||
}
|
||||
|
||||
|
||||
public void createNDAEvent() {
|
||||
Log.i(TAG,"createNDAEvent()");
|
||||
Date curDate = new Date();
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String dateStr = dateFormat.format(curDate);
|
||||
createLocalEvent(dateStr,6,"nda", null, null,
|
||||
mSdSettingsData.toSettingsJSON());
|
||||
}
|
||||
|
||||
public void updateSdData(SdData sdData) {
|
||||
mSdSettingsData = sdData;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static class OsdDbHelper extends SQLiteOpenHelper {
|
||||
// If you change the database schema, you must increment the database version.
|
||||
public static final int DATABASE_VERSION = 1;
|
||||
@@ -1141,6 +1266,52 @@ public class LogManager {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Log Normal Daily Activities periodically.
|
||||
*/
|
||||
private class NDATimer extends CountDownTimer {
|
||||
double mNDALogPeriodHours = 0;
|
||||
public NDATimer(long startTime, long interval, double logPeriod) {
|
||||
super(startTime, interval);
|
||||
mNDALogPeriodHours = logPeriod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick(long l) {
|
||||
// Do Nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
Log.d(TAG, "mNDATimer - onFinish - Recording a Normal Daily Activity Event");
|
||||
createNDAEvent();
|
||||
// Check if we have been logging NDA events for more than the set limit. If it has, we disable it
|
||||
// and set the start time to zero so it is re-set next time NDA logging is enabled.
|
||||
Time timeNow = new Time(Time.getCurrentTimezone());
|
||||
timeNow.setToNow();
|
||||
long tNow = timeNow.toMillis(true);
|
||||
long tDiffMillis = (tNow - mNDATimerStartTime);
|
||||
double tDiffHrs = tDiffMillis / (3600.*1000.);
|
||||
mNDATimeRemaining = mNDALogPeriodHours - tDiffHrs;
|
||||
if (tDiffHrs >= mNDALogPeriodHours) {
|
||||
Log.i(TAG, "mNDATimer - onFinish - NDA logging period completed - switching off NDA Logging");
|
||||
SharedPreferences SP = PreferenceManager
|
||||
.getDefaultSharedPreferences(mContext);
|
||||
SharedPreferences.Editor editor = SP.edit();
|
||||
editor.putLong("NDATimerStartTime", 0);
|
||||
editor.putBoolean("LogNDA", false);
|
||||
editor.apply();
|
||||
} else {
|
||||
// Restart this timer.
|
||||
Log.i(TAG,"NDATimer - tDiffMillis="+tDiffMillis+", tdiffHrs = "+tDiffHrs+ ", tnow="+tNow+", tstart="+mNDATimerStartTime+", NDALogPeriod="+mNDALogPeriodHours);
|
||||
Log.i(TAG,"NDATimer - re-starting NDA timer");
|
||||
start();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prune the database periodically.
|
||||
*/
|
||||
|
||||
@@ -61,6 +61,7 @@ public class LogManagerControlActivity extends AppCompatActivity {
|
||||
private Integer mUiTimerPeriodFast = 2000; // 2 seconds - we use fast updating while UI is blank and we are waiting for first data
|
||||
private Integer mUiTimerPeriodSlow = 60000; // 60 seconds - once data has been received and UI populated we only update once per minute.
|
||||
private boolean mUpdateSysLog = true;
|
||||
private Menu mMenu;
|
||||
//private Integer UI_MODE_LOCAL = 0;
|
||||
//private Integer UI_MODE_SHARED = 1;
|
||||
//private Integer mUiMode = UI_MODE_SHARED;
|
||||
@@ -117,6 +118,9 @@ public class LogManagerControlActivity extends AppCompatActivity {
|
||||
CheckBox includeWarningsCb =
|
||||
(CheckBox) findViewById(R.id.include_warnings_cb);
|
||||
includeWarningsCb.setOnCheckedChangeListener(onIncludeWarningsCb);
|
||||
CheckBox includeNDACb =
|
||||
(CheckBox) findViewById(R.id.include_nda_cb);
|
||||
includeNDACb.setOnCheckedChangeListener(onIncludeNDACb);
|
||||
|
||||
ListView lv = (ListView) findViewById(R.id.eventLogListView);
|
||||
lv.setOnItemClickListener(onEventListClick);
|
||||
@@ -133,6 +137,7 @@ public class LogManagerControlActivity extends AppCompatActivity {
|
||||
Log.i(TAG, "onCreateOptionsMenu()");
|
||||
getMenuInflater().inflate(R.menu.log_manager_activity_menu, menu);
|
||||
MenuCompat.setGroupDividerEnabled(menu, true);
|
||||
this.mMenu = menu;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -196,8 +201,10 @@ public class LogManagerControlActivity extends AppCompatActivity {
|
||||
private void initialiseServiceConnection() {
|
||||
mLm = mConnection.mSdServer.mLm;
|
||||
startUiTimer(mUiTimerPeriodFast);
|
||||
|
||||
final CheckBox includeWarningsCb = (CheckBox) findViewById(R.id.include_warnings_cb);
|
||||
getRemoteEvents(includeWarningsCb.isChecked());
|
||||
final CheckBox includeNDACb = (CheckBox) findViewById(R.id.include_nda_cb);
|
||||
getRemoteEvents(includeWarningsCb.isChecked(), includeNDACb.isChecked());
|
||||
ProgressBar pb = (ProgressBar)findViewById(R.id.remoteAccessPb);
|
||||
pb.setIndeterminate(true);
|
||||
pb.setVisibility(View.VISIBLE);
|
||||
@@ -217,7 +224,7 @@ public class LogManagerControlActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
|
||||
private void getRemoteEvents(boolean includeWarnings) {
|
||||
private void getRemoteEvents(boolean includeWarnings, boolean includeNDA) {
|
||||
mRemoteEventsList = null; // clear existing data
|
||||
// Retrieve events from remote database
|
||||
mLm.mWac.getEvents((JSONObject remoteEventsObj) -> {
|
||||
@@ -267,10 +274,11 @@ public class LogManagerControlActivity extends AppCompatActivity {
|
||||
eventHashMap.put("type", typeStr);
|
||||
eventHashMap.put("subType", subType);
|
||||
eventHashMap.put("desc", desc);
|
||||
if (osdAlarmState!=1 | includeWarnings) {
|
||||
if ((osdAlarmState!=1 | includeWarnings) &&
|
||||
(osdAlarmState!=6 | includeNDA)) {
|
||||
mRemoteEventsList.add(eventHashMap);
|
||||
} else {
|
||||
Log.v(TAG,"getRemoteEvents - skipping warning");
|
||||
Log.v(TAG,"getRemoteEvents - skipping warning or NDA record");
|
||||
}
|
||||
}
|
||||
Log.v(TAG, "getRemoteEvents() - set mRemoteEventsList(). Updating UI");
|
||||
@@ -301,6 +309,9 @@ public class LogManagerControlActivity extends AppCompatActivity {
|
||||
TextView tv2 = (TextView) findViewById(R.id.num_local_datapoints_tv);
|
||||
tv2.setText(String.format("%d", datapointsCount));
|
||||
});
|
||||
TextView tv3 = (TextView)findViewById(R.id.nda_time_remaining_tv);
|
||||
tv3.setText(String.format("%.1f hrs",mLm.mNDATimeRemaining));
|
||||
Log.d(TAG,"mNDATimeRemaining = "+String.format("%.1f hrs",mLm.mNDATimeRemaining));
|
||||
} else {
|
||||
stopUpdating = false;
|
||||
}
|
||||
@@ -366,6 +377,7 @@ public class LogManagerControlActivity extends AppCompatActivity {
|
||||
stopUiTimer();
|
||||
//startUiTimer(mUiTimerPeriodSlow);
|
||||
}
|
||||
|
||||
} //updateUi();
|
||||
|
||||
public void onRadioButtonClicked(View view) {
|
||||
@@ -444,6 +456,55 @@ public class LogManagerControlActivity extends AppCompatActivity {
|
||||
} catch (Exception ex) {
|
||||
Log.i(TAG, "exception starting settings activity " + ex.toString());
|
||||
}
|
||||
return true;
|
||||
case R.id.start_stop_nda:
|
||||
Log.i(TAG,"start/stop NDA");
|
||||
if (mConnection.mSdServer.mLogNDA) {
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle(R.string.stop_nda_logging_dialog_title)
|
||||
.setMessage(R.string.stop_nda_logging_dialog_meassage)
|
||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
mLm.disableNDATimer();
|
||||
MenuItem startStopNDAMenuItem = mMenu.findItem(R.id.start_stop_nda);
|
||||
startStopNDAMenuItem.setTitle(R.string.start_nda_menu_title);
|
||||
mUtil.stopServer();
|
||||
// Wait 0.1 second to give the server chance to shutdown, then re-start it
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
mUtil.startServer();
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.no, null)
|
||||
.show();
|
||||
|
||||
} else {
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle(R.string.start_nda_logging_dialog_title)
|
||||
.setMessage(R.string.start_nda_logging_dialog_meassage)
|
||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
mLm.enableNDATimer();
|
||||
MenuItem startStopNDAMenuItem = mMenu.findItem(R.id.start_stop_nda);
|
||||
startStopNDAMenuItem.setTitle(R.string.stop_nda_menu_title);
|
||||
mUtil.stopServer();
|
||||
// Wait 0.1 second to give the server chance to shutdown, then re-start it
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
mUtil.startServer();
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.no, null)
|
||||
.show();
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
case R.id.action_mark_unknown:
|
||||
Log.i(TAG, "action_mark_unknown");
|
||||
@@ -555,6 +616,16 @@ public class LogManagerControlActivity extends AppCompatActivity {
|
||||
}
|
||||
};
|
||||
|
||||
CompoundButton.OnCheckedChangeListener onIncludeNDACb =
|
||||
new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
||||
Log.v(TAG, "onIncludeNDACb");
|
||||
initialiseServiceConnection();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
AdapterView.OnItemClickListener onEventListClick =
|
||||
new AdapterView.OnItemClickListener() {
|
||||
public void onItemClick(AdapterView<?> adapter, View v, int position, long id) {
|
||||
|
||||
@@ -516,10 +516,16 @@ public class MainActivity extends AppCompatActivity {
|
||||
tv = (TextView) findViewById(R.id.serverStatusTv);
|
||||
if (mConnection.mBound) {
|
||||
if (mConnection.mSdServer.mSdDataSourceName.equals("Phone")) {
|
||||
if (mConnection.mSdServer.mLogNDA)
|
||||
tv.setText(getString(R.string.ServerRunningOK) + getString(R.string.DataSource) + " = " + "Phone" + "\n" + "(Demo Mode)"+"\nNDA Logging");
|
||||
else
|
||||
tv.setText(getString(R.string.ServerRunningOK) + getString(R.string.DataSource) + " = " + "Phone" + "\n" + "(Demo Mode)");
|
||||
tv.setBackgroundColor(warnColour);
|
||||
tv.setTextColor(warnTextColour);
|
||||
} else {
|
||||
if (mConnection.mSdServer.mLogNDA)
|
||||
tv.setText(getString(R.string.ServerRunningOK) + getString(R.string.DataSource) + " = " + mConnection.mSdServer.mSdDataSourceName+"\nNDA Logging");
|
||||
else
|
||||
tv.setText(getString(R.string.ServerRunningOK) + getString(R.string.DataSource) + " = " + mConnection.mSdServer.mSdDataSourceName);
|
||||
tv.setBackgroundColor(okColour);
|
||||
tv.setTextColor(okTextColour);
|
||||
@@ -579,7 +585,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
tv.setTextColor(okTextColour);
|
||||
tv.setPaintFlags(tv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
|
||||
}
|
||||
|
||||
}
|
||||
tv = (TextView) findViewById(R.id.serverIpTv);
|
||||
tv.setText(getString(R.string.AccessServerAt) + " http://"
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.util.Map;
|
||||
|
||||
public class SdAlgNn {
|
||||
private final static String TAG = "SdAlgNn";
|
||||
private final static String MODEL_PATH = "cnn_v0.20.tflite";
|
||||
private final static String MODEL_PATH = "cnn_v0.22.tflite";
|
||||
private String mUrlBase = "https://osdApi.ddns.net";
|
||||
private InterpreterApi interpreter;
|
||||
private Context mContext;
|
||||
|
||||
@@ -134,6 +134,8 @@ public class SdServer extends Service implements SdDataReceiver {
|
||||
public boolean mLogData = false;
|
||||
public boolean mLogDataRemote = false;
|
||||
public boolean mLogDataRemoteMobile = false;
|
||||
public boolean mLogNDA = false;
|
||||
|
||||
private String mAuthToken = null;
|
||||
private long mEventsTimerPeriod = 60; // Number of seconds between checks to see if there are unvalidated remote events.
|
||||
private long mEventDuration = 120; // event duration in seconds - uploads datapoints that cover this time range centred on the event time.
|
||||
@@ -273,7 +275,7 @@ public class SdServer extends Service implements SdDataReceiver {
|
||||
|
||||
// Create our log manager.
|
||||
mLm = new LogManager(this, mLogDataRemote, mLogDataRemoteMobile, mAuthToken, mEventDuration,
|
||||
mRemoteLogPeriod, mAutoPruneDb, mDataRetentionPeriod);
|
||||
mRemoteLogPeriod, mLogNDA ,mAutoPruneDb, mDataRetentionPeriod, mSdData);
|
||||
|
||||
if (mSMSAlarm) {
|
||||
Log.v(TAG, "Creating LocationFinder");
|
||||
@@ -766,6 +768,7 @@ public class SdServer extends Service implements SdDataReceiver {
|
||||
|
||||
if (webServer != null) webServer.setSdData(mSdData);
|
||||
Log.v(TAG, "onSdDataReceived() - setting mSdData to " + mSdData.toString());
|
||||
mLm.updateSdData(mSdData);
|
||||
|
||||
logData();
|
||||
}
|
||||
@@ -1229,6 +1232,8 @@ public class SdServer extends Service implements SdDataReceiver {
|
||||
mUtil.writeToSysLogFile("updatePrefs() - mLogDataRemote = " + mLogDataRemote);
|
||||
mLogDataRemoteMobile = SP.getBoolean("LogDataRemoteMobile", false);
|
||||
Log.v(TAG, "updatePrefs() - mLogDataRemoteMobile = " + mLogDataRemoteMobile);
|
||||
mLogNDA = SP.getBoolean("LogNDA", false);
|
||||
Log.v(TAG, "updatePrefs() - mLogNDA = " + mLogNDA);
|
||||
mUtil.writeToSysLogFile("updatePrefs() - mLogDataRemoteMobile = " + mLogDataRemoteMobile);
|
||||
mAuthToken = SP.getString("webApiAuthToken", null);
|
||||
Log.v(TAG, "updatePrefs() - mAuthToken = " + mAuthToken);
|
||||
|
||||
@@ -423,4 +423,9 @@ public class WebApiConnection_firebase extends WebApiConnection {
|
||||
return mServerConnectionOk;
|
||||
}
|
||||
|
||||
public boolean getCnnModelInfo(JSONObjectCallback callback) {
|
||||
Log.w(TAG,"getCnnModelInfo() - FIXME - not implemented yet!");
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -713,4 +713,10 @@ public class WebApiConnection_osdapi extends WebApiConnection {
|
||||
|
||||
}
|
||||
|
||||
public boolean getCnnModelInfo(JSONObjectCallback callback) {
|
||||
Log.w(TAG,"getCnnModelInfo() - FIXME - not implemented yet!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -49,6 +49,25 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:text="000" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/NDATimeRemaining" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/nda_time_remaining_tv"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="000" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<RadioGroup xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -80,22 +99,23 @@
|
||||
</RadioGroup>
|
||||
|
||||
<LinearLayout
|
||||
android:visibility="visible"
|
||||
android:id="@+id/shared_data_ll"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
android:orientation="vertical"
|
||||
android:visibility="visible">
|
||||
|
||||
<TextView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/remote_database"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/check_seizures_message"
|
||||
/>
|
||||
android:text="@string/check_seizures_message" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -112,24 +132,36 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/authenticate" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/refresh_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/refreshBtn" />
|
||||
<ProgressBar
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/remoteAccessPb" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/remoteAccessPb"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/include_warnings_cb"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/include_warnings">
|
||||
</CheckBox>
|
||||
android:text="@string/include_warnings"></CheckBox>
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/include_nda_cb"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/include_nda"></CheckBox>
|
||||
</LinearLayout>
|
||||
|
||||
<ListView
|
||||
android:id="@+id/remoteEventsLv"
|
||||
@@ -141,11 +173,11 @@
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:visibility="gone"
|
||||
android:id="@+id/local_data_ll"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
|
||||
<TextView
|
||||
android:layout_width="fill_parent"
|
||||
@@ -161,11 +193,11 @@
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:visibility="gone"
|
||||
android:id="@+id/syslog_ll"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
|
||||
<TextView
|
||||
android:layout_width="fill_parent"
|
||||
|
||||
@@ -31,5 +31,12 @@
|
||||
app:showAsAction="never|withText"
|
||||
android:title="@string/data_sharing_log_in" />
|
||||
|
||||
<item
|
||||
android:id="@+id/start_stop_nda"
|
||||
android:enabled="true"
|
||||
android:icon="@drawable/ic_action_settings"
|
||||
app:showAsAction="never|withText"
|
||||
android:title="@string/start_nda" />
|
||||
|
||||
</group>
|
||||
</menu>
|
||||
|
||||
@@ -446,4 +446,17 @@
|
||||
<string name="mark_unverified_events_false_alarm_dialog_title">Mark all Unverified Events as False Alarm</string>
|
||||
<string name="mark_unverified_events_false_alarm_dialog_message">Please confirm that all genuine seizure events have been verified before marking all unverified events as type \'False Alarm\'. \n\nContinue to mark unverified events as False Alarm?</string>
|
||||
<string name="mark_unverified_events_as_false_alarm">Mark all Unverified Events as False Alarm</string>
|
||||
<string name="LogNDASummary">Continuously log data to the data sharing system to provide background \'normal daily activity\' data to help reduce false alarms.</string>
|
||||
<string name="LogNDATitle">Log Normal Daily Activities (NDA)</string>
|
||||
<string name="NDATimerStartTimeParseError">Error Parsing NDATimerStartTime</string>
|
||||
<string name="include_nda">Include NDA</string>
|
||||
<string name="start_nda">Start NDA Logging</string>
|
||||
<string name="stop_nda">Stop NDA Logging</string>
|
||||
<string name="stop_nda_logging_dialog_title">Stop NDA Logging?</string>
|
||||
<string name="stop_nda_logging_dialog_meassage">Stop Normal Daily Activity (NDA) Logging?</string>
|
||||
<string name="start_nda_logging_dialog_title">Start NDA Logging?</string>
|
||||
<string name="start_nda_logging_dialog_meassage">Start Normal Daily Activity (NDA) Logging (will stop automatically after 24 hours)?</string>
|
||||
<string name="NDATimeRemaining">"NDA Logging Time Remaining (hours): "</string>
|
||||
<string name="stop_nda_menu_title">Stop NDA</string>
|
||||
<string name="start_nda_menu_title">Start NDA</string>
|
||||
</resources>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
android:summary="@string/log_data_summary"
|
||||
android:title="@string/log_data_title" /> -->
|
||||
<EditTextPreference
|
||||
android:defaultValue="150"
|
||||
android:defaultValue="180"
|
||||
android:key="EventDurationSec"
|
||||
android:summary="@string/eventDurationSummary"
|
||||
android:title="@string/eventDurationTitle" />
|
||||
@@ -35,6 +35,11 @@
|
||||
android:key="LogDataRemoteMobile"
|
||||
android:summary="@string/log_data_remote_mobile_summary"
|
||||
android:title="@string/log_data_remote_mobile_title" />
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="LogNDA"
|
||||
android:summary="@string/LogNDASummary"
|
||||
android:title="@string/LogNDATitle" />
|
||||
<!--<EditTextPreference
|
||||
android:defaultValue="60"
|
||||
android:key="RemoteLogPeriod"
|
||||
|
||||
BIN
doc/Installation_Instructions_1A.pptx
Normal file
BIN
doc/Installation_Instructions_1A.pptx
Normal file
Binary file not shown.
BIN
doc/Installation_Instructions_1B.pptx
Normal file
BIN
doc/Installation_Instructions_1B.pptx
Normal file
Binary file not shown.
BIN
doc/Sampling_System_Design.docx
Normal file
BIN
doc/Sampling_System_Design.docx
Normal file
Binary file not shown.
Reference in New Issue
Block a user