Improve Pod fault notifications
This commit is contained in:
parent
36128c4007
commit
e87c568253
2 changed files with 23 additions and 11 deletions
|
@ -33,7 +33,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.defs.BeepType;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.DeliveryStatus;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.DeliveryStatus;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.DeliveryType;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.DeliveryType;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInfoType;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInfoType;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodProgressStatus;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.SetupProgress;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.SetupProgress;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.schedule.BasalSchedule;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.schedule.BasalSchedule;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState;
|
||||||
|
@ -305,16 +304,25 @@ public class OmnipodManager {
|
||||||
.observeOn(Schedulers.io()) //
|
.observeOn(Schedulers.io()) //
|
||||||
.doOnComplete(() -> {
|
.doOnComplete(() -> {
|
||||||
synchronized (bolusDataMutex) {
|
synchronized (bolusDataMutex) {
|
||||||
StatusResponse statusResponse = null;
|
double unitsNotDelivered = 0.0d;
|
||||||
|
|
||||||
for (int i = 0; i < ACTION_VERIFICATION_TRIES; i++) {
|
for (int i = 0; i < ACTION_VERIFICATION_TRIES; i++) {
|
||||||
try {
|
try {
|
||||||
// Retrieve a status response in order to update the pod state
|
// Retrieve a status response in order to update the pod state
|
||||||
statusResponse = getPodStatus();
|
StatusResponse statusResponse = getPodStatus();
|
||||||
if (statusResponse.getDeliveryStatus().isBolusing()) {
|
if (statusResponse.getDeliveryStatus().isBolusing()) {
|
||||||
throw new IllegalDeliveryStatusException(DeliveryStatus.NORMAL, statusResponse.getDeliveryStatus());
|
throw new IllegalDeliveryStatusException(DeliveryStatus.NORMAL, statusResponse.getDeliveryStatus());
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} catch (PodFaultException ex) {
|
||||||
|
// Substract units not delivered in case of a Pod failure
|
||||||
|
unitsNotDelivered = ex.getFaultEvent().getInsulinNotDelivered();
|
||||||
|
|
||||||
|
if (isLoggingEnabled()) {
|
||||||
|
LOG.debug("Caught PodFaultException in bolus completion verification", ex);
|
||||||
|
}
|
||||||
|
break;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
if (isLoggingEnabled()) {
|
if (isLoggingEnabled()) {
|
||||||
LOG.debug("Ignoring exception in bolus completion verification", ex);
|
LOG.debug("Ignoring exception in bolus completion verification", ex);
|
||||||
|
@ -322,9 +330,6 @@ public class OmnipodManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Substract units not delivered in case of a Pod failure
|
|
||||||
double unitsNotDelivered = statusResponse != null && PodProgressStatus.FAULT_EVENT_OCCURRED.equals(statusResponse.getPodProgressStatus()) ? statusResponse.getInsulinNotDelivered() : 0.0D;
|
|
||||||
|
|
||||||
if (hasActiveBolus()) {
|
if (hasActiveBolus()) {
|
||||||
activeBolusData.bolusCompletionSubject.onSuccess(new BolusDeliveryResult(units - unitsNotDelivered));
|
activeBolusData.bolusCompletionSubject.onSuccess(new BolusDeliveryResult(units - unitsNotDelivered));
|
||||||
activeBolusData = null;
|
activeBolusData = null;
|
||||||
|
|
|
@ -326,6 +326,10 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
||||||
|
|
||||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false);
|
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false);
|
||||||
|
|
||||||
|
if (delegate.getPodState().hasFaultEvent()) {
|
||||||
|
showPodFaultErrorDialog(delegate.getPodState().getFaultEvent().getFaultEventType(), R.raw.urgentalarm);
|
||||||
|
}
|
||||||
|
|
||||||
return new PumpEnactResult().success(true).enacted(true).bolusDelivered(unitsDelivered);
|
return new PumpEnactResult().success(true).enacted(true).bolusDelivered(unitsDelivered);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,7 +343,7 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
||||||
addSuccessToHistory(time, PodHistoryEntryType.CancelBolus, null);
|
addSuccessToHistory(time, PodHistoryEntryType.CancelBolus, null);
|
||||||
return new PumpEnactResult().success(true).enacted(true);
|
return new PumpEnactResult().success(true).enacted(true);
|
||||||
} catch (PodFaultException ex) {
|
} catch (PodFaultException ex) {
|
||||||
showErrorDialog(createPodFaultErrorMessage(ex.getFaultEvent().getFaultEventType()), null);
|
showPodFaultErrorDialog(ex.getFaultEvent().getFaultEventType(), null);
|
||||||
addSuccessToHistory(time, PodHistoryEntryType.CancelBolus, null);
|
addSuccessToHistory(time, PodHistoryEntryType.CancelBolus, null);
|
||||||
return new PumpEnactResult().success(true).enacted(true);
|
return new PumpEnactResult().success(true).enacted(true);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
@ -359,9 +363,7 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
||||||
delegate.setTemporaryBasal(PumpType.Insulet_Omnipod.determineCorrectBasalSize(tempBasalPair.getInsulinRate()), Duration.standardMinutes(tempBasalPair.getDurationMinutes()), beepsEnabled, beepsEnabled);
|
delegate.setTemporaryBasal(PumpType.Insulet_Omnipod.determineCorrectBasalSize(tempBasalPair.getInsulinRate()), Duration.standardMinutes(tempBasalPair.getDurationMinutes()), beepsEnabled, beepsEnabled);
|
||||||
time = System.currentTimeMillis();
|
time = System.currentTimeMillis();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
if (ex instanceof PodFaultException) {
|
if ((ex instanceof OmnipodException) && !((OmnipodException) ex).isCertainFailure()) {
|
||||||
showErrorDialog(createPodFaultErrorMessage(((PodFaultException) ex).getFaultEvent().getFaultEventType()), R.raw.urgentalarm);
|
|
||||||
} else if ((ex instanceof OmnipodException) && !((OmnipodException) ex).isCertainFailure()) {
|
|
||||||
addToHistory(time, PodHistoryEntryType.SetTemporaryBasal, "Uncertain failure", false);
|
addToHistory(time, PodHistoryEntryType.SetTemporaryBasal, "Uncertain failure", false);
|
||||||
return new PumpEnactResult().success(false).enacted(false).comment(getStringResource(R.string.omnipod_error_set_temp_basal_failed_uncertain));
|
return new PumpEnactResult().success(false).enacted(false).comment(getStringResource(R.string.omnipod_error_set_temp_basal_failed_uncertain));
|
||||||
}
|
}
|
||||||
|
@ -617,6 +619,7 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
||||||
comment = getStringResource(R.string.omnipod_driver_error_not_enough_data);
|
comment = getStringResource(R.string.omnipod_driver_error_not_enough_data);
|
||||||
} else if (ex instanceof PodFaultException) {
|
} else if (ex instanceof PodFaultException) {
|
||||||
FaultEventType faultEventType = ((PodFaultException) ex).getFaultEvent().getFaultEventType();
|
FaultEventType faultEventType = ((PodFaultException) ex).getFaultEvent().getFaultEventType();
|
||||||
|
showPodFaultErrorDialog(faultEventType, R.raw.urgentalarm);
|
||||||
comment = createPodFaultErrorMessage(faultEventType);
|
comment = createPodFaultErrorMessage(faultEventType);
|
||||||
} else if (ex instanceof PodReturnedErrorResponseException) {
|
} else if (ex instanceof PodReturnedErrorResponseException) {
|
||||||
comment = getStringResource(R.string.omnipod_driver_error_pod_returned_error_response);
|
comment = getStringResource(R.string.omnipod_driver_error_pod_returned_error_response);
|
||||||
|
@ -648,6 +651,10 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
||||||
RxBus.INSTANCE.send(event);
|
RxBus.INSTANCE.send(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showPodFaultErrorDialog(FaultEventType faultEventType, Integer sound) {
|
||||||
|
showErrorDialog(createPodFaultErrorMessage(faultEventType), sound);
|
||||||
|
}
|
||||||
|
|
||||||
private void showErrorDialog(String message, Integer sound) {
|
private void showErrorDialog(String message, Integer sound) {
|
||||||
Intent intent = new Intent(MainApp.instance(), ErrorHelperActivity.class);
|
Intent intent = new Intent(MainApp.instance(), ErrorHelperActivity.class);
|
||||||
intent.putExtra("soundid", sound == null ? 0 : sound);
|
intent.putExtra("soundid", sound == null ? 0 : sound);
|
||||||
|
|
Loading…
Reference in a new issue