diff --git a/core/interfaces/src/main/kotlin/app/aaps/core/interfaces/nsclient/ProcessedDeviceStatusData.kt b/core/interfaces/src/main/kotlin/app/aaps/core/interfaces/nsclient/ProcessedDeviceStatusData.kt index f9d69ac6e5..09fe08cb04 100644 --- a/core/interfaces/src/main/kotlin/app/aaps/core/interfaces/nsclient/ProcessedDeviceStatusData.kt +++ b/core/interfaces/src/main/kotlin/app/aaps/core/interfaces/nsclient/ProcessedDeviceStatusData.kt @@ -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 diff --git a/plugins/main/src/main/kotlin/app/aaps/plugins/main/general/overview/OverviewFragment.kt b/plugins/main/src/main/kotlin/app/aaps/plugins/main/general/overview/OverviewFragment.kt index b56f1144b2..a9a3e0f696 100644 --- a/plugins/main/src/main/kotlin/app/aaps/plugins/main/general/overview/OverviewFragment.kt +++ b/plugins/main/src/main/kotlin/app/aaps/plugins/main/general/overview/OverviewFragment.kt @@ -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) { diff --git a/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/nsclient/data/ProcessedDeviceStatusDataImpl.kt b/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/nsclient/data/ProcessedDeviceStatusDataImpl.kt index 0e6f497d42..3b60851a56 100644 --- a/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/nsclient/data/ProcessedDeviceStatusDataImpl.kt +++ b/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/nsclient/data/ProcessedDeviceStatusDataImpl.kt @@ -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 diff --git a/workflow/src/main/kotlin/app/aaps/workflow/PreparePredictionsWorker.kt b/workflow/src/main/kotlin/app/aaps/workflow/PreparePredictionsWorker.kt index ff57b7b4cf..d229c4c674 100644 --- a/workflow/src/main/kotlin/app/aaps/workflow/PreparePredictionsWorker.kt +++ b/workflow/src/main/kotlin/app/aaps/workflow/PreparePredictionsWorker.kt @@ -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