RuffyScripter: fix on-connect checks to detect running bolus properly.

This commit is contained in:
Johannes Mockenhaupt 2017-12-09 22:11:41 +01:00
parent 26fa63d571
commit bb1c1f79f1
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1

View file

@ -367,14 +367,17 @@ public class RuffyScripter implements RuffyCommands {
// if everything broke before, the pump might still be delivering a bolus, if that's the case, wait for bolus to finish
Double bolusRemaining = (Double) getCurrentMenu().getAttribute(MenuAttribute.BOLUS_REMAINING);
try {
while (isConnected() && bolusRemaining != null) {
log.debug("Waiting for bolus from previous connection to complete, remaining: " + bolusRemaining);
waitForScreenUpdate();
BolusType bolusType = (BolusType) getCurrentMenu().getAttribute(MenuAttribute.BOLUS_TYPE);
if (bolusType != null && bolusType == BolusType.NORMAL) {
try {
while (isConnected() && bolusRemaining != null) {
log.debug("Waiting for bolus from previous connection to complete, remaining: " + bolusRemaining);
waitForScreenUpdate();
}
} catch (Exception e) {
log.error("Exception waiting for bolus from previous command to finish", e);
return false;
}
} catch (Exception e) {
log.error("Exception waiting for bolus from previous command to finish", e);
return false;
}
return true;
}