add check for onError whent the command was sent
This commit is contained in:
parent
b64d530ae9
commit
cddf7a3f68
|
@ -236,6 +236,12 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
): PumpEnactResult {
|
||||
// TODO update Treatments
|
||||
// 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(
|
||||
history.createRecord(
|
||||
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
|
||||
// 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
|
||||
podStateManager.resetActiveCommand()
|
||||
|
||||
podStateManager.markActiveCommandFailed()
|
||||
source.onSuccess(
|
||||
PumpEnactResult(injector).success(false).enacted(false).comment(throwable.message)
|
||||
)
|
||||
|
|
|
@ -68,7 +68,7 @@ interface OmnipodDashPodStateManager {
|
|||
|
||||
fun createActiveCommand(historyId: String): Completable
|
||||
fun updateActiveCommand(): Maybe<PodEvent>
|
||||
fun resetActiveCommand()
|
||||
fun markActiveCommandFailed()
|
||||
|
||||
data class ActiveCommand(
|
||||
val sequence: Short,
|
||||
|
|
|
@ -201,9 +201,14 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
|
|||
}
|
||||
|
||||
@Synchronized
|
||||
override fun resetActiveCommand() {
|
||||
override fun markActiveCommandFailed() {
|
||||
podState.activeCommand?.run {
|
||||
if (sentRealtime < createdRealtime) {
|
||||
// command was not sent
|
||||
podState.activeCommand = null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
override fun updateActiveCommand() = Maybe.create<PodEvent> { source ->
|
||||
|
@ -214,6 +219,7 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
|
|||
"$sequenceNumberOfLastProgrammingCommand $historyId"
|
||||
)
|
||||
if (createdRealtime >= lastStatusResponseReceived)
|
||||
// we did not receive a valid response yet
|
||||
source.onComplete()
|
||||
else {
|
||||
podState.activeCommand = null
|
||||
|
|
Loading…
Reference in a new issue