Merge pull request #1213 from MilosKozak/insight-constraints

insight constraints
This commit is contained in:
Milos Kozak 2018-07-18 11:21:55 +03:00 committed by GitHub
commit b15da5a5cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -914,7 +914,14 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
public Constraint<Double> applyBolusConstraints(Constraint<Double> insulin) {
if (statusResult != null) {
insulin.setIfSmaller(statusResult.maximumBolusAmount, String.format(MainApp.gs(R.string.limitingbolus), statusResult.maximumBolusAmount, MainApp.gs(R.string.pumplimit)), this);
insulin.setIfGreater(statusResult.minimumBolusAmount, String.format(MainApp.gs(R.string.limitingbolus), statusResult.maximumBolusAmount, MainApp.gs(R.string.pumplimit)), this);
if (insulin.value() < statusResult.minimumBolusAmount) {
//TODO: Add function to Constraints or use different approach
// This only works if the interface of the InsightPlugin is called last.
// If not, another contraint could theoretically set the value between 0 and minimumBolusAmount
insulin.set(0d, String.format(MainApp.gs(R.string.limitingbolus), statusResult.minimumBolusAmount, MainApp.gs(R.string.pumplimit)), this);
}
}
return insulin;
}