check 3min timeout SMB right before execution
This commit is contained in:
parent
0e9366c6fe
commit
3cfc9c16fe
|
@ -9,8 +9,11 @@ import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressDialog;
|
import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressDialog;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventDismissBolusprogressIfRunning;
|
import info.nightscout.androidaps.plugins.Overview.events.EventDismissBolusprogressIfRunning;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.queue.Callback;
|
import info.nightscout.androidaps.queue.Callback;
|
||||||
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
|
import info.nightscout.utils.T;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 09.11.2017.
|
* Created by mike on 09.11.2017.
|
||||||
|
@ -29,7 +32,11 @@ public class CommandSMBBolus extends Command {
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
PumpEnactResult r;
|
PumpEnactResult r;
|
||||||
if (detailedBolusInfo.deliverAt != 0 && detailedBolusInfo.deliverAt + 60 * 1000L > System.currentTimeMillis())
|
long lastBolusTime = TreatmentsPlugin.getPlugin().getLastBolusTime();
|
||||||
|
if (lastBolusTime != 0 && lastBolusTime + T.mins(3).msecs() > DateUtil.now()) {
|
||||||
|
log.debug("SMB requsted but still in 3 min interval");
|
||||||
|
r = new PumpEnactResult().enacted(false).success(false).comment("SMB requsted but still in 3 min interval");
|
||||||
|
} else if (detailedBolusInfo.deliverAt != 0 && detailedBolusInfo.deliverAt + T.mins(1).msecs() > System.currentTimeMillis())
|
||||||
r = ConfigBuilderPlugin.getActivePump().deliverTreatment(detailedBolusInfo);
|
r = ConfigBuilderPlugin.getActivePump().deliverTreatment(detailedBolusInfo);
|
||||||
else {
|
else {
|
||||||
r = new PumpEnactResult().enacted(false).success(false).comment("SMB request too old");
|
r = new PumpEnactResult().enacted(false).success(false).comment("SMB request too old");
|
||||||
|
|
Loading…
Reference in a new issue