limitClosedLoop & remove openloop flavor
This commit is contained in:
parent
5a96b88499
commit
326229ebbb
18 changed files with 64 additions and 60 deletions
|
@ -97,21 +97,6 @@ android {
|
||||||
buildConfigField "boolean", "APS", "true"
|
buildConfigField "boolean", "APS", "true"
|
||||||
buildConfigField "boolean", "PUMPDRIVERS", "true"
|
buildConfigField "boolean", "PUMPDRIVERS", "true"
|
||||||
buildConfigField "boolean", "NSCLIENTOLNY", "false"
|
buildConfigField "boolean", "NSCLIENTOLNY", "false"
|
||||||
buildConfigField "boolean", "CLOSEDLOOP", "true"
|
|
||||||
buildConfigField "boolean", "G5UPLOADER", "false"
|
|
||||||
buildConfigField "boolean", "PUMPCONTROL", "false"
|
|
||||||
}
|
|
||||||
openloop {
|
|
||||||
dimension "standard"
|
|
||||||
resValue "string", "app_name", "AndroidAPS"
|
|
||||||
versionName version
|
|
||||||
manifestPlaceholders = [
|
|
||||||
appIcon: "@mipmap/blueowl"
|
|
||||||
]
|
|
||||||
buildConfigField "boolean", "APS", "true"
|
|
||||||
buildConfigField "boolean", "PUMPDRIVERS", "true"
|
|
||||||
buildConfigField "boolean", "NSCLIENTOLNY", "false"
|
|
||||||
buildConfigField "boolean", "CLOSEDLOOP", "false"
|
|
||||||
buildConfigField "boolean", "G5UPLOADER", "false"
|
buildConfigField "boolean", "G5UPLOADER", "false"
|
||||||
buildConfigField "boolean", "PUMPCONTROL", "false"
|
buildConfigField "boolean", "PUMPCONTROL", "false"
|
||||||
}
|
}
|
||||||
|
@ -125,7 +110,6 @@ android {
|
||||||
buildConfigField "boolean", "APS", "false"
|
buildConfigField "boolean", "APS", "false"
|
||||||
buildConfigField "boolean", "PUMPDRIVERS", "true"
|
buildConfigField "boolean", "PUMPDRIVERS", "true"
|
||||||
buildConfigField "boolean", "NSCLIENTOLNY", "false"
|
buildConfigField "boolean", "NSCLIENTOLNY", "false"
|
||||||
buildConfigField "boolean", "CLOSEDLOOP", "false"
|
|
||||||
buildConfigField "boolean", "G5UPLOADER", "false"
|
buildConfigField "boolean", "G5UPLOADER", "false"
|
||||||
buildConfigField "boolean", "PUMPCONTROL", "true"
|
buildConfigField "boolean", "PUMPCONTROL", "true"
|
||||||
}
|
}
|
||||||
|
@ -139,7 +123,6 @@ android {
|
||||||
buildConfigField "boolean", "APS", "false"
|
buildConfigField "boolean", "APS", "false"
|
||||||
buildConfigField "boolean", "PUMPDRIVERS", "false"
|
buildConfigField "boolean", "PUMPDRIVERS", "false"
|
||||||
buildConfigField "boolean", "NSCLIENTOLNY", "true"
|
buildConfigField "boolean", "NSCLIENTOLNY", "true"
|
||||||
buildConfigField "boolean", "CLOSEDLOOP", "false"
|
|
||||||
buildConfigField "boolean", "G5UPLOADER", "false"
|
buildConfigField "boolean", "G5UPLOADER", "false"
|
||||||
buildConfigField "boolean", "PUMPCONTROL", "false"
|
buildConfigField "boolean", "PUMPCONTROL", "false"
|
||||||
}
|
}
|
||||||
|
@ -153,7 +136,6 @@ android {
|
||||||
buildConfigField "boolean", "APS", "false"
|
buildConfigField "boolean", "APS", "false"
|
||||||
buildConfigField "boolean", "PUMPDRIVERS", "false"
|
buildConfigField "boolean", "PUMPDRIVERS", "false"
|
||||||
buildConfigField "boolean", "NSCLIENTOLNY", "false"
|
buildConfigField "boolean", "NSCLIENTOLNY", "false"
|
||||||
buildConfigField "boolean", "CLOSEDLOOP", "false"
|
|
||||||
buildConfigField "boolean", "G5UPLOADER", "true"
|
buildConfigField "boolean", "G5UPLOADER", "true"
|
||||||
buildConfigField "boolean", "PUMPCONTROL", "false"
|
buildConfigField "boolean", "PUMPCONTROL", "false"
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ import info.nightscout.androidaps.Services.Intents;
|
||||||
import info.nightscout.androidaps.db.DatabaseHelper;
|
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||||
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
|
import info.nightscout.androidaps.interfaces.constrains.BooleanConstraint;
|
||||||
import info.nightscout.androidaps.plugins.Actions.ActionsFragment;
|
import info.nightscout.androidaps.plugins.Actions.ActionsFragment;
|
||||||
import info.nightscout.androidaps.plugins.Careportal.CareportalPlugin;
|
import info.nightscout.androidaps.plugins.Careportal.CareportalPlugin;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
|
||||||
|
@ -191,13 +192,16 @@ public class MainApp extends Application {
|
||||||
MainApp.getConfigBuilder().initialize();
|
MainApp.getConfigBuilder().initialize();
|
||||||
}
|
}
|
||||||
NSUpload.uploadAppStart();
|
NSUpload.uploadAppStart();
|
||||||
|
BooleanConstraint closedLoopEnabled = new BooleanConstraint(true);
|
||||||
|
MainApp.getConfigBuilder().limitClosedLoop(closedLoopEnabled);
|
||||||
|
|
||||||
if (Config.NSCLIENT)
|
if (Config.NSCLIENT)
|
||||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("AppStart-NSClient"));
|
FabricPrivacy.getInstance().logCustom(new CustomEvent("AppStart-NSClient"));
|
||||||
else if (Config.G5UPLOADER)
|
else if (Config.G5UPLOADER)
|
||||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("AppStart-G5Uploader"));
|
FabricPrivacy.getInstance().logCustom(new CustomEvent("AppStart-G5Uploader"));
|
||||||
else if (Config.PUMPCONTROL)
|
else if (Config.PUMPCONTROL)
|
||||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("AppStart-PumpControl"));
|
FabricPrivacy.getInstance().logCustom(new CustomEvent("AppStart-PumpControl"));
|
||||||
else if (MainApp.getConfigBuilder().isClosedModeEnabled())
|
else if (closedLoopEnabled.get())
|
||||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("AppStart-ClosedLoop"));
|
FabricPrivacy.getInstance().logCustom(new CustomEvent("AppStart-ClosedLoop"));
|
||||||
else
|
else
|
||||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("AppStart-OpenLoop"));
|
FabricPrivacy.getInstance().logCustom(new CustomEvent("AppStart-OpenLoop"));
|
||||||
|
|
|
@ -9,7 +9,7 @@ public interface ConstraintsInterface {
|
||||||
|
|
||||||
void limitRunningLoop(BooleanConstraint value);
|
void limitRunningLoop(BooleanConstraint value);
|
||||||
|
|
||||||
boolean isClosedModeEnabled();
|
void limitClosedLoop(BooleanConstraint value);
|
||||||
|
|
||||||
boolean isAutosensModeEnabled();
|
boolean isAutosensModeEnabled();
|
||||||
|
|
||||||
|
|
|
@ -453,23 +453,21 @@ public class ConfigBuilderPlugin implements PluginBase, ConstraintsInterface, Tr
|
||||||
|
|
||||||
ArrayList<PluginBase> constraintsPlugins = MainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
ArrayList<PluginBase> constraintsPlugins = MainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
||||||
for (PluginBase p : constraintsPlugins) {
|
for (PluginBase p : constraintsPlugins) {
|
||||||
ConstraintsInterface constrain = (ConstraintsInterface) p;
|
ConstraintsInterface constraint = (ConstraintsInterface) p;
|
||||||
if (!p.isEnabled(PluginBase.CONSTRAINTS)) continue;
|
if (!p.isEnabled(PluginBase.CONSTRAINTS)) continue;
|
||||||
constrain.limitRunningLoop(value);
|
constraint.limitRunningLoop(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isClosedModeEnabled() {
|
public void limitClosedLoop(BooleanConstraint value) {
|
||||||
boolean result = true;
|
|
||||||
|
|
||||||
ArrayList<PluginBase> constraintsPlugins = MainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
ArrayList<PluginBase> constraintsPlugins = MainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
||||||
for (PluginBase p : constraintsPlugins) {
|
for (PluginBase p : constraintsPlugins) {
|
||||||
ConstraintsInterface constrain = (ConstraintsInterface) p;
|
ConstraintsInterface constraint = (ConstraintsInterface) p;
|
||||||
if (!p.isEnabled(PluginBase.CONSTRAINTS)) continue;
|
if (!p.isEnabled(PluginBase.CONSTRAINTS)) continue;
|
||||||
result = result && constrain.isClosedModeEnabled();
|
constraint.limitClosedLoop(value);
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -15,9 +15,9 @@ import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.db.DatabaseHelper;
|
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||||
import info.nightscout.androidaps.interfaces.APSInterface;
|
import info.nightscout.androidaps.interfaces.APSInterface;
|
||||||
import info.nightscout.androidaps.interfaces.constrains.BooleanConstraint;
|
|
||||||
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
|
import info.nightscout.androidaps.interfaces.constrains.BooleanConstraint;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.ConstraintsSafety.SafetyPlugin;
|
import info.nightscout.androidaps.plugins.ConstraintsSafety.SafetyPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||||
|
@ -183,8 +183,9 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
|
||||||
case 2:
|
case 2:
|
||||||
return new RequirementResult(true, "");
|
return new RequirementResult(true, "");
|
||||||
case 3:
|
case 3:
|
||||||
boolean closedModeEnabled = SafetyPlugin.getPlugin().isClosedModeEnabled();
|
BooleanConstraint closedLoopEnabled = new BooleanConstraint(true);
|
||||||
return new RequirementResult(closedModeEnabled, MainApp.sResources.getString(R.string.closedmodeenabled) + ": " + yesOrNo(closedModeEnabled));
|
SafetyPlugin.getPlugin().limitClosedLoop(closedLoopEnabled);
|
||||||
|
return new RequirementResult(closedLoopEnabled.get(), MainApp.sResources.getString(R.string.closedmodeenabled) + ": " + yesOrNo(closedLoopEnabled.get()));
|
||||||
case 4:
|
case 4:
|
||||||
double maxIOB = MainApp.getConfigBuilder().applyMaxIOBConstraints(1000d);
|
double maxIOB = MainApp.getConfigBuilder().applyMaxIOBConstraints(1000d);
|
||||||
boolean maxIobSet = maxIOB > 0;
|
boolean maxIobSet = maxIOB > 0;
|
||||||
|
@ -296,12 +297,13 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
|
||||||
@Override
|
@Override
|
||||||
public void limitRunningLoop(BooleanConstraint value) {
|
public void limitRunningLoop(BooleanConstraint value) {
|
||||||
if (objectives.get(0).started.getTime() == 0)
|
if (objectives.get(0).started.getTime() == 0)
|
||||||
value.set(false, MainApp.gs(R.string.objective1notstarted));
|
value.set(false, String.format(MainApp.gs(R.string.objectivenotstarted), 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isClosedModeEnabled() {
|
public void limitClosedLoop(BooleanConstraint value) {
|
||||||
return objectives.get(3).started.getTime() > 0;
|
if (objectives.get(3).started.getTime() == 0)
|
||||||
|
value.set(false, String.format(MainApp.gs(R.string.objectivenotstarted), 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -5,7 +5,6 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import info.nightscout.androidaps.BuildConfig;
|
|
||||||
import info.nightscout.androidaps.Config;
|
import info.nightscout.androidaps.Config;
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
@ -103,10 +102,13 @@ public class SafetyPlugin implements PluginBase, ConstraintsInterface {
|
||||||
* Constraints interface
|
* Constraints interface
|
||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
public boolean isClosedModeEnabled() {
|
public void limitClosedLoop(BooleanConstraint value) {
|
||||||
if (!MainApp.isEngineeringModeOrRelease()) return false;
|
if (!MainApp.isEngineeringModeOrRelease())
|
||||||
|
value.set(false, MainApp.gs(R.string.closed_loop_disabled_on_dev_branch));
|
||||||
|
|
||||||
String mode = SP.getString("aps_mode", "open");
|
String mode = SP.getString("aps_mode", "open");
|
||||||
return mode.equals("closed") && BuildConfig.CLOSEDLOOP;
|
if (!mode.equals("closed"))
|
||||||
|
value.set(false, MainApp.gs(R.string.closedmodedisabledinpreferences));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -26,9 +26,9 @@ import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
import info.nightscout.androidaps.events.EventNewBG;
|
import info.nightscout.androidaps.events.EventNewBG;
|
||||||
import info.nightscout.androidaps.events.EventTreatmentChange;
|
import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||||
import info.nightscout.androidaps.interfaces.APSInterface;
|
import info.nightscout.androidaps.interfaces.APSInterface;
|
||||||
import info.nightscout.androidaps.interfaces.constrains.BooleanConstraint;
|
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
|
import info.nightscout.androidaps.interfaces.constrains.BooleanConstraint;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished;
|
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished;
|
||||||
import info.nightscout.androidaps.plugins.Loop.events.EventLoopSetLastRunGui;
|
import info.nightscout.androidaps.plugins.Loop.events.EventLoopSetLastRunGui;
|
||||||
|
@ -331,7 +331,10 @@ public class LoopPlugin implements PluginBase {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MainApp.getConfigBuilder().isClosedModeEnabled()) {
|
BooleanConstraint closedLoopEnabled = new BooleanConstraint(true);
|
||||||
|
MainApp.getConfigBuilder().limitClosedLoop(closedLoopEnabled);
|
||||||
|
|
||||||
|
if (closedLoopEnabled.get()) {
|
||||||
if (result.isChangeRequested()) {
|
if (result.isChangeRequested()) {
|
||||||
final PumpEnactResult waiting = new PumpEnactResult();
|
final PumpEnactResult waiting = new PumpEnactResult();
|
||||||
waiting.queued = true;
|
waiting.queued = true;
|
||||||
|
|
|
@ -19,6 +19,7 @@ import info.nightscout.androidaps.db.TemporaryBasal;
|
||||||
import info.nightscout.androidaps.interfaces.APSInterface;
|
import info.nightscout.androidaps.interfaces.APSInterface;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
|
import info.nightscout.androidaps.interfaces.constrains.BooleanConstraint;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult;
|
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult;
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||||
|
@ -248,7 +249,9 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
|
||||||
if (determineBasalResultAMA.rate == 0d && determineBasalResultAMA.duration == 0 && !MainApp.getConfigBuilder().isTempBasalInProgress())
|
if (determineBasalResultAMA.rate == 0d && determineBasalResultAMA.duration == 0 && !MainApp.getConfigBuilder().isTempBasalInProgress())
|
||||||
determineBasalResultAMA.tempBasalReqested = false;
|
determineBasalResultAMA.tempBasalReqested = false;
|
||||||
// limit requests on openloop mode
|
// limit requests on openloop mode
|
||||||
if (!MainApp.getConfigBuilder().isClosedModeEnabled()) {
|
BooleanConstraint closedLoopEnabled = new BooleanConstraint(true);
|
||||||
|
MainApp.getConfigBuilder().limitClosedLoop(closedLoopEnabled);
|
||||||
|
if (!closedLoopEnabled.get()) {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(now);
|
TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(now);
|
||||||
if (activeTemp != null && determineBasalResultAMA.rate == 0 && determineBasalResultAMA.duration == 0) {
|
if (activeTemp != null && determineBasalResultAMA.rate == 0 && determineBasalResultAMA.duration == 0) {
|
||||||
|
|
|
@ -19,6 +19,7 @@ import info.nightscout.androidaps.db.TemporaryBasal;
|
||||||
import info.nightscout.androidaps.interfaces.APSInterface;
|
import info.nightscout.androidaps.interfaces.APSInterface;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
|
import info.nightscout.androidaps.interfaces.constrains.BooleanConstraint;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Loop.APSResult;
|
import info.nightscout.androidaps.plugins.Loop.APSResult;
|
||||||
import info.nightscout.androidaps.plugins.Loop.ScriptReader;
|
import info.nightscout.androidaps.plugins.Loop.ScriptReader;
|
||||||
|
@ -237,7 +238,9 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
|
||||||
if (determineBasalResultMA.rate == 0d && determineBasalResultMA.duration == 0 && !MainApp.getConfigBuilder().isTempBasalInProgress())
|
if (determineBasalResultMA.rate == 0d && determineBasalResultMA.duration == 0 && !MainApp.getConfigBuilder().isTempBasalInProgress())
|
||||||
determineBasalResultMA.tempBasalReqested = false;
|
determineBasalResultMA.tempBasalReqested = false;
|
||||||
// limit requests on openloop mode
|
// limit requests on openloop mode
|
||||||
if (!MainApp.getConfigBuilder().isClosedModeEnabled()) {
|
BooleanConstraint closedLoopEnabled = new BooleanConstraint(true);
|
||||||
|
MainApp.getConfigBuilder().limitClosedLoop(closedLoopEnabled);
|
||||||
|
if (!closedLoopEnabled.get()) {
|
||||||
TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(now);
|
TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(now);
|
||||||
if (activeTemp != null && determineBasalResultMA.rate == 0 && determineBasalResultMA.duration == 0) {
|
if (activeTemp != null && determineBasalResultMA.rate == 0 && determineBasalResultMA.duration == 0) {
|
||||||
// going to cancel
|
// going to cancel
|
||||||
|
|
|
@ -27,12 +27,11 @@ import info.nightscout.androidaps.data.IobTotal;
|
||||||
import info.nightscout.androidaps.data.MealData;
|
import info.nightscout.androidaps.data.MealData;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.constrains.BooleanConstraint;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Loop.ScriptReader;
|
import info.nightscout.androidaps.plugins.Loop.ScriptReader;
|
||||||
import info.nightscout.androidaps.plugins.OpenAPSMA.LoggerCallback;
|
import info.nightscout.androidaps.plugins.OpenAPSMA.LoggerCallback;
|
||||||
import info.nightscout.androidaps.plugins.SourceDexcomG5.SourceDexcomG5Plugin;
|
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
import info.nightscout.utils.SafeParse;
|
import info.nightscout.utils.SafeParse;
|
||||||
|
|
||||||
|
@ -217,6 +216,9 @@ public class DetermineBasalAdapterSMBJS {
|
||||||
|
|
||||||
String units = profile.getUnits();
|
String units = profile.getUnits();
|
||||||
|
|
||||||
|
BooleanConstraint closedLoopEnabled = new BooleanConstraint(true);
|
||||||
|
MainApp.getConfigBuilder().limitClosedLoop(closedLoopEnabled);
|
||||||
|
|
||||||
mProfile = new JSONObject();
|
mProfile = new JSONObject();
|
||||||
|
|
||||||
mProfile.put("max_iob", maxIob);
|
mProfile.put("max_iob", maxIob);
|
||||||
|
@ -246,7 +248,7 @@ public class DetermineBasalAdapterSMBJS {
|
||||||
mProfile.put("remainingCarbsCap", SMBDefaults.remainingCarbsCap);
|
mProfile.put("remainingCarbsCap", SMBDefaults.remainingCarbsCap);
|
||||||
mProfile.put("enableUAM", SP.getBoolean(R.string.key_use_uam, false));
|
mProfile.put("enableUAM", SP.getBoolean(R.string.key_use_uam, false));
|
||||||
mProfile.put("A52_risk_enable", SMBDefaults.A52_risk_enable);
|
mProfile.put("A52_risk_enable", SMBDefaults.A52_risk_enable);
|
||||||
boolean SMBEnabled = SP.getBoolean(R.string.key_use_smb, false) && MainApp.getConfigBuilder().isClosedModeEnabled();
|
boolean SMBEnabled = SP.getBoolean(R.string.key_use_smb, false) && closedLoopEnabled.get();
|
||||||
mProfile.put("enableSMB_with_COB", SMBEnabled && SP.getBoolean(R.string.key_enableSMB_with_COB, false));
|
mProfile.put("enableSMB_with_COB", SMBEnabled && SP.getBoolean(R.string.key_enableSMB_with_COB, false));
|
||||||
mProfile.put("enableSMB_with_temptarget", SMBEnabled && SP.getBoolean(R.string.key_enableSMB_with_temptarget, false));
|
mProfile.put("enableSMB_with_temptarget", SMBEnabled && SP.getBoolean(R.string.key_enableSMB_with_temptarget, false));
|
||||||
mProfile.put("allowSMB_with_high_temptarget", SMBEnabled && SP.getBoolean(R.string.key_allowSMB_with_high_temptarget, false));
|
mProfile.put("allowSMB_with_high_temptarget", SMBEnabled && SP.getBoolean(R.string.key_allowSMB_with_high_temptarget, false));
|
||||||
|
|
|
@ -19,6 +19,7 @@ import info.nightscout.androidaps.db.TemporaryBasal;
|
||||||
import info.nightscout.androidaps.interfaces.APSInterface;
|
import info.nightscout.androidaps.interfaces.APSInterface;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
|
import info.nightscout.androidaps.interfaces.constrains.BooleanConstraint;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult;
|
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult;
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||||
|
@ -253,7 +254,9 @@ public class OpenAPSSMBPlugin implements PluginBase, APSInterface {
|
||||||
if (determineBasalResultSMB.rate == 0d && determineBasalResultSMB.duration == 0 && !MainApp.getConfigBuilder().isTempBasalInProgress())
|
if (determineBasalResultSMB.rate == 0d && determineBasalResultSMB.duration == 0 && !MainApp.getConfigBuilder().isTempBasalInProgress())
|
||||||
determineBasalResultSMB.tempBasalReqested = false;
|
determineBasalResultSMB.tempBasalReqested = false;
|
||||||
// limit requests on openloop mode
|
// limit requests on openloop mode
|
||||||
if (!MainApp.getConfigBuilder().isClosedModeEnabled()) {
|
BooleanConstraint closedLoopEnabled = new BooleanConstraint(true);
|
||||||
|
MainApp.getConfigBuilder().limitClosedLoop(closedLoopEnabled);
|
||||||
|
if (!closedLoopEnabled.get()) {
|
||||||
TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(now);
|
TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(now);
|
||||||
if (activeTemp != null && determineBasalResultSMB.rate == 0 && determineBasalResultSMB.duration == 0) {
|
if (activeTemp != null && determineBasalResultSMB.rate == 0 && determineBasalResultSMB.duration == 0) {
|
||||||
// going to cancel
|
// going to cancel
|
||||||
|
|
|
@ -87,6 +87,7 @@ import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
|
import info.nightscout.androidaps.interfaces.constrains.BooleanConstraint;
|
||||||
import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
|
import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
|
||||||
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
|
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
|
||||||
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
|
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
|
||||||
|
@ -1016,6 +1017,9 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BooleanConstraint closedLoopEnabled = new BooleanConstraint(true);
|
||||||
|
MainApp.getConfigBuilder().limitClosedLoop(closedLoopEnabled);
|
||||||
|
|
||||||
// open loop mode
|
// open loop mode
|
||||||
final LoopPlugin.LastRun finalLastRun = LoopPlugin.lastRun;
|
final LoopPlugin.LastRun finalLastRun = LoopPlugin.lastRun;
|
||||||
if (Config.APS && pump.getPumpDescription().isTempBasalCapable) {
|
if (Config.APS && pump.getPumpDescription().isTempBasalCapable) {
|
||||||
|
@ -1036,7 +1040,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
apsModeView.setText(MainApp.sResources.getString(R.string.pumpsuspended));
|
apsModeView.setText(MainApp.sResources.getString(R.string.pumpsuspended));
|
||||||
apsModeView.setTextColor(Color.WHITE);
|
apsModeView.setTextColor(Color.WHITE);
|
||||||
} else if (activeloop != null && activeloop.isEnabled(activeloop.getType())) {
|
} else if (activeloop != null && activeloop.isEnabled(activeloop.getType())) {
|
||||||
if (MainApp.getConfigBuilder().isClosedModeEnabled()) {
|
if (closedLoopEnabled.get()) {
|
||||||
apsModeView.setText(MainApp.sResources.getString(R.string.closedloop));
|
apsModeView.setText(MainApp.sResources.getString(R.string.closedloop));
|
||||||
} else {
|
} else {
|
||||||
apsModeView.setText(MainApp.sResources.getString(R.string.openloop));
|
apsModeView.setText(MainApp.sResources.getString(R.string.openloop));
|
||||||
|
@ -1066,7 +1070,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
|
|
||||||
// **** Temp button ****
|
// **** Temp button ****
|
||||||
if (acceptTempLayout != null) {
|
if (acceptTempLayout != null) {
|
||||||
boolean showAcceptButton = !MainApp.getConfigBuilder().isClosedModeEnabled(); // Open mode needed
|
boolean showAcceptButton = !closedLoopEnabled.get(); // Open mode needed
|
||||||
showAcceptButton = showAcceptButton && finalLastRun != null && finalLastRun.lastAPSRun != null; // aps result must exist
|
showAcceptButton = showAcceptButton && finalLastRun != null && finalLastRun.lastAPSRun != null; // aps result must exist
|
||||||
showAcceptButton = showAcceptButton && (finalLastRun.lastOpenModeAccept == null || finalLastRun.lastOpenModeAccept.getTime() < finalLastRun.lastAPSRun.getTime()); // never accepted or before last result
|
showAcceptButton = showAcceptButton && (finalLastRun.lastOpenModeAccept == null || finalLastRun.lastOpenModeAccept.getTime() < finalLastRun.lastAPSRun.getTime()); // never accepted or before last result
|
||||||
showAcceptButton = showAcceptButton && finalLastRun.constraintsProcessed.isChangeRequested(); // change is requested
|
showAcceptButton = showAcceptButton && finalLastRun.constraintsProcessed.isChangeRequested(); // change is requested
|
||||||
|
|
|
@ -1428,8 +1428,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isClosedModeEnabled() {
|
public void limitClosedLoop(BooleanConstraint value) {
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -441,8 +441,7 @@ public abstract class AbstractDanaRPlugin implements PluginBase, PumpInterface,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isClosedModeEnabled() {
|
public void limitClosedLoop(BooleanConstraint value) {
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -279,8 +279,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isClosedModeEnabled() {
|
public void limitClosedLoop(BooleanConstraint value) {
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1084,8 +1084,7 @@ public class InsightPumpPlugin implements PluginBase, PumpInterface, Constraints
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isClosedModeEnabled() {
|
public void limitClosedLoop(BooleanConstraint value) {
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package info.nightscout.androidaps.plugins.Wear;
|
package info.nightscout.androidaps.plugins.Wear;
|
||||||
|
|
||||||
import android.Manifest;
|
|
||||||
import android.os.HandlerThread;
|
import android.os.HandlerThread;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
|
@ -27,8 +26,8 @@ import info.nightscout.androidaps.db.Source;
|
||||||
import info.nightscout.androidaps.db.TempTarget;
|
import info.nightscout.androidaps.db.TempTarget;
|
||||||
import info.nightscout.androidaps.interfaces.APSInterface;
|
import info.nightscout.androidaps.interfaces.APSInterface;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
|
import info.nightscout.androidaps.interfaces.constrains.BooleanConstraint;
|
||||||
import info.nightscout.androidaps.plugins.Actions.dialogs.FillDialog;
|
import info.nightscout.androidaps.plugins.Actions.dialogs.FillDialog;
|
||||||
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
|
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
|
@ -436,7 +435,9 @@ public class ActionStringHandler {
|
||||||
// decide if enabled/disabled closed/open; what Plugin as APS?
|
// decide if enabled/disabled closed/open; what Plugin as APS?
|
||||||
final LoopPlugin activeloop = MainApp.getConfigBuilder().getActiveLoop();
|
final LoopPlugin activeloop = MainApp.getConfigBuilder().getActiveLoop();
|
||||||
if (activeloop != null && activeloop.isEnabled(activeloop.getType())) {
|
if (activeloop != null && activeloop.isEnabled(activeloop.getType())) {
|
||||||
if (MainApp.getConfigBuilder().isClosedModeEnabled()) {
|
BooleanConstraint closedLoopEnabled = new BooleanConstraint(true);
|
||||||
|
MainApp.getConfigBuilder().limitClosedLoop(closedLoopEnabled);
|
||||||
|
if (closedLoopEnabled.get()) {
|
||||||
ret += "CLOSED LOOP\n";
|
ret += "CLOSED LOOP\n";
|
||||||
} else {
|
} else {
|
||||||
ret += "OPEN LOOP\n";
|
ret += "OPEN LOOP\n";
|
||||||
|
|
|
@ -962,8 +962,9 @@
|
||||||
<string name="profileswitch_ismissing">ProfileSwitch missing. Please do a profile switch or press \"Activate Profile\" in the LocalProfile.</string>
|
<string name="profileswitch_ismissing">ProfileSwitch missing. Please do a profile switch or press \"Activate Profile\" in the LocalProfile.</string>
|
||||||
<string name="combo_bolus_count">Bolus count</string>
|
<string name="combo_bolus_count">Bolus count</string>
|
||||||
<string name="combo_tbr_count">TBR count</string>
|
<string name="combo_tbr_count">TBR count</string>
|
||||||
<string name="objective1notstarted">Objective 1 not started</string>
|
<string name="objectivenotstarted" formatted="false">Objective %d not started</string>
|
||||||
<string name="pumpisnottempbasalcapable">Pump is not temp basal capable</string>
|
<string name="pumpisnottempbasalcapable">Pump is not temp basal capable</string>
|
||||||
<string name="novalidbasalrate">No valid basal rate read from pump</string>
|
<string name="novalidbasalrate">No valid basal rate read from pump</string>
|
||||||
|
<string name="closedmodedisabledinpreferences">Closed loop mode disabled in preferences</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue