From 14b7895f201d10331f08a53237d965a3b3e5daea Mon Sep 17 00:00:00 2001 From: Andy Rozman Date: Thu, 13 May 2021 13:33:25 +0100 Subject: [PATCH] - final changes on Bolus (checking if bolus entry was changed in last 35 minutes) - added class for Dropbox support (not yet implemented) --- .../general/maintenance/DropboxUploader.kt | 8 ++++++++ .../comm/history/pump/PumpHistoryEntry.kt | 15 +++++++++++++-- .../pump/medtronic/data/MedtronicHistoryData.kt | 4 ++-- .../plugins/pump/medtronic/data/dto/BolusDTO.kt | 4 ++-- 4 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/DropboxUploader.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/DropboxUploader.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/DropboxUploader.kt new file mode 100644 index 0000000000..cc7b28bc06 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/DropboxUploader.kt @@ -0,0 +1,8 @@ +package info.nightscout.androidaps.plugins.general.maintenance + +class DropboxUploader { + + + + +} \ No newline at end of file diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/pump/PumpHistoryEntry.kt b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/pump/PumpHistoryEntry.kt index a38ec2647e..83fbd2677d 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/pump/PumpHistoryEntry.kt +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/pump/PumpHistoryEntry.kt @@ -5,6 +5,7 @@ import com.google.gson.annotations.Expose import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil import info.nightscout.androidaps.plugins.pump.common.utils.StringUtil import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.MedtronicHistoryEntry +import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.BolusDTO import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceType import java.util.* @@ -113,8 +114,18 @@ class PumpHistoryEntry : MedtronicHistoryEntry() { super.pumpId = pumpId } - fun hasBolusOrTBRDataChanged(entry: PumpHistoryEntry) : Boolean { - if (entryType!=null && (entryType!! == PumpHistoryEntryType.Bolus || entryType!! == PumpHistoryEntryType.TempBasalCombined)) { + fun hasBolusChanged(entry: PumpHistoryEntry) : Boolean { + if (entryType!=null && entryType == PumpHistoryEntryType.Bolus) { + val thisOne: BolusDTO? = this.decodedData!!["Object"]!! as BolusDTO? + val otherOne: BolusDTO? = entry.decodedData!!["Object"]!! as BolusDTO? + + if (thisOne==null || otherOne==null) { + return false; + } + + + + return false // TODO needs to be implemented } 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 1c67eb3b92..587d70e461 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 @@ -88,10 +88,10 @@ class MedtronicHistoryData @Inject constructor( } else { val entryByPumpId = getEntryByPumpId(validEntry.pumpId!!) - // TODO not implemented - if (entryByPumpId!=null && entryByPumpId.hasBolusOrTBRDataChanged(validEntry)) { + if (entryByPumpId!=null && entryByPumpId.hasBolusChanged(validEntry)) { newEntries.add(validEntry) allHistory.remove(entryByPumpId) + allPumpIds.remove(validEntry.pumpId!!); } } } diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/BolusDTO.kt b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/BolusDTO.kt index 671aae39a5..6e205248fe 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/BolusDTO.kt +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/BolusDTO.kt @@ -57,7 +57,7 @@ class BolusDTO : PumpTimeStampedRecord() { return StringUtil.getLeadingZero(h, 2) + ":" + StringUtil.getLeadingZero(minutes, 2) } - val value: String? + val value: String get() = if (bolusType === PumpBolusType.Normal || bolusType === PumpBolusType.Audio) { getFormattedDecimal(deliveredAmount!!) } else if (bolusType === PumpBolusType.Extended) { @@ -77,7 +77,7 @@ class BolusDTO : PumpTimeStampedRecord() { return value } - override fun getFormattedDecimal(value: Double): String? { + override fun getFormattedDecimal(value: Double): String { return StringUtil.getFormatedValueUS(value, 2) }