From 24164eee98fbb11582e2e0111aedb856bd2da996 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Wed, 14 Apr 2021 19:36:13 +0200 Subject: [PATCH] PumpInterface rename --- .../configBuilder/ConfigBuilderPlugin.kt | 2 +- .../plugins/configBuilder/PluginStore.kt | 8 +- .../general/overview/OverviewFragment.kt | 2 +- .../androidaps/plugins/pump/mdi/MDIPlugin.kt | 2 +- .../plugins/pump/virtual/VirtualPumpPlugin.kt | 2 +- .../receivers/TimeDateOrTZChangeReceiver.kt | 4 +- .../utils/extensions/DoubleToSignedString.kt | 4 +- .../nightscout/androidaps/TestPumpPlugin.kt | 4 +- .../general/automation/TestPumpPlugin.kt | 4 +- .../plugins/pump/combo/ComboPlugin.java | 4 +- .../nightscout/androidaps/data/Profile.java | 4 +- .../extensions/DeviceStatusExtension.kt | 6 +- .../androidaps/interfaces/ActivePlugin.kt | 2 +- .../interfaces/{PumpInterface.kt => Pump.kt} | 127 +++++++++++++++--- .../androidaps/utils/DecimalFormatter.kt | 8 +- .../nightscout/androidaps/TestPumpPlugin.kt | 4 +- .../androidaps/dana/DanaFragment.kt | 4 +- .../services/DanaRv2ExecutionService.java | 4 +- .../androidaps/danar/AbstractDanaRPlugin.java | 4 +- .../nightscout/androidaps/TestPumpPlugin.kt | 4 +- .../androidaps/danars/DanaRSPlugin.kt | 2 +- .../pump/insight/LocalInsightPlugin.java | 4 +- .../pump/common/PumpPluginAbstract.java | 4 +- .../pump/medtronic/MedtronicPumpPlugin.java | 4 +- .../omnipod/dash/OmnipodDashPumpPlugin.java | 4 +- .../omnipod/eros/OmnipodErosPumpPlugin.java | 4 +- 26 files changed, 161 insertions(+), 64 deletions(-) rename core/src/main/java/info/nightscout/androidaps/interfaces/{PumpInterface.kt => Pump.kt} (72%) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPlugin.kt index ccf362643e..51b85c0a4b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPlugin.kt @@ -186,7 +186,7 @@ class ConfigBuilderPlugin @Inject constructor( PluginType.PROFILE -> pluginsInCategory = activePlugin.getSpecificPluginsListByInterface(ProfileInterface::class.java) PluginType.BGSOURCE -> pluginsInCategory = activePlugin.getSpecificPluginsListByInterface(BgSource::class.java) PluginType.TREATMENT -> pluginsInCategory = activePlugin.getSpecificPluginsListByInterface(TreatmentsInterface::class.java) - PluginType.PUMP -> pluginsInCategory = activePlugin.getSpecificPluginsListByInterface(PumpInterface::class.java) + PluginType.PUMP -> pluginsInCategory = activePlugin.getSpecificPluginsListByInterface(Pump::class.java) else -> { } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/PluginStore.kt b/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/PluginStore.kt index d8ae74d8c2..897798e778 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/PluginStore.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/PluginStore.kt @@ -16,7 +16,7 @@ class PluginStore @Inject constructor( lateinit var plugins: List<@JvmSuppressWildcards PluginBase> private var activeBgSourceStore: BgSource? = null - private var activePumpStore: PumpInterface? = null + private var activePumpStore: Pump? = null private var activeProfile: ProfileInterface? = null private var activeAPSStore: APS? = null private var activeInsulinStore: Insulin? = null @@ -114,9 +114,9 @@ class PluginStore @Inject constructor( // PluginType.PUMP pluginsInCategory = getSpecificPluginsList(PluginType.PUMP) - activePumpStore = getTheOneEnabledInArray(pluginsInCategory, PluginType.PUMP) as PumpInterface? + activePumpStore = getTheOneEnabledInArray(pluginsInCategory, PluginType.PUMP) as Pump? if (activePumpStore == null) { - activePumpStore = getDefaultPlugin(PluginType.PUMP) as PumpInterface + activePumpStore = getDefaultPlugin(PluginType.PUMP) as Pump (activePumpStore as PluginBase).setPluginEnabled(PluginType.PUMP, true) aapsLogger.debug(LTag.CONFIGBUILDER, "Defaulting PumpInterface") } @@ -168,7 +168,7 @@ class PluginStore @Inject constructor( override val activeAPS: APS get() = activeAPSStore ?: checkNotNull(activeAPSStore) { "No APS selected" } - override val activePump: PumpInterface + override val activePump: Pump get() = activePumpStore ?: checkNotNull(activePumpStore) { "No pump selected" } override val activeSensitivity: Sensitivity diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt index c93559f279..bbf702cfa9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt @@ -815,7 +815,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList } ?: "" } - private fun updateGraph(lastRun: LoopInterface.LastRun?, predictionsAvailable: Boolean, lowLine: Double, highLine: Double, pump: PumpInterface, profile: Profile) { + private fun updateGraph(lastRun: LoopInterface.LastRun?, predictionsAvailable: Boolean, lowLine: Double, highLine: Double, pump: Pump, profile: Profile) { viewLifecycleOwner.lifecycleScope.launch(Dispatchers.Main) { if (_binding == null) return@launch val menuChartSettings = overviewMenus.setting diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/mdi/MDIPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/mdi/MDIPlugin.kt index 609d753704..758bf03ff5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/mdi/MDIPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/mdi/MDIPlugin.kt @@ -33,7 +33,7 @@ class MDIPlugin @Inject constructor( .pluginName(R.string.mdi) .description(R.string.description_pump_mdi), injector, aapsLogger, resourceHelper, commandQueue -), PumpInterface { +), Pump { override val pumpDescription = PumpDescription() diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.kt index df2a67928c..b595da0409 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.kt @@ -63,7 +63,7 @@ open class VirtualPumpPlugin @Inject constructor( .description(R.string.description_pump_virtual) .setDefault(), injector, aapsLogger, resourceHelper, commandQueue -), PumpInterface { +), Pump { private val disposable = CompositeDisposable() var batteryPercent = 50 diff --git a/app/src/main/java/info/nightscout/androidaps/receivers/TimeDateOrTZChangeReceiver.kt b/app/src/main/java/info/nightscout/androidaps/receivers/TimeDateOrTZChangeReceiver.kt index 24136399f2..51bf087cd0 100644 --- a/app/src/main/java/info/nightscout/androidaps/receivers/TimeDateOrTZChangeReceiver.kt +++ b/app/src/main/java/info/nightscout/androidaps/receivers/TimeDateOrTZChangeReceiver.kt @@ -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.PumpInterface +import info.nightscout.androidaps.interfaces.Pump import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.BundleLogger import info.nightscout.androidaps.logging.LTag @@ -37,7 +37,7 @@ class TimeDateOrTZChangeReceiver : DaggerBroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { super.onReceive(context, intent) val action = intent.action - val activePump: PumpInterface = activePlugin.activePump + val activePump: Pump = activePlugin.activePump aapsLogger.debug(LTag.PUMP, "TimeDateOrTZChangeReceiver::Date, Time and/or TimeZone changed. [action={}]", action) aapsLogger.debug(LTag.PUMP, "TimeDateOrTZChangeReceiver::Intent::{}", BundleLogger.log(intent.extras)) diff --git a/app/src/main/java/info/nightscout/androidaps/utils/extensions/DoubleToSignedString.kt b/app/src/main/java/info/nightscout/androidaps/utils/extensions/DoubleToSignedString.kt index af942b871e..bbad911a7c 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/extensions/DoubleToSignedString.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/extensions/DoubleToSignedString.kt @@ -1,9 +1,9 @@ package info.nightscout.androidaps.utils.extensions -import info.nightscout.androidaps.interfaces.PumpInterface +import info.nightscout.androidaps.interfaces.Pump import info.nightscout.androidaps.utils.DecimalFormatter -fun Double.toSignedString(pump: PumpInterface): String { +fun Double.toSignedString(pump: Pump): String { val formatted = DecimalFormatter.toPumpSupportedBolus(this, pump) return if (this > 0) "+$formatted" else formatted } diff --git a/app/src/test/java/info/nightscout/androidaps/TestPumpPlugin.kt b/app/src/test/java/info/nightscout/androidaps/TestPumpPlugin.kt index bfc9e86370..0cb1ec2e78 100644 --- a/app/src/test/java/info/nightscout/androidaps/TestPumpPlugin.kt +++ b/app/src/test/java/info/nightscout/androidaps/TestPumpPlugin.kt @@ -5,7 +5,7 @@ import info.nightscout.androidaps.data.DetailedBolusInfo import info.nightscout.androidaps.data.Profile import info.nightscout.androidaps.data.PumpEnactResult import info.nightscout.androidaps.interfaces.PumpDescription -import info.nightscout.androidaps.interfaces.PumpInterface +import info.nightscout.androidaps.interfaces.Pump import info.nightscout.androidaps.interfaces.PumpSync import info.nightscout.androidaps.plugins.common.ManufacturerType import info.nightscout.androidaps.plugins.pump.common.defs.PumpType @@ -13,7 +13,7 @@ import info.nightscout.androidaps.utils.TimeChangeType import org.json.JSONObject @Suppress("MemberVisibilityCanBePrivate") -class TestPumpPlugin(val injector: HasAndroidInjector) : PumpInterface { +class TestPumpPlugin(val injector: HasAndroidInjector) : Pump { var connected = false var isProfileSet = true diff --git a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/TestPumpPlugin.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/TestPumpPlugin.kt index 742d0a4ebf..5864054151 100644 --- a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/TestPumpPlugin.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/TestPumpPlugin.kt @@ -7,7 +7,7 @@ import info.nightscout.androidaps.data.PumpEnactResult import info.nightscout.androidaps.interfaces.PluginBase import info.nightscout.androidaps.interfaces.PluginDescription import info.nightscout.androidaps.interfaces.PumpDescription -import info.nightscout.androidaps.interfaces.PumpInterface +import info.nightscout.androidaps.interfaces.Pump import info.nightscout.androidaps.interfaces.PumpSync import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.common.ManufacturerType @@ -23,7 +23,7 @@ class TestPumpPlugin(pluginDescription: PluginDescription, injector: HasAndroidInjector ) : PluginBase( pluginDescription, aapsLogger, resourceHelper, injector -), PumpInterface { +), Pump { var connected = false var isProfileSet = true diff --git a/combo/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java b/combo/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java index 952bd9b7cb..1f17b035cc 100644 --- a/combo/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java +++ b/combo/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java @@ -37,7 +37,7 @@ import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.interfaces.PumpDescription; -import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.interfaces.Pump; import info.nightscout.androidaps.interfaces.PumpPluginBase; import info.nightscout.androidaps.interfaces.PumpSync; import info.nightscout.androidaps.logging.AAPSLogger; @@ -72,7 +72,7 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP; * Created by mike on 05.08.2016. */ @Singleton -public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constraints { +public class ComboPlugin extends PumpPluginBase implements Pump, Constraints { static final String COMBO_TBRS_SET = "combo_tbrs_set"; static final String COMBO_BOLUSES_DELIVERED = "combo_boluses_delivered"; diff --git a/core/src/main/java/info/nightscout/androidaps/data/Profile.java b/core/src/main/java/info/nightscout/androidaps/data/Profile.java index 01cf6f5264..3292c6fe96 100644 --- a/core/src/main/java/info/nightscout/androidaps/data/Profile.java +++ b/core/src/main/java/info/nightscout/androidaps/data/Profile.java @@ -20,7 +20,7 @@ import info.nightscout.androidaps.interfaces.ActivePlugin; import info.nightscout.androidaps.interfaces.Config; import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.interfaces.PumpDescription; -import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.interfaces.Pump; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification; @@ -245,7 +245,7 @@ public class Profile { if (isValid) { // Check for hours alignment - PumpInterface pump = activePlugin.getActivePump(); + Pump pump = activePlugin.getActivePump(); if (!pump.getPumpDescription().is30minBasalRatesCapable()) { for (int index = 0; index < basal_v.size(); index++) { long secondsFromMidnight = basal_v.keyAt(index); diff --git a/core/src/main/java/info/nightscout/androidaps/extensions/DeviceStatusExtension.kt b/core/src/main/java/info/nightscout/androidaps/extensions/DeviceStatusExtension.kt index d7496fafe6..1d5d6dea9c 100644 --- a/core/src/main/java/info/nightscout/androidaps/extensions/DeviceStatusExtension.kt +++ b/core/src/main/java/info/nightscout/androidaps/extensions/DeviceStatusExtension.kt @@ -5,7 +5,7 @@ import info.nightscout.androidaps.database.entities.DeviceStatus import info.nightscout.androidaps.interfaces.IobCobCalculator import info.nightscout.androidaps.interfaces.LoopInterface import info.nightscout.androidaps.interfaces.ProfileFunction -import info.nightscout.androidaps.interfaces.PumpInterface +import info.nightscout.androidaps.interfaces.Pump import info.nightscout.androidaps.plugins.configBuilder.RunningConfiguration import info.nightscout.androidaps.receivers.ReceiverStatusStore import info.nightscout.androidaps.utils.DateUtil @@ -31,7 +31,7 @@ fun buildDeviceStatus( loopPlugin: LoopInterface, iobCobCalculatorPlugin: IobCobCalculator, profileFunction: ProfileFunction, - pumpInterface: PumpInterface, + pump: Pump, receiverStatusStore: ReceiverStatusStore, runningConfiguration: RunningConfiguration, version: String @@ -78,7 +78,7 @@ fun buildDeviceStatus( iob = iob?.toString(), enacted = enacted?.toString(), device = "openaps://" + Build.MANUFACTURER + " " + Build.MODEL, - pump = pumpInterface.getJSONStatus(profile, profileName, version).toString(), + pump = pump.getJSONStatus(profile, profileName, version).toString(), uploaderBattery = receiverStatusStore.batteryLevel, configuration = runningConfiguration.configuration().toString() ) diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/ActivePlugin.kt b/core/src/main/java/info/nightscout/androidaps/interfaces/ActivePlugin.kt index 77dac99e04..9397287f8d 100644 --- a/core/src/main/java/info/nightscout/androidaps/interfaces/ActivePlugin.kt +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/ActivePlugin.kt @@ -32,7 +32,7 @@ interface ActivePlugin { * Currently selected Pump plugin * Default VirtualPump */ - val activePump: PumpInterface + val activePump: Pump /** * Currently selected Sensitivity plugin diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.kt b/core/src/main/java/info/nightscout/androidaps/interfaces/Pump.kt similarity index 72% rename from core/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.kt rename to core/src/main/java/info/nightscout/androidaps/interfaces/Pump.kt index 429939b98e..cd0b20e8dd 100644 --- a/core/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.kt +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/Pump.kt @@ -17,29 +17,104 @@ import org.json.JSONObject * * Created by mike on 04.06.2016. */ -interface PumpInterface { +interface Pump { - fun isInitialized(): Boolean // true if pump status has been read and is ready to accept commands - fun isSuspended(): Boolean // true if suspended (not delivering insulin) - fun isBusy(): Boolean // if true pump is not ready to accept commands right now - fun isConnected(): Boolean // true if BT connection is established - fun isConnecting(): Boolean // true if BT connection is in progress - fun isHandshakeInProgress(): Boolean // true if BT is connected but initial handshake is still in progress - @JvmDefault fun finishHandshaking() {} // set initial handshake completed + /** + * @return true if pump status has been read and is ready to accept commands + */ + fun isInitialized(): Boolean + + /** + * @return true if suspended (not delivering insulin) + */ + fun isSuspended(): Boolean + + /** + * @return true if pump is not ready to accept commands right now + */ + fun isBusy(): Boolean + + /** + * @return true if BT connection is established + */ + fun isConnected(): Boolean + + /** + * @return true if BT connection is in progress + */ + fun isConnecting(): Boolean + + /** + * @return true if BT is connected but initial handshake is still in progress + */ + fun isHandshakeInProgress(): Boolean + + /** + * set initial handshake completed (moved to connected state) + */ + @JvmDefault fun finishHandshaking() {} + + /** + * Perform BT connect, there is new command waiting in queue + * @param reason originator identification + */ fun connect(reason: String) + + /** + * Perform BT disconnect, there is NO command waiting in queue + * @param reason originator identification + */ fun disconnect(reason: String) - @JvmDefault fun waitForDisconnectionInSeconds(): Int = 5 // wait [x] second after last command before sending disconnect + + /** + * @return # of second to wait before [disconnect] is send after last command + */ + @JvmDefault fun waitForDisconnectionInSeconds(): Int = 5 + + /** + * Stop connection process + */ fun stopConnecting() + + /** + * Force reading of full pump status + * @param reason originator identification + */ fun getPumpStatus(reason: String) - // Upload to pump new basal profile + /** + * Upload to pump new basal profile (and IC/ISF if supported by pump) + * + * @param profile new profile + */ fun setNewBasalProfile(profile: Profile): PumpEnactResult + + /** + * @param profile profile to check + * + * @return true if pump is running the same profile as in param + */ fun isThisProfileSet(profile: Profile): Boolean + + /** + * @return timestamp of last connection to the pump + */ fun lastDataTime(): Long - val baseBasalRate: Double // base basal rate, not temp basal + /** + * Currently running base basal rate [U/h] + */ + val baseBasalRate: Double + + /** + * Reservoir level at time of last connection [Units of insulin] + */ val reservoirLevel: Double - val batteryLevel: Int // in percent as integer + + /** + * Battery level at time of last connection [%] + */ + val batteryLevel: Int /** * Request a bolus to be delivered, carbs to be stored on pump or both. @@ -137,13 +212,30 @@ interface PumpInterface { */ fun serialNumber(): String - // Pump capabilities + /** + * Pump capabilities + */ val pumpDescription: PumpDescription - // Short info for SMS, Wear etc + /** + * Short info for SMS, Wear etc + */ fun shortStatus(veryShort: Boolean): String + + /** + * @return true if pump is currently emulating temporary basals by extended boluses (usually to bypass 200% limit) + */ val isFakingTempsByExtendedBoluses: Boolean + + /** + * Load TDDs and store them to the database + */ fun loadTDDs(): PumpEnactResult + + /** + * @return true if pump handles DST changes by it self. In this case it's not necessary stop the loop + * after DST change + */ fun canHandleDST(): Boolean /** @@ -176,9 +268,14 @@ interface PumpInterface { */ @JvmDefault fun timezoneOrDSTChanged(timeChangeType: TimeChangeType) {} - /* Only used for pump types where hasCustomUnreachableAlertCheck=true */ + /** + * Only used for pump types where hasCustomUnreachableAlertCheck=true + */ @JvmDefault fun isUnreachableAlertTimeoutExceeded(alertTimeoutMilliseconds: Long): Boolean = false + /** + * if true APS set 100% basal before full hour to avoid pump beeping + */ @JvmDefault fun setNeutralTempAtFullHour(): Boolean = false } \ No newline at end of file diff --git a/core/src/main/java/info/nightscout/androidaps/utils/DecimalFormatter.kt b/core/src/main/java/info/nightscout/androidaps/utils/DecimalFormatter.kt index 7d04cb8447..280e8a348e 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/DecimalFormatter.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/DecimalFormatter.kt @@ -1,7 +1,7 @@ package info.nightscout.androidaps.utils import info.nightscout.androidaps.core.R -import info.nightscout.androidaps.interfaces.PumpInterface +import info.nightscout.androidaps.interfaces.Pump import info.nightscout.androidaps.utils.resources.ResourceHelper import java.text.DecimalFormat @@ -20,7 +20,7 @@ object DecimalFormatter { fun to2Decimal(value: Double, unit: String): String = format2dec.format(value) + unit fun to3Decimal(value: Double): String = format3dec.format(value) fun to3Decimal(value: Double, unit: String): String = format3dec.format(value) + unit - fun toPumpSupportedBolus(value: Double, pump: PumpInterface): String = if (pump.pumpDescription.bolusStep <= 0.051) to2Decimal(value) else to1Decimal(value) - fun toPumpSupportedBolus(value: Double, pump: PumpInterface, resourceHelper: ResourceHelper): String = if (pump.pumpDescription.bolusStep <= 0.051) resourceHelper.gs(R.string.formatinsulinunits, value) else resourceHelper.gs(R.string.formatinsulinunits1, value) - fun pumpSupportedBolusFormat(pump: PumpInterface): DecimalFormat = if (pump.pumpDescription.bolusStep <= 0.051) DecimalFormat("0.00") else DecimalFormat("0.0") + fun toPumpSupportedBolus(value: Double, pump: Pump): String = if (pump.pumpDescription.bolusStep <= 0.051) to2Decimal(value) else to1Decimal(value) + fun toPumpSupportedBolus(value: Double, pump: Pump, resourceHelper: ResourceHelper): String = if (pump.pumpDescription.bolusStep <= 0.051) resourceHelper.gs(R.string.formatinsulinunits, value) else resourceHelper.gs(R.string.formatinsulinunits1, value) + fun pumpSupportedBolusFormat(pump: Pump): DecimalFormat = if (pump.pumpDescription.bolusStep <= 0.051) DecimalFormat("0.00") else DecimalFormat("0.0") } \ No newline at end of file diff --git a/core/src/test/java/info/nightscout/androidaps/TestPumpPlugin.kt b/core/src/test/java/info/nightscout/androidaps/TestPumpPlugin.kt index bfc9e86370..0cb1ec2e78 100644 --- a/core/src/test/java/info/nightscout/androidaps/TestPumpPlugin.kt +++ b/core/src/test/java/info/nightscout/androidaps/TestPumpPlugin.kt @@ -5,7 +5,7 @@ import info.nightscout.androidaps.data.DetailedBolusInfo import info.nightscout.androidaps.data.Profile import info.nightscout.androidaps.data.PumpEnactResult import info.nightscout.androidaps.interfaces.PumpDescription -import info.nightscout.androidaps.interfaces.PumpInterface +import info.nightscout.androidaps.interfaces.Pump import info.nightscout.androidaps.interfaces.PumpSync import info.nightscout.androidaps.plugins.common.ManufacturerType import info.nightscout.androidaps.plugins.pump.common.defs.PumpType @@ -13,7 +13,7 @@ import info.nightscout.androidaps.utils.TimeChangeType import org.json.JSONObject @Suppress("MemberVisibilityCanBePrivate") -class TestPumpPlugin(val injector: HasAndroidInjector) : PumpInterface { +class TestPumpPlugin(val injector: HasAndroidInjector) : Pump { var connected = false var isProfileSet = true diff --git a/dana/src/main/java/info/nightscout/androidaps/dana/DanaFragment.kt b/dana/src/main/java/info/nightscout/androidaps/dana/DanaFragment.kt index 34968ff475..8277823fbe 100644 --- a/dana/src/main/java/info/nightscout/androidaps/dana/DanaFragment.kt +++ b/dana/src/main/java/info/nightscout/androidaps/dana/DanaFragment.kt @@ -17,7 +17,7 @@ import info.nightscout.androidaps.events.EventPumpStatusChanged import info.nightscout.androidaps.events.EventTempBasalChange import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.interfaces.CommandQueueProvider -import info.nightscout.androidaps.interfaces.PumpInterface +import info.nightscout.androidaps.interfaces.Pump import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.UserEntryLogger @@ -189,7 +189,7 @@ class DanaFragment : DaggerFragment() { fun updateGUI() { if (_binding == null) return val pump = danaPump - val plugin: PumpInterface = activePlugin.activePump + val plugin: Pump = activePlugin.activePump if (pump.lastConnection != 0L) { val agoMsec = System.currentTimeMillis() - pump.lastConnection val agoMin = (agoMsec.toDouble() / 60.0 / 1000.0).toInt() diff --git a/danar/src/main/java/info/nightscout/androidaps/danaRv2/services/DanaRv2ExecutionService.java b/danar/src/main/java/info/nightscout/androidaps/danaRv2/services/DanaRv2ExecutionService.java index 35ad542dd3..cb393a5ed9 100644 --- a/danar/src/main/java/info/nightscout/androidaps/danaRv2/services/DanaRv2ExecutionService.java +++ b/danar/src/main/java/info/nightscout/androidaps/danaRv2/services/DanaRv2ExecutionService.java @@ -58,7 +58,7 @@ import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.interfaces.ActivePlugin; import info.nightscout.androidaps.interfaces.CommandQueueProvider; import info.nightscout.androidaps.interfaces.ProfileFunction; -import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.interfaces.Pump; import info.nightscout.androidaps.interfaces.PumpSync; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; @@ -168,7 +168,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { danaPump.setLastConnection(System.currentTimeMillis()); Profile profile = profileFunction.getProfile(); - PumpInterface pump = activePlugin.getActivePump(); + Pump pump = activePlugin.getActivePump(); if (profile != null && Math.abs(danaPump.getCurrentBasal() - profile.getBasal()) >= pump.getPumpDescription().getBasalStep()) { rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumpsettings))); mSerialIOThread.sendMessage(new MsgSettingBasal(injector)); diff --git a/danar/src/main/java/info/nightscout/androidaps/danar/AbstractDanaRPlugin.java b/danar/src/main/java/info/nightscout/androidaps/danar/AbstractDanaRPlugin.java index 3f29f11fc6..270a4cbe1b 100644 --- a/danar/src/main/java/info/nightscout/androidaps/danar/AbstractDanaRPlugin.java +++ b/danar/src/main/java/info/nightscout/androidaps/danar/AbstractDanaRPlugin.java @@ -23,7 +23,7 @@ import info.nightscout.androidaps.interfaces.Dana; import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PumpDescription; -import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.interfaces.Pump; import info.nightscout.androidaps.interfaces.PumpPluginBase; import info.nightscout.androidaps.interfaces.PumpSync; import info.nightscout.androidaps.logging.AAPSLogger; @@ -46,7 +46,7 @@ import io.reactivex.disposables.CompositeDisposable; * Created by mike on 28.01.2018. */ -public abstract class AbstractDanaRPlugin extends PumpPluginBase implements PumpInterface, Dana, Constraints { +public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump, Dana, Constraints { protected AbstractDanaRExecutionService sExecutionService; protected CompositeDisposable disposable = new CompositeDisposable(); diff --git a/danar/src/test/java/info/nightscout/androidaps/TestPumpPlugin.kt b/danar/src/test/java/info/nightscout/androidaps/TestPumpPlugin.kt index bfc9e86370..0cb1ec2e78 100644 --- a/danar/src/test/java/info/nightscout/androidaps/TestPumpPlugin.kt +++ b/danar/src/test/java/info/nightscout/androidaps/TestPumpPlugin.kt @@ -5,7 +5,7 @@ import info.nightscout.androidaps.data.DetailedBolusInfo import info.nightscout.androidaps.data.Profile import info.nightscout.androidaps.data.PumpEnactResult import info.nightscout.androidaps.interfaces.PumpDescription -import info.nightscout.androidaps.interfaces.PumpInterface +import info.nightscout.androidaps.interfaces.Pump import info.nightscout.androidaps.interfaces.PumpSync import info.nightscout.androidaps.plugins.common.ManufacturerType import info.nightscout.androidaps.plugins.pump.common.defs.PumpType @@ -13,7 +13,7 @@ import info.nightscout.androidaps.utils.TimeChangeType import org.json.JSONObject @Suppress("MemberVisibilityCanBePrivate") -class TestPumpPlugin(val injector: HasAndroidInjector) : PumpInterface { +class TestPumpPlugin(val injector: HasAndroidInjector) : Pump { var connected = false var isProfileSet = true diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/DanaRSPlugin.kt b/danars/src/main/java/info/nightscout/androidaps/danars/DanaRSPlugin.kt index ca289a8757..0693b76912 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/DanaRSPlugin.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/DanaRSPlugin.kt @@ -71,7 +71,7 @@ class DanaRSPlugin @Inject constructor( .preferencesId(R.xml.pref_danars) .description(R.string.description_pump_dana_rs), injector, aapsLogger, resourceHelper, commandQueue -), PumpInterface, Dana, Constraints { +), Pump, Dana, Constraints { private val disposable = CompositeDisposable() private var danaRSService: DanaRSService? = null diff --git a/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java b/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java index 1cb9515b92..2ba8ced252 100644 --- a/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java +++ b/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java @@ -52,7 +52,7 @@ import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.interfaces.PumpDescription; -import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.interfaces.Pump; import info.nightscout.androidaps.interfaces.PumpPluginBase; import info.nightscout.androidaps.interfaces.PumpSync; import info.nightscout.androidaps.interfaces.TreatmentsInterface; @@ -138,7 +138,7 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper; import info.nightscout.androidaps.utils.sharedPreferences.SP; @Singleton -public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface, Constraints, InsightConnectionService.StateCallback { +public class LocalInsightPlugin extends PumpPluginBase implements Pump, Constraints, InsightConnectionService.StateCallback { private final AAPSLogger aapsLogger; private final RxBusWrapper rxBus; diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.java b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.java index 57ab3d013d..47077d5135 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.java +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.java @@ -25,7 +25,7 @@ import info.nightscout.androidaps.interfaces.CommandQueueProvider; import info.nightscout.androidaps.interfaces.Constraints; import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PumpDescription; -import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.interfaces.Pump; import info.nightscout.androidaps.interfaces.PumpPluginBase; import info.nightscout.androidaps.interfaces.PumpSync; import info.nightscout.androidaps.logging.AAPSLogger; @@ -50,7 +50,7 @@ import io.reactivex.disposables.CompositeDisposable; // When using this class, make sure that your first step is to create mConnection (see MedtronicPumpPlugin) -public abstract class PumpPluginAbstract extends PumpPluginBase implements PumpInterface, Constraints { +public abstract class PumpPluginAbstract extends PumpPluginBase implements Pump, Constraints { private final CompositeDisposable disposable = new CompositeDisposable(); protected HasAndroidInjector injector; diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java index 3499364bdb..490bf90359 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java @@ -39,7 +39,7 @@ import info.nightscout.androidaps.interfaces.ActivePlugin; import info.nightscout.androidaps.interfaces.CommandQueueProvider; import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; -import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.interfaces.Pump; import info.nightscout.androidaps.interfaces.PumpSync; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; @@ -97,7 +97,7 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP; * @author Andy Rozman (andy.rozman@gmail.com) */ @Singleton -public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInterface, RileyLinkPumpDevice { +public class MedtronicPumpPlugin extends PumpPluginAbstract implements Pump, RileyLinkPumpDevice { private final SP sp; private final MedtronicUtil medtronicUtil; diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.java b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.java index 4591a4b69e..3386d9f8a0 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.java +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.java @@ -20,7 +20,7 @@ import info.nightscout.androidaps.interfaces.CommandQueueProvider; import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PumpDescription; -import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.interfaces.Pump; import info.nightscout.androidaps.interfaces.PumpPluginBase; import info.nightscout.androidaps.interfaces.PumpSync; import info.nightscout.androidaps.logging.AAPSLogger; @@ -35,7 +35,7 @@ import info.nightscout.androidaps.utils.TimeChangeType; import info.nightscout.androidaps.utils.resources.ResourceHelper; @Singleton -public class OmnipodDashPumpPlugin extends PumpPluginBase implements PumpInterface { +public class OmnipodDashPumpPlugin extends PumpPluginBase implements Pump { private static final PumpDescription PUMP_DESCRIPTION = new PumpDescription(PumpType.OMNIPOD_DASH); private final AAPSLogger aapsLogger; diff --git a/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/OmnipodErosPumpPlugin.java b/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/OmnipodErosPumpPlugin.java index b985f757d2..da8af74d7a 100644 --- a/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/OmnipodErosPumpPlugin.java +++ b/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/OmnipodErosPumpPlugin.java @@ -46,7 +46,7 @@ import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.interfaces.PumpDescription; -import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.interfaces.Pump; import info.nightscout.androidaps.interfaces.PumpPluginBase; import info.nightscout.androidaps.interfaces.PumpSync; import info.nightscout.androidaps.logging.AAPSLogger; @@ -116,7 +116,7 @@ import io.reactivex.disposables.CompositeDisposable; * @author Andy Rozman (andy.rozman@gmail.com) */ @Singleton -public class OmnipodErosPumpPlugin extends PumpPluginBase implements PumpInterface, RileyLinkPumpDevice { +public class OmnipodErosPumpPlugin extends PumpPluginBase implements Pump, RileyLinkPumpDevice { private static final long RILEY_LINK_CONNECT_TIMEOUT_MILLIS = 3 * 60 * 1_000L; // 3 minutes private static final long STATUS_CHECK_INTERVAL_MILLIS = 60 * 1_000L; // 1 minute public static final int STARTUP_STATUS_REQUEST_TRIES = 2;