Xdrip: check for running sync
This commit is contained in:
parent
7df80eebe0
commit
0caded7bbb
1 changed files with 16 additions and 1 deletions
|
@ -4,6 +4,9 @@ import app.aaps.core.interfaces.logging.AAPSLogger
|
|||
import app.aaps.core.interfaces.logging.LTag
|
||||
import app.aaps.core.interfaces.plugin.ActivePlugin
|
||||
import app.aaps.core.interfaces.profile.ProfileFunction
|
||||
import app.aaps.core.interfaces.rx.bus.RxBus
|
||||
import app.aaps.core.interfaces.rx.events.EventNSClientNewLog
|
||||
import app.aaps.core.interfaces.rx.events.EventXdripNewLog
|
||||
import app.aaps.core.interfaces.sharedPreferences.SP
|
||||
import app.aaps.core.interfaces.sync.DataSyncSelector
|
||||
import app.aaps.core.interfaces.sync.DataSyncSelectorXdrip
|
||||
|
@ -25,7 +28,8 @@ class DataSyncSelectorXdripImpl @Inject constructor(
|
|||
private val profileFunction: ProfileFunction,
|
||||
private val activePlugin: ActivePlugin,
|
||||
private val xdripBroadcast: Lazy<XDripBroadcast>,
|
||||
private val appRepository: AppRepository
|
||||
private val appRepository: AppRepository,
|
||||
private val rxBus: RxBus
|
||||
) : DataSyncSelectorXdrip {
|
||||
|
||||
class QueueCounter(
|
||||
|
@ -72,7 +76,17 @@ class DataSyncSelectorXdripImpl @Inject constructor(
|
|||
|
||||
override fun queueSize(): Long = queueCounter.size()
|
||||
|
||||
private var running = false
|
||||
private val sync = Any()
|
||||
|
||||
override suspend fun doUpload() {
|
||||
synchronized(sync) {
|
||||
if (running) {
|
||||
rxBus.send(EventXdripNewLog("RUN", "Already running"))
|
||||
return
|
||||
}
|
||||
running = true
|
||||
}
|
||||
if (isEnabled) {
|
||||
processChangedGlucoseValues()
|
||||
processChangedBoluses()
|
||||
|
@ -96,6 +110,7 @@ class DataSyncSelectorXdripImpl @Inject constructor(
|
|||
// not supported at the moment
|
||||
//processChangedProfileStore()
|
||||
}
|
||||
running = false
|
||||
}
|
||||
|
||||
override fun resetToNextFullSync() {
|
||||
|
|
Loading…
Reference in a new issue