From 9af5499d7058466bdc44811c6a095bf86a0e5c20 Mon Sep 17 00:00:00 2001 From: Carlos Rafael Giani Date: Sun, 1 Jan 2023 15:36:45 +0100 Subject: [PATCH] comboctl-base: Rename CMDBolusType to CMDImmediateBolusType This name is less confusing, especially if another enum class for the bolus delivery is about to be introduced. Signed-off-by: Carlos Rafael Giani --- .../nightscout/comboctl/base/ApplicationLayer.kt | 16 ++++++++++------ .../info/nightscout/comboctl/base/PumpIO.kt | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/base/ApplicationLayer.kt b/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/base/ApplicationLayer.kt index 15aa500b76..2b18b71743 100644 --- a/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/base/ApplicationLayer.kt +++ b/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/base/ApplicationLayer.kt @@ -524,14 +524,18 @@ object ApplicationLayer { ) /** - * Possible bolus types used in COMMAND mode commands. + * Possible immediate bolus types used in COMMAND mode commands. + * + * "Immediate" means that the bolus gets delivered immediately once the command is sent. + * A standard bolus only has an immediate delivery, an extended bolus has none, and + * a multiwave bolus is partially made up of an immediate and an extended delivery. */ - enum class CMDBolusType(val id: Int) { + enum class CMDImmediateBolusType(val id: Int) { STANDARD(0x47), MULTI_WAVE(0xB7); companion object { - private val values = CMDBolusType.values() + private val values = CMDImmediateBolusType.values() fun fromInt(value: Int) = values.firstOrNull { it.id == value } } } @@ -565,7 +569,7 @@ object ApplicationLayer { * "57" means 5.7 IU. */ data class CMDBolusDeliveryStatus( - val bolusType: CMDBolusType, + val bolusType: CMDImmediateBolusType, val deliveryState: CMDBolusDeliveryState, val remainingAmount: Int ) @@ -1068,7 +1072,7 @@ object ApplicationLayer { * @param bolusType The type of the bolus to cancel. * @return The produced packet. */ - fun createCMDCancelBolusPacket(bolusType: CMDBolusType) = Packet( + fun createCMDCancelBolusPacket(bolusType: CMDImmediateBolusType) = Packet( command = Command.CMD_CANCEL_BOLUS, payload = byteArrayListOfInts(bolusType.id) ) @@ -1477,7 +1481,7 @@ object ApplicationLayer { val payload = packet.payload val bolusTypeInt = payload[2].toPosInt() - val bolusType = CMDBolusType.fromInt(bolusTypeInt) + val bolusType = CMDImmediateBolusType.fromInt(bolusTypeInt) ?: throw PayloadDataCorruptionException( packet, "Invalid bolus type ${bolusTypeInt.toHexString(2, true)}" diff --git a/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/base/PumpIO.kt b/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/base/PumpIO.kt index d16fad4d3c..0fef728217 100644 --- a/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/base/PumpIO.kt +++ b/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/base/PumpIO.kt @@ -1038,7 +1038,7 @@ class PumpIO( // TODO: Test that this function does the expected thing // when no bolus is actually ongoing. val packet = sendPacketWithResponse( - ApplicationLayer.createCMDCancelBolusPacket(ApplicationLayer.CMDBolusType.STANDARD), + ApplicationLayer.createCMDCancelBolusPacket(ApplicationLayer.CMDImmediateBolusType.STANDARD), ApplicationLayer.Command.CMD_CANCEL_BOLUS_RESPONSE )