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 <crg7475@mailbox.org>
This commit is contained in:
parent
7598ae758c
commit
9af5499d70
2 changed files with 11 additions and 7 deletions
|
@ -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),
|
STANDARD(0x47),
|
||||||
MULTI_WAVE(0xB7);
|
MULTI_WAVE(0xB7);
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val values = CMDBolusType.values()
|
private val values = CMDImmediateBolusType.values()
|
||||||
fun fromInt(value: Int) = values.firstOrNull { it.id == value }
|
fun fromInt(value: Int) = values.firstOrNull { it.id == value }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -565,7 +569,7 @@ object ApplicationLayer {
|
||||||
* "57" means 5.7 IU.
|
* "57" means 5.7 IU.
|
||||||
*/
|
*/
|
||||||
data class CMDBolusDeliveryStatus(
|
data class CMDBolusDeliveryStatus(
|
||||||
val bolusType: CMDBolusType,
|
val bolusType: CMDImmediateBolusType,
|
||||||
val deliveryState: CMDBolusDeliveryState,
|
val deliveryState: CMDBolusDeliveryState,
|
||||||
val remainingAmount: Int
|
val remainingAmount: Int
|
||||||
)
|
)
|
||||||
|
@ -1068,7 +1072,7 @@ object ApplicationLayer {
|
||||||
* @param bolusType The type of the bolus to cancel.
|
* @param bolusType The type of the bolus to cancel.
|
||||||
* @return The produced packet.
|
* @return The produced packet.
|
||||||
*/
|
*/
|
||||||
fun createCMDCancelBolusPacket(bolusType: CMDBolusType) = Packet(
|
fun createCMDCancelBolusPacket(bolusType: CMDImmediateBolusType) = Packet(
|
||||||
command = Command.CMD_CANCEL_BOLUS,
|
command = Command.CMD_CANCEL_BOLUS,
|
||||||
payload = byteArrayListOfInts(bolusType.id)
|
payload = byteArrayListOfInts(bolusType.id)
|
||||||
)
|
)
|
||||||
|
@ -1477,7 +1481,7 @@ object ApplicationLayer {
|
||||||
val payload = packet.payload
|
val payload = packet.payload
|
||||||
|
|
||||||
val bolusTypeInt = payload[2].toPosInt()
|
val bolusTypeInt = payload[2].toPosInt()
|
||||||
val bolusType = CMDBolusType.fromInt(bolusTypeInt)
|
val bolusType = CMDImmediateBolusType.fromInt(bolusTypeInt)
|
||||||
?: throw PayloadDataCorruptionException(
|
?: throw PayloadDataCorruptionException(
|
||||||
packet,
|
packet,
|
||||||
"Invalid bolus type ${bolusTypeInt.toHexString(2, true)}"
|
"Invalid bolus type ${bolusTypeInt.toHexString(2, true)}"
|
||||||
|
|
|
@ -1038,7 +1038,7 @@ class PumpIO(
|
||||||
// TODO: Test that this function does the expected thing
|
// TODO: Test that this function does the expected thing
|
||||||
// when no bolus is actually ongoing.
|
// when no bolus is actually ongoing.
|
||||||
val packet = sendPacketWithResponse(
|
val packet = sendPacketWithResponse(
|
||||||
ApplicationLayer.createCMDCancelBolusPacket(ApplicationLayer.CMDBolusType.STANDARD),
|
ApplicationLayer.createCMDCancelBolusPacket(ApplicationLayer.CMDImmediateBolusType.STANDARD),
|
||||||
ApplicationLayer.Command.CMD_CANCEL_BOLUS_RESPONSE
|
ApplicationLayer.Command.CMD_CANCEL_BOLUS_RESPONSE
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue