move to interfaces

This commit is contained in:
Milos Kozak 2022-11-10 19:27:04 +01:00
parent c31bfc7c23
commit 73f876a45d
221 changed files with 971 additions and 771 deletions

View file

@ -23,7 +23,6 @@ import info.nightscout.androidaps.danar.DanaRPlugin
import info.nightscout.androidaps.danars.DanaRSPlugin
import info.nightscout.androidaps.diaconn.DiaconnG8Plugin
import info.nightscout.androidaps.events.EventPreferenceChange
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.plugin.general.openhumans.OpenHumansUploader
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
@ -56,8 +55,10 @@ import info.nightscout.androidaps.utils.protection.ProtectionCheck.ProtectionTyp
import info.nightscout.androidaps.utils.protection.ProtectionCheck.ProtectionType.CUSTOM_PIN
import info.nightscout.androidaps.utils.protection.ProtectionCheck.ProtectionType.NONE
import info.nightscout.automation.AutomationPlugin
import info.nightscout.core.profile.toCurrentUnits
import info.nightscout.interfaces.Config
import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.profile.Profile
import info.nightscout.plugins.general.autotune.AutotunePlugin
import info.nightscout.plugins.general.smsCommunicator.SmsCommunicatorPlugin
import info.nightscout.plugins.general.xdripStatusline.StatusLinePlugin

View file

@ -15,7 +15,6 @@ import info.nightscout.androidaps.interfaces.DataSyncSelector
import info.nightscout.androidaps.interfaces.IobCobCalculator
import info.nightscout.androidaps.interfaces.Loop
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.interfaces.PumpSync
import info.nightscout.androidaps.interfaces.TrendCalculator
import info.nightscout.androidaps.interfaces.XDripBroadcast
import info.nightscout.androidaps.interfaces.stats.DexcomTirCalculator
@ -28,7 +27,6 @@ import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctionImpl
import info.nightscout.androidaps.plugins.general.maintenance.ImportExportPrefsImpl
import info.nightscout.androidaps.plugins.general.maintenance.PrefFileListProvider
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
import info.nightscout.androidaps.utils.HardLimits
import info.nightscout.androidaps.utils.androidNotification.NotificationHolderImpl
import info.nightscout.androidaps.utils.buildHelper.BuildHelperImpl
import info.nightscout.androidaps.utils.buildHelper.ConfigImpl
@ -58,11 +56,13 @@ import info.nightscout.interfaces.NotificationHolder
import info.nightscout.interfaces.autotune.Autotune
import info.nightscout.interfaces.maintenance.ImportExportPrefs
import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.smsCommunicator.SmsCommunicator
import info.nightscout.interfaces.storage.FileStorage
import info.nightscout.interfaces.storage.Storage
import info.nightscout.interfaces.ui.ActivityNames
import info.nightscout.interfaces.ui.IconsProvider
import info.nightscout.interfaces.utils.HardLimits
import info.nightscout.plugins.general.autotune.AutotunePlugin
import info.nightscout.plugins.general.smsCommunicator.SmsCommunicatorPlugin
import info.nightscout.plugins.sync.nsclient.DataSyncSelectorImplementation

View file

@ -14,7 +14,6 @@ import info.nightscout.androidaps.extensions.formatColor
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.CommandQueue
import info.nightscout.androidaps.interfaces.Constraints
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.utils.DecimalFormatter
@ -24,6 +23,7 @@ import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.utils.extensions.toSignedString
import info.nightscout.androidaps.utils.protection.ProtectionCheck
import info.nightscout.androidaps.utils.protection.ProtectionCheck.Protection.BOLUS
import info.nightscout.core.profile.toMgdl
import info.nightscout.core.pumpExtensions.insertBolusTransaction
import info.nightscout.database.entities.TemporaryTarget
import info.nightscout.database.entities.UserEntry.Action
@ -35,6 +35,7 @@ import info.nightscout.interfaces.BolusTimer
import info.nightscout.interfaces.Config
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.constraints.Constraint
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.ui.ActivityNames

View file

@ -11,25 +11,26 @@ import android.widget.ArrayAdapter
import com.google.common.base.Joiner
import info.nightscout.androidaps.R
import info.nightscout.androidaps.data.ProfileSealed
import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.transactions.InsertAndCancelCurrentTemporaryTargetTransaction
import info.nightscout.androidaps.databinding.DialogProfileswitchBinding
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.utils.DefaultValueHelper
import info.nightscout.androidaps.utils.HardLimits
import info.nightscout.androidaps.utils.ToastUtils
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.utils.protection.ProtectionCheck
import info.nightscout.androidaps.utils.protection.ProtectionCheck.Protection.BOLUS
import info.nightscout.core.profile.toMgdl
import info.nightscout.database.entities.TemporaryTarget
import info.nightscout.database.entities.UserEntry.Action
import info.nightscout.database.entities.UserEntry.Sources
import info.nightscout.database.entities.ValueWithUnit
import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.transactions.InsertAndCancelCurrentTemporaryTargetTransaction
import info.nightscout.interfaces.Config
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.utils.HardLimits
import info.nightscout.interfaces.utils.HtmlHelper
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.logging.LTag

View file

@ -13,7 +13,6 @@ import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.CommandQueue
import info.nightscout.androidaps.interfaces.Constraints
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.interfaces.PumpSync
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.utils.ToastUtils
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
@ -23,6 +22,7 @@ import info.nightscout.database.entities.UserEntry.Action
import info.nightscout.database.entities.UserEntry.Sources
import info.nightscout.database.entities.ValueWithUnit
import info.nightscout.interfaces.constraints.Constraint
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.pump.defs.PumpDescription
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.ui.ActivityNames

View file

@ -9,13 +9,8 @@ import android.widget.ArrayAdapter
import com.google.common.base.Joiner
import com.google.common.collect.Lists
import info.nightscout.androidaps.R
import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.ValueWrapper
import info.nightscout.database.impl.transactions.CancelCurrentTemporaryTargetIfAnyTransaction
import info.nightscout.database.impl.transactions.InsertAndCancelCurrentTemporaryTargetTransaction
import info.nightscout.androidaps.databinding.DialogTemptargetBinding
import info.nightscout.androidaps.interfaces.Constraints
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.utils.DefaultValueHelper
@ -23,12 +18,19 @@ import info.nightscout.androidaps.utils.ToastUtils
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.utils.protection.ProtectionCheck
import info.nightscout.androidaps.utils.protection.ProtectionCheck.Protection.BOLUS
import info.nightscout.core.profile.toCurrentUnitsString
import info.nightscout.core.profile.toMgdl
import info.nightscout.database.entities.TemporaryTarget
import info.nightscout.database.entities.UserEntry.Action
import info.nightscout.database.entities.UserEntry.Sources
import info.nightscout.database.entities.ValueWithUnit
import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.ValueWrapper
import info.nightscout.database.impl.transactions.CancelCurrentTemporaryTargetIfAnyTransaction
import info.nightscout.database.impl.transactions.InsertAndCancelCurrentTemporaryTargetTransaction
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.utils.HtmlHelper
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.interfaces.ResourceHelper

View file

@ -26,7 +26,6 @@ import info.nightscout.androidaps.extensions.valueToUnits
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.Constraints
import info.nightscout.androidaps.interfaces.IobCobCalculator
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.androidaps.utils.ToastUtils
@ -35,11 +34,14 @@ import info.nightscout.androidaps.utils.protection.ProtectionCheck.Protection.BO
import info.nightscout.androidaps.utils.wizard.BolusWizard
import info.nightscout.core.fabric.FabricPrivacy
import info.nightscout.core.iob.round
import info.nightscout.core.profile.toMgdl
import info.nightscout.core.profile.toUnitsString
import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.ValueWrapper
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.constraints.Constraint
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.utils.HtmlHelper
import info.nightscout.interfaces.utils.Round
import info.nightscout.rx.AapsSchedulers

View file

@ -26,9 +26,7 @@ import info.nightscout.androidaps.interfaces.Constraints
import info.nightscout.androidaps.interfaces.IobCobCalculator
import info.nightscout.androidaps.interfaces.Loop
import info.nightscout.androidaps.interfaces.Loop.LastRun
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.interfaces.PumpSync
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.aps.loop.events.EventLoopSetLastRunGui
import info.nightscout.androidaps.plugins.aps.loop.events.EventLoopUpdateGui
@ -36,7 +34,6 @@ import info.nightscout.androidaps.plugins.aps.loop.events.EventNewOpenLoopNotifi
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
import info.nightscout.androidaps.receivers.ReceiverStatusStore
import info.nightscout.androidaps.utils.HardLimits
import info.nightscout.androidaps.utils.extensions.buildDeviceStatus
import info.nightscout.core.fabric.FabricPrivacy
import info.nightscout.database.entities.OfflineEvent
@ -54,10 +51,13 @@ import info.nightscout.interfaces.notifications.Notification
import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.pump.defs.PumpDescription
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.ui.ActivityNames
import info.nightscout.interfaces.utils.HardLimits
import info.nightscout.plugins.configBuilder.RunningConfiguration
import info.nightscout.plugins.pump.virtual.VirtualPumpPlugin
import info.nightscout.rx.AapsSchedulers

View file

@ -8,7 +8,6 @@ import info.nightscout.androidaps.extensions.plannedRemainingMinutes
import info.nightscout.androidaps.interfaces.Constraints
import info.nightscout.androidaps.interfaces.DetermineBasalAdapterInterface
import info.nightscout.androidaps.interfaces.IobCobCalculator
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.plugins.aps.logger.LoggerCallback
import info.nightscout.androidaps.plugins.aps.loop.APSResult
@ -18,6 +17,7 @@ import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.aps.SMBDefaults
import info.nightscout.interfaces.iob.IobTotal
import info.nightscout.interfaces.iob.MealData
import info.nightscout.interfaces.profile.Profile
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.sharedPreferences.SP

View file

@ -10,7 +10,6 @@ import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.Constraints
import info.nightscout.androidaps.interfaces.DetermineBasalAdapterInterface
import info.nightscout.androidaps.interfaces.IobCobCalculator
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.plugins.aps.OpenAPSFragment
import info.nightscout.androidaps.plugins.aps.events.EventOpenAPSUpdateGui
@ -18,15 +17,17 @@ import info.nightscout.androidaps.plugins.aps.events.EventOpenAPSUpdateResultGui
import info.nightscout.androidaps.plugins.aps.loop.ScriptReader
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
import info.nightscout.androidaps.utils.HardLimits
import info.nightscout.androidaps.utils.Profiler
import info.nightscout.core.fabric.FabricPrivacy
import info.nightscout.core.profile.secondsFromMidnight
import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.ValueWrapper
import info.nightscout.interfaces.constraints.Constraint
import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.utils.HardLimits
import info.nightscout.interfaces.utils.Round
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.logging.AAPSLogger

View file

@ -9,7 +9,6 @@ import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.Constraints
import info.nightscout.androidaps.interfaces.DetermineBasalAdapterInterface
import info.nightscout.androidaps.interfaces.IobCobCalculator
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.plugins.aps.logger.LoggerCallback
import info.nightscout.androidaps.plugins.aps.loop.APSResult
@ -19,6 +18,7 @@ import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.aps.SMBDefaults
import info.nightscout.interfaces.iob.IobTotal
import info.nightscout.interfaces.iob.MealData
import info.nightscout.interfaces.profile.Profile
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.SafeParse

View file

@ -12,7 +12,6 @@ import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.Constraints
import info.nightscout.androidaps.interfaces.DetermineBasalAdapterInterface
import info.nightscout.androidaps.interfaces.IobCobCalculator
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.plugins.aps.OpenAPSFragment
import info.nightscout.androidaps.plugins.aps.events.EventOpenAPSUpdateGui
@ -20,8 +19,8 @@ import info.nightscout.androidaps.plugins.aps.events.EventOpenAPSUpdateResultGui
import info.nightscout.androidaps.plugins.aps.loop.ScriptReader
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
import info.nightscout.androidaps.utils.HardLimits
import info.nightscout.androidaps.utils.Profiler
import info.nightscout.core.profile.secondsFromMidnight
import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.ValueWrapper
import info.nightscout.interfaces.aps.SMBDefaults
@ -29,6 +28,8 @@ import info.nightscout.interfaces.constraints.Constraint
import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.utils.HardLimits
import info.nightscout.interfaces.utils.Round
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.logging.AAPSLogger

View file

@ -9,18 +9,19 @@ import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.Constraints
import info.nightscout.androidaps.interfaces.DetermineBasalAdapterInterface
import info.nightscout.androidaps.interfaces.IobCobCalculator
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.interfaces.stats.TddCalculator
import info.nightscout.androidaps.plugins.aps.logger.LoggerCallback
import info.nightscout.androidaps.plugins.aps.loop.ScriptReader
import info.nightscout.androidaps.plugins.aps.openAPSSMB.DetermineBasalResultSMB
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus
import info.nightscout.core.profile.toMgdl
import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.aps.SMBDefaults
import info.nightscout.interfaces.iob.IobTotal
import info.nightscout.interfaces.iob.MealData
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.utils.Round
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag

View file

@ -4,23 +4,23 @@ import android.content.Context
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.database.impl.AppRepository
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.interfaces.BuildHelper
import info.nightscout.androidaps.interfaces.Constraints
import info.nightscout.androidaps.interfaces.DetermineBasalAdapterInterface
import info.nightscout.androidaps.interfaces.IobCobCalculator
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.androidaps.plugins.aps.loop.ScriptReader
import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
import info.nightscout.shared.utils.DateUtil
import info.nightscout.androidaps.utils.HardLimits
import info.nightscout.androidaps.utils.Profiler
import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.BuildHelper
import info.nightscout.interfaces.utils.HardLimits
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.shared.utils.DateUtil
import javax.inject.Inject
import javax.inject.Singleton

View file

@ -6,8 +6,6 @@ import info.nightscout.androidaps.R
import info.nightscout.androidaps.interfaces.APS
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.BgSource
import info.nightscout.androidaps.interfaces.Pump
import info.nightscout.androidaps.interfaces.PumpSync
import info.nightscout.androidaps.interfaces.Sensitivity
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.configBuilder.events.EventConfigBuilderUpdateGui
@ -21,6 +19,8 @@ import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.profile.ProfileSource
import info.nightscout.interfaces.pump.Pump
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.sync.NsClient
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventAppInitialized

View file

@ -4,7 +4,6 @@ import info.nightscout.androidaps.interfaces.APS
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.BgSource
import info.nightscout.androidaps.interfaces.IobCobCalculator
import info.nightscout.androidaps.interfaces.Pump
import info.nightscout.androidaps.interfaces.Sensitivity
import info.nightscout.interfaces.Config
import info.nightscout.interfaces.Overview
@ -13,6 +12,7 @@ import info.nightscout.interfaces.insulin.Insulin
import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.profile.ProfileSource
import info.nightscout.interfaces.pump.Pump
import info.nightscout.interfaces.sync.NsClient
import info.nightscout.interfaces.sync.Sync
import info.nightscout.rx.logging.AAPSLogger

View file

@ -2,11 +2,9 @@ package info.nightscout.androidaps.plugins.configBuilder
import info.nightscout.androidaps.data.ProfileSealed
import info.nightscout.androidaps.events.EventEffectiveProfileSwitchChanged
import info.nightscout.androidaps.extensions.fromConstant
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.utils.HardLimits
import info.nightscout.androidaps.utils.extensions.fromConstant
import info.nightscout.core.fabric.FabricPrivacy
import info.nightscout.core.main.R
import info.nightscout.database.entities.ProfileSwitch
@ -16,7 +14,9 @@ import info.nightscout.database.impl.transactions.InsertOrUpdateProfileSwitch
import info.nightscout.interfaces.Config
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileStore
import info.nightscout.interfaces.utils.HardLimits
import info.nightscout.plugins.sync.nsclient.data.ProcessedDeviceStatusData
import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus

View file

@ -11,14 +11,12 @@ import info.nightscout.androidaps.extensions.storeString
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.Constraints
import info.nightscout.androidaps.interfaces.IobCobCalculator
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin
import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin
import info.nightscout.androidaps.plugins.aps.openAPSSMBDynamicISF.OpenAPSSMBDynamicISFPlugin
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.androidaps.utils.HardLimits
import info.nightscout.interfaces.BuildHelper
import info.nightscout.interfaces.Config
import info.nightscout.interfaces.constraints.Constraint
@ -27,7 +25,9 @@ import info.nightscout.interfaces.notifications.Notification
import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.pump.defs.PumpDescription
import info.nightscout.interfaces.utils.HardLimits
import info.nightscout.interfaces.utils.Round
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.logging.AAPSLogger

View file

@ -16,7 +16,6 @@ import info.nightscout.androidaps.events.EventPreferenceChange
import info.nightscout.androidaps.insight.database.InsightDatabase
import info.nightscout.androidaps.interfaces.DataSyncSelector
import info.nightscout.androidaps.interfaces.IobCobCalculator
import info.nightscout.androidaps.interfaces.PumpSync
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.general.maintenance.activities.LogSettingActivity
import info.nightscout.androidaps.plugins.general.overview.OverviewData
@ -30,6 +29,7 @@ import info.nightscout.database.entities.UserEntry.Action
import info.nightscout.database.entities.UserEntry.Sources
import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.maintenance.ImportExportPrefs
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.utils.HtmlHelper
import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus

View file

@ -48,7 +48,6 @@ import info.nightscout.androidaps.interfaces.CommandQueue
import info.nightscout.androidaps.interfaces.Constraints
import info.nightscout.androidaps.interfaces.IobCobCalculator
import info.nightscout.androidaps.interfaces.Loop
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.interfaces.TrendCalculator
import info.nightscout.androidaps.logging.UserEntryLogger
@ -74,6 +73,9 @@ import info.nightscout.androidaps.utils.ui.UIRunnable
import info.nightscout.androidaps.utils.wizard.QuickWizard
import info.nightscout.automation.AutomationPlugin
import info.nightscout.core.fabric.FabricPrivacy
import info.nightscout.core.profile.toSignedUnitsString
import info.nightscout.core.profile.toTargetRangeString
import info.nightscout.core.profile.toUnits
import info.nightscout.database.entities.UserEntry.Action
import info.nightscout.database.entities.UserEntry.Sources
import info.nightscout.database.entities.interfaces.end
@ -84,6 +86,7 @@ import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.constraints.Constraint
import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.pump.defs.PumpType
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.plugins.constraints.bgQualityCheck.BgQualityCheckPlugin

View file

@ -13,17 +13,18 @@ import info.nightscout.androidaps.extensions.toStringShort
import info.nightscout.androidaps.extensions.valueToUnitsString
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.IobCobCalculator
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.core.fabric.FabricPrivacy
import info.nightscout.core.iob.round
import info.nightscout.core.profile.toSignedUnitsString
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.NotificationHolder
import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.ui.IconsProvider
import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus

View file

@ -15,7 +15,6 @@ import info.nightscout.androidaps.interfaces.CommandQueue
import info.nightscout.androidaps.interfaces.Constraints
import info.nightscout.androidaps.interfaces.IobCobCalculator
import info.nightscout.androidaps.interfaces.Loop
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.interfaces.TrendCalculator
import info.nightscout.androidaps.logging.UserEntryLogger
@ -25,13 +24,15 @@ import info.nightscout.androidaps.receivers.ReceiverStatusStore
import info.nightscout.androidaps.services.AlarmSoundServiceHelper
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.androidaps.utils.DefaultValueHelper
import info.nightscout.androidaps.utils.HardLimits
import info.nightscout.androidaps.utils.ToastUtils
import info.nightscout.androidaps.utils.wizard.BolusWizard
import info.nightscout.androidaps.utils.wizard.QuickWizard
import info.nightscout.androidaps.utils.wizard.QuickWizardEntry
import info.nightscout.core.fabric.FabricPrivacy
import info.nightscout.core.iob.round
import info.nightscout.core.profile.fromMgdlToUnits
import info.nightscout.core.profile.toMgdl
import info.nightscout.core.profile.toTargetRangeString
import info.nightscout.database.entities.Bolus
import info.nightscout.database.entities.GlucoseValue
import info.nightscout.database.entities.TemporaryBasal
@ -49,8 +50,10 @@ import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.constraints.Constraint
import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.utils.HardLimits
import info.nightscout.plugins.sync.nsclient.data.ProcessedDeviceStatusData
import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus

View file

@ -13,7 +13,6 @@ import info.nightscout.androidaps.extensions.iobCalc
import info.nightscout.androidaps.extensions.toTemporaryBasal
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.IobCobCalculator
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.plugins.general.overview.OverviewData
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData
@ -37,6 +36,7 @@ import info.nightscout.interfaces.iob.MealData
import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.utils.MidnightTime
import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus

View file

@ -3,17 +3,18 @@ package info.nightscout.androidaps.plugins.sensitivity
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.extensions.isPSEvent5minBack
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.interfaces.Sensitivity.SensitivityType
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensDataStore
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult
import info.nightscout.androidaps.utils.extensions.isPSEvent5minBack
import info.nightscout.core.profile.secondsFromMidnight
import info.nightscout.database.entities.TherapyEvent
import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.profile.Profile
import info.nightscout.plugins.sync.nsclient.extensions.isTherapyEventEvent5minBack
import info.nightscout.plugins.utils.Percentile
import info.nightscout.rx.logging.AAPSLogger

View file

@ -3,18 +3,19 @@ package info.nightscout.androidaps.plugins.sensitivity
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.extensions.isPSEvent5minBack
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.interfaces.Sensitivity.SensitivityType
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensDataStore
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult
import info.nightscout.androidaps.utils.extensions.isPSEvent5minBack
import info.nightscout.core.profile.secondsFromMidnight
import info.nightscout.database.entities.TherapyEvent
import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.aps.SMBDefaults
import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.profile.Profile
import info.nightscout.plugins.sync.nsclient.extensions.isTherapyEventEvent5minBack
import info.nightscout.plugins.utils.Percentile
import info.nightscout.rx.logging.AAPSLogger

View file

@ -4,17 +4,18 @@ import androidx.collection.LongSparseArray
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.extensions.isPSEvent5minBack
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.interfaces.Sensitivity.SensitivityType
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensDataStore
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult
import info.nightscout.androidaps.utils.extensions.isPSEvent5minBack
import info.nightscout.core.profile.secondsFromMidnight
import info.nightscout.database.entities.TherapyEvent
import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.profile.Profile
import info.nightscout.plugins.sync.nsclient.extensions.isTherapyEventEvent5minBack
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag

View file

@ -11,11 +11,11 @@ import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.extensions.fromConstant
import info.nightscout.androidaps.interfaces.BgSource
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.XDripBroadcast
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.source.activities.RequestDexcomPermissionActivity
import info.nightscout.androidaps.receivers.DataWorkerStorage
import info.nightscout.core.profile.unit
import info.nightscout.database.entities.GlucoseValue
import info.nightscout.database.entities.TherapyEvent
import info.nightscout.database.entities.UserEntry.Action
@ -28,6 +28,7 @@ import info.nightscout.interfaces.Config
import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.profile.Profile
import info.nightscout.plugins.source.BGSourceFragment
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag

View file

@ -5,7 +5,7 @@ import android.content.Intent
import com.google.gson.Gson
import dagger.android.DaggerBroadcastReceiver
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.Pump
import info.nightscout.interfaces.pump.Pump
import info.nightscout.interfaces.utils.TimeChangeType
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.BundleLogger

View file

@ -35,7 +35,6 @@ import info.nightscout.androidaps.setupwizard.elements.SWPreference
import info.nightscout.androidaps.setupwizard.elements.SWRadioButton
import info.nightscout.androidaps.setupwizard.events.EventSWUpdate
import info.nightscout.androidaps.utils.CryptoUtil
import info.nightscout.androidaps.utils.HardLimits
import info.nightscout.androidaps.utils.extensions.isRunningTest
import info.nightscout.interfaces.AndroidPermission
import info.nightscout.interfaces.Config
@ -43,6 +42,7 @@ import info.nightscout.interfaces.ConfigBuilder
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.maintenance.ImportExportPrefs
import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.utils.HardLimits
import info.nightscout.plugins.profile.ProfileFragment
import info.nightscout.plugins.profile.ProfilePlugin
import info.nightscout.plugins.sync.nsShared.events.EventNSClientStatus

View file

@ -7,12 +7,13 @@ import android.view.View
import android.widget.LinearLayout
import android.widget.TextView
import dagger.android.HasAndroidInjector
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.setupwizard.SWNumberValidator
import info.nightscout.shared.SafeParse
import info.nightscout.androidaps.utils.ui.NumberPicker
import info.nightscout.core.profile.toCurrentUnits
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.profile.Profile
import info.nightscout.shared.SafeParse
import java.text.DecimalFormat
import javax.inject.Inject

View file

