Cleanups.
This commit is contained in:
parent
b99513aafb
commit
21a2c688c6
7 changed files with 28 additions and 52 deletions
|
@ -12,10 +12,10 @@
|
|||
- [ ] Reading history
|
||||
- [x] Bolus
|
||||
- [x] Read
|
||||
- [x] Sync DB
|
||||
- [x] Update DB
|
||||
- [ ] TBRs
|
||||
- [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
|
||||
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).
|
||||
|
@ -26,13 +26,13 @@
|
|||
from 59.9999 to 0)
|
||||
- [ ] Alerts
|
||||
- [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,
|
||||
the user had to deal with them on the pump already).
|
||||
- [x] Display in UI
|
||||
- [ ] TDD
|
||||
- [x] TDD
|
||||
- [x] Read
|
||||
- [ ] Sync DB?
|
||||
- [x] Update DB? No, just write to plugin cache
|
||||
- [x] Display in UI
|
||||
- [ ] Taking over alerts
|
||||
- [ ] On connect
|
||||
|
|
|
@ -49,6 +49,10 @@
|
|||
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
|
||||
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
|
||||
...
|
||||
- [ ] Refilling cartridge
|
||||
|
|
|
@ -277,7 +277,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
|||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
|
|
@ -219,7 +219,7 @@ public class RuffyScripter implements RuffyCommands {
|
|||
while (menuType != MenuType.MAIN_MENU && menuType != MenuType.STOP && menuType != MenuType.WARNING_OR_ERROR) {
|
||||
log.debug("Going back to main menu, currently at " + menuType);
|
||||
pressBackKey();
|
||||
waitForMenuUpdate();
|
||||
waitForScreenUpdate();
|
||||
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;
|
||||
private void waitForScreenUpdate() {
|
||||
/**
|
||||
* Wait until the menu is updated
|
||||
*/
|
||||
public void waitForScreenUpdate() {
|
||||
if (Thread.currentThread().isInterrupted())
|
||||
throw new CommandException("Interrupted");
|
||||
synchronized (screenlock) {
|
||||
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) {
|
||||
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) {
|
||||
if (Thread.currentThread().isInterrupted())
|
||||
throw new CommandException("Interrupted");
|
||||
|
@ -619,25 +599,17 @@ public class RuffyScripter implements RuffyCommands {
|
|||
}
|
||||
|
||||
public void navigateToMenu(MenuType desiredMenu) {
|
||||
// MenuType startedFrom = getCurrentMenu().getType();
|
||||
// boolean movedOnce = false;
|
||||
int retries = 20;
|
||||
int moviesLeft = 20;
|
||||
while (getCurrentMenu().getType() != desiredMenu) {
|
||||
retries--;
|
||||
moviesLeft--;
|
||||
MenuType currentMenuType = getCurrentMenu().getType();
|
||||
log.debug("Navigating to menu " + desiredMenu + ", current menu: " + currentMenuType);
|
||||
// if (movedOnce && currentMenuType == startedFrom) {
|
||||
// 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) {
|
||||
if (moviesLeft == 0) {
|
||||
throw new CommandException("Menu not found searching for " + desiredMenu
|
||||
+ ". Check menu settings on your pump to ensure it's not hidden.");
|
||||
}
|
||||
pressMenuKey();
|
||||
// waitForMenuToBeLeft(currentMenuType);
|
||||
SystemClock.sleep(200);
|
||||
// movedOnce = true;
|
||||
waitForScreenUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -161,7 +161,7 @@ public class BolusCommand extends BaseCommand {
|
|||
scripter.navigateToMenu(MenuType.BOLUS_MENU);
|
||||
scripter.verifyMenuIsDisplayed(MenuType.BOLUS_MENU);
|
||||
scripter.pressCheckKey();
|
||||
scripter.waitForMenuUpdate();
|
||||
scripter.waitForScreenUpdate();
|
||||
scripter.verifyMenuIsDisplayed(MenuType.BOLUS_ENTER);
|
||||
}
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@ public class ReadHistoryCommand extends BaseCommand {
|
|||
break;
|
||||
}
|
||||
scripter.pressDownKey();
|
||||
scripter.waitForMenuUpdate();
|
||||
scripter.waitForScreenUpdate();
|
||||
record = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD);
|
||||
}
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ public class ReadHistoryCommand extends BaseCommand {
|
|||
break;
|
||||
}
|
||||
scripter.pressDownKey();
|
||||
scripter.waitForMenuUpdate();
|
||||
scripter.waitForScreenUpdate();
|
||||
record = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD);
|
||||
}
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ public class ReadHistoryCommand extends BaseCommand {
|
|||
break;
|
||||
}
|
||||
scripter.pressDownKey();
|
||||
scripter.waitForMenuUpdate();
|
||||
scripter.waitForScreenUpdate();
|
||||
record = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD);
|
||||
}
|
||||
}
|
||||
|
@ -245,7 +245,7 @@ public class ReadHistoryCommand extends BaseCommand {
|
|||
break;
|
||||
}
|
||||
scripter.pressDownKey();
|
||||
scripter.waitForMenuUpdate();
|
||||
scripter.waitForScreenUpdate();
|
||||
record = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ public class SetTbrCommand extends BaseCommand {
|
|||
// switch to TBR_DURATION menu by pressing menu key
|
||||
scripter.verifyMenuIsDisplayed(MenuType.TBR_SET);
|
||||
scripter.pressMenuKey();
|
||||
scripter.waitForMenuUpdate();
|
||||
scripter.waitForScreenUpdate();
|
||||
scripter.verifyMenuIsDisplayed(MenuType.TBR_DURATION);
|
||||
|
||||
boolean increasingDuration = inputTbrDuration();
|
||||
|
@ -88,7 +88,7 @@ public class SetTbrCommand extends BaseCommand {
|
|||
scripter.navigateToMenu(MenuType.TBR_MENU);
|
||||
scripter.verifyMenuIsDisplayed(MenuType.TBR_MENU);
|
||||
scripter.pressCheckKey();
|
||||
scripter.waitForMenuUpdate();
|
||||
scripter.waitForScreenUpdate();
|
||||
scripter.verifyMenuIsDisplayed(MenuType.TBR_SET);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue