Make RuffyScripter.readPumpStateInternal more robust.
This commit is contained in:
parent
a169245dc3
commit
5654a8ee6e
|
@ -495,6 +495,7 @@ public class RuffyScripter implements RuffyCommands {
|
|||
return state;
|
||||
}
|
||||
|
||||
log.debug("Parsing menu: " + menu);
|
||||
MenuType menuType = menu.getType();
|
||||
state.menu = menuType.name();
|
||||
|
||||
|
@ -505,7 +506,7 @@ public class RuffyScripter implements RuffyCommands {
|
|||
|
||||
if (bolusType != null && bolusType != BolusType.NORMAL || !activeBasalRate.equals(1)) {
|
||||
state.unsafeUsageDetected = true;
|
||||
} else if (tbrPercentage != 100) {
|
||||
} else if (tbrPercentage != null && tbrPercentage != 100) {
|
||||
state.tbrActive = true;
|
||||
Double displayedTbr = (Double) menu.getAttribute(MenuAttribute.TBR);
|
||||
state.tbrPercent = displayedTbr.intValue();
|
||||
|
@ -513,24 +514,36 @@ public class RuffyScripter implements RuffyCommands {
|
|||
state.tbrRemainingDuration = durationMenuTime.getHour() * 60 + durationMenuTime.getMinute();
|
||||
state.tbrRate = ((double) menu.getAttribute(MenuAttribute.BASAL_RATE));
|
||||
}
|
||||
state.batteryState = ((int) menu.getAttribute(MenuAttribute.BATTERY_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();
|
||||
if (menu.attributes().contains(MenuAttribute.BATTERY_STATE)) {
|
||||
state.batteryState = ((int) menu.getAttribute(MenuAttribute.BATTERY_STATE));
|
||||
}
|
||||
if (menu.attributes().contains(MenuAttribute.INSULIN_STATE)) {
|
||||
state.insulinState = ((int) menu.getAttribute(MenuAttribute.INSULIN_STATE));
|
||||
}
|
||||
if (menu.attributes().contains(MenuAttribute.TIME)) {
|
||||
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) {
|
||||
state.activeAlert = readWarningOrErrorCode();
|
||||
} else if (menuType == MenuType.STOP) {
|
||||
state.suspended = true;
|
||||
state.batteryState = ((int) menu.getAttribute(MenuAttribute.BATTERY_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();
|
||||
if (menu.attributes().contains(MenuAttribute.BATTERY_STATE)) {
|
||||
state.batteryState = ((int) menu.getAttribute(MenuAttribute.BATTERY_STATE));
|
||||
}
|
||||
if (menu.attributes().contains(MenuAttribute.INSULIN_STATE)) {
|
||||
state.insulinState = ((int) menu.getAttribute(MenuAttribute.INSULIN_STATE));
|
||||
}
|
||||
if (menu.attributes().contains(MenuAttribute.TIME)) {
|
||||
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;
|
||||
|
|
Loading…
Reference in a new issue