Enforce low-suspend loop mode rather than disabling loop on usage violation. Because.

This commit is contained in:
Johannes Mockenhaupt 2017-12-03 21:22:22 +01:00
parent 1e19f19cd2
commit 1b91684c65
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
2 changed files with 7 additions and 8 deletions

View file

@ -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;
}
}

View file

@ -789,7 +789,7 @@
<string name="combo_pump_bolus_verification_failed">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.</string>
<string name="combo_pump_unsupported_operation">Requested operation not supported by pump</string>
<string name="combo_bolus_bolus_delivery_failed">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.</string>
<string name="combo_force_disabled_notification">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.</string>
<string name="combo_force_disabled_notification">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.</string>
<string name="combo_notification_check_time_date">Check pump time and date</string>
<string name="bolus_frequency_exceeded">A bolus with the same amount was requested within the last minute. For safety reasons this is disallowed.</string>
<string name="combo_pump_connected_now">Now</string>