This commit is contained in:
Tim Gunn 2020-05-02 00:07:24 +12:00
parent 01e8934f7a
commit b54e1a0af3
No known key found for this signature in database
GPG key ID: C9BC1E9D0D0AED8C
6 changed files with 22 additions and 3 deletions

View file

@ -98,7 +98,7 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface {
@NonNull @Override
public Constraint<Boolean> isClosedLoopAllowed(@NonNull Constraint<Boolean> value) {
String mode = sp.getString(R.string.key_aps_mode, "open");
if (!mode.equals("closed"))
if ((mode.equals("open")))
value.set(getAapsLogger(), false, getResourceHelper().gs(R.string.closedmodedisabledinpreferences), this);
if (!buildHelper.isEngineeringModeOrRelease()) {
@ -266,6 +266,7 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface {
@NonNull @Override
public Constraint<Double> applyMaxIOBConstraints(@NonNull Constraint<Double> maxIob) {
double maxIobPref;
String apsmode = sp.getString(R.string.key_aps_mode, "open");
if (openAPSSMBPlugin.isEnabled(PluginType.APS))
maxIobPref = sp.getDouble(R.string.key_openapssmb_max_iob, 3d);
else
@ -276,6 +277,9 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface {
maxIob.setIfSmaller(getAapsLogger(), hardLimits.maxIobAMA(), String.format(getResourceHelper().gs(R.string.limitingiob), hardLimits.maxIobAMA(), getResourceHelper().gs(R.string.hardlimit)), this);
if (openAPSSMBPlugin.isEnabled(PluginType.APS))
maxIob.setIfSmaller(getAapsLogger(), hardLimits.maxIobSMB(), String.format(getResourceHelper().gs(R.string.limitingiob), hardLimits.maxIobSMB(), getResourceHelper().gs(R.string.hardlimit)), this);
if ((apsmode.equals("lgs")))
maxIob.setIfSmaller(getAapsLogger(), hardLimits.maxIobLGS(), String.format(getResourceHelper().gs(R.string.limitingiob), hardLimits.maxIobLGS(), getResourceHelper().gs(R.string.lowglucosesuspend)), this);
return maxIob;
}

View file

@ -622,8 +622,10 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
}
loopPlugin.isEnabled(PluginType.LOOP) -> {
overview_apsmode?.text = if (closedLoopEnabled.value()) resourceHelper.gs(R.string.closedloop) else resourceHelper.gs(R.string.openloop)
overview_apsmode?.setBackgroundColor(resourceHelper.gc(R.color.ribbonDefault))
val APSmode = sp.getString(R.string.key_aps_mode, "open")
val isLGS = loopPlugin.isLGS
overview_apsmode?.text = if (closedLoopEnabled.value()) if (isLGS) resourceHelper.gs(R.string.lgs) else resourceHelper.gs(R.string.closedloop) else resourceHelper.gs(R.string.openloop)
overview_apsmode?.setBackgroundColor(if (isLGS) resourceHelper.gc(R.color.ribbonUnusual) else resourceHelper.gc(R.color.ribbonDefault))
overview_apsmode?.setTextColor(resourceHelper.gc(R.color.ribbonTextDefault))
}

View file

@ -45,6 +45,10 @@ class HardLimits @Inject constructor(
val MAXIOB_SMB = doubleArrayOf(3.0, 7.0, 12.0, 25.0)
val MAXBASAL = doubleArrayOf(2.0, 5.0, 10.0, 12.0)
//LGS Hard limits
//No IOB at all
val MAXIOB_LGS = 0.0
private fun loadAge(): Int {
val sp_age = sp.getString(R.string.key_age, "")
val age: Int
@ -68,6 +72,10 @@ class HardLimits @Inject constructor(
return MAXIOB_SMB[loadAge()]
}
fun maxIobLGS(): Double {
return MAXIOB_LGS
}
fun maxBasal(): Double {
return MAXBASAL[loadAge()]
}

View file

@ -4,10 +4,12 @@
<string-array name="aps_modeArray">
<item>@string/closedloop</item>
<item>@string/openloop</item>
<item>@string/lowglucosesuspend</item>
</string-array>
<string-array name="aps_modeValues" translatable="false">
<item>closed</item>
<item>open</item>
<item>lgs</item>
</string-array>
<string-array name="unitsArray">

View file

@ -86,6 +86,7 @@
<color name="ribbonCritical">#ff0400</color>
<color name="ribbonTextDefault">#FFFFFF</color>
<color name="ribbonTextWarning">#303030</color>
<color name="ribbonUnusual">#01017A</color>
<color name="ribbonTextCritical">#FFFFFF</color>
<color name="splashBackground">#2E2E2E</color>

View file

@ -187,10 +187,12 @@
<string name="closedloop">Closed Loop</string>
<string name="openloop">Open Loop</string>
<string name="lowglucosesuspend">Low Glucose Suspend</string>
<string name="disabledloop">Loop Disabled</string>
<string name="disableloop">Disable loop</string>
<string name="enableloop">Enable loop</string>
<string name="lgs">LGS</string>
<string name="openloop_newsuggestion">New suggestion available</string>
<string name="unsupportednsversion">Unsupported version of Nightscout</string>
<string name="loopdisabled">LOOP DISABLED BY CONSTRAINTS</string>