From 1e8e2a59fd476c365432b158b4d517142844e4a4 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Sat, 3 Feb 2018 19:56:27 +0100 Subject: [PATCH] ReadHistoryCommand: fetch records including the requested timestamp. To ensure we retrieve records with the same timestamp. --- .../ruffyscripter/commands/ReadHistoryCommand.java | 9 ++++----- .../ruffyscripter/history/PumpHistoryRequest.java | 6 ++++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ruffyscripter/commands/ReadHistoryCommand.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ruffyscripter/commands/ReadHistoryCommand.java index 1cf5b86e28..6af1b99dee 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ruffyscripter/commands/ReadHistoryCommand.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ruffyscripter/commands/ReadHistoryCommand.java @@ -4,7 +4,6 @@ import android.support.annotation.NonNull; import org.monkey.d.ruffy.ruffy.driver.display.MenuAttribute; import org.monkey.d.ruffy.ruffy.driver.display.MenuType; -import org.monkey.d.ruffy.ruffy.driver.display.menu.BolusType; import org.monkey.d.ruffy.ruffy.driver.display.menu.MenuDate; import org.monkey.d.ruffy.ruffy.driver.display.menu.MenuTime; import org.slf4j.Logger; @@ -145,7 +144,7 @@ public class ReadHistoryCommand extends BaseCommand { int totalRecords = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.TOTAL_RECORD); while (true) { Tdd tdd = readTddRecord(); - if (requestedTime != PumpHistoryRequest.FULL && tdd.timestamp <= requestedTime) { + if (requestedTime != PumpHistoryRequest.FULL && tdd.timestamp < requestedTime) { break; } log.debug("Read TDD record #" + record + "/" + totalRecords); @@ -183,7 +182,7 @@ public class ReadHistoryCommand extends BaseCommand { int totalRecords = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.TOTAL_RECORD); while (true) { Tbr tbr = readTbrRecord(); - if (requestedTime != PumpHistoryRequest.FULL && tbr.timestamp <= requestedTime) { + if (requestedTime != PumpHistoryRequest.FULL && tbr.timestamp < requestedTime) { break; } log.debug("Read TBR record #" + record + "/" + totalRecords); @@ -215,7 +214,7 @@ public class ReadHistoryCommand extends BaseCommand { int totalRecords = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.TOTAL_RECORD); while (true) { Bolus bolus = readBolusRecord(); - if (requestedTime != PumpHistoryRequest.FULL && bolus.timestamp <= requestedTime) { + if (requestedTime != PumpHistoryRequest.FULL && bolus.timestamp < requestedTime) { break; } log.debug("Read bolus record #" + record + "/" + totalRecords); @@ -237,7 +236,7 @@ public class ReadHistoryCommand extends BaseCommand { int totalRecords = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.TOTAL_RECORD); while (true) { PumpAlert error = readAlertRecord(); - if (requestedTime != PumpHistoryRequest.FULL && error.timestamp <= requestedTime) { + if (requestedTime != PumpHistoryRequest.FULL && error.timestamp < requestedTime) { break; } log.debug("Read alert record #" + record + "/" + totalRecords); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ruffyscripter/history/PumpHistoryRequest.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ruffyscripter/history/PumpHistoryRequest.java index 40dd6e553e..e785c1d67c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ruffyscripter/history/PumpHistoryRequest.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ruffyscripter/history/PumpHistoryRequest.java @@ -5,8 +5,10 @@ import java.util.Date; /** What data a 'read history' request should return. */ public class PumpHistoryRequest { /* History to read: - Either the timestamp of the last known record to fetch all newer records, - or one of the constants to read no history or all of it. + Either the timestamp of the last known record or one of the constants to read no history + or all of it. When a timestamp is provided all newer records and records matching the + timestamp are returned. Returning all records equal to the timestamp ensures a record + with a duplicate timestamp is also detected as a new record. */ public static final long LAST = -2; public static final long SKIP = -1;