recover unconfirmed basal

This commit is contained in:
Andrei Vereha 2021-06-05 14:52:58 +02:00
parent 7c20bfb7f0
commit 70eb5e6d0c
2 changed files with 10 additions and 2 deletions

View file

@ -3,9 +3,11 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.DetailedBolusInfo import info.nightscout.androidaps.data.DetailedBolusInfo
import info.nightscout.androidaps.data.PumpEnactResult import info.nightscout.androidaps.data.PumpEnactResult
import info.nightscout.androidaps.events.EventProfileSwitchChanged
import info.nightscout.androidaps.interfaces.* import info.nightscout.androidaps.interfaces.*
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.common.ManufacturerType import info.nightscout.androidaps.plugins.common.ManufacturerType
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction
import info.nightscout.androidaps.plugins.general.actions.defs.CustomActionType import info.nightscout.androidaps.plugins.general.actions.defs.CustomActionType
@ -28,6 +30,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.data.BolusTy
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.mapProfileToBasalProgram import info.nightscout.androidaps.plugins.pump.omnipod.dash.util.mapProfileToBasalProgram
import info.nightscout.androidaps.queue.commands.Command
import info.nightscout.androidaps.queue.commands.CustomCommand import info.nightscout.androidaps.queue.commands.CustomCommand
import info.nightscout.androidaps.utils.T import info.nightscout.androidaps.utils.T
import info.nightscout.androidaps.utils.TimeChangeType import info.nightscout.androidaps.utils.TimeChangeType
@ -51,6 +54,8 @@ class OmnipodDashPumpPlugin @Inject constructor(
private val profileFunction: ProfileFunction, private val profileFunction: ProfileFunction,
private val history: DashHistory, private val history: DashHistory,
private val pumpSync: PumpSync, private val pumpSync: PumpSync,
private val rxBus: RxBusWrapper,
injector: HasAndroidInjector, injector: HasAndroidInjector,
aapsLogger: AAPSLogger, aapsLogger: AAPSLogger,
resourceHelper: ResourceHelper, resourceHelper: ResourceHelper,
@ -672,6 +677,10 @@ class OmnipodDashPumpPlugin @Inject constructor(
if (podStateManager.basalProgram == null) { if (podStateManager.basalProgram == null) {
aapsLogger.warn(LTag.PUMP, "Saving null basal profile") aapsLogger.warn(LTag.PUMP, "Saving null basal profile")
} }
if (!commandQueue.isRunning(Command.CommandType.BASAL_PROFILE)) {
// we are late-confirming this command. before that, we answered with success:false
rxBus.send(EventProfileSwitchChanged())
}
pumpSync.syncStopTemporaryBasalWithPumpId( pumpSync.syncStopTemporaryBasalWithPumpId(
historyEntry.createdAt, historyEntry.createdAt,
historyEntry.pumpId(), historyEntry.pumpId(),

View file

@ -24,8 +24,7 @@ class BasalProgram(
val minuteOfHour = instance[Calendar.MINUTE] val minuteOfHour = instance[Calendar.MINUTE]
val slotIndex = hourOfDay * 2 + minuteOfHour.div(30) val slotIndex = hourOfDay * 2 + minuteOfHour.div(30)
val slot = segments.find { it.startSlotIndex <= slotIndex && slotIndex< it.endSlotIndex } val slot = segments.find { it.startSlotIndex <= slotIndex && slotIndex< it.endSlotIndex }
val ret = (slot?.basalRateInHundredthUnitsPerHour ?: 0).toDouble() / 100 return (slot?.basalRateInHundredthUnitsPerHour ?: 0).toDouble() / 100
return ret
} }
class Segment( class Segment(