workflow module

This commit is contained in:
Milos Kozak 2022-12-01 17:16:17 +01:00
parent 6103524e4d
commit 1ac1345797
40 changed files with 252 additions and 151 deletions

View file

@ -0,0 +1,3 @@
package info.nightscout.rx.events
class EventUpdateOverviewCalcProgress(val from: String) : Event()

View file

@ -0,0 +1,3 @@
package info.nightscout.rx.events
class EventUpdateOverviewGraph(val from: String) : Event()

View file

@ -0,0 +1,3 @@
package info.nightscout.rx.events
class EventUpdateOverviewIobCob(val from: String) : Event()

View file

@ -0,0 +1,3 @@
package info.nightscout.rx.events
class EventUpdateOverviewSensitivity(val from: String) : Event()

View file

@ -221,6 +221,7 @@ dependencies {
implementation project(':pump:omnipod-common') implementation project(':pump:omnipod-common')
implementation project(':pump:omnipod-eros') implementation project(':pump:omnipod-eros')
implementation project(':pump:omnipod-dash') implementation project(':pump:omnipod-dash')
implementation project(':workflow')
implementation fileTree(include: ['*.jar'], dir: 'libs') implementation fileTree(include: ['*.jar'], dir: 'libs')

View file

@ -14,21 +14,21 @@ import dagger.android.HasAndroidInjector
import dagger.android.support.DaggerAppCompatActivity import dagger.android.support.DaggerAppCompatActivity
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.databinding.ActivityHistorybrowseBinding import info.nightscout.androidaps.databinding.ActivityHistorybrowseBinding
import info.nightscout.core.events.EventIobCalculationProgress
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.core.workflow.CalculationWorkflow import info.nightscout.core.workflow.CalculationWorkflow
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
import info.nightscout.interfaces.overview.OverviewMenus
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.profile.DefaultValueHelper import info.nightscout.interfaces.profile.DefaultValueHelper
import info.nightscout.plugins.general.overview.OverviewMenus
import info.nightscout.plugins.general.overview.events.EventUpdateOverviewGraph
import info.nightscout.plugins.general.overview.graphData.GraphData import info.nightscout.plugins.general.overview.graphData.GraphData
import info.nightscout.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress
import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventAutosensCalculationFinished import info.nightscout.rx.events.EventAutosensCalculationFinished
import info.nightscout.rx.events.EventCustomCalculationFinished import info.nightscout.rx.events.EventCustomCalculationFinished
import info.nightscout.rx.events.EventRefreshOverview import info.nightscout.rx.events.EventRefreshOverview
import info.nightscout.rx.events.EventScale import info.nightscout.rx.events.EventScale
import info.nightscout.rx.events.EventUpdateOverviewGraph
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag import info.nightscout.rx.logging.LTag
import info.nightscout.shared.extensions.toVisibility import info.nightscout.shared.extensions.toVisibility

View file

@ -35,6 +35,7 @@ import info.nightscout.rx.di.RxModule
import info.nightscout.shared.di.SharedModule import info.nightscout.shared.di.SharedModule
import info.nightscout.shared.impl.di.SharedImplModule import info.nightscout.shared.impl.di.SharedImplModule
import info.nightscout.ui.di.UiModule import info.nightscout.ui.di.UiModule
import info.nightscout.workflow.di.WorkflowModule
import javax.inject.Singleton import javax.inject.Singleton
@Singleton @Singleton

View file

@ -19,8 +19,6 @@ import info.nightscout.core.workflow.CalculationWorkflow.Companion.MAIN_CALCULAT
import info.nightscout.interfaces.iob.IobCobCalculator import info.nightscout.interfaces.iob.IobCobCalculator
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin import info.nightscout.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
import info.nightscout.plugins.iob.iobCobCalculator.IobCobOref1Worker
import info.nightscout.plugins.iob.iobCobCalculator.IobCobOrefWorker
import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.Event import info.nightscout.rx.events.Event
@ -33,6 +31,20 @@ import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag import info.nightscout.rx.logging.LTag
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.DateUtil
import info.nightscout.workflow.DummyWorker
import info.nightscout.workflow.InvokeLoopWorker
import info.nightscout.workflow.LoadBgDataWorker
import info.nightscout.workflow.PrepareBasalDataWorker
import info.nightscout.workflow.PrepareBgDataWorker
import info.nightscout.workflow.PrepareBucketedDataWorker
import info.nightscout.workflow.PrepareIobAutosensGraphDataWorker
import info.nightscout.workflow.PreparePredictionsWorker
import info.nightscout.workflow.PrepareTemporaryTargetDataWorker
import info.nightscout.workflow.PrepareTreatmentsDataWorker
import info.nightscout.workflow.UpdateGraphWorker
import info.nightscout.workflow.UpdateIobCobSensWorker
import info.nightscout.workflow.iob.IobCobOref1Worker
import info.nightscout.workflow.iob.IobCobOrefWorker
import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.kotlin.plusAssign import io.reactivex.rxjava3.kotlin.plusAssign
import javax.inject.Inject import javax.inject.Inject

View file

@ -1,4 +1,4 @@
package info.nightscout.plugins.iob.iobCobCalculator.events package info.nightscout.core.events
import info.nightscout.core.workflow.CalculationWorkflow import info.nightscout.core.workflow.CalculationWorkflow
import info.nightscout.rx.events.Event import info.nightscout.rx.events.Event

View file

@ -0,0 +1,26 @@
package info.nightscout.interfaces.overview
import android.content.Context
import android.widget.ImageButton
interface OverviewMenus {
enum class CharType {
PRE,
TREAT,
BAS,
ABS,
IOB,
COB,
DEV,
BGI,
SEN,
ACT,
DEVSLOPE
}
val setting: List<Array<Boolean>>
fun loadGraphConfig()
fun setupChartMenu(context: Context, chartButton: ImageButton)
fun enabledTypes(graph: Int): String
fun isEnabledIn(type: CharType): Int
}

View file

@ -1,15 +1,22 @@
package info.nightscout.plugins.di package info.nightscout.plugins.di
import dagger.Binds
import dagger.Module import dagger.Module
import dagger.android.ContributesAndroidInjector import dagger.android.ContributesAndroidInjector
import info.nightscout.interfaces.overview.OverviewMenus
import info.nightscout.plugins.general.overview.OverviewFragment import info.nightscout.plugins.general.overview.OverviewFragment
import info.nightscout.plugins.general.overview.OverviewMenusImpl
import info.nightscout.plugins.general.overview.activities.QuickWizardListActivity import info.nightscout.plugins.general.overview.activities.QuickWizardListActivity
import info.nightscout.plugins.general.overview.dialogs.EditQuickWizardDialog import info.nightscout.plugins.general.overview.dialogs.EditQuickWizardDialog
import info.nightscout.plugins.general.overview.graphData.GraphData import info.nightscout.plugins.general.overview.graphData.GraphData
import info.nightscout.plugins.general.overview.notifications.DismissNotificationService import info.nightscout.plugins.general.overview.notifications.DismissNotificationService
import info.nightscout.plugins.general.overview.notifications.NotificationWithAction import info.nightscout.plugins.general.overview.notifications.NotificationWithAction
@Module @Module(
includes = [
OverviewModule.Bindings::class
]
)
@Suppress("unused") @Suppress("unused")
abstract class OverviewModule { abstract class OverviewModule {
@ -19,4 +26,10 @@ abstract class OverviewModule {
@ContributesAndroidInjector abstract fun contributesOverviewFragment(): OverviewFragment @ContributesAndroidInjector abstract fun contributesOverviewFragment(): OverviewFragment
@ContributesAndroidInjector abstract fun notificationWithActionInjector(): NotificationWithAction @ContributesAndroidInjector abstract fun notificationWithActionInjector(): NotificationWithAction
@ContributesAndroidInjector abstract fun graphDataInjector(): GraphData @ContributesAndroidInjector abstract fun graphDataInjector(): GraphData
@Module
interface Bindings {
@Binds fun bindOverviewMenus(overviewMenusImpl: OverviewMenusImpl): OverviewMenus
}
} }

View file

@ -29,9 +29,9 @@ import dagger.android.HasAndroidInjector
import dagger.android.support.DaggerFragment import dagger.android.support.DaggerFragment
import info.nightscout.core.extensions.directionToIcon import info.nightscout.core.extensions.directionToIcon
import info.nightscout.core.extensions.valueToUnitsString import info.nightscout.core.extensions.valueToUnitsString
import info.nightscout.core.iob.iobCobCalculator.GlucoseStatusProvider
import info.nightscout.core.graph.OverviewData import info.nightscout.core.graph.OverviewData
import info.nightscout.core.iob.displayText import info.nightscout.core.iob.displayText
import info.nightscout.core.iob.iobCobCalculator.GlucoseStatusProvider
import info.nightscout.core.profile.ProfileSealed import info.nightscout.core.profile.ProfileSealed
import info.nightscout.core.ui.UIRunnable import info.nightscout.core.ui.UIRunnable
import info.nightscout.core.ui.dialogs.OKDialog import info.nightscout.core.ui.dialogs.OKDialog
@ -56,6 +56,7 @@ import info.nightscout.interfaces.iob.IobCobCalculator
import info.nightscout.interfaces.logging.UserEntryLogger import info.nightscout.interfaces.logging.UserEntryLogger
import info.nightscout.interfaces.nsclient.NSSettingsStatus import info.nightscout.interfaces.nsclient.NSSettingsStatus
import info.nightscout.interfaces.nsclient.ProcessedDeviceStatusData import info.nightscout.interfaces.nsclient.ProcessedDeviceStatusData
import info.nightscout.interfaces.overview.OverviewMenus
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.profile.DefaultValueHelper import info.nightscout.interfaces.profile.DefaultValueHelper
@ -70,10 +71,6 @@ import info.nightscout.plugins.R
import info.nightscout.plugins.aps.loop.events.EventNewOpenLoopNotification import info.nightscout.plugins.aps.loop.events.EventNewOpenLoopNotification
import info.nightscout.plugins.databinding.OverviewFragmentBinding import info.nightscout.plugins.databinding.OverviewFragmentBinding
import info.nightscout.plugins.general.overview.activities.QuickWizardListActivity import info.nightscout.plugins.general.overview.activities.QuickWizardListActivity
import info.nightscout.plugins.general.overview.events.EventUpdateOverviewCalcProgress
import info.nightscout.plugins.general.overview.events.EventUpdateOverviewGraph
import info.nightscout.plugins.general.overview.events.EventUpdateOverviewIobCob
import info.nightscout.plugins.general.overview.events.EventUpdateOverviewSensitivity
import info.nightscout.plugins.general.overview.graphData.GraphData import info.nightscout.plugins.general.overview.graphData.GraphData
import info.nightscout.plugins.general.overview.notifications.NotificationStore import info.nightscout.plugins.general.overview.notifications.NotificationStore
import info.nightscout.plugins.general.overview.notifications.events.EventUpdateOverviewNotification import info.nightscout.plugins.general.overview.notifications.events.EventUpdateOverviewNotification
@ -94,6 +91,10 @@ import info.nightscout.rx.events.EventRefreshOverview
import info.nightscout.rx.events.EventScale import info.nightscout.rx.events.EventScale
import info.nightscout.rx.events.EventTempBasalChange import info.nightscout.rx.events.EventTempBasalChange
import info.nightscout.rx.events.EventTempTargetChange import info.nightscout.rx.events.EventTempTargetChange
import info.nightscout.rx.events.EventUpdateOverviewCalcProgress
import info.nightscout.rx.events.EventUpdateOverviewGraph
import info.nightscout.rx.events.EventUpdateOverviewIobCob
import info.nightscout.rx.events.EventUpdateOverviewSensitivity
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.weardata.EventData import info.nightscout.rx.weardata.EventData
import info.nightscout.shared.extensions.runOnUiThread import info.nightscout.shared.extensions.runOnUiThread

View file

@ -14,6 +14,7 @@ import com.google.gson.Gson
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
import info.nightscout.interfaces.aps.Loop import info.nightscout.interfaces.aps.Loop
import info.nightscout.interfaces.overview.OverviewMenus
import info.nightscout.plugins.R import info.nightscout.plugins.R
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventRefreshOverview import info.nightscout.rx.events.EventRefreshOverview
@ -25,7 +26,7 @@ import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
@Singleton @Singleton
class OverviewMenus @Inject constructor( class OverviewMenusImpl @Inject constructor(
private val aapsLogger: AAPSLogger, private val aapsLogger: AAPSLogger,
private val rh: ResourceHelper, private val rh: ResourceHelper,
private val sp: SP, private val sp: SP,
@ -33,9 +34,9 @@ class OverviewMenus @Inject constructor(
private val config: Config, private val config: Config,
private val loop: Loop, private val loop: Loop,
private val fabricPrivacy: FabricPrivacy private val fabricPrivacy: FabricPrivacy
) { ) : OverviewMenus {
enum class CharType(@StringRes val nameId: Int, @AttrRes val attrId: Int, @AttrRes val attrTextId: Int, val primary: Boolean, val secondary: Boolean, @StringRes val shortnameId: Int) { enum class CharTypeData(@StringRes val nameId: Int, @AttrRes val attrId: Int, @AttrRes val attrTextId: Int, val primary: Boolean, val secondary: Boolean, @StringRes val shortnameId: Int) {
PRE(R.string.overview_show_predictions, R.attr.predictionColor, R.attr.menuTextColor, primary = true, secondary = false, shortnameId = R.string.prediction_shortname), PRE(R.string.overview_show_predictions, R.attr.predictionColor, R.attr.menuTextColor, primary = true, secondary = false, shortnameId = R.string.prediction_shortname),
TREAT(R.string.overview_show_treatments, R.attr.cobColor, R.attr.menuTextColor, primary = true, secondary = false, shortnameId = R.string.treatments_shortname), TREAT(R.string.overview_show_treatments, R.attr.cobColor, R.attr.menuTextColor, primary = true, secondary = false, shortnameId = R.string.treatments_shortname),
BAS(R.string.overview_show_basals, R.attr.basal, R.attr.menuTextColor, primary = true, secondary = false, shortnameId = R.string.basal_shortname), BAS(R.string.overview_show_basals, R.attr.basal, R.attr.menuTextColor, primary = true, secondary = false, shortnameId = R.string.basal_shortname),
@ -55,9 +56,9 @@ class OverviewMenus @Inject constructor(
const val SCALE_ID = 1001 const val SCALE_ID = 1001
} }
fun enabledTypes(graph: Int): String { override fun enabledTypes(graph: Int): String {
val r = StringBuilder() val r = StringBuilder()
for (type in CharType.values()) if (_setting[graph][type.ordinal]) { for (type in CharTypeData.values()) if (_setting[graph][type.ordinal]) {
r.append(rh.gs(type.shortnameId)) r.append(rh.gs(type.shortnameId))
r.append(" ") r.append(" ")
} }
@ -66,7 +67,7 @@ class OverviewMenus @Inject constructor(
private var _setting: MutableList<Array<Boolean>> = ArrayList() private var _setting: MutableList<Array<Boolean>> = ArrayList()
val setting: List<Array<Boolean>> override val setting: List<Array<Boolean>>
@Synchronized get() = _setting.toMutableList() // implicitly does a list copy @Synchronized get() = _setting.toMutableList() // implicitly does a list copy
@Synchronized @Synchronized
@ -77,23 +78,23 @@ class OverviewMenus @Inject constructor(
} }
@Synchronized @Synchronized
fun loadGraphConfig() { override fun loadGraphConfig() {
val sts = sp.getString(R.string.key_graph_config, "") val sts = sp.getString(R.string.key_graph_config, "")
if (sts.isNotEmpty()) { if (sts.isNotEmpty()) {
_setting = Gson().fromJson(sts, Array<Array<Boolean>>::class.java).toMutableList() _setting = Gson().fromJson(sts, Array<Array<Boolean>>::class.java).toMutableList()
// reset when new CharType added // reset when new CharType added
for (s in _setting) for (s in _setting)
if (s.size != CharType.values().size) { if (s.size != OverviewMenus.CharType.values().size) {
_setting = ArrayList() _setting = ArrayList()
_setting.add(Array(CharType.values().size) { true }) _setting.add(Array(OverviewMenus.CharType.values().size) { true })
} }
} else { } else {
_setting = ArrayList() _setting = ArrayList()
_setting.add(Array(CharType.values().size) { true }) _setting.add(Array(OverviewMenus.CharType.values().size) { true })
} }
} }
fun setupChartMenu(context: Context, chartButton: ImageButton) { override fun setupChartMenu(context: Context, chartButton: ImageButton) {
val settingsCopy = setting val settingsCopy = setting
val numOfGraphs = settingsCopy.size // 1 main + x secondary val numOfGraphs = settingsCopy.size // 1 main + x secondary
@ -120,12 +121,12 @@ class OverviewMenus @Inject constructor(
dividerItem.isCheckable = true dividerItem.isCheckable = true
dividerItem.isChecked = true dividerItem.isChecked = true
} }
CharType.values().forEach { m -> CharTypeData.values().forEach { m ->
if (g == 0 && !m.primary) return@forEach if (g == 0 && !m.primary) return@forEach
if (g > 0 && !m.secondary) return@forEach if (g > 0 && !m.secondary) return@forEach
var insert = true var insert = true
if (m == CharType.PRE) insert = predictionsAvailable if (m == CharTypeData.PRE) insert = predictionsAvailable
if (m == CharType.DEVSLOPE) insert = config.isDev() if (m == CharTypeData.DEVSLOPE) insert = config.isDev()
if (used.contains(m.ordinal)) insert = false if (used.contains(m.ordinal)) insert = false
for (g2 in g + 1 until numOfGraphs) { for (g2 in g + 1 until numOfGraphs) {
if (settingsCopy[g2][m.ordinal]) insert = false if (settingsCopy[g2][m.ordinal]) insert = false
@ -165,7 +166,7 @@ class OverviewMenus @Inject constructor(
it.itemId == numOfGraphs -> { it.itemId == numOfGraphs -> {
// add new empty // add new empty
_setting.add(Array(CharType.values().size) { false }) _setting.add(Array(CharTypeData.values().size) { false })
} }
it.itemId < 100 -> { it.itemId < 100 -> {
@ -194,7 +195,7 @@ class OverviewMenus @Inject constructor(
} }
} }
fun isEnabledIn(type: CharType): Int { override fun isEnabledIn(type: OverviewMenus.CharType): Int {
val settingsCopy = setting val settingsCopy = setting
val numOfGraphs = settingsCopy.size // 1 main + x secondary val numOfGraphs = settingsCopy.size // 1 main + x secondary
for (g in 0 until numOfGraphs) if (settingsCopy[g][type.ordinal]) return g for (g in 0 until numOfGraphs) if (settingsCopy[g][type.ordinal]) return g

View file

@ -5,31 +5,32 @@ import androidx.annotation.StringRes
import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceFragmentCompat
import androidx.preference.SwitchPreference import androidx.preference.SwitchPreference
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.core.events.EventIobCalculationProgress
import info.nightscout.core.events.EventNewNotification
import info.nightscout.core.extensions.putDouble import info.nightscout.core.extensions.putDouble
import info.nightscout.core.extensions.putInt import info.nightscout.core.extensions.putInt
import info.nightscout.core.extensions.putString import info.nightscout.core.extensions.putString
import info.nightscout.core.extensions.storeDouble import info.nightscout.core.extensions.storeDouble
import info.nightscout.core.extensions.storeInt import info.nightscout.core.extensions.storeInt
import info.nightscout.core.extensions.storeString import info.nightscout.core.extensions.storeString
import info.nightscout.core.events.EventNewNotification
import info.nightscout.core.graph.OverviewData import info.nightscout.core.graph.OverviewData
import info.nightscout.core.ui.dialogs.OKDialog import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
import info.nightscout.interfaces.Overview import info.nightscout.interfaces.Overview
import info.nightscout.interfaces.overview.OverviewMenus
import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginDescription import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.plugin.PluginType import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.plugins.R import info.nightscout.plugins.R
import info.nightscout.plugins.general.overview.events.EventUpdateOverviewCalcProgress
import info.nightscout.plugins.general.overview.notifications.NotificationStore import info.nightscout.plugins.general.overview.notifications.NotificationStore
import info.nightscout.plugins.general.overview.notifications.NotificationWithAction import info.nightscout.plugins.general.overview.notifications.NotificationWithAction
import info.nightscout.plugins.general.overview.notifications.events.EventUpdateOverviewNotification import info.nightscout.plugins.general.overview.notifications.events.EventUpdateOverviewNotification
import info.nightscout.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress
import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventDismissNotification import info.nightscout.rx.events.EventDismissNotification
import info.nightscout.rx.events.EventPumpStatusChanged import info.nightscout.rx.events.EventPumpStatusChanged
import info.nightscout.rx.events.EventUpdateOverviewCalcProgress
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP

View file

@ -1,5 +0,0 @@
package info.nightscout.plugins.general.overview.events
import info.nightscout.rx.events.Event
class EventUpdateOverviewCalcProgress(val from: String) : Event()

View file

@ -1,5 +0,0 @@
package info.nightscout.plugins.general.overview.events
import info.nightscout.rx.events.Event
class EventUpdateOverviewGraph(val from: String) : Event()

View file

@ -1,5 +0,0 @@
package info.nightscout.plugins.general.overview.events
import info.nightscout.rx.events.Event
class EventUpdateOverviewIobCob(val from: String) : Event()

View file

@ -1,5 +0,0 @@
package info.nightscout.plugins.general.overview.events
import info.nightscout.rx.events.Event
class EventUpdateOverviewSensitivity(val from: String) : Event()

View file

@ -40,3 +40,4 @@ include ':pump:pump-common'
include ':pump:pump-core' include ':pump:pump-core'
include ':pump:rileylink' include ':pump:rileylink'
include ':plugins:sync' include ':plugins:sync'
include ':workflow'

1
workflow/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/build

29
workflow/build.gradle Normal file
View file

@ -0,0 +1,29 @@
plugins {
id 'com.android.library'
id 'kotlin-android'
id 'kotlin-kapt'
id 'kotlin-allopen'
id 'com.hiya.jacoco-android'
}
apply from: "${project.rootDir}/core/core-main/android_dependencies.gradle"
apply from: "${project.rootDir}/core/core-main/android_module_dependencies.gradle"
apply from: "${project.rootDir}/core/core-main/test_dependencies.gradle"
apply from: "${project.rootDir}/core/core-main/jacoco_global.gradle"
android {
namespace 'info.nightscout.workflow'
}
dependencies {
implementation project(':core:libraries')
implementation project(':core:graphview')
implementation project(':app-wear-shared:shared')
implementation project(':database:entities')
implementation project(':database:impl')
implementation project(':core:core-main')
implementation project(':core:interfaces')
implementation project(':core:graph')
implementation project(':core:ui')
implementation project(':core:utils')
}

View file

21
workflow/proguard-rules.pro vendored Normal file
View file

@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest>
</manifest>

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.workflow package info.nightscout.workflow
import android.content.Context import android.content.Context
import androidx.work.Worker import androidx.work.Worker

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.workflow package info.nightscout.workflow
import android.content.Context import android.content.Context
import androidx.work.Worker import androidx.work.Worker

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.workflow package info.nightscout.workflow
import android.content.Context import android.content.Context
import androidx.work.Worker import androidx.work.Worker

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.workflow package info.nightscout.workflow
import android.content.Context import android.content.Context
import android.graphics.DashPathEffect import android.graphics.DashPathEffect
@ -8,14 +8,13 @@ import androidx.work.WorkerParameters
import androidx.work.workDataOf import androidx.work.workDataOf
import com.jjoe64.graphview.series.LineGraphSeries import com.jjoe64.graphview.series.LineGraphSeries
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R import info.nightscout.core.events.EventIobCalculationProgress
import info.nightscout.core.graph.OverviewData import info.nightscout.core.graph.OverviewData
import info.nightscout.core.graph.data.ScaledDataPoint import info.nightscout.core.graph.data.ScaledDataPoint
import info.nightscout.core.utils.receivers.DataWorkerStorage import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.core.workflow.CalculationWorkflow import info.nightscout.core.workflow.CalculationWorkflow
import info.nightscout.interfaces.iob.IobCobCalculator import info.nightscout.interfaces.iob.IobCobCalculator
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import javax.inject.Inject import javax.inject.Inject

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.workflow package info.nightscout.workflow
import android.content.Context import android.content.Context
import androidx.work.Worker import androidx.work.Worker

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.workflow package info.nightscout.workflow
import android.content.Context import android.content.Context
import androidx.work.Worker import androidx.work.Worker

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.workflow package info.nightscout.workflow
import android.content.Context import android.content.Context
import android.graphics.DashPathEffect import android.graphics.DashPathEffect
@ -9,8 +9,7 @@ import androidx.work.workDataOf
import com.jjoe64.graphview.series.BarGraphSeries import com.jjoe64.graphview.series.BarGraphSeries
import com.jjoe64.graphview.series.LineGraphSeries import com.jjoe64.graphview.series.LineGraphSeries
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R import info.nightscout.core.events.EventIobCalculationProgress
import info.nightscout.core.iob.iobCobCalculator.data.AutosensDataObject
import info.nightscout.core.graph.OverviewData import info.nightscout.core.graph.OverviewData
import info.nightscout.core.graph.data.DataPointWithLabelInterface import info.nightscout.core.graph.data.DataPointWithLabelInterface
import info.nightscout.core.graph.data.DeviationDataPoint import info.nightscout.core.graph.data.DeviationDataPoint
@ -20,6 +19,7 @@ import info.nightscout.core.graph.data.Scale
import info.nightscout.core.graph.data.ScaledDataPoint import info.nightscout.core.graph.data.ScaledDataPoint
import info.nightscout.core.iob.combine import info.nightscout.core.iob.combine
import info.nightscout.core.iob.copy import info.nightscout.core.iob.copy
import info.nightscout.core.iob.iobCobCalculator.data.AutosensDataObject
import info.nightscout.core.utils.receivers.DataWorkerStorage import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.core.workflow.CalculationWorkflow import info.nightscout.core.workflow.CalculationWorkflow
import info.nightscout.database.ValueWrapper import info.nightscout.database.ValueWrapper
@ -28,10 +28,9 @@ import info.nightscout.interfaces.aps.AutosensResult
import info.nightscout.interfaces.aps.SMBDefaults import info.nightscout.interfaces.aps.SMBDefaults
import info.nightscout.interfaces.iob.IobCobCalculator import info.nightscout.interfaces.iob.IobCobCalculator
import info.nightscout.interfaces.iob.IobTotal import info.nightscout.interfaces.iob.IobTotal
import info.nightscout.interfaces.overview.OverviewMenus
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.utils.DecimalFormatter import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.plugins.general.overview.OverviewMenus
import info.nightscout.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag import info.nightscout.rx.logging.LTag

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.workflow package info.nightscout.workflow
import android.content.Context import android.content.Context
import androidx.work.Worker import androidx.work.Worker
@ -14,9 +14,9 @@ import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
import info.nightscout.interfaces.aps.Loop import info.nightscout.interfaces.aps.Loop
import info.nightscout.interfaces.nsclient.ProcessedDeviceStatusData import info.nightscout.interfaces.nsclient.ProcessedDeviceStatusData
import info.nightscout.interfaces.overview.OverviewMenus
import info.nightscout.interfaces.profile.DefaultValueHelper import info.nightscout.interfaces.profile.DefaultValueHelper
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.plugins.general.overview.OverviewMenus
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.utils.T import info.nightscout.shared.utils.T

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.workflow package info.nightscout.workflow
import android.content.Context import android.content.Context
import androidx.work.Worker import androidx.work.Worker
@ -7,7 +7,7 @@ import androidx.work.workDataOf
import com.jjoe64.graphview.series.DataPoint import com.jjoe64.graphview.series.DataPoint
import com.jjoe64.graphview.series.LineGraphSeries import com.jjoe64.graphview.series.LineGraphSeries
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R import info.nightscout.core.events.EventIobCalculationProgress
import info.nightscout.core.extensions.target import info.nightscout.core.extensions.target
import info.nightscout.core.graph.OverviewData import info.nightscout.core.graph.OverviewData
import info.nightscout.core.utils.receivers.DataWorkerStorage import info.nightscout.core.utils.receivers.DataWorkerStorage
@ -17,7 +17,6 @@ import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.aps.Loop import info.nightscout.interfaces.aps.Loop
import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import javax.inject.Inject import javax.inject.Inject
@ -34,7 +33,7 @@ class PrepareTemporaryTargetDataWorker(
@Inject lateinit var repository: AppRepository @Inject lateinit var repository: AppRepository
@Inject lateinit var loop: Loop @Inject lateinit var loop: Loop
@Inject lateinit var rxBus: RxBus @Inject lateinit var rxBus: RxBus
var ctx: Context private var ctx: Context
init { init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this) (context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
ctx = rh.getThemedCtx(context) ctx = rh.getThemedCtx(context)

View file

@ -1,10 +1,11 @@
package info.nightscout.androidaps.workflow package info.nightscout.workflow
import android.content.Context import android.content.Context
import androidx.work.Worker import androidx.work.Worker
import androidx.work.WorkerParameters import androidx.work.WorkerParameters
import androidx.work.workDataOf import androidx.work.workDataOf
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.core.events.EventIobCalculationProgress
import info.nightscout.core.graph.OverviewData import info.nightscout.core.graph.OverviewData
import info.nightscout.core.graph.data.BolusDataPoint import info.nightscout.core.graph.data.BolusDataPoint
import info.nightscout.core.graph.data.CarbsDataPoint import info.nightscout.core.graph.data.CarbsDataPoint
@ -25,7 +26,6 @@ import info.nightscout.interfaces.profile.DefaultValueHelper
import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.utils.Round import info.nightscout.interfaces.utils.Round
import info.nightscout.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.utils.T import info.nightscout.shared.utils.T

View file

@ -1,14 +1,14 @@
package info.nightscout.androidaps.workflow package info.nightscout.workflow
import android.content.Context import android.content.Context
import androidx.work.Worker import androidx.work.Worker
import androidx.work.WorkerParameters import androidx.work.WorkerParameters
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.core.events.EventIobCalculationProgress
import info.nightscout.core.workflow.CalculationWorkflow import info.nightscout.core.workflow.CalculationWorkflow
import info.nightscout.plugins.general.overview.OverviewPlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.plugins.general.overview.events.EventUpdateOverviewGraph
import info.nightscout.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventUpdateOverviewGraph
import javax.inject.Inject import javax.inject.Inject
class UpdateGraphWorker( class UpdateGraphWorker(
@ -17,7 +17,7 @@ class UpdateGraphWorker(
) : Worker(context, params) { ) : Worker(context, params) {
@Inject lateinit var rxBus: RxBus @Inject lateinit var rxBus: RxBus
@Inject lateinit var overviewPlugin: OverviewPlugin @Inject lateinit var activePlugin: ActivePlugin
init { init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this) (context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
@ -25,7 +25,7 @@ class UpdateGraphWorker(
override fun doWork(): Result { override fun doWork(): Result {
if (inputData.getString(CalculationWorkflow.JOB) == CalculationWorkflow.MAIN_CALCULATION) if (inputData.getString(CalculationWorkflow.JOB) == CalculationWorkflow.MAIN_CALCULATION)
overviewPlugin.overviewBus.send(EventUpdateOverviewGraph("UpdateGraphWorker")) activePlugin.activeOverview.overviewBus.send(EventUpdateOverviewGraph("UpdateGraphWorker"))
else else
rxBus.send(EventUpdateOverviewGraph("UpdateGraphWorker")) rxBus.send(EventUpdateOverviewGraph("UpdateGraphWorker"))
rxBus.send(EventIobCalculationProgress(CalculationWorkflow.ProgressData.DRAW, 100, null)) rxBus.send(EventIobCalculationProgress(CalculationWorkflow.ProgressData.DRAW, 100, null))

View file

@ -1,13 +1,13 @@
package info.nightscout.androidaps.workflow package info.nightscout.workflow
import android.content.Context import android.content.Context
import androidx.work.Worker import androidx.work.Worker
import androidx.work.WorkerParameters import androidx.work.WorkerParameters
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.plugins.general.overview.OverviewPlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.plugins.general.overview.events.EventUpdateOverviewIobCob
import info.nightscout.plugins.general.overview.events.EventUpdateOverviewSensitivity
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventUpdateOverviewIobCob
import info.nightscout.rx.events.EventUpdateOverviewSensitivity
import javax.inject.Inject import javax.inject.Inject
class UpdateIobCobSensWorker( class UpdateIobCobSensWorker(
@ -16,15 +16,15 @@ class UpdateIobCobSensWorker(
) : Worker(context, params) { ) : Worker(context, params) {
@Inject lateinit var rxBus: RxBus @Inject lateinit var rxBus: RxBus
@Inject lateinit var overviewPlugin: OverviewPlugin @Inject lateinit var activePlugin: ActivePlugin
init { init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this) (context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
} }
override fun doWork(): Result { override fun doWork(): Result {
overviewPlugin.overviewBus.send(EventUpdateOverviewIobCob("UpdateIobCobSensWorker")) activePlugin.activeOverview.overviewBus.send(EventUpdateOverviewIobCob("UpdateIobCobSensWorker"))
overviewPlugin.overviewBus.send(EventUpdateOverviewSensitivity("UpdateIobCobSensWorker")) activePlugin.activeOverview.overviewBus.send(EventUpdateOverviewSensitivity("UpdateIobCobSensWorker"))
return Result.success() return Result.success()
} }
} }

View file

@ -1,20 +1,20 @@
package info.nightscout.androidaps.di package info.nightscout.workflow.di
import dagger.Module import dagger.Module
import dagger.android.ContributesAndroidInjector import dagger.android.ContributesAndroidInjector
import info.nightscout.androidaps.workflow.InvokeLoopWorker import info.nightscout.workflow.InvokeLoopWorker
import info.nightscout.androidaps.workflow.LoadBgDataWorker import info.nightscout.workflow.LoadBgDataWorker
import info.nightscout.androidaps.workflow.PrepareBasalDataWorker import info.nightscout.workflow.PrepareBasalDataWorker
import info.nightscout.androidaps.workflow.PrepareBgDataWorker import info.nightscout.workflow.PrepareBgDataWorker
import info.nightscout.androidaps.workflow.PrepareBucketedDataWorker import info.nightscout.workflow.PrepareBucketedDataWorker
import info.nightscout.androidaps.workflow.PrepareIobAutosensGraphDataWorker import info.nightscout.workflow.PrepareIobAutosensGraphDataWorker
import info.nightscout.androidaps.workflow.PreparePredictionsWorker import info.nightscout.workflow.PreparePredictionsWorker
import info.nightscout.androidaps.workflow.PrepareTemporaryTargetDataWorker import info.nightscout.workflow.PrepareTemporaryTargetDataWorker
import info.nightscout.androidaps.workflow.PrepareTreatmentsDataWorker import info.nightscout.workflow.PrepareTreatmentsDataWorker
import info.nightscout.androidaps.workflow.UpdateGraphWorker import info.nightscout.workflow.UpdateGraphWorker
import info.nightscout.androidaps.workflow.UpdateIobCobSensWorker import info.nightscout.workflow.UpdateIobCobSensWorker
import info.nightscout.plugins.iob.iobCobCalculator.IobCobOref1Worker import info.nightscout.workflow.iob.IobCobOref1Worker
import info.nightscout.plugins.iob.iobCobCalculator.IobCobOrefWorker import info.nightscout.workflow.iob.IobCobOrefWorker
@Module @Module
@Suppress("unused") @Suppress("unused")

View file

@ -1,4 +1,4 @@
package info.nightscout.plugins.iob.iobCobCalculator package info.nightscout.workflow.iob
import android.content.Context import android.content.Context
import android.os.SystemClock import android.os.SystemClock
@ -6,9 +6,9 @@ import androidx.work.Worker
import androidx.work.WorkerParameters import androidx.work.WorkerParameters
import androidx.work.workDataOf import androidx.work.workDataOf
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.core.events.EventIobCalculationProgress
import info.nightscout.core.extensions.target import info.nightscout.core.extensions.target
import info.nightscout.core.iob.iobCobCalculator.data.AutosensDataObject import info.nightscout.core.iob.iobCobCalculator.data.AutosensDataObject
import info.nightscout.core.events.EventNewNotification
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.core.utils.receivers.DataWorkerStorage import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.core.workflow.CalculationWorkflow import info.nightscout.core.workflow.CalculationWorkflow
@ -19,13 +19,11 @@ import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.aps.AutosensData import info.nightscout.interfaces.aps.AutosensData
import info.nightscout.interfaces.aps.SMBDefaults import info.nightscout.interfaces.aps.SMBDefaults
import info.nightscout.interfaces.iob.IobCobCalculator import info.nightscout.interfaces.iob.IobCobCalculator
import info.nightscout.interfaces.notifications.Notification
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.profiling.Profiler import info.nightscout.interfaces.profiling.Profiler
import info.nightscout.interfaces.utils.DecimalFormatter import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.plugins.R import info.nightscout.plugins.iob.iobCobCalculator.fromCarbs
import info.nightscout.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.Event import info.nightscout.rx.events.Event
import info.nightscout.rx.events.EventAutosensCalculationFinished import info.nightscout.rx.events.EventAutosensCalculationFinished
@ -35,6 +33,7 @@ import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.DateUtil
import info.nightscout.shared.utils.T import info.nightscout.shared.utils.T
import info.nightscout.workflow.R
import java.util.Calendar import java.util.Calendar
import java.util.GregorianCalendar import java.util.GregorianCalendar
import javax.inject.Inject import javax.inject.Inject
@ -155,10 +154,11 @@ class IobCobOref1Worker(
val initialIndex = autosensDataTable.indexOfKey(hourAgoData.time) val initialIndex = autosensDataTable.indexOfKey(hourAgoData.time)
aapsLogger.debug(LTag.AUTOSENS, { ">>>>> bucketed_data.size()=" + bucketedData.size + " i=" + i + " hourAgoData=" + hourAgoData.toString() }) aapsLogger.debug(LTag.AUTOSENS, { ">>>>> bucketed_data.size()=" + bucketedData.size + " i=" + i + " hourAgoData=" + hourAgoData.toString() })
var past = 1 var past = 1
try { // try {
while (past < 12) { while (past < 12) {
val ad = autosensDataTable.valueAt(initialIndex + past) val ad = autosensDataTable.valueAt(initialIndex + past)
aapsLogger.debug(LTag.AUTOSENS, { ">>>>> past=" + past + " ad=" + ad?.toString() }) aapsLogger.debug(LTag.AUTOSENS, { ">>>>> past=" + past + " ad=" + ad?.toString() })
/*
if (ad == null) { if (ad == null) {
aapsLogger.debug(LTag.AUTOSENS, {autosensDataTable.toString()}) aapsLogger.debug(LTag.AUTOSENS, {autosensDataTable.toString()})
aapsLogger.debug(LTag.AUTOSENS, {bucketedData.toString()}) aapsLogger.debug(LTag.AUTOSENS, {bucketedData.toString()})
@ -168,6 +168,7 @@ class IobCobOref1Worker(
sp.putBoolean("log_AUTOSENS", true) sp.putBoolean("log_AUTOSENS", true)
break break
} }
*/
// let it here crash on NPE to get more data as i cannot reproduce this bug // let it here crash on NPE to get more data as i cannot reproduce this bug
val deviationSlope = (ad.avgDeviation - avgDeviation) / (ad.time - bgTime) * 1000 * 60 * 5 val deviationSlope = (ad.avgDeviation - avgDeviation) / (ad.time - bgTime) * 1000 * 60 * 5
if (ad.avgDeviation > maxDeviation) { if (ad.avgDeviation > maxDeviation) {
@ -180,17 +181,17 @@ class IobCobOref1Worker(
} }
past++ past++
} }
} catch (e: Exception) { // } catch (e: Exception) {
aapsLogger.error("Unhandled exception", e) // aapsLogger.error("Unhandled exception", e)
fabricPrivacy.logException(e) // fabricPrivacy.logException(e)
aapsLogger.debug(autosensDataTable.toString()) // aapsLogger.debug(autosensDataTable.toString())
aapsLogger.debug(bucketedData.toString()) // aapsLogger.debug(bucketedData.toString())
//aapsLogger.debug(iobCobCalculatorPlugin.getBgReadingsDataTable().toString()) // //aapsLogger.debug(iobCobCalculatorPlugin.getBgReadingsDataTable().toString())
val notification = Notification(Notification.SEND_LOGFILES, rh.gs(R.string.send_logfiles), Notification.LOW) // val notification = Notification(Notification.SEND_LOGFILES, rh.gs(R.string.send_logfiles), Notification.LOW)
rxBus.send(EventNewNotification(notification)) // rxBus.send(EventNewNotification(notification))
sp.putBoolean("log_AUTOSENS", true) // sp.putBoolean("log_AUTOSENS", true)
break // break
} // }
} else { } else {
aapsLogger.debug(LTag.AUTOSENS, ">>>>> bucketed_data.size()=" + bucketedData.size + " i=" + i + " hourAgoData=" + "null") aapsLogger.debug(LTag.AUTOSENS, ">>>>> bucketed_data.size()=" + bucketedData.size + " i=" + i + " hourAgoData=" + "null")
} }

View file

@ -1,4 +1,4 @@
package info.nightscout.plugins.iob.iobCobCalculator package info.nightscout.workflow.iob
import android.content.Context import android.content.Context
import android.os.SystemClock import android.os.SystemClock
@ -6,8 +6,8 @@ import androidx.work.Worker
import androidx.work.WorkerParameters import androidx.work.WorkerParameters
import androidx.work.workDataOf import androidx.work.workDataOf
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.core.events.EventIobCalculationProgress
import info.nightscout.core.iob.iobCobCalculator.data.AutosensDataObject import info.nightscout.core.iob.iobCobCalculator.data.AutosensDataObject
import info.nightscout.core.events.EventNewNotification
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.core.utils.receivers.DataWorkerStorage import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.core.workflow.CalculationWorkflow import info.nightscout.core.workflow.CalculationWorkflow
@ -17,13 +17,11 @@ import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.aps.AutosensData import info.nightscout.interfaces.aps.AutosensData
import info.nightscout.interfaces.aps.SMBDefaults import info.nightscout.interfaces.aps.SMBDefaults
import info.nightscout.interfaces.iob.IobCobCalculator import info.nightscout.interfaces.iob.IobCobCalculator
import info.nightscout.interfaces.notifications.Notification
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.profiling.Profiler import info.nightscout.interfaces.profiling.Profiler
import info.nightscout.interfaces.utils.DecimalFormatter import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.plugins.R import info.nightscout.plugins.iob.iobCobCalculator.fromCarbs
import info.nightscout.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.Event import info.nightscout.rx.events.Event
import info.nightscout.rx.events.EventAutosensCalculationFinished import info.nightscout.rx.events.EventAutosensCalculationFinished
@ -33,6 +31,7 @@ import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.DateUtil
import info.nightscout.shared.utils.T import info.nightscout.shared.utils.T
import info.nightscout.workflow.R
import javax.inject.Inject import javax.inject.Inject
import kotlin.math.abs import kotlin.math.abs
import kotlin.math.max import kotlin.math.max
@ -150,19 +149,19 @@ class IobCobOrefWorker @Inject internal constructor(
val initialIndex = autosensDataTable.indexOfKey(hourAgoData.time) val initialIndex = autosensDataTable.indexOfKey(hourAgoData.time)
aapsLogger.debug(LTag.AUTOSENS, ">>>>> bucketed_data.size()=" + bucketedData.size + " i=" + i + " hourAgoData=" + hourAgoData.toString()) aapsLogger.debug(LTag.AUTOSENS, ">>>>> bucketed_data.size()=" + bucketedData.size + " i=" + i + " hourAgoData=" + hourAgoData.toString())
var past = 1 var past = 1
try { // try {
while (past < 12) { while (past < 12) {
val ad = autosensDataTable.valueAt(initialIndex + past) val ad = autosensDataTable.valueAt(initialIndex + past)
aapsLogger.debug(LTag.AUTOSENS, ">>>>> past=" + past + " ad=" + ad?.toString()) aapsLogger.debug(LTag.AUTOSENS, ">>>>> past=" + past + " ad=" + ad?.toString())
if (ad == null) { // if (ad == null) {
aapsLogger.debug(LTag.AUTOSENS, autosensDataTable.toString()) // aapsLogger.debug(LTag.AUTOSENS, autosensDataTable.toString())
aapsLogger.debug(LTag.AUTOSENS, bucketedData.toString()) // aapsLogger.debug(LTag.AUTOSENS, bucketedData.toString())
//aapsLogger.debug(LTag.AUTOSENS, data.iobCobCalculatorPlugin.getBgReadingsDataTable().toString()) // //aapsLogger.debug(LTag.AUTOSENS, data.iobCobCalculatorPlugin.getBgReadingsDataTable().toString())
val notification = Notification(Notification.SEND_LOGFILES, rh.gs(R.string.send_logfiles), Notification.LOW) // val notification = Notification(Notification.SEND_LOGFILES, rh.gs(R.string.send_logfiles), Notification.LOW)
rxBus.send(EventNewNotification(notification)) // rxBus.send(EventNewNotification(notification))
sp.putBoolean("log_AUTOSENS", true) // sp.putBoolean("log_AUTOSENS", true)
break // break
} // }
// let it here crash on NPE to get more data as i cannot reproduce this bug // let it here crash on NPE to get more data as i cannot reproduce this bug
val deviationSlope = (ad.avgDeviation - avgDeviation) / (ad.time - bgTime) * 1000 * 60 * 5 val deviationSlope = (ad.avgDeviation - avgDeviation) / (ad.time - bgTime) * 1000 * 60 * 5
if (ad.avgDeviation > maxDeviation) { if (ad.avgDeviation > maxDeviation) {
@ -175,17 +174,17 @@ class IobCobOrefWorker @Inject internal constructor(
} }
past++ past++
} }
} catch (e: Exception) { // } catch (e: Exception) {
aapsLogger.error("Unhandled exception", e) // aapsLogger.error("Unhandled exception", e)
fabricPrivacy.logException(e) // fabricPrivacy.logException(e)
aapsLogger.debug(autosensDataTable.toString()) // aapsLogger.debug(autosensDataTable.toString())
aapsLogger.debug(bucketedData.toString()) // aapsLogger.debug(bucketedData.toString())
//aapsLogger.debug(data.iobCobCalculatorPlugin.getBgReadingsDataTable().toString()) // //aapsLogger.debug(data.iobCobCalculatorPlugin.getBgReadingsDataTable().toString())
val notification = Notification(Notification.SEND_LOGFILES, rh.gs(R.string.send_logfiles), Notification.LOW) // val notification = Notification(Notification.SEND_LOGFILES, rh.gs(R.string.send_logfiles), Notification.LOW)
rxBus.send(EventNewNotification(notification)) // rxBus.send(EventNewNotification(notification))
sp.putBoolean("log_AUTOSENS", true) // sp.putBoolean("log_AUTOSENS", true)
break // break
} // }
} else { } else {
aapsLogger.debug(LTag.AUTOSENS, ">>>>> bucketed_data.size()=" + bucketedData.size + " i=" + i + " hourAgoData=" + "null") aapsLogger.debug(LTag.AUTOSENS, ">>>>> bucketed_data.size()=" + bucketedData.size + " i=" + i + " hourAgoData=" + "null")
} }