add history, command confirmation for more commands
This commit is contained in:
parent
842f196ae8
commit
142ad126b5
2 changed files with 55 additions and 30 deletions
|
@ -21,6 +21,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.Omn
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.DashHistory
|
import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.DashHistory
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.data.BolusRecord
|
import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.data.BolusRecord
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.data.BolusType
|
import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.data.BolusType
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.data.TempBasalRecord
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.ui.OmnipodDashOverviewFragment
|
import info.nightscout.androidaps.plugins.pump.omnipod.dash.ui.OmnipodDashOverviewFragment
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.util.mapProfileToBasalProgram
|
import info.nightscout.androidaps.plugins.pump.omnipod.dash.util.mapProfileToBasalProgram
|
||||||
import info.nightscout.androidaps.queue.commands.CustomCommand
|
import info.nightscout.androidaps.queue.commands.CustomCommand
|
||||||
|
@ -191,8 +192,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
||||||
detailedBolusInfo.insulin,
|
detailedBolusInfo.insulin,
|
||||||
if (detailedBolusInfo.isSMB) BolusType.SMB else BolusType.DEFAULT
|
if (detailedBolusInfo.isSMB) BolusType.SMB else BolusType.DEFAULT
|
||||||
),
|
),
|
||||||
).flatMapObservable {
|
).flatMapObservable { recordId ->
|
||||||
recordId ->
|
|
||||||
podStateManager.createActiveCommand(recordId).toObservable()
|
podStateManager.createActiveCommand(recordId).toObservable()
|
||||||
},
|
},
|
||||||
omnipodManager.bolus(
|
omnipodManager.bolus(
|
||||||
|
@ -202,8 +202,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
||||||
),
|
),
|
||||||
history.updateFromState(podStateManager).toObservable(),
|
history.updateFromState(podStateManager).toObservable(),
|
||||||
podStateManager.updateActiveCommand().toObservable(),
|
podStateManager.updateActiveCommand().toObservable(),
|
||||||
)
|
).subscribeBy(
|
||||||
.subscribeBy(
|
|
||||||
onNext = { podEvent ->
|
onNext = { podEvent ->
|
||||||
aapsLogger.debug(
|
aapsLogger.debug(
|
||||||
LTag.PUMP,
|
LTag.PUMP,
|
||||||
|
@ -226,10 +225,18 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun stopBolusDelivering() {
|
override fun stopBolusDelivering() {
|
||||||
// TODO history
|
|
||||||
// TODO update Treatments (?)
|
// TODO update Treatments (?)
|
||||||
|
|
||||||
omnipodManager.stopBolus().blockingSubscribeBy(
|
Observable.concat(
|
||||||
|
history.createRecord(
|
||||||
|
commandType = OmnipodCommandType.CANCEL_BOLUS,
|
||||||
|
).flatMapObservable { recordId ->
|
||||||
|
podStateManager.createActiveCommand(recordId).toObservable()
|
||||||
|
},
|
||||||
|
omnipodManager.stopBolus(),
|
||||||
|
history.updateFromState(podStateManager).toObservable(),
|
||||||
|
podStateManager.updateActiveCommand().toObservable(),
|
||||||
|
).blockingSubscribeBy(
|
||||||
onNext = { podEvent ->
|
onNext = { podEvent ->
|
||||||
aapsLogger.debug(
|
aapsLogger.debug(
|
||||||
LTag.PUMP,
|
LTag.PUMP,
|
||||||
|
@ -251,13 +258,22 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
||||||
profile: Profile,
|
profile: Profile,
|
||||||
enforceNew: Boolean
|
enforceNew: Boolean
|
||||||
): PumpEnactResult {
|
): PumpEnactResult {
|
||||||
// TODO history
|
|
||||||
// TODO update Treatments
|
// TODO update Treatments
|
||||||
|
|
||||||
return Single.create<PumpEnactResult> { source ->
|
return Single.create<PumpEnactResult> { source ->
|
||||||
|
Observable.concat(
|
||||||
|
history.createRecord(
|
||||||
|
commandType = OmnipodCommandType.SET_TEMPORARY_BASAL,
|
||||||
|
tempBasalRecord = TempBasalRecord(duration = durationInMinutes, rate = absoluteRate)
|
||||||
|
).flatMapObservable { recordId ->
|
||||||
|
podStateManager.createActiveCommand(recordId).toObservable()
|
||||||
|
},
|
||||||
omnipodManager.setTempBasal(
|
omnipodManager.setTempBasal(
|
||||||
absoluteRate,
|
absoluteRate,
|
||||||
durationInMinutes.toShort()
|
durationInMinutes.toShort()
|
||||||
|
),
|
||||||
|
history.updateFromState(podStateManager).toObservable(),
|
||||||
|
podStateManager.updateActiveCommand().toObservable(),
|
||||||
).subscribeBy(
|
).subscribeBy(
|
||||||
onNext = { podEvent ->
|
onNext = { podEvent ->
|
||||||
aapsLogger.debug(
|
aapsLogger.debug(
|
||||||
|
@ -298,11 +314,20 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult {
|
override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult {
|
||||||
// TODO history
|
|
||||||
// TODO update Treatments
|
// TODO update Treatments
|
||||||
|
|
||||||
return Single.create<PumpEnactResult> { source ->
|
return Single.create<PumpEnactResult> { source ->
|
||||||
omnipodManager.stopTempBasal().subscribeBy(
|
|
||||||
|
Observable.concat(
|
||||||
|
history.createRecord(
|
||||||
|
commandType = OmnipodCommandType.CANCEL_TEMPORARY_BASAL
|
||||||
|
).flatMapObservable { recordId ->
|
||||||
|
podStateManager.createActiveCommand(recordId).toObservable()
|
||||||
|
},
|
||||||
|
omnipodManager.stopTempBasal(),
|
||||||
|
history.updateFromState(podStateManager).toObservable(),
|
||||||
|
podStateManager.updateActiveCommand().toObservable(),
|
||||||
|
).subscribeBy(
|
||||||
onNext = { podEvent ->
|
onNext = { podEvent ->
|
||||||
aapsLogger.debug(
|
aapsLogger.debug(
|
||||||
LTag.PUMP,
|
LTag.PUMP,
|
||||||
|
|
|
@ -4,7 +4,7 @@ sealed class Record
|
||||||
|
|
||||||
data class BolusRecord(val amout: Double, val bolusType: BolusType) : Record()
|
data class BolusRecord(val amout: Double, val bolusType: BolusType) : Record()
|
||||||
|
|
||||||
data class TempBasalRecord(val duration: Long, val rate: Double) : Record()
|
data class TempBasalRecord(val duration: Int, val rate: Double) : Record()
|
||||||
|
|
||||||
enum class BolusType {
|
enum class BolusType {
|
||||||
DEFAULT, SMB
|
DEFAULT, SMB
|
||||||
|
|
Loading…
Reference in a new issue