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.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);

View file

@ -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;