From f2ed33c237128e7713ea030c875e04fda96ea00f Mon Sep 17 00:00:00 2001 From: Andy Rozman Date: Sun, 6 Jun 2021 21:54:29 +0100 Subject: [PATCH] - log changes, little bit of refactoring on PumpSyncStorage class --- .../plugins/pump/medtronic/data/MedtronicHistoryData.kt | 7 +++++-- .../androidaps/plugins/pump/common/sync/PumpSyncStorage.kt | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/MedtronicHistoryData.kt b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/MedtronicHistoryData.kt index d1c3fc55e5..28ce753ee8 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/MedtronicHistoryData.kt +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/MedtronicHistoryData.kt @@ -9,6 +9,7 @@ import info.nightscout.androidaps.interfaces.PumpSync import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.common.defs.PumpType +import info.nightscout.androidaps.plugins.pump.common.sync.PumpDbEntry import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil import info.nightscout.androidaps.plugins.pump.common.utils.StringUtil import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.MedtronicPumpHistoryDecoder @@ -490,9 +491,11 @@ class MedtronicHistoryData @Inject constructor( if (!multiwave) { val entryWithTempId = findDbEntry(bolus, boluses) - aapsLogger.debug(LTag.PUMP, String.format("DD: entryWithTempId=%s", gson.toJson(entryWithTempId))) + aapsLogger.debug(LTag.PUMP, String.format("DD: entryWithTempId=%s", entryWithTempId)) if (entryWithTempId != null) { + aapsLogger.debug(LTag.PUMP, String.format("DD: entryWithTempId.bolusData=%s", if (entryWithTempId.bolusData == null) "null" else entryWithTempId.bolusData)) + temporaryId = entryWithTempId.temporaryId pumpSyncStorage.removeBolusWithTemporaryId(temporaryId) boluses.remove(entryWithTempId) @@ -725,7 +728,7 @@ class MedtronicHistoryData @Inject constructor( /** * Looks at all boluses that have temporaryId and find one that is correct for us (if such entry exists) */ - private fun findDbEntry(treatment: PumpHistoryEntry, temporaryEntries: MutableList): info.nightscout.androidaps.plugins.pump.common.sync.PumpDbEntry? { + private fun findDbEntry(treatment: PumpHistoryEntry, temporaryEntries: MutableList): PumpDbEntry? { if (temporaryEntries.isEmpty()) { return null diff --git a/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/sync/PumpSyncStorage.kt b/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/sync/PumpSyncStorage.kt index 8084d52cd6..66ab54cb7b 100644 --- a/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/sync/PumpSyncStorage.kt +++ b/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/sync/PumpSyncStorage.kt @@ -97,7 +97,11 @@ class PumpSyncStorage @Inject constructor( if (result && writeToInternalHistory) { val innerList: MutableList = pumpSyncStorage[BOLUS]!! - innerList.add(PumpDbEntry(temporaryId, detailedBolusInfo.timestamp, creator.model(), creator.serialNumber(), detailedBolusInfo)) + val dbEntry = PumpDbEntry(temporaryId, detailedBolusInfo.timestamp, creator.model(), creator.serialNumber(), detailedBolusInfo) + + aapsLogger.debug("PumpDbEntry: $dbEntry") + + innerList.add(dbEntry) pumpSyncStorage[BOLUS] = innerList saveStorage() }