fix overlapping profile switches of the same value, fix storing profiles from NS
This commit is contained in:
parent
016cf9dada
commit
01bb554651
6 changed files with 8 additions and 15 deletions
|
@ -191,7 +191,7 @@ class KeepAliveWorker(
|
|||
}
|
||||
if (loop.isDisconnected) {
|
||||
// do nothing if pump is disconnected
|
||||
} else if (runningProfile == null || ((!pump.isThisProfileSet(requestedProfile) || !requestedProfile.isEqual(runningProfile)) && !commandQueue.isRunning(Command.CommandType.BASAL_PROFILE))) {
|
||||
} else if (runningProfile == null || ((!pump.isThisProfileSet(requestedProfile) || !requestedProfile.isEqual(runningProfile) || (runningProfile is ProfileSealed.EPS && runningProfile.value.originalEnd < dateUtil.now())) && !commandQueue.isRunning(Command.CommandType.BASAL_PROFILE))) {
|
||||
rxBus.send(EventProfileSwitchChanged())
|
||||
} else if (isStatusOutdated && !pump.isBusy()) {
|
||||
lastReadStatus = now
|
||||
|
|
|
@ -25,7 +25,6 @@ interface CommandQueue {
|
|||
fun extendedBolus(insulin: Double, durationInMinutes: Int, callback: Callback?): Boolean
|
||||
fun cancelTempBasal(enforceNew: Boolean, callback: Callback?): Boolean
|
||||
fun cancelExtended(callback: Callback?): Boolean
|
||||
fun setProfile(profile: Profile, hasNsId: Boolean, callback: Callback?): Boolean
|
||||
fun readStatus(reason: String, callback: Callback?): Boolean
|
||||
fun statusInQueue(): Boolean
|
||||
fun loadHistory(type: Byte, callback: Callback?): Boolean
|
||||
|
|
|
@ -71,7 +71,7 @@ class ProfileFunctionImpl @Inject constructor(
|
|||
override fun getProfileNameWithRemainingTime(): String =
|
||||
getProfileName(System.currentTimeMillis(), customized = true, showRemainingTime = true)
|
||||
|
||||
fun getProfileName(time: Long, customized: Boolean, showRemainingTime: Boolean): String {
|
||||
private fun getProfileName(time: Long, customized: Boolean, showRemainingTime: Boolean): String {
|
||||
var profileName = rh.gs(info.nightscout.core.ui.R.string.no_profile_set)
|
||||
|
||||
val profileSwitch = repository.getEffectiveProfileSwitchActiveAt(time).blockingGet()
|
||||
|
|
|
@ -113,12 +113,13 @@ class CommandQueueImplementation @Inject constructor(
|
|||
return@subscribe
|
||||
}
|
||||
aapsLogger.debug(LTag.PROFILE, "onEventProfileSwitchChanged")
|
||||
val effective = repository.getEffectiveProfileSwitchActiveAt(dateUtil.now()).blockingGet()
|
||||
profileFunction.getRequestedProfile()?.let {
|
||||
setProfile(ProfileSealed.PS(it), it.interfaceIDs.nightscoutId != null, object : Callback() {
|
||||
override fun run() {
|
||||
if (!result.success) {
|
||||
uiInteraction.runAlarm(result.comment, rh.gs(info.nightscout.core.ui.R.string.failed_update_basal_profile), info.nightscout.core.ui.R.raw.boluserror)
|
||||
} else if (result.enacted) {
|
||||
} else if (result.enacted || effective is ValueWrapper.Existing && effective.value.originalEnd < dateUtil.now()) {
|
||||
val nonCustomized = ProfileSealed.PS(it).convertToNonCustomizedProfile(dateUtil)
|
||||
EffectiveProfileSwitch(
|
||||
timestamp = dateUtil.now(),
|
||||
|
@ -421,7 +422,7 @@ class CommandQueueImplementation @Inject constructor(
|
|||
}
|
||||
|
||||
// returns true if command is queued
|
||||
override fun setProfile(profile: Profile, hasNsId: Boolean, callback: Callback?): Boolean {
|
||||
fun setProfile(profile: ProfileSealed.PS, hasNsId: Boolean, callback: Callback?): Boolean {
|
||||
if (isRunning(CommandType.BASAL_PROFILE)) {
|
||||
aapsLogger.debug(LTag.PUMPQUEUE, "Command is already executed")
|
||||
callback?.result(PumpEnactResult(injector).success(true).enacted(false))?.run()
|
||||
|
|
|
@ -841,11 +841,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
if (it.value.originalPercentage != 100 || it.value.originalTimeshift != 0L || it.value.originalDuration != 0L)
|
||||
info.nightscout.core.ui.R.attr.ribbonWarningColor
|
||||
else info.nightscout.core.ui.R.attr.ribbonDefaultColor
|
||||
} else if (it is ProfileSealed.PS) {
|
||||
info.nightscout.core.ui.R.attr.ribbonDefaultColor
|
||||
} else {
|
||||
info.nightscout.core.ui.R.attr.ribbonDefaultColor
|
||||
}
|
||||
} else info.nightscout.core.ui.R.attr.ribbonDefaultColor
|
||||
} ?: info.nightscout.core.ui.R.attr.ribbonCriticalColor
|
||||
|
||||
val profileTextColor = profile?.let {
|
||||
|
@ -853,11 +849,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
if (it.value.originalPercentage != 100 || it.value.originalTimeshift != 0L || it.value.originalDuration != 0L)
|
||||
info.nightscout.core.ui.R.attr.ribbonTextWarningColor
|
||||
else info.nightscout.core.ui.R.attr.ribbonTextDefaultColor
|
||||
} else if (it is ProfileSealed.PS) {
|
||||
info.nightscout.core.ui.R.attr.ribbonTextDefaultColor
|
||||
} else {
|
||||
info.nightscout.core.ui.R.attr.ribbonTextDefaultColor
|
||||
}
|
||||
} else info.nightscout.core.ui.R.attr.ribbonTextDefaultColor
|
||||
} ?: info.nightscout.core.ui.R.attr.ribbonTextDefaultColor
|
||||
setRibbon(binding.activeProfile, profileTextColor, profileBackgroundColor, profileFunction.getProfileNameWithRemainingTime())
|
||||
}
|
||||
|
|
|
@ -255,6 +255,7 @@ class ProfilePlugin @Inject constructor(
|
|||
isEdited = false
|
||||
createAndStoreConvertedProfile()
|
||||
aapsLogger.debug(LTag.PROFILE, "Accepted ${profiles.size} profiles")
|
||||
storeSettings()
|
||||
rxBus.send(EventLocalProfileChanged())
|
||||
} else
|
||||
aapsLogger.debug(LTag.PROFILE, "ProfileStore not accepted")
|
||||
|
|
Loading…
Reference in a new issue