AutotuneIob open class for unit test

This commit is contained in:
Philoul 2022-06-25 00:21:59 +02:00
parent 4e8d057979
commit 17ca068d36
2 changed files with 5 additions and 5 deletions

View file

@ -29,7 +29,7 @@ import kotlin.math.ceil
import kotlin.math.roundToInt import kotlin.math.roundToInt
@Singleton @Singleton
class AutotuneIob @Inject constructor( open class AutotuneIob @Inject constructor(
private val aapsLogger: AAPSLogger, private val aapsLogger: AAPSLogger,
private val repository: AppRepository, private val repository: AppRepository,
private val profileFunction: ProfileFunction, private val profileFunction: ProfileFunction,
@ -41,10 +41,10 @@ class AutotuneIob @Inject constructor(
private val nsTreatments = ArrayList<NsTreatment>() private val nsTreatments = ArrayList<NsTreatment>()
private var dia: Double = Constants.defaultDIA private var dia: Double = Constants.defaultDIA
var boluses: MutableList<Bolus> = ArrayList() var boluses: ArrayList<Bolus> = ArrayList()
var meals = ArrayList<Carbs>() var meals = ArrayList<Carbs>()
lateinit var glucose: List<GlucoseValue> // newest at index 0 lateinit var glucose: List<GlucoseValue> // newest at index 0
private lateinit var tempBasals: MutableList<TemporaryBasal> private lateinit var tempBasals: ArrayList<TemporaryBasal>
var startBG: Long = 0 var startBG: Long = 0
var endBG: Long = 0 var endBG: Long = 0
private fun range(): Long = (60 * 60 * 1000L * dia + T.hours(2).msecs()).toLong() private fun range(): Long = (60 * 60 * 1000L * dia + T.hours(2).msecs()).toLong()
@ -225,7 +225,7 @@ class AutotuneIob @Inject constructor(
} }
} }
fun getIOB(time: Long, localInsulin: LocalInsulin): IobTotal { open fun getIOB(time: Long, localInsulin: LocalInsulin): IobTotal {
val bolusIob = getCalculationToTimeTreatments(time, localInsulin).round() val bolusIob = getCalculationToTimeTreatments(time, localInsulin).round()
return bolusIob return bolusIob
} }

View file

@ -302,7 +302,7 @@ class AutotunePrep @Inject constructor(
// Then, calculate carb absorption for that 5m interval using the deviation. // Then, calculate carb absorption for that 5m interval using the deviation.
if (mealCOB > 0) { if (mealCOB > 0) {
val ci = Math.max(deviation, sp.getDouble("openapsama_min_5m_carbimpact", 3.0)) val ci = Math.max(deviation, sp.getDouble(R.string.key_openapsama_min_5m_carbimpact, 3.0))
val absorbed = ci * tunedprofile.ic / sens val absorbed = ci * tunedprofile.ic / sens
// Store the COB, and use it as the starting point for the next data point. // Store the COB, and use it as the starting point for the next data point.
mealCOB = Math.max(0.0, mealCOB - absorbed) mealCOB = Math.max(0.0, mealCOB - absorbed)