Make new BolusCommand configurable.

This commit is contained in:
Johannes Mockenhaupt 2017-08-27 19:11:17 +02:00
parent b53db22ae1
commit ecd05bef2d
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
2 changed files with 16 additions and 3 deletions

View file

@ -47,4 +47,7 @@ public class Config {
public static final boolean logDanaBTComm = true; public static final boolean logDanaBTComm = true;
public static final boolean logDanaMessageDetail = true; public static final boolean logDanaMessageDetail = true;
public static final boolean logDanaSerialEngine = true; public static final boolean logDanaSerialEngine = true;
// Combo specific
public static final boolean comboExperimentalBolus = false;
} }

View file

@ -26,11 +26,13 @@ import de.jotomo.ruffyscripter.PumpState;
import de.jotomo.ruffyscripter.RuffyScripter; import de.jotomo.ruffyscripter.RuffyScripter;
import de.jotomo.ruffyscripter.commands.BolusCommand; import de.jotomo.ruffyscripter.commands.BolusCommand;
import de.jotomo.ruffyscripter.commands.CancelTbrCommand; import de.jotomo.ruffyscripter.commands.CancelTbrCommand;
import de.jotomo.ruffyscripter.commands.CancellableBolusCommand;
import de.jotomo.ruffyscripter.commands.Command; import de.jotomo.ruffyscripter.commands.Command;
import de.jotomo.ruffyscripter.commands.CommandResult; import de.jotomo.ruffyscripter.commands.CommandResult;
import de.jotomo.ruffyscripter.commands.GetPumpStateCommand; import de.jotomo.ruffyscripter.commands.GetPumpStateCommand;
import de.jotomo.ruffyscripter.commands.SetTbrCommand; import de.jotomo.ruffyscripter.commands.SetTbrCommand;
import info.nightscout.androidaps.BuildConfig; import info.nightscout.androidaps.BuildConfig;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.DetailedBolusInfo; import info.nightscout.androidaps.data.DetailedBolusInfo;
@ -48,6 +50,11 @@ import info.nightscout.androidaps.plugins.PumpCombo.events.EventComboPumpUpdateG
import info.nightscout.utils.DateUtil; import info.nightscout.utils.DateUtil;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
import static de.jotomo.ruffyscripter.commands.CancellableBolusCommand.ProgressReportCallback.State.DELIVERED;
import static de.jotomo.ruffyscripter.commands.CancellableBolusCommand.ProgressReportCallback.State.DELIVERING;
import static de.jotomo.ruffyscripter.commands.CancellableBolusCommand.ProgressReportCallback.State.STOPPED;
import static de.jotomo.ruffyscripter.commands.CancellableBolusCommand.ProgressReportCallback.State.STOPPING;
/** /**
* Created by mike on 05.08.2016. * Created by mike on 05.08.2016.
*/ */
@ -356,9 +363,10 @@ public class ComboPlugin implements PluginBase, PumpInterface {
return basal; return basal;
} }
private static BolusCommand.ProgressReportCallback bolusProgressReportCallback = new BolusCommand.ProgressReportCallback() { private static CancellableBolusCommand.ProgressReportCallback bolusProgressReportCallback =
new CancellableBolusCommand.ProgressReportCallback() {
@Override @Override
public void report(BolusCommand.ProgressReportCallback.State state, int percent, double delivered) { public void report(CancellableBolusCommand.ProgressReportCallback.State state, int percent, double delivered) {
EventOverviewBolusProgress enent = EventOverviewBolusProgress.getInstance(); EventOverviewBolusProgress enent = EventOverviewBolusProgress.getInstance();
switch (state) { switch (state) {
case DELIVERING: case DELIVERING:
@ -391,7 +399,9 @@ public class ComboPlugin implements PluginBase, PumpInterface {
// Note that the BolusCommand sends progress updates to the bolusProgressReporterCallback, // Note that the BolusCommand sends progress updates to the bolusProgressReporterCallback,
// which then posts appropriate events on the bus, so in this branch no posts are needed // which then posts appropriate events on the bus, so in this branch no posts are needed
runningBolusCommand = new BolusCommand(detailedBolusInfo.insulin, bolusProgressReportCallback); runningBolusCommand = Config.comboExperimentalBolus
? new CancellableBolusCommand(detailedBolusInfo.insulin, bolusProgressReportCallback)
: new BolusCommand(detailedBolusInfo.insulin);
CommandResult bolusCmdResult = runCommand(runningBolusCommand); CommandResult bolusCmdResult = runCommand(runningBolusCommand);
runningBolusCommand = null; runningBolusCommand = null;
PumpEnactResult pumpEnactResult = new PumpEnactResult(); PumpEnactResult pumpEnactResult = new PumpEnactResult();