Merge branch 'dev' into FixSensScale

# Conflicts:
#	app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.kt
This commit is contained in:
Philoul 2021-05-26 21:50:58 +02:00
commit 506fbde587
13 changed files with 63 additions and 113 deletions

View file

@ -15,11 +15,7 @@ import info.nightscout.androidaps.database.entities.ExtendedBolus
import info.nightscout.androidaps.database.entities.GlucoseValue
import info.nightscout.androidaps.database.entities.TemporaryBasal
import info.nightscout.androidaps.database.entities.TemporaryTarget
import info.nightscout.androidaps.extensions.convertedToPercent
import info.nightscout.androidaps.extensions.target
import info.nightscout.androidaps.extensions.toStringFull
import info.nightscout.androidaps.extensions.toStringShort
import info.nightscout.androidaps.extensions.valueToUnits
import info.nightscout.androidaps.extensions.*
import info.nightscout.androidaps.interfaces.*
import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag
@ -152,6 +148,7 @@ class OverviewData @Inject constructor(
val temporaryBasalText: String
get() =
profile?.let { profile ->
if (temporaryBasal?.isInProgress == false) temporaryBasal = null
temporaryBasal?.let { "T:" + it.toStringShort() }
?: resourceHelper.gs(R.string.pump_basebasalrate, profile.getBasal())
} ?: resourceHelper.gs(R.string.notavailable)
@ -191,7 +188,10 @@ class OverviewData @Inject constructor(
val extendedBolusText: String
get() =
extendedBolus?.let { extendedBolus ->
if (activePlugin.activePump.isFakingTempsByExtendedBoluses) resourceHelper.gs(R.string.pump_basebasalrate, extendedBolus.rate)
if (!extendedBolus.isInProgress(dateUtil)) {
this@OverviewData.extendedBolus = null
""
} else if (activePlugin.activePump.isFakingTempsByExtendedBoluses) resourceHelper.gs(R.string.pump_basebasalrate, extendedBolus.rate)
else ""
} ?: ""

View file

@ -38,6 +38,7 @@ import info.nightscout.androidaps.events.EventPreferenceChange
import info.nightscout.androidaps.events.EventPumpStatusChanged
import info.nightscout.androidaps.events.EventRefreshOverview
import info.nightscout.androidaps.extensions.directionToIcon
import info.nightscout.androidaps.extensions.isInProgress
import info.nightscout.androidaps.extensions.toVisibility
import info.nightscout.androidaps.extensions.valueToUnitsString
import info.nightscout.androidaps.interfaces.*
@ -702,6 +703,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
OverviewData.Property.TEMPORARY_TARGET -> {
// temp target
if (overviewData.temporaryTarget?.isInProgress(dateUtil) == false) overviewData.temporaryTarget = null
val tempTarget = overviewData.temporaryTarget
if (tempTarget != null) {
binding.loopPumpStatusLayout.tempTarget.setTextColor(resourceHelper.gc(R.color.ribbonTextWarning))

View file

@ -15,7 +15,6 @@ import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.plugins.general.overview.OverviewData
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.AreaGraphSeries
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DoubleDataPoint
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.Scale
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.TimeAsXAxisLabelFormatter
import info.nightscout.androidaps.utils.DefaultValueHelper
import info.nightscout.androidaps.utils.Round
@ -77,7 +76,7 @@ class GraphData(
addSeries(overviewData.tempBasalGraphSeries)
addSeries(overviewData.basalLineGraphSeries)
addSeries(overviewData.absoluteBasalGraphSeries)
overviewData.basalScale.setMultiplier(maxY * scale / overviewData.maxBasalValueFound)
overviewData.basalScale.multiplier = maxY * scale / overviewData.maxBasalValueFound
}
fun addTargetLine() {
@ -92,7 +91,7 @@ class GraphData(
fun addActivity(scale: Double) {
addSeries(overviewData.activitySeries)
addSeries(overviewData.activityPredictionSeries)
overviewData.actScale.setMultiplier(maxY * scale / overviewData.maxIAValue)
overviewData.actScale.multiplier = maxY * scale / overviewData.maxIAValue
}
//Function below show -BGI to be able to compare curves with deviations
@ -101,7 +100,7 @@ class GraphData(
maxY = overviewData.maxBGIValue
minY = -overviewData.maxBGIValue
}
overviewData.bgiScale.setMultiplier(maxY * scale / overviewData.maxBGIValue)
overviewData.bgiScale.multiplier = maxY * scale / overviewData.maxBGIValue
addSeries(overviewData.minusBgiSeries)
addSeries(overviewData.minusBgiHistSeries)
}
@ -112,7 +111,7 @@ class GraphData(
maxY = overviewData.maxIobValueFound
minY = -overviewData.maxIobValueFound
}
overviewData.iobScale.setMultiplier(maxY * scale / overviewData.maxIobValueFound)
overviewData.iobScale.multiplier = maxY * scale / overviewData.maxIobValueFound
addSeries(overviewData.iobSeries)
addSeries(overviewData.iobPredictions1Series)
addSeries(overviewData.iobPredictions2Series)
@ -124,7 +123,7 @@ class GraphData(
maxY = overviewData.maxIobValueFound
minY = -overviewData.maxIobValueFound
}
overviewData.iobScale.setMultiplier(maxY * scale / overviewData.maxIobValueFound)
overviewData.iobScale.multiplier = maxY * scale / overviewData.maxIobValueFound
addSeries(overviewData.absIobSeries)
}
@ -134,7 +133,7 @@ class GraphData(
maxY = overviewData.maxCobValueFound
minY = 0.0
}
overviewData.cobScale.setMultiplier(maxY * scale / overviewData.maxCobValueFound)
overviewData.cobScale.multiplier = maxY * scale / overviewData.maxCobValueFound
addSeries(overviewData.cobSeries)
addSeries(overviewData.cobMinFailOverSeries)
}
@ -145,7 +144,7 @@ class GraphData(
maxY = overviewData.maxDevValueFound
minY = -maxY
}
overviewData.devScale.setMultiplier(maxY * scale / overviewData.maxDevValueFound)
overviewData.devScale.multiplier = maxY * scale / overviewData.maxDevValueFound
addSeries(overviewData.deviationsSeries)
}
@ -154,11 +153,11 @@ class GraphData(
if (useForScale) {
maxY = 100.0 + max(overviewData.maxRatioValueFound, abs(overviewData.minRatioValueFound))
minY = 100.0 - max(overviewData.maxRatioValueFound, abs(overviewData.minRatioValueFound))
overviewData.ratioScale = Scale(100.0)
overviewData.ratioScale.setMultiplier(1.0)
overviewData.ratioScale.multiplier = 1.0
overviewData.ratioScale.shift = 100.0
} else {
overviewData.ratioScale = Scale()
overviewData.ratioScale.setMultiplier(maxY * scale / max(overviewData.maxRatioValueFound, abs(overviewData.minRatioValueFound)))
overviewData.ratioScale.multiplier = maxY * scale / max(overviewData.maxRatioValueFound, abs(overviewData.minRatioValueFound))
overviewData.ratioScale.shift = 0.0
}
addSeries(overviewData.ratioSeries)
}
@ -172,14 +171,14 @@ class GraphData(
var graphMaxY = maxY
if (isRatioScale) {
graphMaxY = maxY - 100.0
overviewData.dsMinScale = Scale(100.0)
overviewData.dsMaxScale = Scale(100.0)
overviewData.dsMinScale.shift = 100.0
overviewData.dsMaxScale.shift = 100.0
} else {
overviewData.dsMinScale = Scale()
overviewData.dsMaxScale = Scale()
overviewData.dsMinScale.shift = 0
overviewData.dsMaxScale.shift = 0
}
overviewData.dsMaxScale.setMultiplier(graphMaxY * scale / overviewData.maxFromMaxValueFound)
overviewData.dsMinScale.setMultiplier(graphMaxY * scale / overviewData.maxFromMinValueFound)
overviewData.dsMaxScale.setMultiplier = graphMaxY * scale / overviewData.maxFromMaxValueFound
overviewData.dsMinScale.setMultiplier = graphMaxY * scale / overviewData.maxFromMinValueFound
addSeries(overviewData.dsMaxSeries)
addSeries(overviewData.dsMinSeries)
}

View file

@ -12,7 +12,7 @@ buildscript {
rxkotlin_version = '2.4.0'
room_version = '2.3.0'
lifecycle_version = '2.3.1'
dagger_version = '2.35.1'
dagger_version = '2.36'
coroutinesVersion = '1.4.1'
activityVersion = '1.2.0'
fragmentktx_version = '1.3.0'

View file

@ -1,15 +0,0 @@
package info.nightscout.androidaps.db;
import java.util.concurrent.ScheduledFuture;
/**
* Created by triplem on 05.01.18.
*/
public interface ICallback {
void setPost(ScheduledFuture<?> post);
ScheduledFuture<?> getPost();
}

View file

@ -2,10 +2,10 @@ package info.nightscout.androidaps.extensions
import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.core.R
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.database.entities.TemporaryTarget
import info.nightscout.androidaps.database.entities.TherapyEvent
import info.nightscout.androidaps.interfaces.GlucoseUnit
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.androidaps.utils.JsonHelper
@ -14,6 +14,9 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper
import org.json.JSONObject
import java.util.concurrent.TimeUnit
fun TemporaryTarget.isInProgress(dateUtil: DateUtil): Boolean =
dateUtil.now() in timestamp..timestamp + duration
fun TemporaryTarget.lowValueToUnitsToString(units: GlucoseUnit): String =
if (units == GlucoseUnit.MGDL) DecimalFormatter.to0Decimal(this.lowTarget)
else DecimalFormatter.to1Decimal(this.lowTarget * Constants.MGDL_TO_MMOLL)

View file

@ -1,30 +0,0 @@
package info.nightscout.androidaps.plugins.general.overview.graphExtensions;
/**
* Created by mike on 18.10.2017.
*/
public class Scale {
private double multiplier;
private final double shift;
public Scale() {
shift = 0;
}
public Scale(double shift) {
this.shift = shift;
}
public void setMultiplier(double value) {
this.multiplier = value;
}
public double transform(double original) {
return original * multiplier + shift;
}
public double getShift() {
return shift;
}
}

View file

@ -0,0 +1,8 @@
package info.nightscout.androidaps.plugins.general.overview.graphExtensions
class Scale(var shift: Double = 0.0, var multiplier: Double = 0.0) {
fun transform(original: Double): Double {
return original * multiplier + shift
}
}

View file

@ -1,39 +0,0 @@
package info.nightscout.androidaps.plugins.iob.iobCobCalculator;
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.logging.LTag;
/**
* Created by mike on 06.01.2017.
*/
public class AutosensResult {
//default values to show when autosens algorithm is not called
public double ratio = 1d;
public double carbsAbsorbed = 0d;
public String sensResult = "autosens not available";
public String pastSensitivity = "";
public String ratioLimit = "";
public JSONObject json() {
JSONObject ret = new JSONObject();
try {
ret.put("ratio", ratio);
ret.put("ratioLimit", ratioLimit);
ret.put("pastSensitivity", pastSensitivity);
ret.put("sensResult", sensResult);
ret.put("ratio", ratio);
} catch (JSONException e) {
LoggerFactory.getLogger(LTag.CORE.getTag()).error("Unhandled exception", e);
}
return ret;
}
@Override
public String toString() {
return json().toString();
}
}

View file

@ -0,0 +1,22 @@
package info.nightscout.androidaps.plugins.iob.iobCobCalculator
import org.json.JSONObject
class AutosensResult {
//default values to show when autosens algorithm is not called
var ratio = 1.0
var carbsAbsorbed = 0.0
var sensResult = "autosens not available"
var pastSensitivity = ""
var ratioLimit = ""
fun json(): JSONObject = JSONObject()
.put("ratio", ratio)
.put("ratioLimit", ratioLimit)
.put("pastSensitivity", pastSensitivity)
.put("sensResult", sensResult)
.put("ratio", ratio)
override fun toString(): String = json().toString()
}

View file

@ -108,7 +108,7 @@ public class AutosensData implements DataPointWithLabelInterface {
@NonNull @Override
public String toString() {
return String.format(Locale.ENGLISH, "AutosensData: %s pastSensitivity=%s delta=%.02f avgDelta=%.02f bgi=%.02f deviation=%.02f avgDeviation=%.02f absorbed=%.02f carbsFromBolus=%.02f cob=%.02f autosensRatio=%.02f slopeFromMaxDeviation=%.02f slopeFromMinDeviation=%.02f activeCarbsList=%s",
dateUtil.dateAndTimeString(time), pastSensitivity, delta, avgDelta, bgi, deviation, avgDeviation, absorbed, carbsFromBolus, cob, autosensResult.ratio, slopeFromMaxDeviation, slopeFromMinDeviation, activeCarbsList.toString());
dateUtil.dateAndTimeString(time), pastSensitivity, delta, avgDelta, bgi, deviation, avgDeviation, absorbed, carbsFromBolus, cob, autosensResult.getRatio(), slopeFromMaxDeviation, slopeFromMinDeviation, activeCarbsList.toString());
}
public List<CarbsInPast> cloneCarbsList() {

View file

@ -26,7 +26,7 @@ dependencies {
implementation "io.reactivex.rxjava2:rxandroid:$rxandroid_version"
implementation("io.reactivex.rxjava2:rxkotlin:$rxkotlin_version")
implementation "com.google.code.gson:gson:2.8.6"
implementation "com.google.code.gson:gson:2.8.7"
api "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"

View file

@ -145,7 +145,7 @@ dependencies {
testImplementation "org.powermock:powermock-module-junit4-rule:${powermockVersion}"
testImplementation "org.powermock:powermock-module-junit4:${powermockVersion}"
testImplementation "joda-time:joda-time:$jodatime_version"
testImplementation('com.google.truth:truth:1.1.2') {
testImplementation('com.google.truth:truth:1.1.3') {
exclude group: "com.google.guava", module: "guava"
}
testImplementation "org.skyscreamer:jsonassert:1.5.0"