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
|
||||
stateView.setText(plugin.getStateSummary());
|
||||
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);
|
||||
} else if (plugin.getPump().state.suspended) {
|
||||
} else if (plugin.getPump().state.suspended
|
||||
|| ps.activeAlert != null && ps.activeAlert.warningCode != null) {
|
||||
stateView.setTextColor(Color.YELLOW);
|
||||
} else {
|
||||
stateView.setTextColor(Color.WHITE);
|
||||
|
|
|
@ -141,7 +141,11 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
|||
|
||||
String getStateSummary() {
|
||||
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);
|
||||
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);
|
||||
|
@ -642,6 +646,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
|||
if (!ruffyScripter.isConnected()) {
|
||||
CommandResult preCheckError = runOnConnectChecks();
|
||||
if (preCheckError != null) {
|
||||
updateLocalData(preCheckError);
|
||||
return preCheckError;
|
||||
}
|
||||
}
|
||||
|
@ -656,7 +661,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
|||
}
|
||||
|
||||
for (Integer forwardedWarning : commandResult.forwardedWarnings) {
|
||||
notifyAboutPumpWarning(new WarningOrErrorCode(forwardedWarning, null));
|
||||
notifyAboutPumpWarning(new WarningOrErrorCode(forwardedWarning, null, null));
|
||||
}
|
||||
|
||||
if (commandResult.success) {
|
||||
|
|
|
@ -7,13 +7,16 @@ public class WarningOrErrorCode {
|
|||
public final Integer warningCode;
|
||||
@Nullable
|
||||
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) {
|
||||
throw new IllegalArgumentException("Either code must be non-null");
|
||||
}
|
||||
this.warningCode = warningCode;
|
||||
this.errorCode = errorCode;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -21,6 +24,7 @@ public class WarningOrErrorCode {
|
|||
return "WarningOrErrorCode{" +
|
||||
"warningCode=" + warningCode +
|
||||
", errorCode=" + errorCode +
|
||||
", message=" + message +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -254,6 +254,7 @@ public class RuffyScripter implements RuffyCommands {
|
|||
// check pump in a suitable state to run the requested command
|
||||
if (cmd instanceof ReadPumpStateCommand) {
|
||||
// always allowed, state is set at the end of runCommand method
|
||||
activeCmd.getResult().success = true;
|
||||
} else if (getCurrentMenu().getType() == MenuType.STOP && cmd.needsRunMode()) {
|
||||
log.error("Requested command requires run mode, but pump is suspended");
|
||||
activeCmd.getResult().success = false;
|
||||
|
@ -508,8 +509,9 @@ public class RuffyScripter implements RuffyCommands {
|
|||
errorCode = (Integer) getCurrentMenu().getAttribute(MenuAttribute.ERROR);
|
||||
retries--;
|
||||
}
|
||||
String message = (String) getCurrentMenu().getAttribute(MenuAttribute.MESSAGE);
|
||||
return (warningCode != null || errorCode != null)
|
||||
? new WarningOrErrorCode(warningCode, errorCode) : null;
|
||||
? new WarningOrErrorCode(warningCode, errorCode, message) : null;
|
||||
}
|
||||
|
||||
public static class Key {
|
||||
|
|
Loading…
Reference in a new issue