Minor fixes;

Allow set of fake TBR when 0 temp is already running,
Automatically force deactivation when patch is in error state
This commit is contained in:
jbr7rr 2023-07-01 12:28:01 +02:00
parent 93dee4eb3c
commit f52726128a
2 changed files with 9 additions and 2 deletions

View file

@ -443,7 +443,7 @@ class MedtrumPump @Inject constructor(
fun setFakeTBRIfNeeded() {
val expectedTemporaryBasal = pumpSync.expectedPumpState().temporaryBasal
if (expectedTemporaryBasal?.rate != 0.0 && expectedTemporaryBasal?.duration != T.mins(FAKE_TBR_LENGTH).msecs()) {
if (expectedTemporaryBasal?.duration != T.mins(FAKE_TBR_LENGTH).msecs()) {
setFakeTBR()
}
}

View file

@ -243,9 +243,16 @@ class MedtrumViewModel @Inject constructor(
if (this.result.success) {
// Do nothing, state change will handle this
} else {
if (medtrumPump.pumpState >= MedtrumPumpState.OCCLUSION && medtrumPump.pumpState <= MedtrumPumpState.NO_CALIBRATION) {
// We are in a fault state, we need to force deactivation
aapsLogger.info(LTag.PUMP, "deactivatePatch: force deactivation")
medtrumPump.pumpState = MedtrumPumpState.STOPPED
} else {
aapsLogger.info(LTag.PUMP, "deactivatePatch: failure!")
updateSetupStep(SetupStep.ERROR)
}
}
}
})
}