Merge pull request #934 from MilosKozak/future-iob-array
For review: Future iob array
This commit is contained in:
commit
584b0f7824
|
@ -312,7 +312,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
//log.debug(">>> calculateFromTreatmentsAndTemps Cache miss " + new Date(time).toLocaleString());
|
//log.debug(">>> calculateFromTreatmentsAndTemps Cache miss " + new Date(time).toLocaleString());
|
||||||
}
|
}
|
||||||
IobTotal bolusIob = TreatmentsPlugin.getPlugin().getCalculationToTimeTreatments(time).round();
|
IobTotal bolusIob = TreatmentsPlugin.getPlugin().getCalculationToTimeTreatments(time).round();
|
||||||
IobTotal basalIob = TreatmentsPlugin.getPlugin().getCalculationToTimeTempBasals(time, profile).round();
|
IobTotal basalIob = TreatmentsPlugin.getPlugin().getCalculationToTimeTempBasals(time, profile, true, now).round();
|
||||||
if (OpenAPSSMBPlugin.getPlugin().isEnabled(PluginType.APS)) {
|
if (OpenAPSSMBPlugin.getPlugin().isEnabled(PluginType.APS)) {
|
||||||
// Add expected zero temp basal for next 240 mins
|
// Add expected zero temp basal for next 240 mins
|
||||||
IobTotal basalIobWithZeroTemp = basalIob.copy();
|
IobTotal basalIobWithZeroTemp = basalIob.copy();
|
||||||
|
|
|
@ -338,12 +338,24 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IobTotal getCalculationToTimeTempBasals(long time, Profile profile) {
|
public IobTotal getCalculationToTimeTempBasals(long time, Profile profile) {
|
||||||
|
return getCalculationToTimeTempBasals(time, profile, false, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IobTotal getCalculationToTimeTempBasals(long time, Profile profile, boolean truncate, long truncateTime) {
|
||||||
IobTotal total = new IobTotal(time);
|
IobTotal total = new IobTotal(time);
|
||||||
synchronized (tempBasals) {
|
synchronized (tempBasals) {
|
||||||
for (Integer pos = 0; pos < tempBasals.size(); pos++) {
|
for (Integer pos = 0; pos < tempBasals.size(); pos++) {
|
||||||
TemporaryBasal t = tempBasals.get(pos);
|
TemporaryBasal t = tempBasals.get(pos);
|
||||||
if (t.date > time) continue;
|
if (t.date > time) continue;
|
||||||
IobTotal calc = t.iobCalc(time, profile);
|
IobTotal calc;
|
||||||
|
if(truncate && t.end() > truncateTime){
|
||||||
|
TemporaryBasal dummyTemp = new TemporaryBasal();
|
||||||
|
dummyTemp.copyFrom(t);
|
||||||
|
dummyTemp.cutEndTo(truncateTime);
|
||||||
|
calc = dummyTemp.iobCalc(time, profile);
|
||||||
|
} else {
|
||||||
|
calc = t.iobCalc(time, profile);
|
||||||
|
}
|
||||||
//log.debug("BasalIOB " + new Date(time) + " >>> " + calc.basaliob);
|
//log.debug("BasalIOB " + new Date(time) + " >>> " + calc.basaliob);
|
||||||
total.plus(calc);
|
total.plus(calc);
|
||||||
}
|
}
|
||||||
|
@ -354,7 +366,15 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
for (Integer pos = 0; pos < extendedBoluses.size(); pos++) {
|
for (Integer 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;
|
||||||
|
if(truncate && e.end() > truncateTime){
|
||||||
|
ExtendedBolus dummyExt = new ExtendedBolus();
|
||||||
|
dummyExt.copyFrom(e);
|
||||||
|
dummyExt.cutEndTo(truncateTime);
|
||||||
|
calc = dummyExt.iobCalc(time);
|
||||||
|
} else {
|
||||||
|
calc = e.iobCalc(time);
|
||||||
|
}
|
||||||
totalExt.plus(calc);
|
totalExt.plus(calc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue