RuffyScripter.waitForMenuToBeLeft: add timeout.
This commit is contained in:
parent
77711b2174
commit
952aa0e8a2
1 changed files with 6 additions and 2 deletions
|
@ -99,7 +99,7 @@ public class RuffyScripter {
|
||||||
};
|
};
|
||||||
|
|
||||||
public boolean isPumpBusy() {
|
public boolean isPumpBusy() {
|
||||||
return activeCmd != null; // || currentMenu == null || currentMenu.getType() != MenuType.MAIN_MENU;
|
return activeCmd != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private volatile Command activeCmd = null;
|
private volatile Command activeCmd = null;
|
||||||
|
@ -287,8 +287,12 @@ public class RuffyScripter {
|
||||||
* Wait till a menu changed has completed, "away" from the menu provided as argument.
|
* Wait till a menu changed has completed, "away" from the menu provided as argument.
|
||||||
*/
|
*/
|
||||||
public void waitForMenuToBeLeft(MenuType menuType) {
|
public void waitForMenuToBeLeft(MenuType menuType) {
|
||||||
|
long timeout = System.currentTimeMillis() + 30 * 1000;
|
||||||
while (currentMenu.getType() == menuType) {
|
while (currentMenu.getType() == menuType) {
|
||||||
SystemClock.sleep(250);
|
if (System.currentTimeMillis() > timeout) {
|
||||||
|
throw new CommandException().message("Timeout waiting for menu " + menuType + " to be left");
|
||||||
|
}
|
||||||
|
SystemClock.sleep(50);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue