From 9f57f82b6adde12ad8bd594de905da3f3869e1fc Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Thu, 24 Aug 2017 15:31:27 +0200 Subject: [PATCH] Remove wait for carb-only treatment. --- .../plugins/PumpCombo/ComboPlugin.java | 37 +++---------------- .../plugins/PumpCombo/ComboPump.java | 4 ++ 2 files changed, 10 insertions(+), 31 deletions(-) create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPump.java diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java index 8f3efb408e..b1c8b157be 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java @@ -54,6 +54,7 @@ import info.nightscout.androidaps.interfaces.ProfileInterface; import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; +import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress; import info.nightscout.androidaps.plugins.PumpCombo.events.EventComboPumpUpdateGUI; import info.nightscout.utils.DateUtil; import info.nightscout.utils.SP; @@ -377,40 +378,10 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf if (!Config.comboSplitBoluses) { return deliverBolus(detailedBolusInfo); } else { - // split up bolus into 2 U parts - PumpEnactResult pumpEnactResult = new PumpEnactResult(); - pumpEnactResult.success = true; - pumpEnactResult.enacted = true; - pumpEnactResult.bolusDelivered = 0d; - pumpEnactResult.carbsDelivered = detailedBolusInfo.carbs; - pumpEnactResult.comment = MainApp.instance().getString(R.string.virtualpump_resultok); - - double remainingBolus = detailedBolusInfo.insulin; - int split = 1; - while (remainingBolus > 0.05) { - double bolus = remainingBolus > 2 ? 2 : remainingBolus; - DetailedBolusInfo bolusInfo = new DetailedBolusInfo(); - bolusInfo.insulin = bolus; - bolusInfo.isValid = false; - log.debug("Delivering split bolus #" + split + " with " + bolus + " U"); - PumpEnactResult bolusResult = deliverBolus(bolusInfo); - if (!bolusResult.success) { - return bolusResult; - } - pumpEnactResult.bolusDelivered += bolus; - remainingBolus -= 2; - split++; - } - MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo); - return pumpEnactResult; + return deliverSplittedBolus(detailedBolusInfo); } } else { // no bolus required, carb only treatment - - // TODO the ui freezes when the calculator issues a carb-only treatment - // so just wait, yeah, this is dumb. for now; proper fix via GL#10 - // info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressDialog.scheduleDismiss() - SystemClock.sleep(6000); PumpEnactResult pumpEnactResult = new PumpEnactResult(); pumpEnactResult.success = true; pumpEnactResult.enacted = true; @@ -418,6 +389,10 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf pumpEnactResult.carbsDelivered = detailedBolusInfo.carbs; pumpEnactResult.comment = MainApp.instance().getString(R.string.virtualpump_resultok); MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo); + + EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance(); + bolusingEvent.percent = 100; + MainApp.bus().post(bolusingEvent); return pumpEnactResult; } } else { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPump.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPump.java new file mode 100644 index 0000000000..c9581f5911 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPump.java @@ -0,0 +1,4 @@ +package info.nightscout.androidaps.plugins.PumpCombo; + +public class ComboPump { +}