remove Command dependency
This commit is contained in:
parent
d108755814
commit
4120a4ad81
19 changed files with 103 additions and 30 deletions
|
@ -1,13 +1,9 @@
|
||||||
package info.nightscout.androidaps.queue.commands
|
package info.nightscout.androidaps.queue.commands
|
||||||
|
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.core.main.R
|
|
||||||
import info.nightscout.androidaps.data.PumpEnactResultObject
|
|
||||||
import info.nightscout.database.impl.AppRepository
|
|
||||||
import info.nightscout.shared.interfaces.ResourceHelper
|
|
||||||
import info.nightscout.interfaces.queue.Callback
|
import info.nightscout.interfaces.queue.Callback
|
||||||
import info.nightscout.rx.logging.AAPSLogger
|
import info.nightscout.rx.logging.AAPSLogger
|
||||||
import info.nightscout.rx.logging.LTag
|
import info.nightscout.shared.interfaces.ResourceHelper
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
abstract class Command(
|
abstract class Command(
|
||||||
|
@ -18,7 +14,6 @@ abstract class Command(
|
||||||
|
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
@Inject lateinit var rh: ResourceHelper
|
@Inject lateinit var rh: ResourceHelper
|
||||||
@Inject lateinit var repository: AppRepository
|
|
||||||
|
|
||||||
enum class CommandType {
|
enum class CommandType {
|
||||||
BOLUS,
|
BOLUS,
|
||||||
|
@ -46,12 +41,5 @@ abstract class Command(
|
||||||
abstract fun execute()
|
abstract fun execute()
|
||||||
abstract fun status(): String
|
abstract fun status(): String
|
||||||
abstract fun log(): String
|
abstract fun log(): String
|
||||||
|
abstract fun cancel()
|
||||||
fun cancel() {
|
|
||||||
val result = PumpEnactResultObject(injector)
|
|
||||||
result.success = false
|
|
||||||
result.comment = rh.gs(R.string.connectiontimedout)
|
|
||||||
aapsLogger.debug(LTag.PUMPQUEUE, "Result cancel")
|
|
||||||
callback?.result(result)?.run()
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -190,6 +190,7 @@ class CommandQueueImplementation @Inject constructor(
|
||||||
synchronized(queue) {
|
synchronized(queue) {
|
||||||
for (i in queue.indices) {
|
for (i in queue.indices) {
|
||||||
queue[i].cancel()
|
queue[i].cancel()
|
||||||
|
|
||||||
}
|
}
|
||||||
queue.clear()
|
queue.clear()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
package info.nightscout.implementation.queue.commands
|
package info.nightscout.implementation.queue.commands
|
||||||
|
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.interfaces.pump.DetailedBolusInfo
|
import info.nightscout.androidaps.data.PumpEnactResultObject
|
||||||
import info.nightscout.androidaps.dialogs.BolusProgressDialog
|
import info.nightscout.androidaps.dialogs.BolusProgressDialog
|
||||||
import info.nightscout.androidaps.interfaces.ActivePlugin
|
import info.nightscout.androidaps.interfaces.ActivePlugin
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissBolusProgressIfRunning
|
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissBolusProgressIfRunning
|
||||||
import info.nightscout.interfaces.queue.Callback
|
|
||||||
import info.nightscout.androidaps.queue.commands.Command
|
import info.nightscout.androidaps.queue.commands.Command
|
||||||
import info.nightscout.implementation.R
|
import info.nightscout.implementation.R
|
||||||
|
import info.nightscout.interfaces.pump.DetailedBolusInfo
|
||||||
|
import info.nightscout.interfaces.queue.Callback
|
||||||
import info.nightscout.rx.bus.RxBus
|
import info.nightscout.rx.bus.RxBus
|
||||||
import info.nightscout.rx.logging.LTag
|
import info.nightscout.rx.logging.LTag
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -41,4 +42,9 @@ class CommandBolus(
|
||||||
return (if (detailedBolusInfo.insulin > 0) "BOLUS " + rh.gs(R.string.formatinsulinunits, detailedBolusInfo.insulin) else "") +
|
return (if (detailedBolusInfo.insulin > 0) "BOLUS " + rh.gs(R.string.formatinsulinunits, detailedBolusInfo.insulin) else "") +
|
||||||
if (detailedBolusInfo.carbs > 0) "CARBS " + rh.gs(R.string.format_carbs, detailedBolusInfo.carbs.toInt()) else ""
|
if (detailedBolusInfo.carbs > 0) "CARBS " + rh.gs(R.string.format_carbs, detailedBolusInfo.carbs.toInt()) else ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun cancel() {
|
||||||
|
aapsLogger.debug(LTag.PUMPQUEUE, "Result cancel")
|
||||||
|
callback?.result(PumpEnactResultObject(injector).success(false).comment(info.nightscout.core.main.R.string.connectiontimedout))?.run()
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,12 +1,12 @@
|
||||||
package info.nightscout.implementation.queue.commands
|
package info.nightscout.implementation.queue.commands
|
||||||
|
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.data.PumpEnactResultObject
|
||||||
import info.nightscout.androidaps.interfaces.ActivePlugin
|
import info.nightscout.androidaps.interfaces.ActivePlugin
|
||||||
import info.nightscout.interfaces.queue.Callback
|
|
||||||
import info.nightscout.androidaps.queue.commands.Command
|
import info.nightscout.androidaps.queue.commands.Command
|
||||||
import info.nightscout.implementation.R
|
import info.nightscout.implementation.R
|
||||||
|
import info.nightscout.interfaces.queue.Callback
|
||||||
import info.nightscout.rx.logging.LTag
|
import info.nightscout.rx.logging.LTag
|
||||||
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class CommandCancelExtendedBolus constructor(
|
class CommandCancelExtendedBolus constructor(
|
||||||
|
@ -25,4 +25,8 @@ class CommandCancelExtendedBolus constructor(
|
||||||
override fun status(): String = rh.gs(R.string.uel_cancel_extended_bolus)
|
override fun status(): String = rh.gs(R.string.uel_cancel_extended_bolus)
|
||||||
|
|
||||||
override fun log(): String = "CANCEL EXTENDEDBOLUS"
|
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()
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,12 +1,12 @@
|
||||||
package info.nightscout.implementation.queue.commands
|
package info.nightscout.implementation.queue.commands
|
||||||
|
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.data.PumpEnactResultObject
|
||||||
import info.nightscout.androidaps.interfaces.ActivePlugin
|
import info.nightscout.androidaps.interfaces.ActivePlugin
|
||||||
import info.nightscout.interfaces.queue.Callback
|
|
||||||
import info.nightscout.androidaps.queue.commands.Command
|
import info.nightscout.androidaps.queue.commands.Command
|
||||||
import info.nightscout.implementation.R
|
import info.nightscout.implementation.R
|
||||||
|
import info.nightscout.interfaces.queue.Callback
|
||||||
import info.nightscout.rx.logging.LTag
|
import info.nightscout.rx.logging.LTag
|
||||||
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class CommandCancelTempBasal(
|
class CommandCancelTempBasal(
|
||||||
|
@ -26,4 +26,8 @@ class CommandCancelTempBasal(
|
||||||
override fun status(): String = rh.gs(R.string.uel_accepts_temp_basal)
|
override fun status(): String = rh.gs(R.string.uel_accepts_temp_basal)
|
||||||
|
|
||||||
override fun log(): String = "CANCEL TEMPBASAL"
|
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()
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,12 +1,12 @@
|
||||||
package info.nightscout.implementation.queue.commands
|
package info.nightscout.implementation.queue.commands
|
||||||
|
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.data.PumpEnactResultObject
|
||||||
import info.nightscout.androidaps.interfaces.ActivePlugin
|
import info.nightscout.androidaps.interfaces.ActivePlugin
|
||||||
import info.nightscout.interfaces.queue.Callback
|
|
||||||
import info.nightscout.androidaps.queue.commands.Command
|
import info.nightscout.androidaps.queue.commands.Command
|
||||||
|
import info.nightscout.interfaces.queue.Callback
|
||||||
import info.nightscout.interfaces.queue.CustomCommand
|
import info.nightscout.interfaces.queue.CustomCommand
|
||||||
import info.nightscout.rx.logging.LTag
|
import info.nightscout.rx.logging.LTag
|
||||||
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class CommandCustomCommand(
|
class CommandCustomCommand(
|
||||||
|
@ -27,4 +27,8 @@ class CommandCustomCommand(
|
||||||
override fun status(): String = customCommand.statusDescription
|
override fun status(): String = customCommand.statusDescription
|
||||||
|
|
||||||
override fun log(): String = customCommand.statusDescription
|
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()
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,12 +1,12 @@
|
||||||
package info.nightscout.implementation.queue.commands
|
package info.nightscout.implementation.queue.commands
|
||||||
|
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.data.PumpEnactResultObject
|
||||||
import info.nightscout.androidaps.interfaces.ActivePlugin
|
import info.nightscout.androidaps.interfaces.ActivePlugin
|
||||||
import info.nightscout.interfaces.queue.Callback
|
|
||||||
import info.nightscout.androidaps.queue.commands.Command
|
import info.nightscout.androidaps.queue.commands.Command
|
||||||
import info.nightscout.implementation.R
|
import info.nightscout.implementation.R
|
||||||
|
import info.nightscout.interfaces.queue.Callback
|
||||||
import info.nightscout.rx.logging.LTag
|
import info.nightscout.rx.logging.LTag
|
||||||
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class CommandExtendedBolus constructor(
|
class CommandExtendedBolus constructor(
|
||||||
|
@ -27,4 +27,8 @@ class CommandExtendedBolus constructor(
|
||||||
override fun status(): String = rh.gs(R.string.extended_bolus_u_min, insulin, durationInMinutes)
|
override fun status(): String = rh.gs(R.string.extended_bolus_u_min, insulin, durationInMinutes)
|
||||||
|
|
||||||
override fun log(): String = "EXTENDEDBOLUS $insulin U $durationInMinutes min"
|
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()
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,11 +1,13 @@
|
||||||
package info.nightscout.implementation.queue.commands
|
package info.nightscout.implementation.queue.commands
|
||||||
|
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.data.PumpEnactResultObject
|
||||||
import info.nightscout.androidaps.interfaces.ActivePlugin
|
import info.nightscout.androidaps.interfaces.ActivePlugin
|
||||||
import info.nightscout.androidaps.queue.commands.Command
|
import info.nightscout.androidaps.queue.commands.Command
|
||||||
import info.nightscout.implementation.R
|
import info.nightscout.implementation.R
|
||||||
import info.nightscout.interfaces.pump.Insight
|
import info.nightscout.interfaces.pump.Insight
|
||||||
import info.nightscout.interfaces.queue.Callback
|
import info.nightscout.interfaces.queue.Callback
|
||||||
|
import info.nightscout.rx.logging.LTag
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class CommandInsightSetTBROverNotification constructor(
|
class CommandInsightSetTBROverNotification constructor(
|
||||||
|
@ -28,4 +30,8 @@ class CommandInsightSetTBROverNotification constructor(
|
||||||
|
|
||||||
@Suppress("SpellCheckingInspection")
|
@Suppress("SpellCheckingInspection")
|
||||||
override fun log(): String = "INSIGHTSETTBROVERNOTIFICATION"
|
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()
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package info.nightscout.implementation.queue.commands
|
package info.nightscout.implementation.queue.commands
|
||||||
|
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.data.PumpEnactResultObject
|
||||||
import info.nightscout.androidaps.interfaces.ActivePlugin
|
import info.nightscout.androidaps.interfaces.ActivePlugin
|
||||||
import info.nightscout.androidaps.queue.commands.Command
|
import info.nightscout.androidaps.queue.commands.Command
|
||||||
import info.nightscout.implementation.R
|
import info.nightscout.implementation.R
|
||||||
|
@ -37,4 +38,8 @@ class CommandLoadEvents(
|
||||||
override fun status(): String = rh.gs(R.string.load_events)
|
override fun status(): String = rh.gs(R.string.load_events)
|
||||||
|
|
||||||
override fun log(): String = "LOAD EVENTS"
|
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()
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package info.nightscout.implementation.queue.commands
|
package info.nightscout.implementation.queue.commands
|
||||||
|
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.data.PumpEnactResultObject
|
||||||
import info.nightscout.androidaps.interfaces.ActivePlugin
|
import info.nightscout.androidaps.interfaces.ActivePlugin
|
||||||
import info.nightscout.androidaps.queue.commands.Command
|
import info.nightscout.androidaps.queue.commands.Command
|
||||||
import info.nightscout.implementation.R
|
import info.nightscout.implementation.R
|
||||||
|
@ -38,4 +39,8 @@ class CommandLoadHistory(
|
||||||
override fun status(): String = rh.gs(R.string.load_history, type.toInt())
|
override fun status(): String = rh.gs(R.string.load_history, type.toInt())
|
||||||
|
|
||||||
override fun log(): String = "LOAD HISTORY $type"
|
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()
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,12 +1,12 @@
|
||||||
package info.nightscout.implementation.queue.commands
|
package info.nightscout.implementation.queue.commands
|
||||||
|
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.data.PumpEnactResultObject
|
||||||
import info.nightscout.androidaps.interfaces.ActivePlugin
|
import info.nightscout.androidaps.interfaces.ActivePlugin
|
||||||
import info.nightscout.interfaces.queue.Callback
|
|
||||||
import info.nightscout.androidaps.queue.commands.Command
|
import info.nightscout.androidaps.queue.commands.Command
|
||||||
import info.nightscout.implementation.R
|
import info.nightscout.implementation.R
|
||||||
|
import info.nightscout.interfaces.queue.Callback
|
||||||
import info.nightscout.rx.logging.LTag
|
import info.nightscout.rx.logging.LTag
|
||||||
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class CommandLoadTDDs(
|
class CommandLoadTDDs(
|
||||||
|
@ -26,4 +26,8 @@ class CommandLoadTDDs(
|
||||||
override fun status(): String = rh.gs(R.string.load_tdds)
|
override fun status(): String = rh.gs(R.string.load_tdds)
|
||||||
|
|
||||||
override fun log(): String = "LOAD TDDs"
|
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()
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -3,13 +3,12 @@ package info.nightscout.implementation.queue.commands
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.data.PumpEnactResultObject
|
import info.nightscout.androidaps.data.PumpEnactResultObject
|
||||||
import info.nightscout.androidaps.interfaces.ActivePlugin
|
import info.nightscout.androidaps.interfaces.ActivePlugin
|
||||||
|
import info.nightscout.androidaps.queue.commands.Command
|
||||||
|
import info.nightscout.implementation.R
|
||||||
import info.nightscout.interfaces.LocalAlertUtils
|
import info.nightscout.interfaces.LocalAlertUtils
|
||||||
import info.nightscout.interfaces.queue.Callback
|
import info.nightscout.interfaces.queue.Callback
|
||||||
import info.nightscout.androidaps.queue.commands.Command
|
|
||||||
import info.nightscout.shared.utils.T
|
|
||||||
import info.nightscout.implementation.R
|
|
||||||
import info.nightscout.rx.logging.LTag
|
import info.nightscout.rx.logging.LTag
|
||||||
|
import info.nightscout.shared.utils.T
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class CommandReadStatus(
|
class CommandReadStatus(
|
||||||
|
@ -35,4 +34,8 @@ class CommandReadStatus(
|
||||||
override fun status(): String = rh.gs(R.string.read_status, reason)
|
override fun status(): String = rh.gs(R.string.read_status, reason)
|
||||||
|
|
||||||
override fun log(): String = "READSTATUS $reason"
|
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()
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -4,6 +4,7 @@ import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.data.PumpEnactResultObject
|
import info.nightscout.androidaps.data.PumpEnactResultObject
|
||||||
import info.nightscout.androidaps.interfaces.ActivePlugin
|
import info.nightscout.androidaps.interfaces.ActivePlugin
|
||||||
import info.nightscout.androidaps.queue.commands.Command
|
import info.nightscout.androidaps.queue.commands.Command
|
||||||
|
import info.nightscout.database.impl.AppRepository
|
||||||
import info.nightscout.implementation.R
|
import info.nightscout.implementation.R
|
||||||
import info.nightscout.interfaces.pump.DetailedBolusInfo
|
import info.nightscout.interfaces.pump.DetailedBolusInfo
|
||||||
import info.nightscout.interfaces.pump.PumpEnactResult
|
import info.nightscout.interfaces.pump.PumpEnactResult
|
||||||
|
@ -21,6 +22,7 @@ class CommandSMBBolus(
|
||||||
|
|
||||||
@Inject lateinit var dateUtil: DateUtil
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
@Inject lateinit var activePlugin: ActivePlugin
|
@Inject lateinit var activePlugin: ActivePlugin
|
||||||
|
@Inject lateinit var repository: AppRepository
|
||||||
|
|
||||||
override fun execute() {
|
override fun execute() {
|
||||||
val r: PumpEnactResult
|
val r: PumpEnactResult
|
||||||
|
@ -42,4 +44,8 @@ class CommandSMBBolus(
|
||||||
override fun status(): String = rh.gs(R.string.smb_bolus_u, detailedBolusInfo.insulin)
|
override fun status(): String = rh.gs(R.string.smb_bolus_u, detailedBolusInfo.insulin)
|
||||||
|
|
||||||
override fun log(): String = "SMB BOLUS ${rh.gs(R.string.formatinsulinunits, detailedBolusInfo.insulin)}"
|
override fun log(): String = "SMB BOLUS ${rh.gs(R.string.formatinsulinunits, detailedBolusInfo.insulin)}"
|
||||||
|
override fun cancel() {
|
||||||
|
aapsLogger.debug(LTag.PUMPQUEUE, "Result cancel")
|
||||||
|
callback?.result(PumpEnactResultObject(injector).success(false).comment(info.nightscout.core.main.R.string.connectiontimedout))?.run()
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -5,6 +5,7 @@ import info.nightscout.androidaps.data.PumpEnactResultObject
|
||||||
import info.nightscout.androidaps.interfaces.ActivePlugin
|
import info.nightscout.androidaps.interfaces.ActivePlugin
|
||||||
import info.nightscout.androidaps.interfaces.CommandQueue
|
import info.nightscout.androidaps.interfaces.CommandQueue
|
||||||
import info.nightscout.androidaps.queue.commands.Command
|
import info.nightscout.androidaps.queue.commands.Command
|
||||||
|
import info.nightscout.database.impl.AppRepository
|
||||||
import info.nightscout.database.impl.ValueWrapper
|
import info.nightscout.database.impl.ValueWrapper
|
||||||
import info.nightscout.implementation.R
|
import info.nightscout.implementation.R
|
||||||
import info.nightscout.interfaces.Config
|
import info.nightscout.interfaces.Config
|
||||||
|
@ -28,6 +29,7 @@ class CommandSetProfile constructor(
|
||||||
@Inject lateinit var dateUtil: DateUtil
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
@Inject lateinit var commandQueue: CommandQueue
|
@Inject lateinit var commandQueue: CommandQueue
|
||||||
@Inject lateinit var config: Config
|
@Inject lateinit var config: Config
|
||||||
|
@Inject lateinit var repository: AppRepository
|
||||||
|
|
||||||
override fun execute() {
|
override fun execute() {
|
||||||
if (commandQueue.isThisProfileSet(profile) && repository.getEffectiveProfileSwitchActiveAt(dateUtil.now()).blockingGet() is ValueWrapper.Existing) {
|
if (commandQueue.isThisProfileSet(profile) && repository.getEffectiveProfileSwitchActiveAt(dateUtil.now()).blockingGet() is ValueWrapper.Existing) {
|
||||||
|
@ -49,4 +51,8 @@ class CommandSetProfile constructor(
|
||||||
override fun status(): String = rh.gs(R.string.set_profile)
|
override fun status(): String = rh.gs(R.string.set_profile)
|
||||||
|
|
||||||
override fun log(): String = "SET PROFILE"
|
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()
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package info.nightscout.implementation.queue.commands
|
package info.nightscout.implementation.queue.commands
|
||||||
|
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.data.PumpEnactResultObject
|
||||||
import info.nightscout.androidaps.interfaces.ActivePlugin
|
import info.nightscout.androidaps.interfaces.ActivePlugin
|
||||||
import info.nightscout.androidaps.queue.commands.Command
|
import info.nightscout.androidaps.queue.commands.Command
|
||||||
import info.nightscout.implementation.R
|
import info.nightscout.implementation.R
|
||||||
|
@ -35,4 +36,8 @@ class CommandSetUserSettings(
|
||||||
override fun status(): String = rh.gs(R.string.set_user_settings)
|
override fun status(): String = rh.gs(R.string.set_user_settings)
|
||||||
|
|
||||||
override fun log(): String = "SET USER SETTINGS"
|
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()
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,11 +1,13 @@
|
||||||
package info.nightscout.implementation.queue.commands
|
package info.nightscout.implementation.queue.commands
|
||||||
|
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.data.PumpEnactResultObject
|
||||||
import info.nightscout.androidaps.interfaces.ActivePlugin
|
import info.nightscout.androidaps.interfaces.ActivePlugin
|
||||||
import info.nightscout.androidaps.queue.commands.Command
|
import info.nightscout.androidaps.queue.commands.Command
|
||||||
import info.nightscout.implementation.R
|
import info.nightscout.implementation.R
|
||||||
import info.nightscout.interfaces.pump.Insight
|
import info.nightscout.interfaces.pump.Insight
|
||||||
import info.nightscout.interfaces.queue.Callback
|
import info.nightscout.interfaces.queue.Callback
|
||||||
|
import info.nightscout.rx.logging.LTag
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class CommandStartPump(
|
class CommandStartPump(
|
||||||
|
@ -26,4 +28,8 @@ class CommandStartPump(
|
||||||
override fun status(): String = rh.gs(R.string.start_pump)
|
override fun status(): String = rh.gs(R.string.start_pump)
|
||||||
|
|
||||||
override fun log(): String = "START PUMP"
|
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()
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,11 +1,13 @@
|
||||||
package info.nightscout.implementation.queue.commands
|
package info.nightscout.implementation.queue.commands
|
||||||
|
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.data.PumpEnactResultObject
|
||||||
import info.nightscout.androidaps.interfaces.ActivePlugin
|
import info.nightscout.androidaps.interfaces.ActivePlugin
|
||||||
import info.nightscout.androidaps.queue.commands.Command
|
import info.nightscout.androidaps.queue.commands.Command
|
||||||
import info.nightscout.implementation.R
|
import info.nightscout.implementation.R
|
||||||
import info.nightscout.interfaces.pump.Insight
|
import info.nightscout.interfaces.pump.Insight
|
||||||
import info.nightscout.interfaces.queue.Callback
|
import info.nightscout.interfaces.queue.Callback
|
||||||
|
import info.nightscout.rx.logging.LTag
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class CommandStopPump(
|
class CommandStopPump(
|
||||||
|
@ -26,4 +28,8 @@ class CommandStopPump(
|
||||||
override fun status(): String = rh.gs(R.string.stop_pump)
|
override fun status(): String = rh.gs(R.string.stop_pump)
|
||||||
|
|
||||||
override fun log(): String = "STOP PUMP"
|
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()
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package info.nightscout.implementation.queue.commands
|
package info.nightscout.implementation.queue.commands
|
||||||
|
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.data.PumpEnactResultObject
|
||||||
import info.nightscout.androidaps.interfaces.ActivePlugin
|
import info.nightscout.androidaps.interfaces.ActivePlugin
|
||||||
import info.nightscout.androidaps.queue.commands.Command
|
import info.nightscout.androidaps.queue.commands.Command
|
||||||
import info.nightscout.implementation.R
|
import info.nightscout.implementation.R
|
||||||
|
@ -31,4 +32,8 @@ class CommandTempBasalAbsolute(
|
||||||
override fun status(): String = rh.gs(R.string.temp_basal_absolute, absoluteRate, durationInMinutes)
|
override fun status(): String = rh.gs(R.string.temp_basal_absolute, absoluteRate, durationInMinutes)
|
||||||
|
|
||||||
override fun log(): String = "TEMP BASAL $absoluteRate U/h $durationInMinutes min"
|
override fun log(): String = "TEMP BASAL $absoluteRate U/h $durationInMinutes min"
|
||||||
|
override fun cancel() {
|
||||||
|
aapsLogger.debug(LTag.PUMPQUEUE, "Result cancel")
|
||||||
|
callback?.result(PumpEnactResultObject(injector).success(false).comment(info.nightscout.core.main.R.string.connectiontimedout))?.run()
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package info.nightscout.implementation.queue.commands
|
package info.nightscout.implementation.queue.commands
|
||||||
|
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.data.PumpEnactResultObject
|
||||||
import info.nightscout.androidaps.interfaces.ActivePlugin
|
import info.nightscout.androidaps.interfaces.ActivePlugin
|
||||||
import info.nightscout.androidaps.queue.commands.Command
|
import info.nightscout.androidaps.queue.commands.Command
|
||||||
import info.nightscout.implementation.R
|
import info.nightscout.implementation.R
|
||||||
|
@ -35,4 +36,8 @@ class CommandTempBasalPercent(
|
||||||
override fun status(): String = rh.gs(R.string.temp_basal_percent, percent, durationInMinutes)
|
override fun status(): String = rh.gs(R.string.temp_basal_percent, percent, durationInMinutes)
|
||||||
|
|
||||||
override fun log(): String = "TEMP BASAL $percent% $durationInMinutes min"
|
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()
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue