bugfix for 0 TBR
This commit is contained in:
parent
d5619dc469
commit
0312eff327
|
@ -36,6 +36,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.data.BolusRe
|
||||||
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.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.Constants
|
||||||
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.Command
|
import info.nightscout.androidaps.queue.commands.Command
|
||||||
import info.nightscout.androidaps.queue.commands.CustomCommand
|
import info.nightscout.androidaps.queue.commands.CustomCommand
|
||||||
|
@ -127,8 +128,6 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
||||||
val tbr = expectedState.temporaryBasal
|
val tbr = expectedState.temporaryBasal
|
||||||
if (tbr == null || tbr.rate != 0.0) {
|
if (tbr == null || tbr.rate != 0.0) {
|
||||||
aapsLogger.info(LTag.PUMP, "createFakeTBRWhenNoActivePod")
|
aapsLogger.info(LTag.PUMP, "createFakeTBRWhenNoActivePod")
|
||||||
// calling connectNewPump() here because pumpSerial could have changed(from 4241 to "n/a")
|
|
||||||
pumpSync.connectNewPump()
|
|
||||||
pumpSync.syncTemporaryBasalWithPumpId(
|
pumpSync.syncTemporaryBasalWithPumpId(
|
||||||
timestamp = System.currentTimeMillis(),
|
timestamp = System.currentTimeMillis(),
|
||||||
rate = 0.0,
|
rate = 0.0,
|
||||||
|
@ -137,7 +136,9 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
||||||
type = PumpSync.TemporaryBasalType.PUMP_SUSPEND,
|
type = PumpSync.TemporaryBasalType.PUMP_SUSPEND,
|
||||||
pumpId = Random.Default.nextLong(), // we don't use this, just make sure it's unique
|
pumpId = Random.Default.nextLong(), // we don't use this, just make sure it's unique
|
||||||
pumpType = PumpType.OMNIPOD_DASH,
|
pumpType = PumpType.OMNIPOD_DASH,
|
||||||
pumpSerial = serialNumber()
|
pumpSerial = Constants.PUMP_SERIAL_FOR_FAKE_TBR // switching the serialNumber here would need a
|
||||||
|
// call to connectNewPump. If we do that, then we will have a TBR started by the "n/a" pump and
|
||||||
|
// cancelled by "4241". This did not work ok.
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.common.ui.wizard.activati
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.R
|
import info.nightscout.androidaps.plugins.pump.omnipod.dash.R
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.OmnipodDashManager
|
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.OmnipodDashManager
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.OmnipodDashPodStateManager
|
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.OmnipodDashPodStateManager
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.dash.util.Constants
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.util.I8n
|
import info.nightscout.androidaps.plugins.pump.omnipod.dash.util.I8n
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.util.mapProfileToBasalProgram
|
import info.nightscout.androidaps.plugins.pump.omnipod.dash.util.mapProfileToBasalProgram
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
@ -80,7 +81,17 @@ class DashInsertCannulaViewModel @Inject constructor(
|
||||||
onComplete = {
|
onComplete = {
|
||||||
logger.debug("Pod activation part 2 completed")
|
logger.debug("Pod activation part 2 completed")
|
||||||
podStateManager.basalProgram = basalProgram
|
podStateManager.basalProgram = basalProgram
|
||||||
|
|
||||||
|
pumpSync.syncStopTemporaryBasalWithPumpId(
|
||||||
|
timestamp = System.currentTimeMillis(),
|
||||||
|
endPumpId = System.currentTimeMillis(),
|
||||||
|
pumpType = PumpType.OMNIPOD_DASH,
|
||||||
|
pumpSerial = Constants.PUMP_SERIAL_FOR_FAKE_TBR // cancel the fake TBR with the same pump
|
||||||
|
// serial that it was created with
|
||||||
|
)
|
||||||
|
|
||||||
pumpSync.connectNewPump()
|
pumpSync.connectNewPump()
|
||||||
|
|
||||||
pumpSync.insertTherapyEventIfNewWithTimestamp(
|
pumpSync.insertTherapyEventIfNewWithTimestamp(
|
||||||
timestamp = System.currentTimeMillis(),
|
timestamp = System.currentTimeMillis(),
|
||||||
type = DetailedBolusInfo.EventType.CANNULA_CHANGE,
|
type = DetailedBolusInfo.EventType.CANNULA_CHANGE,
|
||||||
|
@ -93,12 +104,7 @@ class DashInsertCannulaViewModel @Inject constructor(
|
||||||
pumpType = PumpType.OMNIPOD_DASH,
|
pumpType = PumpType.OMNIPOD_DASH,
|
||||||
pumpSerial = podStateManager.uniqueId?.toString() ?: "n/a"
|
pumpSerial = podStateManager.uniqueId?.toString() ?: "n/a"
|
||||||
)
|
)
|
||||||
pumpSync.syncStopTemporaryBasalWithPumpId(
|
|
||||||
timestamp = System.currentTimeMillis(),
|
|
||||||
endPumpId = System.currentTimeMillis(),
|
|
||||||
pumpType = PumpType.OMNIPOD_DASH,
|
|
||||||
pumpSerial = podStateManager.uniqueId?.toString() ?: "n/a"
|
|
||||||
)
|
|
||||||
podStateManager.updateExpirationAlertSettings(expirationReminderEnabled, expirationHours)
|
podStateManager.updateExpirationAlertSettings(expirationReminderEnabled, expirationHours)
|
||||||
rxBus.send(EventDismissNotification(Notification.OMNIPOD_POD_NOT_ATTACHED))
|
rxBus.send(EventDismissNotification(Notification.OMNIPOD_POD_NOT_ATTACHED))
|
||||||
source.onSuccess(PumpEnactResult(injector).success(true))
|
source.onSuccess(PumpEnactResult(injector).success(true))
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.omnipod.dash.util
|
||||||
|
|
||||||
|
class Constants {
|
||||||
|
companion object {
|
||||||
|
val PUMP_SERIAL_FOR_FAKE_TBR = "4241"
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue