- finished implementation of TBR and Bolus, needs more testing

- missing 35 minutes
This commit is contained in:
Andy Rozman 2021-05-06 20:30:18 +01:00
parent 9526e8228b
commit f285b59b44
7 changed files with 138 additions and 81 deletions

View file

@ -10,7 +10,8 @@ data class PumpDbEntry constructor(var temporaryId: Long,
var pumpType: PumpType, var pumpType: PumpType,
var serialNumber: String, var serialNumber: String,
var bolusData: PumpDbEntryBolus? = null, var bolusData: PumpDbEntryBolus? = null,
var tbrData: PumpDbEntryTBR? = null ) { var tbrData: PumpDbEntryTBR? = null,
var pumpId: Long? = null) {
constructor(temporaryId: Long, constructor(temporaryId: Long,
date: Long, date: Long,

View file

@ -78,7 +78,7 @@ abstract class PumpPluginAbstract protected constructor(
get() = field get() = field
set(value) { set(value) {
field = value field = value
pumpDescription.setPumpDescription(value) pumpDescription.fillFor(value)
} }
@ -90,19 +90,19 @@ abstract class PumpPluginAbstract protected constructor(
super.onStart() super.onStart()
initPumpStatusData() initPumpStatusData()
val intent = Intent(context, serviceClass) val intent = Intent(context, serviceClass)
context.bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE) context.bindService(intent, serviceConnection!!, Context.BIND_AUTO_CREATE)
serviceRunning = true serviceRunning = true
disposable.add(rxBus disposable.add(rxBus
.toObservable(EventAppExit::class.java) .toObservable(EventAppExit::class.java)
.observeOn(aapsSchedulers.io) .observeOn(aapsSchedulers.io)
.subscribe({ event: EventAppExit? -> context.unbindService(serviceConnection) }) { throwable: Throwable? -> fabricPrivacy.logException(throwable!!) } .subscribe({ event: EventAppExit? -> context.unbindService(serviceConnection!!) }) { throwable: Throwable? -> fabricPrivacy.logException(throwable!!) }
) )
onStartCustomActions() onStartCustomActions()
} }
override fun onStop() { override fun onStop() {
aapsLogger.debug(LTag.PUMP, deviceID() + " onStop()") aapsLogger.debug(LTag.PUMP, deviceID() + " onStop()")
context.unbindService(serviceConnection) context.unbindService(serviceConnection!!)
serviceRunning = false serviceRunning = false
disposable.clear() disposable.clear()
super.onStop() super.onStop()
@ -250,7 +250,7 @@ abstract class PumpPluginAbstract protected constructor(
val extended = JSONObject() val extended = JSONObject()
try { try {
battery.put("percent", pumpStatusData.batteryRemaining) battery.put("percent", pumpStatusData.batteryRemaining)
status.put("status", if (pumpStatusData.pumpStatusType != null) pumpStatusData.pumpStatusType.status else "normal") status.put("status", pumpStatusData.pumpStatusType.status)
extended.put("Version", version) extended.put("Version", version)
try { try {
extended.put("ActiveProfile", profileName) extended.put("ActiveProfile", profileName)
@ -386,12 +386,8 @@ abstract class PumpPluginAbstract protected constructor(
} }
init { init {
pumpDescription.setPumpDescription(pumpType) pumpDescription.fillFor(pumpType)
this.pumpType = pumpType this.pumpType = pumpType
this.dateUtil = dateUtil
this.aapsSchedulers = aapsSchedulers
//this.pumpSync = pumpSync
} }
} }

View file

@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.pump.common.data
import info.nightscout.androidaps.plugins.pump.common.defs.PumpStatusType import info.nightscout.androidaps.plugins.pump.common.defs.PumpStatusType
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
import info.nightscout.androidaps.plugins.pump.common.sync.PumpDbEntry
import java.util.* import java.util.*
/** /**

View file

@ -48,6 +48,7 @@ import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.BasalProfile
import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.BasalProfile.Companion.getProfilesByHourToString import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.BasalProfile.Companion.getProfilesByHourToString
import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.BasalProfileEntry import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.BasalProfileEntry
import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.TempBasalPair import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.TempBasalPair
import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.TempBasalProcessDTO
import info.nightscout.androidaps.plugins.pump.medtronic.defs.* import info.nightscout.androidaps.plugins.pump.medtronic.defs.*
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicCommandType.Companion.getSettings import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicCommandType.Companion.getSettings
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus
@ -1011,9 +1012,36 @@ class MedtronicPumpPlugin @Inject constructor(
// activePlugin.activeTreatments.addToHistoryTempBasal(tempBasal) // activePlugin.activeTreatments.addToHistoryTempBasal(tempBasal)
// TODO need to find solution for this !? // TODO need to find solution for this !?
val tempData = PumpDbEntryTBR(0.0, true, 0, TemporaryBasalType.NORMAL) //val tempData = PumpDbEntryTBR(0.0, true, 0, TemporaryBasalType.NORMAL)
pumpSyncStorage.addTemporaryBasalRateWithTempId(tempData, true, this) val runningTBR = medtronicPumpStatus.runningTBR
if (runningTBR!=null) {
if (medtronicHistoryData.isTBRActive(runningTBR)) {
val differenceTime = System.currentTimeMillis() - runningTBR.date
val tbrData = runningTBR.tbrData!!
val result = pumpSync.syncTemporaryBasalWithPumpId(
runningTBR.date,
tbrData.rate,
differenceTime,
tbrData.isAbsolute,
tbrData.tbrType,
runningTBR.pumpId!!,
runningTBR.pumpType,
runningTBR.serialNumber)
val differenceTimeMin = Math.floor(differenceTime/(60.0*1000.0))
aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "canceling running TBR - syncTemporaryBasalWithPumpId [date=%d, pumpId=%d, rate=%.2f U, duration=%d, pumpSerial=%s] - Result: %b",
runningTBR.date, runningTBR.pumpId!!,
tbrData.rate, differenceTimeMin.toInt(),
medtronicPumpStatus.serialNumber!!, result))
}
}
//pumpSyncStorage.addTemporaryBasalRateWithTempId(tempData, true, this)
PumpEnactResult(injector).success(true).enacted(true) // PumpEnactResult(injector).success(true).enacted(true) //
.isTempCancel(true) .isTempCancel(true)

View file

@ -72,7 +72,7 @@ class PumpHistoryEntry : MedtronicHistoryEntry() {
override fun equals(other: Any?): Boolean { override fun equals(other: Any?): Boolean {
if (this === other) return true if (this === other) return true
if (other !is PumpHistoryEntry) return false if (other !is PumpHistoryEntry) return false
val that = other as PumpHistoryEntry val that = other //as PumpHistoryEntry
return this.pumpId === that.pumpId return this.pumpId === that.pumpId
// return entryType == that.entryType && // // return entryType == that.entryType && //
// atechDateTime === that.atechDateTime // && // // atechDateTime === that.atechDateTime // && //

View file

@ -62,6 +62,7 @@ class MedtronicHistoryData @Inject constructor(
) { ) {
val allHistory: MutableList<PumpHistoryEntry> = mutableListOf() val allHistory: MutableList<PumpHistoryEntry> = mutableListOf()
private var allPumpIds: MutableSet<Long> = mutableSetOf()
private var newHistory: MutableList<PumpHistoryEntry> = mutableListOf() private var newHistory: MutableList<PumpHistoryEntry> = mutableListOf()
private var isInit = false private var isInit = false
@ -80,7 +81,7 @@ class MedtronicHistoryData @Inject constructor(
val validEntries: List<PumpHistoryEntry> = result.validEntries val validEntries: List<PumpHistoryEntry> = result.validEntries
val newEntries: MutableList<PumpHistoryEntry> = mutableListOf() val newEntries: MutableList<PumpHistoryEntry> = mutableListOf()
for (validEntry in validEntries) { for (validEntry in validEntries) {
if (!allHistory.contains(validEntry)) { if (!allPumpIds.contains(validEntry.pumpId)) {
newEntries.add(validEntry) newEntries.add(validEntry)
} else { } else {
val entryByPumpId = getEntryByPumpId(validEntry.pumpId!!) val entryByPumpId = getEntryByPumpId(validEntry.pumpId!!)
@ -137,7 +138,7 @@ class MedtronicHistoryData @Inject constructor(
//aapsLogger.debug(LTag.PUMP, "Filter new entries: Before {}", newHistory); //aapsLogger.debug(LTag.PUMP, "Filter new entries: Before {}", newHistory);
if (!isCollectionEmpty(newHistory)) { if (!isCollectionEmpty(newHistory)) {
for (pumpHistoryEntry in newHistory) { for (pumpHistoryEntry in newHistory) {
if (!allHistory.contains(pumpHistoryEntry)) { if (!allPumpIds.contains(pumpHistoryEntry.pumpId)) {
val type = pumpHistoryEntry.entryType val type = pumpHistoryEntry.entryType
if (type === PumpHistoryEntryType.TempBasalRate || type === PumpHistoryEntryType.TempBasalDuration) { if (type === PumpHistoryEntryType.TempBasalRate || type === PumpHistoryEntryType.TempBasalDuration) {
tbrs.add(pumpHistoryEntry) tbrs.add(pumpHistoryEntry)
@ -160,7 +161,16 @@ class MedtronicHistoryData @Inject constructor(
extendBolusRecords(bolusEstimates, newHistory2) extendBolusRecords(bolusEstimates, newHistory2)
} }
newHistory2.addAll(tbrs) newHistory2.addAll(tbrs)
newHistory = newHistory2
val newHistory3: MutableList<PumpHistoryEntry> = mutableListOf()
for (pumpHistoryEntry in newHistory2) {
if (!allPumpIds.contains(pumpHistoryEntry.pumpId)) {
newHistory3.add(pumpHistoryEntry)
}
}
newHistory = newHistory3
sort(newHistory) sort(newHistory)
} }
aapsLogger.debug(LTag.PUMP, "New History entries found: " + newHistory.size) aapsLogger.debug(LTag.PUMP, "New History entries found: " + newHistory.size)
@ -192,10 +202,11 @@ class MedtronicHistoryData @Inject constructor(
// add new entries // add new entries
newHistory.reverse() newHistory.reverse()
for (pumpHistoryEntry in newHistory) { for (pumpHistoryEntry in newHistory) {
if (!allHistory.contains(pumpHistoryEntry)) { if (!allPumpIds.contains(pumpHistoryEntry.pumpId)) {
lastIdUsed++ lastIdUsed++
pumpHistoryEntry.id = lastIdUsed pumpHistoryEntry.id = lastIdUsed
allHistory.add(pumpHistoryEntry) allHistory.add(pumpHistoryEntry)
allPumpIds.add(pumpHistoryEntry.pumpId!!)
} }
} }
// if (pheLast == null) // if we don't have any valid record we don't do the filtering and setting // if (pheLast == null) // if we don't have any valid record we don't do the filtering and setting
@ -215,6 +226,7 @@ class MedtronicHistoryData @Inject constructor(
for (pumpHistoryEntry in allHistory) { for (pumpHistoryEntry in allHistory) {
if (!pumpHistoryEntry.isAfter(dtRemove)) { if (!pumpHistoryEntry.isAfter(dtRemove)) {
removeList.add(pumpHistoryEntry) removeList.add(pumpHistoryEntry)
allPumpIds.remove(pumpHistoryEntry.pumpId!!)
} }
} }
allHistory.removeAll(removeList) allHistory.removeAll(removeList)
@ -262,33 +274,34 @@ class MedtronicHistoryData @Inject constructor(
} else false } else false
} }
private fun getDataForPumpSuspends(): MutableList<PumpHistoryEntry> { private fun getDataForPumpSuspends(): MutableList<PumpHistoryEntry> {
val newAndAll: MutableList<PumpHistoryEntry> = mutableListOf() val newAndAll: MutableList<PumpHistoryEntry> = mutableListOf()
if (isCollectionNotEmpty(allHistory)) { if (isCollectionNotEmpty(allHistory)) {
newAndAll.addAll(allHistory) newAndAll.addAll(allHistory)
} }
if (isCollectionNotEmpty(newHistory)) { if (isCollectionNotEmpty(newHistory)) {
for (pumpHistoryEntry in newHistory) { for (pumpHistoryEntry in newHistory) {
if (!newAndAll.contains(pumpHistoryEntry)) { if (!newAndAll.contains(pumpHistoryEntry)) {
newAndAll.add(pumpHistoryEntry) newAndAll.add(pumpHistoryEntry)
}
} }
} }
if (newAndAll.isEmpty()) return newAndAll
this.sort(newAndAll)
var newAndAll2: MutableList<PumpHistoryEntry> = getFilteredItems(newAndAll, //
setOf(PumpHistoryEntryType.Bolus, //
PumpHistoryEntryType.TempBasalCombined, //
PumpHistoryEntryType.Prime, //
PumpHistoryEntryType.SuspendPump, //
PumpHistoryEntryType.ResumePump, //
PumpHistoryEntryType.Rewind, //
PumpHistoryEntryType.NoDeliveryAlarm, //
PumpHistoryEntryType.BatteryChange, //
PumpHistoryEntryType.BasalProfileStart))
newAndAll2 = filterPumpSuspend(newAndAll2, 10)
return newAndAll2
} }
if (newAndAll.isEmpty()) return newAndAll
this.sort(newAndAll)
var newAndAll2: MutableList<PumpHistoryEntry> = getFilteredItems(newAndAll, //
setOf(PumpHistoryEntryType.Bolus, //
PumpHistoryEntryType.TempBasalCombined, //
PumpHistoryEntryType.Prime, //
PumpHistoryEntryType.SuspendPump, //
PumpHistoryEntryType.ResumePump, //
PumpHistoryEntryType.Rewind, //
PumpHistoryEntryType.NoDeliveryAlarm, //
PumpHistoryEntryType.BatteryChange, //
PumpHistoryEntryType.BasalProfileStart))
newAndAll2 = filterPumpSuspend(newAndAll2, 10)
return newAndAll2
}
private fun filterPumpSuspend(newAndAll: MutableList<PumpHistoryEntry>, filterCount: Int): MutableList<PumpHistoryEntry> { private fun filterPumpSuspend(newAndAll: MutableList<PumpHistoryEntry>, filterCount: Int): MutableList<PumpHistoryEntry> {
if (newAndAll.size <= filterCount) { if (newAndAll.size <= filterCount) {
@ -389,7 +402,8 @@ class MedtronicHistoryData @Inject constructor(
private fun processPrime(primeRecords: List<PumpHistoryEntry?>) { private fun processPrime(primeRecords: List<PumpHistoryEntry?>) {
val maxAllowedTimeInPast = DateTimeUtil.getATDWithAddedMinutes(GregorianCalendar(), -30) val maxAllowedTimeInPast = DateTimeUtil.getATDWithAddedMinutes(GregorianCalendar(), -30)
var lastPrimeRecord = 0L var lastPrimeRecordTime = 0L
var lastPrimeRecord: PumpHistoryEntry? = null
for (primeRecord in primeRecords) { for (primeRecord in primeRecords) {
val fixedAmount = primeRecord!!.getDecodedDataEntry("FixedAmount") val fixedAmount = primeRecord!!.getDecodedDataEntry("FixedAmount")
if (fixedAmount != null && fixedAmount as Float == 0.0f) { if (fixedAmount != null && fixedAmount as Float == 0.0f) {
@ -399,44 +413,58 @@ class MedtronicHistoryData @Inject constructor(
continue continue
} }
if (primeRecord.atechDateTime!! > maxAllowedTimeInPast) { if (primeRecord.atechDateTime!! > maxAllowedTimeInPast) {
if (lastPrimeRecord < primeRecord.atechDateTime!!) { if (lastPrimeRecordTime < primeRecord.atechDateTime!!) {
lastPrimeRecord = primeRecord.atechDateTime!! lastPrimeRecordTime = primeRecord.atechDateTime!!
lastPrimeRecord = primeRecord
} }
} }
} }
if (lastPrimeRecord != 0L) { if (lastPrimeRecord != null) {
val lastPrimeFromAAPS = sp.getLong(MedtronicConst.Statistics.LastPrime, 0L) uploadCareportalEventIfFoundInHistory(lastPrimeRecord,
if (lastPrimeRecord != lastPrimeFromAAPS) { MedtronicConst.Statistics.LastPrime,
uploadCareportalEvent(DateTimeUtil.toMillisFromATD(lastPrimeRecord), DetailedBolusInfo.EventType.CANNULA_CHANGE) DetailedBolusInfo.EventType.CANNULA_CHANGE)
sp.putLong(MedtronicConst.Statistics.LastPrime, lastPrimeRecord)
}
} }
} }
private fun processRewind(rewindRecords: List<PumpHistoryEntry?>) { private fun processRewind(rewindRecords: List<PumpHistoryEntry?>) {
val maxAllowedTimeInPast = DateTimeUtil.getATDWithAddedMinutes(GregorianCalendar(), -30) val maxAllowedTimeInPast = DateTimeUtil.getATDWithAddedMinutes(GregorianCalendar(), -30)
var lastRewindRecord = 0L var lastRewindRecordTime = 0L
var lastRewindRecord: PumpHistoryEntry? = null
for (rewindRecord in rewindRecords) { for (rewindRecord in rewindRecords) {
if (rewindRecord!!.atechDateTime!! > maxAllowedTimeInPast) { if (rewindRecord!!.atechDateTime!! > maxAllowedTimeInPast) {
if (lastRewindRecord < rewindRecord.atechDateTime!!) { if (lastRewindRecordTime < rewindRecord.atechDateTime!!) {
lastRewindRecord = rewindRecord.atechDateTime!! lastRewindRecordTime = rewindRecord.atechDateTime!!
lastRewindRecord = rewindRecord
} }
} }
} }
if (lastRewindRecord != 0L) { if (lastRewindRecord != null) {
val lastRewindFromAAPS = sp.getLong(MedtronicConst.Statistics.LastRewind, 0L) uploadCareportalEventIfFoundInHistory(lastRewindRecord,
if (lastRewindRecord != lastRewindFromAAPS) { MedtronicConst.Statistics.LastRewind,
uploadCareportalEvent(DateTimeUtil.toMillisFromATD(lastRewindRecord), DetailedBolusInfo.EventType.INSULIN_CHANGE) DetailedBolusInfo.EventType.INSULIN_CHANGE)
sp.putLong(MedtronicConst.Statistics.LastRewind, lastRewindRecord)
}
} }
} }
private fun uploadCareportalEvent(date: Long, event: DetailedBolusInfo.EventType) {
pumpSync.insertTherapyEventIfNewWithTimestamp(date, event, null, null, private fun uploadCareportalEventIfFoundInHistory(historyRecord: PumpHistoryEntry, eventSP: String, eventType: DetailedBolusInfo.EventType) {
medtronicPumpStatus.pumpType, medtronicPumpStatus.serialNumber!!) val lastPrimeFromAAPS = sp.getLong(eventSP, 0L)
if (historyRecord.atechDateTime != lastPrimeFromAAPS) {
var result = pumpSync.insertTherapyEventIfNewWithTimestamp(
DateTimeUtil.toMillisFromATD(historyRecord.atechDateTime!!),
eventType, null,
historyRecord.pumpId,
medtronicPumpStatus.pumpType,
medtronicPumpStatus.serialNumber!!)
aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "insertTherapyEventIfNewWithTimestamp [date=%d, eventType=%d, pumpId=%d, pumpSerial=%s] - Result: %b",
historyRecord.atechDateTime!!, eventType, historyRecord.pumpId,
medtronicPumpStatus.serialNumber!!, result))
sp.putLong(eventSP, historyRecord.atechDateTime!!)
}
} }
private fun processTDDs(tddsIn: MutableList<PumpHistoryEntry>) { private fun processTDDs(tddsIn: MutableList<PumpHistoryEntry>) {
val tdds = filterTDDs(tddsIn) val tdds = filterTDDs(tddsIn)
@ -616,7 +644,7 @@ class MedtronicHistoryData @Inject constructor(
val tbrEntry = tempBasalProcessDTO.itemOne!!.getDecodedDataEntry("Object") as TempBasalPair val tbrEntry = tempBasalProcessDTO.itemOne!!.getDecodedDataEntry("Object") as TempBasalPair
removeCancelTBRTemporaryRecord(tempBasalProcessDTO, tbrRecords) // TODO //removeCancelTBRTemporaryRecord(tempBasalProcessDTO, tbrRecords)
if (entryWithTempId!=null) { if (entryWithTempId!=null) {
val result = pumpSync.syncTemporaryBasalWithTempId( val result = pumpSync.syncTemporaryBasalWithTempId(
@ -636,6 +664,14 @@ class MedtronicHistoryData @Inject constructor(
medtronicPumpStatus.serialNumber!!, result)) medtronicPumpStatus.serialNumber!!, result))
pumpSyncStorage.removeTemporaryBasalWithTemporaryId(entryWithTempId.temporaryId) pumpSyncStorage.removeTemporaryBasalWithTemporaryId(entryWithTempId.temporaryId)
tbrRecords.remove(entryWithTempId)
entryWithTempId.pumpId = tempBasalProcessDTO.pumpId
entryWithTempId.date = tryToGetByLocalTime(tempBasalProcessDTO.atechDateTime)
if (isTBRActive(entryWithTempId)) {
medtronicPumpStatus.runningTBR = entryWithTempId
}
} else { } else {
val result = pumpSync.syncTemporaryBasalWithPumpId( val result = pumpSync.syncTemporaryBasalWithPumpId(
@ -659,24 +695,29 @@ class MedtronicHistoryData @Inject constructor(
private fun removeCancelTBRTemporaryRecord(tempBasalProcessDTO: TempBasalProcessDTO, tbrRecords: MutableList<PumpDbEntry>) { private fun removeCancelTBRTemporaryRecord(tempBasalProcessDTO: TempBasalProcessDTO, tbrRecords: MutableList<PumpDbEntry>) {
//fun syncTemporaryBasalWithPumpId(timestamp: Long, rate: Double, duration: Long, isAbsolute: Boolean, type: PumpSync.TemporaryBasalType?, pumpId: Long, pumpType: PumpType, pumpSerial: String): Boolean
if (tempBasalProcessDTO.cancelPresent) { if (tempBasalProcessDTO.cancelPresent) {
//val dateTime : Long = DateTimeUtil.getMillisFromATDWithAddedMinutes(tempBasalProcessDTO.atechDateTime, tempBasalProcessDTO.duration) //val dateTime : Long = DateTimeUtil.getMillisFromATDWithAddedMinutes(tempBasalProcessDTO.atechDateTime, tempBasalProcessDTO.duration)
val dbEntry = findDbEntry(tempBasalProcessDTO.itemTwo!!, tbrRecords) val dbEntry = findDbEntry(tempBasalProcessDTO.itemTwo!!, tbrRecords)
if (dbEntry!=null) { if (dbEntry!=null) {
if (dbEntry.tbrData!!.durationInMinutes == 0) { if (dbEntry.tbrData!!.durationInMinutes == 0) {
pumpSync.invalidateTemporaryBasal(dbEntry.temporaryId) // TODO fix pumpSync.invalidateTemporaryBasalWithTempId(dbEntry.temporaryId)
pumpSyncStorage.removeTemporaryBasalWithTemporaryId(dbEntry.temporaryId)
tbrRecords.remove(dbEntry)
} }
} }
//
} }
} }
fun isTBRActive(dbEntry: PumpDbEntry) : Boolean {
val endDate = dbEntry.date + (dbEntry.tbrData!!.durationInMinutes * 60 * 1000)
return (endDate > System.currentTimeMillis())
}
// private fun processTBREntries_Old(entryList: MutableList<PumpHistoryEntry>) { // private fun processTBREntries_Old(entryList: MutableList<PumpHistoryEntry>) {
// Collections.reverse(entryList) // Collections.reverse(entryList)
// val tbr = entryList[0].getDecodedDataEntry("Object") as TempBasalPair? // val tbr = entryList[0].getDecodedDataEntry("Object") as TempBasalPair?
@ -777,8 +818,8 @@ class MedtronicHistoryData @Inject constructor(
*/ */
private fun findDbEntry_Old(treatment: PumpHistoryEntry?, entriesFromHistory: List<DbObjectBase>): DbObjectBase? { private fun findDbEntry_Old(treatment: PumpHistoryEntry?, entriesFromHistory: List<DbObjectBase>): DbObjectBase? {
val proposedTime = DateTimeUtil.toMillisFromATD(treatment!!.atechDateTime!!) val proposedTime = DateTimeUtil.toMillisFromATD(treatment!!.atechDateTime!!)
//proposedTime += (this.pumpTime.timeDifference * 1000); //proposedTime += (this.pumpTime.timeDifference * 1000);
if (doubleBolusDebug) aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "DoubleBolusDebug: findDbEntry Treatment=%s, FromDb=%s", treatment, gson.toJson(entriesFromHistory))) if (doubleBolusDebug) aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "DoubleBolusDebug: findDbEntry Treatment=%s, FromDb=%s", treatment, gson.toJson(entriesFromHistory)))
if (entriesFromHistory.size == 0) { if (entriesFromHistory.size == 0) {
if (doubleBolusDebug) aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "DoubleBolusDebug: findDbEntry Treatment=%s, FromDb=null", treatment)) if (doubleBolusDebug) aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "DoubleBolusDebug: findDbEntry Treatment=%s, FromDb=null", treatment))
@ -1268,16 +1309,4 @@ class MedtronicHistoryData @Inject constructor(
const val doubleBolusDebug = false const val doubleBolusDebug = false
} }
init {
//allHistory = ArrayList()
//this.injector = injector
//this.aapsLogger = aapsLogger
// this.sp = sp
// this.activePlugin = activePlugin
// this.medtronicUtil = medtronicUtil
// this.medtronicPumpHistoryDecoder = medtronicPumpHistoryDecoder
// this.medtronicPumpStatus = medtronicPumpStatus
// databaseHelper = databaseHelperInterface
//this.pumpSync = pumpSync
}
} }

View file

@ -8,6 +8,7 @@ import info.nightscout.androidaps.plugins.pump.common.events.EventRileyLinkDevic
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistoryItem import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistoryItem
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice
import info.nightscout.androidaps.plugins.pump.common.sync.PumpDbEntry
import info.nightscout.androidaps.plugins.pump.medtronic.defs.BasalProfileStatus import info.nightscout.androidaps.plugins.pump.medtronic.defs.BasalProfileStatus
import info.nightscout.androidaps.plugins.pump.medtronic.defs.BatteryType import info.nightscout.androidaps.plugins.pump.medtronic.defs.BatteryType
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceType import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceType
@ -33,6 +34,7 @@ class MedtronicPumpStatus @Inject constructor(private val resourceHelper: Resour
var pumpFrequency: String? = null var pumpFrequency: String? = null
var maxBolus: Double? = null var maxBolus: Double? = null
var maxBasal: Double? = null var maxBasal: Double? = null
var runningTBR: PumpDbEntry? = null
// statuses // statuses
var pumpDeviceState = PumpDeviceState.NeverContacted var pumpDeviceState = PumpDeviceState.NeverContacted