check 3min timeout SMB right before execution

This commit is contained in:
Milos Kozak 2018-04-01 22:33:32 +02:00
parent 0e9366c6fe
commit 3cfc9c16fe

View file

@ -9,8 +9,11 @@ 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.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.androidaps.queue.Callback;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.T;
/**
* Created by mike on 09.11.2017.
@ -29,7 +32,11 @@ public class CommandSMBBolus extends Command {
@Override
public void execute() {
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);
else {
r = new PumpEnactResult().enacted(false).success(false).comment("SMB request too old");