From bd353a704315ead563fe8261e1c67b72911c2b88 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Thu, 27 Jul 2017 13:39:23 +0200 Subject: [PATCH 1/2] BolusCommand: confirm via My Data history the correct amount was delivered. --- .../ruffyscripter/commands/BolusCommand.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/app/src/main/java/de/jotomo/ruffyscripter/commands/BolusCommand.java b/app/src/main/java/de/jotomo/ruffyscripter/commands/BolusCommand.java index ae3aed3899..edc8b3abe5 100644 --- a/app/src/main/java/de/jotomo/ruffyscripter/commands/BolusCommand.java +++ b/app/src/main/java/de/jotomo/ruffyscripter/commands/BolusCommand.java @@ -70,6 +70,35 @@ public class BolusCommand implements Command { "Bolus delivery did not complete as expected. " + "Check pump manually, the bolus might not have been delivered."); + // read last bolus record; those menus display static data and therefore + // only a single menu update is sent + scripter.navigateToMenu(MenuType.MY_DATA_MENU); + scripter.verifyMenuIsDisplayed(MenuType.MY_DATA_MENU); + scripter.pressCheckKey(); + if (scripter.currentMenu.getType() != MenuType.BOLUS_DATA) { + scripter.waitForMenuUpdate(); + } + + if (!scripter.currentMenu.attributes().contains(MenuAttribute.BOLUS)) { + throw new CommandException().success(false).enacted(true) + .message("Bolus was delivered, but enable to confirm it with history record"); + } + + double lastBolusInHistory = (double) scripter.currentMenu.getAttribute(MenuAttribute.BOLUS); + if (Math.abs(bolus - lastBolusInHistory) > 0.05) { + throw new CommandException().success(false).enacted(true) + .message("Last bolus shows " + lastBolusInHistory + + " U delievered, but " + bolus + " U were requested"); + } + log.debug("Bolus record in history confirms delivered bolus"); + + // leave menu to go back to main menu + scripter.pressCheckKey(); + scripter.waitForMenuToBeLeft(MenuType.BOLUS_DATA); + scripter.verifyMenuIsDisplayed(MenuType.MAIN_MENU, + "Bolus was correctly delivered and checked against history, but we " + + "did not return the main menu successfully."); + return new CommandResult().success(true).enacted(true) .message(String.format(Locale.US, "Delivered %02.1f U", bolus)); } catch (CommandException e) { From 17b0e7d71a12cfe3f1617eea581cd72e91e02762 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Thu, 27 Jul 2017 14:35:56 +0200 Subject: [PATCH 2/2] Fix some typos. --- .../ruffyscripter/commands/BolusCommand.java | 2 +- .../ruffyscripter/commands/SetTbrCommand.java | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/de/jotomo/ruffyscripter/commands/BolusCommand.java b/app/src/main/java/de/jotomo/ruffyscripter/commands/BolusCommand.java index edc8b3abe5..d5197452e3 100644 --- a/app/src/main/java/de/jotomo/ruffyscripter/commands/BolusCommand.java +++ b/app/src/main/java/de/jotomo/ruffyscripter/commands/BolusCommand.java @@ -81,7 +81,7 @@ public class BolusCommand implements Command { if (!scripter.currentMenu.attributes().contains(MenuAttribute.BOLUS)) { throw new CommandException().success(false).enacted(true) - .message("Bolus was delivered, but enable to confirm it with history record"); + .message("Bolus was delivered, but unable to confirm it with history record"); } double lastBolusInHistory = (double) scripter.currentMenu.getAttribute(MenuAttribute.BOLUS); diff --git a/app/src/main/java/de/jotomo/ruffyscripter/commands/SetTbrCommand.java b/app/src/main/java/de/jotomo/ruffyscripter/commands/SetTbrCommand.java index fe4ad3c65a..4ffd154acf 100644 --- a/app/src/main/java/de/jotomo/ruffyscripter/commands/SetTbrCommand.java +++ b/app/src/main/java/de/jotomo/ruffyscripter/commands/SetTbrCommand.java @@ -234,14 +234,14 @@ public class SetTbrCommand implements Command { // A "TBR CANCELLED alert" is only raised by the pump when the remaining time is // greater than 60s (displayed as 0:01, the pump goes from there to finished. // We could read the remaining duration from MAIN_MENU, but by the time we're here, - // the pmup could have moved from 0:02 to 0:01, so instead, check if a "TBR CANCELLED alert" + // the pumup could have moved from 0:02 to 0:01, so instead, check if a "TBR CANCELLED" alert // is raised and if so dismiss it - long inTwoSeconds = System.currentTimeMillis() + 5 * 1000; + long inFiveSeconds = System.currentTimeMillis() + 5 * 1000; boolean alertProcessed = false; - while (System.currentTimeMillis() < inTwoSeconds && !alertProcessed) { + while (System.currentTimeMillis() < inFiveSeconds && !alertProcessed) { if (scripter.currentMenu.getType() == MenuType.WARNING_OR_ERROR) { - // Check the raised alarm is TBR CANCELLED, so we're not accidentally cancelled - // a different that might be raised at the same time. + // Check the raised alarm is TBR CANCELLED, so we're not accidentally cancelling + // a different alarm that might be raised at the same time. // Note that the message is permanently displayed, while the error code is blinking. // A wait till the error code can be read results in the code hanging, despite // menu updates coming in, so just check the message. @@ -252,10 +252,10 @@ public class SetTbrCommand implements Command { .message("An alert other than the expected TBR CANCELLED was raised by the pump: " + errorMsg + ". Please check the pump."); } - // confirm "TBR CANCELLED alert" + // confirm "TBR CANCELLED" alert scripter.verifyMenuIsDisplayed(MenuType.WARNING_OR_ERROR); scripter.pressCheckKey(); - // dismiss "TBR CANCELLED alert" + // dismiss "TBR CANCELLED" alert scripter.verifyMenuIsDisplayed(MenuType.WARNING_OR_ERROR); scripter.pressCheckKey(); scripter.waitForMenuToBeLeft(MenuType.WARNING_OR_ERROR);