Fixes around bolus cancellation.
This commit is contained in:
parent
fe281b9224
commit
ca9fe3e755
|
@ -481,12 +481,10 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
|||
.success(bolusCmdResult.success)
|
||||
.enacted(bolusCmdResult.delivered > 0)
|
||||
.bolusDelivered(bolusCmdResult.delivered)
|
||||
.carbsDelivered(detailedBolusInfo.carbs);
|
||||
.carbsDelivered(detailedBolusInfo.carbs)
|
||||
.comment(bolusCmdResult.success ? "" :
|
||||
MainApp.sResources.getString(R.string.combo_bolus_bolus_delivery_failed));
|
||||
} finally {
|
||||
// BolusCommand.execute() intentionally doesn't close the progress dialog (indirectly
|
||||
// by reporting 100% progress) if an error occurred so it stays open while the connection
|
||||
// was re-established if needed and/or this method did recovery
|
||||
bolusProgressReporter.report(FINISHED, 100, 0);
|
||||
pump.activity = null;
|
||||
MainApp.bus().post(new EventComboPumpUpdateGUI());
|
||||
MainApp.bus().post(new EventRefreshOverview("Combo Bolus"));
|
||||
|
@ -691,7 +689,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
|||
// turn benign warnings into notifications
|
||||
notifyAboutPumpWarning(activeAlert);
|
||||
ruffyScripter.confirmAlert(activeAlert.warningCode);
|
||||
} else {
|
||||
} else if (activeAlert.errorCode != null){
|
||||
Notification notification = new Notification();
|
||||
notification.date = new Date();
|
||||
notification.id = Notification.COMBO_PUMP_ALARM;
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
android:id="@+id/overview_error_status"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="15dp"
|
||||
android:layout_gravity="center_horizontal" />
|
||||
|
||||
<Button
|
||||
|
@ -18,7 +19,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="30dp"
|
||||
android:layout_marginTop="15dp"
|
||||
android:text="@string/ok" />
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -11,9 +11,6 @@ public class WarningOrErrorCode {
|
|||
public String message;
|
||||
|
||||
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;
|
||||
|
|
|
@ -405,13 +405,16 @@ public class RuffyScripter implements RuffyCommands {
|
|||
}
|
||||
}
|
||||
|
||||
// A bolus cancelled is raised BEFORE a bolus is started. If a disconnect occurs after a
|
||||
// A BOLUS CANCELLED alert is raised BEFORE a bolus is started. If a disconnect occurs after a
|
||||
// bolus has started (or the user interacts with the pump) the bolus continues.
|
||||
// If that happened, wait till the pump has finished the bolus, then it can be read from
|
||||
// the history as delivered.
|
||||
Double bolusRemaining = (Double) getCurrentMenu().getAttribute(MenuAttribute.BOLUS_REMAINING);
|
||||
while (isConnected() && bolusRemaining != null) {
|
||||
BolusType bolusType = (BolusType) getCurrentMenu().getAttribute(MenuAttribute.BOLUS_TYPE);
|
||||
while (isConnected() && bolusRemaining != null && bolusType == BolusType.NORMAL) {
|
||||
waitForScreenUpdate();
|
||||
bolusRemaining = (Double) getCurrentMenu().getAttribute(MenuAttribute.BOLUS_REMAINING);
|
||||
bolusType = (BolusType) getCurrentMenu().getAttribute(MenuAttribute.BOLUS_TYPE);
|
||||
}
|
||||
boolean connected = isConnected();
|
||||
if (connected) {
|
||||
|
@ -534,13 +537,14 @@ public class RuffyScripter implements RuffyCommands {
|
|||
return state;
|
||||
}
|
||||
|
||||
/** Precondition: a warning/error must be displayed */
|
||||
@Nullable
|
||||
@NonNull
|
||||
public WarningOrErrorCode readWarningOrErrorCode() {
|
||||
verifyMenuIsDisplayed(MenuType.WARNING_OR_ERROR);
|
||||
if (currentMenu == null || getCurrentMenu().getType() != MenuType.WARNING_OR_ERROR) {
|
||||
return new WarningOrErrorCode(null, null, null);
|
||||
}
|
||||
Integer warningCode = (Integer) getCurrentMenu().getAttribute(MenuAttribute.WARNING);
|
||||
Integer errorCode = (Integer) getCurrentMenu().getAttribute(MenuAttribute.ERROR);
|
||||
int retries = 3;
|
||||
int retries = 5;
|
||||
while (warningCode == null && errorCode == null && retries > 0) {
|
||||
waitForScreenUpdate();
|
||||
warningCode = (Integer) getCurrentMenu().getAttribute(MenuAttribute.WARNING);
|
||||
|
@ -548,8 +552,7 @@ public class RuffyScripter implements RuffyCommands {
|
|||
retries--;
|
||||
}
|
||||
String message = (String) getCurrentMenu().getAttribute(MenuAttribute.MESSAGE);
|
||||
return (warningCode != null || errorCode != null)
|
||||
? new WarningOrErrorCode(warningCode, errorCode, message) : null;
|
||||
return new WarningOrErrorCode(warningCode, errorCode, message);
|
||||
}
|
||||
|
||||
public static class Key {
|
||||
|
@ -844,9 +847,9 @@ public class RuffyScripter implements RuffyCommands {
|
|||
// wait till the pump has processed the alarm, otherwise it might still be showing
|
||||
// when a command returns
|
||||
WarningOrErrorCode displayedWarning = readWarningOrErrorCode();
|
||||
while (displayedWarning.warningCode != null && displayedWarning.warningCode.equals(warningCode)) {
|
||||
while (Objects.equals(displayedWarning.warningCode, warningCode)) {
|
||||
waitForScreenUpdate();
|
||||
displayedWarning = readWarningOrErrorCode();
|
||||
displayedWarning = readWarningOrErrorCode();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -54,7 +54,6 @@ public class BolusCommand extends BaseCommand {
|
|||
|
||||
@Override
|
||||
public void execute() {
|
||||
try {
|
||||
if (cancelRequested) {
|
||||
bolusProgressReporter.report(STOPPED, 0, 0);
|
||||
result.success = true;
|
||||
|
@ -120,14 +119,14 @@ public class BolusCommand extends BaseCommand {
|
|||
if (warningOrErrorCode.errorCode != null) {
|
||||
throw new CommandException("Pump is in error state");
|
||||
}
|
||||
int warningCode = warningOrErrorCode.warningCode;
|
||||
if (warningCode == PumpWarningCodes.BOLUS_CANCELLED) {
|
||||
Integer warningCode = warningOrErrorCode.warningCode;
|
||||
if (Objects.equals(warningCode, PumpWarningCodes.BOLUS_CANCELLED)) {
|
||||
scripter.confirmAlert(PumpWarningCodes.BOLUS_CANCELLED, 2000);
|
||||
bolusProgressReporter.report(STOPPED, 0, 0);
|
||||
} else if (warningCode == PumpWarningCodes.CARTRIDGE_LOW) {
|
||||
} else if (Objects.equals(warningCode, PumpWarningCodes.CARTRIDGE_LOW)) {
|
||||
scripter.confirmAlert(PumpWarningCodes.CARTRIDGE_LOW, 2000);
|
||||
result.forwardedWarnings.add(PumpWarningCodes.CARTRIDGE_LOW);
|
||||
} else if (warningCode == PumpWarningCodes.BATTERY_LOW) {
|
||||
} else if (Objects.equals(warningCode, PumpWarningCodes.BATTERY_LOW)) {
|
||||
scripter.confirmAlert(PumpWarningCodes.BATTERY_LOW, 2000);
|
||||
result.forwardedWarnings.add(PumpWarningCodes.BATTERY_LOW);
|
||||
} else {
|
||||
|
@ -183,14 +182,6 @@ public class BolusCommand extends BaseCommand {
|
|||
|
||||
bolusProgressReporter.report(DELIVERED, 100, bolus);
|
||||
result.success = true;
|
||||
} finally {
|
||||
// this is a bit messy: when there's an issue (e.g. disconnected) the dialog should
|
||||
// stay open, since we're recovering. So leave it open and make sure in ComboPlugin.deliverBolus
|
||||
// the dialog is closed at the end.
|
||||
if (result.success) {
|
||||
bolusProgressReporter.report(FINISHED, 100, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void enterBolusMenu() {
|
||||
|
|
|
@ -10,6 +10,7 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import de.jotomo.ruffy.spi.PumpWarningCodes;
|
||||
import de.jotomo.ruffy.spi.WarningOrErrorCode;
|
||||
|
@ -89,8 +90,7 @@ public class SetTbrCommand extends BaseCommand {
|
|||
// we caused it (in a way), but still fail the command so the usual cleanups of returning
|
||||
// to main menu etc are performed, after which this command can simply be retried.
|
||||
WarningOrErrorCode warningOrErrorCode = scripter.readWarningOrErrorCode();
|
||||
if (warningOrErrorCode.warningCode != null
|
||||
&& warningOrErrorCode.warningCode == PumpWarningCodes.TBR_CANCELLED) {
|
||||
if (Objects.equals(warningOrErrorCode.warningCode, PumpWarningCodes.TBR_CANCELLED)) {
|
||||
scripter.confirmAlert(PumpWarningCodes.TBR_CANCELLED);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue