From 44ccbc06a011654656ba3aca22e89162e0446803 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Fri, 24 Nov 2017 21:04:39 +0100 Subject: [PATCH] Retry reading/writing basal profile, cleanups, notes. --- README-Combo.md | 5 +++-- Testing-Combo.md | 4 ++++ .../androidaps/plugins/PumpCombo/ComboPlugin.java | 12 ++++++------ .../main/java/de/jotomo/ruffy/spi/BasalProfile.java | 10 +++------- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/README-Combo.md b/README-Combo.md index 1ec8e0bc99..3a71d339b0 100644 --- a/README-Combo.md +++ b/README-Combo.md @@ -1,5 +1,6 @@ -**This software is part of a DIY solution and is not a product. -You alone are responsible for what you do with it** +**This software is part of a DIY solution and is not a product, but +requires YOU to read, learn and understand the system and how to use it. +You alone are responsible for what you do with it.** Hardware requirements: - A Roche Accu-Chek Combo (any firmware, they all work) diff --git a/Testing-Combo.md b/Testing-Combo.md index 8a338031b9..a9f5faaba9 100644 --- a/Testing-Combo.md +++ b/Testing-Combo.md @@ -1,3 +1,5 @@ +- [ ] Pairing + - [ ] Pairing works with `combo-scripter-v2` branch - [ ] Bolusing - [ ] Cancelling bolus at various stages and checking error message (if any) and check no bolus or a partial bolus was delivered @@ -87,4 +89,6 @@ - [ ] Pressing refresh while a low cartridge or low battery alarm is active must confirm the alarm, indicate the new status in the Combo tab and show a notification on the overview screen +- [ ] Misc + - [ ] Pump state is correctly uploaded to Nightscout 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 94e9967534..72f4a381e7 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 @@ -234,7 +234,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf MainApp.bus().post(new EventDismissNotification(Notification.FAILED_UDPATE_PROFILE)); return PumpInterface.NOT_NEEDED; } - CommandResult setResult = runCommand(MainApp.sResources.getString(R.string.combo_activity_setting_basal_profile), 0, + CommandResult setResult = runCommand(MainApp.sResources.getString(R.string.combo_activity_setting_basal_profile), 2, () -> ruffyScripter.setBasalProfile(requestedBasalProfile)); if (!setResult.success) { Notification notification = new Notification(Notification.FAILED_UDPATE_PROFILE, MainApp.sResources.getString(R.string.failedupdatebasalprofile), Notification.URGENT); @@ -242,7 +242,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf return PumpInterface.FAILED; } - CommandResult readResult = runCommand(MainApp.sResources.getString(R.string.combo_activity_setting_basal_profile), 0, + CommandResult readResult = runCommand(MainApp.sResources.getString(R.string.combo_activity_setting_basal_profile), 2, ruffyScripter::readBasalProfile); pump.basalProfile = readResult.basalProfile; @@ -284,12 +284,12 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf * 0.05 - if above 1U/h * */ - if(rate < 1){ + if (rate < 1) { //round to 0.01 granularity; - rate = Math.round(rate/0.01)*0.01; + rate = Math.round(rate / 0.01) * 0.01; } else { //round to 0.05 granularity; - rate = Math.round(rate/0.05)*0.05; + rate = Math.round(rate / 0.05) * 0.05; } basalProfile.hourlyRates[i] = rate; @@ -337,7 +337,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf } */ - // read basal profile into cache + // read basal profile into cache and update pump profile if needed if (!pump.initialized) { CommandResult readBasalResult = runCommand("Reading basal profile", 2, ruffyScripter::readBasalProfile); if (!readBasalResult.success) { diff --git a/ruffy-spi/src/main/java/de/jotomo/ruffy/spi/BasalProfile.java b/ruffy-spi/src/main/java/de/jotomo/ruffy/spi/BasalProfile.java index 67ac14d675..1765ff78f4 100644 --- a/ruffy-spi/src/main/java/de/jotomo/ruffy/spi/BasalProfile.java +++ b/ruffy-spi/src/main/java/de/jotomo/ruffy/spi/BasalProfile.java @@ -9,10 +9,6 @@ public class BasalProfile { this.hourlyRates = new double[24]; } - public BasalProfile( double[] hourlyRates) { - this.hourlyRates = hourlyRates; - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -20,8 +16,8 @@ public class BasalProfile { BasalProfile that = (BasalProfile) o; - for(int i = 0; i <= 23; i++) { - if (Math.abs(hourlyRates[i] - that.hourlyRates[i]) > 0.01) { + for(int i = 0; i < 24; i++) { + if (Math.abs(hourlyRates[i] - that.hourlyRates[i]) > 0.001) { return false; } } @@ -36,7 +32,7 @@ public class BasalProfile { @Override public String toString() { double total = 0d; - for(int i = 0; i <= 23; i++) { + for(int i = 0; i < 24; i++) { total += hourlyRates[i]; } return "BasalProfile{" +