Enabled only in dev and Engineering mode

This commit is contained in:
Philoul 2022-05-06 11:58:39 +02:00
parent a12e1079b1
commit 4b2fda3278
5 changed files with 12 additions and 19 deletions

View file

@ -36,7 +36,6 @@ import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.MidnightTime
import info.nightscout.androidaps.utils.Round
import info.nightscout.androidaps.utils.alertDialogs.OKDialog.showConfirmation
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
import info.nightscout.shared.SafeParse
import info.nightscout.shared.sharedPreferences.SP
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
@ -60,7 +59,6 @@ class AutotuneFragment : DaggerFragment() {
@Inject lateinit var uel: UserEntryLogger
@Inject lateinit var rh: ResourceHelper
@Inject lateinit var rxBus: RxBus
@Inject lateinit var buildHelper: BuildHelper
@Inject lateinit var injector: HasAndroidInjector
private var disposable: CompositeDisposable = CompositeDisposable()
@ -305,21 +303,17 @@ class AutotuneFragment : DaggerFragment() {
binding.tuneWarning.text = rh.gs(R.string.autotune_warning_during_run)
}
autotunePlugin.lastRunSuccess -> {
if (buildHelper.isEngineeringMode()) {
binding.autotuneCopylocal.visibility = View.VISIBLE
binding.autotuneUpdateProfile.visibility = autotunePlugin.updateButtonVisibility
binding.autotuneRevertProfile.visibility = if (autotunePlugin.updateButtonVisibility == View.VISIBLE) View.GONE else View.VISIBLE
binding.autotuneProfileswitch.visibility = View.VISIBLE
binding.tuneWarning.text = rh.gs(R.string.autotune_warning_after_run)
} else
binding.tuneWarning.text = rh.gs(R.string.autotune_engineering_mode_warning)
binding.autotuneCompare.visibility = View.VISIBLE
}
buildHelper.isDev() -> {
else -> {
binding.autotuneRun.visibility = View.VISIBLE
binding.autotuneCheckInputProfile.visibility = View.VISIBLE
}
else -> binding.tuneWarning.text = rh.gs(R.string.autotune_dev_warning)
}
binding.tuneLastrun.text = dateUtil.dateAndTimeString(autotunePlugin.lastRun)
showResults()

View file

@ -18,6 +18,7 @@ import info.nightscout.androidaps.plugins.profile.local.events.EventLocalProfile
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.MidnightTime
import info.nightscout.androidaps.utils.T
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.sharedPreferences.SP
import org.json.JSONException
@ -48,6 +49,7 @@ class AutotunePlugin @Inject constructor(
private val autotuneIob: AutotuneIob,
private val autotunePrep: AutotunePrep,
private val autotuneCore: AutotuneCore,
private val buildHelper:BuildHelper,
private val uel: UserEntryLogger,
aapsLogger: AAPSLogger
) : PluginBase(PluginDescription()
@ -295,6 +297,8 @@ class AutotunePlugin @Inject constructor(
atLog("[Plugin] $message")
}
override fun specialEnableCondition(): Boolean = buildHelper.isEngineeringMode() && buildHelper.isDev()
override fun atLog(message: String) {
autotuneFS.atLog(message)
}

View file

@ -332,7 +332,7 @@ class AutomationPlugin @Inject constructor(
ActionCarePortalEvent(injector),
ActionProfileSwitchPercent(injector),
ActionProfileSwitch(injector),
ActionRunAutotune(injector),
//ActionRunAutotune(injector),
ActionSendSMS(injector)
)
}

View file

@ -44,15 +44,12 @@ class ActionRunAutotune(injector: HasAndroidInjector) : Action(injector) {
val profileName = if (inputProfileName.value == rh.gs(R.string.active)) "" else inputProfileName.value
var message = if (autoSwitch) R.string.autotune_run_with_autoswitch else R.string.autotune_run_without_autoswitch
Thread {
if (buildHelper.isDev()) {
autotunePlugin.atLog("[Automation] Run Autotune $profileName, ${daysBack.value} days, Autoswitch $autoSwitch")
autotunePlugin.aapsAutotune(daysBack.value, autoSwitch, profileName)
if (!autotunePlugin.lastRunSuccess) {
message = R.string.autotune_run_with_error
aapsLogger.error(LTag.AUTOMATION, "Error during Autotune Run")
}
} else
message = R.string.autotune_dev_warning
autotunePlugin.atLog("[Automation] Run Autotune $profileName, ${daysBack.value} days, Autoswitch $autoSwitch")
autotunePlugin.aapsAutotune(daysBack.value, autoSwitch, profileName)
if (!autotunePlugin.lastRunSuccess) {
message = R.string.autotune_run_with_error
aapsLogger.error(LTag.AUTOMATION, "Error during Autotune Run")
}
callback.result(PumpEnactResult(injector).success(autotunePlugin.lastRunSuccess).comment(message))?.run()
}.start()
return

View file

@ -566,8 +566,6 @@
<string name="autotune_last_run">Last run :</string>
<string name="autotune_warning">Warning :</string>
<string name="autotune_select_profile">Select profile to tune</string>
<string name="autotune_dev_warning">You can currently only run Autotune on dev builds of AAPS</string>
<string name="autotune_engineering_mode_warning">Copy or Activate Tuned profile is only available in engineering mode</string>
<string name="autotune_ic_warning">Autotune works with only one IC value, your profile has %1$d values. Average value is %2$.2fg/U</string>
<string name="autotune_isf_warning">Autotune works with only one ISF value, your profile has %1$d values. Average value is %2$.1f%3$s/U</string>
<string name="autotune_error">Error in input data, try to run again autotune or reduce the number of days</string>