Merge pull request #2663 from Tornado-Tim/show-targets
Show oref internal overridden targets
This commit is contained in:
commit
88adf04652
5 changed files with 22 additions and 8 deletions
|
@ -407,6 +407,7 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
|
|||
, 'bg': bg
|
||||
, 'tick': tick
|
||||
, 'eventualBG': eventualBG
|
||||
, 'targetBG': target_bg
|
||||
, 'insulinReq': 0
|
||||
, 'reservoir' : reservoir_data // The expected reservoir volume at which to deliver the microbolus (the reservoir volume from right before the last pumphistory run)
|
||||
, 'deliverAt' : deliverAt // The time at which the microbolus should be delivered
|
||||
|
|
|
@ -51,6 +51,9 @@ public class DetermineBasalResultSMB extends APSResult {
|
|||
} else {
|
||||
smb = 0d;
|
||||
}
|
||||
if (result.has("targetBG")) {
|
||||
targetBG = result.getDouble("targetBG");
|
||||
}
|
||||
|
||||
if (result.has("deliverAt")) {
|
||||
String date = result.getString("deliverAt");
|
||||
|
|
|
@ -646,6 +646,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
} else {
|
||||
overview_apsmode_text?.visibility = View.GONE
|
||||
}
|
||||
val lastRun = loopPlugin.lastRun
|
||||
|
||||
// temp target
|
||||
val tempTarget = treatmentsPlugin.tempTargetFromHistory
|
||||
|
@ -654,9 +655,18 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
overview_temptarget?.setBackgroundColor(resourceHelper.gc(R.color.ribbonWarning))
|
||||
overview_temptarget?.text = Profile.toTargetRangeString(tempTarget.low, tempTarget.high, Constants.MGDL, units) + " " + DateUtil.untilString(tempTarget.end(), resourceHelper)
|
||||
} else {
|
||||
overview_temptarget?.setTextColor(resourceHelper.gc(R.color.ribbonTextDefault))
|
||||
overview_temptarget?.setBackgroundColor(resourceHelper.gc(R.color.ribbonDefault))
|
||||
overview_temptarget?.text = Profile.toTargetRangeString(profile.targetLowMgdl, profile.targetHighMgdl, Constants.MGDL, units)
|
||||
// If the target is not the same as set in the profile then oref has overridden it
|
||||
val targetUsed = lastRun?.constraintsProcessed?.targetBG ?: 0.0
|
||||
|
||||
if (targetUsed != 0.0 && profile.targetMgdl != targetUsed) {
|
||||
overview_temptarget?.text = Profile.toTargetRangeString(targetUsed, targetUsed, Constants.MGDL, units)
|
||||
overview_temptarget?.setTextColor(resourceHelper.gc(R.color.ribbonTextWarning))
|
||||
overview_temptarget?.setBackgroundColor(resourceHelper.gc(R.color.tempTargetBackground))
|
||||
} else {
|
||||
overview_temptarget?.setTextColor(resourceHelper.gc(R.color.ribbonTextDefault))
|
||||
overview_temptarget?.setBackgroundColor(resourceHelper.gc(R.color.ribbonDefault))
|
||||
overview_temptarget?.text = Profile.toTargetRangeString(profile.targetLowMgdl, profile.targetHighMgdl, Constants.MGDL, units)
|
||||
}
|
||||
}
|
||||
|
||||
// Basal, TBR
|
||||
|
@ -677,7 +687,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
if (activeTemp != null)
|
||||
overview_basebasal_icon.setImageResource(if (activeTemp.tempBasalConvertedToPercent(System.currentTimeMillis(), profile) > 100) R.drawable.icon_cp_basal_tbr_high else R.drawable.icon_cp_basal_tbr_low)
|
||||
else
|
||||
overview_basebasal_icon.setImageResource( R.drawable.icon_cp_basal_no_tbr )
|
||||
overview_basebasal_icon.setImageResource(R.drawable.icon_cp_basal_no_tbr)
|
||||
|
||||
// Extended bolus
|
||||
val extendedBolus = treatmentsPlugin.getExtendedBolusFromHistory(System.currentTimeMillis())
|
||||
|
@ -741,7 +751,6 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
}
|
||||
overview_cob?.text = cobText
|
||||
|
||||
val lastRun = loopPlugin.lastRun
|
||||
val predictionsAvailable = if (config.APS) lastRun?.request?.hasPredictions == true else config.NSCLIENT
|
||||
|
||||
// pump status from ns
|
||||
|
@ -759,7 +768,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
// Sensitivity
|
||||
if (sp.getBoolean(R.string.key_openapsama_useautosens, false) && constraintChecker.isAutosensModeEnabled().value()) {
|
||||
overview_sensitivity_icon.setImageResource(R.drawable.ic_swap_vert_black_48dp_green)
|
||||
}else {
|
||||
} else {
|
||||
overview_sensitivity_icon.setImageResource(R.drawable.ic_x_swap_vert_48px_green)
|
||||
}
|
||||
|
||||
|
@ -883,4 +892,4 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -530,7 +530,6 @@ public class Profile {
|
|||
public double getTargetMgdl(int timeAsSeconds) {
|
||||
return toMgdl((getTargetLowTimeFromMidnight(timeAsSeconds) + getTargetHighTimeFromMidnight(timeAsSeconds)) / 2, units);
|
||||
}
|
||||
|
||||
public double getTargetLowMgdl() {
|
||||
return toMgdl(getTargetLowTimeFromMidnight(secondsFromMidnight()), units);
|
||||
}
|
||||
|
|
|
@ -62,6 +62,7 @@ public class APSResult {
|
|||
public boolean hasPredictions = false;
|
||||
public double smb = 0d; // super micro bolus in units
|
||||
public long deliverAt = 0;
|
||||
public double targetBG = 0d;
|
||||
|
||||
public Constraint<Double> inputConstraints;
|
||||
|
||||
|
@ -184,6 +185,7 @@ public class APSResult {
|
|||
newResult.smbConstraint = smbConstraint;
|
||||
newResult.percent = percent;
|
||||
newResult.usePercent = usePercent;
|
||||
newResult.targetBG = targetBG;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue