Reject requests to bolus the same amount within 60s.

This commit is contained in:
Johannes Mockenhaupt 2017-11-02 15:37:19 +01:00
parent fe3385cce8
commit 604a9e664a
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
2 changed files with 10 additions and 0 deletions

View file

@ -67,6 +67,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
private volatile boolean bolusInProgress;
private volatile boolean cancelBolus;
private Bolus lastRequestedBolus;
public static ComboPlugin getPlugin() {
if (plugin == null)
@ -368,6 +369,14 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
@NonNull
private PumpEnactResult deliverBolus(final DetailedBolusInfo detailedBolusInfo) {
if (lastRequestedBolus != null
&& Math.abs(lastRequestedBolus.amount - detailedBolusInfo.insulin) < 0.05
&& lastRequestedBolus.timestamp + 60 * 1000 > System.currentTimeMillis()) {
return new PumpEnactResult().success(false).enacted(false)
.comment(MainApp.sResources.getString(R.string.bolus_frequency_exceeded));
}
lastRequestedBolus = new Bolus(System.currentTimeMillis(), detailedBolusInfo.insulin, true);
try {
pump.activity = MainApp.sResources.getString(R.string.combo_pump_action_bolusing);
MainApp.bus().post(new EventComboPumpUpdateGUI());

View file

@ -799,5 +799,6 @@
<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">Unsafe usage: extended or multiwave boluses have been delivered within the last 6h. Closed loop mode forcefully disabled. Only normal boluses are supported when running in closed loop mode.</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>
</resources>