Retry reading/writing basal profile, cleanups, notes.

This commit is contained in:
Johannes Mockenhaupt 2017-11-24 21:04:39 +01:00
parent 2d7a8a2e4d
commit 44ccbc06a0
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
4 changed files with 16 additions and 15 deletions

View file

@ -1,5 +1,6 @@
**This software is part of a DIY solution and is not a product. **This software is part of a DIY solution and is not a product, but
You alone are responsible for what you do with it** 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: Hardware requirements:
- A Roche Accu-Chek Combo (any firmware, they all work) - A Roche Accu-Chek Combo (any firmware, they all work)

View file

@ -1,3 +1,5 @@
- [ ] Pairing
- [ ] Pairing works with `combo-scripter-v2` branch
- [ ] Bolusing - [ ] Bolusing
- [ ] Cancelling bolus at various stages and checking error message (if any) and check - [ ] Cancelling bolus at various stages and checking error message (if any) and check
no bolus or a partial bolus was delivered no bolus or a partial bolus was delivered
@ -87,4 +89,6 @@
- [ ] Pressing refresh while a low cartridge or low battery alarm is active - [ ] 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 must confirm the alarm, indicate the new status in the Combo tab and
show a notification on the overview screen show a notification on the overview screen
- [ ] Misc
- [ ] Pump state is correctly uploaded to Nightscout

View file

@ -234,7 +234,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
MainApp.bus().post(new EventDismissNotification(Notification.FAILED_UDPATE_PROFILE)); MainApp.bus().post(new EventDismissNotification(Notification.FAILED_UDPATE_PROFILE));
return PumpInterface.NOT_NEEDED; 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)); () -> ruffyScripter.setBasalProfile(requestedBasalProfile));
if (!setResult.success) { if (!setResult.success) {
Notification notification = new Notification(Notification.FAILED_UDPATE_PROFILE, MainApp.sResources.getString(R.string.failedupdatebasalprofile), Notification.URGENT); 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; 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); ruffyScripter::readBasalProfile);
pump.basalProfile = readResult.basalProfile; pump.basalProfile = readResult.basalProfile;
@ -284,12 +284,12 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
* 0.05 - if above 1U/h * 0.05 - if above 1U/h
* */ * */
if(rate < 1){ if (rate < 1) {
//round to 0.01 granularity; //round to 0.01 granularity;
rate = Math.round(rate/0.01)*0.01; rate = Math.round(rate / 0.01) * 0.01;
} else { } else {
//round to 0.05 granularity; //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; 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) { if (!pump.initialized) {
CommandResult readBasalResult = runCommand("Reading basal profile", 2, ruffyScripter::readBasalProfile); CommandResult readBasalResult = runCommand("Reading basal profile", 2, ruffyScripter::readBasalProfile);
if (!readBasalResult.success) { if (!readBasalResult.success) {

View file

@ -9,10 +9,6 @@ public class BasalProfile {
this.hourlyRates = new double[24]; this.hourlyRates = new double[24];
} }
public BasalProfile( double[] hourlyRates) {
this.hourlyRates = hourlyRates;
}
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o) return true;
@ -20,8 +16,8 @@ public class BasalProfile {
BasalProfile that = (BasalProfile) o; BasalProfile that = (BasalProfile) o;
for(int i = 0; i <= 23; i++) { for(int i = 0; i < 24; i++) {
if (Math.abs(hourlyRates[i] - that.hourlyRates[i]) > 0.01) { if (Math.abs(hourlyRates[i] - that.hourlyRates[i]) > 0.001) {
return false; return false;
} }
} }
@ -36,7 +32,7 @@ public class BasalProfile {
@Override @Override
public String toString() { public String toString() {
double total = 0d; double total = 0d;
for(int i = 0; i <= 23; i++) { for(int i = 0; i < 24; i++) {
total += hourlyRates[i]; total += hourlyRates[i];
} }
return "BasalProfile{" + return "BasalProfile{" +