Fix checkTbrMismatch tolerance for TBRs up to 2m off.

(cherry picked from commit 46c1e00)
This commit is contained in:
Johannes Mockenhaupt 2017-11-26 15:20:19 +01:00
parent 47718723fe
commit 720e64e541
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1

View file

@ -852,18 +852,16 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
private boolean checkForTbrMismatch(PumpState state) {
TemporaryBasal aapsTbr = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
boolean sync = false;
if (aapsTbr == null && state.tbrActive && state.tbrRemainingDuration <= 2) {
// pump runs TBR AAPS is unaware off
if (aapsTbr == null && state.tbrActive && state.tbrRemainingDuration > 2) {
log.debug("Pump runs TBR AAPS is unaware of, cancelling TBR so it can be read from history properly");
runCommand(null, 0, ruffyScripter::cancelTbr);
sync = true;
} else if (aapsTbr != null && aapsTbr.getPlannedRemainingMinutes() > 2 && !state.tbrActive) {
// AAPS has a TBR but the pump isn't running a TBR
log.debug("AAPS shows TBR but pump isn't running a TBR; deleting TBR in AAPS and reading pump history");
log.debug("AAPS shows a TBR but pump isn't running a TBR; deleting TBR in AAPS and reading pump history");
MainApp.getDbHelper().delete(aapsTbr);
sync = true;
} else if (aapsTbr != null && state.tbrActive) {
// both AAPS and pump have a TBR ...
// both AAPS and pump have an active TBR ...
if (aapsTbr.percentRate != state.tbrPercent) {
// ... but they have different percentages
log.debug("TBR percentage differs between AAPS and pump; deleting TBR in AAPS and reading pump history");