Sanity check bolus timestamp on start, after bolusing.

This commit is contained in:
Johannes Mockenhaupt 2018-02-16 14:52:51 +01:00
parent 223d22795a
commit 52aa27de05
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
4 changed files with 20 additions and 6 deletions

View file

@ -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()

View file

@ -426,10 +426,15 @@ 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) {
// 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,
// so force an update after initialization completed
@ -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)

View file

@ -792,5 +792,6 @@
<string name="zerovalueinprofile">Ungültiges Profil: %s</string>
<string name="hoursago">vor %.1f h</string>
<string name="combo_high_temp_rejected_due_to_pump_history_changes">Es wurde keine hohe TBR gesetzt, da nach der Berechnung Boluseinträge in der Pumpenhistorik gefunden wurden.</string>
<string name="combo_check_date">Der letzte Bolus liegt mehr als 24 Stunden zurück. Prüfe bitte das Datum auf der Uhr.</string>
<string name="combo_check_date">Der letzte Bolus liegt mehr als 24 Stunden zurück oder liegt in der Zukunft. Prüfe bitte das Datum auf der Uhr.</string>
<string name="combo_suspious_bolus_time">Zeit/Datum des abgegebenen Boluses auf der Pumpe erscheint falsch, IOB ist wahrscheinlich nicht korrekt. Bitte prüfe Zeit/Datum der Pumpe.</string>
</resources>

View file

@ -877,9 +877,10 @@
<string name="combo_error_multiple_boluses_with_identical_timestamp">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.</string>
<string name="mute">Mute</string>
<string name="about_link_urls">\n\nhttp://www.androidaps.org\nhttp://www.androidaps.de (de)\n\nfacebook:\nhttp://facebook.androidaps.org\nhttp://facebook.androidaps.de (de)</string>
<string name="combo_check_date">The last bolus is older than 24 hours. Please check the date on the pump is set correctly.</string>
<string name="combo_check_date">The last bolus is older than 24 hours or is in the future. Please check the date on the pump is set correctly.</string>
<string name="key_ns_create_announcements_from_errors">ns_create_announcements_from_errors</string>
<string name="ns_create_announcements_from_errors_title">Create announcements from errors</string>
<string name="ns_create_announcements_from_errors_summary">Create Nightscout announcement for error dialogs and local alerts (also viewable in Careportal under Treatments)</string>
<string name="combo_suspious_bolus_time">Time/date of the delivered bolus on pump seems wrong, IOB is likely incorrect. Please check pump time/date.</string>
</resources>