From 0546976cbb6df75d9413c2d3deb7a5c07357c380 Mon Sep 17 00:00:00 2001 From: Theo van Elsberg Date: Mon, 4 Oct 2021 22:36:38 +0200 Subject: [PATCH 1/5] Prevent connection quality to exceed 100% --- .../driver/pod/state/OmnipodDashPodStateManagerImpl.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt index 0195dbeb67..e9368c2954 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt @@ -627,11 +627,14 @@ class OmnipodDashPodStateManagerImpl @Inject constructor( } override fun connectionSuccessRatio(): Float { - val attempts = connectionAttempts - if (attempts == 0) { + if (connectionAttempts == 0) { return 0.0F } - return successfulConnections.toFloat() / attempts.toFloat() + else if (connectionAttempts <= successfulConnections) { + // Prevent bogus quality > 1 during initialisation + return 1.0F + } + return successfulConnections.toFloat() / connectionAttempts.toFloat() } override fun reset() { From 5ffe61d6c4b592a765cf2695b4b27d075561bdff Mon Sep 17 00:00:00 2001 From: Theo van Elsberg Date: Mon, 4 Oct 2021 22:38:37 +0200 Subject: [PATCH 2/5] Move fixed values to PodConstants --- .../plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt | 4 ++-- .../pump/omnipod/dash/driver/OmnipodDashManagerImpl.kt | 4 ++-- .../omnipod/dash/driver/pod/definition/PodConstants.kt | 9 ++++++++- .../driver/pod/state/OmnipodDashPodStateManagerImpl.kt | 2 +- .../pump/omnipod/dash/ui/OmnipodDashOverviewFragment.kt | 8 ++++---- 5 files changed, 17 insertions(+), 10 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 9ac1b96278..364a138484 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 @@ -510,7 +510,7 @@ class OmnipodDashPumpPlugin @Inject constructor( // Omnipod only reports reservoir level when there's < 1023 pulses left return podStateManager.pulsesRemaining?.let { - it * 0.05 + it * PodConstants.POD_PULSE_BOLUS_UNITS } ?: 75.0 } @@ -724,7 +724,7 @@ class OmnipodDashPumpPlugin @Inject constructor( } private fun estimateBolusDeliverySeconds(requestedBolusAmount: Double): Long { - return ceil(requestedBolusAmount / 0.05).toLong() * 2 + 3 + return ceil(requestedBolusAmount / PodConstants.POD_PULSE_BOLUS_UNITS).toLong() * 2 + 3 } private fun pumpSyncBolusStart( 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 d64ea2ef42..3e9c78ed4e 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 @@ -278,7 +278,7 @@ class OmnipodDashManagerImpl @Inject constructor( .setUniqueId(podStateManager.uniqueId!!.toInt()) .setSequenceNumber(podStateManager.messageSequenceNumber) .setNonce(NONCE) - .setNumberOfUnits(podStateManager.firstPrimeBolusVolume!! * 0.05) + .setNumberOfUnits(podStateManager.firstPrimeBolusVolume!! * PodConstants.POD_PRIMING_BOLUS_UNITS) .setDelayBetweenPulsesInEighthSeconds(podStateManager.primePulseRate!!.toByte()) .setProgramReminder(ProgramReminder(atStart = false, atEnd = false, atInterval = 0)) .build(), @@ -380,7 +380,7 @@ class OmnipodDashManagerImpl @Inject constructor( ) observables.add( observeSendProgramBolusCommand( - podStateManager.secondPrimeBolusVolume!! * 0.05, + podStateManager.secondPrimeBolusVolume!! * PodConstants.POD_CANNULA_INSERTION_BOLUS_UNITS, podStateManager.primePulseRate!!.toByte(), confirmationBeeps = false, completionBeeps = false diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/PodConstants.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/PodConstants.kt index 915c6b7bde..f6901d34d7 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/PodConstants.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/PodConstants.kt @@ -4,6 +4,13 @@ import java.time.Duration class PodConstants { companion object { - val MAX_POD_LIFETIME = Duration.ofHours(80) + val MAX_POD_LIFETIME : Duration = Duration.ofHours(80) + + const val POD_PULSE_BOLUS_UNITS = 0.05 + // Priming + const val POD_PRIMING_BOLUS_UNITS = 0.05 + const val POD_CANNULA_INSERTION_BOLUS_UNITS = 0.05 + // Reservoir + const val DEFAULT_MAX_RESERVOIR_ALERT_THRESHOLD : Short = 20 } } diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt index e9368c2954..37798a8412 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt @@ -311,7 +311,7 @@ class OmnipodDashPodStateManagerImpl @Inject constructor( private fun updateLastBolusFromResponse(bolusPulsesRemaining: Short) { podState.lastBolus?.run { - val remainingUnits = bolusPulsesRemaining.toDouble() * 0.05 + val remainingUnits = bolusPulsesRemaining.toDouble() * PodConstants.POD_PULSE_BOLUS_UNITS this.bolusUnitsRemaining = remainingUnits if (remainingUnits == 0.0) { this.deliveryComplete = true 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 d0267f0589..fd0d3785e5 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 @@ -33,6 +33,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.databinding.OmnipodD import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.ActivationProgress import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertType import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.OmnipodDashPodStateManager +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants import info.nightscout.androidaps.queue.Callback import info.nightscout.androidaps.queue.events.EventQueueChanged import info.nightscout.androidaps.utils.DateUtil @@ -68,7 +69,6 @@ class OmnipodDashOverviewFragment : DaggerFragment() { @Inject lateinit var buildHelper: BuildHelper companion object { - private const val REFRESH_INTERVAL_MILLIS = 15 * 1000L // 15 seconds private const val PLACEHOLDER = "-" private const val MAX_TIME_DEVIATION_MINUTES = 10L @@ -372,7 +372,7 @@ class OmnipodDashOverviewFragment : DaggerFragment() { if (podStateManager.isActivationCompleted && podStateManager.pulsesDelivered != null) { resourceHelper.gs( R.string.omnipod_common_overview_total_delivered_value, - podStateManager.pulsesDelivered!! * 0.05 + (podStateManager.pulsesDelivered!! * PodConstants.POD_PULSE_BOLUS_UNITS) ) } else { PLACEHOLDER @@ -387,11 +387,11 @@ class OmnipodDashOverviewFragment : DaggerFragment() { // TODO // val lowReservoirThreshold = (omnipodAlertUtil.lowReservoirAlertUnits // ?: OmnipodConstants.DEFAULT_MAX_RESERVOIR_ALERT_THRESHOLD).toDouble() - val lowReservoirThreshold: Short = 20 + val lowReservoirThreshold: Short = PodConstants.DEFAULT_MAX_RESERVOIR_ALERT_THRESHOLD podInfoBinding.reservoir.text = resourceHelper.gs( R.string.omnipod_common_overview_reservoir_value, - (podStateManager.pulsesRemaining!! * 0.05) + (podStateManager.pulsesRemaining!! * PodConstants.POD_PULSE_BOLUS_UNITS) ) podInfoBinding.reservoir.setTextColor( if (podStateManager.pulsesRemaining!! < lowReservoirThreshold) { From 30342f2e23b87ec9ee6452b7dc1f91dc40154163 Mon Sep 17 00:00:00 2001 From: Theo van Elsberg Date: Tue, 5 Oct 2021 00:07:09 +0200 Subject: [PATCH 3/5] Move fixed values for expiration alerts to PodConstants --- .../omnipod/dash/driver/OmnipodDashManagerImpl.kt | 13 ++++++------- .../dash/driver/pod/definition/PodConstants.kt | 15 +++++++++++++-- 2 files changed, 19 insertions(+), 9 deletions(-) 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 3e9c78ed4e..0828b50c74 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 @@ -9,6 +9,9 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.* import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.GetVersionCommand.Companion.DEFAULT_UNIQUE_ID import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.* import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants.Companion.MAX_POD_LIFETIME +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants.Companion.POD_EXPIRATION_ALERT_MINUTES_DURATION +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants.Companion.POD_EXPIRATION_EMINENT_ALERT_MINUTES +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants.Companion.POD_EXPIRATION_ALERT_MINUTES import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.* import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.OmnipodDashPodStateManager import info.nightscout.androidaps.utils.rx.AapsSchedulers @@ -394,11 +397,9 @@ class OmnipodDashManagerImpl @Inject constructor( AlertConfiguration( AlertType.EXPIRATION, enabled = true, - durationInMinutes = TimeUnit.HOURS.toMinutes(7).toShort(), + durationInMinutes = POD_EXPIRATION_ALERT_MINUTES_DURATION.toShort(), autoOff = false, - AlertTrigger.TimerTrigger( - TimeUnit.HOURS.toMinutes(72).toShort() - ), // FIXME use activation time + AlertTrigger.TimerTrigger(POD_EXPIRATION_ALERT_MINUTES.toShort()), // FIXME use activation time BeepType.FOUR_TIMES_BIP_BEEP, BeepRepetitionType.XXX3 ), @@ -407,9 +408,7 @@ class OmnipodDashManagerImpl @Inject constructor( enabled = true, durationInMinutes = 0, autoOff = false, - AlertTrigger.TimerTrigger( - TimeUnit.HOURS.toMinutes(79).toShort() - ), // FIXME use activation time + AlertTrigger.TimerTrigger(POD_EXPIRATION_EMINENT_ALERT_MINUTES.toShort()), // FIXME use activation time BeepType.FOUR_TIMES_BIP_BEEP, BeepRepetitionType.XXX4 ) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/PodConstants.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/PodConstants.kt index f6901d34d7..04de6d4c50 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/PodConstants.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/PodConstants.kt @@ -1,16 +1,27 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition import java.time.Duration +import java.util.concurrent.TimeUnit class PodConstants { companion object { val MAX_POD_LIFETIME : Duration = Duration.ofHours(80) + // Expiration alerts duration in minutes + const val POD_EXPIRATION_ALERT_MINUTES_DURATION = 60 * 7 + // Expiration alert time in minutes since activation + const val POD_EXPIRATION_ALERT_MINUTES = 60 * 72 + // Expiration eminent alert time in minutes since activation + const val POD_EXPIRATION_EMINENT_ALERT_MINUTES = 60 * 79 + + // Bolus units const val POD_PULSE_BOLUS_UNITS = 0.05 - // Priming + + // Priming units const val POD_PRIMING_BOLUS_UNITS = 0.05 const val POD_CANNULA_INSERTION_BOLUS_UNITS = 0.05 - // Reservoir + + // Reservoir units alert threshold const val DEFAULT_MAX_RESERVOIR_ALERT_THRESHOLD : Short = 20 } } From 99ae6b4b84ee81556aebcdaa7fc2772ffb30a5bb Mon Sep 17 00:00:00 2001 From: Theo van Elsberg Date: Wed, 6 Oct 2021 11:33:47 +0200 Subject: [PATCH 4/5] PodConstants: - Fixed type - PRIMING/CANULLA/PULSE are the same, move to one single const --- .../pump/omnipod/dash/driver/OmnipodDashManagerImpl.kt | 8 ++++---- .../omnipod/dash/driver/pod/definition/PodConstants.kt | 8 ++------ 2 files changed, 6 insertions(+), 10 deletions(-) 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 0828b50c74..7187dd520d 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 @@ -10,7 +10,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.G import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.* import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants.Companion.MAX_POD_LIFETIME import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants.Companion.POD_EXPIRATION_ALERT_MINUTES_DURATION -import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants.Companion.POD_EXPIRATION_EMINENT_ALERT_MINUTES +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants.Companion.POD_EXPIRATION_IMMINENT_ALERT_MINUTES import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants.Companion.POD_EXPIRATION_ALERT_MINUTES import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.* import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.OmnipodDashPodStateManager @@ -281,7 +281,7 @@ class OmnipodDashManagerImpl @Inject constructor( .setUniqueId(podStateManager.uniqueId!!.toInt()) .setSequenceNumber(podStateManager.messageSequenceNumber) .setNonce(NONCE) - .setNumberOfUnits(podStateManager.firstPrimeBolusVolume!! * PodConstants.POD_PRIMING_BOLUS_UNITS) + .setNumberOfUnits(podStateManager.firstPrimeBolusVolume!! * PodConstants.POD_PULSE_BOLUS_UNITS) .setDelayBetweenPulsesInEighthSeconds(podStateManager.primePulseRate!!.toByte()) .setProgramReminder(ProgramReminder(atStart = false, atEnd = false, atInterval = 0)) .build(), @@ -383,7 +383,7 @@ class OmnipodDashManagerImpl @Inject constructor( ) observables.add( observeSendProgramBolusCommand( - podStateManager.secondPrimeBolusVolume!! * PodConstants.POD_CANNULA_INSERTION_BOLUS_UNITS, + podStateManager.secondPrimeBolusVolume!! * PodConstants.POD_PULSE_BOLUS_UNITS, podStateManager.primePulseRate!!.toByte(), confirmationBeeps = false, completionBeeps = false @@ -408,7 +408,7 @@ class OmnipodDashManagerImpl @Inject constructor( enabled = true, durationInMinutes = 0, autoOff = false, - AlertTrigger.TimerTrigger(POD_EXPIRATION_EMINENT_ALERT_MINUTES.toShort()), // FIXME use activation time + AlertTrigger.TimerTrigger(POD_EXPIRATION_IMMINENT_ALERT_MINUTES.toShort()), // FIXME use activation time BeepType.FOUR_TIMES_BIP_BEEP, BeepRepetitionType.XXX4 ) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/PodConstants.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/PodConstants.kt index 04de6d4c50..f2c5939557 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/PodConstants.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/PodConstants.kt @@ -12,15 +12,11 @@ class PodConstants { // Expiration alert time in minutes since activation const val POD_EXPIRATION_ALERT_MINUTES = 60 * 72 // Expiration eminent alert time in minutes since activation - const val POD_EXPIRATION_EMINENT_ALERT_MINUTES = 60 * 79 + const val POD_EXPIRATION_IMMINENT_ALERT_MINUTES = 60 * 79 - // Bolus units + // Bolus & Priming units const val POD_PULSE_BOLUS_UNITS = 0.05 - // Priming units - const val POD_PRIMING_BOLUS_UNITS = 0.05 - const val POD_CANNULA_INSERTION_BOLUS_UNITS = 0.05 - // Reservoir units alert threshold const val DEFAULT_MAX_RESERVOIR_ALERT_THRESHOLD : Short = 20 } From 875cd893e2b833f613894a1da669465107001756 Mon Sep 17 00:00:00 2001 From: Theo van Elsberg Date: Wed, 6 Oct 2021 23:41:16 +0200 Subject: [PATCH 5/5] Refactoring Pod constants: - Const values now defined in "hours" - Use TimeUnit().HOURS.toMinutes() method to convert --- .../dash/driver/OmnipodDashManagerImpl.kt | 16 ++++++++++------ .../dash/driver/pod/definition/PodConstants.kt | 10 +++++----- 2 files changed, 15 insertions(+), 11 deletions(-) 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 7187dd520d..c50ea1b988 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 @@ -9,9 +9,9 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.* import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.GetVersionCommand.Companion.DEFAULT_UNIQUE_ID import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.* import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants.Companion.MAX_POD_LIFETIME -import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants.Companion.POD_EXPIRATION_ALERT_MINUTES_DURATION -import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants.Companion.POD_EXPIRATION_IMMINENT_ALERT_MINUTES -import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants.Companion.POD_EXPIRATION_ALERT_MINUTES +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants.Companion.POD_EXPIRATION_ALERT_HOURS_DURATION +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants.Companion.POD_EXPIRATION_IMMINENT_ALERT_HOURS +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants.Companion.POD_EXPIRATION_ALERT_HOURS import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.* import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.OmnipodDashPodStateManager import info.nightscout.androidaps.utils.rx.AapsSchedulers @@ -397,9 +397,11 @@ class OmnipodDashManagerImpl @Inject constructor( AlertConfiguration( AlertType.EXPIRATION, enabled = true, - durationInMinutes = POD_EXPIRATION_ALERT_MINUTES_DURATION.toShort(), + durationInMinutes = TimeUnit.HOURS.toMinutes(POD_EXPIRATION_ALERT_HOURS_DURATION).toShort(), autoOff = false, - AlertTrigger.TimerTrigger(POD_EXPIRATION_ALERT_MINUTES.toShort()), // FIXME use activation time + AlertTrigger.TimerTrigger( + TimeUnit.HOURS.toMinutes(POD_EXPIRATION_ALERT_HOURS).toShort() + ), // FIXME use activation time BeepType.FOUR_TIMES_BIP_BEEP, BeepRepetitionType.XXX3 ), @@ -408,7 +410,9 @@ class OmnipodDashManagerImpl @Inject constructor( enabled = true, durationInMinutes = 0, autoOff = false, - AlertTrigger.TimerTrigger(POD_EXPIRATION_IMMINENT_ALERT_MINUTES.toShort()), // FIXME use activation time + AlertTrigger.TimerTrigger( + TimeUnit.HOURS.toMinutes(POD_EXPIRATION_IMMINENT_ALERT_HOURS).toShort() + ), // FIXME use activation time BeepType.FOUR_TIMES_BIP_BEEP, BeepRepetitionType.XXX4 ) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/PodConstants.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/PodConstants.kt index f2c5939557..06b0ae96bd 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/PodConstants.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/PodConstants.kt @@ -7,12 +7,12 @@ class PodConstants { companion object { val MAX_POD_LIFETIME : Duration = Duration.ofHours(80) - // Expiration alerts duration in minutes - const val POD_EXPIRATION_ALERT_MINUTES_DURATION = 60 * 7 - // Expiration alert time in minutes since activation - const val POD_EXPIRATION_ALERT_MINUTES = 60 * 72 + // Expiration alert time in minutes since activation and duration in minutes + const val POD_EXPIRATION_ALERT_HOURS = 72L + const val POD_EXPIRATION_ALERT_HOURS_DURATION = 7L + // Expiration eminent alert time in minutes since activation - const val POD_EXPIRATION_IMMINENT_ALERT_MINUTES = 60 * 79 + const val POD_EXPIRATION_IMMINENT_ALERT_HOURS = 79L // Bolus & Priming units const val POD_PULSE_BOLUS_UNITS = 0.05