set TBR 0 when there is no pod
This commit is contained in:
parent
544ee9df6b
commit
e174f3982b
4 changed files with 23 additions and 7 deletions
|
@ -49,6 +49,7 @@ import io.reactivex.Completable
|
|||
import io.reactivex.Single
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.rxkotlin.plusAssign
|
||||
import io.reactivex.rxkotlin.subscribeBy
|
||||
import org.json.JSONObject
|
||||
import java.time.Duration
|
||||
import java.time.ZonedDateTime
|
||||
|
@ -108,18 +109,34 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
statusChecker = Runnable {
|
||||
refreshStatusOnUnacknowledgedCommands()
|
||||
updatePodWarnings()
|
||||
// createFakeTBRWhenNoActivePod()
|
||||
// TODO: this is called from the main thread
|
||||
aapsLogger.info(LTag.PUMP, "statusChecker")
|
||||
|
||||
val err = createFakeTBRWhenNoActivePod()
|
||||
.subscribeOn(aapsSchedulers.io)
|
||||
.subscribeBy(
|
||||
onError = {
|
||||
aapsLogger.warn(LTag.PUMP, "Error on createFakeTBRWhenNoActivePod=$it")
|
||||
},
|
||||
onComplete = {
|
||||
aapsLogger.warn(LTag.PUMP, "createFakeTBRWhenNoActivePod complete")
|
||||
}
|
||||
)
|
||||
aapsLogger.info(LTag.PUMP, "status checker err=$err")
|
||||
err?.let {
|
||||
aapsLogger.warn(LTag.PUMP, "Error on createFakeTBRWhenNoActivePod=$it")
|
||||
}
|
||||
handler.postDelayed(statusChecker, STATUS_CHECK_INTERVAL_MS)
|
||||
}
|
||||
}
|
||||
|
||||
private fun createFakeTBRWhenNoActivePod() {
|
||||
private fun createFakeTBRWhenNoActivePod(): Completable = Completable.defer {
|
||||
if (!podStateManager.isPodRunning) {
|
||||
val expectedState = pumpSync.expectedPumpState()
|
||||
val tbr = expectedState.temporaryBasal
|
||||
if (tbr == null || tbr.rate != 0.0) {
|
||||
aapsLogger.info(LTag.PUMP, "createFakeTBRWhenNoActivePod")
|
||||
// calling connectNewPump() here because pumpSerial could have changed(from 4241 to "n/a")
|
||||
pumpSync.connectNewPump()
|
||||
pumpSync.syncTemporaryBasalWithPumpId(
|
||||
timestamp = System.currentTimeMillis(),
|
||||
rate = 0.0,
|
||||
|
@ -132,6 +149,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
)
|
||||
}
|
||||
}
|
||||
Completable.complete()
|
||||
}
|
||||
|
||||
private fun updatePodWarnings() {
|
||||
|
@ -1078,6 +1096,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
historyEntry = history.createRecord(OmnipodCommandType.DEACTIVATE_POD),
|
||||
command = omnipodManager.deactivatePod().ignoreElements(),
|
||||
checkNoActiveCommand = false,
|
||||
post = createFakeTBRWhenNoActivePod(),
|
||||
).doOnComplete {
|
||||
rxBus.send(EventDismissNotification(Notification.OMNIPOD_POD_FAULT))
|
||||
}.toPumpEnactResult()
|
||||
|
|
|
@ -638,7 +638,6 @@ class OmnipodDashManagerImpl @Inject constructor(
|
|||
observeConnectToPod,
|
||||
observeSendDeactivateCommand
|
||||
).interceptPodEvents()
|
||||
//
|
||||
.doOnComplete(podStateManager::reset)
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.common.ui.wizard.activati
|
|||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.R
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.databinding.OmnipodDashPodManagementBinding
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.ActivationProgress
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodStatus
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.OmnipodDashPodStateManager
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.ui.wizard.activation.DashPodActivationWizardActivity
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.ui.wizard.deactivation.DashPodDeactivationWizardActivity
|
||||
|
|
|
@ -94,7 +94,7 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
|
|||
// These properties are only valid between onCreateView and
|
||||
// onDestroyView.
|
||||
val binding get() = _binding!!
|
||||
val bluetoothStatusBinding get() = _bluetoothStatusBinding!!
|
||||
private val bluetoothStatusBinding get() = _bluetoothStatusBinding!!
|
||||
private val podInfoBinding get() = _podInfoBinding!!
|
||||
private val buttonBinding get() = _buttonBinding!!
|
||||
|
||||
|
@ -245,7 +245,6 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
|
|||
private fun updateBluetoothConnectionStatus(event: EventPumpStatusChanged) {
|
||||
var status = event.getStatus(resourceHelper)
|
||||
bluetoothStatusBinding.omnipodDashBluetoothStatus.text = status
|
||||
|
||||
}
|
||||
|
||||
private fun updateBluetoothStatus() {
|
||||
|
|
Loading…
Reference in a new issue