From e4fd293027d7b001d74bfe614105747cda9a1ba2 Mon Sep 17 00:00:00 2001 From: TebbeUbben Date: Sat, 9 Feb 2019 22:08:49 +0100 Subject: [PATCH] Stop fetching bolus progress when pump has switched operating mode (e.g. because of an empty cartridge) --- .../PumpInsightLocal/LocalInsightPlugin.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsightLocal/LocalInsightPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsightLocal/LocalInsightPlugin.java index 5043d98cda..53fb720132 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsightLocal/LocalInsightPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsightLocal/LocalInsightPlugin.java @@ -535,10 +535,14 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con detailedBolusInfo.pumpId = insightBolusID.id; TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, true); while (true) { - List activeBoluses = connectionService.requestMessage(new GetActiveBolusesMessage()).await().getActiveBoluses(); + fetchStatus(); + if (operatingMode != OperatingMode.STARTED) break; ActiveBolus activeBolus = null; for (ActiveBolus bolus : activeBoluses) { - if (bolus.getBolusID() == bolusID) activeBolus = bolus; + if (bolus.getBolusID() == bolusID) { + activeBolus = bolus; + break; + } } if (activeBolus != null) { trials = -1; @@ -547,12 +551,14 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con bolusingEvent.status = MainApp.gs(R.string.insight_delivered, activeBolus.getInitialAmount() - activeBolus.getRemainingAmount(), activeBolus.getInitialAmount()); if (percentBefore != bolusingEvent.percent) MainApp.bus().post(bolusingEvent); - } else if (trials == -1 || trials++ >= 5) break; + } else if (trials == -1 || trials++ >= 5) { + bolusingEvent.status = MainApp.gs(R.string.insight_delivered, detailedBolusInfo.insulin, detailedBolusInfo.insulin); + bolusingEvent.percent = 100; + MainApp.bus().post(bolusingEvent); + break; + } Thread.sleep(200); } - bolusingEvent.status = MainApp.gs(R.string.insight_delivered, detailedBolusInfo.insulin, detailedBolusInfo.insulin); - bolusingEvent.percent = 100; - MainApp.bus().post(bolusingEvent); readHistory(); fetchStatus(); } catch (AppLayerErrorException e) {