TemporaryBasalStorage interface

This commit is contained in:
Milos Kozak 2022-11-23 15:53:57 +01:00
parent 8e8fbf1b6f
commit 37f9a942b2
21 changed files with 53 additions and 38 deletions

View file

@ -15,7 +15,7 @@ import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProv
import info.nightscout.androidaps.plugins.pump.combo.ComboPlugin
import info.nightscout.androidaps.plugins.pump.combo.ruffyscripter.RuffyScripter
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.TemporaryBasalStorage
import info.nightscout.interfaces.pump.TemporaryBasalStorage
import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin
import info.nightscout.database.impl.AppRepository
import info.nightscout.implementation.constraints.ConstraintsImpl

View file

@ -1,11 +1,11 @@
package info.nightscout.androidaps.plugins.iob.iobCalculator
import info.nightscout.androidaps.TestBase
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensDataStoreObject
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
import info.nightscout.core.iob.asRounded
import info.nightscout.core.iob.log
import info.nightscout.database.entities.GlucoseValue
import info.nightscout.interfaces.aps.AutosensDataStore
import info.nightscout.interfaces.iob.GlucoseStatus
import info.nightscout.interfaces.iob.IobCobCalculator
import info.nightscout.shared.utils.DateUtil
@ -24,7 +24,7 @@ class GlucoseStatusTest : TestBase() {
@Mock lateinit var dateUtil: DateUtil
@Mock lateinit var iobCobCalculatorPlugin: IobCobCalculator
@Mock lateinit var autosensDataStore: AutosensDataStoreObject
@Mock lateinit var autosensDataStore: AutosensDataStore
@Before
fun prepare() {

View file

@ -5,9 +5,9 @@ import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.TestBase
import info.nightscout.androidaps.TestPumpPlugin
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensDataStoreObject
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.aps.AutosensDataStore
import info.nightscout.interfaces.aps.Loop
import info.nightscout.interfaces.constraints.Constraint
import info.nightscout.interfaces.constraints.Constraints
@ -41,7 +41,7 @@ class BolusWizardTest : TestBase() {
@Mock lateinit var loop: Loop
@Mock lateinit var iobCobCalculator: IobCobCalculator
@Mock lateinit var dateUtil: DateUtil
@Mock lateinit var autosensDataStore: AutosensDataStoreObject
@Mock lateinit var autosensDataStore: AutosensDataStore
val injector = HasAndroidInjector {
AndroidInjector {

View file

@ -5,6 +5,7 @@ import dagger.Binds
import dagger.Lazy
import dagger.Module
import dagger.Provides
import dagger.Reusable
import info.nightscout.androidaps.plugins.general.maintenance.formats.EncryptedPrefsFormat
import info.nightscout.core.graph.OverviewData
import info.nightscout.core.utils.CryptoUtil
@ -29,6 +30,7 @@ import info.nightscout.implementation.profiling.ProfilerImpl
import info.nightscout.implementation.protection.PasswordCheckImpl
import info.nightscout.implementation.protection.ProtectionCheckImpl
import info.nightscout.implementation.pump.PumpSyncImplementation
import info.nightscout.implementation.pump.TemporaryBasalStorageImpl
import info.nightscout.implementation.pump.WarnColorsImpl
import info.nightscout.implementation.queue.CommandQueueImplementation
import info.nightscout.implementation.resources.IconsProviderImplementation
@ -54,6 +56,7 @@ import info.nightscout.interfaces.profiling.Profiler
import info.nightscout.interfaces.protection.PasswordCheck
import info.nightscout.interfaces.protection.ProtectionCheck
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.pump.TemporaryBasalStorage
import info.nightscout.interfaces.pump.WarnColors
import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.stats.DexcomTirCalculator
@ -95,7 +98,7 @@ open class ImplementationModule {
fun provideWarnColors(rh: ResourceHelper): WarnColors = WarnColorsImpl(rh)
@Provides
@Singleton
@Reusable
fun provideProfiler(aapsLogger: AAPSLogger): Profiler = ProfilerImpl(aapsLogger)
@Provides
@ -103,23 +106,27 @@ open class ImplementationModule {
fun provideLoggerUtils(prefFileListProvider: PrefFileListProvider): LoggerUtils = LoggerUtilsImpl(prefFileListProvider)
@Provides
@Singleton
@Reusable
fun providePasswordCheck(sp: SP, cryptoUtil: CryptoUtil): PasswordCheck = PasswordCheckImpl(sp, cryptoUtil)
@Provides
@Singleton
@Reusable
fun provideProtectionCheck(sp: SP, passwordCheck: PasswordCheck, dateUtil: DateUtil): ProtectionCheck = ProtectionCheckImpl(sp, passwordCheck, dateUtil)
@Provides
@Singleton
@Reusable
fun provideDefaultValueHelper(sp: SP, profileFunction: ProfileFunction): DefaultValueHelper = DefaultValueHelperImpl(sp, profileFunction)
@Provides
@Singleton
@Reusable
fun provideTranslator(rh: ResourceHelper): Translator = TranslatorImpl(rh)
@Provides
@Singleton
fun provideTemporaryBasalStorage(aapsLogger: AAPSLogger): TemporaryBasalStorage = TemporaryBasalStorageImpl(aapsLogger)
@Provides
@Reusable
fun provideUserEntryLogger(
aapsLogger: AAPSLogger,
repository: AppRepository,
@ -141,7 +148,7 @@ open class ImplementationModule {
): OverviewData = OverviewDataImpl(aapsLogger, rh, dateUtil, sp, activePlugin, defaultValueHelper, profileFunction, repository)
@Provides
@Singleton
@Reusable
fun providePrefFileListProvider(
rh: ResourceHelper,
config: Lazy<Config>,

View file

@ -1,6 +1,7 @@
package info.nightscout.androidaps.plugins.pump.common.bolusInfo
package info.nightscout.implementation.pump
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.interfaces.pump.TemporaryBasalStorage
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag
@ -11,20 +12,20 @@ import kotlin.math.abs
@OpenForTesting
@Singleton
class TemporaryBasalStorage @Inject constructor(
class TemporaryBasalStorageImpl @Inject constructor(
val aapsLogger: AAPSLogger
) {
) : TemporaryBasalStorage {
val store = ArrayList<PumpSync.PumpState.TemporaryBasal>()
@Synchronized
fun add(temporaryBasal: PumpSync.PumpState.TemporaryBasal) {
override fun add(temporaryBasal: PumpSync.PumpState.TemporaryBasal) {
aapsLogger.debug("Stored temporary basal info: $temporaryBasal")
store.add(temporaryBasal)
}
@Synchronized
fun findTemporaryBasal(time: Long, rate: Double): PumpSync.PumpState.TemporaryBasal? {
override fun findTemporaryBasal(time: Long, rate: Double): PumpSync.PumpState.TemporaryBasal? {
// Look for info with temporary basal
for (i in store.indices) {
val d = store[i]

View file

@ -1,7 +1,7 @@
package info.nightscout.androidaps.pump.bolusInfo
package info.nightscout.implementation.pump
import info.nightscout.androidaps.TestBase
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.TemporaryBasalStorage
import info.nightscout.interfaces.pump.TemporaryBasalStorage
import info.nightscout.interfaces.pump.PumpSync
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
@ -14,11 +14,11 @@ class TemporaryBasalStorageTest : TestBase() {
private val info2 = PumpSync.PumpState.TemporaryBasal(1000001, 1000, 4.0, false, PumpSync.TemporaryBasalType.NORMAL, 0L, 0L)
private val info3 = PumpSync.PumpState.TemporaryBasal(2000000, 1000, 5.0, false, PumpSync.TemporaryBasalType.NORMAL, 0L, 0L)
private lateinit var temporaryBasalStorage: TemporaryBasalStorage
private lateinit var temporaryBasalStorage: TemporaryBasalStorageImpl
@Before
fun prepare() {
temporaryBasalStorage = TemporaryBasalStorage(aapsLogger)
temporaryBasalStorage = TemporaryBasalStorageImpl(aapsLogger)
}
private fun setUp() {

View file

@ -0,0 +1,7 @@
package info.nightscout.interfaces.pump
interface TemporaryBasalStorage {
fun add(temporaryBasal: PumpSync.PumpState.TemporaryBasal)
fun findTemporaryBasal(time: Long, rate: Double): PumpSync.PumpState.TemporaryBasal?
}

View file

@ -5,11 +5,11 @@ import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.TestBaseWithProfile
import info.nightscout.androidaps.TestPumpPlugin
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensDataStoreObject
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
import info.nightscout.core.utils.receivers.ReceiverStatusStore
import info.nightscout.automation.AutomationPlugin
import info.nightscout.automation.services.LastLocationDataContainer
import info.nightscout.core.utils.receivers.ReceiverStatusStore
import info.nightscout.interfaces.aps.AutosensDataStore
import info.nightscout.interfaces.iob.IobCobCalculator
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.plugin.PluginDescription
@ -25,7 +25,7 @@ open class TriggerTestBase : TestBaseWithProfile() {
@Mock lateinit var locationDataContainer: LastLocationDataContainer
@Mock lateinit var activePlugin: ActivePlugin
@Mock lateinit var iobCobCalculator: IobCobCalculator
@Mock lateinit var autosensDataStore: AutosensDataStoreObject
@Mock lateinit var autosensDataStore: AutosensDataStore
@Mock lateinit var context: Context
@Mock lateinit var automationPlugin: AutomationPlugin

View file

@ -5,8 +5,6 @@ import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.TestBaseWithProfile
import info.nightscout.androidaps.TestPumpPlugin
import info.nightscout.interfaces.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensDataStoreObject
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
import info.nightscout.database.entities.GlucoseValue
import info.nightscout.database.impl.AppRepository
@ -17,11 +15,13 @@ import info.nightscout.database.impl.transactions.Transaction
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.XDripBroadcast
import info.nightscout.interfaces.aps.AutosensDataStore
import info.nightscout.interfaces.aps.Loop
import info.nightscout.interfaces.constraints.Constraint
import info.nightscout.interfaces.constraints.Constraints
import info.nightscout.interfaces.iob.CobInfo
import info.nightscout.interfaces.iob.IobTotal
import info.nightscout.interfaces.logging.UserEntryLogger
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.profile.ProfileSource
@ -65,7 +65,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
@Mock lateinit var uel: UserEntryLogger
@Mock lateinit var repository: AppRepository
@Mock lateinit var dateUtilMocked: DateUtil
@Mock lateinit var autosensDataStore: AutosensDataStoreObject
@Mock lateinit var autosensDataStore: AutosensDataStore
@Mock lateinit var smsManager: SmsManager
var injector: HasAndroidInjector = HasAndroidInjector {

View file

@ -17,7 +17,7 @@ import info.nightscout.androidaps.danaRv2.services.DanaRv2ExecutionService;
import info.nightscout.androidaps.danar.AbstractDanaRPlugin;
import info.nightscout.androidaps.danar.R;
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage;
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.TemporaryBasalStorage;
import info.nightscout.interfaces.pump.TemporaryBasalStorage;
import info.nightscout.core.utils.fabric.FabricPrivacy;
import info.nightscout.interfaces.constraints.Constraint;
import info.nightscout.interfaces.constraints.Constraints;

View file

@ -8,7 +8,7 @@ import info.nightscout.androidaps.danaRv2.DanaRv2Plugin
import info.nightscout.androidaps.danar.DanaRPlugin
import info.nightscout.androidaps.danar.comm.MessageOriginalNames.getName
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.TemporaryBasalStorage
import info.nightscout.interfaces.pump.TemporaryBasalStorage
import info.nightscout.androidaps.utils.CRC.getCrc16
import info.nightscout.interfaces.ConfigBuilder
import info.nightscout.interfaces.constraints.Constraints

View file

@ -11,7 +11,7 @@ import org.mockito.Mockito.`when`
class MsgBolusProgressTest : DanaRTestBase() {
@Test fun runTest() {
`when`(rh.gs(ArgumentMatchers.eq(R.string.bolusdelivering), ArgumentMatchers.anyDouble())).thenReturn("Delivering %1\$.2fU")
`when`(rh.gs(ArgumentMatchers.eq(R.string.bolus_delivering), ArgumentMatchers.anyDouble())).thenReturn("Delivering %1\$.2fU")
danaPump.bolusingTreatment = EventOverviewBolusProgress.Treatment(0.0, 0, true, 0)
danaPump.bolusAmountToBeDelivered = 3.0
val packet = MsgBolusProgress(injector)

View file

@ -7,7 +7,7 @@ import info.nightscout.androidaps.dana.DanaPump
import info.nightscout.androidaps.danaRv2.DanaRv2Plugin
import info.nightscout.androidaps.danar.R
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.TemporaryBasalStorage
import info.nightscout.interfaces.pump.TemporaryBasalStorage
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.constraints.Constraint
import info.nightscout.interfaces.constraints.Constraints

View file

@ -14,7 +14,7 @@ import info.nightscout.androidaps.dana.comm.RecordTypes
import info.nightscout.androidaps.danars.events.EventDanaRSDeviceChange
import info.nightscout.androidaps.danars.services.DanaRSService
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.TemporaryBasalStorage
import info.nightscout.interfaces.pump.TemporaryBasalStorage
import info.nightscout.core.events.EventNewNotification
import info.nightscout.core.pump.convertedToAbsolute
import info.nightscout.core.pump.plannedRemainingMinutes

View file

@ -5,7 +5,7 @@ import info.nightscout.androidaps.dana.DanaPump
import info.nightscout.androidaps.danars.R
import info.nightscout.androidaps.danars.encryption.BleEncryption
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.TemporaryBasalStorage
import info.nightscout.interfaces.pump.TemporaryBasalStorage
import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.rx.bus.RxBus

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.danars
import android.content.Context
import dagger.android.AndroidInjector
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.TemporaryBasalStorage
import info.nightscout.interfaces.pump.TemporaryBasalStorage
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.constraints.Constraint
import info.nightscout.interfaces.constraints.Constraints

View file

@ -5,7 +5,7 @@ import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.danars.DanaRSTestBase
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.TemporaryBasalStorage
import info.nightscout.interfaces.pump.TemporaryBasalStorage
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.pump.PumpSync
import org.junit.Assert

View file

@ -6,7 +6,7 @@ import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.danars.DanaRSPlugin
import info.nightscout.androidaps.danars.DanaRSTestBase
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.TemporaryBasalStorage
import info.nightscout.interfaces.pump.TemporaryBasalStorage
import info.nightscout.interfaces.constraints.Constraint
import info.nightscout.interfaces.constraints.Constraints
import info.nightscout.interfaces.pump.PumpSync

View file

@ -6,7 +6,7 @@ import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.danars.DanaRSPlugin
import info.nightscout.androidaps.danars.DanaRSTestBase
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.TemporaryBasalStorage
import info.nightscout.interfaces.pump.TemporaryBasalStorage
import info.nightscout.interfaces.constraints.Constraints
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.pump.PumpSync

View file

@ -12,7 +12,7 @@ import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.diaconn.events.EventDiaconnG8DeviceChange
import info.nightscout.androidaps.diaconn.service.DiaconnG8Service
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.TemporaryBasalStorage
import info.nightscout.interfaces.pump.TemporaryBasalStorage
import info.nightscout.core.events.EventNewNotification
import info.nightscout.core.pump.convertedToAbsolute
import info.nightscout.core.pump.plannedRemainingMinutes

View file

@ -39,7 +39,7 @@ import info.nightscout.androidaps.diaconn.pumplog.LOG_TB_START_V3
import info.nightscout.androidaps.diaconn.pumplog.LOG_TB_STOP_V3
import info.nightscout.androidaps.diaconn.pumplog.PumplogUtil
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.TemporaryBasalStorage
import info.nightscout.interfaces.pump.TemporaryBasalStorage
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.pump.PumpSync