Reject requests to bolus the same amount within 60s.
This commit is contained in:
parent
fe3385cce8
commit
604a9e664a
2 changed files with 10 additions and 0 deletions
|
@ -67,6 +67,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
|
|
||||||
private volatile boolean bolusInProgress;
|
private volatile boolean bolusInProgress;
|
||||||
private volatile boolean cancelBolus;
|
private volatile boolean cancelBolus;
|
||||||
|
private Bolus lastRequestedBolus;
|
||||||
|
|
||||||
public static ComboPlugin getPlugin() {
|
public static ComboPlugin getPlugin() {
|
||||||
if (plugin == null)
|
if (plugin == null)
|
||||||
|
@ -368,6 +369,14 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private PumpEnactResult deliverBolus(final DetailedBolusInfo detailedBolusInfo) {
|
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 {
|
try {
|
||||||
pump.activity = MainApp.sResources.getString(R.string.combo_pump_action_bolusing);
|
pump.activity = MainApp.sResources.getString(R.string.combo_pump_action_bolusing);
|
||||||
MainApp.bus().post(new EventComboPumpUpdateGUI());
|
MainApp.bus().post(new EventComboPumpUpdateGUI());
|
||||||
|
|
|
@ -799,5 +799,6 @@
|
||||||
<string name="combo_pump_unsupported_operation">Requested operation not supported by pump</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_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="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>
|
</resources>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue