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 int bolusID = -1;
|
||||||
private List<BasalProfileBlock> profileBlocks;
|
private List<BasalProfileBlock> profileBlocks;
|
||||||
private boolean limitsFetched;
|
private boolean limitsFetched;
|
||||||
|
@ -498,12 +500,14 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
if (detailedBolusInfo.insulin > 0) {
|
if (detailedBolusInfo.insulin > 0) {
|
||||||
try {
|
try {
|
||||||
|
synchronized ($bolusLock) {
|
||||||
DeliverBolusMessage bolusMessage = new DeliverBolusMessage();
|
DeliverBolusMessage bolusMessage = new DeliverBolusMessage();
|
||||||
bolusMessage.setBolusType(BolusType.STANDARD);
|
bolusMessage.setBolusType(BolusType.STANDARD);
|
||||||
bolusMessage.setDuration(0);
|
bolusMessage.setDuration(0);
|
||||||
bolusMessage.setExtendedAmount(0);
|
bolusMessage.setExtendedAmount(0);
|
||||||
bolusMessage.setImmediateAmount(detailedBolusInfo.insulin);
|
bolusMessage.setImmediateAmount(detailedBolusInfo.insulin);
|
||||||
bolusID = connectionService.requestMessage(bolusMessage).await().getBolusId();
|
bolusID = connectionService.requestMessage(bolusMessage).await().getBolusId();
|
||||||
|
}
|
||||||
result.success = true;
|
result.success = true;
|
||||||
result.enacted = true;
|
result.enacted = true;
|
||||||
Treatment t = new Treatment();
|
Treatment t = new Treatment();
|
||||||
|
@ -562,6 +566,7 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
||||||
@Override
|
@Override
|
||||||
public void stopBolusDelivering() {
|
public void stopBolusDelivering() {
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
|
synchronized ($bolusLock) {
|
||||||
try {
|
try {
|
||||||
alertService.ignore(AlertType.WARNING_38);
|
alertService.ignore(AlertType.WARNING_38);
|
||||||
CancelBolusMessage cancelBolusMessage = new CancelBolusMessage();
|
CancelBolusMessage cancelBolusMessage = new CancelBolusMessage();
|
||||||
|
@ -573,6 +578,7 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Exception while canceling bolus", e);
|
log.error("Exception while canceling bolus", e);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue