RuffyScripter: read/infer pump time from menu.

This commit is contained in:
Johannes Mockenhaupt 2017-12-07 23:36:34 +01:00
parent cf142a4538
commit e286b9e3c2
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
2 changed files with 15 additions and 1 deletions

View file

@ -2,8 +2,11 @@ package de.jotomo.ruffy.spi;
/** State displayed on the main screen of the pump. */ /** State displayed on the main screen of the pump. */
public class PumpState { public class PumpState {
/** Time the state was captured. This is NOT the pump's time! */ /** Time the state was captured. */
public long timestamp; public long timestamp;
/** Pump time. Note that this is derived from the time displayed on the main menu and assumes
* the date is set correctly */
public long pumpTime;
public String menu = null; public String menu = null;
public boolean suspended; public boolean suspended;

View file

@ -22,6 +22,7 @@ import org.monkey.d.ruffy.ruffy.driver.display.menu.MenuTime;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
@ -509,12 +510,22 @@ public class RuffyScripter implements RuffyCommands {
} }
state.batteryState = ((int) menu.getAttribute(MenuAttribute.BATTERY_STATE)); state.batteryState = ((int) menu.getAttribute(MenuAttribute.BATTERY_STATE));
state.insulinState = ((int) menu.getAttribute(MenuAttribute.INSULIN_STATE)); state.insulinState = ((int) menu.getAttribute(MenuAttribute.INSULIN_STATE));
MenuTime time = (MenuTime) menu.getAttribute(MenuAttribute.TIME);
Date date = new Date();
date.setHours(time.getHour());
date.setMinutes(time.getMinute());
state.pumpTime = date.getTime();
} else if (menuType == MenuType.WARNING_OR_ERROR) { } else if (menuType == MenuType.WARNING_OR_ERROR) {
state.activeAlert = readWarningOrErrorCode(); state.activeAlert = readWarningOrErrorCode();
} else if (menuType == MenuType.STOP) { } else if (menuType == MenuType.STOP) {
state.suspended = true; state.suspended = true;
state.batteryState = ((int) menu.getAttribute(MenuAttribute.BATTERY_STATE)); state.batteryState = ((int) menu.getAttribute(MenuAttribute.BATTERY_STATE));
state.insulinState = ((int) menu.getAttribute(MenuAttribute.INSULIN_STATE)); state.insulinState = ((int) menu.getAttribute(MenuAttribute.INSULIN_STATE));
MenuTime time = (MenuTime) menu.getAttribute(MenuAttribute.TIME);
Date date = new Date();
date.setHours(time.getHour());
date.setMinutes(time.getMinute());
state.pumpTime = date.getTime();
} }
return state; return state;