- fix of the problem encountered by Ghosa Sardes

This commit is contained in:
Andy Rozman 2021-05-31 13:41:31 +01:00
parent 5867ff8b93
commit a95fabee68
2 changed files with 20 additions and 7 deletions

View file

@ -600,7 +600,9 @@ class MedtronicHistoryData @Inject constructor(
} }
processDTO = TempBasalProcessDTO( processDTO = TempBasalProcessDTO(
itemOne = treatment, itemOne = treatment,
processOperation = TempBasalProcessDTO.Operation.Add) processOperation = TempBasalProcessDTO.Operation.Add,
aapsLogger = aapsLogger
)
} }
} }
if (processDTO != null) { if (processDTO != null) {
@ -841,7 +843,8 @@ class MedtronicHistoryData @Inject constructor(
outList.add(TempBasalProcessDTO( outList.add(TempBasalProcessDTO(
itemOne = filtered2Items[i], itemOne = filtered2Items[i],
itemTwo = filtered2Items[i + 1], itemTwo = filtered2Items[i + 1],
processOperation = TempBasalProcessDTO.Operation.Add)) processOperation = TempBasalProcessDTO.Operation.Add,
aapsLogger = aapsLogger))
i += 2 i += 2
} }
@ -906,14 +909,16 @@ class MedtronicHistoryData @Inject constructor(
outList.add(TempBasalProcessDTO( outList.add(TempBasalProcessDTO(
itemOne = items[items.size - 1], itemOne = items[items.size - 1],
itemTwo = itemTwo, itemTwo = itemTwo,
processOperation = TempBasalProcessDTO.Operation.Add)) processOperation = TempBasalProcessDTO.Operation.Add,
aapsLogger = aapsLogger))
return outList return outList
} }
items = getFilteredItems(tempData, PumpHistoryEntryType.Rewind) items = getFilteredItems(tempData, PumpHistoryEntryType.Rewind)
if (items.size > 0) { if (items.size > 0) {
outList.add(TempBasalProcessDTO( outList.add(TempBasalProcessDTO(
itemOne = items[0], itemOne = items[0],
processOperation = TempBasalProcessDTO.Operation.Add)) processOperation = TempBasalProcessDTO.Operation.Add,
aapsLogger = aapsLogger))
return outList return outList
} }
return outList return outList

View file

@ -1,11 +1,14 @@
package info.nightscout.androidaps.plugins.pump.medtronic.data.dto package info.nightscout.androidaps.plugins.pump.medtronic.data.dto
import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.PumpHistoryEntry import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.PumpHistoryEntry
class TempBasalProcessDTO constructor(var itemOne: PumpHistoryEntry, class TempBasalProcessDTO constructor(var itemOne: PumpHistoryEntry,
var itemTwo: PumpHistoryEntry? = null, var itemTwo: PumpHistoryEntry? = null,
var processOperation: Operation = Operation.None) { var processOperation: Operation = Operation.None,
var aapsLogger: AAPSLogger) {
var cancelPresent: Boolean = false var cancelPresent: Boolean = false
val atechDateTime: Long val atechDateTime: Long
@ -16,8 +19,13 @@ class TempBasalProcessDTO constructor(var itemOne: PumpHistoryEntry,
val duration: Int val duration: Int
get() = if (itemTwo == null) { get() = if (itemTwo == null) {
val tbr = itemOne.getDecodedDataEntry("Object") as TempBasalPair val tbr = itemOne.getDecodedDataEntry("Object") as? TempBasalPair
tbr.durationMinutes if (tbr != null)
tbr.durationMinutes
else {
aapsLogger.error("Couldn't find TempBasalPair in entry: $itemOne")
0
}
} else { } else {
DateTimeUtil.getATechDateDiferenceAsMinutes(itemOne.atechDateTime, itemTwo!!.atechDateTime) DateTimeUtil.getATechDateDiferenceAsMinutes(itemOne.atechDateTime, itemTwo!!.atechDateTime)
} }