Double comparisons.

This commit is contained in:
Johannes Mockenhaupt 2017-11-21 22:31:28 +01:00
parent bf52352224
commit 066d138e59
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
3 changed files with 5 additions and 5 deletions

View file

@ -378,7 +378,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
private PumpEnactResult deliverBolus(final DetailedBolusInfo detailedBolusInfo) {
// guard against boluses issued multiple times within a minute
if (lastRequestedBolus != null
&& Math.abs(lastRequestedBolus.amount - detailedBolusInfo.insulin) < 0.05
&& Math.abs(lastRequestedBolus.amount - detailedBolusInfo.insulin) < 0.01
&& lastRequestedBolus.timestamp + 60 * 1000 > System.currentTimeMillis()) {
return new PumpEnactResult().success(false).enacted(false)
.comment(MainApp.sResources.getString(R.string.bolus_frequency_exceeded));
@ -825,7 +825,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
}
// there's a pump bolus AAPS doesn't know, or we only know one within the same minute but different amount
if (pumpBolus != null && (aapsBolus == null || Math.abs(aapsBolus.insulin - pumpBolus.amount) >= 0.05)) {
if (pumpBolus != null && (aapsBolus == null || Math.abs(aapsBolus.insulin - pumpBolus.amount) >= 0.01)) {
log.debug("Last bolus on pump is unknown, refreshing bolus history");
request.bolusHistory = aapsBolus == null ? PumpHistoryRequest.FULL : aapsBolus.date;
}

View file

@ -22,7 +22,7 @@ public class Bolus extends HistoryRecord {
if (timestamp != bolus.timestamp) return false;
if (isValid != bolus.isValid) return false;
return Math.abs(bolus.amount - amount) <= 0.05;
return Math.abs(bolus.amount - amount) <= 0.01;
}
@Override

View file

@ -185,7 +185,7 @@ public class BolusCommand extends BaseCommand {
}
log.debug("Final bolus: " + displayedBolus);
if (Math.abs(displayedBolus - bolus) > 0.05) {
if (Math.abs(displayedBolus - bolus) > 0.01) {
throw new CommandException("Failed to set correct bolus. Expected: " + bolus + ", actual: " + displayedBolus);
}
@ -193,7 +193,7 @@ public class BolusCommand extends BaseCommand {
SystemClock.sleep(1000);
scripter.verifyMenuIsDisplayed(MenuType.BOLUS_ENTER);
double refreshedDisplayedBolus = scripter.readBlinkingValue(Double.class, MenuAttribute.BOLUS);
if (Math.abs(displayedBolus - refreshedDisplayedBolus) > 0.05) {
if (Math.abs(displayedBolus - refreshedDisplayedBolus) > 0.01) {
throw new CommandException("Failed to set bolus: bolus changed after input stopped from "
+ displayedBolus + " -> " + refreshedDisplayedBolus);
}