recover active commands on start. Display deaction button after SET_UNIQUE_ID
This commit is contained in:
parent
a9f49704d9
commit
3c222f0500
|
@ -274,6 +274,11 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
|
||||
*/
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
podStateManager.onStart()
|
||||
}
|
||||
|
||||
private fun observeDeliverySuspended(): Completable = Completable.defer {
|
||||
if (podStateManager.deliveryStatus == DeliveryStatus.SUSPENDED)
|
||||
Completable.complete()
|
||||
|
|
|
@ -95,6 +95,7 @@ interface OmnipodDashPodStateManager {
|
|||
|
||||
fun createLastBolus(requestedUnits: Double, historyId: String, bolusType: DetailedBolusInfo.BolusType)
|
||||
fun markLastBolusComplete(): LastBolus?
|
||||
fun onStart()
|
||||
|
||||
data class ActiveCommand(
|
||||
val sequence: Short,
|
||||
|
|
|
@ -391,6 +391,31 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
|
|||
store()
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
when (getCommandConfirmationFromState()) {
|
||||
CommandConfirmationSuccess, CommandConfirmationDenied -> {
|
||||
val now = System.currentTimeMillis()
|
||||
val newCommand = podState.activeCommand?.copy(
|
||||
createdRealtime = now,
|
||||
sentRealtime = now + 1
|
||||
)
|
||||
podState.lastStatusResponseReceived = now + 2
|
||||
podState.activeCommand = newCommand
|
||||
}
|
||||
CommandSendingNotConfirmed -> {
|
||||
val now = System.currentTimeMillis()
|
||||
val newCommand = podState.activeCommand?.copy(
|
||||
createdRealtime = now,
|
||||
sentRealtime = now + 1
|
||||
)
|
||||
podState.lastStatusResponseReceived = 0
|
||||
}
|
||||
CommandSendingFailure, NoActiveCommand ->
|
||||
podState.activeCommand = null
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun updateFromDefaultStatusResponse(response: DefaultStatusResponse) {
|
||||
logger.debug(LTag.PUMPCOMM, "Default status response :$response")
|
||||
podState.deliveryStatus = response.deliveryStatus
|
||||
|
|
|
@ -125,7 +125,7 @@ class DashPodManagementActivity : NoSplashAppCompatActivity() {
|
|||
|
||||
binding.buttonActivatePod.isEnabled = podStateManager.activationProgress.isBefore(ActivationProgress.COMPLETED)
|
||||
binding.buttonDeactivatePod.isEnabled =
|
||||
podStateManager.activationProgress.isAtLeast(ActivationProgress.PHASE_1_COMPLETED) ||
|
||||
podStateManager.activationProgress.isAtLeast(ActivationProgress.SET_UNIQUE_ID) ||
|
||||
podStateManager.podStatus == PodStatus.ALARM
|
||||
|
||||
if (podStateManager.activationProgress.isAtLeast(ActivationProgress.PHASE_1_COMPLETED)) {
|
||||
|
|
Loading…
Reference in a new issue