insight constraints

This commit is contained in:
AdrianLxM 2018-07-12 20:30:19 +02:00 committed by GitHub
parent ebb6f746b5
commit 5f5a2b6a0d
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;
}