Polish.
This commit is contained in:
parent
9653af5501
commit
69b98c54c6
|
@ -15,7 +15,6 @@ import org.slf4j.LoggerFactory;
|
||||||
import de.jotomo.ruffyscripter.commands.Command;
|
import de.jotomo.ruffyscripter.commands.Command;
|
||||||
import de.jotomo.ruffyscripter.commands.CommandException;
|
import de.jotomo.ruffyscripter.commands.CommandException;
|
||||||
import de.jotomo.ruffyscripter.commands.CommandResult;
|
import de.jotomo.ruffyscripter.commands.CommandResult;
|
||||||
import de.jotomo.ruffyscripter.commands.PumpAlert;
|
|
||||||
import de.jotomo.ruffyscripter.commands.PumpState;
|
import de.jotomo.ruffyscripter.commands.PumpState;
|
||||||
|
|
||||||
// TODO regularly read "My data" history (boluses, TBR) to double check all commands ran successfully.
|
// TODO regularly read "My data" history (boluses, TBR) to double check all commands ran successfully.
|
||||||
|
@ -122,8 +121,6 @@ public class RuffyScripter {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
cmdResult = null;
|
cmdResult = null;
|
||||||
activeCmd = cmd;
|
activeCmd = cmd;
|
||||||
final RuffyScripter scripter = this;
|
|
||||||
// TODO hackish, to say the least ...
|
|
||||||
// wait till pump is ready for input
|
// wait till pump is ready for input
|
||||||
waitForMenuUpdate();
|
waitForMenuUpdate();
|
||||||
// check if pump is an an error state
|
// check if pump is an an error state
|
||||||
|
@ -134,10 +131,8 @@ public class RuffyScripter {
|
||||||
return new CommandResult().message("Pump is in an error state, reading the error state resulted in the attached exception").exception(e);
|
return new CommandResult().message("Pump is in an error state, reading the error state resulted in the attached exception").exception(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO check pump state; currently most command check their in the MAIN_MENU;
|
|
||||||
// run ReadStateCommand, which handles possible states ... and then do wait?
|
|
||||||
// Return an unsuccessful CommandResult and make the caller do something loud with it
|
|
||||||
log.debug("Cmd execution: connection ready, executing cmd " + cmd);
|
log.debug("Cmd execution: connection ready, executing cmd " + cmd);
|
||||||
|
final RuffyScripter scripter = this;
|
||||||
cmdThread = new Thread(new Runnable() {
|
cmdThread = new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -240,7 +235,6 @@ public class RuffyScripter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pressMenuKey() {
|
public void pressMenuKey() {
|
||||||
// TODO build 'wait for menu update' into this method? get current menu, press key, wait for update?
|
|
||||||
log.debug("Pressing menu key");
|
log.debug("Pressing menu key");
|
||||||
pressKey(Key.MENU);
|
pressKey(Key.MENU);
|
||||||
log.debug("Releasing menu key");
|
log.debug("Releasing menu key");
|
||||||
|
@ -260,17 +254,6 @@ public class RuffyScripter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* "Virtual" key, emulated by pressing menu and up simultaneously
|
|
||||||
*/
|
|
||||||
// Doesn't work
|
|
||||||
/* public void pressBackKey() throws RemoteException {
|
|
||||||
ruffyService.rtSendKey(Key.MENU, true);
|
|
||||||
SystemClock.sleep(50);
|
|
||||||
ruffyService.rtSendKey(Key.UP, true);
|
|
||||||
SystemClock.sleep(100);
|
|
||||||
ruffyService.rtSendKey(Key.NO_KEY, true);
|
|
||||||
}*/
|
|
||||||
private void pressKey(final byte key) {
|
private void pressKey(final byte key) {
|
||||||
try {
|
try {
|
||||||
ruffyService.rtSendKey(key, true);
|
ruffyService.rtSendKey(key, true);
|
||||||
|
|
|
@ -8,6 +8,8 @@ import org.slf4j.LoggerFactory;
|
||||||
import de.jotomo.ruffyscripter.RuffyScripter;
|
import de.jotomo.ruffyscripter.RuffyScripter;
|
||||||
|
|
||||||
// TODO robustness: can a TBR run out, whilst we're trying to cancel it?
|
// TODO robustness: can a TBR run out, whilst we're trying to cancel it?
|
||||||
|
// Hm, we could just ignore TBRs that run out within the next 60s (0:01 or even 0:02
|
||||||
|
// given we need some time to process the request).
|
||||||
public class CancelTbrCommand implements Command {
|
public class CancelTbrCommand implements Command {
|
||||||
private static final Logger log = LoggerFactory.getLogger(CancelTbrCommand.class);
|
private static final Logger log = LoggerFactory.getLogger(CancelTbrCommand.class);
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,4 @@ import de.jotomo.ruffyscripter.RuffyScripter;
|
||||||
|
|
||||||
public interface Command {
|
public interface Command {
|
||||||
CommandResult execute(RuffyScripter ruffyScripter);
|
CommandResult execute(RuffyScripter ruffyScripter);
|
||||||
|
|
||||||
// default String toString() {
|
|
||||||
// return getClass().getSimpleName();
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,7 +110,6 @@ public class SetTbrCommand implements Command {
|
||||||
for (int i = 0; i < percentageSteps; i++) {
|
for (int i = 0; i < percentageSteps; i++) {
|
||||||
if (increasePercentage) scripter.pressUpKey();
|
if (increasePercentage) scripter.pressUpKey();
|
||||||
else scripter.pressDownKey();
|
else scripter.pressDownKey();
|
||||||
// TODO waitForMenuChange instead // or have key press method handle that??
|
|
||||||
SystemClock.sleep(100);
|
SystemClock.sleep(100);
|
||||||
log.debug("Push #" + (i + 1));
|
log.debug("Push #" + (i + 1));
|
||||||
}
|
}
|
||||||
|
@ -159,7 +158,6 @@ public class SetTbrCommand implements Command {
|
||||||
for (int i = 0; i < durationSteps; i++) {
|
for (int i = 0; i < durationSteps; i++) {
|
||||||
if (increaseDuration) scripter.pressUpKey();
|
if (increaseDuration) scripter.pressUpKey();
|
||||||
else scripter.pressDownKey();
|
else scripter.pressDownKey();
|
||||||
// TODO waitForMenuChange instead // or have key press method handle that??
|
|
||||||
SystemClock.sleep(100);
|
SystemClock.sleep(100);
|
||||||
log.debug("Push #" + (i + 1));
|
log.debug("Push #" + (i + 1));
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,7 +209,6 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isBusy() {
|
public boolean isBusy() {
|
||||||
return ruffyScripter.isPumpBusy();
|
return ruffyScripter.isPumpBusy();
|
||||||
|
@ -227,7 +226,6 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
|
||||||
@Override
|
@Override
|
||||||
public Date lastDataTime() {
|
public Date lastDataTime() {
|
||||||
return lastCmdTime;
|
return lastCmdTime;
|
||||||
|
|
Loading…
Reference in a new issue