Merge branch 'jotomo/AndroidAPS#30' into combo
* jotomo/AndroidAPS#30: Increase timeouts. Note an pump sluggishness.
This commit is contained in:
commit
3480cc5441
|
@ -236,8 +236,9 @@ public class RuffyScripter {
|
|||
}, cmd.toString());
|
||||
cmdThread.start();
|
||||
|
||||
// time out if nothing has been happening for more than 30s or after 4m
|
||||
long dynamicTimeout = System.currentTimeMillis() + 30 * 1000;
|
||||
// time out if nothing has been happening for more than 90s or after 4m
|
||||
// (to fail before the next loop iteration issues the next command)
|
||||
long dynamicTimeout = System.currentTimeMillis() + 90 * 1000;
|
||||
long overallTimeout = System.currentTimeMillis() + 4 * 60 * 1000;
|
||||
while (cmdThread.isAlive()) {
|
||||
log.trace("Waiting for running command to complete");
|
||||
|
@ -394,7 +395,7 @@ public class RuffyScripter {
|
|||
* Wait till a menu changed has completed, "away" from the menu provided as argument.
|
||||
*/
|
||||
public void waitForMenuToBeLeft(MenuType menuType) {
|
||||
long timeout = System.currentTimeMillis() + 30 * 1000;
|
||||
long timeout = System.currentTimeMillis() + 60 * 1000;
|
||||
while (currentMenu.getType() == menuType) {
|
||||
if (System.currentTimeMillis() > timeout) {
|
||||
throw new CommandException().message("Timeout waiting for menu " + menuType + " to be left");
|
||||
|
@ -408,10 +409,10 @@ public class RuffyScripter {
|
|||
}
|
||||
|
||||
public void verifyMenuIsDisplayed(MenuType expectedMenu, String failureMessage) {
|
||||
int retries = 5;
|
||||
int retries = 600;
|
||||
while (currentMenu.getType() != expectedMenu) {
|
||||
if (retries > 0) {
|
||||
SystemClock.sleep(200);
|
||||
SystemClock.sleep(100);
|
||||
retries = retries - 1;
|
||||
} else {
|
||||
if (failureMessage == null) {
|
||||
|
|
|
@ -41,9 +41,11 @@ public class BolusCommand implements Command {
|
|||
|
||||
boolean bolusAmountInputSuccess = false;
|
||||
int bolusAmountInputRetries = 2;
|
||||
// see SetTbrCommand.execute for an explanation why we're looping here
|
||||
while (!bolusAmountInputSuccess) {
|
||||
try {
|
||||
inputBolusAmount(scripter);
|
||||
// TODO v2 this call can probably be removed by now
|
||||
SystemClock.sleep(750);
|
||||
verifyDisplayedBolusAmount(scripter);
|
||||
bolusAmountInputSuccess = true;
|
||||
|
@ -68,7 +70,8 @@ public class BolusCommand implements Command {
|
|||
"Pump did not return to MAIN_MEU from BOLUS_ENTER to deliver bolus. "
|
||||
+ "Check pump manually, the bolus might not have been delivered.");
|
||||
|
||||
// wait for bolus delivery to complete
|
||||
// wait for bolus delivery to complete; the remaining units to deliver are counted
|
||||
// down and are displayed on the main menu.
|
||||
Double bolusRemaining = (Double) scripter.currentMenu.getAttribute(MenuAttribute.BOLUS_REMAINING);
|
||||
while (bolusRemaining != null) {
|
||||
log.debug("Delivering bolus, remaining: " + bolusRemaining);
|
||||
|
@ -121,7 +124,9 @@ public class BolusCommand implements Command {
|
|||
}
|
||||
|
||||
private double readDisplayedBolusAmount(RuffyScripter scripter) {
|
||||
// TODO v2 add timeout? Currently the command execution timeout would trigger if exceeded
|
||||
scripter.verifyMenuIsDisplayed(MenuType.BOLUS_ENTER);
|
||||
// bolus amount is blinking, so we need to make sure we catch it at the right moment
|
||||
Object amountObj = scripter.currentMenu.getAttribute(MenuAttribute.BOLUS);
|
||||
while (!(amountObj instanceof Double)) {
|
||||
scripter.waitForMenuUpdate();
|
||||
|
|
|
@ -60,9 +60,19 @@ public class SetTbrCommand implements Command {
|
|||
|
||||
boolean tbrPercentInputSuccess = false;
|
||||
int tbrPercentInputRetries = 2;
|
||||
// Setting TBR percentage/duration works most of the time. Occassionnally though,
|
||||
// button presses don't take, e.g. we press down 10 times to go from 100% to 0%
|
||||
// but the pump ends on 30%. In that case restarting inputing the TBR, so we start
|
||||
// again and push down 3 times.
|
||||
// Either our timings are of, or the pump sometimes is sluggish. I suspect the later,
|
||||
// based on an error when switching from TBR_SET to TBR_DURATION took more than 1.1s
|
||||
// and 4 menu updates were sent before the menu was finally switched. This happened
|
||||
// around the time when a running TBR was about to run out. So maybe the pump was busy
|
||||
// updating its history records.
|
||||
while (!tbrPercentInputSuccess) {
|
||||
try {
|
||||
inputTbrPercentage(scripter);
|
||||
// TODO v2 this can probably be removed by now
|
||||
SystemClock.sleep(750);
|
||||
verifyDisplayedTbrPercentage(scripter);
|
||||
tbrPercentInputSuccess = true;
|
||||
|
@ -87,9 +97,11 @@ public class SetTbrCommand implements Command {
|
|||
|
||||
boolean tbrDurationSuccess = false;
|
||||
int tbrDurationRetries = 2;
|
||||
// see above why we loop here
|
||||
while (!tbrDurationSuccess) {
|
||||
try {
|
||||
inputTbrDuration(scripter);
|
||||
// TODO v2 this can probably be removed by now
|
||||
SystemClock.sleep(750);
|
||||
verifyDisplayedTbrDuration(scripter);
|
||||
tbrDurationSuccess = true;
|
||||
|
@ -167,6 +179,7 @@ public class SetTbrCommand implements Command {
|
|||
}
|
||||
|
||||
private long readDisplayedTbrPercentage(RuffyScripter scripter) {
|
||||
// TODO v2 add timeout? Currently the command execution timeout would trigger if exceeded
|
||||
Object percentageObj = scripter.currentMenu.getAttribute(MenuAttribute.BASAL_RATE);
|
||||
// this as a bit hacky, the display value is blinking, so we might catch that, so
|
||||
// keep trying till we get the Double we want
|
||||
|
@ -219,6 +232,7 @@ public class SetTbrCommand implements Command {
|
|||
}
|
||||
|
||||
private long readDisplayedTbrDuration(RuffyScripter scripter) {
|
||||
// TODO v2 add timeout? Currently the command execution timeout would trigger if exceeded
|
||||
scripter.verifyMenuIsDisplayed(MenuType.TBR_DURATION);
|
||||
Object durationObj = scripter.currentMenu.getAttribute(MenuAttribute.RUNTIME);
|
||||
// this as a bit hacky, the display value is blinking, so we might catch that, so
|
||||
|
|
Loading…
Reference in a new issue