Cleanups.

This commit is contained in:
Johannes Mockenhaupt 2017-11-13 22:55:48 +01:00
parent b99513aafb
commit 21a2c688c6
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
7 changed files with 28 additions and 52 deletions

View file

@ -12,10 +12,10 @@
- [ ] Reading history - [ ] Reading history
- [x] Bolus - [x] Bolus
- [x] Read - [x] Read
- [x] Sync DB - [x] Update DB
- [ ] TBRs - [ ] TBRs
- [x] Read - [x] Read
- [x] Sync DB - [x] Update DB
- [ ] Issue of creating TBR start date from main menu time, which might be off by a minute - [ ] Issue of creating TBR start date from main menu time, which might be off by a minute
when we read it as a history record. End date time might be slightly off, unless when we read it as a history record. End date time might be slightly off, unless
CancelTempBasal is updated to read from history (probably not worth it). CancelTempBasal is updated to read from history (probably not worth it).
@ -26,13 +26,13 @@
from 59.9999 to 0) from 59.9999 to 0)
- [ ] Alerts - [ ] Alerts
- [x] Read - [x] Read
- [ ] Sync DB? No, but raise an alert if new ones are found beyond those read at startup - [ ] Update DB? No, but raise an alert if new ones are found beyond those read at startup
(Those that occurred while AAPS was not active needn't be turned into alarms, (Those that occurred while AAPS was not active needn't be turned into alarms,
the user had to deal with them on the pump already). the user had to deal with them on the pump already).
- [x] Display in UI - [x] Display in UI
- [ ] TDD - [x] TDD
- [x] Read - [x] Read
- [ ] Sync DB? - [x] Update DB? No, just write to plugin cache
- [x] Display in UI - [x] Display in UI
- [ ] Taking over alerts - [ ] Taking over alerts
- [ ] On connect - [ ] On connect

View file

@ -49,6 +49,10 @@
by AAPS and result in the pump's time being updated the next time communication by AAPS and result in the pump's time being updated the next time communication
with the pump takes place, so disabling automatic time updates on the phone and with the pump takes place, so disabling automatic time updates on the phone and
changing the phone clock manually should allow testing this changing the phone clock manually should allow testing this
- [ ] XXX test year change, reading history
Set phone time to 31.12, 23:55, press Refresh in Combo tab to sync time to pump,
enter bolus
- [ ] XXX daylight saving time changes (2am twice)
- [ ] Disconnected pump - [ ] Disconnected pump
... ...
- [ ] Refilling cartridge - [ ] Refilling cartridge

View file

@ -277,7 +277,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
} }
// ComboFragment updates state fully only after the pump has initialized, // ComboFragment updates state fully only after the pump has initialized,
// this fetches state again and updates the ui proper // this fetches state again and updates the UI proper
runCommand(null, 0, ruffyScripter::readPumpState); runCommand(null, 0, ruffyScripter::readPumpState);
} }

View file

@ -219,7 +219,7 @@ public class RuffyScripter implements RuffyCommands {
while (menuType != MenuType.MAIN_MENU && menuType != MenuType.STOP && menuType != MenuType.WARNING_OR_ERROR) { while (menuType != MenuType.MAIN_MENU && menuType != MenuType.STOP && menuType != MenuType.WARNING_OR_ERROR) {
log.debug("Going back to main menu, currently at " + menuType); log.debug("Going back to main menu, currently at " + menuType);
pressBackKey(); pressBackKey();
waitForMenuUpdate(); waitForScreenUpdate();
menuType = getCurrentMenu().getType(); menuType = getCurrentMenu().getType();
} }
} }
@ -570,42 +570,22 @@ public class RuffyScripter implements RuffyCommands {
} }
} }
// TODO sort out usages of this method and waitForMenu update, which have the same intent, /**
// but approach things differently; * Wait until the menu is updated
private void waitForScreenUpdate() { */
public void waitForScreenUpdate() {
if (Thread.currentThread().isInterrupted()) if (Thread.currentThread().isInterrupted())
throw new CommandException("Interrupted"); throw new CommandException("Interrupted");
synchronized (screenlock) { synchronized (screenlock) {
try { try {
screenlock.wait((long) 2000); // updates usually come in every ~500, occasionally up to 1100ms // updates usually come in every ~500, occasionally up to 1100ms
screenlock.wait((long) 2000);
} catch (InterruptedException e) { } catch (InterruptedException e) {
throw new CommandException("Interrupted"); throw new CommandException("Interrupted");
} }
} }
} }
// TODO v2, rework these two methods: waitForMenuUpdate shoud only be used by commands
// then anything longer than a few seconds is an error;
// only ensureConnected() uses the method with the timeout parameter; inline that code,
// so we can use a custom timeout and give a better error message in case of failure
// TODO confirmAlarms? and report back which were cancelled?
/**
* Wait until the menu is updated
*/
public void waitForMenuUpdate() {
waitForScreenUpdate();
// long timeoutExpired = System.currentTimeMillis() + 60 * 1000;
// long initialUpdateTime = menuLastUpdated;
// while (initialUpdateTime == menuLastUpdated) {
// if (System.currentTimeMillis() > timeoutExpired) {
// throw new CommandException("Timeout waiting for menu update");
// }
// SystemClock.sleep(10);
// }
}
private void pressKey(final byte key) { private void pressKey(final byte key) {
if (Thread.currentThread().isInterrupted()) if (Thread.currentThread().isInterrupted())
throw new CommandException("Interrupted"); throw new CommandException("Interrupted");
@ -619,25 +599,17 @@ public class RuffyScripter implements RuffyCommands {
} }
public void navigateToMenu(MenuType desiredMenu) { public void navigateToMenu(MenuType desiredMenu) {
// MenuType startedFrom = getCurrentMenu().getType(); int moviesLeft = 20;
// boolean movedOnce = false;
int retries = 20;
while (getCurrentMenu().getType() != desiredMenu) { while (getCurrentMenu().getType() != desiredMenu) {
retries--; moviesLeft--;
MenuType currentMenuType = getCurrentMenu().getType(); MenuType currentMenuType = getCurrentMenu().getType();
log.debug("Navigating to menu " + desiredMenu + ", current menu: " + currentMenuType); log.debug("Navigating to menu " + desiredMenu + ", current menu: " + currentMenuType);
// if (movedOnce && currentMenuType == startedFrom) { if (moviesLeft == 0) {
// throw new CommandException().message("Menu not found searching for " + desiredMenu
// + ". Check menu settings on your pump to ensure it's not hidden.");
// }
if (retries == 0) {
throw new CommandException("Menu not found searching for " + desiredMenu throw new CommandException("Menu not found searching for " + desiredMenu
+ ". Check menu settings on your pump to ensure it's not hidden."); + ". Check menu settings on your pump to ensure it's not hidden.");
} }
pressMenuKey(); pressMenuKey();
// waitForMenuToBeLeft(currentMenuType); waitForScreenUpdate();
SystemClock.sleep(200);
// movedOnce = true;
} }
} }

