Merge branch 'dev' into smb

This commit is contained in:
Milos Kozak 2017-12-05 07:34:48 +01:00
commit 202d260ad2

View file

@ -29,6 +29,7 @@ public class QueueThread extends Thread {
CommandQueue queue; CommandQueue queue;
private long connectionStartTime = 0; private long connectionStartTime = 0;
private boolean connectLogged = false;
private PowerManager.WakeLock mWakeLock; private PowerManager.WakeLock mWakeLock;
@ -49,19 +50,18 @@ public class QueueThread extends Thread {
try { try {
while (true) { while (true) {
PumpInterface pump = ConfigBuilderPlugin.getActivePump(); PumpInterface pump = ConfigBuilderPlugin.getActivePump();
log.debug("Looping ...");
long secondsElapsed = (System.currentTimeMillis() - connectionStartTime) / 1000; long secondsElapsed = (System.currentTimeMillis() - connectionStartTime) / 1000;
if (pump.isConnecting()) { if (pump.isConnecting()) {
log.debug("State: connecting"); log.debug("QUEUE: connecting " + secondsElapsed);
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTING, (int) secondsElapsed)); MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTING, (int) secondsElapsed));
SystemClock.sleep(1000); SystemClock.sleep(1000);
continue; continue;
} }
if (!pump.isConnected() && secondsElapsed > Constants.PUMP_MAX_CONNECTION_TIME_IN_SECONDS) { if (!pump.isConnected() && secondsElapsed > Constants.PUMP_MAX_CONNECTION_TIME_IN_SECONDS) {
log.debug("State: timed out");
MainApp.bus().post(new EventDismissBolusprogressIfRunning(new PumpEnactResult())); MainApp.bus().post(new EventDismissBolusprogressIfRunning(new PumpEnactResult()));
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.connectiontimedout))); MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.connectiontimedout)));
log.debug("QUEUE: timed out");
pump.stopConnecting(); pump.stopConnecting();
//BLUETOOTH-WATCHDOG //BLUETOOTH-WATCHDOG
@ -87,7 +87,7 @@ public class QueueThread extends Thread {
} }
if (!pump.isConnected()) { if (!pump.isConnected()) {
log.debug("State: connect"); log.debug("QUEUE: connect");
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTING, (int) secondsElapsed)); MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTING, (int) secondsElapsed));
pump.connect("Connection needed"); pump.connect("Connection needed");
SystemClock.sleep(1000); SystemClock.sleep(1000);
@ -95,10 +95,14 @@ public class QueueThread extends Thread {
} }
if (queue.performing() == null) { if (queue.performing() == null) {
if (!connectLogged) {
connectLogged = true;
log.debug("QUEUE: connection time " + secondsElapsed + "s");
}
// Pickup 1st command and set performing variable // Pickup 1st command and set performing variable
if (queue.size() > 0) { if (queue.size() > 0) {
queue.pickup(); queue.pickup();
log.debug("State: performing " + queue.performing().status()); log.debug("QUEUE: performing " + queue.performing().status());
MainApp.bus().post(new EventQueueChanged()); MainApp.bus().post(new EventQueueChanged());
queue.performing().execute(); queue.performing().execute();
queue.resetPerforming(); queue.resetPerforming();
@ -109,7 +113,7 @@ public class QueueThread extends Thread {
} }
if (queue.size() == 0 && queue.performing() == null) { if (queue.size() == 0 && queue.performing() == null) {
log.debug("State: queue empty. disconnect"); log.debug("QUEUE: queue empty. disconnect");
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING)); MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
pump.disconnect("Queue empty"); pump.disconnect("Queue empty");
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTED)); MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTED));