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.plugins.aps.loop.events.EventLoopSetLastRunGui
import info.nightscout.androidaps.plugins.aps.loop.events.EventLoopUpdateGui
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.core.fabric.FabricPrivacy
import info.nightscout.interfaces.aps.Loop
import info.nightscout.interfaces.constraints.Constraint
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.utils.HtmlHelper
import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus
@ -135,9 +137,9 @@ class LoopFragment : DaggerFragment(), MenuProvider {
binding.tbrrequestTime.text = dateUtil.dateAndTimeAndSecondsString(it.lastTBRRequest)
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 =
@ -168,4 +170,44 @@ class LoopFragment : DaggerFragment(), MenuProvider {
binding.smbsetbypump.text = ""
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.R
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.extensions.convertedToAbsolute
import info.nightscout.androidaps.extensions.convertedToPercent
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.ProfileFunction
import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.pump.defs.PumpDescription
import info.nightscout.interfaces.queue.Callback
@ -383,7 +383,7 @@ class LoopPlugin @Inject constructor(
if (resultAfterConstraints.isChangeRequested
&& !commandQueue.bolusInQueue()
) {
val waiting = PumpEnactResultObject(injector)
val waiting = PumpEnactResult(injector)
waiting.queued = true
if (resultAfterConstraints.isTempBasalRequested) lastRun.tbrSetByPump = waiting
if (resultAfterConstraints.isBolusRequested) lastRun.smbSetByPump =
@ -535,18 +535,18 @@ class LoopPlugin @Inject constructor(
*/
private fun applyTBRRequest(request: APSResult, profile: Profile, callback: Callback?) {
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
}
val pump = activePlugin.activePump
if (!pump.isInitialized()) {
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
}
if (pump.isSuspended()) {
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
}
aapsLogger.debug(LTag.APS, "applyAPSRequest: $request")
@ -560,7 +560,7 @@ class LoopPlugin @Inject constructor(
} else {
aapsLogger.debug(LTag.APS, "applyAPSRequest: Basal set correctly")
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)
)?.run()
}
@ -573,7 +573,7 @@ class LoopPlugin @Inject constructor(
} else {
aapsLogger.debug(LTag.APS, "applyAPSRequest: Basal set correctly")
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)
)?.run()
}
@ -584,7 +584,7 @@ class LoopPlugin @Inject constructor(
) {
aapsLogger.debug(LTag.APS, "applyAPSRequest: Temp basal set correctly")
callback?.result(
PumpEnactResultObject(injector).percent(request.percent)
PumpEnactResult(injector).percent(request.percent)
.enacted(false).success(true).duration(activeTemp.plannedRemainingMinutes)
.comment(R.string.let_temp_basal_run)
)?.run()
@ -607,7 +607,7 @@ class LoopPlugin @Inject constructor(
) {
aapsLogger.debug(LTag.APS, "applyAPSRequest: Temp basal set correctly")
callback?.result(
PumpEnactResultObject(injector).absolute(activeTemp.convertedToAbsolute(now, profile))
PumpEnactResult(injector).absolute(activeTemp.convertedToAbsolute(now, profile))
.enacted(false).success(true).duration(activeTemp.plannedRemainingMinutes)
.comment(R.string.let_temp_basal_run)
)?.run()
@ -633,7 +633,7 @@ class LoopPlugin @Inject constructor(
if (lastBolusTime != 0L && lastBolusTime + 3 * 60 * 1000 > System.currentTimeMillis()) {
aapsLogger.debug(LTag.APS, "SMB requested but still in 3 min interval")
callback?.result(
PumpEnactResultObject(injector)
PumpEnactResult(injector)
.comment(R.string.smb_frequency_exceeded)
.enacted(false).success(false)
)?.run()
@ -641,12 +641,12 @@ class LoopPlugin @Inject constructor(
}
if (!pump.isInitialized()) {
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
}
if (pump.isSuspended()) {
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
}
aapsLogger.debug(LTag.APS, "applySMBRequest: $request")

View file

@ -1,7 +1,6 @@
package info.nightscout.androidaps
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.pump.Pump
@ -44,30 +43,30 @@ class TestPumpPlugin(val injector: HasAndroidInjector) : Pump {
override fun waitForDisconnectionInSeconds(): Int = 0
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 lastDataTime(): Long = lastData
override val baseBasalRate: Double = baseBasal
override val reservoirLevel: Double = 0.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 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 =
PumpEnactResultObject(injector).success(true)
PumpEnactResult(injector).success(true)
override fun setExtendedBolus(insulin: Double, durationInMinutes: Int): PumpEnactResult = PumpEnactResultObject(injector).success(true)
override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult = PumpEnactResultObject(injector).success(true)
override fun cancelExtendedBolus(): PumpEnactResult = PumpEnactResultObject(injector).success(true)
override fun setExtendedBolus(insulin: Double, durationInMinutes: Int): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun cancelExtendedBolus(): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun getJSONStatus(profile: Profile, profileName: String, version: String): JSONObject = JSONObject()
override fun manufacturer(): ManufacturerType = ManufacturerType.AAPS
override fun model(): PumpType = PumpType.GENERIC_AAPS
override fun serialNumber(): String = "1"
override fun shortStatus(veryShort: Boolean): String = ""
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 timezoneOrDSTChanged(timeChangeType: TimeChangeType) {}
}

View file

@ -8,7 +8,6 @@ import info.nightscout.androidaps.TestBaseWithProfile
import info.nightscout.androidaps.dana.DanaPump
import info.nightscout.androidaps.danar.DanaRPlugin
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.InsightDbHelper
import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin

View file

@ -4,17 +4,17 @@ import android.content.Context
import android.widget.LinearLayout
import androidx.annotation.DrawableRes
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.elements.InputString
import info.nightscout.automation.elements.LabelWithElement
import info.nightscout.automation.elements.LayoutBuilder
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.shared.utils.DateUtil
import org.json.JSONObject
import javax.inject.Inject
@ -41,7 +41,7 @@ class ActionAlarm(injector: HasAndroidInjector) : Action(injector) {
override fun doAction(callback: Callback) {
timerUtil.scheduleReminder(10, text.value.takeIf { it.isNotBlank() }
?: 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 {

View file

@ -2,7 +2,6 @@ package info.nightscout.automation.actions
import androidx.annotation.DrawableRes
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.automation.R
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.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.rx.bus.RxBus
@ -41,7 +41,7 @@ class ActionLoopDisable(injector: HasAndroidInjector) : Action(injector) {
}
})
} 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 dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.automation.R
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.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventRefreshOverview
@ -33,9 +33,9 @@ class ActionLoopEnable(injector: HasAndroidInjector) : Action(injector) {
configBuilder.storeSettings("ActionLoopEnable")
rxBus.send(EventRefreshOverview("ActionLoopEnable"))
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 {
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 dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.automation.R
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.interfaces.ConfigBuilder
import info.nightscout.interfaces.aps.Loop
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventRefreshOverview
@ -45,9 +45,9 @@ class ActionLoopResume(injector: HasAndroidInjector) : Action(injector) {
})
rxBus.send(EventRefreshOverview("ActionLoopResume"))
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 {
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 androidx.annotation.DrawableRes
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.automation.R
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.ValueWithUnit
import info.nightscout.interfaces.aps.Loop
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.utils.JsonHelper
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()),
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 {
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 androidx.annotation.DrawableRes
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.interfaces.notifications.NotificationUserMessage
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.automation.R
import info.nightscout.automation.elements.InputString
import info.nightscout.automation.elements.LabelWithElement
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.events.EventRefreshOverview
import io.reactivex.rxjava3.disposables.CompositeDisposable
@ -39,7 +39,7 @@ class ActionNotification(injector: HasAndroidInjector) : Action(injector) {
rxBus.send(EventNewNotification(notification))
disposable += repository.runTransaction(InsertTherapyEventAnnouncementTransaction(text.value)).subscribe()
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 {

View file

@ -3,7 +3,6 @@ package info.nightscout.automation.actions
import android.widget.LinearLayout
import androidx.annotation.DrawableRes
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.automation.R
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.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.rx.logging.LTag
@ -39,23 +39,23 @@ class ActionProfileSwitch(injector: HasAndroidInjector) : Action(injector) {
//Check for uninitialized profileName
if (inputProfileName.value == "") {
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
}
if (profileFunction.getProfile() == null) {
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
}
if (inputProfileName.value == activeProfileName) {
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
}
val profileStore = activePlugin.activeProfileSource.profile ?: return
if (profileStore.getSpecificProfile(inputProfileName.value) == null) {
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
}
uel.log(
@ -64,7 +64,7 @@ class ActionProfileSwitch(injector: HasAndroidInjector) : Action(injector) {
ValueWithUnit.Percent(100)
)
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) {

View file

@ -3,7 +3,6 @@ package info.nightscout.automation.actions
import android.widget.LinearLayout
import androidx.annotation.DrawableRes
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.automation.R
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.ValueWithUnit
import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.rx.logging.LTag
@ -50,10 +50,10 @@ class ActionProfileSwitchPercent(injector: HasAndroidInjector) : Action(injector
ValueWithUnit.Percent(pct.value.toInt()),
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 {
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 androidx.annotation.DrawableRes
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.automation.R
import info.nightscout.automation.elements.InputDuration
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.plugin.ActivePlugin
import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.rx.logging.LTag
@ -48,11 +48,11 @@ class ActionRunAutotune(injector: HasAndroidInjector) : Action(injector) {
message = R.string.autotune_run_with_error
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 {
message = R.string.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()
return

View file

@ -2,11 +2,11 @@ package info.nightscout.automation.actions
import android.widget.LinearLayout
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.automation.R
import info.nightscout.automation.elements.InputString
import info.nightscout.automation.elements.LabelWithElement
import info.nightscout.automation.elements.LayoutBuilder
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.smsCommunicator.SmsCommunicator
import info.nightscout.interfaces.utils.JsonHelper
@ -25,7 +25,7 @@ class ActionSendSMS(injector: HasAndroidInjector) : Action(injector) {
override fun doAction(callback: Callback) {
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()

View file

@ -3,7 +3,6 @@ package info.nightscout.automation.actions
import android.widget.LinearLayout
import androidx.annotation.DrawableRes
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.extensions.friendlyDescription
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.automation.R
@ -25,6 +24,7 @@ import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.utils.JsonHelper
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.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)
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 com.google.gson.JsonObject
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.interfaces.queue.Callback
import info.nightscout.automation.R
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback
import org.json.JSONObject
class ActionStopProcessing(injector: HasAndroidInjector) : Action(injector) {
@ -17,7 +17,7 @@ class ActionStopProcessing(injector: HasAndroidInjector) : Action(injector) {
override fun isValid(): Boolean = true
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 {

View file

@ -1,13 +1,13 @@
package info.nightscout.automation.actions
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.automation.R
import info.nightscout.database.entities.UserEntry
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.rx.logging.LTag
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)
})
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

View file

@ -1,7 +1,6 @@
package info.nightscout.androidaps
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.profile.Profile
@ -56,31 +55,31 @@ class TestPumpPlugin(
override fun waitForDisconnectionInSeconds(): Int = 0
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 lastDataTime(): Long = lastData
override val baseBasalRate: Double = baseBasal
override val reservoirLevel: Double = 0.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 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
).success(true)
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 cancelTempBasal(enforceNew: Boolean): PumpEnactResult = PumpEnactResultObject(injector).success(true)
override fun cancelExtendedBolus(): PumpEnactResult = PumpEnactResultObject(injector).success(true)
override fun setExtendedBolus(insulin: Double, durationInMinutes: Int): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun cancelExtendedBolus(): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun getJSONStatus(profile: Profile, profileName: String, version: String): JSONObject = JSONObject()
override fun manufacturer(): ManufacturerType = ManufacturerType.AAPS
override fun model(): PumpType = PumpType.GENERIC_AAPS
override fun serialNumber(): String = "1"
override fun shortStatus(veryShort: Boolean): String = ""
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 timezoneOrDSTChanged(timeChangeType: TimeChangeType) {}
override fun specialEnableCondition(): Boolean = specialEnable

View file

@ -4,15 +4,14 @@ import android.content.Context
import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector
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.elements.InputString
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.shared.interfaces.ResourceHelper
import info.nightscout.shared.utils.DateUtil
import org.junit.Assert
import org.junit.Before
import org.junit.Test

View file

@ -3,15 +3,14 @@ package info.nightscout.automation.actions
import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector
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.transactions.InsertTherapyEventAnnouncementTransaction
import info.nightscout.database.impl.transactions.Transaction
import info.nightscout.shared.interfaces.ResourceHelper
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.shared.interfaces.ResourceHelper
import io.reactivex.rxjava3.core.Completable
import org.junit.Assert
import org.junit.Before

View file

@ -4,7 +4,6 @@ import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.TestBaseWithProfile
import info.nightscout.androidaps.TestPumpPlugin
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.automation.triggers.Trigger
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.android.ContributesAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.plugins.aps.loop.APSResultObject
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensDataObject
import info.nightscout.core.profile.ProfileStoreObject
import info.nightscout.interfaces.pump.PumpEnactResult
@Module
@Suppress("unused")
abstract class CoreDataClassesModule {
@ContributesAndroidInjector abstract fun pumpEnactResultInjector(): PumpEnactResultObject
@ContributesAndroidInjector abstract fun pumpEnactResultInjector(): PumpEnactResult
@ContributesAndroidInjector abstract fun apsResultInjector(): APSResultObject
@ContributesAndroidInjector abstract fun autosensDataInjector(): AutosensDataObject

View file

@ -1,7 +1,6 @@
package info.nightscout.androidaps
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.pump.Pump
@ -44,30 +43,30 @@ class TestPumpPlugin(val injector: HasAndroidInjector) : Pump {
override fun waitForDisconnectionInSeconds(): Int = 0
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 lastDataTime(): Long = lastData
override val baseBasalRate: Double = baseBasal
override val reservoirLevel: Double = 0.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 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 =
PumpEnactResultObject(injector).success(true)
PumpEnactResult(injector).success(true)
override fun setExtendedBolus(insulin: Double, durationInMinutes: Int): PumpEnactResult = PumpEnactResultObject(injector).success(true)
override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult = PumpEnactResultObject(injector).success(true)
override fun cancelExtendedBolus(): PumpEnactResult = PumpEnactResultObject(injector).success(true)
override fun setExtendedBolus(insulin: Double, durationInMinutes: Int): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun cancelExtendedBolus(): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun getJSONStatus(profile: Profile, profileName: String, version: String): JSONObject = JSONObject()
override fun manufacturer(): ManufacturerType = ManufacturerType.AAPS
override fun model(): PumpType = PumpType.GENERIC_AAPS
override fun serialNumber(): String = "1"
override fun shortStatus(veryShort: Boolean): String = ""
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 timezoneOrDSTChanged(timeChangeType: TimeChangeType) {}
}

View file

@ -37,84 +37,84 @@ class PumpEnactResultTest : TestBaseWithProfile() {
}
@Test fun successTest() {
val per = PumpEnactResultObject(injector)
val per = PumpEnactResult(injector)
per.success(true)
Assert.assertEquals(true, per.success)
}
@Test fun enactedTest() {
val per = PumpEnactResultObject(injector)
val per = PumpEnactResult(injector)
per.enacted(true)
Assert.assertEquals(true, per.enacted)
}
@Test fun commentTest() {
val per = PumpEnactResultObject(injector)
val per = PumpEnactResult(injector)
per.comment("SomeComment")
Assert.assertEquals("SomeComment", per.comment)
}
@Test fun durationTest() {
val per = PumpEnactResultObject(injector)
val per = PumpEnactResult(injector)
per.duration(10)
Assert.assertEquals(10, per.duration.toLong())
}
@Test fun absoluteTest() {
val per = PumpEnactResultObject(injector)
val per = PumpEnactResult(injector)
per.absolute(11.0)
Assert.assertEquals(11.0, per.absolute, 0.01)
}
@Test fun percentTest() {
val per = PumpEnactResultObject(injector)
val per = PumpEnactResult(injector)
per.percent(10)
Assert.assertEquals(10, per.percent)
}
@Test fun isPercentTest() {
val per = PumpEnactResultObject(injector)
val per = PumpEnactResult(injector)
per.isPercent(true)
Assert.assertEquals(true, per.isPercent)
}
@Test fun isTempCancelTest() {
val per = PumpEnactResultObject(injector)
val per = PumpEnactResult(injector)
per.isTempCancel(true)
Assert.assertEquals(true, per.isTempCancel)
}
@Test fun bolusDeliveredTest() {
val per = PumpEnactResultObject(injector)
val per = PumpEnactResult(injector)
per.bolusDelivered(11.0)
Assert.assertEquals(11.0, per.bolusDelivered, 0.01)
}
@Test fun carbsDeliveredTest() {
val per = PumpEnactResultObject(injector)
val per = PumpEnactResult(injector)
per.carbsDelivered(11.0)
Assert.assertEquals(11.0, per.carbsDelivered, 0.01)
}
@Test fun queuedTest() {
val per = PumpEnactResultObject(injector)
val per = PumpEnactResult(injector)
per.queued(true)
Assert.assertEquals(true, per.queued)
}
@Test fun logTest() {
val per = PumpEnactResultObject(injector)
val per = PumpEnactResult(injector)
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",
@ -123,7 +123,7 @@ class PumpEnactResultTest : TestBaseWithProfile() {
}
@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(
"""
Success: false
@ -132,7 +132,7 @@ class PumpEnactResultTest : TestBaseWithProfile() {
Insulin: 10.0 U
""".trimIndent(), per.toString()
)
per = PumpEnactResultObject(injector).enacted(true).isTempCancel(true).comment("AAA")
per = PumpEnactResult(injector).enacted(true).isTempCancel(true).comment("AAA")
Assert.assertEquals(
"""
Success: false
@ -141,7 +141,7 @@ class PumpEnactResultTest : TestBaseWithProfile() {
Cancel temp basal
""".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(
"""
Success: false
@ -151,7 +151,7 @@ class PumpEnactResultTest : TestBaseWithProfile() {
Percent: 90%
""".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(
"""
Success: false
@ -161,7 +161,7 @@ class PumpEnactResultTest : TestBaseWithProfile() {
Absolute: 1.0 U/h
""".trimIndent(), per.toString()
)
per = PumpEnactResultObject(injector).enacted(false).comment("AAA")
per = PumpEnactResult(injector).enacted(false).comment("AAA")
Assert.assertEquals(
"""
Success: false
@ -172,31 +172,31 @@ class PumpEnactResultTest : TestBaseWithProfile() {
@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())
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())
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())
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())
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())
}
@Test fun jsonTest() {
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())
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())
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())
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())
JSONAssert.assertEquals("{\"rate\":1,\"duration\":30}", o, false)
}

View file

@ -8,7 +8,6 @@ import androidx.appcompat.app.AppCompatActivity
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.androidaps.data.ProfileSealed
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.dialogs.BolusProgressDialog
import info.nightscout.androidaps.extensions.getCustomizedName
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissBolusProgressIfRunning
@ -147,7 +146,7 @@ class CommandQueueImplementation @Inject constructor(
}
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
@ -271,12 +270,12 @@ class CommandQueueImplementation @Inject constructor(
.subscribeBy(
onSuccess = { result ->
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 = {
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 (bolusInQueue()) {
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
}
val lastBolusTime = repository.getLastBolusRecord()?.timestamp ?: 0L
if (detailedBolusInfo.lastKnownBolusTime < lastBolusTime) {
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
}
removeAll(CommandType.SMB_BOLUS)
@ -352,7 +351,7 @@ class CommandQueueImplementation @Inject constructor(
@Synchronized
override fun cancelAllBoluses(id: Long?) {
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.SMB_BOLUS)
@ -436,12 +435,12 @@ class CommandQueueImplementation @Inject constructor(
override fun setProfile(profile: Profile, hasNsId: Boolean, callback: Callback?): Boolean {
if (isRunning(CommandType.BASAL_PROFILE)) {
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
}
if (isThisProfileSet(profile) && repository.getEffectiveProfileSwitchActiveAt(dateUtil.now()).blockingGet() is ValueWrapper.Existing) {
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
}
// Compare with pump limits
@ -450,7 +449,7 @@ class CommandQueueImplementation @Inject constructor(
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)
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
}
}

View file

@ -1,12 +1,12 @@
package info.nightscout.implementation.queue.commands
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.dialogs.BolusProgressDialog
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissBolusProgressIfRunning
import info.nightscout.implementation.R
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.Command
import info.nightscout.rx.bus.RxBus
@ -45,6 +45,6 @@ class CommandBolus(
override fun 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
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.implementation.R
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.Command
import info.nightscout.rx.logging.LTag
@ -27,6 +27,6 @@ class CommandCancelExtendedBolus constructor(
override fun log(): String = "CANCEL EXTENDEDBOLUS"
override fun 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
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.implementation.R
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.Command
import info.nightscout.rx.logging.LTag
@ -28,6 +28,6 @@ class CommandCancelTempBasal(
override fun log(): String = "CANCEL TEMPBASAL"
override fun 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
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.Command
import info.nightscout.interfaces.queue.CustomCommand
@ -29,6 +29,6 @@ class CommandCustomCommand(
override fun log(): String = customCommand.statusDescription
override fun 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
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.implementation.R
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.Command
import info.nightscout.rx.logging.LTag
@ -29,6 +29,6 @@ class CommandExtendedBolus constructor(
override fun log(): String = "EXTENDEDBOLUS $insulin U $durationInMinutes min"
override fun 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
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.implementation.R
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.pump.Insight
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.Command
import info.nightscout.rx.logging.LTag
@ -32,6 +32,6 @@ class CommandInsightSetTBROverNotification constructor(
override fun log(): String = "INSIGHTSETTBROVERNOTIFICATION"
override fun 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
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.implementation.R
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.pump.Dana
import info.nightscout.interfaces.pump.Diaconn
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.Command
import info.nightscout.rx.logging.LTag
@ -40,6 +40,6 @@ class CommandLoadEvents(
override fun log(): String = "LOAD EVENTS"
override fun 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
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.implementation.R
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.pump.Dana
import info.nightscout.interfaces.pump.Diaconn
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.Command
import info.nightscout.rx.logging.LTag
@ -41,6 +41,6 @@ class CommandLoadHistory(
override fun log(): String = "LOAD HISTORY $type"
override fun 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
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.implementation.R
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.Command
import info.nightscout.rx.logging.LTag
@ -28,6 +28,6 @@ class CommandLoadTDDs(
override fun log(): String = "LOAD TDDs"
override fun 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
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.implementation.R
import info.nightscout.interfaces.LocalAlertUtils
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.Command
import info.nightscout.rx.logging.LTag
@ -25,7 +25,7 @@ class CommandReadStatus(
localAlertUtils.notifyPumpStatusRead()
aapsLogger.debug(LTag.PUMPQUEUE, "CommandReadStatus executed. Reason: $reason")
val pump = activePlugin.activePump
val result = PumpEnactResultObject(injector).success(false)
val result = PumpEnactResult(injector).success(false)
val lastConnection = pump.lastDataTime()
if (lastConnection > System.currentTimeMillis() - T.mins(1).msecs()) result.success(true)
callback?.result(result)?.run()
@ -36,6 +36,6 @@ class CommandReadStatus(
override fun log(): String = "READSTATUS $reason"
override fun 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
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.database.impl.AppRepository
import info.nightscout.implementation.R
import info.nightscout.interfaces.plugin.ActivePlugin
@ -30,11 +29,11 @@ class CommandSMBBolus(
aapsLogger.debug(LTag.PUMPQUEUE, "Last bolus: $lastBolusTime ${dateUtil.dateAndTimeAndSecondsString(lastBolusTime)}")
if (lastBolusTime != 0L && lastBolusTime + T.mins(3).msecs() > dateUtil.now()) {
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()) {
r = activePlugin.activePump.deliverTreatment(detailedBolusInfo)
} 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, "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 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
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.ValueWrapper
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.PluginBase
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.Command
import info.nightscout.interfaces.queue.CommandQueue
@ -34,7 +34,7 @@ class CommandSetProfile constructor(
override fun execute() {
if (commandQueue.isThisProfileSet(profile) && repository.getEffectiveProfileSwitchActiveAt(dateUtil.now()).blockingGet() is ValueWrapper.Existing) {
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
}
val r = activePlugin.activePump.setNewBasalProfile(profile)
@ -53,6 +53,6 @@ class CommandSetProfile constructor(
override fun log(): String = "SET PROFILE"
override fun 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
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.implementation.R
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.pump.Dana
import info.nightscout.interfaces.pump.Diaconn
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.Command
import info.nightscout.rx.logging.LTag
@ -38,6 +38,6 @@ class CommandSetUserSettings(
override fun log(): String = "SET USER SETTINGS"
override fun 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
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.implementation.R
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.pump.Insight
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.Command
import info.nightscout.rx.logging.LTag
@ -30,6 +30,6 @@ class CommandStartPump(
override fun log(): String = "START PUMP"
override fun 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
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.implementation.R
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.pump.Insight
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.Command
import info.nightscout.rx.logging.LTag
@ -30,6 +30,6 @@ class CommandStopPump(
override fun log(): String = "STOP PUMP"
override fun 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
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.implementation.R
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.queue.Callback
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 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
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.implementation.R
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.Command
@ -38,6 +38,6 @@ class CommandTempBasalPercent(
override fun log(): String = "TEMP BASAL $percent% $durationInMinutes min"
override fun 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
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.pump.Pump
@ -44,30 +43,30 @@ class TestPumpPlugin(val injector: HasAndroidInjector) : Pump {
override fun waitForDisconnectionInSeconds(): Int = 0
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 lastDataTime(): Long = lastData
override val baseBasalRate: Double = baseBasal
override val reservoirLevel: Double = 0.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 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 =
PumpEnactResultObject(injector).success(true)
PumpEnactResult(injector).success(true)
override fun setExtendedBolus(insulin: Double, durationInMinutes: Int): PumpEnactResult = PumpEnactResultObject(injector).success(true)
override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult = PumpEnactResultObject(injector).success(true)
override fun cancelExtendedBolus(): PumpEnactResult = PumpEnactResultObject(injector).success(true)
override fun setExtendedBolus(insulin: Double, durationInMinutes: Int): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun cancelExtendedBolus(): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun getJSONStatus(profile: Profile, profileName: String, version: String): JSONObject = JSONObject()
override fun manufacturer(): ManufacturerType = ManufacturerType.AAPS
override fun model(): PumpType = PumpType.GENERIC_AAPS
override fun serialNumber(): String = "1"
override fun shortStatus(veryShort: Boolean): String = ""
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 timezoneOrDSTChanged(timeChangeType: TimeChangeType) {}
}

View file

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

View file

@ -30,7 +30,6 @@ import javax.inject.Inject;
import javax.inject.Singleton;
import dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.data.PumpEnactResultObject;
import info.nightscout.androidaps.insight.R;
import info.nightscout.androidaps.insight.database.InsightBolusID;
import info.nightscout.androidaps.insight.database.InsightDbHelper;
@ -475,7 +474,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Insight,
@NonNull @Override
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));
List<BasalProfileBlock> profileBlocks = new ArrayList<>();
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) {
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;
if (insulin > 0) {
try {
@ -691,7 +690,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Insight,
@NonNull @Override
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.getActiveBasalRate() == 0) return result;
double percent = 100D / activeBasalRate.getActiveBasalRate() * absoluteRate;
@ -741,7 +740,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Insight,
@NonNull @Override
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;
if (percent == 100) return cancelTempBasal(true);
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) {
PumpEnactResult result = new PumpEnactResultObject(getInjector());
PumpEnactResult result = new PumpEnactResult(getInjector());
try {
DeliverBolusMessage bolusMessage = new DeliverBolusMessage();
bolusMessage.setBolusType(BolusType.EXTENDED);
@ -829,7 +828,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Insight,
@NonNull @Override
public PumpEnactResult cancelTempBasal(boolean enforceNew) {
PumpEnactResult result = new PumpEnactResultObject(getInjector());
PumpEnactResult result = new PumpEnactResult(getInjector());
PumpEnactResult cancelEBResult = null;
if (isFakingTempsByExtendedBoluses()) cancelEBResult = cancelExtendedBolusOnly();
PumpEnactResult cancelTBRResult = cancelTempBasalOnly();
@ -850,7 +849,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Insight,
}
private PumpEnactResult cancelTempBasalOnly() {
PumpEnactResult result = new PumpEnactResultObject(getInjector());
PumpEnactResult result = new PumpEnactResult(getInjector());
try {
alertService.ignore(AlertType.WARNING_36);
connectionService.requestMessage(new CancelTBRMessage()).await();
@ -893,7 +892,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Insight,
}
private PumpEnactResult cancelExtendedBolusOnly() {
PumpEnactResult result = new PumpEnactResultObject(getInjector());
PumpEnactResult result = new PumpEnactResult(getInjector());
try {
for (ActiveBolus activeBolus : activeBoluses) {
if (activeBolus.getBolusType() == BolusType.EXTENDED || activeBolus.getBolusType() == BolusType.MULTIWAVE) {
@ -1012,7 +1011,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Insight,
}
public PumpEnactResult stopPump() {
PumpEnactResult result = new PumpEnactResultObject(getInjector());
PumpEnactResult result = new PumpEnactResult(getInjector());
try {
SetOperatingModeMessage operatingModeMessage = new SetOperatingModeMessage();
operatingModeMessage.setOperatingMode(OperatingMode.STOPPED);
@ -1034,7 +1033,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Insight,
}
public PumpEnactResult startPump() {
PumpEnactResult result = new PumpEnactResultObject(getInjector());
PumpEnactResult result = new PumpEnactResult(getInjector());
try {
SetOperatingModeMessage operatingModeMessage = new SetOperatingModeMessage();
operatingModeMessage.setOperatingMode(OperatingMode.STARTED);
@ -1056,7 +1055,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Insight,
}
public PumpEnactResult setTBROverNotification(boolean enabled) {
PumpEnactResult result = new PumpEnactResultObject(getInjector());
PumpEnactResult result = new PumpEnactResult(getInjector());
boolean valueBefore = tbrOverNotificationBlock.isEnabled();
tbrOverNotificationBlock.setEnabled(enabled);
try {
@ -1119,7 +1118,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Insight,
@NonNull @Override
public PumpEnactResult loadTDDs() {
return new PumpEnactResultObject(getInjector()).success(true);
return new PumpEnactResult(getInjector()).success(true);
}
private void readHistory() {

View file

@ -1,40 +1,43 @@
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)
var enacted: Boolean // request was processed successfully and change has been made
var comment: String
@Inject lateinit var context: Context
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
var duration: Int // duration set [minutes]
var absolute: Double // absolute rate [U/h] , isPercent = false
var percent: Int // percent of current basal [%] (100% = current basal), isPercent = true
var isPercent: Boolean // if true percent is used, otherwise absolute
var isTempCancel: Boolean // if true we are canceling temp basal
var duration = -1 // duration set [minutes]
var absolute = -1.0 // absolute rate [U/h] , isPercent = false
var percent = -1 // percent of current basal [%] (100% = current basal), isPercent = true
var isPercent = false // if true percent is used, otherwise absolute
var isTempCancel = false // if true we are canceling temp basal
// Result of treatment delivery
var bolusDelivered: Double // real value of delivered insulin
var carbsDelivered: Double // real value of delivered carbs
var queued: Boolean
var bolusDelivered = 0.0 // real value of delivered insulin
var carbsDelivered = 0.0 // real value of delivered carbs
var queued = false
fun success(success: Boolean): PumpEnactResult
fun enacted(enacted: Boolean): PumpEnactResult
fun comment(comment: String): PumpEnactResult
fun comment(comment: Int): PumpEnactResult
fun duration(duration: Int): PumpEnactResult
fun absolute(absolute: Double): PumpEnactResult
fun percent(percent: Int): PumpEnactResult
fun isPercent(isPercent: Boolean): PumpEnactResult
fun isTempCancel(isTempCancel: Boolean): PumpEnactResult
fun bolusDelivered(bolusDelivered: Double): PumpEnactResult
fun carbsDelivered(carbsDelivered: Double): PumpEnactResult
fun queued(queued: Boolean): PumpEnactResult
fun log(): String
fun toHtml(): String
fun toText(): String
fun json(baseBasal: Double): JSONObject
fun success(success: Boolean): PumpEnactResult = this.also { this.success = success }
fun enacted(enacted: Boolean): PumpEnactResult = this.also { it.enacted = enacted }
fun comment(comment: String): PumpEnactResult = this.also { it.comment = comment }
fun comment(comment: Int): PumpEnactResult = this.also { it.comment = context.getString(comment) }
fun duration(duration: Int): PumpEnactResult = this.also { it.duration = duration }
fun absolute(absolute: Double): PumpEnactResult = this.also { it.absolute = absolute }
fun percent(percent: Int): PumpEnactResult = this.also { it.percent = percent }
fun isPercent(isPercent: Boolean): PumpEnactResult = this.also { it.isPercent = isPercent }
fun isTempCancel(isTempCancel: Boolean): PumpEnactResult = this.also { it.isTempCancel = isTempCancel }
fun bolusDelivered(bolusDelivered: Double): PumpEnactResult = this.also { it.bolusDelivered = bolusDelivered }
fun carbsDelivered(carbsDelivered: Double): PumpEnactResult = this.also { it.carbsDelivered = carbsDelivered }
fun queued(queued: Boolean): PumpEnactResult = this.also { it.queued = queued }
}

View file

@ -4,7 +4,6 @@ import android.os.SystemClock
import androidx.preference.PreferenceFragmentCompat
import androidx.preference.SwitchPreference
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.dialogs.BolusProgressDialog
import info.nightscout.androidaps.extensions.convertedToAbsolute
import info.nightscout.androidaps.extensions.plannedRemainingMinutes
@ -133,7 +132,7 @@ open class VirtualPumpPlugin @Inject constructor(
override var fakeDataDetected = false
override fun loadTDDs(): PumpEnactResult { //no result, could read DB in the future?
return PumpEnactResultObject(injector)
return PumpEnactResult(injector)
}
override fun isInitialized(): Boolean = true
@ -158,7 +157,7 @@ open class VirtualPumpPlugin @Inject constructor(
lastDataTime = System.currentTimeMillis()
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
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
@ -175,7 +174,7 @@ open class VirtualPumpPlugin @Inject constructor(
get() = batteryPercent
override fun deliverTreatment(detailedBolusInfo: DetailedBolusInfo): PumpEnactResult {
val result = PumpEnactResultObject(injector)
val result = PumpEnactResult(injector)
.success(true)
.bolusDelivered(detailedBolusInfo.insulin)
.carbsDelivered(detailedBolusInfo.carbs)
@ -191,7 +190,7 @@ open class VirtualPumpPlugin @Inject constructor(
rxBus.send(bolusingEvent)
delivering += 0.1
if (BolusProgressDialog.stopPressed)
return PumpEnactResultObject(injector)
return PumpEnactResult(injector)
.success(false)
.enacted(false)
.comment(rh.gs(R.string.stoppressed))
@ -226,7 +225,7 @@ open class VirtualPumpPlugin @Inject constructor(
override fun stopBolusDelivering() {}
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.enacted = true
result.isTempCancel = false
@ -243,14 +242,14 @@ open class VirtualPumpPlugin @Inject constructor(
pumpType = pumpType ?: PumpType.GENERIC_AAPS,
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())
lastDataTime = System.currentTimeMillis()
return result
}
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.enacted = true
result.percent = percent
@ -268,7 +267,7 @@ open class VirtualPumpPlugin @Inject constructor(
pumpType = pumpType ?: PumpType.GENERIC_AAPS,
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())
lastDataTime = System.currentTimeMillis()
return result
@ -292,14 +291,14 @@ open class VirtualPumpPlugin @Inject constructor(
pumpType = pumpType ?: PumpType.GENERIC_AAPS,
pumpSerial = serialNumber()
)
aapsLogger.debug(LTag.PUMP, "Setting extended bolus: ${result.toText()}")
aapsLogger.debug(LTag.PUMP, "Setting extended bolus: ${result.toText(rh)}")
rxBus.send(EventVirtualPumpUpdateGui())
lastDataTime = System.currentTimeMillis()
return result
}
override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult {
val result = PumpEnactResultObject(injector)
val result = PumpEnactResult(injector)
result.success = true
result.isTempCancel = true
result.comment = rh.gs(R.string.virtualpump_resultok)
@ -311,7 +310,7 @@ open class VirtualPumpPlugin @Inject constructor(
pumpType = pumpType ?: PumpType.GENERIC_AAPS,
pumpSerial = serialNumber()
)
aapsLogger.debug(LTag.PUMP, "Canceling temp basal: ${result.toText()}")
aapsLogger.debug(LTag.PUMP, "Canceling temp basal: ${result.toText(rh)}")
rxBus.send(EventVirtualPumpUpdateGui())
}
lastDataTime = System.currentTimeMillis()
@ -319,7 +318,7 @@ open class VirtualPumpPlugin @Inject constructor(
}
override fun cancelExtendedBolus(): PumpEnactResult {
val result = PumpEnactResultObject(injector)
val result = PumpEnactResult(injector)
if (pumpSync.expectedPumpState().extendedBolus != null) {
pumpSync.syncStopExtendedBolusWithPumpId(
timestamp = dateUtil.now(),
@ -332,7 +331,7 @@ open class VirtualPumpPlugin @Inject constructor(
result.enacted = true
result.isTempCancel = true
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())
lastDataTime = System.currentTimeMillis()
return result
@ -400,4 +399,40 @@ open class VirtualPumpPlugin @Inject constructor(
}
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.pump.Pump
import info.nightscout.plugins.configBuilder.RunningConfiguration
import info.nightscout.plugins.sync.nsShared.extensions.json
import info.nightscout.shared.utils.DateUtil
import org.json.JSONObject

View file

@ -1,7 +1,6 @@
package info.nightscout.androidaps
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.pump.Pump
@ -44,30 +43,30 @@ class TestPumpPlugin(val injector: HasAndroidInjector) : Pump {
override fun waitForDisconnectionInSeconds(): Int = 0
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 lastDataTime(): Long = lastData
override val baseBasalRate: Double = baseBasal
override val reservoirLevel: Double = 0.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 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 =
PumpEnactResultObject(injector).success(true)
PumpEnactResult(injector).success(true)
override fun setExtendedBolus(insulin: Double, durationInMinutes: Int): PumpEnactResult = PumpEnactResultObject(injector).success(true)
override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult = PumpEnactResultObject(injector).success(true)
override fun cancelExtendedBolus(): PumpEnactResult = PumpEnactResultObject(injector).success(true)
override fun setExtendedBolus(insulin: Double, durationInMinutes: Int): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun cancelExtendedBolus(): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun getJSONStatus(profile: Profile, profileName: String, version: String): JSONObject = JSONObject()
override fun manufacturer(): ManufacturerType = ManufacturerType.AAPS
override fun model(): PumpType = PumpType.GENERIC_AAPS
override fun serialNumber(): String = "1"
override fun shortStatus(veryShort: Boolean): String = ""
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 timezoneOrDSTChanged(timeChangeType: TimeChangeType) {}
}

View file

@ -5,7 +5,6 @@ import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.TestBaseWithProfile
import info.nightscout.androidaps.TestPumpPlugin
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensDataStoreObject
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.PluginType
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.PumpType
import info.nightscout.interfaces.queue.Callback
@ -113,45 +113,45 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
smsCommunicatorPlugin.setPluginEnabled(PluginType.GENERAL, true)
Mockito.doAnswer { invocation: InvocationOnMock ->
val callback = invocation.getArgument<Callback>(1)
callback.result = PumpEnactResultObject(injector).success(true)
callback.result = PumpEnactResult(injector).success(true)
callback.run()
null
}.`when`(commandQueue).cancelTempBasal(ArgumentMatchers.anyBoolean(), ArgumentMatchers.any(Callback::class.java))
Mockito.doAnswer { invocation: InvocationOnMock ->
val callback = invocation.getArgument<Callback>(0)
callback.result = PumpEnactResultObject(injector).success(true)
callback.result = PumpEnactResult(injector).success(true)
callback.run()
null
}.`when`(commandQueue).cancelExtended(ArgumentMatchers.any(Callback::class.java))
Mockito.doAnswer { invocation: InvocationOnMock ->
val callback = invocation.getArgument<Callback>(1)
callback.result = PumpEnactResultObject(injector).success(true)
callback.result = PumpEnactResult(injector).success(true)
callback.run()
null
}.`when`(commandQueue).readStatus(ArgumentMatchers.anyString(), ArgumentMatchers.any(Callback::class.java))
Mockito.doAnswer { invocation: InvocationOnMock ->
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()
null
}.`when`(commandQueue).bolus(anyObject(), ArgumentMatchers.any(Callback::class.java))
Mockito.doAnswer { invocation: InvocationOnMock ->
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()
null
}.`when`(commandQueue)
.tempBasalPercent(ArgumentMatchers.anyInt(), ArgumentMatchers.anyInt(), ArgumentMatchers.anyBoolean(), anyObject(), anyObject(), ArgumentMatchers.any(Callback::class.java))
Mockito.doAnswer { invocation: InvocationOnMock ->
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()
null
}.`when`(commandQueue)
.tempBasalAbsolute(ArgumentMatchers.anyDouble(), ArgumentMatchers.anyInt(), ArgumentMatchers.anyBoolean(), anyObject(), anyObject(), ArgumentMatchers.any(Callback::class.java))
Mockito.doAnswer { invocation: InvocationOnMock ->
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()
null
}.`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 info.nightscout.androidaps.combo.R;
import info.nightscout.androidaps.data.PumpEnactResultObject;
import info.nightscout.androidaps.extensions.PumpStateExtensionKt;
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification;
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() {
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);
}
@ -264,7 +263,7 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
getAapsLogger().error("setNewBasalProfile not initialized");
Notification notification = new Notification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED, getRh().gs(R.string.pumpNotInitializedProfileNotSet), Notification.URGENT);
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);
@ -272,12 +271,12 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
//dismiss previously "FAILED" overview notifications
rxBus.send(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED));
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);
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,
@ -285,7 +284,7 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
if (!setResult.success) {
Notification notification = new Notification(Notification.FAILED_UPDATE_PROFILE, getRh().gs(R.string.failedupdatebasalprofile), Notification.URGENT);
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;
@ -296,7 +295,7 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
//issue success notification
Notification notification = new Notification(Notification.PROFILE_SET_OK, getRh().gs(R.string.profile_set_ok), Notification.INFO, 60);
rxBus.send(new EventNewNotification(notification));
return new PumpEnactResultObject(getInjector()).success(true).enacted(true);
return new PumpEnactResult(getInjector()).success(true).enacted(true);
}
@Override
@ -509,16 +508,16 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
// check pump is ready and all pump bolus records are known
CommandResult stateResult = runCommand(null, 2, () -> ruffyScripter.readQuickInfo(1));
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);
}
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);
}
// the commands above ensured a connection was made, which updated this field
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);
}
@ -531,7 +530,7 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
if (Math.abs(previousBolus.amount - detailedBolusInfo.insulin) < 0.01
&& previousBolus.timestamp + 60 * 1000 > System.currentTimeMillis()) {
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);
}
@ -544,10 +543,10 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
while (previousBolus.timestamp == timeCheckResult.state.pumpTime
&& maxWaitTimeout > System.currentTimeMillis()) {
if (cancelBolus) {
return new PumpEnactResultObject(getInjector()).success(true).enacted(false);
return new PumpEnactResult(getInjector()).success(true).enacted(false);
}
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);
}
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) {
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());
@ -581,7 +580,7 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
// (reads 2 records to update `recentBoluses` further down)
CommandResult postBolusStateResult = runCommand(null, 3, () -> ruffyScripter.readQuickInfo(2));
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);
}
Bolus lastPumpBolus = postBolusStateResult.history != null && !postBolusStateResult.history.bolusHistory.isEmpty()
@ -591,9 +590,9 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
// no bolus delivered?
if (lastPumpBolus == null || lastPumpBolus.equals(previousBolus)) {
if (cancelBolus) {
return new PumpEnactResultObject(getInjector()).success(true).enacted(false);
return new PumpEnactResult(getInjector()).success(true).enacted(false);
} else {
return new PumpEnactResultObject(getInjector())
return new PumpEnactResult(getInjector())
.success(false)
.enacted(false)
.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
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);
// 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
if (Math.abs(lastPumpBolus.amount - detailedBolusInfo.insulin) > 0.01) {
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,
lastPumpBolus.amount, detailedBolusInfo.insulin));
}
// full bolus was delivered successfully
incrementBolusCount();
return new PumpEnactResultObject(getInjector())
return new PumpEnactResult(getInjector())
.success(true)
.enacted(lastPumpBolus.amount > 0)
.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");
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);
}
@ -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),
3, () -> ruffyScripter.setTbr(finalAdjustedPercent, durationInMinutes));
if (!commandResult.success) {
return new PumpEnactResultObject(getInjector()).success(false).enacted(false);
return new PumpEnactResult(getInjector()).success(false).enacted(false);
}
PumpState state = commandResult.state;
@ -781,7 +780,7 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
}
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);
}
@ -805,15 +804,15 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
if (enforceNew) {
CommandResult stateResult = runCommand(getRh().gs(R.string.combo_pump_action_refreshing), 2, ruffyScripter::readPumpState);
if (!stateResult.success) {
return new PumpEnactResultObject(getInjector()).success(false).enacted(false);
return new PumpEnactResult(getInjector()).success(false).enacted(false);
}
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");
CommandResult cancelResult = runCommand(getRh().gs(R.string.combo_pump_action_cancelling_tbr), 2, ruffyScripter::cancelTbr);
if (!cancelResult.success) {
return new PumpEnactResultObject(getInjector()).success(false).enacted(false);
return new PumpEnactResult(getInjector()).success(false).enacted(false);
}
if (!cancelResult.state.tbrActive) {
pumpSync.syncStopTemporaryBasalWithPumpId(
@ -823,19 +822,19 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
PumpType.ACCU_CHEK_COMBO,
serialNumber()
);
return new PumpEnactResultObject(getInjector()).isTempCancel(true).success(true).enacted(true);
return new PumpEnactResult(getInjector()).isTempCancel(true).success(true).enacted(true);
} else {
return new PumpEnactResultObject(getInjector()).success(false).enacted(false);
return new PumpEnactResult(getInjector()).success(false).enacted(false);
}
} 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)
&& PumpStateExtensionKt.getPlannedRemainingMinutes(activeTemp) <= 15) {
// Let fake neutral temp keep run (see below)
// 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).
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 "
+ activeTemp.getRate() + "% and running for another "
+ PumpStateExtensionKt.getPlannedRemainingMinutes(activeTemp) + " mins.");
@ -1361,7 +1360,7 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
@NonNull @Override
public PumpEnactResult loadTDDs() {
PumpEnactResult result = new PumpEnactResultObject(getInjector());
PumpEnactResult result = new PumpEnactResult(getInjector());
result.success(readHistory(new PumpHistoryRequest().tddHistory(PumpHistoryRequest.FULL)));
if (result.getSuccess()) {
List<Tdd> tdds = pump.tddHistory;

View file

@ -4,7 +4,6 @@ import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.TestBase
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.history.Bolus
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.danar.AbstractDanaRPlugin
import info.nightscout.androidaps.danar.R
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.core.fabric.FabricPrivacy
import info.nightscout.interfaces.constraints.Constraint
import info.nightscout.interfaces.constraints.Constraints
@ -134,7 +133,7 @@ class DanaRKoreanPlugin @Inject constructor(
detailedBolusInfo.insulin, detailedBolusInfo.carbs.toInt(), detailedBolusInfo.carbsTimestamp
?: detailedBolusInfo.timestamp, t
)
val result = PumpEnactResultObject(injector)
val result = PumpEnactResult(injector)
result.success(connectionOK && abs(detailedBolusInfo.insulin - t.insulin) < pumpDescription.bolusStep)
.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)
@ -151,7 +150,7 @@ class DanaRKoreanPlugin @Inject constructor(
)
result
} else {
val result = PumpEnactResultObject(injector)
val result = PumpEnactResult(injector)
result.success(false).bolusDelivered(0.0).carbsDelivered(0.0).comment(R.string.invalidinput)
aapsLogger.error("deliverTreatment: Invalid input")
result
@ -191,7 +190,7 @@ class DanaRKoreanPlugin @Inject constructor(
return cancelRealTempBasal()
}
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 extended in progress
@ -212,7 +211,7 @@ class DanaRKoreanPlugin @Inject constructor(
cancelTempBasal(true)
} else {
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) {
// 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)
}
@ -269,7 +268,7 @@ class DanaRKoreanPlugin @Inject constructor(
}
// We should never end here
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 {
@ -277,7 +276,7 @@ class DanaRKoreanPlugin @Inject constructor(
if (danaPump.isExtendedInProgress && useExtendedBoluses) {
return cancelExtendedBolus()
}
val result = PumpEnactResultObject(injector)
val result = PumpEnactResult(injector)
result.success(true).enacted(false).comment(R.string.ok).isTempCancel(true)
return result
}
@ -285,7 +284,7 @@ class DanaRKoreanPlugin @Inject constructor(
override fun model(): PumpType = PumpType.DANA_R_KOREAN
private fun cancelRealTempBasal(): PumpEnactResult {
val result = PumpEnactResultObject(injector)
val result = PumpEnactResult(injector)
if (danaPump.isTempBasalInProgress) {
sExecutionService.tempBasalStop()
if (!danaPump.isTempBasalInProgress) {
@ -304,6 +303,6 @@ class DanaRKoreanPlugin @Inject constructor(
return result
}
override fun loadEvents(): PumpEnactResult = PumpEnactResultObject(injector) // no history, not needed
override fun setUserOptions(): PumpEnactResult = PumpEnactResultObject(injector)
override fun loadEvents(): PumpEnactResult = PumpEnactResult(injector) // no history, not needed
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.danar.AbstractDanaRPlugin;
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.TemporaryBasalStorage;
import info.nightscout.core.fabric.FabricPrivacy;
@ -190,7 +189,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
boolean connectionOK = false;
if (detailedBolusInfo.insulin > 0 || carbs > 0)
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())
.bolusDelivered(t.getInsulin())
.carbsDelivered(detailedBolusInfo.carbs);
@ -203,7 +202,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
// remove carbs because it's get from history separately
return result;
} else {
PumpEnactResult result = new PumpEnactResultObject(getInjector());
PumpEnactResult result = new PumpEnactResult(getInjector());
result.success(false).bolusDelivered(0d).carbsDelivered(0d).comment(R.string.invalidinput);
aapsLogger.error("deliverTreatment: Invalid input");
return result;
@ -223,7 +222,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
@NonNull @Override
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();
@ -290,7 +289,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
@NonNull @Override
public PumpEnactResult setTempBasalPercent(int percent, int durationInMinutes, @NonNull Profile profile, boolean enforceNew, @NonNull PumpSync.TemporaryBasalType tbrType) {
DanaPump pump = danaPump;
PumpEnactResult result = new PumpEnactResultObject(getInjector());
PumpEnactResult result = new PumpEnactResult(getInjector());
percent = constraintChecker.applyBasalPercentConstraints(new Constraint<>(percent), profile).value();
if (percent < 0) {
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) {
DanaPump pump = danaPump;
PumpEnactResult result = new PumpEnactResultObject(getInjector());
PumpEnactResult result = new PumpEnactResult(getInjector());
boolean connectionOK = sExecutionService.highTempBasal(percent, durationInMinutes);
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);
@ -338,7 +337,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
@NonNull @Override
public PumpEnactResult cancelTempBasal(boolean force) {
PumpEnactResult result = new PumpEnactResultObject(getInjector());
PumpEnactResult result = new PumpEnactResult(getInjector());
if (danaPump.isTempBasalInProgress()) {
sExecutionService.tempBasalStop();
result.enacted(true).isTempCancel(true);
@ -357,7 +356,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
int durationInHalfHours = Math.max(durationInMinutes / 30, 1);
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()) {
result.enacted(false)
.success(true)
@ -390,7 +389,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
@NonNull @Override
public PumpEnactResult cancelExtendedBolus() {
PumpEnactResult result = new PumpEnactResultObject(getInjector());
PumpEnactResult result = new PumpEnactResult(getInjector());
if (danaPump.isExtendedInProgress()) {
sExecutionService.extendedBolusStop();
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.MsgStatusTempBasal;
import info.nightscout.androidaps.danar.services.AbstractDanaRExecutionService;
import info.nightscout.androidaps.data.PumpEnactResultObject;
import info.nightscout.androidaps.dialogs.BolusProgressDialog;
import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
@ -430,14 +429,14 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
public PumpEnactResult loadEvents() {
if (!danaRv2Plugin.isInitialized()) {
PumpEnactResult result = new PumpEnactResultObject(injector).success(false);
PumpEnactResult result = new PumpEnactResult(injector).success(false);
result.comment("pump not initialized");
return result;
}
if (!isConnected())
return new PumpEnactResultObject(injector).success(false);
return new PumpEnactResult(injector).success(false);
SystemClock.sleep(300);
MsgHistoryEventsV2 msg = new MsgHistoryEventsV2(injector, danaPump.lastHistoryFetched);
aapsLogger.debug(LTag.PUMP, "Loading event history from: " + dateUtil.dateAndTimeString(danaPump.lastHistoryFetched));
@ -452,7 +451,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
else
danaPump.lastHistoryFetched = 0;
danaPump.setLastConnection(System.currentTimeMillis());
return new PumpEnactResultObject(injector).success(true);
return new PumpEnactResult(injector).success(true);
}
public boolean updateBasalsInPump(final Profile profile) {
@ -471,12 +470,12 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
public PumpEnactResult setUserOptions() {
if (!isConnected())
return new PumpEnactResultObject(injector).success(false);
return new PumpEnactResult(injector).success(false);
SystemClock.sleep(300);
MsgSetUserOptions msg = new MsgSetUserOptions(injector);
mSerialIOThread.sendMessage(msg);
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.comm.RecordTypes;
import info.nightscout.androidaps.danar.services.AbstractDanaRExecutionService;
import info.nightscout.androidaps.data.PumpEnactResultObject;
import info.nightscout.androidaps.extensions.PumpStateExtensionKt;
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
@ -136,7 +135,7 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump
// Pump interface
@NonNull @Override
public PumpEnactResult setNewBasalProfile(@NonNull Profile profile) {
PumpEnactResult result = new PumpEnactResultObject(getInjector());
PumpEnactResult result = new PumpEnactResult(getInjector());
if (sExecutionService == null) {
getAapsLogger().error("setNewBasalProfile sExecutionService is null");
@ -216,7 +215,7 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump
@NonNull @Override
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();
if (percent < 0) {
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);
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()) {
result.enacted(false)
.success(true)
@ -320,7 +319,7 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump
@NonNull @Override
public PumpEnactResult cancelExtendedBolus() {
PumpEnactResult result = new PumpEnactResultObject(getInjector());
PumpEnactResult result = new PumpEnactResult(getInjector());
if (danaPump.isExtendedInProgress()) {
sExecutionService.extendedBolusStop();
if (!danaPump.isExtendedInProgress()) {

View file

@ -14,7 +14,6 @@ import javax.inject.Singleton;
import dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.dana.DanaPump;
import info.nightscout.androidaps.danar.services.DanaRExecutionService;
import info.nightscout.androidaps.data.PumpEnactResultObject;
import info.nightscout.core.fabric.FabricPrivacy;
import info.nightscout.interfaces.constraints.Constraint;
import info.nightscout.interfaces.constraints.Constraints;
@ -165,7 +164,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
boolean connectionOK = false;
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0)
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())
.bolusDelivered(t.getInsulin())
.carbsDelivered(detailedBolusInfo.carbs);
@ -193,7 +192,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
serialNumber());
return result;
} else {
PumpEnactResult result = new PumpEnactResultObject(getInjector());
PumpEnactResult result = new PumpEnactResult(getInjector());
result.success(false).bolusDelivered(0d).carbsDelivered(0d).comment(R.string.invalidinput);
aapsLogger.error("deliverTreatment: Invalid input");
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) {
// Recheck pump status if older than 30 min
//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();
@ -327,7 +326,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
if (danaPump.isExtendedInProgress() && useExtendedBoluses) {
return cancelExtendedBolus();
}
PumpEnactResult result = new PumpEnactResultObject(getInjector());
PumpEnactResult result = new PumpEnactResult(getInjector());
result.success(true).enacted(false).comment(R.string.ok).isTempCancel(true);
return result;
}
@ -338,7 +337,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
}
private PumpEnactResult cancelRealTempBasal() {
PumpEnactResult result = new PumpEnactResultObject(getInjector());
PumpEnactResult result = new PumpEnactResult(getInjector());
if (danaPump.isTempBasalInProgress()) {
sExecutionService.tempBasalStop();
if (!danaPump.isTempBasalInProgress()) {
@ -360,7 +359,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
@NonNull @Override
public PumpEnactResult loadEvents() {
return new PumpEnactResultObject(getInjector()); // no history, not needed
return new PumpEnactResult(getInjector()); // no history, not needed
}
@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.MsgPCCommStart;
import info.nightscout.androidaps.danar.comm.MsgPCCommStop;
import info.nightscout.androidaps.data.PumpEnactResultObject;
import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
import info.nightscout.androidaps.utils.ToastUtils;
@ -242,7 +241,7 @@ public abstract class AbstractDanaRExecutionService extends DaggerService {
}
public PumpEnactResult loadHistory(byte type) {
PumpEnactResult result = new PumpEnactResultObject(injector);
PumpEnactResult result = new PumpEnactResult(injector);
if (!isConnected()) return result;
MessageBase msg = null;
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.MsgStatusBolusExtended;
import info.nightscout.androidaps.danar.comm.MsgStatusTempBasal;
import info.nightscout.androidaps.data.PumpEnactResultObject;
import info.nightscout.androidaps.dialogs.BolusProgressDialog;
import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
@ -397,11 +396,11 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
public PumpEnactResult setUserOptions() {
if (!isConnected())
return new PumpEnactResultObject(injector).success(false);
return new PumpEnactResult(injector).success(false);
SystemClock.sleep(300);
MsgSetUserOptions msg = new MsgSetUserOptions(injector);
mSerialIOThread.sendMessage(msg);
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
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.pump.Pump
@ -44,26 +43,26 @@ class TestPumpPlugin(val injector: HasAndroidInjector) : Pump {
override fun waitForDisconnectionInSeconds(): Int = 0
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 lastDataTime(): Long = lastData
override val baseBasalRate: Double = baseBasal
override val reservoirLevel: Double = 0.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 setTempBasalAbsolute(absoluteRate: Double, 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 = PumpEnactResultObject(injector).success(true)
override fun setExtendedBolus(insulin: Double, durationInMinutes: Int): PumpEnactResult = PumpEnactResultObject(injector).success(true)
override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult = PumpEnactResultObject(injector).success(true)
override fun cancelExtendedBolus(): 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 = PumpEnactResult(injector).success(true)
override fun setExtendedBolus(insulin: Double, durationInMinutes: Int): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun cancelExtendedBolus(): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun getJSONStatus(profile: Profile, profileName: String, version: String): JSONObject = JSONObject()
override fun manufacturer(): ManufacturerType = ManufacturerType.AAPS
override fun model(): PumpType = PumpType.GENERIC_AAPS
override fun serialNumber(): String = "1"
override fun shortStatus(veryShort: Boolean): String = ""
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 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.danars.events.EventDanaRSDeviceChange
import info.nightscout.androidaps.danars.services.DanaRSService
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.extensions.convertedToAbsolute
import info.nightscout.androidaps.extensions.plannedRemainingMinutes
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification
@ -186,15 +185,15 @@ class DanaRSPlugin @Inject constructor(
// DanaR interface
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 {
return danaRSService?.loadEvents() ?: PumpEnactResultObject(injector).success(false)
return danaRSService?.loadEvents() ?: PumpEnactResult(injector).success(false)
}
override fun setUserOptions(): PumpEnactResult {
return danaRSService?.setUserSettings() ?: PumpEnactResultObject(injector).success(false)
return danaRSService?.setUserSettings() ?: PumpEnactResult(injector).success(false)
}
// Constraints interface
@ -229,7 +228,7 @@ class DanaRSPlugin @Inject constructor(
danaRSService?.isConnected ?: false || danaRSService?.isConnecting ?: false
override fun setNewBasalProfile(profile: Profile): PumpEnactResult {
val result = PumpEnactResultObject(injector)
val result = PumpEnactResult(injector)
if (!isInitialized()) {
aapsLogger.error("setNewBasalProfile not initialized")
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
if (detailedBolusInfo.insulin > 0 || carbs > 0) connectionOK = danaRSService?.bolus(detailedBolusInfo.insulin, carbs.toInt(), carbTimeStamp, t)
?: false
val result = PumpEnactResultObject(injector)
val result = PumpEnactResult(injector)
result.success = connectionOK && abs(detailedBolusInfo.insulin - t.insulin) < pumpDescription.bolusStep
result.bolusDelivered = t.insulin
result.carbsDelivered = detailedBolusInfo.carbs
@ -322,7 +321,7 @@ class DanaRSPlugin @Inject constructor(
aapsLogger.debug(LTag.PUMP, "deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered)
result
} else {
val result = PumpEnactResultObject(injector)
val result = PumpEnactResult(injector)
result.success = false
result.bolusDelivered = 0.0
result.carbsDelivered = 0.0
@ -364,7 +363,7 @@ class DanaRSPlugin @Inject constructor(
return cancelTempBasal(false)
}
aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: doTempOff OK")
return PumpEnactResultObject(injector)
return PumpEnactResult(injector)
.success(true)
.enacted(false)
.percent(100)
@ -379,7 +378,7 @@ class DanaRSPlugin @Inject constructor(
if (danaPump.tempBasalPercent == percentRate && danaPump.tempBasalRemainingMin > 4) {
if (!enforceNew) {
aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: Correct temp basal already set (doLowTemp || doHighTemp)")
return PumpEnactResultObject(injector)
return PumpEnactResult(injector)
.success(true)
.percent(percentRate)
.enacted(false)
@ -407,14 +406,14 @@ class DanaRSPlugin @Inject constructor(
}
// We should never end here
aapsLogger.error("setTempBasalAbsolute: Internal error")
return PumpEnactResultObject(injector)
return PumpEnactResult(injector)
.success(false)
.comment("Internal error")
}
@Synchronized
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()
if (percentAfterConstraint < 0) {
result.isTempCancel = false
@ -463,7 +462,7 @@ class DanaRSPlugin @Inject constructor(
}
@Synchronized private fun setHighTempBasalPercent(percent: Int): PumpEnactResult {
val result = PumpEnactResultObject(injector)
val result = PumpEnactResult(injector)
val connectionOK = danaRSService?.highTempBasal(percent) ?: false
if (connectionOK && danaPump.isTempBasalInProgress && danaPump.tempBasalPercent == percent) {
result.enacted = true
@ -489,7 +488,7 @@ class DanaRSPlugin @Inject constructor(
// needs to be rounded
val durationInHalfHours = max(durationInMinutes / 30, 1)
insulinAfterConstraint = Round.roundTo(insulinAfterConstraint, pumpDescription.extendedBolusStep)
val result = PumpEnactResultObject(injector)
val result = PumpEnactResult(injector)
if (danaPump.isExtendedInProgress && abs(danaPump.extendedBolusAmount - insulinAfterConstraint) < pumpDescription.extendedBolusStep) {
result.enacted = false
result.success = true
@ -524,7 +523,7 @@ class DanaRSPlugin @Inject constructor(
@Synchronized
override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult {
val result = PumpEnactResultObject(injector)
val result = PumpEnactResult(injector)
if (danaPump.isTempBasalInProgress) {
danaRSService?.tempBasalStop()
result.success = !danaPump.isTempBasalInProgress
@ -541,7 +540,7 @@ class DanaRSPlugin @Inject constructor(
}
@Synchronized override fun cancelExtendedBolus(): PumpEnactResult {
val result = PumpEnactResultObject(injector)
val result = PumpEnactResult(injector)
if (danaPump.isExtendedInProgress) {
danaRSService?.extendedBolusStop()
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.DanaRSPacketOptionSetPumpUTCAndTimeZone
import info.nightscout.androidaps.danars.comm.DanaRSPacketOptionSetUserOption
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.dialogs.BolusProgressDialog
import info.nightscout.androidaps.events.EventPumpStatusChanged
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
@ -261,7 +260,7 @@ class DanaRSService : DaggerService() {
fun loadEvents(): PumpEnactResult {
if (!danaRSPlugin.isInitialized()) {
val result = PumpEnactResultObject(injector).success(false)
val result = PumpEnactResult(injector).success(false)
result.comment = "pump not initialized"
return result
}
@ -283,13 +282,13 @@ class DanaRSService : DaggerService() {
rxBus.send(EventPumpStatusChanged(rh.gs(R.string.gettingpumpstatus)))
sendMessage(DanaRSPacketGeneralInitialScreenInformation(injector))
danaPump.lastConnection = System.currentTimeMillis()
return PumpEnactResultObject(injector).success(msg.success())
return PumpEnactResult(injector).success(msg.success())
}
fun setUserSettings(): PumpEnactResult {
val message = DanaRSPacketOptionSetUserOption(injector)
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 {
@ -499,7 +498,7 @@ class DanaRSService : DaggerService() {
}
fun loadHistory(type: Byte): PumpEnactResult {
val result = PumpEnactResultObject(injector)
val result = PumpEnactResult(injector)
if (!isConnected) return result
var msg: DanaRSPacketHistory? = null
when (type) {

View file

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

View file

@ -8,7 +8,6 @@ import android.os.IBinder
import android.os.SystemClock
import dagger.android.DaggerService
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.diaconn.DiaconnG8Plugin
import info.nightscout.androidaps.diaconn.DiaconnG8Pump
import info.nightscout.androidaps.diaconn.R
@ -269,7 +268,7 @@ class DiaconnG8Service : DaggerService() {
fun loadHistory(): PumpEnactResult {
if (!diaconnG8Plugin.isInitialized()) {
val result = PumpEnactResultObject(injector).success(false)
val result = PumpEnactResult(injector).success(false)
result.comment = "pump not initialized"
return result
}
@ -279,7 +278,7 @@ class DiaconnG8Service : DaggerService() {
sendMessage(IncarnationInquirePacket(injector))
}
val result = PumpEnactResultObject(injector)
val result = PumpEnactResult(injector)
var apsLastLogNum = 9999
var apsWrappingCount = -1
// get saved last loginfo
@ -421,7 +420,7 @@ class DiaconnG8Service : DaggerService() {
}
fun setUserSettings(): PumpEnactResult {
val result = PumpEnactResultObject(injector)
val result = PumpEnactResult(injector)
val msg: DiaconnG8Packet = when (diaconnG8Pump.setUserOptionType) {
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 dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
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.ble.IPatchManager
@ -177,7 +176,7 @@ class EopatchPumpPlugin @Inject constructor(
mLastDataTime = System.currentTimeMillis()
if (patchManager.isActivated) {
if (patchManager.patchState.isTempBasalActive || patchManager.patchState.isBolusActive) {
return PumpEnactResultObject(injector)
return PumpEnactResult(injector)
} else {
var isSuccess: Boolean? = null
val result: BehaviorSubject<Boolean> = BehaviorSubject.create()
@ -205,16 +204,16 @@ class EopatchPumpPlugin @Inject constructor(
aapsLogger.info(LTag.PUMP, "Basal Profile was set: ${isSuccess ?: false}")
if (isSuccess == true) {
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 {
return PumpEnactResultObject(injector)
return PumpEnactResult(injector)
}
}
} else {
preferenceManager.getNormalBasalManager().setNormalBasal(profile)
preferenceManager.flushNormalBasalManager()
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) {
// neither carbs nor bolus requested
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))
} else if (detailedBolusInfo.insulin > 0.0) {
var isSuccess = true
@ -311,15 +310,15 @@ class EopatchPumpPlugin @Inject constructor(
disposable.dispose()
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
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 {
// no bolus required, carb only treatment
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))
}
}
@ -357,15 +356,15 @@ class EopatchPumpPlugin @Inject constructor(
)
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(
PumpEnactResultObject(injector).success(false).enacted(false)
PumpEnactResult(injector).success(false).enacted(false)
.comment("Internal error")
)
.blockingGet()
} else {
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()}")
}
.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(
PumpEnactResultObject(injector).success(false).enacted(false)
PumpEnactResult(injector).success(false).enacted(false)
.comment("Internal error")
)
.blockingGet()
} else {
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()
)
}
.map { PumpEnactResultObject(injector).success(true).enacted(true) }
.map { PumpEnactResult(injector).success(true).enacted(true) }
.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))
)
.blockingGet()
@ -431,14 +430,14 @@ class EopatchPumpPlugin @Inject constructor(
if (tbrCurrent == null) {
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) {
return if (pumpSync.expectedPumpState().temporaryBasal != null) {
PumpEnactResultObject(injector).success(true).enacted(true).isTempCancel(true)
PumpEnactResult(injector).success(true).enacted(true).isTempCancel(true)
} else
PumpEnactResultObject(injector).success(true).isTempCancel(true)
PumpEnactResult(injector).success(true).isTempCancel(true)
}
return patchManager.stopTempBasal()
@ -455,9 +454,9 @@ class EopatchPumpPlugin @Inject constructor(
.doOnError {
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(
PumpEnactResultObject(injector).success(false).enacted(false)
PumpEnactResult(injector).success(false).enacted(false)
.comment(rh.gs(info.nightscout.core.main.R.string.error))
)
.blockingGet()
@ -476,9 +475,9 @@ class EopatchPumpPlugin @Inject constructor(
pumpSerial = serialNumber()
)
}
.map { PumpEnactResultObject(injector).success(true).enacted(true).isTempCancel(true) }
.map { PumpEnactResult(injector).success(true).enacted(true).isTempCancel(true) }
.onErrorReturnItem(
PumpEnactResultObject(injector).success(false).enacted(false)
PumpEnactResult(injector).success(false).enacted(false)
.comment(rh.gs(info.nightscout.core.main.R.string.error))
)
.blockingGet()
@ -491,9 +490,9 @@ class EopatchPumpPlugin @Inject constructor(
pumpType = PumpType.EOFLOW_EOPATCH2,
pumpSerial = serialNumber()
)
PumpEnactResultObject(injector).success(true).enacted(true).isTempCancel(true)
PumpEnactResult(injector).success(true).enacted(true).isTempCancel(true)
} else
PumpEnactResultObject(injector)
PumpEnactResult(injector)
}
}
@ -546,7 +545,7 @@ class EopatchPumpPlugin @Inject constructor(
override val isFakingTempsByExtendedBoluses: Boolean = false
override fun loadTDDs(): PumpEnactResult {
return PumpEnactResultObject(injector)
return PumpEnactResult(injector)
}
override fun canHandleDST(): Boolean {

View file

@ -7,7 +7,6 @@ import android.os.IBinder
import android.os.SystemClock
import androidx.preference.Preference
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
import info.nightscout.androidaps.plugins.pump.common.PumpPluginAbstract
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)
setRefreshButtonEnabled(false)
if (detailedBolusInfo.insulin > medtronicPumpStatus.reservoirRemainingUnits) {
return PumpEnactResultObject(injector) //
return PumpEnactResult(injector) //
.success(false) //
.enacted(false) //
.comment(
@ -633,7 +632,7 @@ class MedtronicPumpPlugin @Inject constructor(
// LOG.debug("MedtronicPumpPlugin::deliverBolus - Response: {}", response);
return if (response == null || !response) {
PumpEnactResultObject(injector) //
PumpEnactResult(injector) //
.success(bolusDeliveryType == BolusDeliveryType.CancelDelivery) //
.enacted(false) //
.comment(R.string.medtronic_cmd_bolus_could_not_be_delivered)
@ -660,7 +659,7 @@ class MedtronicPumpPlugin @Inject constructor(
val time = now + bolusTime * 1000
busyTimestamps.add(time)
setEnableCustomAction(MedtronicCustomActionType.ClearBolusBlock, true)
PumpEnactResultObject(injector).success(true) //
PumpEnactResult(injector).success(true) //
.enacted(true) //
.bolusDelivered(detailedBolusInfo.insulin) //
.carbsDelivered(detailedBolusInfo.carbs)
@ -677,8 +676,8 @@ class MedtronicPumpPlugin @Inject constructor(
private fun setNotReachable(isBolus: Boolean, success: Boolean): PumpEnactResult {
setRefreshButtonEnabled(true)
if (isBolus) bolusDeliveryType = BolusDeliveryType.Idle
return if (success) PumpEnactResultObject(injector).success(true).enacted(false)
else PumpEnactResultObject(injector).success(false).enacted(false).comment(R.string.medtronic_pump_status_pump_unreachable)
return if (success) PumpEnactResult(injector).success(true).enacted(false)
else PumpEnactResult(injector).success(false).enacted(false).comment(R.string.medtronic_pump_status_pump_unreachable)
}
override fun stopBolusDelivering() {
@ -701,7 +700,7 @@ class MedtronicPumpPlugin @Inject constructor(
setRefreshButtonEnabled(false)
if (isPumpNotReachable) {
setRefreshButtonEnabled(true)
return PumpEnactResultObject(injector) //
return PumpEnactResult(injector) //
.success(false) //
.enacted(false) //
.comment(R.string.medtronic_pump_status_pump_unreachable)
@ -714,7 +713,7 @@ class MedtronicPumpPlugin @Inject constructor(
if (tbrCurrent == null) {
aapsLogger.warn(LTag.PUMP, logPrefix + "setTempBasalAbsolute - Could not read current TBR, canceling operation.")
finishAction("TBR")
return PumpEnactResultObject(injector).success(false).enacted(false)
return PumpEnactResult(injector).success(false).enacted(false)
.comment(R.string.medtronic_cmd_cant_read_tbr)
} else {
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) {
aapsLogger.info(LTag.PUMP, logPrefix + "setTempBasalAbsolute - No enforceNew and same rate. Exiting.")
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
@ -745,7 +744,7 @@ class MedtronicPumpPlugin @Inject constructor(
if (response == null || !response) {
aapsLogger.error(logPrefix + "setTempBasalAbsolute - Cancel TBR failed.")
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)
} else {
//cancelTBRWithTemporaryId()
@ -762,7 +761,7 @@ class MedtronicPumpPlugin @Inject constructor(
aapsLogger.info(LTag.PUMP, logPrefix + "setTempBasalAbsolute - setTBR. Response: " + response)
return if (response == null || !response) {
finishAction("TBR")
PumpEnactResultObject(injector).success(false).enacted(false) //
PumpEnactResult(injector).success(false).enacted(false) //
.comment(R.string.medtronic_cmd_tbr_could_not_be_delivered)
} else {
medtronicPumpStatus.tempBasalStart = System.currentTimeMillis()
@ -776,7 +775,7 @@ class MedtronicPumpPlugin @Inject constructor(
incrementStatistics(MedtronicConst.Statistics.TBRsSet)
finishAction("TBR")
PumpEnactResultObject(injector).success(true).enacted(true) //
PumpEnactResult(injector).success(true).enacted(true) //
.absolute(absoluteRate).duration(durationInMinutes)
}
}
@ -1022,7 +1021,7 @@ class MedtronicPumpPlugin @Inject constructor(
aapsLogger.info(LTag.PUMP, logPrefix + "cancelTempBasal - started")
if (isPumpNotReachable) {
setRefreshButtonEnabled(true)
return PumpEnactResultObject(injector) //
return PumpEnactResult(injector) //
.success(false) //
.enacted(false) //
.comment(R.string.medtronic_pump_status_pump_unreachable)
@ -1034,12 +1033,12 @@ class MedtronicPumpPlugin @Inject constructor(
if (tbrCurrent.insulinRate > 0.0f && tbrCurrent.durationMinutes == 0) {
aapsLogger.info(LTag.PUMP, logPrefix + "cancelTempBasal - TBR already canceled.")
finishAction("TBR")
return PumpEnactResultObject(injector).success(true).enacted(false)
return PumpEnactResult(injector).success(true).enacted(false)
}
} else {
aapsLogger.warn(LTag.PUMP, logPrefix + "cancelTempBasal - Could not read current TBR, canceling operation.")
finishAction("TBR")
return PumpEnactResultObject(injector).success(false).enacted(false)
return PumpEnactResult(injector).success(false).enacted(false)
.comment(R.string.medtronic_cmd_cant_read_tbr)
}
val responseTask2 = rileyLinkMedtronicService?.medtronicUIComm?.executeCommand(MedtronicCommandType.CancelTBR)
@ -1047,7 +1046,7 @@ class MedtronicPumpPlugin @Inject constructor(
finishAction("TBR")
return if (response == null || !response) {
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)
} else {
aapsLogger.info(LTag.PUMP, logPrefix + "cancelTempBasal - Cancel TBR successful.")
@ -1083,7 +1082,7 @@ class MedtronicPumpPlugin @Inject constructor(
//cancelTBRWithTemporaryId()
PumpEnactResultObject(injector).success(true).enacted(true) //
PumpEnactResult(injector).success(true).enacted(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
if (isProfileSame(profile)) {
return PumpEnactResultObject(injector) //
return PumpEnactResult(injector) //
.success(true) //
.enacted(false) //
.comment(R.string.medtronic_cmd_basal_profile_not_set_is_same)
@ -1114,7 +1113,7 @@ class MedtronicPumpPlugin @Inject constructor(
setRefreshButtonEnabled(false)
if (isPumpNotReachable) {
setRefreshButtonEnabled(true)
return PumpEnactResultObject(injector) //
return PumpEnactResult(injector) //
.success(false) //
.enacted(false) //
.comment(R.string.medtronic_pump_status_pump_unreachable)
@ -1124,7 +1123,7 @@ class MedtronicPumpPlugin @Inject constructor(
aapsLogger.debug("Basal Profile: $basalProfile")
val profileInvalid = isProfileValid(basalProfile)
if (profileInvalid != null) {
return PumpEnactResultObject(injector) //
return PumpEnactResult(injector) //
.success(false) //
.enacted(false) //
.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?
aapsLogger.info(LTag.PUMP, logPrefix + "Basal Profile was set: " + 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)
} 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.MutableLiveData
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.rx.AapsSchedulers
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)
_isActionExecutingLiveData.postValue(false)
_actionResultLiveData.postValue(
PumpEnactResultObject(injector).success(false).comment(
PumpEnactResult(injector).success(false).comment(
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.text.format.DateFormat
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.extensions.convertedToAbsolute
import info.nightscout.androidaps.extensions.plannedRemainingMinutes
import info.nightscout.androidaps.extensions.toStringFull
@ -395,7 +394,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
override fun setNewBasalProfile(profile: Profile): PumpEnactResult {
if (!podStateManager.isActivationCompleted) {
return PumpEnactResultObject(injector).success(true).enacted(true)
return PumpEnactResult(injector).success(true).enacted(true)
}
aapsLogger.debug(LTag.PUMP, "setNewBasalProfile profile=$profile")
return setNewBasalProfile(profile, OmnipodCommandType.SET_BASAL_PROFILE)
@ -567,7 +566,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
detailedBolusInfo.insulin == 0.0
) {
// Accept only valid insulin requests
return PumpEnactResultObject(injector)
return PumpEnactResult(injector)
.success(false)
.enacted(false)
.bolusDelivered(0.0)
@ -575,7 +574,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
}
val requestedBolusAmount = detailedBolusInfo.insulin
if (requestedBolusAmount > reservoirLevel) {
return PumpEnactResultObject(injector)
return PumpEnactResult(injector)
.success(false)
.enacted(false)
.bolusDelivered(0.0)
@ -584,7 +583,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
if (podStateManager.deliveryStatus == DeliveryStatus.BOLUS_AND_BASAL_ACTIVE ||
podStateManager.deliveryStatus == DeliveryStatus.BOLUS_AND_TEMP_BASAL_ACTIVE
) {
return PumpEnactResultObject(injector)
return PumpEnactResult(injector)
.success(false)
.enacted(false)
.bolusDelivered(0.0)
@ -653,10 +652,10 @@ class OmnipodDashPumpPlugin @Inject constructor(
}
}
}.toSingle {
PumpEnactResultObject(injector).success(true).enacted(true).bolusDelivered(deliveredBolusAmount)
PumpEnactResult(injector).success(true).enacted(true).bolusDelivered(deliveredBolusAmount)
}.onErrorReturnItem(
// success if canceled
PumpEnactResultObject(injector).success(bolusCanceled).enacted(false)
PumpEnactResult(injector).success(bolusCanceled).enacted(false)
)
.blockingGet()
aapsLogger.info(
@ -940,13 +939,13 @@ class OmnipodDashPumpPlugin @Inject constructor(
tbrType: PumpSync.TemporaryBasalType
): PumpEnactResult {
// 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")
}
override fun setExtendedBolus(insulin: Double, durationInMinutes: Int): PumpEnactResult {
// 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")
}
@ -963,7 +962,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
pumpSync.expectedPumpState().temporaryBasal == null
) {
// nothing to cancel
return PumpEnactResultObject(injector).success(true).enacted(false)
return PumpEnactResult(injector).success(true).enacted(false)
}
return executeProgrammingCommand(
@ -986,17 +985,17 @@ class OmnipodDashPumpPlugin @Inject constructor(
}
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 ->
aapsLogger.error(LTag.PUMP, "toPumpEnactResult, error executing command: $throwable")
}
.onErrorReturnItem(PumpEnactResultObject(injector).success(false).enacted(false))
.onErrorReturnItem(PumpEnactResult(injector).success(false).enacted(false))
.blockingGet()
}
override fun cancelExtendedBolus(): PumpEnactResult {
// 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")
}
@ -1097,7 +1096,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
override fun loadTDDs(): PumpEnactResult {
// TODO i18n
return PumpEnactResultObject(injector).success(false).enacted(false)
return PumpEnactResult(injector).success(false).enacted(false)
.comment("Omnipod Dash driver does not support TDD")
}
@ -1132,7 +1131,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
else -> {
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(
R.string.omnipod_common_error_unsupported_custom_command,
customCommand.javaClass.name
@ -1149,7 +1148,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
historyEntry = history.createRecord(commandType = OmnipodCommandType.ACKNOWLEDGE_ALERTS),
command = omnipodManager.silenceAlerts(it).ignoreElements(),
).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 {
@ -1197,7 +1196,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
R.raw.boluserror
)
}.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 {
@ -1223,7 +1222,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
private fun handleTimeChange(): PumpEnactResult {
return profileFunction.getProfile()?.let {
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 {
@ -1241,12 +1240,12 @@ class OmnipodDashPumpPlugin @Inject constructor(
lowReservoirAlertUnits
) -> {
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 -> {
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 " +
"expiryAlertDuration=$expiryAlertDelay"
)
PumpEnactResultObject(injector).success(false).enacted(false)
PumpEnactResult(injector).success(false).enacted(false)
}
val alerts = listOf(
AlertConfiguration(

View file

@ -2,7 +2,6 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.ui.wizard.activatio
import androidx.annotation.StringRes
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.ui.wizard.activation.viewmodel.action.InitializePodViewModel
import info.nightscout.androidaps.plugins.pump.omnipod.dash.R
@ -66,14 +65,14 @@ class DashInitializePodViewModel @Inject constructor(
onError = { throwable ->
logger.error(LTag.PUMP, "Error in Pod activation part 1", throwable)
source.onSuccess(
PumpEnactResultObject(injector)
PumpEnactResult(injector)
.success(false)
.comment(I8n.textFromException(throwable, rh))
)
},
onComplete = {
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 dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
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.ui.wizard.activation.viewmodel.action.InsertCannulaViewModel
@ -91,7 +90,7 @@ class DashInsertCannulaViewModel @Inject constructor(
.subscribeBy(
onError = { 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 = {
logger.debug("Pod activation part 2 completed")
@ -121,7 +120,7 @@ class DashInsertCannulaViewModel @Inject constructor(
)
rxBus.send(EventDismissNotification(Notification.OMNIPOD_POD_NOT_ATTACHED))
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 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.EventNewNotification;
import info.nightscout.androidaps.plugins.pump.common.defs.TempBasalPair;
@ -603,7 +602,7 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements Pump, Riley
@Override
public PumpEnactResult setNewBasalProfile(@NonNull Profile profile) {
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));
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) {
// neither carbs nor bolus requested
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);
} else if (detailedBolusInfo.insulin > 0) {
// 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",
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);
}
}
@ -697,7 +696,7 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements Pump, Riley
aapsLogger.info(LTag.PUMP, "setTempBasalAbsolute: rate: {}, duration={}", absoluteRate, durationInMinutes);
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
@ -711,7 +710,7 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements Pump, Riley
if (tbrCurrent != null && !enforceNew) {
if (Round.INSTANCE.isSame(tbrCurrent.getRate(), absoluteRate)) {
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) {
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);
@ -857,7 +856,7 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements Pump, Riley
@Override
public PumpEnactResult executeCustomCommand(@NonNull CustomCommand command) {
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) {
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());
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() {
@ -895,7 +894,7 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements Pump, Riley
try {
result = executeCommand(OmnipodCommandType.READ_POD_PULSE_LOG, aapsOmnipodErosManager::readPulseLog);
} 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());
@ -905,7 +904,7 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements Pump, Riley
i.putExtra("clipboardContent", result.toString());
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
return new PumpEnactResultObject(getInjector()).success(true).enacted(false);
return new PumpEnactResult(getInjector()).success(true).enacted(false);
}
@NonNull private PumpEnactResult updateAlertConfiguration() {
@ -1171,7 +1170,7 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements Pump, Riley
}
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 dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.data.PumpEnactResultObject;
import info.nightscout.androidaps.extensions.PumpStateExtensionKt;
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
@ -170,7 +169,7 @@ public class AapsOmnipodErosManager {
}
public PumpEnactResult initializePod() {
PumpEnactResult result = new PumpEnactResultObject(injector);
PumpEnactResult result = new PumpEnactResult(injector);
try {
Boolean res = executeCommand(delegate::pairAndPrime)
.blockingGet();
@ -192,10 +191,10 @@ public class AapsOmnipodErosManager {
public PumpEnactResult insertCannula(Profile profile) {
if (profile == null) {
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 {
BasalSchedule basalSchedule = mapProfileToBasalSchedule(profile);
@ -233,11 +232,11 @@ public class AapsOmnipodErosManager {
} catch (Exception ex) {
String errorMessage = translateException(ex);
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);
return new PumpEnactResultObject(injector).success(true).enacted(false);
return new PumpEnactResult(injector).success(true).enacted(false);
}
public PumpEnactResult playTestBeep(BeepConfigType beepType) {
@ -246,11 +245,11 @@ public class AapsOmnipodErosManager {
} catch (Exception ex) {
String errorMessage = translateException(ex);
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);
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) {
String errorMessage = translateException(ex);
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);
return new PumpEnactResultObject(injector).success(true).enacted(false);
return new PumpEnactResult(injector).success(true).enacted(false);
}
public PumpEnactResult deactivatePod() {
@ -276,7 +275,7 @@ public class AapsOmnipodErosManager {
} catch (Exception ex) {
String errorMessage = translateException(ex);
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);
@ -284,7 +283,7 @@ public class AapsOmnipodErosManager {
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) {
@ -293,7 +292,7 @@ public class AapsOmnipodErosManager {
if (showNotifications) {
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
@ -301,7 +300,7 @@ public class AapsOmnipodErosManager {
// otherwise a catch-22
if (!podStateManager.getActivationProgress().isCompleted()) {
// 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");
}
@ -317,14 +316,14 @@ public class AapsOmnipodErosManager {
}
String errorMessage = translateException(ex.getCause());
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) {
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);
}
String errorMessage = translateException(ex.getCause());
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) {
if (showNotifications) {
String note;
@ -337,7 +336,7 @@ public class AapsOmnipodErosManager {
}
String errorMessage = translateException(ex);
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_TIME_OUT_OF_SYNC);
return new PumpEnactResultObject(injector).success(true).enacted(true);
return new PumpEnactResult(injector).success(true).enacted(true);
}
public PumpEnactResult discardPodState() {
@ -369,7 +368,7 @@ public class AapsOmnipodErosManager {
sendEvent(new EventOmnipodErosPumpValuesChanged());
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) {
@ -393,7 +392,7 @@ public class AapsOmnipodErosManager {
} catch (Exception ex) {
String errorMessage = translateException(ex);
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())) {
@ -448,7 +447,7 @@ public class AapsOmnipodErosManager {
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() {
@ -463,7 +462,7 @@ public class AapsOmnipodErosManager {
aapsLogger.debug(LTag.PUMP, "Not cancelling bolus: bolus command failed");
String comment = getStringResource(R.string.omnipod_common_error_bolus_did_not_succeed);
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()));
aapsLogger.debug(LTag.PUMP, "Successfully cancelled bolus", i);
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) {
aapsLogger.debug(LTag.PUMP, "Successfully cancelled bolus (implicitly because of a Pod Fault)");
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) {
aapsLogger.debug(LTag.PUMP, "Failed to cancel bolus", ex);
comment = translateException(ex);
@ -487,7 +486,7 @@ public class AapsOmnipodErosManager {
}
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) {
@ -497,7 +496,7 @@ public class AapsOmnipodErosManager {
} catch (CommandFailedAfterChangingDeliveryStatusException ex) {
String errorMessage = translateException(ex.getCause());
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) {
String errorMessage = translateException(ex.getCause());
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
return new PumpEnactResultObject(injector).success(false).enacted(false).comment(errorMessage);
return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage);
} catch (Exception ex) {
String errorMessage = translateException(ex);
long pumpId = addFailureToHistory(PodHistoryEntryType.SET_TEMPORARY_BASAL, errorMessage);
@ -524,7 +523,7 @@ public class AapsOmnipodErosManager {
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);
@ -533,7 +532,7 @@ public class AapsOmnipodErosManager {
sendEvent(new EventDismissNotification(Notification.OMNIPOD_TBR_ALERTS));
return new PumpEnactResultObject(injector)
return new PumpEnactResult(injector)
.duration(tempBasalPair.getDurationMinutes())
.absolute(PumpType.OMNIPOD_EROS.determineCorrectBasalSize(tempBasalPair.getInsulinRate()))
.success(true).enacted(true);
@ -550,7 +549,7 @@ public class AapsOmnipodErosManager {
}
String errorMessage = translateException(ex);
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);
@ -564,7 +563,7 @@ public class AapsOmnipodErosManager {
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() {
@ -573,11 +572,11 @@ public class AapsOmnipodErosManager {
} catch (Exception ex) {
String errorMessage = translateException(ex);
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);
return new PumpEnactResultObject(injector).success(true).enacted(true);
return new PumpEnactResult(injector).success(true).enacted(true);
}
public PumpEnactResult suspendDelivery() {
@ -586,7 +585,7 @@ public class AapsOmnipodErosManager {
} catch (Exception ex) {
String errorMessage = translateException(ex);
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);
@ -595,7 +594,7 @@ public class AapsOmnipodErosManager {
dismissNotification(Notification.FAILED_UPDATE_PROFILE);
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
@ -609,21 +608,21 @@ public class AapsOmnipodErosManager {
}
String errorMessage = translateException(ex.getCause());
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) {
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);
}
String errorMessage = translateException(ex.getCause());
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) {
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);
}
String errorMessage = translateException(ex);
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);
@ -632,7 +631,7 @@ public class AapsOmnipodErosManager {
dismissNotification(Notification.OMNIPOD_POD_SUSPENDED);
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() {

View file

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

View file

@ -6,7 +6,6 @@ import android.content.ServiceConnection
import android.text.format.DateFormat
import com.google.gson.GsonBuilder
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.androidaps.extensions.convertedToAbsolute
import info.nightscout.androidaps.extensions.plannedRemainingMinutes
import info.nightscout.androidaps.extensions.toStringFull
@ -313,7 +312,7 @@ abstract class PumpPluginAbstract protected constructor(
if (detailedBolusInfo.insulin == 0.0 && detailedBolusInfo.carbs == 0.0) {
// neither carbs nor bolus requested
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)
} else if (detailedBolusInfo.insulin > 0) {
// bolus needed, ask pump to deliver it
@ -329,7 +328,7 @@ abstract class PumpPluginAbstract protected constructor(
bolusingEvent.percent = 100
rxBus.send(bolusingEvent)
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)
}
} finally {
@ -350,7 +349,7 @@ abstract class PumpPluginAbstract protected constructor(
protected abstract fun triggerUIChange()
private fun getOperationNotSupportedWithCustomText(resourceId: Int): PumpEnactResult =
PumpEnactResultObject(injector).success(false).enacted(false).comment(resourceId)
PumpEnactResult(injector).success(false).enacted(false).comment(resourceId)
init {
pumpDescription.fillFor(pumpType)

View file

@ -1,7 +1,6 @@
package info.nightscout.androidaps
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResultObject
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.pump.Pump
@ -44,30 +43,30 @@ class TestPumpPlugin(val injector: HasAndroidInjector) : Pump {
override fun waitForDisconnectionInSeconds(): Int = 0
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 lastDataTime(): Long = lastData
override val baseBasalRate: Double = baseBasal
override val reservoirLevel: Double = 0.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 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 =
PumpEnactResultObject(injector).success(true)
PumpEnactResult(injector).success(true)
override fun setExtendedBolus(insulin: Double, durationInMinutes: Int): PumpEnactResult = PumpEnactResultObject(injector).success(true)
override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult = PumpEnactResultObject(injector).success(true)
override fun cancelExtendedBolus(): PumpEnactResult = PumpEnactResultObject(injector).success(true)
override fun setExtendedBolus(insulin: Double, durationInMinutes: Int): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun cancelExtendedBolus(): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun getJSONStatus(profile: Profile, profileName: String, version: String): JSONObject = JSONObject()
override fun manufacturer(): ManufacturerType = ManufacturerType.AAPS
override fun model(): PumpType = PumpType.GENERIC_AAPS
override fun serialNumber(): String = "1"
override fun shortStatus(veryShort: Boolean): String = ""
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 timezoneOrDSTChanged(timeChangeType: TimeChangeType) {}
}