Fixes around bolus cancellation.
This commit is contained in:
parent
fe281b9224
commit
ca9fe3e755
6 changed files with 25 additions and 35 deletions
|
@ -481,12 +481,10 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
.success(bolusCmdResult.success)
|
.success(bolusCmdResult.success)
|
||||||
.enacted(bolusCmdResult.delivered > 0)
|
.enacted(bolusCmdResult.delivered > 0)
|
||||||
.bolusDelivered(bolusCmdResult.delivered)
|
.bolusDelivered(bolusCmdResult.delivered)
|
||||||
.carbsDelivered(detailedBolusInfo.carbs);
|
.carbsDelivered(detailedBolusInfo.carbs)
|
||||||
|
.comment(bolusCmdResult.success ? "" :
|
||||||
|
MainApp.sResources.getString(R.string.combo_bolus_bolus_delivery_failed));
|
||||||
} finally {
|
} 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;
|
pump.activity = null;
|
||||||
MainApp.bus().post(new EventComboPumpUpdateGUI());
|
MainApp.bus().post(new EventComboPumpUpdateGUI());
|
||||||
MainApp.bus().post(new EventRefreshOverview("Combo Bolus"));
|
MainApp.bus().post(new EventRefreshOverview("Combo Bolus"));
|
||||||
|
@ -691,7 +689,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
// turn benign warnings into notifications
|
// turn benign warnings into notifications
|
||||||
notifyAboutPumpWarning(activeAlert);
|
notifyAboutPumpWarning(activeAlert);
|
||||||
ruffyScripter.confirmAlert(activeAlert.warningCode);
|
ruffyScripter.confirmAlert(activeAlert.warningCode);
|
||||||
} else {
|
} else if (activeAlert.errorCode != null){
|
||||||
Notification notification = new Notification();
|
Notification notification = new Notification();
|
||||||
notification.date = new Date();
|
notification.date = new Date();
|
||||||
notification.id = Notification.COMBO_PUMP_ALARM;
|
notification.id = Notification.COMBO_PUMP_ALARM;
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
android:id="@+id/overview_error_status"
|
android:id="@+id/overview_error_status"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="15dp"
|
||||||
android:layout_gravity="center_horizontal" />
|
android:layout_gravity="center_horizontal" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
|
@ -18,7 +19,7 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_horizontal"
|
android:layout_gravity="center_horizontal"
|
||||||
android:layout_marginTop="30dp"
|
android:layout_marginTop="15dp"
|
||||||
android:text="@string/ok" />
|
android:text="@string/ok" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -11,9 +11,6 @@ public class WarningOrErrorCode {
|
||||||
public String message;
|
public String message;
|
||||||
|
|
||||||
public WarningOrErrorCode(@Nullable Integer warningCode, @Nullable Integer errorCode, @Nullable 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.warningCode = warningCode;
|
||||||
this.errorCode = errorCode;
|
this.errorCode = errorCode;
|
||||||
this.message = message;
|
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.
|
// 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
|
// If that happened, wait till the pump has finished the bolus, then it can be read from
|
||||||
// the history as delivered.
|
// the history as delivered.
|
||||||
Double bolusRemaining = (Double) getCurrentMenu().getAttribute(MenuAttribute.BOLUS_REMAINING);
|
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();
|
waitForScreenUpdate();
|
||||||
|
bolusRemaining = (Double) getCurrentMenu().getAttribute(MenuAttribute.BOLUS_REMAINING);
|
||||||
|
bolusType = (BolusType) getCurrentMenu().getAttribute(MenuAttribute.BOLUS_TYPE);
|
||||||
}
|
}
|
||||||
boolean connected = isConnected();
|
boolean connected = isConnected();
|
||||||
if (connected) {
|
if (connected) {
|
||||||
|
@ -534,13 +537,14 @@ public class RuffyScripter implements RuffyCommands {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Precondition: a warning/error must be displayed */
|
@NonNull
|
||||||
@Nullable
|
|
||||||
public WarningOrErrorCode readWarningOrErrorCode() {
|
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 warningCode = (Integer) getCurrentMenu().getAttribute(MenuAttribute.WARNING);
|
||||||
Integer errorCode = (Integer) getCurrentMenu().getAttribute(MenuAttribute.ERROR);
|
Integer errorCode = (Integer) getCurrentMenu().getAttribute(MenuAttribute.ERROR);
|
||||||
int retries = 3;
|
int retries = 5;
|
||||||
while (warningCode == null && errorCode == null && retries > 0) {
|
while (warningCode == null && errorCode == null && retries > 0) {
|
||||||
waitForScreenUpdate();
|
waitForScreenUpdate();
|
||||||
warningCode = (Integer) getCurrentMenu().getAttribute(MenuAttribute.WARNING);
|
warningCode = (Integer) getCurrentMenu().getAttribute(MenuAttribute.WARNING);
|
||||||
|
@ -548,8 +552,7 @@ public class RuffyScripter implements RuffyCommands {
|
||||||
retries--;
|
retries--;
|
||||||
}
|
}
|
||||||
String message = (String) getCurrentMenu().getAttribute(MenuAttribute.MESSAGE);
|
String message = (String) getCurrentMenu().getAttribute(MenuAttribute.MESSAGE);
|
||||||
return (warningCode != null || errorCode != null)
|
return new WarningOrErrorCode(warningCode, errorCode, message);
|
||||||
? new WarningOrErrorCode(warningCode, errorCode, message) : null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Key {
|
public static class Key {
|
||||||
|
@ -844,7 +847,7 @@ public class RuffyScripter implements RuffyCommands {
|
||||||
// wait till the pump has processed the alarm, otherwise it might still be showing
|
// wait till the pump has processed the alarm, otherwise it might still be showing
|
||||||
// when a command returns
|
// when a command returns
|
||||||
WarningOrErrorCode displayedWarning = readWarningOrErrorCode();
|
WarningOrErrorCode displayedWarning = readWarningOrErrorCode();
|
||||||
while (displayedWarning.warningCode != null && displayedWarning.warningCode.equals(warningCode)) {
|
while (Objects.equals(displayedWarning.warningCode, warningCode)) {
|
||||||
waitForScreenUpdate();
|
waitForScreenUpdate();
|
||||||
displayedWarning = readWarningOrErrorCode();
|
displayedWarning = readWarningOrErrorCode();
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,6 @@ public class BolusCommand extends BaseCommand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
try {
|
|
||||||
if (cancelRequested) {
|
if (cancelRequested) {
|
||||||
bolusProgressReporter.report(STOPPED, 0, 0);
|
bolusProgressReporter.report(STOPPED, 0, 0);
|
||||||
result.success = true;
|
result.success = true;
|
||||||
|
@ -120,14 +119,14 @@ public class BolusCommand extends BaseCommand {
|
||||||
if (warningOrErrorCode.errorCode != null) {
|
if (warningOrErrorCode.errorCode != null) {
|
||||||
throw new CommandException("Pump is in error state");
|
throw new CommandException("Pump is in error state");
|
||||||
}
|
}
|
||||||
int warningCode = warningOrErrorCode.warningCode;
|
Integer warningCode = warningOrErrorCode.warningCode;
|
||||||
if (warningCode == PumpWarningCodes.BOLUS_CANCELLED) {
|
if (Objects.equals(warningCode, PumpWarningCodes.BOLUS_CANCELLED)) {
|
||||||
scripter.confirmAlert(PumpWarningCodes.BOLUS_CANCELLED, 2000);
|
scripter.confirmAlert(PumpWarningCodes.BOLUS_CANCELLED, 2000);
|
||||||
bolusProgressReporter.report(STOPPED, 0, 0);
|
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);
|
scripter.confirmAlert(PumpWarningCodes.CARTRIDGE_LOW, 2000);
|
||||||
result.forwardedWarnings.add(PumpWarningCodes.CARTRIDGE_LOW);
|
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);
|
scripter.confirmAlert(PumpWarningCodes.BATTERY_LOW, 2000);
|
||||||
result.forwardedWarnings.add(PumpWarningCodes.BATTERY_LOW);
|
result.forwardedWarnings.add(PumpWarningCodes.BATTERY_LOW);
|
||||||
} else {
|
} else {
|
||||||
|
@ -183,14 +182,6 @@ public class BolusCommand extends BaseCommand {
|
||||||
|
|
||||||
bolusProgressReporter.report(DELIVERED, 100, bolus);
|
bolusProgressReporter.report(DELIVERED, 100, bolus);
|
||||||
result.success = true;
|
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() {
|
private void enterBolusMenu() {
|
||||||
|
|
|
@ -10,6 +10,7 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import de.jotomo.ruffy.spi.PumpWarningCodes;
|
import de.jotomo.ruffy.spi.PumpWarningCodes;
|
||||||
import de.jotomo.ruffy.spi.WarningOrErrorCode;
|
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
|
// 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.
|
// to main menu etc are performed, after which this command can simply be retried.
|
||||||
WarningOrErrorCode warningOrErrorCode = scripter.readWarningOrErrorCode();
|
WarningOrErrorCode warningOrErrorCode = scripter.readWarningOrErrorCode();
|
||||||
if (warningOrErrorCode.warningCode != null
|
if (Objects.equals(warningOrErrorCode.warningCode, PumpWarningCodes.TBR_CANCELLED)) {
|
||||||
&& warningOrErrorCode.warningCode == PumpWarningCodes.TBR_CANCELLED) {
|
|
||||||
scripter.confirmAlert(PumpWarningCodes.TBR_CANCELLED);
|
scripter.confirmAlert(PumpWarningCodes.TBR_CANCELLED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue