Merge remote-tracking branch 'origin/dev' into combo-scripter-v2
* origin/dev: wait a few sec before disconnection for another command
This commit is contained in:
commit
4094b0dd61
1 changed files with 14 additions and 6 deletions
|
@ -28,6 +28,7 @@ public class QueueThread extends Thread {
|
||||||
|
|
||||||
private CommandQueue queue;
|
private CommandQueue queue;
|
||||||
|
|
||||||
|
private long lastCommandTime = 0;
|
||||||
private boolean connectLogged = false;
|
private boolean connectLogged = false;
|
||||||
|
|
||||||
private PowerManager.WakeLock mWakeLock;
|
private PowerManager.WakeLock mWakeLock;
|
||||||
|
@ -44,7 +45,7 @@ public class QueueThread extends Thread {
|
||||||
public final void run() {
|
public final void run() {
|
||||||
mWakeLock.acquire();
|
mWakeLock.acquire();
|
||||||
MainApp.bus().post(new EventQueueChanged());
|
MainApp.bus().post(new EventQueueChanged());
|
||||||
long connectionStartTime = System.currentTimeMillis();
|
long connectionStartTime = lastCommandTime = System.currentTimeMillis();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@ -106,17 +107,24 @@ public class QueueThread extends Thread {
|
||||||
queue.performing().execute();
|
queue.performing().execute();
|
||||||
queue.resetPerforming();
|
queue.resetPerforming();
|
||||||
MainApp.bus().post(new EventQueueChanged());
|
MainApp.bus().post(new EventQueueChanged());
|
||||||
|
lastCommandTime = System.currentTimeMillis();
|
||||||
SystemClock.sleep(100);
|
SystemClock.sleep(100);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (queue.size() == 0 && queue.performing() == null) {
|
if (queue.size() == 0 && queue.performing() == null) {
|
||||||
|
long secondsFromLastCommand = (System.currentTimeMillis() - lastCommandTime) / 1000;
|
||||||
|
if (secondsFromLastCommand >= 5) {
|
||||||
log.debug("QUEUE: 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));
|
||||||
return;
|
return;
|
||||||
|
} else {
|
||||||
|
log.debug("QUEUE: waiting for disconnect");
|
||||||
|
SystemClock.sleep(1000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
|
Loading…
Reference in a new issue