From 1247fded3bf7d4c30489cde9ef9392c6dc76bb70 Mon Sep 17 00:00:00 2001 From: Andrei Vereha Date: Wed, 24 Nov 2021 21:43:36 +0100 Subject: [PATCH] disable the suspend Button --- .../omnipod/dash/OmnipodDashPumpPlugin.kt | 40 +------------------ .../dash/driver/OmnipodDashManagerImpl.kt | 2 +- .../pod/command/SuspendDeliveryCommand.kt | 15 +------ .../pod/definition/BeepRepetitionType.kt | 2 +- .../dash/ui/OmnipodDashOverviewFragment.kt | 14 ++----- omnipod-dash/src/main/res/values/strings.xml | 1 - .../pod/command/ProgramAlertsCommandTest.kt | 2 +- 7 files changed, 10 insertions(+), 66 deletions(-) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt index ec66db8f4f..0edbc7b19f 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt @@ -1092,8 +1092,6 @@ class OmnipodDashPumpPlugin @Inject constructor( return when (customCommand) { is CommandSilenceAlerts -> silenceAlerts() - is CommandSuspendDelivery -> - suspendDelivery() is CommandResumeDelivery -> resumeDelivery() is CommandDeactivatePod -> @@ -1131,17 +1129,6 @@ class OmnipodDashPumpPlugin @Inject constructor( private fun disableSuspendAlerts(): PumpEnactResult { val alerts = listOf( - AlertConfiguration( - AlertType.SUSPEND_IN_PROGRESS, - enabled = false, - durationInMinutes = 0, - autoOff = false, - AlertTrigger.TimerTrigger( - 0 - ), - BeepType.XXX, - BeepRepetitionType.XXX4 - ), AlertConfiguration( AlertType.SUSPEND_ENDED, enabled = false, @@ -1151,7 +1138,7 @@ class OmnipodDashPumpPlugin @Inject constructor( 0 ), BeepType.FOUR_TIMES_BIP_BEEP, - BeepRepetitionType.EVERY_MINUTE + BeepRepetitionType.EVERY_MINUTE_AND_EVERY_15_MIN ), ) val ret = executeProgrammingCommand( @@ -1164,29 +1151,6 @@ class OmnipodDashPumpPlugin @Inject constructor( return ret } - private fun suspendDelivery(): PumpEnactResult { - return executeProgrammingCommand( - historyEntry = history.createRecord(OmnipodCommandType.SUSPEND_DELIVERY), - command = omnipodManager.suspendDelivery(hasBasalBeepEnabled()) - .filter { podEvent -> podEvent.isCommandSent() } - .map { - pumpSyncTempBasal( - 0.0, - PodConstants.MAX_POD_LIFETIME.toMinutes(), - PumpSync.TemporaryBasalType.PUMP_SUSPEND - ) - } - .ignoreElements(), - pre = observeDeliveryActive(), - ).doFinally { - notifyOnUnconfirmed( - Notification.PUMP_ERROR, - "Unconfirmed suspendDelivery command. Please refresh pod status", - R.raw.boluserror - ) - }.toPumpEnactResult() - } - private fun observeDeliveryActive(): Completable = Completable.defer { if (podStateManager.deliveryStatus != DeliveryStatus.SUSPENDED) Completable.complete() @@ -1289,7 +1253,7 @@ class OmnipodDashPumpPlugin @Inject constructor( expiryAlertDelay.toMinutes().toShort() ), BeepType.FOUR_TIMES_BIP_BEEP, - BeepRepetitionType.EVERY_MINUTE + BeepRepetitionType.EVERY_MINUTE_AND_EVERY_15_MIN ) ) return executeProgrammingCommand( diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/OmnipodDashManagerImpl.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/OmnipodDashManagerImpl.kt index fc1502d074..288153834c 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/OmnipodDashManagerImpl.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/OmnipodDashManagerImpl.kt @@ -437,7 +437,7 @@ class OmnipodDashManagerImpl @Inject constructor( userExpiryAlertDelay.toMinutes().toShort() ), BeepType.FOUR_TIMES_BIP_BEEP, - BeepRepetitionType.EVERY_MINUTE + BeepRepetitionType.EVERY_MINUTE_AND_EVERY_15_MIN ) ) } diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SuspendDeliveryCommand.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SuspendDeliveryCommand.kt index df7a847b25..c434125335 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SuspendDeliveryCommand.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SuspendDeliveryCommand.kt @@ -19,27 +19,16 @@ class SuspendDeliveryCommand private constructor( override val encoded: ByteArray get() { val alerts = listOf( - AlertConfiguration( - AlertType.SUSPEND_IN_PROGRESS, - enabled = true, - durationInMinutes = 10, - autoOff = false, - AlertTrigger.TimerTrigger( - 1 - ), - BeepType.XXX, - BeepRepetitionType.XXX4 - ), AlertConfiguration( AlertType.SUSPEND_ENDED, enabled = true, durationInMinutes = 0, autoOff = false, AlertTrigger.TimerTrigger( - 10 + 20 ), BeepType.FOUR_TIMES_BIP_BEEP, - BeepRepetitionType.EVERY_MINUTE + BeepRepetitionType.EVERY_MINUTE_AND_EVERY_15_MIN ), ) val programAlerts = ProgramAlertsCommand.Builder() diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/BeepRepetitionType.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/BeepRepetitionType.kt index 514dc1e874..1e290b9e3f 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/BeepRepetitionType.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/BeepRepetitionType.kt @@ -6,7 +6,7 @@ enum class BeepRepetitionType( ) { XXX(0x01.toByte()), // Used in lump of coal alert, LOW_RESERVOIR - EVERY_MINUTE(0x03.toByte()), // Used in USER_SET_EXPIRATION, suspend delivery + EVERY_MINUTE_AND_EVERY_15_MIN(0x03.toByte()), // Used in USER_SET_EXPIRATION, suspend delivery XXX3(0x05.toByte()), // published system expiration alert XXX4(0x06.toByte()), // Used in imminent pod expiration alert, suspend in progress. No repeat? XXX5(0x08.toByte()); // Lump of coal alert diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/OmnipodDashOverviewFragment.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/OmnipodDashOverviewFragment.kt index 4900b51eb2..0e917c3147 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/OmnipodDashOverviewFragment.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/OmnipodDashOverviewFragment.kt @@ -442,7 +442,7 @@ class OmnipodDashOverviewFragment : DaggerFragment() { AlertType.SUSPEND_IN_PROGRESS -> R.string.omnipod_common_alert_delivery_suspended AlertType.SUSPEND_ENDED -> - R.string.omnipod_common_alert_delivery_suspended2 + R.string.omnipod_common_alert_delivery_suspended else -> R.string.omnipod_common_alert_unknown_alert } @@ -633,16 +633,8 @@ class OmnipodDashOverviewFragment : DaggerFragment() { private fun updateSuspendDeliveryButton() { // If the Pod is currently suspended, we show the Resume delivery button instead. - if (isSuspendDeliveryButtonEnabled() && - podStateManager.isPodRunning && - (!podStateManager.isSuspended || commandQueue.isCustomCommandInQueue(CommandSuspendDelivery::class.java)) - ) { - buttonBinding.buttonSuspendDelivery.visibility = View.VISIBLE - buttonBinding.buttonSuspendDelivery.isEnabled = - podStateManager.isPodRunning && !podStateManager.isSuspended && isQueueEmpty() - } else { - buttonBinding.buttonSuspendDelivery.visibility = View.GONE - } + // disable the 'suspendDelivery' button. + buttonBinding.buttonSuspendDelivery.visibility = View.GONE } private fun updateSetTimeButton() { diff --git a/omnipod-dash/src/main/res/values/strings.xml b/omnipod-dash/src/main/res/values/strings.xml index 4e5953a980..f16cd9b2de 100644 --- a/omnipod-dash/src/main/res/values/strings.xml +++ b/omnipod-dash/src/main/res/values/strings.xml @@ -48,5 +48,4 @@ %1$.2f U Delivering %1$.2f U Insulin delivery is suspended - Insulin delivery is suspended 2 diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramAlertsCommandTest.kt b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramAlertsCommandTest.kt index 3cbea38f9a..05b31e66f1 100644 --- a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramAlertsCommandTest.kt +++ b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramAlertsCommandTest.kt @@ -85,7 +85,7 @@ class ProgramAlertsCommandTest { false, AlertTrigger.TimerTrigger(4079.toShort()), BeepType.FOUR_TIMES_BIP_BEEP, - BeepRepetitionType.EVERY_MINUTE + BeepRepetitionType.EVERY_MINUTE_AND_EVERY_15_MIN ) )