Add basic Engineering mode.

- Insight plugin disabled unless EM enabled
- Closed loop constrainted unless EM enabled.
This commit is contained in:
Johannes Mockenhaupt 2018-03-05 22:30:48 +01:00
parent e088b4df78
commit 090e1b13f8
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
2 changed files with 8 additions and 1 deletions

View file

@ -20,6 +20,7 @@ import net.danlew.android.joda.JodaTimeAndroid;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import info.nightscout.androidaps.Services.Intents; import info.nightscout.androidaps.Services.Intents;
@ -95,6 +96,9 @@ public class MainApp extends Application {
private static AckAlarmReceiver ackAlarmReciever = new AckAlarmReceiver(); private static AckAlarmReceiver ackAlarmReciever = new AckAlarmReceiver();
private LocalBroadcastManager lbm; private LocalBroadcastManager lbm;
public static boolean devBranch;
public static boolean engineeringMode;
@Override @Override
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
@ -139,7 +143,7 @@ public class MainApp extends Application {
if (Config.DANAR) pluginsList.add(DanaRv2Plugin.getPlugin()); if (Config.DANAR) pluginsList.add(DanaRv2Plugin.getPlugin());
if (Config.DANAR) pluginsList.add(DanaRSPlugin.getPlugin()); if (Config.DANAR) pluginsList.add(DanaRSPlugin.getPlugin());
pluginsList.add(CareportalPlugin.getPlugin()); pluginsList.add(CareportalPlugin.getPlugin());
// if (Config.DANAR) pluginsList.add(InsightPumpPlugin.getPlugin()); // <-- Enable Insight plugin here if (Config.DANAR && engineeringMode) pluginsList.add(InsightPumpPlugin.getPlugin()); // <-- Enable Insight plugin here
if (Config.MDI) pluginsList.add(MDIPlugin.getPlugin()); if (Config.MDI) pluginsList.add(MDIPlugin.getPlugin());
if (Config.VIRTUALPUMP) pluginsList.add(VirtualPumpPlugin.getPlugin()); if (Config.VIRTUALPUMP) pluginsList.add(VirtualPumpPlugin.getPlugin());
if (Config.APS) pluginsList.add(LoopPlugin.getPlugin()); if (Config.APS) pluginsList.add(LoopPlugin.getPlugin());
@ -195,6 +199,8 @@ public class MainApp extends Application {
} }
}).start(); }).start();
engineeringMode = new File(System.getProperty("EXT_FILES_DIR"),"engineering_mode").canRead();
devBranch = BuildConfig.VERSION.contains("dev");
} }
private void registerLocalBroadcastReceiver() { private void registerLocalBroadcastReceiver() {

View file

@ -102,6 +102,7 @@ public class SafetyPlugin implements PluginBase, ConstraintsInterface {
**/ **/
@Override @Override
public boolean isClosedModeEnabled() { public boolean isClosedModeEnabled() {
if (MainApp.devBranch && !MainApp.engineeringMode) return false;
String mode = SP.getString("aps_mode", "open"); String mode = SP.getString("aps_mode", "open");
return mode.equals("closed") && BuildConfig.CLOSEDLOOP; return mode.equals("closed") && BuildConfig.CLOSEDLOOP;
} }