From bd87a893c24e252253322c31f9a0755fb6135611 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Sun, 28 Jan 2018 18:58:06 +0100 Subject: [PATCH] Best effort to handle multiple boluses within the same minute. (cherry picked from commit cc9094f) --- .../plugins/PumpCombo/ComboPlugin.java | 16 +++++++++------- app/src/main/res/values-de/strings.xml | 2 ++ app/src/main/res/values-es/strings.xml | 2 +- app/src/main/res/values/strings.xml | 4 ++-- 4 files changed, 14 insertions(+), 10 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 94f9cebda7..480d29602c 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 @@ -490,10 +490,12 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf @NonNull private PumpEnactResult deliverBolus(final DetailedBolusInfo detailedBolusInfo) { - // guard against boluses issued multiple times within a minute + // Guard against boluses issued multiple times within two minutes. + // Two minutes, so that the resulting timestamp and bolus are different with the Combo + // history records which only store with minute-precision if (lastRequestedBolus != null && Math.abs(lastRequestedBolus.amount - detailedBolusInfo.insulin) < 0.01 - && lastRequestedBolus.timestamp + 60 * 1000 > System.currentTimeMillis()) { + && lastRequestedBolus.timestamp + 120 * 1000 > System.currentTimeMillis()) { log.error("Bolus delivery failure at stage 0", new Exception()); return new PumpEnactResult().success(false).enacted(false) .comment(MainApp.gs(R.string.bolus_frequency_exceeded)); @@ -557,9 +559,9 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf .comment(MainApp.gs(R.string.combo_error_partial_bolus_delivered)); } - // seems we actually made it ... - detailedBolusInfo.date = lastBolus.timestamp; - detailedBolusInfo.pumpId = lastBolus.timestamp + ((int) lastBolus.amount * 10); + // seems we actually made it this far, let's add a treatment record + detailedBolusInfo.date = lastBolus.timestamp + (Math.min((int) lastBolus.amount * 10 * 1000, 59 * 1000)); + detailedBolusInfo.pumpId = lastBolus.timestamp + (Math.min((int) lastBolus.amount * 10 * 1000, 59 * 1000)); detailedBolusInfo.source = Source.PUMP; detailedBolusInfo.insulin = lastBolus.amount; boolean treatmentCreated = MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo); @@ -955,8 +957,8 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf // Bolus for (Bolus pumpBolus : history.bolusHistory) { DetailedBolusInfo dbi = new DetailedBolusInfo(); - dbi.date = pumpBolus.timestamp; - dbi.pumpId = pumpBolus.timestamp + ((int) pumpBolus.amount * 10); + dbi.date = pumpBolus.timestamp + (Math.min((int) pumpBolus.amount * 10 * 1000, 59 * 1000)); + dbi.pumpId = pumpBolus.timestamp + (Math.min((int) pumpBolus.amount * 10 * 1000, 59 * 1000)); dbi.source = Source.PUMP; dbi.insulin = pumpBolus.amount; dbi.eventType = CareportalEvent.CORRECTIONBOLUS; diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 794675c887..3ff98e2520 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -780,4 +780,6 @@ Achtung! Normalerweise musst Du diese Werte nicht ändern. Bitte KLICKE HIER und LESE den Text. Verändere Werte erst, wenn Du den Inhalt des Textes verstanden hast. %.2f IE/h Basalratenprofil wird gelesen + %.2f IE/h + Dringender Alarm diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 988a92928d..aa59862b20 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -229,7 +229,7 @@ Esperando resultado Números de teléfono permitidos XXXXXXXXXX +; + YYYYYYYYYY - Para entregar bolo% .2fU responder con código% s + Para entregar bolo %.2fU responder con código% s Bolo falló Bolo %.2fU entregado con éxito Entregando %.2fU diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 647b3aed13..ca7dce0430 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -866,7 +866,7 @@ Extended bolus delivery error %.2f U/h Reading basal profile - The pump history has changed after the bolus calculation was performed. The bolus was not delivered. Please recalculate if a bolus is still needed. If the same bolus amount is required, please wait a minute since boluses with the same amount are blocked when requested within the same minute for saftery (regardless of whether they were administered or not). - Bolus successfully delivered, but adding the treatment entry failed. This can happen if two small boluses of the same size are administered within the same minute. Please check the pump history and treatment entries and use the Careportal to add missing entries. Make sure not to add any entries for the exact same minute. + The pump history has changed after the bolus calculation was performed. The bolus was not delivered. Please recalculate if a bolus is still needed. If the same bolus amount is required, please wait a minute since boluses with the same amount are blocked when requested with less than tow minutes between them for safety (regardless of whether they were administered or not). + Bolus successfully delivered, but adding the treatment entry failed. This can happen if two small boluses of the same size are administered within the last two minutes. Please check the pump history and treatment entries and use the Careportal to add missing entries. Make sure not to add any entries for the exact same minute and same amount.