Display active alert in Combo tab.
This commit is contained in:
parent
3070cba612
commit
dafb6d225b
|
@ -96,9 +96,11 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
|
||||||
// state
|
// state
|
||||||
stateView.setText(plugin.getStateSummary());
|
stateView.setText(plugin.getStateSummary());
|
||||||
PumpState ps = plugin.getPump().state;
|
PumpState ps = plugin.getPump().state;
|
||||||
if (ps.insulinState == PumpState.EMPTY || ps.batteryState == PumpState.EMPTY) {
|
if (ps.insulinState == PumpState.EMPTY || ps.batteryState == PumpState.EMPTY
|
||||||
|
|| ps.activeAlert != null && ps.activeAlert.errorCode != null) {
|
||||||
stateView.setTextColor(Color.RED);
|
stateView.setTextColor(Color.RED);
|
||||||
} else if (plugin.getPump().state.suspended) {
|
} else if (plugin.getPump().state.suspended
|
||||||
|
|| ps.activeAlert != null && ps.activeAlert.warningCode != null) {
|
||||||
stateView.setTextColor(Color.YELLOW);
|
stateView.setTextColor(Color.YELLOW);
|
||||||
} else {
|
} else {
|
||||||
stateView.setTextColor(Color.WHITE);
|
stateView.setTextColor(Color.WHITE);
|
||||||
|
|
|
@ -141,7 +141,11 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
|
|
||||||
String getStateSummary() {
|
String getStateSummary() {
|
||||||
PumpState ps = pump.state;
|
PumpState ps = pump.state;
|
||||||
if (ps.menu == null)
|
if (ps.activeAlert != null) {
|
||||||
|
return ps.activeAlert.errorCode != null
|
||||||
|
? "E" + ps.activeAlert.errorCode + ": " + ps.activeAlert.message
|
||||||
|
: "W" + ps.activeAlert.warningCode + ": " + ps.activeAlert.message;
|
||||||
|
} else if (ps.menu == null)
|
||||||
return MainApp.sResources.getString(R.string.combo_pump_state_disconnected);
|
return MainApp.sResources.getString(R.string.combo_pump_state_disconnected);
|
||||||
else if (ps.suspended && (ps.batteryState == PumpState.EMPTY || ps.insulinState == PumpState.EMPTY))
|
else if (ps.suspended && (ps.batteryState == PumpState.EMPTY || ps.insulinState == PumpState.EMPTY))
|
||||||
return MainApp.sResources.getString(R.string.combo_pump_state_suspended_due_to_error);
|
return MainApp.sResources.getString(R.string.combo_pump_state_suspended_due_to_error);
|
||||||
|
@ -642,6 +646,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
if (!ruffyScripter.isConnected()) {
|
if (!ruffyScripter.isConnected()) {
|
||||||
CommandResult preCheckError = runOnConnectChecks();
|
CommandResult preCheckError = runOnConnectChecks();
|
||||||
if (preCheckError != null) {
|
if (preCheckError != null) {
|
||||||
|
updateLocalData(preCheckError);
|
||||||
return preCheckError;
|
return preCheckError;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -656,7 +661,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Integer forwardedWarning : commandResult.forwardedWarnings) {
|
for (Integer forwardedWarning : commandResult.forwardedWarnings) {
|
||||||
notifyAboutPumpWarning(new WarningOrErrorCode(forwardedWarning, null));
|
notifyAboutPumpWarning(new WarningOrErrorCode(forwardedWarning, null, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (commandResult.success) {
|
if (commandResult.success) {
|
||||||
|
|
|
@ -7,13 +7,16 @@ public class WarningOrErrorCode {
|
||||||
public final Integer warningCode;
|
public final Integer warningCode;
|
||||||
@Nullable
|
@Nullable
|
||||||
public final Integer errorCode;
|
public final Integer errorCode;
|
||||||
|
@Nullable
|
||||||
|
public String message;
|
||||||
|
|
||||||
public WarningOrErrorCode(@Nullable Integer warningCode, @Nullable Integer errorCode) {
|
public WarningOrErrorCode(@Nullable Integer warningCode, @Nullable Integer errorCode, @Nullable String message) {
|
||||||
if (warningCode == null && errorCode == null) {
|
if (warningCode == null && errorCode == null) {
|
||||||
throw new IllegalArgumentException("Either code must be non-null");
|
throw new IllegalArgumentException("Either code must be non-null");
|
||||||
}
|
}
|
||||||
this.warningCode = warningCode;
|
this.warningCode = warningCode;
|
||||||
this.errorCode = errorCode;
|
this.errorCode = errorCode;
|
||||||
|
this.message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -21,6 +24,7 @@ public class WarningOrErrorCode {
|
||||||
return "WarningOrErrorCode{" +
|
return "WarningOrErrorCode{" +
|
||||||
"warningCode=" + warningCode +
|
"warningCode=" + warningCode +
|
||||||
", errorCode=" + errorCode +
|
", errorCode=" + errorCode +
|
||||||
|
", message=" + message +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -254,6 +254,7 @@ public class RuffyScripter implements RuffyCommands {
|
||||||
// check pump in a suitable state to run the requested command
|
// check pump in a suitable state to run the requested command
|
||||||
if (cmd instanceof ReadPumpStateCommand) {
|
if (cmd instanceof ReadPumpStateCommand) {
|
||||||
// always allowed, state is set at the end of runCommand method
|
// always allowed, state is set at the end of runCommand method
|
||||||
|
activeCmd.getResult().success = true;
|
||||||
} else if (getCurrentMenu().getType() == MenuType.STOP && cmd.needsRunMode()) {
|
} else if (getCurrentMenu().getType() == MenuType.STOP && cmd.needsRunMode()) {
|
||||||
log.error("Requested command requires run mode, but pump is suspended");
|
log.error("Requested command requires run mode, but pump is suspended");
|
||||||
activeCmd.getResult().success = false;
|
activeCmd.getResult().success = false;
|
||||||
|
@ -508,8 +509,9 @@ public class RuffyScripter implements RuffyCommands {
|
||||||
errorCode = (Integer) getCurrentMenu().getAttribute(MenuAttribute.ERROR);
|
errorCode = (Integer) getCurrentMenu().getAttribute(MenuAttribute.ERROR);
|
||||||
retries--;
|
retries--;
|
||||||
}
|
}
|
||||||
|
String message = (String) getCurrentMenu().getAttribute(MenuAttribute.MESSAGE);
|
||||||
return (warningCode != null || errorCode != null)
|
return (warningCode != null || errorCode != null)
|
||||||
? new WarningOrErrorCode(warningCode, errorCode) : null;
|
? new WarningOrErrorCode(warningCode, errorCode, message) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Key {
|
public static class Key {
|
||||||
|
|
Loading…
Reference in a new issue