Try to be clever about slow screen updates when scrolling.
This commit is contained in:
parent
ad44b356c4
commit
e399fac8dc
3 changed files with 45 additions and 19 deletions
|
@ -224,14 +224,22 @@ public class BolusCommand extends BaseCommand {
|
||||||
|
|
||||||
private void verifyDisplayedBolusAmount() {
|
private void verifyDisplayedBolusAmount() {
|
||||||
scripter.verifyMenuIsDisplayed(MenuType.BOLUS_ENTER);
|
scripter.verifyMenuIsDisplayed(MenuType.BOLUS_ENTER);
|
||||||
|
|
||||||
|
// wait up to 5s for any scrolling to finish
|
||||||
double displayedBolus = scripter.readBlinkingValue(Double.class, MenuAttribute.BOLUS);
|
double displayedBolus = scripter.readBlinkingValue(Double.class, MenuAttribute.BOLUS);
|
||||||
|
long timeout = System.currentTimeMillis() + 10 * 1000;
|
||||||
|
while (timeout > System.currentTimeMillis() && bolus - displayedBolus > 0.05) {
|
||||||
|
log.debug("Waiting for pump to process scrolling input for amount, current: " + displayedBolus + ", desired: " + bolus);
|
||||||
|
displayedBolus = scripter.readBlinkingValue(Double.class, MenuAttribute.BOLUS);
|
||||||
|
}
|
||||||
|
|
||||||
log.debug("Final bolus: " + displayedBolus);
|
log.debug("Final bolus: " + displayedBolus);
|
||||||
if (Math.abs(displayedBolus - bolus) > 0.05) {
|
if (Math.abs(displayedBolus - bolus) > 0.05) {
|
||||||
throw new CommandException().message("Failed to set correct bolus. Expected: " + bolus + ", actual: " + displayedBolus);
|
throw new CommandException().message("Failed to set correct bolus. Expected: " + bolus + ", actual: " + displayedBolus);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check again to ensure the displayed value hasn't change due to due scrolling taking extremely long
|
// check again to ensure the displayed value hasn't change due to due scrolling taking extremely long
|
||||||
SystemClock.sleep(2000);
|
SystemClock.sleep(1000);
|
||||||
scripter.verifyMenuIsDisplayed(MenuType.BOLUS_ENTER);
|
scripter.verifyMenuIsDisplayed(MenuType.BOLUS_ENTER);
|
||||||
double refreshedDisplayedBolus = scripter.readBlinkingValue(Double.class, MenuAttribute.BOLUS);
|
double refreshedDisplayedBolus = scripter.readBlinkingValue(Double.class, MenuAttribute.BOLUS);
|
||||||
if (Math.abs(displayedBolus - refreshedDisplayedBolus) > 0.05) {
|
if (Math.abs(displayedBolus - refreshedDisplayedBolus) > 0.05) {
|
||||||
|
|
|
@ -69,8 +69,8 @@ public class SetTbrCommand extends BaseCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
enterTbrMenu();
|
enterTbrMenu();
|
||||||
inputTbrPercentage();
|
boolean increasingPercentage = inputTbrPercentage();
|
||||||
verifyDisplayedTbrPercentage();
|
verifyDisplayedTbrPercentage(increasingPercentage);
|
||||||
|
|
||||||
if (cancellingTbr) {
|
if (cancellingTbr) {
|
||||||
cancelTbrAndConfirmCancellationWarning();
|
cancelTbrAndConfirmCancellationWarning();
|
||||||
|
@ -81,8 +81,8 @@ public class SetTbrCommand extends BaseCommand {
|
||||||
scripter.waitForMenuUpdate();
|
scripter.waitForMenuUpdate();
|
||||||
scripter.verifyMenuIsDisplayed(MenuType.TBR_DURATION);
|
scripter.verifyMenuIsDisplayed(MenuType.TBR_DURATION);
|
||||||
|
|
||||||
inputTbrDuration();
|
boolean increasingDuration = inputTbrDuration();
|
||||||
verifyDisplayedTbrDuration();
|
verifyDisplayedTbrDuration(increasingDuration);
|
||||||
|
|
||||||
// confirm TBR
|
// confirm TBR
|
||||||
scripter.pressCheckKey();
|
scripter.pressCheckKey();
|
||||||
|
@ -117,7 +117,7 @@ public class SetTbrCommand extends BaseCommand {
|
||||||
scripter.verifyMenuIsDisplayed(MenuType.TBR_SET);
|
scripter.verifyMenuIsDisplayed(MenuType.TBR_SET);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void inputTbrPercentage() {
|
private boolean inputTbrPercentage() {
|
||||||
scripter.verifyMenuIsDisplayed(MenuType.TBR_SET);
|
scripter.verifyMenuIsDisplayed(MenuType.TBR_SET);
|
||||||
long currentPercent = scripter.readBlinkingValue(Double.class, MenuAttribute.BASAL_RATE).longValue();
|
long currentPercent = scripter.readBlinkingValue(Double.class, MenuAttribute.BASAL_RATE).longValue();
|
||||||
log.debug("Current TBR %: " + currentPercent);
|
log.debug("Current TBR %: " + currentPercent);
|
||||||
|
@ -136,21 +136,29 @@ public class SetTbrCommand extends BaseCommand {
|
||||||
else scripter.pressDownKey();
|
else scripter.pressDownKey();
|
||||||
SystemClock.sleep(100);
|
SystemClock.sleep(100);
|
||||||
}
|
}
|
||||||
// Give the pump time to finish any scrolling that might still be going on, can take
|
return increasePercentage;
|
||||||
// up to 1100ms. Plus some extra time to be sure
|
|
||||||
SystemClock.sleep(2000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifyDisplayedTbrPercentage() {
|
// TODO extract verification into a method TBR percentage, duration and bolus amount
|
||||||
|
private void verifyDisplayedTbrPercentage(boolean increasingPercentage) {
|
||||||
scripter.verifyMenuIsDisplayed(MenuType.TBR_SET);
|
scripter.verifyMenuIsDisplayed(MenuType.TBR_SET);
|
||||||
|
// wait up to 5s for any scrolling to finish
|
||||||
long displayedPercentage = scripter.readBlinkingValue(Double.class, MenuAttribute.BASAL_RATE).longValue();
|
long displayedPercentage = scripter.readBlinkingValue(Double.class, MenuAttribute.BASAL_RATE).longValue();
|
||||||
|
long timeout = System.currentTimeMillis() + 10 * 1000;
|
||||||
|
while (timeout > System.currentTimeMillis()
|
||||||
|
&& ((increasingPercentage && displayedPercentage < percentage)
|
||||||
|
|| (!increasingPercentage && displayedPercentage > percentage))) {
|
||||||
|
log.debug("Waiting for pump to process scrolling input for percentage, current: "
|
||||||
|
+ displayedPercentage + ", desired: " + percentage + ", scrolling up: " + increasingPercentage);
|
||||||
|
displayedPercentage = scripter.readBlinkingValue(Double.class, MenuAttribute.BASAL_RATE).longValue();
|
||||||
|
}
|
||||||
|
log.debug("Final displayed TBR percentage: " + displayedPercentage);
|
||||||
if (displayedPercentage != percentage) {
|
if (displayedPercentage != percentage) {
|
||||||
log.debug("Final displayed TBR percentage: " + displayedPercentage);
|
|
||||||
throw new CommandException().message("Failed to set TBR percentage, requested: " + percentage + ", actual: " + displayedPercentage);
|
throw new CommandException().message("Failed to set TBR percentage, requested: " + percentage + ", actual: " + displayedPercentage);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check again to ensure the displayed value hasn't change due to due scrolling taking extremely long
|
// check again to ensure the displayed value hasn't change due to due scrolling taking extremely long
|
||||||
SystemClock.sleep(2000);
|
SystemClock.sleep(1000);
|
||||||
scripter.verifyMenuIsDisplayed(MenuType.TBR_SET);
|
scripter.verifyMenuIsDisplayed(MenuType.TBR_SET);
|
||||||
long refreshedDisplayedTbrPecentage = scripter.readBlinkingValue(Double.class, MenuAttribute.BASAL_RATE).longValue();
|
long refreshedDisplayedTbrPecentage = scripter.readBlinkingValue(Double.class, MenuAttribute.BASAL_RATE).longValue();
|
||||||
if (displayedPercentage != refreshedDisplayedTbrPecentage) {
|
if (displayedPercentage != refreshedDisplayedTbrPecentage) {
|
||||||
|
@ -160,7 +168,7 @@ public class SetTbrCommand extends BaseCommand {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void inputTbrDuration() {
|
private boolean inputTbrDuration() {
|
||||||
scripter.verifyMenuIsDisplayed(MenuType.TBR_DURATION);
|
scripter.verifyMenuIsDisplayed(MenuType.TBR_DURATION);
|
||||||
long currentDuration = scripter.readDisplayedDuration();
|
long currentDuration = scripter.readDisplayedDuration();
|
||||||
if (currentDuration % 15 != 0) {
|
if (currentDuration % 15 != 0) {
|
||||||
|
@ -190,21 +198,30 @@ public class SetTbrCommand extends BaseCommand {
|
||||||
SystemClock.sleep(100);
|
SystemClock.sleep(100);
|
||||||
log.debug("Push #" + (i + 1));
|
log.debug("Push #" + (i + 1));
|
||||||
}
|
}
|
||||||
// Give the pump time to finish any scrolling that might still be going on, can take
|
return increaseDuration;
|
||||||
// up to 1100ms. Plus some extra time to be sure
|
|
||||||
SystemClock.sleep(2000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifyDisplayedTbrDuration() {
|
private void verifyDisplayedTbrDuration(boolean increasingPercentage) {
|
||||||
scripter.verifyMenuIsDisplayed(MenuType.TBR_DURATION);
|
scripter.verifyMenuIsDisplayed(MenuType.TBR_DURATION);
|
||||||
|
|
||||||
|
// wait up to 5s for any scrolling to finish
|
||||||
long displayedDuration = scripter.readDisplayedDuration();
|
long displayedDuration = scripter.readDisplayedDuration();
|
||||||
|
long timeout = System.currentTimeMillis() + 10 * 1000;
|
||||||
|
while (timeout > System.currentTimeMillis()
|
||||||
|
&& ((increasingPercentage && displayedDuration < duration)
|
||||||
|
|| (!increasingPercentage && displayedDuration > duration))) {
|
||||||
|
log.debug("Waiting for pump to process scrolling input for duration, current: "
|
||||||
|
+ displayedDuration + ", desired: " + duration + ", scrolling up: " + increasingPercentage);
|
||||||
|
displayedDuration = scripter.readDisplayedDuration();
|
||||||
|
}
|
||||||
|
|
||||||
|
log.debug("Final displayed TBR duration: " + displayedDuration);
|
||||||
if (displayedDuration != duration) {
|
if (displayedDuration != duration) {
|
||||||
log.debug("Final displayed TBR duration: " + displayedDuration);
|
|
||||||
throw new CommandException().message("Failed to set TBR duration, requested: " + duration + ", actual: " + displayedDuration);
|
throw new CommandException().message("Failed to set TBR duration, requested: " + duration + ", actual: " + displayedDuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check again to ensure the displayed value hasn't change due to due scrolling taking extremely long
|
// check again to ensure the displayed value hasn't change due to due scrolling taking extremely long
|
||||||
SystemClock.sleep(2000);
|
SystemClock.sleep(1000);
|
||||||
scripter.verifyMenuIsDisplayed(MenuType.TBR_DURATION);
|
scripter.verifyMenuIsDisplayed(MenuType.TBR_DURATION);
|
||||||
long refreshedDisplayedTbrDuration = scripter.readDisplayedDuration();
|
long refreshedDisplayedTbrDuration = scripter.readDisplayedDuration();
|
||||||
if (displayedDuration != refreshedDisplayedTbrDuration) {
|
if (displayedDuration != refreshedDisplayedTbrDuration) {
|
||||||
|
|
|
@ -70,6 +70,7 @@ public class BolusActivity extends ViewSelectorActivity {
|
||||||
if (editInsulin != null){
|
if (editInsulin != null){
|
||||||
def = SafeParse.stringToDouble(editInsulin.editText.getText().toString());
|
def = SafeParse.stringToDouble(editInsulin.editText.getText().toString());
|
||||||
}
|
}
|
||||||
|
// TODO use pump supported stet size
|
||||||
editInsulin = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 30d, 0.1d, new DecimalFormat("#0.0"), false);
|
editInsulin = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 30d, 0.1d, new DecimalFormat("#0.0"), false);
|
||||||
setLabelToPlusMinusView(view, "insulin");
|
setLabelToPlusMinusView(view, "insulin");
|
||||||
container.addView(view);
|
container.addView(view);
|
||||||
|
|
Loading…
Reference in a new issue