DataPointWithLabelInterface -> kt
This commit is contained in:
parent
477dca0ede
commit
090994ab51
11 changed files with 115 additions and 189 deletions
|
@ -20,18 +20,21 @@ class BolusDataPoint @Inject constructor(
|
|||
|
||||
override fun getX(): Double = data.timestamp.toDouble()
|
||||
override fun getY(): Double = if (data.type == Bolus.Type.SMB) defaultValueHelper.determineLowLine() else yValue
|
||||
override fun getLabel(): String = DecimalFormatter.toPumpSupportedBolus(data.amount, activePlugin.activePump, rh)
|
||||
override fun getDuration(): Long = 0
|
||||
override fun getSize(): Float = 2f
|
||||
override val label
|
||||
get() = DecimalFormatter.toPumpSupportedBolus(data.amount, activePlugin.activePump, rh)
|
||||
override val duration = 0L
|
||||
override val size = 2f
|
||||
|
||||
override fun getShape(): PointsWithLabelGraphSeries.Shape =
|
||||
if (data.type == Bolus.Type.SMB) PointsWithLabelGraphSeries.Shape.SMB
|
||||
else PointsWithLabelGraphSeries.Shape.BOLUS
|
||||
override val shape
|
||||
get() = if (data.type == Bolus.Type.SMB) PointsWithLabelGraphSeries.Shape.SMB else PointsWithLabelGraphSeries.Shape.BOLUS
|
||||
|
||||
override fun getColor(): Int =
|
||||
if (data.type == Bolus.Type.SMB) rh.gc(R.color.tempbasal)
|
||||
else if (data.isValid) Color.CYAN
|
||||
else rh.gc(android.R.color.holo_red_light)
|
||||
override val color
|
||||
get() =
|
||||
when {
|
||||
data.type == Bolus.Type.SMB -> rh.gc(R.color.tempbasal)
|
||||
data.isValid -> Color.CYAN
|
||||
else -> rh.gc(android.R.color.holo_red_light)
|
||||
}
|
||||
|
||||
override fun setY(y: Double) {
|
||||
yValue = y
|
||||
|
|
|
@ -14,15 +14,11 @@ class CarbsDataPoint @Inject constructor(
|
|||
|
||||
override fun getX(): Double = data.timestamp.toDouble()
|
||||
override fun getY(): Double = yValue
|
||||
override fun getLabel(): String = rh.gs(R.string.format_carbs, data.amount.toInt())
|
||||
override fun getDuration(): Long = 0
|
||||
override fun getSize(): Float = 2f
|
||||
|
||||
override fun getShape(): PointsWithLabelGraphSeries.Shape = PointsWithLabelGraphSeries.Shape.CARBS
|
||||
|
||||
override fun getColor(): Int =
|
||||
if (data.isValid) rh.gc(R.color.carbs)
|
||||
else rh.gc(android.R.color.holo_red_light)
|
||||
override val label get() = rh.gs(R.string.format_carbs, data.amount.toInt())
|
||||
override val duration = 0L
|
||||
override val size = 2f
|
||||
override val shape = PointsWithLabelGraphSeries.Shape.CARBS
|
||||
override val color get() = if (data.isValid) rh.gc(R.color.carbs) else rh.gc(android.R.color.holo_red_light)
|
||||
|
||||
override fun setY(y: Double) {
|
||||
yValue = y
|
||||
|
|
|
@ -17,9 +17,9 @@ class EffectiveProfileSwitchDataPoint @Inject constructor(
|
|||
yValue = y
|
||||
}
|
||||
|
||||
override fun getLabel(): String = data.originalCustomizedName
|
||||
override fun getDuration(): Long = 0
|
||||
override fun getShape(): PointsWithLabelGraphSeries.Shape = PointsWithLabelGraphSeries.Shape.PROFILE
|
||||
override fun getSize(): Float = 10f
|
||||
override fun getColor(): Int = Color.CYAN
|
||||
override val label get() = data.originalCustomizedName
|
||||
override val duration = 0L
|
||||
override val shape = PointsWithLabelGraphSeries.Shape.PROFILE
|
||||
override val size = 10f
|
||||
override val color = Color.CYAN
|
||||
}
|
|
@ -13,11 +13,11 @@ class ExtendedBolusDataPoint @Inject constructor(
|
|||
|
||||
override fun getX(): Double = data.timestamp.toDouble()
|
||||
override fun getY(): Double = yValue
|
||||
override fun getLabel(): String = data.toStringTotal()
|
||||
override fun getDuration(): Long = data.duration
|
||||
override fun getSize(): Float = 10f
|
||||
override fun getShape(): PointsWithLabelGraphSeries.Shape = PointsWithLabelGraphSeries.Shape.EXTENDEDBOLUS
|
||||
override fun getColor(): Int = Color.CYAN
|
||||
override val label get() = data.toStringTotal()
|
||||
override val duration get() = data.duration
|
||||
override val size = 10f
|
||||
override val shape = PointsWithLabelGraphSeries.Shape.EXTENDEDBOLUS
|
||||
override val color = Color.CYAN
|
||||
|
||||
override fun setY(y: Double) {
|
||||
yValue = y
|
||||
|
|
|
@ -19,44 +19,36 @@ class GlucoseValueDataPoint @Inject constructor(
|
|||
fun valueToUnits(units: GlucoseUnit): Double =
|
||||
if (units == GlucoseUnit.MGDL) data.value else data.value * Constants.MGDL_TO_MMOLL
|
||||
|
||||
override fun getX(): Double {
|
||||
return data.timestamp.toDouble()
|
||||
}
|
||||
|
||||
override fun getY(): Double {
|
||||
return valueToUnits(profileFunction.getUnits())
|
||||
}
|
||||
override fun getX(): Double = data.timestamp.toDouble()
|
||||
override fun getY(): Double = valueToUnits(profileFunction.getUnits())
|
||||
|
||||
override fun setY(y: Double) {}
|
||||
override fun getLabel(): String? = null
|
||||
override fun getDuration(): Long = 0
|
||||
override fun getShape(): PointsWithLabelGraphSeries.Shape =
|
||||
if (isPrediction) PointsWithLabelGraphSeries.Shape.PREDICTION
|
||||
else PointsWithLabelGraphSeries.Shape.BG
|
||||
|
||||
override fun getSize(): Float = 1f
|
||||
|
||||
override fun getColor(): Int {
|
||||
val units = profileFunction.getUnits()
|
||||
val lowLine = defaultValueHelper.determineLowLine()
|
||||
val highLine = defaultValueHelper.determineHighLine()
|
||||
return when {
|
||||
isPrediction -> predictionColor
|
||||
valueToUnits(units) < lowLine -> rh.gc(R.color.low)
|
||||
valueToUnits(units) > highLine -> rh.gc(R.color.high)
|
||||
else -> rh.gc(R.color.inrange)
|
||||
override val label: String? = null
|
||||
override val duration = 0L
|
||||
override val shape get() = if (isPrediction) PointsWithLabelGraphSeries.Shape.PREDICTION else PointsWithLabelGraphSeries.Shape.BG
|
||||
override val size = 1f
|
||||
override val color: Int
|
||||
get() {
|
||||
val units = profileFunction.getUnits()
|
||||
val lowLine = defaultValueHelper.determineLowLine()
|
||||
val highLine = defaultValueHelper.determineHighLine()
|
||||
return when {
|
||||
isPrediction -> predictionColor
|
||||
valueToUnits(units) < lowLine -> rh.gc(R.color.low)
|
||||
valueToUnits(units) > highLine -> rh.gc(R.color.high)
|
||||
else -> rh.gc(R.color.inrange)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val predictionColor: Int
|
||||
get() {
|
||||
return when (data.sourceSensor) {
|
||||
GlucoseValue.SourceSensor.IOB_PREDICTION -> rh.gc(R.color.iob)
|
||||
GlucoseValue.SourceSensor.IOB_PREDICTION -> rh.gc(R.color.iob)
|
||||
GlucoseValue.SourceSensor.COB_PREDICTION -> rh.gc(R.color.cob)
|
||||
GlucoseValue.SourceSensor.A_COB_PREDICTION -> -0x7f000001 and rh.gc(R.color.cob)
|
||||
GlucoseValue.SourceSensor.UAM_PREDICTION -> rh.gc(R.color.uam)
|
||||
GlucoseValue.SourceSensor.ZT_PREDICTION -> rh.gc(R.color.zt)
|
||||
else -> R.color.white
|
||||
GlucoseValue.SourceSensor.ZT_PREDICTION -> rh.gc(R.color.zt)
|
||||
else -> R.color.white
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,9 +20,9 @@ class InMemoryGlucoseValueDataPoint @Inject constructor(
|
|||
override fun getX(): Double = data.timestamp.toDouble()
|
||||
override fun getY(): Double = valueToUnits(profileFunction.getUnits())
|
||||
override fun setY(y: Double) {}
|
||||
override fun getLabel(): String? = null
|
||||
override fun getDuration(): Long = 0
|
||||
override fun getShape(): PointsWithLabelGraphSeries.Shape = PointsWithLabelGraphSeries.Shape.BUCKETED_BG
|
||||
override fun getSize(): Float = 0.3f
|
||||
override fun getColor(): Int = rh.gc(R.color.white)
|
||||
override val label: String? = null
|
||||
override val duration = 0L
|
||||
override val shape = PointsWithLabelGraphSeries.Shape.BUCKETED_BG
|
||||
override val size = 0.3f
|
||||
override val color get() = rh.gc(R.color.white)
|
||||
}
|
|
@ -19,9 +19,7 @@ class TherapyEventDataPoint @Inject constructor(
|
|||
|
||||
private var yValue = 0.0
|
||||
|
||||
override fun getX(): Double {
|
||||
return data.timestamp.toDouble()
|
||||
}
|
||||
override fun getX(): Double = data.timestamp.toDouble()
|
||||
|
||||
override fun getY(): Double {
|
||||
val units = profileFunction.getUnits()
|
||||
|
@ -46,30 +44,29 @@ class TherapyEventDataPoint @Inject constructor(
|
|||
yValue = y
|
||||
}
|
||||
|
||||
override fun getLabel(): String? =
|
||||
if (data.note.isNullOrBlank().not()) data.note
|
||||
else translator.translate(data.type)
|
||||
override val label get() = if (data.note.isNullOrBlank().not()) data.note else translator.translate(data.type)
|
||||
override val duration get() = data.duration
|
||||
override val shape
|
||||
get() =
|
||||
when {
|
||||
data.type == TherapyEvent.Type.NS_MBG -> PointsWithLabelGraphSeries.Shape.MBG
|
||||
data.type == TherapyEvent.Type.FINGER_STICK_BG_VALUE -> PointsWithLabelGraphSeries.Shape.BGCHECK
|
||||
data.type == TherapyEvent.Type.ANNOUNCEMENT -> PointsWithLabelGraphSeries.Shape.ANNOUNCEMENT
|
||||
data.type == TherapyEvent.Type.APS_OFFLINE -> PointsWithLabelGraphSeries.Shape.OPENAPSOFFLINE
|
||||
data.type == TherapyEvent.Type.EXERCISE -> PointsWithLabelGraphSeries.Shape.EXERCISE
|
||||
duration > 0 -> PointsWithLabelGraphSeries.Shape.GENERALWITHDURATION
|
||||
else -> PointsWithLabelGraphSeries.Shape.GENERAL
|
||||
}
|
||||
|
||||
override fun getDuration(): Long = data.duration
|
||||
override fun getShape(): PointsWithLabelGraphSeries.Shape =
|
||||
when {
|
||||
data.type == TherapyEvent.Type.NS_MBG -> PointsWithLabelGraphSeries.Shape.MBG
|
||||
data.type == TherapyEvent.Type.FINGER_STICK_BG_VALUE -> PointsWithLabelGraphSeries.Shape.BGCHECK
|
||||
data.type == TherapyEvent.Type.ANNOUNCEMENT -> PointsWithLabelGraphSeries.Shape.ANNOUNCEMENT
|
||||
data.type == TherapyEvent.Type.APS_OFFLINE -> PointsWithLabelGraphSeries.Shape.OPENAPSOFFLINE
|
||||
data.type == TherapyEvent.Type.EXERCISE -> PointsWithLabelGraphSeries.Shape.EXERCISE
|
||||
duration > 0 -> PointsWithLabelGraphSeries.Shape.GENERALWITHDURATION
|
||||
else -> PointsWithLabelGraphSeries.Shape.GENERAL
|
||||
}
|
||||
|
||||
override fun getSize(): Float = if (rh.gb(R.bool.isTablet)) 12.0f else 10.0f
|
||||
override fun getColor(): Int =
|
||||
when (data.type) {
|
||||
TherapyEvent.Type.ANNOUNCEMENT -> rh.gc(R.color.notificationAnnouncement)
|
||||
TherapyEvent.Type.NS_MBG -> Color.RED
|
||||
TherapyEvent.Type.FINGER_STICK_BG_VALUE -> Color.RED
|
||||
TherapyEvent.Type.EXERCISE -> Color.BLUE
|
||||
TherapyEvent.Type.APS_OFFLINE -> Color.GRAY and -0x7f000001
|
||||
else -> Color.GRAY
|
||||
}
|
||||
override val size get() = if (rh.gb(R.bool.isTablet)) 12.0f else 10.0f
|
||||
override val color
|
||||
get() =
|
||||
when (data.type) {
|
||||
TherapyEvent.Type.ANNOUNCEMENT -> rh.gc(R.color.notificationAnnouncement)
|
||||
TherapyEvent.Type.NS_MBG -> Color.RED
|
||||
TherapyEvent.Type.FINGER_STICK_BG_VALUE -> Color.RED
|
||||
TherapyEvent.Type.EXERCISE -> Color.BLUE
|
||||
TherapyEvent.Type.APS_OFFLINE -> Color.GRAY and -0x7f000001
|
||||
else -> Color.GRAY
|
||||
}
|
||||
}
|
|
@ -664,13 +664,15 @@ public class WatchUpdaterService extends WearableListenerService implements Goog
|
|||
IobTotal bolusIob = iobCobCalculator.calculateIobFromBolus().round();
|
||||
IobTotal basalIob = iobCobCalculator.calculateIobFromTempBasalsIncludingConvertedExtended().round();
|
||||
|
||||
iobSum = DecimalFormatter.INSTANCE.to2Decimal(bolusIob.iob + basalIob.basaliob);
|
||||
iobDetail = "(" + DecimalFormatter.INSTANCE.to2Decimal(bolusIob.iob) + "|" + DecimalFormatter.INSTANCE.to2Decimal(basalIob.basaliob) + ")";
|
||||
iobSum = DecimalFormatter.INSTANCE.to2Decimal(bolusIob.getIob() + basalIob.getBasaliob());
|
||||
iobDetail =
|
||||
"(" + DecimalFormatter.INSTANCE.to2Decimal(bolusIob.getIob()) + "|" + DecimalFormatter.INSTANCE.to2Decimal(basalIob.getBasaliob()) + ")";
|
||||
cobString = iobCobCalculator.getCobInfo(false, "WatcherUpdaterService").generateCOBString();
|
||||
currentBasal = generateBasalString();
|
||||
|
||||
//bgi
|
||||
double bgi = -(bolusIob.activity + basalIob.activity) * 5 * Profile.Companion.fromMgdlToUnits(profile.getIsfMgdl(), profileFunction.getUnits());
|
||||
double bgi =
|
||||
-(bolusIob.getActivity() + basalIob.getActivity()) * 5 * Profile.Companion.fromMgdlToUnits(profile.getIsfMgdl(), profileFunction.getUnits());
|
||||
bgiString = "" + ((bgi >= 0) ? "+" : "") + DecimalFormatter.INSTANCE.to1Decimal(bgi);
|
||||
|
||||
status = generateStatusString(profile, currentBasal, iobSum, iobDetail, bgiString);
|
||||
|
|
|
@ -10,18 +10,18 @@ import org.json.JSONObject
|
|||
@Suppress("SpellCheckingInspection")
|
||||
class IobTotal(val time: Long) : DataPointWithLabelInterface {
|
||||
|
||||
@JvmField var iob = 0.0
|
||||
@JvmField var activity = 0.0
|
||||
@JvmField var bolussnooze = 0.0
|
||||
@JvmField var basaliob = 0.0
|
||||
@JvmField var netbasalinsulin = 0.0
|
||||
@JvmField var hightempinsulin = 0.0
|
||||
var iob = 0.0
|
||||
var activity = 0.0
|
||||
var bolussnooze = 0.0
|
||||
var basaliob = 0.0
|
||||
var netbasalinsulin = 0.0
|
||||
var hightempinsulin = 0.0
|
||||
|
||||
// oref1
|
||||
@JvmField var lastBolusTime: Long = 0
|
||||
var lastBolusTime: Long = 0
|
||||
var iobWithZeroTemp: IobTotal? = null
|
||||
@JvmField var netInsulin = 0.0 // for calculations from temp basals only
|
||||
@JvmField var extendedBolusInsulin = 0.0 // total insulin for extended bolus
|
||||
var netInsulin = 0.0 // for calculations from temp basals only
|
||||
var extendedBolusInsulin = 0.0 // total insulin for extended bolus
|
||||
fun copy(): IobTotal {
|
||||
val i = IobTotal(time)
|
||||
i.iob = iob
|
||||
|
@ -104,36 +104,14 @@ class IobTotal(val time: Long) : DataPointWithLabelInterface {
|
|||
}
|
||||
|
||||
// DataPoint interface
|
||||
private var color = 0
|
||||
override fun getX(): Double {
|
||||
return time.toDouble()
|
||||
}
|
||||
|
||||
override fun getY(): Double {
|
||||
return iob
|
||||
}
|
||||
|
||||
override var color = 0
|
||||
override fun getX(): Double = time.toDouble()
|
||||
override fun getY(): Double = iob
|
||||
override fun setY(y: Double) {}
|
||||
|
||||
override fun getLabel(): String {
|
||||
return ""
|
||||
}
|
||||
|
||||
override fun getDuration(): Long {
|
||||
return 0
|
||||
}
|
||||
|
||||
override fun getShape(): PointsWithLabelGraphSeries.Shape {
|
||||
return PointsWithLabelGraphSeries.Shape.IOBPREDICTION
|
||||
}
|
||||
|
||||
override fun getSize(): Float {
|
||||
return 0.5f
|
||||
}
|
||||
|
||||
override fun getColor(): Int {
|
||||
return color
|
||||
}
|
||||
override val label = ""
|
||||
override val duration = 0L
|
||||
override val shape = PointsWithLabelGraphSeries.Shape.IOBPREDICTION
|
||||
override val size = 0.5f
|
||||
|
||||
fun setColor(color: Int): IobTotal {
|
||||
this.color = color
|
||||
|
|
|
@ -1,58 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.general.overview.graphExtensions;
|
||||
/**
|
||||
* GraphView
|
||||
* Copyright (C) 2014 Jonas Gehring
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License,
|
||||
* with the "Linking Exception", which can be found at the license.txt
|
||||
* file in this program.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* with the "Linking Exception" along with this program; if not,
|
||||
* write to the author Jonas Gehring <g.jjoe64@gmail.com>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Added by mike
|
||||
*/
|
||||
|
||||
import com.jjoe64.graphview.series.DataPointInterface;
|
||||
|
||||
/**
|
||||
* interface of data points. Implement this in order
|
||||
* to use your class in {@link com.jjoe64.graphview.series.Series}.
|
||||
*
|
||||
* You can also use the default implementation {@link com.jjoe64.graphview.series.DataPoint} so
|
||||
* you do not have to implement it for yourself.
|
||||
*
|
||||
* @author jjoe64
|
||||
*/
|
||||
public interface DataPointWithLabelInterface extends DataPointInterface{
|
||||
/**
|
||||
* @return the x value
|
||||
*/
|
||||
double getX();
|
||||
|
||||
/**
|
||||
* @return the y value
|
||||
*/
|
||||
double getY();
|
||||
void setY(double y);
|
||||
|
||||
/**
|
||||
* @return the label value
|
||||
*/
|
||||
String getLabel();
|
||||
|
||||
long getDuration();
|
||||
PointsWithLabelGraphSeries.Shape getShape();
|
||||
float getSize();
|
||||
int getColor();
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package info.nightscout.androidaps.plugins.general.overview.graphExtensions
|
||||
|
||||
import com.jjoe64.graphview.series.DataPointInterface
|
||||
|
||||
interface DataPointWithLabelInterface : DataPointInterface {
|
||||
|
||||
override fun getX(): Double
|
||||
override fun getY(): Double
|
||||
fun setY(y: Double)
|
||||
|
||||
val label: String?
|
||||
val duration: Long
|
||||
val shape: PointsWithLabelGraphSeries.Shape?
|
||||
val size: Float
|
||||
val color: Int
|
||||
}
|
Loading…
Reference in a new issue