add checkPodKaput

This commit is contained in:
Andrei Vereha 2021-06-06 18:41:17 +02:00
parent aa719e0b9f
commit b55dacd12c
3 changed files with 14 additions and 12 deletions

View file

@ -132,8 +132,8 @@ class OmnipodDashPumpPlugin @Inject constructor(
history.updateFromState(podStateManager), history.updateFromState(podStateManager),
podStateManager.updateActiveCommand() podStateManager.updateActiveCommand()
.map { handleCommandConfirmation(it) } .map { handleCommandConfirmation(it) }
.map { checkPodKaput() }
.ignoreElement(), .ignoreElement(),
checkPodKaput()
) )
).blockingGet() ).blockingGet()
if (throwable != null) { if (throwable != null) {
@ -143,12 +143,11 @@ class OmnipodDashPumpPlugin @Inject constructor(
} }
} }
private fun checkPodKaput() { private fun checkPodKaput(): Completable = Completable.defer {
if (podStateManager.isPodKaput) { val tbr = pumpSync.expectedPumpState().temporaryBasal
val tbr = pumpSync.expectedPumpState().temporaryBasal if (podStateManager.isPodKaput &&
if (tbr?.rate == 0.0) { (tbr == null || tbr.rate != 0.0)
return ) {
}
pumpSync.syncTemporaryBasalWithPumpId( pumpSync.syncTemporaryBasalWithPumpId(
timestamp = System.currentTimeMillis(), timestamp = System.currentTimeMillis(),
rate = 0.0, rate = 0.0,
@ -160,6 +159,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
pumpSerial = serialNumber() pumpSerial = serialNumber()
) )
} }
Completable.complete()
} }
override fun setNewBasalProfile(profile: Profile): PumpEnactResult { override fun setNewBasalProfile(profile: Profile): PumpEnactResult {

View file

@ -140,7 +140,7 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
override val activeAlerts: EnumSet<AlertType>? override val activeAlerts: EnumSet<AlertType>?
get() = podState.activeAlerts get() = podState.activeAlerts
override val alarmType: AlarmType? override val alarmType: AlarmType?
get() = podState.alarmType get() = podState.alarmType
override var tempBasal: OmnipodDashPodStateManager.TempBasal? override var tempBasal: OmnipodDashPodStateManager.TempBasal?

View file

@ -296,10 +296,12 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
} }
*/ */
podStateManager.alarmType?.let { podStateManager.alarmType?.let {
errors.add(resourceHelper.gs( errors.add(
R.string.omnipod_common_pod_status_pod_fault_description, resourceHelper.gs(
it.value, R.string.omnipod_common_pod_status_pod_fault_description,
it.toString()) it.value,
it.toString()
)
) )
} }