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.RuffyScripter;
|
||||||
import info.nightscout.androidaps.plugins.PumpCombo.scripter.commands.BolusCommand;
|
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.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.Command;
|
||||||
import info.nightscout.androidaps.plugins.PumpCombo.scripter.commands.CommandResult;
|
import info.nightscout.androidaps.plugins.PumpCombo.scripter.commands.CommandResult;
|
||||||
import info.nightscout.androidaps.plugins.PumpCombo.scripter.commands.GetPumpStateCommand;
|
import info.nightscout.androidaps.plugins.PumpCombo.scripter.commands.GetPumpStateCommand;
|
||||||
|
@ -365,10 +365,10 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
return basal;
|
return basal;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static CancellableBolusCommand.ProgressReportCallback bolusProgressReportCallback =
|
private static ExperimentalBolusCommand.ProgressReportCallback bolusProgressReportCallback =
|
||||||
new CancellableBolusCommand.ProgressReportCallback() {
|
new ExperimentalBolusCommand.ProgressReportCallback() {
|
||||||
@Override
|
@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();
|
EventOverviewBolusProgress enent = EventOverviewBolusProgress.getInstance();
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case DELIVERING:
|
case DELIVERING:
|
||||||
|
@ -465,7 +465,7 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
private PumpEnactResult deliverBolus(DetailedBolusInfo detailedBolusInfo) {
|
private PumpEnactResult deliverBolus(DetailedBolusInfo detailedBolusInfo) {
|
||||||
runningBolusCommand = SP.getBoolean(R.string.key_combo_enable_experimental_features, false)
|
runningBolusCommand = SP.getBoolean(R.string.key_combo_enable_experimental_features, false)
|
||||||
&& SP.getBoolean(R.string.key_combo_enable_experimental_bolus, 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);
|
: new BolusCommand(detailedBolusInfo.insulin);
|
||||||
CommandResult bolusCmdResult = runCommand(runningBolusCommand);
|
CommandResult bolusCmdResult = runCommand(runningBolusCommand);
|
||||||
PumpEnactResult pumpEnactResult = new PumpEnactResult();
|
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.PumpState;
|
||||||
import info.nightscout.androidaps.plugins.PumpCombo.scripter.RuffyScripter;
|
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.ExperimentalBolusCommand.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.ExperimentalBolusCommand.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.ExperimentalBolusCommand.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.STOPPING;
|
||||||
|
|
||||||
public class CancellableBolusCommand extends BolusCommand {
|
public class ExperimentalBolusCommand extends BolusCommand {
|
||||||
private static final Logger log = LoggerFactory.getLogger(CancellableBolusCommand.class);
|
private static final Logger log = LoggerFactory.getLogger(ExperimentalBolusCommand.class);
|
||||||
|
|
||||||
private final ProgressReportCallback progressReportCallback;
|
private final ProgressReportCallback progressReportCallback;
|
||||||
private volatile boolean cancelRequested;
|
private volatile boolean cancelRequested;
|
||||||
|
|
||||||
public CancellableBolusCommand(double bolus, ProgressReportCallback progressReportCallback) {
|
public ExperimentalBolusCommand(double bolus, ProgressReportCallback progressReportCallback) {
|
||||||
super(bolus);
|
super(bolus);
|
||||||
this.progressReportCallback = progressReportCallback;
|
this.progressReportCallback = progressReportCallback;
|
||||||
}
|
}
|
|
@ -5,15 +5,19 @@ import java.util.List;
|
||||||
public class GetReservoirLevelCommand extends BaseCommand {
|
public class GetReservoirLevelCommand extends BaseCommand {
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute() {
|
public CommandResult execute() {
|
||||||
// TODO stub
|
// TODO merge this into GetPumpHistory / GetFullPumpState; or maybe just have
|
||||||
// watch out, level goes into PumpState, which is usually set by RuffyScripter
|
// GetPumpState and parameterize to just read the displayed menu, read reservoir level, read history?
|
||||||
// after a command ran, unless a command has already set it ... I don't like
|
// TODO rough version, no error handling thought out
|
||||||
// that, it's too implicit ...
|
|
||||||
|
|
||||||
// also, maybe ditch this command and add a parameter to GetPumpStateCommand to also
|
// turn into a method; bolus commands needs this as a precheck, parameterize GetPumpState command
|
||||||
// read the reservoir level if possible (pump must be in a state to accept commands
|
// to include reservoir level if desired
|
||||||
// (possible on main, stop ...)
|
scripter.verifyMenuIsDisplayed(MenuType.MAIN_MENU);
|
||||||
return null;
|
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
|
@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