Bolusing: make cancellation during 'confirmation wait window' robust.

This commit is contained in:
Johannes Mockenhaupt 2017-12-15 22:38:28 +01:00
parent b9f12aeddb
commit 7e7b11ba14
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1

View file

@ -19,7 +19,6 @@ import de.jotomo.ruffyscripter.RuffyScripter;
import static de.jotomo.ruffy.spi.BolusProgressReporter.State.DELIVERED;
import static de.jotomo.ruffy.spi.BolusProgressReporter.State.DELIVERING;
import static de.jotomo.ruffy.spi.BolusProgressReporter.State.FINISHED;
import static de.jotomo.ruffy.spi.BolusProgressReporter.State.PROGRAMMING;
import static de.jotomo.ruffy.spi.BolusProgressReporter.State.STOPPED;
import static de.jotomo.ruffy.spi.BolusProgressReporter.State.STOPPING;
@ -128,6 +127,15 @@ public class BolusCommand extends BaseCommand {
}
Integer warningCode = warningOrErrorCode.warningCode;
if (Objects.equals(warningCode, PumpWarningCodes.BOLUS_CANCELLED)) {
// wait until cancellation thread releases the up button, otherwise we won't
// be able to confirm anything
if (cancellationThread != null) {
try {
cancellationThread.join(3500);
} catch (InterruptedException e) {
// ignore
}
}
scripter.confirmAlert(PumpWarningCodes.BOLUS_CANCELLED, 2000);
bolusProgressReporter.report(STOPPED, 0, 0);
log.debug("Stage 3: confirmed BOLUS CANCELLED after cancelling bolus during delivery");