From 52aa27de05946b3d1bee1d57acf27f6da936d2c5 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Fri, 16 Feb 2018 14:52:51 +0100 Subject: [PATCH] Sanity check bolus timestamp on start, after bolusing. --- app/build.gradle | 2 +- .../plugins/PumpCombo/ComboPlugin.java | 18 +++++++++++++++--- app/src/main/res/values-de/strings.xml | 3 ++- app/src/main/res/values/strings.xml | 3 ++- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index c4e5238f76..00b1b2d1ee 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -57,7 +57,7 @@ android { targetSdkVersion 23 multiDexEnabled true versionCode 1500 - version "1.57-combo-csv2-beta-4" + version "1.57-combo-csv2-beta-5" buildConfigField "String", "VERSION", '"' + version + '"' buildConfigField "String", "BUILDVERSION", generateGitBuild() 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 e0772da979..1c0710372a 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 @@ -426,9 +426,14 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf MainApp.bus().post(new EventInitializationChanged()); // show notification to check pump date if last bolus is older than 24 hours - if (!recentBoluses.isEmpty() && recentBoluses.get(0).timestamp < System.currentTimeMillis() - 24 * 60 * 60 * 1000) { - Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, MainApp.gs(R.string.combo_check_date), Notification.URGENT); - MainApp.bus().post(new EventNewNotification(notification)); + // or is in the future + if (!recentBoluses.isEmpty()) { + long lastBolusTimestamp = recentBoluses.get(0).timestamp; + long now = System.currentTimeMillis(); + if (lastBolusTimestamp < now - 24 * 60 * 60 * 1000 || lastBolusTimestamp > now + 5 * 60 * 1000) { + Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, MainApp.gs(R.string.combo_check_date), Notification.URGENT); + MainApp.bus().post(new EventNewNotification(notification)); + } } // ComboFragment updates state fully only after the pump has initialized, @@ -641,6 +646,13 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf lastPumpBolus.amount, detailedBolusInfo.insulin)); } + // check pump bolus record has a sane timestamp + long now = System.currentTimeMillis(); + if (lastPumpBolus.timestamp < now - 10 * 60 * 1000 || lastPumpBolus.timestamp > now + 10 * 60 * 1000) { + Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, MainApp.gs(R.string.combo_suspious_bolus_time), Notification.URGENT); + MainApp.bus().post(new EventNewNotification(notification)); + } + // full bolus was delivered successfully return new PumpEnactResult() .success(true) diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 68ff187e53..50b012defa 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -792,5 +792,6 @@ Ungültiges Profil: %s vor %.1f h Es wurde keine hohe TBR gesetzt, da nach der Berechnung Boluseinträge in der Pumpenhistorik gefunden wurden. - Der letzte Bolus liegt mehr als 24 Stunden zurück. Prüfe bitte das Datum auf der Uhr. + Der letzte Bolus liegt mehr als 24 Stunden zurück oder liegt in der Zukunft. Prüfe bitte das Datum auf der Uhr. + Zeit/Datum des abgegebenen Boluses auf der Pumpe erscheint falsch, IOB ist wahrscheinlich nicht korrekt. Bitte prüfe Zeit/Datum der Pumpe. diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c64a3da0aa..6b9fbd2e0c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -877,9 +877,10 @@ Multiple boluses with the same amount within the same minute were just imported. Only one record could be added to treatments. Please check the pump and manually add a bolus record using the Careportal tab. Make sure to create a bolus with a time no other bolus uses. Mute \n\nhttp://www.androidaps.org\nhttp://www.androidaps.de (de)\n\nfacebook:\nhttp://facebook.androidaps.org\nhttp://facebook.androidaps.de (de) - The last bolus is older than 24 hours. Please check the date on the pump is set correctly. + The last bolus is older than 24 hours or is in the future. Please check the date on the pump is set correctly. ns_create_announcements_from_errors Create announcements from errors Create Nightscout announcement for error dialogs and local alerts (also viewable in Careportal under Treatments) + Time/date of the delivered bolus on pump seems wrong, IOB is likely incorrect. Please check pump time/date.