distinguish between common and SMB bolus in queue
This commit is contained in:
parent
622ac15c50
commit
67c89f5d98
3 changed files with 51 additions and 6 deletions
|
@ -31,6 +31,7 @@ import info.nightscout.androidaps.queue.commands.CommandExtendedBolus;
|
||||||
import info.nightscout.androidaps.queue.commands.CommandLoadEvents;
|
import info.nightscout.androidaps.queue.commands.CommandLoadEvents;
|
||||||
import info.nightscout.androidaps.queue.commands.CommandLoadHistory;
|
import info.nightscout.androidaps.queue.commands.CommandLoadHistory;
|
||||||
import info.nightscout.androidaps.queue.commands.CommandReadStatus;
|
import info.nightscout.androidaps.queue.commands.CommandReadStatus;
|
||||||
|
import info.nightscout.androidaps.queue.commands.CommandSMBBolus;
|
||||||
import info.nightscout.androidaps.queue.commands.CommandSetProfile;
|
import info.nightscout.androidaps.queue.commands.CommandSetProfile;
|
||||||
import info.nightscout.androidaps.queue.commands.CommandTempBasalAbsolute;
|
import info.nightscout.androidaps.queue.commands.CommandTempBasalAbsolute;
|
||||||
import info.nightscout.androidaps.queue.commands.CommandTempBasalPercent;
|
import info.nightscout.androidaps.queue.commands.CommandTempBasalPercent;
|
||||||
|
@ -65,7 +66,6 @@ import info.nightscout.androidaps.queue.commands.CommandTempBasalPercent;
|
||||||
* connect() is called again
|
* connect() is called again
|
||||||
*
|
*
|
||||||
* when queue is empty, disconnect is called
|
* when queue is empty, disconnect is called
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class CommandQueue {
|
public class CommandQueue {
|
||||||
|
@ -141,17 +141,22 @@ public class CommandQueue {
|
||||||
|
|
||||||
// returns true if command is queued
|
// returns true if command is queued
|
||||||
public boolean bolus(DetailedBolusInfo detailedBolusInfo, Callback callback) {
|
public boolean bolus(DetailedBolusInfo detailedBolusInfo, Callback callback) {
|
||||||
if (isRunning(Command.CommandType.BOLUS)) {
|
Command.CommandType type = detailedBolusInfo.isSMB ? Command.CommandType.SMB_BOLUS : Command.CommandType.BOLUS;
|
||||||
|
|
||||||
|
if (isRunning(type)) {
|
||||||
if (callback != null)
|
if (callback != null)
|
||||||
callback.result(executingNowError()).run();
|
callback.result(executingNowError()).run();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove all unfinished boluses
|
// remove all unfinished boluses
|
||||||
removeAll(Command.CommandType.BOLUS);
|
removeAll(type);
|
||||||
|
|
||||||
// add new command to queue
|
// add new command to queue
|
||||||
add(new CommandBolus(detailedBolusInfo, callback));
|
if (detailedBolusInfo.isSMB)
|
||||||
|
add(new CommandSMBBolus(detailedBolusInfo, callback));
|
||||||
|
else
|
||||||
|
add(new CommandBolus(detailedBolusInfo, callback));
|
||||||
|
|
||||||
notifyAboutNewCommand();
|
notifyAboutNewCommand();
|
||||||
|
|
||||||
|
@ -162,7 +167,7 @@ public class CommandQueue {
|
||||||
detailedBolusInfo.insulin = MainApp.getConfigBuilder().applyBolusConstraints(detailedBolusInfo.insulin);
|
detailedBolusInfo.insulin = MainApp.getConfigBuilder().applyBolusConstraints(detailedBolusInfo.insulin);
|
||||||
detailedBolusInfo.carbs = MainApp.getConfigBuilder().applyCarbsConstraints((int) detailedBolusInfo.carbs);
|
detailedBolusInfo.carbs = MainApp.getConfigBuilder().applyCarbsConstraints((int) detailedBolusInfo.carbs);
|
||||||
|
|
||||||
BolusProgressDialog bolusProgressDialog = null;
|
BolusProgressDialog bolusProgressDialog;
|
||||||
if (detailedBolusInfo.context != null) {
|
if (detailedBolusInfo.context != null) {
|
||||||
bolusProgressDialog = new BolusProgressDialog();
|
bolusProgressDialog = new BolusProgressDialog();
|
||||||
bolusProgressDialog.setInsulin(detailedBolusInfo.insulin);
|
bolusProgressDialog.setInsulin(detailedBolusInfo.insulin);
|
||||||
|
@ -228,7 +233,7 @@ public class CommandQueue {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Double rateAfterConstraints = MainApp.getConfigBuilder().applyBolusConstraints(insulin);
|
Double rateAfterConstraints = MainApp.getConfigBuilder().applyBolusConstraints(insulin);
|
||||||
|
|
||||||
// remove all unfinished
|
// remove all unfinished
|
||||||
removeAll(Command.CommandType.EXTENDEDBOLUS);
|
removeAll(Command.CommandType.EXTENDEDBOLUS);
|
||||||
|
|
|
@ -11,6 +11,7 @@ import info.nightscout.androidaps.queue.Callback;
|
||||||
public abstract class Command {
|
public abstract class Command {
|
||||||
public enum CommandType {
|
public enum CommandType {
|
||||||
BOLUS,
|
BOLUS,
|
||||||
|
SMB_BOLUS,
|
||||||
TEMPBASAL,
|
TEMPBASAL,
|
||||||
EXTENDEDBOLUS,
|
EXTENDEDBOLUS,
|
||||||
BASALPROFILE,
|
BASALPROFILE,
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
package info.nightscout.androidaps.queue.commands;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||||
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressDialog;
|
||||||
|
import info.nightscout.androidaps.plugins.Overview.events.EventDismissBolusprogressIfRunning;
|
||||||
|
import info.nightscout.androidaps.queue.Callback;
|
||||||
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by mike on 09.11.2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class CommandSMBBolus extends Command {
|
||||||
|
DetailedBolusInfo detailedBolusInfo;
|
||||||
|
|
||||||
|
public CommandSMBBolus(DetailedBolusInfo detailedBolusInfo, Callback callback) {
|
||||||
|
commandType = CommandType.SMB_BOLUS;
|
||||||
|
this.detailedBolusInfo = detailedBolusInfo;
|
||||||
|
this.callback = callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
PumpEnactResult r = ConfigBuilderPlugin.getActivePump().deliverTreatment(detailedBolusInfo);
|
||||||
|
|
||||||
|
BolusProgressDialog.bolusEnded = true;
|
||||||
|
MainApp.bus().post(new EventDismissBolusprogressIfRunning(r));
|
||||||
|
|
||||||
|
if (callback != null)
|
||||||
|
callback.result(r).run();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String status() {
|
||||||
|
return "SMBBOLUS " + DecimalFormatter.to1Decimal(detailedBolusInfo.insulin) + "U";
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue