Don't ignore user requests to update pump data, tweak alerter.
This commit is contained in:
parent
338d29630c
commit
29e7ea1966
1 changed files with 8 additions and 8 deletions
|
@ -137,9 +137,9 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
while (true) {
|
while (true) {
|
||||||
String errorMsg = pumpState.errorMsg;
|
String errorMsg = pumpState.errorMsg;
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
long sixMinutesSinceLastAlarm = lastAlarmTime + (5 * 60 * 1000) + (15 * 1000);
|
long fiveMinutesSinceLastAlarm = lastAlarmTime + (5 * 60 * 1000) + (15 * 1000);
|
||||||
if (errorMsg != null)
|
if (errorMsg != null)
|
||||||
if (now > sixMinutesSinceLastAlarm) {
|
if (now > fiveMinutesSinceLastAlarm) {
|
||||||
log.warn("Pump is in error state, raising alert: " + errorMsg);
|
log.warn("Pump is in error state, raising alert: " + errorMsg);
|
||||||
log.warn(" LastCmd: " + lastCmd);
|
log.warn(" LastCmd: " + lastCmd);
|
||||||
log.warn(" LastCmdTime: " + lastCmdTime);
|
log.warn(" LastCmdTime: " + lastCmdTime);
|
||||||
|
@ -150,9 +150,7 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
.setSmallIcon(R.drawable.notif_icon)
|
.setSmallIcon(R.drawable.notif_icon)
|
||||||
.setSmallIcon(R.drawable.icon_bolus)
|
.setSmallIcon(R.drawable.icon_bolus)
|
||||||
.setContentTitle("Combo communication error")
|
.setContentTitle("Combo communication error")
|
||||||
.setContentText("Error: " + errorMsg +
|
.setContentText(errorMsg)
|
||||||
"\nCommand: " + lastCmd +
|
|
||||||
"\nTime: " + lastCmdTime)
|
|
||||||
.setPriority(NotificationCompat.PRIORITY_MAX)
|
.setPriority(NotificationCompat.PRIORITY_MAX)
|
||||||
.setLights(Color.BLUE, 1000, 0)
|
.setLights(Color.BLUE, 1000, 0)
|
||||||
.setSound(uri)
|
.setSound(uri)
|
||||||
|
@ -164,7 +162,7 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
} else {
|
} else {
|
||||||
log.debug("Pump state normal");
|
log.debug("Pump state normal");
|
||||||
}
|
}
|
||||||
SystemClock.sleep(60 * 1000);
|
SystemClock.sleep(5 * 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, "combo-alerter").start();
|
}, "combo-alerter").start();
|
||||||
|
@ -296,7 +294,9 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
public void refreshDataFromPump(String reason) {
|
public void refreshDataFromPump(String reason) {
|
||||||
log.debug("RefreshDataFromPump called");
|
log.debug("RefreshDataFromPump called");
|
||||||
|
|
||||||
if (lastCmdTime.getTime() > 0 && System.currentTimeMillis() > lastCmdTime.getTime() + 60 * 1000) {
|
if (!reason.toLowerCase().contains("user")
|
||||||
|
&& lastCmdTime.getTime() > 0
|
||||||
|
&& System.currentTimeMillis() > lastCmdTime.getTime() + 60 * 1000) {
|
||||||
log.debug("Not fetching state from pump, since we did already within the last 60 seconds");
|
log.debug("Not fetching state from pump, since we did already within the last 60 seconds");
|
||||||
} else {
|
} else {
|
||||||
runCommand(new ReadPumpStateCommand());
|
runCommand(new ReadPumpStateCommand());
|
||||||
|
@ -359,7 +359,7 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
private CommandResult runCommand(Command command) {
|
private CommandResult runCommand(Command command) {
|
||||||
statusSummary = "Busy running command: " + command;
|
statusSummary = "Executing " + command;
|
||||||
MainApp.bus().post(new EventComboPumpUpdateGUI());
|
MainApp.bus().post(new EventComboPumpUpdateGUI());
|
||||||
|
|
||||||
CommandResult commandResult = ruffyScripter.runCommand(command);
|
CommandResult commandResult = ruffyScripter.runCommand(command);
|
||||||
|
|
Loading…
Reference in a new issue