Stop fetching bolus progress when pump has switched operating mode
(e.g. because of an empty cartridge)
This commit is contained in:
parent
c5241b6cad
commit
e4fd293027
1 changed files with 12 additions and 6 deletions
|
@ -535,10 +535,14 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
||||||
detailedBolusInfo.pumpId = insightBolusID.id;
|
detailedBolusInfo.pumpId = insightBolusID.id;
|
||||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, true);
|
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, true);
|
||||||
while (true) {
|
while (true) {
|
||||||
List<ActiveBolus> activeBoluses = connectionService.requestMessage(new GetActiveBolusesMessage()).await().getActiveBoluses();
|
fetchStatus();
|
||||||
|
if (operatingMode != OperatingMode.STARTED) break;
|
||||||
ActiveBolus activeBolus = null;
|
ActiveBolus activeBolus = null;
|
||||||
for (ActiveBolus bolus : activeBoluses) {
|
for (ActiveBolus bolus : activeBoluses) {
|
||||||
if (bolus.getBolusID() == bolusID) activeBolus = bolus;
|
if (bolus.getBolusID() == bolusID) {
|
||||||
|
activeBolus = bolus;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (activeBolus != null) {
|
if (activeBolus != null) {
|
||||||
trials = -1;
|
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());
|
bolusingEvent.status = MainApp.gs(R.string.insight_delivered, activeBolus.getInitialAmount() - activeBolus.getRemainingAmount(), activeBolus.getInitialAmount());
|
||||||
if (percentBefore != bolusingEvent.percent)
|
if (percentBefore != bolusingEvent.percent)
|
||||||
MainApp.bus().post(bolusingEvent);
|
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);
|
Thread.sleep(200);
|
||||||
}
|
}
|
||||||
bolusingEvent.status = MainApp.gs(R.string.insight_delivered, detailedBolusInfo.insulin, detailedBolusInfo.insulin);
|
|
||||||
bolusingEvent.percent = 100;
|
|
||||||
MainApp.bus().post(bolusingEvent);
|
|
||||||
readHistory();
|
readHistory();
|
||||||
fetchStatus();
|
fetchStatus();
|
||||||
} catch (AppLayerErrorException e) {
|
} catch (AppLayerErrorException e) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue