Remove MDIPlugin in favor of VirtualPump with MDI pump type

This commit is contained in:
Milos Kozak 2022-05-20 11:39:51 +02:00
parent d92ce31cc5
commit 1c8cd56491
5 changed files with 3 additions and 168 deletions

View file

@ -44,7 +44,6 @@ import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorP
import info.nightscout.androidaps.plugins.profile.local.LocalProfilePlugin
import info.nightscout.androidaps.plugins.pump.combo.ComboPlugin
import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin
import info.nightscout.androidaps.plugins.pump.mdi.MDIPlugin
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin
import info.nightscout.androidaps.plugins.pump.omnipod.dash.OmnipodDashPumpPlugin
import info.nightscout.androidaps.plugins.pump.omnipod.eros.OmnipodErosPumpPlugin
@ -182,14 +181,8 @@ abstract class PluginsModule {
@Binds
@PumpDriver
@IntoMap
@IntKey(155)
abstract fun bindDiaconnG8Plugin(plugin: DiaconnG8Plugin): PluginBase
@Binds
@NotNSClient
@IntoMap
@IntKey(160)
abstract fun bindMDIPlugin(plugin: MDIPlugin): PluginBase
abstract fun bindDiaconnG8Plugin(plugin: DiaconnG8Plugin): PluginBase
@Binds
@AllConfigs

View file

@ -1,158 +0,0 @@
package info.nightscout.androidaps.plugins.pump.mdi
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.data.DetailedBolusInfo
import info.nightscout.androidaps.data.PumpEnactResult
import info.nightscout.androidaps.interfaces.*
import info.nightscout.androidaps.plugins.common.ManufacturerType
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.InstanceId
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import org.json.JSONException
import org.json.JSONObject
import javax.inject.Inject
import javax.inject.Singleton
@Singleton
class MDIPlugin @Inject constructor(
injector: HasAndroidInjector,
aapsLogger: AAPSLogger,
rh: ResourceHelper,
commandQueue: CommandQueue,
private val dateUtil: DateUtil,
private val pumpSync: PumpSync
) : PumpPluginBase(PluginDescription()
.mainType(PluginType.PUMP)
.pluginIcon(R.drawable.ic_ict)
.pluginName(R.string.mdi)
.description(R.string.description_pump_mdi),
injector, aapsLogger, rh, commandQueue
), Pump {
override val pumpDescription = PumpDescription()
init {
pumpDescription.isBolusCapable = true
pumpDescription.bolusStep = 0.5
pumpDescription.isExtendedBolusCapable = false
pumpDescription.isTempBasalCapable = false
pumpDescription.isSetBasalProfileCapable = false
pumpDescription.isRefillingCapable = false
pumpDescription.isBatteryReplaceable = false
}
override val isFakingTempsByExtendedBoluses: Boolean = false
override fun loadTDDs(): PumpEnactResult = PumpEnactResult(injector)
override fun isInitialized(): Boolean = true
override fun isSuspended(): Boolean = false
override fun isBusy(): Boolean = false
override fun isConnected(): Boolean = true
override fun isConnecting(): Boolean = false
override fun isHandshakeInProgress(): Boolean = false
override fun connect(reason: String) {}
override fun disconnect(reason: String) {}
override fun waitForDisconnectionInSeconds(): Int = 0
override fun stopConnecting() {}
override fun getPumpStatus(reason: String) {}
override fun setNewBasalProfile(profile: Profile): PumpEnactResult = PumpEnactResult(injector).success(true).enacted(true)
override fun isThisProfileSet(profile: Profile): Boolean = false
override fun lastDataTime(): Long = System.currentTimeMillis()
override val baseBasalRate: Double = 0.0
override val reservoirLevel: Double = -1.0
override val batteryLevel: Int = -1
override fun deliverTreatment(detailedBolusInfo: DetailedBolusInfo): PumpEnactResult {
val result = PumpEnactResult(injector)
result.success = true
result.bolusDelivered = detailedBolusInfo.insulin
result.carbsDelivered = detailedBolusInfo.carbs
result.comment = rh.gs(R.string.virtualpump_resultok)
if (detailedBolusInfo.insulin > 0)
pumpSync.syncBolusWithPumpId(
timestamp = detailedBolusInfo.timestamp,
amount = detailedBolusInfo.insulin,
type = detailedBolusInfo.bolusType,
pumpId = dateUtil.now(),
pumpType = PumpType.MDI,
pumpSerial = serialNumber())
if (detailedBolusInfo.carbs > 0)
pumpSync.syncCarbsWithTimestamp(
timestamp = detailedBolusInfo.carbsTimestamp ?: detailedBolusInfo.timestamp,
amount = detailedBolusInfo.carbs,
pumpId = null,
pumpType = PumpType.MDI,
pumpSerial = serialNumber())
return result
}
override fun stopBolusDelivering() {}
override fun setTempBasalAbsolute(absoluteRate: Double, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult {
val result = PumpEnactResult(injector)
result.success = false
result.comment = rh.gs(R.string.pumperror)
aapsLogger.debug(LTag.PUMPBTCOMM, "Setting temp basal absolute: $result")
return result
}
override fun setTempBasalPercent(percent: Int, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult {
val result = PumpEnactResult(injector)
result.success = false
result.comment = rh.gs(R.string.pumperror)
aapsLogger.debug(LTag.PUMPBTCOMM, "Settings temp basal percent: $result")
return result
}
override fun setExtendedBolus(insulin: Double, durationInMinutes: Int): PumpEnactResult {
val result = PumpEnactResult(injector)
result.success = false
result.comment = rh.gs(R.string.pumperror)
aapsLogger.debug(LTag.PUMPBTCOMM, "Setting extended bolus: $result")
return result
}
override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult {
val result = PumpEnactResult(injector)
result.success = false
result.comment = rh.gs(R.string.pumperror)
aapsLogger.debug(LTag.PUMPBTCOMM, "Cancel temp basal: $result")
return result
}
override fun cancelExtendedBolus(): PumpEnactResult {
val result = PumpEnactResult(injector)
result.success = false
result.comment = rh.gs(R.string.pumperror)
aapsLogger.debug(LTag.PUMPBTCOMM, "Canceling extended bolus: $result")
return result
}
override fun getJSONStatus(profile: Profile, profileName: String, version: String): JSONObject {
val now = System.currentTimeMillis()
val pump = JSONObject()
val status = JSONObject()
val extended = JSONObject()
try {
status.put("status", "normal")
extended.put("Version", version)
extended.put("ActiveProfile", profileName)
status.put("timestamp", dateUtil.toISOString(now))
pump.put("status", status)
pump.put("extended", extended)
pump.put("clock", dateUtil.toISOString(now))
} catch (e: JSONException) {
aapsLogger.error("Exception: ", e)
}
return pump
}
override fun manufacturer(): ManufacturerType = ManufacturerType.AndroidAPS
override fun model(): PumpType = PumpType.MDI
override fun serialNumber(): String = InstanceId.instanceId
override fun shortStatus(veryShort: Boolean): String = model().model
override fun canHandleDST(): Boolean = true
}

View file

@ -92,6 +92,7 @@
<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>

View file

@ -81,7 +81,6 @@
<string name="description_overview">Displays the current state of your loop and buttons for most common actions</string>
<string name="description_persistent_notification">Shows an ongoing notification with a short overview of what your loop is doing</string>
<string name="description_profile_local">Define a profile which is available offline.</string>
<string name="description_pump_mdi">Pump integration for people who do multiple daily injections for their diabetes therapy</string>
<string name="description_pump_virtual">Pump integration for pumps which don\'t have any driver yet (Open Loop)</string>
<string name="description_sensitivity_aaps">Sensitivity is calculated the same way like Oref0, but you can specify timeframe to the past. Minimal carb absorption is calculated from max carb absorption time from preferences.</string>
<string name="description_sensitivity_oref1">Sensitivity is calculated from 8h or 24h data in the past (using either which is more sensitive). Carbs (if not absorbed) are cut after time specified in preferences. Plugin also calculates UAM.</string>
@ -303,7 +302,6 @@
<string name="basalvaluebelowminimum">Basal value below minimum. Profile not set!</string>
<string name="sms_actualbg">BG:</string>
<string name="sms_lastbg">Last BG:</string>
<string name="mdi">MDI</string>
<string name="MM640g">MM640g</string>
<string name="ongoingnotificaction">Ongoing Notification</string>
<string name="old_data">OLD DATA</string>

View file

@ -288,6 +288,7 @@ enum class PumpType {
pumpCapability = PumpCapability.YpsomedCapabilities),
MDI(description = "MDI",
manufacturer = ManufacturerType.AndroidAPS,
bolusSize = 0.5,
model = "MDI",
tbrSettings = DoseSettings(1.0, 15, 24 * 60, 0.0, 500.0),
extendedBolusSettings = DoseSettings(0.1, 15, 12 * 60, 0.1),