Recover after command failure by returning to pump main menu, so
subsequent commands won't fail.
This commit is contained in:
parent
e27730229e
commit
7c662345ae
|
@ -340,11 +340,16 @@ public class RuffyScripter implements RuffyCommands {
|
||||||
// TOD under which circumstances can these occur?
|
// TOD under which circumstances can these occur?
|
||||||
} catch (CommandException e) {
|
} catch (CommandException e) {
|
||||||
log.error("CommandException while executing command", e);
|
log.error("CommandException while executing command", e);
|
||||||
|
recoverFromCommandFailure();
|
||||||
return activeCmd.getResult().success(false).state(readPumpStateInternal());
|
return activeCmd.getResult().success(false).state(readPumpStateInternal());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Unexpected exception communication with ruffy", e);
|
log.error("Unexpected exception communication with ruffy", e);
|
||||||
|
recoverFromCommandFailure();
|
||||||
return activeCmd.getResult().success(false).exception(e).state(readPumpStateInternal());
|
return activeCmd.getResult().success(false).exception(e).state(readPumpStateInternal());
|
||||||
} finally {
|
} finally {
|
||||||
|
if (activeCmd.getResult().success) {
|
||||||
|
log.warn("Command " + activeCmd + " successful, but finished leaving pump on menu " + getCurrentMenuName());
|
||||||
|
}
|
||||||
activeCmd = null;
|
activeCmd = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -399,6 +404,23 @@ public class RuffyScripter implements RuffyCommands {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Returns to the main menu (if possible) after a command failure, so that subsequent commands
|
||||||
|
* reusing the connection won't fail. */
|
||||||
|
private void recoverFromCommandFailure() {
|
||||||
|
Menu menu = this.currentMenu;
|
||||||
|
if (menu == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MenuType type = menu.getType();
|
||||||
|
if (type != MenuType.WARNING_OR_ERROR && type != MenuType.MAIN_MENU) {
|
||||||
|
try {
|
||||||
|
returnToRootMenu();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("Error returning to main menu, when trying to recover from command failure", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** If there's an issue, this times out eventually and throws a CommandException */
|
/** If there's an issue, this times out eventually and throws a CommandException */
|
||||||
private void ensureConnected() {
|
private void ensureConnected() {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue