fix remaining duration
This commit is contained in:
parent
aea505e543
commit
cc45f74c25
|
@ -110,49 +110,6 @@ public class TempBasal {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
public Iob calcIob() {
|
|
||||||
Iob iob = new Iob();
|
|
||||||
|
|
||||||
long msAgo = getMillisecondsFromStart();
|
|
||||||
Calendar startAdjusted = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
|
|
||||||
startAdjusted.setTime(this.timeStart);
|
|
||||||
int minutes = startAdjusted.get(Calendar.MINUTE);
|
|
||||||
minutes = minutes % 4;
|
|
||||||
if (startAdjusted.get(Calendar.SECOND) > 0 && minutes == 0) {
|
|
||||||
minutes += 4;
|
|
||||||
}
|
|
||||||
startAdjusted.add(Calendar.MINUTE, minutes);
|
|
||||||
startAdjusted.set(Calendar.SECOND, 0);
|
|
||||||
|
|
||||||
IobCalc iobCalc = new IobCalc();
|
|
||||||
iobCalc.setTime(new Date());
|
|
||||||
iobCalc.setAmount(-1.0d * (baseRatio - tempRatio) / 15.0d / 100.0d);
|
|
||||||
|
|
||||||
long timeStartTime = startAdjusted.getTimeInMillis();
|
|
||||||
Date currentTimeEnd = timeEnd;
|
|
||||||
if (currentTimeEnd == null) {
|
|
||||||
currentTimeEnd = new Date();
|
|
||||||
if (getPlannedTimeEnd().getTime() < currentTimeEnd.getTime()) {
|
|
||||||
currentTimeEnd = getPlannedTimeEnd();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (long time = timeStartTime; time < currentTimeEnd.getTime(); time += 4 * 60_000) {
|
|
||||||
Date start = new Date(time);
|
|
||||||
|
|
||||||
iobCalc.setTimeStart(start);
|
|
||||||
iob.plus(iobCalc.invoke());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Settings.logTempIOBCalculation) {
|
|
||||||
log.debug("TempIOB start: " + this.timeStart + " end: " + this.timeEnd + " Percent: " + this.percent + " Duration: " + this.duration + " CalcDurat: " + (int) ((currentTimeEnd.getTime() - this.timeStart.getTime()) / 1000 / 60)
|
|
||||||
+ "min minAgo: " + (int) (msAgo / 1000 / 60) + " IOB: " + iob.iobContrib + " Activity: " + iob.activityContrib + " Impact: " + (-0.01d * (baseRatio - tempRatio) * ((currentTimeEnd.getTime() - this.timeStart.getTime()) / 1000 / 60) / 60)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return iob;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
// Determine end of basal
|
// Determine end of basal
|
||||||
public Date getTimeEnd() {
|
public Date getTimeEnd() {
|
||||||
Date tempBasalTimePlannedEnd = getPlannedTimeEnd();
|
Date tempBasalTimePlannedEnd = getPlannedTimeEnd();
|
||||||
|
@ -181,8 +138,9 @@ public class TempBasal {
|
||||||
return new Date().getTime() - timeStart.getTime();
|
return new Date().getTime() - timeStart.getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRemainingMinutes() {
|
public int getPlannedRemainingMinutes() {
|
||||||
long remainingMin = (getTimeEnd().getTime() - new Date().getTime()) / 1000 / 60;
|
if (timeEnd != null) return 0;
|
||||||
|
long remainingMin = (getPlannedTimeEnd().getTime() - new Date().getTime()) / 1000 / 60;
|
||||||
return (remainingMin < 0) ? 0 : (int) remainingMin;
|
return (remainingMin < 0) ? 0 : (int) remainingMin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,9 +17,6 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.text.DecimalFormat;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Config;
|
import info.nightscout.androidaps.Config;
|
||||||
|
@ -30,7 +27,6 @@ import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.data.Result;
|
import info.nightscout.androidaps.data.Result;
|
||||||
import info.nightscout.androidaps.db.TempBasal;
|
import info.nightscout.androidaps.db.TempBasal;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.plugins.APSResult;
|
import info.nightscout.androidaps.plugins.APSResult;
|
||||||
import info.nightscout.client.data.NSProfile;
|
import info.nightscout.client.data.NSProfile;
|
||||||
|
@ -220,7 +216,7 @@ public class VirtualPumpFragment extends Fragment implements PluginBase, PumpInt
|
||||||
public double getTempBasalRemainingMinutes() {
|
public double getTempBasalRemainingMinutes() {
|
||||||
if (!isTempBasalInProgress())
|
if (!isTempBasalInProgress())
|
||||||
return 0;
|
return 0;
|
||||||
return tempBasal.getRemainingMinutes();
|
return tempBasal.getPlannedRemainingMinutes();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -410,7 +406,7 @@ public class VirtualPumpFragment extends Fragment implements PluginBase, PumpInt
|
||||||
if (isTempBasalInProgress()) {
|
if (isTempBasalInProgress()) {
|
||||||
status.put("tempbasalpct", tempBasal.percent);
|
status.put("tempbasalpct", tempBasal.percent);
|
||||||
status.put("tempbasalstart", DateUtil.toISOString(tempBasal.timeStart));
|
status.put("tempbasalstart", DateUtil.toISOString(tempBasal.timeStart));
|
||||||
status.put("tempbasalremainmin", tempBasal.getRemainingMinutes());
|
status.put("tempbasalremainmin", tempBasal.getPlannedRemainingMinutes());
|
||||||
}
|
}
|
||||||
status.put("timestamp", DateUtil.toISOString(new Date()));
|
status.put("timestamp", DateUtil.toISOString(new Date()));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue