Fix ReadHistoryCommand to read the 30th record as well.

This commit is contained in:
Johannes Mockenhaupt 2017-11-12 18:32:59 +01:00
parent c21799fe0f
commit f2569b587a
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1

View file

@ -107,25 +107,25 @@ public class ReadHistoryCommand extends BaseCommand {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
if (!history.bolusHistory.isEmpty()) { if (!history.bolusHistory.isEmpty()) {
log.debug("Read bolus history:"); log.debug("Read bolus history (" + history.bolusHistory.size() + "):");
for (Bolus bolus : history.bolusHistory) { for (Bolus bolus : history.bolusHistory) {
log.debug(new Date(bolus.timestamp) + ": " + bolus.toString()); log.debug(new Date(bolus.timestamp) + ": " + bolus.toString());
} }
} }
if (!history.pumpErrorHistory.isEmpty()) { if (!history.pumpErrorHistory.isEmpty()) {
log.debug("Read error history:"); log.debug("Read error history (" + history.pumpErrorHistory.size() + "):");
for (PumpError pumpError : history.pumpErrorHistory) { for (PumpError pumpError : history.pumpErrorHistory) {
log.debug(new Date(pumpError.timestamp) + ": " + pumpError.toString()); log.debug(new Date(pumpError.timestamp) + ": " + pumpError.toString());
} }
} }
if (!history.tddHistory.isEmpty()) { if (!history.tddHistory.isEmpty()) {
log.debug("Read TDD history:"); log.debug("Read TDD history (" + history.tddHistory.size() + "):");
for (Tdd tdd : history.tddHistory) { for (Tdd tdd : history.tddHistory) {
log.debug(new Date(tdd.timestamp) + ": " + tdd.toString()); log.debug(new Date(tdd.timestamp) + ": " + tdd.toString());
} }
} }
if (!history.tbrHistory.isEmpty()) { if (!history.tbrHistory.isEmpty()) {
log.debug("Read TBR history:"); log.debug("Read TBR history (" + history.tbrHistory.size() + "):");
for (Tbr tbr : history.tbrHistory) { for (Tbr tbr : history.tbrHistory) {
log.debug(new Date(tbr.timestamp) + ": " + tbr.toString()); log.debug(new Date(tbr.timestamp) + ": " + tbr.toString());
} }
@ -144,12 +144,12 @@ public class ReadHistoryCommand extends BaseCommand {
break; break;
} }
history.tddHistory.add(tdd); history.tddHistory.add(tdd);
scripter.pressDownKey();
scripter.waitForMenuUpdate();
record = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD);
if (record == totalRecords) { if (record == totalRecords) {
break; break;
} }
scripter.pressDownKey();
scripter.waitForMenuUpdate();
record = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD);
} }
} }
@ -175,12 +175,12 @@ public class ReadHistoryCommand extends BaseCommand {
break; break;
} }
history.tbrHistory.add(tbr); history.tbrHistory.add(tbr);
scripter.pressDownKey();
scripter.waitForMenuUpdate();
record = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD);
if (record == totalRecords) { if (record == totalRecords) {
break; break;
} }
scripter.pressDownKey();
scripter.waitForMenuUpdate();
record = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD);
} }
} }
@ -190,8 +190,8 @@ public class ReadHistoryCommand extends BaseCommand {
Double percentage = (Double) scripter.getCurrentMenu().getAttribute(MenuAttribute.TBR); Double percentage = (Double) scripter.getCurrentMenu().getAttribute(MenuAttribute.TBR);
MenuTime durationTime = (MenuTime) scripter.getCurrentMenu().getAttribute(MenuAttribute.RUNTIME); MenuTime durationTime = (MenuTime) scripter.getCurrentMenu().getAttribute(MenuAttribute.RUNTIME);
int duration = durationTime.getHour() * 60 + durationTime.getMinute(); int duration = durationTime.getHour() * 60 + durationTime.getMinute();
long recordDate = readRecordDate(); long tbrStartDate = readRecordDate() - duration * 60 * 1000;
return new Tbr(recordDate, duration, percentage.intValue()); return new Tbr(tbrStartDate, duration, percentage.intValue());
} }
private void readBolusRecords(long requestedTime) { private void readBolusRecords(long requestedTime) {
@ -204,12 +204,12 @@ public class ReadHistoryCommand extends BaseCommand {
break; break;
} }
history.bolusHistory.add(bolus); history.bolusHistory.add(bolus);
scripter.pressDownKey();
scripter.waitForMenuUpdate();
record = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD);
if (record == totalRecords) { if (record == totalRecords) {
break; break;
} }
scripter.pressDownKey();
scripter.waitForMenuUpdate();
record = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD);
} }
} }
@ -233,12 +233,12 @@ public class ReadHistoryCommand extends BaseCommand {
break; break;
} }
history.pumpErrorHistory.add(error); history.pumpErrorHistory.add(error);
scripter.pressDownKey();
scripter.waitForMenuUpdate();
record = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD);
if (record == totalRecords) { if (record == totalRecords) {
break; break;
} }
scripter.pressDownKey();
scripter.waitForMenuUpdate();
record = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD);
} }
} }