Add DanaI and add UserEntry.Sources in Pumptype to simplify code

This commit is contained in:
Philoul 2021-07-15 00:30:57 +02:00
parent 7c9ea0b528
commit 4e00389622
6 changed files with 48 additions and 26 deletions

View file

@ -11,6 +11,7 @@ import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.interfaces.PumpSync import info.nightscout.androidaps.interfaces.PumpSync
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification import info.nightscout.androidaps.plugins.general.overview.notifications.Notification
@ -30,7 +31,8 @@ class PumpSyncImplementation @Inject constructor(
private val rxBus: RxBusWrapper, private val rxBus: RxBusWrapper,
private val resourceHelper: ResourceHelper, private val resourceHelper: ResourceHelper,
private val profileFunction: ProfileFunction, private val profileFunction: ProfileFunction,
private val repository: AppRepository private val repository: AppRepository,
private val uel: UserEntryLogger
) : PumpSync { ) : PumpSync {
private val disposable = CompositeDisposable() private val disposable = CompositeDisposable()
@ -213,6 +215,7 @@ class PumpSyncImplementation @Inject constructor(
pumpType = pumpType.toDbPumpType(), pumpType = pumpType.toDbPumpType(),
pumpSerial = pumpSerial) pumpSerial = pumpSerial)
) )
uel.log(UserEntry.Action.CAREPORTAL, pumpType.source, note, ValueWithUnit.Timestamp(timestamp), ValueWithUnit.TherapyEventType(type.toDBbEventType()))
repository.runTransactionForResult(InsertIfNewByTimestampTherapyEventTransaction(therapyEvent)) repository.runTransactionForResult(InsertIfNewByTimestampTherapyEventTransaction(therapyEvent))
.doOnError { .doOnError {
aapsLogger.error(LTag.DATABASE, "Error while saving TherapyEvent", it) aapsLogger.error(LTag.DATABASE, "Error while saving TherapyEvent", it)

View file

@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.pump.common.defs
import info.nightscout.androidaps.core.R import info.nightscout.androidaps.core.R
import info.nightscout.androidaps.database.embedments.InterfaceIDs import info.nightscout.androidaps.database.embedments.InterfaceIDs
import info.nightscout.androidaps.database.entities.UserEntry.Sources
import info.nightscout.androidaps.plugins.common.ManufacturerType import info.nightscout.androidaps.plugins.common.ManufacturerType
import info.nightscout.androidaps.utils.Round import info.nightscout.androidaps.utils.Round
import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.resources.ResourceHelper
@ -50,7 +51,8 @@ enum class PumpType {
baseBasalMinValue = 0.01, baseBasalMinValue = 0.01,
baseBasalStep = 0.01, baseBasalStep = 0.01,
baseBasalSpecialSteps = DoseStepSize.ComboBasal, baseBasalSpecialSteps = DoseStepSize.ComboBasal,
pumpCapability = PumpCapability.ComboCapabilities), pumpCapability = PumpCapability.ComboCapabilities,
source = Sources.Combo),
ACCU_CHEK_SPIRIT(description = "Accu-Chek Spirit", ACCU_CHEK_SPIRIT(description = "Accu-Chek Spirit",
manufacturer = ManufacturerType.Roche, manufacturer = ManufacturerType.Roche,
model = "Spirit", model = "Spirit",
@ -90,7 +92,8 @@ enum class PumpType {
baseBasalMaxValue = null, baseBasalMaxValue = null,
baseBasalStep = 0.01, baseBasalStep = 0.01,
baseBasalSpecialSteps = DoseStepSize.InsightBasal, baseBasalSpecialSteps = DoseStepSize.InsightBasal,
pumpCapability = PumpCapability.InsightCapabilities), pumpCapability = PumpCapability.InsightCapabilities,
source = Sources.Insight),
ACCU_CHEK_SOLO(description = "Accu-Chek Solo", ACCU_CHEK_SOLO(description = "Accu-Chek Solo",
manufacturer = ManufacturerType.Roche, manufacturer = ManufacturerType.Roche,
model = "Solo", model = "Solo",
@ -133,7 +136,8 @@ enum class PumpType {
baseBasalMinValue = 0.04, baseBasalMinValue = 0.04,
baseBasalStep = 0.01, baseBasalStep = 0.01,
baseBasalSpecialSteps = null, baseBasalSpecialSteps = null,
pumpCapability = PumpCapability.DanaCapabilities), pumpCapability = PumpCapability.DanaCapabilities,
source = Sources.DanaR),
DANA_R_KOREAN(description = "DanaR Korean", DANA_R_KOREAN(description = "DanaR Korean",
manufacturer = ManufacturerType.Sooil, manufacturer = ManufacturerType.Sooil,
model = "DanaRKorean", model = "DanaRKorean",
@ -146,7 +150,8 @@ enum class PumpType {
baseBasalMinValue = 0.1, baseBasalMinValue = 0.1,
baseBasalStep = 0.01, baseBasalStep = 0.01,
baseBasalSpecialSteps = null, baseBasalSpecialSteps = null,
pumpCapability = PumpCapability.DanaCapabilities), pumpCapability = PumpCapability.DanaCapabilities,
source = Sources.DanaRC),
DANA_RS(description = "DanaRS", DANA_RS(description = "DanaRS",
manufacturer = ManufacturerType.Sooil, manufacturer = ManufacturerType.Sooil,
model = "DanaRS", model = "DanaRS",
@ -159,10 +164,11 @@ enum class PumpType {
baseBasalMinValue = 0.04, baseBasalMinValue = 0.04,
baseBasalStep = 0.01, baseBasalStep = 0.01,
baseBasalSpecialSteps = null, baseBasalSpecialSteps = null,
pumpCapability = PumpCapability.DanaWithHistoryCapabilities), pumpCapability = PumpCapability.DanaWithHistoryCapabilities,
source = Sources.DanaRS),
DANA_RS_KOREAN(description = "DanaRSKorean", model = "DanaRSKorean", parent = DANA_RS), DANA_RS_KOREAN(description = "DanaRSKorean", model = "DanaRSKorean", parent = DANA_RS),
DANA_I(description = "DanaI", model = "DanaI", parent = DANA_RS), DANA_I(description = "DanaI", model = "DanaI", parent = DANA_RS, source = Sources.DanaI),
DANA_RV2(description = "DanaRv2", model = "DanaRv2", parent = DANA_RS), DANA_RV2(description = "DanaRv2", model = "DanaRv2", parent = DANA_RS, source = Sources.DanaRv2),
OMNIPOD_EROS(description = "Omnipod Eros", OMNIPOD_EROS(description = "Omnipod Eros",
manufacturer = ManufacturerType.Insulet, manufacturer = ManufacturerType.Insulet,
model = "Eros", model = "Eros",
@ -177,7 +183,8 @@ enum class PumpType {
baseBasalStep = 0.05, baseBasalStep = 0.05,
baseBasalSpecialSteps = null, baseBasalSpecialSteps = null,
pumpCapability = PumpCapability.OmnipodCapabilities, pumpCapability = PumpCapability.OmnipodCapabilities,
hasCustomUnreachableAlertCheck = true), hasCustomUnreachableAlertCheck = true,
source = Sources.OmnipodEros),
OMNIPOD_DASH(description = "Omnipod Dash", OMNIPOD_DASH(description = "Omnipod Dash",
manufacturer = ManufacturerType.Insulet, manufacturer = ManufacturerType.Insulet,
model = "Dash", model = "Dash",
@ -205,7 +212,8 @@ enum class PumpType {
baseBasalMinValue = 0.05, baseBasalMinValue = 0.05,
baseBasalStep = 0.05, baseBasalStep = 0.05,
baseBasalSpecialSteps = null, baseBasalSpecialSteps = null,
pumpCapability = PumpCapability.MedtronicCapabilities), pumpCapability = PumpCapability.MedtronicCapabilities,
source = Sources.Medtronic),
MEDTRONIC_515_715(description = "Medtronic 515/715", MEDTRONIC_515_715(description = "Medtronic 515/715",
model = "515/715", model = "515/715",
parent = MEDTRONIC_512_712), parent = MEDTRONIC_512_712),
@ -224,7 +232,8 @@ enum class PumpType {
baseBasalMinValue = 0.025, baseBasalMinValue = 0.025,
baseBasalStep = 0.025, baseBasalStep = 0.025,
baseBasalSpecialSteps = DoseStepSize.MedtronicVeoBasal, baseBasalSpecialSteps = DoseStepSize.MedtronicVeoBasal,
pumpCapability = PumpCapability.MedtronicCapabilities), pumpCapability = PumpCapability.MedtronicCapabilities,
source = Sources.Medtronic),
MEDTRONIC_554_754_VEO(description = "Medtronic 554/754 (Veo)", model = "554/754 (Veo)", parent = MEDTRONIC_523_723_REVEL), MEDTRONIC_554_754_VEO(description = "Medtronic 554/754 (Veo)", model = "554/754 (Veo)", parent = MEDTRONIC_523_723_REVEL),
MEDTRONIC_640G(description = "Medtronic 640G", MEDTRONIC_640G(description = "Medtronic 640G",
manufacturer = ManufacturerType.Medtronic, manufacturer = ManufacturerType.Medtronic,
@ -284,7 +293,8 @@ enum class PumpType {
model = "USER", model = "USER",
tbrSettings = DoseSettings(1.0, 15, 24 * 60, 0.0, 500.0), tbrSettings = DoseSettings(1.0, 15, 24 * 60, 0.0, 500.0),
extendedBolusSettings = DoseSettings(0.1, 15, 12 * 60, 0.1), extendedBolusSettings = DoseSettings(0.1, 15, 12 * 60, 0.1),
pumpCapability = PumpCapability.MDI), pumpCapability = PumpCapability.MDI,
source = Sources.MDI),
//Diaconn Pump //Diaconn Pump
DIACONN_G8(description = "DiaconnG8", DIACONN_G8(description = "DiaconnG8",
@ -300,7 +310,8 @@ enum class PumpType {
baseBasalMaxValue = 3.0, baseBasalMaxValue = 3.0,
baseBasalStep = 0.01, baseBasalStep = 0.01,
baseBasalSpecialSteps = null, baseBasalSpecialSteps = null,
pumpCapability = PumpCapability.DanaWithHistoryCapabilities); pumpCapability = PumpCapability.DanaWithHistoryCapabilities,
source = Sources.DiaconnG8);
val description: String val description: String
var manufacturer: ManufacturerType? = null var manufacturer: ManufacturerType? = null
@ -342,6 +353,7 @@ enum class PumpType {
var hasCustomUnreachableAlertCheck = false var hasCustomUnreachableAlertCheck = false
private set private set
private var parent: PumpType? = null private var parent: PumpType? = null
val source: Sources
companion object { companion object {
@ -349,9 +361,10 @@ enum class PumpType {
values().firstOrNull { it.description == desc } ?: GENERIC_AAPS values().firstOrNull { it.description == desc } ?: GENERIC_AAPS
} }
constructor(description: String, model: String, parent: PumpType, pumpCapability: PumpCapability? = null) { constructor(description: String, model: String, parent: PumpType, pumpCapability: PumpCapability? = null, source: Sources? = null) {
this.description = description this.description = description
this.parent = parent this.parent = parent
this.source = source ?: parent.source
this.pumpCapability = pumpCapability this.pumpCapability = pumpCapability
parent.model = model parent.model = model
} }
@ -370,7 +383,8 @@ enum class PumpType {
baseBasalStep: Double = 1.0, baseBasalStep: Double = 1.0,
baseBasalSpecialSteps: DoseStepSize? = null, baseBasalSpecialSteps: DoseStepSize? = null,
pumpCapability: PumpCapability, pumpCapability: PumpCapability,
hasCustomUnreachableAlertCheck: Boolean = false) { hasCustomUnreachableAlertCheck: Boolean = false,
source: Sources = Sources.VirtualPump) {
this.description = description this.description = description
this.manufacturer = manufacturer this.manufacturer = manufacturer
this.model = model this.model = model
@ -386,6 +400,7 @@ enum class PumpType {
this.baseBasalSpecialSteps = baseBasalSpecialSteps this.baseBasalSpecialSteps = baseBasalSpecialSteps
this.pumpCapability = pumpCapability this.pumpCapability = pumpCapability
this.hasCustomUnreachableAlertCheck = hasCustomUnreachableAlertCheck this.hasCustomUnreachableAlertCheck = hasCustomUnreachableAlertCheck
this.source = source
} }
fun getFullDescription(i18nTemplate: String, hasExtendedBasals: Boolean, resourceHelper: ResourceHelper): String { fun getFullDescription(i18nTemplate: String, hasExtendedBasals: Boolean, resourceHelper: ResourceHelper): String {

View file

@ -264,6 +264,7 @@ class Translator @Inject internal constructor(
Sources.DanaRC -> TODO() Sources.DanaRC -> TODO()
Sources.DanaRv2 -> TODO() Sources.DanaRv2 -> TODO()
Sources.DanaRS -> TODO() Sources.DanaRS -> TODO()
Sources.DanaI -> TODO()
Sources.DiaconnG8 -> TODO() Sources.DiaconnG8 -> TODO()
Sources.Insight -> TODO() Sources.Insight -> TODO()
Sources.Combo -> TODO() Sources.Combo -> TODO()

View file

@ -129,6 +129,7 @@ class UserEntryMapper {
DanaRC (UserEntry.Sources.DanaRC), DanaRC (UserEntry.Sources.DanaRC),
DanaRv2 (UserEntry.Sources.DanaRv2), DanaRv2 (UserEntry.Sources.DanaRv2),
DanaRS (UserEntry.Sources.DanaRS), DanaRS (UserEntry.Sources.DanaRS),
DanaI (UserEntry.Sources.DanaI),
DiaconnG8 (UserEntry.Sources.DiaconnG8), DiaconnG8 (UserEntry.Sources.DiaconnG8),
Insight (UserEntry.Sources.Insight), Insight (UserEntry.Sources.Insight),
Combo (UserEntry.Sources.Combo), Combo (UserEntry.Sources.Combo),

View file

@ -83,6 +83,7 @@ class UserEntryPresentationHelper @Inject constructor(
Sources.DanaRC -> R.drawable.ic_danars_128 Sources.DanaRC -> R.drawable.ic_danars_128
Sources.DanaRv2 -> R.drawable.ic_danars_128 Sources.DanaRv2 -> R.drawable.ic_danars_128
Sources.DanaRS -> R.drawable.ic_danars_128 Sources.DanaRS -> R.drawable.ic_danars_128
Sources.DanaI -> R.drawable.ic_danai_128
Sources.DiaconnG8 -> R.drawable.ic_diaconn_g8 Sources.DiaconnG8 -> R.drawable.ic_diaconn_g8
Sources.Insight -> R.drawable.ic_insight_128 Sources.Insight -> R.drawable.ic_insight_128
Sources.Combo -> R.drawable.ic_combo_128 Sources.Combo -> R.drawable.ic_combo_128

View file

@ -153,19 +153,20 @@ data class UserEntry(
Objectives, //From Objectives plugin Objectives, //From Objectives plugin
Pump, //To update with one Source per pump Pump, //To update with one Source per pump
Dana, //Only one UserEntry in Common module Dana Dana, //Only one UserEntry in Common module Dana
DanaR, //No entry currently DanaR,
DanaRC, //No entry currently DanaRC,
DanaRv2, //No entry currently DanaRv2,
DanaRS, //No entry currently DanaRS,
DiaconnG8, //No entry currently DanaI,
Insight, //No entry currently DiaconnG8,
Combo, //No entry currently Insight,
Medtronic, //No entry currently Combo,
Medtronic,
Omnipod, //No entry currently Omnipod, //No entry currently
OmnipodEros, //No entry currently OmnipodEros,
OmnipodDash, //No entry currently OmnipodDash, //No entry currently
MDI, //No entry currently MDI,
VirtualPump, //No entry currently VirtualPump,
SMS, //From SMS plugin SMS, //From SMS plugin
Treatments, //From Treatments plugin Treatments, //From Treatments plugin
Wear, //From Wear plugin Wear, //From Wear plugin