Handle the pump being stopped: don't treat it like an error, but don't execute commands either.
This commit is contained in:
parent
222ad0a527
commit
36966c8907
3 changed files with 17 additions and 2 deletions
|
@ -12,6 +12,7 @@ public class PumpState {
|
|||
public double tbrRate = -1;
|
||||
public int tbrRemainingDuration = -1;
|
||||
public String errorMsg;
|
||||
public boolean suspended;
|
||||
|
||||
public PumpState tbrActive(boolean tbrActive) {
|
||||
this.tbrActive = tbrActive;
|
||||
|
@ -38,6 +39,11 @@ public class PumpState {
|
|||
return this;
|
||||
}
|
||||
|
||||
public PumpState suspended(boolean suspended) {
|
||||
this.suspended = suspended;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PumpState{" +
|
||||
|
@ -46,6 +52,7 @@ public class PumpState {
|
|||
", tbrRate=" + tbrRate +
|
||||
", tbrRemainingDuration=" + tbrRemainingDuration +
|
||||
", errorMsg=" + errorMsg +
|
||||
", suspended=" + suspended +
|
||||
", timestamp=" + timestamp +
|
||||
'}';
|
||||
}
|
||||
|
|
|
@ -195,6 +195,11 @@ public class RuffyScripter {
|
|||
return;
|
||||
}
|
||||
}
|
||||
// don't execute anything if STOP menu is shown (pump is noisy already and user is probably changing the cartridge)
|
||||
if (currentMenu == null || currentMenu.getType() == MenuType.STOP) {
|
||||
returnable.cmdResult = new CommandResult().success(true).enacted(false);
|
||||
return;
|
||||
}
|
||||
log.debug("Cmd execution: connection ready, executing cmd " + cmd);
|
||||
returnable.cmdResult = cmd.execute(scripter);
|
||||
} catch (CommandException e) {
|
||||
|
@ -401,6 +406,8 @@ public class RuffyScripter {
|
|||
}
|
||||
} else if (menuType == MenuType.WARNING_OR_ERROR) {
|
||||
state.errorMsg = (String) menu.getAttribute(MenuAttribute.MESSAGE);
|
||||
} else if (menuType == MenuType.STOP) {
|
||||
state.suspended = true;
|
||||
} else {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (MenuAttribute menuAttribute : menu.attributes()) {
|
||||
|
|
|
@ -129,7 +129,8 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
|||
int id = 1000;
|
||||
long lastAlarmTime = 0;
|
||||
while (true) {
|
||||
String errorMsg = pumpState.errorMsg;
|
||||
PumpState ps = ComboPlugin.this.pumpState;
|
||||
String errorMsg = ps.errorMsg;
|
||||
if (errorMsg != null) {
|
||||
long now = System.currentTimeMillis();
|
||||
long fiveMinutesSinceLastAlarm = lastAlarmTime + (5 * 60 * 1000) + (15 * 1000);
|
||||
|
@ -155,7 +156,7 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
|||
log.warn("Pump still in error state, but alarm raised recently, so not triggering again: " + errorMsg);
|
||||
}
|
||||
} else {
|
||||
log.trace("Pump state normal");
|
||||
log.trace("Pump state: " + (ps.suspended ? "suspended" : "normal"));
|
||||
}
|
||||
SystemClock.sleep(5 * 1000);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue