Abort Autotune Run if no valid profile on first selected day
This commit is contained in:
parent
f22c8ca642
commit
0af05deae9
2 changed files with 13 additions and 4 deletions
|
@ -35,10 +35,8 @@ open class AutotuneIob @Inject constructor(
|
|||
private val profileFunction: ProfileFunction,
|
||||
private val sp: SP,
|
||||
private val dateUtil: DateUtil,
|
||||
private val activePlugin: ActivePlugin,
|
||||
private val autotuneFS: AutotuneFS
|
||||
) {
|
||||
|
||||
private var nsTreatments = ArrayList<NsTreatment>()
|
||||
private var dia: Double = Constants.defaultDIA
|
||||
var boluses: ArrayList<Bolus> = ArrayList()
|
||||
|
@ -54,7 +52,11 @@ open class AutotuneIob @Inject constructor(
|
|||
startBG = from
|
||||
endBG = to
|
||||
nsTreatments.clear()
|
||||
meals.clear()
|
||||
boluses.clear()
|
||||
tempBasals = ArrayList<TemporaryBasal>()
|
||||
if (profileFunction.getProfile(from - range()) == null)
|
||||
return
|
||||
initializeBgreadings(from, to)
|
||||
initializeTreatmentData(from - range(), to)
|
||||
initializeTempBasalData(from - range(), to, tunedProfile)
|
||||
|
@ -91,8 +93,6 @@ open class AutotuneIob @Inject constructor(
|
|||
aapsLogger.debug(LTag.AUTOTUNE, "Check BG date: BG Size: " + glucose.size + " OldestBG: " + dateUtil.dateAndTimeAndSecondsString(oldestBgDate) + " to: " + dateUtil.dateAndTimeAndSecondsString(to))
|
||||
val tmpCarbs = repository.getCarbsDataFromTimeToTimeExpanded(from, to, false).blockingGet()
|
||||
aapsLogger.debug(LTag.AUTOTUNE, "Nb treatments after query: " + tmpCarbs.size)
|
||||
meals.clear()
|
||||
boluses.clear()
|
||||
var nbCarbs = 0
|
||||
for (i in tmpCarbs.indices) {
|
||||
val tp = tmpCarbs[i]
|
||||
|
|
|
@ -134,6 +134,15 @@ class AutotunePlugin @Inject constructor(
|
|||
log("Tune day " + (i + 1) + " of " + daysBack)
|
||||
tunedProfile?.let { it ->
|
||||
autotuneIob.initializeData(from, to, it) //autotuneIob contains BG and Treatments data from history (<=> query for ns-treatments and ns-entries)
|
||||
if (autotuneIob.boluses.size == 0) {
|
||||
result = rh.gs(R.string.autotune_error)
|
||||
log("No basal data on day ${i + 1}")
|
||||
autotuneFS.exportResult(result)
|
||||
autotuneFS.exportLogAndZip(lastRun)
|
||||
rxBus.send(EventAutotuneUpdateGui())
|
||||
calculationRunning = false
|
||||
return
|
||||
}
|
||||
autotuneFS.exportEntries(autotuneIob) //<=> ns-entries.yyyymmdd.json files exported for results compare with oref0 autotune on virtual machine
|
||||
autotuneFS.exportTreatments(autotuneIob) //<=> ns-treatments.yyyymmdd.json files exported for results compare with oref0 autotune on virtual machine (include treatments ,tempBasal and extended
|
||||
preppedGlucose = autotunePrep.categorize(it) //<=> autotune.yyyymmdd.json files exported for results compare with oref0 autotune on virtual machine
|
||||
|
|
Loading…
Reference in a new issue