From 066d138e5930003bd6a6fb12cd2431830f1183f2 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Tue, 21 Nov 2017 22:31:28 +0100 Subject: [PATCH] Double comparisons. --- .../nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java | 4 ++-- .../src/main/java/de/jotomo/ruffy/spi/history/Bolus.java | 2 +- .../java/de/jotomo/ruffyscripter/commands/BolusCommand.java | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) 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 5a58ae3ef6..1651e33ab8 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 @@ -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; } diff --git a/ruffy-spi/src/main/java/de/jotomo/ruffy/spi/history/Bolus.java b/ruffy-spi/src/main/java/de/jotomo/ruffy/spi/history/Bolus.java index faed71c948..b24958beeb 100644 --- a/ruffy-spi/src/main/java/de/jotomo/ruffy/spi/history/Bolus.java +++ b/ruffy-spi/src/main/java/de/jotomo/ruffy/spi/history/Bolus.java @@ -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 diff --git a/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/commands/BolusCommand.java b/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/commands/BolusCommand.java index 02a53e1fe2..8138de4b2e 100644 --- a/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/commands/BolusCommand.java +++ b/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/commands/BolusCommand.java @@ -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); }