improve KeepAlive and widget
This commit is contained in:
parent
2b4cc885b2
commit
9145870e7c
|
@ -139,10 +139,10 @@ class MainApp : DaggerApplication() {
|
||||||
}, 10000
|
}, 10000
|
||||||
)
|
)
|
||||||
WorkManager.getInstance(this).enqueueUniquePeriodicWork(
|
WorkManager.getInstance(this).enqueueUniquePeriodicWork(
|
||||||
"KeepAlive",
|
KeepAliveWorker.KA_0,
|
||||||
ExistingPeriodicWorkPolicy.REPLACE,
|
ExistingPeriodicWorkPolicy.REPLACE,
|
||||||
PeriodicWorkRequest.Builder(KeepAliveWorker::class.java, 15, TimeUnit.MINUTES)
|
PeriodicWorkRequest.Builder(KeepAliveWorker::class.java, 15, TimeUnit.MINUTES)
|
||||||
.setInputData(Data.Builder().putString("schedule", "KeepAlive").build())
|
.setInputData(Data.Builder().putString("schedule", KeepAliveWorker.KA_0).build())
|
||||||
.setInitialDelay(5, TimeUnit.SECONDS)
|
.setInitialDelay(5, TimeUnit.SECONDS)
|
||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package info.nightscout.androidaps.db
|
package info.nightscout.androidaps.db
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import info.nightscout.androidaps.database.AppRepository
|
import info.nightscout.androidaps.database.AppRepository
|
||||||
import info.nightscout.androidaps.database.entities.*
|
import info.nightscout.androidaps.database.entities.*
|
||||||
import info.nightscout.androidaps.events.*
|
import info.nightscout.androidaps.events.*
|
||||||
|
@ -7,6 +8,7 @@ import info.nightscout.shared.logging.AAPSLogger
|
||||||
import info.nightscout.shared.logging.LTag
|
import info.nightscout.shared.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus
|
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventNewHistoryData
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventNewHistoryData
|
||||||
|
import info.nightscout.androidaps.widget.updateWidget
|
||||||
import io.reactivex.rxjava3.disposables.Disposable
|
import io.reactivex.rxjava3.disposables.Disposable
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
@ -15,13 +17,15 @@ import javax.inject.Singleton
|
||||||
class CompatDBHelper @Inject constructor(
|
class CompatDBHelper @Inject constructor(
|
||||||
val aapsLogger: AAPSLogger,
|
val aapsLogger: AAPSLogger,
|
||||||
val repository: AppRepository,
|
val repository: AppRepository,
|
||||||
val rxBus: RxBus
|
val rxBus: RxBus,
|
||||||
|
val context: Context
|
||||||
) {
|
) {
|
||||||
|
|
||||||
fun dbChangeDisposable(): Disposable = repository
|
fun dbChangeDisposable(): Disposable = repository
|
||||||
.changeObservable()
|
.changeObservable()
|
||||||
.doOnSubscribe {
|
.doOnSubscribe {
|
||||||
rxBus.send(EventNewBG(null))
|
rxBus.send(EventNewBG(null))
|
||||||
|
updateWidget(context)
|
||||||
}
|
}
|
||||||
.subscribe {
|
.subscribe {
|
||||||
/**
|
/**
|
||||||
|
@ -34,6 +38,7 @@ class CompatDBHelper @Inject constructor(
|
||||||
it.filterIsInstance<GlucoseValue>().maxByOrNull { gv -> gv.timestamp }?.let { gv ->
|
it.filterIsInstance<GlucoseValue>().maxByOrNull { gv -> gv.timestamp }?.let { gv ->
|
||||||
aapsLogger.debug(LTag.DATABASE, "Firing EventNewBg $gv")
|
aapsLogger.debug(LTag.DATABASE, "Firing EventNewBg $gv")
|
||||||
rxBus.send(EventNewBG(gv))
|
rxBus.send(EventNewBG(gv))
|
||||||
|
updateWidget(context)
|
||||||
newestGlucoseValue = gv
|
newestGlucoseValue = gv
|
||||||
}
|
}
|
||||||
it.filterIsInstance<GlucoseValue>().minOfOrNull { gv -> gv.timestamp }?.let { timestamp ->
|
it.filterIsInstance<GlucoseValue>().minOfOrNull { gv -> gv.timestamp }?.let { timestamp ->
|
||||||
|
|
|
@ -15,7 +15,7 @@ import info.nightscout.androidaps.interfaces.PluginDescription
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
import info.nightscout.shared.logging.AAPSLogger
|
import info.nightscout.shared.logging.AAPSLogger
|
||||||
import info.nightscout.shared.logging.LTag
|
import info.nightscout.shared.logging.LTag
|
||||||
import info.nightscout.androidaps.receivers.DataWorker
|
import info.nightscout.androidaps.receivers.DataWorkerStorage
|
||||||
import info.nightscout.androidaps.utils.JsonHelper
|
import info.nightscout.androidaps.utils.JsonHelper
|
||||||
import info.nightscout.androidaps.interfaces.ResourceHelper
|
import info.nightscout.androidaps.interfaces.ResourceHelper
|
||||||
import info.nightscout.shared.sharedPreferences.SP
|
import info.nightscout.shared.sharedPreferences.SP
|
||||||
|
@ -48,14 +48,14 @@ class FoodPlugin @Inject constructor(
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
@Inject lateinit var repository: AppRepository
|
@Inject lateinit var repository: AppRepository
|
||||||
@Inject lateinit var sp: SP
|
@Inject lateinit var sp: SP
|
||||||
@Inject lateinit var dataWorker: DataWorker
|
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
|
||||||
|
|
||||||
init {
|
init {
|
||||||
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
|
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun doWork(): Result {
|
override fun doWork(): Result {
|
||||||
val foods = dataWorker.pickupJSONArray(inputData.getLong(DataWorker.STORE_KEY, -1))
|
val foods = dataWorkerStorage.pickupJSONArray(inputData.getLong(DataWorkerStorage.STORE_KEY, -1))
|
||||||
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
||||||
aapsLogger.debug(LTag.DATABASE, "Received Food Data: $foods")
|
aapsLogger.debug(LTag.DATABASE, "Received Food Data: $foods")
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ import info.nightscout.shared.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus
|
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.acks.NSAddAck
|
import info.nightscout.androidaps.plugins.general.nsclient.acks.NSAddAck
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientNewLog
|
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientNewLog
|
||||||
import info.nightscout.androidaps.receivers.DataWorker
|
import info.nightscout.androidaps.receivers.DataWorkerStorage
|
||||||
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import info.nightscout.shared.sharedPreferences.SP
|
import info.nightscout.shared.sharedPreferences.SP
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -27,7 +27,7 @@ class NSClientAddAckWorker(
|
||||||
params: WorkerParameters
|
params: WorkerParameters
|
||||||
) : Worker(context, params) {
|
) : Worker(context, params) {
|
||||||
|
|
||||||
@Inject lateinit var dataWorker: DataWorker
|
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
@Inject lateinit var repository: AppRepository
|
@Inject lateinit var repository: AppRepository
|
||||||
@Inject lateinit var rxBus: RxBus
|
@Inject lateinit var rxBus: RxBus
|
||||||
|
@ -38,7 +38,7 @@ class NSClientAddAckWorker(
|
||||||
override fun doWork(): Result {
|
override fun doWork(): Result {
|
||||||
var ret = Result.success()
|
var ret = Result.success()
|
||||||
|
|
||||||
val ack = dataWorker.pickupObject(inputData.getLong(DataWorker.STORE_KEY, -1)) as NSAddAck?
|
val ack = dataWorkerStorage.pickupObject(inputData.getLong(DataWorkerStorage.STORE_KEY, -1)) as NSAddAck?
|
||||||
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
||||||
|
|
||||||
if (sp.getBoolean(R.string.key_ns_sync_slow, false)) SystemClock.sleep(1000)
|
if (sp.getBoolean(R.string.key_ns_sync_slow, false)) SystemClock.sleep(1000)
|
||||||
|
|
|
@ -23,7 +23,7 @@ import info.nightscout.androidaps.plugins.bus.RxBus
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
|
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
|
||||||
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification
|
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification
|
||||||
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin
|
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin
|
||||||
import info.nightscout.androidaps.receivers.DataWorker
|
import info.nightscout.androidaps.receivers.DataWorkerStorage
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.JsonHelper
|
import info.nightscout.androidaps.utils.JsonHelper
|
||||||
import info.nightscout.androidaps.utils.JsonHelper.safeGetLong
|
import info.nightscout.androidaps.utils.JsonHelper.safeGetLong
|
||||||
|
@ -39,7 +39,7 @@ class NSClientAddUpdateWorker(
|
||||||
) : Worker(context, params) {
|
) : Worker(context, params) {
|
||||||
|
|
||||||
@Inject lateinit var nsClientPlugin: NSClientPlugin
|
@Inject lateinit var nsClientPlugin: NSClientPlugin
|
||||||
@Inject lateinit var dataWorker: DataWorker
|
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
@Inject lateinit var buildHelper: BuildHelper
|
@Inject lateinit var buildHelper: BuildHelper
|
||||||
@Inject lateinit var sp: SP
|
@Inject lateinit var sp: SP
|
||||||
|
@ -53,7 +53,7 @@ class NSClientAddUpdateWorker(
|
||||||
@Inject lateinit var xDripBroadcast: XDripBroadcast
|
@Inject lateinit var xDripBroadcast: XDripBroadcast
|
||||||
|
|
||||||
override fun doWork(): Result {
|
override fun doWork(): Result {
|
||||||
val treatments = dataWorker.pickupJSONArray(inputData.getLong(DataWorker.STORE_KEY, -1))
|
val treatments = dataWorkerStorage.pickupJSONArray(inputData.getLong(DataWorkerStorage.STORE_KEY, -1))
|
||||||
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
||||||
|
|
||||||
var ret = Result.success()
|
var ret = Result.success()
|
||||||
|
|
|
@ -13,7 +13,7 @@ import info.nightscout.androidaps.interfaces.Config
|
||||||
import info.nightscout.shared.logging.AAPSLogger
|
import info.nightscout.shared.logging.AAPSLogger
|
||||||
import info.nightscout.shared.logging.LTag
|
import info.nightscout.shared.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.data.NSMbg
|
import info.nightscout.androidaps.plugins.general.nsclient.data.NSMbg
|
||||||
import info.nightscout.androidaps.receivers.DataWorker
|
import info.nightscout.androidaps.receivers.DataWorkerStorage
|
||||||
import info.nightscout.androidaps.interfaces.BuildHelper
|
import info.nightscout.androidaps.interfaces.BuildHelper
|
||||||
import info.nightscout.shared.sharedPreferences.SP
|
import info.nightscout.shared.sharedPreferences.SP
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -24,7 +24,7 @@ class NSClientMbgWorker(
|
||||||
) : Worker(context, params) {
|
) : Worker(context, params) {
|
||||||
|
|
||||||
@Inject lateinit var repository: AppRepository
|
@Inject lateinit var repository: AppRepository
|
||||||
@Inject lateinit var dataWorker: DataWorker
|
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
@Inject lateinit var sp: SP
|
@Inject lateinit var sp: SP
|
||||||
@Inject lateinit var buildHelper: BuildHelper
|
@Inject lateinit var buildHelper: BuildHelper
|
||||||
|
@ -36,7 +36,7 @@ class NSClientMbgWorker(
|
||||||
val acceptNSData = sp.getBoolean(R.string.key_ns_receive_therapy_events, false) || config.NSCLIENT
|
val acceptNSData = sp.getBoolean(R.string.key_ns_receive_therapy_events, false) || config.NSCLIENT
|
||||||
if (!acceptNSData) return Result.success(workDataOf("Result" to "Sync not enabled"))
|
if (!acceptNSData) return Result.success(workDataOf("Result" to "Sync not enabled"))
|
||||||
|
|
||||||
val mbgArray = dataWorker.pickupJSONArray(inputData.getLong(DataWorker.STORE_KEY, -1))
|
val mbgArray = dataWorkerStorage.pickupJSONArray(inputData.getLong(DataWorkerStorage.STORE_KEY, -1))
|
||||||
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
||||||
for (i in 0 until mbgArray.length()) {
|
for (i in 0 until mbgArray.length()) {
|
||||||
val nsMbg = NSMbg(mbgArray.getJSONObject(i))
|
val nsMbg = NSMbg(mbgArray.getJSONObject(i))
|
||||||
|
|
|
@ -12,7 +12,7 @@ import info.nightscout.shared.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus
|
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.acks.NSUpdateAck
|
import info.nightscout.androidaps.plugins.general.nsclient.acks.NSUpdateAck
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientNewLog
|
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientNewLog
|
||||||
import info.nightscout.androidaps.receivers.DataWorker
|
import info.nightscout.androidaps.receivers.DataWorkerStorage
|
||||||
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ class NSClientUpdateRemoveAckWorker(
|
||||||
params: WorkerParameters
|
params: WorkerParameters
|
||||||
) : Worker(context, params) {
|
) : Worker(context, params) {
|
||||||
|
|
||||||
@Inject lateinit var dataWorker: DataWorker
|
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
@Inject lateinit var repository: AppRepository
|
@Inject lateinit var repository: AppRepository
|
||||||
@Inject lateinit var rxBus: RxBus
|
@Inject lateinit var rxBus: RxBus
|
||||||
|
@ -31,7 +31,7 @@ class NSClientUpdateRemoveAckWorker(
|
||||||
override fun doWork(): Result {
|
override fun doWork(): Result {
|
||||||
var ret = Result.success()
|
var ret = Result.success()
|
||||||
|
|
||||||
val ack = dataWorker.pickupObject(inputData.getLong(DataWorker.STORE_KEY, -1)) as NSUpdateAck?
|
val ack = dataWorkerStorage.pickupObject(inputData.getLong(DataWorkerStorage.STORE_KEY, -1)) as NSUpdateAck?
|
||||||
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
||||||
|
|
||||||
// new room way
|
// new room way
|
||||||
|
|
|
@ -42,7 +42,7 @@ import info.nightscout.androidaps.plugins.general.overview.notifications.Notific
|
||||||
import info.nightscout.androidaps.plugins.general.overview.notifications.NotificationWithAction
|
import info.nightscout.androidaps.plugins.general.overview.notifications.NotificationWithAction
|
||||||
import info.nightscout.androidaps.plugins.profile.local.LocalProfilePlugin
|
import info.nightscout.androidaps.plugins.profile.local.LocalProfilePlugin
|
||||||
import info.nightscout.androidaps.plugins.source.NSClientSourcePlugin.NSClientSourceWorker
|
import info.nightscout.androidaps.plugins.source.NSClientSourcePlugin.NSClientSourceWorker
|
||||||
import info.nightscout.androidaps.receivers.DataWorker
|
import info.nightscout.androidaps.receivers.DataWorkerStorage
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.JsonHelper.safeGetString
|
import info.nightscout.androidaps.utils.JsonHelper.safeGetString
|
||||||
|
@ -79,7 +79,7 @@ class NSClientService : DaggerService() {
|
||||||
@Inject lateinit var buildHelper: BuildHelper
|
@Inject lateinit var buildHelper: BuildHelper
|
||||||
@Inject lateinit var config: Config
|
@Inject lateinit var config: Config
|
||||||
@Inject lateinit var dateUtil: DateUtil
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
@Inject lateinit var dataWorker: DataWorker
|
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
|
||||||
@Inject lateinit var dataSyncSelector: DataSyncSelector
|
@Inject lateinit var dataSyncSelector: DataSyncSelector
|
||||||
@Inject lateinit var repository: AppRepository
|
@Inject lateinit var repository: AppRepository
|
||||||
|
|
||||||
|
@ -177,18 +177,18 @@ class NSClientService : DaggerService() {
|
||||||
|
|
||||||
private fun processAddAck(ack: NSAddAck) {
|
private fun processAddAck(ack: NSAddAck) {
|
||||||
lastAckTime = dateUtil.now()
|
lastAckTime = dateUtil.now()
|
||||||
dataWorker.enqueue(
|
dataWorkerStorage.enqueue(
|
||||||
OneTimeWorkRequest.Builder(NSClientAddAckWorker::class.java)
|
OneTimeWorkRequest.Builder(NSClientAddAckWorker::class.java)
|
||||||
.setInputData(dataWorker.storeInputData(ack))
|
.setInputData(dataWorkerStorage.storeInputData(ack))
|
||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun processUpdateAck(ack: NSUpdateAck) {
|
private fun processUpdateAck(ack: NSUpdateAck) {
|
||||||
lastAckTime = dateUtil.now()
|
lastAckTime = dateUtil.now()
|
||||||
dataWorker.enqueue(
|
dataWorkerStorage.enqueue(
|
||||||
OneTimeWorkRequest.Builder(NSClientUpdateRemoveAckWorker::class.java)
|
OneTimeWorkRequest.Builder(NSClientUpdateRemoveAckWorker::class.java)
|
||||||
.setInputData(dataWorker.storeInputData(ack))
|
.setInputData(dataWorkerStorage.storeInputData(ack))
|
||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -466,9 +466,9 @@ class NSClientService : DaggerService() {
|
||||||
// take the newest
|
// take the newest
|
||||||
val profileStoreJson = profiles[profiles.length() - 1] as JSONObject
|
val profileStoreJson = profiles[profiles.length() - 1] as JSONObject
|
||||||
rxBus.send(EventNSClientNewLog("PROFILE", "profile received"))
|
rxBus.send(EventNSClientNewLog("PROFILE", "profile received"))
|
||||||
dataWorker.enqueue(
|
dataWorkerStorage.enqueue(
|
||||||
OneTimeWorkRequest.Builder(LocalProfilePlugin.NSProfileWorker::class.java)
|
OneTimeWorkRequest.Builder(LocalProfilePlugin.NSProfileWorker::class.java)
|
||||||
.setInputData(dataWorker.storeInputData(profileStoreJson))
|
.setInputData(dataWorkerStorage.storeInputData(profileStoreJson))
|
||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -484,9 +484,9 @@ class NSClientService : DaggerService() {
|
||||||
else if (action == "update") addedOrUpdatedTreatments.put(jsonTreatment)
|
else if (action == "update") addedOrUpdatedTreatments.put(jsonTreatment)
|
||||||
}
|
}
|
||||||
if (addedOrUpdatedTreatments.length() > 0) {
|
if (addedOrUpdatedTreatments.length() > 0) {
|
||||||
dataWorker.enqueue(
|
dataWorkerStorage.enqueue(
|
||||||
OneTimeWorkRequest.Builder(NSClientAddUpdateWorker::class.java)
|
OneTimeWorkRequest.Builder(NSClientAddUpdateWorker::class.java)
|
||||||
.setInputData(dataWorker.storeInputData(addedOrUpdatedTreatments))
|
.setInputData(dataWorkerStorage.storeInputData(addedOrUpdatedTreatments))
|
||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -501,18 +501,18 @@ class NSClientService : DaggerService() {
|
||||||
if (data.has("food")) {
|
if (data.has("food")) {
|
||||||
val foods = data.getJSONArray("food")
|
val foods = data.getJSONArray("food")
|
||||||
if (foods.length() > 0) rxBus.send(EventNSClientNewLog("DATA", "received " + foods.length() + " foods"))
|
if (foods.length() > 0) rxBus.send(EventNSClientNewLog("DATA", "received " + foods.length() + " foods"))
|
||||||
dataWorker.enqueue(
|
dataWorkerStorage.enqueue(
|
||||||
OneTimeWorkRequest.Builder(FoodWorker::class.java)
|
OneTimeWorkRequest.Builder(FoodWorker::class.java)
|
||||||
.setInputData(dataWorker.storeInputData(foods))
|
.setInputData(dataWorkerStorage.storeInputData(foods))
|
||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (data.has("mbgs")) {
|
if (data.has("mbgs")) {
|
||||||
val mbgArray = data.getJSONArray("mbgs")
|
val mbgArray = data.getJSONArray("mbgs")
|
||||||
if (mbgArray.length() > 0) rxBus.send(EventNSClientNewLog("DATA", "received " + mbgArray.length() + " mbgs"))
|
if (mbgArray.length() > 0) rxBus.send(EventNSClientNewLog("DATA", "received " + mbgArray.length() + " mbgs"))
|
||||||
dataWorker.enqueue(
|
dataWorkerStorage.enqueue(
|
||||||
OneTimeWorkRequest.Builder(NSClientMbgWorker::class.java)
|
OneTimeWorkRequest.Builder(NSClientMbgWorker::class.java)
|
||||||
.setInputData(dataWorker.storeInputData(mbgArray))
|
.setInputData(dataWorkerStorage.storeInputData(mbgArray))
|
||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -527,9 +527,9 @@ class NSClientService : DaggerService() {
|
||||||
rxBus.send(EventNSClientNewLog("DATA", "received " + sgvs.length() + " sgvs"))
|
rxBus.send(EventNSClientNewLog("DATA", "received " + sgvs.length() + " sgvs"))
|
||||||
// Objective0
|
// Objective0
|
||||||
sp.putBoolean(R.string.key_ObjectivesbgIsAvailableInNS, true)
|
sp.putBoolean(R.string.key_ObjectivesbgIsAvailableInNS, true)
|
||||||
dataWorker.enqueue(
|
dataWorkerStorage.enqueue(
|
||||||
OneTimeWorkRequest.Builder(NSClientSourceWorker::class.java)
|
OneTimeWorkRequest.Builder(NSClientSourceWorker::class.java)
|
||||||
.setInputData(dataWorker.storeInputData(sgvs))
|
.setInputData(dataWorkerStorage.storeInputData(sgvs))
|
||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ import info.nightscout.androidaps.plugins.general.smsCommunicator.events.EventSm
|
||||||
import info.nightscout.androidaps.plugins.general.smsCommunicator.otp.OneTimePassword
|
import info.nightscout.androidaps.plugins.general.smsCommunicator.otp.OneTimePassword
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
|
||||||
import info.nightscout.androidaps.queue.Callback
|
import info.nightscout.androidaps.queue.Callback
|
||||||
import info.nightscout.androidaps.receivers.DataWorker
|
import info.nightscout.androidaps.receivers.DataWorkerStorage
|
||||||
import info.nightscout.androidaps.utils.*
|
import info.nightscout.androidaps.utils.*
|
||||||
import info.nightscout.androidaps.interfaces.ResourceHelper
|
import info.nightscout.androidaps.interfaces.ResourceHelper
|
||||||
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
|
@ -178,7 +178,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
||||||
) : Worker(context, params) {
|
) : Worker(context, params) {
|
||||||
|
|
||||||
@Inject lateinit var smsCommunicatorPlugin: SmsCommunicatorPlugin
|
@Inject lateinit var smsCommunicatorPlugin: SmsCommunicatorPlugin
|
||||||
@Inject lateinit var dataWorker: DataWorker
|
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
|
||||||
|
|
||||||
init {
|
init {
|
||||||
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
|
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
|
||||||
|
@ -186,7 +186,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
||||||
|
|
||||||
@Suppress("SpellCheckingInspection")
|
@Suppress("SpellCheckingInspection")
|
||||||
override fun doWork(): Result {
|
override fun doWork(): Result {
|
||||||
val bundle = dataWorker.pickupBundle(inputData.getLong(DataWorker.STORE_KEY, -1))
|
val bundle = dataWorkerStorage.pickupBundle(inputData.getLong(DataWorkerStorage.STORE_KEY, -1))
|
||||||
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
||||||
val format = bundle.getString("format")
|
val format = bundle.getString("format")
|
||||||
?: return Result.failure(workDataOf("Error" to "missing format in input data"))
|
?: return Result.failure(workDataOf("Error" to "missing format in input data"))
|
||||||
|
|
|
@ -24,7 +24,7 @@ import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress
|
||||||
import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin
|
import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin
|
||||||
import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin
|
import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin
|
||||||
import info.nightscout.androidaps.receivers.DataWorker
|
import info.nightscout.androidaps.receivers.DataWorkerStorage
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter
|
import info.nightscout.androidaps.utils.DecimalFormatter
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
|
@ -62,7 +62,7 @@ class IobCobOref1Worker(
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||||
@Inject lateinit var dateUtil: DateUtil
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
@Inject lateinit var repository: AppRepository
|
@Inject lateinit var repository: AppRepository
|
||||||
@Inject lateinit var dataWorker: DataWorker
|
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
|
||||||
@Inject lateinit var calculationWorkflow: CalculationWorkflow
|
@Inject lateinit var calculationWorkflow: CalculationWorkflow
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
@ -80,7 +80,7 @@ class IobCobOref1Worker(
|
||||||
|
|
||||||
override fun doWork(): Result {
|
override fun doWork(): Result {
|
||||||
|
|
||||||
val data = dataWorker.pickupObject(inputData.getLong(DataWorker.STORE_KEY, -1)) as IobCobOref1WorkerData?
|
val data = dataWorkerStorage.pickupObject(inputData.getLong(DataWorkerStorage.STORE_KEY, -1)) as IobCobOref1WorkerData?
|
||||||
?: return Result.success(workDataOf("Error" to "missing input data"))
|
?: return Result.success(workDataOf("Error" to "missing input data"))
|
||||||
|
|
||||||
val start = dateUtil.now()
|
val start = dateUtil.now()
|
||||||
|
|
|
@ -22,7 +22,7 @@ import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress
|
||||||
import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin
|
import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin
|
||||||
import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin
|
import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin
|
||||||
import info.nightscout.androidaps.receivers.DataWorker
|
import info.nightscout.androidaps.receivers.DataWorkerStorage
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter
|
import info.nightscout.androidaps.utils.DecimalFormatter
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
|
@ -59,7 +59,7 @@ class IobCobOrefWorker @Inject internal constructor(
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||||
@Inject lateinit var dateUtil: DateUtil
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
@Inject lateinit var repository: AppRepository
|
@Inject lateinit var repository: AppRepository
|
||||||
@Inject lateinit var dataWorker: DataWorker
|
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
|
||||||
|
|
||||||
init {
|
init {
|
||||||
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
|
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
|
||||||
|
@ -75,7 +75,7 @@ class IobCobOrefWorker @Inject internal constructor(
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun doWork(): Result {
|
override fun doWork(): Result {
|
||||||
val data = dataWorker.pickupObject(inputData.getLong(DataWorker.STORE_KEY, -1)) as IobCobOrefWorkerData?
|
val data = dataWorkerStorage.pickupObject(inputData.getLong(DataWorkerStorage.STORE_KEY, -1)) as IobCobOrefWorkerData?
|
||||||
?: return Result.success(workDataOf("Error" to "missing input data"))
|
?: return Result.success(workDataOf("Error" to "missing input data"))
|
||||||
|
|
||||||
val start = dateUtil.now()
|
val start = dateUtil.now()
|
||||||
|
|
|
@ -22,7 +22,7 @@ import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotifi
|
||||||
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification
|
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification
|
||||||
import info.nightscout.androidaps.plugins.general.overview.notifications.NotificationWithAction
|
import info.nightscout.androidaps.plugins.general.overview.notifications.NotificationWithAction
|
||||||
import info.nightscout.androidaps.plugins.profile.local.events.EventLocalProfileChanged
|
import info.nightscout.androidaps.plugins.profile.local.events.EventLocalProfileChanged
|
||||||
import info.nightscout.androidaps.receivers.DataWorker
|
import info.nightscout.androidaps.receivers.DataWorkerStorage
|
||||||
import info.nightscout.androidaps.utils.*
|
import info.nightscout.androidaps.utils.*
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||||
import info.nightscout.androidaps.interfaces.ResourceHelper
|
import info.nightscout.androidaps.interfaces.ResourceHelper
|
||||||
|
@ -457,7 +457,7 @@ class LocalProfilePlugin @Inject constructor(
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
@Inject lateinit var rxBus: RxBus
|
@Inject lateinit var rxBus: RxBus
|
||||||
@Inject lateinit var dateUtil: DateUtil
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
@Inject lateinit var dataWorker: DataWorker
|
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
|
||||||
@Inject lateinit var sp: SP
|
@Inject lateinit var sp: SP
|
||||||
@Inject lateinit var config: Config
|
@Inject lateinit var config: Config
|
||||||
@Inject lateinit var localProfilePlugin: LocalProfilePlugin
|
@Inject lateinit var localProfilePlugin: LocalProfilePlugin
|
||||||
|
@ -468,7 +468,7 @@ class LocalProfilePlugin @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun doWork(): Result {
|
override fun doWork(): Result {
|
||||||
val profileJson = dataWorker.pickupJSONObject(inputData.getLong(DataWorker.STORE_KEY, -1))
|
val profileJson = dataWorkerStorage.pickupJSONObject(inputData.getLong(DataWorkerStorage.STORE_KEY, -1))
|
||||||
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
||||||
xDripBroadcast.sendProfile(profileJson)
|
xDripBroadcast.sendProfile(profileJson)
|
||||||
if (sp.getBoolean(R.string.key_ns_receive_profile_store, true) || config.NSCLIENT) {
|
if (sp.getBoolean(R.string.key_ns_receive_profile_store, true) || config.NSCLIENT) {
|
||||||
|
|
|
@ -11,7 +11,7 @@ import info.nightscout.androidaps.database.AppRepository
|
||||||
import info.nightscout.androidaps.database.entities.GlucoseValue
|
import info.nightscout.androidaps.database.entities.GlucoseValue
|
||||||
import info.nightscout.androidaps.database.transactions.CgmSourceTransaction
|
import info.nightscout.androidaps.database.transactions.CgmSourceTransaction
|
||||||
import info.nightscout.androidaps.interfaces.*
|
import info.nightscout.androidaps.interfaces.*
|
||||||
import info.nightscout.androidaps.receivers.DataWorker
|
import info.nightscout.androidaps.receivers.DataWorkerStorage
|
||||||
import info.nightscout.androidaps.receivers.Intents
|
import info.nightscout.androidaps.receivers.Intents
|
||||||
import info.nightscout.androidaps.interfaces.BuildHelper
|
import info.nightscout.androidaps.interfaces.BuildHelper
|
||||||
import info.nightscout.shared.logging.AAPSLogger
|
import info.nightscout.shared.logging.AAPSLogger
|
||||||
|
@ -62,7 +62,7 @@ class AidexPlugin @Inject constructor(
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
@Inject lateinit var aidexPlugin: AidexPlugin
|
@Inject lateinit var aidexPlugin: AidexPlugin
|
||||||
@Inject lateinit var repository: AppRepository
|
@Inject lateinit var repository: AppRepository
|
||||||
@Inject lateinit var dataWorker: DataWorker
|
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
|
||||||
|
|
||||||
init {
|
init {
|
||||||
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
|
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
|
||||||
|
@ -72,7 +72,7 @@ class AidexPlugin @Inject constructor(
|
||||||
var ret = Result.success()
|
var ret = Result.success()
|
||||||
|
|
||||||
if (!aidexPlugin.isEnabled()) return Result.success(workDataOf("Result" to "Plugin not enabled"))
|
if (!aidexPlugin.isEnabled()) return Result.success(workDataOf("Result" to "Plugin not enabled"))
|
||||||
val bundle = dataWorker.pickupBundle(inputData.getLong(DataWorker.STORE_KEY, -1))
|
val bundle = dataWorkerStorage.pickupBundle(inputData.getLong(DataWorkerStorage.STORE_KEY, -1))
|
||||||
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
||||||
|
|
||||||
aapsLogger.debug(LTag.BGSOURCE, "Received Aidex data: $bundle")
|
aapsLogger.debug(LTag.BGSOURCE, "Received Aidex data: $bundle")
|
||||||
|
|
|
@ -28,7 +28,7 @@ import info.nightscout.androidaps.interfaces.PluginType
|
||||||
import info.nightscout.androidaps.interfaces.Profile
|
import info.nightscout.androidaps.interfaces.Profile
|
||||||
import info.nightscout.androidaps.interfaces.ResourceHelper
|
import info.nightscout.androidaps.interfaces.ResourceHelper
|
||||||
import info.nightscout.androidaps.logging.UserEntryLogger
|
import info.nightscout.androidaps.logging.UserEntryLogger
|
||||||
import info.nightscout.androidaps.receivers.DataWorker
|
import info.nightscout.androidaps.receivers.DataWorkerStorage
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.T
|
import info.nightscout.androidaps.utils.T
|
||||||
import info.nightscout.androidaps.utils.XDripBroadcast
|
import info.nightscout.androidaps.utils.XDripBroadcast
|
||||||
|
@ -91,7 +91,7 @@ class DexcomPlugin @Inject constructor(
|
||||||
@Inject lateinit var dexcomPlugin: DexcomPlugin
|
@Inject lateinit var dexcomPlugin: DexcomPlugin
|
||||||
@Inject lateinit var sp: SP
|
@Inject lateinit var sp: SP
|
||||||
@Inject lateinit var dateUtil: DateUtil
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
@Inject lateinit var dataWorker: DataWorker
|
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
|
||||||
@Inject lateinit var xDripBroadcast: XDripBroadcast
|
@Inject lateinit var xDripBroadcast: XDripBroadcast
|
||||||
@Inject lateinit var repository: AppRepository
|
@Inject lateinit var repository: AppRepository
|
||||||
@Inject lateinit var uel: UserEntryLogger
|
@Inject lateinit var uel: UserEntryLogger
|
||||||
|
@ -104,7 +104,7 @@ class DexcomPlugin @Inject constructor(
|
||||||
var ret = Result.success()
|
var ret = Result.success()
|
||||||
|
|
||||||
if (!dexcomPlugin.isEnabled()) return Result.success(workDataOf("Result" to "Plugin not enabled"))
|
if (!dexcomPlugin.isEnabled()) return Result.success(workDataOf("Result" to "Plugin not enabled"))
|
||||||
val bundle = dataWorker.pickupBundle(inputData.getLong(DataWorker.STORE_KEY, -1))
|
val bundle = dataWorkerStorage.pickupBundle(inputData.getLong(DataWorkerStorage.STORE_KEY, -1))
|
||||||
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
||||||
try {
|
try {
|
||||||
val sourceSensor = when (bundle.getString("sensorType") ?: "") {
|
val sourceSensor = when (bundle.getString("sensorType") ?: "") {
|
||||||
|
|
|
@ -17,7 +17,7 @@ import info.nightscout.androidaps.interfaces.PluginDescription
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
import info.nightscout.shared.logging.AAPSLogger
|
import info.nightscout.shared.logging.AAPSLogger
|
||||||
import info.nightscout.shared.logging.LTag
|
import info.nightscout.shared.logging.LTag
|
||||||
import info.nightscout.androidaps.receivers.DataWorker
|
import info.nightscout.androidaps.receivers.DataWorkerStorage
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.XDripBroadcast
|
import info.nightscout.androidaps.utils.XDripBroadcast
|
||||||
import info.nightscout.androidaps.interfaces.ResourceHelper
|
import info.nightscout.androidaps.interfaces.ResourceHelper
|
||||||
|
@ -58,7 +58,7 @@ class EversensePlugin @Inject constructor(
|
||||||
@Inject lateinit var eversensePlugin: EversensePlugin
|
@Inject lateinit var eversensePlugin: EversensePlugin
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
@Inject lateinit var dateUtil: DateUtil
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
@Inject lateinit var dataWorker: DataWorker
|
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
|
||||||
@Inject lateinit var repository: AppRepository
|
@Inject lateinit var repository: AppRepository
|
||||||
@Inject lateinit var xDripBroadcast: XDripBroadcast
|
@Inject lateinit var xDripBroadcast: XDripBroadcast
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ class EversensePlugin @Inject constructor(
|
||||||
var ret = Result.success()
|
var ret = Result.success()
|
||||||
|
|
||||||
if (!eversensePlugin.isEnabled()) return Result.success(workDataOf("Result" to "Plugin not enabled"))
|
if (!eversensePlugin.isEnabled()) return Result.success(workDataOf("Result" to "Plugin not enabled"))
|
||||||
val bundle = dataWorker.pickupBundle(inputData.getLong(DataWorker.STORE_KEY, -1))
|
val bundle = dataWorkerStorage.pickupBundle(inputData.getLong(DataWorkerStorage.STORE_KEY, -1))
|
||||||
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
||||||
if (bundle.containsKey("currentCalibrationPhase")) aapsLogger.debug(LTag.BGSOURCE, "currentCalibrationPhase: " + bundle.getString("currentCalibrationPhase"))
|
if (bundle.containsKey("currentCalibrationPhase")) aapsLogger.debug(LTag.BGSOURCE, "currentCalibrationPhase: " + bundle.getString("currentCalibrationPhase"))
|
||||||
if (bundle.containsKey("placementModeInProgress")) aapsLogger.debug(LTag.BGSOURCE, "placementModeInProgress: " + bundle.getBoolean("placementModeInProgress"))
|
if (bundle.containsKey("placementModeInProgress")) aapsLogger.debug(LTag.BGSOURCE, "placementModeInProgress: " + bundle.getBoolean("placementModeInProgress"))
|
||||||
|
|
|
@ -15,7 +15,7 @@ import info.nightscout.androidaps.interfaces.PluginDescription
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
import info.nightscout.shared.logging.AAPSLogger
|
import info.nightscout.shared.logging.AAPSLogger
|
||||||
import info.nightscout.shared.logging.LTag
|
import info.nightscout.shared.logging.LTag
|
||||||
import info.nightscout.androidaps.receivers.DataWorker
|
import info.nightscout.androidaps.receivers.DataWorkerStorage
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.XDripBroadcast
|
import info.nightscout.androidaps.utils.XDripBroadcast
|
||||||
import info.nightscout.androidaps.interfaces.ResourceHelper
|
import info.nightscout.androidaps.interfaces.ResourceHelper
|
||||||
|
@ -50,7 +50,7 @@ class MM640gPlugin @Inject constructor(
|
||||||
@Inject lateinit var injector: HasAndroidInjector
|
@Inject lateinit var injector: HasAndroidInjector
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
@Inject lateinit var dateUtil: DateUtil
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
@Inject lateinit var dataWorker: DataWorker
|
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
|
||||||
@Inject lateinit var repository: AppRepository
|
@Inject lateinit var repository: AppRepository
|
||||||
@Inject lateinit var xDripBroadcast: XDripBroadcast
|
@Inject lateinit var xDripBroadcast: XDripBroadcast
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ import info.nightscout.androidaps.plugins.general.nsclient.NSClientPlugin
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.data.NSSgv
|
import info.nightscout.androidaps.plugins.general.nsclient.data.NSSgv
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification
|
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification
|
||||||
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification
|
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification
|
||||||
import info.nightscout.androidaps.receivers.DataWorker
|
import info.nightscout.androidaps.receivers.DataWorkerStorage
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.T
|
import info.nightscout.androidaps.utils.T
|
||||||
import info.nightscout.androidaps.utils.XDripBroadcast
|
import info.nightscout.androidaps.utils.XDripBroadcast
|
||||||
|
@ -89,7 +89,7 @@ class NSClientSourcePlugin @Inject constructor(
|
||||||
@Inject lateinit var sp: SP
|
@Inject lateinit var sp: SP
|
||||||
@Inject lateinit var rxBus: RxBus
|
@Inject lateinit var rxBus: RxBus
|
||||||
@Inject lateinit var dateUtil: DateUtil
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
@Inject lateinit var dataWorker: DataWorker
|
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
|
||||||
@Inject lateinit var repository: AppRepository
|
@Inject lateinit var repository: AppRepository
|
||||||
@Inject lateinit var xDripBroadcast: XDripBroadcast
|
@Inject lateinit var xDripBroadcast: XDripBroadcast
|
||||||
@Inject lateinit var dexcomPlugin: DexcomPlugin
|
@Inject lateinit var dexcomPlugin: DexcomPlugin
|
||||||
|
@ -115,7 +115,7 @@ class NSClientSourcePlugin @Inject constructor(
|
||||||
@Suppress("SpellCheckingInspection")
|
@Suppress("SpellCheckingInspection")
|
||||||
override fun doWork(): Result {
|
override fun doWork(): Result {
|
||||||
var ret = Result.success()
|
var ret = Result.success()
|
||||||
val sgvs = dataWorker.pickupJSONArray(inputData.getLong(DataWorker.STORE_KEY, -1))
|
val sgvs = dataWorkerStorage.pickupJSONArray(inputData.getLong(DataWorkerStorage.STORE_KEY, -1))
|
||||||
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
||||||
xDripBroadcast.sendSgvs(sgvs)
|
xDripBroadcast.sendSgvs(sgvs)
|
||||||
if (!nsClientSourcePlugin.isEnabled() && !sp.getBoolean(R.string.key_ns_receive_cgm, false))
|
if (!nsClientSourcePlugin.isEnabled() && !sp.getBoolean(R.string.key_ns_receive_cgm, false))
|
||||||
|
|
|
@ -15,7 +15,7 @@ import info.nightscout.androidaps.interfaces.PluginDescription
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
import info.nightscout.shared.logging.AAPSLogger
|
import info.nightscout.shared.logging.AAPSLogger
|
||||||
import info.nightscout.shared.logging.LTag
|
import info.nightscout.shared.logging.LTag
|
||||||
import info.nightscout.androidaps.receivers.DataWorker
|
import info.nightscout.androidaps.receivers.DataWorkerStorage
|
||||||
import info.nightscout.androidaps.receivers.Intents
|
import info.nightscout.androidaps.receivers.Intents
|
||||||
import info.nightscout.androidaps.interfaces.ResourceHelper
|
import info.nightscout.androidaps.interfaces.ResourceHelper
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -64,7 +64,7 @@ class XdripPlugin @Inject constructor(
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
@Inject lateinit var xdripPlugin: XdripPlugin
|
@Inject lateinit var xdripPlugin: XdripPlugin
|
||||||
@Inject lateinit var repository: AppRepository
|
@Inject lateinit var repository: AppRepository
|
||||||
@Inject lateinit var dataWorker: DataWorker
|
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
|
||||||
|
|
||||||
init {
|
init {
|
||||||
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
|
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
|
||||||
|
@ -74,7 +74,7 @@ class XdripPlugin @Inject constructor(
|
||||||
var ret = Result.success()
|
var ret = Result.success()
|
||||||
|
|
||||||
if (!xdripPlugin.isEnabled()) return Result.success(workDataOf("Result" to "Plugin not enabled"))
|
if (!xdripPlugin.isEnabled()) return Result.success(workDataOf("Result" to "Plugin not enabled"))
|
||||||
val bundle = dataWorker.pickupBundle(inputData.getLong(DataWorker.STORE_KEY, -1))
|
val bundle = dataWorkerStorage.pickupBundle(inputData.getLong(DataWorkerStorage.STORE_KEY, -1))
|
||||||
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
||||||
|
|
||||||
aapsLogger.debug(LTag.BGSOURCE, "Received xDrip data: $bundle")
|
aapsLogger.debug(LTag.BGSOURCE, "Received xDrip data: $bundle")
|
||||||
|
|
|
@ -19,7 +19,7 @@ import javax.inject.Inject
|
||||||
open class DataReceiver : DaggerBroadcastReceiver() {
|
open class DataReceiver : DaggerBroadcastReceiver() {
|
||||||
|
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
@Inject lateinit var dataWorker: DataWorker
|
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
|
||||||
|
|
||||||
override fun onReceive(context: Context, intent: Intent) {
|
override fun onReceive(context: Context, intent: Intent) {
|
||||||
super.onReceive(context, intent)
|
super.onReceive(context, intent)
|
||||||
|
@ -29,7 +29,7 @@ open class DataReceiver : DaggerBroadcastReceiver() {
|
||||||
when (intent.action) {
|
when (intent.action) {
|
||||||
Intents.ACTION_NEW_BG_ESTIMATE ->
|
Intents.ACTION_NEW_BG_ESTIMATE ->
|
||||||
OneTimeWorkRequest.Builder(XdripPlugin.XdripWorker::class.java)
|
OneTimeWorkRequest.Builder(XdripPlugin.XdripWorker::class.java)
|
||||||
.setInputData(dataWorker.storeInputData(bundle, intent.action)).build()
|
.setInputData(dataWorkerStorage.storeInputData(bundle, intent.action)).build()
|
||||||
Intents.POCTECH_BG ->
|
Intents.POCTECH_BG ->
|
||||||
OneTimeWorkRequest.Builder(PoctechPlugin.PoctechWorker::class.java)
|
OneTimeWorkRequest.Builder(PoctechPlugin.PoctechWorker::class.java)
|
||||||
.setInputData(Data.Builder().also {
|
.setInputData(Data.Builder().also {
|
||||||
|
@ -57,18 +57,18 @@ open class DataReceiver : DaggerBroadcastReceiver() {
|
||||||
}.build()).build()
|
}.build()).build()
|
||||||
Telephony.Sms.Intents.SMS_RECEIVED_ACTION ->
|
Telephony.Sms.Intents.SMS_RECEIVED_ACTION ->
|
||||||
OneTimeWorkRequest.Builder(SmsCommunicatorPlugin.SmsCommunicatorWorker::class.java)
|
OneTimeWorkRequest.Builder(SmsCommunicatorPlugin.SmsCommunicatorWorker::class.java)
|
||||||
.setInputData(dataWorker.storeInputData(bundle, intent.action)).build()
|
.setInputData(dataWorkerStorage.storeInputData(bundle, intent.action)).build()
|
||||||
Intents.EVERSENSE_BG ->
|
Intents.EVERSENSE_BG ->
|
||||||
OneTimeWorkRequest.Builder(EversensePlugin.EversenseWorker::class.java)
|
OneTimeWorkRequest.Builder(EversensePlugin.EversenseWorker::class.java)
|
||||||
.setInputData(dataWorker.storeInputData(bundle, intent.action)).build()
|
.setInputData(dataWorkerStorage.storeInputData(bundle, intent.action)).build()
|
||||||
Intents.DEXCOM_BG ->
|
Intents.DEXCOM_BG ->
|
||||||
OneTimeWorkRequest.Builder(DexcomPlugin.DexcomWorker::class.java)
|
OneTimeWorkRequest.Builder(DexcomPlugin.DexcomWorker::class.java)
|
||||||
.setInputData(dataWorker.storeInputData(bundle, intent.action)).build()
|
.setInputData(dataWorkerStorage.storeInputData(bundle, intent.action)).build()
|
||||||
Intents.AIDEX_NEW_BG_ESTIMATE ->
|
Intents.AIDEX_NEW_BG_ESTIMATE ->
|
||||||
OneTimeWorkRequest.Builder(AidexPlugin.AidexWorker::class.java)
|
OneTimeWorkRequest.Builder(AidexPlugin.AidexWorker::class.java)
|
||||||
.setInputData(dataWorker.storeInputData(bundle, intent.action)).build()
|
.setInputData(dataWorkerStorage.storeInputData(bundle, intent.action)).build()
|
||||||
else -> null
|
else -> null
|
||||||
}?.let { request -> dataWorker.enqueue(request) }
|
}?.let { request -> dataWorkerStorage.enqueue(request) }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package info.nightscout.androidaps.receivers
|
package info.nightscout.androidaps.receivers
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.work.Data
|
import androidx.work.Data
|
||||||
import androidx.work.ExistingWorkPolicy
|
import androidx.work.ExistingWorkPolicy
|
||||||
|
@ -13,7 +12,7 @@ import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class DataWorker @Inject constructor(
|
class DataWorkerStorage @Inject constructor(
|
||||||
private val context: Context
|
private val context: Context
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -1,7 +1,15 @@
|
||||||
package info.nightscout.androidaps.receivers
|
package info.nightscout.androidaps.receivers
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import androidx.work.*
|
import androidx.work.Data
|
||||||
|
import androidx.work.ExistingWorkPolicy
|
||||||
|
import androidx.work.OneTimeWorkRequest
|
||||||
|
import androidx.work.WorkInfo
|
||||||
|
import androidx.work.WorkManager
|
||||||
|
import androidx.work.WorkQuery
|
||||||
|
import androidx.work.Worker
|
||||||
|
import androidx.work.WorkerParameters
|
||||||
|
import androidx.work.workDataOf
|
||||||
import com.google.common.util.concurrent.ListenableFuture
|
import com.google.common.util.concurrent.ListenableFuture
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.BuildConfig
|
import info.nightscout.androidaps.BuildConfig
|
||||||
|
@ -10,7 +18,14 @@ import info.nightscout.androidaps.data.ProfileSealed
|
||||||
import info.nightscout.androidaps.database.AppRepository
|
import info.nightscout.androidaps.database.AppRepository
|
||||||
import info.nightscout.androidaps.events.EventProfileSwitchChanged
|
import info.nightscout.androidaps.events.EventProfileSwitchChanged
|
||||||
import info.nightscout.androidaps.extensions.buildDeviceStatus
|
import info.nightscout.androidaps.extensions.buildDeviceStatus
|
||||||
import info.nightscout.androidaps.interfaces.*
|
import info.nightscout.androidaps.interfaces.ActivePlugin
|
||||||
|
import info.nightscout.androidaps.interfaces.CommandQueue
|
||||||
|
import info.nightscout.androidaps.interfaces.Config
|
||||||
|
import info.nightscout.androidaps.interfaces.IobCobCalculator
|
||||||
|
import info.nightscout.androidaps.interfaces.Loop
|
||||||
|
import info.nightscout.androidaps.interfaces.PluginBase
|
||||||
|
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||||
|
import info.nightscout.androidaps.interfaces.ResourceHelper
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus
|
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.RunningConfiguration
|
import info.nightscout.androidaps.plugins.configBuilder.RunningConfiguration
|
||||||
import info.nightscout.androidaps.plugins.general.maintenance.MaintenancePlugin
|
import info.nightscout.androidaps.plugins.general.maintenance.MaintenancePlugin
|
||||||
|
@ -19,7 +34,6 @@ import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.LocalAlertUtils
|
import info.nightscout.androidaps.utils.LocalAlertUtils
|
||||||
import info.nightscout.androidaps.utils.T
|
import info.nightscout.androidaps.utils.T
|
||||||
import info.nightscout.androidaps.interfaces.ResourceHelper
|
|
||||||
import info.nightscout.androidaps.widget.updateWidget
|
import info.nightscout.androidaps.widget.updateWidget
|
||||||
import info.nightscout.shared.logging.AAPSLogger
|
import info.nightscout.shared.logging.AAPSLogger
|
||||||
import info.nightscout.shared.logging.LTag
|
import info.nightscout.shared.logging.LTag
|
||||||
|
@ -62,31 +76,45 @@ class KeepAliveWorker(
|
||||||
private var lastRun: Long = 0
|
private var lastRun: Long = 0
|
||||||
private var lastIobUpload: Long = 0
|
private var lastIobUpload: Long = 0
|
||||||
|
|
||||||
|
const val KA_0 = "KeepAlive"
|
||||||
|
private const val KA_5 = "KeepAlive_5"
|
||||||
|
private const val KA_10 = "KeepAlive_10"
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun doWork(): Result {
|
override fun doWork(): Result {
|
||||||
aapsLogger.debug(LTag.CORE, "KeepAlive received from: " + inputData.getString("schedule"))
|
aapsLogger.debug(LTag.CORE, "KeepAlive received from: " + inputData.getString("schedule"))
|
||||||
|
|
||||||
// 15 min interval is WorkManager minimum so schedule another instances to have 5 min interval
|
// 15 min interval is WorkManager minimum so schedule another instances to have 5 min interval
|
||||||
if (inputData.getString("schedule") == "KeepAlive") {
|
if (inputData.getString("schedule") == KA_0) {
|
||||||
WorkManager.getInstance(context).enqueueUniqueWork(
|
WorkManager.getInstance(context).enqueueUniqueWork(
|
||||||
"KeepAlive_5",
|
KA_5,
|
||||||
ExistingWorkPolicy.REPLACE,
|
ExistingWorkPolicy.REPLACE,
|
||||||
OneTimeWorkRequest.Builder(KeepAliveWorker::class.java)
|
OneTimeWorkRequest.Builder(KeepAliveWorker::class.java)
|
||||||
.setInputData(Data.Builder().putString("schedule", "KeepAlive_5").build())
|
.setInputData(Data.Builder().putString("schedule", KA_5).build())
|
||||||
.setInitialDelay(5, TimeUnit.MINUTES)
|
.setInitialDelay(5, TimeUnit.MINUTES)
|
||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
WorkManager.getInstance(context).enqueueUniqueWork(
|
WorkManager.getInstance(context).enqueueUniqueWork(
|
||||||
"KeepAlive_10",
|
KA_10,
|
||||||
ExistingWorkPolicy.REPLACE,
|
ExistingWorkPolicy.REPLACE,
|
||||||
OneTimeWorkRequest.Builder(KeepAliveWorker::class.java)
|
OneTimeWorkRequest.Builder(KeepAliveWorker::class.java)
|
||||||
.setInputData(Data.Builder().putString("schedule", "KeepAlive_10").build())
|
.setInputData(Data.Builder().putString("schedule", KA_10).build())
|
||||||
.setInitialDelay(10, TimeUnit.MINUTES)
|
.setInitialDelay(10, TimeUnit.MINUTES)
|
||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
|
} else {
|
||||||
|
// Sometimes schedule +5min, +10min gets broken
|
||||||
|
// If this happen do nothing
|
||||||
|
// It's causing false Pump unreachable alerts
|
||||||
|
if (lastRun + T.mins(4).msecs() > dateUtil.now()) return Result.success(workDataOf("Error" to "Schedule broken. Ignoring"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (lastRun != 0L && dateUtil.now() - lastRun > T.mins(10).msecs()) {
|
||||||
|
aapsLogger.error(LTag.CORE, "KeepAlive fail")
|
||||||
|
fabricPrivacy.logCustom("KeepAliveFail")
|
||||||
|
}
|
||||||
|
lastRun = dateUtil.now()
|
||||||
|
|
||||||
updateWidget(context)
|
updateWidget(context)
|
||||||
localAlertUtils.shortenSnoozeInterval()
|
localAlertUtils.shortenSnoozeInterval()
|
||||||
localAlertUtils.checkStaleBGAlert()
|
localAlertUtils.checkStaleBGAlert()
|
||||||
|
@ -141,12 +169,12 @@ class KeepAliveWorker(
|
||||||
val requestedProfile = ProfileSealed.PS(ps)
|
val requestedProfile = ProfileSealed.PS(ps)
|
||||||
val runningProfile = profileFunction.getProfile()
|
val runningProfile = profileFunction.getProfile()
|
||||||
val lastConnection = pump.lastDataTime()
|
val lastConnection = pump.lastDataTime()
|
||||||
val isStatusOutdated = lastConnection + STATUS_UPDATE_FREQUENCY < System.currentTimeMillis()
|
val isStatusOutdated = lastConnection + STATUS_UPDATE_FREQUENCY < dateUtil.now()
|
||||||
val isBasalOutdated = abs(requestedProfile.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))
|
aapsLogger.debug(LTag.CORE, "Last connection: " + dateUtil.dateAndTimeString(lastConnection))
|
||||||
// sometimes keep alive broadcast stops
|
// sometimes keep alive broadcast stops
|
||||||
// as as workaround test if readStatus was requested before an alarm is generated
|
// as as workaround test if readStatus was requested before an alarm is generated
|
||||||
if (lastReadStatus != 0L && lastReadStatus > System.currentTimeMillis() - T.mins(5).msecs()) {
|
if (lastReadStatus != 0L && lastReadStatus > dateUtil.now() - T.mins(5).msecs()) {
|
||||||
localAlertUtils.checkPumpUnreachableAlarm(lastConnection, isStatusOutdated, loop.isDisconnected)
|
localAlertUtils.checkPumpUnreachableAlarm(lastConnection, isStatusOutdated, loop.isDisconnected)
|
||||||
}
|
}
|
||||||
if (loop.isDisconnected) {
|
if (loop.isDisconnected) {
|
||||||
|
@ -154,16 +182,11 @@ class KeepAliveWorker(
|
||||||
} 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)) && !commandQueue.isRunning(Command.CommandType.BASAL_PROFILE))) {
|
||||||
rxBus.send(EventProfileSwitchChanged())
|
rxBus.send(EventProfileSwitchChanged())
|
||||||
} else if (isStatusOutdated && !pump.isBusy()) {
|
} else if (isStatusOutdated && !pump.isBusy()) {
|
||||||
lastReadStatus = System.currentTimeMillis()
|
lastReadStatus = dateUtil.now()
|
||||||
commandQueue.readStatus(rh.gs(R.string.keepalive_status_outdated), null)
|
commandQueue.readStatus(rh.gs(R.string.keepalive_status_outdated), null)
|
||||||
} else if (isBasalOutdated && !pump.isBusy()) {
|
} else if (isBasalOutdated && !pump.isBusy()) {
|
||||||
lastReadStatus = System.currentTimeMillis()
|
lastReadStatus = dateUtil.now()
|
||||||
commandQueue.readStatus(rh.gs(R.string.keepalive_basal_outdated), null)
|
commandQueue.readStatus(rh.gs(R.string.keepalive_basal_outdated), null)
|
||||||
}
|
}
|
||||||
if (lastRun != 0L && System.currentTimeMillis() - lastRun > T.mins(10).msecs()) {
|
|
||||||
aapsLogger.error(LTag.CORE, "KeepAlive fail")
|
|
||||||
fabricPrivacy.logCustom("KeepAliveFail")
|
|
||||||
}
|
|
||||||
lastRun = System.currentTimeMillis()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -19,7 +19,7 @@ import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobOref1Worker
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobOrefWorker
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobOrefWorker
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventNewHistoryData
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventNewHistoryData
|
||||||
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin
|
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin
|
||||||
import info.nightscout.androidaps.receivers.DataWorker
|
import info.nightscout.androidaps.receivers.DataWorkerStorage
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.interfaces.ResourceHelper
|
import info.nightscout.androidaps.interfaces.ResourceHelper
|
||||||
|
@ -42,7 +42,7 @@ class CalculationWorkflow @Inject constructor(
|
||||||
private val fabricPrivacy: FabricPrivacy,
|
private val fabricPrivacy: FabricPrivacy,
|
||||||
private val dateUtil: DateUtil,
|
private val dateUtil: DateUtil,
|
||||||
private val sensitivityOref1Plugin: SensitivityOref1Plugin,
|
private val sensitivityOref1Plugin: SensitivityOref1Plugin,
|
||||||
private val dataWorker: DataWorker,
|
private val dataWorkerStorage: DataWorkerStorage,
|
||||||
private val activePlugin: ActivePlugin
|
private val activePlugin: ActivePlugin
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
@ -151,17 +151,17 @@ class CalculationWorkflow @Inject constructor(
|
||||||
WorkManager.getInstance(context)
|
WorkManager.getInstance(context)
|
||||||
.beginUniqueWork(
|
.beginUniqueWork(
|
||||||
job, ExistingWorkPolicy.REPLACE,
|
job, ExistingWorkPolicy.REPLACE,
|
||||||
if (bgDataReload) OneTimeWorkRequest.Builder(LoadBgDataWorker::class.java).setInputData(dataWorker.storeInputData(LoadBgDataWorker.LoadBgData(iobCobCalculator, end))).build()
|
if (bgDataReload) OneTimeWorkRequest.Builder(LoadBgDataWorker::class.java).setInputData(dataWorkerStorage.storeInputData(LoadBgDataWorker.LoadBgData(iobCobCalculator, end))).build()
|
||||||
else OneTimeWorkRequest.Builder(DummyWorker::class.java).build()
|
else OneTimeWorkRequest.Builder(DummyWorker::class.java).build()
|
||||||
)
|
)
|
||||||
.then(
|
.then(
|
||||||
OneTimeWorkRequest.Builder(PrepareBucketedDataWorker::class.java)
|
OneTimeWorkRequest.Builder(PrepareBucketedDataWorker::class.java)
|
||||||
.setInputData(dataWorker.storeInputData(PrepareBucketedDataWorker.PrepareBucketedData(iobCobCalculator, overviewData)))
|
.setInputData(dataWorkerStorage.storeInputData(PrepareBucketedDataWorker.PrepareBucketedData(iobCobCalculator, overviewData)))
|
||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
.then(
|
.then(
|
||||||
OneTimeWorkRequest.Builder(PrepareBgDataWorker::class.java)
|
OneTimeWorkRequest.Builder(PrepareBgDataWorker::class.java)
|
||||||
.setInputData(dataWorker.storeInputData(PrepareBgDataWorker.PrepareBgData(iobCobCalculator, overviewData)))
|
.setInputData(dataWorkerStorage.storeInputData(PrepareBgDataWorker.PrepareBgData(iobCobCalculator, overviewData)))
|
||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
.then(
|
.then(
|
||||||
|
@ -171,17 +171,17 @@ class CalculationWorkflow @Inject constructor(
|
||||||
)
|
)
|
||||||
.then(
|
.then(
|
||||||
OneTimeWorkRequest.Builder(PrepareTreatmentsDataWorker::class.java)
|
OneTimeWorkRequest.Builder(PrepareTreatmentsDataWorker::class.java)
|
||||||
.setInputData(dataWorker.storeInputData(PrepareTreatmentsDataWorker.PrepareTreatmentsData(overviewData)))
|
.setInputData(dataWorkerStorage.storeInputData(PrepareTreatmentsDataWorker.PrepareTreatmentsData(overviewData)))
|
||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
.then(
|
.then(
|
||||||
OneTimeWorkRequest.Builder(PrepareBasalDataWorker::class.java)
|
OneTimeWorkRequest.Builder(PrepareBasalDataWorker::class.java)
|
||||||
.setInputData(dataWorker.storeInputData(PrepareBasalDataWorker.PrepareBasalData(iobCobCalculator, overviewData)))
|
.setInputData(dataWorkerStorage.storeInputData(PrepareBasalDataWorker.PrepareBasalData(iobCobCalculator, overviewData)))
|
||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
.then(
|
.then(
|
||||||
OneTimeWorkRequest.Builder(PrepareTemporaryTargetDataWorker::class.java)
|
OneTimeWorkRequest.Builder(PrepareTemporaryTargetDataWorker::class.java)
|
||||||
.setInputData(dataWorker.storeInputData(PrepareTemporaryTargetDataWorker.PrepareTemporaryTargetData(overviewData)))
|
.setInputData(dataWorkerStorage.storeInputData(PrepareTemporaryTargetDataWorker.PrepareTemporaryTargetData(overviewData)))
|
||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
.then(
|
.then(
|
||||||
|
@ -192,17 +192,17 @@ class CalculationWorkflow @Inject constructor(
|
||||||
.then(
|
.then(
|
||||||
if (sensitivityOref1Plugin.isEnabled())
|
if (sensitivityOref1Plugin.isEnabled())
|
||||||
OneTimeWorkRequest.Builder(IobCobOref1Worker::class.java)
|
OneTimeWorkRequest.Builder(IobCobOref1Worker::class.java)
|
||||||
.setInputData(dataWorker.storeInputData(IobCobOref1Worker.IobCobOref1WorkerData(injector, iobCobCalculator, from, end, limitDataToOldestAvailable, cause)))
|
.setInputData(dataWorkerStorage.storeInputData(IobCobOref1Worker.IobCobOref1WorkerData(injector, iobCobCalculator, from, end, limitDataToOldestAvailable, cause)))
|
||||||
.build()
|
.build()
|
||||||
else
|
else
|
||||||
OneTimeWorkRequest.Builder(IobCobOrefWorker::class.java)
|
OneTimeWorkRequest.Builder(IobCobOrefWorker::class.java)
|
||||||
.setInputData(dataWorker.storeInputData(IobCobOrefWorker.IobCobOrefWorkerData(injector, iobCobCalculator, from, end, limitDataToOldestAvailable, cause)))
|
.setInputData(dataWorkerStorage.storeInputData(IobCobOrefWorker.IobCobOrefWorkerData(injector, iobCobCalculator, from, end, limitDataToOldestAvailable, cause)))
|
||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
.then(OneTimeWorkRequest.Builder(UpdateIobCobSensWorker::class.java).build())
|
.then(OneTimeWorkRequest.Builder(UpdateIobCobSensWorker::class.java).build())
|
||||||
.then(
|
.then(
|
||||||
OneTimeWorkRequest.Builder(PrepareIobAutosensGraphDataWorker::class.java)
|
OneTimeWorkRequest.Builder(PrepareIobAutosensGraphDataWorker::class.java)
|
||||||
.setInputData(dataWorker.storeInputData(PrepareIobAutosensGraphDataWorker.PrepareIobAutosensData(iobCobCalculator, overviewData)))
|
.setInputData(dataWorkerStorage.storeInputData(PrepareIobAutosensGraphDataWorker.PrepareIobAutosensData(iobCobCalculator, overviewData)))
|
||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
.then(
|
.then(
|
||||||
|
@ -213,13 +213,13 @@ class CalculationWorkflow @Inject constructor(
|
||||||
.then(
|
.then(
|
||||||
runLoop,
|
runLoop,
|
||||||
OneTimeWorkRequest.Builder(InvokeLoopWorker::class.java)
|
OneTimeWorkRequest.Builder(InvokeLoopWorker::class.java)
|
||||||
.setInputData(dataWorker.storeInputData(InvokeLoopWorker.InvokeLoopData(cause)))
|
.setInputData(dataWorkerStorage.storeInputData(InvokeLoopWorker.InvokeLoopData(cause)))
|
||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
.then(
|
.then(
|
||||||
runLoop,
|
runLoop,
|
||||||
OneTimeWorkRequest.Builder(PreparePredictionsWorker::class.java)
|
OneTimeWorkRequest.Builder(PreparePredictionsWorker::class.java)
|
||||||
.setInputData(dataWorker.storeInputData(PreparePredictionsWorker.PreparePredictionsData(overviewData)))
|
.setInputData(dataWorkerStorage.storeInputData(PreparePredictionsWorker.PreparePredictionsData(overviewData)))
|
||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
.then(
|
.then(
|
||||||
|
@ -238,7 +238,7 @@ class CalculationWorkflow @Inject constructor(
|
||||||
.beginUniqueWork(
|
.beginUniqueWork(
|
||||||
MAIN_CALCULATION, ExistingWorkPolicy.APPEND,
|
MAIN_CALCULATION, ExistingWorkPolicy.APPEND,
|
||||||
OneTimeWorkRequest.Builder(PrepareTreatmentsDataWorker::class.java)
|
OneTimeWorkRequest.Builder(PrepareTreatmentsDataWorker::class.java)
|
||||||
.setInputData(dataWorker.storeInputData(PrepareTreatmentsDataWorker.PrepareTreatmentsData(overviewData)))
|
.setInputData(dataWorkerStorage.storeInputData(PrepareTreatmentsDataWorker.PrepareTreatmentsData(overviewData)))
|
||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
.then(
|
.then(
|
||||||
|
@ -254,12 +254,12 @@ class CalculationWorkflow @Inject constructor(
|
||||||
.beginUniqueWork(
|
.beginUniqueWork(
|
||||||
MAIN_CALCULATION, ExistingWorkPolicy.APPEND,
|
MAIN_CALCULATION, ExistingWorkPolicy.APPEND,
|
||||||
OneTimeWorkRequest.Builder(PrepareBucketedDataWorker::class.java)
|
OneTimeWorkRequest.Builder(PrepareBucketedDataWorker::class.java)
|
||||||
.setInputData(dataWorker.storeInputData(PrepareBucketedDataWorker.PrepareBucketedData(iobCobCalculator, overviewData)))
|
.setInputData(dataWorkerStorage.storeInputData(PrepareBucketedDataWorker.PrepareBucketedData(iobCobCalculator, overviewData)))
|
||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
.then(
|
.then(
|
||||||
OneTimeWorkRequest.Builder(PrepareBgDataWorker::class.java)
|
OneTimeWorkRequest.Builder(PrepareBgDataWorker::class.java)
|
||||||
.setInputData(dataWorker.storeInputData(PrepareBgDataWorker.PrepareBgData(iobCobCalculator, overviewData)))
|
.setInputData(dataWorkerStorage.storeInputData(PrepareBgDataWorker.PrepareBgData(iobCobCalculator, overviewData)))
|
||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
.then(
|
.then(
|
||||||
|
|
|
@ -9,7 +9,7 @@ import info.nightscout.androidaps.events.Event
|
||||||
import info.nightscout.androidaps.events.EventNewBG
|
import info.nightscout.androidaps.events.EventNewBG
|
||||||
import info.nightscout.androidaps.interfaces.IobCobCalculator
|
import info.nightscout.androidaps.interfaces.IobCobCalculator
|
||||||
import info.nightscout.androidaps.interfaces.Loop
|
import info.nightscout.androidaps.interfaces.Loop
|
||||||
import info.nightscout.androidaps.receivers.DataWorker
|
import info.nightscout.androidaps.receivers.DataWorkerStorage
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class InvokeLoopWorker(
|
class InvokeLoopWorker(
|
||||||
|
@ -17,7 +17,7 @@ class InvokeLoopWorker(
|
||||||
params: WorkerParameters
|
params: WorkerParameters
|
||||||
) : Worker(context, params) {
|
) : Worker(context, params) {
|
||||||
|
|
||||||
@Inject lateinit var dataWorker: DataWorker
|
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
|
||||||
@Inject lateinit var iobCobCalculator: IobCobCalculator
|
@Inject lateinit var iobCobCalculator: IobCobCalculator
|
||||||
@Inject lateinit var loop: Loop
|
@Inject lateinit var loop: Loop
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ class InvokeLoopWorker(
|
||||||
*/
|
*/
|
||||||
override fun doWork(): Result {
|
override fun doWork(): Result {
|
||||||
|
|
||||||
val data = dataWorker.pickupObject(inputData.getLong(DataWorker.STORE_KEY, -1)) as InvokeLoopData?
|
val data = dataWorkerStorage.pickupObject(inputData.getLong(DataWorkerStorage.STORE_KEY, -1)) as InvokeLoopData?
|
||||||
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
||||||
|
|
||||||
if (data.cause !is EventNewBG) return Result.success(workDataOf("Result" to "no calculation needed"))
|
if (data.cause !is EventNewBG) return Result.success(workDataOf("Result" to "no calculation needed"))
|
||||||
|
|
|
@ -8,7 +8,7 @@ import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.database.AppRepository
|
import info.nightscout.androidaps.database.AppRepository
|
||||||
import info.nightscout.androidaps.interfaces.IobCobCalculator
|
import info.nightscout.androidaps.interfaces.IobCobCalculator
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus
|
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||||
import info.nightscout.androidaps.receivers.DataWorker
|
import info.nightscout.androidaps.receivers.DataWorkerStorage
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.shared.logging.AAPSLogger
|
import info.nightscout.shared.logging.AAPSLogger
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -18,7 +18,7 @@ class LoadBgDataWorker(
|
||||||
params: WorkerParameters
|
params: WorkerParameters
|
||||||
) : Worker(context, params) {
|
) : Worker(context, params) {
|
||||||
|
|
||||||
@Inject lateinit var dataWorker: DataWorker
|
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
@Inject lateinit var dateUtil: DateUtil
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
@Inject lateinit var rxBus: RxBus
|
@Inject lateinit var rxBus: RxBus
|
||||||
|
@ -35,7 +35,7 @@ class LoadBgDataWorker(
|
||||||
|
|
||||||
override fun doWork(): Result {
|
override fun doWork(): Result {
|
||||||
|
|
||||||
val data = dataWorker.pickupObject(inputData.getLong(DataWorker.STORE_KEY, -1)) as LoadBgData?
|
val data = dataWorkerStorage.pickupObject(inputData.getLong(DataWorkerStorage.STORE_KEY, -1)) as LoadBgData?
|
||||||
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
||||||
|
|
||||||
data.iobCobCalculator.ads.loadBgData(data.end, repository, aapsLogger, dateUtil, rxBus)
|
data.iobCobCalculator.ads.loadBgData(data.end, repository, aapsLogger, dateUtil, rxBus)
|
||||||
|
|
|
@ -15,18 +15,17 @@ import info.nightscout.androidaps.plugins.bus.RxBus
|
||||||
import info.nightscout.androidaps.plugins.general.overview.OverviewData
|
import info.nightscout.androidaps.plugins.general.overview.OverviewData
|
||||||
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.ScaledDataPoint
|
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.ScaledDataPoint
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress
|
||||||
import info.nightscout.androidaps.receivers.DataWorker
|
import info.nightscout.androidaps.receivers.DataWorkerStorage
|
||||||
import info.nightscout.androidaps.interfaces.ResourceHelper
|
import info.nightscout.androidaps.interfaces.ResourceHelper
|
||||||
import java.util.ArrayList
|
import java.util.ArrayList
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import kotlin.math.max
|
|
||||||
|
|
||||||
class PrepareBasalDataWorker(
|
class PrepareBasalDataWorker(
|
||||||
context: Context,
|
context: Context,
|
||||||
params: WorkerParameters
|
params: WorkerParameters
|
||||||
) : Worker(context, params) {
|
) : Worker(context, params) {
|
||||||
|
|
||||||
@Inject lateinit var dataWorker: DataWorker
|
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
|
||||||
@Inject lateinit var profileFunction: ProfileFunction
|
@Inject lateinit var profileFunction: ProfileFunction
|
||||||
@Inject lateinit var rh: ResourceHelper
|
@Inject lateinit var rh: ResourceHelper
|
||||||
@Inject lateinit var rxBus: RxBus
|
@Inject lateinit var rxBus: RxBus
|
||||||
|
@ -43,7 +42,7 @@ class PrepareBasalDataWorker(
|
||||||
|
|
||||||
override fun doWork(): Result {
|
override fun doWork(): Result {
|
||||||
|
|
||||||
val data = dataWorker.pickupObject(inputData.getLong(DataWorker.STORE_KEY, -1)) as PrepareBasalData?
|
val data = dataWorkerStorage.pickupObject(inputData.getLong(DataWorkerStorage.STORE_KEY, -1)) as PrepareBasalData?
|
||||||
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
||||||
|
|
||||||
rxBus.send(EventIobCalculationProgress(CalculationWorkflow.ProgressData.PREPARE_BASAL_DATA, 0, null))
|
rxBus.send(EventIobCalculationProgress(CalculationWorkflow.ProgressData.PREPARE_BASAL_DATA, 0, null))
|
||||||
|
|
|
@ -14,7 +14,7 @@ import info.nightscout.androidaps.plugins.general.overview.OverviewData
|
||||||
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DataPointWithLabelInterface
|
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DataPointWithLabelInterface
|
||||||
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.GlucoseValueDataPoint
|
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.GlucoseValueDataPoint
|
||||||
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.PointsWithLabelGraphSeries
|
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.PointsWithLabelGraphSeries
|
||||||
import info.nightscout.androidaps.receivers.DataWorker
|
import info.nightscout.androidaps.receivers.DataWorkerStorage
|
||||||
import info.nightscout.androidaps.utils.DefaultValueHelper
|
import info.nightscout.androidaps.utils.DefaultValueHelper
|
||||||
import info.nightscout.androidaps.utils.Round
|
import info.nightscout.androidaps.utils.Round
|
||||||
import info.nightscout.androidaps.interfaces.ResourceHelper
|
import info.nightscout.androidaps.interfaces.ResourceHelper
|
||||||
|
@ -26,7 +26,7 @@ class PrepareBgDataWorker(
|
||||||
params: WorkerParameters
|
params: WorkerParameters
|
||||||
) : Worker(context, params) {
|
) : Worker(context, params) {
|
||||||
|
|
||||||
@Inject lateinit var dataWorker: DataWorker
|
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
|
||||||
@Inject lateinit var profileFunction: ProfileFunction
|
@Inject lateinit var profileFunction: ProfileFunction
|
||||||
@Inject lateinit var rh: ResourceHelper
|
@Inject lateinit var rh: ResourceHelper
|
||||||
@Inject lateinit var defaultValueHelper: DefaultValueHelper
|
@Inject lateinit var defaultValueHelper: DefaultValueHelper
|
||||||
|
@ -43,7 +43,7 @@ class PrepareBgDataWorker(
|
||||||
|
|
||||||
override fun doWork(): Result {
|
override fun doWork(): Result {
|
||||||
|
|
||||||
val data = dataWorker.pickupObject(inputData.getLong(DataWorker.STORE_KEY, -1)) as PrepareBgData?
|
val data = dataWorkerStorage.pickupObject(inputData.getLong(DataWorkerStorage.STORE_KEY, -1)) as PrepareBgData?
|
||||||
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
||||||
|
|
||||||
data.overviewData.maxBgValue = Double.MIN_VALUE
|
data.overviewData.maxBgValue = Double.MIN_VALUE
|
||||||
|
|
|
@ -11,7 +11,7 @@ import info.nightscout.androidaps.plugins.general.overview.OverviewData
|
||||||
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DataPointWithLabelInterface
|
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DataPointWithLabelInterface
|
||||||
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.InMemoryGlucoseValueDataPoint
|
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.InMemoryGlucoseValueDataPoint
|
||||||
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.PointsWithLabelGraphSeries
|
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.PointsWithLabelGraphSeries
|
||||||
import info.nightscout.androidaps.receivers.DataWorker
|
import info.nightscout.androidaps.receivers.DataWorkerStorage
|
||||||
import info.nightscout.androidaps.interfaces.ResourceHelper
|
import info.nightscout.androidaps.interfaces.ResourceHelper
|
||||||
import info.nightscout.shared.logging.AAPSLogger
|
import info.nightscout.shared.logging.AAPSLogger
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -21,7 +21,7 @@ class PrepareBucketedDataWorker(
|
||||||
params: WorkerParameters
|
params: WorkerParameters
|
||||||
) : Worker(context, params) {
|
) : Worker(context, params) {
|
||||||
|
|
||||||
@Inject lateinit var dataWorker: DataWorker
|
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
|
||||||
@Inject lateinit var profileFunction: ProfileFunction
|
@Inject lateinit var profileFunction: ProfileFunction
|
||||||
@Inject lateinit var rh: ResourceHelper
|
@Inject lateinit var rh: ResourceHelper
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
|
@ -37,7 +37,7 @@ class PrepareBucketedDataWorker(
|
||||||
|
|
||||||
override fun doWork(): Result {
|
override fun doWork(): Result {
|
||||||
|
|
||||||
val data = dataWorker.pickupObject(inputData.getLong(DataWorker.STORE_KEY, -1)) as PrepareBucketedData?
|
val data = dataWorkerStorage.pickupObject(inputData.getLong(DataWorkerStorage.STORE_KEY, -1)) as PrepareBucketedData?
|
||||||
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
||||||
|
|
||||||
val bucketedData = data.iobCobCalculator.ads.getBucketedDataTableCopy() ?: return Result.success()
|
val bucketedData = data.iobCobCalculator.ads.getBucketedDataTableCopy() ?: return Result.success()
|
||||||
|
|
|
@ -26,7 +26,7 @@ import info.nightscout.androidaps.plugins.general.overview.graphExtensions.Point
|
||||||
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.ScaledDataPoint
|
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.ScaledDataPoint
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress
|
||||||
import info.nightscout.androidaps.receivers.DataWorker
|
import info.nightscout.androidaps.receivers.DataWorkerStorage
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter
|
import info.nightscout.androidaps.utils.DecimalFormatter
|
||||||
import info.nightscout.androidaps.interfaces.ResourceHelper
|
import info.nightscout.androidaps.interfaces.ResourceHelper
|
||||||
|
@ -43,7 +43,7 @@ class PrepareIobAutosensGraphDataWorker(
|
||||||
params: WorkerParameters
|
params: WorkerParameters
|
||||||
) : Worker(context, params) {
|
) : Worker(context, params) {
|
||||||
|
|
||||||
@Inject lateinit var dataWorker: DataWorker
|
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
|
||||||
@Inject lateinit var dateUtil: DateUtil
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
@Inject lateinit var profileFunction: ProfileFunction
|
@Inject lateinit var profileFunction: ProfileFunction
|
||||||
@Inject lateinit var rh: ResourceHelper
|
@Inject lateinit var rh: ResourceHelper
|
||||||
|
@ -63,7 +63,7 @@ class PrepareIobAutosensGraphDataWorker(
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun doWork(): Result {
|
override fun doWork(): Result {
|
||||||
val data = dataWorker.pickupObject(inputData.getLong(DataWorker.STORE_KEY, -1)) as PrepareIobAutosensData?
|
val data = dataWorkerStorage.pickupObject(inputData.getLong(DataWorkerStorage.STORE_KEY, -1)) as PrepareIobAutosensData?
|
||||||
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
||||||
rxBus.send(EventIobCalculationProgress(CalculationWorkflow.ProgressData.PREPARE_IOB_AUTOSENS_DATA, 0, null))
|
rxBus.send(EventIobCalculationProgress(CalculationWorkflow.ProgressData.PREPARE_IOB_AUTOSENS_DATA, 0, null))
|
||||||
val iobArray: MutableList<ScaledDataPoint> = ArrayList()
|
val iobArray: MutableList<ScaledDataPoint> = ArrayList()
|
||||||
|
|
|
@ -16,7 +16,7 @@ import info.nightscout.androidaps.plugins.general.overview.OverviewMenus
|
||||||
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DataPointWithLabelInterface
|
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DataPointWithLabelInterface
|
||||||
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.GlucoseValueDataPoint
|
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.GlucoseValueDataPoint
|
||||||
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.PointsWithLabelGraphSeries
|
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.PointsWithLabelGraphSeries
|
||||||
import info.nightscout.androidaps.receivers.DataWorker
|
import info.nightscout.androidaps.receivers.DataWorkerStorage
|
||||||
import info.nightscout.androidaps.utils.DefaultValueHelper
|
import info.nightscout.androidaps.utils.DefaultValueHelper
|
||||||
import info.nightscout.androidaps.utils.T
|
import info.nightscout.androidaps.utils.T
|
||||||
import info.nightscout.androidaps.interfaces.ResourceHelper
|
import info.nightscout.androidaps.interfaces.ResourceHelper
|
||||||
|
@ -39,7 +39,7 @@ class PreparePredictionsWorker(
|
||||||
@Inject lateinit var nsDeviceStatus: NSDeviceStatus
|
@Inject lateinit var nsDeviceStatus: NSDeviceStatus
|
||||||
@Inject lateinit var loop: Loop
|
@Inject lateinit var loop: Loop
|
||||||
@Inject lateinit var overviewMenus: OverviewMenus
|
@Inject lateinit var overviewMenus: OverviewMenus
|
||||||
@Inject lateinit var dataWorker: DataWorker
|
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
|
||||||
@Inject lateinit var defaultValueHelper: DefaultValueHelper
|
@Inject lateinit var defaultValueHelper: DefaultValueHelper
|
||||||
@Inject lateinit var profileFunction: ProfileFunction
|
@Inject lateinit var profileFunction: ProfileFunction
|
||||||
@Inject lateinit var rh: ResourceHelper
|
@Inject lateinit var rh: ResourceHelper
|
||||||
|
@ -53,7 +53,7 @@ class PreparePredictionsWorker(
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun doWork(): Result {
|
override fun doWork(): Result {
|
||||||
val data = dataWorker.pickupObject(inputData.getLong(DataWorker.STORE_KEY, -1)) as PreparePredictionsData?
|
val data = dataWorkerStorage.pickupObject(inputData.getLong(DataWorkerStorage.STORE_KEY, -1)) as PreparePredictionsData?
|
||||||
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
||||||
|
|
||||||
val apsResult = if (config.APS) loop.lastRun?.constraintsProcessed else nsDeviceStatus.getAPSResult(injector)
|
val apsResult = if (config.APS) loop.lastRun?.constraintsProcessed else nsDeviceStatus.getAPSResult(injector)
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package info.nightscout.androidaps.workflow
|
package info.nightscout.androidaps.workflow
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import androidx.core.content.ContextCompat
|
|
||||||
import androidx.work.Worker
|
import androidx.work.Worker
|
||||||
import androidx.work.WorkerParameters
|
import androidx.work.WorkerParameters
|
||||||
import androidx.work.workDataOf
|
import androidx.work.workDataOf
|
||||||
|
@ -18,7 +17,7 @@ import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus
|
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||||
import info.nightscout.androidaps.plugins.general.overview.OverviewData
|
import info.nightscout.androidaps.plugins.general.overview.OverviewData
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress
|
||||||
import info.nightscout.androidaps.receivers.DataWorker
|
import info.nightscout.androidaps.receivers.DataWorkerStorage
|
||||||
import info.nightscout.androidaps.interfaces.ResourceHelper
|
import info.nightscout.androidaps.interfaces.ResourceHelper
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
|
@ -28,7 +27,7 @@ class PrepareTemporaryTargetDataWorker(
|
||||||
params: WorkerParameters
|
params: WorkerParameters
|
||||||
) : Worker(context, params) {
|
) : Worker(context, params) {
|
||||||
|
|
||||||
@Inject lateinit var dataWorker: DataWorker
|
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
|
||||||
@Inject lateinit var profileFunction: ProfileFunction
|
@Inject lateinit var profileFunction: ProfileFunction
|
||||||
@Inject lateinit var rh: ResourceHelper
|
@Inject lateinit var rh: ResourceHelper
|
||||||
@Inject lateinit var repository: AppRepository
|
@Inject lateinit var repository: AppRepository
|
||||||
|
@ -46,7 +45,7 @@ class PrepareTemporaryTargetDataWorker(
|
||||||
|
|
||||||
override fun doWork(): Result {
|
override fun doWork(): Result {
|
||||||
|
|
||||||
val data = dataWorker.pickupObject(inputData.getLong(DataWorker.STORE_KEY, -1)) as PrepareTemporaryTargetData?
|
val data = dataWorkerStorage.pickupObject(inputData.getLong(DataWorkerStorage.STORE_KEY, -1)) as PrepareTemporaryTargetData?
|
||||||
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
||||||
|
|
||||||
rxBus.send(EventIobCalculationProgress(CalculationWorkflow.ProgressData.PREPARE_TEMPORARY_TARGET_DATA, 0, null))
|
rxBus.send(EventIobCalculationProgress(CalculationWorkflow.ProgressData.PREPARE_TEMPORARY_TARGET_DATA, 0, null))
|
||||||
|
|
|
@ -17,7 +17,7 @@ import info.nightscout.androidaps.plugins.bus.RxBus
|
||||||
import info.nightscout.androidaps.plugins.general.overview.OverviewData
|
import info.nightscout.androidaps.plugins.general.overview.OverviewData
|
||||||
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.*
|
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.*
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress
|
||||||
import info.nightscout.androidaps.receivers.DataWorker
|
import info.nightscout.androidaps.receivers.DataWorkerStorage
|
||||||
import info.nightscout.androidaps.utils.DefaultValueHelper
|
import info.nightscout.androidaps.utils.DefaultValueHelper
|
||||||
import info.nightscout.androidaps.utils.Round
|
import info.nightscout.androidaps.utils.Round
|
||||||
import info.nightscout.androidaps.utils.T
|
import info.nightscout.androidaps.utils.T
|
||||||
|
@ -29,7 +29,7 @@ class PrepareTreatmentsDataWorker(
|
||||||
params: WorkerParameters
|
params: WorkerParameters
|
||||||
) : Worker(context, params) {
|
) : Worker(context, params) {
|
||||||
|
|
||||||
@Inject lateinit var dataWorker: DataWorker
|
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
|
||||||
@Inject lateinit var profileFunction: ProfileFunction
|
@Inject lateinit var profileFunction: ProfileFunction
|
||||||
@Inject lateinit var rh: ResourceHelper
|
@Inject lateinit var rh: ResourceHelper
|
||||||
@Inject lateinit var rxBus: RxBus
|
@Inject lateinit var rxBus: RxBus
|
||||||
|
@ -48,7 +48,7 @@ class PrepareTreatmentsDataWorker(
|
||||||
|
|
||||||
override fun doWork(): Result {
|
override fun doWork(): Result {
|
||||||
|
|
||||||
val data = dataWorker.pickupObject(inputData.getLong(DataWorker.STORE_KEY, -1)) as PrepareTreatmentsData?
|
val data = dataWorkerStorage.pickupObject(inputData.getLong(DataWorkerStorage.STORE_KEY, -1)) as PrepareTreatmentsData?
|
||||||
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
||||||
|
|
||||||
rxBus.send(EventIobCalculationProgress(CalculationWorkflow.ProgressData.PREPARE_TREATMENTS_DATA, 0, null))
|
rxBus.send(EventIobCalculationProgress(CalculationWorkflow.ProgressData.PREPARE_TREATMENTS_DATA, 0, null))
|
||||||
|
|
Loading…
Reference in a new issue