Overview: show adjusted target in NSC mode

This commit is contained in:
Milos Kozak 2023-10-30 13:54:24 +01:00
parent 238a622d5e
commit aa2ae1b99f
4 changed files with 9 additions and 7 deletions

View file

@ -2,7 +2,6 @@ package app.aaps.core.interfaces.nsclient
import android.text.Spanned
import app.aaps.core.interfaces.aps.APSResult
import dagger.android.HasAndroidInjector
import org.json.JSONObject
interface ProcessedDeviceStatusData {
@ -61,7 +60,7 @@ interface ProcessedDeviceStatusData {
val extendedOpenApsStatus: Spanned
val openApsStatus: Spanned
val openApsTimestamp: Long
fun getAPSResult(injector: HasAndroidInjector): APSResult
fun getAPSResult(): APSResult
val uploaderStatus: String
val uploaderStatusSpanned: Spanned
val extendedUploaderStatus: Spanned

View file

@ -963,9 +963,12 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
profileUtil.toTargetRangeString(tempTarget.lowTarget, tempTarget.highTarget, GlucoseUnit.MGDL, units) + " " + dateUtil.untilString(tempTarget.end, rh)
)
} else {
// If the target is not the same as set in the profile then oref has overridden it
profileFunction.getProfile()?.let { profile ->
val targetUsed = loop.lastRun?.constraintsProcessed?.targetBG ?: 0.0
// If the target is not the same as set in the profile then oref has overridden it
val targetUsed =
if (config.APS) loop.lastRun?.constraintsProcessed?.targetBG ?: 0.0
else if (config.NSCLIENT) JsonHelper.safeGetDouble(processedDeviceStatusData.getAPSResult().json, "targetBg")
else 0.0
if (targetUsed != 0.0 && abs(profile.getTargetMgdl() - targetUsed) > 0.01) {
aapsLogger.debug("Adjusted target. Profile: ${profile.getTargetMgdl()} APS: $targetUsed")
@ -1111,7 +1114,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
val isfMgdl = profile?.getIsfMgdl()
val variableSens =
if (config.APS && request is VariableSensitivityResult) request.variableSens ?: 0.0
else if (config.NSCLIENT) JsonHelper.safeGetDouble(processedDeviceStatusData.getAPSResult(injector).json, "variable_sens")
else if (config.NSCLIENT) JsonHelper.safeGetDouble(processedDeviceStatusData.getAPSResult().json, "variable_sens")
else 0.0
if (variableSens != isfMgdl && variableSens != 0.0 && isfMgdl != null) {

View file

@ -116,7 +116,7 @@ class ProcessedDeviceStatusDataImpl @Inject constructor(
override val openApsTimestamp: Long
get() = if (openAPSData.clockSuggested != 0L) openAPSData.clockSuggested else -1
override fun getAPSResult(injector: HasAndroidInjector): APSResult =
override fun getAPSResult(): APSResult =
instantiator.provideAPSResultObject().also {
it.json = openAPSData.suggested
it.date = openAPSData.clockSuggested

View file

@ -51,7 +51,7 @@ class PreparePredictionsWorker(
val data = dataWorkerStorage.pickupObject(inputData.getLong(DataWorkerStorage.STORE_KEY, -1)) as PreparePredictionsData?
?: return Result.failure(workDataOf("Error" to "missing input data"))
val apsResult = if (config.APS) loop.lastRun?.constraintsProcessed else processedDeviceStatusData.getAPSResult(injector)
val apsResult = if (config.APS) loop.lastRun?.constraintsProcessed else processedDeviceStatusData.getAPSResult()
val predictionsAvailable = if (config.APS) loop.lastRun?.request?.hasPredictions == true else config.NSCLIENT
val menuChartSettings = overviewMenus.setting
// align to hours