Merge pull request #1747 from Philoul/Fix/ATCrashlytics
Fix Autotune Crashes
This commit is contained in:
commit
12466b1951
2 changed files with 8 additions and 2 deletions
|
@ -312,7 +312,8 @@ class AutotuneFragment : DaggerFragment() {
|
||||||
binding.autotuneCompare.visibility = View.VISIBLE
|
binding.autotuneCompare.visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
binding.autotuneRun.visibility = View.VISIBLE
|
if (profile.isValid)
|
||||||
|
binding.autotuneRun.visibility = View.VISIBLE
|
||||||
binding.autotuneCheckInputProfile.visibility = View.VISIBLE
|
binding.autotuneCheckInputProfile.visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -337,7 +338,8 @@ class AutotuneFragment : DaggerFragment() {
|
||||||
warning = rh.gs(R.string.profileswitch_ismissing)
|
warning = rh.gs(R.string.profileswitch_ismissing)
|
||||||
return warning
|
return warning
|
||||||
}
|
}
|
||||||
profileFunction.getProfile()?.let {
|
profileFunction.getProfile()?.let { currentProfile ->
|
||||||
|
profile = ATProfile(profileStore.getSpecificProfile(profileName)?.let { ProfileSealed.Pure(it) } ?:currentProfile, LocalInsulin(""), injector)
|
||||||
if (!profile.isValid) return rh.gs(R.string.autotune_profile_invalid)
|
if (!profile.isValid) return rh.gs(R.string.autotune_profile_invalid)
|
||||||
if (profile.icSize > 1) {
|
if (profile.icSize > 1) {
|
||||||
warning += nl + rh.gs(R.string.autotune_ic_warning, profile.icSize, profile.ic)
|
warning += nl + rh.gs(R.string.autotune_ic_warning, profile.icSize, profile.ic)
|
||||||
|
|
|
@ -235,11 +235,15 @@ class ATProfile(profile: Profile, var localInsulin: LocalInsulin, val injector:
|
||||||
isValid = profile.isValid
|
isValid = profile.isValid
|
||||||
if (isValid) {
|
if (isValid) {
|
||||||
//initialize tuned value with current profile values
|
//initialize tuned value with current profile values
|
||||||
|
var minBasal = 1.0
|
||||||
for (h in 0..23) {
|
for (h in 0..23) {
|
||||||
basal[h] = Round.roundTo(profile.basalBlocks.blockValueBySeconds(T.hours(h.toLong()).secs().toInt(), 1.0, 0), 0.001)
|
basal[h] = Round.roundTo(profile.basalBlocks.blockValueBySeconds(T.hours(h.toLong()).secs().toInt(), 1.0, 0), 0.001)
|
||||||
|
minBasal = Math.min(minBasal, basal[h])
|
||||||
}
|
}
|
||||||
ic = avgIC
|
ic = avgIC
|
||||||
isf = avgISF
|
isf = avgISF
|
||||||
|
if (ic * isf * minBasal == 0.0) // Additional validity check to avoid error later in AutotunePrep
|
||||||
|
isValid = false
|
||||||
pumpProfile = profile
|
pumpProfile = profile
|
||||||
pumpProfileAvgIC = avgIC
|
pumpProfileAvgIC = avgIC
|
||||||
pumpProfileAvgISF = avgISF
|
pumpProfileAvgISF = avgISF
|
||||||
|
|
Loading…
Reference in a new issue