ComboPlugin.runCommand: wait if pump is busy with a command.

This commit is contained in:
Johannes Mockenhaupt 2017-07-15 15:00:27 +02:00
parent d8011aeaa4
commit 77711b2174
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1

View file

@ -319,6 +319,13 @@ public class ComboPlugin implements PluginBase, PumpInterface {
private CommandResult runCommand(Command command, boolean keepConnectionOpen) {
// TODO use this to dispatch methods to a service thread, like DanaRs executionService
try {
long timeout = System.currentTimeMillis() + 10 * 1000;
while (ruffyScripter.isPumpBusy()) {
if (System.currentTimeMillis() < timeout) {
return new CommandResult().success(false).enacted(false).message("Timeout waiting for the pump to be ready");
}
SystemClock.sleep(200);
}
return ruffyScripter.runCommand(command);
} finally {
lastCmdTime = new Date();