From b87f41a363168a534e6f08bd2e6843d8aa805cc5 Mon Sep 17 00:00:00 2001 From: jbr7rr <> Date: Fri, 25 Aug 2023 21:33:03 +0200 Subject: [PATCH] Medtrum: Support for 300U --- .../java/info/nightscout/interfaces/pump/defs/PumpType.kt | 1 + .../java/info/nightscout/core/pump/PumpTypeExtension.kt | 7 +++++-- .../java/info/nightscout/database/entities/UserEntry.kt | 1 + .../database/entities/embedments/InterfaceIDs.kt | 3 ++- .../java/info/nightscout/pump/medtrum/MedtrumPlugin.kt | 4 ++-- .../main/java/info/nightscout/pump/medtrum/MedtrumPump.kt | 1 + pump/medtrum/src/main/res/values/strings.xml | 2 +- 7 files changed, 13 insertions(+), 6 deletions(-) diff --git a/core/interfaces/src/main/java/info/nightscout/interfaces/pump/defs/PumpType.kt b/core/interfaces/src/main/java/info/nightscout/interfaces/pump/defs/PumpType.kt index 3bd481629c..6f51a417ac 100644 --- a/core/interfaces/src/main/java/info/nightscout/interfaces/pump/defs/PumpType.kt +++ b/core/interfaces/src/main/java/info/nightscout/interfaces/pump/defs/PumpType.kt @@ -413,6 +413,7 @@ enum class PumpType { maxReservoirReading = 400, source = Source.Medtrum ), + MEDTRUM_300U(description = "Medtrum 300U", model = "300U", parent = MEDTRUM_NANO), MEDTRUM_UNTESTED(description = "Medtrum untested", model = "untested", parent = MEDTRUM_NANO); val description: String diff --git a/core/main/src/main/java/info/nightscout/core/pump/PumpTypeExtension.kt b/core/main/src/main/java/info/nightscout/core/pump/PumpTypeExtension.kt index 321365cba4..cb7699d041 100644 --- a/core/main/src/main/java/info/nightscout/core/pump/PumpTypeExtension.kt +++ b/core/main/src/main/java/info/nightscout/core/pump/PumpTypeExtension.kt @@ -59,7 +59,8 @@ fun PumpType.Companion.fromDbPumpType(pt: InterfaceIDs.PumpType): PumpType = InterfaceIDs.PumpType.USER -> PumpType.USER InterfaceIDs.PumpType.DIACONN_G8 -> PumpType.DIACONN_G8 InterfaceIDs.PumpType.EOPATCH2 -> PumpType.EOFLOW_EOPATCH2 - InterfaceIDs.PumpType.MEDTRUM -> PumpType.MEDTRUM_NANO + InterfaceIDs.PumpType.MEDTRUM_NANO -> PumpType.MEDTRUM_NANO + InterfaceIDs.PumpType.MEDTRUM_300U -> PumpType.MEDTRUM_300U InterfaceIDs.PumpType.MEDTRUM_UNTESTED -> PumpType.MEDTRUM_UNTESTED InterfaceIDs.PumpType.CACHE -> PumpType.CACHE } @@ -80,6 +81,7 @@ fun PumpType.Source.toDbSource(): UserEntry.Sources = PumpType.Source.OmnipodEros -> UserEntry.Sources.OmnipodEros PumpType.Source.OmnipodDash -> UserEntry.Sources.OmnipodDash PumpType.Source.EOPatch2 -> UserEntry.Sources.EOPatch2 + PumpType.Source.Medtrum -> UserEntry.Sources.Medtrum PumpType.Source.MDI -> UserEntry.Sources.MDI PumpType.Source.VirtualPump -> UserEntry.Sources.VirtualPump else -> UserEntry.Sources.Unknown @@ -119,7 +121,8 @@ fun PumpType.toDbPumpType(): InterfaceIDs.PumpType = PumpType.USER -> InterfaceIDs.PumpType.USER PumpType.DIACONN_G8 -> InterfaceIDs.PumpType.DIACONN_G8 PumpType.EOFLOW_EOPATCH2 -> InterfaceIDs.PumpType.EOPATCH2 - PumpType.MEDTRUM_NANO -> InterfaceIDs.PumpType.MEDTRUM + PumpType.MEDTRUM_NANO -> InterfaceIDs.PumpType.MEDTRUM_NANO + PumpType.MEDTRUM_300U -> InterfaceIDs.PumpType.MEDTRUM_300U PumpType.MEDTRUM_UNTESTED -> InterfaceIDs.PumpType.MEDTRUM_UNTESTED PumpType.CACHE -> InterfaceIDs.PumpType.CACHE } diff --git a/database/entities/src/main/java/info/nightscout/database/entities/UserEntry.kt b/database/entities/src/main/java/info/nightscout/database/entities/UserEntry.kt index c91244ead4..a39ea837b6 100644 --- a/database/entities/src/main/java/info/nightscout/database/entities/UserEntry.kt +++ b/database/entities/src/main/java/info/nightscout/database/entities/UserEntry.kt @@ -172,6 +172,7 @@ data class UserEntry( OmnipodEros, OmnipodDash, //No entry currently EOPatch2, + Medtrum, MDI, VirtualPump, SMS, //From SMS plugin diff --git a/database/entities/src/main/java/info/nightscout/database/entities/embedments/InterfaceIDs.kt b/database/entities/src/main/java/info/nightscout/database/entities/embedments/InterfaceIDs.kt index 0a244aa3c6..2086a99e6e 100644 --- a/database/entities/src/main/java/info/nightscout/database/entities/embedments/InterfaceIDs.kt +++ b/database/entities/src/main/java/info/nightscout/database/entities/embedments/InterfaceIDs.kt @@ -43,7 +43,8 @@ data class InterfaceIDs( MDI, DIACONN_G8, EOPATCH2, - MEDTRUM, + MEDTRUM_NANO, + MEDTRUM_300U, MEDTRUM_UNTESTED, USER, CACHE; diff --git a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/MedtrumPlugin.kt b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/MedtrumPlugin.kt index 2aa61cda52..9059b4a75b 100644 --- a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/MedtrumPlugin.kt +++ b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/MedtrumPlugin.kt @@ -186,12 +186,12 @@ import kotlin.math.abs } when (medtrumPump.pumpType()) { - PumpType.MEDTRUM_NANO -> { + PumpType.MEDTRUM_NANO, PumpType.MEDTRUM_300U -> { alarmSetting?.entries = arrayOf(allAlarmEntries[6], allAlarmEntries[7]) // "Beep", "Silent" alarmSetting?.entryValues = arrayOf(allAlarmValues[6], allAlarmValues[7]) // "6", "7" } - else -> { + else -> { // Use Nano settings for unknown pumps alarmSetting?.entries = arrayOf(allAlarmEntries[6], allAlarmEntries[7]) // "Beep", "Silent" alarmSetting?.entryValues = arrayOf(allAlarmValues[6], allAlarmValues[7]) // "6", "7" diff --git a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/MedtrumPump.kt b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/MedtrumPump.kt index 094e5ebaf7..ee7131a684 100644 --- a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/MedtrumPump.kt +++ b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/MedtrumPump.kt @@ -294,6 +294,7 @@ class MedtrumPump @Inject constructor( fun pumpType(type: Int): PumpType = when (type) { MedtrumSnUtil.MD_0201, MedtrumSnUtil.MD_8201 -> PumpType.MEDTRUM_NANO + MedtrumSnUtil.MD_8301 -> PumpType.MEDTRUM_300U else -> PumpType.MEDTRUM_UNTESTED } diff --git a/pump/medtrum/src/main/res/values/strings.xml b/pump/medtrum/src/main/res/values/strings.xml index 3161372a56..18953f45cf 100644 --- a/pump/medtrum/src/main/res/values/strings.xml +++ b/pump/medtrum/src/main/res/values/strings.xml @@ -25,7 +25,7 @@ Medtrum MT - Pump integration for Medtrum Nano + Pump integration for Medtrum Nano and Medtrum 300U Medtrum pump settings Pump error: %1$s !! Pump is suspended