diff --git a/app/src/main/assets/OpenAPSAMA/determine-basal.js b/app/src/main/assets/OpenAPSAMA/determine-basal.js index 4e052e8e01..e31fb90a28 100644 --- a/app/src/main/assets/OpenAPSAMA/determine-basal.js +++ b/app/src/main/assets/OpenAPSAMA/determine-basal.js @@ -324,7 +324,7 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ rT.reason += ", but Min. Delta " + minDelta.toFixed(2) + " > Exp. Delta " + expectedDelta; } if (currenttemp.duration > 15 && (round_basal(basal, profile) === round_basal(currenttemp.rate, profile))) { - rT.reason += ", temp " + currenttemp.rate + " ~ req " + basal + "U/hr"; + rT.reason += ", temp " + currenttemp.rate + " ~ req " + round(basal, 2) + "U/hr"; return rT; } else { rT.reason += "; setting current basal of " + round(basal, 2) + " as temp"; @@ -367,10 +367,10 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ return tempBasalFunctions.setTempBasal(rate, 30, profile, rT, currenttemp); } if (typeof currenttemp.rate !== 'undefined' && (currenttemp.duration > 5 && rate >= currenttemp.rate * 0.8)) { - rT.reason += ", temp " + currenttemp.rate + " ~< req " + rate + "U/hr"; + rT.reason += ", temp " + (currenttemp.rate).toFixed(3) + " ~< req " + round(rate, 2) + "U/hr"; return rT; } else { - rT.reason += ", setting " + rate + "U/hr"; + rT.reason += ", setting " + round(rate, 2) + "U/hr"; return tempBasalFunctions.setTempBasal(rate, 30, profile, rT, currenttemp); } } @@ -476,22 +476,22 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ var insulinScheduled = currenttemp.duration * (currenttemp.rate - basal) / 60; if (insulinScheduled >= insulinReq * 2) { // if current temp would deliver >2x more than the required insulin, lower the rate - rT.reason += currenttemp.duration + "m@" + (currenttemp.rate - basal).toFixed(3) + " = " + insulinScheduled.toFixed(3) + " > 2 * req " + insulinReq + ". Setting temp basal of " + rate + "U/hr"; + rT.reason += currenttemp.duration + "m@" + (currenttemp.rate - basal).toFixed(3) + " = " + insulinScheduled.toFixed(3) + " > 2 * req " + insulinReq + ". Setting temp basal of " + round(rate, 2) + "U/hr"; return tempBasalFunctions.setTempBasal(rate, 30, profile, rT, currenttemp); } if (typeof currenttemp.duration == 'undefined' || currenttemp.duration == 0) { // no temp is set - rT.reason += "no temp, setting " + rate + "U/hr"; + rT.reason += "no temp, setting " + round(rate, 2) + "U/hr"; return tempBasalFunctions.setTempBasal(rate, 30, profile, rT, currenttemp); } if (currenttemp.duration > 5 && (round_basal(rate, profile) <= round_basal(currenttemp.rate, profile))) { // if required temp <~ existing temp basal - rT.reason += "temp " + currenttemp.rate + " >~ req " + rate + "U/hr"; + rT.reason += "temp " + (currenttemp.rate).toFixed(3) + " >~ req " + round(rate, 2) + "U/hr"; return rT; } // required temp > existing temp basal - rT.reason += "temp " + currenttemp.rate + "<" + rate + "U/hr"; + rT.reason += "temp " + (currenttemp.rate).toFixed(3) + " < " + round(rate, 2) + "U/hr"; return tempBasalFunctions.setTempBasal(rate, 30, profile, rT, currenttemp); } diff --git a/app/src/main/assets/OpenAPSSMB/determine-basal.js b/app/src/main/assets/OpenAPSSMB/determine-basal.js index f7d952f141..f69317bfa6 100644 --- a/app/src/main/assets/OpenAPSSMB/determine-basal.js +++ b/app/src/main/assets/OpenAPSSMB/determine-basal.js @@ -955,7 +955,7 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ return tempBasalFunctions.setTempBasal(rate, 30, profile, rT, currenttemp); } if (typeof currenttemp.rate !== 'undefined' && (currenttemp.duration > 5 && rate >= currenttemp.rate * 0.8)) { - rT.reason += ", temp " + currenttemp.rate + " ~< req " + rate + "U/hr. "; + rT.reason += ", temp " + currenttemp.rate + " ~< req " + round(rate, 2) + "U/hr. "; return rT; } else { // calculate a long enough zero temp to eventually correct back up to target @@ -976,7 +976,7 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ return tempBasalFunctions.setTempBasal(rate, durationReq, profile, rT, currenttemp); } } else { - rT.reason += ", setting " + rate + "U/hr. "; + rT.reason += ", setting " + round(rate, 2) + "U/hr. "; } return tempBasalFunctions.setTempBasal(rate, 30, profile, rT, currenttemp); } @@ -1143,22 +1143,22 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ insulinScheduled = currenttemp.duration * (currenttemp.rate - basal) / 60; if (insulinScheduled >= insulinReq * 2) { // if current temp would deliver >2x more than the required insulin, lower the rate - rT.reason += currenttemp.duration + "m@" + (currenttemp.rate).toFixed(2) + " > 2 * insulinReq. Setting temp basal of " + rate + "U/hr. "; + rT.reason += currenttemp.duration + "m@" + (currenttemp.rate).toFixed(2) + " > 2 * insulinReq. Setting temp basal of " + round(rate, 2) + "U/hr. "; return tempBasalFunctions.setTempBasal(rate, 30, profile, rT, currenttemp); } if (typeof currenttemp.duration === 'undefined' || currenttemp.duration === 0) { // no temp is set - rT.reason += "no temp, setting " + rate + "U/hr. "; + rT.reason += "no temp, setting " + round(rate, 2) + "U/hr. "; return tempBasalFunctions.setTempBasal(rate, 30, profile, rT, currenttemp); } if (currenttemp.duration > 5 && (round_basal(rate, profile) <= round_basal(currenttemp.rate, profile))) { // if required temp <~ existing temp basal - rT.reason += "temp " + currenttemp.rate + " >~ req " + rate + "U/hr. "; + rT.reason += "temp " + (currenttemp.rate).toFixed(2) + " >~ req " + round(rate, 2) + "U/hr. "; return rT; } // required temp > existing temp basal - rT.reason += "temp " + currenttemp.rate + "<" + rate + "U/hr. "; + rT.reason += "temp " + (currenttemp.rate).toFixed(2) + " < " + round(rate, 2) + "U/hr. "; return tempBasalFunctions.setTempBasal(rate, 30, profile, rT, currenttemp); } diff --git a/app/src/main/assets/OpenAPSSMBDynamicISF/determine-basal.js b/app/src/main/assets/OpenAPSSMBDynamicISF/determine-basal.js index adaa126a8c..81b09e4730 100644 --- a/app/src/main/assets/OpenAPSSMBDynamicISF/determine-basal.js +++ b/app/src/main/assets/OpenAPSSMBDynamicISF/determine-basal.js @@ -1085,7 +1085,7 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ return tempBasalFunctions.setTempBasal(rate, 30, profile, rT, currenttemp); } if (typeof currenttemp.rate !== 'undefined' && (currenttemp.duration > 5 && rate >= currenttemp.rate * 0.8)) { - rT.reason += ", temp " + currenttemp.rate + " ~< req " + rate + "U/hr. "; + rT.reason += ", temp " + currenttemp.rate + " ~< req " + round(rate, 2) + "U/hr. "; return rT; } else { // calculate a long enough zero temp to eventually correct back up to target @@ -1106,7 +1106,7 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ return tempBasalFunctions.setTempBasal(rate, durationReq, profile, rT, currenttemp); } } else { - rT.reason += ", setting " + rate + "U/hr. "; + rT.reason += ", setting " + round(rate, 2) + "U/hr. "; } return tempBasalFunctions.setTempBasal(rate, 30, profile, rT, currenttemp); } @@ -1273,22 +1273,22 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ insulinScheduled = currenttemp.duration * (currenttemp.rate - basal) / 60; if (insulinScheduled >= insulinReq * 2) { // if current temp would deliver >2x more than the required insulin, lower the rate - rT.reason += currenttemp.duration + "m@" + (currenttemp.rate).toFixed(2) + " > 2 * insulinReq. Setting temp basal of " + rate + "U/hr. "; + rT.reason += currenttemp.duration + "m@" + (currenttemp.rate).toFixed(2) + " > 2 * insulinReq. Setting temp basal of " + round(rate, 2) + "U/hr. "; return tempBasalFunctions.setTempBasal(rate, 30, profile, rT, currenttemp); } if (typeof currenttemp.duration === 'undefined' || currenttemp.duration === 0) { // no temp is set - rT.reason += "no temp, setting " + rate + "U/hr. "; + rT.reason += "no temp, setting " + round(rate, 2) + "U/hr. "; return tempBasalFunctions.setTempBasal(rate, 30, profile, rT, currenttemp); } if (currenttemp.duration > 5 && (round_basal(rate, profile) <= round_basal(currenttemp.rate, profile))) { // if required temp <~ existing temp basal - rT.reason += "temp " + currenttemp.rate + " >~ req " + rate + "U/hr. "; + rT.reason += "temp " + (currenttemp.rate).toFixed(2) + " >~ req " + round(rate, 2) + "U/hr. "; return rT; } // required temp > existing temp basal - rT.reason += "temp " + currenttemp.rate + "<" + rate + "U/hr. "; + rT.reason += "temp " + (currenttemp.rate).toFixed(2) + " < " + round(rate, 2) + "U/hr. "; return tempBasalFunctions.setTempBasal(rate, 30, profile, rT, currenttemp); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotuneCore.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotuneCore.kt index 9bfb851952..d0dc4da9be 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotuneCore.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotuneCore.kt @@ -28,9 +28,9 @@ class AutotuneCore @Inject constructor( //console.error(isf); var carbRatio = previousAutotune.ic //console.error(carbRatio); - var csf = isf / carbRatio - var dia = previousAutotune.dia - var peak = previousAutotune.peak + val csf = isf / carbRatio + val dia = previousAutotune.dia + val peak = previousAutotune.peak val csfGlucose = preppedGlucose.csfGlucoseData val isfGlucose = preppedGlucose.isfGlucoseData val basalGlucose = preppedGlucose.basalGlucoseData diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotuneFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotuneFragment.kt index d76d870bb9..6f2af8f065 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotuneFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotuneFragment.kt @@ -87,7 +87,6 @@ class AutotuneFragment : DaggerFragment() { super.onViewCreated(view, savedInstanceState) sp.putBoolean(R.string.key_autotune_tune_insulin_curve, false) // put to false tune insulin curve sp.putBoolean(R.string.key_autotune_additional_log, false) // put to false additional log - autotunePlugin.lastRun = sp.getLong(R.string.key_autotune_last_run, 0) autotunePlugin.loadLastRun() if (autotunePlugin.lastNbDays.isEmpty()) autotunePlugin.lastNbDays = sp.getInt(R.string.key_autotune_default_tune_days, 5).toString() diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotunePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotunePlugin.kt index 5ab81d8ab6..20556987f8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotunePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotunePlugin.kt @@ -220,14 +220,15 @@ class AutotunePlugin @Inject constructor( } } } - lastRunSuccess = true - saveLastRun() - rxBus.send(EventAutotuneUpdateGui()) - calculationRunning = false + tunedProfile?.let { + lastRunSuccess = true + saveLastRun() + rxBus.send(EventAutotuneUpdateGui()) + calculationRunning = false return result } - return "No Result" // should never occurs + return rh.gs(R.string.autotune_error) } private fun showResults(tunedProfile: ATProfile?, pumpProfile: ATProfile): String {