Refactorings and notes.
(cherry picked from commit 8c77f0e)
This commit is contained in:
parent
0fda86dffa
commit
a33d7db471
|
@ -27,7 +27,7 @@ import info.nightscout.androidaps.plugins.PumpCombo.scripter.PumpState;
|
|||
import info.nightscout.androidaps.plugins.PumpCombo.scripter.RuffyScripter;
|
||||
import info.nightscout.androidaps.plugins.PumpCombo.scripter.commands.BolusCommand;
|
||||
import info.nightscout.androidaps.plugins.PumpCombo.scripter.commands.CancelTbrCommand;
|
||||
import info.nightscout.androidaps.plugins.PumpCombo.scripter.commands.CancellableBolusCommand;
|
||||
import info.nightscout.androidaps.plugins.PumpCombo.scripter.commands.ExperimentalBolusCommand;
|
||||
import info.nightscout.androidaps.plugins.PumpCombo.scripter.commands.Command;
|
||||
import info.nightscout.androidaps.plugins.PumpCombo.scripter.commands.CommandResult;
|
||||
import info.nightscout.androidaps.plugins.PumpCombo.scripter.commands.GetPumpStateCommand;
|
||||
|
@ -365,10 +365,10 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
|||
return basal;
|
||||
}
|
||||
|
||||
private static CancellableBolusCommand.ProgressReportCallback bolusProgressReportCallback =
|
||||
new CancellableBolusCommand.ProgressReportCallback() {
|
||||
private static ExperimentalBolusCommand.ProgressReportCallback bolusProgressReportCallback =
|
||||
new ExperimentalBolusCommand.ProgressReportCallback() {
|
||||
@Override
|
||||
public void report(CancellableBolusCommand.ProgressReportCallback.State state, int percent, double delivered) {
|
||||
public void report(ExperimentalBolusCommand.ProgressReportCallback.State state, int percent, double delivered) {
|
||||
EventOverviewBolusProgress enent = EventOverviewBolusProgress.getInstance();
|
||||
switch (state) {
|
||||
case DELIVERING:
|
||||
|
@ -465,7 +465,7 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
|||
private PumpEnactResult deliverBolus(DetailedBolusInfo detailedBolusInfo) {
|
||||
runningBolusCommand = SP.getBoolean(R.string.key_combo_enable_experimental_features, false)
|
||||
&& SP.getBoolean(R.string.key_combo_enable_experimental_bolus, false)
|
||||
? new CancellableBolusCommand(detailedBolusInfo.insulin, bolusProgressReportCallback)
|
||||
? new ExperimentalBolusCommand(detailedBolusInfo.insulin, bolusProgressReportCallback)
|
||||
: new BolusCommand(detailedBolusInfo.insulin);
|
||||
CommandResult bolusCmdResult = runCommand(runningBolusCommand);
|
||||
PumpEnactResult pumpEnactResult = new PumpEnactResult();
|
||||
|
|
|
@ -14,18 +14,18 @@ import java.util.Locale;
|
|||
import info.nightscout.androidaps.plugins.PumpCombo.scripter.PumpState;
|
||||
import info.nightscout.androidaps.plugins.PumpCombo.scripter.RuffyScripter;
|
||||
|
||||
import static info.nightscout.androidaps.plugins.PumpCombo.scripter.commands.CancellableBolusCommand.ProgressReportCallback.State.DELIVERED;
|
||||
import static info.nightscout.androidaps.plugins.PumpCombo.scripter.commands.CancellableBolusCommand.ProgressReportCallback.State.DELIVERING;
|
||||
import static info.nightscout.androidaps.plugins.PumpCombo.scripter.commands.CancellableBolusCommand.ProgressReportCallback.State.STOPPED;
|
||||
import static info.nightscout.androidaps.plugins.PumpCombo.scripter.commands.CancellableBolusCommand.ProgressReportCallback.State.STOPPING;
|
||||
import static info.nightscout.androidaps.plugins.PumpCombo.scripter.commands.ExperimentalBolusCommand.ProgressReportCallback.State.DELIVERED;
|
||||
import static info.nightscout.androidaps.plugins.PumpCombo.scripter.commands.ExperimentalBolusCommand.ProgressReportCallback.State.DELIVERING;
|
||||
import static info.nightscout.androidaps.plugins.PumpCombo.scripter.commands.ExperimentalBolusCommand.ProgressReportCallback.State.STOPPED;
|
||||
import static info.nightscout.androidaps.plugins.PumpCombo.scripter.commands.ExperimentalBolusCommand.ProgressReportCallback.State.STOPPING;
|
||||
|
||||
public class CancellableBolusCommand extends BolusCommand {
|
||||
private static final Logger log = LoggerFactory.getLogger(CancellableBolusCommand.class);
|
||||
public class ExperimentalBolusCommand extends BolusCommand {
|
||||
private static final Logger log = LoggerFactory.getLogger(ExperimentalBolusCommand.class);
|
||||
|
||||
private final ProgressReportCallback progressReportCallback;
|
||||
private volatile boolean cancelRequested;
|
||||
|
||||
public CancellableBolusCommand(double bolus, ProgressReportCallback progressReportCallback) {
|
||||
public ExperimentalBolusCommand(double bolus, ProgressReportCallback progressReportCallback) {
|
||||
super(bolus);
|
||||
this.progressReportCallback = progressReportCallback;
|
||||
}
|
|
@ -5,15 +5,19 @@ import java.util.List;
|
|||
public class GetReservoirLevelCommand extends BaseCommand {
|
||||
@Override
|
||||
public CommandResult execute() {
|
||||
// TODO stub
|
||||
// watch out, level goes into PumpState, which is usually set by RuffyScripter
|
||||
// after a command ran, unless a command has already set it ... I don't like
|
||||
// that, it's too implicit ...
|
||||
// TODO merge this into GetPumpHistory / GetFullPumpState; or maybe just have
|
||||
// GetPumpState and parameterize to just read the displayed menu, read reservoir level, read history?
|
||||
// TODO rough version, no error handling thought out
|
||||
|
||||
// also, maybe ditch this command and add a parameter to GetPumpStateCommand to also
|
||||
// read the reservoir level if possible (pump must be in a state to accept commands
|
||||
// (possible on main, stop ...)
|
||||
return null;
|
||||
// turn into a method; bolus commands needs this as a precheck, parameterize GetPumpState command
|
||||
// to include reservoir level if desired
|
||||
scripter.verifyMenuIsDisplayed(MenuType.MAIN_MENU);
|
||||
scripter.pressCheckKey();
|
||||
scripter.waitForMenuToBeLeft(MenuType.MAIN_MENU);
|
||||
scripter.verifyMenuIsDisplayed(MenuType.QUICK_INFO);
|
||||
int remainingInsulin = ((Double) scripter.getCurrentMenu().getAttribute(MenuAttribute.REMAINING_INSULIN)).intValue();
|
||||
scripter.returnToMainMenu();
|
||||
return new CommandResult().success(true).enacted(false).reservoirLevel(remainingInsulin);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
package info.nightscout.androidaps.plugins.PumpCombo.scripter.commands;
|
||||
|
||||
/**
|
||||
* Draft.
|
||||
*
|
||||
* small bolus, don't check reservoir level beforehand ... ??
|
||||
* not cancellable
|
||||
* less of an issue if it fails
|
||||
* can be retried automatically
|
||||
*/
|
||||
public class SuperMicroBolusCommand extends BolusCommand {
|
||||
public SuperMicroBolusCommand(double bolus) {
|
||||
super(bolus);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue