:pump:virtual

This commit is contained in:
Milos Kozak 2022-12-09 15:34:11 +01:00
parent 53e29aaf33
commit 16bf64129d
27 changed files with 168 additions and 70 deletions

View file

@ -218,10 +218,11 @@ dependencies {
implementation project(':pump:medtronic')
implementation project(':pump:pump-common')
implementation project(':pump:pump-core')
implementation project(':pump:rileylink')
implementation project(':pump:omnipod-common')
implementation project(':pump:omnipod-eros')
implementation project(':pump:omnipod-dash')
implementation project(':pump:rileylink')
implementation project(':pump:virtual')
implementation project(':workflow')
implementation fileTree(include: ['*.jar'], dir: 'libs')

View file

@ -48,7 +48,6 @@ import info.nightscout.plugins.general.autotune.AutotunePlugin
import info.nightscout.plugins.general.smsCommunicator.SmsCommunicatorPlugin
import info.nightscout.plugins.general.wear.WearPlugin
import info.nightscout.plugins.general.xdripStatusline.StatusLinePlugin
import info.nightscout.plugins.pump.virtual.VirtualPumpPlugin
import info.nightscout.plugins.source.AidexPlugin
import info.nightscout.plugins.source.DexcomPlugin
import info.nightscout.plugins.source.EversensePlugin
@ -63,6 +62,7 @@ import info.nightscout.plugins.sync.tidepool.TidepoolPlugin
import info.nightscout.pump.combo.ComboPlugin
import info.nightscout.pump.combov2.ComboV2Plugin
import info.nightscout.pump.diaconn.DiaconnG8Plugin
import info.nightscout.pump.virtual.VirtualPumpPlugin
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventPreferenceChange
import info.nightscout.rx.events.EventRebuildTabs

View file

@ -32,6 +32,7 @@ import info.nightscout.pump.dana.di.DanaHistoryModule
import info.nightscout.pump.dana.di.DanaModule
import info.nightscout.pump.danars.di.DanaRSModule
import info.nightscout.pump.diaconn.di.DiaconnG8Module
import info.nightscout.pump.virtual.di.VirtualPumpModule
import info.nightscout.rx.di.RxModule
import info.nightscout.shared.di.SharedModule
import info.nightscout.shared.impl.di.SharedImplModule
@ -83,7 +84,8 @@ import javax.inject.Singleton
OmnipodDashModule::class,
OmnipodErosModule::class,
PumpCommonModule::class,
RileyLinkModule::class
RileyLinkModule::class,
VirtualPumpModule::class
]
)
interface AppComponent : AndroidInjector<MainApp> {

View file

@ -41,7 +41,6 @@ import info.nightscout.plugins.general.wear.WearPlugin
import info.nightscout.plugins.general.xdripStatusline.StatusLinePlugin
import info.nightscout.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
import info.nightscout.plugins.profile.ProfilePlugin
import info.nightscout.plugins.pump.virtual.VirtualPumpPlugin
import info.nightscout.plugins.source.AidexPlugin
import info.nightscout.plugins.source.DexcomPlugin
import info.nightscout.plugins.source.GlimpPlugin
@ -59,6 +58,7 @@ import info.nightscout.plugins.sync.tidepool.TidepoolPlugin
import info.nightscout.pump.combo.ComboPlugin
import info.nightscout.pump.combov2.ComboV2Plugin
import info.nightscout.pump.diaconn.DiaconnG8Plugin
import info.nightscout.pump.virtual.VirtualPumpPlugin
import info.nightscout.sensitivity.SensitivityAAPSPlugin
import info.nightscout.sensitivity.SensitivityOref1Plugin
import info.nightscout.sensitivity.SensitivityWeightedAveragePlugin

View file

@ -6,7 +6,7 @@ import info.nightscout.androidaps.TestBaseWithProfile
import info.nightscout.core.pump.toHtml
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.plugins.aps.loop.extensions.json
import info.nightscout.plugins.extensions.toText
import info.nightscout.pump.virtual.extensions.toText
import info.nightscout.plugins.sync.nsShared.extensions.log
import org.json.JSONObject
import org.junit.jupiter.api.Assertions

View file

@ -71,6 +71,8 @@ files:
translation: /pump/omnipod-eros/src/main/res/values-%android_code%/strings.xml
- source: /pump/rileylink/src/main/res/values/strings.xml
translation: /pump/rileylink/src/main/res/values-%android_code%/strings.xml
- source: /pump/virtual/src/main/res/values/strings.xml
translation: /pump/virtual/src/main/res/values-%android_code%/strings.xml
- source: /insight/src/main/res/values/strings.xml
translation: /insight/src/main/res/values-%android_code%/strings.xml
- source: /insight/src/main/res/values/alert_codes.xml

View file

@ -18,7 +18,6 @@ import info.nightscout.plugins.iob.iobCobCalculator.data.AutosensDataObject
SMSCommunicatorModule::class,
ProfileModule::class,
SourceModule::class,
VirtualPumpModule::class,
SkinsModule::class,
SkinsUiModule::class,
ActionsModule::class,

View file

@ -14,9 +14,9 @@ import info.nightscout.interfaces.XDripBroadcast
import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.pump.VirtualPump
import info.nightscout.interfaces.source.BgSource
import info.nightscout.plugins.R
import info.nightscout.plugins.pump.virtual.VirtualPumpPlugin
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.interfaces.ResourceHelper
@ -39,7 +39,7 @@ class RandomBgPlugin @Inject constructor(
private val sp: SP,
private val repository: AppRepository,
private val xDripBroadcast: XDripBroadcast,
private val virtualPumpPlugin: VirtualPumpPlugin,
private val virtualPump: VirtualPump,
private val config: Config
) : PluginBase(
PluginDescription()
@ -94,7 +94,7 @@ class RandomBgPlugin @Inject constructor(
}
override fun specialEnableCondition(): Boolean {
return isRunningTest() || config.isUnfinishedMode() || virtualPumpPlugin.isEnabled() && config.isEngineeringMode()
return isRunningTest() || config.isUnfinishedMode() || virtualPump.isEnabled() && config.isEngineeringMode()
}
private fun handleNewData() {

View file

@ -12,36 +12,4 @@
<item>@string/value_system_theme</item>
</string-array>
<string-array name="virtualPumpTypes">
<item>Generic AAPS</item>
<item>MDI</item>
<item>Accu-Chek Combo</item>
<item>Accu-Chek Spirit</item>
<item>Accu-Chek Insight</item>
<item>Accu-Chek Solo</item>
<item>Animas Ping</item>
<item>Animas Vibe</item>
<item>Cellnovo</item>
<item>DanaR</item>
<item>DanaR Korean</item>
<item>DanaRS</item>
<item>DanaRv2</item>
<item>DanaI</item>
<item>Diaconn G8</item>
<item>Eoflow Eopatch2</item>
<item>Medtronic 512/712</item>
<item>Medtronic 515/715</item>
<item>Medtronic 522/722</item>
<item>Medtronic 523/723 (Revel)</item>
<item>Medtronic 554/754 (Veo)</item>
<item>Medtronic 640G</item>
<item>Omnipod Dash</item>
<item>Omnipod Eros</item>
<item>Tandem t:slim</item>
<item>Tandem t:flex</item>
<item>Tandem t:slim G4</item>
<item>Tandem t:slim X2</item>
<item>YpsoPump</item>
</string-array>
</resources>

View file

@ -344,16 +344,6 @@
<string name="graph_scale">Graph scale</string>
<string name="graph_menu_divider_header">Graph</string>
<!-- VirtualPump -->
<string name="virtual_pump_type">Virtual Pump Type</string>
<string name="virtual_pump_definition">Pump Definition</string>
<string name="virtual_pump_pump_def">Bolus: Step=%1$s\nExtended Bolus: [Step=%2$s, Duration=%3$smin-%4$sh]\nBasal: Step=%5$s\nTBR: %6$s (by %7$s), Duration=%8$smin-%9$sh\n%10$s</string>
<string name="virtual_pump_shortname">VPUMP</string>
<string name="description_pump_virtual">Pump integration for pumps which don\'t have any driver yet (Open Loop)</string>
<string name="virtual_pump_label">VIRTUAL PUMP</string>
<string name="virtualpump_settings">Virtual pump settings</string>
<!-- Source -->
<string name="key_dexcom_log_ns_sensor_change" translatable="false">dexcom_lognssensorchange</string>
<string name="key_last_processed_glunovo_timestamp" translatable="false">last_processed_glunovo_timestamp</string>

1
pump/virtual/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/build

27
pump/virtual/build.gradle Normal file
View file

@ -0,0 +1,27 @@
plugins {
id 'com.android.library'
id 'kotlin-android'
id 'kotlin-kapt'
id 'kotlin-allopen'
id 'com.hiya.jacoco-android'
}
apply from: "${project.rootDir}/core/main/android_dependencies.gradle"
apply from: "${project.rootDir}/core/main/android_module_dependencies.gradle"
apply from: "${project.rootDir}/core/main/allopen_dependencies.gradle"
apply from: "${project.rootDir}/core/main/test_dependencies.gradle"
apply from: "${project.rootDir}/core/main/jacoco_global.gradle"
android {
namespace 'info.nightscout.pump.virtual'
}
dependencies {
implementation project(':app-wear-shared:shared')
implementation project(':database:entities')
implementation project(':core:interfaces')
implementation project(':core:main')
implementation project(':core:ui')
implementation project(':core:utils')
}

View file

21
pump/virtual/proguard-rules.pro vendored Normal file
View file

@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View file

@ -0,0 +1,3 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>

View file

@ -1,4 +1,4 @@
package info.nightscout.plugins.pump.virtual
package info.nightscout.pump.virtual
import android.os.Bundle
import android.os.Handler
@ -11,9 +11,8 @@ import info.nightscout.core.extensions.toStringFull
import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.interfaces.iob.IobCobCalculator
import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.plugins.R
import info.nightscout.plugins.databinding.VirtualPumpFragmentBinding
import info.nightscout.plugins.pump.virtual.events.EventVirtualPumpUpdateGui
import info.nightscout.pump.virtual.databinding.VirtualPumpFragmentBinding
import info.nightscout.pump.virtual.events.EventVirtualPumpUpdateGui
import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventExtendedBolusChange

View file

@ -1,4 +1,4 @@
package info.nightscout.plugins.pump.virtual
package info.nightscout.pump.virtual
import android.os.SystemClock
import androidx.preference.PreferenceFragmentCompat
@ -28,9 +28,8 @@ import info.nightscout.interfaces.pump.defs.PumpDescription
import info.nightscout.interfaces.pump.defs.PumpType
import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.utils.TimeChangeType
import info.nightscout.plugins.R
import info.nightscout.plugins.extensions.toText
import info.nightscout.plugins.pump.virtual.events.EventVirtualPumpUpdateGui
import info.nightscout.pump.virtual.events.EventVirtualPumpUpdateGui
import info.nightscout.pump.virtual.extensions.toText
import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventOverviewBolusProgress

View file

@ -1,11 +1,11 @@
package info.nightscout.plugins.di
package info.nightscout.pump.virtual.di
import dagger.Binds
import dagger.Module
import dagger.android.ContributesAndroidInjector
import info.nightscout.interfaces.pump.VirtualPump
import info.nightscout.plugins.pump.virtual.VirtualPumpFragment
import info.nightscout.plugins.pump.virtual.VirtualPumpPlugin
import info.nightscout.pump.virtual.VirtualPumpFragment
import info.nightscout.pump.virtual.VirtualPumpPlugin
@Module(
includes = [

View file

@ -1,4 +1,4 @@
package info.nightscout.plugins.pump.virtual.events
package info.nightscout.pump.virtual.events
import info.nightscout.rx.events.EventUpdateGui

View file

@ -1,4 +1,4 @@
package info.nightscout.plugins.extensions
package info.nightscout.pump.virtual.extensions
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.shared.interfaces.ResourceHelper

View file

@ -2,7 +2,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".pump.virtual.VirtualPumpFragment">
tools:context=".VirtualPumpFragment">
<LinearLayout
android:layout_width="match_parent"

View file

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="virtualPumpTypes">
<item>Generic AAPS</item>
<item>MDI</item>
<item>Accu-Chek Combo</item>
<item>Accu-Chek Spirit</item>
<item>Accu-Chek Insight</item>
<item>Accu-Chek Solo</item>
<item>Animas Ping</item>
<item>Animas Vibe</item>
<item>Cellnovo</item>
<item>DanaR</item>
<item>DanaR Korean</item>
<item>DanaRS</item>
<item>DanaRv2</item>
<item>DanaI</item>
<item>Diaconn G8</item>
<item>Eoflow Eopatch2</item>
<item>Medtronic 512/712</item>
<item>Medtronic 515/715</item>
<item>Medtronic 522/722</item>
<item>Medtronic 523/723 (Revel)</item>
<item>Medtronic 554/754 (Veo)</item>
<item>Medtronic 640G</item>
<item>Omnipod Dash</item>
<item>Omnipod Eros</item>
<item>Tandem t:slim</item>
<item>Tandem t:flex</item>
<item>Tandem t:slim G4</item>
<item>Tandem t:slim X2</item>
<item>YpsoPump</item>
</string-array>
</resources>

View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- VirtualPump -->
<string name="virtual_pump_type">Virtual Pump Type</string>
<string name="virtual_pump_definition">Pump Definition</string>
<string name="virtual_pump_pump_def">Bolus: Step=%1$s\nExtended Bolus: [Step=%2$s, Duration=%3$smin-%4$sh]\nBasal: Step=%5$s\nTBR: %6$s (by %7$s), Duration=%8$smin-%9$sh\n%10$s</string>
<string name="virtual_pump_shortname">VPUMP</string>
<string name="description_pump_virtual">Pump integration for pumps which don\'t have any driver yet (Open Loop)</string>
<string name="virtual_pump_label">VIRTUAL PUMP</string>
<string name="virtualpump_settings">Virtual pump settings</string>
</resources>

View file

@ -0,0 +1,37 @@
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.plugins.pump.virtual
package info.nightscout.pump.virtual
import dagger.android.AndroidInjector
import info.nightscout.androidaps.TestBase
@ -13,7 +13,7 @@ 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.junit.Assert
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.Mock
@ -32,7 +32,7 @@ class VirtualPumpPluginUTest : TestBase() {
@Mock lateinit var pumpSync: PumpSync
@Mock lateinit var config: Config
lateinit var virtualPumpPlugin: VirtualPumpPlugin
private lateinit var virtualPumpPlugin: VirtualPumpPlugin
@BeforeEach
fun prepareMocks() {
@ -43,7 +43,7 @@ class VirtualPumpPluginUTest : TestBase() {
fun refreshConfiguration() {
`when`(sp.getString(info.nightscout.core.utils.R.string.key_virtualpump_type, "Generic AAPS")).thenReturn("Accu-Chek Combo")
virtualPumpPlugin.refreshConfiguration()
Assert.assertEquals(PumpType.ACCU_CHEK_COMBO, virtualPumpPlugin.pumpType)
Assertions.assertEquals(PumpType.ACCU_CHEK_COMBO, virtualPumpPlugin.pumpType)
}
@Test
@ -52,6 +52,6 @@ class VirtualPumpPluginUTest : TestBase() {
virtualPumpPlugin.refreshConfiguration()
`when`(sp.getString(info.nightscout.core.utils.R.string.key_virtualpump_type, "Generic AAPS")).thenReturn("Accu-Chek Combo")
virtualPumpPlugin.refreshConfiguration()
Assert.assertEquals(PumpType.ACCU_CHEK_COMBO, virtualPumpPlugin.pumpType)
Assertions.assertEquals(PumpType.ACCU_CHEK_COMBO, virtualPumpPlugin.pumpType)
}
}

View file

@ -40,5 +40,6 @@ include ':pump:omnipod-dash'
include ':pump:pump-common'
include ':pump:pump-core'
include ':pump:rileylink'
include ':pump:virtual'
include ':plugins:sync'
include ':workflow'