Misc cleanups.

This commit is contained in:
Johannes Mockenhaupt 2017-08-23 22:10:19 +02:00
parent 5eea6d7b8d
commit eb74a24e54
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
7 changed files with 67 additions and 74 deletions

View file

@ -36,7 +36,7 @@ public class RuffyScripter {
private IRuffyService ruffyService; private IRuffyService ruffyService;
private String unrecoverableError = null; private String unrecoverableError = null;
public volatile Menu currentMenu; private volatile Menu currentMenu;
private volatile long menuLastUpdated = 0; private volatile long menuLastUpdated = 0;
private volatile long lastCmdExecutionTime; private volatile long lastCmdExecutionTime;
@ -49,10 +49,6 @@ public class RuffyScripter {
private final Object screenlock = new Object(); private final Object screenlock = new Object();
public RuffyScripter() {
}
public void start(IRuffyService newService) { public void start(IRuffyService newService) {
try { try {
if (ruffyService != null) { if (ruffyService != null) {
@ -72,23 +68,11 @@ public class RuffyScripter {
newService.addHandler(mHandler); newService.addHandler(mHandler);
} }
} catch (Exception e) { } catch (Exception e) {
log.error("Unhandled exception starting RuffyScripter", e);
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
public void stop() {
if (started) {
started = false;
// TODO ruffy removes dead handlers automatically by now.
// still, check this when going through recovery logic
/* try {
ruffyService.removeHandler(mHandler);
} catch (RemoteException e) {
log.warn("Removing IRTHandler from Ruffy service failed, ignoring", e);
}*/
}
}
public boolean isRunning() { public boolean isRunning() {
return started; return started;
} }
@ -234,6 +218,10 @@ public class RuffyScripter {
this.ruffyService = null; this.ruffyService = null;
} }
public Menu getCurrentMenu() {
return currentMenu;
}
private static class Returnable { private static class Returnable {
CommandResult cmdResult; CommandResult cmdResult;
} }

View file

@ -11,8 +11,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import de.jotomo.ruffyscripter.RuffyScripter;
public class BolusCommand extends BaseCommand { public class BolusCommand extends BaseCommand {
private static final Logger log = LoggerFactory.getLogger(BolusCommand.class); private static final Logger log = LoggerFactory.getLogger(BolusCommand.class);
@ -54,11 +52,11 @@ public class BolusCommand extends BaseCommand {
// wait for bolus delivery to complete; the remaining units to deliver are counted // wait for bolus delivery to complete; the remaining units to deliver are counted
// down and are displayed on the main menu. // down and are displayed on the main menu.
Double bolusRemaining = (Double) scripter.currentMenu.getAttribute(MenuAttribute.BOLUS_REMAINING); Double bolusRemaining = (Double) scripter.getCurrentMenu().getAttribute(MenuAttribute.BOLUS_REMAINING);
while (bolusRemaining != null) { while (bolusRemaining != null) {
log.debug("Delivering bolus, remaining: " + bolusRemaining); log.debug("Delivering bolus, remaining: " + bolusRemaining);
SystemClock.sleep(200); SystemClock.sleep(200);
bolusRemaining = (Double) scripter.currentMenu.getAttribute(MenuAttribute.BOLUS_REMAINING); bolusRemaining = (Double) scripter.getCurrentMenu().getAttribute(MenuAttribute.BOLUS_REMAINING);
} }
// TODO what if we hit 'cartridge low' alert here? is it immediately displayed or after the bolus? // TODO what if we hit 'cartridge low' alert here? is it immediately displayed or after the bolus?
@ -74,16 +72,16 @@ public class BolusCommand extends BaseCommand {
scripter.navigateToMenu(MenuType.MY_DATA_MENU); scripter.navigateToMenu(MenuType.MY_DATA_MENU);
scripter.verifyMenuIsDisplayed(MenuType.MY_DATA_MENU); scripter.verifyMenuIsDisplayed(MenuType.MY_DATA_MENU);
scripter.pressCheckKey(); scripter.pressCheckKey();
if (scripter.currentMenu.getType() != MenuType.BOLUS_DATA) { if (scripter.getCurrentMenu().getType() != MenuType.BOLUS_DATA) {
scripter.waitForMenuUpdate(); scripter.waitForMenuUpdate();
} }
if (!scripter.currentMenu.attributes().contains(MenuAttribute.BOLUS)) { if (!scripter.getCurrentMenu().attributes().contains(MenuAttribute.BOLUS)) {
throw new CommandException().success(false).enacted(true) throw new CommandException().success(false).enacted(true)
.message("Bolus was delivered, but unable 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); double lastBolusInHistory = (double) scripter.getCurrentMenu().getAttribute(MenuAttribute.BOLUS);
if (Math.abs(bolus - lastBolusInHistory) > 0.05) { if (Math.abs(bolus - lastBolusInHistory) > 0.05) {
throw new CommandException().success(false).enacted(true) throw new CommandException().success(false).enacted(true)
.message("Last bolus shows " + lastBolusInHistory .message("Last bolus shows " + lastBolusInHistory

View file

@ -12,7 +12,6 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import de.jotomo.ruffyscripter.PumpCapabilities; import de.jotomo.ruffyscripter.PumpCapabilities;
import de.jotomo.ruffyscripter.RuffyScripter;
public class DetermineCapabilitiesCommand extends BaseCommand { public class DetermineCapabilitiesCommand extends BaseCommand {
@ -123,21 +122,21 @@ public class DetermineCapabilitiesCommand extends BaseCommand {
private long readDisplayedTbrPercentage() { private long readDisplayedTbrPercentage() {
SystemClock.sleep(1000); SystemClock.sleep(1000);
// TODO v2 add timeout? Currently the command execution timeout would trigger if exceeded // TODO v2 add timeout? Currently the command execution timeout would trigger if exceeded
Object percentageObj = scripter.currentMenu.getAttribute(MenuAttribute.BASAL_RATE); Object percentageObj = scripter.getCurrentMenu().getAttribute(MenuAttribute.BASAL_RATE);
// this as a bit hacky, the display value is blinking, so we might catch that, so // this as a bit hacky, the display value is blinking, so we might catch that, so
// keep trying till we get the Double we want // keep trying till we get the Double we want
while (!(percentageObj instanceof Double)) { while (!(percentageObj instanceof Double)) {
scripter.waitForMenuUpdate(); scripter.waitForMenuUpdate();
percentageObj = scripter.currentMenu.getAttribute(MenuAttribute.BASAL_RATE); percentageObj = scripter.getCurrentMenu().getAttribute(MenuAttribute.BASAL_RATE);
} }
return ((Double) percentageObj).longValue(); return ((Double) percentageObj).longValue();
} }
private int readDisplayedTbrDurationMainMenu() { private int readDisplayedTbrDurationMainMenu() {
scripter.verifyMenuIsDisplayed(MenuType.MAIN_MENU); scripter.verifyMenuIsDisplayed(MenuType.MAIN_MENU);
if(scripter.currentMenu.attributes().contains(MenuAttribute.RUNTIME)){ if(scripter.getCurrentMenu().attributes().contains(MenuAttribute.RUNTIME)){
// TODO v2 add timeout? Currently the command execution timeout would trigger if exceeded // TODO v2 add timeout? Currently the command execution timeout would trigger if exceeded
Object durationObj = scripter.currentMenu.getAttribute(MenuAttribute.RUNTIME); Object durationObj = scripter.getCurrentMenu().getAttribute(MenuAttribute.RUNTIME);
MenuTime duration = (MenuTime) durationObj; MenuTime duration = (MenuTime) durationObj;
return duration.getHour() * 60 + duration.getMinute(); return duration.getHour() * 60 + duration.getMinute();
} else { } else {
@ -147,8 +146,8 @@ public class DetermineCapabilitiesCommand extends BaseCommand {
private int readDisplayedTbrPercentageMainMenu() { private int readDisplayedTbrPercentageMainMenu() {
scripter.verifyMenuIsDisplayed(MenuType.MAIN_MENU); scripter.verifyMenuIsDisplayed(MenuType.MAIN_MENU);
if(scripter.currentMenu.attributes().contains(MenuAttribute.TBR)){ if(scripter.getCurrentMenu().attributes().contains(MenuAttribute.TBR)){
return (int)((Double) scripter.currentMenu.getAttribute(MenuAttribute.TBR)).doubleValue(); return (int)((Double) scripter.getCurrentMenu().getAttribute(MenuAttribute.TBR)).doubleValue();
} else { } else {
return 100; return 100;
} }

View file

@ -4,6 +4,7 @@ import org.monkey.d.ruffy.ruffy.driver.display.MenuType;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.TreeSet;
import de.jotomo.ruffyscripter.PumpState; import de.jotomo.ruffyscripter.PumpState;
import de.jotomo.ruffyscripter.RuffyScripter; import de.jotomo.ruffyscripter.RuffyScripter;
@ -68,6 +69,7 @@ public class GetPumpStateCommand extends BaseCommand {
public StepBuilder cancel(Step step) { public StepBuilder cancel(Step step) {
return this; return this;
} }
public StepBuilder failure(Step step) { return this; }
public StepBuilder run() { public StepBuilder run() {
return this; return this;
} }
@ -106,6 +108,12 @@ public class GetPumpStateCommand extends BaseCommand {
.run(); .run();
new StepBuilder("Input bolus") // turn into a method createStep() or so, which has access to the scripter new StepBuilder("Input bolus") // turn into a method createStep() or so, which has access to the scripter
.retries(5) .retries(5)
.failure(new Step() {
@Override
public void doStep() {
System.out.println("retry command");
}
})
.step(new Step() { .step(new Step() {
@Override @Override
public void doStep() { public void doStep() {

View file

@ -61,36 +61,36 @@ public class SetTbrCommand extends BaseCommand {
@Override @Override
public CommandResult execute() { public CommandResult execute() {
try { try {
log.debug("1. going from " + scripter.currentMenu + " to TBR_MENU"); log.debug("1. going from " + scripter.getCurrentMenu() + " to TBR_MENU");
int retries = 5; int retries = 5;
while (!scripter.goToMainTypeScreen(TBR_MENU, 3000)) { while (!scripter.goToMainTypeScreen(TBR_MENU, 3000)) {
retries--; retries--;
if (retries == 0) if (retries == 0)
throw new CommandException().message("not able to find TBR_MENU: stuck in " + scripter.currentMenu); throw new CommandException().message("not able to find TBR_MENU: stuck in " + scripter.getCurrentMenu());
SystemClock.sleep(500); SystemClock.sleep(500);
if (scripter.currentMenu.getType() == TBR_MENU) if (scripter.getCurrentMenu().getType() == TBR_MENU)
break; break;
} }
if (scripter.currentMenu.getType() != TBR_MENU) if (scripter.getCurrentMenu().getType() != TBR_MENU)
throw new CommandException().message("not able to find TBR_MENU: stuck in " + scripter.currentMenu); throw new CommandException().message("not able to find TBR_MENU: stuck in " + scripter.getCurrentMenu());
log.debug("2. entering " + scripter.currentMenu); log.debug("2. entering " + scripter.getCurrentMenu());
retries = 5; retries = 5;
while (!scripter.enterMenu(TBR_MENU, MenuType.TBR_SET, RuffyScripter.Key.CHECK, 2000)) { while (!scripter.enterMenu(TBR_MENU, MenuType.TBR_SET, RuffyScripter.Key.CHECK, 2000)) {
retries--; retries--;
if (retries == 0) if (retries == 0)
throw new CommandException().message("not able to find TBR_SET: stuck in " + scripter.currentMenu); throw new CommandException().message("not able to find TBR_SET: stuck in " + scripter.getCurrentMenu());
SystemClock.sleep(500); SystemClock.sleep(500);
if (scripter.currentMenu.getType() == TBR_SET) if (scripter.getCurrentMenu().getType() == TBR_SET)
break; break;
if (scripter.currentMenu.getType() == TBR_DURATION) { if (scripter.getCurrentMenu().getType() == TBR_DURATION) {
scripter.pressMenuKey(); scripter.pressMenuKey();
scripter.waitForScreenUpdate(1000); scripter.waitForScreenUpdate(1000);
} }
} }
log.debug("SetTbrCommand: 3. getting/setting basal percentage in " + scripter.currentMenu); log.debug("SetTbrCommand: 3. getting/setting basal percentage in " + scripter.getCurrentMenu());
retries = 30; retries = 30;
double currentPercentage = scripter.readBlinkingValue(Double.class, MenuAttribute.BASAL_RATE); double currentPercentage = scripter.readBlinkingValue(Double.class, MenuAttribute.BASAL_RATE);
@ -110,29 +110,29 @@ public class SetTbrCommand extends BaseCommand {
if (currentPercentage < 0 || retries < 0) if (currentPercentage < 0 || retries < 0)
throw new CommandException().message("unable to set basal percentage"); throw new CommandException().message("unable to set basal percentage");
log.debug("4. checking basal percentage in " + scripter.currentMenu); log.debug("4. checking basal percentage in " + scripter.getCurrentMenu());
scripter.waitForScreenUpdate(1000); scripter.waitForScreenUpdate(1000);
currentPercentage = scripter.readBlinkingValue(Double.class, MenuAttribute.BASAL_RATE); currentPercentage = scripter.readBlinkingValue(Double.class, MenuAttribute.BASAL_RATE);
if (currentPercentage != percentage) if (currentPercentage != percentage)
throw new CommandException().message("Unable to set percentage. Requested: " + percentage + ", value displayed on pump: " + currentPercentage); throw new CommandException().message("Unable to set percentage. Requested: " + percentage + ", value displayed on pump: " + currentPercentage);
if (currentPercentage != 100) { if (currentPercentage != 100) {
log.debug("5. change to TBR_DURATION from " + scripter.currentMenu); log.debug("5. change to TBR_DURATION from " + scripter.getCurrentMenu());
retries = 5; retries = 5;
while (retries >= 0 && !scripter.enterMenu(TBR_SET, MenuType.TBR_DURATION, RuffyScripter.Key.MENU, 2000)) { while (retries >= 0 && !scripter.enterMenu(TBR_SET, MenuType.TBR_DURATION, RuffyScripter.Key.MENU, 2000)) {
retries--; retries--;
if (retries == 0) if (retries == 0)
throw new CommandException().message("not able to find TBR_SET: stuck in " + scripter.currentMenu); throw new CommandException().message("not able to find TBR_SET: stuck in " + scripter.getCurrentMenu());
SystemClock.sleep(500); SystemClock.sleep(500);
if (scripter.currentMenu.getType() == TBR_DURATION) if (scripter.getCurrentMenu().getType() == TBR_DURATION)
break; break;
if (scripter.currentMenu.getType() == TBR_SET) { if (scripter.getCurrentMenu().getType() == TBR_SET) {
scripter.pressMenuKey(); scripter.pressMenuKey();
scripter.waitForScreenUpdate(1000); scripter.waitForScreenUpdate(1000);
} }
} }
log.debug("6. getting/setting duration in " + scripter.currentMenu); log.debug("6. getting/setting duration in " + scripter.getCurrentMenu());
retries = 30; retries = 30;
double currentDuration = scripter.readDisplayedDuration(); double currentDuration = scripter.readDisplayedDuration();
@ -156,30 +156,30 @@ public class SetTbrCommand extends BaseCommand {
if (currentDuration < 0 || retries < 0) if (currentDuration < 0 || retries < 0)
throw new CommandException().message("unable to set duration, requested:" + duration + ", displayed on pump: " + currentDuration); throw new CommandException().message("unable to set duration, requested:" + duration + ", displayed on pump: " + currentDuration);
log.debug("7. checking duration in " + scripter.currentMenu); log.debug("7. checking duration in " + scripter.getCurrentMenu());
scripter.waitForScreenUpdate(1000); scripter.waitForScreenUpdate(1000);
currentDuration = scripter.readDisplayedDuration(); currentDuration = scripter.readDisplayedDuration();
if (currentDuration != duration) if (currentDuration != duration)
throw new CommandException().message("wrong duration! Requested: " + duration + ", displayed on pump: " + currentDuration); throw new CommandException().message("wrong duration! Requested: " + duration + ", displayed on pump: " + currentDuration);
} }
log.debug("8. confirming TBR om " + scripter.currentMenu); log.debug("8. confirming TBR om " + scripter.getCurrentMenu());
retries = 5; retries = 5;
while (retries >= 0 && (scripter.currentMenu.getType() == TBR_DURATION || scripter.currentMenu.getType() == TBR_SET)) { while (retries >= 0 && (scripter.getCurrentMenu().getType() == TBR_DURATION || scripter.getCurrentMenu().getType() == TBR_SET)) {
retries--; retries--;
scripter.pressCheckKey(); scripter.pressCheckKey();
scripter.waitForScreenUpdate(1000); scripter.waitForScreenUpdate(1000);
} }
if (retries < 0 || scripter.currentMenu.getType() == TBR_DURATION || scripter.currentMenu.getType() == TBR_SET) if (retries < 0 || scripter.getCurrentMenu().getType() == TBR_DURATION || scripter.getCurrentMenu().getType() == TBR_SET)
throw new CommandException().message("failed setting basal!"); throw new CommandException().message("failed setting basal!");
retries = 10; retries = 10;
boolean cancelledError = true; boolean cancelledError = true;
if (percentage == 100) if (percentage == 100)
cancelledError = false; cancelledError = false;
while (retries >= 0 && scripter.currentMenu.getType() != MAIN_MENU) { while (retries >= 0 && scripter.getCurrentMenu().getType() != MAIN_MENU) {
// TODO how probable is it, that a totally unrelated error (like occlusion alert) // TODO how probable is it, that a totally unrelated error (like occlusion alert)
// is raised at this point, which we'd cancel together with the TBR cancelled alert? // is raised at this point, which we'd cancel together with the TBR cancelled alert?
if (percentage == 100 && scripter.currentMenu.getType() == WARNING_OR_ERROR) { if (percentage == 100 && scripter.getCurrentMenu().getType() == WARNING_OR_ERROR) {
// TODO extract method confirmAlert(alert) // TODO extract method confirmAlert(alert)
scripter.pressCheckKey(); scripter.pressCheckKey();
retries++; retries++;
@ -187,17 +187,17 @@ public class SetTbrCommand extends BaseCommand {
scripter.waitForScreenUpdate(1000); scripter.waitForScreenUpdate(1000);
} else { } else {
retries--; retries--;
if (scripter.currentMenu.getType() == MAIN_MENU && cancelledError) if (scripter.getCurrentMenu().getType() == MAIN_MENU && cancelledError)
break; break;
} }
} }
log.debug("9. verifying the main menu display the TBR we just set/cancelled"); log.debug("9. verifying the main menu display the TBR we just set/cancelled");
if (retries < 0 || scripter.currentMenu.getType() != MAIN_MENU) if (retries < 0 || scripter.getCurrentMenu().getType() != MAIN_MENU)
throw new CommandException().message("failed going to main!"); throw new CommandException().message("failed going to main!");
Object percentageObj = scripter.currentMenu.getAttribute(MenuAttribute.TBR); Object percentageObj = scripter.getCurrentMenu().getAttribute(MenuAttribute.TBR);
Object durationObj = scripter.currentMenu.getAttribute(MenuAttribute.RUNTIME); Object durationObj = scripter.getCurrentMenu().getAttribute(MenuAttribute.RUNTIME);
if (percentage == 100) { if (percentage == 100) {
if (durationObj != null) if (durationObj != null)

View file

@ -214,14 +214,14 @@ public class SetTbrCommandAlt extends BaseCommand {
long inFiveSeconds = System.currentTimeMillis() + 5 * 1000; long inFiveSeconds = System.currentTimeMillis() + 5 * 1000;
boolean alertProcessed = false; boolean alertProcessed = false;
while (System.currentTimeMillis() < inFiveSeconds && !alertProcessed) { while (System.currentTimeMillis() < inFiveSeconds && !alertProcessed) {
if (scripter.currentMenu.getType() == MenuType.WARNING_OR_ERROR) { if (scripter.getCurrentMenu().getType() == MenuType.WARNING_OR_ERROR) {
// Check the raised alarm is TBR CANCELLED, so we're not accidentally cancelling // Check the raised alarm is TBR CANCELLED, so we're not accidentally cancelling
// a different alarm that might be raised at the same time. // a different alarm that might be raised at the same time.
// Note that the message is permanently displayed, while the error code is blinking. // 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 // A wait till the error code can be read results in the code hanging, despite
// menu updates coming in, so just check the message. // menu updates coming in, so just check the message.
// TODO v2 this only works when the pump's language is English // TODO v2 this only works when the pump's language is English
String errorMsg = (String) scripter.currentMenu.getAttribute(MenuAttribute.MESSAGE); String errorMsg = (String) scripter.getCurrentMenu().getAttribute(MenuAttribute.MESSAGE);
if (!errorMsg.equals("TBR CANCELLED")) { if (!errorMsg.equals("TBR CANCELLED")) {
throw new CommandException().success(false).enacted(false) throw new CommandException().success(false).enacted(false)
.message("An alert other than the expected TBR CANCELLED was raised by the pump: " .message("An alert other than the expected TBR CANCELLED was raised by the pump: "
@ -242,8 +242,8 @@ public class SetTbrCommandAlt extends BaseCommand {
private void verifyMainMenuShowsNoActiveTbr() { private void verifyMainMenuShowsNoActiveTbr() {
scripter.verifyMenuIsDisplayed(MenuType.MAIN_MENU); scripter.verifyMenuIsDisplayed(MenuType.MAIN_MENU);
Double tbrPercentage = (Double) scripter.currentMenu.getAttribute(MenuAttribute.TBR); Double tbrPercentage = (Double) scripter.getCurrentMenu().getAttribute(MenuAttribute.TBR);
boolean runtimeDisplayed = scripter.currentMenu.attributes().contains(MenuAttribute.RUNTIME); boolean runtimeDisplayed = scripter.getCurrentMenu().attributes().contains(MenuAttribute.RUNTIME);
if (tbrPercentage != 100 || runtimeDisplayed) { if (tbrPercentage != 100 || runtimeDisplayed) {
throw new CommandException().message("Cancelling TBR failed, TBR is still set according to MAIN_MENU"); throw new CommandException().message("Cancelling TBR failed, TBR is still set according to MAIN_MENU");
} }
@ -252,12 +252,12 @@ public class SetTbrCommandAlt extends BaseCommand {
private void verifyMainMenuShowsExpectedTbrActive() { private void verifyMainMenuShowsExpectedTbrActive() {
scripter.verifyMenuIsDisplayed(MenuType.MAIN_MENU); scripter.verifyMenuIsDisplayed(MenuType.MAIN_MENU);
// new TBR set; percentage and duration must be displayed ... // new TBR set; percentage and duration must be displayed ...
if (!scripter.currentMenu.attributes().contains(MenuAttribute.TBR) || if (!scripter.getCurrentMenu().attributes().contains(MenuAttribute.TBR) ||
!scripter.currentMenu.attributes().contains(MenuAttribute.RUNTIME)) { !scripter.getCurrentMenu().attributes().contains(MenuAttribute.RUNTIME)) {
throw new CommandException().message("Setting TBR failed, according to MAIN_MENU no TBR is active"); throw new CommandException().message("Setting TBR failed, according to MAIN_MENU no TBR is active");
} }
Double mmTbrPercentage = (Double) scripter.currentMenu.getAttribute(MenuAttribute.TBR); Double mmTbrPercentage = (Double) scripter.getCurrentMenu().getAttribute(MenuAttribute.TBR);
MenuTime mmTbrDuration = (MenuTime) scripter.currentMenu.getAttribute(MenuAttribute.RUNTIME); MenuTime mmTbrDuration = (MenuTime) scripter.getCurrentMenu().getAttribute(MenuAttribute.RUNTIME);
// ... and be the same as what we set // ... and be the same as what we set
// note that displayed duration might have already counted down, e.g. from 30 minutes to // note that displayed duration might have already counted down, e.g. from 30 minutes to
// 29 minutes and 59 seconds, so that 29 minutes are displayed // 29 minutes and 59 seconds, so that 29 minutes are displayed

View file

@ -189,10 +189,11 @@ public class ComboPlugin implements PluginBase, PumpInterface {
// this must be the base package of the app (check package attribute in // this must be the base package of the app (check package attribute in
// manifest element in the manifest file of the providing app) // manifest element in the manifest file of the providing app)
"org.monkey.d.ruffy.ruffy", "org.monkey.d.ruffy.ruffy",
// full path to the driver // full path to the driver;
// in the logs this service is mentioned as (note the slash) // in the logs this service is mentioned as (note the slash)
// "org.monkey.d.ruffy.ruffy/.driver.Ruffy" // "org.monkey.d.ruffy.ruffy/.driver.Ruffy";
//org.monkey.d.ruffy.ruffy is the base package identifier and /.driver.Ruffy the service within the package // org.monkey.d.ruffy.ruffy is the base package identifier
// and /.driver.Ruffy the service within the package
"org.monkey.d.ruffy.ruffy.driver.Ruffy" "org.monkey.d.ruffy.ruffy.driver.Ruffy"
)); ));
context.startService(intent); context.startService(intent);
@ -208,9 +209,8 @@ public class ComboPlugin implements PluginBase, PumpInterface {
@Override @Override
public void onServiceDisconnected(ComponentName name) { public void onServiceDisconnected(ComponentName name) {
ruffyScripter.stop();
log.debug("ruffy service disconnected"); log.debug("ruffy service disconnected");
// try to reconnect ruffy service unless unbind was explicitely requested // try to reconnect ruffy service unless unbind was explicitly requested
// via unbindRuffyService // via unbindRuffyService
if(!keepUnbound) { if(!keepUnbound) {
SystemClock.sleep(250); SystemClock.sleep(250);
@ -311,7 +311,7 @@ public class ComboPlugin implements PluginBase, PumpInterface {
@Override @Override
public boolean isBusy() { public boolean isBusy() {
return ruffyScripter == null || ruffyScripter.isPumpBusy(); return ruffyScripter.isPumpBusy();
} }
// TODO // TODO
@ -337,8 +337,8 @@ public class ComboPlugin implements PluginBase, PumpInterface {
log.debug("RefreshDataFromPump called"); log.debug("RefreshDataFromPump called");
// if Android is sluggish this might get called before ruffy is bound // if Android is sluggish this might get called before ruffy is bound
if (ruffyScripter == null) { if (!ruffyScripter.isRunning()) {
log.warn("Rejecting call to RefreshDataFromPump: ruffy service not bound (yet)"); log.warn("Rejecting call to RefreshDataFromPump: scripter not ready yet.");
return; return;
} }