Loop: check for empty queue sooner
This commit is contained in:
parent
a5774b6e2e
commit
a108158909
2 changed files with 10 additions and 9 deletions
|
@ -7,5 +7,6 @@ interface APS {
|
|||
var lastDetermineBasalAdapter: DetermineBasalAdapter?
|
||||
var lastAutosensResult: AutosensResult
|
||||
|
||||
operator fun invoke(initiator: String, tempBasalFallback: Boolean)
|
||||
fun isEnabled(): Boolean
|
||||
fun invoke(initiator: String, tempBasalFallback: Boolean)
|
||||
}
|
|
@ -218,7 +218,7 @@ class LoopPlugin @Inject constructor(
|
|||
val start = dateUtil.now()
|
||||
while (start + T.mins(maxMinutes).msecs() > dateUtil.now()) {
|
||||
if (commandQueue.size() == 0 && commandQueue.performing() == null) return true
|
||||
SystemClock.sleep(100)
|
||||
SystemClock.sleep(1000)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
@ -247,10 +247,16 @@ class LoopPlugin @Inject constructor(
|
|||
return
|
||||
}
|
||||
|
||||
if (!isEmptyQueue()) {
|
||||
aapsLogger.debug(LTag.APS, rh.gs(info.nightscout.core.ui.R.string.pump_busy))
|
||||
rxBus.send(EventLoopSetLastRunGui(rh.gs(info.nightscout.core.ui.R.string.pump_busy)))
|
||||
return
|
||||
}
|
||||
|
||||
// Check if pump info is loaded
|
||||
if (pump.baseBasalRate < 0.01) return
|
||||
val usedAPS = activePlugin.activeAPS
|
||||
if ((usedAPS as PluginBase).isEnabled()) {
|
||||
if (usedAPS.isEnabled()) {
|
||||
usedAPS.invoke(initiator, tempBasalFallback)
|
||||
apsResult = usedAPS.lastAPSResult
|
||||
}
|
||||
|
@ -261,12 +267,6 @@ class LoopPlugin @Inject constructor(
|
|||
return
|
||||
}
|
||||
|
||||
if (!isEmptyQueue()) {
|
||||
aapsLogger.debug(LTag.APS, rh.gs(info.nightscout.core.ui.R.string.pump_busy))
|
||||
rxBus.send(EventLoopSetLastRunGui(rh.gs(info.nightscout.core.ui.R.string.pump_busy)))
|
||||
return
|
||||
}
|
||||
|
||||
// Prepare for pumps using % basals
|
||||
if (pump.pumpDescription.tempBasalStyle == PumpDescription.PERCENT && allowPercentage()) {
|
||||
apsResult.usePercent = true
|
||||
|
|
Loading…
Reference in a new issue