fix canceling temp in open loop mode. credits to @warstar2187

This commit is contained in:
Milos Kozak 2018-01-09 19:47:32 +01:00
parent 1ce6f32c39
commit 70e22487b2

View file

@ -68,7 +68,7 @@ public class OpenAPSSMBPlugin implements PluginBase, APSInterface {
@Override
public String getNameShort() {
String name = MainApp.sResources.getString(R.string.smb_shortname);
if (!name.trim().isEmpty()){
if (!name.trim().isEmpty()) {
//only if translation exists
return name;
}
@ -251,11 +251,14 @@ public class OpenAPSSMBPlugin implements PluginBase, APSInterface {
determineBasalResultSMB.changeRequested = false;
// limit requests on openloop mode
if (!MainApp.getConfigBuilder().isClosedModeEnabled()) {
if (MainApp.getConfigBuilder().isTempBasalInProgress() && Math.abs(determineBasalResultSMB.rate - MainApp.getConfigBuilder().getTempBasalAbsoluteRateHistory()) < 0.1)
if (MainApp.getConfigBuilder().isTempBasalInProgress() && determineBasalResultSMB.rate == 0 && determineBasalResultSMB.duration == 0) {
// going to cancel
} else if (MainApp.getConfigBuilder().isTempBasalInProgress() && Math.abs(determineBasalResultSMB.rate - MainApp.getConfigBuilder().getTempBasalAbsoluteRateHistory()) < 0.1) {
determineBasalResultSMB.changeRequested = false;
if (!MainApp.getConfigBuilder().isTempBasalInProgress() && Math.abs(determineBasalResultSMB.rate - pump.getBaseBasalRate()) < 0.1)
} else if (!MainApp.getConfigBuilder().isTempBasalInProgress() && Math.abs(determineBasalResultSMB.rate - pump.getBaseBasalRate()) < 0.1) {
determineBasalResultSMB.changeRequested = false;
}
}
determineBasalResultSMB.iob = iobArray[0];
Date now = new Date();