Make cancelling TBR more robust to dismiss TBR cancelled alert specifially and only if it is raised.

Cancelling a TBR with a runtime < 60s (0:01 in the display) does NOT raise a TBR cancelled alert.
This commit is contained in:
Johannes Mockenhaupt 2017-07-15 14:46:58 +02:00
parent 2c706e7c22
commit d8011aeaa4
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1

View file

@ -185,38 +185,35 @@ public class SetTbrCommand implements Command {
} }
private void cancelTbrAndConfirmCancellationWarning(RuffyScripter scripter) { private void cancelTbrAndConfirmCancellationWarning(RuffyScripter scripter) {
// TODO tbr with 1m remaining doesn't raise an alert;
// BT connection is NOT lost when an alarm is raised, see if we can improve checking for
// and acknowleding errors;
// i think timing is crucial: waiting too long and the pump display activates and we lose
// connection. we can reconnect, but by then the pump might be noisy already.
// confirm entered TBR // confirm entered TBR
scripter.pressCheckKey(); scripter.pressCheckKey();
scripter.waitForMenuUpdate();
// hm, waiting here (more) makes things worse, if we don't press the alert away quickly, // we could read remaining duration from MAIN_MENU, but but the time we're here,
// the pump exits BT mode ... so I guess we'll live with the checks below, // we could have moved from 0:02 to 0:01, so instead,/ check if a TBR CANCELLED alert
// verifying we made it back to the main menu and the displayed TBR data // is raised and if so dismiss it
// corresponds to what we set. Hope the timing is stable enough ... scripter.waitForMenuToBeLeft(MenuType.TBR_SET);
long inTwoSeconds = System.currentTimeMillis() + 2 * 1000;
/* scripter.waitForMenuToBeLeft(MenuType.TBR_SET); boolean alertProcessed = false;
if (scripter.currentMenu.getType() != MenuType.MAIN_MENU) { while (System.currentTimeMillis() < inTwoSeconds && !alertProcessed) {
// pump shortly enters the main menu before raising the alert if (scripter.currentMenu.getType() == MenuType.WARNING_OR_ERROR) {
// TODO is this always entered? // check the raised alarm is TBR CANCELLED
log.debug("TBR cancelled, going over main menu"); int errorCode = (int) scripter.currentMenu.getAttribute(MenuAttribute.ERROR);
scripter.waitForMenuToBeLeft(MenuType.MAIN_MENU); String errorMsg = (String) scripter.currentMenu.getAttribute(MenuAttribute.MESSAGE);
if (errorCode != 6 || errorMsg.equals("TBR CANCELLED")) {
throw new CommandException().success(false).enacted(false)
.message("An alert other than the expected TBR CANCELLED was raised by the pump: "
+ errorMsg + "(" + errorCode + "). Please check the pump.");
} }
if (scripter.currentMenu.getType() != MenuType.WARNING_OR_ERROR) { // confirm "TBR CANCELLED alert"
throw new CommandException(false, null, "Expected WARNING_OR_ERROR menu was not shown when cancelling TBR");
}*/
// confirm "TBR cancelled alert"
scripter.pressCheckKey(); scripter.pressCheckKey();
SystemClock.sleep(200); SystemClock.sleep(200);
// dismiss "TBR cancelled alert" // dismiss "TBR CANCELLED alert"
scripter.pressCheckKey(); scripter.pressCheckKey();
scripter.waitForMenuToBeLeft(MenuType.WARNING_OR_ERROR); scripter.waitForMenuToBeLeft(MenuType.WARNING_OR_ERROR);
alertProcessed = true;
}
SystemClock.sleep(50);
}
} }
private void verifyMainMenuShowsNoActiveTbr(RuffyScripter scripter) { private void verifyMainMenuShowsNoActiveTbr(RuffyScripter scripter) {