From 1b91684c6574ae6e0e89ae6ff86010b803e90dae Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Sun, 3 Dec 2017 21:22:22 +0100 Subject: [PATCH] Enforce low-suspend loop mode rather than disabling loop on usage violation. Because. --- .../androidaps/plugins/PumpCombo/ComboPlugin.java | 13 ++++++------- app/src/main/res/values/strings.xml | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java index f1b226b4b3..9ff674923f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java @@ -9,7 +9,6 @@ import org.slf4j.LoggerFactory; import java.util.Calendar; import java.util.Date; -import java.util.List; import java.util.Objects; import de.jotomo.ruffy.spi.BasalProfile; @@ -835,14 +834,14 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf } } if (lastViolation > 0) { - closedLoopDisabledUntil = lastViolation + 6 * 60 * 60 * 1000; - if (closedLoopDisabledUntil > System.currentTimeMillis() && violationWarningRaisedFor != closedLoopDisabledUntil) { + lowSuspendOnlyLoopEnforcetTill = lastViolation + 6 * 60 * 60 * 1000; + if (lowSuspendOnlyLoopEnforcetTill > System.currentTimeMillis() && violationWarningRaisedFor != lowSuspendOnlyLoopEnforcetTill) { Notification n = new Notification(Notification.COMBO_PUMP_ALARM, MainApp.sResources.getString(R.string.combo_force_disabled_notification), Notification.URGENT); n.soundId = R.raw.alarm; MainApp.bus().post(new EventNewNotification(n)); - violationWarningRaisedFor = closedLoopDisabledUntil; + violationWarningRaisedFor = lowSuspendOnlyLoopEnforcetTill; } } } @@ -1131,12 +1130,12 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf } // Constraints interface - private long closedLoopDisabledUntil = 0; + private long lowSuspendOnlyLoopEnforcetTill = 0; private long violationWarningRaisedFor = 0; @Override public boolean isLoopEnabled() { - return closedLoopDisabledUntil < System.currentTimeMillis(); + return true; } @Override @@ -1176,6 +1175,6 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf @Override public Double applyMaxIOBConstraints(Double maxIob) { - return maxIob; + return lowSuspendOnlyLoopEnforcetTill < System.currentTimeMillis() ? maxIob : 0; } } \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8475f64a6a..ec52c305c4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -789,7 +789,7 @@ Bolus delivery verification failed. The pump history will be read again on the next loop run or when refreshing from the Combo page. Please check and bolus again if needed. Requested operation not supported by pump Bolus delivery failed. A (partial) bolus might have been delivered. Attempting to update history from pump. Please check the Combo page and bolus again as needed. - Unsafe usage: extended or multiwave boluses have been delivered within the last 6 hours or the selected basal rate is not 1. Loop mode has been disabled until 6 hours after the last unsupported bolus or basal rate profile. Only normal boluses are supported in loop mode with basal rate profile 1. + Unsafe usage: extended or multiwave boluses have been delivered within the last 6 hours or the selected basal rate is not 1. Loop mode has been set to low-suspend only until 6 hours after the last unsupported bolus or basal rate profile. Only normal boluses are supported in loop mode with basal rate profile 1. Check pump time and date A bolus with the same amount was requested within the last minute. For safety reasons this is disallowed. Now