Rename ReadReservoirLevelAndLastBolus to ReadQuickInfoCommand.
This commit is contained in:
parent
739e52dc47
commit
5fbd9097d8
5 changed files with 21 additions and 18 deletions
|
@ -345,7 +345,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
|||
if (!pump.initialized) {
|
||||
initializePump();
|
||||
} else {
|
||||
runCommand(MainApp.gs(R.string.combo_pump_action_refreshing), 1, ruffyScripter::readReservoirLevelAndLastBolus);
|
||||
runCommand(MainApp.gs(R.string.combo_pump_action_refreshing), 1, ruffyScripter::readQuickInfo);
|
||||
// note that since the history is checked upon every connect, the above already updated
|
||||
// the DB with any changed history records
|
||||
}
|
||||
|
@ -395,9 +395,10 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
|||
MainApp.bus().post(new EventInitializationChanged());
|
||||
|
||||
// ComboFragment updates state fully only after the pump has initialized, so read full state here
|
||||
updateLocalData(runCommand(null, 1, ruffyScripter::readReservoirLevelAndLastBolus));
|
||||
updateLocalData(runCommand(null, 1, ruffyScripter::readQuickInfo));
|
||||
}
|
||||
|
||||
/** Updates local cache with state (reservoir level, last bolus ...) returned from the pump */
|
||||
private void updateLocalData(CommandResult result) {
|
||||
if (result.reservoirLevel != PumpState.UNKNOWN) {
|
||||
pump.reservoirLevel = result.reservoirLevel;
|
||||
|
@ -492,7 +493,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
|||
lastRequestedBolus = new Bolus(System.currentTimeMillis(), detailedBolusInfo.insulin, true);
|
||||
|
||||
// check pump is ready and all pump bolus records are known
|
||||
CommandResult stateResult = runCommand(null, 2, ruffyScripter::readReservoirLevelAndLastBolus);
|
||||
CommandResult stateResult = runCommand(null, 2, ruffyScripter::readQuickInfo);
|
||||
if (!stateResult.success) {
|
||||
return new PumpEnactResult().success(false).enacted(false)
|
||||
.comment(MainApp.gs(R.string.combo_error_no_connection_no_bolus_delivered));
|
||||
|
@ -531,7 +532,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
|||
// a connection problem, ruffyscripter tried to recover and we can just check the
|
||||
// history below to see what was actually delivered
|
||||
|
||||
CommandResult postBolusStateResult = runCommand(null, 3, ruffyScripter::readReservoirLevelAndLastBolus);
|
||||
CommandResult postBolusStateResult = runCommand(null, 3, ruffyScripter::readQuickInfo);
|
||||
if (!postBolusStateResult.success) {
|
||||
return new PumpEnactResult().success(false).enacted(false)
|
||||
.comment(MainApp.gs(R.string.combo_error_bolus_verification_failed));
|
||||
|
|
|
@ -32,7 +32,7 @@ public interface RuffyCommands {
|
|||
CommandResult readPumpState();
|
||||
|
||||
/** Read reservoir level and last bolus via Quick Info */
|
||||
CommandResult readReservoirLevelAndLastBolus();
|
||||
CommandResult readQuickInfo();
|
||||
|
||||
/** Reads pump history via the My Data menu. The {@link PumpHistoryRequest} specifies
|
||||
* what types of data and how far back data is returned. */
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.commands.ReadQuickInfoCommand;
|
||||
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.PumpHistoryRequest;
|
||||
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.commands.BolusCommand;
|
||||
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.commands.CancelTbrCommand;
|
||||
|
@ -37,7 +38,6 @@ import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.commands.Confi
|
|||
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.commands.ReadBasalProfileCommand;
|
||||
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.commands.ReadHistoryCommand;
|
||||
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.commands.ReadPumpStateCommand;
|
||||
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.commands.ReadReservoirLevelAndLastBolus;
|
||||
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.commands.SetBasalProfileCommand;
|
||||
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.commands.SetTbrCommand;
|
||||
import info.nightscout.androidaps.BuildConfig;
|
||||
|
@ -48,7 +48,7 @@ import info.nightscout.androidaps.BuildConfig;
|
|||
* operations and are cleanly separated from the thread management, connection management etc
|
||||
*/
|
||||
public class RuffyScripter implements RuffyCommands {
|
||||
private final boolean readQuickInfoMenu = true;
|
||||
private final boolean readQuickInfo = true;
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(RuffyScripter.class);
|
||||
|
||||
|
@ -217,10 +217,10 @@ public class RuffyScripter implements RuffyCommands {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CommandResult readReservoirLevelAndLastBolus() {
|
||||
if (readQuickInfoMenu) {
|
||||
public CommandResult readQuickInfo() {
|
||||
if (readQuickInfo) {
|
||||
Answers.getInstance().logCustom(new CustomEvent("ComboReadQuickInfoCmd"));
|
||||
return runCommand(new ReadReservoirLevelAndLastBolus());
|
||||
return runCommand(new ReadQuickInfoCommand());
|
||||
}
|
||||
Answers.getInstance().logCustom(new CustomEvent("ComboReadHistoryCmd"));
|
||||
return runCommand(new ReadHistoryCommand(new PumpHistoryRequest().bolusHistory(PumpHistoryRequest.LAST)));
|
||||
|
|
|
@ -12,6 +12,7 @@ import java.util.List;
|
|||
import java.util.Objects;
|
||||
|
||||
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.BolusProgressReporter;
|
||||
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.CommandResult;
|
||||
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.PumpWarningCodes;
|
||||
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.WarningOrErrorCode;
|
||||
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.Bolus;
|
||||
|
@ -185,17 +186,18 @@ public class BolusCommand extends BaseCommand {
|
|||
|
||||
if (cancelInProgress) {
|
||||
log.debug("Stage 4: reading last bolus from pump history since a cancellation was requested during bolus delivery");
|
||||
ReadReservoirLevelAndLastBolus readReservoirLevelAndLastBolus = new ReadReservoirLevelAndLastBolus();
|
||||
readReservoirLevelAndLastBolus.setScripter(scripter);
|
||||
readReservoirLevelAndLastBolus.execute();
|
||||
Bolus lastBolus = readReservoirLevelAndLastBolus.result.history != null && !readReservoirLevelAndLastBolus.result.history.bolusHistory.isEmpty()
|
||||
? readReservoirLevelAndLastBolus.result.history.bolusHistory.get(0)
|
||||
ReadQuickInfoCommand readQuickInfoCommand = new ReadQuickInfoCommand();
|
||||
readQuickInfoCommand.setScripter(scripter);
|
||||
readQuickInfoCommand.execute();
|
||||
CommandResult quickInfoResult = readQuickInfoCommand.result;
|
||||
Bolus lastBolus = quickInfoResult.history != null && !quickInfoResult.history.bolusHistory.isEmpty()
|
||||
? quickInfoResult.history.bolusHistory.get(0)
|
||||
: null;
|
||||
if (lastBolus == null || Math.abs(System.currentTimeMillis() - lastBolus.timestamp) >= 10 * 60 * 1000) {
|
||||
throw new CommandException("Unable to determine last bolus");
|
||||
}
|
||||
log.debug("Stage 4: " + lastBolus.amount + " U delivered before cancellation according to history");
|
||||
result.delivered = lastBolus.amount;
|
||||
this.result.delivered = lastBolus.amount;
|
||||
} else {
|
||||
log.debug("Stage 4: full bolus of " + bolus + " U was successfully delivered");
|
||||
result.delivered = bolus;
|
||||
|
|
|
@ -15,7 +15,7 @@ import java.util.List;
|
|||
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.Bolus;
|
||||
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.PumpHistory;
|
||||
|
||||
public class ReadReservoirLevelAndLastBolus extends BaseCommand {
|
||||
public class ReadQuickInfoCommand extends BaseCommand {
|
||||
@Override
|
||||
public void execute() {
|
||||
scripter.verifyRootMenuIsDisplayed();
|
||||
|
@ -62,6 +62,6 @@ public class ReadReservoirLevelAndLastBolus extends BaseCommand {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ReadReservoirLevelAndLastBolus{}";
|
||||
return "ReadQuickInfoCommand{}";
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue