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
public String toString() {
return "PumpState{" +
"menu=" + menu +
"timestamp=" + timestamp +
", pumpTime=" + pumpTime +
", menu='" + menu + '\'' +
", suspended=" + suspended +
", tbrActive=" + tbrActive +
", tbrPercent=" + tbrPercent +
", tbrRate=" + tbrRate +
", tbrRemainingDuration=" + tbrRemainingDuration +
", suspended=" + suspended +
", activeAlert=" + activeAlert +
", batteryState=" + batteryState +
", insulinState=" + insulinState +
", activeBasalProfileNumber=" + activeBasalProfileNumber +
", unsafeUsageDetected=" + unsafeUsageDetected +
'}';
}
}

View file

@ -392,6 +392,15 @@ public class RuffyScripter implements RuffyCommands {
boolean connected = isConnected();
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();
if (menuType != MenuType.MAIN_MENU && menuType != MenuType.WARNING_OR_ERROR) {
returnToRootMenu();
@ -500,7 +509,8 @@ public class RuffyScripter implements RuffyCommands {
Date date = new Date();
date.setHours(time.getHour());
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) {
state.activeAlert = readWarningOrErrorCode();
@ -517,10 +527,12 @@ public class RuffyScripter implements RuffyCommands {
Date date = new Date();
date.setHours(time.getHour());
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;
}