View file

@ -161,7 +161,7 @@ public class BolusCommand extends BaseCommand {
scripter.navigateToMenu(MenuType.BOLUS_MENU); scripter.navigateToMenu(MenuType.BOLUS_MENU);
scripter.verifyMenuIsDisplayed(MenuType.BOLUS_MENU); scripter.verifyMenuIsDisplayed(MenuType.BOLUS_MENU);
scripter.pressCheckKey(); scripter.pressCheckKey();
scripter.waitForMenuUpdate(); scripter.waitForScreenUpdate();
scripter.verifyMenuIsDisplayed(MenuType.BOLUS_ENTER); scripter.verifyMenuIsDisplayed(MenuType.BOLUS_ENTER);
} }

View file

@ -149,7 +149,7 @@ public class ReadHistoryCommand extends BaseCommand {
break; break;
} }
scripter.pressDownKey(); scripter.pressDownKey();
scripter.waitForMenuUpdate(); scripter.waitForScreenUpdate();
record = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD); record = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD);
} }
} }
@ -185,7 +185,7 @@ public class ReadHistoryCommand extends BaseCommand {
break; break;
} }
scripter.pressDownKey(); scripter.pressDownKey();
scripter.waitForMenuUpdate(); scripter.waitForScreenUpdate();
record = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD); record = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD);
} }
} }
@ -215,7 +215,7 @@ public class ReadHistoryCommand extends BaseCommand {
break; break;
} }
scripter.pressDownKey(); scripter.pressDownKey();
scripter.waitForMenuUpdate(); scripter.waitForScreenUpdate();
record = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD); record = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD);
} }
} }
@ -245,7 +245,7 @@ public class ReadHistoryCommand extends BaseCommand {
break; break;
} }
scripter.pressDownKey(); scripter.pressDownKey();
scripter.waitForMenuUpdate(); scripter.waitForScreenUpdate();
record = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD); record = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD);
} }
} }

View file

@ -70,7 +70,7 @@ public class SetTbrCommand extends BaseCommand {
// switch to TBR_DURATION menu by pressing menu key // switch to TBR_DURATION menu by pressing menu key
scripter.verifyMenuIsDisplayed(MenuType.TBR_SET); scripter.verifyMenuIsDisplayed(MenuType.TBR_SET);
scripter.pressMenuKey(); scripter.pressMenuKey();
scripter.waitForMenuUpdate(); scripter.waitForScreenUpdate();
scripter.verifyMenuIsDisplayed(MenuType.TBR_DURATION); scripter.verifyMenuIsDisplayed(MenuType.TBR_DURATION);
boolean increasingDuration = inputTbrDuration(); boolean increasingDuration = inputTbrDuration();
@ -88,7 +88,7 @@ public class SetTbrCommand extends BaseCommand {
scripter.navigateToMenu(MenuType.TBR_MENU); scripter.navigateToMenu(MenuType.TBR_MENU);
scripter.verifyMenuIsDisplayed(MenuType.TBR_MENU); scripter.verifyMenuIsDisplayed(MenuType.TBR_MENU);
scripter.pressCheckKey(); scripter.pressCheckKey();
scripter.waitForMenuUpdate(); scripter.waitForScreenUpdate();
scripter.verifyMenuIsDisplayed(MenuType.TBR_SET); scripter.verifyMenuIsDisplayed(MenuType.TBR_SET);
} }