- fixing handling of Suspend items
This commit is contained in:
parent
71bedba7ee
commit
b90ce3804f
2 changed files with 42 additions and 19 deletions
|
@ -605,7 +605,8 @@ class MedtronicHistoryData @Inject constructor(
|
||||||
processDTO = TempBasalProcessDTO(
|
processDTO = TempBasalProcessDTO(
|
||||||
itemOne = treatment,
|
itemOne = treatment,
|
||||||
processOperation = TempBasalProcessDTO.Operation.Add,
|
processOperation = TempBasalProcessDTO.Operation.Add,
|
||||||
aapsLogger = aapsLogger
|
aapsLogger = aapsLogger,
|
||||||
|
objectType = TempBasalProcessDTO.ObjectType.TemporaryBasal
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -875,7 +876,8 @@ class MedtronicHistoryData @Inject constructor(
|
||||||
val tbrProcess = TempBasalProcessDTO(
|
val tbrProcess = TempBasalProcessDTO(
|
||||||
itemOne = filtered2Items[i],
|
itemOne = filtered2Items[i],
|
||||||
processOperation = TempBasalProcessDTO.Operation.Add,
|
processOperation = TempBasalProcessDTO.Operation.Add,
|
||||||
aapsLogger = aapsLogger)
|
aapsLogger = aapsLogger,
|
||||||
|
objectType = TempBasalProcessDTO.ObjectType.Suspend)
|
||||||
|
|
||||||
tbrProcess.itemTwo = filtered2Items[i + 1]
|
tbrProcess.itemTwo = filtered2Items[i + 1]
|
||||||
|
|
||||||
|
@ -944,7 +946,8 @@ class MedtronicHistoryData @Inject constructor(
|
||||||
val tbrProcess = TempBasalProcessDTO(
|
val tbrProcess = TempBasalProcessDTO(
|
||||||
itemOne = items[items.size - 1],
|
itemOne = items[items.size - 1],
|
||||||
processOperation = TempBasalProcessDTO.Operation.Add,
|
processOperation = TempBasalProcessDTO.Operation.Add,
|
||||||
aapsLogger = aapsLogger)
|
aapsLogger = aapsLogger,
|
||||||
|
objectType = TempBasalProcessDTO.ObjectType.Suspend)
|
||||||
|
|
||||||
tbrProcess.itemTwo = itemTwo
|
tbrProcess.itemTwo = itemTwo
|
||||||
|
|
||||||
|
@ -957,7 +960,8 @@ class MedtronicHistoryData @Inject constructor(
|
||||||
outList.add(TempBasalProcessDTO(
|
outList.add(TempBasalProcessDTO(
|
||||||
itemOne = items[0],
|
itemOne = items[0],
|
||||||
processOperation = TempBasalProcessDTO.Operation.Add,
|
processOperation = TempBasalProcessDTO.Operation.Add,
|
||||||
aapsLogger = aapsLogger))
|
aapsLogger = aapsLogger,
|
||||||
|
objectType = TempBasalProcessDTO.ObjectType.Suspend))
|
||||||
return outList
|
return outList
|
||||||
}
|
}
|
||||||
return outList
|
return outList
|
||||||
|
|
|
@ -7,12 +7,15 @@ import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.PumpH
|
||||||
|
|
||||||
class TempBasalProcessDTO constructor(var itemOne: PumpHistoryEntry,
|
class TempBasalProcessDTO constructor(var itemOne: PumpHistoryEntry,
|
||||||
var processOperation: Operation = Operation.None,
|
var processOperation: Operation = Operation.None,
|
||||||
var aapsLogger: AAPSLogger) {
|
var aapsLogger: AAPSLogger,
|
||||||
|
var objectType: ObjectType = ObjectType.TemporaryBasal) {
|
||||||
|
|
||||||
var itemTwo: PumpHistoryEntry? = null
|
var itemTwo: PumpHistoryEntry? = null
|
||||||
set(value) {
|
set(value) {
|
||||||
field = value
|
field = value
|
||||||
itemTwoTbr = value!!.getDecodedDataEntry("Object") as TempBasalPair
|
if (objectType == ObjectType.TemporaryBasal) {
|
||||||
|
itemTwoTbr = value!!.getDecodedDataEntry("Object") as TempBasalPair
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var itemOneTbr: TempBasalPair? = null
|
var itemOneTbr: TempBasalPair? = null
|
||||||
|
@ -27,27 +30,38 @@ class TempBasalProcessDTO constructor(var itemOne: PumpHistoryEntry,
|
||||||
get() = itemOne.pumpId
|
get() = itemOne.pumpId
|
||||||
|
|
||||||
val durationAsSeconds: Int
|
val durationAsSeconds: Int
|
||||||
get() = if (itemTwo == null) {
|
get() {
|
||||||
if (itemOneTbr != null) {
|
if (objectType == ObjectType.TemporaryBasal) {
|
||||||
aapsLogger.debug("TemporaryBasalPair - itemOneSingle: $itemOneTbr")
|
if (itemTwo == null) {
|
||||||
itemOneTbr!!.durationMinutes * 60
|
if (itemOneTbr != null) {
|
||||||
|
aapsLogger.debug("TemporaryBasalPair - itemOneSingle: $itemOneTbr")
|
||||||
|
return itemOneTbr!!.durationMinutes * 60
|
||||||
|
} else {
|
||||||
|
aapsLogger.error("Couldn't find TempBasalPair in entry: $itemOne")
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
aapsLogger.debug(LTag.PUMP, "Found 2 items for duration: itemOne=$itemOne, itemTwo=$itemTwo")
|
||||||
|
val secondsDiff = DateTimeUtil.getATechDateDiferenceAsSeconds(itemOne.atechDateTime, itemTwo!!.atechDateTime)
|
||||||
|
aapsLogger.debug(LTag.PUMP, "Difference in seconds: $secondsDiff")
|
||||||
|
return secondsDiff
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
aapsLogger.error("Couldn't find TempBasalPair in entry: $itemOne")
|
aapsLogger.debug(LTag.PUMP, "Found 2 items for duration (in SuspendMode): itemOne=$itemOne, itemTwo=$itemTwo")
|
||||||
0
|
val secondsDiff = DateTimeUtil.getATechDateDiferenceAsSeconds(itemOne.atechDateTime, itemTwo!!.atechDateTime)
|
||||||
|
aapsLogger.debug(LTag.PUMP, "Difference in seconds: $secondsDiff")
|
||||||
|
return secondsDiff
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
aapsLogger.debug(LTag.PUMP, "Found 2 items for duration: itemOne=$itemOne, itemTwo=$itemTwo")
|
|
||||||
val secondsDiff = DateTimeUtil.getATechDateDiferenceAsSeconds(itemOne.atechDateTime, itemTwo!!.atechDateTime)
|
|
||||||
aapsLogger.debug(LTag.PUMP, "Difference in seconds: $secondsDiff")
|
|
||||||
secondsDiff
|
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
itemOneTbr = itemOne.getDecodedDataEntry("Object") as TempBasalPair
|
if (objectType == ObjectType.TemporaryBasal) {
|
||||||
|
itemOneTbr = itemOne.getDecodedDataEntry("Object") as TempBasalPair
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
return "ItemOne: $itemOne, ItemTwo: $itemTwo, Duration: $durationAsSeconds, Operation: $processOperation"
|
return "ItemOne: $itemOne, ItemTwo: $itemTwo, Duration: $durationAsSeconds, Operation: $processOperation, ObjectType: $objectType"
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class Operation {
|
enum class Operation {
|
||||||
|
@ -55,4 +69,9 @@ class TempBasalProcessDTO constructor(var itemOne: PumpHistoryEntry,
|
||||||
Add,
|
Add,
|
||||||
Edit
|
Edit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum class ObjectType {
|
||||||
|
TemporaryBasal,
|
||||||
|
Suspend,
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue