Instantiator
This commit is contained in:
parent
bc9ec4c9c5
commit
c8113bf4fc
26 changed files with 121 additions and 119 deletions
|
@ -7,13 +7,15 @@ import dagger.Module
|
||||||
import dagger.Provides
|
import dagger.Provides
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.MainApp
|
import info.nightscout.androidaps.MainApp
|
||||||
import info.nightscout.androidaps.implementations.UiInteractionImpl
|
|
||||||
import info.nightscout.androidaps.implementations.ConfigImpl
|
import info.nightscout.androidaps.implementations.ConfigImpl
|
||||||
|
import info.nightscout.androidaps.implementations.InstantiatorImpl
|
||||||
|
import info.nightscout.androidaps.implementations.UiInteractionImpl
|
||||||
import info.nightscout.androidaps.workflow.CalculationWorkflowImpl
|
import info.nightscout.androidaps.workflow.CalculationWorkflowImpl
|
||||||
import info.nightscout.androidaps.workflow.WorkerClassesImpl
|
import info.nightscout.androidaps.workflow.WorkerClassesImpl
|
||||||
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.plugin.PluginBase
|
import info.nightscout.interfaces.plugin.PluginBase
|
||||||
|
import info.nightscout.interfaces.profile.Instantiator
|
||||||
import info.nightscout.interfaces.ui.UiInteraction
|
import info.nightscout.interfaces.ui.UiInteraction
|
||||||
import info.nightscout.interfaces.workflow.WorkerClasses
|
import info.nightscout.interfaces.workflow.WorkerClasses
|
||||||
|
|
||||||
|
@ -53,6 +55,8 @@ open class AppModule {
|
||||||
@Binds fun bindActivityNames(activityNames: UiInteractionImpl): UiInteraction
|
@Binds fun bindActivityNames(activityNames: UiInteractionImpl): UiInteraction
|
||||||
@Binds fun bindWorkerClasses(workerClassesImpl: WorkerClassesImpl): WorkerClasses
|
@Binds fun bindWorkerClasses(workerClassesImpl: WorkerClassesImpl): WorkerClasses
|
||||||
@Binds fun bindCalculationWorkflow(calculationWorkflow: CalculationWorkflowImpl): CalculationWorkflow
|
@Binds fun bindCalculationWorkflow(calculationWorkflow: CalculationWorkflowImpl): CalculationWorkflow
|
||||||
|
@Binds fun bindInstantiator(instantiatorImpl: InstantiatorImpl): Instantiator
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
package info.nightscout.androidaps.implementations
|
||||||
|
|
||||||
|
import dagger.Reusable
|
||||||
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.implementation.profile.ProfileStoreObject
|
||||||
|
import info.nightscout.interfaces.aps.APSResult
|
||||||
|
import info.nightscout.interfaces.aps.AutosensData
|
||||||
|
import info.nightscout.interfaces.profile.Instantiator
|
||||||
|
import info.nightscout.interfaces.profile.ProfileStore
|
||||||
|
import info.nightscout.plugins.aps.APSResultObject
|
||||||
|
import info.nightscout.plugins.iob.iobCobCalculator.data.AutosensDataObject
|
||||||
|
import info.nightscout.shared.utils.DateUtil
|
||||||
|
import org.json.JSONObject
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@Reusable
|
||||||
|
class InstantiatorImpl @Inject constructor(
|
||||||
|
private val injector: HasAndroidInjector,
|
||||||
|
private val dateUtil: DateUtil
|
||||||
|
) : Instantiator {
|
||||||
|
|
||||||
|
override fun provideProfileStore(jsonObject: JSONObject): ProfileStore =
|
||||||
|
ProfileStoreObject(injector, jsonObject, dateUtil)
|
||||||
|
|
||||||
|
override fun provideAPSResultObject(): APSResult = APSResultObject(injector)
|
||||||
|
|
||||||
|
override fun provideAutosensDataObject(): AutosensData = AutosensDataObject(injector)
|
||||||
|
}
|
|
@ -20,7 +20,7 @@ import info.nightscout.interfaces.maintenance.PrefFileListProvider
|
||||||
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.plugin.PluginType
|
import info.nightscout.interfaces.plugin.PluginType
|
||||||
import info.nightscout.interfaces.profile.ProfileInstantiator
|
import info.nightscout.interfaces.profile.Instantiator
|
||||||
import info.nightscout.interfaces.profiling.Profiler
|
import info.nightscout.interfaces.profiling.Profiler
|
||||||
import info.nightscout.interfaces.pump.DetailedBolusInfoStorage
|
import info.nightscout.interfaces.pump.DetailedBolusInfoStorage
|
||||||
import info.nightscout.interfaces.pump.PumpEnactResult
|
import info.nightscout.interfaces.pump.PumpEnactResult
|
||||||
|
@ -70,7 +70,7 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
|
||||||
@Mock lateinit var insightDatabaseDao: InsightDatabaseDao
|
@Mock lateinit var insightDatabaseDao: InsightDatabaseDao
|
||||||
@Mock lateinit var ruffyScripter: RuffyScripter
|
@Mock lateinit var ruffyScripter: RuffyScripter
|
||||||
@Mock lateinit var uiInteraction: UiInteraction
|
@Mock lateinit var uiInteraction: UiInteraction
|
||||||
@Mock lateinit var profileInstantiator: ProfileInstantiator
|
@Mock lateinit var instantiator: Instantiator
|
||||||
@Mock lateinit var danaHistoryDatabase: DanaHistoryDatabase
|
@Mock lateinit var danaHistoryDatabase: DanaHistoryDatabase
|
||||||
@Mock lateinit var insightDatabase: InsightDatabase
|
@Mock lateinit var insightDatabase: InsightDatabase
|
||||||
@Mock lateinit var bgQualityCheck: BgQualityCheck
|
@Mock lateinit var bgQualityCheck: BgQualityCheck
|
||||||
|
@ -145,7 +145,7 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
|
||||||
|
|
||||||
hardLimits = HardLimitsMock(sp, rh)
|
hardLimits = HardLimitsMock(sp, rh)
|
||||||
insightDbHelper = InsightDbHelper(insightDatabaseDao)
|
insightDbHelper = InsightDbHelper(insightDatabaseDao)
|
||||||
danaPump = DanaPump(aapsLogger, sp, dateUtil, profileInstantiator)
|
danaPump = DanaPump(aapsLogger, sp, dateUtil, instantiator)
|
||||||
objectivesPlugin = ObjectivesPlugin(injector, aapsLogger, rh, activePlugin, sp, config)
|
objectivesPlugin = ObjectivesPlugin(injector, aapsLogger, rh, activePlugin, sp, config)
|
||||||
comboPlugin = ComboPlugin(injector, aapsLogger, rxBus, rh, profileFunction, sp, commandQueue, pumpSync, dateUtil, ruffyScripter, uiInteraction)
|
comboPlugin = ComboPlugin(injector, aapsLogger, rxBus, rh, profileFunction, sp, commandQueue, pumpSync, dateUtil, ruffyScripter, uiInteraction)
|
||||||
danaRPlugin = DanaRPlugin(injector, aapsLogger, aapsSchedulers, rxBus, context, rh, constraintChecker, activePlugin, sp, commandQueue, danaPump, dateUtil, fabricPrivacy, pumpSync,
|
danaRPlugin = DanaRPlugin(injector, aapsLogger, aapsSchedulers, rxBus, context, rh, constraintChecker, activePlugin, sp, commandQueue, danaPump, dateUtil, fabricPrivacy, pumpSync,
|
||||||
|
|
|
@ -57,6 +57,4 @@ interface Loop {
|
||||||
runningConfiguration: RunningConfiguration,
|
runningConfiguration: RunningConfiguration,
|
||||||
version: String
|
version: String
|
||||||
): DeviceStatus?
|
): DeviceStatus?
|
||||||
|
|
||||||
fun provideEmptyAPSResultObject(): APSResult
|
|
||||||
}
|
}
|
|
@ -104,6 +104,4 @@ interface IobCobCalculator {
|
||||||
* @return IobTotal
|
* @return IobTotal
|
||||||
*/
|
*/
|
||||||
fun calculateIobFromTempBasalsIncludingConvertedExtended(): IobTotal
|
fun calculateIobFromTempBasalsIncludingConvertedExtended(): IobTotal
|
||||||
|
|
||||||
fun provideEmptyAutosensDataObject(): AutosensData
|
|
||||||
}
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
package info.nightscout.interfaces.profile
|
||||||
|
|
||||||
|
import info.nightscout.interfaces.aps.APSResult
|
||||||
|
import info.nightscout.interfaces.aps.AutosensData
|
||||||
|
import org.json.JSONObject
|
||||||
|
|
||||||
|
interface Instantiator {
|
||||||
|
|
||||||
|
fun provideProfileStore(jsonObject: JSONObject): ProfileStore
|
||||||
|
fun provideAPSResultObject(): APSResult
|
||||||
|
fun provideAutosensDataObject(): AutosensData
|
||||||
|
}
|
|
@ -1,7 +0,0 @@
|
||||||
package info.nightscout.interfaces.profile
|
|
||||||
|
|
||||||
import org.json.JSONObject
|
|
||||||
|
|
||||||
interface ProfileInstantiator {
|
|
||||||
fun storeInstance(jsonObject: JSONObject): ProfileStore
|
|
||||||
}
|
|
|
@ -18,7 +18,6 @@ import info.nightscout.implementation.logging.LoggerUtilsImpl
|
||||||
import info.nightscout.implementation.overview.OverviewDataImpl
|
import info.nightscout.implementation.overview.OverviewDataImpl
|
||||||
import info.nightscout.implementation.plugin.PluginStore
|
import info.nightscout.implementation.plugin.PluginStore
|
||||||
import info.nightscout.implementation.profile.ProfileFunctionImpl
|
import info.nightscout.implementation.profile.ProfileFunctionImpl
|
||||||
import info.nightscout.implementation.profile.ProfileInstantiatorImpl
|
|
||||||
import info.nightscout.implementation.profile.ProfileStoreObject
|
import info.nightscout.implementation.profile.ProfileStoreObject
|
||||||
import info.nightscout.implementation.profiling.ProfilerImpl
|
import info.nightscout.implementation.profiling.ProfilerImpl
|
||||||
import info.nightscout.implementation.protection.PasswordCheckImpl
|
import info.nightscout.implementation.protection.PasswordCheckImpl
|
||||||
|
@ -49,7 +48,6 @@ import info.nightscout.interfaces.logging.UserEntryLogger
|
||||||
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.interfaces.profile.ProfileFunction
|
import info.nightscout.interfaces.profile.ProfileFunction
|
||||||
import info.nightscout.interfaces.profile.ProfileInstantiator
|
|
||||||
import info.nightscout.interfaces.profiling.Profiler
|
import info.nightscout.interfaces.profiling.Profiler
|
||||||
import info.nightscout.interfaces.protection.PasswordCheck
|
import info.nightscout.interfaces.protection.PasswordCheck
|
||||||
import info.nightscout.interfaces.protection.ProtectionCheck
|
import info.nightscout.interfaces.protection.ProtectionCheck
|
||||||
|
@ -100,7 +98,6 @@ abstract class ImplementationModule {
|
||||||
@Binds fun bindWarnColors(warnColorsImpl: WarnColorsImpl): WarnColors
|
@Binds fun bindWarnColors(warnColorsImpl: WarnColorsImpl): WarnColors
|
||||||
@Binds fun bindHardLimits(hardLimitsImpl: HardLimitsImpl): HardLimits
|
@Binds fun bindHardLimits(hardLimitsImpl: HardLimitsImpl): HardLimits
|
||||||
@Binds fun bindResourceHelper(resourceHelperImpl: ResourceHelperImpl): ResourceHelper
|
@Binds fun bindResourceHelper(resourceHelperImpl: ResourceHelperImpl): ResourceHelper
|
||||||
@Binds fun bindProfileStoreInstantiator(profileStoreInstantiatorImpl: ProfileInstantiatorImpl): ProfileInstantiator
|
|
||||||
@Binds fun bindBlePreCheck(blePreCheckImpl: BlePreCheckImpl): BlePreCheck
|
@Binds fun bindBlePreCheck(blePreCheckImpl: BlePreCheckImpl): BlePreCheck
|
||||||
|
|
||||||
@Binds fun bindTrendCalculatorInterface(trendCalculator: TrendCalculatorImpl): TrendCalculator
|
@Binds fun bindTrendCalculatorInterface(trendCalculator: TrendCalculatorImpl): TrendCalculator
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
package info.nightscout.implementation.profile
|
|
||||||
|
|
||||||
import dagger.android.HasAndroidInjector
|
|
||||||
import info.nightscout.interfaces.profile.ProfileInstantiator
|
|
||||||
import info.nightscout.interfaces.profile.ProfileStore
|
|
||||||
import info.nightscout.shared.utils.DateUtil
|
|
||||||
import org.json.JSONObject
|
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
class ProfileInstantiatorImpl @Inject constructor(
|
|
||||||
private val injector: HasAndroidInjector,
|
|
||||||
private val dateUtil: DateUtil
|
|
||||||
): ProfileInstantiator {
|
|
||||||
|
|
||||||
override fun storeInstance(jsonObject: JSONObject): ProfileStore =
|
|
||||||
ProfileStoreObject(injector, jsonObject, dateUtil)
|
|
||||||
}
|
|
|
@ -57,7 +57,6 @@ import info.nightscout.interfaces.queue.CommandQueue
|
||||||
import info.nightscout.interfaces.receivers.ReceiverStatusStore
|
import info.nightscout.interfaces.receivers.ReceiverStatusStore
|
||||||
import info.nightscout.interfaces.ui.UiInteraction
|
import info.nightscout.interfaces.ui.UiInteraction
|
||||||
import info.nightscout.interfaces.utils.HardLimits
|
import info.nightscout.interfaces.utils.HardLimits
|
||||||
import info.nightscout.plugins.aps.APSResultObject
|
|
||||||
import info.nightscout.plugins.aps.R
|
import info.nightscout.plugins.aps.R
|
||||||
import info.nightscout.plugins.aps.loop.events.EventLoopSetLastRunGui
|
import info.nightscout.plugins.aps.loop.events.EventLoopSetLastRunGui
|
||||||
import info.nightscout.plugins.aps.loop.extensions.json
|
import info.nightscout.plugins.aps.loop.extensions.json
|
||||||
|
@ -784,8 +783,6 @@ class LoopPlugin @Inject constructor(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun provideEmptyAPSResultObject(): APSResult = APSResultObject(injector)
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
private const val CHANNEL_ID = "AAPS-OpenLoop"
|
private const val CHANNEL_ID = "AAPS-OpenLoop"
|
||||||
|
|
|
@ -30,7 +30,7 @@ import info.nightscout.interfaces.logging.UserEntryLogger
|
||||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||||
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.profile.ProfileInstantiator
|
import info.nightscout.interfaces.profile.Instantiator
|
||||||
import info.nightscout.interfaces.profile.ProfileStore
|
import info.nightscout.interfaces.profile.ProfileStore
|
||||||
import info.nightscout.interfaces.ui.UiInteraction
|
import info.nightscout.interfaces.ui.UiInteraction
|
||||||
import info.nightscout.interfaces.utils.MidnightTime
|
import info.nightscout.interfaces.utils.MidnightTime
|
||||||
|
@ -70,7 +70,7 @@ class AutotuneFragment : DaggerFragment() {
|
||||||
@Inject lateinit var injector: HasAndroidInjector
|
@Inject lateinit var injector: HasAndroidInjector
|
||||||
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
||||||
@Inject lateinit var uiInteraction: UiInteraction
|
@Inject lateinit var uiInteraction: UiInteraction
|
||||||
@Inject lateinit var profileInstantiator: ProfileInstantiator
|
@Inject lateinit var instantiator: Instantiator
|
||||||
|
|
||||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||||
private var handler = Handler(HandlerThread(this::class.simpleName + "Handler").also { it.start() }.looper)
|
private var handler = Handler(HandlerThread(this::class.simpleName + "Handler").also { it.start() }.looper)
|
||||||
|
@ -97,7 +97,7 @@ class AutotuneFragment : DaggerFragment() {
|
||||||
if (autotunePlugin.lastNbDays.isEmpty())
|
if (autotunePlugin.lastNbDays.isEmpty())
|
||||||
autotunePlugin.lastNbDays = sp.getInt(info.nightscout.core.utils.R.string.key_autotune_default_tune_days, 5).toString()
|
autotunePlugin.lastNbDays = sp.getInt(info.nightscout.core.utils.R.string.key_autotune_default_tune_days, 5).toString()
|
||||||
val defaultValue = sp.getInt(info.nightscout.core.utils.R.string.key_autotune_default_tune_days, 5).toDouble()
|
val defaultValue = sp.getInt(info.nightscout.core.utils.R.string.key_autotune_default_tune_days, 5).toDouble()
|
||||||
profileStore = activePlugin.activeProfileSource.profile ?: profileInstantiator.storeInstance(JSONObject())
|
profileStore = activePlugin.activeProfileSource.profile ?: instantiator.provideProfileStore(JSONObject())
|
||||||
profileName = if (binding.profileList.text.toString() == rh.gs(info.nightscout.core.ui.R.string.active)) "" else binding.profileList.text.toString()
|
profileName = if (binding.profileList.text.toString() == rh.gs(info.nightscout.core.ui.R.string.active)) "" else binding.profileList.text.toString()
|
||||||
profileFunction.getProfile()?.let { currentProfile ->
|
profileFunction.getProfile()?.let { currentProfile ->
|
||||||
profile = ATProfile(profileStore.getSpecificProfile(profileName)?.let { ProfileSealed.Pure(it) } ?: currentProfile, LocalInsulin(""), injector)
|
profile = ATProfile(profileStore.getSpecificProfile(profileName)?.let { ProfileSealed.Pure(it) } ?: currentProfile, LocalInsulin(""), injector)
|
||||||
|
@ -295,7 +295,7 @@ class AutotuneFragment : DaggerFragment() {
|
||||||
@Synchronized
|
@Synchronized
|
||||||
private fun updateGui() {
|
private fun updateGui() {
|
||||||
_binding ?: return
|
_binding ?: return
|
||||||
profileStore = activePlugin.activeProfileSource.profile ?: profileInstantiator.storeInstance(JSONObject())
|
profileStore = activePlugin.activeProfileSource.profile ?: instantiator.provideProfileStore(JSONObject())
|
||||||
profileName = if (binding.profileList.text.toString() == rh.gs(info.nightscout.core.ui.R.string.active)) "" else binding.profileList.text.toString()
|
profileName = if (binding.profileList.text.toString() == rh.gs(info.nightscout.core.ui.R.string.active)) "" else binding.profileList.text.toString()
|
||||||
profileFunction.getProfile()?.let { currentProfile ->
|
profileFunction.getProfile()?.let { currentProfile ->
|
||||||
profile = ATProfile(profileStore.getSpecificProfile(profileName)?.let { ProfileSealed.Pure(it) } ?: currentProfile, LocalInsulin(""), injector)
|
profile = ATProfile(profileStore.getSpecificProfile(profileName)?.let { ProfileSealed.Pure(it) } ?: currentProfile, LocalInsulin(""), injector)
|
||||||
|
|
|
@ -16,7 +16,7 @@ import info.nightscout.interfaces.plugin.PluginDescription
|
||||||
import info.nightscout.interfaces.plugin.PluginType
|
import info.nightscout.interfaces.plugin.PluginType
|
||||||
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.profile.ProfileInstantiator
|
import info.nightscout.interfaces.profile.Instantiator
|
||||||
import info.nightscout.interfaces.utils.JsonHelper
|
import info.nightscout.interfaces.utils.JsonHelper
|
||||||
import info.nightscout.interfaces.utils.MidnightTime
|
import info.nightscout.interfaces.utils.MidnightTime
|
||||||
import info.nightscout.plugins.aps.R
|
import info.nightscout.plugins.aps.R
|
||||||
|
@ -61,7 +61,7 @@ class AutotunePlugin @Inject constructor(
|
||||||
private val config: Config,
|
private val config: Config,
|
||||||
private val uel: UserEntryLogger,
|
private val uel: UserEntryLogger,
|
||||||
aapsLogger: AAPSLogger,
|
aapsLogger: AAPSLogger,
|
||||||
private val profileInstantiator: ProfileInstantiator
|
private val instantiator: Instantiator
|
||||||
) : PluginBase(
|
) : PluginBase(
|
||||||
PluginDescription()
|
PluginDescription()
|
||||||
.mainType(PluginType.GENERAL)
|
.mainType(PluginType.GENERAL)
|
||||||
|
@ -325,7 +325,7 @@ class AutotunePlugin @Inject constructor(
|
||||||
if (newProfile == null) return
|
if (newProfile == null) return
|
||||||
val profilePlugin = activePlugin.activeProfileSource
|
val profilePlugin = activePlugin.activeProfileSource
|
||||||
val circadian = sp.getBoolean(info.nightscout.core.utils.R.string.key_autotune_circadian_ic_isf, false)
|
val circadian = sp.getBoolean(info.nightscout.core.utils.R.string.key_autotune_circadian_ic_isf, false)
|
||||||
val profileStore = activePlugin.activeProfileSource.profile ?: profileInstantiator.storeInstance(JSONObject())
|
val profileStore = activePlugin.activeProfileSource.profile ?: instantiator.provideProfileStore(JSONObject())
|
||||||
val profileList: ArrayList<CharSequence> = profileStore.getProfileList()
|
val profileList: ArrayList<CharSequence> = profileStore.getProfileList()
|
||||||
var indexLocalProfile = -1
|
var indexLocalProfile = -1
|
||||||
for (p in profileList.indices)
|
for (p in profileList.indices)
|
||||||
|
|
|
@ -12,7 +12,7 @@ import info.nightscout.interfaces.insulin.Insulin
|
||||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||||
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.profile.ProfileInstantiator
|
import info.nightscout.interfaces.profile.Instantiator
|
||||||
import info.nightscout.interfaces.profile.ProfileStore
|
import info.nightscout.interfaces.profile.ProfileStore
|
||||||
import info.nightscout.interfaces.profile.PureProfile
|
import info.nightscout.interfaces.profile.PureProfile
|
||||||
import info.nightscout.interfaces.utils.Round
|
import info.nightscout.interfaces.utils.Round
|
||||||
|
@ -38,7 +38,7 @@ class ATProfile(profile: Profile, var localInsulin: LocalInsulin, val injector:
|
||||||
@Inject lateinit var config: Config
|
@Inject lateinit var config: Config
|
||||||
@Inject lateinit var rxBus: RxBus
|
@Inject lateinit var rxBus: RxBus
|
||||||
@Inject lateinit var rh: ResourceHelper
|
@Inject lateinit var rh: ResourceHelper
|
||||||
@Inject lateinit var profileInstantiator: ProfileInstantiator
|
@Inject lateinit var instantiator: Instantiator
|
||||||
|
|
||||||
var profile: ProfileSealed
|
var profile: ProfileSealed
|
||||||
var circadianProfile: ProfileSealed
|
var circadianProfile: ProfileSealed
|
||||||
|
@ -179,7 +179,7 @@ class ATProfile(profile: Profile, var localInsulin: LocalInsulin, val injector:
|
||||||
json.put("defaultProfile", profilename)
|
json.put("defaultProfile", profilename)
|
||||||
json.put("store", store)
|
json.put("store", store)
|
||||||
json.put("startDate", dateUtil.toISOAsUTC(dateUtil.now()))
|
json.put("startDate", dateUtil.toISOAsUTC(dateUtil.now()))
|
||||||
profileStore = profileInstantiator.storeInstance(json)
|
profileStore = instantiator.provideProfileStore(json)
|
||||||
} catch (e: JSONException) {
|
} catch (e: JSONException) {
|
||||||
}
|
}
|
||||||
return profileStore
|
return profileStore
|
||||||
|
|
|
@ -10,7 +10,6 @@ import info.nightscout.database.entities.DeviceStatus
|
||||||
import info.nightscout.database.entities.OfflineEvent
|
import info.nightscout.database.entities.OfflineEvent
|
||||||
import info.nightscout.interfaces.ConfigBuilder
|
import info.nightscout.interfaces.ConfigBuilder
|
||||||
import info.nightscout.interfaces.GlucoseUnit
|
import info.nightscout.interfaces.GlucoseUnit
|
||||||
import info.nightscout.interfaces.aps.APSResult
|
|
||||||
import info.nightscout.interfaces.aps.Loop
|
import info.nightscout.interfaces.aps.Loop
|
||||||
import info.nightscout.interfaces.configBuilder.RunningConfiguration
|
import info.nightscout.interfaces.configBuilder.RunningConfiguration
|
||||||
import info.nightscout.interfaces.constraints.Constraint
|
import info.nightscout.interfaces.constraints.Constraint
|
||||||
|
@ -43,8 +42,7 @@ ActionsTestBase : TestBaseWithProfile() {
|
||||||
aapsLogger: AAPSLogger,
|
aapsLogger: AAPSLogger,
|
||||||
rh: ResourceHelper,
|
rh: ResourceHelper,
|
||||||
injector: HasAndroidInjector,
|
injector: HasAndroidInjector,
|
||||||
pluginDescription: PluginDescription,
|
pluginDescription: PluginDescription
|
||||||
private val apsResult: APSResult
|
|
||||||
) : PluginBase(
|
) : PluginBase(
|
||||||
pluginDescription, aapsLogger, rh, injector
|
pluginDescription, aapsLogger, rh, injector
|
||||||
), Loop {
|
), Loop {
|
||||||
|
@ -78,8 +76,6 @@ ActionsTestBase : TestBaseWithProfile() {
|
||||||
version: String
|
version: String
|
||||||
): DeviceStatus? = null
|
): DeviceStatus? = null
|
||||||
|
|
||||||
override fun provideEmptyAPSResultObject(): APSResult = apsResult
|
|
||||||
|
|
||||||
override fun setPluginEnabled(type: PluginType, newState: Boolean) {}
|
override fun setPluginEnabled(type: PluginType, newState: Boolean) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +88,6 @@ ActionsTestBase : TestBaseWithProfile() {
|
||||||
@Mock lateinit var loopPlugin: TestLoopPlugin
|
@Mock lateinit var loopPlugin: TestLoopPlugin
|
||||||
@Mock lateinit var uel: UserEntryLogger
|
@Mock lateinit var uel: UserEntryLogger
|
||||||
@Mock lateinit var context: Context
|
@Mock lateinit var context: Context
|
||||||
@Mock lateinit var apsResult: APSResult
|
|
||||||
|
|
||||||
private val pluginDescription = PluginDescription()
|
private val pluginDescription = PluginDescription()
|
||||||
lateinit var testPumpPlugin: TestPumpPlugin
|
lateinit var testPumpPlugin: TestPumpPlugin
|
||||||
|
|
|
@ -38,7 +38,6 @@ import info.nightscout.interfaces.profile.ProfileFunction
|
||||||
import info.nightscout.interfaces.utils.DecimalFormatter
|
import info.nightscout.interfaces.utils.DecimalFormatter
|
||||||
import info.nightscout.interfaces.utils.MidnightTime
|
import info.nightscout.interfaces.utils.MidnightTime
|
||||||
import info.nightscout.plugins.R
|
import info.nightscout.plugins.R
|
||||||
import info.nightscout.plugins.iob.iobCobCalculator.data.AutosensDataObject
|
|
||||||
import info.nightscout.plugins.iob.iobCobCalculator.data.AutosensDataStoreObject
|
import info.nightscout.plugins.iob.iobCobCalculator.data.AutosensDataStoreObject
|
||||||
import info.nightscout.rx.AapsSchedulers
|
import info.nightscout.rx.AapsSchedulers
|
||||||
import info.nightscout.rx.bus.RxBus
|
import info.nightscout.rx.bus.RxBus
|
||||||
|
@ -600,8 +599,6 @@ class IobCobCalculatorPlugin @Inject constructor(
|
||||||
override fun calculateIobFromTempBasalsIncludingConvertedExtended(): IobTotal =
|
override fun calculateIobFromTempBasalsIncludingConvertedExtended(): IobTotal =
|
||||||
calculateIobToTimeFromTempBasalsIncludingConvertedExtended(dateUtil.now())
|
calculateIobToTimeFromTempBasalsIncludingConvertedExtended(dateUtil.now())
|
||||||
|
|
||||||
override fun provideEmptyAutosensDataObject(): AutosensData = AutosensDataObject(injector)
|
|
||||||
|
|
||||||
override fun calculateIobToTimeFromTempBasalsIncludingConvertedExtended(toTime: Long): IobTotal {
|
override fun calculateIobToTimeFromTempBasalsIncludingConvertedExtended(toTime: Long): IobTotal {
|
||||||
val total = IobTotal(toTime)
|
val total = IobTotal(toTime)
|
||||||
val now = dateUtil.now()
|
val now = dateUtil.now()
|
||||||
|
|
|
@ -24,7 +24,7 @@ import info.nightscout.interfaces.plugin.PluginDescription
|
||||||
import info.nightscout.interfaces.plugin.PluginType
|
import info.nightscout.interfaces.plugin.PluginType
|
||||||
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.profile.ProfileInstantiator
|
import info.nightscout.interfaces.profile.Instantiator
|
||||||
import info.nightscout.interfaces.profile.ProfileSource
|
import info.nightscout.interfaces.profile.ProfileSource
|
||||||
import info.nightscout.interfaces.profile.ProfileStore
|
import info.nightscout.interfaces.profile.ProfileStore
|
||||||
import info.nightscout.interfaces.profile.PureProfile
|
import info.nightscout.interfaces.profile.PureProfile
|
||||||
|
@ -60,7 +60,7 @@ class ProfilePlugin @Inject constructor(
|
||||||
private val hardLimits: HardLimits,
|
private val hardLimits: HardLimits,
|
||||||
private val dateUtil: DateUtil,
|
private val dateUtil: DateUtil,
|
||||||
private val config: Config,
|
private val config: Config,
|
||||||
private val profileInstantiator: ProfileInstantiator
|
private val instantiator: Instantiator
|
||||||
) : PluginBase(
|
) : PluginBase(
|
||||||
PluginDescription()
|
PluginDescription()
|
||||||
.mainType(PluginType.PROFILE)
|
.mainType(PluginType.PROFILE)
|
||||||
|
@ -419,7 +419,7 @@ class ProfilePlugin @Inject constructor(
|
||||||
aapsLogger.error("Unhandled exception", e)
|
aapsLogger.error("Unhandled exception", e)
|
||||||
}
|
}
|
||||||
|
|
||||||
return profileInstantiator.storeInstance(json)
|
return instantiator.provideProfileStore(json)
|
||||||
}
|
}
|
||||||
|
|
||||||
override val profile: ProfileStore?
|
override val profile: ProfileStore?
|
||||||
|
@ -444,14 +444,14 @@ class ProfilePlugin @Inject constructor(
|
||||||
@Inject lateinit var config: Config
|
@Inject lateinit var config: Config
|
||||||
@Inject lateinit var profilePlugin: ProfilePlugin
|
@Inject lateinit var profilePlugin: ProfilePlugin
|
||||||
@Inject lateinit var xDripBroadcast: XDripBroadcast
|
@Inject lateinit var xDripBroadcast: XDripBroadcast
|
||||||
@Inject lateinit var profileInstantiator: ProfileInstantiator
|
@Inject lateinit var instantiator: Instantiator
|
||||||
|
|
||||||
override fun doWorkAndLog(): Result {
|
override fun doWorkAndLog(): Result {
|
||||||
val profileJson = dataWorkerStorage.pickupJSONObject(inputData.getLong(DataWorkerStorage.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(info.nightscout.core.utils.R.string.key_ns_receive_profile_store, true) || config.NSCLIENT) {
|
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_receive_profile_store, true) || config.NSCLIENT) {
|
||||||
val store = profileInstantiator.storeInstance(profileJson)
|
val store = instantiator.provideProfileStore(profileJson)
|
||||||
val createdAt = store.getStartDate()
|
val createdAt = store.getStartDate()
|
||||||
val lastLocalChange = sp.getLong(info.nightscout.core.utils.R.string.key_local_profile_last_change, 0)
|
val lastLocalChange = sp.getLong(info.nightscout.core.utils.R.string.key_local_profile_last_change, 0)
|
||||||
aapsLogger.debug(LTag.PROFILE, "Received profileStore: createdAt: $createdAt Local last modification: $lastLocalChange")
|
aapsLogger.debug(LTag.PROFILE, "Received profileStore: createdAt: $createdAt Local last modification: $lastLocalChange")
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
package info.nightscout.plugins.sync.nsclient.data
|
package info.nightscout.plugins.sync.nsclient.data
|
||||||
|
|
||||||
import android.text.Spanned
|
import android.text.Spanned
|
||||||
import dagger.Lazy
|
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.interfaces.aps.APSResult
|
import info.nightscout.interfaces.aps.APSResult
|
||||||
import info.nightscout.interfaces.aps.Loop
|
|
||||||
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.profile.Instantiator
|
||||||
import info.nightscout.interfaces.utils.HtmlHelper
|
import info.nightscout.interfaces.utils.HtmlHelper
|
||||||
import info.nightscout.interfaces.utils.JsonHelper
|
import info.nightscout.interfaces.utils.JsonHelper
|
||||||
import info.nightscout.interfaces.utils.Round
|
import info.nightscout.interfaces.utils.Round
|
||||||
|
@ -24,7 +23,7 @@ class ProcessedDeviceStatusDataImpl @Inject constructor(
|
||||||
private val rh: ResourceHelper,
|
private val rh: ResourceHelper,
|
||||||
private val dateUtil: DateUtil,
|
private val dateUtil: DateUtil,
|
||||||
private val sp: SP,
|
private val sp: SP,
|
||||||
private val loop: Lazy<Loop>
|
private val instantiator: Instantiator
|
||||||
) : ProcessedDeviceStatusData {
|
) : ProcessedDeviceStatusData {
|
||||||
|
|
||||||
override var pumpData: ProcessedDeviceStatusData.PumpData? = null
|
override var pumpData: ProcessedDeviceStatusData.PumpData? = null
|
||||||
|
@ -116,7 +115,7 @@ class ProcessedDeviceStatusDataImpl @Inject constructor(
|
||||||
get() = if (openAPSData.clockSuggested != 0L) openAPSData.clockSuggested else -1
|
get() = if (openAPSData.clockSuggested != 0L) openAPSData.clockSuggested else -1
|
||||||
|
|
||||||
override fun getAPSResult(injector: HasAndroidInjector): APSResult =
|
override fun getAPSResult(injector: HasAndroidInjector): APSResult =
|
||||||
loop.get().provideEmptyAPSResultObject().also {
|
instantiator.provideAPSResultObject().also {
|
||||||
it.json = openAPSData.suggested
|
it.json = openAPSData.suggested
|
||||||
it.date = openAPSData.clockSuggested
|
it.date = openAPSData.clockSuggested
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package info.nightscout.pump.dana
|
||||||
|
|
||||||
import info.nightscout.interfaces.Constants
|
import info.nightscout.interfaces.Constants
|
||||||
import info.nightscout.interfaces.profile.Profile
|
import info.nightscout.interfaces.profile.Profile
|
||||||
import info.nightscout.interfaces.profile.ProfileInstantiator
|
import info.nightscout.interfaces.profile.Instantiator
|
||||||
import info.nightscout.interfaces.profile.ProfileStore
|
import info.nightscout.interfaces.profile.ProfileStore
|
||||||
import info.nightscout.interfaces.pump.PumpSync
|
import info.nightscout.interfaces.pump.PumpSync
|
||||||
import info.nightscout.interfaces.pump.defs.PumpType
|
import info.nightscout.interfaces.pump.defs.PumpType
|
||||||
|
@ -33,7 +33,7 @@ class DanaPump @Inject constructor(
|
||||||
private val aapsLogger: AAPSLogger,
|
private val aapsLogger: AAPSLogger,
|
||||||
private val sp: SP,
|
private val sp: SP,
|
||||||
private val dateUtil: DateUtil,
|
private val dateUtil: DateUtil,
|
||||||
private val profileInstantiator: ProfileInstantiator
|
private val instantiator: Instantiator
|
||||||
) {
|
) {
|
||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
|
@ -380,7 +380,7 @@ class DanaPump @Inject constructor(
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
return profileInstantiator.storeInstance(json)
|
return instantiator.provideProfileStore(json)
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package info.nightscout.androidaps.dana
|
package info.nightscout.androidaps.dana
|
||||||
|
|
||||||
import info.nightscout.androidaps.TestBaseWithProfile
|
import info.nightscout.androidaps.TestBaseWithProfile
|
||||||
import info.nightscout.interfaces.profile.ProfileInstantiator
|
import info.nightscout.interfaces.profile.Instantiator
|
||||||
import info.nightscout.pump.dana.DanaPump
|
import info.nightscout.pump.dana.DanaPump
|
||||||
import info.nightscout.shared.sharedPreferences.SP
|
import info.nightscout.shared.sharedPreferences.SP
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
|
@ -12,18 +12,18 @@ import org.mockito.Mock
|
||||||
class DanaPumpTest : TestBaseWithProfile() {
|
class DanaPumpTest : TestBaseWithProfile() {
|
||||||
|
|
||||||
@Mock lateinit var sp: SP
|
@Mock lateinit var sp: SP
|
||||||
@Mock lateinit var profileInstantiator: ProfileInstantiator
|
@Mock lateinit var instantiator: Instantiator
|
||||||
|
|
||||||
private lateinit var sut: DanaPump
|
private lateinit var sut: DanaPump
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
fun setup() {
|
fun setup() {
|
||||||
sut = DanaPump(aapsLogger, sp, dateUtil, profileInstantiator)
|
sut = DanaPump(aapsLogger, sp, dateUtil, instantiator)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun detectDanaRS() {
|
fun detectDanaRS() {
|
||||||
sut.hwModel = 0x05
|
sut.hwModel = 0x05
|
||||||
Assert.assertTrue(sut.modelFriendlyName().contains("DanaRS"))
|
Assertions.assertTrue(sut.modelFriendlyName().contains("DanaRS"))
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -8,14 +8,14 @@ import info.nightscout.interfaces.Constants
|
||||||
import info.nightscout.interfaces.constraints.Constraint
|
import info.nightscout.interfaces.constraints.Constraint
|
||||||
import info.nightscout.interfaces.constraints.Constraints
|
import info.nightscout.interfaces.constraints.Constraints
|
||||||
import info.nightscout.interfaces.plugin.PluginType
|
import info.nightscout.interfaces.plugin.PluginType
|
||||||
import info.nightscout.interfaces.profile.ProfileInstantiator
|
import info.nightscout.interfaces.profile.Instantiator
|
||||||
import info.nightscout.interfaces.pump.PumpSync
|
import info.nightscout.interfaces.pump.PumpSync
|
||||||
import info.nightscout.interfaces.queue.CommandQueue
|
import info.nightscout.interfaces.queue.CommandQueue
|
||||||
import info.nightscout.interfaces.ui.UiInteraction
|
import info.nightscout.interfaces.ui.UiInteraction
|
||||||
import info.nightscout.pump.dana.DanaPump
|
import info.nightscout.pump.dana.DanaPump
|
||||||
import info.nightscout.pump.dana.database.DanaHistoryDatabase
|
import info.nightscout.pump.dana.database.DanaHistoryDatabase
|
||||||
import info.nightscout.shared.sharedPreferences.SP
|
import info.nightscout.shared.sharedPreferences.SP
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
|
@ -27,7 +27,7 @@ class DanaRPluginTest : TestBaseWithProfile() {
|
||||||
@Mock lateinit var sp: SP
|
@Mock lateinit var sp: SP
|
||||||
@Mock lateinit var commandQueue: CommandQueue
|
@Mock lateinit var commandQueue: CommandQueue
|
||||||
@Mock lateinit var pumpSync: PumpSync
|
@Mock lateinit var pumpSync: PumpSync
|
||||||
@Mock lateinit var profileInstantiator: ProfileInstantiator
|
@Mock lateinit var instantiator: Instantiator
|
||||||
@Mock lateinit var uiInteraction: UiInteraction
|
@Mock lateinit var uiInteraction: UiInteraction
|
||||||
@Mock lateinit var danaHistoryDatabase: DanaHistoryDatabase
|
@Mock lateinit var danaHistoryDatabase: DanaHistoryDatabase
|
||||||
|
|
||||||
|
@ -47,9 +47,11 @@ class DanaRPluginTest : TestBaseWithProfile() {
|
||||||
`when`(rh.gs(info.nightscout.core.ui.R.string.itmustbepositivevalue)).thenReturn("it must be positive value")
|
`when`(rh.gs(info.nightscout.core.ui.R.string.itmustbepositivevalue)).thenReturn("it must be positive value")
|
||||||
`when`(rh.gs(info.nightscout.core.ui.R.string.limitingbasalratio)).thenReturn("Limiting max basal rate to %1\$.2f U/h because of %2\$s")
|
`when`(rh.gs(info.nightscout.core.ui.R.string.limitingbasalratio)).thenReturn("Limiting max basal rate to %1\$.2f U/h because of %2\$s")
|
||||||
`when`(rh.gs(info.nightscout.core.ui.R.string.limitingpercentrate)).thenReturn("Limiting max percent rate to %1\$d%% because of %2\$s")
|
`when`(rh.gs(info.nightscout.core.ui.R.string.limitingpercentrate)).thenReturn("Limiting max percent rate to %1\$d%% because of %2\$s")
|
||||||
danaPump = DanaPump(aapsLogger, sp, dateUtil, profileInstantiator)
|
danaPump = DanaPump(aapsLogger, sp, dateUtil, instantiator)
|
||||||
danaRPlugin = DanaRPlugin(injector, aapsLogger, aapsSchedulers, rxBus, context, rh, constraintChecker, activePluginProvider, sp, commandQueue, danaPump, dateUtil, fabricPrivacy, pumpSync,
|
danaRPlugin = DanaRPlugin(
|
||||||
uiInteraction, danaHistoryDatabase)
|
injector, aapsLogger, aapsSchedulers, rxBus, context, rh, constraintChecker, activePluginProvider, sp, commandQueue, danaPump, dateUtil, fabricPrivacy, pumpSync,
|
||||||
|
uiInteraction, danaHistoryDatabase
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test @Throws(Exception::class)
|
@Test @Throws(Exception::class)
|
||||||
|
@ -59,9 +61,9 @@ class DanaRPluginTest : TestBaseWithProfile() {
|
||||||
danaPump.maxBasal = 0.8
|
danaPump.maxBasal = 0.8
|
||||||
val c = Constraint(Constants.REALLYHIGHBASALRATE)
|
val c = Constraint(Constants.REALLYHIGHBASALRATE)
|
||||||
danaRPlugin.applyBasalConstraints(c, validProfile)
|
danaRPlugin.applyBasalConstraints(c, validProfile)
|
||||||
Assert.assertEquals(0.8, c.value(), 0.01)
|
Assertions.assertEquals(0.8, c.value(), 0.01)
|
||||||
Assert.assertEquals("DanaR: Limiting max basal rate to 0.80 U/h because of pump limit", c.getReasons(aapsLogger))
|
Assertions.assertEquals("DanaR: Limiting max basal rate to 0.80 U/h because of pump limit", c.getReasons(aapsLogger))
|
||||||
Assert.assertEquals("DanaR: Limiting max basal rate to 0.80 U/h because of pump limit", c.getMostLimitedReasons(aapsLogger))
|
Assertions.assertEquals("DanaR: Limiting max basal rate to 0.80 U/h because of pump limit", c.getMostLimitedReasons(aapsLogger))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test @Throws(Exception::class)
|
@Test @Throws(Exception::class)
|
||||||
|
@ -71,8 +73,8 @@ class DanaRPluginTest : TestBaseWithProfile() {
|
||||||
danaPump.maxBasal = 0.8
|
danaPump.maxBasal = 0.8
|
||||||
val c = Constraint(Constants.REALLYHIGHPERCENTBASALRATE)
|
val c = Constraint(Constants.REALLYHIGHPERCENTBASALRATE)
|
||||||
danaRPlugin.applyBasalPercentConstraints(c, validProfile)
|
danaRPlugin.applyBasalPercentConstraints(c, validProfile)
|
||||||
Assert.assertEquals(200, c.value())
|
Assertions.assertEquals(200, c.value())
|
||||||
Assert.assertEquals("DanaR: Limiting max percent rate to 200% because of pump limit", c.getReasons(aapsLogger))
|
Assertions.assertEquals("DanaR: Limiting max percent rate to 200% because of pump limit", c.getReasons(aapsLogger))
|
||||||
Assert.assertEquals("DanaR: Limiting max percent rate to 200% because of pump limit", c.getMostLimitedReasons(aapsLogger))
|
Assertions.assertEquals("DanaR: Limiting max percent rate to 200% because of pump limit", c.getMostLimitedReasons(aapsLogger))
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -11,8 +11,7 @@ import info.nightscout.androidaps.danar.comm.MessageBase
|
||||||
import info.nightscout.interfaces.ConfigBuilder
|
import info.nightscout.interfaces.ConfigBuilder
|
||||||
import info.nightscout.interfaces.constraints.Constraints
|
import info.nightscout.interfaces.constraints.Constraints
|
||||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||||
import info.nightscout.interfaces.profile.ProfileFunction
|
import info.nightscout.interfaces.profile.Instantiator
|
||||||
import info.nightscout.interfaces.profile.ProfileInstantiator
|
|
||||||
import info.nightscout.interfaces.pump.DetailedBolusInfoStorage
|
import info.nightscout.interfaces.pump.DetailedBolusInfoStorage
|
||||||
import info.nightscout.interfaces.pump.PumpSync
|
import info.nightscout.interfaces.pump.PumpSync
|
||||||
import info.nightscout.interfaces.queue.CommandQueue
|
import info.nightscout.interfaces.queue.CommandQueue
|
||||||
|
@ -33,7 +32,6 @@ import org.mockito.kotlin.doNothing
|
||||||
open class DanaRTestBase : TestBase() {
|
open class DanaRTestBase : TestBase() {
|
||||||
|
|
||||||
@Mock lateinit var sp: SP
|
@Mock lateinit var sp: SP
|
||||||
@Mock lateinit var profileFunction: ProfileFunction
|
|
||||||
@Mock lateinit var activePlugin: ActivePlugin
|
@Mock lateinit var activePlugin: ActivePlugin
|
||||||
@Mock lateinit var dateUtil: DateUtil
|
@Mock lateinit var dateUtil: DateUtil
|
||||||
@Mock lateinit var danaRPlugin: DanaRPlugin
|
@Mock lateinit var danaRPlugin: DanaRPlugin
|
||||||
|
@ -46,14 +44,14 @@ open class DanaRTestBase : TestBase() {
|
||||||
@Mock lateinit var constraintChecker: Constraints
|
@Mock lateinit var constraintChecker: Constraints
|
||||||
@Mock lateinit var pumpSync: PumpSync
|
@Mock lateinit var pumpSync: PumpSync
|
||||||
@Mock lateinit var danaHistoryRecordDao: DanaHistoryRecordDao
|
@Mock lateinit var danaHistoryRecordDao: DanaHistoryRecordDao
|
||||||
@Mock lateinit var profileInstantiator: ProfileInstantiator
|
@Mock lateinit var instantiator: Instantiator
|
||||||
@Mock lateinit var uiInteraction: UiInteraction
|
@Mock lateinit var uiInteraction: UiInteraction
|
||||||
|
|
||||||
private lateinit var testPumpPlugin: TestPumpPlugin
|
private lateinit var testPumpPlugin: TestPumpPlugin
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
fun setup() {
|
fun setup() {
|
||||||
danaPump = DanaPump(aapsLogger, sp, dateUtil, profileInstantiator)
|
danaPump = DanaPump(aapsLogger, sp, dateUtil, instantiator)
|
||||||
testPumpPlugin = TestPumpPlugin(injector)
|
testPumpPlugin = TestPumpPlugin(injector)
|
||||||
`when`(activePlugin.activePump).thenReturn(testPumpPlugin)
|
`when`(activePlugin.activePump).thenReturn(testPumpPlugin)
|
||||||
doNothing().`when`(danaRKoreanPlugin).setPluginEnabled(anyObject(), anyBoolean())
|
doNothing().`when`(danaRKoreanPlugin).setPluginEnabled(anyObject(), anyBoolean())
|
||||||
|
|
|
@ -8,14 +8,14 @@ import info.nightscout.interfaces.Constants
|
||||||
import info.nightscout.interfaces.constraints.Constraint
|
import info.nightscout.interfaces.constraints.Constraint
|
||||||
import info.nightscout.interfaces.constraints.Constraints
|
import info.nightscout.interfaces.constraints.Constraints
|
||||||
import info.nightscout.interfaces.plugin.PluginType
|
import info.nightscout.interfaces.plugin.PluginType
|
||||||
import info.nightscout.interfaces.profile.ProfileInstantiator
|
import info.nightscout.interfaces.profile.Instantiator
|
||||||
import info.nightscout.interfaces.pump.PumpSync
|
import info.nightscout.interfaces.pump.PumpSync
|
||||||
import info.nightscout.interfaces.queue.CommandQueue
|
import info.nightscout.interfaces.queue.CommandQueue
|
||||||
import info.nightscout.interfaces.ui.UiInteraction
|
import info.nightscout.interfaces.ui.UiInteraction
|
||||||
import info.nightscout.pump.dana.DanaPump
|
import info.nightscout.pump.dana.DanaPump
|
||||||
import info.nightscout.pump.dana.database.DanaHistoryDatabase
|
import info.nightscout.pump.dana.database.DanaHistoryDatabase
|
||||||
import info.nightscout.shared.sharedPreferences.SP
|
import info.nightscout.shared.sharedPreferences.SP
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
|
@ -27,7 +27,7 @@ class DanaRKoreanPluginTest : TestBaseWithProfile() {
|
||||||
@Mock lateinit var sp: SP
|
@Mock lateinit var sp: SP
|
||||||
@Mock lateinit var commandQueue: CommandQueue
|
@Mock lateinit var commandQueue: CommandQueue
|
||||||
@Mock lateinit var pumpSync: PumpSync
|
@Mock lateinit var pumpSync: PumpSync
|
||||||
@Mock lateinit var profileInstantiator: ProfileInstantiator
|
@Mock lateinit var instantiator: Instantiator
|
||||||
@Mock lateinit var uiInteraction: UiInteraction
|
@Mock lateinit var uiInteraction: UiInteraction
|
||||||
@Mock lateinit var danaHistoryDatabase: DanaHistoryDatabase
|
@Mock lateinit var danaHistoryDatabase: DanaHistoryDatabase
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ class DanaRKoreanPluginTest : TestBaseWithProfile() {
|
||||||
`when`(rh.gs(info.nightscout.core.ui.R.string.itmustbepositivevalue)).thenReturn("it must be positive value")
|
`when`(rh.gs(info.nightscout.core.ui.R.string.itmustbepositivevalue)).thenReturn("it must be positive value")
|
||||||
`when`(rh.gs(info.nightscout.core.ui.R.string.limitingbasalratio)).thenReturn("Limiting max basal rate to %1\$.2f U/h because of %2\$s")
|
`when`(rh.gs(info.nightscout.core.ui.R.string.limitingbasalratio)).thenReturn("Limiting max basal rate to %1\$.2f U/h because of %2\$s")
|
||||||
`when`(rh.gs(info.nightscout.core.ui.R.string.limitingpercentrate)).thenReturn("Limiting max percent rate to %1\$d%% because of %2\$s")
|
`when`(rh.gs(info.nightscout.core.ui.R.string.limitingpercentrate)).thenReturn("Limiting max percent rate to %1\$d%% because of %2\$s")
|
||||||
danaPump = DanaPump(aapsLogger, sp, dateUtil, profileInstantiator)
|
danaPump = DanaPump(aapsLogger, sp, dateUtil, instantiator)
|
||||||
danaRPlugin = DanaRKoreanPlugin(injector, aapsLogger, aapsSchedulers, rxBus, context, rh, constraintChecker, activePluginProvider, sp, commandQueue, danaPump, dateUtil, fabricPrivacy,
|
danaRPlugin = DanaRKoreanPlugin(injector, aapsLogger, aapsSchedulers, rxBus, context, rh, constraintChecker, activePluginProvider, sp, commandQueue, danaPump, dateUtil, fabricPrivacy,
|
||||||
pumpSync, uiInteraction, danaHistoryDatabase)
|
pumpSync, uiInteraction, danaHistoryDatabase)
|
||||||
}
|
}
|
||||||
|
@ -59,9 +59,9 @@ class DanaRKoreanPluginTest : TestBaseWithProfile() {
|
||||||
danaPump.maxBasal = 0.8
|
danaPump.maxBasal = 0.8
|
||||||
val c = Constraint(Constants.REALLYHIGHBASALRATE)
|
val c = Constraint(Constants.REALLYHIGHBASALRATE)
|
||||||
danaRPlugin.applyBasalConstraints(c, validProfile)
|
danaRPlugin.applyBasalConstraints(c, validProfile)
|
||||||
Assert.assertEquals(0.8, c.value(), 0.01)
|
Assertions.assertEquals(0.8, c.value(), 0.01)
|
||||||
Assert.assertEquals("DanaRKorean: Limiting max basal rate to 0.80 U/h because of pump limit", c.getReasons(aapsLogger))
|
Assertions.assertEquals("DanaRKorean: Limiting max basal rate to 0.80 U/h because of pump limit", c.getReasons(aapsLogger))
|
||||||
Assert.assertEquals("DanaRKorean: Limiting max basal rate to 0.80 U/h because of pump limit", c.getMostLimitedReasons(aapsLogger))
|
Assertions.assertEquals("DanaRKorean: Limiting max basal rate to 0.80 U/h because of pump limit", c.getMostLimitedReasons(aapsLogger))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test @Throws(Exception::class)
|
@Test @Throws(Exception::class)
|
||||||
|
@ -71,8 +71,8 @@ class DanaRKoreanPluginTest : TestBaseWithProfile() {
|
||||||
danaPump.maxBasal = 0.8
|
danaPump.maxBasal = 0.8
|
||||||
val c = Constraint(Constants.REALLYHIGHPERCENTBASALRATE)
|
val c = Constraint(Constants.REALLYHIGHPERCENTBASALRATE)
|
||||||
danaRPlugin.applyBasalPercentConstraints(c, validProfile)
|
danaRPlugin.applyBasalPercentConstraints(c, validProfile)
|
||||||
Assert.assertEquals(200, c.value())
|
Assertions.assertEquals(200, c.value())
|
||||||
Assert.assertEquals("DanaRKorean: Limiting max percent rate to 200% because of pump limit", c.getReasons(aapsLogger))
|
Assertions.assertEquals("DanaRKorean: Limiting max percent rate to 200% because of pump limit", c.getReasons(aapsLogger))
|
||||||
Assert.assertEquals("DanaRKorean: Limiting max percent rate to 200% because of pump limit", c.getMostLimitedReasons(aapsLogger))
|
Assertions.assertEquals("DanaRKorean: Limiting max percent rate to 200% because of pump limit", c.getMostLimitedReasons(aapsLogger))
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -8,7 +8,7 @@ import info.nightscout.interfaces.Constants
|
||||||
import info.nightscout.interfaces.constraints.Constraint
|
import info.nightscout.interfaces.constraints.Constraint
|
||||||
import info.nightscout.interfaces.constraints.Constraints
|
import info.nightscout.interfaces.constraints.Constraints
|
||||||
import info.nightscout.interfaces.plugin.PluginType
|
import info.nightscout.interfaces.plugin.PluginType
|
||||||
import info.nightscout.interfaces.profile.ProfileInstantiator
|
import info.nightscout.interfaces.profile.Instantiator
|
||||||
import info.nightscout.interfaces.pump.DetailedBolusInfoStorage
|
import info.nightscout.interfaces.pump.DetailedBolusInfoStorage
|
||||||
import info.nightscout.interfaces.pump.PumpSync
|
import info.nightscout.interfaces.pump.PumpSync
|
||||||
import info.nightscout.interfaces.pump.TemporaryBasalStorage
|
import info.nightscout.interfaces.pump.TemporaryBasalStorage
|
||||||
|
@ -17,6 +17,7 @@ import info.nightscout.interfaces.ui.UiInteraction
|
||||||
import info.nightscout.pump.dana.DanaPump
|
import info.nightscout.pump.dana.DanaPump
|
||||||
import info.nightscout.pump.dana.database.DanaHistoryDatabase
|
import info.nightscout.pump.dana.database.DanaHistoryDatabase
|
||||||
import info.nightscout.shared.sharedPreferences.SP
|
import info.nightscout.shared.sharedPreferences.SP
|
||||||
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
|
@ -30,7 +31,7 @@ class DanaRv2PluginTest : TestBaseWithProfile() {
|
||||||
@Mock lateinit var detailedBolusInfoStorage: DetailedBolusInfoStorage
|
@Mock lateinit var detailedBolusInfoStorage: DetailedBolusInfoStorage
|
||||||
@Mock lateinit var temporaryBasalStorage: TemporaryBasalStorage
|
@Mock lateinit var temporaryBasalStorage: TemporaryBasalStorage
|
||||||
@Mock lateinit var pumpSync: PumpSync
|
@Mock lateinit var pumpSync: PumpSync
|
||||||
@Mock lateinit var profileInstantiator: ProfileInstantiator
|
@Mock lateinit var instantiator: Instantiator
|
||||||
@Mock lateinit var uiInteraction: UiInteraction
|
@Mock lateinit var uiInteraction: UiInteraction
|
||||||
@Mock lateinit var danaHistoryDatabase: DanaHistoryDatabase
|
@Mock lateinit var danaHistoryDatabase: DanaHistoryDatabase
|
||||||
|
|
||||||
|
@ -50,7 +51,7 @@ class DanaRv2PluginTest : TestBaseWithProfile() {
|
||||||
`when`(rh.gs(info.nightscout.core.ui.R.string.itmustbepositivevalue)).thenReturn("it must be positive value")
|
`when`(rh.gs(info.nightscout.core.ui.R.string.itmustbepositivevalue)).thenReturn("it must be positive value")
|
||||||
`when`(rh.gs(info.nightscout.core.ui.R.string.limitingbasalratio)).thenReturn("Limiting max basal rate to %1\$.2f U/h because of %2\$s")
|
`when`(rh.gs(info.nightscout.core.ui.R.string.limitingbasalratio)).thenReturn("Limiting max basal rate to %1\$.2f U/h because of %2\$s")
|
||||||
`when`(rh.gs(info.nightscout.core.ui.R.string.limitingpercentrate)).thenReturn("Limiting max percent rate to %1\$d%% because of %2\$s")
|
`when`(rh.gs(info.nightscout.core.ui.R.string.limitingpercentrate)).thenReturn("Limiting max percent rate to %1\$d%% because of %2\$s")
|
||||||
danaPump = DanaPump(aapsLogger, sp, dateUtil, profileInstantiator)
|
danaPump = DanaPump(aapsLogger, sp, dateUtil, instantiator)
|
||||||
danaRv2Plugin = DanaRv2Plugin(
|
danaRv2Plugin = DanaRv2Plugin(
|
||||||
injector, aapsLogger, aapsSchedulers, rxBus, context, rh, constraintChecker, activePluginProvider, sp, commandQueue, danaPump, detailedBolusInfoStorage,
|
injector, aapsLogger, aapsSchedulers, rxBus, context, rh, constraintChecker, activePluginProvider, sp, commandQueue, danaPump, detailedBolusInfoStorage,
|
||||||
temporaryBasalStorage, dateUtil, fabricPrivacy, pumpSync, uiInteraction, danaHistoryDatabase
|
temporaryBasalStorage, dateUtil, fabricPrivacy, pumpSync, uiInteraction, danaHistoryDatabase
|
||||||
|
@ -64,9 +65,9 @@ class DanaRv2PluginTest : TestBaseWithProfile() {
|
||||||
danaPump.maxBasal = 0.8
|
danaPump.maxBasal = 0.8
|
||||||
val c = Constraint(Constants.REALLYHIGHBASALRATE)
|
val c = Constraint(Constants.REALLYHIGHBASALRATE)
|
||||||
danaRv2Plugin.applyBasalConstraints(c, validProfile)
|
danaRv2Plugin.applyBasalConstraints(c, validProfile)
|
||||||
org.junit.Assert.assertEquals(0.8, c.value(), 0.01)
|
Assertions.assertEquals(0.8, c.value(), 0.01)
|
||||||
org.junit.Assert.assertEquals("DanaRv2: Limiting max basal rate to 0.80 U/h because of pump limit", c.getReasons(aapsLogger))
|
Assertions.assertEquals("DanaRv2: Limiting max basal rate to 0.80 U/h because of pump limit", c.getReasons(aapsLogger))
|
||||||
org.junit.Assert.assertEquals("DanaRv2: Limiting max basal rate to 0.80 U/h because of pump limit", c.getMostLimitedReasons(aapsLogger))
|
Assertions.assertEquals("DanaRv2: Limiting max basal rate to 0.80 U/h because of pump limit", c.getMostLimitedReasons(aapsLogger))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -76,8 +77,8 @@ class DanaRv2PluginTest : TestBaseWithProfile() {
|
||||||
danaPump.maxBasal = 0.8
|
danaPump.maxBasal = 0.8
|
||||||
val c = Constraint(Constants.REALLYHIGHPERCENTBASALRATE)
|
val c = Constraint(Constants.REALLYHIGHPERCENTBASALRATE)
|
||||||
danaRv2Plugin.applyBasalPercentConstraints(c, validProfile)
|
danaRv2Plugin.applyBasalPercentConstraints(c, validProfile)
|
||||||
org.junit.Assert.assertEquals(200, c.value())
|
Assertions.assertEquals(200, c.value())
|
||||||
org.junit.Assert.assertEquals("DanaRv2: Limiting max percent rate to 200% because of pump limit", c.getReasons(aapsLogger))
|
Assertions.assertEquals("DanaRv2: Limiting max percent rate to 200% because of pump limit", c.getReasons(aapsLogger))
|
||||||
org.junit.Assert.assertEquals("DanaRv2: Limiting max percent rate to 200% because of pump limit", c.getMostLimitedReasons(aapsLogger))
|
Assertions.assertEquals("DanaRv2: Limiting max percent rate to 200% because of pump limit", c.getMostLimitedReasons(aapsLogger))
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,9 +1,7 @@
|
||||||
package info.nightscout.pump.danars
|
package info.nightscout.pump.danars
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
|
||||||
import dagger.android.HasAndroidInjector
|
|
||||||
import info.nightscout.androidaps.TestBaseWithProfile
|
import info.nightscout.androidaps.TestBaseWithProfile
|
||||||
import info.nightscout.interfaces.profile.ProfileInstantiator
|
import info.nightscout.interfaces.profile.Instantiator
|
||||||
import info.nightscout.interfaces.ui.UiInteraction
|
import info.nightscout.interfaces.ui.UiInteraction
|
||||||
import info.nightscout.pump.dana.DanaPump
|
import info.nightscout.pump.dana.DanaPump
|
||||||
import info.nightscout.pump.danars.comm.DanaRSPacket
|
import info.nightscout.pump.danars.comm.DanaRSPacket
|
||||||
|
@ -16,11 +14,9 @@ import org.mockito.Mockito
|
||||||
open class DanaRSTestBase : TestBaseWithProfile() {
|
open class DanaRSTestBase : TestBaseWithProfile() {
|
||||||
|
|
||||||
@Mock lateinit var sp: SP
|
@Mock lateinit var sp: SP
|
||||||
@Mock lateinit var profileInstantiator: ProfileInstantiator
|
@Mock lateinit var instantiator: Instantiator
|
||||||
@Mock lateinit var uiInteraction: UiInteraction
|
@Mock lateinit var uiInteraction: UiInteraction
|
||||||
|
|
||||||
val injector = HasAndroidInjector { AndroidInjector { } }
|
|
||||||
|
|
||||||
lateinit var danaPump: DanaPump
|
lateinit var danaPump: DanaPump
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
|
@ -58,6 +54,6 @@ open class DanaRSTestBase : TestBaseWithProfile() {
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
fun setup() {
|
fun setup() {
|
||||||
danaPump = DanaPump(aapsLogger, sp, dateUtil, profileInstantiator)
|
danaPump = DanaPump(aapsLogger, sp, dateUtil, instantiator)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -19,6 +19,7 @@ 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.plugin.ActivePlugin
|
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||||
|
import info.nightscout.interfaces.profile.Instantiator
|
||||||
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
|
||||||
|
@ -56,6 +57,7 @@ class IobCobOref1Worker(
|
||||||
@Inject lateinit var dateUtil: DateUtil
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
@Inject lateinit var repository: AppRepository
|
@Inject lateinit var repository: AppRepository
|
||||||
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
|
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
|
||||||
|
@Inject lateinit var instantiator: Instantiator
|
||||||
|
|
||||||
class IobCobOref1WorkerData(
|
class IobCobOref1WorkerData(
|
||||||
val injector: HasAndroidInjector,
|
val injector: HasAndroidInjector,
|
||||||
|
@ -114,7 +116,7 @@ class IobCobOref1Worker(
|
||||||
}
|
}
|
||||||
aapsLogger.debug(LTag.AUTOSENS, "Processing calculation thread: ${data.reason} ($i/${bucketedData.size})")
|
aapsLogger.debug(LTag.AUTOSENS, "Processing calculation thread: ${data.reason} ($i/${bucketedData.size})")
|
||||||
val sens = profile.getIsfMgdl(bgTime)
|
val sens = profile.getIsfMgdl(bgTime)
|
||||||
val autosensData = data.iobCobCalculator.provideEmptyAutosensDataObject()
|
val autosensData = instantiator.provideAutosensDataObject()
|
||||||
autosensData.time = bgTime
|
autosensData.time = bgTime
|
||||||
if (previous != null) autosensData.activeCarbsList = previous.cloneCarbsList() else autosensData.activeCarbsList = ArrayList()
|
if (previous != null) autosensData.activeCarbsList = previous.cloneCarbsList() else autosensData.activeCarbsList = ArrayList()
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ 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.plugin.ActivePlugin
|
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||||
|
import info.nightscout.interfaces.profile.Instantiator
|
||||||
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
|
||||||
|
@ -52,6 +53,7 @@ class IobCobOrefWorker @Inject internal constructor(
|
||||||
@Inject lateinit var dateUtil: DateUtil
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
@Inject lateinit var repository: AppRepository
|
@Inject lateinit var repository: AppRepository
|
||||||
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
|
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
|
||||||
|
@Inject lateinit var instantiator: Instantiator
|
||||||
|
|
||||||
class IobCobOrefWorkerData(
|
class IobCobOrefWorkerData(
|
||||||
val injector: HasAndroidInjector,
|
val injector: HasAndroidInjector,
|
||||||
|
@ -109,7 +111,7 @@ class IobCobOrefWorker @Inject internal constructor(
|
||||||
}
|
}
|
||||||
aapsLogger.debug(LTag.AUTOSENS, "Processing calculation thread: ${data.reason} ($i/${bucketedData.size})")
|
aapsLogger.debug(LTag.AUTOSENS, "Processing calculation thread: ${data.reason} ($i/${bucketedData.size})")
|
||||||
val sens = profile.getIsfMgdl(bgTime)
|
val sens = profile.getIsfMgdl(bgTime)
|
||||||
val autosensData = data.iobCobCalculator.provideEmptyAutosensDataObject()
|
val autosensData = instantiator.provideAutosensDataObject()
|
||||||
autosensData.time = bgTime
|
autosensData.time = bgTime
|
||||||
if (previous != null) autosensData.activeCarbsList = previous.cloneCarbsList() else autosensData.activeCarbsList = ArrayList()
|
if (previous != null) autosensData.activeCarbsList = previous.cloneCarbsList() else autosensData.activeCarbsList = ArrayList()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue