ComboPlugin.runCommand: wait if pump is busy with a command.
This commit is contained in:
parent
d8011aeaa4
commit
77711b2174
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue