EOPATCH: fix rounding
This commit is contained in:
parent
31a6bf4460
commit
23cc3c9c3e
1 changed files with 5 additions and 3 deletions
|
@ -27,6 +27,7 @@ import info.nightscout.interfaces.pump.defs.PumpType
|
||||||
import info.nightscout.interfaces.queue.CommandQueue
|
import info.nightscout.interfaces.queue.CommandQueue
|
||||||
import info.nightscout.interfaces.queue.CustomCommand
|
import info.nightscout.interfaces.queue.CustomCommand
|
||||||
import info.nightscout.interfaces.ui.UiInteraction
|
import info.nightscout.interfaces.ui.UiInteraction
|
||||||
|
import info.nightscout.interfaces.utils.Round
|
||||||
import info.nightscout.interfaces.utils.TimeChangeType
|
import info.nightscout.interfaces.utils.TimeChangeType
|
||||||
import info.nightscout.rx.AapsSchedulers
|
import info.nightscout.rx.AapsSchedulers
|
||||||
import info.nightscout.rx.bus.RxBus
|
import info.nightscout.rx.bus.RxBus
|
||||||
|
@ -44,6 +45,7 @@ import io.reactivex.rxjava3.subjects.BehaviorSubject
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
import kotlin.math.abs
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
|
@ -311,10 +313,10 @@ class EopatchPumpPlugin @Inject constructor(
|
||||||
|
|
||||||
disposable.dispose()
|
disposable.dispose()
|
||||||
|
|
||||||
return if (isSuccess && askedInsulin == detailedBolusInfo.insulin)
|
return if (isSuccess && abs(askedInsulin - detailedBolusInfo.insulin) < pumpDescription.bolusStep)
|
||||||
PumpEnactResult(injector).success(true).enacted(true).bolusDelivered(detailedBolusInfo.insulin)
|
PumpEnactResult(injector).success(true).enacted(true).bolusDelivered(askedInsulin)
|
||||||
else
|
else
|
||||||
PumpEnactResult(injector).success(false)/*.enacted(false)*/.bolusDelivered(detailedBolusInfo.insulin)
|
PumpEnactResult(injector).success(false)/*.enacted(false)*/.bolusDelivered(Round.roundTo(detailedBolusInfo.insulin, 0.01))
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// no bolus required
|
// no bolus required
|
||||||
|
|
Loading…
Reference in a new issue