ReadHistoryCommand: fetch records including the requested timestamp.

To ensure we retrieve records with the same timestamp.
This commit is contained in:
Johannes Mockenhaupt 2018-02-03 19:56:27 +01:00
parent 6fded4c1bd
commit 1e8e2a59fd
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
2 changed files with 8 additions and 7 deletions

View file

@ -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.MenuAttribute;
import org.monkey.d.ruffy.ruffy.driver.display.MenuType; 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.MenuDate;
import org.monkey.d.ruffy.ruffy.driver.display.menu.MenuTime; import org.monkey.d.ruffy.ruffy.driver.display.menu.MenuTime;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -145,7 +144,7 @@ public class ReadHistoryCommand extends BaseCommand {
int totalRecords = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.TOTAL_RECORD); int totalRecords = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.TOTAL_RECORD);
while (true) { while (true) {
Tdd tdd = readTddRecord(); Tdd tdd = readTddRecord();
if (requestedTime != PumpHistoryRequest.FULL && tdd.timestamp <= requestedTime) { if (requestedTime != PumpHistoryRequest.FULL && tdd.timestamp < requestedTime) {
break; break;
} }
log.debug("Read TDD record #" + record + "/" + totalRecords); 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); int totalRecords = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.TOTAL_RECORD);
while (true) { while (true) {
Tbr tbr = readTbrRecord(); Tbr tbr = readTbrRecord();
if (requestedTime != PumpHistoryRequest.FULL && tbr.timestamp <= requestedTime) { if (requestedTime != PumpHistoryRequest.FULL && tbr.timestamp < requestedTime) {
break; break;
} }
log.debug("Read TBR record #" + record + "/" + totalRecords); 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); int totalRecords = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.TOTAL_RECORD);
while (true) { while (true) {
Bolus bolus = readBolusRecord(); Bolus bolus = readBolusRecord();
if (requestedTime != PumpHistoryRequest.FULL && bolus.timestamp <= requestedTime) { if (requestedTime != PumpHistoryRequest.FULL && bolus.timestamp < requestedTime) {
break; break;
} }
log.debug("Read bolus record #" + record + "/" + totalRecords); 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); int totalRecords = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.TOTAL_RECORD);
while (true) { while (true) {
PumpAlert error = readAlertRecord(); PumpAlert error = readAlertRecord();
if (requestedTime != PumpHistoryRequest.FULL && error.timestamp <= requestedTime) { if (requestedTime != PumpHistoryRequest.FULL && error.timestamp < requestedTime) {
break; break;
} }
log.debug("Read alert record #" + record + "/" + totalRecords); log.debug("Read alert record #" + record + "/" + totalRecords);

View file

@ -5,8 +5,10 @@ import java.util.Date;
/** What data a 'read history' request should return. */ /** What data a 'read history' request should return. */
public class PumpHistoryRequest { public class PumpHistoryRequest {
/* History to read: /* History to read:
Either the timestamp of the last known record to fetch all newer records, Either the timestamp of the last known record or one of the constants to read no history
or one of the constants to read no history or all of it. 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 LAST = -2;
public static final long SKIP = -1; public static final long SKIP = -1;