fix deactivation

This commit is contained in:
Andrei Vereha 2021-10-31 00:22:50 +02:00
parent 42daad43f4
commit c68491ba78

View file

@ -310,8 +310,8 @@ class OmnipodDashPumpPlugin @Inject constructor(
) )
private fun checkPodKaput(): Completable = Completable.defer { private fun checkPodKaput(): Completable = Completable.defer {
val tbr = pumpSync.expectedPumpState().temporaryBasal
if (podStateManager.isPodKaput) { if (podStateManager.isPodKaput) {
val tbr = pumpSync.expectedPumpState().temporaryBasal
if (tbr == null || tbr.rate != 0.0) { if (tbr == null || tbr.rate != 0.0) {
pumpSync.syncTemporaryBasalWithPumpId( pumpSync.syncTemporaryBasalWithPumpId(
timestamp = System.currentTimeMillis(), timestamp = System.currentTimeMillis(),
@ -340,15 +340,17 @@ class OmnipodDashPumpPlugin @Inject constructor(
aapsLogger.info(LTag.PUMP, "syncBolusWithPumpId on CANCEL_BOLUS returned: $sync") aapsLogger.info(LTag.PUMP, "syncBolusWithPumpId on CANCEL_BOLUS returned: $sync")
} }
} }
podStateManager.alarmType?.let {
showNotification( showNotification(
Notification.OMNIPOD_POD_FAULT, Notification.OMNIPOD_POD_FAULT,
podStateManager.alarmType.toString(), it.toString(),
Notification.URGENT, Notification.URGENT,
R.raw.boluserror R.raw.boluserror
) )
if (!podStateManager.alarmSynced) { if (!podStateManager.alarmSynced) {
pumpSync.insertAnnouncement( pumpSync.insertAnnouncement(
error = podStateManager.alarmType?.toString() ?: "Unknown pod failure", error = it.toString(),
pumpId = Random.Default.nextLong(), pumpId = Random.Default.nextLong(),
pumpType = PumpType.OMNIPOD_DASH, pumpType = PumpType.OMNIPOD_DASH,
pumpSerial = serialNumber() pumpSerial = serialNumber()
@ -356,6 +358,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
podStateManager.alarmSynced = true podStateManager.alarmSynced = true
} }
} }
}
Completable.complete() Completable.complete()
} }
@ -1165,14 +1168,14 @@ class OmnipodDashPumpPlugin @Inject constructor(
val ret = executeProgrammingCommand( val ret = executeProgrammingCommand(
historyEntry = history.createRecord(OmnipodCommandType.DEACTIVATE_POD), historyEntry = history.createRecord(OmnipodCommandType.DEACTIVATE_POD),
command = omnipodManager.deactivatePod().ignoreElements(), command = omnipodManager.deactivatePod().ignoreElements(),
checkNoActiveCommand = false, checkNoActiveCommand = false
post = createFakeTBRWhenNoActivePod(),
).doOnComplete { ).doOnComplete {
if (podStateManager.activeCommand != null) { if (podStateManager.activeCommand != null) {
success = false success = false
} } else {
podStateManager.reset() podStateManager.reset()
rxBus.send(EventDismissNotification(Notification.OMNIPOD_POD_FAULT)) rxBus.send(EventDismissNotification(Notification.OMNIPOD_POD_FAULT))
}
}.toPumpEnactResult() }.toPumpEnactResult()
if (!success) { if (!success) {
ret.success(false) ret.success(false)