From 97a9d65b52bb866ed5e3d49ac383118a126c3e2a Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Wed, 13 Dec 2017 15:09:45 +0100 Subject: [PATCH] Fix reading pump time. --- .../main/java/de/jotomo/ruffy/spi/PumpState.java | 8 ++++++-- .../de/jotomo/ruffyscripter/RuffyScripter.java | 16 ++++++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/ruffy-spi/src/main/java/de/jotomo/ruffy/spi/PumpState.java b/ruffy-spi/src/main/java/de/jotomo/ruffy/spi/PumpState.java index d646de7f63..728b9f7fa0 100644 --- a/ruffy-spi/src/main/java/de/jotomo/ruffy/spi/PumpState.java +++ b/ruffy-spi/src/main/java/de/jotomo/ruffy/spi/PumpState.java @@ -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 + '}'; } } diff --git a/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java b/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java index af437ae49f..b0dfa5280a 100644 --- a/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java +++ b/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java @@ -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; }