Move fixed values to PodConstants
This commit is contained in:
parent
0546976cbb
commit
5ffe61d6c4
5 changed files with 17 additions and 10 deletions
|
@ -510,7 +510,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
||||||
|
|
||||||
// Omnipod only reports reservoir level when there's < 1023 pulses left
|
// Omnipod only reports reservoir level when there's < 1023 pulses left
|
||||||
return podStateManager.pulsesRemaining?.let {
|
return podStateManager.pulsesRemaining?.let {
|
||||||
it * 0.05
|
it * PodConstants.POD_PULSE_BOLUS_UNITS
|
||||||
} ?: 75.0
|
} ?: 75.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -724,7 +724,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun estimateBolusDeliverySeconds(requestedBolusAmount: Double): Long {
|
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(
|
private fun pumpSyncBolusStart(
|
||||||
|
|
|
@ -278,7 +278,7 @@ class OmnipodDashManagerImpl @Inject constructor(
|
||||||
.setUniqueId(podStateManager.uniqueId!!.toInt())
|
.setUniqueId(podStateManager.uniqueId!!.toInt())
|
||||||
.setSequenceNumber(podStateManager.messageSequenceNumber)
|
.setSequenceNumber(podStateManager.messageSequenceNumber)
|
||||||
.setNonce(NONCE)
|
.setNonce(NONCE)
|
||||||
.setNumberOfUnits(podStateManager.firstPrimeBolusVolume!! * 0.05)
|
.setNumberOfUnits(podStateManager.firstPrimeBolusVolume!! * PodConstants.POD_PRIMING_BOLUS_UNITS)
|
||||||
.setDelayBetweenPulsesInEighthSeconds(podStateManager.primePulseRate!!.toByte())
|
.setDelayBetweenPulsesInEighthSeconds(podStateManager.primePulseRate!!.toByte())
|
||||||
.setProgramReminder(ProgramReminder(atStart = false, atEnd = false, atInterval = 0))
|
.setProgramReminder(ProgramReminder(atStart = false, atEnd = false, atInterval = 0))
|
||||||
.build(),
|
.build(),
|
||||||
|
@ -380,7 +380,7 @@ class OmnipodDashManagerImpl @Inject constructor(
|
||||||
)
|
)
|
||||||
observables.add(
|
observables.add(
|
||||||
observeSendProgramBolusCommand(
|
observeSendProgramBolusCommand(
|
||||||
podStateManager.secondPrimeBolusVolume!! * 0.05,
|
podStateManager.secondPrimeBolusVolume!! * PodConstants.POD_CANNULA_INSERTION_BOLUS_UNITS,
|
||||||
podStateManager.primePulseRate!!.toByte(),
|
podStateManager.primePulseRate!!.toByte(),
|
||||||
confirmationBeeps = false,
|
confirmationBeeps = false,
|
||||||
completionBeeps = false
|
completionBeeps = false
|
||||||
|
|
|
@ -4,6 +4,13 @@ import java.time.Duration
|
||||||
|
|
||||||
class PodConstants {
|
class PodConstants {
|
||||||
companion object {
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -311,7 +311,7 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
|
||||||
|
|
||||||
private fun updateLastBolusFromResponse(bolusPulsesRemaining: Short) {
|
private fun updateLastBolusFromResponse(bolusPulsesRemaining: Short) {
|
||||||
podState.lastBolus?.run {
|
podState.lastBolus?.run {
|
||||||
val remainingUnits = bolusPulsesRemaining.toDouble() * 0.05
|
val remainingUnits = bolusPulsesRemaining.toDouble() * PodConstants.POD_PULSE_BOLUS_UNITS
|
||||||
this.bolusUnitsRemaining = remainingUnits
|
this.bolusUnitsRemaining = remainingUnits
|
||||||
if (remainingUnits == 0.0) {
|
if (remainingUnits == 0.0) {
|
||||||
this.deliveryComplete = true
|
this.deliveryComplete = true
|
||||||
|
|
|
@ -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.ActivationProgress
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertType
|
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.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.Callback
|
||||||
import info.nightscout.androidaps.queue.events.EventQueueChanged
|
import info.nightscout.androidaps.queue.events.EventQueueChanged
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
|
@ -68,7 +69,6 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
|
||||||
@Inject lateinit var buildHelper: BuildHelper
|
@Inject lateinit var buildHelper: BuildHelper
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
private const val REFRESH_INTERVAL_MILLIS = 15 * 1000L // 15 seconds
|
private const val REFRESH_INTERVAL_MILLIS = 15 * 1000L // 15 seconds
|
||||||
private const val PLACEHOLDER = "-"
|
private const val PLACEHOLDER = "-"
|
||||||
private const val MAX_TIME_DEVIATION_MINUTES = 10L
|
private const val MAX_TIME_DEVIATION_MINUTES = 10L
|
||||||
|
@ -372,7 +372,7 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
|
||||||
if (podStateManager.isActivationCompleted && podStateManager.pulsesDelivered != null) {
|
if (podStateManager.isActivationCompleted && podStateManager.pulsesDelivered != null) {
|
||||||
resourceHelper.gs(
|
resourceHelper.gs(
|
||||||
R.string.omnipod_common_overview_total_delivered_value,
|
R.string.omnipod_common_overview_total_delivered_value,
|
||||||
podStateManager.pulsesDelivered!! * 0.05
|
(podStateManager.pulsesDelivered!! * PodConstants.POD_PULSE_BOLUS_UNITS)
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
PLACEHOLDER
|
PLACEHOLDER
|
||||||
|
@ -387,11 +387,11 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
|
||||||
// TODO
|
// TODO
|
||||||
// val lowReservoirThreshold = (omnipodAlertUtil.lowReservoirAlertUnits
|
// val lowReservoirThreshold = (omnipodAlertUtil.lowReservoirAlertUnits
|
||||||
// ?: OmnipodConstants.DEFAULT_MAX_RESERVOIR_ALERT_THRESHOLD).toDouble()
|
// ?: 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(
|
podInfoBinding.reservoir.text = resourceHelper.gs(
|
||||||
R.string.omnipod_common_overview_reservoir_value,
|
R.string.omnipod_common_overview_reservoir_value,
|
||||||
(podStateManager.pulsesRemaining!! * 0.05)
|
(podStateManager.pulsesRemaining!! * PodConstants.POD_PULSE_BOLUS_UNITS)
|
||||||
)
|
)
|
||||||
podInfoBinding.reservoir.setTextColor(
|
podInfoBinding.reservoir.setTextColor(
|
||||||
if (podStateManager.pulsesRemaining!! < lowReservoirThreshold) {
|
if (podStateManager.pulsesRemaining!! < lowReservoirThreshold) {
|
||||||
|
|
Loading…
Reference in a new issue