DetailedBolusInfoStorage interface

This commit is contained in:
Milos Kozak 2022-11-23 16:02:54 +01:00
parent 37f9a942b2
commit d444979603
18 changed files with 49 additions and 36 deletions

View file

@ -14,8 +14,6 @@ import info.nightscout.androidaps.insight.database.InsightDbHelper
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
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.interfaces.pump.TemporaryBasalStorage
import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin
import info.nightscout.database.impl.AppRepository
import info.nightscout.implementation.constraints.ConstraintsImpl
@ -27,8 +25,10 @@ import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.profiling.Profiler
import info.nightscout.interfaces.pump.DetailedBolusInfoStorage
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.pump.TemporaryBasalStorage
import info.nightscout.interfaces.pump.defs.PumpDescription
import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.utils.HardLimits

View file

@ -29,6 +29,7 @@ import info.nightscout.implementation.overview.OverviewDataImpl
import info.nightscout.implementation.profiling.ProfilerImpl
import info.nightscout.implementation.protection.PasswordCheckImpl
import info.nightscout.implementation.protection.ProtectionCheckImpl
import info.nightscout.implementation.pump.DetailedBolusInfoStorageImpl
import info.nightscout.implementation.pump.PumpSyncImplementation
import info.nightscout.implementation.pump.TemporaryBasalStorageImpl
import info.nightscout.implementation.pump.WarnColorsImpl
@ -55,6 +56,7 @@ import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.profiling.Profiler
import info.nightscout.interfaces.protection.PasswordCheck
import info.nightscout.interfaces.protection.ProtectionCheck
import info.nightscout.interfaces.pump.DetailedBolusInfoStorage
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.pump.TemporaryBasalStorage
import info.nightscout.interfaces.pump.WarnColors
@ -125,6 +127,10 @@ open class ImplementationModule {
@Singleton
fun provideTemporaryBasalStorage(aapsLogger: AAPSLogger): TemporaryBasalStorage = TemporaryBasalStorageImpl(aapsLogger)
@Provides
@Singleton
fun provideDetailedBolusInfoStorage(aapsLogger: AAPSLogger): DetailedBolusInfoStorage = DetailedBolusInfoStorageImpl(aapsLogger)
@Provides
@Reusable
fun provideUserEntryLogger(

View file

@ -1,31 +1,32 @@
package info.nightscout.androidaps.plugins.pump.common.bolusInfo
package info.nightscout.implementation.pump
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.core.pump.toJsonString
import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.shared.utils.T
import info.nightscout.interfaces.pump.DetailedBolusInfoStorage
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.utils.T
import javax.inject.Inject
import javax.inject.Singleton
import kotlin.math.abs
@OpenForTesting
@Singleton
class DetailedBolusInfoStorage @Inject constructor(
class DetailedBolusInfoStorageImpl @Inject constructor(
val aapsLogger: AAPSLogger
) {
) : DetailedBolusInfoStorage {
val store = ArrayList<DetailedBolusInfo>()
@Synchronized
fun add(detailedBolusInfo: DetailedBolusInfo) {
override fun add(detailedBolusInfo: DetailedBolusInfo) {
aapsLogger.debug("Stored bolus info: ${detailedBolusInfo.toJsonString()}")
store.add(detailedBolusInfo)
}
@Synchronized
fun findDetailedBolusInfo(bolusTime: Long, bolus: Double): DetailedBolusInfo? {
override fun findDetailedBolusInfo(bolusTime: Long, bolus: Double): DetailedBolusInfo? {
// Look for info with bolus
for (i in store.indices) {
val d = store[i]

View file

@ -1,8 +1,7 @@
package info.nightscout.androidaps.pump.bolusInfo
package info.nightscout.implementation.pump
import info.nightscout.androidaps.TestBase
import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Before
@ -14,7 +13,7 @@ class DetailedBolusInfoStorageTest : TestBase() {
private val info2 = DetailedBolusInfo()
private val info3 = DetailedBolusInfo()
private lateinit var detailedBolusInfoStorage: DetailedBolusInfoStorage
private lateinit var detailedBolusInfoStorage: DetailedBolusInfoStorageImpl
init {
info1.timestamp = 1000000
@ -27,7 +26,7 @@ class DetailedBolusInfoStorageTest : TestBase() {
@Before
fun prepare() {
detailedBolusInfoStorage = DetailedBolusInfoStorage(aapsLogger)
detailedBolusInfoStorage = DetailedBolusInfoStorageImpl(aapsLogger)
}
private fun setUp() {

View file

@ -0,0 +1,7 @@
package info.nightscout.interfaces.pump
interface DetailedBolusInfoStorage {
fun add(detailedBolusInfo: DetailedBolusInfo)
fun findDetailedBolusInfo(bolusTime: Long, bolus: Double): DetailedBolusInfo?
}

View file

@ -16,16 +16,16 @@ import info.nightscout.androidaps.dana.DanaPump;
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.interfaces.pump.TemporaryBasalStorage;
import info.nightscout.core.utils.fabric.FabricPrivacy;
import info.nightscout.interfaces.constraints.Constraint;
import info.nightscout.interfaces.constraints.Constraints;
import info.nightscout.interfaces.plugin.ActivePlugin;
import info.nightscout.interfaces.profile.Profile;
import info.nightscout.interfaces.pump.DetailedBolusInfo;
import info.nightscout.interfaces.pump.DetailedBolusInfoStorage;
import info.nightscout.interfaces.pump.PumpEnactResult;
import info.nightscout.interfaces.pump.PumpSync;
import info.nightscout.interfaces.pump.TemporaryBasalStorage;
import info.nightscout.interfaces.pump.defs.PumpType;
import info.nightscout.interfaces.queue.CommandQueue;
import info.nightscout.interfaces.utils.Round;

View file

@ -7,13 +7,13 @@ import info.nightscout.androidaps.danaRKorean.DanaRKoreanPlugin
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.interfaces.pump.TemporaryBasalStorage
import info.nightscout.androidaps.utils.CRC.getCrc16
import info.nightscout.interfaces.ConfigBuilder
import info.nightscout.interfaces.constraints.Constraints
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.pump.DetailedBolusInfoStorage
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.pump.TemporaryBasalStorage
import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.logging.AAPSLogger

View file

@ -10,11 +10,11 @@ import info.nightscout.androidaps.danaRKorean.DanaRKoreanPlugin
import info.nightscout.androidaps.danaRv2.DanaRv2Plugin
import info.nightscout.androidaps.danar.DanaRPlugin
import info.nightscout.androidaps.danar.comm.MessageBase
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage
import info.nightscout.interfaces.ConfigBuilder
import info.nightscout.interfaces.constraints.Constraints
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.pump.DetailedBolusInfoStorage
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.rx.bus.RxBus

View file

@ -6,13 +6,13 @@ import info.nightscout.androidaps.TestBaseWithProfile
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.interfaces.pump.TemporaryBasalStorage
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.constraints.Constraint
import info.nightscout.interfaces.constraints.Constraints
import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.pump.DetailedBolusInfoStorage
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.pump.TemporaryBasalStorage
import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.shared.sharedPreferences.SP
import org.junit.Before

View file

@ -13,8 +13,6 @@ import info.nightscout.androidaps.dana.DanaPump
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.interfaces.pump.TemporaryBasalStorage
import info.nightscout.core.events.EventNewNotification
import info.nightscout.core.pump.convertedToAbsolute
import info.nightscout.core.pump.plannedRemainingMinutes
@ -29,10 +27,12 @@ import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.pump.Dana
import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.pump.DetailedBolusInfoStorage
import info.nightscout.interfaces.pump.Pump
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.pump.PumpPluginBase
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.pump.TemporaryBasalStorage
import info.nightscout.interfaces.pump.defs.ManufacturerType
import info.nightscout.interfaces.pump.defs.PumpDescription
import info.nightscout.interfaces.pump.defs.PumpType

View file

@ -4,10 +4,10 @@ import dagger.android.HasAndroidInjector
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.interfaces.pump.TemporaryBasalStorage
import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.pump.DetailedBolusInfoStorage
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.pump.TemporaryBasalStorage
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventPumpStatusChanged
import info.nightscout.rx.logging.LTag

View file

@ -2,13 +2,13 @@ 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.interfaces.pump.TemporaryBasalStorage
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.constraints.Constraint
import info.nightscout.interfaces.constraints.Constraints
import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.pump.DetailedBolusInfoStorage
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.pump.TemporaryBasalStorage
import info.nightscout.interfaces.queue.CommandQueue
import org.junit.Assert
import org.junit.Before

View file

@ -4,10 +4,10 @@ import android.content.Context
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.interfaces.pump.TemporaryBasalStorage
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.pump.DetailedBolusInfoStorage
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.pump.TemporaryBasalStorage
import org.junit.Assert
import org.junit.Test
import org.mockito.Mock

View file

@ -5,11 +5,11 @@ import dagger.android.AndroidInjector
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.interfaces.pump.TemporaryBasalStorage
import info.nightscout.interfaces.constraints.Constraint
import info.nightscout.interfaces.constraints.Constraints
import info.nightscout.interfaces.pump.DetailedBolusInfoStorage
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.pump.TemporaryBasalStorage
import info.nightscout.interfaces.queue.CommandQueue
import org.junit.Assert
import org.junit.Before

View file

@ -5,11 +5,11 @@ import dagger.android.AndroidInjector
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.interfaces.pump.TemporaryBasalStorage
import info.nightscout.interfaces.constraints.Constraints
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.pump.DetailedBolusInfoStorage
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.pump.TemporaryBasalStorage
import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.rx.events.EventOverviewBolusProgress
import org.junit.Assert

View file

@ -11,8 +11,6 @@ import androidx.preference.PreferenceFragmentCompat
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.interfaces.pump.TemporaryBasalStorage
import info.nightscout.core.events.EventNewNotification
import info.nightscout.core.pump.convertedToAbsolute
import info.nightscout.core.pump.plannedRemainingMinutes
@ -26,11 +24,13 @@ import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.pump.DetailedBolusInfoStorage
import info.nightscout.interfaces.pump.Diaconn
import info.nightscout.interfaces.pump.Pump
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.pump.PumpPluginBase
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.pump.TemporaryBasalStorage
import info.nightscout.interfaces.pump.actions.CustomAction
import info.nightscout.interfaces.pump.actions.CustomActionType
import info.nightscout.interfaces.pump.defs.ManufacturerType

View file

@ -38,11 +38,11 @@ import info.nightscout.androidaps.diaconn.pumplog.LOG_SUSPEND_V2
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.interfaces.pump.TemporaryBasalStorage
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.pump.DetailedBolusInfoStorage
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.pump.TemporaryBasalStorage
import info.nightscout.interfaces.pump.defs.PumpDescription
import info.nightscout.interfaces.pump.defs.PumpType
import info.nightscout.rx.bus.RxBus

View file

@ -44,7 +44,6 @@ import info.nightscout.androidaps.diaconn.packet.TempBasalSettingPacket
import info.nightscout.androidaps.diaconn.packet.TimeInquirePacket
import info.nightscout.androidaps.diaconn.packet.TimeSettingPacket
import info.nightscout.androidaps.diaconn.pumplog.PumplogUtil
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage
import info.nightscout.core.events.EventNewNotification
import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.interfaces.Constants
@ -54,6 +53,7 @@ import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.pump.BolusProgressData
import info.nightscout.interfaces.pump.DetailedBolusInfoStorage
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.pump.defs.PumpType