add check for onError whent the command was sent
This commit is contained in:
parent
b64d530ae9
commit
cddf7a3f68
3 changed files with 17 additions and 4 deletions
|
@ -236,6 +236,12 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
||||||
): PumpEnactResult {
|
): PumpEnactResult {
|
||||||
// TODO update Treatments
|
// TODO update Treatments
|
||||||
// TODO check for existing basal
|
// TODO check for existing basal
|
||||||
|
// check existing basal(locally and maybe? get status)
|
||||||
|
// if enforceNew -> cancel it()
|
||||||
|
// else -> return error that existing basal is running
|
||||||
|
// set new temp basal
|
||||||
|
// update treatments
|
||||||
|
// profit
|
||||||
return executeProgrammingCommand(
|
return executeProgrammingCommand(
|
||||||
history.createRecord(
|
history.createRecord(
|
||||||
commandType = OmnipodCommandType.SET_TEMPORARY_BASAL,
|
commandType = OmnipodCommandType.SET_TEMPORARY_BASAL,
|
||||||
|
@ -468,7 +474,8 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
||||||
// Here we assume that onError will be called only BEFORE we manage to send a command
|
// Here we assume that onError will be called only BEFORE we manage to send a command
|
||||||
// If it gets called later, we will have the command as "not sent" in history and will not try to
|
// If it gets called later, we will have the command as "not sent" in history and will not try to
|
||||||
// get it's final status, even if it was send
|
// get it's final status, even if it was send
|
||||||
podStateManager.resetActiveCommand()
|
|
||||||
|
podStateManager.markActiveCommandFailed()
|
||||||
source.onSuccess(
|
source.onSuccess(
|
||||||
PumpEnactResult(injector).success(false).enacted(false).comment(throwable.message)
|
PumpEnactResult(injector).success(false).enacted(false).comment(throwable.message)
|
||||||
)
|
)
|
||||||
|
|
|
@ -68,7 +68,7 @@ interface OmnipodDashPodStateManager {
|
||||||
|
|
||||||
fun createActiveCommand(historyId: String): Completable
|
fun createActiveCommand(historyId: String): Completable
|
||||||
fun updateActiveCommand(): Maybe<PodEvent>
|
fun updateActiveCommand(): Maybe<PodEvent>
|
||||||
fun resetActiveCommand()
|
fun markActiveCommandFailed()
|
||||||
|
|
||||||
data class ActiveCommand(
|
data class ActiveCommand(
|
||||||
val sequence: Short,
|
val sequence: Short,
|
||||||
|
|
|
@ -201,9 +201,14 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
override fun resetActiveCommand() {
|
override fun markActiveCommandFailed() {
|
||||||
|
podState.activeCommand?.run {
|
||||||
|
if (sentRealtime < createdRealtime) {
|
||||||
|
// command was not sent
|
||||||
podState.activeCommand = null
|
podState.activeCommand = null
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
override fun updateActiveCommand() = Maybe.create<PodEvent> { source ->
|
override fun updateActiveCommand() = Maybe.create<PodEvent> { source ->
|
||||||
|
@ -214,6 +219,7 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
|
||||||
"$sequenceNumberOfLastProgrammingCommand $historyId"
|
"$sequenceNumberOfLastProgrammingCommand $historyId"
|
||||||
)
|
)
|
||||||
if (createdRealtime >= lastStatusResponseReceived)
|
if (createdRealtime >= lastStatusResponseReceived)
|
||||||
|
// we did not receive a valid response yet
|
||||||
source.onComplete()
|
source.onComplete()
|
||||||
else {
|
else {
|
||||||
podState.activeCommand = null
|
podState.activeCommand = null
|
||||||
|
|
Loading…
Reference in a new issue