From 8184500467a6a7a6d8f7fe2ec2a6b0f7507056c0 Mon Sep 17 00:00:00 2001 From: Andrei Vereha Date: Tue, 21 Sep 2021 21:17:34 +0200 Subject: [PATCH] fix warnings --- .../driver/pod/command/ProgramBasalCommand.kt | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBasalCommand.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBasalCommand.kt index f8a15f7178..aeb12e5953 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBasalCommand.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBasalCommand.kt @@ -100,22 +100,23 @@ class ProgramBasalCommand private constructor( } override fun buildCommand(): ProgramBasalCommand { - requireNotNull(basalProgram) { "basalProgram can not be null" } - requireNotNull(programReminder) { "programReminder can not be null" } - requireNotNull(currentTime) { "currentTime can not be null" } - val pulsesPerSlot = ProgramBasalUtil.mapBasalProgramToPulsesPerSlot(basalProgram!!) - val currentSlot = ProgramBasalUtil.calculateCurrentSlot(pulsesPerSlot, currentTime) + val program = requireNotNull(basalProgram) { "basalProgram can not be null" } + val reminder = requireNotNull(programReminder) { "programReminder can not be null" } + val time = requireNotNull(currentTime) { "currentTime can not be null" } + + val pulsesPerSlot = ProgramBasalUtil.mapBasalProgramToPulsesPerSlot(program) + val currentSlot = ProgramBasalUtil.calculateCurrentSlot(pulsesPerSlot, time) val checksum = ProgramBasalUtil.calculateChecksum(pulsesPerSlot, currentSlot) val longInsulinProgramElements: List = mapTenthPulsesPerSlotToLongInsulinProgramElements( - ProgramBasalUtil.mapBasalProgramToTenthPulsesPerSlot(basalProgram!!) + ProgramBasalUtil.mapBasalProgramToTenthPulsesPerSlot(program) ) val shortInsulinProgramElements = ProgramBasalUtil.mapPulsesPerSlotToShortInsulinProgramElements( pulsesPerSlot ) val currentBasalInsulinProgramElement = ProgramBasalUtil.calculateCurrentLongInsulinProgramElement( longInsulinProgramElements, - currentTime + time ) val interlockCommand = ProgramInsulinCommand( uniqueId!!, sequenceNumber!!, multiCommandFlag, nonce!!, @@ -128,7 +129,7 @@ class ProgramBasalCommand private constructor( sequenceNumber!!, multiCommandFlag, longInsulinProgramElements, - programReminder!!, + reminder, currentBasalInsulinProgramElement.index, currentBasalInsulinProgramElement.remainingTenthPulses, currentBasalInsulinProgramElement.delayUntilNextTenthPulseInUsec