Fix race condition for bolus cancel
This commit is contained in:
parent
a282124497
commit
71c4c411b2
|
@ -152,6 +152,8 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
|||
}
|
||||
};
|
||||
|
||||
private final Object $bolusLock = new Object[0];
|
||||
private boolean bolusInProgress;
|
||||
private int bolusID = -1;
|
||||
private List<BasalProfileBlock> profileBlocks;
|
||||
private boolean limitsFetched;
|
||||
|
@ -498,12 +500,14 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
|||
PumpEnactResult result = new PumpEnactResult();
|
||||
if (detailedBolusInfo.insulin > 0) {
|
||||
try {
|
||||
synchronized ($bolusLock) {
|
||||
DeliverBolusMessage bolusMessage = new DeliverBolusMessage();
|
||||
bolusMessage.setBolusType(BolusType.STANDARD);
|
||||
bolusMessage.setDuration(0);
|
||||
bolusMessage.setExtendedAmount(0);
|
||||
bolusMessage.setImmediateAmount(detailedBolusInfo.insulin);
|
||||
bolusID = connectionService.requestMessage(bolusMessage).await().getBolusId();
|
||||
}
|
||||
result.success = true;
|
||||
result.enacted = true;
|
||||
Treatment t = new Treatment();
|
||||
|
@ -562,6 +566,7 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
|||
@Override
|
||||
public void stopBolusDelivering() {
|
||||
new Thread(() -> {
|
||||
synchronized ($bolusLock) {
|
||||
try {
|
||||
alertService.ignore(AlertType.WARNING_38);
|
||||
CancelBolusMessage cancelBolusMessage = new CancelBolusMessage();
|
||||
|
@ -573,6 +578,7 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
|||
} catch (Exception e) {
|
||||
log.error("Exception while canceling bolus", e);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue