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