break more dependencies

This commit is contained in:
Milos Kozak 2022-11-13 18:14:37 +01:00
parent e49c5f2d35
commit c9164e6274
77 changed files with 613 additions and 688 deletions

View file

@ -16,9 +16,11 @@ import info.nightscout.androidaps.R
import info.nightscout.androidaps.databinding.LoopFragmentBinding import info.nightscout.androidaps.databinding.LoopFragmentBinding
import info.nightscout.androidaps.plugins.aps.loop.events.EventLoopSetLastRunGui import info.nightscout.androidaps.plugins.aps.loop.events.EventLoopSetLastRunGui
import info.nightscout.androidaps.plugins.aps.loop.events.EventLoopUpdateGui import info.nightscout.androidaps.plugins.aps.loop.events.EventLoopUpdateGui
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.core.fabric.FabricPrivacy import info.nightscout.core.fabric.FabricPrivacy
import info.nightscout.interfaces.aps.Loop import info.nightscout.interfaces.aps.Loop
import info.nightscout.interfaces.constraints.Constraint import info.nightscout.interfaces.constraints.Constraint
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.utils.HtmlHelper import info.nightscout.interfaces.utils.HtmlHelper
import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
@ -135,9 +137,9 @@ class LoopFragment : DaggerFragment(), MenuProvider {
binding.tbrrequestTime.text = dateUtil.dateAndTimeAndSecondsString(it.lastTBRRequest) binding.tbrrequestTime.text = dateUtil.dateAndTimeAndSecondsString(it.lastTBRRequest)
binding.tbrexecutionTime.text = dateUtil.dateAndTimeAndSecondsString(it.lastTBREnact) binding.tbrexecutionTime.text = dateUtil.dateAndTimeAndSecondsString(it.lastTBREnact)
binding.tbrsetbypump.text = it.tbrSetByPump?.let { tbrSetByPump -> HtmlHelper.fromHtml(tbrSetByPump.toHtml()) } binding.tbrsetbypump.text = it.tbrSetByPump?.let { tbrSetByPump -> HtmlHelper.fromHtml(tbrSetByPump.toHtml(rh)) }
?: "" ?: ""
binding.smbsetbypump.text = it.smbSetByPump?.let { smbSetByPump -> HtmlHelper.fromHtml(smbSetByPump.toHtml()) } binding.smbsetbypump.text = it.smbSetByPump?.let { smbSetByPump -> HtmlHelper.fromHtml(smbSetByPump.toHtml(rh)) }
?: "" ?: ""
var constraints = var constraints =
@ -168,4 +170,44 @@ class LoopFragment : DaggerFragment(), MenuProvider {
binding.smbsetbypump.text = "" binding.smbsetbypump.text = ""
binding.swipeRefresh.isRefreshing = false binding.swipeRefresh.isRefreshing = false
} }
private fun PumpEnactResult.toHtml(rh: ResourceHelper): String {
var ret = "<b>" + rh.gs(info.nightscout.core.main.R.string.success) + "</b>: " + success
if (queued) {
ret = rh.gs(info.nightscout.core.main.R.string.waitingforpumpresult)
} else if (enacted) {
when {
bolusDelivered > 0 -> {
ret += "<br><b>" + rh.gs(info.nightscout.core.main.R.string.enacted) + "</b>: " + enacted
if (comment.isNotEmpty()) ret += "<br><b>" + rh.gs(info.nightscout.core.main.R.string.comment) + "</b>: " + comment
ret += "<br><b>" + rh.gs(info.nightscout.core.main.R.string.smb_shortname) + "</b>: " + bolusDelivered + " " + rh.gs(info.nightscout.core.main.R.string.insulin_unit_shortname)
}
isTempCancel -> {
ret += "<br><b>" + rh.gs(info.nightscout.core.main.R.string.enacted) + "</b>: " + enacted
ret += "<br><b>" + rh.gs(info.nightscout.core.main.R.string.comment) + "</b>: " + comment +
"<br>" + rh.gs(info.nightscout.core.main.R.string.cancel_temp)
}
isPercent && percent != -1 -> {
ret += "<br><b>" + rh.gs(info.nightscout.core.main.R.string.enacted) + "</b>: " + enacted
if (comment.isNotEmpty()) ret += "<br><b>" + rh.gs(info.nightscout.core.main.R.string.comment) + "</b>: " + comment
ret += "<br><b>" + rh.gs(info.nightscout.core.main.R.string.duration) + "</b>: " + duration + " min"
ret += "<br><b>" + rh.gs(info.nightscout.core.main.R.string.percent) + "</b>: " + percent + "%"
}
absolute != -1.0 -> {
ret += "<br><b>" + rh.gs(info.nightscout.core.main.R.string.enacted) + "</b>: " + enacted
if (comment.isNotEmpty()) ret += "<br><b>" + rh.gs(info.nightscout.core.main.R.string.comment) + "</b>: " + comment
ret += "<br><b>" + rh.gs(info.nightscout.core.main.R.string.duration) + "</b>: " + duration + " min"
ret += "<br><b>" + rh.gs(info.nightscout.core.main.R.string.absolute) + "</b>: " + DecimalFormatter.to2Decimal(absolute) + " U/h"
}
}
} else {
if (comment.isNotEmpty()) ret += "<br><b>" + rh.gs(info.nightscout.core.main.R.string.comment) + "</b>: " + comment
}
return ret
}
} }

View file

@ -16,7 +16,6 @@ import info.nightscout.androidaps.BuildConfig
import info.nightscout.androidaps.MainActivity import info.nightscout.androidaps.MainActivity
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.annotations.OpenForTesting import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.extensions.convertedToAbsolute import info.nightscout.androidaps.extensions.convertedToAbsolute
import info.nightscout.androidaps.extensions.convertedToPercent import info.nightscout.androidaps.extensions.convertedToPercent
import info.nightscout.androidaps.extensions.plannedRemainingMinutes import info.nightscout.androidaps.extensions.plannedRemainingMinutes
@ -52,6 +51,7 @@ import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.pump.DetailedBolusInfo import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.pump.PumpSync import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.pump.defs.PumpDescription import info.nightscout.interfaces.pump.defs.PumpDescription
import info.nightscout.interfaces.queue.Callback import info.nightscout.interfaces.queue.Callback
@ -383,7 +383,7 @@ class LoopPlugin @Inject constructor(
if (resultAfterConstraints.isChangeRequested if (resultAfterConstraints.isChangeRequested
&& !commandQueue.bolusInQueue() && !commandQueue.bolusInQueue()
) { ) {
val waiting = PumpEnactResultObject(injector) val waiting = PumpEnactResult(injector)
waiting.queued = true waiting.queued = true
if (resultAfterConstraints.isTempBasalRequested) lastRun.tbrSetByPump = waiting if (resultAfterConstraints.isTempBasalRequested) lastRun.tbrSetByPump = waiting
if (resultAfterConstraints.isBolusRequested) lastRun.smbSetByPump = if (resultAfterConstraints.isBolusRequested) lastRun.smbSetByPump =
@ -535,18 +535,18 @@ class LoopPlugin @Inject constructor(
*/ */
private fun applyTBRRequest(request: APSResult, profile: Profile, callback: Callback?) { private fun applyTBRRequest(request: APSResult, profile: Profile, callback: Callback?) {
if (!request.isTempBasalRequested) { if (!request.isTempBasalRequested) {
callback?.result(PumpEnactResultObject(injector).enacted(false).success(true).comment(R.string.nochangerequested))?.run() callback?.result(PumpEnactResult(injector).enacted(false).success(true).comment(R.string.nochangerequested))?.run()
return return
} }
val pump = activePlugin.activePump val pump = activePlugin.activePump
if (!pump.isInitialized()) { if (!pump.isInitialized()) {
aapsLogger.debug(LTag.APS, "applyAPSRequest: " + rh.gs(R.string.pumpNotInitialized)) aapsLogger.debug(LTag.APS, "applyAPSRequest: " + rh.gs(R.string.pumpNotInitialized))
callback?.result(PumpEnactResultObject(injector).comment(R.string.pumpNotInitialized).enacted(false).success(false))?.run() callback?.result(PumpEnactResult(injector).comment(R.string.pumpNotInitialized).enacted(false).success(false))?.run()
return return
} }
if (pump.isSuspended()) { if (pump.isSuspended()) {
aapsLogger.debug(LTag.APS, "applyAPSRequest: " + rh.gs(R.string.pumpsuspended)) aapsLogger.debug(LTag.APS, "applyAPSRequest: " + rh.gs(R.string.pumpsuspended))
callback?.result(PumpEnactResultObject(injector).comment(R.string.pumpsuspended).enacted(false).success(false))?.run() callback?.result(PumpEnactResult(injector).comment(R.string.pumpsuspended).enacted(false).success(false))?.run()
return return
} }
aapsLogger.debug(LTag.APS, "applyAPSRequest: $request") aapsLogger.debug(LTag.APS, "applyAPSRequest: $request")
@ -560,7 +560,7 @@ class LoopPlugin @Inject constructor(
} else { } else {
aapsLogger.debug(LTag.APS, "applyAPSRequest: Basal set correctly") aapsLogger.debug(LTag.APS, "applyAPSRequest: Basal set correctly")
callback?.result( callback?.result(
PumpEnactResultObject(injector).absolute(request.rate).duration(0) PumpEnactResult(injector).absolute(request.rate).duration(0)
.enacted(false).success(true).comment(R.string.basal_set_correctly) .enacted(false).success(true).comment(R.string.basal_set_correctly)
)?.run() )?.run()
} }
@ -573,7 +573,7 @@ class LoopPlugin @Inject constructor(
} else { } else {
aapsLogger.debug(LTag.APS, "applyAPSRequest: Basal set correctly") aapsLogger.debug(LTag.APS, "applyAPSRequest: Basal set correctly")
callback?.result( callback?.result(
PumpEnactResultObject(injector).percent(request.percent).duration(0) PumpEnactResult(injector).percent(request.percent).duration(0)
.enacted(false).success(true).comment(R.string.basal_set_correctly) .enacted(false).success(true).comment(R.string.basal_set_correctly)
)?.run() )?.run()
} }
@ -584,7 +584,7 @@ class LoopPlugin @Inject constructor(
) { ) {
aapsLogger.debug(LTag.APS, "applyAPSRequest: Temp basal set correctly") aapsLogger.debug(LTag.APS, "applyAPSRequest: Temp basal set correctly")
callback?.result( callback?.result(
PumpEnactResultObject(injector).percent(request.percent) PumpEnactResult(injector).percent(request.percent)
.enacted(false).success(true).duration(activeTemp.plannedRemainingMinutes) .enacted(false).success(true).duration(activeTemp.plannedRemainingMinutes)
.comment(R.string.let_temp_basal_run) .comment(R.string.let_temp_basal_run)
)?.run() )?.run()
@ -607,7 +607,7 @@ class LoopPlugin @Inject constructor(
) { ) {
aapsLogger.debug(LTag.APS, "applyAPSRequest: Temp basal set correctly") aapsLogger.debug(LTag.APS, "applyAPSRequest: Temp basal set correctly")
callback?.result( callback?.result(
PumpEnactResultObject(injector).absolute(activeTemp.convertedToAbsolute(now, profile)) PumpEnactResult(injector).absolute(activeTemp.convertedToAbsolute(now, profile))
.enacted(false).success(true).duration(activeTemp.plannedRemainingMinutes) .enacted(false).success(true).duration(activeTemp.plannedRemainingMinutes)
.comment(R.string.let_temp_basal_run) .comment(R.string.let_temp_basal_run)
)?.run() )?.run()
@ -633,7 +633,7 @@ class LoopPlugin @Inject constructor(
if (lastBolusTime != 0L && lastBolusTime + 3 * 60 * 1000 > System.currentTimeMillis()) { if (lastBolusTime != 0L && lastBolusTime + 3 * 60 * 1000 > System.currentTimeMillis()) {
aapsLogger.debug(LTag.APS, "SMB requested but still in 3 min interval") aapsLogger.debug(LTag.APS, "SMB requested but still in 3 min interval")
callback?.result( callback?.result(
PumpEnactResultObject(injector) PumpEnactResult(injector)
.comment(R.string.smb_frequency_exceeded) .comment(R.string.smb_frequency_exceeded)
.enacted(false).success(false) .enacted(false).success(false)
)?.run() )?.run()
@ -641,12 +641,12 @@ class LoopPlugin @Inject constructor(
} }
if (!pump.isInitialized()) { if (!pump.isInitialized()) {
aapsLogger.debug(LTag.APS, "applySMBRequest: " + rh.gs(R.string.pumpNotInitialized)) aapsLogger.debug(LTag.APS, "applySMBRequest: " + rh.gs(R.string.pumpNotInitialized))
callback?.result(PumpEnactResultObject(injector).comment(R.string.pumpNotInitialized).enacted(false).success(false))?.run() callback?.result(PumpEnactResult(injector).comment(R.string.pumpNotInitialized).enacted(false).success(false))?.run()
return return
} }
if (pump.isSuspended()) { if (pump.isSuspended()) {
aapsLogger.debug(LTag.APS, "applySMBRequest: " + rh.gs(R.string.pumpsuspended)) aapsLogger.debug(LTag.APS, "applySMBRequest: " + rh.gs(R.string.pumpsuspended))
callback?.result(PumpEnactResultObject(injector).comment(R.string.pumpsuspended).enacted(false).success(false))?.run() callback?.result(PumpEnactResult(injector).comment(R.string.pumpsuspended).enacted(false).success(false))?.run()
return return
} }
aapsLogger.debug(LTag.APS, "applySMBRequest: $request") aapsLogger.debug(LTag.APS, "applySMBRequest: $request")

View file

@ -1,7 +1,6 @@
package info.nightscout.androidaps package info.nightscout.androidaps
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.pump.DetailedBolusInfo import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.pump.Pump import info.nightscout.interfaces.pump.Pump
@ -44,30 +43,30 @@ class TestPumpPlugin(val injector: HasAndroidInjector) : Pump {
override fun waitForDisconnectionInSeconds(): Int = 0 override fun waitForDisconnectionInSeconds(): Int = 0
override fun getPumpStatus(reason: String) {} override fun getPumpStatus(reason: String) {}
override fun setNewBasalProfile(profile: Profile): PumpEnactResult = PumpEnactResultObject(injector) override fun setNewBasalProfile(profile: Profile): PumpEnactResult = PumpEnactResult(injector)
override fun isThisProfileSet(profile: Profile): Boolean = isProfileSet override fun isThisProfileSet(profile: Profile): Boolean = isProfileSet
override fun lastDataTime(): Long = lastData override fun lastDataTime(): Long = lastData
override val baseBasalRate: Double = baseBasal override val baseBasalRate: Double = baseBasal
override val reservoirLevel: Double = 0.0 override val reservoirLevel: Double = 0.0
override val batteryLevel: Int = 0 override val batteryLevel: Int = 0
override fun deliverTreatment(detailedBolusInfo: DetailedBolusInfo): PumpEnactResult = PumpEnactResultObject(injector).success(true) override fun deliverTreatment(detailedBolusInfo: DetailedBolusInfo): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun stopBolusDelivering() {} override fun stopBolusDelivering() {}
override fun setTempBasalAbsolute(absoluteRate: Double, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult = override fun setTempBasalAbsolute(absoluteRate: Double, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult =
PumpEnactResultObject(injector).success(true) PumpEnactResult(injector).success(true)
override fun setTempBasalPercent(percent: Int, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult = override fun setTempBasalPercent(percent: Int, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult =
PumpEnactResultObject(injector).success(true) PumpEnactResult(injector).success(true)
override fun setExtendedBolus(insulin: Double, durationInMinutes: Int): PumpEnactResult = PumpEnactResultObject(injector).success(true) override fun setExtendedBolus(insulin: Double, durationInMinutes: Int): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult = PumpEnactResultObject(injector).success(true) override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun cancelExtendedBolus(): PumpEnactResult = PumpEnactResultObject(injector).success(true) override fun cancelExtendedBolus(): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun getJSONStatus(profile: Profile, profileName: String, version: String): JSONObject = JSONObject() override fun getJSONStatus(profile: Profile, profileName: String, version: String): JSONObject = JSONObject()
override fun manufacturer(): ManufacturerType = ManufacturerType.AAPS override fun manufacturer(): ManufacturerType = ManufacturerType.AAPS
override fun model(): PumpType = PumpType.GENERIC_AAPS override fun model(): PumpType = PumpType.GENERIC_AAPS
override fun serialNumber(): String = "1" override fun serialNumber(): String = "1"
override fun shortStatus(veryShort: Boolean): String = "" override fun shortStatus(veryShort: Boolean): String = ""
override val isFakingTempsByExtendedBoluses: Boolean = false override val isFakingTempsByExtendedBoluses: Boolean = false
override fun loadTDDs(): PumpEnactResult = PumpEnactResultObject(injector).success(true) override fun loadTDDs(): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun canHandleDST(): Boolean = true override fun canHandleDST(): Boolean = true
override fun timezoneOrDSTChanged(timeChangeType: TimeChangeType) {} override fun timezoneOrDSTChanged(timeChangeType: TimeChangeType) {}
} }

View file

@ -8,7 +8,6 @@ import info.nightscout.androidaps.TestBaseWithProfile
import info.nightscout.androidaps.dana.DanaPump import info.nightscout.androidaps.dana.DanaPump
import info.nightscout.androidaps.danar.DanaRPlugin import info.nightscout.androidaps.danar.DanaRPlugin
import info.nightscout.androidaps.danars.DanaRSPlugin import info.nightscout.androidaps.danars.DanaRSPlugin
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.insight.database.InsightDatabaseDao import info.nightscout.androidaps.insight.database.InsightDatabaseDao
import info.nightscout.androidaps.insight.database.InsightDbHelper import info.nightscout.androidaps.insight.database.InsightDbHelper
import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin

View file

@ -4,17 +4,17 @@ import android.content.Context
import android.widget.LinearLayout import android.widget.LinearLayout
import androidx.annotation.DrawableRes import androidx.annotation.DrawableRes
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.interfaces.queue.Callback
import info.nightscout.shared.utils.DateUtil
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.interfaces.utils.TimerUtil
import info.nightscout.automation.R import info.nightscout.automation.R
import info.nightscout.automation.elements.InputString import info.nightscout.automation.elements.InputString
import info.nightscout.automation.elements.LabelWithElement import info.nightscout.automation.elements.LabelWithElement
import info.nightscout.automation.elements.LayoutBuilder import info.nightscout.automation.elements.LayoutBuilder
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.interfaces.utils.TimerUtil
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.shared.utils.DateUtil
import org.json.JSONObject import org.json.JSONObject
import javax.inject.Inject import javax.inject.Inject
@ -41,7 +41,7 @@ class ActionAlarm(injector: HasAndroidInjector) : Action(injector) {
override fun doAction(callback: Callback) { override fun doAction(callback: Callback) {
timerUtil.scheduleReminder(10, text.value.takeIf { it.isNotBlank() } timerUtil.scheduleReminder(10, text.value.takeIf { it.isNotBlank() }
?: rh.gs(config.appName)) ?: rh.gs(config.appName))
callback.result(PumpEnactResultObject(injector).success(true).comment(R.string.ok)).run() callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok)).run()
} }
override fun toJSON(): String { override fun toJSON(): String {

View file

@ -2,7 +2,6 @@ package info.nightscout.automation.actions
import androidx.annotation.DrawableRes import androidx.annotation.DrawableRes
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.automation.R import info.nightscout.automation.R
import info.nightscout.database.entities.UserEntry import info.nightscout.database.entities.UserEntry
@ -11,6 +10,7 @@ import info.nightscout.interfaces.ConfigBuilder
import info.nightscout.interfaces.aps.Loop import info.nightscout.interfaces.aps.Loop
import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginType import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
@ -41,7 +41,7 @@ class ActionLoopDisable(injector: HasAndroidInjector) : Action(injector) {
} }
}) })
} else { } else {
callback.result(PumpEnactResultObject(injector).success(true).comment(R.string.alreadydisabled)).run() callback.result(PumpEnactResult(injector).success(true).comment(R.string.alreadydisabled)).run()
} }
} }

View file

@ -2,7 +2,6 @@ package info.nightscout.automation.actions
import androidx.annotation.DrawableRes import androidx.annotation.DrawableRes
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.automation.R import info.nightscout.automation.R
import info.nightscout.database.entities.UserEntry import info.nightscout.database.entities.UserEntry
@ -11,6 +10,7 @@ import info.nightscout.interfaces.ConfigBuilder
import info.nightscout.interfaces.aps.Loop import info.nightscout.interfaces.aps.Loop
import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginType import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback import info.nightscout.interfaces.queue.Callback
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventRefreshOverview import info.nightscout.rx.events.EventRefreshOverview
@ -33,9 +33,9 @@ class ActionLoopEnable(injector: HasAndroidInjector) : Action(injector) {
configBuilder.storeSettings("ActionLoopEnable") configBuilder.storeSettings("ActionLoopEnable")
rxBus.send(EventRefreshOverview("ActionLoopEnable")) rxBus.send(EventRefreshOverview("ActionLoopEnable"))
uel.log(UserEntry.Action.LOOP_ENABLED, Sources.Automation, title) uel.log(UserEntry.Action.LOOP_ENABLED, Sources.Automation, title)
callback.result(PumpEnactResultObject(injector).success(true).comment(R.string.ok)).run() callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok)).run()
} else { } else {
callback.result(PumpEnactResultObject(injector).success(true).comment(R.string.alreadyenabled)).run() callback.result(PumpEnactResult(injector).success(true).comment(R.string.alreadyenabled)).run()
} }
} }

View file

@ -2,7 +2,6 @@ package info.nightscout.automation.actions
import androidx.annotation.DrawableRes import androidx.annotation.DrawableRes
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.automation.R import info.nightscout.automation.R
import info.nightscout.database.entities.UserEntry import info.nightscout.database.entities.UserEntry
@ -11,6 +10,7 @@ import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.transactions.CancelCurrentOfflineEventIfAnyTransaction import info.nightscout.database.impl.transactions.CancelCurrentOfflineEventIfAnyTransaction
import info.nightscout.interfaces.ConfigBuilder import info.nightscout.interfaces.ConfigBuilder
import info.nightscout.interfaces.aps.Loop import info.nightscout.interfaces.aps.Loop
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback import info.nightscout.interfaces.queue.Callback
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventRefreshOverview import info.nightscout.rx.events.EventRefreshOverview
@ -45,9 +45,9 @@ class ActionLoopResume(injector: HasAndroidInjector) : Action(injector) {
}) })
rxBus.send(EventRefreshOverview("ActionLoopResume")) rxBus.send(EventRefreshOverview("ActionLoopResume"))
uel.log(UserEntry.Action.RESUME, Sources.Automation, title) uel.log(UserEntry.Action.RESUME, Sources.Automation, title)
callback.result(PumpEnactResultObject(injector).success(true).comment(R.string.ok)).run() callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok)).run()
} else { } else {
callback.result(PumpEnactResultObject(injector).success(true).comment(R.string.notsuspended)).run() callback.result(PumpEnactResult(injector).success(true).comment(R.string.notsuspended)).run()
} }
} }

View file

@ -3,7 +3,6 @@ package info.nightscout.automation.actions
import android.widget.LinearLayout import android.widget.LinearLayout
import androidx.annotation.DrawableRes import androidx.annotation.DrawableRes
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.automation.R import info.nightscout.automation.R
import info.nightscout.automation.elements.InputDuration import info.nightscout.automation.elements.InputDuration
@ -13,6 +12,7 @@ import info.nightscout.database.entities.UserEntry
import info.nightscout.database.entities.UserEntry.Sources import info.nightscout.database.entities.UserEntry.Sources
import info.nightscout.database.entities.ValueWithUnit import info.nightscout.database.entities.ValueWithUnit
import info.nightscout.interfaces.aps.Loop import info.nightscout.interfaces.aps.Loop
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.utils.JsonHelper import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
@ -40,9 +40,9 @@ class ActionLoopSuspend(injector: HasAndroidInjector) : Action(injector) {
UserEntry.Action.SUSPEND, Sources.Automation, title + ": " + rh.gs(R.string.suspendloopforXmin, minutes.getMinutes()), UserEntry.Action.SUSPEND, Sources.Automation, title + ": " + rh.gs(R.string.suspendloopforXmin, minutes.getMinutes()),
ValueWithUnit.Minute(minutes.getMinutes()) ValueWithUnit.Minute(minutes.getMinutes())
) )
callback.result(PumpEnactResultObject(injector).success(true).comment(R.string.ok)).run() callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok)).run()
} else { } else {
callback.result(PumpEnactResultObject(injector).success(true).comment(R.string.alreadysuspended)).run() callback.result(PumpEnactResult(injector).success(true).comment(R.string.alreadysuspended)).run()
} }
} }

View file

@ -3,17 +3,17 @@ package info.nightscout.automation.actions
import android.widget.LinearLayout import android.widget.LinearLayout
import androidx.annotation.DrawableRes import androidx.annotation.DrawableRes
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.transactions.InsertTherapyEventAnnouncementTransaction
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
import info.nightscout.interfaces.notifications.NotificationUserMessage
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.automation.R import info.nightscout.automation.R
import info.nightscout.automation.elements.InputString import info.nightscout.automation.elements.InputString
import info.nightscout.automation.elements.LabelWithElement import info.nightscout.automation.elements.LabelWithElement
import info.nightscout.automation.elements.LayoutBuilder import info.nightscout.automation.elements.LayoutBuilder
import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.transactions.InsertTherapyEventAnnouncementTransaction
import info.nightscout.interfaces.notifications.NotificationUserMessage
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventRefreshOverview import info.nightscout.rx.events.EventRefreshOverview
import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.disposables.CompositeDisposable
@ -39,7 +39,7 @@ class ActionNotification(injector: HasAndroidInjector) : Action(injector) {
rxBus.send(EventNewNotification(notification)) rxBus.send(EventNewNotification(notification))
disposable += repository.runTransaction(InsertTherapyEventAnnouncementTransaction(text.value)).subscribe() disposable += repository.runTransaction(InsertTherapyEventAnnouncementTransaction(text.value)).subscribe()
rxBus.send(EventRefreshOverview("ActionNotification")) rxBus.send(EventRefreshOverview("ActionNotification"))
callback.result(PumpEnactResultObject(injector).success(true).comment(R.string.ok)).run() callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok)).run()
} }
override fun toJSON(): String { override fun toJSON(): String {

View file

@ -3,7 +3,6 @@ package info.nightscout.automation.actions
import android.widget.LinearLayout import android.widget.LinearLayout
import androidx.annotation.DrawableRes import androidx.annotation.DrawableRes
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.automation.R import info.nightscout.automation.R
import info.nightscout.automation.elements.InputProfileName import info.nightscout.automation.elements.InputProfileName
@ -14,6 +13,7 @@ import info.nightscout.database.entities.UserEntry.Sources
import info.nightscout.database.entities.ValueWithUnit import info.nightscout.database.entities.ValueWithUnit
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.utils.JsonHelper import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.rx.logging.LTag import info.nightscout.rx.logging.LTag
@ -39,23 +39,23 @@ class ActionProfileSwitch(injector: HasAndroidInjector) : Action(injector) {
//Check for uninitialized profileName //Check for uninitialized profileName
if (inputProfileName.value == "") { if (inputProfileName.value == "") {
aapsLogger.error(LTag.AUTOMATION, "Selected profile not initialized") aapsLogger.error(LTag.AUTOMATION, "Selected profile not initialized")
callback.result(PumpEnactResultObject(injector).success(false).comment(R.string.error_field_must_not_be_empty)).run() callback.result(PumpEnactResult(injector).success(false).comment(R.string.error_field_must_not_be_empty)).run()
return return
} }
if (profileFunction.getProfile() == null) { if (profileFunction.getProfile() == null) {
aapsLogger.error(LTag.AUTOMATION, "ProfileFunctions not initialized") aapsLogger.error(LTag.AUTOMATION, "ProfileFunctions not initialized")
callback.result(PumpEnactResultObject(injector).success(false).comment(R.string.noprofile)).run() callback.result(PumpEnactResult(injector).success(false).comment(R.string.noprofile)).run()
return return
} }
if (inputProfileName.value == activeProfileName) { if (inputProfileName.value == activeProfileName) {
aapsLogger.debug(LTag.AUTOMATION, "Profile is already switched") aapsLogger.debug(LTag.AUTOMATION, "Profile is already switched")
callback.result(PumpEnactResultObject(injector).success(true).comment(R.string.alreadyset)).run() callback.result(PumpEnactResult(injector).success(true).comment(R.string.alreadyset)).run()
return return
} }
val profileStore = activePlugin.activeProfileSource.profile ?: return val profileStore = activePlugin.activeProfileSource.profile ?: return
if (profileStore.getSpecificProfile(inputProfileName.value) == null) { if (profileStore.getSpecificProfile(inputProfileName.value) == null) {
aapsLogger.error(LTag.AUTOMATION, "Selected profile does not exist! - ${inputProfileName.value}") aapsLogger.error(LTag.AUTOMATION, "Selected profile does not exist! - ${inputProfileName.value}")
callback.result(PumpEnactResultObject(injector).success(false).comment(R.string.notexists)).run() callback.result(PumpEnactResult(injector).success(false).comment(R.string.notexists)).run()
return return
} }
uel.log( uel.log(
@ -64,7 +64,7 @@ class ActionProfileSwitch(injector: HasAndroidInjector) : Action(injector) {
ValueWithUnit.Percent(100) ValueWithUnit.Percent(100)
) )
val result = profileFunction.createProfileSwitch(profileStore, inputProfileName.value, 0, 100, 0, dateUtil.now()) val result = profileFunction.createProfileSwitch(profileStore, inputProfileName.value, 0, 100, 0, dateUtil.now())
callback.result(PumpEnactResultObject(injector).success(result).comment(R.string.ok)).run() callback.result(PumpEnactResult(injector).success(result).comment(R.string.ok)).run()
} }
override fun generateDialog(root: LinearLayout) { override fun generateDialog(root: LinearLayout) {

View file

@ -3,7 +3,6 @@ package info.nightscout.automation.actions
import android.widget.LinearLayout import android.widget.LinearLayout
import androidx.annotation.DrawableRes import androidx.annotation.DrawableRes
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.automation.R import info.nightscout.automation.R
import info.nightscout.automation.elements.Comparator import info.nightscout.automation.elements.Comparator
@ -16,6 +15,7 @@ import info.nightscout.database.entities.UserEntry
import info.nightscout.database.entities.UserEntry.Sources import info.nightscout.database.entities.UserEntry.Sources
import info.nightscout.database.entities.ValueWithUnit import info.nightscout.database.entities.ValueWithUnit
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.utils.JsonHelper import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.rx.logging.LTag import info.nightscout.rx.logging.LTag
@ -50,10 +50,10 @@ class ActionProfileSwitchPercent(injector: HasAndroidInjector) : Action(injector
ValueWithUnit.Percent(pct.value.toInt()), ValueWithUnit.Percent(pct.value.toInt()),
ValueWithUnit.Minute(duration.value) ValueWithUnit.Minute(duration.value)
) )
callback.result(PumpEnactResultObject(injector).success(true).comment(R.string.ok)).run() callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok)).run()
} else { } else {
aapsLogger.error(LTag.AUTOMATION, "Final profile not valid") aapsLogger.error(LTag.AUTOMATION, "Final profile not valid")
callback.result(PumpEnactResultObject(injector).success(false).comment(R.string.ok)).run() callback.result(PumpEnactResult(injector).success(false).comment(R.string.ok)).run()
} }
} }

View file

@ -3,7 +3,6 @@ package info.nightscout.automation.actions
import android.widget.LinearLayout import android.widget.LinearLayout
import androidx.annotation.DrawableRes import androidx.annotation.DrawableRes
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.automation.R import info.nightscout.automation.R
import info.nightscout.automation.elements.InputDuration import info.nightscout.automation.elements.InputDuration
import info.nightscout.automation.elements.InputProfileName import info.nightscout.automation.elements.InputProfileName
@ -12,6 +11,7 @@ import info.nightscout.automation.elements.LayoutBuilder
import info.nightscout.interfaces.autotune.Autotune import info.nightscout.interfaces.autotune.Autotune
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.utils.JsonHelper import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.rx.logging.LTag import info.nightscout.rx.logging.LTag
@ -48,11 +48,11 @@ class ActionRunAutotune(injector: HasAndroidInjector) : Action(injector) {
message = R.string.autotune_run_with_error message = R.string.autotune_run_with_error
aapsLogger.error(LTag.AUTOMATION, "Error during Autotune Run") aapsLogger.error(LTag.AUTOMATION, "Error during Autotune Run")
} }
callback.result(PumpEnactResultObject(injector).success(autotunePlugin.lastRunSuccess).comment(message)).run() callback.result(PumpEnactResult(injector).success(autotunePlugin.lastRunSuccess).comment(message)).run()
} else { } else {
message = R.string.autotune_run_cancelled message = R.string.autotune_run_cancelled
aapsLogger.debug(LTag.AUTOMATION, "Autotune run detected, Autotune Run Cancelled") aapsLogger.debug(LTag.AUTOMATION, "Autotune run detected, Autotune Run Cancelled")
callback.result(PumpEnactResultObject(injector).success(false).comment(message)).run() callback.result(PumpEnactResult(injector).success(false).comment(message)).run()
} }
}.start() }.start()
return return

View file

@ -2,11 +2,11 @@ package info.nightscout.automation.actions
import android.widget.LinearLayout import android.widget.LinearLayout
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.automation.R import info.nightscout.automation.R
import info.nightscout.automation.elements.InputString import info.nightscout.automation.elements.InputString
import info.nightscout.automation.elements.LabelWithElement import info.nightscout.automation.elements.LabelWithElement
import info.nightscout.automation.elements.LayoutBuilder import info.nightscout.automation.elements.LayoutBuilder
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.smsCommunicator.SmsCommunicator import info.nightscout.interfaces.smsCommunicator.SmsCommunicator
import info.nightscout.interfaces.utils.JsonHelper import info.nightscout.interfaces.utils.JsonHelper
@ -25,7 +25,7 @@ class ActionSendSMS(injector: HasAndroidInjector) : Action(injector) {
override fun doAction(callback: Callback) { override fun doAction(callback: Callback) {
val result = smsCommunicator.sendNotificationToAllNumbers(text.value) val result = smsCommunicator.sendNotificationToAllNumbers(text.value)
callback.result(PumpEnactResultObject(injector).success(result).comment(if (result) R.string.ok else R.string.error)).run() callback.result(PumpEnactResult(injector).success(result).comment(if (result) R.string.ok else R.string.error)).run()
} }
override fun isValid(): Boolean = text.value.isNotEmpty() override fun isValid(): Boolean = text.value.isNotEmpty()

View file

@ -3,7 +3,6 @@ package info.nightscout.automation.actions
import android.widget.LinearLayout import android.widget.LinearLayout
import androidx.annotation.DrawableRes import androidx.annotation.DrawableRes
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.extensions.friendlyDescription import info.nightscout.androidaps.extensions.friendlyDescription
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.automation.R import info.nightscout.automation.R
@ -25,6 +24,7 @@ import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.utils.JsonHelper import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.interfaces.utils.JsonHelper.safeGetDouble import info.nightscout.interfaces.utils.JsonHelper.safeGetDouble
@ -69,10 +69,10 @@ class ActionStartTempTarget(injector: HasAndroidInjector) : Action(injector) {
ValueWithUnit.Mgdl(tt().highTarget).takeIf { tt().lowTarget != tt().highTarget }, ValueWithUnit.Mgdl(tt().highTarget).takeIf { tt().lowTarget != tt().highTarget },
ValueWithUnit.Minute(TimeUnit.MILLISECONDS.toMinutes(tt().duration).toInt()) ValueWithUnit.Minute(TimeUnit.MILLISECONDS.toMinutes(tt().duration).toInt())
) )
callback.result(PumpEnactResultObject(injector).success(true).comment(R.string.ok)).run() callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok)).run()
}, { }, {
aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", it) aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", it)
callback.result(PumpEnactResultObject(injector).success(false).comment(R.string.error)).run() callback.result(PumpEnactResult(injector).success(false).comment(R.string.error)).run()
}) })
} }

View file

@ -3,9 +3,9 @@ package info.nightscout.automation.actions
import androidx.annotation.DrawableRes import androidx.annotation.DrawableRes
import com.google.gson.JsonObject import com.google.gson.JsonObject
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.interfaces.queue.Callback
import info.nightscout.automation.R import info.nightscout.automation.R
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback
import org.json.JSONObject import org.json.JSONObject
class ActionStopProcessing(injector: HasAndroidInjector) : Action(injector) { class ActionStopProcessing(injector: HasAndroidInjector) : Action(injector) {
@ -17,7 +17,7 @@ class ActionStopProcessing(injector: HasAndroidInjector) : Action(injector) {
override fun isValid(): Boolean = true override fun isValid(): Boolean = true
override fun doAction(callback: Callback) { override fun doAction(callback: Callback) {
callback.result(PumpEnactResultObject(injector).success(true).comment(R.string.ok)).run() callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok)).run()
} }
override fun toJSON(): String { override fun toJSON(): String {

View file

@ -1,13 +1,13 @@
package info.nightscout.automation.actions package info.nightscout.automation.actions
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.transactions.CancelCurrentTemporaryTargetIfAnyTransaction
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.automation.R import info.nightscout.automation.R
import info.nightscout.database.entities.UserEntry import info.nightscout.database.entities.UserEntry
import info.nightscout.database.entities.UserEntry.Sources import info.nightscout.database.entities.UserEntry.Sources
import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.transactions.CancelCurrentTemporaryTargetIfAnyTransaction
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback import info.nightscout.interfaces.queue.Callback
import info.nightscout.rx.logging.LTag import info.nightscout.rx.logging.LTag
import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.DateUtil
@ -35,7 +35,7 @@ class ActionStopTempTarget(injector: HasAndroidInjector) : Action(injector) {
}, { }, {
aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", it) aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", it)
}) })
callback.result(PumpEnactResultObject(injector).success(true).comment(R.string.ok)).run() callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok)).run()
} }
override fun isValid(): Boolean = true override fun isValid(): Boolean = true

View file

@ -1,7 +1,6 @@
package info.nightscout.androidaps package info.nightscout.androidaps
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginDescription import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile
@ -56,31 +55,31 @@ class TestPumpPlugin(
override fun waitForDisconnectionInSeconds(): Int = 0 override fun waitForDisconnectionInSeconds(): Int = 0
override fun getPumpStatus(reason: String) {} override fun getPumpStatus(reason: String) {}
override fun setNewBasalProfile(profile: Profile): PumpEnactResult = PumpEnactResultObject(injector) override fun setNewBasalProfile(profile: Profile): PumpEnactResult = PumpEnactResult(injector)
override fun isThisProfileSet(profile: Profile): Boolean = isProfileSet override fun isThisProfileSet(profile: Profile): Boolean = isProfileSet
override fun lastDataTime(): Long = lastData override fun lastDataTime(): Long = lastData
override val baseBasalRate: Double = baseBasal override val baseBasalRate: Double = baseBasal
override val reservoirLevel: Double = 0.0 override val reservoirLevel: Double = 0.0
override val batteryLevel: Int = 0 override val batteryLevel: Int = 0
override fun deliverTreatment(detailedBolusInfo: DetailedBolusInfo): PumpEnactResult = PumpEnactResultObject(injector).success(true) override fun deliverTreatment(detailedBolusInfo: DetailedBolusInfo): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun stopBolusDelivering() {} override fun stopBolusDelivering() {}
override fun setTempBasalAbsolute(absoluteRate: Double, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult = PumpEnactResultObject( override fun setTempBasalAbsolute(absoluteRate: Double, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult = PumpEnactResult(
injector injector
).success(true) ).success(true)
override fun setTempBasalPercent(percent: Int, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult = override fun setTempBasalPercent(percent: Int, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult =
PumpEnactResultObject(injector).success(true) PumpEnactResult(injector).success(true)
override fun setExtendedBolus(insulin: Double, durationInMinutes: Int): PumpEnactResult = PumpEnactResultObject(injector).success(true) override fun setExtendedBolus(insulin: Double, durationInMinutes: Int): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult = PumpEnactResultObject(injector).success(true) override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun cancelExtendedBolus(): PumpEnactResult = PumpEnactResultObject(injector).success(true) override fun cancelExtendedBolus(): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun getJSONStatus(profile: Profile, profileName: String, version: String): JSONObject = JSONObject() override fun getJSONStatus(profile: Profile, profileName: String, version: String): JSONObject = JSONObject()
override fun manufacturer(): ManufacturerType = ManufacturerType.AAPS override fun manufacturer(): ManufacturerType = ManufacturerType.AAPS
override fun model(): PumpType = PumpType.GENERIC_AAPS override fun model(): PumpType = PumpType.GENERIC_AAPS
override fun serialNumber(): String = "1" override fun serialNumber(): String = "1"
override fun shortStatus(veryShort: Boolean): String = "" override fun shortStatus(veryShort: Boolean): String = ""
override val isFakingTempsByExtendedBoluses: Boolean = false override val isFakingTempsByExtendedBoluses: Boolean = false
override fun loadTDDs(): PumpEnactResult = PumpEnactResultObject(injector).success(true) override fun loadTDDs(): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun canHandleDST(): Boolean = true override fun canHandleDST(): Boolean = true
override fun timezoneOrDSTChanged(timeChangeType: TimeChangeType) {} override fun timezoneOrDSTChanged(timeChangeType: TimeChangeType) {}
override fun specialEnableCondition(): Boolean = specialEnable override fun specialEnableCondition(): Boolean = specialEnable

View file

@ -4,15 +4,14 @@ import android.content.Context
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.TestBase import info.nightscout.androidaps.TestBase
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.interfaces.queue.Callback
import info.nightscout.shared.utils.DateUtil
import info.nightscout.interfaces.utils.TimerUtil
import info.nightscout.automation.R import info.nightscout.automation.R
import info.nightscout.automation.elements.InputString import info.nightscout.automation.elements.InputString
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.utils.TimerUtil
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.utils.DateUtil
import org.junit.Assert import org.junit.Assert
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test

View file

@ -3,15 +3,14 @@ package info.nightscout.automation.actions
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.TestBase import info.nightscout.androidaps.TestBase
import info.nightscout.androidaps.data.PumpEnactResultObject import info.nightscout.automation.R
import info.nightscout.automation.elements.InputString
import info.nightscout.database.impl.AppRepository import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.transactions.InsertTherapyEventAnnouncementTransaction import info.nightscout.database.impl.transactions.InsertTherapyEventAnnouncementTransaction
import info.nightscout.database.impl.transactions.Transaction import info.nightscout.database.impl.transactions.Transaction
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.interfaces.queue.Callback import info.nightscout.interfaces.queue.Callback
import info.nightscout.automation.R
import info.nightscout.automation.elements.InputString
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.shared.interfaces.ResourceHelper
import io.reactivex.rxjava3.core.Completable import io.reactivex.rxjava3.core.Completable
import org.junit.Assert import org.junit.Assert
import org.junit.Before import org.junit.Before

View file

@ -4,7 +4,6 @@ import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.TestBaseWithProfile import info.nightscout.androidaps.TestBaseWithProfile
import info.nightscout.androidaps.TestPumpPlugin import info.nightscout.androidaps.TestPumpPlugin
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.automation.triggers.Trigger import info.nightscout.automation.triggers.Trigger
import info.nightscout.database.entities.OfflineEvent import info.nightscout.database.entities.OfflineEvent

View file

@ -1,165 +0,0 @@
package info.nightscout.androidaps.data
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.core.main.R
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.utils.Round
import info.nightscout.shared.interfaces.ResourceHelper
import org.json.JSONObject
import javax.inject.Inject
class PumpEnactResultObject(injector: HasAndroidInjector) : PumpEnactResult {
@Inject lateinit var rh: ResourceHelper
init {
injector.androidInjector().inject(this)
}
override var success = false // request was processed successfully (but possible no change was needed)
override var enacted = false // request was processed successfully and change has been made
override var comment = ""
// Result of basal change
override var duration = -1 // duration set [minutes]
override var absolute = -1.0 // absolute rate [U/h] , isPercent = false
override var percent = -1 // percent of current basal [%] (100% = current basal), isPercent = true
override var isPercent = false // if true percent is used, otherwise absolute
override var isTempCancel = false // if true we are canceling temp basal
// Result of treatment delivery
override var bolusDelivered = 0.0 // real value of delivered insulin
override var carbsDelivered = 0.0 // real value of delivered carbs
override var queued = false
override fun success(success: Boolean): PumpEnactResultObject = this.also { this.success = success }
override fun enacted(enacted: Boolean): PumpEnactResultObject = this.also { it.enacted = enacted }
override fun comment(comment: String): PumpEnactResultObject = this.also { it.comment = comment }
override fun comment(comment: Int): PumpEnactResultObject = this.also { it.comment = rh.gs(comment) }
override fun duration(duration: Int): PumpEnactResultObject = this.also { it.duration = duration }
override fun absolute(absolute: Double): PumpEnactResultObject = this.also { it.absolute = absolute }
override fun percent(percent: Int): PumpEnactResultObject = this.also { it.percent = percent }
override fun isPercent(isPercent: Boolean): PumpEnactResultObject = this.also { it.isPercent = isPercent }
override fun isTempCancel(isTempCancel: Boolean): PumpEnactResultObject = this.also { it.isTempCancel = isTempCancel }
override fun bolusDelivered(bolusDelivered: Double): PumpEnactResultObject = this.also { it.bolusDelivered = bolusDelivered }
override fun carbsDelivered(carbsDelivered: Double): PumpEnactResultObject = this.also { it.carbsDelivered = carbsDelivered }
override fun queued(queued: Boolean): PumpEnactResultObject = this.also { it.queued = queued }
override fun log(): String {
return "Success: " + success +
" Enacted: " + enacted +
" Comment: " + comment +
" Duration: " + duration +
" Absolute: " + absolute +
" Percent: " + percent +
" IsPercent: " + isPercent +
" IsTempCancel: " + isTempCancel +
" bolusDelivered: " + bolusDelivered +
" carbsDelivered: " + carbsDelivered +
" Queued: " + queued
}
override fun toString(): String = toText()
override fun toText(): String {
var ret = rh.gs(R.string.success) + ": " + success
if (enacted) {
when {
bolusDelivered > 0 -> {
ret += "\n${rh.gs(R.string.enacted)}: $enacted"
ret += "\n${rh.gs(R.string.comment)}: $comment"
ret += "\n${rh.gs(R.string.configbuilder_insulin)}: $bolusDelivered ${rh.gs(R.string.insulin_unit_shortname)}"
}
isTempCancel -> {
ret += "\n${rh.gs(R.string.enacted)}: $enacted"
if (comment.isNotEmpty()) ret += "\n${rh.gs(R.string.comment)}: $comment"
ret += "\n${rh.gs(R.string.cancel_temp)}"
}
isPercent -> {
ret += "\n${rh.gs(R.string.enacted)}: $enacted"
if (comment.isNotEmpty()) ret += "\n${rh.gs(R.string.comment)}: $comment"
ret += "\n${rh.gs(R.string.duration)}: $duration min"
ret += "\n${rh.gs(R.string.percent)}: $percent%"
}
else -> {
ret += "\n${rh.gs(R.string.enacted)}: $enacted"
if (comment.isNotEmpty()) ret += "\n${rh.gs(R.string.comment)}: $comment"
ret += "\n${rh.gs(R.string.duration)}: $duration min"
ret += "\n${rh.gs(R.string.absolute)}: $absolute U/h"
}
}
} else {
ret += "\n${rh.gs(R.string.comment)}: $comment"
}
return ret
}
override fun toHtml(): String {
var ret = "<b>" + rh.gs(R.string.success) + "</b>: " + success
if (queued) {
ret = rh.gs(R.string.waitingforpumpresult)
} else if (enacted) {
when {
bolusDelivered > 0 -> {
ret += "<br><b>" + rh.gs(R.string.enacted) + "</b>: " + enacted
if (comment.isNotEmpty()) ret += "<br><b>" + rh.gs(R.string.comment) + "</b>: " + comment
ret += "<br><b>" + rh.gs(R.string.smb_shortname) + "</b>: " + bolusDelivered + " " + rh.gs(R.string.insulin_unit_shortname)
}
isTempCancel -> {
ret += "<br><b>" + rh.gs(R.string.enacted) + "</b>: " + enacted
ret += "<br><b>" + rh.gs(R.string.comment) + "</b>: " + comment +
"<br>" + rh.gs(R.string.cancel_temp)
}
isPercent && percent != -1 -> {
ret += "<br><b>" + rh.gs(R.string.enacted) + "</b>: " + enacted
if (comment.isNotEmpty()) ret += "<br><b>" + rh.gs(R.string.comment) + "</b>: " + comment
ret += "<br><b>" + rh.gs(R.string.duration) + "</b>: " + duration + " min"
ret += "<br><b>" + rh.gs(R.string.percent) + "</b>: " + percent + "%"
}
absolute != -1.0 -> {
ret += "<br><b>" + rh.gs(R.string.enacted) + "</b>: " + enacted
if (comment.isNotEmpty()) ret += "<br><b>" + rh.gs(R.string.comment) + "</b>: " + comment
ret += "<br><b>" + rh.gs(R.string.duration) + "</b>: " + duration + " min"
ret += "<br><b>" + rh.gs(R.string.absolute) + "</b>: " + DecimalFormatter.to2Decimal(absolute) + " U/h"
}
}
} else {
if (comment.isNotEmpty()) ret += "<br><b>" + rh.gs(R.string.comment) + "</b>: " + comment
}
return ret
}
override fun json(baseBasal: Double): JSONObject {
val result = JSONObject()
when {
bolusDelivered > 0 -> {
result.put("smb", bolusDelivered)
}
isTempCancel -> {
result.put("rate", 0)
result.put("duration", 0)
}
isPercent -> {
// Nightscout is expecting absolute value
val abs = Round.roundTo(baseBasal * percent / 100, 0.01)
result.put("rate", abs)
result.put("duration", duration)
}
else -> {
result.put("rate", absolute)
result.put("duration", duration)
}
}
return result
}
}

View file

@ -2,16 +2,16 @@ package info.nightscout.androidaps.di
import dagger.Module import dagger.Module
import dagger.android.ContributesAndroidInjector import dagger.android.ContributesAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.plugins.aps.loop.APSResultObject import info.nightscout.androidaps.plugins.aps.loop.APSResultObject
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensDataObject import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensDataObject
import info.nightscout.core.profile.ProfileStoreObject import info.nightscout.core.profile.ProfileStoreObject
import info.nightscout.interfaces.pump.PumpEnactResult
@Module @Module
@Suppress("unused") @Suppress("unused")
abstract class CoreDataClassesModule { abstract class CoreDataClassesModule {
@ContributesAndroidInjector abstract fun pumpEnactResultInjector(): PumpEnactResultObject @ContributesAndroidInjector abstract fun pumpEnactResultInjector(): PumpEnactResult
@ContributesAndroidInjector abstract fun apsResultInjector(): APSResultObject @ContributesAndroidInjector abstract fun apsResultInjector(): APSResultObject
@ContributesAndroidInjector abstract fun autosensDataInjector(): AutosensDataObject @ContributesAndroidInjector abstract fun autosensDataInjector(): AutosensDataObject

View file

@ -1,7 +1,6 @@
package info.nightscout.androidaps package info.nightscout.androidaps
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.pump.DetailedBolusInfo import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.pump.Pump import info.nightscout.interfaces.pump.Pump
@ -44,30 +43,30 @@ class TestPumpPlugin(val injector: HasAndroidInjector) : Pump {
override fun waitForDisconnectionInSeconds(): Int = 0 override fun waitForDisconnectionInSeconds(): Int = 0
override fun getPumpStatus(reason: String) {} override fun getPumpStatus(reason: String) {}
override fun setNewBasalProfile(profile: Profile): PumpEnactResult = PumpEnactResultObject(injector) override fun setNewBasalProfile(profile: Profile): PumpEnactResult = PumpEnactResult(injector)
override fun isThisProfileSet(profile: Profile): Boolean = isProfileSet override fun isThisProfileSet(profile: Profile): Boolean = isProfileSet
override fun lastDataTime(): Long = lastData override fun lastDataTime(): Long = lastData
override val baseBasalRate: Double = baseBasal override val baseBasalRate: Double = baseBasal
override val reservoirLevel: Double = 0.0 override val reservoirLevel: Double = 0.0
override val batteryLevel: Int = 0 override val batteryLevel: Int = 0
override fun deliverTreatment(detailedBolusInfo: DetailedBolusInfo): PumpEnactResult = PumpEnactResultObject(injector).success(true) override fun deliverTreatment(detailedBolusInfo: DetailedBolusInfo): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun stopBolusDelivering() {} override fun stopBolusDelivering() {}
override fun setTempBasalAbsolute(absoluteRate: Double, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult = override fun setTempBasalAbsolute(absoluteRate: Double, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult =
PumpEnactResultObject(injector).success(true) PumpEnactResult(injector).success(true)
override fun setTempBasalPercent(percent: Int, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult = override fun setTempBasalPercent(percent: Int, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult =
PumpEnactResultObject(injector).success(true) PumpEnactResult(injector).success(true)
override fun setExtendedBolus(insulin: Double, durationInMinutes: Int): PumpEnactResult = PumpEnactResultObject(injector).success(true) override fun setExtendedBolus(insulin: Double, durationInMinutes: Int): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult = PumpEnactResultObject(injector).success(true) override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun cancelExtendedBolus(): PumpEnactResult = PumpEnactResultObject(injector).success(true) override fun cancelExtendedBolus(): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun getJSONStatus(profile: Profile, profileName: String, version: String): JSONObject = JSONObject() override fun getJSONStatus(profile: Profile, profileName: String, version: String): JSONObject = JSONObject()
override fun manufacturer(): ManufacturerType = ManufacturerType.AAPS override fun manufacturer(): ManufacturerType = ManufacturerType.AAPS
override fun model(): PumpType = PumpType.GENERIC_AAPS override fun model(): PumpType = PumpType.GENERIC_AAPS
override fun serialNumber(): String = "1" override fun serialNumber(): String = "1"
override fun shortStatus(veryShort: Boolean): String = "" override fun shortStatus(veryShort: Boolean): String = ""
override val isFakingTempsByExtendedBoluses: Boolean = false override val isFakingTempsByExtendedBoluses: Boolean = false
override fun loadTDDs(): PumpEnactResult = PumpEnactResultObject(injector).success(true) override fun loadTDDs(): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun canHandleDST(): Boolean = true override fun canHandleDST(): Boolean = true
override fun timezoneOrDSTChanged(timeChangeType: TimeChangeType) {} override fun timezoneOrDSTChanged(timeChangeType: TimeChangeType) {}
} }

View file

@ -37,84 +37,84 @@ class PumpEnactResultTest : TestBaseWithProfile() {
} }
@Test fun successTest() { @Test fun successTest() {
val per = PumpEnactResultObject(injector) val per = PumpEnactResult(injector)
per.success(true) per.success(true)
Assert.assertEquals(true, per.success) Assert.assertEquals(true, per.success)
} }
@Test fun enactedTest() { @Test fun enactedTest() {
val per = PumpEnactResultObject(injector) val per = PumpEnactResult(injector)
per.enacted(true) per.enacted(true)
Assert.assertEquals(true, per.enacted) Assert.assertEquals(true, per.enacted)
} }
@Test fun commentTest() { @Test fun commentTest() {
val per = PumpEnactResultObject(injector) val per = PumpEnactResult(injector)
per.comment("SomeComment") per.comment("SomeComment")
Assert.assertEquals("SomeComment", per.comment) Assert.assertEquals("SomeComment", per.comment)
} }
@Test fun durationTest() { @Test fun durationTest() {
val per = PumpEnactResultObject(injector) val per = PumpEnactResult(injector)
per.duration(10) per.duration(10)
Assert.assertEquals(10, per.duration.toLong()) Assert.assertEquals(10, per.duration.toLong())
} }
@Test fun absoluteTest() { @Test fun absoluteTest() {
val per = PumpEnactResultObject(injector) val per = PumpEnactResult(injector)
per.absolute(11.0) per.absolute(11.0)
Assert.assertEquals(11.0, per.absolute, 0.01) Assert.assertEquals(11.0, per.absolute, 0.01)
} }
@Test fun percentTest() { @Test fun percentTest() {
val per = PumpEnactResultObject(injector) val per = PumpEnactResult(injector)
per.percent(10) per.percent(10)
Assert.assertEquals(10, per.percent) Assert.assertEquals(10, per.percent)
} }
@Test fun isPercentTest() { @Test fun isPercentTest() {
val per = PumpEnactResultObject(injector) val per = PumpEnactResult(injector)
per.isPercent(true) per.isPercent(true)
Assert.assertEquals(true, per.isPercent) Assert.assertEquals(true, per.isPercent)
} }
@Test fun isTempCancelTest() { @Test fun isTempCancelTest() {
val per = PumpEnactResultObject(injector) val per = PumpEnactResult(injector)
per.isTempCancel(true) per.isTempCancel(true)
Assert.assertEquals(true, per.isTempCancel) Assert.assertEquals(true, per.isTempCancel)
} }
@Test fun bolusDeliveredTest() { @Test fun bolusDeliveredTest() {
val per = PumpEnactResultObject(injector) val per = PumpEnactResult(injector)
per.bolusDelivered(11.0) per.bolusDelivered(11.0)
Assert.assertEquals(11.0, per.bolusDelivered, 0.01) Assert.assertEquals(11.0, per.bolusDelivered, 0.01)
} }
@Test fun carbsDeliveredTest() { @Test fun carbsDeliveredTest() {
val per = PumpEnactResultObject(injector) val per = PumpEnactResult(injector)
per.carbsDelivered(11.0) per.carbsDelivered(11.0)
Assert.assertEquals(11.0, per.carbsDelivered, 0.01) Assert.assertEquals(11.0, per.carbsDelivered, 0.01)
} }
@Test fun queuedTest() { @Test fun queuedTest() {
val per = PumpEnactResultObject(injector) val per = PumpEnactResult(injector)
per.queued(true) per.queued(true)
Assert.assertEquals(true, per.queued) Assert.assertEquals(true, per.queued)
} }
@Test fun logTest() { @Test fun logTest() {
val per = PumpEnactResultObject(injector) val per = PumpEnactResult(injector)
Assert.assertEquals( Assert.assertEquals(
"Success: false Enacted: false Comment: Duration: -1 Absolute: -1.0 Percent: -1 IsPercent: false IsTempCancel: false bolusDelivered: 0.0 carbsDelivered: 0.0 Queued: false", "Success: false Enacted: false Comment: Duration: -1 Absolute: -1.0 Percent: -1 IsPercent: false IsTempCancel: false bolusDelivered: 0.0 carbsDelivered: 0.0 Queued: false",
@ -123,7 +123,7 @@ class PumpEnactResultTest : TestBaseWithProfile() {
} }
@Test fun toStringTest() { @Test fun toStringTest() {
var per = PumpEnactResultObject(injector).enacted(true).bolusDelivered(10.0).comment("AAA") var per = PumpEnactResult(injector).enacted(true).bolusDelivered(10.0).comment("AAA")
Assert.assertEquals( Assert.assertEquals(
""" """
Success: false Success: false
@ -132,7 +132,7 @@ class PumpEnactResultTest : TestBaseWithProfile() {
Insulin: 10.0 U Insulin: 10.0 U
""".trimIndent(), per.toString() """.trimIndent(), per.toString()
) )
per = PumpEnactResultObject(injector).enacted(true).isTempCancel(true).comment("AAA") per = PumpEnactResult(injector).enacted(true).isTempCancel(true).comment("AAA")
Assert.assertEquals( Assert.assertEquals(
""" """
Success: false Success: false
@ -141,7 +141,7 @@ class PumpEnactResultTest : TestBaseWithProfile() {
Cancel temp basal Cancel temp basal
""".trimIndent(), per.toString() """.trimIndent(), per.toString()
) )
per = PumpEnactResultObject(injector).enacted(true).isPercent(true).percent(90).duration(20).comment("AAA") per = PumpEnactResult(injector).enacted(true).isPercent(true).percent(90).duration(20).comment("AAA")
Assert.assertEquals( Assert.assertEquals(
""" """
Success: false Success: false
@ -151,7 +151,7 @@ class PumpEnactResultTest : TestBaseWithProfile() {
Percent: 90% Percent: 90%
""".trimIndent(), per.toString() """.trimIndent(), per.toString()
) )
per = PumpEnactResultObject(injector).enacted(true).isPercent(false).absolute(1.0).duration(30).comment("AAA") per = PumpEnactResult(injector).enacted(true).isPercent(false).absolute(1.0).duration(30).comment("AAA")
Assert.assertEquals( Assert.assertEquals(
""" """
Success: false Success: false
@ -161,7 +161,7 @@ class PumpEnactResultTest : TestBaseWithProfile() {
Absolute: 1.0 U/h Absolute: 1.0 U/h
""".trimIndent(), per.toString() """.trimIndent(), per.toString()
) )
per = PumpEnactResultObject(injector).enacted(false).comment("AAA") per = PumpEnactResult(injector).enacted(false).comment("AAA")
Assert.assertEquals( Assert.assertEquals(
""" """
Success: false Success: false
@ -172,31 +172,31 @@ class PumpEnactResultTest : TestBaseWithProfile() {
@Test fun toHtmlTest() { @Test fun toHtmlTest() {
var per: PumpEnactResult = PumpEnactResultObject(injector).enacted(true).bolusDelivered(10.0).comment("AAA") var per: PumpEnactResult = PumpEnactResult(injector).enacted(true).bolusDelivered(10.0).comment("AAA")
Assert.assertEquals("<b>Success</b>: false<br><b>Enacted</b>: true<br><b>Comment</b>: AAA<br><b>SMB</b>: 10.0 U", per.toHtml()) Assert.assertEquals("<b>Success</b>: false<br><b>Enacted</b>: true<br><b>Comment</b>: AAA<br><b>SMB</b>: 10.0 U", per.toHtml())
per = PumpEnactResultObject(injector).enacted(true).isTempCancel(true).comment("AAA") per = PumpEnactResult(injector).enacted(true).isTempCancel(true).comment("AAA")
Assert.assertEquals("<b>Success</b>: false<br><b>Enacted</b>: true<br><b>Comment</b>: AAA<br>Cancel temp basal", per.toHtml()) Assert.assertEquals("<b>Success</b>: false<br><b>Enacted</b>: true<br><b>Comment</b>: AAA<br>Cancel temp basal", per.toHtml())
per = PumpEnactResultObject(injector).enacted(true).isPercent(true).percent(90).duration(20).comment("AAA") per = PumpEnactResult(injector).enacted(true).isPercent(true).percent(90).duration(20).comment("AAA")
Assert.assertEquals("<b>Success</b>: false<br><b>Enacted</b>: true<br><b>Comment</b>: AAA<br><b>Duration</b>: 20 min<br><b>Percent</b>: 90%", per.toHtml()) Assert.assertEquals("<b>Success</b>: false<br><b>Enacted</b>: true<br><b>Comment</b>: AAA<br><b>Duration</b>: 20 min<br><b>Percent</b>: 90%", per.toHtml())
per = PumpEnactResultObject(injector).enacted(true).isPercent(false).absolute(1.0).duration(30).comment("AAA") per = PumpEnactResult(injector).enacted(true).isPercent(false).absolute(1.0).duration(30).comment("AAA")
Assert.assertEquals("<b>Success</b>: false<br><b>Enacted</b>: true<br><b>Comment</b>: AAA<br><b>Duration</b>: 30 min<br><b>Absolute</b>: 1.00 U/h", per.toHtml()) Assert.assertEquals("<b>Success</b>: false<br><b>Enacted</b>: true<br><b>Comment</b>: AAA<br><b>Duration</b>: 30 min<br><b>Absolute</b>: 1.00 U/h", per.toHtml())
per = PumpEnactResultObject(injector).enacted(false).comment("AAA") per = PumpEnactResult(injector).enacted(false).comment("AAA")
Assert.assertEquals("<b>Success</b>: false<br><b>Comment</b>: AAA", per.toHtml()) Assert.assertEquals("<b>Success</b>: false<br><b>Comment</b>: AAA", per.toHtml())
} }
@Test fun jsonTest() { @Test fun jsonTest() {
var o: JSONObject? var o: JSONObject?
var per: PumpEnactResult = PumpEnactResultObject(injector).enacted(true).bolusDelivered(10.0).comment("AAA") var per: PumpEnactResult = PumpEnactResult(injector).enacted(true).bolusDelivered(10.0).comment("AAA")
o = per.json(validProfile.getBasal()) o = per.json(validProfile.getBasal())
JSONAssert.assertEquals("{\"smb\":10}", o, false) JSONAssert.assertEquals("{\"smb\":10}", o, false)
per = PumpEnactResultObject(injector).enacted(true).isTempCancel(true).comment("AAA") per = PumpEnactResult(injector).enacted(true).isTempCancel(true).comment("AAA")
o = per.json(validProfile.getBasal()) o = per.json(validProfile.getBasal())
JSONAssert.assertEquals("{\"rate\":0,\"duration\":0}", o, false) JSONAssert.assertEquals("{\"rate\":0,\"duration\":0}", o, false)
per = PumpEnactResultObject(injector).enacted(true).isPercent(true).percent(90).duration(20).comment("AAA") per = PumpEnactResult(injector).enacted(true).isPercent(true).percent(90).duration(20).comment("AAA")
o = per.json(validProfile.getBasal()) o = per.json(validProfile.getBasal())
JSONAssert.assertEquals("{\"rate\":0.9,\"duration\":20}", o, false) JSONAssert.assertEquals("{\"rate\":0.9,\"duration\":20}", o, false)
per = PumpEnactResultObject(injector).enacted(true).isPercent(false).absolute(1.0).duration(30).comment("AAA") per = PumpEnactResult(injector).enacted(true).isPercent(false).absolute(1.0).duration(30).comment("AAA")
o = per.json(validProfile.getBasal()) o = per.json(validProfile.getBasal())
JSONAssert.assertEquals("{\"rate\":1,\"duration\":30}", o, false) JSONAssert.assertEquals("{\"rate\":1,\"duration\":30}", o, false)
} }

View file

@ -8,7 +8,6 @@ import androidx.appcompat.app.AppCompatActivity
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.annotations.OpenForTesting import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.androidaps.data.ProfileSealed import info.nightscout.androidaps.data.ProfileSealed
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.dialogs.BolusProgressDialog import info.nightscout.androidaps.dialogs.BolusProgressDialog
import info.nightscout.androidaps.extensions.getCustomizedName import info.nightscout.androidaps.extensions.getCustomizedName
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissBolusProgressIfRunning import info.nightscout.androidaps.plugins.general.overview.events.EventDismissBolusProgressIfRunning
@ -147,7 +146,7 @@ class CommandQueueImplementation @Inject constructor(
} }
private fun executingNowError(): PumpEnactResult = private fun executingNowError(): PumpEnactResult =
PumpEnactResultObject(injector).success(false).enacted(false).comment(R.string.executing_right_now) PumpEnactResult(injector).success(false).enacted(false).comment(R.string.executing_right_now)
override fun isRunning(type: CommandType): Boolean = performing?.commandType == type override fun isRunning(type: CommandType): Boolean = performing?.commandType == type
@ -271,12 +270,12 @@ class CommandQueueImplementation @Inject constructor(
.subscribeBy( .subscribeBy(
onSuccess = { result -> onSuccess = { result ->
result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted carbs $it") } result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted carbs $it") }
callback?.result(PumpEnactResultObject(injector).enacted(false).success(true))?.run() callback?.result(PumpEnactResult(injector).enacted(false).success(true))?.run()
}, },
onError = { onError = {
aapsLogger.error(LTag.DATABASE, "Error while saving carbs", it) aapsLogger.error(LTag.DATABASE, "Error while saving carbs", it)
callback?.result(PumpEnactResultObject(injector).enacted(false).success(false))?.run() callback?.result(PumpEnactResult(injector).enacted(false).success(false))?.run()
} }
) )
} }
@ -293,13 +292,13 @@ class CommandQueueImplementation @Inject constructor(
if (type == CommandType.SMB_BOLUS) { if (type == CommandType.SMB_BOLUS) {
if (bolusInQueue()) { if (bolusInQueue()) {
aapsLogger.debug(LTag.PUMPQUEUE, "Rejecting SMB since a bolus is queue/running") aapsLogger.debug(LTag.PUMPQUEUE, "Rejecting SMB since a bolus is queue/running")
callback?.result(PumpEnactResultObject(injector).enacted(false).success(false))?.run() callback?.result(PumpEnactResult(injector).enacted(false).success(false))?.run()
return false return false
} }
val lastBolusTime = repository.getLastBolusRecord()?.timestamp ?: 0L val lastBolusTime = repository.getLastBolusRecord()?.timestamp ?: 0L
if (detailedBolusInfo.lastKnownBolusTime < lastBolusTime) { if (detailedBolusInfo.lastKnownBolusTime < lastBolusTime) {
aapsLogger.debug(LTag.PUMPQUEUE, "Rejecting bolus, another bolus was issued since request time") aapsLogger.debug(LTag.PUMPQUEUE, "Rejecting bolus, another bolus was issued since request time")
callback?.result(PumpEnactResultObject(injector).enacted(false).success(false))?.run() callback?.result(PumpEnactResult(injector).enacted(false).success(false))?.run()
return false return false
} }
removeAll(CommandType.SMB_BOLUS) removeAll(CommandType.SMB_BOLUS)
@ -352,7 +351,7 @@ class CommandQueueImplementation @Inject constructor(
@Synchronized @Synchronized
override fun cancelAllBoluses(id: Long?) { override fun cancelAllBoluses(id: Long?) {
if (!isRunning(CommandType.BOLUS)) { if (!isRunning(CommandType.BOLUS)) {
rxBus.send(EventDismissBolusProgressIfRunning(PumpEnactResultObject(injector).success(true).enacted(false), id)) rxBus.send(EventDismissBolusProgressIfRunning(PumpEnactResult(injector).success(true).enacted(false), id))
} }
removeAll(CommandType.BOLUS) removeAll(CommandType.BOLUS)
removeAll(CommandType.SMB_BOLUS) removeAll(CommandType.SMB_BOLUS)
@ -436,12 +435,12 @@ class CommandQueueImplementation @Inject constructor(
override fun setProfile(profile: Profile, hasNsId: Boolean, callback: Callback?): Boolean { override fun setProfile(profile: Profile, hasNsId: Boolean, callback: Callback?): Boolean {
if (isRunning(CommandType.BASAL_PROFILE)) { if (isRunning(CommandType.BASAL_PROFILE)) {
aapsLogger.debug(LTag.PUMPQUEUE, "Command is already executed") aapsLogger.debug(LTag.PUMPQUEUE, "Command is already executed")
callback?.result(PumpEnactResultObject(injector).success(true).enacted(false))?.run() callback?.result(PumpEnactResult(injector).success(true).enacted(false))?.run()
return false return false
} }
if (isThisProfileSet(profile) && repository.getEffectiveProfileSwitchActiveAt(dateUtil.now()).blockingGet() is ValueWrapper.Existing) { if (isThisProfileSet(profile) && repository.getEffectiveProfileSwitchActiveAt(dateUtil.now()).blockingGet() is ValueWrapper.Existing) {
aapsLogger.debug(LTag.PUMPQUEUE, "Correct profile already set") aapsLogger.debug(LTag.PUMPQUEUE, "Correct profile already set")
callback?.result(PumpEnactResultObject(injector).success(true).enacted(false))?.run() callback?.result(PumpEnactResult(injector).success(true).enacted(false))?.run()
return false return false
} }
// Compare with pump limits // Compare with pump limits
@ -450,7 +449,7 @@ class CommandQueueImplementation @Inject constructor(
if (basalValue.value < activePlugin.activePump.pumpDescription.basalMinimumRate) { if (basalValue.value < activePlugin.activePump.pumpDescription.basalMinimumRate) {
val notification = Notification(Notification.BASAL_VALUE_BELOW_MINIMUM, rh.gs(R.string.basal_value_below_minimum), Notification.URGENT) val notification = Notification(Notification.BASAL_VALUE_BELOW_MINIMUM, rh.gs(R.string.basal_value_below_minimum), Notification.URGENT)
rxBus.send(EventNewNotification(notification)) rxBus.send(EventNewNotification(notification))
callback?.result(PumpEnactResultObject(injector).success(false).enacted(false).comment(R.string.basal_value_below_minimum))?.run() callback?.result(PumpEnactResult(injector).success(false).enacted(false).comment(R.string.basal_value_below_minimum))?.run()
return false return false
} }
} }

View file

@ -1,12 +1,12 @@
package info.nightscout.implementation.queue.commands package info.nightscout.implementation.queue.commands
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.dialogs.BolusProgressDialog import info.nightscout.androidaps.dialogs.BolusProgressDialog
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissBolusProgressIfRunning import info.nightscout.androidaps.plugins.general.overview.events.EventDismissBolusProgressIfRunning
import info.nightscout.implementation.R import info.nightscout.implementation.R
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.pump.DetailedBolusInfo import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.Command import info.nightscout.interfaces.queue.Command
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
@ -45,6 +45,6 @@ class CommandBolus(
override fun cancel() { override fun cancel() {
aapsLogger.debug(LTag.PUMPQUEUE, "Result cancel") aapsLogger.debug(LTag.PUMPQUEUE, "Result cancel")
callback?.result(PumpEnactResultObject(injector).success(false).comment(info.nightscout.core.main.R.string.connectiontimedout))?.run() callback?.result(PumpEnactResult(injector).success(false).comment(info.nightscout.core.main.R.string.connectiontimedout))?.run()
} }
} }

View file

@ -1,9 +1,9 @@
package info.nightscout.implementation.queue.commands package info.nightscout.implementation.queue.commands
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.implementation.R import info.nightscout.implementation.R
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.Command import info.nightscout.interfaces.queue.Command
import info.nightscout.rx.logging.LTag import info.nightscout.rx.logging.LTag
@ -27,6 +27,6 @@ class CommandCancelExtendedBolus constructor(
override fun log(): String = "CANCEL EXTENDEDBOLUS" override fun log(): String = "CANCEL EXTENDEDBOLUS"
override fun cancel() { override fun cancel() {
aapsLogger.debug(LTag.PUMPQUEUE, "Result cancel") aapsLogger.debug(LTag.PUMPQUEUE, "Result cancel")
callback?.result(PumpEnactResultObject(injector).success(false).comment(info.nightscout.core.main.R.string.connectiontimedout))?.run() callback?.result(PumpEnactResult(injector).success(false).comment(info.nightscout.core.main.R.string.connectiontimedout))?.run()
} }
} }

View file

@ -1,9 +1,9 @@
package info.nightscout.implementation.queue.commands package info.nightscout.implementation.queue.commands
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.implementation.R import info.nightscout.implementation.R
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.Command import info.nightscout.interfaces.queue.Command
import info.nightscout.rx.logging.LTag import info.nightscout.rx.logging.LTag
@ -28,6 +28,6 @@ class CommandCancelTempBasal(
override fun log(): String = "CANCEL TEMPBASAL" override fun log(): String = "CANCEL TEMPBASAL"
override fun cancel() { override fun cancel() {
aapsLogger.debug(LTag.PUMPQUEUE, "Result cancel") aapsLogger.debug(LTag.PUMPQUEUE, "Result cancel")
callback?.result(PumpEnactResultObject(injector).success(false).comment(info.nightscout.core.main.R.string.connectiontimedout))?.run() callback?.result(PumpEnactResult(injector).success(false).comment(info.nightscout.core.main.R.string.connectiontimedout))?.run()
} }
} }

View file

@ -1,8 +1,8 @@
package info.nightscout.implementation.queue.commands package info.nightscout.implementation.queue.commands
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.Command import info.nightscout.interfaces.queue.Command
import info.nightscout.interfaces.queue.CustomCommand import info.nightscout.interfaces.queue.CustomCommand
@ -29,6 +29,6 @@ class CommandCustomCommand(
override fun log(): String = customCommand.statusDescription override fun log(): String = customCommand.statusDescription
override fun cancel() { override fun cancel() {
aapsLogger.debug(LTag.PUMPQUEUE, "Result cancel") aapsLogger.debug(LTag.PUMPQUEUE, "Result cancel")
callback?.result(PumpEnactResultObject(injector).success(false).comment(info.nightscout.core.main.R.string.connectiontimedout))?.run() callback?.result(PumpEnactResult(injector).success(false).comment(info.nightscout.core.main.R.string.connectiontimedout))?.run()
} }
} }

View file

@ -1,9 +1,9 @@
package info.nightscout.implementation.queue.commands package info.nightscout.implementation.queue.commands
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.implementation.R import info.nightscout.implementation.R
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.Command import info.nightscout.interfaces.queue.Command
import info.nightscout.rx.logging.LTag import info.nightscout.rx.logging.LTag
@ -29,6 +29,6 @@ class CommandExtendedBolus constructor(
override fun log(): String = "EXTENDEDBOLUS $insulin U $durationInMinutes min" override fun log(): String = "EXTENDEDBOLUS $insulin U $durationInMinutes min"
override fun cancel() { override fun cancel() {
aapsLogger.debug(LTag.PUMPQUEUE, "Result cancel") aapsLogger.debug(LTag.PUMPQUEUE, "Result cancel")
callback?.result(PumpEnactResultObject(injector).success(false).comment(info.nightscout.core.main.R.string.connectiontimedout))?.run() callback?.result(PumpEnactResult(injector).success(false).comment(info.nightscout.core.main.R.string.connectiontimedout))?.run()
} }
} }

View file

@ -1,10 +1,10 @@
package info.nightscout.implementation.queue.commands package info.nightscout.implementation.queue.commands
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.implementation.R import info.nightscout.implementation.R
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.pump.Insight import info.nightscout.interfaces.pump.Insight
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.Command import info.nightscout.interfaces.queue.Command
import info.nightscout.rx.logging.LTag import info.nightscout.rx.logging.LTag
@ -32,6 +32,6 @@ class CommandInsightSetTBROverNotification constructor(
override fun log(): String = "INSIGHTSETTBROVERNOTIFICATION" override fun log(): String = "INSIGHTSETTBROVERNOTIFICATION"
override fun cancel() { override fun cancel() {
aapsLogger.debug(LTag.PUMPQUEUE, "Result cancel") aapsLogger.debug(LTag.PUMPQUEUE, "Result cancel")
callback?.result(PumpEnactResultObject(injector).success(false).comment(info.nightscout.core.main.R.string.connectiontimedout))?.run() callback?.result(PumpEnactResult(injector).success(false).comment(info.nightscout.core.main.R.string.connectiontimedout))?.run()
} }
} }

View file

@ -1,11 +1,11 @@
package info.nightscout.implementation.queue.commands package info.nightscout.implementation.queue.commands
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.implementation.R import info.nightscout.implementation.R
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.pump.Dana import info.nightscout.interfaces.pump.Dana
import info.nightscout.interfaces.pump.Diaconn import info.nightscout.interfaces.pump.Diaconn
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.Command import info.nightscout.interfaces.queue.Command
import info.nightscout.rx.logging.LTag import info.nightscout.rx.logging.LTag
@ -40,6 +40,6 @@ class CommandLoadEvents(
override fun log(): String = "LOAD EVENTS" override fun log(): String = "LOAD EVENTS"
override fun cancel() { override fun cancel() {
aapsLogger.debug(LTag.PUMPQUEUE, "Result cancel") aapsLogger.debug(LTag.PUMPQUEUE, "Result cancel")
callback?.result(PumpEnactResultObject(injector).success(false).comment(info.nightscout.core.main.R.string.connectiontimedout))?.run() callback?.result(PumpEnactResult(injector).success(false).comment(info.nightscout.core.main.R.string.connectiontimedout))?.run()
} }
} }

View file

@ -1,11 +1,11 @@
package info.nightscout.implementation.queue.commands package info.nightscout.implementation.queue.commands
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.implementation.R import info.nightscout.implementation.R
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.pump.Dana import info.nightscout.interfaces.pump.Dana
import info.nightscout.interfaces.pump.Diaconn import info.nightscout.interfaces.pump.Diaconn
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.Command import info.nightscout.interfaces.queue.Command
import info.nightscout.rx.logging.LTag import info.nightscout.rx.logging.LTag
@ -41,6 +41,6 @@ class CommandLoadHistory(
override fun log(): String = "LOAD HISTORY $type" override fun log(): String = "LOAD HISTORY $type"
override fun cancel() { override fun cancel() {
aapsLogger.debug(LTag.PUMPQUEUE, "Result cancel") aapsLogger.debug(LTag.PUMPQUEUE, "Result cancel")
callback?.result(PumpEnactResultObject(injector).success(false).comment(info.nightscout.core.main.R.string.connectiontimedout))?.run() callback?.result(PumpEnactResult(injector).success(false).comment(info.nightscout.core.main.R.string.connectiontimedout))?.run()
} }
} }

View file

@ -1,9 +1,9 @@
package info.nightscout.implementation.queue.commands package info.nightscout.implementation.queue.commands
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.implementation.R import info.nightscout.implementation.R
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.Command import info.nightscout.interfaces.queue.Command
import info.nightscout.rx.logging.LTag import info.nightscout.rx.logging.LTag
@ -28,6 +28,6 @@ class CommandLoadTDDs(
override fun log(): String = "LOAD TDDs" override fun log(): String = "LOAD TDDs"
override fun cancel() { override fun cancel() {
aapsLogger.debug(LTag.PUMPQUEUE, "Result cancel") aapsLogger.debug(LTag.PUMPQUEUE, "Result cancel")
callback?.result(PumpEnactResultObject(injector).success(false).comment(info.nightscout.core.main.R.string.connectiontimedout))?.run() callback?.result(PumpEnactResult(injector).success(false).comment(info.nightscout.core.main.R.string.connectiontimedout))?.run()
} }
} }

View file

@ -1,10 +1,10 @@
package info.nightscout.implementation.queue.commands package info.nightscout.implementation.queue.commands
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.implementation.R import info.nightscout.implementation.R
import info.nightscout.interfaces.LocalAlertUtils import info.nightscout.interfaces.LocalAlertUtils
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.Command import info.nightscout.interfaces.queue.Command
import info.nightscout.rx.logging.LTag import info.nightscout.rx.logging.LTag
@ -25,7 +25,7 @@ class CommandReadStatus(
localAlertUtils.notifyPumpStatusRead() localAlertUtils.notifyPumpStatusRead()
aapsLogger.debug(LTag.PUMPQUEUE, "CommandReadStatus executed. Reason: $reason") aapsLogger.debug(LTag.PUMPQUEUE, "CommandReadStatus executed. Reason: $reason")
val pump = activePlugin.activePump val pump = activePlugin.activePump
val result = PumpEnactResultObject(injector).success(false) val result = PumpEnactResult(injector).success(false)
val lastConnection = pump.lastDataTime() val lastConnection = pump.lastDataTime()
if (lastConnection > System.currentTimeMillis() - T.mins(1).msecs()) result.success(true) if (lastConnection > System.currentTimeMillis() - T.mins(1).msecs()) result.success(true)
callback?.result(result)?.run() callback?.result(result)?.run()
@ -36,6 +36,6 @@ class CommandReadStatus(
override fun log(): String = "READSTATUS $reason" override fun log(): String = "READSTATUS $reason"
override fun cancel() { override fun cancel() {
aapsLogger.debug(LTag.PUMPQUEUE, "Result cancel") aapsLogger.debug(LTag.PUMPQUEUE, "Result cancel")
callback?.result(PumpEnactResultObject(injector).success(false).comment(info.nightscout.core.main.R.string.connectiontimedout))?.run() callback?.result(PumpEnactResult(injector).success(false).comment(info.nightscout.core.main.R.string.connectiontimedout))?.run()
} }
} }

View file

@ -1,7 +1,6 @@
package info.nightscout.implementation.queue.commands package info.nightscout.implementation.queue.commands
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.database.impl.AppRepository import info.nightscout.database.impl.AppRepository
import info.nightscout.implementation.R import info.nightscout.implementation.R
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
@ -30,11 +29,11 @@ class CommandSMBBolus(
aapsLogger.debug(LTag.PUMPQUEUE, "Last bolus: $lastBolusTime ${dateUtil.dateAndTimeAndSecondsString(lastBolusTime)}") aapsLogger.debug(LTag.PUMPQUEUE, "Last bolus: $lastBolusTime ${dateUtil.dateAndTimeAndSecondsString(lastBolusTime)}")
if (lastBolusTime != 0L && lastBolusTime + T.mins(3).msecs() > dateUtil.now()) { if (lastBolusTime != 0L && lastBolusTime + T.mins(3).msecs() > dateUtil.now()) {
aapsLogger.debug(LTag.PUMPQUEUE, "SMB requested but still in 3 min interval") aapsLogger.debug(LTag.PUMPQUEUE, "SMB requested but still in 3 min interval")
r = PumpEnactResultObject(injector).enacted(false).success(false).comment("SMB requested but still in 3 min interval") r = PumpEnactResult(injector).enacted(false).success(false).comment("SMB requested but still in 3 min interval")
} else if (detailedBolusInfo.deliverAtTheLatest != 0L && detailedBolusInfo.deliverAtTheLatest + T.mins(1).msecs() > System.currentTimeMillis()) { } else if (detailedBolusInfo.deliverAtTheLatest != 0L && detailedBolusInfo.deliverAtTheLatest + T.mins(1).msecs() > System.currentTimeMillis()) {
r = activePlugin.activePump.deliverTreatment(detailedBolusInfo) r = activePlugin.activePump.deliverTreatment(detailedBolusInfo)
} else { } else {
r = PumpEnactResultObject(injector).enacted(false).success(false).comment("SMB request too old") r = PumpEnactResult(injector).enacted(false).success(false).comment("SMB request too old")
aapsLogger.debug(LTag.PUMPQUEUE, "SMB bolus canceled. deliverAt: " + dateUtil.dateAndTimeString(detailedBolusInfo.deliverAtTheLatest)) aapsLogger.debug(LTag.PUMPQUEUE, "SMB bolus canceled. deliverAt: " + dateUtil.dateAndTimeString(detailedBolusInfo.deliverAtTheLatest))
} }
aapsLogger.debug(LTag.PUMPQUEUE, "Result success: ${r.success} enacted: ${r.enacted}") aapsLogger.debug(LTag.PUMPQUEUE, "Result success: ${r.success} enacted: ${r.enacted}")
@ -46,6 +45,6 @@ class CommandSMBBolus(
override fun log(): String = "SMB BOLUS ${rh.gs(R.string.formatinsulinunits, detailedBolusInfo.insulin)}" override fun log(): String = "SMB BOLUS ${rh.gs(R.string.formatinsulinunits, detailedBolusInfo.insulin)}"
override fun cancel() { override fun cancel() {
aapsLogger.debug(LTag.PUMPQUEUE, "Result cancel") aapsLogger.debug(LTag.PUMPQUEUE, "Result cancel")
callback?.result(PumpEnactResultObject(injector).success(false).comment(info.nightscout.core.main.R.string.connectiontimedout))?.run() callback?.result(PumpEnactResult(injector).success(false).comment(info.nightscout.core.main.R.string.connectiontimedout))?.run()
} }
} }

View file

@ -1,7 +1,6 @@
package info.nightscout.implementation.queue.commands package info.nightscout.implementation.queue.commands
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.database.impl.AppRepository import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.ValueWrapper import info.nightscout.database.impl.ValueWrapper
import info.nightscout.implementation.R import info.nightscout.implementation.R
@ -9,6 +8,7 @@ import info.nightscout.interfaces.Config
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.Command import info.nightscout.interfaces.queue.Command
import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.interfaces.queue.CommandQueue
@ -34,7 +34,7 @@ class CommandSetProfile constructor(
override fun execute() { override fun execute() {
if (commandQueue.isThisProfileSet(profile) && repository.getEffectiveProfileSwitchActiveAt(dateUtil.now()).blockingGet() is ValueWrapper.Existing) { if (commandQueue.isThisProfileSet(profile) && repository.getEffectiveProfileSwitchActiveAt(dateUtil.now()).blockingGet() is ValueWrapper.Existing) {
aapsLogger.debug(LTag.PUMPQUEUE, "Correct profile already set. profile: $profile") aapsLogger.debug(LTag.PUMPQUEUE, "Correct profile already set. profile: $profile")
callback?.result(PumpEnactResultObject(injector).success(true).enacted(false))?.run() callback?.result(PumpEnactResult(injector).success(true).enacted(false))?.run()
return return
} }
val r = activePlugin.activePump.setNewBasalProfile(profile) val r = activePlugin.activePump.setNewBasalProfile(profile)
@ -53,6 +53,6 @@ class CommandSetProfile constructor(
override fun log(): String = "SET PROFILE" override fun log(): String = "SET PROFILE"
override fun cancel() { override fun cancel() {
aapsLogger.debug(LTag.PUMPQUEUE, "Result cancel") aapsLogger.debug(LTag.PUMPQUEUE, "Result cancel")
callback?.result(PumpEnactResultObject(injector).success(false).comment(info.nightscout.core.main.R.string.connectiontimedout))?.run() callback?.result(PumpEnactResult(injector).success(false).comment(info.nightscout.core.main.R.string.connectiontimedout))?.run()
} }
} }

View file

@ -1,11 +1,11 @@
package info.nightscout.implementation.queue.commands package info.nightscout.implementation.queue.commands
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.implementation.R import info.nightscout.implementation.R
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.pump.Dana import info.nightscout.interfaces.pump.Dana
import info.nightscout.interfaces.pump.Diaconn import info.nightscout.interfaces.pump.Diaconn
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.Command import info.nightscout.interfaces.queue.Command
import info.nightscout.rx.logging.LTag import info.nightscout.rx.logging.LTag
@ -38,6 +38,6 @@ class CommandSetUserSettings(
override fun log(): String = "SET USER SETTINGS" override fun log(): String = "SET USER SETTINGS"
override fun cancel() { override fun cancel() {
aapsLogger.debug(LTag.PUMPQUEUE, "Result cancel") aapsLogger.debug(LTag.PUMPQUEUE, "Result cancel")
callback?.result(PumpEnactResultObject(injector).success(false).comment(info.nightscout.core.main.R.string.connectiontimedout))?.run() callback?.result(PumpEnactResult(injector).success(false).comment(info.nightscout.core.main.R.string.connectiontimedout))?.run()
} }
} }

View file

@ -1,10 +1,10 @@
package info.nightscout.implementation.queue.commands package info.nightscout.implementation.queue.commands
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.implementation.R import info.nightscout.implementation.R
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.pump.Insight import info.nightscout.interfaces.pump.Insight
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.Command import info.nightscout.interfaces.queue.Command
import info.nightscout.rx.logging.LTag import info.nightscout.rx.logging.LTag
@ -30,6 +30,6 @@ class CommandStartPump(
override fun log(): String = "START PUMP" override fun log(): String = "START PUMP"
override fun cancel() { override fun cancel() {
aapsLogger.debug(LTag.PUMPQUEUE, "Result cancel") aapsLogger.debug(LTag.PUMPQUEUE, "Result cancel")
callback?.result(PumpEnactResultObject(injector).success(false).comment(info.nightscout.core.main.R.string.connectiontimedout))?.run() callback?.result(PumpEnactResult(injector).success(false).comment(info.nightscout.core.main.R.string.connectiontimedout))?.run()
} }
} }

View file

@ -1,10 +1,10 @@
package info.nightscout.implementation.queue.commands package info.nightscout.implementation.queue.commands
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.implementation.R import info.nightscout.implementation.R
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.pump.Insight import info.nightscout.interfaces.pump.Insight
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.Command import info.nightscout.interfaces.queue.Command
import info.nightscout.rx.logging.LTag import info.nightscout.rx.logging.LTag
@ -30,6 +30,6 @@ class CommandStopPump(
override fun log(): String = "STOP PUMP" override fun log(): String = "STOP PUMP"
override fun cancel() { override fun cancel() {
aapsLogger.debug(LTag.PUMPQUEUE, "Result cancel") aapsLogger.debug(LTag.PUMPQUEUE, "Result cancel")
callback?.result(PumpEnactResultObject(injector).success(false).comment(info.nightscout.core.main.R.string.connectiontimedout))?.run() callback?.result(PumpEnactResult(injector).success(false).comment(info.nightscout.core.main.R.string.connectiontimedout))?.run()
} }
} }

View file

@ -1,10 +1,10 @@
package info.nightscout.implementation.queue.commands package info.nightscout.implementation.queue.commands
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.implementation.R import info.nightscout.implementation.R
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.pump.PumpSync import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.queue.Callback import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.Command import info.nightscout.interfaces.queue.Command
@ -34,6 +34,6 @@ class CommandTempBasalAbsolute(
override fun log(): String = "TEMP BASAL $absoluteRate U/h $durationInMinutes min" override fun log(): String = "TEMP BASAL $absoluteRate U/h $durationInMinutes min"
override fun cancel() { override fun cancel() {
aapsLogger.debug(LTag.PUMPQUEUE, "Result cancel") aapsLogger.debug(LTag.PUMPQUEUE, "Result cancel")
callback?.result(PumpEnactResultObject(injector).success(false).comment(info.nightscout.core.main.R.string.connectiontimedout))?.run() callback?.result(PumpEnactResult(injector).success(false).comment(info.nightscout.core.main.R.string.connectiontimedout))?.run()
} }
} }

View file

@ -1,10 +1,10 @@
package info.nightscout.implementation.queue.commands package info.nightscout.implementation.queue.commands
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.implementation.R import info.nightscout.implementation.R
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.pump.PumpSync import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.queue.Callback import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.Command import info.nightscout.interfaces.queue.Command
@ -38,6 +38,6 @@ class CommandTempBasalPercent(
override fun log(): String = "TEMP BASAL $percent% $durationInMinutes min" override fun log(): String = "TEMP BASAL $percent% $durationInMinutes min"
override fun cancel() { override fun cancel() {
aapsLogger.debug(LTag.PUMPQUEUE, "Result cancel") aapsLogger.debug(LTag.PUMPQUEUE, "Result cancel")
callback?.result(PumpEnactResultObject(injector).success(false).comment(info.nightscout.core.main.R.string.connectiontimedout))?.run() callback?.result(PumpEnactResult(injector).success(false).comment(info.nightscout.core.main.R.string.connectiontimedout))?.run()
} }
} }

View file

@ -1,7 +1,6 @@
package info.nightscout.androidaps package info.nightscout.androidaps
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.pump.DetailedBolusInfo import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.pump.Pump import info.nightscout.interfaces.pump.Pump
@ -44,30 +43,30 @@ class TestPumpPlugin(val injector: HasAndroidInjector) : Pump {
override fun waitForDisconnectionInSeconds(): Int = 0 override fun waitForDisconnectionInSeconds(): Int = 0
override fun getPumpStatus(reason: String) {} override fun getPumpStatus(reason: String) {}
override fun setNewBasalProfile(profile: Profile): PumpEnactResult = PumpEnactResultObject(injector) override fun setNewBasalProfile(profile: Profile): PumpEnactResult = PumpEnactResult(injector)
override fun isThisProfileSet(profile: Profile): Boolean = isProfileSet override fun isThisProfileSet(profile: Profile): Boolean = isProfileSet
override fun lastDataTime(): Long = lastData override fun lastDataTime(): Long = lastData
override val baseBasalRate: Double = baseBasal override val baseBasalRate: Double = baseBasal
override val reservoirLevel: Double = 0.0 override val reservoirLevel: Double = 0.0
override val batteryLevel: Int = 0 override val batteryLevel: Int = 0
override fun deliverTreatment(detailedBolusInfo: DetailedBolusInfo): PumpEnactResult = PumpEnactResultObject(injector).success(true) override fun deliverTreatment(detailedBolusInfo: DetailedBolusInfo): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun stopBolusDelivering() {} override fun stopBolusDelivering() {}
override fun setTempBasalAbsolute(absoluteRate: Double, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult = override fun setTempBasalAbsolute(absoluteRate: Double, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult =
PumpEnactResultObject(injector).success(true) PumpEnactResult(injector).success(true)
override fun setTempBasalPercent(percent: Int, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult = override fun setTempBasalPercent(percent: Int, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult =
PumpEnactResultObject(injector).success(true) PumpEnactResult(injector).success(true)
override fun setExtendedBolus(insulin: Double, durationInMinutes: Int): PumpEnactResult = PumpEnactResultObject(injector).success(true) override fun setExtendedBolus(insulin: Double, durationInMinutes: Int): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult = PumpEnactResultObject(injector).success(true) override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun cancelExtendedBolus(): PumpEnactResult = PumpEnactResultObject(injector).success(true) override fun cancelExtendedBolus(): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun getJSONStatus(profile: Profile, profileName: String, version: String): JSONObject = JSONObject() override fun getJSONStatus(profile: Profile, profileName: String, version: String): JSONObject = JSONObject()
override fun manufacturer(): ManufacturerType = ManufacturerType.AAPS override fun manufacturer(): ManufacturerType = ManufacturerType.AAPS
override fun model(): PumpType = PumpType.GENERIC_AAPS override fun model(): PumpType = PumpType.GENERIC_AAPS
override fun serialNumber(): String = "1" override fun serialNumber(): String = "1"
override fun shortStatus(veryShort: Boolean): String = "" override fun shortStatus(veryShort: Boolean): String = ""
override val isFakingTempsByExtendedBoluses: Boolean = false override val isFakingTempsByExtendedBoluses: Boolean = false
override fun loadTDDs(): PumpEnactResult = PumpEnactResultObject(injector).success(true) override fun loadTDDs(): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun canHandleDST(): Boolean = true override fun canHandleDST(): Boolean = true
override fun timezoneOrDSTChanged(timeChangeType: TimeChangeType) {} override fun timezoneOrDSTChanged(timeChangeType: TimeChangeType) {}
} }

View file

@ -6,7 +6,6 @@ import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.TestBaseWithProfile import info.nightscout.androidaps.TestBaseWithProfile
import info.nightscout.androidaps.TestPumpPlugin import info.nightscout.androidaps.TestPumpPlugin
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.core.fabric.FabricPrivacy import info.nightscout.core.fabric.FabricPrivacy
import info.nightscout.database.entities.Bolus import info.nightscout.database.entities.Bolus
import info.nightscout.database.impl.AppRepository import info.nightscout.database.impl.AppRepository

View file

@ -30,7 +30,6 @@ import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import dagger.android.HasAndroidInjector; import dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.data.PumpEnactResultObject;
import info.nightscout.androidaps.insight.R; import info.nightscout.androidaps.insight.R;
import info.nightscout.androidaps.insight.database.InsightBolusID; import info.nightscout.androidaps.insight.database.InsightBolusID;
import info.nightscout.androidaps.insight.database.InsightDbHelper; import info.nightscout.androidaps.insight.database.InsightDbHelper;
@ -475,7 +474,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Insight,
@NonNull @Override @NonNull @Override
public PumpEnactResult setNewBasalProfile(Profile profile) { public PumpEnactResult setNewBasalProfile(Profile profile) {
PumpEnactResult result = new PumpEnactResultObject(getInjector()); PumpEnactResult result = new PumpEnactResult(getInjector());
rxBus.send(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED)); rxBus.send(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED));
List<BasalProfileBlock> profileBlocks = new ArrayList<>(); List<BasalProfileBlock> profileBlocks = new ArrayList<>();
for (int i = 0; i < profile.getBasalValues().length; i++) { for (int i = 0; i < profile.getBasalValues().length; i++) {
@ -575,7 +574,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Insight,
if (detailedBolusInfo.insulin == 0 || detailedBolusInfo.carbs > 0) { if (detailedBolusInfo.insulin == 0 || detailedBolusInfo.carbs > 0) {
throw new IllegalArgumentException(detailedBolusInfo.toString(), new Exception()); throw new IllegalArgumentException(detailedBolusInfo.toString(), new Exception());
} }
PumpEnactResult result = new PumpEnactResultObject(getInjector()); PumpEnactResult result = new PumpEnactResult(getInjector());
double insulin = Math.round(detailedBolusInfo.insulin / 0.01) * 0.01; double insulin = Math.round(detailedBolusInfo.insulin / 0.01) * 0.01;
if (insulin > 0) { if (insulin > 0) {
try { try {
@ -691,7 +690,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Insight,
@NonNull @Override @NonNull @Override
public PumpEnactResult setTempBasalAbsolute(double absoluteRate, int durationInMinutes, @NonNull Profile profile, boolean enforceNew, @NonNull PumpSync.TemporaryBasalType tbrType) { public PumpEnactResult setTempBasalAbsolute(double absoluteRate, int durationInMinutes, @NonNull Profile profile, boolean enforceNew, @NonNull PumpSync.TemporaryBasalType tbrType) {
PumpEnactResult result = new PumpEnactResultObject(getInjector()); PumpEnactResult result = new PumpEnactResult(getInjector());
if (activeBasalRate == null) return result; if (activeBasalRate == null) return result;
if (activeBasalRate.getActiveBasalRate() == 0) return result; if (activeBasalRate.getActiveBasalRate() == 0) return result;
double percent = 100D / activeBasalRate.getActiveBasalRate() * absoluteRate; double percent = 100D / activeBasalRate.getActiveBasalRate() * absoluteRate;
@ -741,7 +740,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Insight,
@NonNull @Override @NonNull @Override
public PumpEnactResult setTempBasalPercent(int percent, int durationInMinutes, @NonNull Profile profile, boolean enforceNew, @NonNull PumpSync.TemporaryBasalType tbrType) { public PumpEnactResult setTempBasalPercent(int percent, int durationInMinutes, @NonNull Profile profile, boolean enforceNew, @NonNull PumpSync.TemporaryBasalType tbrType) {
PumpEnactResult result = new PumpEnactResultObject(getInjector()); PumpEnactResult result = new PumpEnactResult(getInjector());
percent = (int) Math.round(((double) percent) / 10d) * 10; percent = (int) Math.round(((double) percent) / 10d) * 10;
if (percent == 100) return cancelTempBasal(true); if (percent == 100) return cancelTempBasal(true);
else if (percent > 250) percent = 250; else if (percent > 250) percent = 250;
@ -797,7 +796,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Insight,
} }
public PumpEnactResult setExtendedBolusOnly(Double insulin, Integer durationInMinutes, boolean disableVibration) { public PumpEnactResult setExtendedBolusOnly(Double insulin, Integer durationInMinutes, boolean disableVibration) {
PumpEnactResult result = new PumpEnactResultObject(getInjector()); PumpEnactResult result = new PumpEnactResult(getInjector());
try { try {
DeliverBolusMessage bolusMessage = new DeliverBolusMessage(); DeliverBolusMessage bolusMessage = new DeliverBolusMessage();
bolusMessage.setBolusType(BolusType.EXTENDED); bolusMessage.setBolusType(BolusType.EXTENDED);
@ -829,7 +828,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Insight,
@NonNull @Override @NonNull @Override
public PumpEnactResult cancelTempBasal(boolean enforceNew) { public PumpEnactResult cancelTempBasal(boolean enforceNew) {
PumpEnactResult result = new PumpEnactResultObject(getInjector()); PumpEnactResult result = new PumpEnactResult(getInjector());
PumpEnactResult cancelEBResult = null; PumpEnactResult cancelEBResult = null;
if (isFakingTempsByExtendedBoluses()) cancelEBResult = cancelExtendedBolusOnly(); if (isFakingTempsByExtendedBoluses()) cancelEBResult = cancelExtendedBolusOnly();
PumpEnactResult cancelTBRResult = cancelTempBasalOnly(); PumpEnactResult cancelTBRResult = cancelTempBasalOnly();
@ -850,7 +849,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Insight,
} }
private PumpEnactResult cancelTempBasalOnly() { private PumpEnactResult cancelTempBasalOnly() {
PumpEnactResult result = new PumpEnactResultObject(getInjector()); PumpEnactResult result = new PumpEnactResult(getInjector());
try { try {
alertService.ignore(AlertType.WARNING_36); alertService.ignore(AlertType.WARNING_36);
connectionService.requestMessage(new CancelTBRMessage()).await(); connectionService.requestMessage(new CancelTBRMessage()).await();
@ -893,7 +892,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Insight,
} }
private PumpEnactResult cancelExtendedBolusOnly() { private PumpEnactResult cancelExtendedBolusOnly() {
PumpEnactResult result = new PumpEnactResultObject(getInjector()); PumpEnactResult result = new PumpEnactResult(getInjector());
try { try {
for (ActiveBolus activeBolus : activeBoluses) { for (ActiveBolus activeBolus : activeBoluses) {
if (activeBolus.getBolusType() == BolusType.EXTENDED || activeBolus.getBolusType() == BolusType.MULTIWAVE) { if (activeBolus.getBolusType() == BolusType.EXTENDED || activeBolus.getBolusType() == BolusType.MULTIWAVE) {
@ -1012,7 +1011,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Insight,
} }
public PumpEnactResult stopPump() { public PumpEnactResult stopPump() {
PumpEnactResult result = new PumpEnactResultObject(getInjector()); PumpEnactResult result = new PumpEnactResult(getInjector());
try { try {
SetOperatingModeMessage operatingModeMessage = new SetOperatingModeMessage(); SetOperatingModeMessage operatingModeMessage = new SetOperatingModeMessage();
operatingModeMessage.setOperatingMode(OperatingMode.STOPPED); operatingModeMessage.setOperatingMode(OperatingMode.STOPPED);
@ -1034,7 +1033,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Insight,
} }
public PumpEnactResult startPump() { public PumpEnactResult startPump() {
PumpEnactResult result = new PumpEnactResultObject(getInjector()); PumpEnactResult result = new PumpEnactResult(getInjector());
try { try {
SetOperatingModeMessage operatingModeMessage = new SetOperatingModeMessage(); SetOperatingModeMessage operatingModeMessage = new SetOperatingModeMessage();
operatingModeMessage.setOperatingMode(OperatingMode.STARTED); operatingModeMessage.setOperatingMode(OperatingMode.STARTED);
@ -1056,7 +1055,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Insight,
} }
public PumpEnactResult setTBROverNotification(boolean enabled) { public PumpEnactResult setTBROverNotification(boolean enabled) {
PumpEnactResult result = new PumpEnactResultObject(getInjector()); PumpEnactResult result = new PumpEnactResult(getInjector());
boolean valueBefore = tbrOverNotificationBlock.isEnabled(); boolean valueBefore = tbrOverNotificationBlock.isEnabled();
tbrOverNotificationBlock.setEnabled(enabled); tbrOverNotificationBlock.setEnabled(enabled);
try { try {
@ -1119,7 +1118,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Insight,
@NonNull @Override @NonNull @Override
public PumpEnactResult loadTDDs() { public PumpEnactResult loadTDDs() {
return new PumpEnactResultObject(getInjector()).success(true); return new PumpEnactResult(getInjector()).success(true);
} }
private void readHistory() { private void readHistory() {

View file

@ -1,40 +1,43 @@
package info.nightscout.interfaces.pump package info.nightscout.interfaces.pump
import org.json.JSONObject import android.content.Context
import dagger.android.HasAndroidInjector
import javax.inject.Inject
interface PumpEnactResult { class PumpEnactResult(injector: HasAndroidInjector) {
var success: Boolean // request was processed successfully (but possible no change was needed) @Inject lateinit var context: Context
var enacted: Boolean // request was processed successfully and change has been made
var comment: String init {
injector.androidInjector().inject(this)
}
var success = false // request was processed successfully (but possible no change was needed)
var enacted = false // request was processed successfully and change has been made
var comment = ""
// Result of basal change // Result of basal change
var duration: Int // duration set [minutes] var duration = -1 // duration set [minutes]
var absolute: Double // absolute rate [U/h] , isPercent = false var absolute = -1.0 // absolute rate [U/h] , isPercent = false
var percent: Int // percent of current basal [%] (100% = current basal), isPercent = true var percent = -1 // percent of current basal [%] (100% = current basal), isPercent = true
var isPercent: Boolean // if true percent is used, otherwise absolute var isPercent = false // if true percent is used, otherwise absolute
var isTempCancel: Boolean // if true we are canceling temp basal var isTempCancel = false // if true we are canceling temp basal
// Result of treatment delivery // Result of treatment delivery
var bolusDelivered: Double // real value of delivered insulin var bolusDelivered = 0.0 // real value of delivered insulin
var carbsDelivered: Double // real value of delivered carbs var carbsDelivered = 0.0 // real value of delivered carbs
var queued: Boolean var queued = false
fun success(success: Boolean): PumpEnactResult fun success(success: Boolean): PumpEnactResult = this.also { this.success = success }
fun enacted(enacted: Boolean): PumpEnactResult fun enacted(enacted: Boolean): PumpEnactResult = this.also { it.enacted = enacted }
fun comment(comment: String): PumpEnactResult fun comment(comment: String): PumpEnactResult = this.also { it.comment = comment }
fun comment(comment: Int): PumpEnactResult fun comment(comment: Int): PumpEnactResult = this.also { it.comment = context.getString(comment) }
fun duration(duration: Int): PumpEnactResult fun duration(duration: Int): PumpEnactResult = this.also { it.duration = duration }
fun absolute(absolute: Double): PumpEnactResult fun absolute(absolute: Double): PumpEnactResult = this.also { it.absolute = absolute }
fun percent(percent: Int): PumpEnactResult fun percent(percent: Int): PumpEnactResult = this.also { it.percent = percent }
fun isPercent(isPercent: Boolean): PumpEnactResult fun isPercent(isPercent: Boolean): PumpEnactResult = this.also { it.isPercent = isPercent }
fun isTempCancel(isTempCancel: Boolean): PumpEnactResult fun isTempCancel(isTempCancel: Boolean): PumpEnactResult = this.also { it.isTempCancel = isTempCancel }
fun bolusDelivered(bolusDelivered: Double): PumpEnactResult fun bolusDelivered(bolusDelivered: Double): PumpEnactResult = this.also { it.bolusDelivered = bolusDelivered }
fun carbsDelivered(carbsDelivered: Double): PumpEnactResult fun carbsDelivered(carbsDelivered: Double): PumpEnactResult = this.also { it.carbsDelivered = carbsDelivered }
fun queued(queued: Boolean): PumpEnactResult fun queued(queued: Boolean): PumpEnactResult = this.also { it.queued = queued }
fun log(): String
fun toHtml(): String
fun toText(): String
fun json(baseBasal: Double): JSONObject
} }

View file

@ -4,7 +4,6 @@ import android.os.SystemClock
import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceFragmentCompat
import androidx.preference.SwitchPreference import androidx.preference.SwitchPreference
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.dialogs.BolusProgressDialog import info.nightscout.androidaps.dialogs.BolusProgressDialog
import info.nightscout.androidaps.extensions.convertedToAbsolute import info.nightscout.androidaps.extensions.convertedToAbsolute
import info.nightscout.androidaps.extensions.plannedRemainingMinutes import info.nightscout.androidaps.extensions.plannedRemainingMinutes
@ -133,7 +132,7 @@ open class VirtualPumpPlugin @Inject constructor(
override var fakeDataDetected = false override var fakeDataDetected = false
override fun loadTDDs(): PumpEnactResult { //no result, could read DB in the future? override fun loadTDDs(): PumpEnactResult { //no result, could read DB in the future?
return PumpEnactResultObject(injector) return PumpEnactResult(injector)
} }
override fun isInitialized(): Boolean = true override fun isInitialized(): Boolean = true
@ -158,7 +157,7 @@ open class VirtualPumpPlugin @Inject constructor(
lastDataTime = System.currentTimeMillis() lastDataTime = System.currentTimeMillis()
rxBus.send(EventNewNotification(Notification(Notification.PROFILE_SET_OK, rh.gs(R.string.profile_set_ok), Notification.INFO, 60))) rxBus.send(EventNewNotification(Notification(Notification.PROFILE_SET_OK, rh.gs(R.string.profile_set_ok), Notification.INFO, 60)))
// Do nothing here. we are using database profile // Do nothing here. we are using database profile
return PumpEnactResultObject(injector).success(true).enacted(true) return PumpEnactResult(injector).success(true).enacted(true)
} }
override fun isThisProfileSet(profile: Profile): Boolean = pumpSync.expectedPumpState().profile?.isEqual(profile) ?: false override fun isThisProfileSet(profile: Profile): Boolean = pumpSync.expectedPumpState().profile?.isEqual(profile) ?: false
@ -175,7 +174,7 @@ open class VirtualPumpPlugin @Inject constructor(
get() = batteryPercent get() = batteryPercent
override fun deliverTreatment(detailedBolusInfo: DetailedBolusInfo): PumpEnactResult { override fun deliverTreatment(detailedBolusInfo: DetailedBolusInfo): PumpEnactResult {
val result = PumpEnactResultObject(injector) val result = PumpEnactResult(injector)
.success(true) .success(true)
.bolusDelivered(detailedBolusInfo.insulin) .bolusDelivered(detailedBolusInfo.insulin)
.carbsDelivered(detailedBolusInfo.carbs) .carbsDelivered(detailedBolusInfo.carbs)
@ -191,7 +190,7 @@ open class VirtualPumpPlugin @Inject constructor(
rxBus.send(bolusingEvent) rxBus.send(bolusingEvent)
delivering += 0.1 delivering += 0.1
if (BolusProgressDialog.stopPressed) if (BolusProgressDialog.stopPressed)
return PumpEnactResultObject(injector) return PumpEnactResult(injector)
.success(false) .success(false)
.enacted(false) .enacted(false)
.comment(rh.gs(R.string.stoppressed)) .comment(rh.gs(R.string.stoppressed))
@ -226,7 +225,7 @@ open class VirtualPumpPlugin @Inject constructor(
override fun stopBolusDelivering() {} override fun stopBolusDelivering() {}
override fun setTempBasalAbsolute(absoluteRate: Double, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult { override fun setTempBasalAbsolute(absoluteRate: Double, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult {
val result = PumpEnactResultObject(injector) val result = PumpEnactResult(injector)
result.success = true result.success = true
result.enacted = true result.enacted = true
result.isTempCancel = false result.isTempCancel = false
@ -243,14 +242,14 @@ open class VirtualPumpPlugin @Inject constructor(
pumpType = pumpType ?: PumpType.GENERIC_AAPS, pumpType = pumpType ?: PumpType.GENERIC_AAPS,
pumpSerial = serialNumber() pumpSerial = serialNumber()
) )
aapsLogger.debug(LTag.PUMP, "Setting temp basal absolute: ${result.toText()}") aapsLogger.debug(LTag.PUMP, "Setting temp basal absolute: ${result.toText(rh)}")
rxBus.send(EventVirtualPumpUpdateGui()) rxBus.send(EventVirtualPumpUpdateGui())
lastDataTime = System.currentTimeMillis() lastDataTime = System.currentTimeMillis()
return result return result
} }
override fun setTempBasalPercent(percent: Int, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult { override fun setTempBasalPercent(percent: Int, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult {
val result = PumpEnactResultObject(injector) val result = PumpEnactResult(injector)
result.success = true result.success = true
result.enacted = true result.enacted = true
result.percent = percent result.percent = percent
@ -268,7 +267,7 @@ open class VirtualPumpPlugin @Inject constructor(
pumpType = pumpType ?: PumpType.GENERIC_AAPS, pumpType = pumpType ?: PumpType.GENERIC_AAPS,
pumpSerial = serialNumber() pumpSerial = serialNumber()
) )
aapsLogger.debug(LTag.PUMP, "Settings temp basal percent: ${result.toText()}") aapsLogger.debug(LTag.PUMP, "Settings temp basal percent: ${result.toText(rh)}")
rxBus.send(EventVirtualPumpUpdateGui()) rxBus.send(EventVirtualPumpUpdateGui())
lastDataTime = System.currentTimeMillis() lastDataTime = System.currentTimeMillis()
return result return result
@ -292,14 +291,14 @@ open class VirtualPumpPlugin @Inject constructor(
pumpType = pumpType ?: PumpType.GENERIC_AAPS, pumpType = pumpType ?: PumpType.GENERIC_AAPS,
pumpSerial = serialNumber() pumpSerial = serialNumber()
) )
aapsLogger.debug(LTag.PUMP, "Setting extended bolus: ${result.toText()}") aapsLogger.debug(LTag.PUMP, "Setting extended bolus: ${result.toText(rh)}")
rxBus.send(EventVirtualPumpUpdateGui()) rxBus.send(EventVirtualPumpUpdateGui())
lastDataTime = System.currentTimeMillis() lastDataTime = System.currentTimeMillis()
return result return result
} }
override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult { override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult {
val result = PumpEnactResultObject(injector) val result = PumpEnactResult(injector)
result.success = true result.success = true
result.isTempCancel = true result.isTempCancel = true
result.comment = rh.gs(R.string.virtualpump_resultok) result.comment = rh.gs(R.string.virtualpump_resultok)
@ -311,7 +310,7 @@ open class VirtualPumpPlugin @Inject constructor(
pumpType = pumpType ?: PumpType.GENERIC_AAPS, pumpType = pumpType ?: PumpType.GENERIC_AAPS,
pumpSerial = serialNumber() pumpSerial = serialNumber()
) )
aapsLogger.debug(LTag.PUMP, "Canceling temp basal: ${result.toText()}") aapsLogger.debug(LTag.PUMP, "Canceling temp basal: ${result.toText(rh)}")
rxBus.send(EventVirtualPumpUpdateGui()) rxBus.send(EventVirtualPumpUpdateGui())
} }
lastDataTime = System.currentTimeMillis() lastDataTime = System.currentTimeMillis()
@ -319,7 +318,7 @@ open class VirtualPumpPlugin @Inject constructor(
} }
override fun cancelExtendedBolus(): PumpEnactResult { override fun cancelExtendedBolus(): PumpEnactResult {
val result = PumpEnactResultObject(injector) val result = PumpEnactResult(injector)
if (pumpSync.expectedPumpState().extendedBolus != null) { if (pumpSync.expectedPumpState().extendedBolus != null) {
pumpSync.syncStopExtendedBolusWithPumpId( pumpSync.syncStopExtendedBolusWithPumpId(
timestamp = dateUtil.now(), timestamp = dateUtil.now(),
@ -332,7 +331,7 @@ open class VirtualPumpPlugin @Inject constructor(
result.enacted = true result.enacted = true
result.isTempCancel = true result.isTempCancel = true
result.comment = rh.gs(R.string.virtualpump_resultok) result.comment = rh.gs(R.string.virtualpump_resultok)
aapsLogger.debug(LTag.PUMP, "Canceling extended bolus: ${result.toText()}") aapsLogger.debug(LTag.PUMP, "Canceling extended bolus: ${result.toText(rh)}")
rxBus.send(EventVirtualPumpUpdateGui()) rxBus.send(EventVirtualPumpUpdateGui())
lastDataTime = System.currentTimeMillis() lastDataTime = System.currentTimeMillis()
return result return result
@ -400,4 +399,40 @@ open class VirtualPumpPlugin @Inject constructor(
} }
override fun timezoneOrDSTChanged(timeChangeType: TimeChangeType) {} override fun timezoneOrDSTChanged(timeChangeType: TimeChangeType) {}
private fun PumpEnactResult.toText(rh: ResourceHelper): String {
var ret = rh.gs(info.nightscout.core.main.R.string.success) + ": " + success
if (enacted) {
when {
bolusDelivered > 0 -> {
ret += "\n${rh.gs(info.nightscout.core.main.R.string.enacted)}: $enacted"
ret += "\n${rh.gs(info.nightscout.core.main.R.string.comment)}: $comment"
ret += "\n${rh.gs(info.nightscout.core.main.R.string.configbuilder_insulin)}: $bolusDelivered ${rh.gs(info.nightscout.core.main.R.string.insulin_unit_shortname)}"
}
isTempCancel -> {
ret += "\n${rh.gs(info.nightscout.core.main.R.string.enacted)}: $enacted"
if (comment.isNotEmpty()) ret += "\n${rh.gs(info.nightscout.core.main.R.string.comment)}: $comment"
ret += "\n${rh.gs(info.nightscout.core.main.R.string.cancel_temp)}"
}
isPercent -> {
ret += "\n${rh.gs(info.nightscout.core.main.R.string.enacted)}: $enacted"
if (comment.isNotEmpty()) ret += "\n${rh.gs(info.nightscout.core.main.R.string.comment)}: $comment"
ret += "\n${rh.gs(info.nightscout.core.main.R.string.duration)}: $duration min"
ret += "\n${rh.gs(info.nightscout.core.main.R.string.percent)}: $percent%"
}
else -> {
ret += "\n${rh.gs(info.nightscout.core.main.R.string.enacted)}: $enacted"
if (comment.isNotEmpty()) ret += "\n${rh.gs(info.nightscout.core.main.R.string.comment)}: $comment"
ret += "\n${rh.gs(info.nightscout.core.main.R.string.duration)}: $duration min"
ret += "\n${rh.gs(info.nightscout.core.main.R.string.absolute)}: $absolute U/h"
}
}
} else {
ret += "\n${rh.gs(info.nightscout.core.main.R.string.comment)}: $comment"
}
return ret
}
} }

View file

@ -0,0 +1,46 @@
package info.nightscout.plugins.sync.nsShared.extensions
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.utils.Round
import org.json.JSONObject
fun PumpEnactResult.log(): String {
return "Success: " + success +
" Enacted: " + enacted +
" Comment: " + comment +
" Duration: " + duration +
" Absolute: " + absolute +
" Percent: " + percent +
" IsPercent: " + isPercent +
" IsTempCancel: " + isTempCancel +
" bolusDelivered: " + bolusDelivered +
" carbsDelivered: " + carbsDelivered +
" Queued: " + queued
}
fun PumpEnactResult.json(baseBasal: Double): JSONObject {
val result = JSONObject()
when {
bolusDelivered > 0 -> {
result.put("smb", bolusDelivered)
}
isTempCancel -> {
result.put("rate", 0)
result.put("duration", 0)
}
isPercent -> {
// Nightscout is expecting absolute value
val abs = Round.roundTo(baseBasal * percent / 100, 0.01)
result.put("rate", abs)
result.put("duration", duration)
}
else -> {
result.put("rate", absolute)
result.put("duration", duration)
}
}
return result
}

View file

@ -9,6 +9,7 @@ import info.nightscout.interfaces.iob.IobCobCalculator
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.pump.Pump import info.nightscout.interfaces.pump.Pump
import info.nightscout.plugins.configBuilder.RunningConfiguration import info.nightscout.plugins.configBuilder.RunningConfiguration
import info.nightscout.plugins.sync.nsShared.extensions.json
import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.DateUtil
import org.json.JSONObject import org.json.JSONObject

View file

@ -1,7 +1,6 @@
package info.nightscout.androidaps package info.nightscout.androidaps
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.pump.DetailedBolusInfo import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.pump.Pump import info.nightscout.interfaces.pump.Pump
@ -44,30 +43,30 @@ class TestPumpPlugin(val injector: HasAndroidInjector) : Pump {
override fun waitForDisconnectionInSeconds(): Int = 0 override fun waitForDisconnectionInSeconds(): Int = 0
override fun getPumpStatus(reason: String) {} override fun getPumpStatus(reason: String) {}
override fun setNewBasalProfile(profile: Profile): PumpEnactResult = PumpEnactResultObject(injector) override fun setNewBasalProfile(profile: Profile): PumpEnactResult = PumpEnactResult(injector)
override fun isThisProfileSet(profile: Profile): Boolean = isProfileSet override fun isThisProfileSet(profile: Profile): Boolean = isProfileSet
override fun lastDataTime(): Long = lastData override fun lastDataTime(): Long = lastData
override val baseBasalRate: Double = baseBasal override val baseBasalRate: Double = baseBasal
override val reservoirLevel: Double = 0.0 override val reservoirLevel: Double = 0.0
override val batteryLevel: Int = 0 override val batteryLevel: Int = 0
override fun deliverTreatment(detailedBolusInfo: DetailedBolusInfo): PumpEnactResult = PumpEnactResultObject(injector).success(true) override fun deliverTreatment(detailedBolusInfo: DetailedBolusInfo): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun stopBolusDelivering() {} override fun stopBolusDelivering() {}
override fun setTempBasalAbsolute(absoluteRate: Double, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult = override fun setTempBasalAbsolute(absoluteRate: Double, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult =
PumpEnactResultObject(injector).success(true) PumpEnactResult(injector).success(true)
override fun setTempBasalPercent(percent: Int, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult = override fun setTempBasalPercent(percent: Int, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult =
PumpEnactResultObject(injector).success(true) PumpEnactResult(injector).success(true)
override fun setExtendedBolus(insulin: Double, durationInMinutes: Int): PumpEnactResult = PumpEnactResultObject(injector).success(true) override fun setExtendedBolus(insulin: Double, durationInMinutes: Int): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult = PumpEnactResultObject(injector).success(true) override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun cancelExtendedBolus(): PumpEnactResult = PumpEnactResultObject(injector).success(true) override fun cancelExtendedBolus(): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun getJSONStatus(profile: Profile, profileName: String, version: String): JSONObject = JSONObject() override fun getJSONStatus(profile: Profile, profileName: String, version: String): JSONObject = JSONObject()
override fun manufacturer(): ManufacturerType = ManufacturerType.AAPS override fun manufacturer(): ManufacturerType = ManufacturerType.AAPS
override fun model(): PumpType = PumpType.GENERIC_AAPS override fun model(): PumpType = PumpType.GENERIC_AAPS
override fun serialNumber(): String = "1" override fun serialNumber(): String = "1"
override fun shortStatus(veryShort: Boolean): String = "" override fun shortStatus(veryShort: Boolean): String = ""
override val isFakingTempsByExtendedBoluses: Boolean = false override val isFakingTempsByExtendedBoluses: Boolean = false
override fun loadTDDs(): PumpEnactResult = PumpEnactResultObject(injector).success(true) override fun loadTDDs(): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun canHandleDST(): Boolean = true override fun canHandleDST(): Boolean = true
override fun timezoneOrDSTChanged(timeChangeType: TimeChangeType) {} override fun timezoneOrDSTChanged(timeChangeType: TimeChangeType) {}
} }

View file

@ -5,7 +5,6 @@ import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.TestBaseWithProfile import info.nightscout.androidaps.TestBaseWithProfile
import info.nightscout.androidaps.TestPumpPlugin import info.nightscout.androidaps.TestPumpPlugin
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensDataStoreObject import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensDataStoreObject
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
@ -26,6 +25,7 @@ import info.nightscout.interfaces.iob.IobTotal
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.plugin.PluginType import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.profile.ProfileSource import info.nightscout.interfaces.profile.ProfileSource
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.pump.defs.PumpDescription import info.nightscout.interfaces.pump.defs.PumpDescription
import info.nightscout.interfaces.pump.defs.PumpType import info.nightscout.interfaces.pump.defs.PumpType
import info.nightscout.interfaces.queue.Callback import info.nightscout.interfaces.queue.Callback
@ -113,45 +113,45 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
smsCommunicatorPlugin.setPluginEnabled(PluginType.GENERAL, true) smsCommunicatorPlugin.setPluginEnabled(PluginType.GENERAL, true)
Mockito.doAnswer { invocation: InvocationOnMock -> Mockito.doAnswer { invocation: InvocationOnMock ->
val callback = invocation.getArgument<Callback>(1) val callback = invocation.getArgument<Callback>(1)
callback.result = PumpEnactResultObject(injector).success(true) callback.result = PumpEnactResult(injector).success(true)
callback.run() callback.run()
null null
}.`when`(commandQueue).cancelTempBasal(ArgumentMatchers.anyBoolean(), ArgumentMatchers.any(Callback::class.java)) }.`when`(commandQueue).cancelTempBasal(ArgumentMatchers.anyBoolean(), ArgumentMatchers.any(Callback::class.java))
Mockito.doAnswer { invocation: InvocationOnMock -> Mockito.doAnswer { invocation: InvocationOnMock ->
val callback = invocation.getArgument<Callback>(0) val callback = invocation.getArgument<Callback>(0)
callback.result = PumpEnactResultObject(injector).success(true) callback.result = PumpEnactResult(injector).success(true)
callback.run() callback.run()
null null
}.`when`(commandQueue).cancelExtended(ArgumentMatchers.any(Callback::class.java)) }.`when`(commandQueue).cancelExtended(ArgumentMatchers.any(Callback::class.java))
Mockito.doAnswer { invocation: InvocationOnMock -> Mockito.doAnswer { invocation: InvocationOnMock ->
val callback = invocation.getArgument<Callback>(1) val callback = invocation.getArgument<Callback>(1)
callback.result = PumpEnactResultObject(injector).success(true) callback.result = PumpEnactResult(injector).success(true)
callback.run() callback.run()
null null
}.`when`(commandQueue).readStatus(ArgumentMatchers.anyString(), ArgumentMatchers.any(Callback::class.java)) }.`when`(commandQueue).readStatus(ArgumentMatchers.anyString(), ArgumentMatchers.any(Callback::class.java))
Mockito.doAnswer { invocation: InvocationOnMock -> Mockito.doAnswer { invocation: InvocationOnMock ->
val callback = invocation.getArgument<Callback>(1) val callback = invocation.getArgument<Callback>(1)
callback.result = PumpEnactResultObject(injector).success(true).bolusDelivered(1.0) callback.result = PumpEnactResult(injector).success(true).bolusDelivered(1.0)
callback.run() callback.run()
null null
}.`when`(commandQueue).bolus(anyObject(), ArgumentMatchers.any(Callback::class.java)) }.`when`(commandQueue).bolus(anyObject(), ArgumentMatchers.any(Callback::class.java))
Mockito.doAnswer { invocation: InvocationOnMock -> Mockito.doAnswer { invocation: InvocationOnMock ->
val callback = invocation.getArgument<Callback>(5) val callback = invocation.getArgument<Callback>(5)
callback.result = PumpEnactResultObject(injector).success(true).isPercent(true).percent(invocation.getArgument(0)).duration(invocation.getArgument(1)) callback.result = PumpEnactResult(injector).success(true).isPercent(true).percent(invocation.getArgument(0)).duration(invocation.getArgument(1))
callback.run() callback.run()
null null
}.`when`(commandQueue) }.`when`(commandQueue)
.tempBasalPercent(ArgumentMatchers.anyInt(), ArgumentMatchers.anyInt(), ArgumentMatchers.anyBoolean(), anyObject(), anyObject(), ArgumentMatchers.any(Callback::class.java)) .tempBasalPercent(ArgumentMatchers.anyInt(), ArgumentMatchers.anyInt(), ArgumentMatchers.anyBoolean(), anyObject(), anyObject(), ArgumentMatchers.any(Callback::class.java))
Mockito.doAnswer { invocation: InvocationOnMock -> Mockito.doAnswer { invocation: InvocationOnMock ->
val callback = invocation.getArgument<Callback>(5) val callback = invocation.getArgument<Callback>(5)
callback.result = PumpEnactResultObject(injector).success(true).isPercent(false).absolute(invocation.getArgument(0)).duration(invocation.getArgument(1)) callback.result = PumpEnactResult(injector).success(true).isPercent(false).absolute(invocation.getArgument(0)).duration(invocation.getArgument(1))
callback.run() callback.run()
null null
}.`when`(commandQueue) }.`when`(commandQueue)
.tempBasalAbsolute(ArgumentMatchers.anyDouble(), ArgumentMatchers.anyInt(), ArgumentMatchers.anyBoolean(), anyObject(), anyObject(), ArgumentMatchers.any(Callback::class.java)) .tempBasalAbsolute(ArgumentMatchers.anyDouble(), ArgumentMatchers.anyInt(), ArgumentMatchers.anyBoolean(), anyObject(), anyObject(), ArgumentMatchers.any(Callback::class.java))
Mockito.doAnswer { invocation: InvocationOnMock -> Mockito.doAnswer { invocation: InvocationOnMock ->
val callback = invocation.getArgument<Callback>(2) val callback = invocation.getArgument<Callback>(2)
callback.result = PumpEnactResultObject(injector).success(true).isPercent(false).absolute(invocation.getArgument(0)).duration(invocation.getArgument(1)) callback.result = PumpEnactResult(injector).success(true).isPercent(false).absolute(invocation.getArgument(0)).duration(invocation.getArgument(1))
callback.run() callback.run()
null null
}.`when`(commandQueue).extendedBolus(ArgumentMatchers.anyDouble(), ArgumentMatchers.anyInt(), ArgumentMatchers.any(Callback::class.java)) }.`when`(commandQueue).extendedBolus(ArgumentMatchers.anyDouble(), ArgumentMatchers.anyInt(), ArgumentMatchers.any(Callback::class.java))

View file

@ -21,7 +21,6 @@ import javax.inject.Singleton;
import dagger.android.HasAndroidInjector; import dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.combo.R; import info.nightscout.androidaps.combo.R;
import info.nightscout.androidaps.data.PumpEnactResultObject;
import info.nightscout.androidaps.extensions.PumpStateExtensionKt; import info.nightscout.androidaps.extensions.PumpStateExtensionKt;
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
@ -177,7 +176,7 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
@Override protected void onStart() { @Override protected void onStart() {
super.onStart(); super.onStart();
OPERATION_NOT_SUPPORTED = new PumpEnactResultObject(getInjector()) OPERATION_NOT_SUPPORTED = new PumpEnactResult(getInjector())
.success(false).enacted(false).comment(R.string.combo_pump_unsupported_operation); .success(false).enacted(false).comment(R.string.combo_pump_unsupported_operation);
} }
@ -264,7 +263,7 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
getAapsLogger().error("setNewBasalProfile not initialized"); getAapsLogger().error("setNewBasalProfile not initialized");
Notification notification = new Notification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED, getRh().gs(R.string.pumpNotInitializedProfileNotSet), Notification.URGENT); Notification notification = new Notification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED, getRh().gs(R.string.pumpNotInitializedProfileNotSet), Notification.URGENT);
rxBus.send(new EventNewNotification(notification)); rxBus.send(new EventNewNotification(notification));
return new PumpEnactResultObject(getInjector()).success(false).enacted(false).comment(R.string.pumpNotInitializedProfileNotSet); return new PumpEnactResult(getInjector()).success(false).enacted(false).comment(R.string.pumpNotInitializedProfileNotSet);
} }
BasalProfile requestedBasalProfile = convertProfileToComboProfile(profile); BasalProfile requestedBasalProfile = convertProfileToComboProfile(profile);
@ -272,12 +271,12 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
//dismiss previously "FAILED" overview notifications //dismiss previously "FAILED" overview notifications
rxBus.send(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED)); rxBus.send(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED));
rxBus.send(new EventDismissNotification(Notification.FAILED_UPDATE_PROFILE)); rxBus.send(new EventDismissNotification(Notification.FAILED_UPDATE_PROFILE));
return new PumpEnactResultObject(getInjector()).success(true).enacted(false); return new PumpEnactResult(getInjector()).success(true).enacted(false);
} }
CommandResult stateResult = runCommand(null, 1, ruffyScripter::readPumpState); CommandResult stateResult = runCommand(null, 1, ruffyScripter::readPumpState);
if (stateResult.state.unsafeUsageDetected == PumpState.UNSUPPORTED_BASAL_RATE_PROFILE) { if (stateResult.state.unsafeUsageDetected == PumpState.UNSUPPORTED_BASAL_RATE_PROFILE) {
return new PumpEnactResultObject(getInjector()).success(false).enacted(false).comment(R.string.combo_force_disabled_notification); return new PumpEnactResult(getInjector()).success(false).enacted(false).comment(R.string.combo_force_disabled_notification);
} }
CommandResult setResult = runCommand(getRh().gs(R.string.combo_activity_setting_basal_profile), 2, CommandResult setResult = runCommand(getRh().gs(R.string.combo_activity_setting_basal_profile), 2,
@ -285,7 +284,7 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
if (!setResult.success) { if (!setResult.success) {
Notification notification = new Notification(Notification.FAILED_UPDATE_PROFILE, getRh().gs(R.string.failedupdatebasalprofile), Notification.URGENT); Notification notification = new Notification(Notification.FAILED_UPDATE_PROFILE, getRh().gs(R.string.failedupdatebasalprofile), Notification.URGENT);
rxBus.send(new EventNewNotification(notification)); rxBus.send(new EventNewNotification(notification));
return new PumpEnactResultObject(getInjector()).success(false).enacted(false).comment(R.string.failedupdatebasalprofile); return new PumpEnactResult(getInjector()).success(false).enacted(false).comment(R.string.failedupdatebasalprofile);
} }
pump.basalProfile = requestedBasalProfile; pump.basalProfile = requestedBasalProfile;
@ -296,7 +295,7 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
//issue success notification //issue success notification
Notification notification = new Notification(Notification.PROFILE_SET_OK, getRh().gs(R.string.profile_set_ok), Notification.INFO, 60); Notification notification = new Notification(Notification.PROFILE_SET_OK, getRh().gs(R.string.profile_set_ok), Notification.INFO, 60);
rxBus.send(new EventNewNotification(notification)); rxBus.send(new EventNewNotification(notification));
return new PumpEnactResultObject(getInjector()).success(true).enacted(true); return new PumpEnactResult(getInjector()).success(true).enacted(true);
} }
@Override @Override
@ -509,16 +508,16 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
// check pump is ready and all pump bolus records are known // check pump is ready and all pump bolus records are known
CommandResult stateResult = runCommand(null, 2, () -> ruffyScripter.readQuickInfo(1)); CommandResult stateResult = runCommand(null, 2, () -> ruffyScripter.readQuickInfo(1));
if (!stateResult.success) { if (!stateResult.success) {
return new PumpEnactResultObject(getInjector()).success(false).enacted(false) return new PumpEnactResult(getInjector()).success(false).enacted(false)
.comment(R.string.combo_error_no_connection_no_bolus_delivered); .comment(R.string.combo_error_no_connection_no_bolus_delivered);
} }
if (stateResult.reservoirLevel != -1 && stateResult.reservoirLevel - 0.5 < detailedBolusInfo.insulin) { if (stateResult.reservoirLevel != -1 && stateResult.reservoirLevel - 0.5 < detailedBolusInfo.insulin) {
return new PumpEnactResultObject(getInjector()).success(false).enacted(false) return new PumpEnactResult(getInjector()).success(false).enacted(false)
.comment(R.string.combo_reservoir_level_insufficient_for_bolus); .comment(R.string.combo_reservoir_level_insufficient_for_bolus);
} }
// the commands above ensured a connection was made, which updated this field // the commands above ensured a connection was made, which updated this field
if (pumpHistoryChanged) { if (pumpHistoryChanged) {
return new PumpEnactResultObject(getInjector()).success(false).enacted(false) return new PumpEnactResult(getInjector()).success(false).enacted(false)
.comment(R.string.combo_bolus_rejected_due_to_pump_history_change); .comment(R.string.combo_bolus_rejected_due_to_pump_history_change);
} }
@ -531,7 +530,7 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
if (Math.abs(previousBolus.amount - detailedBolusInfo.insulin) < 0.01 if (Math.abs(previousBolus.amount - detailedBolusInfo.insulin) < 0.01
&& previousBolus.timestamp + 60 * 1000 > System.currentTimeMillis()) { && previousBolus.timestamp + 60 * 1000 > System.currentTimeMillis()) {
getAapsLogger().debug(LTag.PUMP, "Bolus request rejected, same bolus was successfully delivered very recently"); getAapsLogger().debug(LTag.PUMP, "Bolus request rejected, same bolus was successfully delivered very recently");
return new PumpEnactResultObject(getInjector()).success(false).enacted(false) return new PumpEnactResult(getInjector()).success(false).enacted(false)
.comment(R.string.bolus_frequency_exceeded); .comment(R.string.bolus_frequency_exceeded);
} }
@ -544,10 +543,10 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
while (previousBolus.timestamp == timeCheckResult.state.pumpTime while (previousBolus.timestamp == timeCheckResult.state.pumpTime
&& maxWaitTimeout > System.currentTimeMillis()) { && maxWaitTimeout > System.currentTimeMillis()) {
if (cancelBolus) { if (cancelBolus) {
return new PumpEnactResultObject(getInjector()).success(true).enacted(false); return new PumpEnactResult(getInjector()).success(true).enacted(false);
} }
if (!timeCheckResult.success) { if (!timeCheckResult.success) {
return new PumpEnactResultObject(getInjector()).success(false).enacted(false) return new PumpEnactResult(getInjector()).success(false).enacted(false)
.comment(R.string.combo_error_no_connection_no_bolus_delivered); .comment(R.string.combo_error_no_connection_no_bolus_delivered);
} }
getAapsLogger().debug(LTag.PUMP, "Waiting for pump clock to advance for the next unused bolus record timestamp"); getAapsLogger().debug(LTag.PUMP, "Waiting for pump clock to advance for the next unused bolus record timestamp");
@ -561,7 +560,7 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
} }
if (cancelBolus) { if (cancelBolus) {
return new PumpEnactResultObject(getInjector()).success(true).enacted(false); return new PumpEnactResult(getInjector()).success(true).enacted(false);
} }
EventOverviewBolusProgress.Treatment treatment = new EventOverviewBolusProgress.Treatment(0.0, 0, detailedBolusInfo.getBolusType() == DetailedBolusInfo.BolusType.SMB, detailedBolusInfo.getId()); EventOverviewBolusProgress.Treatment treatment = new EventOverviewBolusProgress.Treatment(0.0, 0, detailedBolusInfo.getBolusType() == DetailedBolusInfo.BolusType.SMB, detailedBolusInfo.getId());
@ -581,7 +580,7 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
// (reads 2 records to update `recentBoluses` further down) // (reads 2 records to update `recentBoluses` further down)
CommandResult postBolusStateResult = runCommand(null, 3, () -> ruffyScripter.readQuickInfo(2)); CommandResult postBolusStateResult = runCommand(null, 3, () -> ruffyScripter.readQuickInfo(2));
if (!postBolusStateResult.success) { if (!postBolusStateResult.success) {
return new PumpEnactResultObject(getInjector()).success(false).enacted(false) return new PumpEnactResult(getInjector()).success(false).enacted(false)
.comment(R.string.combo_error_bolus_verification_failed); .comment(R.string.combo_error_bolus_verification_failed);
} }
Bolus lastPumpBolus = postBolusStateResult.history != null && !postBolusStateResult.history.bolusHistory.isEmpty() Bolus lastPumpBolus = postBolusStateResult.history != null && !postBolusStateResult.history.bolusHistory.isEmpty()
@ -591,9 +590,9 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
// no bolus delivered? // no bolus delivered?
if (lastPumpBolus == null || lastPumpBolus.equals(previousBolus)) { if (lastPumpBolus == null || lastPumpBolus.equals(previousBolus)) {
if (cancelBolus) { if (cancelBolus) {
return new PumpEnactResultObject(getInjector()).success(true).enacted(false); return new PumpEnactResult(getInjector()).success(true).enacted(false);
} else { } else {
return new PumpEnactResultObject(getInjector()) return new PumpEnactResult(getInjector())
.success(false) .success(false)
.enacted(false) .enacted(false)
.comment(R.string.combo_error_no_bolus_delivered); .comment(R.string.combo_error_no_bolus_delivered);
@ -602,7 +601,7 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
// at least some insulin delivered, so add it to treatments // at least some insulin delivered, so add it to treatments
if (!addBolusToTreatments(detailedBolusInfo, lastPumpBolus)) if (!addBolusToTreatments(detailedBolusInfo, lastPumpBolus))
return new PumpEnactResultObject(getInjector()).success(false).enacted(true) return new PumpEnactResult(getInjector()).success(false).enacted(true)
.comment(R.string.combo_error_updating_treatment_record); .comment(R.string.combo_error_updating_treatment_record);
// check pump bolus record has a sane timestamp // check pump bolus record has a sane timestamp
@ -619,16 +618,16 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
// only a partial bolus was delivered // only a partial bolus was delivered
if (Math.abs(lastPumpBolus.amount - detailedBolusInfo.insulin) > 0.01) { if (Math.abs(lastPumpBolus.amount - detailedBolusInfo.insulin) > 0.01) {
if (cancelBolus) { if (cancelBolus) {
return new PumpEnactResultObject(getInjector()).success(true).enacted(true); return new PumpEnactResult(getInjector()).success(true).enacted(true);
} }
return new PumpEnactResultObject(getInjector()).success(false).enacted(true) return new PumpEnactResult(getInjector()).success(false).enacted(true)
.comment(getRh().gs(R.string.combo_error_partial_bolus_delivered, .comment(getRh().gs(R.string.combo_error_partial_bolus_delivered,
lastPumpBolus.amount, detailedBolusInfo.insulin)); lastPumpBolus.amount, detailedBolusInfo.insulin));
} }
// full bolus was delivered successfully // full bolus was delivered successfully
incrementBolusCount(); incrementBolusCount();
return new PumpEnactResultObject(getInjector()) return new PumpEnactResult(getInjector())
.success(true) .success(true)
.enacted(lastPumpBolus.amount > 0) .enacted(lastPumpBolus.amount > 0)
.bolusDelivered(lastPumpBolus.amount) .bolusDelivered(lastPumpBolus.amount)
@ -729,7 +728,7 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
getAapsLogger().debug(LTag.PUMP, "setTempBasalPercent called with " + percent + "% for " + durationInMinutes + "min"); getAapsLogger().debug(LTag.PUMP, "setTempBasalPercent called with " + percent + "% for " + durationInMinutes + "min");
if (pumpHistoryChanged && percent > 110) { if (pumpHistoryChanged && percent > 110) {
return new PumpEnactResultObject(getInjector()).success(false).enacted(false) return new PumpEnactResult(getInjector()).success(false).enacted(false)
.comment(R.string.combo_high_temp_rejected_due_to_pump_history_changes); .comment(R.string.combo_high_temp_rejected_due_to_pump_history_changes);
} }
@ -755,7 +754,7 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
CommandResult commandResult = runCommand(getRh().gs(R.string.combo_pump_action_setting_tbr, percent, durationInMinutes), CommandResult commandResult = runCommand(getRh().gs(R.string.combo_pump_action_setting_tbr, percent, durationInMinutes),
3, () -> ruffyScripter.setTbr(finalAdjustedPercent, durationInMinutes)); 3, () -> ruffyScripter.setTbr(finalAdjustedPercent, durationInMinutes));
if (!commandResult.success) { if (!commandResult.success) {
return new PumpEnactResultObject(getInjector()).success(false).enacted(false); return new PumpEnactResult(getInjector()).success(false).enacted(false);
} }
PumpState state = commandResult.state; PumpState state = commandResult.state;
@ -781,7 +780,7 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
} }
incrementTbrCount(); incrementTbrCount();
return new PumpEnactResultObject(getInjector()).success(true).enacted(true).isPercent(true) return new PumpEnactResult(getInjector()).success(true).enacted(true).isPercent(true)
.percent(state.tbrPercent).duration(state.tbrRemainingDuration); .percent(state.tbrPercent).duration(state.tbrRemainingDuration);
} }
@ -805,15 +804,15 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
if (enforceNew) { if (enforceNew) {
CommandResult stateResult = runCommand(getRh().gs(R.string.combo_pump_action_refreshing), 2, ruffyScripter::readPumpState); CommandResult stateResult = runCommand(getRh().gs(R.string.combo_pump_action_refreshing), 2, ruffyScripter::readPumpState);
if (!stateResult.success) { if (!stateResult.success) {
return new PumpEnactResultObject(getInjector()).success(false).enacted(false); return new PumpEnactResult(getInjector()).success(false).enacted(false);
} }
if (!stateResult.state.tbrActive) { if (!stateResult.state.tbrActive) {
return new PumpEnactResultObject(getInjector()).success(true).enacted(false); return new PumpEnactResult(getInjector()).success(true).enacted(false);
} }
getAapsLogger().debug(LTag.PUMP, "cancelTempBasal: hard-cancelling TBR since force requested"); getAapsLogger().debug(LTag.PUMP, "cancelTempBasal: hard-cancelling TBR since force requested");
CommandResult cancelResult = runCommand(getRh().gs(R.string.combo_pump_action_cancelling_tbr), 2, ruffyScripter::cancelTbr); CommandResult cancelResult = runCommand(getRh().gs(R.string.combo_pump_action_cancelling_tbr), 2, ruffyScripter::cancelTbr);
if (!cancelResult.success) { if (!cancelResult.success) {
return new PumpEnactResultObject(getInjector()).success(false).enacted(false); return new PumpEnactResult(getInjector()).success(false).enacted(false);
} }
if (!cancelResult.state.tbrActive) { if (!cancelResult.state.tbrActive) {
pumpSync.syncStopTemporaryBasalWithPumpId( pumpSync.syncStopTemporaryBasalWithPumpId(
@ -823,19 +822,19 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
PumpType.ACCU_CHEK_COMBO, PumpType.ACCU_CHEK_COMBO,
serialNumber() serialNumber()
); );
return new PumpEnactResultObject(getInjector()).isTempCancel(true).success(true).enacted(true); return new PumpEnactResult(getInjector()).isTempCancel(true).success(true).enacted(true);
} else { } else {
return new PumpEnactResultObject(getInjector()).success(false).enacted(false); return new PumpEnactResult(getInjector()).success(false).enacted(false);
} }
} else if (activeTemp == null) { } else if (activeTemp == null) {
return new PumpEnactResultObject(getInjector()).success(true).enacted(false); return new PumpEnactResult(getInjector()).success(true).enacted(false);
} else if ((activeTemp.getRate() >= 90 && activeTemp.getRate() <= 110) } else if ((activeTemp.getRate() >= 90 && activeTemp.getRate() <= 110)
&& PumpStateExtensionKt.getPlannedRemainingMinutes(activeTemp) <= 15) { && PumpStateExtensionKt.getPlannedRemainingMinutes(activeTemp) <= 15) {
// Let fake neutral temp keep run (see below) // Let fake neutral temp keep run (see below)
// Note that since this runs on the queue a connection is opened regardless, but this // Note that since this runs on the queue a connection is opened regardless, but this
// case doesn't occur all that often, so it's not worth optimizing (1.3k SetTBR vs 4 cancelTBR). // case doesn't occur all that often, so it's not worth optimizing (1.3k SetTBR vs 4 cancelTBR).
getAapsLogger().debug(LTag.PUMP, "cancelTempBasal: skipping changing tbr since it already is at " + activeTemp.getRate() + "% and running for another " + PumpStateExtensionKt.getPlannedRemainingMinutes(activeTemp) + " mins."); getAapsLogger().debug(LTag.PUMP, "cancelTempBasal: skipping changing tbr since it already is at " + activeTemp.getRate() + "% and running for another " + PumpStateExtensionKt.getPlannedRemainingMinutes(activeTemp) + " mins.");
return new PumpEnactResultObject(getInjector()).success(true).enacted(true) return new PumpEnactResult(getInjector()).success(true).enacted(true)
.comment("cancelTempBasal skipping changing tbr since it already is at " .comment("cancelTempBasal skipping changing tbr since it already is at "
+ activeTemp.getRate() + "% and running for another " + activeTemp.getRate() + "% and running for another "
+ PumpStateExtensionKt.getPlannedRemainingMinutes(activeTemp) + " mins."); + PumpStateExtensionKt.getPlannedRemainingMinutes(activeTemp) + " mins.");
@ -1361,7 +1360,7 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
@NonNull @Override @NonNull @Override
public PumpEnactResult loadTDDs() { public PumpEnactResult loadTDDs() {
PumpEnactResult result = new PumpEnactResultObject(getInjector()); PumpEnactResult result = new PumpEnactResult(getInjector());
result.success(readHistory(new PumpHistoryRequest().tddHistory(PumpHistoryRequest.FULL))); result.success(readHistory(new PumpHistoryRequest().tddHistory(PumpHistoryRequest.FULL)));
if (result.getSuccess()) { if (result.getSuccess()) {
List<Tdd> tdds = pump.tddHistory; List<Tdd> tdds = pump.tddHistory;

View file

@ -4,7 +4,6 @@ import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.TestBase import info.nightscout.androidaps.TestBase
import info.nightscout.androidaps.combo.R import info.nightscout.androidaps.combo.R
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.plugins.pump.combo.ruffyscripter.RuffyScripter import info.nightscout.androidaps.plugins.pump.combo.ruffyscripter.RuffyScripter
import info.nightscout.androidaps.plugins.pump.combo.ruffyscripter.history.Bolus import info.nightscout.androidaps.plugins.pump.combo.ruffyscripter.history.Bolus
import info.nightscout.interfaces.constraints.Constraint import info.nightscout.interfaces.constraints.Constraint

View file

@ -10,7 +10,6 @@ import info.nightscout.androidaps.dana.DanaPump
import info.nightscout.androidaps.danaRKorean.services.DanaRKoreanExecutionService import info.nightscout.androidaps.danaRKorean.services.DanaRKoreanExecutionService
import info.nightscout.androidaps.danar.AbstractDanaRPlugin import info.nightscout.androidaps.danar.AbstractDanaRPlugin
import info.nightscout.androidaps.danar.R import info.nightscout.androidaps.danar.R
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.core.fabric.FabricPrivacy import info.nightscout.core.fabric.FabricPrivacy
import info.nightscout.interfaces.constraints.Constraint import info.nightscout.interfaces.constraints.Constraint
import info.nightscout.interfaces.constraints.Constraints import info.nightscout.interfaces.constraints.Constraints
@ -134,7 +133,7 @@ class DanaRKoreanPlugin @Inject constructor(
detailedBolusInfo.insulin, detailedBolusInfo.carbs.toInt(), detailedBolusInfo.carbsTimestamp detailedBolusInfo.insulin, detailedBolusInfo.carbs.toInt(), detailedBolusInfo.carbsTimestamp
?: detailedBolusInfo.timestamp, t ?: detailedBolusInfo.timestamp, t
) )
val result = PumpEnactResultObject(injector) val result = PumpEnactResult(injector)
result.success(connectionOK && abs(detailedBolusInfo.insulin - t.insulin) < pumpDescription.bolusStep) result.success(connectionOK && abs(detailedBolusInfo.insulin - t.insulin) < pumpDescription.bolusStep)
.bolusDelivered(t.insulin) .bolusDelivered(t.insulin)
if (!result.success) result.comment(rh.gs(R.string.boluserrorcode, detailedBolusInfo.insulin, t.insulin, danaPump.bolusStartErrorCode)) else result.comment(R.string.ok) if (!result.success) result.comment(rh.gs(R.string.boluserrorcode, detailedBolusInfo.insulin, t.insulin, danaPump.bolusStartErrorCode)) else result.comment(R.string.ok)
@ -151,7 +150,7 @@ class DanaRKoreanPlugin @Inject constructor(
) )
result result
} else { } else {
val result = PumpEnactResultObject(injector) val result = PumpEnactResult(injector)
result.success(false).bolusDelivered(0.0).carbsDelivered(0.0).comment(R.string.invalidinput) result.success(false).bolusDelivered(0.0).carbsDelivered(0.0).comment(R.string.invalidinput)
aapsLogger.error("deliverTreatment: Invalid input") aapsLogger.error("deliverTreatment: Invalid input")
result result
@ -191,7 +190,7 @@ class DanaRKoreanPlugin @Inject constructor(
return cancelRealTempBasal() return cancelRealTempBasal()
} }
aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: doTempOff OK") aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: doTempOff OK")
return PumpEnactResultObject(injector).success(true).enacted(false).percent(100).isPercent(true).isTempCancel(true) return PumpEnactResult(injector).success(true).enacted(false).percent(100).isPercent(true).isTempCancel(true)
} }
if (doLowTemp || doHighTemp) { if (doLowTemp || doHighTemp) {
// If extended in progress // If extended in progress
@ -212,7 +211,7 @@ class DanaRKoreanPlugin @Inject constructor(
cancelTempBasal(true) cancelTempBasal(true)
} else { } else {
aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: Correct temp basal already set (doLowTemp || doHighTemp)") aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: Correct temp basal already set (doLowTemp || doHighTemp)")
return PumpEnactResultObject(injector).success(true).percent(percentRate).enacted(false).duration(danaPump.tempBasalRemainingMin).isPercent(true).isTempCancel(false) return PumpEnactResult(injector).success(true).percent(percentRate).enacted(false).duration(danaPump.tempBasalRemainingMin).isPercent(true).isTempCancel(false)
} }
} }
} }
@ -251,7 +250,7 @@ class DanaRKoreanPlugin @Inject constructor(
if (danaPump.isExtendedInProgress && abs(danaPump.extendedBolusAbsoluteRate - extendedRateToSet) < pumpDescription.extendedBolusStep) { if (danaPump.isExtendedInProgress && abs(danaPump.extendedBolusAbsoluteRate - extendedRateToSet) < pumpDescription.extendedBolusStep) {
// correct extended already set // correct extended already set
aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: Correct extended already set") aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: Correct extended already set")
return PumpEnactResultObject(injector).success(true).absolute(danaPump.extendedBolusAbsoluteRate).enacted(false).duration(danaPump.extendedBolusRemainingMinutes).isPercent(false) return PumpEnactResult(injector).success(true).absolute(danaPump.extendedBolusAbsoluteRate).enacted(false).duration(danaPump.extendedBolusRemainingMinutes).isPercent(false)
.isTempCancel(false) .isTempCancel(false)
} }
@ -269,7 +268,7 @@ class DanaRKoreanPlugin @Inject constructor(
} }
// We should never end here // We should never end here
aapsLogger.error("setTempBasalAbsolute: Internal error") aapsLogger.error("setTempBasalAbsolute: Internal error")
return PumpEnactResultObject(injector).success(false).comment("Internal error") return PumpEnactResult(injector).success(false).comment("Internal error")
} }
override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult { override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult {
@ -277,7 +276,7 @@ class DanaRKoreanPlugin @Inject constructor(
if (danaPump.isExtendedInProgress && useExtendedBoluses) { if (danaPump.isExtendedInProgress && useExtendedBoluses) {
return cancelExtendedBolus() return cancelExtendedBolus()
} }
val result = PumpEnactResultObject(injector) val result = PumpEnactResult(injector)
result.success(true).enacted(false).comment(R.string.ok).isTempCancel(true) result.success(true).enacted(false).comment(R.string.ok).isTempCancel(true)
return result return result
} }
@ -285,7 +284,7 @@ class DanaRKoreanPlugin @Inject constructor(
override fun model(): PumpType = PumpType.DANA_R_KOREAN override fun model(): PumpType = PumpType.DANA_R_KOREAN
private fun cancelRealTempBasal(): PumpEnactResult { private fun cancelRealTempBasal(): PumpEnactResult {
val result = PumpEnactResultObject(injector) val result = PumpEnactResult(injector)
if (danaPump.isTempBasalInProgress) { if (danaPump.isTempBasalInProgress) {
sExecutionService.tempBasalStop() sExecutionService.tempBasalStop()
if (!danaPump.isTempBasalInProgress) { if (!danaPump.isTempBasalInProgress) {
@ -304,6 +303,6 @@ class DanaRKoreanPlugin @Inject constructor(
return result return result
} }
override fun loadEvents(): PumpEnactResult = PumpEnactResultObject(injector) // no history, not needed override fun loadEvents(): PumpEnactResult = PumpEnactResult(injector) // no history, not needed
override fun setUserOptions(): PumpEnactResult = PumpEnactResultObject(injector) override fun setUserOptions(): PumpEnactResult = PumpEnactResult(injector)
} }

View file

@ -16,7 +16,6 @@ import info.nightscout.androidaps.dana.DanaPump;
import info.nightscout.androidaps.danaRv2.services.DanaRv2ExecutionService; import info.nightscout.androidaps.danaRv2.services.DanaRv2ExecutionService;
import info.nightscout.androidaps.danar.AbstractDanaRPlugin; import info.nightscout.androidaps.danar.AbstractDanaRPlugin;
import info.nightscout.androidaps.danar.R; import info.nightscout.androidaps.danar.R;
import info.nightscout.androidaps.data.PumpEnactResultObject;
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage; import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage;
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.TemporaryBasalStorage; import info.nightscout.androidaps.plugins.pump.common.bolusInfo.TemporaryBasalStorage;
import info.nightscout.core.fabric.FabricPrivacy; import info.nightscout.core.fabric.FabricPrivacy;
@ -190,7 +189,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
boolean connectionOK = false; boolean connectionOK = false;
if (detailedBolusInfo.insulin > 0 || carbs > 0) if (detailedBolusInfo.insulin > 0 || carbs > 0)
connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) carbs, carbTimeStamp, t); connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) carbs, carbTimeStamp, t);
PumpEnactResult result = new PumpEnactResultObject(getInjector()); PumpEnactResult result = new PumpEnactResult(getInjector());
result.success(connectionOK && Math.abs(detailedBolusInfo.insulin - t.getInsulin()) < pumpDescription.getBolusStep()) result.success(connectionOK && Math.abs(detailedBolusInfo.insulin - t.getInsulin()) < pumpDescription.getBolusStep())
.bolusDelivered(t.getInsulin()) .bolusDelivered(t.getInsulin())
.carbsDelivered(detailedBolusInfo.carbs); .carbsDelivered(detailedBolusInfo.carbs);
@ -203,7 +202,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
// remove carbs because it's get from history separately // remove carbs because it's get from history separately
return result; return result;
} else { } else {
PumpEnactResult result = new PumpEnactResultObject(getInjector()); PumpEnactResult result = new PumpEnactResult(getInjector());
result.success(false).bolusDelivered(0d).carbsDelivered(0d).comment(R.string.invalidinput); result.success(false).bolusDelivered(0d).carbsDelivered(0d).comment(R.string.invalidinput);
aapsLogger.error("deliverTreatment: Invalid input"); aapsLogger.error("deliverTreatment: Invalid input");
return result; return result;
@ -223,7 +222,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
@NonNull @Override @NonNull @Override
public PumpEnactResult setTempBasalAbsolute(double absoluteRate, int durationInMinutes, @NonNull Profile profile, boolean enforceNew, @NonNull PumpSync.TemporaryBasalType tbrType) { public PumpEnactResult setTempBasalAbsolute(double absoluteRate, int durationInMinutes, @NonNull Profile profile, boolean enforceNew, @NonNull PumpSync.TemporaryBasalType tbrType) {
PumpEnactResult result = new PumpEnactResultObject(getInjector()); PumpEnactResult result = new PumpEnactResult(getInjector());
absoluteRate = constraintChecker.applyBasalConstraints(new Constraint<>(absoluteRate), profile).value(); absoluteRate = constraintChecker.applyBasalConstraints(new Constraint<>(absoluteRate), profile).value();
@ -290,7 +289,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
@NonNull @Override @NonNull @Override
public PumpEnactResult setTempBasalPercent(int percent, int durationInMinutes, @NonNull Profile profile, boolean enforceNew, @NonNull PumpSync.TemporaryBasalType tbrType) { public PumpEnactResult setTempBasalPercent(int percent, int durationInMinutes, @NonNull Profile profile, boolean enforceNew, @NonNull PumpSync.TemporaryBasalType tbrType) {
DanaPump pump = danaPump; DanaPump pump = danaPump;
PumpEnactResult result = new PumpEnactResultObject(getInjector()); PumpEnactResult result = new PumpEnactResult(getInjector());
percent = constraintChecker.applyBasalPercentConstraints(new Constraint<>(percent), profile).value(); percent = constraintChecker.applyBasalPercentConstraints(new Constraint<>(percent), profile).value();
if (percent < 0) { if (percent < 0) {
result.isTempCancel(false).enacted(false).success(false).comment(R.string.invalidinput); result.isTempCancel(false).enacted(false).success(false).comment(R.string.invalidinput);
@ -324,7 +323,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
private PumpEnactResult setHighTempBasalPercent(Integer percent, int durationInMinutes) { private PumpEnactResult setHighTempBasalPercent(Integer percent, int durationInMinutes) {
DanaPump pump = danaPump; DanaPump pump = danaPump;
PumpEnactResult result = new PumpEnactResultObject(getInjector()); PumpEnactResult result = new PumpEnactResult(getInjector());
boolean connectionOK = sExecutionService.highTempBasal(percent, durationInMinutes); boolean connectionOK = sExecutionService.highTempBasal(percent, durationInMinutes);
if (connectionOK && pump.isTempBasalInProgress() && pump.getTempBasalPercent() == percent) { if (connectionOK && pump.isTempBasalInProgress() && pump.getTempBasalPercent() == percent) {
result.enacted(true).success(true).comment(R.string.ok).isTempCancel(false).duration(pump.getTempBasalRemainingMin()).percent(pump.getTempBasalPercent()).isPercent(true); result.enacted(true).success(true).comment(R.string.ok).isTempCancel(false).duration(pump.getTempBasalRemainingMin()).percent(pump.getTempBasalPercent()).isPercent(true);
@ -338,7 +337,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
@NonNull @Override @NonNull @Override
public PumpEnactResult cancelTempBasal(boolean force) { public PumpEnactResult cancelTempBasal(boolean force) {
PumpEnactResult result = new PumpEnactResultObject(getInjector()); PumpEnactResult result = new PumpEnactResult(getInjector());
if (danaPump.isTempBasalInProgress()) { if (danaPump.isTempBasalInProgress()) {
sExecutionService.tempBasalStop(); sExecutionService.tempBasalStop();
result.enacted(true).isTempCancel(true); result.enacted(true).isTempCancel(true);
@ -357,7 +356,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
int durationInHalfHours = Math.max(durationInMinutes / 30, 1); int durationInHalfHours = Math.max(durationInMinutes / 30, 1);
insulin = Round.INSTANCE.roundTo(insulin, getPumpDescription().getExtendedBolusStep()); insulin = Round.INSTANCE.roundTo(insulin, getPumpDescription().getExtendedBolusStep());
PumpEnactResult result = new PumpEnactResultObject(getInjector()); PumpEnactResult result = new PumpEnactResult(getInjector());
if (danaPump.isExtendedInProgress() && Math.abs(danaPump.getExtendedBolusAmount() - insulin) < pumpDescription.getExtendedBolusStep()) { if (danaPump.isExtendedInProgress() && Math.abs(danaPump.getExtendedBolusAmount() - insulin) < pumpDescription.getExtendedBolusStep()) {
result.enacted(false) result.enacted(false)
.success(true) .success(true)
@ -390,7 +389,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
@NonNull @Override @NonNull @Override
public PumpEnactResult cancelExtendedBolus() { public PumpEnactResult cancelExtendedBolus() {
PumpEnactResult result = new PumpEnactResultObject(getInjector()); PumpEnactResult result = new PumpEnactResult(getInjector());
if (danaPump.isExtendedInProgress()) { if (danaPump.isExtendedInProgress()) {
sExecutionService.extendedBolusStop(); sExecutionService.extendedBolusStop();
result.enacted(true).success(!danaPump.isExtendedInProgress()).isTempCancel(true); result.enacted(true).success(!danaPump.isExtendedInProgress()).isTempCancel(true);

View file

@ -48,7 +48,6 @@ import info.nightscout.androidaps.danar.comm.MsgStatusBasic;
import info.nightscout.androidaps.danar.comm.MsgStatusBolusExtended; import info.nightscout.androidaps.danar.comm.MsgStatusBolusExtended;
import info.nightscout.androidaps.danar.comm.MsgStatusTempBasal; import info.nightscout.androidaps.danar.comm.MsgStatusTempBasal;
import info.nightscout.androidaps.danar.services.AbstractDanaRExecutionService; import info.nightscout.androidaps.danar.services.AbstractDanaRExecutionService;
import info.nightscout.androidaps.data.PumpEnactResultObject;
import info.nightscout.androidaps.dialogs.BolusProgressDialog; import info.nightscout.androidaps.dialogs.BolusProgressDialog;
import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
@ -430,14 +429,14 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
public PumpEnactResult loadEvents() { public PumpEnactResult loadEvents() {
if (!danaRv2Plugin.isInitialized()) { if (!danaRv2Plugin.isInitialized()) {
PumpEnactResult result = new PumpEnactResultObject(injector).success(false); PumpEnactResult result = new PumpEnactResult(injector).success(false);
result.comment("pump not initialized"); result.comment("pump not initialized");
return result; return result;
} }
if (!isConnected()) if (!isConnected())
return new PumpEnactResultObject(injector).success(false); return new PumpEnactResult(injector).success(false);
SystemClock.sleep(300); SystemClock.sleep(300);
MsgHistoryEventsV2 msg = new MsgHistoryEventsV2(injector, danaPump.lastHistoryFetched); MsgHistoryEventsV2 msg = new MsgHistoryEventsV2(injector, danaPump.lastHistoryFetched);
aapsLogger.debug(LTag.PUMP, "Loading event history from: " + dateUtil.dateAndTimeString(danaPump.lastHistoryFetched)); aapsLogger.debug(LTag.PUMP, "Loading event history from: " + dateUtil.dateAndTimeString(danaPump.lastHistoryFetched));
@ -452,7 +451,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
else else
danaPump.lastHistoryFetched = 0; danaPump.lastHistoryFetched = 0;
danaPump.setLastConnection(System.currentTimeMillis()); danaPump.setLastConnection(System.currentTimeMillis());
return new PumpEnactResultObject(injector).success(true); return new PumpEnactResult(injector).success(true);
} }
public boolean updateBasalsInPump(final Profile profile) { public boolean updateBasalsInPump(final Profile profile) {
@ -471,12 +470,12 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
public PumpEnactResult setUserOptions() { public PumpEnactResult setUserOptions() {
if (!isConnected()) if (!isConnected())
return new PumpEnactResultObject(injector).success(false); return new PumpEnactResult(injector).success(false);
SystemClock.sleep(300); SystemClock.sleep(300);
MsgSetUserOptions msg = new MsgSetUserOptions(injector); MsgSetUserOptions msg = new MsgSetUserOptions(injector);
mSerialIOThread.sendMessage(msg); mSerialIOThread.sendMessage(msg);
SystemClock.sleep(200); SystemClock.sleep(200);
return new PumpEnactResultObject(injector).success(!msg.getFailed()); return new PumpEnactResult(injector).success(!msg.getFailed());
} }
} }

View file

@ -10,7 +10,6 @@ import info.nightscout.androidaps.dana.DanaFragment;
import info.nightscout.androidaps.dana.DanaPump; import info.nightscout.androidaps.dana.DanaPump;
import info.nightscout.androidaps.dana.comm.RecordTypes; import info.nightscout.androidaps.dana.comm.RecordTypes;
import info.nightscout.androidaps.danar.services.AbstractDanaRExecutionService; import info.nightscout.androidaps.danar.services.AbstractDanaRExecutionService;
import info.nightscout.androidaps.data.PumpEnactResultObject;
import info.nightscout.androidaps.extensions.PumpStateExtensionKt; import info.nightscout.androidaps.extensions.PumpStateExtensionKt;
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
@ -136,7 +135,7 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump
// Pump interface // Pump interface
@NonNull @Override @NonNull @Override
public PumpEnactResult setNewBasalProfile(@NonNull Profile profile) { public PumpEnactResult setNewBasalProfile(@NonNull Profile profile) {
PumpEnactResult result = new PumpEnactResultObject(getInjector()); PumpEnactResult result = new PumpEnactResult(getInjector());
if (sExecutionService == null) { if (sExecutionService == null) {
getAapsLogger().error("setNewBasalProfile sExecutionService is null"); getAapsLogger().error("setNewBasalProfile sExecutionService is null");
@ -216,7 +215,7 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump
@NonNull @Override @NonNull @Override
public PumpEnactResult setTempBasalPercent(int percent, int durationInMinutes, @NonNull Profile profile, boolean enforceNew, @NonNull PumpSync.TemporaryBasalType tbrType) { public PumpEnactResult setTempBasalPercent(int percent, int durationInMinutes, @NonNull Profile profile, boolean enforceNew, @NonNull PumpSync.TemporaryBasalType tbrType) {
PumpEnactResult result = new PumpEnactResultObject(getInjector()); PumpEnactResult result = new PumpEnactResult(getInjector());
percent = constraintChecker.applyBasalPercentConstraints(new Constraint<>(percent), profile).value(); percent = constraintChecker.applyBasalPercentConstraints(new Constraint<>(percent), profile).value();
if (percent < 0) { if (percent < 0) {
result.isTempCancel(false).enacted(false).success(false).comment(R.string.invalidinput); result.isTempCancel(false).enacted(false).success(false).comment(R.string.invalidinput);
@ -269,7 +268,7 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump
int durationInHalfHours = Math.max(durationInMinutes / 30, 1); int durationInHalfHours = Math.max(durationInMinutes / 30, 1);
insulin = Round.INSTANCE.roundTo(insulin, getPumpDescription().getExtendedBolusStep()); insulin = Round.INSTANCE.roundTo(insulin, getPumpDescription().getExtendedBolusStep());
PumpEnactResult result = new PumpEnactResultObject(getInjector()); PumpEnactResult result = new PumpEnactResult(getInjector());
if (danaPump.isExtendedInProgress() && Math.abs(danaPump.getExtendedBolusAmount() - insulin) < getPumpDescription().getExtendedBolusStep()) { if (danaPump.isExtendedInProgress() && Math.abs(danaPump.getExtendedBolusAmount() - insulin) < getPumpDescription().getExtendedBolusStep()) {
result.enacted(false) result.enacted(false)
.success(true) .success(true)
@ -320,7 +319,7 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump
@NonNull @Override @NonNull @Override
public PumpEnactResult cancelExtendedBolus() { public PumpEnactResult cancelExtendedBolus() {
PumpEnactResult result = new PumpEnactResultObject(getInjector()); PumpEnactResult result = new PumpEnactResult(getInjector());
if (danaPump.isExtendedInProgress()) { if (danaPump.isExtendedInProgress()) {
sExecutionService.extendedBolusStop(); sExecutionService.extendedBolusStop();
if (!danaPump.isExtendedInProgress()) { if (!danaPump.isExtendedInProgress()) {

View file

@ -14,7 +14,6 @@ import javax.inject.Singleton;
import dagger.android.HasAndroidInjector; import dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.dana.DanaPump; import info.nightscout.androidaps.dana.DanaPump;
import info.nightscout.androidaps.danar.services.DanaRExecutionService; import info.nightscout.androidaps.danar.services.DanaRExecutionService;
import info.nightscout.androidaps.data.PumpEnactResultObject;
import info.nightscout.core.fabric.FabricPrivacy; import info.nightscout.core.fabric.FabricPrivacy;
import info.nightscout.interfaces.constraints.Constraint; import info.nightscout.interfaces.constraints.Constraint;
import info.nightscout.interfaces.constraints.Constraints; import info.nightscout.interfaces.constraints.Constraints;
@ -165,7 +164,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
boolean connectionOK = false; boolean connectionOK = false;
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0)
connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) detailedBolusInfo.carbs, detailedBolusInfo.getCarbsTimestamp() != null ? detailedBolusInfo.getCarbsTimestamp() : detailedBolusInfo.timestamp, t); connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) detailedBolusInfo.carbs, detailedBolusInfo.getCarbsTimestamp() != null ? detailedBolusInfo.getCarbsTimestamp() : detailedBolusInfo.timestamp, t);
PumpEnactResult result = new PumpEnactResultObject(getInjector()); PumpEnactResult result = new PumpEnactResult(getInjector());
result.success(connectionOK && Math.abs(detailedBolusInfo.insulin - t.getInsulin()) < pumpDescription.getBolusStep()) result.success(connectionOK && Math.abs(detailedBolusInfo.insulin - t.getInsulin()) < pumpDescription.getBolusStep())
.bolusDelivered(t.getInsulin()) .bolusDelivered(t.getInsulin())
.carbsDelivered(detailedBolusInfo.carbs); .carbsDelivered(detailedBolusInfo.carbs);
@ -193,7 +192,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
serialNumber()); serialNumber());
return result; return result;
} else { } else {
PumpEnactResult result = new PumpEnactResultObject(getInjector()); PumpEnactResult result = new PumpEnactResult(getInjector());
result.success(false).bolusDelivered(0d).carbsDelivered(0d).comment(R.string.invalidinput); result.success(false).bolusDelivered(0d).carbsDelivered(0d).comment(R.string.invalidinput);
aapsLogger.error("deliverTreatment: Invalid input"); aapsLogger.error("deliverTreatment: Invalid input");
return result; return result;
@ -205,7 +204,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
public PumpEnactResult setTempBasalAbsolute(double absoluteRate, int durationInMinutes, @NonNull Profile profile, boolean enforceNew, @NonNull PumpSync.TemporaryBasalType tbrType) { public PumpEnactResult setTempBasalAbsolute(double absoluteRate, int durationInMinutes, @NonNull Profile profile, boolean enforceNew, @NonNull PumpSync.TemporaryBasalType tbrType) {
// Recheck pump status if older than 30 min // Recheck pump status if older than 30 min
//This should not be needed while using queue because connection should be done before calling this //This should not be needed while using queue because connection should be done before calling this
PumpEnactResult result = new PumpEnactResultObject(getInjector()); PumpEnactResult result = new PumpEnactResult(getInjector());
absoluteRate = constraints.applyBasalConstraints(new Constraint<>(absoluteRate), profile).value(); absoluteRate = constraints.applyBasalConstraints(new Constraint<>(absoluteRate), profile).value();
@ -327,7 +326,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
if (danaPump.isExtendedInProgress() && useExtendedBoluses) { if (danaPump.isExtendedInProgress() && useExtendedBoluses) {
return cancelExtendedBolus(); return cancelExtendedBolus();
} }
PumpEnactResult result = new PumpEnactResultObject(getInjector()); PumpEnactResult result = new PumpEnactResult(getInjector());
result.success(true).enacted(false).comment(R.string.ok).isTempCancel(true); result.success(true).enacted(false).comment(R.string.ok).isTempCancel(true);
return result; return result;
} }
@ -338,7 +337,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
} }
private PumpEnactResult cancelRealTempBasal() { private PumpEnactResult cancelRealTempBasal() {
PumpEnactResult result = new PumpEnactResultObject(getInjector()); PumpEnactResult result = new PumpEnactResult(getInjector());
if (danaPump.isTempBasalInProgress()) { if (danaPump.isTempBasalInProgress()) {
sExecutionService.tempBasalStop(); sExecutionService.tempBasalStop();
if (!danaPump.isTempBasalInProgress()) { if (!danaPump.isTempBasalInProgress()) {
@ -360,7 +359,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
@NonNull @Override @NonNull @Override
public PumpEnactResult loadEvents() { public PumpEnactResult loadEvents() {
return new PumpEnactResultObject(getInjector()); // no history, not needed return new PumpEnactResult(getInjector()); // no history, not needed
} }
@NonNull @Override @NonNull @Override

View file

@ -39,7 +39,6 @@ import info.nightscout.androidaps.danar.comm.MsgHistoryRefill;
import info.nightscout.androidaps.danar.comm.MsgHistorySuspend; import info.nightscout.androidaps.danar.comm.MsgHistorySuspend;
import info.nightscout.androidaps.danar.comm.MsgPCCommStart; import info.nightscout.androidaps.danar.comm.MsgPCCommStart;
import info.nightscout.androidaps.danar.comm.MsgPCCommStop; import info.nightscout.androidaps.danar.comm.MsgPCCommStop;
import info.nightscout.androidaps.data.PumpEnactResultObject;
import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
import info.nightscout.androidaps.utils.ToastUtils; import info.nightscout.androidaps.utils.ToastUtils;
@ -242,7 +241,7 @@ public abstract class AbstractDanaRExecutionService extends DaggerService {
} }
public PumpEnactResult loadHistory(byte type) { public PumpEnactResult loadHistory(byte type) {
PumpEnactResult result = new PumpEnactResultObject(injector); PumpEnactResult result = new PumpEnactResult(injector);
if (!isConnected()) return result; if (!isConnected()) return result;
MessageBase msg = null; MessageBase msg = null;
switch (type) { switch (type) {

View file

@ -43,7 +43,6 @@ import info.nightscout.androidaps.danar.comm.MsgStatus;
import info.nightscout.androidaps.danar.comm.MsgStatusBasic; import info.nightscout.androidaps.danar.comm.MsgStatusBasic;
import info.nightscout.androidaps.danar.comm.MsgStatusBolusExtended; import info.nightscout.androidaps.danar.comm.MsgStatusBolusExtended;
import info.nightscout.androidaps.danar.comm.MsgStatusTempBasal; import info.nightscout.androidaps.danar.comm.MsgStatusTempBasal;
import info.nightscout.androidaps.data.PumpEnactResultObject;
import info.nightscout.androidaps.dialogs.BolusProgressDialog; import info.nightscout.androidaps.dialogs.BolusProgressDialog;
import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
@ -397,11 +396,11 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
public PumpEnactResult setUserOptions() { public PumpEnactResult setUserOptions() {
if (!isConnected()) if (!isConnected())
return new PumpEnactResultObject(injector).success(false); return new PumpEnactResult(injector).success(false);
SystemClock.sleep(300); SystemClock.sleep(300);
MsgSetUserOptions msg = new MsgSetUserOptions(injector); MsgSetUserOptions msg = new MsgSetUserOptions(injector);
mSerialIOThread.sendMessage(msg); mSerialIOThread.sendMessage(msg);
SystemClock.sleep(200); SystemClock.sleep(200);
return new PumpEnactResultObject(injector).success(!msg.getFailed()); return new PumpEnactResult(injector).success(!msg.getFailed());
} }
} }

View file

@ -1,7 +1,6 @@
package info.nightscout.androidaps package info.nightscout.androidaps
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.pump.DetailedBolusInfo import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.pump.Pump import info.nightscout.interfaces.pump.Pump
@ -44,26 +43,26 @@ class TestPumpPlugin(val injector: HasAndroidInjector) : Pump {
override fun waitForDisconnectionInSeconds(): Int = 0 override fun waitForDisconnectionInSeconds(): Int = 0
override fun getPumpStatus(reason: String) {} override fun getPumpStatus(reason: String) {}
override fun setNewBasalProfile(profile: Profile): PumpEnactResult = PumpEnactResultObject(injector) override fun setNewBasalProfile(profile: Profile): PumpEnactResult = PumpEnactResult(injector)
override fun isThisProfileSet(profile: Profile): Boolean = isProfileSet override fun isThisProfileSet(profile: Profile): Boolean = isProfileSet
override fun lastDataTime(): Long = lastData override fun lastDataTime(): Long = lastData
override val baseBasalRate: Double = baseBasal override val baseBasalRate: Double = baseBasal
override val reservoirLevel: Double = 0.0 override val reservoirLevel: Double = 0.0
override val batteryLevel: Int = 0 override val batteryLevel: Int = 0
override fun deliverTreatment(detailedBolusInfo: DetailedBolusInfo): PumpEnactResult = PumpEnactResultObject(injector).success(true) override fun deliverTreatment(detailedBolusInfo: DetailedBolusInfo): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun stopBolusDelivering() {} override fun stopBolusDelivering() {}
override fun setTempBasalAbsolute(absoluteRate: Double, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult = PumpEnactResultObject(injector).success(true) override fun setTempBasalAbsolute(absoluteRate: Double, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun setTempBasalPercent(percent: Int, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult = PumpEnactResultObject(injector).success(true) override fun setTempBasalPercent(percent: Int, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun setExtendedBolus(insulin: Double, durationInMinutes: Int): PumpEnactResult = PumpEnactResultObject(injector).success(true) override fun setExtendedBolus(insulin: Double, durationInMinutes: Int): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult = PumpEnactResultObject(injector).success(true) override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun cancelExtendedBolus(): PumpEnactResult = PumpEnactResultObject(injector).success(true) override fun cancelExtendedBolus(): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun getJSONStatus(profile: Profile, profileName: String, version: String): JSONObject = JSONObject() override fun getJSONStatus(profile: Profile, profileName: String, version: String): JSONObject = JSONObject()
override fun manufacturer(): ManufacturerType = ManufacturerType.AAPS override fun manufacturer(): ManufacturerType = ManufacturerType.AAPS
override fun model(): PumpType = PumpType.GENERIC_AAPS override fun model(): PumpType = PumpType.GENERIC_AAPS
override fun serialNumber(): String = "1" override fun serialNumber(): String = "1"
override fun shortStatus(veryShort: Boolean): String = "" override fun shortStatus(veryShort: Boolean): String = ""
override val isFakingTempsByExtendedBoluses: Boolean = false override val isFakingTempsByExtendedBoluses: Boolean = false
override fun loadTDDs(): PumpEnactResult = PumpEnactResultObject(injector).success(true) override fun loadTDDs(): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun canHandleDST(): Boolean = true override fun canHandleDST(): Boolean = true
override fun timezoneOrDSTChanged(timeChangeType: TimeChangeType) {} override fun timezoneOrDSTChanged(timeChangeType: TimeChangeType) {}
} }

View file

@ -13,7 +13,6 @@ import info.nightscout.androidaps.dana.DanaPump
import info.nightscout.androidaps.dana.comm.RecordTypes import info.nightscout.androidaps.dana.comm.RecordTypes
import info.nightscout.androidaps.danars.events.EventDanaRSDeviceChange import info.nightscout.androidaps.danars.events.EventDanaRSDeviceChange
import info.nightscout.androidaps.danars.services.DanaRSService import info.nightscout.androidaps.danars.services.DanaRSService
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.extensions.convertedToAbsolute import info.nightscout.androidaps.extensions.convertedToAbsolute
import info.nightscout.androidaps.extensions.plannedRemainingMinutes import info.nightscout.androidaps.extensions.plannedRemainingMinutes
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification
@ -186,15 +185,15 @@ class DanaRSPlugin @Inject constructor(
// DanaR interface // DanaR interface
override fun loadHistory(type: Byte): PumpEnactResult { override fun loadHistory(type: Byte): PumpEnactResult {
return danaRSService?.loadHistory(type) ?: PumpEnactResultObject(injector).success(false) return danaRSService?.loadHistory(type) ?: PumpEnactResult(injector).success(false)
} }
override fun loadEvents(): PumpEnactResult { override fun loadEvents(): PumpEnactResult {
return danaRSService?.loadEvents() ?: PumpEnactResultObject(injector).success(false) return danaRSService?.loadEvents() ?: PumpEnactResult(injector).success(false)
} }
override fun setUserOptions(): PumpEnactResult { override fun setUserOptions(): PumpEnactResult {
return danaRSService?.setUserSettings() ?: PumpEnactResultObject(injector).success(false) return danaRSService?.setUserSettings() ?: PumpEnactResult(injector).success(false)
} }
// Constraints interface // Constraints interface
@ -229,7 +228,7 @@ class DanaRSPlugin @Inject constructor(
danaRSService?.isConnected ?: false || danaRSService?.isConnecting ?: false danaRSService?.isConnected ?: false || danaRSService?.isConnecting ?: false
override fun setNewBasalProfile(profile: Profile): PumpEnactResult { override fun setNewBasalProfile(profile: Profile): PumpEnactResult {
val result = PumpEnactResultObject(injector) val result = PumpEnactResult(injector)
if (!isInitialized()) { if (!isInitialized()) {
aapsLogger.error("setNewBasalProfile not initialized") aapsLogger.error("setNewBasalProfile not initialized")
val notification = Notification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED, rh.gs(R.string.pumpNotInitializedProfileNotSet), Notification.URGENT) val notification = Notification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED, rh.gs(R.string.pumpNotInitializedProfileNotSet), Notification.URGENT)
@ -305,7 +304,7 @@ class DanaRSPlugin @Inject constructor(
var connectionOK = false var connectionOK = false
if (detailedBolusInfo.insulin > 0 || carbs > 0) connectionOK = danaRSService?.bolus(detailedBolusInfo.insulin, carbs.toInt(), carbTimeStamp, t) if (detailedBolusInfo.insulin > 0 || carbs > 0) connectionOK = danaRSService?.bolus(detailedBolusInfo.insulin, carbs.toInt(), carbTimeStamp, t)
?: false ?: false
val result = PumpEnactResultObject(injector) val result = PumpEnactResult(injector)
result.success = connectionOK && abs(detailedBolusInfo.insulin - t.insulin) < pumpDescription.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
@ -322,7 +321,7 @@ class DanaRSPlugin @Inject constructor(
aapsLogger.debug(LTag.PUMP, "deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered) aapsLogger.debug(LTag.PUMP, "deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered)
result result
} else { } else {
val result = PumpEnactResultObject(injector) val result = PumpEnactResult(injector)
result.success = false result.success = false
result.bolusDelivered = 0.0 result.bolusDelivered = 0.0
result.carbsDelivered = 0.0 result.carbsDelivered = 0.0
@ -364,7 +363,7 @@ class DanaRSPlugin @Inject constructor(
return cancelTempBasal(false) return cancelTempBasal(false)
} }
aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: doTempOff OK") aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: doTempOff OK")
return PumpEnactResultObject(injector) return PumpEnactResult(injector)
.success(true) .success(true)
.enacted(false) .enacted(false)
.percent(100) .percent(100)
@ -379,7 +378,7 @@ class DanaRSPlugin @Inject constructor(
if (danaPump.tempBasalPercent == percentRate && danaPump.tempBasalRemainingMin > 4) { if (danaPump.tempBasalPercent == percentRate && danaPump.tempBasalRemainingMin > 4) {
if (!enforceNew) { if (!enforceNew) {
aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: Correct temp basal already set (doLowTemp || doHighTemp)") aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: Correct temp basal already set (doLowTemp || doHighTemp)")
return PumpEnactResultObject(injector) return PumpEnactResult(injector)
.success(true) .success(true)
.percent(percentRate) .percent(percentRate)
.enacted(false) .enacted(false)
@ -407,14 +406,14 @@ class DanaRSPlugin @Inject constructor(
} }
// We should never end here // We should never end here
aapsLogger.error("setTempBasalAbsolute: Internal error") aapsLogger.error("setTempBasalAbsolute: Internal error")
return PumpEnactResultObject(injector) return PumpEnactResult(injector)
.success(false) .success(false)
.comment("Internal error") .comment("Internal error")
} }
@Synchronized @Synchronized
override fun setTempBasalPercent(percent: Int, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult { override fun setTempBasalPercent(percent: Int, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult {
val result = PumpEnactResultObject(injector) val result = PumpEnactResult(injector)
var percentAfterConstraint = constraintChecker.applyBasalPercentConstraints(Constraint(percent), profile).value() var percentAfterConstraint = constraintChecker.applyBasalPercentConstraints(Constraint(percent), profile).value()
if (percentAfterConstraint < 0) { if (percentAfterConstraint < 0) {
result.isTempCancel = false result.isTempCancel = false
@ -463,7 +462,7 @@ class DanaRSPlugin @Inject constructor(
} }
@Synchronized private fun setHighTempBasalPercent(percent: Int): PumpEnactResult { @Synchronized private fun setHighTempBasalPercent(percent: Int): PumpEnactResult {
val result = PumpEnactResultObject(injector) val result = PumpEnactResult(injector)
val connectionOK = danaRSService?.highTempBasal(percent) ?: false val connectionOK = danaRSService?.highTempBasal(percent) ?: false
if (connectionOK && danaPump.isTempBasalInProgress && danaPump.tempBasalPercent == percent) { if (connectionOK && danaPump.isTempBasalInProgress && danaPump.tempBasalPercent == percent) {
result.enacted = true result.enacted = true
@ -489,7 +488,7 @@ class DanaRSPlugin @Inject constructor(
// needs to be rounded // needs to be rounded
val durationInHalfHours = max(durationInMinutes / 30, 1) val durationInHalfHours = max(durationInMinutes / 30, 1)
insulinAfterConstraint = Round.roundTo(insulinAfterConstraint, pumpDescription.extendedBolusStep) insulinAfterConstraint = Round.roundTo(insulinAfterConstraint, pumpDescription.extendedBolusStep)
val result = PumpEnactResultObject(injector) val result = PumpEnactResult(injector)
if (danaPump.isExtendedInProgress && abs(danaPump.extendedBolusAmount - insulinAfterConstraint) < pumpDescription.extendedBolusStep) { if (danaPump.isExtendedInProgress && abs(danaPump.extendedBolusAmount - insulinAfterConstraint) < pumpDescription.extendedBolusStep) {
result.enacted = false result.enacted = false
result.success = true result.success = true
@ -524,7 +523,7 @@ class DanaRSPlugin @Inject constructor(
@Synchronized @Synchronized
override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult { override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult {
val result = PumpEnactResultObject(injector) val result = PumpEnactResult(injector)
if (danaPump.isTempBasalInProgress) { if (danaPump.isTempBasalInProgress) {
danaRSService?.tempBasalStop() danaRSService?.tempBasalStop()
result.success = !danaPump.isTempBasalInProgress result.success = !danaPump.isTempBasalInProgress
@ -541,7 +540,7 @@ class DanaRSPlugin @Inject constructor(
} }
@Synchronized override fun cancelExtendedBolus(): PumpEnactResult { @Synchronized override fun cancelExtendedBolus(): PumpEnactResult {
val result = PumpEnactResultObject(injector) val result = PumpEnactResult(injector)
if (danaPump.isExtendedInProgress) { if (danaPump.isExtendedInProgress) {
danaRSService?.extendedBolusStop() danaRSService?.extendedBolusStop()
result.success = !danaPump.isExtendedInProgress result.success = !danaPump.isExtendedInProgress

View file

@ -54,7 +54,6 @@ import info.nightscout.androidaps.danars.comm.DanaRSPacketOptionGetUserOption
import info.nightscout.androidaps.danars.comm.DanaRSPacketOptionSetPumpTime import info.nightscout.androidaps.danars.comm.DanaRSPacketOptionSetPumpTime
import info.nightscout.androidaps.danars.comm.DanaRSPacketOptionSetPumpUTCAndTimeZone import info.nightscout.androidaps.danars.comm.DanaRSPacketOptionSetPumpUTCAndTimeZone
import info.nightscout.androidaps.danars.comm.DanaRSPacketOptionSetUserOption import info.nightscout.androidaps.danars.comm.DanaRSPacketOptionSetUserOption
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.dialogs.BolusProgressDialog import info.nightscout.androidaps.dialogs.BolusProgressDialog
import info.nightscout.androidaps.events.EventPumpStatusChanged import info.nightscout.androidaps.events.EventPumpStatusChanged
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
@ -261,7 +260,7 @@ class DanaRSService : DaggerService() {
fun loadEvents(): PumpEnactResult { fun loadEvents(): PumpEnactResult {
if (!danaRSPlugin.isInitialized()) { if (!danaRSPlugin.isInitialized()) {
val result = PumpEnactResultObject(injector).success(false) val result = PumpEnactResult(injector).success(false)
result.comment = "pump not initialized" result.comment = "pump not initialized"
return result return result
} }
@ -283,13 +282,13 @@ class DanaRSService : DaggerService() {
rxBus.send(EventPumpStatusChanged(rh.gs(R.string.gettingpumpstatus))) rxBus.send(EventPumpStatusChanged(rh.gs(R.string.gettingpumpstatus)))
sendMessage(DanaRSPacketGeneralInitialScreenInformation(injector)) sendMessage(DanaRSPacketGeneralInitialScreenInformation(injector))
danaPump.lastConnection = System.currentTimeMillis() danaPump.lastConnection = System.currentTimeMillis()
return PumpEnactResultObject(injector).success(msg.success()) return PumpEnactResult(injector).success(msg.success())
} }
fun setUserSettings(): PumpEnactResult { fun setUserSettings(): PumpEnactResult {
val message = DanaRSPacketOptionSetUserOption(injector) val message = DanaRSPacketOptionSetUserOption(injector)
sendMessage(message) sendMessage(message)
return PumpEnactResultObject(injector).success(message.success()) return PumpEnactResult(injector).success(message.success())
} }
fun bolus(insulin: Double, carbs: Int, carbTime: Long, t: EventOverviewBolusProgress.Treatment): Boolean { fun bolus(insulin: Double, carbs: Int, carbTime: Long, t: EventOverviewBolusProgress.Treatment): Boolean {
@ -499,7 +498,7 @@ class DanaRSService : DaggerService() {
} }
fun loadHistory(type: Byte): PumpEnactResult { fun loadHistory(type: Byte): PumpEnactResult {
val result = PumpEnactResultObject(injector) val result = PumpEnactResult(injector)
if (!isConnected) return result if (!isConnected) return result
var msg: DanaRSPacketHistory? = null var msg: DanaRSPacketHistory? = null
when (type) { when (type) {

View file

@ -9,7 +9,6 @@ import android.text.format.DateFormat
import androidx.preference.Preference import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceFragmentCompat
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.diaconn.events.EventDiaconnG8DeviceChange import info.nightscout.androidaps.diaconn.events.EventDiaconnG8DeviceChange
import info.nightscout.androidaps.diaconn.service.DiaconnG8Service import info.nightscout.androidaps.diaconn.service.DiaconnG8Service
import info.nightscout.androidaps.extensions.convertedToAbsolute import info.nightscout.androidaps.extensions.convertedToAbsolute
@ -174,11 +173,11 @@ class DiaconnG8Plugin @Inject constructor(
// Diaconn Pump Interface // Diaconn Pump Interface
override fun loadHistory(): PumpEnactResult { override fun loadHistory(): PumpEnactResult {
return diaconnG8Service?.loadHistory() ?: PumpEnactResultObject(injector).success(false) return diaconnG8Service?.loadHistory() ?: PumpEnactResult(injector).success(false)
} }
override fun setUserOptions(): PumpEnactResult { override fun setUserOptions(): PumpEnactResult {
return diaconnG8Service?.setUserSettings() ?: PumpEnactResultObject(injector).success(false) return diaconnG8Service?.setUserSettings() ?: PumpEnactResult(injector).success(false)
} }
// Constraints interface // Constraints interface
@ -213,7 +212,7 @@ class DiaconnG8Plugin @Inject constructor(
diaconnG8Service?.isConnected ?: false || diaconnG8Service?.isConnecting ?: false diaconnG8Service?.isConnected ?: false || diaconnG8Service?.isConnecting ?: false
override fun setNewBasalProfile(profile: Profile): PumpEnactResult { override fun setNewBasalProfile(profile: Profile): PumpEnactResult {
val result = PumpEnactResultObject(injector) val result = PumpEnactResult(injector)
if (!isInitialized()) { if (!isInitialized()) {
val notification = Notification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED, rh.gs(R.string.pumpNotInitializedProfileNotSet), Notification.URGENT) val notification = Notification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED, rh.gs(R.string.pumpNotInitializedProfileNotSet), Notification.URGENT)
rxBus.send(EventNewNotification(notification)) rxBus.send(EventNewNotification(notification))
@ -277,7 +276,7 @@ class DiaconnG8Plugin @Inject constructor(
var connectionOK = false var connectionOK = false
if (detailedBolusInfo.insulin > 0 || carbs > 0) connectionOK = diaconnG8Service?.bolus(detailedBolusInfo.insulin, carbs.toInt(), carbTimeStamp, t) if (detailedBolusInfo.insulin > 0 || carbs > 0) connectionOK = diaconnG8Service?.bolus(detailedBolusInfo.insulin, carbs.toInt(), carbTimeStamp, t)
?: false ?: false
val result = PumpEnactResultObject(injector) val result = PumpEnactResult(injector)
result.success = connectionOK result.success = connectionOK
result.bolusDelivered = t.insulin result.bolusDelivered = t.insulin
result.carbsDelivered = detailedBolusInfo.carbs result.carbsDelivered = detailedBolusInfo.carbs
@ -289,7 +288,7 @@ class DiaconnG8Plugin @Inject constructor(
aapsLogger.debug(LTag.PUMP, "deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered) aapsLogger.debug(LTag.PUMP, "deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered)
result result
} else { } else {
val result = PumpEnactResultObject(injector) val result = PumpEnactResult(injector)
result.success = false result.success = false
result.bolusDelivered = 0.0 result.bolusDelivered = 0.0
result.carbsDelivered = 0.0 result.carbsDelivered = 0.0
@ -306,7 +305,7 @@ class DiaconnG8Plugin @Inject constructor(
// This is called from APS // This is called from APS
@Synchronized @Synchronized
override fun setTempBasalAbsolute(absoluteRate: Double, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult { override fun setTempBasalAbsolute(absoluteRate: Double, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult {
val result = PumpEnactResultObject(injector) val result = PumpEnactResult(injector)
val absoluteAfterConstrain = constraintChecker.applyBasalConstraints(Constraint(absoluteRate), profile).value() val absoluteAfterConstrain = constraintChecker.applyBasalConstraints(Constraint(absoluteRate), profile).value()
val doTempOff = baseBasalRate - absoluteAfterConstrain == 0.0 val doTempOff = baseBasalRate - absoluteAfterConstrain == 0.0
val doLowTemp = absoluteAfterConstrain < baseBasalRate val doLowTemp = absoluteAfterConstrain < baseBasalRate
@ -397,7 +396,7 @@ class DiaconnG8Plugin @Inject constructor(
var insulinAfterConstraint = constraintChecker.applyExtendedBolusConstraints(Constraint(insulin)).value() var insulinAfterConstraint = constraintChecker.applyExtendedBolusConstraints(Constraint(insulin)).value()
// needs to be rounded // needs to be rounded
insulinAfterConstraint = Round.roundTo(insulinAfterConstraint, pumpDescription.extendedBolusStep) insulinAfterConstraint = Round.roundTo(insulinAfterConstraint, pumpDescription.extendedBolusStep)
val result = PumpEnactResultObject(injector) val result = PumpEnactResult(injector)
if (diaconnG8Pump.isExtendedInProgress && abs(diaconnG8Pump.extendedBolusAmount - insulinAfterConstraint) < pumpDescription.extendedBolusStep) { if (diaconnG8Pump.isExtendedInProgress && abs(diaconnG8Pump.extendedBolusAmount - insulinAfterConstraint) < pumpDescription.extendedBolusStep) {
result.enacted = false result.enacted = false
@ -435,7 +434,7 @@ class DiaconnG8Plugin @Inject constructor(
@Synchronized @Synchronized
override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult { override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult {
val result = PumpEnactResultObject(injector) val result = PumpEnactResult(injector)
if (diaconnG8Pump.isTempBasalInProgress) { if (diaconnG8Pump.isTempBasalInProgress) {
diaconnG8Service?.tempBasalStop() diaconnG8Service?.tempBasalStop()
result.success = !diaconnG8Pump.isTempBasalInProgress result.success = !diaconnG8Pump.isTempBasalInProgress
@ -453,7 +452,7 @@ class DiaconnG8Plugin @Inject constructor(
} }
@Synchronized override fun cancelExtendedBolus(): PumpEnactResult { @Synchronized override fun cancelExtendedBolus(): PumpEnactResult {
val result = PumpEnactResultObject(injector) val result = PumpEnactResult(injector)
if (diaconnG8Pump.isExtendedInProgress) { if (diaconnG8Pump.isExtendedInProgress) {
diaconnG8Service?.extendedBolusStop() diaconnG8Service?.extendedBolusStop()
result.success = !diaconnG8Pump.isExtendedInProgress result.success = !diaconnG8Pump.isExtendedInProgress

View file

@ -8,7 +8,6 @@ import android.os.IBinder
import android.os.SystemClock import android.os.SystemClock
import dagger.android.DaggerService import dagger.android.DaggerService
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.diaconn.DiaconnG8Plugin import info.nightscout.androidaps.diaconn.DiaconnG8Plugin
import info.nightscout.androidaps.diaconn.DiaconnG8Pump import info.nightscout.androidaps.diaconn.DiaconnG8Pump
import info.nightscout.androidaps.diaconn.R import info.nightscout.androidaps.diaconn.R
@ -269,7 +268,7 @@ class DiaconnG8Service : DaggerService() {
fun loadHistory(): PumpEnactResult { fun loadHistory(): PumpEnactResult {
if (!diaconnG8Plugin.isInitialized()) { if (!diaconnG8Plugin.isInitialized()) {
val result = PumpEnactResultObject(injector).success(false) val result = PumpEnactResult(injector).success(false)
result.comment = "pump not initialized" result.comment = "pump not initialized"
return result return result
} }
@ -279,7 +278,7 @@ class DiaconnG8Service : DaggerService() {
sendMessage(IncarnationInquirePacket(injector)) sendMessage(IncarnationInquirePacket(injector))
} }
val result = PumpEnactResultObject(injector) val result = PumpEnactResult(injector)
var apsLastLogNum = 9999 var apsLastLogNum = 9999
var apsWrappingCount = -1 var apsWrappingCount = -1
// get saved last loginfo // get saved last loginfo
@ -421,7 +420,7 @@ class DiaconnG8Service : DaggerService() {
} }
fun setUserSettings(): PumpEnactResult { fun setUserSettings(): PumpEnactResult {
val result = PumpEnactResultObject(injector) val result = PumpEnactResult(injector)
val msg: DiaconnG8Packet = when (diaconnG8Pump.setUserOptionType) { val msg: DiaconnG8Packet = when (diaconnG8Pump.setUserOptionType) {
DiaconnG8Pump.ALARM -> SoundSettingPacket(injector, diaconnG8Pump.beepAndAlarm, diaconnG8Pump.alarmIntesity) DiaconnG8Pump.ALARM -> SoundSettingPacket(injector, diaconnG8Pump.beepAndAlarm, diaconnG8Pump.alarmIntesity)

View file

@ -2,7 +2,6 @@ package info.nightscout.androidaps.plugins.pump.eopatch
import android.os.SystemClock import android.os.SystemClock
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
import info.nightscout.androidaps.plugins.pump.eopatch.alarm.IAlarmManager import info.nightscout.androidaps.plugins.pump.eopatch.alarm.IAlarmManager
import info.nightscout.androidaps.plugins.pump.eopatch.ble.IPatchManager import info.nightscout.androidaps.plugins.pump.eopatch.ble.IPatchManager
@ -177,7 +176,7 @@ class EopatchPumpPlugin @Inject constructor(
mLastDataTime = System.currentTimeMillis() mLastDataTime = System.currentTimeMillis()
if (patchManager.isActivated) { if (patchManager.isActivated) {
if (patchManager.patchState.isTempBasalActive || patchManager.patchState.isBolusActive) { if (patchManager.patchState.isTempBasalActive || patchManager.patchState.isBolusActive) {
return PumpEnactResultObject(injector) return PumpEnactResult(injector)
} else { } else {
var isSuccess: Boolean? = null var isSuccess: Boolean? = null
val result: BehaviorSubject<Boolean> = BehaviorSubject.create() val result: BehaviorSubject<Boolean> = BehaviorSubject.create()
@ -205,16 +204,16 @@ class EopatchPumpPlugin @Inject constructor(
aapsLogger.info(LTag.PUMP, "Basal Profile was set: ${isSuccess ?: false}") aapsLogger.info(LTag.PUMP, "Basal Profile was set: ${isSuccess ?: false}")
if (isSuccess == true) { if (isSuccess == true) {
rxBus.send(EventNewNotification(Notification(Notification.PROFILE_SET_OK, rh.gs(R.string.profile_set_ok), Notification.INFO, 60))) rxBus.send(EventNewNotification(Notification(Notification.PROFILE_SET_OK, rh.gs(R.string.profile_set_ok), Notification.INFO, 60)))
return PumpEnactResultObject(injector).success(true).enacted(true) return PumpEnactResult(injector).success(true).enacted(true)
} else { } else {
return PumpEnactResultObject(injector) return PumpEnactResult(injector)
} }
} }
} else { } else {
preferenceManager.getNormalBasalManager().setNormalBasal(profile) preferenceManager.getNormalBasalManager().setNormalBasal(profile)
preferenceManager.flushNormalBasalManager() preferenceManager.flushNormalBasalManager()
rxBus.send(EventNewNotification(Notification(Notification.PROFILE_SET_OK, rh.gs(R.string.profile_set_ok), Notification.INFO, 60))) rxBus.send(EventNewNotification(Notification(Notification.PROFILE_SET_OK, rh.gs(R.string.profile_set_ok), Notification.INFO, 60)))
return PumpEnactResultObject(injector).success(true).enacted(true) return PumpEnactResult(injector).success(true).enacted(true)
} }
} }
@ -264,7 +263,7 @@ class EopatchPumpPlugin @Inject constructor(
if (detailedBolusInfo.insulin == 0.0 && detailedBolusInfo.carbs == 0.0) { if (detailedBolusInfo.insulin == 0.0 && detailedBolusInfo.carbs == 0.0) {
// neither carbs nor bolus requested // neither carbs nor bolus requested
aapsLogger.error("deliverTreatment: Invalid input: neither carbs nor insulin are set in treatment") aapsLogger.error("deliverTreatment: Invalid input: neither carbs nor insulin are set in treatment")
return PumpEnactResultObject(injector).success(false).enacted(false).bolusDelivered(0.0).carbsDelivered(0.0) return PumpEnactResult(injector).success(false).enacted(false).bolusDelivered(0.0).carbsDelivered(0.0)
.comment(rh.gs(R.string.invalidinput)) .comment(rh.gs(R.string.invalidinput))
} else if (detailedBolusInfo.insulin > 0.0) { } else if (detailedBolusInfo.insulin > 0.0) {
var isSuccess = true var isSuccess = true
@ -311,15 +310,15 @@ class EopatchPumpPlugin @Inject constructor(
disposable.dispose() disposable.dispose()
return if (isSuccess) return if (isSuccess)
PumpEnactResultObject(injector).success(true)/*.enacted(true)*/.carbsDelivered(detailedBolusInfo.carbs).bolusDelivered(detailedBolusInfo.insulin) PumpEnactResult(injector).success(true)/*.enacted(true)*/.carbsDelivered(detailedBolusInfo.carbs).bolusDelivered(detailedBolusInfo.insulin)
else else
PumpEnactResultObject(injector).success(false)/*.enacted(false)*/.carbsDelivered(0.0).bolusDelivered(detailedBolusInfo.insulin) PumpEnactResult(injector).success(false)/*.enacted(false)*/.carbsDelivered(0.0).bolusDelivered(detailedBolusInfo.insulin)
} else { } else {
// no bolus required, carb only treatment // no bolus required, carb only treatment
patchManager.addBolusToHistory(detailedBolusInfo) patchManager.addBolusToHistory(detailedBolusInfo)
return PumpEnactResultObject(injector).success(true).enacted(true).bolusDelivered(0.0) return PumpEnactResult(injector).success(true).enacted(true).bolusDelivered(0.0)
.carbsDelivered(detailedBolusInfo.carbs).comment(rh.gs(info.nightscout.core.main.R.string.ok)) .carbsDelivered(detailedBolusInfo.carbs).comment(rh.gs(info.nightscout.core.main.R.string.ok))
} }
} }
@ -357,15 +356,15 @@ class EopatchPumpPlugin @Inject constructor(
) )
aapsLogger.info(LTag.PUMP, "setTempBasalAbsolute - tbrCurrent:${readTBR()}") aapsLogger.info(LTag.PUMP, "setTempBasalAbsolute - tbrCurrent:${readTBR()}")
} }
.map { PumpEnactResultObject(injector).success(true).enacted(true).duration(durationInMinutes).absolute(absoluteRate).isPercent(false).isTempCancel(false) } .map { PumpEnactResult(injector).success(true).enacted(true).duration(durationInMinutes).absolute(absoluteRate).isPercent(false).isTempCancel(false) }
.onErrorReturnItem( .onErrorReturnItem(
PumpEnactResultObject(injector).success(false).enacted(false) PumpEnactResult(injector).success(false).enacted(false)
.comment("Internal error") .comment("Internal error")
) )
.blockingGet() .blockingGet()
} else { } else {
aapsLogger.info(LTag.PUMP, "setTempBasalAbsolute - normal basal is not active") aapsLogger.info(LTag.PUMP, "setTempBasalAbsolute - normal basal is not active")
return PumpEnactResultObject(injector).success(false).enacted(false) return PumpEnactResult(injector).success(false).enacted(false)
} }
} }
@ -390,15 +389,15 @@ class EopatchPumpPlugin @Inject constructor(
) )
aapsLogger.info(LTag.PUMP, "setTempBasalPercent - tbrCurrent:${readTBR()}") aapsLogger.info(LTag.PUMP, "setTempBasalPercent - tbrCurrent:${readTBR()}")
} }
.map { PumpEnactResultObject(injector).success(true).enacted(true).duration(durationInMinutes).percent(percent).isPercent(true).isTempCancel(false) } .map { PumpEnactResult(injector).success(true).enacted(true).duration(durationInMinutes).percent(percent).isPercent(true).isTempCancel(false) }
.onErrorReturnItem( .onErrorReturnItem(
PumpEnactResultObject(injector).success(false).enacted(false) PumpEnactResult(injector).success(false).enacted(false)
.comment("Internal error") .comment("Internal error")
) )
.blockingGet() .blockingGet()
} else { } else {
aapsLogger.info(LTag.PUMP, "setTempBasalPercent - normal basal is not active") aapsLogger.info(LTag.PUMP, "setTempBasalPercent - normal basal is not active")
return PumpEnactResultObject(injector).success(false).enacted(false) return PumpEnactResult(injector).success(false).enacted(false)
} }
} }
@ -418,9 +417,9 @@ class EopatchPumpPlugin @Inject constructor(
pumpSerial = serialNumber() pumpSerial = serialNumber()
) )
} }
.map { PumpEnactResultObject(injector).success(true).enacted(true) } .map { PumpEnactResult(injector).success(true).enacted(true) }
.onErrorReturnItem( .onErrorReturnItem(
PumpEnactResultObject(injector).success(false).enacted(false).bolusDelivered(0.0) PumpEnactResult(injector).success(false).enacted(false).bolusDelivered(0.0)
.comment(rh.gs(info.nightscout.core.main.R.string.error)) .comment(rh.gs(info.nightscout.core.main.R.string.error))
) )
.blockingGet() .blockingGet()
@ -431,14 +430,14 @@ class EopatchPumpPlugin @Inject constructor(
if (tbrCurrent == null) { if (tbrCurrent == null) {
aapsLogger.debug(LTag.PUMP, "cancelTempBasal - TBR already false.") aapsLogger.debug(LTag.PUMP, "cancelTempBasal - TBR already false.")
return PumpEnactResultObject(injector).success(true).enacted(false) return PumpEnactResult(injector).success(true).enacted(false)
} }
if (!patchManager.patchState.isTempBasalActive) { if (!patchManager.patchState.isTempBasalActive) {
return if (pumpSync.expectedPumpState().temporaryBasal != null) { return if (pumpSync.expectedPumpState().temporaryBasal != null) {
PumpEnactResultObject(injector).success(true).enacted(true).isTempCancel(true) PumpEnactResult(injector).success(true).enacted(true).isTempCancel(true)
} else } else
PumpEnactResultObject(injector).success(true).isTempCancel(true) PumpEnactResult(injector).success(true).isTempCancel(true)
} }
return patchManager.stopTempBasal() return patchManager.stopTempBasal()
@ -455,9 +454,9 @@ class EopatchPumpPlugin @Inject constructor(
.doOnError { .doOnError {
aapsLogger.error(LTag.PUMP, "cancelTempBasal() - $it") aapsLogger.error(LTag.PUMP, "cancelTempBasal() - $it")
} }
.map { PumpEnactResultObject(injector).success(true).enacted(true).isTempCancel(true) } .map { PumpEnactResult(injector).success(true).enacted(true).isTempCancel(true) }
.onErrorReturnItem( .onErrorReturnItem(
PumpEnactResultObject(injector).success(false).enacted(false) PumpEnactResult(injector).success(false).enacted(false)
.comment(rh.gs(info.nightscout.core.main.R.string.error)) .comment(rh.gs(info.nightscout.core.main.R.string.error))
) )
.blockingGet() .blockingGet()
@ -476,9 +475,9 @@ class EopatchPumpPlugin @Inject constructor(
pumpSerial = serialNumber() pumpSerial = serialNumber()
) )
} }
.map { PumpEnactResultObject(injector).success(true).enacted(true).isTempCancel(true) } .map { PumpEnactResult(injector).success(true).enacted(true).isTempCancel(true) }
.onErrorReturnItem( .onErrorReturnItem(
PumpEnactResultObject(injector).success(false).enacted(false) PumpEnactResult(injector).success(false).enacted(false)
.comment(rh.gs(info.nightscout.core.main.R.string.error)) .comment(rh.gs(info.nightscout.core.main.R.string.error))
) )
.blockingGet() .blockingGet()
@ -491,9 +490,9 @@ class EopatchPumpPlugin @Inject constructor(
pumpType = PumpType.EOFLOW_EOPATCH2, pumpType = PumpType.EOFLOW_EOPATCH2,
pumpSerial = serialNumber() pumpSerial = serialNumber()
) )
PumpEnactResultObject(injector).success(true).enacted(true).isTempCancel(true) PumpEnactResult(injector).success(true).enacted(true).isTempCancel(true)
} else } else
PumpEnactResultObject(injector) PumpEnactResult(injector)
} }
} }
@ -546,7 +545,7 @@ class EopatchPumpPlugin @Inject constructor(
override val isFakingTempsByExtendedBoluses: Boolean = false override val isFakingTempsByExtendedBoluses: Boolean = false
override fun loadTDDs(): PumpEnactResult { override fun loadTDDs(): PumpEnactResult {
return PumpEnactResultObject(injector) return PumpEnactResult(injector)
} }
override fun canHandleDST(): Boolean { override fun canHandleDST(): Boolean {

View file

@ -7,7 +7,6 @@ import android.os.IBinder
import android.os.SystemClock import android.os.SystemClock
import androidx.preference.Preference import androidx.preference.Preference
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
import info.nightscout.androidaps.plugins.pump.common.PumpPluginAbstract import info.nightscout.androidaps.plugins.pump.common.PumpPluginAbstract
import info.nightscout.androidaps.plugins.pump.common.data.PumpStatus import info.nightscout.androidaps.plugins.pump.common.data.PumpStatus
@ -592,7 +591,7 @@ class MedtronicPumpPlugin @Inject constructor(
aapsLogger.info(LTag.PUMP, "MedtronicPumpPlugin::deliverBolus - " + BolusDeliveryType.DeliveryPrepared) aapsLogger.info(LTag.PUMP, "MedtronicPumpPlugin::deliverBolus - " + BolusDeliveryType.DeliveryPrepared)
setRefreshButtonEnabled(false) setRefreshButtonEnabled(false)
if (detailedBolusInfo.insulin > medtronicPumpStatus.reservoirRemainingUnits) { if (detailedBolusInfo.insulin > medtronicPumpStatus.reservoirRemainingUnits) {
return PumpEnactResultObject(injector) // return PumpEnactResult(injector) //
.success(false) // .success(false) //
.enacted(false) // .enacted(false) //
.comment( .comment(
@ -633,7 +632,7 @@ class MedtronicPumpPlugin @Inject constructor(
// LOG.debug("MedtronicPumpPlugin::deliverBolus - Response: {}", response); // LOG.debug("MedtronicPumpPlugin::deliverBolus - Response: {}", response);
return if (response == null || !response) { return if (response == null || !response) {
PumpEnactResultObject(injector) // PumpEnactResult(injector) //
.success(bolusDeliveryType == BolusDeliveryType.CancelDelivery) // .success(bolusDeliveryType == BolusDeliveryType.CancelDelivery) //
.enacted(false) // .enacted(false) //
.comment(R.string.medtronic_cmd_bolus_could_not_be_delivered) .comment(R.string.medtronic_cmd_bolus_could_not_be_delivered)
@ -660,7 +659,7 @@ class MedtronicPumpPlugin @Inject constructor(
val time = now + bolusTime * 1000 val time = now + bolusTime * 1000
busyTimestamps.add(time) busyTimestamps.add(time)
setEnableCustomAction(MedtronicCustomActionType.ClearBolusBlock, true) setEnableCustomAction(MedtronicCustomActionType.ClearBolusBlock, true)
PumpEnactResultObject(injector).success(true) // PumpEnactResult(injector).success(true) //
.enacted(true) // .enacted(true) //
.bolusDelivered(detailedBolusInfo.insulin) // .bolusDelivered(detailedBolusInfo.insulin) //
.carbsDelivered(detailedBolusInfo.carbs) .carbsDelivered(detailedBolusInfo.carbs)
@ -677,8 +676,8 @@ class MedtronicPumpPlugin @Inject constructor(
private fun setNotReachable(isBolus: Boolean, success: Boolean): PumpEnactResult { private fun setNotReachable(isBolus: Boolean, success: Boolean): PumpEnactResult {
setRefreshButtonEnabled(true) setRefreshButtonEnabled(true)
if (isBolus) bolusDeliveryType = BolusDeliveryType.Idle if (isBolus) bolusDeliveryType = BolusDeliveryType.Idle
return if (success) PumpEnactResultObject(injector).success(true).enacted(false) return if (success) PumpEnactResult(injector).success(true).enacted(false)
else PumpEnactResultObject(injector).success(false).enacted(false).comment(R.string.medtronic_pump_status_pump_unreachable) else PumpEnactResult(injector).success(false).enacted(false).comment(R.string.medtronic_pump_status_pump_unreachable)
} }
override fun stopBolusDelivering() { override fun stopBolusDelivering() {
@ -701,7 +700,7 @@ class MedtronicPumpPlugin @Inject constructor(
setRefreshButtonEnabled(false) setRefreshButtonEnabled(false)
if (isPumpNotReachable) { if (isPumpNotReachable) {
setRefreshButtonEnabled(true) setRefreshButtonEnabled(true)
return PumpEnactResultObject(injector) // return PumpEnactResult(injector) //
.success(false) // .success(false) //
.enacted(false) // .enacted(false) //
.comment(R.string.medtronic_pump_status_pump_unreachable) .comment(R.string.medtronic_pump_status_pump_unreachable)
@ -714,7 +713,7 @@ class MedtronicPumpPlugin @Inject constructor(
if (tbrCurrent == null) { if (tbrCurrent == null) {
aapsLogger.warn(LTag.PUMP, logPrefix + "setTempBasalAbsolute - Could not read current TBR, canceling operation.") aapsLogger.warn(LTag.PUMP, logPrefix + "setTempBasalAbsolute - Could not read current TBR, canceling operation.")
finishAction("TBR") finishAction("TBR")
return PumpEnactResultObject(injector).success(false).enacted(false) return PumpEnactResult(injector).success(false).enacted(false)
.comment(R.string.medtronic_cmd_cant_read_tbr) .comment(R.string.medtronic_cmd_cant_read_tbr)
} else { } else {
aapsLogger.info(LTag.PUMP, logPrefix + "setTempBasalAbsolute: Current Basal: duration: " + tbrCurrent.durationMinutes + " min, rate=" + tbrCurrent.insulinRate) aapsLogger.info(LTag.PUMP, logPrefix + "setTempBasalAbsolute: Current Basal: duration: " + tbrCurrent.durationMinutes + " min, rate=" + tbrCurrent.insulinRate)
@ -729,7 +728,7 @@ class MedtronicPumpPlugin @Inject constructor(
if (sameRate) { if (sameRate) {
aapsLogger.info(LTag.PUMP, logPrefix + "setTempBasalAbsolute - No enforceNew and same rate. Exiting.") aapsLogger.info(LTag.PUMP, logPrefix + "setTempBasalAbsolute - No enforceNew and same rate. Exiting.")
finishAction("TBR") finishAction("TBR")
return PumpEnactResultObject(injector).success(true).enacted(false) return PumpEnactResult(injector).success(true).enacted(false)
} }
} }
// if not the same rate, we cancel and start new // if not the same rate, we cancel and start new
@ -745,7 +744,7 @@ class MedtronicPumpPlugin @Inject constructor(
if (response == null || !response) { if (response == null || !response) {
aapsLogger.error(logPrefix + "setTempBasalAbsolute - Cancel TBR failed.") aapsLogger.error(logPrefix + "setTempBasalAbsolute - Cancel TBR failed.")
finishAction("TBR") finishAction("TBR")
return PumpEnactResultObject(injector).success(false).enacted(false) return PumpEnactResult(injector).success(false).enacted(false)
.comment(R.string.medtronic_cmd_cant_cancel_tbr_stop_op) .comment(R.string.medtronic_cmd_cant_cancel_tbr_stop_op)
} else { } else {
//cancelTBRWithTemporaryId() //cancelTBRWithTemporaryId()
@ -762,7 +761,7 @@ class MedtronicPumpPlugin @Inject constructor(
aapsLogger.info(LTag.PUMP, logPrefix + "setTempBasalAbsolute - setTBR. Response: " + response) aapsLogger.info(LTag.PUMP, logPrefix + "setTempBasalAbsolute - setTBR. Response: " + response)
return if (response == null || !response) { return if (response == null || !response) {
finishAction("TBR") finishAction("TBR")
PumpEnactResultObject(injector).success(false).enacted(false) // PumpEnactResult(injector).success(false).enacted(false) //
.comment(R.string.medtronic_cmd_tbr_could_not_be_delivered) .comment(R.string.medtronic_cmd_tbr_could_not_be_delivered)
} else { } else {
medtronicPumpStatus.tempBasalStart = System.currentTimeMillis() medtronicPumpStatus.tempBasalStart = System.currentTimeMillis()
@ -776,7 +775,7 @@ class MedtronicPumpPlugin @Inject constructor(
incrementStatistics(MedtronicConst.Statistics.TBRsSet) incrementStatistics(MedtronicConst.Statistics.TBRsSet)
finishAction("TBR") finishAction("TBR")
PumpEnactResultObject(injector).success(true).enacted(true) // PumpEnactResult(injector).success(true).enacted(true) //
.absolute(absoluteRate).duration(durationInMinutes) .absolute(absoluteRate).duration(durationInMinutes)
} }
} }
@ -1022,7 +1021,7 @@ class MedtronicPumpPlugin @Inject constructor(
aapsLogger.info(LTag.PUMP, logPrefix + "cancelTempBasal - started") aapsLogger.info(LTag.PUMP, logPrefix + "cancelTempBasal - started")
if (isPumpNotReachable) { if (isPumpNotReachable) {
setRefreshButtonEnabled(true) setRefreshButtonEnabled(true)
return PumpEnactResultObject(injector) // return PumpEnactResult(injector) //
.success(false) // .success(false) //
.enacted(false) // .enacted(false) //
.comment(R.string.medtronic_pump_status_pump_unreachable) .comment(R.string.medtronic_pump_status_pump_unreachable)
@ -1034,12 +1033,12 @@ class MedtronicPumpPlugin @Inject constructor(
if (tbrCurrent.insulinRate > 0.0f && tbrCurrent.durationMinutes == 0) { if (tbrCurrent.insulinRate > 0.0f && tbrCurrent.durationMinutes == 0) {
aapsLogger.info(LTag.PUMP, logPrefix + "cancelTempBasal - TBR already canceled.") aapsLogger.info(LTag.PUMP, logPrefix + "cancelTempBasal - TBR already canceled.")
finishAction("TBR") finishAction("TBR")
return PumpEnactResultObject(injector).success(true).enacted(false) return PumpEnactResult(injector).success(true).enacted(false)
} }
} else { } else {
aapsLogger.warn(LTag.PUMP, logPrefix + "cancelTempBasal - Could not read current TBR, canceling operation.") aapsLogger.warn(LTag.PUMP, logPrefix + "cancelTempBasal - Could not read current TBR, canceling operation.")
finishAction("TBR") finishAction("TBR")
return PumpEnactResultObject(injector).success(false).enacted(false) return PumpEnactResult(injector).success(false).enacted(false)
.comment(R.string.medtronic_cmd_cant_read_tbr) .comment(R.string.medtronic_cmd_cant_read_tbr)
} }
val responseTask2 = rileyLinkMedtronicService?.medtronicUIComm?.executeCommand(MedtronicCommandType.CancelTBR) val responseTask2 = rileyLinkMedtronicService?.medtronicUIComm?.executeCommand(MedtronicCommandType.CancelTBR)
@ -1047,7 +1046,7 @@ class MedtronicPumpPlugin @Inject constructor(
finishAction("TBR") finishAction("TBR")
return if (response == null || !response) { return if (response == null || !response) {
aapsLogger.info(LTag.PUMP, logPrefix + "cancelTempBasal - Cancel TBR failed.") aapsLogger.info(LTag.PUMP, logPrefix + "cancelTempBasal - Cancel TBR failed.")
PumpEnactResultObject(injector).success(false).enacted(false) // PumpEnactResult(injector).success(false).enacted(false) //
.comment(R.string.medtronic_cmd_cant_cancel_tbr) .comment(R.string.medtronic_cmd_cant_cancel_tbr)
} else { } else {
aapsLogger.info(LTag.PUMP, logPrefix + "cancelTempBasal - Cancel TBR successful.") aapsLogger.info(LTag.PUMP, logPrefix + "cancelTempBasal - Cancel TBR successful.")
@ -1083,7 +1082,7 @@ class MedtronicPumpPlugin @Inject constructor(
//cancelTBRWithTemporaryId() //cancelTBRWithTemporaryId()
PumpEnactResultObject(injector).success(true).enacted(true) // PumpEnactResult(injector).success(true).enacted(true) //
.isTempCancel(true) .isTempCancel(true)
} }
} }
@ -1106,7 +1105,7 @@ class MedtronicPumpPlugin @Inject constructor(
// this shouldn't be needed, but let's do check if profile setting we are setting is same as current one // this shouldn't be needed, but let's do check if profile setting we are setting is same as current one
if (isProfileSame(profile)) { if (isProfileSame(profile)) {
return PumpEnactResultObject(injector) // return PumpEnactResult(injector) //
.success(true) // .success(true) //
.enacted(false) // .enacted(false) //
.comment(R.string.medtronic_cmd_basal_profile_not_set_is_same) .comment(R.string.medtronic_cmd_basal_profile_not_set_is_same)
@ -1114,7 +1113,7 @@ class MedtronicPumpPlugin @Inject constructor(
setRefreshButtonEnabled(false) setRefreshButtonEnabled(false)
if (isPumpNotReachable) { if (isPumpNotReachable) {
setRefreshButtonEnabled(true) setRefreshButtonEnabled(true)
return PumpEnactResultObject(injector) // return PumpEnactResult(injector) //
.success(false) // .success(false) //
.enacted(false) // .enacted(false) //
.comment(R.string.medtronic_pump_status_pump_unreachable) .comment(R.string.medtronic_pump_status_pump_unreachable)
@ -1124,7 +1123,7 @@ class MedtronicPumpPlugin @Inject constructor(
aapsLogger.debug("Basal Profile: $basalProfile") aapsLogger.debug("Basal Profile: $basalProfile")
val profileInvalid = isProfileValid(basalProfile) val profileInvalid = isProfileValid(basalProfile)
if (profileInvalid != null) { if (profileInvalid != null) {
return PumpEnactResultObject(injector) // return PumpEnactResult(injector) //
.success(false) // .success(false) //
.enacted(false) // .enacted(false) //
.comment(rh.gs(R.string.medtronic_cmd_set_profile_pattern_overflow, profileInvalid)) .comment(rh.gs(R.string.medtronic_cmd_set_profile_pattern_overflow, profileInvalid))
@ -1136,10 +1135,10 @@ class MedtronicPumpPlugin @Inject constructor(
val response = responseTask?.result as Boolean? val response = responseTask?.result as Boolean?
aapsLogger.info(LTag.PUMP, logPrefix + "Basal Profile was set: " + response) aapsLogger.info(LTag.PUMP, logPrefix + "Basal Profile was set: " + response)
return if (response == null || !response) { return if (response == null || !response) {
PumpEnactResultObject(injector).success(false).enacted(false) // PumpEnactResult(injector).success(false).enacted(false) //
.comment(R.string.medtronic_cmd_basal_profile_could_not_be_set) .comment(R.string.medtronic_cmd_basal_profile_could_not_be_set)
} else { } else {
PumpEnactResultObject(injector).success(true).enacted(true) PumpEnactResult(injector).success(true).enacted(true)
} }
} }

View file

@ -3,7 +3,6 @@ package info.nightscout.androidaps.plugins.pump.omnipod.common.ui.wizard.common.
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.interfaces.pump.PumpEnactResult import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger
@ -41,7 +40,7 @@ abstract class ActionViewModelBase(
logger.error(LTag.PUMP, "Caught exception in while executing action in ActionViewModelBase", throwable) logger.error(LTag.PUMP, "Caught exception in while executing action in ActionViewModelBase", throwable)
_isActionExecutingLiveData.postValue(false) _isActionExecutingLiveData.postValue(false)
_actionResultLiveData.postValue( _actionResultLiveData.postValue(
PumpEnactResultObject(injector).success(false).comment( PumpEnactResult(injector).success(false).comment(
throwable.message ?: "Caught exception in while executing action in ActionViewModelBase" throwable.message ?: "Caught exception in while executing action in ActionViewModelBase"
) )
) )

View file

@ -5,7 +5,6 @@ import android.os.Handler
import android.os.HandlerThread import android.os.HandlerThread
import android.text.format.DateFormat import android.text.format.DateFormat
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.extensions.convertedToAbsolute import info.nightscout.androidaps.extensions.convertedToAbsolute
import info.nightscout.androidaps.extensions.plannedRemainingMinutes import info.nightscout.androidaps.extensions.plannedRemainingMinutes
import info.nightscout.androidaps.extensions.toStringFull import info.nightscout.androidaps.extensions.toStringFull
@ -395,7 +394,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
override fun setNewBasalProfile(profile: Profile): PumpEnactResult { override fun setNewBasalProfile(profile: Profile): PumpEnactResult {
if (!podStateManager.isActivationCompleted) { if (!podStateManager.isActivationCompleted) {
return PumpEnactResultObject(injector).success(true).enacted(true) return PumpEnactResult(injector).success(true).enacted(true)
} }
aapsLogger.debug(LTag.PUMP, "setNewBasalProfile profile=$profile") aapsLogger.debug(LTag.PUMP, "setNewBasalProfile profile=$profile")
return setNewBasalProfile(profile, OmnipodCommandType.SET_BASAL_PROFILE) return setNewBasalProfile(profile, OmnipodCommandType.SET_BASAL_PROFILE)
@ -567,7 +566,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
detailedBolusInfo.insulin == 0.0 detailedBolusInfo.insulin == 0.0
) { ) {
// Accept only valid insulin requests // Accept only valid insulin requests
return PumpEnactResultObject(injector) return PumpEnactResult(injector)
.success(false) .success(false)
.enacted(false) .enacted(false)
.bolusDelivered(0.0) .bolusDelivered(0.0)
@ -575,7 +574,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
} }
val requestedBolusAmount = detailedBolusInfo.insulin val requestedBolusAmount = detailedBolusInfo.insulin
if (requestedBolusAmount > reservoirLevel) { if (requestedBolusAmount > reservoirLevel) {
return PumpEnactResultObject(injector) return PumpEnactResult(injector)
.success(false) .success(false)
.enacted(false) .enacted(false)
.bolusDelivered(0.0) .bolusDelivered(0.0)
@ -584,7 +583,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
if (podStateManager.deliveryStatus == DeliveryStatus.BOLUS_AND_BASAL_ACTIVE || if (podStateManager.deliveryStatus == DeliveryStatus.BOLUS_AND_BASAL_ACTIVE ||
podStateManager.deliveryStatus == DeliveryStatus.BOLUS_AND_TEMP_BASAL_ACTIVE podStateManager.deliveryStatus == DeliveryStatus.BOLUS_AND_TEMP_BASAL_ACTIVE
) { ) {
return PumpEnactResultObject(injector) return PumpEnactResult(injector)
.success(false) .success(false)
.enacted(false) .enacted(false)
.bolusDelivered(0.0) .bolusDelivered(0.0)
@ -653,10 +652,10 @@ class OmnipodDashPumpPlugin @Inject constructor(
} }
} }
}.toSingle { }.toSingle {
PumpEnactResultObject(injector).success(true).enacted(true).bolusDelivered(deliveredBolusAmount) PumpEnactResult(injector).success(true).enacted(true).bolusDelivered(deliveredBolusAmount)
}.onErrorReturnItem( }.onErrorReturnItem(
// success if canceled // success if canceled
PumpEnactResultObject(injector).success(bolusCanceled).enacted(false) PumpEnactResult(injector).success(bolusCanceled).enacted(false)
) )
.blockingGet() .blockingGet()
aapsLogger.info( aapsLogger.info(
@ -940,13 +939,13 @@ class OmnipodDashPumpPlugin @Inject constructor(
tbrType: PumpSync.TemporaryBasalType tbrType: PumpSync.TemporaryBasalType
): PumpEnactResult { ): PumpEnactResult {
// TODO i18n // TODO i18n
return PumpEnactResultObject(injector).success(false).enacted(false) return PumpEnactResult(injector).success(false).enacted(false)
.comment("Omnipod Dash driver does not support percentage temp basals") .comment("Omnipod Dash driver does not support percentage temp basals")
} }
override fun setExtendedBolus(insulin: Double, durationInMinutes: Int): PumpEnactResult { override fun setExtendedBolus(insulin: Double, durationInMinutes: Int): PumpEnactResult {
// TODO i18n // TODO i18n
return PumpEnactResultObject(injector).success(false).enacted(false) return PumpEnactResult(injector).success(false).enacted(false)
.comment("Omnipod Dash driver does not support extended boluses") .comment("Omnipod Dash driver does not support extended boluses")
} }
@ -963,7 +962,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
pumpSync.expectedPumpState().temporaryBasal == null pumpSync.expectedPumpState().temporaryBasal == null
) { ) {
// nothing to cancel // nothing to cancel
return PumpEnactResultObject(injector).success(true).enacted(false) return PumpEnactResult(injector).success(true).enacted(false)
} }
return executeProgrammingCommand( return executeProgrammingCommand(
@ -986,17 +985,17 @@ class OmnipodDashPumpPlugin @Inject constructor(
} }
private fun Completable.toPumpEnactResultImpl(): PumpEnactResult { private fun Completable.toPumpEnactResultImpl(): PumpEnactResult {
return this.toSingleDefault(PumpEnactResultObject(injector).success(true).enacted(true)) return this.toSingleDefault(PumpEnactResult(injector).success(true).enacted(true))
.doOnError { throwable -> .doOnError { throwable ->
aapsLogger.error(LTag.PUMP, "toPumpEnactResult, error executing command: $throwable") aapsLogger.error(LTag.PUMP, "toPumpEnactResult, error executing command: $throwable")
} }
.onErrorReturnItem(PumpEnactResultObject(injector).success(false).enacted(false)) .onErrorReturnItem(PumpEnactResult(injector).success(false).enacted(false))
.blockingGet() .blockingGet()
} }
override fun cancelExtendedBolus(): PumpEnactResult { override fun cancelExtendedBolus(): PumpEnactResult {
// TODO i18n // TODO i18n
return PumpEnactResultObject(injector).success(false).enacted(false) return PumpEnactResult(injector).success(false).enacted(false)
.comment("Omnipod Dash driver does not support extended boluses") .comment("Omnipod Dash driver does not support extended boluses")
} }
@ -1097,7 +1096,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
override fun loadTDDs(): PumpEnactResult { override fun loadTDDs(): PumpEnactResult {
// TODO i18n // TODO i18n
return PumpEnactResultObject(injector).success(false).enacted(false) return PumpEnactResult(injector).success(false).enacted(false)
.comment("Omnipod Dash driver does not support TDD") .comment("Omnipod Dash driver does not support TDD")
} }
@ -1132,7 +1131,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
else -> { else -> {
aapsLogger.warn(LTag.PUMP, "Unsupported custom command: " + customCommand.javaClass.name) aapsLogger.warn(LTag.PUMP, "Unsupported custom command: " + customCommand.javaClass.name)
PumpEnactResultObject(injector).success(false).enacted(false).comment( PumpEnactResult(injector).success(false).enacted(false).comment(
rh.gs( rh.gs(
R.string.omnipod_common_error_unsupported_custom_command, R.string.omnipod_common_error_unsupported_custom_command,
customCommand.javaClass.name customCommand.javaClass.name
@ -1149,7 +1148,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
historyEntry = history.createRecord(commandType = OmnipodCommandType.ACKNOWLEDGE_ALERTS), historyEntry = history.createRecord(commandType = OmnipodCommandType.ACKNOWLEDGE_ALERTS),
command = omnipodManager.silenceAlerts(it).ignoreElements(), command = omnipodManager.silenceAlerts(it).ignoreElements(),
).toPumpEnactResultImpl() ).toPumpEnactResultImpl()
} ?: PumpEnactResultObject(injector).success(false).enacted(false).comment("No active alerts") // TODO i18n } ?: PumpEnactResult(injector).success(false).enacted(false).comment("No active alerts") // TODO i18n
} }
private fun disableSuspendAlerts(): PumpEnactResult { private fun disableSuspendAlerts(): PumpEnactResult {
@ -1197,7 +1196,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
R.raw.boluserror R.raw.boluserror
) )
}.toPumpEnactResultImpl() }.toPumpEnactResultImpl()
} ?: PumpEnactResultObject(injector).success(false).enacted(false).comment("No profile active") // TODO i18n } ?: PumpEnactResult(injector).success(false).enacted(false).comment("No profile active") // TODO i18n
} }
private fun deactivatePod(): PumpEnactResult { private fun deactivatePod(): PumpEnactResult {
@ -1223,7 +1222,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
private fun handleTimeChange(): PumpEnactResult { private fun handleTimeChange(): PumpEnactResult {
return profileFunction.getProfile()?.let { return profileFunction.getProfile()?.let {
setNewBasalProfile(it, OmnipodCommandType.SET_TIME) setNewBasalProfile(it, OmnipodCommandType.SET_TIME)
} ?: PumpEnactResultObject(injector).success(false).enacted(false).comment("No profile active") } ?: PumpEnactResult(injector).success(false).enacted(false).comment("No profile active")
} }
private fun updateAlertConfiguration(): PumpEnactResult { private fun updateAlertConfiguration(): PumpEnactResult {
@ -1241,12 +1240,12 @@ class OmnipodDashPumpPlugin @Inject constructor(
lowReservoirAlertUnits lowReservoirAlertUnits
) -> { ) -> {
aapsLogger.debug(LTag.PUMP, "Ignoring updateAlertConfiguration because the settings did not change") aapsLogger.debug(LTag.PUMP, "Ignoring updateAlertConfiguration because the settings did not change")
return PumpEnactResultObject(injector).success(true).enacted(false) return PumpEnactResult(injector).success(true).enacted(false)
} }
!podStateManager.isPodRunning -> { !podStateManager.isPodRunning -> {
aapsLogger.debug(LTag.PUMP, "Ignoring updateAlertConfiguration because there is no active pod") aapsLogger.debug(LTag.PUMP, "Ignoring updateAlertConfiguration because there is no active pod")
return PumpEnactResultObject(injector).success(true).enacted(false) return PumpEnactResult(injector).success(true).enacted(false)
} }
} }
@ -1258,7 +1257,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
"updateAlertConfiguration negative " + "updateAlertConfiguration negative " +
"expiryAlertDuration=$expiryAlertDelay" "expiryAlertDuration=$expiryAlertDelay"
) )
PumpEnactResultObject(injector).success(false).enacted(false) PumpEnactResult(injector).success(false).enacted(false)
} }
val alerts = listOf( val alerts = listOf(
AlertConfiguration( AlertConfiguration(

View file

@ -2,7 +2,6 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.ui.wizard.activatio
import androidx.annotation.StringRes import androidx.annotation.StringRes
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.plugins.pump.omnipod.common.definition.OmnipodCommandType import info.nightscout.androidaps.plugins.pump.omnipod.common.definition.OmnipodCommandType
import info.nightscout.androidaps.plugins.pump.omnipod.common.ui.wizard.activation.viewmodel.action.InitializePodViewModel import info.nightscout.androidaps.plugins.pump.omnipod.common.ui.wizard.activation.viewmodel.action.InitializePodViewModel
import info.nightscout.androidaps.plugins.pump.omnipod.dash.R import info.nightscout.androidaps.plugins.pump.omnipod.dash.R
@ -66,14 +65,14 @@ class DashInitializePodViewModel @Inject constructor(
onError = { throwable -> onError = { throwable ->
logger.error(LTag.PUMP, "Error in Pod activation part 1", throwable) logger.error(LTag.PUMP, "Error in Pod activation part 1", throwable)
source.onSuccess( source.onSuccess(
PumpEnactResultObject(injector) PumpEnactResult(injector)
.success(false) .success(false)
.comment(I8n.textFromException(throwable, rh)) .comment(I8n.textFromException(throwable, rh))
) )
}, },
onComplete = { onComplete = {
logger.debug("Pod activation part 1 completed") logger.debug("Pod activation part 1 completed")
source.onSuccess(PumpEnactResultObject(injector).success(true)) source.onSuccess(PumpEnactResult(injector).success(true))
} }
) )
} }

View file

@ -2,7 +2,6 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.ui.wizard.activatio
import androidx.annotation.StringRes import androidx.annotation.StringRes
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification
import info.nightscout.androidaps.plugins.pump.omnipod.common.definition.OmnipodCommandType import info.nightscout.androidaps.plugins.pump.omnipod.common.definition.OmnipodCommandType
import info.nightscout.androidaps.plugins.pump.omnipod.common.ui.wizard.activation.viewmodel.action.InsertCannulaViewModel import info.nightscout.androidaps.plugins.pump.omnipod.common.ui.wizard.activation.viewmodel.action.InsertCannulaViewModel
@ -91,7 +90,7 @@ class DashInsertCannulaViewModel @Inject constructor(
.subscribeBy( .subscribeBy(
onError = { throwable -> onError = { throwable ->
logger.error(LTag.PUMP, "Error in Pod activation part 2", throwable) logger.error(LTag.PUMP, "Error in Pod activation part 2", throwable)
source.onSuccess(PumpEnactResultObject(injector).success(false).comment(I8n.textFromException(throwable, rh))) source.onSuccess(PumpEnactResult(injector).success(false).comment(I8n.textFromException(throwable, rh)))
}, },
onComplete = { onComplete = {
logger.debug("Pod activation part 2 completed") logger.debug("Pod activation part 2 completed")
@ -121,7 +120,7 @@ class DashInsertCannulaViewModel @Inject constructor(
) )
rxBus.send(EventDismissNotification(Notification.OMNIPOD_POD_NOT_ATTACHED)) rxBus.send(EventDismissNotification(Notification.OMNIPOD_POD_NOT_ATTACHED))
fabricPrivacy.logCustom("OmnipodDashPodActivated") fabricPrivacy.logCustom("OmnipodDashPodActivated")
source.onSuccess(PumpEnactResultObject(injector).success(true)) source.onSuccess(PumpEnactResult(injector).success(true))
} }
) )
} }

View file

@ -34,7 +34,6 @@ import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import dagger.android.HasAndroidInjector; import dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.data.PumpEnactResultObject;
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.pump.common.defs.TempBasalPair; import info.nightscout.androidaps.plugins.pump.common.defs.TempBasalPair;
@ -603,7 +602,7 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements Pump, Riley
@Override @Override
public PumpEnactResult setNewBasalProfile(@NonNull Profile profile) { public PumpEnactResult setNewBasalProfile(@NonNull Profile profile) {
if (!podStateManager.hasPodState()) if (!podStateManager.hasPodState())
return new PumpEnactResultObject(getInjector()).enacted(false).success(false).comment("Null pod state"); return new PumpEnactResult(getInjector()).enacted(false).success(false).comment("Null pod state");
PumpEnactResult result = executeCommand(OmnipodCommandType.SET_BASAL_PROFILE, () -> aapsOmnipodErosManager.setBasalProfile(profile, true)); PumpEnactResult result = executeCommand(OmnipodCommandType.SET_BASAL_PROFILE, () -> aapsOmnipodErosManager.setBasalProfile(profile, true));
aapsLogger.info(LTag.PUMP, "Basal Profile was set: " + result.getSuccess()); aapsLogger.info(LTag.PUMP, "Basal Profile was set: " + result.getSuccess());
@ -661,7 +660,7 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements Pump, Riley
if (detailedBolusInfo.insulin == 0 && detailedBolusInfo.carbs == 0) { if (detailedBolusInfo.insulin == 0 && detailedBolusInfo.carbs == 0) {
// neither carbs nor bolus requested // neither carbs nor bolus requested
aapsLogger.error("deliverTreatment: Invalid input: neither carbs nor insulin are set in treatment"); aapsLogger.error("deliverTreatment: Invalid input: neither carbs nor insulin are set in treatment");
return new PumpEnactResultObject(getInjector()).success(false).enacted(false).bolusDelivered(0d).carbsDelivered(0d) return new PumpEnactResult(getInjector()).success(false).enacted(false).bolusDelivered(0d).carbsDelivered(0d)
.comment(R.string.invalidinput); .comment(R.string.invalidinput);
} else if (detailedBolusInfo.insulin > 0) { } else if (detailedBolusInfo.insulin > 0) {
// bolus needed, ask pump to deliver it // bolus needed, ask pump to deliver it
@ -679,7 +678,7 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements Pump, Riley
"[date=%d, carbs=%.2f, pumpSerial=%s] - Result: %b", "[date=%d, carbs=%.2f, pumpSerial=%s] - Result: %b",
detailedBolusInfo.timestamp, detailedBolusInfo.carbs, serialNumber(), result)); detailedBolusInfo.timestamp, detailedBolusInfo.carbs, serialNumber(), result));
return new PumpEnactResultObject(getInjector()).success(true).enacted(true).bolusDelivered(0d) return new PumpEnactResult(getInjector()).success(true).enacted(true).bolusDelivered(0d)
.carbsDelivered(detailedBolusInfo.carbs); .carbsDelivered(detailedBolusInfo.carbs);
} }
} }
@ -697,7 +696,7 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements Pump, Riley
aapsLogger.info(LTag.PUMP, "setTempBasalAbsolute: rate: {}, duration={}", absoluteRate, durationInMinutes); aapsLogger.info(LTag.PUMP, "setTempBasalAbsolute: rate: {}, duration={}", absoluteRate, durationInMinutes);
if (durationInMinutes <= 0 || durationInMinutes % BASAL_STEP_DURATION.getStandardMinutes() != 0) { if (durationInMinutes <= 0 || durationInMinutes % BASAL_STEP_DURATION.getStandardMinutes() != 0) {
return new PumpEnactResultObject(getInjector()).success(false).comment(rh.gs(R.string.omnipod_eros_error_set_temp_basal_failed_validation, BASAL_STEP_DURATION.getStandardMinutes())); return new PumpEnactResult(getInjector()).success(false).comment(rh.gs(R.string.omnipod_eros_error_set_temp_basal_failed_validation, BASAL_STEP_DURATION.getStandardMinutes()));
} }
// read current TBR // read current TBR
@ -711,7 +710,7 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements Pump, Riley
if (tbrCurrent != null && !enforceNew) { if (tbrCurrent != null && !enforceNew) {
if (Round.INSTANCE.isSame(tbrCurrent.getRate(), absoluteRate)) { if (Round.INSTANCE.isSame(tbrCurrent.getRate(), absoluteRate)) {
aapsLogger.info(LTag.PUMP, "setTempBasalAbsolute - No enforceNew and same rate. Exiting."); aapsLogger.info(LTag.PUMP, "setTempBasalAbsolute - No enforceNew and same rate. Exiting.");
return new PumpEnactResultObject(getInjector()).success(true).enacted(false); return new PumpEnactResult(getInjector()).success(true).enacted(false);
} }
} }
@ -733,7 +732,7 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements Pump, Riley
if (tbrCurrent == null) { if (tbrCurrent == null) {
aapsLogger.info(LTag.PUMP, "cancelTempBasal - TBR already cancelled."); aapsLogger.info(LTag.PUMP, "cancelTempBasal - TBR already cancelled.");
return new PumpEnactResultObject(getInjector()).success(true).enacted(false); return new PumpEnactResult(getInjector()).success(true).enacted(false);
} }
return executeCommand(OmnipodCommandType.CANCEL_TEMPORARY_BASAL, aapsOmnipodErosManager::cancelTemporaryBasal); return executeCommand(OmnipodCommandType.CANCEL_TEMPORARY_BASAL, aapsOmnipodErosManager::cancelTemporaryBasal);
@ -857,7 +856,7 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements Pump, Riley
@Override @Override
public PumpEnactResult executeCustomCommand(@NonNull CustomCommand command) { public PumpEnactResult executeCustomCommand(@NonNull CustomCommand command) {
if (!podStateManager.hasPodState()) if (!podStateManager.hasPodState())
return new PumpEnactResultObject(getInjector()).enacted(false).success(false).comment("Null pod state"); return new PumpEnactResult(getInjector()).enacted(false).success(false).comment("Null pod state");
if (command instanceof CommandSilenceAlerts) { if (command instanceof CommandSilenceAlerts) {
return executeCommand(OmnipodCommandType.ACKNOWLEDGE_ALERTS, aapsOmnipodErosManager::acknowledgeAlerts); return executeCommand(OmnipodCommandType.ACKNOWLEDGE_ALERTS, aapsOmnipodErosManager::acknowledgeAlerts);
} }
@ -887,7 +886,7 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements Pump, Riley
} }
aapsLogger.warn(LTag.PUMP, "Unsupported custom command: " + command.getClass().getName()); aapsLogger.warn(LTag.PUMP, "Unsupported custom command: " + command.getClass().getName());
return new PumpEnactResultObject(getInjector()).success(false).enacted(false).comment(rh.gs(R.string.omnipod_common_error_unsupported_custom_command, command.getClass().getName())); return new PumpEnactResult(getInjector()).success(false).enacted(false).comment(rh.gs(R.string.omnipod_common_error_unsupported_custom_command, command.getClass().getName()));
} }
private PumpEnactResult retrievePulseLog() { private PumpEnactResult retrievePulseLog() {
@ -895,7 +894,7 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements Pump, Riley
try { try {
result = executeCommand(OmnipodCommandType.READ_POD_PULSE_LOG, aapsOmnipodErosManager::readPulseLog); result = executeCommand(OmnipodCommandType.READ_POD_PULSE_LOG, aapsOmnipodErosManager::readPulseLog);
} catch (Exception ex) { } catch (Exception ex) {
return new PumpEnactResultObject(getInjector()).success(false).enacted(false).comment(aapsOmnipodErosManager.translateException(ex)); return new PumpEnactResult(getInjector()).success(false).enacted(false).comment(aapsOmnipodErosManager.translateException(ex));
} }
Intent i = new Intent(context, activityNames.getErrorHelperActivity()); Intent i = new Intent(context, activityNames.getErrorHelperActivity());
@ -905,7 +904,7 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements Pump, Riley
i.putExtra("clipboardContent", result.toString()); i.putExtra("clipboardContent", result.toString());
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i); context.startActivity(i);
return new PumpEnactResultObject(getInjector()).success(true).enacted(false); return new PumpEnactResult(getInjector()).success(true).enacted(false);
} }
@NonNull private PumpEnactResult updateAlertConfiguration() { @NonNull private PumpEnactResult updateAlertConfiguration() {
@ -1171,7 +1170,7 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements Pump, Riley
} }
private PumpEnactResult getOperationNotSupportedWithCustomText(int resourceId) { private PumpEnactResult getOperationNotSupportedWithCustomText(int resourceId) {
return new PumpEnactResultObject(getInjector()).success(false).enacted(false).comment(resourceId); return new PumpEnactResult(getInjector()).success(false).enacted(false).comment(resourceId);
} }
} }

View file

@ -14,7 +14,6 @@ import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import dagger.android.HasAndroidInjector; import dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.data.PumpEnactResultObject;
import info.nightscout.androidaps.extensions.PumpStateExtensionKt; import info.nightscout.androidaps.extensions.PumpStateExtensionKt;
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
@ -170,7 +169,7 @@ public class AapsOmnipodErosManager {
} }
public PumpEnactResult initializePod() { public PumpEnactResult initializePod() {
PumpEnactResult result = new PumpEnactResultObject(injector); PumpEnactResult result = new PumpEnactResult(injector);
try { try {
Boolean res = executeCommand(delegate::pairAndPrime) Boolean res = executeCommand(delegate::pairAndPrime)
.blockingGet(); .blockingGet();
@ -192,10 +191,10 @@ public class AapsOmnipodErosManager {
public PumpEnactResult insertCannula(Profile profile) { public PumpEnactResult insertCannula(Profile profile) {
if (profile == null) { if (profile == null) {
String comment = getStringResource(R.string.omnipod_common_error_set_initial_basal_schedule_no_profile); String comment = getStringResource(R.string.omnipod_common_error_set_initial_basal_schedule_no_profile);
return new PumpEnactResultObject(injector).success(false).enacted(false).comment(comment); return new PumpEnactResult(injector).success(false).enacted(false).comment(comment);
} }
PumpEnactResult result = new PumpEnactResultObject(injector); PumpEnactResult result = new PumpEnactResult(injector);
try { try {
BasalSchedule basalSchedule = mapProfileToBasalSchedule(profile); BasalSchedule basalSchedule = mapProfileToBasalSchedule(profile);
@ -233,11 +232,11 @@ public class AapsOmnipodErosManager {
} catch (Exception ex) { } catch (Exception ex) {
String errorMessage = translateException(ex); String errorMessage = translateException(ex);
addFailureToHistory(PodHistoryEntryType.CONFIGURE_ALERTS, errorMessage); addFailureToHistory(PodHistoryEntryType.CONFIGURE_ALERTS, errorMessage);
return new PumpEnactResultObject(injector).success(false).enacted(false).comment(errorMessage); return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage);
} }
addSuccessToHistory(PodHistoryEntryType.CONFIGURE_ALERTS, alertConfigurations); addSuccessToHistory(PodHistoryEntryType.CONFIGURE_ALERTS, alertConfigurations);
return new PumpEnactResultObject(injector).success(true).enacted(false); return new PumpEnactResult(injector).success(true).enacted(false);
} }
public PumpEnactResult playTestBeep(BeepConfigType beepType) { public PumpEnactResult playTestBeep(BeepConfigType beepType) {
@ -246,11 +245,11 @@ public class AapsOmnipodErosManager {
} catch (Exception ex) { } catch (Exception ex) {
String errorMessage = translateException(ex); String errorMessage = translateException(ex);
addFailureToHistory(PodHistoryEntryType.PLAY_TEST_BEEP, errorMessage); addFailureToHistory(PodHistoryEntryType.PLAY_TEST_BEEP, errorMessage);
return new PumpEnactResultObject(injector).success(false).enacted(false).comment(errorMessage); return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage);
} }
addSuccessToHistory(PodHistoryEntryType.PLAY_TEST_BEEP, beepType); addSuccessToHistory(PodHistoryEntryType.PLAY_TEST_BEEP, beepType);
return new PumpEnactResultObject(injector).success(true).enacted(false); return new PumpEnactResult(injector).success(true).enacted(false);
} }
@ -262,12 +261,12 @@ public class AapsOmnipodErosManager {
} catch (Exception ex) { } catch (Exception ex) {
String errorMessage = translateException(ex); String errorMessage = translateException(ex);
addFailureToHistory(PodHistoryEntryType.GET_POD_STATUS, errorMessage); addFailureToHistory(PodHistoryEntryType.GET_POD_STATUS, errorMessage);
return new PumpEnactResultObject(injector).success(false).enacted(false).comment(errorMessage); return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage);
} }
addSuccessToHistory(PodHistoryEntryType.GET_POD_STATUS, statusResponse); addSuccessToHistory(PodHistoryEntryType.GET_POD_STATUS, statusResponse);
return new PumpEnactResultObject(injector).success(true).enacted(false); return new PumpEnactResult(injector).success(true).enacted(false);
} }
public PumpEnactResult deactivatePod() { public PumpEnactResult deactivatePod() {
@ -276,7 +275,7 @@ public class AapsOmnipodErosManager {
} catch (Exception ex) { } catch (Exception ex) {
String errorMessage = translateException(ex); String errorMessage = translateException(ex);
addFailureToHistory(PodHistoryEntryType.DEACTIVATE_POD, errorMessage); addFailureToHistory(PodHistoryEntryType.DEACTIVATE_POD, errorMessage);
return new PumpEnactResultObject(injector).success(false).enacted(false).comment(errorMessage); return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage);
} }
addSuccessToHistory(PodHistoryEntryType.DEACTIVATE_POD, null); addSuccessToHistory(PodHistoryEntryType.DEACTIVATE_POD, null);
@ -284,7 +283,7 @@ public class AapsOmnipodErosManager {
dismissNotification(Notification.OMNIPOD_POD_FAULT); dismissNotification(Notification.OMNIPOD_POD_FAULT);
return new PumpEnactResultObject(injector).success(true).enacted(true); return new PumpEnactResult(injector).success(true).enacted(true);
} }
public PumpEnactResult setBasalProfile(Profile profile, boolean showNotifications) { public PumpEnactResult setBasalProfile(Profile profile, boolean showNotifications) {
@ -293,7 +292,7 @@ public class AapsOmnipodErosManager {
if (showNotifications) { if (showNotifications) {
showNotification(Notification.FAILED_UPDATE_PROFILE, note, Notification.URGENT, R.raw.boluserror); showNotification(Notification.FAILED_UPDATE_PROFILE, note, Notification.URGENT, R.raw.boluserror);
} }
return new PumpEnactResultObject(injector).success(false).enacted(false).comment(note); return new PumpEnactResult(injector).success(false).enacted(false).comment(note);
} }
// #1963 return synthetic success if pre-activation // #1963 return synthetic success if pre-activation
@ -301,7 +300,7 @@ public class AapsOmnipodErosManager {
// otherwise a catch-22 // otherwise a catch-22
if (!podStateManager.getActivationProgress().isCompleted()) { if (!podStateManager.getActivationProgress().isCompleted()) {
// TODO: i18n string // TODO: i18n string
return new PumpEnactResultObject(injector).success(true).enacted(false).comment("pre" + return new PumpEnactResult(injector).success(true).enacted(false).comment("pre" +
"-activation basal change moot"); "-activation basal change moot");
} }
@ -317,14 +316,14 @@ public class AapsOmnipodErosManager {
} }
String errorMessage = translateException(ex.getCause()); String errorMessage = translateException(ex.getCause());
addFailureToHistory(historyEntryType, errorMessage); addFailureToHistory(historyEntryType, errorMessage);
return new PumpEnactResultObject(injector).success(false).enacted(false).comment(errorMessage); return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage);
} catch (PrecedingCommandFailedUncertainlyException ex) { } catch (PrecedingCommandFailedUncertainlyException ex) {
if (showNotifications) { if (showNotifications) {
showNotification(Notification.FAILED_UPDATE_PROFILE, getStringResource(R.string.omnipod_eros_error_set_basal_failed_delivery_might_be_suspended), Notification.URGENT, R.raw.boluserror); showNotification(Notification.FAILED_UPDATE_PROFILE, getStringResource(R.string.omnipod_eros_error_set_basal_failed_delivery_might_be_suspended), Notification.URGENT, R.raw.boluserror);
} }
String errorMessage = translateException(ex.getCause()); String errorMessage = translateException(ex.getCause());
addFailureToHistory(historyEntryType, errorMessage); addFailureToHistory(historyEntryType, errorMessage);
return new PumpEnactResultObject(injector).success(false).enacted(false).comment(errorMessage); return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage);
} catch (Exception ex) { } catch (Exception ex) {
if (showNotifications) { if (showNotifications) {
String note; String note;
@ -337,7 +336,7 @@ public class AapsOmnipodErosManager {
} }
String errorMessage = translateException(ex); String errorMessage = translateException(ex);
addFailureToHistory(historyEntryType, errorMessage); addFailureToHistory(historyEntryType, errorMessage);
return new PumpEnactResultObject(injector).success(false).enacted(false).comment(errorMessage); return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage);
} }
@ -355,7 +354,7 @@ public class AapsOmnipodErosManager {
dismissNotification(Notification.OMNIPOD_POD_SUSPENDED); dismissNotification(Notification.OMNIPOD_POD_SUSPENDED);
dismissNotification(Notification.OMNIPOD_TIME_OUT_OF_SYNC); dismissNotification(Notification.OMNIPOD_TIME_OUT_OF_SYNC);
return new PumpEnactResultObject(injector).success(true).enacted(true); return new PumpEnactResult(injector).success(true).enacted(true);
} }
public PumpEnactResult discardPodState() { public PumpEnactResult discardPodState() {
@ -369,7 +368,7 @@ public class AapsOmnipodErosManager {
sendEvent(new EventOmnipodErosPumpValuesChanged()); sendEvent(new EventOmnipodErosPumpValuesChanged());
sendEvent(new EventRefreshOverview("Omnipod command: " + OmnipodCommandType.DISCARD_POD, false)); sendEvent(new EventRefreshOverview("Omnipod command: " + OmnipodCommandType.DISCARD_POD, false));
return new PumpEnactResultObject(injector).success(true).enacted(true); return new PumpEnactResult(injector).success(true).enacted(true);
} }
public PumpEnactResult bolus(DetailedBolusInfo detailedBolusInfo) { public PumpEnactResult bolus(DetailedBolusInfo detailedBolusInfo) {
@ -393,7 +392,7 @@ public class AapsOmnipodErosManager {
} catch (Exception ex) { } catch (Exception ex) {
String errorMessage = translateException(ex); String errorMessage = translateException(ex);
addFailureToHistory(System.currentTimeMillis(), PodHistoryEntryType.SET_BOLUS, errorMessage); addFailureToHistory(System.currentTimeMillis(), PodHistoryEntryType.SET_BOLUS, errorMessage);
return new PumpEnactResultObject(injector).success(false).enacted(false).comment(errorMessage); return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage);
} }
if (OmnipodManager.CommandDeliveryStatus.UNCERTAIN_FAILURE.equals(bolusCommandResult.getCommandDeliveryStatus())) { if (OmnipodManager.CommandDeliveryStatus.UNCERTAIN_FAILURE.equals(bolusCommandResult.getCommandDeliveryStatus())) {
@ -448,7 +447,7 @@ public class AapsOmnipodErosManager {
sp.remove(OmnipodErosStorageKeys.Preferences.ACTIVE_BOLUS); sp.remove(OmnipodErosStorageKeys.Preferences.ACTIVE_BOLUS);
return new PumpEnactResultObject(injector).success(true).enacted(true).carbsDelivered(detailedBolusInfo.carbs).bolusDelivered(detailedBolusInfo.insulin); return new PumpEnactResult(injector).success(true).enacted(true).carbsDelivered(detailedBolusInfo.carbs).bolusDelivered(detailedBolusInfo.insulin);
} }
public PumpEnactResult cancelBolus() { public PumpEnactResult cancelBolus() {
@ -463,7 +462,7 @@ public class AapsOmnipodErosManager {
aapsLogger.debug(LTag.PUMP, "Not cancelling bolus: bolus command failed"); aapsLogger.debug(LTag.PUMP, "Not cancelling bolus: bolus command failed");
String comment = getStringResource(R.string.omnipod_common_error_bolus_did_not_succeed); String comment = getStringResource(R.string.omnipod_common_error_bolus_did_not_succeed);
addFailureToHistory(System.currentTimeMillis(), PodHistoryEntryType.CANCEL_BOLUS, comment); addFailureToHistory(System.currentTimeMillis(), PodHistoryEntryType.CANCEL_BOLUS, comment);
return new PumpEnactResultObject(injector).success(true).enacted(false).comment(comment); return new PumpEnactResult(injector).success(true).enacted(false).comment(comment);
} }
} }
@ -475,11 +474,11 @@ public class AapsOmnipodErosManager {
executeCommand(() -> delegate.cancelBolus(isBolusBeepsEnabled())); executeCommand(() -> delegate.cancelBolus(isBolusBeepsEnabled()));
aapsLogger.debug(LTag.PUMP, "Successfully cancelled bolus", i); aapsLogger.debug(LTag.PUMP, "Successfully cancelled bolus", i);
addSuccessToHistory(System.currentTimeMillis(), PodHistoryEntryType.CANCEL_BOLUS, null); addSuccessToHistory(System.currentTimeMillis(), PodHistoryEntryType.CANCEL_BOLUS, null);
return new PumpEnactResultObject(injector).success(true).enacted(true); return new PumpEnactResult(injector).success(true).enacted(true);
} catch (PodFaultException ex) { } catch (PodFaultException ex) {
aapsLogger.debug(LTag.PUMP, "Successfully cancelled bolus (implicitly because of a Pod Fault)"); aapsLogger.debug(LTag.PUMP, "Successfully cancelled bolus (implicitly because of a Pod Fault)");
addSuccessToHistory(System.currentTimeMillis(), PodHistoryEntryType.CANCEL_BOLUS, null); addSuccessToHistory(System.currentTimeMillis(), PodHistoryEntryType.CANCEL_BOLUS, null);
return new PumpEnactResultObject(injector).success(true).enacted(true); return new PumpEnactResult(injector).success(true).enacted(true);
} catch (Exception ex) { } catch (Exception ex) {
aapsLogger.debug(LTag.PUMP, "Failed to cancel bolus", ex); aapsLogger.debug(LTag.PUMP, "Failed to cancel bolus", ex);
comment = translateException(ex); comment = translateException(ex);
@ -487,7 +486,7 @@ public class AapsOmnipodErosManager {
} }
addFailureToHistory(System.currentTimeMillis(), PodHistoryEntryType.CANCEL_BOLUS, comment); addFailureToHistory(System.currentTimeMillis(), PodHistoryEntryType.CANCEL_BOLUS, comment);
return new PumpEnactResultObject(injector).success(false).enacted(false).comment(comment); return new PumpEnactResult(injector).success(false).enacted(false).comment(comment);
} }
public PumpEnactResult setTemporaryBasal(TempBasalPair tempBasalPair) { public PumpEnactResult setTemporaryBasal(TempBasalPair tempBasalPair) {
@ -497,7 +496,7 @@ public class AapsOmnipodErosManager {
} catch (CommandFailedAfterChangingDeliveryStatusException ex) { } catch (CommandFailedAfterChangingDeliveryStatusException ex) {
String errorMessage = translateException(ex.getCause()); String errorMessage = translateException(ex.getCause());
addFailureToHistory(PodHistoryEntryType.SET_TEMPORARY_BASAL, errorMessage); addFailureToHistory(PodHistoryEntryType.SET_TEMPORARY_BASAL, errorMessage);
return new PumpEnactResultObject(injector).success(false).enacted(false).comment(errorMessage); return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage);
} catch (PrecedingCommandFailedUncertainlyException ex) { } catch (PrecedingCommandFailedUncertainlyException ex) {
String errorMessage = translateException(ex.getCause()); String errorMessage = translateException(ex.getCause());
addFailureToHistory(PodHistoryEntryType.SET_TEMPORARY_BASAL, errorMessage); addFailureToHistory(PodHistoryEntryType.SET_TEMPORARY_BASAL, errorMessage);
@ -506,7 +505,7 @@ public class AapsOmnipodErosManager {
splitActiveTbr(); // Split any active TBR so when we recover from the uncertain TBR status,we only cancel the part after the cancellation splitActiveTbr(); // Split any active TBR so when we recover from the uncertain TBR status,we only cancel the part after the cancellation
return new PumpEnactResultObject(injector).success(false).enacted(false).comment(errorMessage); return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage);
} catch (Exception ex) { } catch (Exception ex) {
String errorMessage = translateException(ex); String errorMessage = translateException(ex);
long pumpId = addFailureToHistory(PodHistoryEntryType.SET_TEMPORARY_BASAL, errorMessage); long pumpId = addFailureToHistory(PodHistoryEntryType.SET_TEMPORARY_BASAL, errorMessage);
@ -524,7 +523,7 @@ public class AapsOmnipodErosManager {
addTempBasalTreatment(System.currentTimeMillis(), pumpId, tempBasalPair); addTempBasalTreatment(System.currentTimeMillis(), pumpId, tempBasalPair);
} }
return new PumpEnactResultObject(injector).success(false).enacted(false).comment(errorMessage); return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage);
} }
long pumpId = addSuccessToHistory(PodHistoryEntryType.SET_TEMPORARY_BASAL, tempBasalPair); long pumpId = addSuccessToHistory(PodHistoryEntryType.SET_TEMPORARY_BASAL, tempBasalPair);
@ -533,7 +532,7 @@ public class AapsOmnipodErosManager {
sendEvent(new EventDismissNotification(Notification.OMNIPOD_TBR_ALERTS)); sendEvent(new EventDismissNotification(Notification.OMNIPOD_TBR_ALERTS));
return new PumpEnactResultObject(injector) return new PumpEnactResult(injector)
.duration(tempBasalPair.getDurationMinutes()) .duration(tempBasalPair.getDurationMinutes())
.absolute(PumpType.OMNIPOD_EROS.determineCorrectBasalSize(tempBasalPair.getInsulinRate())) .absolute(PumpType.OMNIPOD_EROS.determineCorrectBasalSize(tempBasalPair.getInsulinRate()))
.success(true).enacted(true); .success(true).enacted(true);
@ -550,7 +549,7 @@ public class AapsOmnipodErosManager {
} }
String errorMessage = translateException(ex); String errorMessage = translateException(ex);
addFailureToHistory(PodHistoryEntryType.CANCEL_TEMPORARY_BASAL, errorMessage); addFailureToHistory(PodHistoryEntryType.CANCEL_TEMPORARY_BASAL, errorMessage);
return new PumpEnactResultObject(injector).success(false).enacted(false).comment(errorMessage); return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage);
} }
long pumpId = addSuccessToHistory(PodHistoryEntryType.CANCEL_TEMPORARY_BASAL, null); long pumpId = addSuccessToHistory(PodHistoryEntryType.CANCEL_TEMPORARY_BASAL, null);
@ -564,7 +563,7 @@ public class AapsOmnipodErosManager {
sendEvent(new EventDismissNotification(Notification.OMNIPOD_TBR_ALERTS)); sendEvent(new EventDismissNotification(Notification.OMNIPOD_TBR_ALERTS));
return new PumpEnactResultObject(injector).success(true).enacted(true); return new PumpEnactResult(injector).success(true).enacted(true);
} }
public PumpEnactResult acknowledgeAlerts() { public PumpEnactResult acknowledgeAlerts() {
@ -573,11 +572,11 @@ public class AapsOmnipodErosManager {
} catch (Exception ex) { } catch (Exception ex) {
String errorMessage = translateException(ex); String errorMessage = translateException(ex);
addFailureToHistory(PodHistoryEntryType.ACKNOWLEDGE_ALERTS, errorMessage); addFailureToHistory(PodHistoryEntryType.ACKNOWLEDGE_ALERTS, errorMessage);
return new PumpEnactResultObject(injector).success(false).enacted(false).comment(errorMessage); return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage);
} }
addSuccessToHistory(PodHistoryEntryType.ACKNOWLEDGE_ALERTS, null); addSuccessToHistory(PodHistoryEntryType.ACKNOWLEDGE_ALERTS, null);
return new PumpEnactResultObject(injector).success(true).enacted(true); return new PumpEnactResult(injector).success(true).enacted(true);
} }
public PumpEnactResult suspendDelivery() { public PumpEnactResult suspendDelivery() {
@ -586,7 +585,7 @@ public class AapsOmnipodErosManager {
} catch (Exception ex) { } catch (Exception ex) {
String errorMessage = translateException(ex); String errorMessage = translateException(ex);
addFailureToHistory(PodHistoryEntryType.SUSPEND_DELIVERY, errorMessage); addFailureToHistory(PodHistoryEntryType.SUSPEND_DELIVERY, errorMessage);
return new PumpEnactResultObject(injector).success(false).enacted(false).comment(errorMessage); return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage);
} }
addSuccessToHistory(PodHistoryEntryType.SUSPEND_DELIVERY, null); addSuccessToHistory(PodHistoryEntryType.SUSPEND_DELIVERY, null);
@ -595,7 +594,7 @@ public class AapsOmnipodErosManager {
dismissNotification(Notification.FAILED_UPDATE_PROFILE); dismissNotification(Notification.FAILED_UPDATE_PROFILE);
dismissNotification(Notification.OMNIPOD_TIME_OUT_OF_SYNC); dismissNotification(Notification.OMNIPOD_TIME_OUT_OF_SYNC);
return new PumpEnactResultObject(injector).success(true).enacted(true); return new PumpEnactResult(injector).success(true).enacted(true);
} }
// Updates the pods current time based on the device timezone and the pod's time zone // Updates the pods current time based on the device timezone and the pod's time zone
@ -609,21 +608,21 @@ public class AapsOmnipodErosManager {
} }
String errorMessage = translateException(ex.getCause()); String errorMessage = translateException(ex.getCause());
addFailureToHistory(PodHistoryEntryType.SET_TIME, errorMessage); addFailureToHistory(PodHistoryEntryType.SET_TIME, errorMessage);
return new PumpEnactResultObject(injector).success(false).enacted(false).comment(errorMessage); return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage);
} catch (PrecedingCommandFailedUncertainlyException ex) { } catch (PrecedingCommandFailedUncertainlyException ex) {
if (showNotifications) { if (showNotifications) {
showNotification(Notification.FAILED_UPDATE_PROFILE, getStringResource(R.string.omnipod_eros_error_set_time_failed_delivery_might_be_suspended), Notification.URGENT, R.raw.boluserror); showNotification(Notification.FAILED_UPDATE_PROFILE, getStringResource(R.string.omnipod_eros_error_set_time_failed_delivery_might_be_suspended), Notification.URGENT, R.raw.boluserror);
} }
String errorMessage = translateException(ex.getCause()); String errorMessage = translateException(ex.getCause());
addFailureToHistory(PodHistoryEntryType.SET_TIME, errorMessage); addFailureToHistory(PodHistoryEntryType.SET_TIME, errorMessage);
return new PumpEnactResultObject(injector).success(false).enacted(false).comment(errorMessage); return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage);
} catch (Exception ex) { } catch (Exception ex) {
if (showNotifications) { if (showNotifications) {
showNotification(Notification.FAILED_UPDATE_PROFILE, getStringResource(R.string.omnipod_eros_error_set_time_failed_delivery_might_be_suspended), Notification.URGENT, R.raw.boluserror); showNotification(Notification.FAILED_UPDATE_PROFILE, getStringResource(R.string.omnipod_eros_error_set_time_failed_delivery_might_be_suspended), Notification.URGENT, R.raw.boluserror);
} }
String errorMessage = translateException(ex); String errorMessage = translateException(ex);
addFailureToHistory(PodHistoryEntryType.SET_TIME, errorMessage); addFailureToHistory(PodHistoryEntryType.SET_TIME, errorMessage);
return new PumpEnactResultObject(injector).success(false).enacted(false).comment(errorMessage); return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage);
} }
addSuccessToHistory(PodHistoryEntryType.SET_TIME, null); addSuccessToHistory(PodHistoryEntryType.SET_TIME, null);
@ -632,7 +631,7 @@ public class AapsOmnipodErosManager {
dismissNotification(Notification.OMNIPOD_POD_SUSPENDED); dismissNotification(Notification.OMNIPOD_POD_SUSPENDED);
dismissNotification(Notification.OMNIPOD_TIME_OUT_OF_SYNC); dismissNotification(Notification.OMNIPOD_TIME_OUT_OF_SYNC);
return new PumpEnactResultObject(injector).success(true).enacted(true); return new PumpEnactResult(injector).success(true).enacted(true);
} }
public PodInfoRecentPulseLog readPulseLog() { public PodInfoRecentPulseLog readPulseLog() {

View file

@ -3,12 +3,12 @@ package info.nightscout.androidaps.plugins.pump.omnipod.eros
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.TestBase import info.nightscout.androidaps.TestBase
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.plugins.pump.common.defs.TempBasalPair import info.nightscout.androidaps.plugins.pump.common.defs.TempBasalPair
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil
import info.nightscout.androidaps.plugins.pump.omnipod.eros.manager.AapsOmnipodErosManager import info.nightscout.androidaps.plugins.pump.omnipod.eros.manager.AapsOmnipodErosManager
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.pump.PumpSync import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.pump.defs.PumpType import info.nightscout.interfaces.pump.defs.PumpType
import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.interfaces.queue.CommandQueue
@ -74,7 +74,7 @@ class OmnipodErosPumpPluginTest : TestBase() {
) )
).thenAnswer { invocation: InvocationOnMock -> ).thenAnswer { invocation: InvocationOnMock ->
val pair = invocation.getArgument<TempBasalPair>(0) val pair = invocation.getArgument<TempBasalPair>(0)
val result = PumpEnactResultObject(injector) val result = PumpEnactResult(injector)
result.absolute(pair.insulinRate) result.absolute(pair.insulinRate)
result.duration(pair.durationMinutes) result.duration(pair.durationMinutes)
result result

View file

@ -6,7 +6,6 @@ import android.content.ServiceConnection
import android.text.format.DateFormat import android.text.format.DateFormat
import com.google.gson.GsonBuilder import com.google.gson.GsonBuilder
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.extensions.convertedToAbsolute import info.nightscout.androidaps.extensions.convertedToAbsolute
import info.nightscout.androidaps.extensions.plannedRemainingMinutes import info.nightscout.androidaps.extensions.plannedRemainingMinutes
import info.nightscout.androidaps.extensions.toStringFull import info.nightscout.androidaps.extensions.toStringFull
@ -313,7 +312,7 @@ abstract class PumpPluginAbstract protected constructor(
if (detailedBolusInfo.insulin == 0.0 && detailedBolusInfo.carbs == 0.0) { if (detailedBolusInfo.insulin == 0.0 && detailedBolusInfo.carbs == 0.0) {
// neither carbs nor bolus requested // neither carbs nor bolus requested
aapsLogger.error("deliverTreatment: Invalid input") aapsLogger.error("deliverTreatment: Invalid input")
PumpEnactResultObject(injector).success(false).enacted(false).bolusDelivered(0.0).carbsDelivered(0.0) PumpEnactResult(injector).success(false).enacted(false).bolusDelivered(0.0).carbsDelivered(0.0)
.comment(R.string.invalidinput) .comment(R.string.invalidinput)
} else if (detailedBolusInfo.insulin > 0) { } else if (detailedBolusInfo.insulin > 0) {
// bolus needed, ask pump to deliver it // bolus needed, ask pump to deliver it
@ -329,7 +328,7 @@ abstract class PumpPluginAbstract protected constructor(
bolusingEvent.percent = 100 bolusingEvent.percent = 100
rxBus.send(bolusingEvent) rxBus.send(bolusingEvent)
aapsLogger.debug(LTag.PUMP, "deliverTreatment: Carb only treatment.") aapsLogger.debug(LTag.PUMP, "deliverTreatment: Carb only treatment.")
PumpEnactResultObject(injector).success(true).enacted(true).bolusDelivered(0.0) PumpEnactResult(injector).success(true).enacted(true).bolusDelivered(0.0)
.carbsDelivered(detailedBolusInfo.carbs).comment(R.string.common_resultok) .carbsDelivered(detailedBolusInfo.carbs).comment(R.string.common_resultok)
} }
} finally { } finally {
@ -350,7 +349,7 @@ abstract class PumpPluginAbstract protected constructor(
protected abstract fun triggerUIChange() protected abstract fun triggerUIChange()
private fun getOperationNotSupportedWithCustomText(resourceId: Int): PumpEnactResult = private fun getOperationNotSupportedWithCustomText(resourceId: Int): PumpEnactResult =
PumpEnactResultObject(injector).success(false).enacted(false).comment(resourceId) PumpEnactResult(injector).success(false).enacted(false).comment(resourceId)
init { init {
pumpDescription.fillFor(pumpType) pumpDescription.fillFor(pumpType)

View file

@ -1,7 +1,6 @@
package info.nightscout.androidaps package info.nightscout.androidaps
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.pump.DetailedBolusInfo import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.pump.Pump import info.nightscout.interfaces.pump.Pump
@ -44,30 +43,30 @@ class TestPumpPlugin(val injector: HasAndroidInjector) : Pump {
override fun waitForDisconnectionInSeconds(): Int = 0 override fun waitForDisconnectionInSeconds(): Int = 0
override fun getPumpStatus(reason: String) {} override fun getPumpStatus(reason: String) {}
override fun setNewBasalProfile(profile: Profile): PumpEnactResult = PumpEnactResultObject(injector) override fun setNewBasalProfile(profile: Profile): PumpEnactResult = PumpEnactResult(injector)
override fun isThisProfileSet(profile: Profile): Boolean = isProfileSet override fun isThisProfileSet(profile: Profile): Boolean = isProfileSet
override fun lastDataTime(): Long = lastData override fun lastDataTime(): Long = lastData
override val baseBasalRate: Double = baseBasal override val baseBasalRate: Double = baseBasal
override val reservoirLevel: Double = 0.0 override val reservoirLevel: Double = 0.0
override val batteryLevel: Int = 0 override val batteryLevel: Int = 0
override fun deliverTreatment(detailedBolusInfo: DetailedBolusInfo): PumpEnactResult = PumpEnactResultObject(injector).success(true) override fun deliverTreatment(detailedBolusInfo: DetailedBolusInfo): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun stopBolusDelivering() {} override fun stopBolusDelivering() {}
override fun setTempBasalAbsolute(absoluteRate: Double, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult = override fun setTempBasalAbsolute(absoluteRate: Double, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult =
PumpEnactResultObject(injector).success(true) PumpEnactResult(injector).success(true)
override fun setTempBasalPercent(percent: Int, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult = override fun setTempBasalPercent(percent: Int, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult =
PumpEnactResultObject(injector).success(true) PumpEnactResult(injector).success(true)
override fun setExtendedBolus(insulin: Double, durationInMinutes: Int): PumpEnactResult = PumpEnactResultObject(injector).success(true) override fun setExtendedBolus(insulin: Double, durationInMinutes: Int): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult = PumpEnactResultObject(injector).success(true) override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun cancelExtendedBolus(): PumpEnactResult = PumpEnactResultObject(injector).success(true) override fun cancelExtendedBolus(): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun getJSONStatus(profile: Profile, profileName: String, version: String): JSONObject = JSONObject() override fun getJSONStatus(profile: Profile, profileName: String, version: String): JSONObject = JSONObject()
override fun manufacturer(): ManufacturerType = ManufacturerType.AAPS override fun manufacturer(): ManufacturerType = ManufacturerType.AAPS
override fun model(): PumpType = PumpType.GENERIC_AAPS override fun model(): PumpType = PumpType.GENERIC_AAPS
override fun serialNumber(): String = "1" override fun serialNumber(): String = "1"
override fun shortStatus(veryShort: Boolean): String = "" override fun shortStatus(veryShort: Boolean): String = ""
override val isFakingTempsByExtendedBoluses: Boolean = false override val isFakingTempsByExtendedBoluses: Boolean = false
override fun loadTDDs(): PumpEnactResult = PumpEnactResultObject(injector).success(true) override fun loadTDDs(): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun canHandleDST(): Boolean = true override fun canHandleDST(): Boolean = true
override fun timezoneOrDSTChanged(timeChangeType: TimeChangeType) {} override fun timezoneOrDSTChanged(timeChangeType: TimeChangeType) {}
} }