LocalInsulin -> autotune
This commit is contained in:
parent
d0a240b417
commit
0442a9ae5b
|
@ -1,6 +1,5 @@
|
|||
package info.nightscout.androidaps.extensions
|
||||
|
||||
import info.nightscout.androidaps.data.LocalInsulin
|
||||
import info.nightscout.androidaps.interfaces.ActivePlugin
|
||||
import info.nightscout.androidaps.interfaces.Insulin
|
||||
import info.nightscout.database.entities.Bolus
|
||||
|
@ -10,10 +9,4 @@ fun Bolus.iobCalc(activePlugin: ActivePlugin, time: Long, dia: Double): Iob {
|
|||
if (!isValid || type == Bolus.Type.PRIMING ) return Iob()
|
||||
val insulinInterface: Insulin = activePlugin.activeInsulin
|
||||
return insulinInterface.iobCalcForTreatment(this, time, dia)
|
||||
}
|
||||
|
||||
// Add specific calculation for Autotune (reference localInsulin for Peak/dia)
|
||||
fun Bolus.iobCalc(time: Long, localInsulin: LocalInsulin): Iob {
|
||||
if (!isValid || type == Bolus.Type.PRIMING ) return Iob()
|
||||
return localInsulin.iobCalcForTreatment(this, time)
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
package info.nightscout.plugins.general.autotune
|
||||
|
||||
import info.nightscout.androidaps.data.LocalInsulin
|
||||
import info.nightscout.interfaces.utils.Round
|
||||
import info.nightscout.plugins.R
|
||||
import info.nightscout.plugins.general.autotune.data.ATProfile
|
||||
import info.nightscout.plugins.general.autotune.data.LocalInsulin
|
||||
import info.nightscout.plugins.general.autotune.data.PreppedGlucose
|
||||
import info.nightscout.plugins.utils.Percentile
|
||||
import info.nightscout.shared.sharedPreferences.SP
|
||||
import java.util.*
|
||||
import java.util.Calendar
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
import kotlin.math.max
|
||||
|
|
|
@ -19,7 +19,6 @@ import android.widget.TableRow
|
|||
import android.widget.TextView
|
||||
import dagger.android.HasAndroidInjector
|
||||
import dagger.android.support.DaggerFragment
|
||||
import info.nightscout.androidaps.data.LocalInsulin
|
||||
import info.nightscout.androidaps.data.ProfileSealed
|
||||
import info.nightscout.androidaps.dialogs.ProfileViewerDialog
|
||||
import info.nightscout.androidaps.interfaces.ActivePlugin
|
||||
|
@ -38,6 +37,7 @@ import info.nightscout.interfaces.utils.Round
|
|||
import info.nightscout.plugins.R
|
||||
import info.nightscout.plugins.databinding.AutotuneFragmentBinding
|
||||
import info.nightscout.plugins.general.autotune.data.ATProfile
|
||||
import info.nightscout.plugins.general.autotune.data.LocalInsulin
|
||||
import info.nightscout.plugins.general.autotune.events.EventAutotuneUpdateGui
|
||||
import info.nightscout.plugins.profile.ProfilePlugin
|
||||
import info.nightscout.rx.AapsSchedulers
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package info.nightscout.plugins.general.autotune
|
||||
|
||||
import info.nightscout.androidaps.data.LocalInsulin
|
||||
import info.nightscout.androidaps.extensions.durationInMinutes
|
||||
import info.nightscout.androidaps.extensions.iobCalc
|
||||
import info.nightscout.androidaps.extensions.toJson
|
||||
import info.nightscout.androidaps.extensions.toTemporaryBasal
|
||||
import info.nightscout.androidaps.interfaces.Profile
|
||||
|
@ -17,10 +15,12 @@ import info.nightscout.database.entities.TherapyEvent
|
|||
import info.nightscout.database.entities.embedments.InterfaceIDs
|
||||
import info.nightscout.database.impl.AppRepository
|
||||
import info.nightscout.interfaces.Constants
|
||||
import info.nightscout.interfaces.iob.Iob
|
||||
import info.nightscout.interfaces.iob.IobTotal
|
||||
import info.nightscout.interfaces.utils.Round
|
||||
import info.nightscout.plugins.R
|
||||
import info.nightscout.plugins.general.autotune.data.ATProfile
|
||||
import info.nightscout.plugins.general.autotune.data.LocalInsulin
|
||||
import info.nightscout.plugins.sync.nsclient.extensions.toJson
|
||||
import info.nightscout.rx.logging.AAPSLogger
|
||||
import info.nightscout.rx.logging.LTag
|
||||
|
@ -247,6 +247,11 @@ open class AutotuneIob @Inject constructor(
|
|||
open fun getIOB(time: Long, localInsulin: LocalInsulin): IobTotal =
|
||||
getCalculationToTimeTreatments(time, localInsulin).round()
|
||||
|
||||
// Add specific calculation for Autotune (reference localInsulin for Peak/dia)
|
||||
fun Bolus.iobCalc(time: Long, localInsulin: LocalInsulin): Iob {
|
||||
if (!isValid || type == Bolus.Type.PRIMING ) return Iob()
|
||||
return localInsulin.iobCalcForTreatment(this, time)
|
||||
}
|
||||
private fun getCalculationToTimeTreatments(time: Long, localInsulin: LocalInsulin): IobTotal {
|
||||
val total = IobTotal(time)
|
||||
val detailedLog = sp.getBoolean(R.string.key_autotune_additional_log, false)
|
||||
|
|
|
@ -2,7 +2,6 @@ package info.nightscout.plugins.general.autotune
|
|||
|
||||
import android.view.View
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.data.LocalInsulin
|
||||
import info.nightscout.androidaps.data.ProfileSealed
|
||||
import info.nightscout.androidaps.interfaces.ActivePlugin
|
||||
import info.nightscout.androidaps.interfaces.Insulin
|
||||
|
@ -22,6 +21,7 @@ import info.nightscout.interfaces.utils.JsonHelper
|
|||
import info.nightscout.interfaces.utils.MidnightTime
|
||||
import info.nightscout.plugins.R
|
||||
import info.nightscout.plugins.general.autotune.data.ATProfile
|
||||
import info.nightscout.plugins.general.autotune.data.LocalInsulin
|
||||
import info.nightscout.plugins.general.autotune.data.PreppedGlucose
|
||||
import info.nightscout.plugins.general.autotune.events.EventAutotuneUpdateGui
|
||||
import info.nightscout.plugins.profile.ProfilePlugin
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package info.nightscout.plugins.general.autotune
|
||||
|
||||
import info.nightscout.androidaps.data.LocalInsulin
|
||||
import info.nightscout.database.entities.Bolus
|
||||
import info.nightscout.database.entities.Carbs
|
||||
import info.nightscout.database.entities.GlucoseValue
|
||||
|
@ -11,6 +10,7 @@ import info.nightscout.plugins.general.autotune.data.ATProfile
|
|||
import info.nightscout.plugins.general.autotune.data.BGDatum
|
||||
import info.nightscout.plugins.general.autotune.data.CRDatum
|
||||
import info.nightscout.plugins.general.autotune.data.DiaDeviation
|
||||
import info.nightscout.plugins.general.autotune.data.LocalInsulin
|
||||
import info.nightscout.plugins.general.autotune.data.PeakDeviation
|
||||
import info.nightscout.plugins.general.autotune.data.PreppedGlucose
|
||||
import info.nightscout.shared.sharedPreferences.SP
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package info.nightscout.plugins.general.autotune.data
|
||||
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.data.LocalInsulin
|
||||
import info.nightscout.androidaps.data.ProfileSealed
|
||||
import info.nightscout.androidaps.data.PureProfile
|
||||
import info.nightscout.androidaps.extensions.blockValueBySeconds
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.androidaps.data
|
||||
package info.nightscout.plugins.general.autotune.data
|
||||
|
||||
import info.nightscout.database.entities.Bolus
|
||||
import info.nightscout.interfaces.iob.Iob
|
|
@ -2,7 +2,6 @@ package info.nightscout.plugins.general.autotune
|
|||
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.TestBaseWithProfile
|
||||
import info.nightscout.androidaps.data.LocalInsulin
|
||||
import info.nightscout.androidaps.data.ProfileSealed
|
||||
import info.nightscout.androidaps.data.PureProfile
|
||||
import info.nightscout.database.entities.data.Block
|
||||
|
@ -11,6 +10,7 @@ import info.nightscout.interfaces.GlucoseUnit
|
|||
import info.nightscout.interfaces.utils.JsonHelper
|
||||
import info.nightscout.plugins.R
|
||||
import info.nightscout.plugins.general.autotune.data.ATProfile
|
||||
import info.nightscout.plugins.general.autotune.data.LocalInsulin
|
||||
import info.nightscout.plugins.general.autotune.data.PreppedGlucose
|
||||
import info.nightscout.shared.sharedPreferences.SP
|
||||
import info.nightscout.shared.utils.DateUtil
|
||||
|
|
|
@ -2,7 +2,6 @@ package info.nightscout.plugins.general.autotune
|
|||
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.TestBaseWithProfile
|
||||
import info.nightscout.androidaps.data.LocalInsulin
|
||||
import info.nightscout.androidaps.data.ProfileSealed
|
||||
import info.nightscout.androidaps.data.PureProfile
|
||||
import info.nightscout.androidaps.extensions.shiftBlock
|
||||
|
@ -18,6 +17,7 @@ import info.nightscout.interfaces.iob.IobTotal
|
|||
import info.nightscout.interfaces.utils.JsonHelper
|
||||
import info.nightscout.plugins.R
|
||||
import info.nightscout.plugins.general.autotune.data.ATProfile
|
||||
import info.nightscout.plugins.general.autotune.data.LocalInsulin
|
||||
import info.nightscout.plugins.general.autotune.data.PreppedGlucose
|
||||
import info.nightscout.rx.logging.AAPSLogger
|
||||
import info.nightscout.shared.sharedPreferences.SP
|
||||
|
|
Loading…
Reference in a new issue