Combo-specifici hack: Consider a TBR with less than 60 seconds left as completed
when determining whether to set a new TBR. Setting a new TBR overrides an running TBR if any, so this won't fail on the Combo. Without this, a TBR mostly runs out 20 seconds after a loop iteration (when receiving a SGV), so for that almost 5 minutes to TBR is set. Note that this is Combo-specific and needs to be revised when integrating this with mainline.
This commit is contained in:
parent
3bd865a870
commit
0029fdad01
|
@ -252,6 +252,11 @@ public class TemporaryBasal implements Interval {
|
||||||
return Math.round(msecs / 60f / 1000);
|
return Math.round(msecs / 60f / 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getPlannedRemainingSeconds() {
|
||||||
|
Float remainingMin = (end() - System.currentTimeMillis()) / 1000f;
|
||||||
|
return remainingMin.intValue();
|
||||||
|
}
|
||||||
|
|
||||||
public int getPlannedRemainingMinutes() {
|
public int getPlannedRemainingMinutes() {
|
||||||
float remainingMin = (end() - System.currentTimeMillis()) / 1000f / 60;
|
float remainingMin = (end() - System.currentTimeMillis()) / 1000f / 60;
|
||||||
return (remainingMin < 0) ? 0 : Math.round(remainingMin);
|
return (remainingMin < 0) ? 0 : Math.round(remainingMin);
|
||||||
|
@ -280,6 +285,8 @@ public class TemporaryBasal implements Interval {
|
||||||
", isAbsolute=" + isAbsolute +
|
", isAbsolute=" + isAbsolute +
|
||||||
", isFakeExtended=" + isFakeExtended +
|
", isFakeExtended=" + isFakeExtended +
|
||||||
", netExtendedRate=" + netExtendedRate +
|
", netExtendedRate=" + netExtendedRate +
|
||||||
|
", minutesRemaining=" + getPlannedRemainingMinutes() +
|
||||||
|
", secondsRemaining=" + getPlannedRemainingSeconds() +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -263,7 +263,9 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isTempBasalInProgress() {
|
public boolean isTempBasalInProgress() {
|
||||||
return getTempBasalFromHistory(System.currentTimeMillis()) != null;
|
TemporaryBasal tempBasalFromHistory = getTempBasalFromHistory(System.currentTimeMillis());
|
||||||
|
log.debug("activeTempbasal: " + tempBasalFromHistory);
|
||||||
|
return tempBasalFromHistory != null && tempBasalFromHistory.getPlannedRemainingSeconds() > 60;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue