Merge pull request #2887 from Philoul/ExtendedIOBCalc
Replace Default Dia by profile Dia in extendedBolus's Iob calculation
This commit is contained in:
commit
9318f0637a
3 changed files with 12 additions and 7 deletions
|
@ -273,7 +273,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
for (int pos = 0; pos < extendedBoluses.size(); pos++) {
|
for (int pos = 0; pos < extendedBoluses.size(); pos++) {
|
||||||
ExtendedBolus e = extendedBoluses.get(pos);
|
ExtendedBolus e = extendedBoluses.get(pos);
|
||||||
if (e.date > time) continue;
|
if (e.date > time) continue;
|
||||||
IobTotal calc = e.iobCalc(time);
|
IobTotal calc = e.iobCalc(time, profile);
|
||||||
total.plus(calc);
|
total.plus(calc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -439,9 +439,9 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
ExtendedBolus dummyExt = new ExtendedBolus(getInjector());
|
ExtendedBolus dummyExt = new ExtendedBolus(getInjector());
|
||||||
dummyExt.copyFrom(e);
|
dummyExt.copyFrom(e);
|
||||||
dummyExt.cutEndTo(truncateTime);
|
dummyExt.cutEndTo(truncateTime);
|
||||||
calc = dummyExt.iobCalc(time);
|
calc = dummyExt.iobCalc(time, profile);
|
||||||
} else {
|
} else {
|
||||||
calc = e.iobCalc(time);
|
calc = e.iobCalc(time, profile);
|
||||||
}
|
}
|
||||||
totalExt.plus(calc);
|
totalExt.plus(calc);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ import info.nightscout.androidaps.db.ExtendedBolus
|
||||||
import info.nightscout.androidaps.db.Source
|
import info.nightscout.androidaps.db.Source
|
||||||
import info.nightscout.androidaps.events.EventExtendedBolusChange
|
import info.nightscout.androidaps.events.EventExtendedBolusChange
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
|
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.UploadQueue
|
import info.nightscout.androidaps.plugins.general.nsclient.UploadQueue
|
||||||
|
@ -42,6 +43,7 @@ class TreatmentsExtendedBolusesFragment : DaggerFragment() {
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||||
@Inject lateinit var nsUpload: NSUpload
|
@Inject lateinit var nsUpload: NSUpload
|
||||||
@Inject lateinit var uploadQueue: UploadQueue
|
@Inject lateinit var uploadQueue: UploadQueue
|
||||||
|
@Inject lateinit var profileFunction: ProfileFunction
|
||||||
@Inject lateinit var dateUtil: DateUtil
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
@ -77,16 +79,16 @@ class TreatmentsExtendedBolusesFragment : DaggerFragment() {
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
if (extendedBolus.isInProgress) holder.date.text = dateUtil.dateAndTimeString(extendedBolus.date)
|
if (extendedBolus.isInProgress) holder.date.text = dateUtil.dateAndTimeString(extendedBolus.date)
|
||||||
else holder.date.text = dateUtil.dateAndTimeString(extendedBolus.date) + " - " + dateUtil.timeString(extendedBolus.end())
|
else holder.date.text = dateUtil.dateAndTimeString(extendedBolus.date) + " - " + dateUtil.timeString(extendedBolus.end())
|
||||||
|
val profile = profileFunction.getProfile(extendedBolus.date)
|
||||||
holder.duration.text = resourceHelper.gs(R.string.format_mins, extendedBolus.durationInMinutes)
|
holder.duration.text = resourceHelper.gs(R.string.format_mins, extendedBolus.durationInMinutes)
|
||||||
holder.insulin.text = resourceHelper.gs(R.string.formatinsulinunits, extendedBolus.insulin)
|
holder.insulin.text = resourceHelper.gs(R.string.formatinsulinunits, extendedBolus.insulin)
|
||||||
holder.realDuration.text = resourceHelper.gs(R.string.format_mins, extendedBolus.realDuration)
|
holder.realDuration.text = resourceHelper.gs(R.string.format_mins, extendedBolus.realDuration)
|
||||||
val iob = extendedBolus.iobCalc(System.currentTimeMillis())
|
val iob = extendedBolus.iobCalc(System.currentTimeMillis(), profile)
|
||||||
holder.iob.text = resourceHelper.gs(R.string.formatinsulinunits, iob.iob)
|
holder.iob.text = resourceHelper.gs(R.string.formatinsulinunits, iob.iob)
|
||||||
holder.insulinSoFar.text = resourceHelper.gs(R.string.formatinsulinunits, extendedBolus.insulinSoFar())
|
holder.insulinSoFar.text = resourceHelper.gs(R.string.formatinsulinunits, extendedBolus.insulinSoFar())
|
||||||
holder.ratio.text = resourceHelper.gs(R.string.pump_basebasalrate, extendedBolus.absoluteRate())
|
holder.ratio.text = resourceHelper.gs(R.string.pump_basebasalrate, extendedBolus.absoluteRate())
|
||||||
if (extendedBolus.isInProgress) holder.date.setTextColor(resourceHelper.gc(R.color.colorActive)) else holder.date.setTextColor(holder.insulin.currentTextColor)
|
if (extendedBolus.isInProgress) holder.date.setTextColor(resourceHelper.gc(R.color.colorActive)) else holder.date.setTextColor(holder.insulin.currentTextColor)
|
||||||
if (extendedBolus.iobCalc(System.currentTimeMillis()).iob != 0.0) holder.iob.setTextColor(resourceHelper.gc(R.color.colorActive)) else holder.iob.setTextColor(holder.insulin.currentTextColor)
|
if (iob.iob != 0.0) holder.iob.setTextColor(resourceHelper.gc(R.color.colorActive)) else holder.iob.setTextColor(holder.insulin.currentTextColor)
|
||||||
}
|
}
|
||||||
holder.remove.tag = extendedBolus
|
holder.remove.tag = extendedBolus
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,7 @@ public class ExtendedBolus implements Interval, DataPointWithLabelInterface {
|
||||||
|
|
||||||
@DatabaseField
|
@DatabaseField
|
||||||
public int insulinInterfaceID = InsulinInterface.OREF_RAPID_ACTING;
|
public int insulinInterfaceID = InsulinInterface.OREF_RAPID_ACTING;
|
||||||
|
|
||||||
@DatabaseField
|
@DatabaseField
|
||||||
public double dia = Constants.defaultDIA;
|
public double dia = Constants.defaultDIA;
|
||||||
|
|
||||||
|
@ -229,13 +230,14 @@ public class ExtendedBolus implements Interval, DataPointWithLabelInterface {
|
||||||
return absoluteRate() * getRealDuration() / 60d;
|
return absoluteRate() * getRealDuration() / 60d;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IobTotal iobCalc(long time) {
|
public IobTotal iobCalc(long time, Profile profile) {
|
||||||
IobTotal result = new IobTotal(time);
|
IobTotal result = new IobTotal(time);
|
||||||
InsulinInterface insulinInterface = activePlugin.getActiveInsulin();
|
InsulinInterface insulinInterface = activePlugin.getActiveInsulin();
|
||||||
|
|
||||||
double realDuration = getDurationToTime(time);
|
double realDuration = getDurationToTime(time);
|
||||||
|
|
||||||
if (realDuration > 0) {
|
if (realDuration > 0) {
|
||||||
|
double dia = profile.getDia();
|
||||||
double dia_ago = time - dia * 60 * 60 * 1000;
|
double dia_ago = time - dia * 60 * 60 * 1000;
|
||||||
int aboutFiveMinIntervals = (int) Math.ceil(realDuration / 5d);
|
int aboutFiveMinIntervals = (int) Math.ceil(realDuration / 5d);
|
||||||
double spacing = realDuration / aboutFiveMinIntervals;
|
double spacing = realDuration / aboutFiveMinIntervals;
|
||||||
|
@ -280,6 +282,7 @@ public class ExtendedBolus implements Interval, DataPointWithLabelInterface {
|
||||||
|
|
||||||
if (realDuration > 0) {
|
if (realDuration > 0) {
|
||||||
double netBasalRate;
|
double netBasalRate;
|
||||||
|
double dia = profile.getDia();
|
||||||
double dia_ago = time - dia * 60 * 60 * 1000;
|
double dia_ago = time - dia * 60 * 60 * 1000;
|
||||||
int aboutFiveMinIntervals = (int) Math.ceil(realDuration / 5d);
|
int aboutFiveMinIntervals = (int) Math.ceil(realDuration / 5d);
|
||||||
double spacing = realDuration / aboutFiveMinIntervals;
|
double spacing = realDuration / aboutFiveMinIntervals;
|
||||||
|
|
Loading…
Reference in a new issue