shared-tests #3

This commit is contained in:
Milos Kozak 2023-09-03 18:13:47 +02:00
parent bfb343f92b
commit 24c2f47e84
65 changed files with 377 additions and 283 deletions

View file

@ -1,7 +1,7 @@
package info.nightscout.sharedtests
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.pump.Pump

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.annotations
package info.nightscout.annotations
/**
* This is the actual annotation that makes the class open. Don't use it directly, only through [OpenForTesting]

View file

@ -1,6 +1,6 @@
package info.nightscout.rx.bus
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.events.Event
import info.nightscout.rx.logging.AAPSLogger

View file

@ -4,10 +4,10 @@ import android.content.Context
import android.os.Build
import androidx.annotation.RequiresApi
import androidx.collection.LongSparseArray
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.annotations.OpenForTesting
import info.nightscout.shared.R
import info.nightscout.shared.SafeParse
import info.nightscout.shared.interfaces.ResourceHelper
import org.apache.commons.lang3.time.DateUtils.isSameDay
import org.joda.time.DateTime
import org.joda.time.format.DateTimeFormat

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.annotations
package info.nightscout.annotations
/**
* Annotate a class with [OpenForTesting] if it should be extendable for testing.

View file

@ -1,37 +0,0 @@
package info.nightscout.androidaps
import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.TestAapsSchedulers
import info.nightscout.rx.logging.AAPSLoggerTest
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.extension.ExtendWith
import org.mockito.Mockito
import org.mockito.junit.jupiter.MockitoExtension
import org.mockito.junit.jupiter.MockitoSettings
import org.mockito.quality.Strictness
import java.util.Locale
@ExtendWith(MockitoExtension::class)
@MockitoSettings(strictness = Strictness.LENIENT)
open class TestBase {
val aapsLogger = AAPSLoggerTest()
val aapsSchedulers: AapsSchedulers = TestAapsSchedulers()
@BeforeEach
fun setupLocale() {
Locale.setDefault(Locale.ENGLISH)
System.setProperty("disableFirebase", "true")
}
// Workaround for Kotlin nullability.
// https://medium.com/@elye.project/befriending-kotlin-and-mockito-1c2e7b0ef791
// https://stackoverflow.com/questions/30305217/is-it-possible-to-use-mockito-in-kotlin
fun <T> anyObject(): T {
Mockito.any<T>()
return uninitialized()
}
@Suppress("Unchecked_Cast")
fun <T> uninitialized(): T = null as T
}

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.utils.rx
package info.nightscout.rx
import io.reactivex.rxjava3.android.plugins.RxAndroidPlugins
import io.reactivex.rxjava3.core.Scheduler

View file

@ -1,14 +1,18 @@
package info.nightscout.rx.weardata
import info.nightscout.androidaps.TestBase
import kotlinx.serialization.ExperimentalSerializationApi
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
import org.mockito.junit.jupiter.MockitoExtension
import org.mockito.junit.jupiter.MockitoSettings
import org.mockito.quality.Strictness
@ExperimentalSerializationApi
class EventDataTest : TestBase() {
@ExtendWith(MockitoExtension::class)
@MockitoSettings(strictness = Strictness.LENIENT)
class EventDataTest {
@BeforeEach
fun setUp() {
@ -147,13 +151,13 @@ class EventDataTest : TestBase() {
EventData.TreatmentData(
arrayListOf(EventData.TreatmentData.TempBasal(1, 2.0, 3, 4.0, 5.0)),
arrayListOf(EventData.TreatmentData.Basal(1, 2, 3.0)),
arrayListOf(EventData.TreatmentData.Treatment(1, 2.0, 3.0, true, true)),
arrayListOf(EventData.TreatmentData.Treatment(1, 2.0, 3.0, true, isValid = true)),
arrayListOf(EventData.SingleBg(1, sgv = 2.0, high = 3.0, low = 4.0))
).let {
Assertions.assertEquals(it, EventData.deserializeByte(it.serializeByte()))
Assertions.assertEquals(it, EventData.deserialize(it.serialize()))
}
EventData.Preferences(1, true, true, 2, 3, 4.0, 5.0, 6.0, 7, 8).let {
EventData.Preferences(1, wearControl = true, true, 2, 3, 4.0, 5.0, 6.0, 7, 8).let {
Assertions.assertEquals(it, EventData.deserializeByte(it.serializeByte()))
Assertions.assertEquals(it, EventData.deserialize(it.serialize()))
}

View file

@ -1,6 +1,6 @@
package info.nightscout.shared
import org.junit.Assert.assertEquals
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
@Suppress("SpellCheckingInspection")
@ -8,105 +8,105 @@ class SafeParseTest {
@Test fun stringToDoubleTest() {
// correct values
assertEquals(0.1234, SafeParse.stringToDouble("0.1234"), 0.001)
assertEquals(0.1234, SafeParse.stringToDouble("0,1234"), 0.001)
assertEquals(0.5436564812, SafeParse.stringToDouble(".5436564812"), 0.001)
assertEquals(0.5436564812, SafeParse.stringToDouble(",5436564812"), 0.001)
assertEquals(1000500100900.0, SafeParse.stringToDouble("1000500100900"), 0.001)
assertEquals(42.0, SafeParse.stringToDouble("42"), 0.001)
Assertions.assertEquals(0.1234, SafeParse.stringToDouble("0.1234"), 0.001)
Assertions.assertEquals(0.1234, SafeParse.stringToDouble("0,1234"), 0.001)
Assertions.assertEquals(0.5436564812, SafeParse.stringToDouble(".5436564812"), 0.001)
Assertions.assertEquals(0.5436564812, SafeParse.stringToDouble(",5436564812"), 0.001)
Assertions.assertEquals(1000500100900.0, SafeParse.stringToDouble("1000500100900"), 0.001)
Assertions.assertEquals(42.0, SafeParse.stringToDouble("42"), 0.001)
// units or other extra values are not permitted
assertEquals(0.0, SafeParse.stringToDouble("12 U/h"), 0.001)
Assertions.assertEquals(0.0, SafeParse.stringToDouble("12 U/h"), 0.001)
// strings are not parsable
assertEquals(0.0, SafeParse.stringToDouble("ala ma kota"), 0.001)
Assertions.assertEquals(0.0, SafeParse.stringToDouble("ala ma kota"), 0.001)
// separator errors
assertEquals(0.0, SafeParse.stringToDouble("0.1234.5678"), 0.001)
assertEquals(0.0, SafeParse.stringToDouble("0,1234,5678"), 0.001)
Assertions.assertEquals(0.0, SafeParse.stringToDouble("0.1234.5678"), 0.001)
Assertions.assertEquals(0.0, SafeParse.stringToDouble("0,1234,5678"), 0.001)
// various emptiness
assertEquals(0.0, SafeParse.stringToDouble(""), 0.001)
assertEquals(0.0, SafeParse.stringToDouble(" "), 0.001)
assertEquals(0.0, SafeParse.stringToDouble("\n\r"), 0.001)
Assertions.assertEquals(0.0, SafeParse.stringToDouble(""), 0.001)
Assertions.assertEquals(0.0, SafeParse.stringToDouble(" "), 0.001)
Assertions.assertEquals(0.0, SafeParse.stringToDouble("\n\r"), 0.001)
}
@Test fun stringToIntTest() {
// correct values
assertEquals(1052934, SafeParse.stringToInt("1052934"))
assertEquals(-42, SafeParse.stringToInt("-42"))
assertEquals(2147483647, SafeParse.stringToInt("2147483647"))
assertEquals(-2147483648, SafeParse.stringToInt("-2147483648"))
Assertions.assertEquals(1052934, SafeParse.stringToInt("1052934"))
Assertions.assertEquals(-42, SafeParse.stringToInt("-42"))
Assertions.assertEquals(2147483647, SafeParse.stringToInt("2147483647"))
Assertions.assertEquals(-2147483648, SafeParse.stringToInt("-2147483648"))
// outside Integer range
assertEquals(0, SafeParse.stringToInt("2147483648"))
assertEquals(0, SafeParse.stringToInt("-2147483649"))
Assertions.assertEquals(0, SafeParse.stringToInt("2147483648"))
Assertions.assertEquals(0, SafeParse.stringToInt("-2147483649"))
// units or other extra values are not permitted
assertEquals(0, SafeParse.stringToInt("12 U/h"))
assertEquals(0, SafeParse.stringToInt("0.1234"))
assertEquals(0, SafeParse.stringToInt("0,1234"))
assertEquals(0, SafeParse.stringToInt(".5436564812"))
assertEquals(0, SafeParse.stringToInt(",5436564812"))
assertEquals(0, SafeParse.stringToInt("42.1234"))
assertEquals(0, SafeParse.stringToInt("42,1234"))
assertEquals(0, SafeParse.stringToInt("3212.5436564812"))
assertEquals(0, SafeParse.stringToInt("3212,5436564812"))
assertEquals(0, SafeParse.stringToInt("1000500100900"))
Assertions.assertEquals(0, SafeParse.stringToInt("12 U/h"))
Assertions.assertEquals(0, SafeParse.stringToInt("0.1234"))
Assertions.assertEquals(0, SafeParse.stringToInt("0,1234"))
Assertions.assertEquals(0, SafeParse.stringToInt(".5436564812"))
Assertions.assertEquals(0, SafeParse.stringToInt(",5436564812"))
Assertions.assertEquals(0, SafeParse.stringToInt("42.1234"))
Assertions.assertEquals(0, SafeParse.stringToInt("42,1234"))
Assertions.assertEquals(0, SafeParse.stringToInt("3212.5436564812"))
Assertions.assertEquals(0, SafeParse.stringToInt("3212,5436564812"))
Assertions.assertEquals(0, SafeParse.stringToInt("1000500100900"))
// strings are not parsable
assertEquals(0, SafeParse.stringToInt("ala ma kota"))
Assertions.assertEquals(0, SafeParse.stringToInt("ala ma kota"))
// various emptiness
assertEquals(0, SafeParse.stringToInt(""))
assertEquals(0, SafeParse.stringToInt(" "))
assertEquals(0, SafeParse.stringToInt("\n\r"))
Assertions.assertEquals(0, SafeParse.stringToInt(""))
Assertions.assertEquals(0, SafeParse.stringToInt(" "))
Assertions.assertEquals(0, SafeParse.stringToInt("\n\r"))
}
@Test fun stringToLongTest() {
// correct values
assertEquals(1052934L, SafeParse.stringToLong("1052934"))
assertEquals(-42L, SafeParse.stringToLong("-42"))
assertEquals(2147483647L, SafeParse.stringToLong("2147483647"))
assertEquals(-2147483648L, SafeParse.stringToLong("-2147483648"))
assertEquals(1000500100900L, SafeParse.stringToLong("1000500100900"))
Assertions.assertEquals(1052934L, SafeParse.stringToLong("1052934"))
Assertions.assertEquals(-42L, SafeParse.stringToLong("-42"))
Assertions.assertEquals(2147483647L, SafeParse.stringToLong("2147483647"))
Assertions.assertEquals(-2147483648L, SafeParse.stringToLong("-2147483648"))
Assertions.assertEquals(1000500100900L, SafeParse.stringToLong("1000500100900"))
// outside Integer range
assertEquals(2147483648L, SafeParse.stringToLong("2147483648"))
assertEquals(-2147483649L, SafeParse.stringToLong("-2147483649"))
Assertions.assertEquals(2147483648L, SafeParse.stringToLong("2147483648"))
Assertions.assertEquals(-2147483649L, SafeParse.stringToLong("-2147483649"))
// units or other extra values are not permitted
assertEquals(0L, SafeParse.stringToLong("12 U/h"))
assertEquals(0L, SafeParse.stringToLong("0.1234"))
assertEquals(0L, SafeParse.stringToLong("0,1234"))
assertEquals(0L, SafeParse.stringToLong(".5436564812"))
assertEquals(0L, SafeParse.stringToLong(",5436564812"))
assertEquals(0L, SafeParse.stringToLong("42.1234"))
assertEquals(0L, SafeParse.stringToLong("42,1234"))
assertEquals(0L, SafeParse.stringToLong("3212.5436564812"))
assertEquals(0L, SafeParse.stringToLong("3212,5436564812"))
Assertions.assertEquals(0L, SafeParse.stringToLong("12 U/h"))
Assertions.assertEquals(0L, SafeParse.stringToLong("0.1234"))
Assertions.assertEquals(0L, SafeParse.stringToLong("0,1234"))
Assertions.assertEquals(0L, SafeParse.stringToLong(".5436564812"))
Assertions.assertEquals(0L, SafeParse.stringToLong(",5436564812"))
Assertions.assertEquals(0L, SafeParse.stringToLong("42.1234"))
Assertions.assertEquals(0L, SafeParse.stringToLong("42,1234"))
Assertions.assertEquals(0L, SafeParse.stringToLong("3212.5436564812"))
Assertions.assertEquals(0L, SafeParse.stringToLong("3212,5436564812"))
// strings are not parsable
assertEquals(0L, SafeParse.stringToLong("ala ma kota"))
Assertions.assertEquals(0L, SafeParse.stringToLong("ala ma kota"))
// various emptiness
assertEquals(0L, SafeParse.stringToLong(""))
assertEquals(0L, SafeParse.stringToLong(" "))
assertEquals(0L, SafeParse.stringToLong("\n\r"))
Assertions.assertEquals(0L, SafeParse.stringToLong(""))
Assertions.assertEquals(0L, SafeParse.stringToLong(" "))
Assertions.assertEquals(0L, SafeParse.stringToLong("\n\r"))
}
@Test
fun stringToDoubleNullTest() {
assertEquals(0.0, SafeParse.stringToDouble(null), 0.001)
Assertions.assertEquals(0.0, SafeParse.stringToDouble(null), 0.001)
}
@Test
fun stringToIntNullTest() {
assertEquals(0, SafeParse.stringToInt(null))
Assertions.assertEquals(0, SafeParse.stringToInt(null))
}
@Test
fun stringToLongNullTest() {
assertEquals(0L, SafeParse.stringToLong(null))
Assertions.assertEquals(0L, SafeParse.stringToLong(null))
}
}

View file

@ -1,4 +1,4 @@
allOpen {
// allows mocking for classes w/o directly opening them for release builds
annotation 'info.nightscout.androidaps.annotations.OpenForTesting'
annotation 'info.nightscout.annotations.OpenForTesting'
}

View file

@ -1,7 +1,7 @@
package info.nightscout.core.wizard
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.core.extensions.valueToUnits
import info.nightscout.core.iob.round
import info.nightscout.core.utils.MidnightUtils
@ -38,9 +38,11 @@ class QuickWizardEntry @Inject constructor(private val injector: HasAndroidInjec
// for mock
@OpenForTesting
class Time {
fun secondsFromMidnight(): Int = MidnightUtils.secondsFromMidnight()
}
var time = Time()
lateinit var storage: JSONObject
@ -151,7 +153,26 @@ class QuickWizardEntry @Inject constructor(private val injector: HasAndroidInjec
trend = true
}
val percentage = if (usePercentage() == DEFAULT) sp.getInt(info.nightscout.core.utils.R.string.key_boluswizard_percentage, 100) else percentage()
return BolusWizard(injector).doCalc(profile, profileName, tempTarget, carbs(), cob, bg, 0.0, percentage, true, useCOB() == YES, bolusIOB, basalIOB, superBolus, useTempTarget() == YES, trend, false, buttonText(), quickWizard = true) //tbc, ok if only quickwizard, but if other sources elsewhere use Sources.QuickWizard
return BolusWizard(injector).doCalc(
profile,
profileName,
tempTarget,
carbs(),
cob,
bg,
0.0,
percentage,
true,
useCOB() == YES,
bolusIOB,
basalIOB,
superBolus,
useTempTarget() == YES,
trend,
false,
buttonText(),
quickWizard = true
) //tbc, ok if only quickwizard, but if other sources elsewhere use Sources.QuickWizard
}
fun guid(): String = safeGetString(storage, "guid", "")

View file

@ -5,7 +5,7 @@ import com.google.firebase.analytics.FirebaseAnalytics
import com.google.firebase.analytics.ktx.analytics
import com.google.firebase.crashlytics.FirebaseCrashlytics
import com.google.firebase.ktx.Firebase
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.core.utils.R
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag

View file

@ -6,7 +6,7 @@ import androidx.work.Data
import androidx.work.ExistingWorkPolicy
import androidx.work.OneTimeWorkRequest
import androidx.work.WorkManager
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import org.json.JSONArray
import org.json.JSONObject
import javax.inject.Inject

View file

@ -1,6 +1,6 @@
package info.nightscout.implementation
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.profile.DefaultValueHelper

View file

@ -1,7 +1,7 @@
package info.nightscout.implementation
import android.content.Context
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.transactions.InsertTherapyEventAnnouncementTransaction
import info.nightscout.interfaces.ui.UiInteraction

View file

@ -1,7 +1,7 @@
package info.nightscout.implementation
import dagger.Reusable
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.database.entities.UserEntry
import info.nightscout.database.entities.UserEntry.Action
import info.nightscout.database.entities.UserEntry.Sources

View file

@ -1,7 +1,7 @@
package info.nightscout.implementation.iob
import dagger.Reusable
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.core.iob.asRounded
import info.nightscout.core.iob.log
import info.nightscout.interfaces.iob.GlucoseStatus
@ -73,7 +73,6 @@ class GlucoseStatusProviderImpl @Inject constructor(
// // short_deltas are calculated from everything ~5-15 minutes ago
// } else
if (2.5 < minutesAgo && minutesAgo < 17.5) {
//console.error(minutesAgo, avgDelta);
shortDeltas.add(avgDel)
// last_deltas are calculated from everything ~5 minutes ago
if (2.5 < minutesAgo && minutesAgo < 7.5) {
@ -191,7 +190,7 @@ class GlucoseStatusProviderImpl @Inject constructor(
fun average(array: ArrayList<Double>): Double {
var sum = 0.0
if (array.size == 0) return 0.0
if (array.isEmpty()) return 0.0
for (value in array) {
sum += value
}

View file

@ -1,7 +1,7 @@
package info.nightscout.implementation.logging
import dagger.Reusable
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.interfaces.logging.LoggerUtils
import info.nightscout.interfaces.maintenance.PrefFileListProvider
import javax.inject.Inject

View file

@ -1,7 +1,7 @@
package info.nightscout.implementation.profiling
import dagger.Reusable
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.interfaces.profiling.Profiler
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag

View file

@ -2,14 +2,14 @@ package info.nightscout.implementation.pump
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.implementation.R
import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.pump.DetailedBolusInfoStorage
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.shared.utils.T
import javax.inject.Inject
import javax.inject.Singleton
@ -39,7 +39,6 @@ class DetailedBolusInfoStorageImpl @Inject constructor(
// Look for info with bolus
for (i in store.indices) {
val d = store[i]
//aapsLogger.debug(LTag.PUMP, "Existing bolus info: " + store[i])
if (bolusTime > d.timestamp - T.mins(1).msecs() && bolusTime < d.timestamp + T.mins(1).msecs() && abs(store[i].insulin - bolus) < 0.01) {
aapsLogger.debug(LTag.PUMP, "Using & removing bolus info for time $bolusTime: ${store[i]}")
store.removeAt(i)

View file

@ -1,8 +1,8 @@
package info.nightscout.implementation.pump
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.interfaces.pump.TemporaryBasalStorage
import info.nightscout.annotations.OpenForTesting
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.pump.TemporaryBasalStorage
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.utils.T

View file

@ -8,7 +8,7 @@ import android.os.SystemClock
import android.text.Spanned
import androidx.appcompat.app.AppCompatActivity
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.core.events.EventNewNotification
import info.nightscout.core.extensions.getCustomizedName
import info.nightscout.core.profile.ProfileSealed
@ -319,7 +319,14 @@ class CommandQueueImplementation @Inject constructor(
// not when the Bolus command is starting. The command closes the dialog upon completion).
showBolusProgressDialog(detailedBolusInfo)
// Notify Wear about upcoming bolus
rxBus.send(EventMobileToWear(info.nightscout.rx.weardata.EventData.BolusProgress(percent = 0, status = rh.gs(info.nightscout.core.ui.R.string.goingtodeliver, detailedBolusInfo.insulin))))
rxBus.send(
EventMobileToWear(
info.nightscout.rx.weardata.EventData.BolusProgress(
percent = 0,
status = rh.gs(info.nightscout.core.ui.R.string.goingtodeliver, detailedBolusInfo.insulin)
)
)
)
}
}
notifyAboutNewCommand()
@ -609,10 +616,7 @@ class CommandQueueImplementation @Inject constructor(
override fun isCustomCommandRunning(customCommandType: Class<out CustomCommand>): Boolean {
val performing = this.performing
if (performing is CommandCustomCommand && customCommandType.isInstance(performing.customCommand)) {
return true
}
return false
return performing is CommandCustomCommand && customCommandType.isInstance(performing.customCommand)
}
@Synchronized

View file

@ -2,7 +2,7 @@ package info.nightscout.implementation.receivers
import android.content.Context
import android.content.Intent
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.interfaces.receivers.ReceiverStatusStore
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventChargingState

View file

@ -13,7 +13,7 @@ import android.os.HandlerThread
import android.os.SystemClock
import androidx.core.app.NotificationCompat
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.core.events.EventNewNotification
import info.nightscout.core.extensions.convertedToAbsolute
import info.nightscout.core.extensions.convertedToPercent
@ -29,9 +29,9 @@ import info.nightscout.database.entities.ValueWithUnit
import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.transactions.InsertAndCancelCurrentOfflineEventTransaction
import info.nightscout.database.impl.transactions.InsertTherapyEventAnnouncementTransaction
import info.nightscout.interfaces.ApsMode
import info.nightscout.interfaces.Config
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.ApsMode
import info.nightscout.interfaces.aps.APSResult
import info.nightscout.interfaces.aps.Loop
import info.nightscout.interfaces.aps.Loop.LastRun
@ -327,14 +327,22 @@ class LoopPlugin @Inject constructor(
0
) && carbsSuggestionsSuspendedUntil < System.currentTimeMillis() && !treatmentTimeThreshold(-15)
) {
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_enable_carbs_required_alert_local, true) && !sp.getBoolean(info.nightscout.core.ui.R.string.key_raise_notifications_as_android_notifications, true)) {
if (sp.getBoolean(
info.nightscout.core.utils.R.string.key_enable_carbs_required_alert_local,
true
) && !sp.getBoolean(info.nightscout.core.ui.R.string.key_raise_notifications_as_android_notifications, true)
) {
val carbReqLocal = Notification(Notification.CARBS_REQUIRED, resultAfterConstraints.carbsRequiredText, Notification.NORMAL)
rxBus.send(EventNewNotification(carbReqLocal))
}
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_create_announcements_from_carbs_req, false)) {
disposable += repository.runTransaction(InsertTherapyEventAnnouncementTransaction(resultAfterConstraints.carbsRequiredText)).subscribe()
}
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_enable_carbs_required_alert_local, true) && sp.getBoolean(info.nightscout.core.ui.R.string.key_raise_notifications_as_android_notifications, true)) {
if (sp.getBoolean(
info.nightscout.core.utils.R.string.key_enable_carbs_required_alert_local,
true
) && sp.getBoolean(info.nightscout.core.ui.R.string.key_raise_notifications_as_android_notifications, true)
) {
val intentAction5m = Intent(context, CarbSuggestionReceiver::class.java)
intentAction5m.putExtra("ignoreDuration", 5)
val pendingIntent5m = PendingIntent.getBroadcast(context, 1, intentAction5m, PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT)

View file

@ -2,7 +2,7 @@ package info.nightscout.plugins.aps.openAPSAMA
import android.content.Context
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.core.extensions.target
import info.nightscout.core.utils.MidnightUtils
import info.nightscout.core.utils.fabric.FabricPrivacy
@ -128,10 +128,22 @@ class OpenAPSAMAPlugin @Inject constructor(
val maxIob = constraintChecker.getMaxIOBAllowed().also { maxIOBAllowedConstraint ->
inputConstraints.copyReasons(maxIOBAllowedConstraint)
}.value()
var minBg = hardLimits.verifyHardLimits(Round.roundTo(profile.getTargetLowMgdl(), 0.1), info.nightscout.core.ui.R.string.profile_low_target, HardLimits.VERY_HARD_LIMIT_MIN_BG[0], HardLimits.VERY_HARD_LIMIT_MIN_BG[1])
var minBg =
hardLimits.verifyHardLimits(
Round.roundTo(profile.getTargetLowMgdl(), 0.1),
info.nightscout.core.ui.R.string.profile_low_target,
HardLimits.VERY_HARD_LIMIT_MIN_BG[0],
HardLimits.VERY_HARD_LIMIT_MIN_BG[1]
)
var maxBg =
hardLimits.verifyHardLimits(Round.roundTo(profile.getTargetHighMgdl(), 0.1), info.nightscout.core.ui.R.string.profile_high_target, HardLimits.VERY_HARD_LIMIT_MAX_BG[0], HardLimits.VERY_HARD_LIMIT_MAX_BG[1])
var targetBg = hardLimits.verifyHardLimits(profile.getTargetMgdl(), info.nightscout.core.ui.R.string.temp_target_value, HardLimits.VERY_HARD_LIMIT_TARGET_BG[0], HardLimits.VERY_HARD_LIMIT_TARGET_BG[1])
hardLimits.verifyHardLimits(
Round.roundTo(profile.getTargetHighMgdl(), 0.1),
info.nightscout.core.ui.R.string.profile_high_target,
HardLimits.VERY_HARD_LIMIT_MAX_BG[0],
HardLimits.VERY_HARD_LIMIT_MAX_BG[1]
)
var targetBg =
hardLimits.verifyHardLimits(profile.getTargetMgdl(), info.nightscout.core.ui.R.string.temp_target_value, HardLimits.VERY_HARD_LIMIT_TARGET_BG[0], HardLimits.VERY_HARD_LIMIT_TARGET_BG[1])
var isTempTarget = false
val tempTarget = repository.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet()
if (tempTarget is ValueWrapper.Existing) {
@ -159,7 +171,13 @@ class OpenAPSAMAPlugin @Inject constructor(
)
}
if (!hardLimits.checkHardLimits(profile.dia, info.nightscout.core.ui.R.string.profile_dia, hardLimits.minDia(), hardLimits.maxDia())) return
if (!hardLimits.checkHardLimits(profile.getIcTimeFromMidnight(MidnightUtils.secondsFromMidnight()), info.nightscout.core.ui.R.string.profile_carbs_ratio_value, hardLimits.minIC(), hardLimits.maxIC())) return
if (!hardLimits.checkHardLimits(
profile.getIcTimeFromMidnight(MidnightUtils.secondsFromMidnight()),
info.nightscout.core.ui.R.string.profile_carbs_ratio_value,
hardLimits.minIC(),
hardLimits.maxIC()
)
) return
if (!hardLimits.checkHardLimits(profile.getIsfMgdl(), info.nightscout.core.ui.R.string.profile_sensitivity_value, HardLimits.MIN_ISF, HardLimits.MAX_ISF)) return
if (!hardLimits.checkHardLimits(profile.getMaxDailyBasal(), info.nightscout.core.ui.R.string.profile_max_daily_basal_value, 0.02, hardLimits.maxBasal())) return
if (!hardLimits.checkHardLimits(pump.baseBasalRate, info.nightscout.core.ui.R.string.current_basal_value, 0.01, hardLimits.maxBasal())) return
@ -237,7 +255,12 @@ class OpenAPSAMAPlugin @Inject constructor(
// Check percentRate but absolute rate too, because we know real current basal in pump
val maxBasalMultiplier = sp.getDouble(R.string.key_openapsama_current_basal_safety_multiplier, 4.0)
val maxFromBasalMultiplier = floor(maxBasalMultiplier * profile.getBasal() * 100) / 100
absoluteRate.setIfSmaller(aapsLogger, maxFromBasalMultiplier, rh.gs(info.nightscout.core.ui.R.string.limitingbasalratio, maxFromBasalMultiplier, rh.gs(R.string.max_basal_multiplier)), this)
absoluteRate.setIfSmaller(
aapsLogger,
maxFromBasalMultiplier,
rh.gs(info.nightscout.core.ui.R.string.limitingbasalratio, maxFromBasalMultiplier, rh.gs(R.string.max_basal_multiplier)),
this
)
val maxBasalFromDaily = sp.getDouble(R.string.key_openapsama_max_daily_safety_multiplier, 3.0)
val maxFromDaily = floor(profile.getMaxDailyBasal() * maxBasalFromDaily * 100) / 100
absoluteRate.setIfSmaller(aapsLogger, maxFromDaily, rh.gs(info.nightscout.core.ui.R.string.limitingbasalratio, maxFromDaily, rh.gs(R.string.max_daily_basal_multiplier)), this)

View file

@ -4,7 +4,6 @@ import android.content.Context
import androidx.preference.PreferenceFragmentCompat
import androidx.preference.SwitchPreference
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.core.extensions.target
import info.nightscout.core.utils.MidnightUtils
import info.nightscout.database.ValueWrapper
@ -40,9 +39,8 @@ import javax.inject.Inject
import javax.inject.Singleton
import kotlin.math.floor
@OpenForTesting
@Singleton
class OpenAPSSMBPlugin @Inject constructor(
open class OpenAPSSMBPlugin @Inject constructor(
injector: HasAndroidInjector,
aapsLogger: AAPSLogger,
private val rxBus: RxBus,
@ -142,10 +140,22 @@ class OpenAPSSMBPlugin @Inject constructor(
inputConstraints.copyReasons(maxIOBAllowedConstraint)
}.value()
var minBg = hardLimits.verifyHardLimits(Round.roundTo(profile.getTargetLowMgdl(), 0.1), info.nightscout.core.ui.R.string.profile_low_target, HardLimits.VERY_HARD_LIMIT_MIN_BG[0], HardLimits.VERY_HARD_LIMIT_MIN_BG[1])
var minBg =
hardLimits.verifyHardLimits(
Round.roundTo(profile.getTargetLowMgdl(), 0.1),
info.nightscout.core.ui.R.string.profile_low_target,
HardLimits.VERY_HARD_LIMIT_MIN_BG[0],
HardLimits.VERY_HARD_LIMIT_MIN_BG[1]
)
var maxBg =
hardLimits.verifyHardLimits(Round.roundTo(profile.getTargetHighMgdl(), 0.1), info.nightscout.core.ui.R.string.profile_high_target, HardLimits.VERY_HARD_LIMIT_MAX_BG[0], HardLimits.VERY_HARD_LIMIT_MAX_BG[1])
var targetBg = hardLimits.verifyHardLimits(profile.getTargetMgdl(), info.nightscout.core.ui.R.string.temp_target_value, HardLimits.VERY_HARD_LIMIT_TARGET_BG[0], HardLimits.VERY_HARD_LIMIT_TARGET_BG[1])
hardLimits.verifyHardLimits(
Round.roundTo(profile.getTargetHighMgdl(), 0.1),
info.nightscout.core.ui.R.string.profile_high_target,
HardLimits.VERY_HARD_LIMIT_MAX_BG[0],
HardLimits.VERY_HARD_LIMIT_MAX_BG[1]
)
var targetBg =
hardLimits.verifyHardLimits(profile.getTargetMgdl(), info.nightscout.core.ui.R.string.temp_target_value, HardLimits.VERY_HARD_LIMIT_TARGET_BG[0], HardLimits.VERY_HARD_LIMIT_TARGET_BG[1])
var isTempTarget = false
val tempTarget = repository.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet()
if (tempTarget is ValueWrapper.Existing) {
@ -173,7 +183,13 @@ class OpenAPSSMBPlugin @Inject constructor(
)
}
if (!hardLimits.checkHardLimits(profile.dia, info.nightscout.core.ui.R.string.profile_dia, hardLimits.minDia(), hardLimits.maxDia())) return
if (!hardLimits.checkHardLimits(profile.getIcTimeFromMidnight(MidnightUtils.secondsFromMidnight()), info.nightscout.core.ui.R.string.profile_carbs_ratio_value, hardLimits.minIC(), hardLimits.maxIC())) return
if (!hardLimits.checkHardLimits(
profile.getIcTimeFromMidnight(MidnightUtils.secondsFromMidnight()),
info.nightscout.core.ui.R.string.profile_carbs_ratio_value,
hardLimits.minIC(),
hardLimits.maxIC()
)
) return
if (!hardLimits.checkHardLimits(profile.getIsfMgdl(), info.nightscout.core.ui.R.string.profile_sensitivity_value, HardLimits.MIN_ISF, HardLimits.MAX_ISF)) return
if (!hardLimits.checkHardLimits(profile.getMaxDailyBasal(), info.nightscout.core.ui.R.string.profile_max_daily_basal_value, 0.02, hardLimits.maxBasal())) return
if (!hardLimits.checkHardLimits(pump.baseBasalRate, info.nightscout.core.ui.R.string.current_basal_value, 0.01, hardLimits.maxBasal())) return
@ -290,7 +306,12 @@ class OpenAPSSMBPlugin @Inject constructor(
// Check percentRate but absolute rate too, because we know real current basal in pump
val maxBasalMultiplier = sp.getDouble(R.string.key_openapsama_current_basal_safety_multiplier, 4.0)
val maxFromBasalMultiplier = floor(maxBasalMultiplier * profile.getBasal() * 100) / 100
absoluteRate.setIfSmaller(aapsLogger, maxFromBasalMultiplier, rh.gs(info.nightscout.core.ui.R.string.limitingbasalratio, maxFromBasalMultiplier, rh.gs(R.string.max_basal_multiplier)), this)
absoluteRate.setIfSmaller(
aapsLogger,
maxFromBasalMultiplier,
rh.gs(info.nightscout.core.ui.R.string.limitingbasalratio, maxFromBasalMultiplier, rh.gs(R.string.max_basal_multiplier)),
this
)
val maxBasalFromDaily = sp.getDouble(R.string.key_openapsama_max_daily_safety_multiplier, 3.0)
val maxFromDaily = floor(profile.getMaxDailyBasal() * maxBasalFromDaily * 100) / 100
absoluteRate.setIfSmaller(aapsLogger, maxFromDaily, rh.gs(info.nightscout.core.ui.R.string.limitingbasalratio, maxFromDaily, rh.gs(R.string.max_daily_basal_multiplier)), this)
@ -316,5 +337,5 @@ class OpenAPSSMBPlugin @Inject constructor(
return value
}
fun provideDetermineBasalAdapter(): DetermineBasalAdapter = DetermineBasalAdapterSMBJS(ScriptReader(context), injector)
open fun provideDetermineBasalAdapter(): DetermineBasalAdapter = DetermineBasalAdapterSMBJS(ScriptReader(context), injector)
}

View file

@ -2,7 +2,7 @@ package info.nightscout.plugins.aps.openAPSSMBDynamicISF
import android.content.Context
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.aps.DetermineBasalAdapter
import info.nightscout.interfaces.bgQualityCheck.BgQualityCheck

View file

@ -1,6 +1,6 @@
package info.nightscout.plugins.general.autotune
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.interfaces.logging.LoggerUtils
import info.nightscout.plugins.general.autotune.data.ATProfile
import info.nightscout.plugins.general.autotune.data.PreppedGlucose

View file

@ -5,7 +5,7 @@ import android.os.Handler
import android.os.HandlerThread
import android.os.SystemClock
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.automation.actions.Action
import info.nightscout.automation.actions.ActionAlarm
import info.nightscout.automation.actions.ActionCarePortalEvent

View file

@ -1,7 +1,7 @@
package info.nightscout.automation.services
import android.location.Location
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import javax.inject.Inject
import javax.inject.Singleton

View file

@ -5,7 +5,7 @@ import android.content.Context
import android.content.Intent
import android.content.ServiceConnection
import android.os.IBinder
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.interfaces.NotificationHolder
import javax.inject.Inject
import javax.inject.Singleton

View file

@ -3,15 +3,14 @@ package info.nightscout.automation.ui
import android.content.Context
import android.content.Intent
import android.provider.AlarmClock
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.automation.R
import info.nightscout.core.ui.toast.ToastUtils
import javax.inject.Inject
import javax.inject.Singleton
@OpenForTesting
@Singleton
open class TimerUtil @Inject constructor(
@Singleton class TimerUtil @Inject constructor(
private val context: Context
) {

View file

@ -4,7 +4,7 @@ import android.content.Context
import android.os.Environment
import dagger.Lazy
import dagger.Reusable
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.configuration.R
import info.nightscout.configuration.maintenance.formats.EncryptedPrefsFormat
import info.nightscout.interfaces.Config
@ -42,6 +42,7 @@ class PrefFileListProviderImpl @Inject constructor(
private val sp: SP,
context: Context
) : PrefFileListProvider {
private val path = File(Environment.getExternalStorageDirectory().toString())
private val aapsPath = File(path, "AAPS" + File.separator + "preferences")
private val exportsPath = File(path, "AAPS" + File.separator + "exports")
@ -146,6 +147,7 @@ class PrefFileListProviderImpl @Inject constructor(
val timeLocal = LocalDateTime.now().toString(DateTimeFormat.forPattern("yyyy-MM-dd'_'HHmmss"))
return File(exportsPath, timeLocal + "_UserEntry.csv")
}
override fun newCwfFile(filename: String): File {
val timeLocal = LocalDateTime.now().toString(DateTimeFormat.forPattern("yyyy-MM-dd'_'HHmmss"))
return File(exportsPath, "${filename}_$timeLocal${ZipWatchfaceFormat.CWF_EXTENTION}")

View file

@ -3,7 +3,7 @@ package info.nightscout.plugins.constraints.storage
import android.os.Environment
import android.os.StatFs
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.constraints.Constraint
import info.nightscout.interfaces.constraints.Constraints

View file

@ -10,7 +10,7 @@ import androidx.preference.PreferenceFragmentCompat
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.core.events.EventNewNotification
import info.nightscout.core.extensions.valueToUnitsString
import info.nightscout.core.iob.generateCOBString
@ -882,7 +882,11 @@ class SmsCommunicatorPlugin @Inject constructor(
uel.log(
Action.EXTENDED_BOLUS,
Sources.SMS,
activePlugin.activePump.shortStatus(true) + "\n" + rh.gs(R.string.smscommunicator_extended_set, aDouble, duration) + " / " + rh.gs(info.nightscout.core.ui.R.string.loopsuspended),
activePlugin.activePump.shortStatus(true) + "\n" + rh.gs(
R.string.smscommunicator_extended_set,
aDouble,
duration
) + " / " + rh.gs(info.nightscout.core.ui.R.string.loopsuspended),
ValueWithUnit.Insulin(aDouble ?: 0.0),
ValueWithUnit.Minute(duration),
ValueWithUnit.SimpleString(rh.gsNotLocalised(info.nightscout.core.ui.R.string.loopsuspended))

View file

@ -3,7 +3,7 @@ package info.nightscout.plugins.general.smsCommunicator.otp
import android.util.Base64
import com.eatthepath.otp.HmacOneTimePasswordGenerator
import com.google.common.io.BaseEncoding
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.interfaces.Constants
import info.nightscout.plugins.R
import info.nightscout.shared.interfaces.ResourceHelper
@ -107,7 +107,9 @@ class OneTimePassword @Inject constructor(
* Return URI used to provision Authenticator apps
*/
fun provisioningURI(): String? =
key?.let { "otpauth://totp/AndroidAPS:" + URLEncoder.encode(name(), "utf-8").replace("+", "%20") + "?secret=" + BaseEncoding.base32().encode(it.encoded).replace("=", "") + "&issuer=AndroidAPS" }
key?.let {
"otpauth://totp/AndroidAPS:" + URLEncoder.encode(name(), "utf-8").replace("+", "%20") + "?secret=" + BaseEncoding.base32().encode(it.encoded).replace("=", "") + "&issuer=AndroidAPS"
}
/**
* Return secret used to provision Authenticator apps, in Base32 format

View file

@ -2,7 +2,7 @@ package info.nightscout.plugins.iob.iobCobCalculator
import androidx.collection.LongSparseArray
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.core.extensions.convertedToAbsolute
import info.nightscout.core.extensions.iobCalc
import info.nightscout.core.extensions.toTemporaryBasal

View file

@ -2,7 +2,7 @@ package info.nightscout.plugins.iob.iobCobCalculator.data
import androidx.collection.LongSparseArray
import androidx.collection.size
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.database.entities.GlucoseValue
import info.nightscout.interfaces.aps.AutosensData
import info.nightscout.interfaces.aps.AutosensDataStore
@ -232,7 +232,6 @@ class AutosensDataStoreObject : AutosensDataStore {
// after adjusting time may be newer. In this case use T-5min
currentTime = if (adjustedTime > currentTime) adjustedTime - T.mins(5).msecs() else adjustedTime
aapsLogger.debug("Adjusted time " + dateUtil.dateAndTimeAndSecondsString(currentTime))
//log.debug("First reading: " + new Date(currentTime).toLocaleString());
while (true) {
// test if current value is older than current time
val newer = findNewer(currentTime)
@ -248,7 +247,6 @@ class AutosensDataStoreObject : AutosensDataStore {
val currentBg = newer.value - timeDiffToNew.toDouble() / (newer.timestamp - older.timestamp) * bgDelta
val newBgReading = InMemoryGlucoseValue(currentTime, currentBg.roundToLong().toDouble(), filledGap = filledGap, sourceSensor = lastBg.sourceSensor)
newBucketedData.add(newBgReading)
//log.debug("BG: " + newBgReading.value + " (" + new Date(newBgReading.date).toLocaleString() + ") Prev: " + older.value + " (" + new Date(older.date).toLocaleString() + ") Newer: " + newer.value + " (" + new Date(newer.date).toLocaleString() + ")");
}
currentTime -= T.mins(5).msecs()
}
@ -268,23 +266,19 @@ class AutosensDataStoreObject : AutosensDataStore {
for (i in 1 until bgReadings.size) {
val bgTime = bgReadings[i].timestamp
var lastBgTime = bgReadings[i - 1].timestamp
//log.error("Processing " + i + ": " + new Date(bgTime).toString() + " " + bgReadings.get(i).value + " Previous: " + new Date(lastBgTime).toString() + " " + bgReadings.get(i - 1).value);
var elapsedMinutes = (bgTime - lastBgTime) / (60 * 1000)
when {
abs(elapsedMinutes) > 8 -> {
// interpolate missing data points
var lastBgValue = bgReadings[i - 1].value
elapsedMinutes = abs(elapsedMinutes)
//console.error(elapsed_minutes);
var nextBgTime: Long
while (elapsedMinutes > 5) {
nextBgTime = lastBgTime - 5 * 60 * 1000
j++
val gapDelta = bgReadings[i].value - lastBgValue
//console.error(gapDelta, lastBg, elapsed_minutes);
val nextBg = lastBgValue + 5.0 / elapsedMinutes * gapDelta
val newBgReading = InMemoryGlucoseValue(nextBgTime, nextBg.roundToLong().toDouble(), filledGap = true, sourceSensor = lastBg.sourceSensor)
//console.error("Interpolated", bData[j]);
bData.add(newBgReading)
aapsLogger.debug(LTag.AUTOSENS) { "Adding. bgTime: ${dateUtil.toISOString(bgTime)} lastBgTime: ${dateUtil.toISOString(lastBgTime)} $newBgReading" }
elapsedMinutes -= 5
@ -306,7 +300,6 @@ class AutosensDataStoreObject : AutosensDataStore {
else -> {
bData[j].value = (bData[j].value + bgReadings[i].value) / 2
//log.error("***** Average");
}
}
}

View file

@ -2,7 +2,7 @@ package info.nightscout.plugins.profile
import androidx.fragment.app.FragmentActivity
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.core.extensions.blockFromJsonArray
import info.nightscout.core.extensions.pureProfileFromJson
import info.nightscout.core.profile.ProfileSealed

View file

@ -1,7 +1,7 @@
package info.nightscout.sensitivity
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.core.utils.MidnightUtils
import info.nightscout.core.utils.Percentile
import info.nightscout.database.entities.TherapyEvent
@ -162,18 +162,30 @@ class SensitivityAAPSPlugin @Inject constructor(
override fun applyConfiguration(configuration: JSONObject) {
try {
if (configuration.has(rh.gs(info.nightscout.core.utils.R.string.key_absorption_maxtime))) sp.putDouble(
info.nightscout.core.utils.R.string.key_absorption_maxtime, configuration.getDouble(rh.gs(
info.nightscout.core.utils.R.string.key_absorption_maxtime)))
info.nightscout.core.utils.R.string.key_absorption_maxtime, configuration.getDouble(
rh.gs(
info.nightscout.core.utils.R.string.key_absorption_maxtime
)
)
)
if (configuration.has(rh.gs(info.nightscout.core.utils.R.string.key_openapsama_autosens_period))) sp.putDouble(
info.nightscout.core.utils.R.string.key_openapsama_autosens_period,
configuration.getDouble(rh.gs(info.nightscout.core.utils.R.string.key_openapsama_autosens_period))
)
if (configuration.has(rh.gs(info.nightscout.core.utils.R.string.key_openapsama_autosens_max))) sp.getDouble(
info.nightscout.core.utils.R.string.key_openapsama_autosens_max, configuration.getDouble(rh.gs(
info.nightscout.core.utils.R.string.key_openapsama_autosens_max)))
info.nightscout.core.utils.R.string.key_openapsama_autosens_max, configuration.getDouble(
rh.gs(
info.nightscout.core.utils.R.string.key_openapsama_autosens_max
)
)
)
if (configuration.has(rh.gs(info.nightscout.core.utils.R.string.key_openapsama_autosens_min))) sp.getDouble(
info.nightscout.core.utils.R.string.key_openapsama_autosens_min, configuration.getDouble(rh.gs(
info.nightscout.core.utils.R.string.key_openapsama_autosens_min)))
info.nightscout.core.utils.R.string.key_openapsama_autosens_min, configuration.getDouble(
rh.gs(
info.nightscout.core.utils.R.string.key_openapsama_autosens_min
)
)
)
} catch (e: JSONException) {
e.printStackTrace()
}

View file

@ -1,7 +1,7 @@
package info.nightscout.sensitivity
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.core.utils.MidnightUtils
import info.nightscout.core.utils.Percentile
import info.nightscout.database.entities.TherapyEvent
@ -211,7 +211,10 @@ class SensitivityOref1Plugin @Inject constructor(
override fun configuration(): JSONObject {
val c = JSONObject()
try {
c.put(rh.gs(info.nightscout.core.utils.R.string.key_openapsama_min_5m_carbimpact), sp.getDouble(info.nightscout.core.utils.R.string.key_openapsama_min_5m_carbimpact, SMBDefaults.min_5m_carbimpact))
c.put(
rh.gs(info.nightscout.core.utils.R.string.key_openapsama_min_5m_carbimpact),
sp.getDouble(info.nightscout.core.utils.R.string.key_openapsama_min_5m_carbimpact, SMBDefaults.min_5m_carbimpact)
)
c.put(rh.gs(info.nightscout.core.utils.R.string.key_absorption_cutoff), sp.getDouble(info.nightscout.core.utils.R.string.key_absorption_cutoff, Constants.DEFAULT_MAX_ABSORPTION_TIME))
c.put(rh.gs(info.nightscout.core.utils.R.string.key_openapsama_autosens_max), sp.getDouble(info.nightscout.core.utils.R.string.key_openapsama_autosens_max, 1.2))
c.put(rh.gs(info.nightscout.core.utils.R.string.key_openapsama_autosens_min), sp.getDouble(info.nightscout.core.utils.R.string.key_openapsama_autosens_min, 0.7))
@ -228,14 +231,26 @@ class SensitivityOref1Plugin @Inject constructor(
configuration.getDouble(rh.gs(info.nightscout.core.utils.R.string.key_openapsama_min_5m_carbimpact))
)
if (configuration.has(rh.gs(info.nightscout.core.utils.R.string.key_absorption_cutoff))) sp.putDouble(
info.nightscout.core.utils.R.string.key_absorption_cutoff, configuration.getDouble(rh.gs(
info.nightscout.core.utils.R.string.key_absorption_cutoff)))
info.nightscout.core.utils.R.string.key_absorption_cutoff, configuration.getDouble(
rh.gs(
info.nightscout.core.utils.R.string.key_absorption_cutoff
)
)
)
if (configuration.has(rh.gs(info.nightscout.core.utils.R.string.key_openapsama_autosens_max))) sp.getDouble(
info.nightscout.core.utils.R.string.key_openapsama_autosens_max, configuration.getDouble(rh.gs(
info.nightscout.core.utils.R.string.key_openapsama_autosens_max)))
info.nightscout.core.utils.R.string.key_openapsama_autosens_max, configuration.getDouble(
rh.gs(
info.nightscout.core.utils.R.string.key_openapsama_autosens_max
)
)
)
if (configuration.has(rh.gs(info.nightscout.core.utils.R.string.key_openapsama_autosens_min))) sp.getDouble(
info.nightscout.core.utils.R.string.key_openapsama_autosens_min, configuration.getDouble(rh.gs(
info.nightscout.core.utils.R.string.key_openapsama_autosens_min)))
info.nightscout.core.utils.R.string.key_openapsama_autosens_min, configuration.getDouble(
rh.gs(
info.nightscout.core.utils.R.string.key_openapsama_autosens_min
)
)
)
} catch (e: JSONException) {
e.printStackTrace()
}

View file

@ -2,7 +2,7 @@ package info.nightscout.sensitivity
import androidx.collection.LongSparseArray
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.core.utils.MidnightUtils
import info.nightscout.database.entities.TherapyEvent
import info.nightscout.database.impl.AppRepository
@ -182,18 +182,30 @@ class SensitivityWeightedAveragePlugin @Inject constructor(
override fun applyConfiguration(configuration: JSONObject) {
try {
if (configuration.has(rh.gs(info.nightscout.core.utils.R.string.key_absorption_maxtime))) sp.putDouble(
info.nightscout.core.utils.R.string.key_absorption_maxtime, configuration.getDouble(rh.gs(
info.nightscout.core.utils.R.string.key_absorption_maxtime)))
info.nightscout.core.utils.R.string.key_absorption_maxtime, configuration.getDouble(
rh.gs(
info.nightscout.core.utils.R.string.key_absorption_maxtime
)
)
)
if (configuration.has(rh.gs(info.nightscout.core.utils.R.string.key_openapsama_autosens_period))) sp.putDouble(
info.nightscout.core.utils.R.string.key_openapsama_autosens_period,
configuration.getDouble(rh.gs(info.nightscout.core.utils.R.string.key_openapsama_autosens_period))
)
if (configuration.has(rh.gs(info.nightscout.core.utils.R.string.key_openapsama_autosens_max))) sp.getDouble(
info.nightscout.core.utils.R.string.key_openapsama_autosens_max, configuration.getDouble(rh.gs(
info.nightscout.core.utils.R.string.key_openapsama_autosens_max)))
info.nightscout.core.utils.R.string.key_openapsama_autosens_max, configuration.getDouble(
rh.gs(
info.nightscout.core.utils.R.string.key_openapsama_autosens_max
)
)
)
if (configuration.has(rh.gs(info.nightscout.core.utils.R.string.key_openapsama_autosens_min))) sp.getDouble(
info.nightscout.core.utils.R.string.key_openapsama_autosens_min, configuration.getDouble(rh.gs(
info.nightscout.core.utils.R.string.key_openapsama_autosens_min)))
info.nightscout.core.utils.R.string.key_openapsama_autosens_min, configuration.getDouble(
rh.gs(
info.nightscout.core.utils.R.string.key_openapsama_autosens_min
)
)
)
} catch (e: JSONException) {
e.printStackTrace()
}

View file

@ -1,7 +1,7 @@
package info.nightscout.smoothing
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.database.entities.GlucoseValue
import info.nightscout.interfaces.iob.InMemoryGlucoseValue
import info.nightscout.interfaces.plugin.PluginBase
@ -33,8 +33,7 @@ class AvgSmoothingPlugin @Inject constructor(
), Smoothing {
override fun smooth(data: MutableList<InMemoryGlucoseValue>): MutableList<InMemoryGlucoseValue> {
if (data.lastIndex < 4)
{
if (data.lastIndex < 4) {
aapsLogger.debug(LTag.GLUCOSE, "Not enough value's to smooth!")
return data
}
@ -60,6 +59,7 @@ class AvgSmoothingPlugin @Inject constructor(
// data[0].smoothed = data[0].value
return data
}
private fun isValid(n: Double): Boolean {
// For Dexcom: Below 39 is LOW, above 401 Dexcom just says HI
return n > 39 && n < 401

View file

@ -1,7 +1,7 @@
package info.nightscout.smoothing
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.database.entities.GlucoseValue
import info.nightscout.interfaces.iob.InMemoryGlucoseValue
import info.nightscout.interfaces.plugin.PluginBase
@ -123,11 +123,6 @@ class ExponentialSmoothingPlugin @Inject constructor(
// here
ssBG.add(o1_weight * o1_sBG[i] + (1 - o1_weight) * o2_sBG[i]) //MP build array of doubly smoothed bgs
}
/*
for (i in 0 until ssBG.size - 1) {
ssD.add(ssBG[i] - ssBG[i + 1]) //MP build array of doubly smoothed bg deltas
}
*/
for (i in 0 until minOf(ssBG.size, data.size)) { // noise at the beginning of the smoothing window is the greatest, so only include the 10 most recent values in the output
data[i].smoothed = max(round(ssBG[i]), 39.0) //Make 39 the smallest value as smaller values trigger errors (xDrip error state = 38)
data[i].trendArrow = GlucoseValue.TrendArrow.NONE

View file

@ -1,7 +1,7 @@
package info.nightscout.smoothing
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.interfaces.iob.InMemoryGlucoseValue
import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginDescription

View file

@ -4,7 +4,7 @@ import android.content.Context
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.core.utils.worker.LoggingWorker
import info.nightscout.database.entities.GlucoseValue
import info.nightscout.database.impl.AppRepository

View file

@ -1,6 +1,6 @@
package info.nightscout.plugins.sync.nsShared
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.database.entities.Food
import info.nightscout.database.entities.GlucoseValue
import info.nightscout.database.transactions.TransactionGlucoseValue

View file

@ -1,6 +1,6 @@
package info.nightscout.plugins.sync.nsclient
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.interfaces.receivers.ReceiverStatusStore
import info.nightscout.plugins.sync.R

View file

@ -1,6 +1,6 @@
package info.nightscout.plugins.sync.nsclient.data
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.interfaces.Config
import info.nightscout.interfaces.configBuilder.RunningConfiguration
import info.nightscout.interfaces.nsclient.ProcessedDeviceStatusData

View file

@ -3,7 +3,7 @@
package info.nightscout.plugins.sync.nsclient.data
import android.content.Context
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.database.entities.UserEntry
import info.nightscout.database.entities.UserEntry.Action

View file

@ -1,6 +1,6 @@
package info.nightscout.plugins.sync.nsclientV3
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.Config
import info.nightscout.interfaces.nsclient.StoreDataForDb

View file

@ -14,7 +14,7 @@ import androidx.work.WorkManager
import com.google.gson.Gson
import com.google.gson.GsonBuilder
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.database.ValueWrapper
import info.nightscout.database.entities.interfaces.TraceableDBEntry

View file

@ -2,7 +2,7 @@ package info.nightscout.plugins.sync.nsclientV3.workers
import android.content.Context
import androidx.work.WorkerParameters
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.core.utils.worker.LoggingWorker
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.plugins.sync.nsclientV3.DataSyncSelectorV3

View file

@ -2,7 +2,7 @@ package info.nightscout.plugins.sync.xdrip.workers
import android.content.Context
import androidx.work.WorkerParameters
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.core.utils.worker.LoggingWorker
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.plugins.sync.xdrip.DataSyncSelectorXdripImpl

View file

@ -1,7 +1,7 @@
package info.nightscout.androidaps
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.pump.Pump

View file

@ -6,10 +6,10 @@ import android.content.Intent
import android.content.ServiceConnection
import android.os.IBinder
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.androidaps.danaRKorean.services.DanaRKoreanExecutionService
import info.nightscout.androidaps.danar.AbstractDanaRPlugin
import info.nightscout.androidaps.danar.R
import info.nightscout.annotations.OpenForTesting
import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.interfaces.constraints.Constraint
import info.nightscout.interfaces.constraints.Constraints
@ -130,7 +130,7 @@ class DanaRKoreanPlugin @Inject constructor(
override fun deliverTreatment(detailedBolusInfo: DetailedBolusInfo): PumpEnactResult {
detailedBolusInfo.insulin = constraintChecker.applyBolusConstraints(Constraint(detailedBolusInfo.insulin)).value()
if (detailedBolusInfo.carbs > 0) throw IllegalArgumentException()
require(detailedBolusInfo.carbs > 0)
return if (detailedBolusInfo.insulin > 0) {
val t = EventOverviewBolusProgress.Treatment(0.0, 0, detailedBolusInfo.bolusType == DetailedBolusInfo.BolusType.SMB, detailedBolusInfo.id)
var connectionOK = false
@ -142,7 +142,14 @@ class DanaRKoreanPlugin @Inject constructor(
val result = PumpEnactResult(injector)
result.success(connectionOK && abs(detailedBolusInfo.insulin - t.insulin) < pumpDescription.bolusStep)
.bolusDelivered(t.insulin)
if (!result.success) result.comment(rh.gs(info.nightscout.pump.dana.R.string.boluserrorcode, detailedBolusInfo.insulin, t.insulin, danaPump.bolusStartErrorCode)) else result.comment(info.nightscout.core.ui.R.string.ok)
if (!result.success) result.comment(
rh.gs(
info.nightscout.pump.dana.R.string.boluserrorcode,
detailedBolusInfo.insulin,
t.insulin,
danaPump.bolusStartErrorCode
)
) else result.comment(info.nightscout.core.ui.R.string.ok)
aapsLogger.debug(LTag.PUMP, "deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered)
detailedBolusInfo.insulin = t.insulin
detailedBolusInfo.timestamp = dateUtil.now()

View file

@ -12,10 +12,10 @@ import javax.inject.Inject;
import javax.inject.Singleton;
import dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.annotations.OpenForTesting;
import info.nightscout.androidaps.danaRv2.services.DanaRv2ExecutionService;
import info.nightscout.androidaps.danar.AbstractDanaRPlugin;
import info.nightscout.androidaps.danar.R;
import info.nightscout.annotations.OpenForTesting;
import info.nightscout.core.utils.fabric.FabricPrivacy;
import info.nightscout.interfaces.constraints.Constraint;
import info.nightscout.interfaces.constraints.Constraints;
@ -232,8 +232,8 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
int percentRate = (int) (absoluteRate / getBaseBasalRate() * 100);
// Any basal less than 0.10u/h will be dumped once per hour, not every 4 minutes. So if it's less than .10u/h, set a zero temp.
if (absoluteRate < 0.10d) percentRate = 0;
if (percentRate < 100) percentRate = (int) Round.INSTANCE.ceilTo((double) percentRate, 10d);
else percentRate = (int) Round.INSTANCE.floorTo((double) percentRate, 10d);
if (percentRate < 100) percentRate = (int) Round.INSTANCE.ceilTo(percentRate, 10d);
else percentRate = (int) Round.INSTANCE.floorTo(percentRate, 10d);
if (percentRate > 500) // Special high temp 500/15min
percentRate = 500;
aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: Calculated percent rate: " + percentRate);

View file

@ -12,8 +12,8 @@ import javax.inject.Inject;
import javax.inject.Singleton;
import dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.annotations.OpenForTesting;
import info.nightscout.androidaps.danar.services.DanaRExecutionService;
import info.nightscout.annotations.OpenForTesting;
import info.nightscout.core.utils.fabric.FabricPrivacy;
import info.nightscout.interfaces.constraints.Constraint;
import info.nightscout.interfaces.constraints.Constraints;

View file

@ -1,6 +1,5 @@
package info.nightscout.androidaps.plugins.pump.medtronic.driver
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.androidaps.plugins.pump.common.events.EventRileyLinkDeviceStatusChange
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistoryItem
@ -9,6 +8,7 @@ import info.nightscout.androidaps.plugins.pump.medtronic.defs.BasalProfileStatus
import info.nightscout.androidaps.plugins.pump.medtronic.defs.BatteryType
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceType
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicConst
import info.nightscout.annotations.OpenForTesting
import info.nightscout.interfaces.pump.defs.PumpType
import info.nightscout.pump.common.data.PumpStatus
import info.nightscout.pump.common.sync.PumpDbEntryTBR

View file

@ -1,10 +1,11 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.util
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import java.security.SecureRandom
@OpenForTesting
class RandomByteGenerator {
private val secureRandom = SecureRandom()
fun nextBytes(length: Int): ByteArray = ByteArray(length).also(secureRandom::nextBytes)

View file

@ -1,7 +1,7 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.util
import com.google.crypto.tink.subtle.X25519
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
@OpenForTesting
class X25519KeyGenerator {

View file

@ -2,7 +2,7 @@ package info.nightscout.pump.common.sync
import com.thoughtworks.xstream.XStream
import com.thoughtworks.xstream.security.AnyTypePermission
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.rx.logging.AAPSLogger
@ -24,6 +24,7 @@ class PumpSyncStorage @Inject constructor(
) {
companion object {
const val pumpSyncStorageBolusKey: String = "pump_sync_storage_bolus"
const val pumpSyncStorageTBRKey: String = "pump_sync_storage_tbr"
}
@ -80,7 +81,7 @@ class PumpSyncStorage @Inject constructor(
}
fun saveStorageBolus() {
if (!pumpSyncStorageBolus.isEmpty()) {
if (pumpSyncStorageBolus.isNotEmpty()) {
sp.putString(pumpSyncStorageBolusKey, xstream.toXML(pumpSyncStorageBolus))
aapsLogger.debug(LTag.PUMP, "Saving Pump Sync Storage: boluses=${pumpSyncStorageBolus.size}")
} else {
@ -90,7 +91,7 @@ class PumpSyncStorage @Inject constructor(
}
fun saveStorageTBR() {
if (!pumpSyncStorageTBR.isEmpty()) {
if (pumpSyncStorageTBR.isNotEmpty()) {
sp.putString(pumpSyncStorageTBRKey, xstream.toXML(pumpSyncStorageTBR))
aapsLogger.debug(LTag.PUMP, "Saving Pump Sync Storage: tbr=${pumpSyncStorageTBR.size}")
} else {
@ -124,23 +125,27 @@ class PumpSyncStorage @Inject constructor(
temporaryId,
detailedBolusInfo.bolusType,
creator.model(),
creator.serialNumber())
creator.serialNumber()
)
aapsLogger.debug(
LTag.PUMP, "addBolusWithTempId [date=${detailedBolusInfo.timestamp}, temporaryId=$temporaryId, " +
"insulin=${detailedBolusInfo.insulin}, type=${detailedBolusInfo.bolusType}, pumpSerial=${creator.serialNumber()}] - " +
"Result: $result")
"Result: $result"
)
if (detailedBolusInfo.carbs > 0.0) {
addCarbs(PumpDbEntryCarbs(detailedBolusInfo, creator))
}
if (result && writeToInternalHistory) {
val dbEntry = PumpDbEntryBolus(temporaryId = temporaryId,
val dbEntry = PumpDbEntryBolus(
temporaryId = temporaryId,
date = detailedBolusInfo.timestamp,
pumpType = creator.model(),
serialNumber = creator.serialNumber(),
detailedBolusInfo = detailedBolusInfo)
detailedBolusInfo = detailedBolusInfo
)
aapsLogger.debug("PumpDbEntryBolus: $dbEntry")
@ -156,11 +161,13 @@ class PumpSyncStorage @Inject constructor(
carbsDto.carbs,
null,
carbsDto.pumpType,
carbsDto.serialNumber)
carbsDto.serialNumber
)
aapsLogger.debug(
LTag.PUMP, "syncCarbsWithTimestamp [date=${carbsDto.date}, " +
"carbs=${carbsDto.carbs}, pumpSerial=${carbsDto.serialNumber}] - Result: $result")
"carbs=${carbsDto.carbs}, pumpSerial=${carbsDto.serialNumber}] - Result: $result"
)
}
fun addTemporaryBasalRateWithTempId(temporaryBasal: PumpDbEntryTBR, writeToInternalHistory: Boolean, creator: PumpSyncEntriesCreator): Boolean {
@ -175,15 +182,18 @@ class PumpSyncStorage @Inject constructor(
temporaryId,
temporaryBasal.tbrType,
creator.model(),
creator.serialNumber())
creator.serialNumber()
)
if (response && writeToInternalHistory) {
val dbEntry = PumpDbEntryTBR(temporaryId = temporaryId,
val dbEntry = PumpDbEntryTBR(
temporaryId = temporaryId,
date = timeNow,
pumpType = creator.model(),
serialNumber = creator.serialNumber(),
entry = temporaryBasal,
pumpId=null)
pumpId = null
)
aapsLogger.debug("PumpDbEntryTBR: $dbEntry")

View file

@ -1,6 +1,6 @@
package info.nightscout.androidaps.interaction.utils
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag
import info.nightscout.rx.weardata.EventData

View file

@ -2,7 +2,7 @@ package info.nightscout.androidaps.interaction.utils
import android.content.Context
import android.os.PowerManager
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.annotations.OpenForTesting
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag

View file

@ -1,8 +1,8 @@
package info.nightscout.androidaps.testing.mockers
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.androidaps.interaction.utils.Constants
import info.nightscout.androidaps.interaction.utils.WearUtil
import info.nightscout.annotations.OpenForTesting
import org.mockito.ArgumentMatchers
import org.mockito.Mockito