fix RS plugin

This commit is contained in:
Milos Kozak 2021-02-19 20:58:35 +01:00
parent 051cbe7870
commit c00e5859e2

View file

@ -73,7 +73,7 @@ class DanaRSPlugin @Inject constructor(
private var danaRSService: DanaRSService? = null private var danaRSService: DanaRSService? = null
private var mDeviceAddress = "" private var mDeviceAddress = ""
var mDeviceName = "" var mDeviceName = ""
private var pumpDesc = PumpDescription(PumpType.DanaRS) override val pumpDescription = PumpDescription(PumpType.DanaRS)
override fun updatePreferenceSummary(pref: Preference) { override fun updatePreferenceSummary(pref: Preference) {
super.updatePreferenceSummary(pref) super.updatePreferenceSummary(pref)
@ -156,8 +156,8 @@ class DanaRSPlugin @Inject constructor(
override fun getPumpStatus(reason: String) { override fun getPumpStatus(reason: String) {
danaRSService?.readPumpStatus() danaRSService?.readPumpStatus()
pumpDesc.basalStep = danaPump.basalStep pumpDescription.basalStep = danaPump.basalStep
pumpDesc.bolusStep = danaPump.bolusStep pumpDescription.bolusStep = danaPump.bolusStep
} }
// DanaR interface // DanaR interface
@ -249,9 +249,12 @@ class DanaRSPlugin @Inject constructor(
} }
override fun lastDataTime(): Long = danaPump.lastConnection override fun lastDataTime(): Long = danaPump.lastConnection
override val baseBasalRate: Double = danaPump.currentBasal override val baseBasalRate: Double
override val reservoirLevel: Double = danaPump.reservoirRemainingUnits get() = danaPump.currentBasal
override val batteryLevel: Int = danaPump.batteryRemaining override val reservoirLevel: Double
get() = danaPump.reservoirRemainingUnits
override val batteryLevel: Int
get() = danaPump.batteryRemaining
@Synchronized @Synchronized
override fun deliverTreatment(detailedBolusInfo: DetailedBolusInfo): PumpEnactResult { override fun deliverTreatment(detailedBolusInfo: DetailedBolusInfo): PumpEnactResult {
@ -281,7 +284,7 @@ class DanaRSPlugin @Inject constructor(
if (detailedBolusInfo.insulin > 0 || carbs > 0) connectionOK = danaRSService?.bolus(detailedBolusInfo.insulin, carbs.toInt(), DateUtil.now() + T.mins(carbTime.toLong()).msecs(), t) if (detailedBolusInfo.insulin > 0 || carbs > 0) connectionOK = danaRSService?.bolus(detailedBolusInfo.insulin, carbs.toInt(), DateUtil.now() + T.mins(carbTime.toLong()).msecs(), t)
?: false ?: false
val result = PumpEnactResult(injector) val result = PumpEnactResult(injector)
result.success = connectionOK && abs(detailedBolusInfo.insulin - t.insulin) < pumpDesc.bolusStep result.success = connectionOK && abs(detailedBolusInfo.insulin - t.insulin) < pumpDescription.bolusStep
result.bolusDelivered = t.insulin result.bolusDelivered = t.insulin
result.carbsDelivered = detailedBolusInfo.carbs result.carbsDelivered = detailedBolusInfo.carbs
if (!result.success) { if (!result.success) {
@ -600,8 +603,6 @@ class DanaRSPlugin @Inject constructor(
return danaPump.serialNumber return danaPump.serialNumber
} }
override val pumpDescription: PumpDescription = pumpDesc
@Suppress("SpellCheckingInspection") @Suppress("SpellCheckingInspection")
override fun shortStatus(veryShort: Boolean): String { override fun shortStatus(veryShort: Boolean): String {
var ret = "" var ret = ""