Move fixed values to PodConstants

This commit is contained in:
Theo van Elsberg 2021-10-04 22:38:37 +02:00
parent 0546976cbb
commit 5ffe61d6c4
5 changed files with 17 additions and 10 deletions

View file

@ -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(

View file

@ -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

View file

@ -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
}
}

View file

@ -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

View file

@ -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) {