@ -1,7 +1,7 @@
package info.nightscout.androidaps.utils.extensions
import info.nightscout.androidaps.interfaces.Pump
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.interfaces.pump.Pump
fun Double.toSignedString(pump: Pump): String {
val formatted = DecimalFormatter.toPumpSupportedBolus(this, pump)

View file

@ -13,14 +13,14 @@ import info.nightscout.androidaps.interfaces.CommandQueue
import info.nightscout.androidaps.interfaces.Constraints
import info.nightscout.androidaps.interfaces.IobCobCalculator
import info.nightscout.androidaps.interfaces.Loop
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.interfaces.PumpSync
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.core.iob.round
import info.nightscout.core.profile.fromMgdlToUnits
import info.nightscout.core.profile.toMgdl
import info.nightscout.database.entities.BolusCalculatorResult
import info.nightscout.database.entities.OfflineEvent
import info.nightscout.database.entities.TemporaryTarget
@ -34,7 +34,9 @@ import info.nightscout.interfaces.CarbTimer
import info.nightscout.interfaces.Config
import info.nightscout.interfaces.constraints.Constraint
import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.pump.defs.PumpDescription
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.ui.ActivityNames

View file

@ -6,14 +6,15 @@ import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.androidaps.extensions.valueToUnits
import info.nightscout.androidaps.interfaces.IobCobCalculator
import info.nightscout.androidaps.interfaces.Loop
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
import info.nightscout.core.iob.round
import info.nightscout.core.profile.secondsFromMidnight
import info.nightscout.database.entities.GlucoseValue
import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.ValueWrapper
import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.utils.JsonHelper.safeGetInt
import info.nightscout.interfaces.utils.JsonHelper.safeGetString
import info.nightscout.rx.logging.AAPSLogger

View file

@ -5,10 +5,7 @@ import androidx.work.Worker
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector
import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.androidaps.interfaces.IobCobCalculator
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.plugins.general.overview.OverviewData
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DataPointWithLabelInterface
@ -16,9 +13,12 @@ import info.nightscout.androidaps.plugins.general.overview.graphExtensions.Gluco
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.PointsWithLabelGraphSeries
import info.nightscout.androidaps.receivers.DataWorkerStorage
import info.nightscout.androidaps.utils.DefaultValueHelper
import info.nightscout.core.profile.fromMgdlToUnits
import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.utils.Round
import info.nightscout.shared.interfaces.ResourceHelper
import java.util.ArrayList
import javax.inject.Inject
class PrepareBgDataWorker(

View file

@ -8,17 +8,18 @@ import com.jjoe64.graphview.series.DataPoint
import com.jjoe64.graphview.series.LineGraphSeries
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.ValueWrapper
import info.nightscout.androidaps.extensions.target
import info.nightscout.androidaps.interfaces.Loop
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.androidaps.plugins.general.overview.OverviewData
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress
import info.nightscout.androidaps.receivers.DataWorkerStorage
import info.nightscout.core.profile.fromMgdlToUnits
import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.ValueWrapper
import info.nightscout.interfaces.profile.Profile
import info.nightscout.rx.bus.RxBus
import info.nightscout.shared.interfaces.ResourceHelper
import javax.inject.Inject
import kotlin.math.max

View file

@ -5,9 +5,7 @@ import androidx.work.Worker
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector
import info.nightscout.database.impl.AppRepository
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.plugins.general.overview.OverviewData
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.BolusDataPoint
@ -21,9 +19,12 @@ import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCa
import info.nightscout.androidaps.receivers.DataWorkerStorage
import info.nightscout.androidaps.utils.DefaultValueHelper
import info.nightscout.androidaps.utils.Translator
import info.nightscout.core.profile.fromMgdlToUnits
import info.nightscout.database.entities.Bolus
import info.nightscout.database.entities.TherapyEvent
import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.utils.Round
import info.nightscout.rx.bus.RxBus
import info.nightscout.shared.interfaces.ResourceHelper

View file

@ -4,10 +4,10 @@ import android.content.Context
import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.ProfileSealed
import info.nightscout.androidaps.extensions.pureProfileFromJson
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.IobCobCalculator
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.utils.extensions.pureProfileFromJson
import info.nightscout.core.fabric.FabricPrivacy
import info.nightscout.core.profile.ProfileStoreObject
import info.nightscout.database.entities.EffectiveProfileSwitch

View file

@ -2,11 +2,11 @@ package info.nightscout.androidaps
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultImpl
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.Pump
import info.nightscout.androidaps.interfaces.PumpSync
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.pump.Pump
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.pump.defs.ManufacturerType
import info.nightscout.interfaces.pump.defs.PumpDescription
import info.nightscout.interfaces.pump.defs.PumpType

View file

@ -25,7 +25,6 @@ import info.nightscout.androidaps.plugins.pump.common.bolusInfo.TemporaryBasalSt
import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin
import info.nightscout.androidaps.plugins.source.GlimpPlugin
import info.nightscout.androidaps.utils.HardLimits
import info.nightscout.androidaps.utils.Profiler
import info.nightscout.androidaps.utils.buildHelper.BuildHelperImpl
import info.nightscout.database.impl.AppRepository
@ -34,7 +33,9 @@ import info.nightscout.interfaces.BuildHelper
import info.nightscout.interfaces.constraints.Constraint
import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.pump.defs.PumpDescription
import info.nightscout.interfaces.utils.HardLimits
import info.nightscout.plugins.pump.virtual.VirtualPumpPlugin
import info.nightscout.shared.sharedPreferences.SP
import org.junit.Assert
@ -63,6 +64,7 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
@Mock lateinit var insightDatabaseDao: InsightDatabaseDao
@Mock lateinit var ruffyScripter: RuffyScripter
@Mock lateinit var buildHelper: BuildHelper
@Mock lateinit var hardLimits: HardLimits
private lateinit var danaPump: DanaPump
private lateinit var insightDbHelper: InsightDbHelper
@ -76,7 +78,6 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
private lateinit var openAPSSMBPlugin: OpenAPSSMBPlugin
private lateinit var openAPSAMAPlugin: OpenAPSAMAPlugin
private lateinit var openAPSSMBDynamicISFPlugin: OpenAPSSMBDynamicISFPlugin
private lateinit var hardLimits: HardLimits
private val injector = HasAndroidInjector {
AndroidInjector {
@ -131,7 +132,6 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
insightDbHelper = InsightDbHelper(insightDatabaseDao)
danaPump = DanaPump(aapsLogger, sp, dateUtil, injector)
hardLimits = HardLimits(aapsLogger, rxBus, sp, rh, context, repository)
objectivesPlugin = ObjectivesPlugin(injector, aapsLogger, rh, activePlugin, sp, config)
comboPlugin = ComboPlugin(injector, aapsLogger, rxBus, rh, profileFunction, sp, commandQueue, pumpSync, dateUtil, ruffyScripter)
danaRPlugin = DanaRPlugin(injector, aapsLogger, aapsSchedulers, rxBus, context, rh, constraintChecker, activePlugin, sp, commandQueue, danaPump, dateUtil, fabricPrivacy, pumpSync)

View file

@ -4,10 +4,10 @@ import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.TestBase
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.PumpSync
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.rx.bus.RxBus
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP
import org.junit.Before
import org.junit.Test

View file

@ -11,12 +11,12 @@ import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin
import info.nightscout.androidaps.plugins.aps.openAPSSMBDynamicISF.OpenAPSSMBDynamicISFPlugin
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin
import info.nightscout.androidaps.plugins.source.GlimpPlugin
import info.nightscout.androidaps.utils.HardLimits
import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.BuildHelper
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.constraints.Constraint
import info.nightscout.interfaces.pump.defs.PumpDescription
import info.nightscout.interfaces.utils.HardLimits
import info.nightscout.plugins.pump.virtual.VirtualPumpPlugin
import info.nightscout.shared.sharedPreferences.SP
import org.junit.Assert
@ -38,8 +38,8 @@ class SafetyPluginTest : TestBaseWithProfile() {
@Mock lateinit var virtualPumpPlugin: VirtualPumpPlugin
@Mock lateinit var glimpPlugin: GlimpPlugin
@Mock lateinit var repository: AppRepository
@Mock lateinit var hardLimits: HardLimits
private lateinit var hardLimits: HardLimits
private lateinit var safetyPlugin: SafetyPlugin
val injector = HasAndroidInjector { AndroidInjector { } }
@ -69,11 +69,12 @@ class SafetyPluginTest : TestBaseWithProfile() {
`when`(activePlugin.activePump).thenReturn(virtualPumpPlugin)
`when`(virtualPumpPlugin.pumpDescription).thenReturn(pumpDescription)
hardLimits = HardLimits(aapsLogger, rxBus, sp, rh, context, repository)
`when`(config.APS).thenReturn(true)
safetyPlugin = SafetyPlugin(injector, aapsLogger, rh, sp, rxBus, constraintChecker, openAPSAMAPlugin, openAPSSMBPlugin, openAPSSMBDynamicISFPlugin, sensitivityOref1Plugin, activePlugin,
hardLimits, buildHelper,
iobCobCalculator, config, dateUtil)
safetyPlugin = SafetyPlugin(
injector, aapsLogger, rh, sp, rxBus, constraintChecker, openAPSAMAPlugin, openAPSSMBPlugin, openAPSSMBDynamicISFPlugin, sensitivityOref1Plugin, activePlugin,
hardLimits, buildHelper,
iobCobCalculator, config, dateUtil
)
}
@Test fun pumpDescriptionShouldLimitLoopInvocation() {
@ -135,12 +136,14 @@ class SafetyPluginTest : TestBaseWithProfile() {
val c = Constraint(Constants.REALLYHIGHBASALRATE)
safetyPlugin.applyBasalConstraints(c, validProfile)
Assert.assertEquals(1.0, c.value(), 0.01)
Assert.assertEquals("""
Assert.assertEquals(
"""
Safety: Limiting max basal rate to 1.00 U/h because of max value in preferences
Safety: Limiting max basal rate to 4.00 U/h because of max basal multiplier
Safety: Limiting max basal rate to 3.00 U/h because of max daily basal multiplier
Safety: Limiting max basal rate to 2.00 U/h because of hard limit
""".trimIndent(), c.getReasons(aapsLogger))
""".trimIndent(), c.getReasons(aapsLogger)
)
Assert.assertEquals("Safety: Limiting max basal rate to 1.00 U/h because of max value in preferences", c.getMostLimitedReasons(aapsLogger))
}
@ -149,10 +152,12 @@ class SafetyPluginTest : TestBaseWithProfile() {
val d = Constraint(-0.5)
safetyPlugin.applyBasalConstraints(d, validProfile)
Assert.assertEquals(0.0, d.value(), 0.01)
Assert.assertEquals("""
Assert.assertEquals(
"""
Safety: Limiting max basal rate to 0.00 U/h because of it must be positive value
Safety: Increasing max basal value because setting is lower than your max basal in profile
""".trimIndent(), d.getReasons(aapsLogger))
""".trimIndent(), d.getReasons(aapsLogger)
)
}
@Test fun percentBasalRateShouldBeLimited() {
@ -164,7 +169,8 @@ class SafetyPluginTest : TestBaseWithProfile() {
val i = Constraint(Constants.REALLYHIGHPERCENTBASALRATE)
safetyPlugin.applyBasalPercentConstraints(i, validProfile)
Assert.assertEquals(100, i.value())
Assert.assertEquals("""
Assert.assertEquals(
"""
Safety: Percent rate 1111111% recalculated to 11111.11 U/h with current basal 1.00 U/h
Safety: Limiting max basal rate to 1.00 U/h because of max value in preferences
Safety: Limiting max basal rate to 4.00 U/h because of max basal multiplier
@ -172,7 +178,8 @@ class SafetyPluginTest : TestBaseWithProfile() {
Safety: Limiting max basal rate to 2.00 U/h because of hard limit
Safety: Limiting max percent rate to 100% because of pump limit
Safety: Limiting max basal rate to 500.00 U/h because of pump limit
""".trimIndent(), i.getReasons(aapsLogger))
""".trimIndent(), i.getReasons(aapsLogger)
)
Assert.assertEquals("Safety: Limiting max percent rate to 100% because of pump limit", i.getMostLimitedReasons(aapsLogger))
}
@ -181,12 +188,14 @@ class SafetyPluginTest : TestBaseWithProfile() {
val i = Constraint(-22)
safetyPlugin.applyBasalPercentConstraints(i, validProfile)
Assert.assertEquals(0, i.value())
Assert.assertEquals("""
Assert.assertEquals(
"""
Safety: Percent rate -22% recalculated to -0.22 U/h with current basal 1.00 U/h
Safety: Limiting max basal rate to 0.00 U/h because of it must be positive value
Safety: Increasing max basal value because setting is lower than your max basal in profile
Safety: Limiting max percent rate to 0% because of pump limit
""".trimIndent(), i.getReasons(aapsLogger))
""".trimIndent(), i.getReasons(aapsLogger)
)
Assert.assertEquals("Safety: Limiting max percent rate to 0% because of pump limit", i.getMostLimitedReasons(aapsLogger))
}
@ -196,10 +205,12 @@ class SafetyPluginTest : TestBaseWithProfile() {
var d = Constraint(Constants.REALLYHIGHBOLUS)
d = safetyPlugin.applyBolusConstraints(d)
Assert.assertEquals(3.0, d.value(), 0.01)
Assert.assertEquals("""
Assert.assertEquals(
"""
Safety: Limiting bolus to 3.0 U because of max value in preferences
Safety: Limiting bolus to 5.0 U because of hard limit
""".trimIndent(), d.getReasons(aapsLogger))
""".trimIndent(), d.getReasons(aapsLogger)
)
Assert.assertEquals("Safety: Limiting bolus to 3.0 U because of max value in preferences", d.getMostLimitedReasons(aapsLogger))
}

View file

@ -9,13 +9,13 @@ import info.nightscout.androidaps.interfaces.CommandQueue
import info.nightscout.androidaps.interfaces.Constraints
import info.nightscout.androidaps.interfaces.IobCobCalculator
import info.nightscout.androidaps.interfaces.Loop
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensDataStore
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.constraints.Constraint
import info.nightscout.interfaces.iob.IobTotal
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.pump.defs.PumpDescription
import info.nightscout.plugins.pump.virtual.VirtualPumpPlugin
import info.nightscout.rx.bus.RxBus

View file

@ -4,11 +4,8 @@ import android.widget.LinearLayout
import androidx.annotation.DrawableRes
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultImpl
import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.transactions.InsertAndCancelCurrentTemporaryTargetTransaction
import info.nightscout.androidaps.extensions.friendlyDescription
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.automation.R
@ -18,12 +15,16 @@ import info.nightscout.automation.elements.InputTempTarget
import info.nightscout.automation.elements.LabelWithElement
import info.nightscout.automation.elements.LayoutBuilder
import info.nightscout.automation.triggers.TriggerTempTarget
import info.nightscout.core.profile.toMgdl
import info.nightscout.database.entities.TemporaryTarget
import info.nightscout.database.entities.UserEntry
import info.nightscout.database.entities.UserEntry.Sources
import info.nightscout.database.entities.ValueWithUnit
import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.transactions.InsertAndCancelCurrentTemporaryTargetTransaction
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.interfaces.utils.JsonHelper.safeGetDouble

View file

@ -11,11 +11,12 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.FragmentManager
import com.google.android.material.timepicker.MaterialTimePicker
import com.google.android.material.timepicker.TimeFormat
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.automation.R
import info.nightscout.core.profile.secondsFromMidnight
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.utils.MidnightTime
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.utils.DateUtil
import info.nightscout.interfaces.utils.MidnightTime
import info.nightscout.automation.R
import java.util.Calendar
class InputTime(private val rh: ResourceHelper, private val dateUtil: DateUtil) : Element() {

View file

@ -12,11 +12,12 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.FragmentManager
import com.google.android.material.timepicker.MaterialTimePicker
import com.google.android.material.timepicker.TimeFormat
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.automation.R
import info.nightscout.core.profile.secondsFromMidnight
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.utils.MidnightTime
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.utils.DateUtil
import info.nightscout.interfaces.utils.MidnightTime
import info.nightscout.automation.R
import java.util.Calendar
class InputTimeRange(private val rh: ResourceHelper, private val dateUtil: DateUtil) : Element() {

View file

@ -3,18 +3,18 @@ package info.nightscout.automation.triggers
import android.widget.LinearLayout
import com.google.common.base.Optional
import dagger.android.HasAndroidInjector
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.automation.R
import info.nightscout.automation.elements.Comparator
import info.nightscout.automation.elements.InputBg
import info.nightscout.automation.elements.LabelWithElement
import info.nightscout.automation.elements.LayoutBuilder
import info.nightscout.automation.elements.StaticLabel
import info.nightscout.core.profile.toMgdl
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.rx.logging.LTag
import org.json.JSONObject
class TriggerBg(injector: HasAndroidInjector) : Trigger(injector) {

View file

@ -3,10 +3,6 @@ package info.nightscout.automation.triggers
import android.widget.LinearLayout
import com.google.common.base.Optional
import dagger.android.HasAndroidInjector
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.automation.R
import info.nightscout.automation.elements.Comparator
import info.nightscout.automation.elements.InputDelta
@ -14,8 +10,12 @@ import info.nightscout.automation.elements.InputDelta.DeltaType
import info.nightscout.automation.elements.LabelWithElement
import info.nightscout.automation.elements.LayoutBuilder
import info.nightscout.automation.elements.StaticLabel
import info.nightscout.core.profile.toMgdl
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.rx.logging.LTag
import org.json.JSONObject
import java.text.DecimalFormat

View file

@ -3,16 +3,16 @@ package info.nightscout.automation.triggers
import android.widget.LinearLayout
import com.google.common.base.Optional
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.interfaces.utils.MidnightTime
import info.nightscout.automation.R
import info.nightscout.automation.elements.InputTime
import info.nightscout.automation.elements.InputWeekDay
import info.nightscout.automation.elements.LayoutBuilder
import info.nightscout.automation.elements.StaticLabel
import info.nightscout.core.profile.secondsFromMidnight
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.interfaces.utils.MidnightTime
import info.nightscout.rx.logging.LTag
import org.json.JSONObject
import java.util.Calendar
import java.util.Objects

View file

@ -3,19 +3,19 @@ package info.nightscout.automation.triggers
import android.widget.LinearLayout
import com.google.common.base.Optional
import dagger.android.HasAndroidInjector
import info.nightscout.interfaces.Constants
import info.nightscout.database.impl.ValueWrapper
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.automation.R
import info.nightscout.automation.elements.Comparator
import info.nightscout.automation.elements.InputBg
import info.nightscout.automation.elements.LabelWithElement
import info.nightscout.automation.elements.LayoutBuilder
import info.nightscout.automation.elements.StaticLabel
import info.nightscout.core.profile.toMgdl
import info.nightscout.database.impl.ValueWrapper
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.rx.logging.LTag
import org.json.JSONObject
class TriggerTempTargetValue(injector: HasAndroidInjector) : Trigger(injector) {

View file

@ -3,15 +3,15 @@ package info.nightscout.automation.triggers
import android.widget.LinearLayout
import com.google.common.base.Optional
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.interfaces.utils.JsonHelper.safeGetInt
import info.nightscout.interfaces.utils.MidnightTime
import info.nightscout.automation.R
import info.nightscout.automation.elements.InputTimeRange
import info.nightscout.automation.elements.LayoutBuilder
import info.nightscout.automation.elements.StaticLabel
import info.nightscout.core.profile.secondsFromMidnight
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.utils.JsonHelper.safeGetInt
import info.nightscout.interfaces.utils.MidnightTime
import info.nightscout.rx.logging.LTag
import org.json.JSONObject
// Trigger for time range ( from 10:00AM till 13:00PM )

View file

@ -3,15 +3,15 @@ package info.nightscout.androidaps
import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.ProfileSealed
import info.nightscout.androidaps.extensions.pureProfileFromJson
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.utils.DefaultValueHelper
import info.nightscout.androidaps.utils.extensions.pureProfileFromJson
import info.nightscout.core.fabric.FabricPrivacy
import info.nightscout.core.profile.ProfileStoreObject
import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.Config
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileStore
import info.nightscout.rx.bus.RxBus
import info.nightscout.shared.interfaces.ResourceHelper

View file

@ -2,13 +2,13 @@ package info.nightscout.androidaps
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultImpl
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.Pump
import info.nightscout.androidaps.interfaces.PumpSync
import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.pump.Pump
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.pump.defs.ManufacturerType
import info.nightscout.interfaces.pump.defs.PumpDescription
import info.nightscout.interfaces.pump.defs.PumpType

View file

@ -8,7 +8,6 @@ import info.nightscout.androidaps.data.PumpEnactResultImpl
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.CommandQueue
import info.nightscout.androidaps.interfaces.Loop
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.automation.triggers.Trigger
import info.nightscout.database.entities.OfflineEvent
@ -17,6 +16,7 @@ import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.constraints.Constraint
import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileSource
import info.nightscout.interfaces.smsCommunicator.SmsCommunicator
import info.nightscout.rx.logging.AAPSLogger

View file

@ -6,14 +6,10 @@ import info.nightscout.androidaps.extensions.lowTargetBlockValueBySeconds
import info.nightscout.androidaps.extensions.shiftBlock
import info.nightscout.androidaps.extensions.shiftTargetBlock
import info.nightscout.androidaps.extensions.targetBlockValueBySeconds
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.Profile.Companion.secondsFromMidnight
import info.nightscout.androidaps.interfaces.Profile.Companion.toMgdl
import info.nightscout.androidaps.interfaces.Profile.ProfileValue
import info.nightscout.androidaps.interfaces.Pump
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
import info.nightscout.androidaps.utils.HardLimits
import info.nightscout.core.main.R
import info.nightscout.core.profile.secondsFromMidnight
import info.nightscout.core.profile.toMgdl
import info.nightscout.database.entities.EffectiveProfileSwitch
import info.nightscout.database.entities.ProfileSwitch
import info.nightscout.database.entities.data.Block
@ -23,7 +19,11 @@ import info.nightscout.database.entities.embedments.InterfaceIDs
import info.nightscout.interfaces.Config
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.notifications.Notification
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.Profile.ProfileValue
import info.nightscout.interfaces.profile.PureProfile
import info.nightscout.interfaces.pump.Pump
import info.nightscout.interfaces.utils.HardLimits
import info.nightscout.rx.bus.RxBus
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.utils.DateUtil
@ -161,14 +161,14 @@ sealed class ProfileSealed(
break
}
for (isf in isfBlocks)
if (!hardLimits.isInRange(toMgdl(isf.amount * 100.0 / percentage, units), HardLimits.MIN_ISF, HardLimits.MAX_ISF)) {
if (!hardLimits.isInRange(Profile.toMgdl(isf.amount * 100.0 / percentage, units), HardLimits.MIN_ISF, HardLimits.MAX_ISF)) {
validityCheck.isValid = false
validityCheck.reasons.add(rh.gs(R.string.value_out_of_hard_limits, rh.gs(R.string.profile_sensitivity_value), isf.amount * 100.0 / percentage))
break
}
for (target in targetBlocks) {
if (!hardLimits.isInRange(
toMgdl(target.lowTarget, units),
Profile.toMgdl(target.lowTarget, units),
HardLimits.VERY_HARD_LIMIT_MIN_BG[0],
HardLimits.VERY_HARD_LIMIT_MIN_BG[1]
)
@ -178,7 +178,7 @@ sealed class ProfileSealed(
break
}
if (!hardLimits.isInRange(
toMgdl(target.highTarget, units),
Profile.toMgdl(target.highTarget, units),
HardLimits.VERY_HARD_LIMIT_MAX_BG[0],
HardLimits.VERY_HARD_LIMIT_MAX_BG[1]
)
@ -214,11 +214,11 @@ sealed class ProfileSealed(
override fun isEqual(profile: Profile): Boolean {
for (hour in 0..23) {
val seconds = T.hours(hour.toLong()).secs().toInt()
if (getBasalTimeFromMidnight(seconds) != profile.getBasalTimeFromMidnight(seconds)) return false
if (getIsfMgdlTimeFromMidnight(seconds) != profile.getIsfMgdlTimeFromMidnight(seconds)) return false
if (getIcTimeFromMidnight(seconds) != profile.getIcTimeFromMidnight(seconds)) return false
if (getTargetLowMgdlTimeFromMidnight(seconds) != profile.getTargetLowMgdlTimeFromMidnight(seconds)) return false
if (getTargetHighMgdlTimeFromMidnight(seconds) != profile.getTargetHighMgdlTimeFromMidnight(seconds)) return false
if (getBasalTimeFromMidnight(seconds) != profile.getBasalTimeFromMidnight(seconds)) return false
if (getIsfMgdlTimeFromMidnight(seconds) != profile.getIsfMgdlTimeFromMidnight(seconds)) return false
if (getIcTimeFromMidnight(seconds) != profile.getIcTimeFromMidnight(seconds)) return false
if (getTargetLowMgdlTimeFromMidnight(seconds) != profile.getTargetLowMgdlTimeFromMidnight(seconds)) return false
if (getTargetHighMgdlTimeFromMidnight(seconds) != profile.getTargetHighMgdlTimeFromMidnight(seconds)) return false
}
if (dia != profile.dia) return false
if ((profile is EPS) && profileName != profile.value.originalProfileName) return false // handle profile name change too
@ -228,29 +228,33 @@ sealed class ProfileSealed(
override val percentage: Int
get() = pct
override fun getBasal(): Double = basalBlocks.blockValueBySeconds(secondsFromMidnight(), percentage / 100.0, timeshift)
override fun getBasal(timestamp: Long): Double = basalBlocks.blockValueBySeconds(secondsFromMidnight(timestamp), percentage / 100.0, timeshift)
override fun getIc(): Double = icBlocks.blockValueBySeconds(secondsFromMidnight(), 100.0 / percentage, timeshift)
override fun getIc(timestamp: Long): Double = icBlocks.blockValueBySeconds(secondsFromMidnight(timestamp), 100.0 / percentage, timeshift)
override fun getIsfMgdl(): Double = toMgdl(isfBlocks.blockValueBySeconds(secondsFromMidnight(), 100.0 / percentage, timeshift), units)
override fun getIsfMgdl(timestamp: Long): Double = toMgdl(isfBlocks.blockValueBySeconds(secondsFromMidnight(timestamp), 100.0 / percentage, timeshift), units)
override fun getTargetMgdl(): Double = toMgdl(targetBlocks.targetBlockValueBySeconds(secondsFromMidnight(), timeshift), units)
override fun getTargetLowMgdl(): Double = toMgdl(targetBlocks.lowTargetBlockValueBySeconds(secondsFromMidnight(), timeshift), units)
override fun getTargetLowMgdl(timestamp: Long): Double = toMgdl(targetBlocks.lowTargetBlockValueBySeconds(secondsFromMidnight(timestamp), timeshift), units)
override fun getTargetHighMgdl(): Double = toMgdl(targetBlocks.highTargetBlockValueBySeconds(secondsFromMidnight(), timeshift), units)
override fun getTargetHighMgdl(timestamp: Long): Double = toMgdl(targetBlocks.highTargetBlockValueBySeconds(secondsFromMidnight(timestamp), timeshift), units)
override fun getBasal(): Double = basalBlocks.blockValueBySeconds(Profile.secondsFromMidnight(), percentage / 100.0, timeshift)
override fun getBasal(timestamp: Long): Double = basalBlocks.blockValueBySeconds(Profile.secondsFromMidnight(timestamp), percentage / 100.0, timeshift)
override fun getIc(): Double = icBlocks.blockValueBySeconds(Profile.secondsFromMidnight(), 100.0 / percentage, timeshift)
override fun getIc(timestamp: Long): Double = icBlocks.blockValueBySeconds(Profile.secondsFromMidnight(timestamp), 100.0 / percentage, timeshift)
override fun getIsfMgdl(): Double = Profile.toMgdl(isfBlocks.blockValueBySeconds(Profile.secondsFromMidnight(), 100.0 / percentage, timeshift), units)
override fun getIsfMgdl(timestamp: Long): Double = Profile.toMgdl(isfBlocks.blockValueBySeconds(Profile.secondsFromMidnight(timestamp), 100.0 / percentage, timeshift), units)
override fun getTargetMgdl(): Double = Profile.toMgdl(targetBlocks.targetBlockValueBySeconds(Profile.secondsFromMidnight(), timeshift), units)
override fun getTargetLowMgdl(): Double = Profile.toMgdl(targetBlocks.lowTargetBlockValueBySeconds(Profile.secondsFromMidnight(), timeshift), units)
override fun getTargetLowMgdl(timestamp: Long): Double = Profile.toMgdl(targetBlocks.lowTargetBlockValueBySeconds(Profile.secondsFromMidnight(timestamp), timeshift), units)
override fun getTargetHighMgdl(): Double = Profile.toMgdl(targetBlocks.highTargetBlockValueBySeconds(Profile.secondsFromMidnight(), timeshift), units)
override fun getTargetHighMgdl(timestamp: Long): Double = Profile.toMgdl(targetBlocks.highTargetBlockValueBySeconds(Profile.secondsFromMidnight(timestamp), timeshift), units)
override fun getBasalTimeFromMidnight(timeAsSeconds: Int): Double = basalBlocks.blockValueBySeconds(timeAsSeconds, percentage / 100.0, timeshift)
override fun getIcTimeFromMidnight(timeAsSeconds: Int): Double = icBlocks.blockValueBySeconds(timeAsSeconds, 100.0 / percentage, timeshift)
fun getIsfTimeFromMidnight(timeAsSeconds: Int): Double = isfBlocks.blockValueBySeconds(timeAsSeconds, 100.0 / percentage, timeshift)
override fun getIsfMgdlTimeFromMidnight(timeAsSeconds: Int): Double = toMgdl(isfBlocks.blockValueBySeconds(timeAsSeconds, 100.0 / percentage, timeshift), units)
override fun getTargetLowMgdlTimeFromMidnight(timeAsSeconds: Int): Double = toMgdl(targetBlocks.lowTargetBlockValueBySeconds(timeAsSeconds, timeshift), units)
override fun getIsfMgdlTimeFromMidnight(timeAsSeconds: Int): Double = Profile.toMgdl(isfBlocks.blockValueBySeconds(timeAsSeconds, 100.0 / percentage, timeshift), units)
override fun getTargetLowMgdlTimeFromMidnight(timeAsSeconds: Int): Double = Profile.toMgdl(targetBlocks.lowTargetBlockValueBySeconds(timeAsSeconds, timeshift), units)
private fun getTargetLowTimeFromMidnight(timeAsSeconds: Int): Double = targetBlocks.lowTargetBlockValueBySeconds(timeAsSeconds, timeshift)
private fun getTargetHighTimeFromMidnight(timeAsSeconds: Int): Double = targetBlocks.highTargetBlockValueBySeconds(timeAsSeconds, timeshift)
override fun getTargetHighMgdlTimeFromMidnight(timeAsSeconds: Int): Double = toMgdl(targetBlocks.highTargetBlockValueBySeconds(timeAsSeconds, timeshift), units)
override fun getTargetHighMgdlTimeFromMidnight(timeAsSeconds: Int): Double = Profile.toMgdl(targetBlocks.highTargetBlockValueBySeconds(timeAsSeconds, timeshift), units)
override fun getIcList(rh: ResourceHelper, dateUtil: DateUtil): String = getValuesList(icBlocks, 100.0 / percentage, DecimalFormat("0.0"), rh.gs(R.string.profile_carbs_per_unit), dateUtil)
override fun getIsfList(rh: ResourceHelper, dateUtil: DateUtil): String = getValuesList(isfBlocks, 100.0 / percentage, DecimalFormat("0.0"), units.asText + rh.gs(R.string.profile_per_unit), dateUtil)
override fun getBasalList(rh: ResourceHelper, dateUtil: DateUtil): String = getValuesList(basalBlocks, percentage / 100.0, DecimalFormat("0.00"), rh.gs(R.string.profile_ins_units_per_hour), dateUtil)
override fun getIsfList(rh: ResourceHelper, dateUtil: DateUtil): String =
getValuesList(isfBlocks, 100.0 / percentage, DecimalFormat("0.0"), units.asText + rh.gs(R.string.profile_per_unit), dateUtil)
override fun getBasalList(rh: ResourceHelper, dateUtil: DateUtil): String =
getValuesList(basalBlocks, percentage / 100.0, DecimalFormat("0.00"), rh.gs(R.string.profile_ins_units_per_hour), dateUtil)
override fun getTargetList(rh: ResourceHelper, dateUtil: DateUtil): String = getTargetValuesList(targetBlocks, DecimalFormat("0.0"), units.asText, dateUtil)
override fun convertToNonCustomizedProfile(dateUtil: DateUtil): PureProfile =
@ -278,10 +282,11 @@ sealed class ProfileSealed(
val sens = JSONArray()
var elapsedHours = 0L
isfBlocks.forEach {
sens.put(JSONObject()
.put("time", DecimalFormat("00").format(elapsedHours) + ":00")
.put("timeAsSeconds", T.hours(elapsedHours).secs())
.put("value", getIsfTimeFromMidnight(T.hours(elapsedHours).secs().toInt()))
sens.put(
JSONObject()
.put("time", DecimalFormat("00").format(elapsedHours) + ":00")
.put("timeAsSeconds", T.hours(elapsedHours).secs())
.put("value", getIsfTimeFromMidnight(T.hours(elapsedHours).secs().toInt()))
)
elapsedHours += T.msecs(it.duration).hours()
}
@ -289,10 +294,11 @@ sealed class ProfileSealed(
val carbratio = JSONArray()
elapsedHours = 0L
icBlocks.forEach {
carbratio.put(JSONObject()
.put("time", DecimalFormat("00").format(elapsedHours) + ":00")
.put("timeAsSeconds", T.hours(elapsedHours).secs())
.put("value", getIcTimeFromMidnight(T.hours(elapsedHours).secs().toInt()))
carbratio.put(
JSONObject()
.put("time", DecimalFormat("00").format(elapsedHours) + ":00")
.put("timeAsSeconds", T.hours(elapsedHours).secs())
.put("value", getIcTimeFromMidnight(T.hours(elapsedHours).secs().toInt()))
)
elapsedHours += T.msecs(it.duration).hours()
}
@ -300,10 +306,11 @@ sealed class ProfileSealed(
val basal = JSONArray()
elapsedHours = 0L
basalBlocks.forEach {
basal.put(JSONObject()
.put("time", DecimalFormat("00").format(elapsedHours) + ":00")
.put("timeAsSeconds", T.hours(elapsedHours).secs())
.put("value", getBasalTimeFromMidnight(T.hours(elapsedHours).secs().toInt()))
basal.put(
JSONObject()
.put("time", DecimalFormat("00").format(elapsedHours) + ":00")
.put("timeAsSeconds", T.hours(elapsedHours).secs())
.put("value", getBasalTimeFromMidnight(T.hours(elapsedHours).secs().toInt()))
)
elapsedHours += T.msecs(it.duration).hours()
}
@ -312,15 +319,17 @@ sealed class ProfileSealed(
val targetHigh = JSONArray()
elapsedHours = 0L
targetBlocks.forEach {
targetLow.put(JSONObject()
.put("time", DecimalFormat("00").format(elapsedHours) + ":00")
.put("timeAsSeconds", T.hours(elapsedHours).secs())
.put("value", getTargetLowTimeFromMidnight(T.hours(elapsedHours).secs().toInt()))
targetLow.put(
JSONObject()
.put("time", DecimalFormat("00").format(elapsedHours) + ":00")
.put("timeAsSeconds", T.hours(elapsedHours).secs())
.put("value", getTargetLowTimeFromMidnight(T.hours(elapsedHours).secs().toInt()))
)
targetHigh.put(JSONObject()
.put("time", DecimalFormat("00").format(elapsedHours) + ":00")
.put("timeAsSeconds", T.hours(elapsedHours).secs())
.put("value", getTargetHighTimeFromMidnight(T.hours(elapsedHours).secs().toInt()))
targetHigh.put(
JSONObject()
.put("time", DecimalFormat("00").format(elapsedHours) + ":00")
.put("timeAsSeconds", T.hours(elapsedHours).secs())
.put("value", getTargetHighTimeFromMidnight(T.hours(elapsedHours).secs().toInt()))
)
elapsedHours += T.msecs(it.duration).hours()
}
@ -351,7 +360,7 @@ sealed class ProfileSealed(
val ret = Array(shifted.size) { ProfileValue(0, 0.0) }
var elapsed = 0
for (index in shifted.indices) {
ret[index] = ProfileValue(elapsed, toMgdl(shifted[index].amount, units))
ret[index] = ProfileValue(elapsed, Profile.toMgdl(shifted[index].amount, units))
elapsed += T.msecs(shifted[index].duration).secs().toInt()
}
return ret

View file

@ -9,24 +9,26 @@ import android.view.Window
import android.view.WindowManager
import dagger.android.HasAndroidInjector
import dagger.android.support.DaggerDialogFragment
import info.nightscout.androidaps.data.ProfileSealed
import info.nightscout.androidaps.extensions.getCustomizedName
import info.nightscout.androidaps.extensions.pureProfileFromJson
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.core.main.R
import info.nightscout.core.main.databinding.DialogProfileviewerBinding
import info.nightscout.androidaps.data.ProfileSealed
import info.nightscout.core.profile.fromMgdlToUnits
import info.nightscout.core.profile.toUnitsString
import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.ValueWrapper
import info.nightscout.shared.extensions.toVisibility
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.utils.DateUtil
import info.nightscout.androidaps.utils.HardLimits
import info.nightscout.androidaps.utils.extensions.getCustomizedName
import info.nightscout.androidaps.utils.extensions.pureProfileFromJson
import info.nightscout.interfaces.Config
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.utils.HardLimits
import info.nightscout.interfaces.utils.HtmlHelper
import info.nightscout.rx.bus.RxBus
import info.nightscout.shared.extensions.toVisibility
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.utils.DateUtil
import org.json.JSONObject
import java.text.DecimalFormat
import javax.inject.Inject

View file

@ -2,9 +2,10 @@ package info.nightscout.androidaps.extensions
import com.google.gson.Gson
import com.google.gson.JsonSyntaxException
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.core.profile.fromMgdlToUnits
import info.nightscout.database.entities.BolusCalculatorResult
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.shared.utils.DateUtil
import org.json.JSONObject

View file

@ -1,14 +1,14 @@
package info.nightscout.androidaps.extensions
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult
import info.nightscout.androidaps.utils.DecimalFormatter.to2Decimal
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.database.entities.Bolus
import info.nightscout.database.entities.ExtendedBolus
import info.nightscout.database.entities.TemporaryBasal
import info.nightscout.database.entities.interfaces.end
import info.nightscout.interfaces.insulin.Insulin
import info.nightscout.interfaces.iob.IobTotal
import info.nightscout.interfaces.profile.Profile
import info.nightscout.shared.utils.DateUtil
import info.nightscout.shared.utils.T
import kotlin.math.ceil
@ -24,13 +24,13 @@ val ExtendedBolus.plannedRemainingMinutes: Int
get() = max(round((end - System.currentTimeMillis()) / 1000.0 / 60).toInt(), 0)
fun ExtendedBolus.toStringFull(dateUtil: DateUtil): String =
"E " + to2Decimal(rate) + "U/h @" + dateUtil.timeString(timestamp) +
"E " + DecimalFormatter.to2Decimal(rate) + "U/h @" + dateUtil.timeString(timestamp) +
" " + getPassedDurationToTimeInMinutes(dateUtil.now()) + "/" + T.msecs(duration).mins() + "min"
fun ExtendedBolus.toStringMedium(dateUtil: DateUtil): String =
to2Decimal(rate) + "U/h " + getPassedDurationToTimeInMinutes(dateUtil.now()) + "/" + T.msecs(duration).mins() + "'"
DecimalFormatter.to2Decimal(rate) + "U/h " + getPassedDurationToTimeInMinutes(dateUtil.now()) + "/" + T.msecs(duration).mins() + "'"
fun ExtendedBolus.toStringTotal(): String = "${to2Decimal(amount)}U ( ${to2Decimal(rate)} U/h )"
fun ExtendedBolus.toStringTotal(): String = "${DecimalFormatter.to2Decimal(amount)}U ( ${DecimalFormatter.to2Decimal(rate)} U/h )"
fun ExtendedBolus.getPassedDurationToTimeInMinutes(time: Long): Int =
((min(time, end) - timestamp) / 60.0 / 1000).roundToInt()

View file

@ -1,5 +1,6 @@
package info.nightscout.androidaps.extensions
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.database.entities.GlucoseValue
import info.nightscout.interfaces.Constants

View file

@ -1,9 +1,7 @@
package info.nightscout.androidaps.utils.extensions
package info.nightscout.androidaps.extensions
import info.nightscout.androidaps.data.ProfileSealed
import info.nightscout.androidaps.extensions.blockFromJsonArray
import info.nightscout.androidaps.extensions.targetBlockFromJsonArray
import info.nightscout.androidaps.utils.DecimalFormatter.to2Decimal
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.database.entities.ProfileSwitch
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.GlucoseUnit
@ -29,7 +27,7 @@ fun List<ProfileSwitch>.isPSEvent5minBack(time: Long): Boolean {
fun ProfileSwitch.getCustomizedName(): String {
var name: String = profileName
if (Constants.LOCAL_PROFILE == name) {
name = to2Decimal(ProfileSealed.PS(this).percentageBasalSum()) + "U "
name = DecimalFormatter.to2Decimal(ProfileSealed.PS(this).percentageBasalSum()) + "U "
}
if (timeshift != 0L || percentage != 100) {
name += "($percentage%"

View file

@ -1,14 +1,13 @@
package info.nightscout.androidaps.extensions
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult
import info.nightscout.androidaps.utils.DecimalFormatter.to0Decimal
import info.nightscout.androidaps.utils.DecimalFormatter.to2Decimal
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.database.entities.Bolus
import info.nightscout.database.entities.TemporaryBasal
import info.nightscout.database.entities.interfaces.end
import info.nightscout.interfaces.insulin.Insulin
import info.nightscout.interfaces.iob.IobTotal
import info.nightscout.interfaces.profile.Profile
import info.nightscout.shared.utils.DateUtil
import info.nightscout.shared.utils.T
import kotlin.math.ceil
@ -38,13 +37,13 @@ val TemporaryBasal.durationInMinutes
fun TemporaryBasal.toStringFull(profile: Profile, dateUtil: DateUtil): String {
return when {
type == TemporaryBasal.Type.FAKE_EXTENDED -> {
to2Decimal(rate) + "U/h (" + to2Decimal(netExtendedRate(profile)) + "E) @" +
DecimalFormatter.to2Decimal(rate) + "U/h (" + DecimalFormatter.to2Decimal(netExtendedRate(profile)) + "E) @" +
dateUtil.timeString(timestamp) +
" " + getPassedDurationToTimeInMinutes(dateUtil.now()) + "/" + durationInMinutes + "'"
}
isAbsolute -> {
to2Decimal(rate) + "U/h @" +
DecimalFormatter.to2Decimal(rate) + "U/h @" +
dateUtil.timeString(timestamp) +
" " + getPassedDurationToTimeInMinutes(dateUtil.now()) + "/" + durationInMinutes + "'"
}
@ -58,8 +57,8 @@ fun TemporaryBasal.toStringFull(profile: Profile, dateUtil: DateUtil): String {
}
fun TemporaryBasal.toStringShort(): String =
if (isAbsolute || type == TemporaryBasal.Type.FAKE_EXTENDED) to2Decimal(rate) + "U/h"
else "${to0Decimal(rate)}%"
if (isAbsolute || type == TemporaryBasal.Type.FAKE_EXTENDED) DecimalFormatter.to2Decimal(rate) + "U/h"
else "${DecimalFormatter.to0Decimal(rate)}%"
fun TemporaryBasal.iobCalc(time: Long, profile: Profile, insulinInterface: Insulin): IobTotal {
val result = IobTotal(time)

View file

@ -1,11 +1,12 @@
package info.nightscout.androidaps.extensions
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.core.main.R
import info.nightscout.core.profile.toTargetRangeString
import info.nightscout.database.entities.TemporaryTarget
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.profile.Profile
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.utils.DateUtil
import java.util.concurrent.TimeUnit

View file

@ -6,6 +6,7 @@ import info.nightscout.interfaces.insulin.Insulin
import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.profile.ProfileSource
import info.nightscout.interfaces.pump.Pump
import info.nightscout.interfaces.sync.NsClient
import info.nightscout.interfaces.sync.Sync

View file

@ -1,9 +1,11 @@
package info.nightscout.androidaps.interfaces
import android.text.Spanned
import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.queue.Callback
import info.nightscout.androidaps.queue.commands.Command
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.CustomCommand
interface CommandQueue {

View file

@ -2,6 +2,7 @@ package info.nightscout.androidaps.interfaces
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.constraints.Constraint
import info.nightscout.interfaces.profile.Profile
/**
* Constraints interface

View file

@ -4,6 +4,7 @@ import info.nightscout.androidaps.plugins.aps.loop.APSResult
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus
import info.nightscout.interfaces.iob.IobTotal
import info.nightscout.interfaces.iob.MealData
import info.nightscout.interfaces.profile.Profile
interface DetermineBasalAdapterInterface {

View file

@ -9,6 +9,7 @@ import info.nightscout.database.entities.ExtendedBolus
import info.nightscout.database.entities.TemporaryBasal
import info.nightscout.interfaces.iob.IobTotal
import info.nightscout.interfaces.iob.MealData
import info.nightscout.interfaces.profile.Profile
import org.json.JSONArray
interface IobCobCalculator {

View file

@ -3,6 +3,7 @@ package info.nightscout.androidaps.interfaces
import info.nightscout.androidaps.plugins.aps.loop.APSResult
import info.nightscout.database.entities.OfflineEvent
import info.nightscout.interfaces.constraints.Constraint
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.pump.PumpEnactResult
interface Loop {

View file

@ -1,212 +0,0 @@
package info.nightscout.androidaps.interfaces
import info.nightscout.androidaps.utils.DecimalFormatter.to0Decimal
import info.nightscout.androidaps.utils.DecimalFormatter.to1Decimal
import info.nightscout.androidaps.utils.HardLimits
import info.nightscout.interfaces.Config
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.profile.PureProfile
import info.nightscout.interfaces.utils.Round
import info.nightscout.rx.bus.RxBus
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.utils.DateUtil
import org.joda.time.DateTime
import org.json.JSONObject
interface Profile {
class ValidityCheck(var isValid: Boolean = true, val reasons: ArrayList<String> = arrayListOf())
fun isValid(from: String, pump: Pump, config: Config, rh: ResourceHelper, rxBus: RxBus, hardLimits: HardLimits, sendNotifications: Boolean): ValidityCheck
/**
* Units used for ISF & target
*/
val units: GlucoseUnit
//@Deprecated("Replace in favor of accessing InsulinProfile")
val dia: Double
val percentage: Int
/**
* Timeshift modifier of base profile in hours
*/
val timeshift: Int
/**
* is equal to another profile?
*/
fun isEqual(profile: Profile): Boolean
/**
* Basal value according to "now"
*/
fun getBasal(): Double
/**
* Basal value according to timestamp
*/
fun getBasal(timestamp: Long): Double
/**
* I:C value according to "now"
*/
fun getIc(): Double
/**
* I:C value according to timestamp
*/
fun getIc(timestamp: Long): Double
/**
* ISF value according to "now"" in MGDL
*/
fun getIsfMgdl(): Double
/**
* ISF value according to timestamp in MGDL
*/
fun getIsfMgdl(timestamp: Long): Double
/**
* Average target value according to "now" in MGDL
*/
fun getTargetMgdl(): Double
fun getTargetLowMgdl(): Double
fun getTargetLowMgdl(timestamp: Long): Double
fun getTargetHighMgdl(): Double
fun getTargetHighMgdl(timestamp: Long): Double
/**
* Basal value according to elapsed seconds from midnight
*/
fun getBasalTimeFromMidnight(timeAsSeconds: Int): Double
/**
* I:C value according to elapsed seconds from midnight
*/
fun getIcTimeFromMidnight(timeAsSeconds: Int): Double
/**
* ISF value according to elapsed seconds from midnight
*/
fun getIsfMgdlTimeFromMidnight(timeAsSeconds: Int): Double
/**
* Low target value according to elapsed seconds from midnight
*/
fun getTargetLowMgdlTimeFromMidnight(timeAsSeconds: Int): Double
/**
* High target value according to elapsed seconds from midnight in MGDL
*/
fun getTargetHighMgdlTimeFromMidnight(timeAsSeconds: Int): Double
fun getIcList(rh: ResourceHelper, dateUtil: DateUtil): String
fun getIsfList(rh: ResourceHelper, dateUtil: DateUtil): String
fun getBasalList(rh: ResourceHelper, dateUtil: DateUtil): String
fun getTargetList(rh: ResourceHelper, dateUtil: DateUtil): String
fun convertToNonCustomizedProfile(dateUtil: DateUtil): PureProfile
fun toPureNsJson(dateUtil: DateUtil): JSONObject
fun getMaxDailyBasal(): Double
fun baseBasalSum(): Double
fun percentageBasalSum(): Double
fun getBasalValues(): Array<ProfileValue>
fun getIcsValues(): Array<ProfileValue>
fun getIsfsMgdlValues(): Array<ProfileValue>
fun getSingleTargetsMgdl(): Array<ProfileValue>
open class ProfileValue(var timeAsSeconds: Int, var value: Double) {
override fun equals(other: Any?): Boolean {
if (other !is ProfileValue) {
return false
}
return timeAsSeconds == other.timeAsSeconds && Round.isSame(value, other.value)
}
override fun hashCode(): Int {
var result = timeAsSeconds
result = 31 * result + value.hashCode()
return result
}
}
companion object {
/*
* Midnight time conversion
*/
fun secondsFromMidnight(): Int {
val passed = DateTime().millisOfDay.toLong()
return (passed / 1000).toInt()
}
fun secondsFromMidnight(date: Long): Int {
val passed = DateTime(date).millisOfDay.toLong()
return (passed / 1000).toInt()
}
fun milliSecFromMidnight(date: Long): Long {
return DateTime(date).millisOfDay.toLong()
}
/*
* Units conversion
*/
fun fromMgdlToUnits(value: Double, units: GlucoseUnit): Double =
if (units == GlucoseUnit.MGDL) value else value * Constants.MGDL_TO_MMOLL
fun fromMmolToUnits(value: Double, units: GlucoseUnit): Double =
if (units == GlucoseUnit.MMOL) value else value * Constants.MMOLL_TO_MGDL
fun toUnits(valueInMgdl: Double, valueInMmol: Double, units: GlucoseUnit): Double =
if (units == GlucoseUnit.MGDL) valueInMgdl else valueInMmol
fun toUnitsString(valueInMgdl: Double, valueInMmol: Double, units: GlucoseUnit): String =
if (units == GlucoseUnit.MGDL) to0Decimal(valueInMgdl) else to1Decimal(valueInMmol)
fun toSignedUnitsString(valueInMgdl: Double, valueInMmol: Double, units: GlucoseUnit): String =
if (units == GlucoseUnit.MGDL) (if (valueInMgdl > 0) "+" else "") + to0Decimal(valueInMgdl)
else (if (valueInMmol > 0) "+" else "") + to1Decimal(valueInMmol)
fun isMgdl(anyBg: Double) = anyBg >= 39
fun isMmol(anyBg: Double) = anyBg < 39
fun unit(anyBg: Double) = if (isMgdl(anyBg)) GlucoseUnit.MGDL else GlucoseUnit.MMOL
fun toCurrentUnits(profileFunction: ProfileFunction, anyBg: Double): Double =
if (isMmol(anyBg)) fromMmolToUnits(anyBg, profileFunction.getUnits())
else fromMgdlToUnits(anyBg, profileFunction.getUnits())
fun toCurrentUnits(units: GlucoseUnit, anyBg: Double): Double =
if (isMmol(anyBg)) fromMmolToUnits(anyBg, units)
else fromMgdlToUnits(anyBg, units)
fun toCurrentUnitsString(profileFunction: ProfileFunction, anyBg: Double): String =
if (isMmol(anyBg)) toUnitsString(anyBg * Constants.MMOLL_TO_MGDL, anyBg, profileFunction.getUnits())
else toUnitsString(anyBg, anyBg * Constants.MGDL_TO_MMOLL, profileFunction.getUnits())
fun toMgdl(value: Double): Double =
if (isMgdl(value)) value else value * Constants.MMOLL_TO_MGDL
fun toMgdl(value: Double, units: GlucoseUnit): Double =
if (units == GlucoseUnit.MGDL) value else value * Constants.MMOLL_TO_MGDL
fun toMmol(value: Double, units: GlucoseUnit): Double =
if (units == GlucoseUnit.MGDL) value * Constants.MGDL_TO_MMOLL else value
// targets are stored in mg/dl but profile vary
fun toTargetRangeString(low: Double, high: Double, sourceUnits: GlucoseUnit, units: GlucoseUnit): String {
val lowMgdl = toMgdl(low, sourceUnits)
val highMgdl = toMgdl(high, sourceUnits)
val lowMmol = toMmol(low, sourceUnits)
val highMmol = toMmol(high, sourceUnits)
return if (low == high) toUnitsString(lowMgdl, lowMmol, units) else toUnitsString(lowMgdl, lowMmol, units) + " - " + toUnitsString(highMgdl, highMmol, units)
}
}
}

View file

@ -2,6 +2,7 @@ package info.nightscout.androidaps.interfaces
import info.nightscout.database.entities.ProfileSwitch
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileStore
interface ProfileFunction {

View file

@ -1,13 +1,14 @@
package info.nightscout.androidaps.plugins.general.overview.graphExtensions
import android.content.Context
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.utils.DefaultValueHelper
import info.nightscout.core.main.R
import info.nightscout.core.profile.toCurrentUnitsString
import info.nightscout.database.entities.GlucoseValue
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.profile.Profile
import info.nightscout.shared.interfaces.ResourceHelper
class GlucoseValueDataPoint(

View file

@ -1,12 +1,14 @@
package info.nightscout.androidaps.plugins.general.overview.graphExtensions
import android.content.Context
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.utils.Translator
import info.nightscout.core.main.R
import info.nightscout.core.profile.fromMgdlToUnits
import info.nightscout.core.profile.toUnits
import info.nightscout.database.entities.TherapyEvent
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.profile.Profile
import info.nightscout.shared.interfaces.ResourceHelper
class TherapyEventDataPoint(

View file

@ -1,10 +1,10 @@
package info.nightscout.androidaps.plugins.pump.common.bolusInfo
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.androidaps.interfaces.PumpSync
import info.nightscout.shared.utils.T
import info.nightscout.interfaces.pump.PumpSync
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

View file

@ -1,7 +1,7 @@
package info.nightscout.androidaps.utils
import info.nightscout.core.main.R
import info.nightscout.androidaps.interfaces.Pump
import info.nightscout.interfaces.pump.Pump
import info.nightscout.shared.interfaces.ResourceHelper
import java.text.DecimalFormat

View file

@ -1,11 +1,12 @@
package info.nightscout.androidaps.utils
import info.nightscout.interfaces.Constants
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.core.main.R
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.core.main.R
import info.nightscout.core.profile.toCurrentUnits
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.profile.Profile
import info.nightscout.shared.sharedPreferences.SP
import javax.inject.Inject
import javax.inject.Singleton

View file

@ -7,10 +7,37 @@ import android.text.TextWatcher
import android.widget.EditText
import com.google.android.material.textfield.TextInputLayout
import dagger.android.HasAndroidInjector
import info.nightscout.core.main.R
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.utils.textValidator.validators.*
import info.nightscout.androidaps.utils.textValidator.validators.AlphaNumericValidator
import info.nightscout.androidaps.utils.textValidator.validators.AlphaValidator
import info.nightscout.androidaps.utils.textValidator.validators.AndValidator
import info.nightscout.androidaps.utils.textValidator.validators.BgRangeValidator
import info.nightscout.androidaps.utils.textValidator.validators.CreditCardValidator
import info.nightscout.androidaps.utils.textValidator.validators.DateValidator
import info.nightscout.androidaps.utils.textValidator.validators.DomainValidator
import info.nightscout.androidaps.utils.textValidator.validators.DummyValidator
import info.nightscout.androidaps.utils.textValidator.validators.EmailValidator
import info.nightscout.androidaps.utils.textValidator.validators.EmptyValidator
import info.nightscout.androidaps.utils.textValidator.validators.FloatNumericRangeValidator
import info.nightscout.androidaps.utils.textValidator.validators.HttpsUrlValidator
import info.nightscout.androidaps.utils.textValidator.validators.IpAddressValidator
import info.nightscout.androidaps.utils.textValidator.validators.MinDigitLengthValidator
import info.nightscout.androidaps.utils.textValidator.validators.MultiPhoneValidator
import info.nightscout.androidaps.utils.textValidator.validators.MultiValidator
import info.nightscout.androidaps.utils.textValidator.validators.NotValidator
import info.nightscout.androidaps.utils.textValidator.validators.NumericRangeValidator
import info.nightscout.androidaps.utils.textValidator.validators.NumericValidator
import info.nightscout.androidaps.utils.textValidator.validators.OrValidator
import info.nightscout.androidaps.utils.textValidator.validators.PersonFullNameValidator
import info.nightscout.androidaps.utils.textValidator.validators.PersonNameValidator
import info.nightscout.androidaps.utils.textValidator.validators.PhoneValidator
import info.nightscout.androidaps.utils.textValidator.validators.PinStrengthValidator
import info.nightscout.androidaps.utils.textValidator.validators.RegexpValidator
import info.nightscout.androidaps.utils.textValidator.validators.Validator
import info.nightscout.androidaps.utils.textValidator.validators.WebUrlValidator
import info.nightscout.core.main.R
import info.nightscout.core.profile.fromMgdlToUnits
import info.nightscout.interfaces.profile.Profile
import javax.inject.Inject
@Suppress("SpellCheckingInspection")

View file

@ -5,9 +5,11 @@ import android.util.AttributeSet
import androidx.preference.EditTextPreference
import androidx.preference.PreferenceViewHolder
import dagger.android.HasAndroidInjector
import info.nightscout.core.main.R
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.core.main.R
import info.nightscout.core.profile.fromMgdlToUnits
import info.nightscout.core.profile.toMgdl
import info.nightscout.interfaces.profile.Profile
import info.nightscout.shared.SafeParse
import javax.inject.Inject

View file

@ -1,8 +1,9 @@
package info.nightscout.androidaps.utils.textValidator.validators
import android.widget.EditText
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.core.profile.fromMgdlToUnits
import info.nightscout.interfaces.profile.Profile
class BgRangeValidator(_customErrorMessage: String?, private val min: Int, private val max: Int, private val profileFunction: ProfileFunction) : Validator(_customErrorMessage) {

View file

@ -7,7 +7,7 @@ import com.jjoe64.graphview.GraphView
import com.jjoe64.graphview.series.DataPoint
import com.jjoe64.graphview.series.LineGraphSeries
import info.nightscout.core.main.R
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.utils.Round
import java.text.NumberFormat
import kotlin.math.max

View file

@ -7,7 +7,7 @@ import com.jjoe64.graphview.GraphView
import com.jjoe64.graphview.series.DataPoint
import com.jjoe64.graphview.series.LineGraphSeries
import info.nightscout.core.main.R
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.utils.Round
import java.text.NumberFormat
import kotlin.math.max

View file

@ -7,7 +7,8 @@ import com.jjoe64.graphview.GraphView
import com.jjoe64.graphview.series.DataPoint
import com.jjoe64.graphview.series.LineGraphSeries
import info.nightscout.core.main.R
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.core.profile.fromMgdlToUnits
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.utils.Round
import java.text.NumberFormat
import kotlin.math.max

View file

@ -4,11 +4,12 @@ import android.content.Context
import android.util.AttributeSet
import com.jjoe64.graphview.DefaultLabelFormatter
import com.jjoe64.graphview.GraphView
import info.nightscout.core.main.R
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.AreaGraphSeries
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DoubleDataPoint
import info.nightscout.core.main.R
import info.nightscout.core.profile.fromMgdlToUnits
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.utils.Round
import java.text.NumberFormat
import kotlin.math.max

View file

@ -2,11 +2,11 @@ package info.nightscout.androidaps.utils.userEntry
import android.text.Spanned
import dagger.Reusable
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.androidaps.utils.Translator
import info.nightscout.core.main.R
import info.nightscout.core.profile.toUnitsString
import info.nightscout.database.entities.UserEntry
import info.nightscout.database.entities.UserEntry.Action
import info.nightscout.database.entities.UserEntry.ColorGroup
@ -14,6 +14,7 @@ import info.nightscout.database.entities.UserEntry.Sources
import info.nightscout.database.entities.ValueWithUnit
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.utils.HtmlHelper
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.utils.DateUtil

View file

@ -0,0 +1,80 @@
package info.nightscout.core.profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.profile.Profile
import org.joda.time.DateTime
/*
* Midnight time conversion
*/
fun Profile.Companion.secondsFromMidnight(): Int {
val passed = DateTime().millisOfDay.toLong()
return (passed / 1000).toInt()
}
fun Profile.Companion.secondsFromMidnight(date: Long): Int {
val passed = DateTime(date).millisOfDay.toLong()
return (passed / 1000).toInt()
}
fun Profile.Companion.milliSecFromMidnight(date: Long): Long {
return DateTime(date).millisOfDay.toLong()
}
/*
* Units conversion
*/
fun Profile.Companion.fromMgdlToUnits(value: Double, units: GlucoseUnit): Double =
if (units == GlucoseUnit.MGDL) value else value * Constants.MGDL_TO_MMOLL
fun Profile.Companion.fromMmolToUnits(value: Double, units: GlucoseUnit): Double =
if (units == GlucoseUnit.MMOL) value else value * Constants.MMOLL_TO_MGDL
fun Profile.Companion.toUnits(valueInMgdl: Double, valueInMmol: Double, units: GlucoseUnit): Double =
if (units == GlucoseUnit.MGDL) valueInMgdl else valueInMmol
fun Profile.Companion.toUnitsString(valueInMgdl: Double, valueInMmol: Double, units: GlucoseUnit): String =
if (units == GlucoseUnit.MGDL) DecimalFormatter.to0Decimal(valueInMgdl) else DecimalFormatter.to1Decimal(valueInMmol)
fun Profile.Companion.toSignedUnitsString(valueInMgdl: Double, valueInMmol: Double, units: GlucoseUnit): String =
if (units == GlucoseUnit.MGDL) (if (valueInMgdl > 0) "+" else "") + DecimalFormatter.to0Decimal(valueInMgdl)
else (if (valueInMmol > 0) "+" else "") + DecimalFormatter.to1Decimal(valueInMmol)
fun Profile.Companion.isMgdl(anyBg: Double) = anyBg >= 39
fun Profile.Companion.isMmol(anyBg: Double) = anyBg < 39
fun Profile.Companion.unit(anyBg: Double) = if (isMgdl(anyBg)) GlucoseUnit.MGDL else GlucoseUnit.MMOL
fun Profile.Companion.toCurrentUnits(profileFunction: ProfileFunction, anyBg: Double): Double =
if (isMmol(anyBg)) fromMmolToUnits(anyBg, profileFunction.getUnits())
else fromMgdlToUnits(anyBg, profileFunction.getUnits())
fun Profile.Companion.toCurrentUnits(units: GlucoseUnit, anyBg: Double): Double =
if (isMmol(anyBg)) fromMmolToUnits(anyBg, units)
else fromMgdlToUnits(anyBg, units)
fun Profile.Companion.toCurrentUnitsString(profileFunction: ProfileFunction, anyBg: Double): String =
if (isMmol(anyBg)) toUnitsString(anyBg * Constants.MMOLL_TO_MGDL, anyBg, profileFunction.getUnits())
else toUnitsString(anyBg, anyBg * Constants.MGDL_TO_MMOLL, profileFunction.getUnits())
fun Profile.Companion.toMgdl(value: Double): Double =
if (isMgdl(value)) value else value * Constants.MMOLL_TO_MGDL
fun Profile.Companion.toMgdl(value: Double, units: GlucoseUnit): Double =
if (units == GlucoseUnit.MGDL) value else value * Constants.MMOLL_TO_MGDL
fun Profile.Companion.toMmol(value: Double, units: GlucoseUnit): Double =
if (units == GlucoseUnit.MGDL) value * Constants.MGDL_TO_MMOLL else value
// targets are stored in mg/dl but profile vary
fun Profile.Companion.toTargetRangeString(low: Double, high: Double, sourceUnits: GlucoseUnit, units: GlucoseUnit): String {
val lowMgdl = toMgdl(low, sourceUnits)
val highMgdl = toMgdl(high, sourceUnits)
val lowMmol = toMmol(low, sourceUnits)
val highMmol = toMmol(high, sourceUnits)
return if (low == high) toUnitsString(lowMgdl, lowMmol, units)
else toUnitsString(lowMgdl, lowMmol, units) + " - " + toUnitsString(highMgdl, highMmol, units)
}

View file

@ -3,12 +3,12 @@ package info.nightscout.core.profile
import androidx.collection.ArrayMap
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.ProfileSealed
import info.nightscout.androidaps.extensions.pureProfileFromJson
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.utils.HardLimits
import info.nightscout.androidaps.utils.extensions.pureProfileFromJson
import info.nightscout.interfaces.Config
import info.nightscout.interfaces.profile.ProfileStore
import info.nightscout.interfaces.profile.PureProfile
import info.nightscout.interfaces.utils.HardLimits
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.logging.AAPSLogger

View file

@ -1,8 +1,8 @@
package info.nightscout.androidaps.extensions
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.PumpSync
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.shared.utils.DateUtil
import info.nightscout.shared.utils.T
import kotlin.math.ceil

View file

@ -4,16 +4,16 @@ import android.content.Context
import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.ProfileSealed
import info.nightscout.androidaps.extensions.pureProfileFromJson
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.utils.DefaultValueHelper
import info.nightscout.androidaps.utils.HardLimits
import info.nightscout.androidaps.utils.extensions.pureProfileFromJson
import info.nightscout.core.profile.ProfileStoreObject
import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.Config
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileStore
import info.nightscout.interfaces.utils.HardLimits
import info.nightscout.rx.bus.RxBus
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP
@ -35,6 +35,7 @@ open class TestBaseWithProfile : TestBase() {
@Mock lateinit var sp: SP
@Mock lateinit var context: Context
@Mock lateinit var repository: AppRepository
@Mock lateinit var hardLimits: HardLimits
lateinit var testPumpPlugin: TestPumpPlugin
@ -48,7 +49,7 @@ open class TestBaseWithProfile : TestBase() {
it.config = config
it.rh = rh
it.rxBus = rxBus
it.hardLimits = HardLimits(aapsLogger, rxBus, sp, rh, context, repository)
it.hardLimits = hardLimits
}
}
}

View file

@ -2,11 +2,11 @@ package info.nightscout.androidaps
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultImpl
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.Pump
import info.nightscout.androidaps.interfaces.PumpSync
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.pump.Pump
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.pump.defs.ManufacturerType
import info.nightscout.interfaces.pump.defs.PumpDescription
import info.nightscout.interfaces.pump.defs.PumpType

View file

@ -4,19 +4,25 @@ import android.content.Context
import dagger.android.AndroidInjector
import info.nightscout.androidaps.TestBase
import info.nightscout.androidaps.TestPumpPlugin
import info.nightscout.core.main.R
import info.nightscout.database.impl.AppRepository
import info.nightscout.androidaps.extensions.pureProfileFromJson
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.utils.DateUtil
import info.nightscout.androidaps.utils.HardLimits
import info.nightscout.androidaps.utils.extensions.pureProfileFromJson
import info.nightscout.core.main.R
import info.nightscout.core.profile.fromMgdlToUnits
import info.nightscout.core.profile.toMgdl
import info.nightscout.core.profile.toMmol
import info.nightscout.core.profile.toTargetRangeString
import info.nightscout.core.profile.toUnits
import info.nightscout.core.profile.toUnitsString
import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.Config
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.utils.HardLimits
import info.nightscout.rx.TestAapsSchedulers
import info.nightscout.rx.bus.RxBus
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.shared.utils.DateUtil
import org.json.JSONObject
import org.junit.Assert
import org.junit.Before
@ -38,11 +44,11 @@ class ProfileTest : TestBase() {
@Mock lateinit var config: Config
@Mock lateinit var sp: SP
@Mock lateinit var repository: AppRepository
@Mock lateinit var hardLimits: HardLimits
private lateinit var rxBus: RxBus
private lateinit var dateUtil: DateUtil
private lateinit var testPumpPlugin: TestPumpPlugin
private lateinit var hardLimits: HardLimits
private var okProfile = "{\"dia\":\"5\",\"carbratio\":[{\"time\":\"00:00\",\"value\":\"30\"}]," +
"\"sens\":[{\"time\":\"00:00\",\"value\":\"6\"},{\"time\":\"2:00\",\"value\":\"6.2\"}],\"timezone\":\"UTC\",\"basal\":[{\"time\":\"00:00\",\"value\":\"0.1\"}],\"target_low\":[{\"time\":\"00:00\",\"value\":\"5\"}],\"target_high\":[{\"time\":\"00:00\",\"value\":\"5\"}],\"startDate\":\"1970-01-01T00:00:00.000Z\",\"units\":\"mmol\"}"
@ -64,7 +70,6 @@ class ProfileTest : TestBase() {
testPumpPlugin = TestPumpPlugin { AndroidInjector { } }
dateUtil = DateUtil(context)
rxBus = RxBus(TestAapsSchedulers(), aapsLogger)
hardLimits = HardLimits(aapsLogger, rxBus, sp, rh, context, repository)
`when`(activePluginProvider.activePump).thenReturn(testPumpPlugin)
`when`(rh.gs(R.string.profile_per_unit)).thenReturn("/U")
`when`(rh.gs(R.string.profile_carbs_per_unit)).thenReturn("g/U")

View file

@ -1,8 +1,8 @@
package info.nightscout.androidaps.pump.bolusInfo
import info.nightscout.androidaps.TestBase
import info.nightscout.androidaps.interfaces.PumpSync
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.TemporaryBasalStorage
import info.nightscout.interfaces.pump.PumpSync
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Before

View file

@ -1,13 +1,15 @@
package info.nightscout.androidaps.utils
package info.nightscout.implementation
import android.content.Context
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.androidaps.utils.ToastUtils
import info.nightscout.core.main.R
import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.transactions.InsertTherapyEventAnnouncementTransaction
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.interfaces.utils.HardLimits
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP
import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.kotlin.plusAssign
@ -18,14 +20,14 @@ import kotlin.math.min
@OpenForTesting
@Singleton
class HardLimits @Inject constructor(
class HardLimitsImpl @Inject constructor(
private val aapsLogger: AAPSLogger,
private val rxBus: RxBus,
private val sp: SP,
private val rh: ResourceHelper,
private val context: Context,
private val repository: AppRepository
) {
) : HardLimits {
private val disposable = CompositeDisposable()
@ -70,26 +72,26 @@ class HardLimits @Inject constructor(
rh.gs(R.string.key_adult) -> ADULT
rh.gs(R.string.key_resistantadult) -> RESISTANT_ADULT
rh.gs(R.string.key_pregnant) -> PREGNANT
else -> ADULT
else -> ADULT
}
fun maxBolus(): Double = MAX_BOLUS[loadAge()]
fun maxIobAMA(): Double = MAX_IOB_AMA[loadAge()]
fun maxIobSMB(): Double = MAX_IOB_SMB[loadAge()]
fun maxBasal(): Double = MAX_BASAL[loadAge()]
fun minDia(): Double = MIN_DIA[loadAge()]
fun maxDia(): Double = MAX_DIA[loadAge()]
fun minIC(): Double = MIN_IC[loadAge()]
fun maxIC(): Double = MAX_IC[loadAge()]
override fun maxBolus(): Double = MAX_BOLUS[loadAge()]
override fun maxIobAMA(): Double = MAX_IOB_AMA[loadAge()]
override fun maxIobSMB(): Double = MAX_IOB_SMB[loadAge()]
override fun maxBasal(): Double = MAX_BASAL[loadAge()]
override fun minDia(): Double = MIN_DIA[loadAge()]
override fun maxDia(): Double = MAX_DIA[loadAge()]
override fun minIC(): Double = MIN_IC[loadAge()]
override fun maxIC(): Double = MAX_IC[loadAge()]
// safety checks
fun checkHardLimits(value: Double, valueName: Int, lowLimit: Double, highLimit: Double): Boolean =
value == verifyHardLimits(value, valueName, lowLimit, highLimit)
override fun checkHardLimits(value: Double, valueName: Int, lowLimit: Double, highLimit: Double): Boolean =
value == verifyHardLimits(value, valueName, lowLimit, highLimit)
fun isInRange(value: Double, lowLimit: Double, highLimit: Double): Boolean =
override fun isInRange(value: Double, lowLimit: Double, highLimit: Double): Boolean =
value in lowLimit..highLimit
fun verifyHardLimits(value: Double, valueName: Int, lowLimit: Double, highLimit: Double): Double {
override fun verifyHardLimits(value: Double, valueName: Int, lowLimit: Double, highLimit: Double): Double {
var newValue = value
if (newValue < lowLimit || newValue > highLimit) {
newValue = max(newValue, lowLimit)

View file

@ -2,8 +2,8 @@ package info.nightscout.implementation.constraints
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.Constraints
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.interfaces.constraints.Constraint
import info.nightscout.interfaces.profile.Profile
import javax.inject.Inject
import javax.inject.Singleton

View file

@ -4,7 +4,14 @@ import android.content.Context
import dagger.Module
import dagger.Provides
import info.nightscout.core.fabric.FabricPrivacy
import info.nightscout.database.impl.AppRepository
import info.nightscout.implementation.HardLimitsImpl
import info.nightscout.implementation.resources.ResourceHelperImpl
import info.nightscout.interfaces.utils.HardLimits
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP
import javax.inject.Singleton
@Module(
@ -15,8 +22,14 @@ import javax.inject.Singleton
@Suppress("unused")
open class ImplementationModule {
@Provides
@Singleton
fun provideResources(context: Context, fabricPrivacy: FabricPrivacy): ResourceHelper =
info.nightscout.implementation.resources.ResourceHelperImpl(context, fabricPrivacy)
ResourceHelperImpl(context, fabricPrivacy)
@Provides
@Singleton
fun provideHardLimits(aapsLogger: AAPSLogger, rxBus: RxBus, sp: SP, rh: ResourceHelper, context: Context, repository: AppRepository): HardLimits =
HardLimitsImpl(aapsLogger, rxBus, sp, rh, context, repository)
}

View file

@ -2,7 +2,6 @@ package info.nightscout.implementation.pump
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.interfaces.PumpSync
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
import info.nightscout.core.main.R
@ -38,6 +37,7 @@ import info.nightscout.database.impl.transactions.SyncPumpTotalDailyDoseTransact
import info.nightscout.database.impl.transactions.SyncTemporaryBasalWithTempIdTransaction
import info.nightscout.interfaces.notifications.Notification
import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.pump.VirtualPump
import info.nightscout.interfaces.pump.defs.PumpType
import info.nightscout.rx.bus.RxBus

View file

@ -10,18 +10,16 @@ import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.androidaps.data.ProfileSealed
import info.nightscout.androidaps.data.PumpEnactResultImpl
import info.nightscout.androidaps.dialogs.BolusProgressDialog
import info.nightscout.androidaps.extensions.getCustomizedName
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.CommandQueue
import info.nightscout.androidaps.interfaces.Constraints
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.interfaces.PumpSync
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissBolusProgressIfRunning
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
import info.nightscout.androidaps.queue.commands.Command
import info.nightscout.androidaps.queue.commands.Command.CommandType
import info.nightscout.androidaps.utils.extensions.getCustomizedName
import info.nightscout.core.fabric.FabricPrivacy
import info.nightscout.core.pumpExtensions.insertCarbsTransaction
import info.nightscout.database.entities.EffectiveProfileSwitch
@ -52,8 +50,10 @@ import info.nightscout.interfaces.BuildHelper
import info.nightscout.interfaces.Config
import info.nightscout.interfaces.constraints.Constraint
import info.nightscout.interfaces.notifications.Notification
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.CustomCommand
import info.nightscout.interfaces.ui.ActivityNames

View file

@ -4,12 +4,12 @@ import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultImpl
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.CommandQueue
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.queue.commands.Command
import info.nightscout.database.impl.ValueWrapper
import info.nightscout.implementation.R
import info.nightscout.interfaces.Config
import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.smsCommunicator.SmsCommunicator
import info.nightscout.rx.logging.LTag

View file

@ -2,13 +2,12 @@ package info.nightscout.implementation.queue.commands
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.PumpSync
import info.nightscout.interfaces.queue.Callback
import info.nightscout.androidaps.queue.commands.Command
import info.nightscout.implementation.R
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.queue.Callback
import info.nightscout.rx.logging.LTag
import javax.inject.Inject
class CommandTempBasalAbsolute(

View file

@ -2,13 +2,12 @@ package info.nightscout.implementation.queue.commands
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.PumpSync
import info.nightscout.interfaces.queue.Callback
import info.nightscout.androidaps.queue.commands.Command
import info.nightscout.implementation.R
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.queue.Callback
import info.nightscout.rx.logging.LTag
import javax.inject.Inject
class CommandTempBasalPercent(

View file

@ -6,13 +6,15 @@ import android.graphics.Typeface
import android.view.Gravity
import android.widget.TableRow
import android.widget.TextView
import info.nightscout.interfaces.Constants
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.androidaps.interfaces.stats.DexcomTIR
import info.nightscout.core.profile.toCurrentUnitsString
import info.nightscout.core.profile.toUnitsString
import info.nightscout.implementation.R
import java.util.*
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.profile.Profile
import info.nightscout.shared.interfaces.ResourceHelper
import java.util.Calendar
import kotlin.math.pow
import kotlin.math.roundToInt
import kotlin.math.sqrt

View file

@ -8,17 +8,18 @@ import android.view.Gravity
import android.view.ViewGroup
import android.widget.TableLayout
import android.widget.TextView
import info.nightscout.interfaces.Constants
import info.nightscout.database.impl.AppRepository
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.androidaps.interfaces.stats.TIR
import info.nightscout.androidaps.interfaces.stats.TirCalculator
import info.nightscout.shared.utils.DateUtil
import info.nightscout.interfaces.utils.MidnightTime
import info.nightscout.shared.utils.T
import info.nightscout.core.profile.toCurrentUnitsString
import info.nightscout.database.impl.AppRepository
import info.nightscout.implementation.R
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.utils.MidnightTime
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.utils.DateUtil
import info.nightscout.shared.utils.T
import javax.inject.Inject
import javax.inject.Singleton

View file

@ -4,10 +4,10 @@ import android.content.Context
import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.ProfileSealed
import info.nightscout.androidaps.extensions.pureProfileFromJson
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.IobCobCalculator
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.utils.extensions.pureProfileFromJson
import info.nightscout.core.fabric.FabricPrivacy
import info.nightscout.core.profile.ProfileStoreObject
import info.nightscout.database.entities.EffectiveProfileSwitch

Some files were not shown because too many files have changed in this diff Show more