Merge branch 'avereha/merge-small-fixes' into avereha/conn
This commit is contained in:
commit
1d925aee12
2 changed files with 28 additions and 0 deletions
|
@ -53,6 +53,7 @@ import javax.inject.Inject
|
|||
import javax.inject.Singleton
|
||||
import kotlin.concurrent.thread
|
||||
import kotlin.math.ceil
|
||||
import kotlin.math.exp
|
||||
import kotlin.random.Random
|
||||
|
||||
@Singleton
|
||||
|
@ -98,10 +99,31 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
statusChecker = Runnable {
|
||||
refreshStatusOnUnacknowledgedCommands()
|
||||
updatePodWarnings()
|
||||
createFakeTBRWhenNoActivePod()
|
||||
handler.postDelayed(statusChecker, STATUS_CHECK_INTERVAL_MS)
|
||||
}
|
||||
}
|
||||
|
||||
private fun createFakeTBRWhenNoActivePod() {
|
||||
if (!podStateManager.isPodRunning) {
|
||||
val expectedState = pumpSync.expectedPumpState()
|
||||
val tbr = expectedState.temporaryBasal
|
||||
if (tbr == null || tbr.rate!=0.0) {
|
||||
aapsLogger.info(LTag.PUMP, "createFakeTBRWhenNoActivePod")
|
||||
pumpSync.syncTemporaryBasalWithPumpId(
|
||||
timestamp = System.currentTimeMillis(),
|
||||
rate = 0.0,
|
||||
duration = T.mins(PodConstants.MAX_POD_LIFETIME.standardMinutes).msecs(),
|
||||
isAbsolute = true,
|
||||
type = PumpSync.TemporaryBasalType.PUMP_SUSPEND,
|
||||
pumpId = Random.Default.nextLong(), // we don't use this, just make sure it's unique
|
||||
pumpType = PumpType.OMNIPOD_DASH,
|
||||
pumpSerial = serialNumber()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun updatePodWarnings() {
|
||||
if (System.currentTimeMillis() > nextPodWarningCheck) {
|
||||
if (!podStateManager.isPodRunning) {
|
||||
|
|
|
@ -71,6 +71,12 @@ class DashInsertCannulaViewModel @Inject constructor(
|
|||
pumpType = PumpType.OMNIPOD_DASH,
|
||||
pumpSerial = podStateManager.uniqueId?.toString() ?: "n/a"
|
||||
)
|
||||
pumpSync.syncStopTemporaryBasalWithPumpId(
|
||||
timestamp = System.currentTimeMillis(),
|
||||
endPumpId = System.currentTimeMillis(),
|
||||
pumpType = PumpType.OMNIPOD_DASH,
|
||||
pumpSerial = podStateManager.uniqueId?.toString() ?: "n/a"
|
||||
)
|
||||
source.onSuccess(PumpEnactResult(injector).success(true))
|
||||
}
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue