Fix reading pump time.

This commit is contained in:
Johannes Mockenhaupt 2017-12-13 15:09:45 +01:00
parent 27922a045e
commit 97a9d65b52
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
2 changed files with 20 additions and 4 deletions

View file

@ -81,15 +81,19 @@ public class PumpState {
@Override @Override
public String toString() { public String toString() {
return "PumpState{" + return "PumpState{" +
"menu=" + menu + "timestamp=" + timestamp +
", pumpTime=" + pumpTime +
", menu='" + menu + '\'' +
", suspended=" + suspended +
", tbrActive=" + tbrActive + ", tbrActive=" + tbrActive +
", tbrPercent=" + tbrPercent + ", tbrPercent=" + tbrPercent +
", tbrRate=" + tbrRate + ", tbrRate=" + tbrRate +
", tbrRemainingDuration=" + tbrRemainingDuration + ", tbrRemainingDuration=" + tbrRemainingDuration +
", suspended=" + suspended + ", activeAlert=" + activeAlert +
", batteryState=" + batteryState + ", batteryState=" + batteryState +
", insulinState=" + insulinState + ", insulinState=" + insulinState +
", activeBasalProfileNumber=" + activeBasalProfileNumber + ", activeBasalProfileNumber=" + activeBasalProfileNumber +
", unsafeUsageDetected=" + unsafeUsageDetected +
'}'; '}';
} }
} }

View file

@ -392,6 +392,15 @@ public class RuffyScripter implements RuffyCommands {
boolean connected = isConnected(); boolean connected = isConnected();
if (connected) { if (connected) {
long menuTime = this.menuLastUpdated;
waitForScreenUpdate();
if (menuTime == this.menuLastUpdated) {
log.error("NOT RECEIVING UPDATES YET JOE");
}
while(currentMenu==null) {
log.warn("waiting for currentMenu to become != null");
waitForScreenUpdate();
}
MenuType menuType = getCurrentMenu().getType(); MenuType menuType = getCurrentMenu().getType();
if (menuType != MenuType.MAIN_MENU && menuType != MenuType.WARNING_OR_ERROR) { if (menuType != MenuType.MAIN_MENU && menuType != MenuType.WARNING_OR_ERROR) {
returnToRootMenu(); returnToRootMenu();
@ -500,7 +509,8 @@ public class RuffyScripter implements RuffyCommands {
Date date = new Date(); Date date = new Date();
date.setHours(time.getHour()); date.setHours(time.getHour());
date.setMinutes(time.getMinute()); date.setMinutes(time.getMinute());
state.pumpTime = date.getTime(); date.setSeconds(0);
state.pumpTime = date.getTime() - date.getTime() % 1000;
} }
} else if (menuType == MenuType.WARNING_OR_ERROR) { } else if (menuType == MenuType.WARNING_OR_ERROR) {
state.activeAlert = readWarningOrErrorCode(); state.activeAlert = readWarningOrErrorCode();
@ -517,10 +527,12 @@ public class RuffyScripter implements RuffyCommands {
Date date = new Date(); Date date = new Date();
date.setHours(time.getHour()); date.setHours(time.getHour());
date.setMinutes(time.getMinute()); date.setMinutes(time.getMinute());
state.pumpTime = date.getTime(); date.setSeconds(0);
state.pumpTime = date.getTime() - date.getTime() % 1000;
} }
} }
log.debug("State read: " + state);
return state; return state;
} }