Better error message on connect attempt failure.
This commit is contained in:
parent
52d2b425b8
commit
fdf974cb3c
1 changed files with 10 additions and 4 deletions
|
@ -399,7 +399,9 @@ public class RuffyScripter {
|
||||||
// if the user just pressed a button on the combo, the screen needs to time first
|
// if the user just pressed a button on the combo, the screen needs to time first
|
||||||
// before a connection is possible. In that case, it takes 45s before the
|
// before a connection is possible. In that case, it takes 45s before the
|
||||||
// connection comes up.
|
// connection comes up.
|
||||||
waitForMenuUpdate(90);
|
waitForMenuUpdate(90, "Timeout connecting to pump");
|
||||||
|
} catch (CommandException e) {
|
||||||
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new CommandException().exception(e).message("Unexpected exception while initiating/restoring pump connection");
|
throw new CommandException().exception(e).message("Unexpected exception while initiating/restoring pump connection");
|
||||||
}
|
}
|
||||||
|
@ -505,16 +507,17 @@ public class RuffyScripter {
|
||||||
/**
|
/**
|
||||||
* Wait until the menu update is in
|
* Wait until the menu update is in
|
||||||
*/
|
*/
|
||||||
|
// TODO donn't use this in ensureConnected
|
||||||
public void waitForMenuUpdate() {
|
public void waitForMenuUpdate() {
|
||||||
waitForMenuUpdate(60);
|
waitForMenuUpdate(60, "Timeout waiting for menu update");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void waitForMenuUpdate(long timeoutInSeconds) {
|
public void waitForMenuUpdate(long timeoutInSeconds, String errorMessage) {
|
||||||
long timeoutExpired = System.currentTimeMillis() + timeoutInSeconds * 1000;
|
long timeoutExpired = System.currentTimeMillis() + timeoutInSeconds * 1000;
|
||||||
long initialUpdateTime = menuLastUpdated;
|
long initialUpdateTime = menuLastUpdated;
|
||||||
while (initialUpdateTime == menuLastUpdated) {
|
while (initialUpdateTime == menuLastUpdated) {
|
||||||
if (System.currentTimeMillis() > timeoutExpired) {
|
if (System.currentTimeMillis() > timeoutExpired) {
|
||||||
throw new CommandException().message("Timeout waiting for menu update");
|
throw new CommandException().message(errorMessage);
|
||||||
}
|
}
|
||||||
SystemClock.sleep(50);
|
SystemClock.sleep(50);
|
||||||
}
|
}
|
||||||
|
@ -589,6 +592,9 @@ public class RuffyScripter {
|
||||||
|
|
||||||
// TODO v2 add remaining info we can extract from the main menu, low battery and low
|
// TODO v2 add remaining info we can extract from the main menu, low battery and low
|
||||||
// cartridge warnings, running extended bolus (how does that look if a TBR is active as well?)
|
// cartridge warnings, running extended bolus (how does that look if a TBR is active as well?)
|
||||||
|
|
||||||
|
/** This reads the state of the, which is whatever is currently displayed on the display,
|
||||||
|
* no actions are performed. */
|
||||||
private PumpState readPumpState() {
|
private PumpState readPumpState() {
|
||||||
PumpState state = new PumpState();
|
PumpState state = new PumpState();
|
||||||
Menu menu = currentMenu;
|
Menu menu = currentMenu;
|
||||||
|
|
Loading…
Reference in a new issue