show how is value hard limited
This commit is contained in:
parent
649cab63fc
commit
f8feaf565b
|
@ -174,7 +174,7 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
|
|||
maxIob = MainApp.getConfigBuilder().applyMaxIOBConstraints(maxIob);
|
||||
|
||||
minBg = verifyHardLimits(minBg, "minBg", 72, 180);
|
||||
maxBg = verifyHardLimits(maxBg, "maxBg", 100, 270);
|
||||
maxBg = verifyHardLimits(maxBg, "maxBg", 99, 270);
|
||||
targetBg = verifyHardLimits(targetBg, "targetBg", 80, 200);
|
||||
|
||||
boolean isTempTarget = false;
|
||||
|
@ -248,15 +248,18 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
|
|||
}
|
||||
|
||||
public static Double verifyHardLimits(Double value, String valueName, double lowLimit, double highLimit) {
|
||||
if (value < lowLimit || value > highLimit) {
|
||||
Double newvalue = value;
|
||||
if (newvalue < lowLimit || newvalue > highLimit) {
|
||||
newvalue = Math.max(newvalue, lowLimit);
|
||||
newvalue = Math.min(newvalue, highLimit);
|
||||
String msg = String.format(MainApp.sResources.getString(R.string.openapsma_valueoutofrange), valueName);
|
||||
msg += ".\n";
|
||||
msg += String.format(MainApp.sResources.getString(R.string.openapsma_valuelimitedto), value, newvalue);
|
||||
log.error(msg);
|
||||
MainApp.getConfigBuilder().uploadError(msg);
|
||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), msg, R.raw.error);
|
||||
value = Math.max(value, lowLimit);
|
||||
value = Math.min(value, highLimit);
|
||||
}
|
||||
return value;
|
||||
return newvalue;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -34,6 +34,9 @@ import info.nightscout.utils.Round;
|
|||
import info.nightscout.utils.SafeParse;
|
||||
import info.nightscout.utils.ToastUtils;
|
||||
|
||||
import static info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin.checkOnlyHardLimits;
|
||||
import static info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin.verifyHardLimits;
|
||||
|
||||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
|
@ -179,7 +182,7 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
|
|||
maxIob = MainApp.getConfigBuilder().applyMaxIOBConstraints(maxIob);
|
||||
|
||||
minBg = verifyHardLimits(minBg, "minBg", 72, 180);
|
||||
maxBg = verifyHardLimits(maxBg, "maxBg", 100, 270);
|
||||
maxBg = verifyHardLimits(maxBg, "maxBg", 99, 270);
|
||||
targetBg = verifyHardLimits(targetBg, "targetBg", 80, 200);
|
||||
|
||||
TempTargetRangePlugin tempTargetRangePlugin = (TempTargetRangePlugin) MainApp.getSpecificPlugin(TempTargetRangePlugin.class);
|
||||
|
@ -235,21 +238,5 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
|
|||
//deviceStatus.suggested = determineBasalResultMA.json;
|
||||
}
|
||||
|
||||
// safety checks
|
||||
public static boolean checkOnlyHardLimits(Double value, String valueName, double lowLimit, double highLimit) {
|
||||
return value.equals(verifyHardLimits(value, valueName, lowLimit, highLimit));
|
||||
}
|
||||
|
||||
public static Double verifyHardLimits(Double value, String valueName, double lowLimit, double highLimit) {
|
||||
if (value < lowLimit || value > highLimit) {
|
||||
String msg = String.format(MainApp.sResources.getString(R.string.openapsma_valueoutofrange), valueName);
|
||||
log.error(msg);
|
||||
MainApp.getConfigBuilder().uploadError(msg);
|
||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), msg, R.raw.error);
|
||||
value = Math.max(value, lowLimit);
|
||||
value = Math.min(value, highLimit);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -319,6 +319,7 @@
|
|||
<string name="smscommunicator_loophasbeenenabled">Loop has been enabled</string>
|
||||
<string name="smscommunicator_loopisdisabled">Loop is disabled</string>
|
||||
<string name="smscommunicator_loopisenabled">Loop is enabled</string>
|
||||
<string name="openapsma_valuelimitedto" formatted="false">%.2f limited to %.2f</string>
|
||||
<string name="openapsma_valueoutofrange" formatted="false">Value %s is out of hard limits</string>
|
||||
<string name="smscommunicator_remotebasalnotallowed">Remote basal setting is not allowed</string>
|
||||
<string name="smscommunicator_basalreplywithcode" formatted="false">To start basal %.2fU/h reply with code %s</string>
|
||||
|
|
Loading…
Reference in a new issue