Merge branch 'dev' of https://github.com/nightscout/AndroidAPS into dev
This commit is contained in:
commit
9d99913282
6 changed files with 29 additions and 14 deletions
|
@ -145,7 +145,7 @@ abstract class Trigger(val injector: HasAndroidInjector) {
|
|||
TriggerWifiSsid::class.java.simpleName -> TriggerWifiSsid(injector).fromJSON(
|
||||
data.toString()
|
||||
)
|
||||
else -> throw ClassNotFoundException(type)
|
||||
else -> TriggerConnector(injector)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,12 +7,16 @@ import info.nightscout.androidaps.data.PumpEnactResult
|
|||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.logging.LTag
|
||||
import io.reactivex.Single
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.rxkotlin.addTo
|
||||
import io.reactivex.rxkotlin.plusAssign
|
||||
import io.reactivex.rxkotlin.subscribeBy
|
||||
|
||||
abstract class ActionViewModelBase(
|
||||
protected val injector: HasAndroidInjector,
|
||||
protected val logger: AAPSLogger
|
||||
) : ViewModelBase() {
|
||||
protected val disposable = CompositeDisposable()
|
||||
|
||||
private val _isActionExecutingLiveData = MutableLiveData(false)
|
||||
val isActionExecutingLiveData: LiveData<Boolean> = _isActionExecutingLiveData
|
||||
|
@ -22,7 +26,7 @@ abstract class ActionViewModelBase(
|
|||
|
||||
fun executeAction() {
|
||||
_isActionExecutingLiveData.postValue(true)
|
||||
val disposable = doExecuteAction().subscribeBy(
|
||||
disposable += doExecuteAction().subscribeBy(
|
||||
onSuccess = { result ->
|
||||
_isActionExecutingLiveData.postValue(false)
|
||||
_actionResultLiveData.postValue(result)
|
||||
|
@ -35,5 +39,11 @@ abstract class ActionViewModelBase(
|
|||
})
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
super.onCleared()
|
||||
disposable.clear()
|
||||
}
|
||||
|
||||
|
||||
protected abstract fun doExecuteAction(): Single<PumpEnactResult>
|
||||
}
|
||||
|
|
|
@ -111,13 +111,12 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
updatePodWarnings()
|
||||
aapsLogger.info(LTag.PUMP, "statusChecker")
|
||||
|
||||
createFakeTBRWhenNoActivePod()
|
||||
val err = createFakeTBRWhenNoActivePod()
|
||||
.subscribeOn(aapsSchedulers.io)
|
||||
.subscribeBy(
|
||||
onError = {
|
||||
aapsLogger.warn(LTag.PUMP, "Error on createFakeTBRWhenNoActivePod=$it")
|
||||
}
|
||||
)
|
||||
.blockingGet()
|
||||
err?.let {
|
||||
aapsLogger.warn(LTag.PUMP, "Error on createFakeTBRWhenNoActivePod=$it")
|
||||
}
|
||||
handler.postDelayed(statusChecker, STATUS_CHECK_INTERVAL_MS)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,13 +17,13 @@ class AlertConfiguration(
|
|||
get() {
|
||||
var firstByte = (type.index.toInt() shl 4).toByte()
|
||||
if (enabled) {
|
||||
firstByte = firstByte or (1 shl 3).toByte()
|
||||
firstByte = (firstByte.toInt() or (1 shl 3)).toByte()
|
||||
}
|
||||
if (trigger is AlertTrigger.ReservoirVolumeTrigger) {
|
||||
firstByte = firstByte or (1 shl 2).toByte()
|
||||
firstByte = (firstByte.toInt() or (1 shl 2)).toByte()
|
||||
}
|
||||
if (autoOff) {
|
||||
firstByte = firstByte or (1 shl 1).toByte()
|
||||
firstByte = (firstByte.toInt() or (1 shl 1)).toByte()
|
||||
}
|
||||
firstByte = firstByte or ((durationInMinutes.toInt() shr 8 and 0x01).toByte())
|
||||
return ByteBuffer.allocate(6)
|
||||
|
|
|
@ -14,6 +14,9 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.util.I8n
|
|||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
import io.reactivex.Single
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.rxkotlin.addTo
|
||||
import io.reactivex.rxkotlin.plusAssign
|
||||
import io.reactivex.rxkotlin.subscribeBy
|
||||
import javax.inject.Inject
|
||||
|
||||
|
@ -40,7 +43,7 @@ class DashInitializePodViewModel @Inject constructor(
|
|||
} else
|
||||
null
|
||||
|
||||
omnipodManager.activatePodPart1(lowReservoirAlertTrigger).subscribeBy(
|
||||
super.disposable += omnipodManager.activatePodPart1(lowReservoirAlertTrigger).subscribeBy(
|
||||
onNext = { podEvent ->
|
||||
logger.debug(
|
||||
LTag.PUMP,
|
||||
|
|
|
@ -21,6 +21,9 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.util.mapProfileToBas
|
|||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
import io.reactivex.Single
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.rxkotlin.addTo
|
||||
import io.reactivex.rxkotlin.plusAssign
|
||||
import io.reactivex.rxkotlin.subscribeBy
|
||||
import javax.inject.Inject
|
||||
|
||||
|
@ -36,7 +39,6 @@ class DashInsertCannulaViewModel @Inject constructor(
|
|||
injector: HasAndroidInjector,
|
||||
logger: AAPSLogger
|
||||
) : InsertCannulaViewModel(injector, logger) {
|
||||
|
||||
override fun isPodInAlarm(): Boolean = false // TODO
|
||||
|
||||
override fun isPodActivationTimeExceeded(): Boolean = false // TODO
|
||||
|
@ -63,7 +65,8 @@ class DashInsertCannulaViewModel @Inject constructor(
|
|||
else
|
||||
null
|
||||
|
||||
omnipodManager.activatePodPart2(basalProgram, expirationHoursBeforeShutdown).subscribeBy(
|
||||
super.disposable += omnipodManager.activatePodPart2(basalProgram, expirationHoursBeforeShutdown)
|
||||
.subscribeBy(
|
||||
onNext = { podEvent ->
|
||||
logger.debug(
|
||||
LTag.PUMP,
|
||||
|
|
Loading…
Reference in a new issue