Update bolus progress dialog when recovery kicks in.
This commit is contained in:
parent
97a9d65b52
commit
618e00d71d
2 changed files with 12 additions and 3 deletions
|
@ -404,6 +404,8 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
case STOPPED:
|
case STOPPED:
|
||||||
event.status = MainApp.sResources.getString(R.string.bolusstopped);
|
event.status = MainApp.sResources.getString(R.string.bolusstopped);
|
||||||
break;
|
break;
|
||||||
|
case RECOVERING:
|
||||||
|
event.status = "Connection was interrupted. Please wait while recovery takes place.";
|
||||||
case FINISHED:
|
case FINISHED:
|
||||||
// no state, just percent below to close bolus progress dialog
|
// no state, just percent below to close bolus progress dialog
|
||||||
break;
|
break;
|
||||||
|
@ -466,11 +468,15 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
return new PumpEnactResult().success(true).enacted(false);
|
return new PumpEnactResult().success(true).enacted(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BolusProgressReporter progressReporter = detailedBolusInfo.isSMB ? nullBolusProgressReporter : ComboPlugin.bolusProgressReporter;
|
||||||
|
|
||||||
// start bolus delivery
|
// start bolus delivery
|
||||||
bolusInProgress = true;
|
bolusInProgress = true;
|
||||||
CommandResult bolusCmdResult = runCommand(null, 0,
|
CommandResult bolusCmdResult = runCommand(null, 0,
|
||||||
() -> ruffyScripter.deliverBolus(detailedBolusInfo.insulin,
|
() -> {
|
||||||
detailedBolusInfo.isSMB ? nullBolusProgressReporter : bolusProgressReporter));
|
return ruffyScripter.deliverBolus(detailedBolusInfo.insulin,
|
||||||
|
progressReporter);
|
||||||
|
});
|
||||||
bolusInProgress = false;
|
bolusInProgress = false;
|
||||||
|
|
||||||
if (bolusCmdResult.success) {
|
if (bolusCmdResult.success) {
|
||||||
|
@ -485,6 +491,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
.bolusDelivered(bolusCmdResult.delivered)
|
.bolusDelivered(bolusCmdResult.delivered)
|
||||||
.carbsDelivered(detailedBolusInfo.carbs);
|
.carbsDelivered(detailedBolusInfo.carbs);
|
||||||
} else {
|
} else {
|
||||||
|
progressReporter.report(BolusProgressReporter.State.RECOVERING, 0, 0);
|
||||||
return recoverFromErrorDuringBolusDelivery(detailedBolusInfo, pumpTimeWhenBolusWasRequested);
|
return recoverFromErrorDuringBolusDelivery(detailedBolusInfo, pumpTimeWhenBolusWasRequested);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -509,7 +516,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
*/
|
*/
|
||||||
private PumpEnactResult recoverFromErrorDuringBolusDelivery(DetailedBolusInfo detailedBolusInfo, long pumpTimeWhenBolusWasRequested) {
|
private PumpEnactResult recoverFromErrorDuringBolusDelivery(DetailedBolusInfo detailedBolusInfo, long pumpTimeWhenBolusWasRequested) {
|
||||||
log.debug("Trying to determine from pump history what was actually delivered");
|
log.debug("Trying to determine from pump history what was actually delivered");
|
||||||
CommandResult readLastBolusResult = runCommand(MainApp.sResources.getString(R.string.combo_activity_verifying_delivered_bolus), 3,
|
CommandResult readLastBolusResult = runCommand(null , 3,
|
||||||
() -> ruffyScripter.readHistory(new PumpHistoryRequest().bolusHistory(PumpHistoryRequest.LAST)));
|
() -> ruffyScripter.readHistory(new PumpHistoryRequest().bolusHistory(PumpHistoryRequest.LAST)));
|
||||||
if (!readLastBolusResult.success || readLastBolusResult.history == null) {
|
if (!readLastBolusResult.success || readLastBolusResult.history == null) {
|
||||||
// this happens when the cartridge runs empty during delivery, the pump will be in an error
|
// this happens when the cartridge runs empty during delivery, the pump will be in an error
|
||||||
|
@ -520,6 +527,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
|
|
||||||
List<Bolus> bolusHistory = readLastBolusResult.history.bolusHistory;
|
List<Bolus> bolusHistory = readLastBolusResult.history.bolusHistory;
|
||||||
Bolus lastBolus = !bolusHistory.isEmpty() ? bolusHistory.get(0) : null;
|
Bolus lastBolus = !bolusHistory.isEmpty() ? bolusHistory.get(0) : null;
|
||||||
|
log.debug("Last bolus read from history: " + lastBolus + ", request time: " + pumpTimeWhenBolusWasRequested);
|
||||||
|
|
||||||
if (lastBolus == null // no bolus ever given
|
if (lastBolus == null // no bolus ever given
|
||||||
|| lastBolus.timestamp < pumpTimeWhenBolusWasRequested // this is not the bolus you're looking for
|
|| lastBolus.timestamp < pumpTimeWhenBolusWasRequested // this is not the bolus you're looking for
|
||||||
|
|
|
@ -7,6 +7,7 @@ public interface BolusProgressReporter {
|
||||||
DELIVERED,
|
DELIVERED,
|
||||||
STOPPING,
|
STOPPING,
|
||||||
STOPPED,
|
STOPPED,
|
||||||
|
RECOVERING,
|
||||||
FINISHED
|
FINISHED
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue