fix updating non basal profile changes
This commit is contained in:
parent
3ed45fdd11
commit
3d1b7e8ded
2 changed files with 8 additions and 7 deletions
|
@ -566,11 +566,12 @@ open class CommandQueue @Inject constructor(
|
|||
return HtmlHelper.fromHtml(s)
|
||||
}
|
||||
|
||||
override fun isThisProfileSet(profile: Profile): Boolean {
|
||||
val result = activePlugin.activePump.isThisProfileSet(profile)
|
||||
override fun isThisProfileSet(requestedProfile: Profile): Boolean {
|
||||
val runningProfile = profileFunction.getProfile() ?: return false
|
||||
val result = activePlugin.activePump.isThisProfileSet(requestedProfile) && requestedProfile.isEqual(runningProfile)
|
||||
if (!result) {
|
||||
aapsLogger.debug(LTag.PUMPQUEUE, "Current profile: ${profileFunction.getProfile()}")
|
||||
aapsLogger.debug(LTag.PUMPQUEUE, "New profile: $profile")
|
||||
aapsLogger.debug(LTag.PUMPQUEUE, "New profile: $requestedProfile")
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
|
|
@ -119,18 +119,18 @@ class KeepAliveReceiver : DaggerBroadcastReceiver() {
|
|||
private fun checkPump() {
|
||||
val pump = activePlugin.activePump
|
||||
val ps = profileFunction.getRequestedProfile() ?: return
|
||||
val profile = ProfileSealed.PS(ps)
|
||||
val requestedProfile = ProfileSealed.PS(ps)
|
||||
val runningProfile = profileFunction.getProfile()
|
||||
val lastConnection = pump.lastDataTime()
|
||||
val isStatusOutdated = lastConnection + STATUS_UPDATE_FREQUENCY < System.currentTimeMillis()
|
||||
val isBasalOutdated = abs(profile.getBasal() - pump.baseBasalRate) > pump.pumpDescription.basalStep
|
||||
val isBasalOutdated = abs(requestedProfile.getBasal() - pump.baseBasalRate) > pump.pumpDescription.basalStep
|
||||
aapsLogger.debug(LTag.CORE, "Last connection: " + dateUtil.dateAndTimeString(lastConnection))
|
||||
// sometimes keep alive broadcast stops
|
||||
// as as workaround test if readStatus was requested before an alarm is generated
|
||||
if (lastReadStatus != 0L && lastReadStatus > System.currentTimeMillis() - T.mins(5).msecs()) {
|
||||
localAlertUtils.checkPumpUnreachableAlarm(lastConnection, isStatusOutdated, loopPlugin.isDisconnected)
|
||||
}
|
||||
if (!pump.isThisProfileSet(profile) && !commandQueue.isRunning(Command.CommandType.BASAL_PROFILE)
|
||||
|| profileFunction.getProfile() == null) {
|
||||
if (runningProfile == null || ((!pump.isThisProfileSet(requestedProfile) || !requestedProfile.isEqual(runningProfile)) && !commandQueue.isRunning(Command.CommandType.BASAL_PROFILE))) {
|
||||
rxBus.send(EventProfileSwitchChanged())
|
||||
} else if (isStatusOutdated && !pump.isBusy()) {
|
||||
lastReadStatus = System.currentTimeMillis()
|
||||
|
|
Loading…
Reference in a new issue