autosensDataTable = iobCobCalculatorPlugin.getAutosensDataTable();
if (bucketed_data == null || bucketed_data.size() < 3) {
- log.debug("Aborting calculation thread (No bucketed data available): " + from);
+ if (L.isEnabled(L.AUTOSENS))
+ log.debug("Aborting calculation thread (No bucketed data available): " + from);
return;
}
long prevDataTime = IobCobCalculatorPlugin.roundUpTime(bucketed_data.get(bucketed_data.size() - 3).date);
- log.debug("Prev data time: " + new Date(prevDataTime).toLocaleString());
+ if (L.isEnabled(L.AUTOSENS))
+ log.debug("Prev data time: " + new Date(prevDataTime).toLocaleString());
AutosensData previous = autosensDataTable.get(prevDataTime);
// start from oldest to be able sub cob
for (int i = bucketed_data.size() - 4; i >= 0; i--) {
@@ -107,7 +112,8 @@ public class IobCobThread extends Thread {
if (iobCobCalculatorPlugin.stopCalculationTrigger) {
iobCobCalculatorPlugin.stopCalculationTrigger = false;
- log.debug("Aborting calculation thread (trigger): " + from);
+ if (L.isEnabled(L.AUTOSENS))
+ log.debug("Aborting calculation thread (trigger): " + from);
return;
}
// check if data already exists
@@ -124,11 +130,12 @@ public class IobCobThread extends Thread {
Profile profile = MainApp.getConfigBuilder().getProfile(bgTime);
if (profile == null) {
- log.debug("Aborting calculation thread (no profile): " + from);
+ if (L.isEnabled(L.AUTOSENS))
+ log.debug("Aborting calculation thread (no profile): " + from);
return; // profile not set yet
}
- if (Config.logAutosensData)
+ if (L.isEnabled(L.AUTOSENS))
log.debug("Processing calculation thread: " + from + " (" + i + "/" + bucketed_data.size() + ")");
double sens = Profile.toMgdl(profile.getIsf(bgTime), profile.getUnits());
@@ -170,7 +177,7 @@ public class IobCobThread extends Thread {
AutosensData hourAgoData = iobCobCalculatorPlugin.getAutosensData(hourago);
if (hourAgoData != null) {
int initialIndex = autosensDataTable.indexOfKey(hourAgoData.time);
- if (Config.logAutosensData)
+ if (L.isEnabled(L.AUTOSENS))
log.debug(">>>>> bucketed_data.size()=" + bucketed_data.size() + " i=" + i + "hourAgoData=" + hourAgoData.toString());
int past = 1;
try {
@@ -186,7 +193,7 @@ public class IobCobThread extends Thread {
minDeviation = ad.avgDeviation;
}
- //if (Config.logAutosensData)
+ //if (Config.isEnabled(L.AUTOSENS))
// log.debug("Deviations: " + new Date(bgTime) + new Date(ad.time) + " avgDeviation=" + avgDeviation + " deviationSlope=" + deviationSlope + " slopeFromMaxDeviation=" + slopeFromMaxDeviation + " slopeFromMinDeviation=" + slopeFromMinDeviation);
}
} catch (Exception e) {
@@ -267,13 +274,13 @@ public class IobCobThread extends Thread {
previous = autosensData;
if (bgTime < now())
autosensDataTable.put(bgTime, autosensData);
- if (Config.logAutosensData)
+ if (L.isEnabled(L.AUTOSENS))
log.debug("Running detectSensitivity from: " + DateUtil.dateAndTimeString(oldestTimeWithData) + " to: " + DateUtil.dateAndTimeString(bgTime) + " lastDataTime:" + iobCobCalculatorPlugin.lastDataTime());
AutosensResult sensitivity = iobCobCalculatorPlugin.detectSensitivityWithLock(oldestTimeWithData, bgTime);
- if (Config.logAutosensData)
+ if (L.isEnabled(L.AUTOSENS))
log.debug("Sensitivity result: " + sensitivity.toString());
autosensData.autosensResult = sensitivity;
- if (Config.logAutosensData)
+ if (L.isEnabled(L.AUTOSENS))
log.debug(autosensData.toString());
}
}
@@ -284,7 +291,8 @@ public class IobCobThread extends Thread {
} finally {
mWakeLock.release();
MainApp.bus().post(new EventIobCalculationProgress(""));
- log.debug("AUTOSENSDATA thread ended: " + from);
+ if (L.isEnabled(L.AUTOSENS))
+ log.debug("AUTOSENSDATA thread ended: " + from);
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/APSResult.java b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/APSResult.java
index ce63ad67e5..8ea19fe8a7 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/APSResult.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/APSResult.java
@@ -18,6 +18,7 @@ import info.nightscout.androidaps.data.IobTotal;
import info.nightscout.androidaps.db.BgReading;
import info.nightscout.androidaps.interfaces.Constraint;
import info.nightscout.androidaps.interfaces.PumpInterface;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.utils.DecimalFormatter;
@@ -25,7 +26,7 @@ import info.nightscout.utils.DecimalFormatter;
* Created by mike on 09.06.2016.
*/
public class APSResult {
- private static Logger log = LoggerFactory.getLogger(APSResult.class);
+ private static Logger log = LoggerFactory.getLogger(L.APS);
public long date = 0;
public String reason;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/DeviceStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/DeviceStatus.java
index acf59865d1..2c2bb1a2ee 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/DeviceStatus.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/DeviceStatus.java
@@ -1,17 +1,11 @@
package info.nightscout.androidaps.plugins.Loop;
-import android.content.Context;
-import android.content.Intent;
-import android.os.Bundle;
-
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.MainApp;
-import info.nightscout.androidaps.Services.Intents;
-import info.nightscout.androidaps.plugins.NSClientInternal.data.DbLogger;
+import info.nightscout.androidaps.logging.L;
/*
{
@@ -371,7 +365,7 @@ import info.nightscout.androidaps.plugins.NSClientInternal.data.DbLogger;
*/
public class DeviceStatus {
- private static Logger log = LoggerFactory.getLogger(DeviceStatus.class);
+ private static Logger log = LoggerFactory.getLogger(L.APS);
public String device = null;
public JSONObject pump = null;
@@ -381,12 +375,12 @@ public class DeviceStatus {
public int uploaderBattery = 0;
public String created_at = null;
- public JSONObject mongoRecord () {
+ public JSONObject mongoRecord() {
JSONObject record = new JSONObject();
try {
- if (device != null) record.put("device" , device);
- if (pump != null) record.put("pump" , pump);
+ if (device != null) record.put("device", device);
+ if (pump != null) record.put("pump", pump);
if (suggested != null) {
JSONObject openaps = new JSONObject();
if (enacted != null) openaps.put("enacted", enacted);
@@ -395,7 +389,7 @@ public class DeviceStatus {
record.put("openaps", openaps);
}
if (uploaderBattery != 0) record.put("uploaderBattery", uploaderBattery);
- if (created_at != null) record.put("created_at" , created_at);
+ if (created_at != null) record.put("created_at", created_at);
} catch (JSONException e) {
log.error("Unhandled exception", e);
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopFragment.java
index 7fa810f8c0..0c0e31fb03 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopFragment.java
@@ -28,8 +28,6 @@ import info.nightscout.androidaps.plugins.Loop.events.EventLoopUpdateGui;
import info.nightscout.utils.FabricPrivacy;
public class LoopFragment extends SubscriberFragment {
- private static Logger log = LoggerFactory.getLogger(LoopFragment.class);
-
@BindView(R.id.loop_run)
Button runNowButton;
@BindView(R.id.loop_lastrun)
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java
index 480646ccfc..4200317cef 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java
@@ -21,7 +21,6 @@ import org.slf4j.LoggerFactory;
import java.util.Date;
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainActivity;
import info.nightscout.androidaps.MainApp;
@@ -32,36 +31,36 @@ import info.nightscout.androidaps.db.BgReading;
import info.nightscout.androidaps.db.DatabaseHelper;
import info.nightscout.androidaps.events.Event;
import info.nightscout.androidaps.events.EventNewBG;
-import info.nightscout.androidaps.events.EventTreatmentChange;
import info.nightscout.androidaps.interfaces.APSInterface;
import info.nightscout.androidaps.interfaces.Constraint;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.PumpInterface;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished;
import info.nightscout.androidaps.plugins.Loop.events.EventLoopSetLastRunGui;
import info.nightscout.androidaps.plugins.Loop.events.EventLoopUpdateGui;
import info.nightscout.androidaps.plugins.Loop.events.EventNewOpenLoopNotification;
+import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.androidaps.queue.Callback;
import info.nightscout.androidaps.queue.commands.Command;
import info.nightscout.utils.FabricPrivacy;
-import info.nightscout.utils.NSUpload;
import info.nightscout.utils.SP;
/**
* Created by mike on 05.08.2016.
*/
public class LoopPlugin extends PluginBase {
- private static Logger log = LoggerFactory.getLogger(LoopPlugin.class);
+ private static Logger log = LoggerFactory.getLogger(L.APS);
- public static final String CHANNEL_ID = "AndroidAPS-Openloop";
+ private static final String CHANNEL_ID = "AndroidAPS-Openloop";
- long lastBgTriggeredRun = 0;
+ private long lastBgTriggeredRun = 0;
- protected static LoopPlugin loopPlugin;
+ private static LoopPlugin loopPlugin;
@NonNull
public static LoopPlugin getPlugin() {
@@ -132,15 +131,15 @@ public class LoopPlugin extends PluginBase {
PumpInterface pump = ConfigBuilderPlugin.getActivePump();
return pump == null || pump.getPumpDescription().isTempBasalCapable;
}
-
+
/**
* This method is triggered once autosens calculation has completed, so the LoopPlugin
* has current data to work with. However, autosens calculation can be triggered by multiple
* sources and currently only a new BG should trigger a loop run. Hence we return early if
* the event causing the calculation is not EventNewBg.
- *
- * Callers of {@link info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin#runCalculation(String, long, boolean, Event)}
- * are sources triggering a calculation which triggers this method upon completion.
+ *
+ * Callers of {@link info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin#runCalculation(String, long, boolean, Event)}
+ * are sources triggering a calculation which triggers this method upon completion.
*/
@Subscribe
public void onStatusEvent(final EventAutosensCalculationFinished ev) {
@@ -249,19 +248,20 @@ public class LoopPlugin extends PluginBase {
return isDisconnected;
}
- public synchronized void invoke(String initiator, boolean allowNotification){
+ public synchronized void invoke(String initiator, boolean allowNotification) {
invoke(initiator, allowNotification, false);
}
public synchronized void invoke(String initiator, boolean allowNotification, boolean tempBasalFallback) {
try {
- if (Config.logFunctionCalls)
+ if (L.isEnabled(L.APS))
log.debug("invoke from " + initiator);
Constraint loopEnabled = MainApp.getConstraintChecker().isLoopInvokationAllowed();
if (!loopEnabled.value()) {
String message = MainApp.gs(R.string.loopdisabled) + "\n" + loopEnabled.getReasons();
- log.debug(message);
+ if (L.isEnabled(L.APS))
+ log.debug(message);
MainApp.bus().post(new EventLoopSetLastRunGui(message));
return;
}
@@ -274,7 +274,8 @@ public class LoopPlugin extends PluginBase {
Profile profile = MainApp.getConfigBuilder().getProfile();
if (!MainApp.getConfigBuilder().isProfileValid("Loop")) {
- log.debug(MainApp.gs(R.string.noprofileselected));
+ if (L.isEnabled(L.APS))
+ log.debug(MainApp.gs(R.string.noprofileselected));
MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.gs(R.string.noprofileselected)));
return;
}
@@ -304,7 +305,8 @@ public class LoopPlugin extends PluginBase {
// safety check for multiple SMBs
long lastBolusTime = TreatmentsPlugin.getPlugin().getLastBolusTime();
if (lastBolusTime != 0 && lastBolusTime + 3 * 60 * 1000 > System.currentTimeMillis()) {
- log.debug("SMB requsted but still in 3 min interval");
+ if (L.isEnabled(L.APS))
+ log.debug("SMB requsted but still in 3 min interval");
resultAfterConstraints.smb = 0;
}
@@ -319,13 +321,15 @@ public class LoopPlugin extends PluginBase {
NSUpload.uploadDeviceStatus();
if (isSuspended()) {
- log.debug(MainApp.gs(R.string.loopsuspended));
+ if (L.isEnabled(L.APS))
+ log.debug(MainApp.gs(R.string.loopsuspended));
MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.gs(R.string.loopsuspended)));
return;
}
if (pump.isSuspended()) {
- log.debug(MainApp.gs(R.string.pumpsuspended));
+ if (L.isEnabled(L.APS))
+ log.debug(MainApp.gs(R.string.pumpsuspended));
MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.gs(R.string.pumpsuspended)));
return;
}
@@ -412,7 +416,7 @@ public class LoopPlugin extends PluginBase {
MainApp.bus().post(new EventLoopUpdateGui());
} finally {
- if (Config.logFunctionCalls)
+ if (L.isEnabled(L.APS))
log.debug("invoke end");
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientFragment.java
index 3bff1c9be3..64e2091eb8 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientFragment.java
@@ -34,8 +34,6 @@ import info.nightscout.utils.FabricPrivacy;
import info.nightscout.utils.SP;
public class NSClientFragment extends SubscriberFragment implements View.OnClickListener, CompoundButton.OnCheckedChangeListener {
- private static Logger log = LoggerFactory.getLogger(NSClientFragment.class);
-
private TextView logTextView;
private TextView queueTextView;
private TextView urlTextView;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientPlugin.java
index 6949cdc8b1..cc9d843368 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientPlugin.java
@@ -29,6 +29,7 @@ import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientNewLog;
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientStatus;
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientUpdateGUI;
@@ -37,7 +38,7 @@ import info.nightscout.utils.SP;
import info.nightscout.utils.ToastUtils;
public class NSClientPlugin extends PluginBase {
- private static Logger log = LoggerFactory.getLogger(NSClientPlugin.class);
+ private Logger log = LoggerFactory.getLogger(L.NSCLIENT);
static NSClientPlugin nsClientPlugin;
@@ -53,8 +54,8 @@ public class NSClientPlugin extends PluginBase {
private final List listLog = new ArrayList<>();
Spanned textLog = Html.fromHtml("");
- public boolean paused = false;
- boolean autoscroll = true;
+ public boolean paused;
+ boolean autoscroll;
public String status = "";
@@ -132,12 +133,14 @@ public class NSClientPlugin extends PluginBase {
private ServiceConnection mConnection = new ServiceConnection() {
public void onServiceDisconnected(ComponentName name) {
- log.debug("Service is disconnected");
+ if (L.isEnabled(L.NSCLIENT))
+ log.debug("Service is disconnected");
nsClientService = null;
}
public void onServiceConnected(ComponentName name, IBinder service) {
- log.debug("Service is connected");
+ if (L.isEnabled(L.NSCLIENT))
+ log.debug("Service is connected");
NSClientService.LocalBinder mLocalBinder = (NSClientService.LocalBinder) service;
if (mLocalBinder != null) // is null when running in roboelectric
nsClientService = mLocalBinder.getServiceInstance();
@@ -155,7 +158,8 @@ public class NSClientPlugin extends PluginBase {
@Subscribe
public void onStatusEvent(final EventNSClientNewLog ev) {
addToLog(ev);
- log.debug(ev.action + " " + ev.logText);
+ if (L.isEnabled(L.NSCLIENT))
+ log.debug(ev.action + " " + ev.logText);
}
@Subscribe
@@ -165,30 +169,24 @@ public class NSClientPlugin extends PluginBase {
}
synchronized void clearLog() {
- handler.post(new Runnable() {
- @Override
- public void run() {
- synchronized (listLog) {
- listLog.clear();
- }
- MainApp.bus().post(new EventNSClientUpdateGUI());
+ handler.post(() -> {
+ synchronized (listLog) {
+ listLog.clear();
}
+ MainApp.bus().post(new EventNSClientUpdateGUI());
});
}
private synchronized void addToLog(final EventNSClientNewLog ev) {
- handler.post(new Runnable() {
- @Override
- public void run() {
- synchronized (listLog) {
- listLog.add(ev);
- // remove the first line if log is too large
- if (listLog.size() >= Constants.MAX_LOG_LINES) {
- listLog.remove(0);
- }
+ handler.post(() -> {
+ synchronized (listLog) {
+ listLog.add(ev);
+ // remove the first line if log is too large
+ if (listLog.size() >= Constants.MAX_LOG_LINES) {
+ listLog.remove(0);
}
- MainApp.bus().post(new EventNSClientUpdateGUI());
}
+ MainApp.bus().post(new EventNSClientUpdateGUI());
});
}
diff --git a/app/src/main/java/info/nightscout/utils/NSUpload.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSUpload.java
similarity index 98%
rename from app/src/main/java/info/nightscout/utils/NSUpload.java
rename to app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSUpload.java
index 00d5e39821..a3094a4646 100644
--- a/app/src/main/java/info/nightscout/utils/NSUpload.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSUpload.java
@@ -1,4 +1,4 @@
-package info.nightscout.utils;
+package info.nightscout.androidaps.plugins.NSClientInternal;
import android.content.Context;
import android.content.Intent;
@@ -23,7 +23,8 @@ import java.util.Locale;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
-import info.nightscout.androidaps.Services.Intents;
+import info.nightscout.androidaps.logging.L;
+import info.nightscout.androidaps.services.Intents;
import info.nightscout.androidaps.data.DetailedBolusInfo;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.db.BgReading;
@@ -37,13 +38,16 @@ import info.nightscout.androidaps.plugins.Loop.APSResult;
import info.nightscout.androidaps.plugins.Loop.DeviceStatus;
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.androidaps.plugins.NSClientInternal.data.DbLogger;
+import info.nightscout.utils.BatteryLevel;
+import info.nightscout.utils.DateUtil;
+import info.nightscout.utils.SP;
/**
* Created by mike on 26.05.2017.
*/
public class NSUpload {
- private static Logger log = LoggerFactory.getLogger(NSUpload.class);
+ private static Logger log = LoggerFactory.getLogger(L.NSCLIENT);
public static void uploadTempBasalStartAbsolute(TemporaryBasal temporaryBasal, Double originalExtendedAmount) {
try {
@@ -232,7 +236,8 @@ public class NSUpload {
deviceStatus.enacted.put("requested", requested);
}
} else {
- log.debug("OpenAPS data too old to upload");
+ if (L.isEnabled(L.NSCLIENT))
+ log.debug("OpenAPS data too old to upload");
}
deviceStatus.device = "openaps://" + Build.MANUFACTURER + " " + Build.MODEL;
JSONObject pumpstatus = ConfigBuilderPlugin.getActivePump().getJSONStatus(profile, profileName);
@@ -490,7 +495,7 @@ public class NSUpload {
try {
data.put("eventType", "Note");
data.put("created_at", DateUtil.toISOString(new Date()));
- data.put("notes", MainApp.gs(R.string.androidaps_start)+" - "+ Build.MANUFACTURER + " "+ Build.MODEL);
+ data.put("notes", MainApp.gs(R.string.androidaps_start) + " - " + Build.MANUFACTURER + " " + Build.MODEL);
} catch (JSONException e) {
log.error("Unhandled exception", e);
}
@@ -500,7 +505,7 @@ public class NSUpload {
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent);
DbLogger.dbAdd(intent, data.toString());
- }
+ }
}
public static void uploadEvent(String careportalEvent, long time, @Nullable String notes) {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/UploadQueue.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/UploadQueue.java
index 17cc1dced3..9c0284029c 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/UploadQueue.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/UploadQueue.java
@@ -16,13 +16,14 @@ import java.sql.SQLException;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.db.DatabaseHelper;
import info.nightscout.androidaps.db.DbRequest;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.NSClientInternal.services.NSClientService;
/**
* Created by mike on 21.02.2016.
*/
public class UploadQueue {
- private static Logger log = LoggerFactory.getLogger(UploadQueue.class);
+ private static Logger log = LoggerFactory.getLogger(L.NSCLIENT);
public static String status() {
return "QUEUE: " + MainApp.getDbHelper().size(DatabaseHelper.DATABASE_DBREQUESTS);
@@ -43,15 +44,13 @@ public class UploadQueue {
public static void add(final DbRequest dbr) {
startService();
if (NSClientService.handler != null) {
- NSClientService.handler.post(new Runnable() {
- @Override
- public void run() {
- log.debug("QUEUE adding: " + dbr.data);
- MainApp.getDbHelper().create(dbr);
- NSClientPlugin plugin = NSClientPlugin.getPlugin();
- if (plugin != null) {
- plugin.resend("newdata");
- }
+ NSClientService.handler.post(() -> {
+ if (L.isEnabled(L.NSCLIENT))
+ log.debug("Adding to queue: " + dbr.data);
+ MainApp.getDbHelper().create(dbr);
+ NSClientPlugin plugin = NSClientPlugin.getPlugin();
+ if (plugin != null) {
+ plugin.resend("newdata");
}
});
}
@@ -60,13 +59,12 @@ public class UploadQueue {
public static void clearQueue() {
startService();
if (NSClientService.handler != null) {
- NSClientService.handler.post(new Runnable() {
- @Override
- public void run() {
- log.debug("QUEUE ClearQueue");
- MainApp.getDbHelper().deleteAllDbRequests();
+ NSClientService.handler.post(() -> {
+ if (L.isEnabled(L.NSCLIENT))
+ log.debug("ClearQueue");
+ MainApp.getDbHelper().deleteAllDbRequests();
+ if (L.isEnabled(L.NSCLIENT))
log.debug(status());
- }
});
}
}
@@ -74,22 +72,20 @@ public class UploadQueue {
public static void removeID(final JSONObject record) {
startService();
if (NSClientService.handler != null) {
- NSClientService.handler.post(new Runnable() {
- @Override
- public void run() {
- try {
- String id;
- if (record.has("NSCLIENT_ID")) {
- id = record.getString("NSCLIENT_ID");
- } else {
- return;
- }
- if (MainApp.getDbHelper().deleteDbRequest(id) == 1) {
- log.debug("Removed item from UploadQueue. " + UploadQueue.status());
- }
- } catch (JSONException e) {
- log.error("Unhandled exception", e);
+ NSClientService.handler.post(() -> {
+ try {
+ String id;
+ if (record.has("NSCLIENT_ID")) {
+ id = record.getString("NSCLIENT_ID");
+ } else {
+ return;
}
+ if (MainApp.getDbHelper().deleteDbRequest(id) == 1) {
+ if (L.isEnabled(L.NSCLIENT))
+ log.debug("Removed item from UploadQueue. " + UploadQueue.status());
+ }
+ } catch (JSONException e) {
+ log.error("Unhandled exception", e);
}
});
}
@@ -100,18 +96,17 @@ public class UploadQueue {
return;
startService();
if (NSClientService.handler != null) {
- NSClientService.handler.post(new Runnable() {
- @Override
- public void run() {
- MainApp.getDbHelper().deleteDbRequestbyMongoId(action, _id);
- }
+ NSClientService.handler.post(() -> {
+ MainApp.getDbHelper().deleteDbRequestbyMongoId(action, _id);
+ if (L.isEnabled(L.NSCLIENT))
+ log.debug("Removing " + _id + " from UploadQueue. " + UploadQueue.status());
});
}
}
public String textList() {
String result = "";
- CloseableIterator iterator = null;
+ CloseableIterator iterator;
try {
iterator = MainApp.getDbHelper().getDbRequestInterator();
try {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSAddAck.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSAddAck.java
index e90dce3bec..ed9c4c3013 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSAddAck.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSAddAck.java
@@ -1,13 +1,13 @@
package info.nightscout.androidaps.plugins.NSClientInternal.acks;
import org.json.JSONArray;
-import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.events.Event;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientRestart;
import io.socket.client.Ack;
@@ -15,17 +15,18 @@ import io.socket.client.Ack;
* Created by mike on 29.12.2015.
*/
public class NSAddAck extends Event implements Ack {
- private static Logger log = LoggerFactory.getLogger(NSAddAck.class);
+ private static Logger log = LoggerFactory.getLogger(L.NSCLIENT);
public String _id = null;
public String nsClientID = null;
public JSONObject json = null;
- public void call(Object...args) {
+
+ public void call(Object... args) {
// Regular response
try {
JSONArray responsearray = (JSONArray) (args[0]);
JSONObject response = null;
- if (responsearray.length()>0) {
- response = responsearray.getJSONObject(0);
+ if (responsearray.length() > 0) {
+ response = responsearray.getJSONObject(0);
_id = response.getString("_id");
json = response;
if (response.has("NSCLIENT_ID")) {
@@ -35,6 +36,7 @@ public class NSAddAck extends Event implements Ack {
MainApp.bus().post(this);
return;
} catch (Exception e) {
+ log.error("Unhandled exception", e);
}
// Check for not authorized
try {
@@ -45,7 +47,8 @@ public class NSAddAck extends Event implements Ack {
MainApp.bus().post(new EventNSClientRestart());
return;
}
- log.debug("DBACCESS " + response.getString("result"));
+ if (L.isEnabled(L.NSCLIENT))
+ log.debug("DBACCESS " + response.getString("result"));
}
return;
} catch (Exception e) {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSUpdateAck.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSUpdateAck.java
index 2bf520da64..42534387b2 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSUpdateAck.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSUpdateAck.java
@@ -7,15 +7,16 @@ import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.events.Event;
+import info.nightscout.androidaps.logging.L;
import io.socket.client.Ack;
/**
* Created by mike on 21.02.2016.
*/
public class NSUpdateAck extends Event implements Ack {
- private static Logger log = LoggerFactory.getLogger(NSUpdateAck.class);
+ private static Logger log = LoggerFactory.getLogger(L.NSCLIENT);
public boolean result = false;
- public String _id = null;
+ public String _id;
public String action;
public void call(Object...args) {
JSONObject response = (JSONObject)args[0];
@@ -29,6 +30,7 @@ public class NSUpdateAck extends Event implements Ack {
}
MainApp.bus().post(this);
} catch (JSONException e) {
+ log.error("Unhandled exception", e);
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAckAlarm.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAckAlarm.java
index 216fa3d19a..b2db8d7ce3 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAckAlarm.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAckAlarm.java
@@ -2,18 +2,12 @@ package info.nightscout.androidaps.plugins.NSClientInternal.broadcasts;
import android.content.Context;
import android.content.Intent;
-import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.support.v4.content.LocalBroadcastManager;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.List;
-
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
-import info.nightscout.androidaps.Services.Intents;
+import info.nightscout.androidaps.services.Intents;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSAlarm;
import info.nightscout.utils.SP;
@@ -22,7 +16,6 @@ import info.nightscout.utils.SP;
*/
public class BroadcastAckAlarm {
- private static Logger log = LoggerFactory.getLogger(BroadcastAckAlarm.class);
public static void handleClearAlarm(NSAlarm originalAlarm, Context context, long silenceTimeInMsec) {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAlarm.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAlarm.java
index 0fee6600bd..7146f1814f 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAlarm.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAlarm.java
@@ -2,27 +2,20 @@ package info.nightscout.androidaps.plugins.NSClientInternal.broadcasts;
import android.content.Context;
import android.content.Intent;
-import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.support.v4.content.LocalBroadcastManager;
import org.json.JSONObject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.List;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
-import info.nightscout.androidaps.Services.Intents;
+import info.nightscout.androidaps.services.Intents;
import info.nightscout.utils.SP;
/**
* Created by mike on 26.06.2016.
*/
public class BroadcastAlarm {
- private static Logger log = LoggerFactory.getLogger(BroadcastAlarm.class);
-
public static void handleAlarm(JSONObject alarm, Context context) {
Bundle bundle = new Bundle();
bundle.putString("data", alarm.toString());
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAnnouncement.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAnnouncement.java
index 9b133c2551..f7cecf0445 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAnnouncement.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAnnouncement.java
@@ -2,28 +2,20 @@ package info.nightscout.androidaps.plugins.NSClientInternal.broadcasts;
import android.content.Context;
import android.content.Intent;
-import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.support.v4.content.LocalBroadcastManager;
-import org.json.JSONArray;
import org.json.JSONObject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.List;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
-import info.nightscout.androidaps.Services.Intents;
+import info.nightscout.androidaps.services.Intents;
import info.nightscout.utils.SP;
/**
* Created by mike on 26.06.2016.
*/
public class BroadcastAnnouncement {
- private static Logger log = LoggerFactory.getLogger(BroadcastAnnouncement.class);
-
public static void handleAnnouncement(JSONObject announcement, Context context) {
Bundle bundle = new Bundle();
bundle.putString("data", announcement.toString());
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastCals.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastCals.java
index 7580a00088..6a1b9746e4 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastCals.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastCals.java
@@ -2,27 +2,20 @@ package info.nightscout.androidaps.plugins.NSClientInternal.broadcasts;
import android.content.Context;
import android.content.Intent;
-import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.support.v4.content.LocalBroadcastManager;
import org.json.JSONArray;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.List;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
-import info.nightscout.androidaps.Services.Intents;
+import info.nightscout.androidaps.services.Intents;
import info.nightscout.utils.SP;
/**
* Created by mike on 26.06.2016.
*/
public class BroadcastCals {
- private static Logger log = LoggerFactory.getLogger(BroadcastCals.class);
-
public static void handleNewCal(JSONArray cals, Context context, boolean isDelta) {
Bundle bundle = new Bundle();
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastClearAlarm.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastClearAlarm.java
index 23406837a7..b63d2e5a60 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastClearAlarm.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastClearAlarm.java
@@ -2,27 +2,20 @@ package info.nightscout.androidaps.plugins.NSClientInternal.broadcasts;
import android.content.Context;
import android.content.Intent;
-import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.support.v4.content.LocalBroadcastManager;
import org.json.JSONObject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.List;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
-import info.nightscout.androidaps.Services.Intents;
+import info.nightscout.androidaps.services.Intents;
import info.nightscout.utils.SP;
/**
* Created by mike on 26.06.2016.
*/
public class BroadcastClearAlarm {
- private static Logger log = LoggerFactory.getLogger(BroadcastClearAlarm.class);
-
public static void handleClearAlarm(JSONObject clearalarm, Context context) {
Bundle bundle = new Bundle();
bundle.putString("data", clearalarm.toString());
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastDeviceStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastDeviceStatus.java
index 59f5ab136c..992ff00c81 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastDeviceStatus.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastDeviceStatus.java
@@ -2,45 +2,20 @@ package info.nightscout.androidaps.plugins.NSClientInternal.broadcasts;
import android.content.Context;
import android.content.Intent;
-import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.support.v4.content.LocalBroadcastManager;
import org.json.JSONArray;
-import org.json.JSONObject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import java.util.List;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
-import info.nightscout.androidaps.Services.Intents;
+import info.nightscout.androidaps.services.Intents;
import info.nightscout.utils.SP;
public class BroadcastDeviceStatus {
- private static Logger log = LoggerFactory.getLogger(BroadcastDeviceStatus.class);
-
- public static void handleNewDeviceStatus(JSONObject status, Context context, boolean isDelta) {
- Bundle bundle = new Bundle();
- bundle.putString("devicestatus", status.toString());
- bundle.putBoolean("delta", isDelta);
- Intent intent = new Intent(Intents.ACTION_NEW_DEVICESTATUS);
- intent.putExtras(bundle);
- intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
- LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
-
- if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
- bundle = new Bundle();
- bundle.putString("devicestatus", status.toString());
- bundle.putBoolean("delta", isDelta);
- intent = new Intent(Intents.ACTION_NEW_DEVICESTATUS);
- intent.putExtras(bundle);
- intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
- context.sendBroadcast(intent);
- }
- }
public static void handleNewDeviceStatus(JSONArray statuses, Context context, boolean isDelta) {
List splitted = BroadcastTreatment.splitArray(statuses);
@@ -67,31 +42,4 @@ public class BroadcastDeviceStatus {
}
}
}
-
- public static void handleNewFoods(JSONArray foods, Context context, boolean isDelta) {
-
- List splitted = BroadcastTreatment.splitArray(foods);
- for (JSONArray part: splitted) {
- Bundle bundle = new Bundle();
- bundle.putString("foods", part.toString());
- bundle.putBoolean("delta", isDelta);
- Intent intent = new Intent(Intents.ACTION_NEW_FOOD);
- intent.putExtras(bundle);
- intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
- LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
- }
-
- if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
- splitted = BroadcastTreatment.splitArray(foods);
- for (JSONArray part : splitted) {
- Bundle bundle = new Bundle();
- bundle.putString("foods", part.toString());
- bundle.putBoolean("delta", isDelta);
- Intent intent = new Intent(Intents.ACTION_NEW_FOOD);
- intent.putExtras(bundle);
- intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
- context.sendBroadcast(intent);
- }
- }
- }
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastFood.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastFood.java
index dbb3385fbb..31a582ade2 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastFood.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastFood.java
@@ -6,26 +6,18 @@ import android.os.Bundle;
import android.support.v4.content.LocalBroadcastManager;
import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import java.util.ArrayList;
import java.util.List;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
-import info.nightscout.androidaps.Services.Intents;
-import info.nightscout.androidaps.plugins.NSClientInternal.data.NSTreatment;
+import info.nightscout.androidaps.services.Intents;
import info.nightscout.utils.SP;
/**
* Created by mike on 20.02.2016.
*/
public class BroadcastFood {
- private static Logger log = LoggerFactory.getLogger(BroadcastFood.class);
-
public static void handleNewFood(JSONArray foods, Context context, boolean isDelta) {
List splitted = BroadcastTreatment.splitArray(foods);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastMbgs.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastMbgs.java
index a715747791..2dc48eb9a4 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastMbgs.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastMbgs.java
@@ -2,27 +2,20 @@ package info.nightscout.androidaps.plugins.NSClientInternal.broadcasts;
import android.content.Context;
import android.content.Intent;
-import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.support.v4.content.LocalBroadcastManager;
import org.json.JSONArray;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.List;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
-import info.nightscout.androidaps.Services.Intents;
+import info.nightscout.androidaps.services.Intents;
import info.nightscout.utils.SP;
/**
* Created by mike on 26.06.2016.
*/
public class BroadcastMbgs {
- private static Logger log = LoggerFactory.getLogger(BroadcastMbgs.class);
-
public static void handleNewMbg(JSONArray mbgs, Context context, boolean isDelta) {
Bundle bundle = new Bundle();
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastProfile.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastProfile.java
index 3802b09657..ae76212105 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastProfile.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastProfile.java
@@ -2,18 +2,12 @@ package info.nightscout.androidaps.plugins.NSClientInternal.broadcasts;
import android.content.Context;
import android.content.Intent;
-import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.support.v4.content.LocalBroadcastManager;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.List;
-
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
-import info.nightscout.androidaps.Services.Intents;
+import info.nightscout.androidaps.services.Intents;
import info.nightscout.androidaps.data.ProfileStore;
import info.nightscout.utils.SP;
@@ -22,8 +16,6 @@ import info.nightscout.utils.SP;
* Created by mike on 20.02.2016.
*/
public class BroadcastProfile {
- private static Logger log = LoggerFactory.getLogger(BroadcastProfile.class);
-
public static void handleNewTreatment(ProfileStore profile, Context context, boolean isDelta) {
Bundle bundle = new Bundle();
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastQueueStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastQueueStatus.java
deleted file mode 100644
index abc49be18a..0000000000
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastQueueStatus.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package info.nightscout.androidaps.plugins.NSClientInternal.broadcasts;
-
-import android.content.Context;
-import android.content.Intent;
-import android.os.Bundle;
-import android.os.PowerManager;
-
-import info.nightscout.androidaps.R;
-import info.nightscout.androidaps.Services.Intents;
-import info.nightscout.utils.SP;
-
-/**
- * Created by mike on 28.02.2016.
- */
-public class BroadcastQueueStatus {
- public static void handleNewStatus(int size, Context context) {
-
- if(!SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) return;
-
- PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
- PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
- "sendQueue");
- wakeLock.acquire();
- try {
- Bundle bundle = new Bundle();
- bundle.putInt("size", size);
- Intent intent = new Intent(Intents.ACTION_QUEUE_STATUS);
- intent.putExtras(bundle);
- intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
- context.sendBroadcast(intent);
- } finally {
- wakeLock.release();
- }
- }
-}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastSgvs.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastSgvs.java
index 65a90f3b74..b15fe606fb 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastSgvs.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastSgvs.java
@@ -2,49 +2,22 @@ package info.nightscout.androidaps.plugins.NSClientInternal.broadcasts;
import android.content.Context;
import android.content.Intent;
-import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.support.v4.content.LocalBroadcastManager;
import org.json.JSONArray;
-import org.json.JSONObject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import java.util.List;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
-import info.nightscout.androidaps.Services.Intents;
+import info.nightscout.androidaps.services.Intents;
import info.nightscout.utils.SP;
/**
* Created by mike on 22.02.2016.
*/
public class BroadcastSgvs {
- private static Logger log = LoggerFactory.getLogger(BroadcastSgvs.class);
-
- public static void handleNewSgv(JSONObject sgv, Context context, boolean isDelta) {
-
- Bundle bundle = new Bundle();
- bundle.putString("sgv", sgv.toString());
- bundle.putBoolean("delta", isDelta);
- Intent intent = new Intent(Intents.ACTION_NEW_SGV);
- intent.putExtras(bundle);
- intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
- LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
-
- if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
- bundle = new Bundle();
- bundle.putString("sgv", sgv.toString());
- bundle.putBoolean("delta", isDelta);
- intent = new Intent(Intents.ACTION_NEW_SGV);
- intent.putExtras(bundle);
- intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
- context.sendBroadcast(intent);
- }
- }
-
public static void handleNewSgv(JSONArray sgvs, Context context, boolean isDelta) {
List splitted = BroadcastTreatment.splitArray(sgvs);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastStatus.java
index a2b6e64aec..da28fe9881 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastStatus.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastStatus.java
@@ -3,18 +3,16 @@ package info.nightscout.androidaps.plugins.NSClientInternal.broadcasts;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.support.v4.content.LocalBroadcastManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.List;
-
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
-import info.nightscout.androidaps.Services.Intents;
+import info.nightscout.androidaps.logging.L;
+import info.nightscout.androidaps.services.Intents;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSettingsStatus;
import info.nightscout.androidaps.plugins.NSClientInternal.services.NSClientService;
import info.nightscout.utils.SP;
@@ -23,7 +21,7 @@ import info.nightscout.utils.SP;
* Created by mike on 24.02.2016.
*/
public class BroadcastStatus {
- private static Logger log = LoggerFactory.getLogger(BroadcastStatus.class);
+ private static Logger log = LoggerFactory.getLogger(L.NSCLIENT);
public static void handleNewStatus(NSSettingsStatus status, Context context, boolean isDelta) {
LocalBroadcastManager.getInstance(MainApp.instance())
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastTreatment.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastTreatment.java
index 94b83c56bd..dc834215a9 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastTreatment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastTreatment.java
@@ -15,14 +15,15 @@ import java.util.List;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
-import info.nightscout.androidaps.Services.Intents;
+import info.nightscout.androidaps.logging.L;
+import info.nightscout.androidaps.services.Intents;
import info.nightscout.utils.SP;
/**
* Created by mike on 20.02.2016.
*/
public class BroadcastTreatment {
- private static Logger log = LoggerFactory.getLogger(BroadcastTreatment.class);
+ private static Logger log = LoggerFactory.getLogger(L.NSCLIENT);
public static void handleNewTreatment(JSONObject treatment, boolean isDelta, boolean isLocalBypass) {
@@ -73,28 +74,6 @@ public class BroadcastTreatment {
}
}
- public void handleChangedTreatment(JSONObject treatment, boolean isDelta) {
-
- Bundle bundle = new Bundle();
- bundle.putString("treatment", treatment.toString());
- bundle.putBoolean("delta", isDelta);
- Intent intent = new Intent(Intents.ACTION_CHANGED_TREATMENT);
- intent.putExtras(bundle);
- intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
- LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
-
-
- if (SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
- bundle = new Bundle();
- bundle.putString("treatment", treatment.toString());
- bundle.putBoolean("delta", isDelta);
- intent = new Intent(Intents.ACTION_CHANGED_TREATMENT);
- intent.putExtras(bundle);
- intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
- MainApp.instance().getApplicationContext().sendBroadcast(intent);
- }
- }
-
public static void handleChangedTreatment(JSONArray treatments, boolean isDelta) {
List splitted = splitArray(treatments);
@@ -122,28 +101,6 @@ public class BroadcastTreatment {
}
}
- public static void handleRemovedTreatment(JSONObject treatment, boolean isDelta) {
-
- Bundle bundle = new Bundle();
- bundle.putString("treatment", treatment.toString());
- bundle.putBoolean("delta", isDelta);
- Intent intent = new Intent(Intents.ACTION_REMOVED_TREATMENT);
- intent.putExtras(bundle);
- intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
- LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
-
-
- if (SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
- bundle = new Bundle();
- bundle.putString("treatment", treatment.toString());
- bundle.putBoolean("delta", isDelta);
- intent = new Intent(Intents.ACTION_REMOVED_TREATMENT);
- intent.putExtras(bundle);
- intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
- MainApp.instance().getApplicationContext().sendBroadcast(intent);
- }
- }
-
public static void handleRemovedTreatment(JSONArray treatments, boolean isDelta) {
Bundle bundle = new Bundle();
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastUrgentAlarm.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastUrgentAlarm.java
index c332be03af..76095453d0 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastUrgentAlarm.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastUrgentAlarm.java
@@ -2,27 +2,20 @@ package info.nightscout.androidaps.plugins.NSClientInternal.broadcasts;
import android.content.Context;
import android.content.Intent;
-import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.support.v4.content.LocalBroadcastManager;
import org.json.JSONObject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.List;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
-import info.nightscout.androidaps.Services.Intents;
+import info.nightscout.androidaps.services.Intents;
import info.nightscout.utils.SP;
/**
* Created by mike on 26.06.2016.
*/
public class BroadcastUrgentAlarm {
- private static Logger log = LoggerFactory.getLogger(BroadcastUrgentAlarm.class);
-
public static void handleUrgentAlarm(JSONObject urgentalarm, Context context) {
Bundle bundle = new Bundle();
bundle.putString("data", urgentalarm.toString());
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/DbLogger.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/DbLogger.java
index 2723fc0748..ec31141002 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/DbLogger.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/DbLogger.java
@@ -8,32 +8,36 @@ import org.slf4j.LoggerFactory;
import java.util.List;
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.utils.ToastUtils;
/**
* Created by mike on 02.07.2016.
*/
public class DbLogger {
- private static Logger log = LoggerFactory.getLogger(DbLogger.class);
+ private static Logger log = LoggerFactory.getLogger(L.NSCLIENT);
public static void dbAdd(Intent intent, String data) {
List q = MainApp.instance().getApplicationContext().getPackageManager().queryBroadcastReceivers(intent, 0);
if (q.size() < 1) {
- ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(),MainApp.gs(R.string.nsclientnotinstalled));
+ ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.nsclientnotinstalled));
log.error("DBADD No receivers");
- } else if (Config.logNSUpload)
- log.debug("DBADD dbAdd " + q.size() + " receivers " + data);
+ } else if (L.isEnabled(L.NSCLIENT)) {
+ if (L.isEnabled(L.NSCLIENT))
+ log.debug("DBADD dbAdd " + q.size() + " receivers " + data);
+ }
}
- public static void dbRemove(Intent intent, String data) {
+ public static void dbRemove(Intent intent, String data) {
List q = MainApp.instance().getApplicationContext().getPackageManager().queryBroadcastReceivers(intent, 0);
if (q.size() < 1) {
- ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(),MainApp.gs(R.string.nsclientnotinstalled));
+ ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.nsclientnotinstalled));
log.error("DBREMOVE No receivers");
- } else if (Config.logNSUpload)
- log.debug("DBREMOVE dbRemove " + q.size() + " receivers " + data);
+ } else if (L.isEnabled(L.NSCLIENT)) {
+ if (L.isEnabled(L.NSCLIENT))
+ log.debug("DBREMOVE dbRemove " + q.size() + " receivers " + data);
+ }
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSAlarm.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSAlarm.java
index 1c28b790d7..7ad82220da 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSAlarm.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSAlarm.java
@@ -5,12 +5,14 @@ import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import info.nightscout.androidaps.logging.L;
+
/**
* Created by mike on 11.06.2017.
*/
public class NSAlarm {
- private static Logger log = LoggerFactory.getLogger(NSAlarm.class);
+ private static Logger log = LoggerFactory.getLogger(L.NSCLIENT);
JSONObject data;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSCal.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSCal.java
index 93d46fa18e..83fe44073e 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSCal.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSCal.java
@@ -5,8 +5,10 @@ import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import info.nightscout.androidaps.logging.L;
+
public class NSCal {
- private static Logger log = LoggerFactory.getLogger(NSCal.class);
+ private static Logger log = LoggerFactory.getLogger(L.NSCLIENT);
public long date;
public double slope;
public double intercept;
@@ -20,7 +22,7 @@ public class NSCal {
scale = json.getDouble("scale");
} catch (JSONException e) {
log.error("Unhandled exception", e);
- log.debug("Data: " + json.toString());
+ log.error("Data: " + json.toString());
}
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSDeviceStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSDeviceStatus.java
index 29d1b33467..1c8aea9b83 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSDeviceStatus.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSDeviceStatus.java
@@ -1,8 +1,11 @@
package info.nightscout.androidaps.plugins.NSClientInternal.data;
+import android.content.Intent;
+import android.os.Bundle;
import android.text.Html;
import android.text.Spanned;
+import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger;
@@ -13,7 +16,10 @@ import java.util.Iterator;
import java.util.Map;
import info.nightscout.androidaps.R;
+import info.nightscout.androidaps.logging.L;
+import info.nightscout.androidaps.plugins.ConstraintsObjectives.ObjectivesPlugin;
import info.nightscout.androidaps.plugins.Loop.APSResult;
+import info.nightscout.androidaps.logging.BundleLogger;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.Round;
import info.nightscout.utils.SP;
@@ -73,7 +79,7 @@ import info.nightscout.utils.SP;
}
*/
public class NSDeviceStatus {
- private static Logger log = LoggerFactory.getLogger(NSDeviceStatus.class);
+ private Logger log = LoggerFactory.getLogger(L.NSCLIENT);
private static NSDeviceStatus instance = null;
@@ -88,6 +94,41 @@ public class NSDeviceStatus {
public NSDeviceStatus() {
}
+ public void handleNewData(Intent intent) {
+ Bundle bundle = intent.getExtras();
+ if (bundle == null) return;
+
+ if (L.isEnabled(L.NSCLIENT))
+ log.debug("Got NS devicestatus: " + BundleLogger.log(bundle));
+
+ try {
+ if (bundle.containsKey("devicestatus")) {
+ JSONObject devicestatusJson = new JSONObject(bundle.getString("devicestatus"));
+ setData(devicestatusJson);
+ if (devicestatusJson.has("pump")) {
+ // Objectives 0
+ ObjectivesPlugin.pumpStatusIsAvailableInNS = true;
+ ObjectivesPlugin.saveProgress();
+ }
+ }
+ if (bundle.containsKey("devicestatuses")) {
+ String devicestatusesstring = bundle.getString("devicestatuses");
+ JSONArray jsonArray = new JSONArray(devicestatusesstring);
+ for (int i = 0; i < jsonArray.length(); i++) {
+ JSONObject devicestatusJson = jsonArray.getJSONObject(i);
+ setData(devicestatusJson);
+ if (devicestatusJson.has("pump")) {
+ // Objectives 0
+ ObjectivesPlugin.pumpStatusIsAvailableInNS = true;
+ ObjectivesPlugin.saveProgress();
+ }
+ }
+ }
+ } catch (Exception e) {
+ log.error("Unhandled exception", e);
+ }
+ }
+
public NSDeviceStatus setData(JSONObject obj) {
this.data = obj;
updatePumpData(obj);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSMbg.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSMbg.java
index 353dd49b74..cd4cd9cdba 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSMbg.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSMbg.java
@@ -5,8 +5,10 @@ import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import info.nightscout.androidaps.logging.L;
+
public class NSMbg {
- private static Logger log = LoggerFactory.getLogger(NSMbg.class);
+ private static Logger log = LoggerFactory.getLogger(L.NSCLIENT);
public long date;
public double mbg;
public String json;
@@ -18,7 +20,7 @@ public class NSMbg {
this.json = json.toString();
} catch (JSONException e) {
log.error("Unhandled exception", e);
- log.debug("Data: " + json.toString());
+ log.error("Data: " + json.toString());
}
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSSettingsStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSSettingsStatus.java
index 8d09a05146..dc3c9f742e 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSSettingsStatus.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSSettingsStatus.java
@@ -1,5 +1,8 @@
package info.nightscout.androidaps.plugins.NSClientInternal.data;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.os.Bundle;
import android.support.annotation.Nullable;
import org.json.JSONException;
@@ -10,6 +13,16 @@ import org.slf4j.LoggerFactory;
import java.util.Date;
import java.util.Objects;
+import info.nightscout.androidaps.Config;
+import info.nightscout.androidaps.MainApp;
+import info.nightscout.androidaps.R;
+import info.nightscout.androidaps.logging.L;
+import info.nightscout.androidaps.plugins.Overview.OverviewPlugin;
+import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
+import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
+import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
+import info.nightscout.androidaps.logging.BundleLogger;
+
/*
{
"status": "ok",
@@ -101,7 +114,7 @@ import java.util.Objects;
}
*/
public class NSSettingsStatus {
- private static Logger log = LoggerFactory.getLogger(NSSettingsStatus.class);
+ private Logger log = LoggerFactory.getLogger(L.NSCLIENT);
private static NSSettingsStatus instance = null;
@@ -111,6 +124,8 @@ public class NSSettingsStatus {
return instance;
}
+ public String nightscoutVersionName = "";
+
private JSONObject data = null;
public NSSettingsStatus() {
@@ -121,6 +136,59 @@ public class NSSettingsStatus {
return this;
}
+ public void handleNewData(Intent intent) {
+ Bundle bundle = intent.getExtras();
+ if (bundle == null) return;
+
+ if (L.isEnabled(L.NSCLIENT))
+ log.debug("Got NS status: " + BundleLogger.log(bundle));
+
+ if (bundle.containsKey("nsclientversioncode")) {
+
+ Integer nightscoutVersionCode = bundle.getInt("nightscoutversioncode");
+ nightscoutVersionName = bundle.getString("nightscoutversionname");
+ Integer nsClientVersionCode = bundle.getInt("nsclientversioncode");
+ String nsClientVersionName = bundle.getString("nsclientversionname");
+ if (L.isEnabled(L.NSCLIENT))
+ log.debug("Got versions: NSClient: " + nsClientVersionName + " Nightscout: " + nightscoutVersionName);
+ try {
+ if (nsClientVersionCode < MainApp.instance().getPackageManager().getPackageInfo(MainApp.instance().getPackageName(), 0).versionCode) {
+ Notification notification = new Notification(Notification.OLD_NSCLIENT, MainApp.gs(R.string.unsupportedclientver), Notification.URGENT);
+ MainApp.bus().post(new EventNewNotification(notification));
+ } else {
+ MainApp.bus().post(new EventDismissNotification(Notification.OLD_NSCLIENT));
+ }
+ } catch (PackageManager.NameNotFoundException e) {
+ log.error("Unhandled exception", e);
+ }
+ if (nightscoutVersionCode < Config.SUPPORTEDNSVERSION) {
+ Notification notification = new Notification(Notification.OLD_NS, MainApp.gs(R.string.unsupportednsversion), Notification.NORMAL);
+ MainApp.bus().post(new EventNewNotification(notification));
+ } else {
+ MainApp.bus().post(new EventDismissNotification(Notification.OLD_NS));
+ }
+ } else {
+ Notification notification = new Notification(Notification.OLD_NSCLIENT, MainApp.gs(R.string.unsupportedclientver), Notification.URGENT);
+ MainApp.bus().post(new EventNewNotification(notification));
+ }
+ if (bundle.containsKey("status")) {
+ try {
+ JSONObject statusJson = new JSONObject(bundle.getString("status"));
+ setData(statusJson);
+ if (L.isEnabled(L.NSCLIENT))
+ log.debug("Received status: " + statusJson.toString());
+ Double targetHigh = getThreshold("bgTargetTop");
+ Double targetlow = getThreshold("bgTargetBottom");
+ if (targetHigh != null)
+ OverviewPlugin.bgTargetHigh = targetHigh;
+ if (targetlow != null)
+ OverviewPlugin.bgTargetLow = targetlow;
+ } catch (JSONException e) {
+ log.error("Unhandled exception", e);
+ }
+ }
+ }
+
public String getName() {
return getStringOrNull("name");
}
@@ -134,7 +202,7 @@ public class NSSettingsStatus {
}
public Date getServerTime() {
- return getDateOrNull("versionNum");
+ return getDateOrNull("serverTime");
}
public boolean getApiEnabled() {
@@ -202,13 +270,11 @@ public class NSSettingsStatus {
if (settingsO.has("thresholds")) {
JSONObject tObject = settingsO.getJSONObject("thresholds");
if (tObject.has(what)) {
- Double result = tObject.getDouble(what);
- return result;
+ return tObject.getDouble(what);
}
}
if (settingsO.has("alarmTimeagoWarnMins") && Objects.equals(what, "alarmTimeagoWarnMins")) {
- Double result = settingsO.getDouble(what);
- return result;
+ return settingsO.getDouble(what);
}
}
} catch (JSONException e) {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSSgv.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSSgv.java
index 50336a5f52..2212884a3e 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSSgv.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSSgv.java
@@ -5,12 +5,14 @@ import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import info.nightscout.androidaps.logging.L;
+
/**
*
* {"mgdl":105,"mills":1455136282375,"device":"xDrip-BluetoothWixel","direction":"Flat","filtered":98272,"unfiltered":98272,"noise":1,"rssi":100}
*/
public class NSSgv {
- private static Logger log = LoggerFactory.getLogger(NSSgv.class);
+ private static Logger log = LoggerFactory.getLogger(L.NSCLIENT);
private JSONObject data;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSTreatment.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSTreatment.java
index a9f960edd0..d4ee20e2a1 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSTreatment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSTreatment.java
@@ -7,8 +7,10 @@ import org.slf4j.LoggerFactory;
import java.util.Date;
+import info.nightscout.androidaps.logging.L;
+
public class NSTreatment {
- private static Logger log = LoggerFactory.getLogger(NSTreatment.class);
+ private static Logger log = LoggerFactory.getLogger(L.NSCLIENT);
private JSONObject data;
private String action = null; // "update", "remove" or null (add)
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/receivers/AckAlarmReceiver.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/receivers/AckAlarmReceiver.java
index 2aae41538a..f23533e9ab 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/receivers/AckAlarmReceiver.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/receivers/AckAlarmReceiver.java
@@ -11,15 +11,15 @@ import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
-import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginType;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientPlugin;
import info.nightscout.androidaps.plugins.NSClientInternal.data.AlarmAck;
import info.nightscout.androidaps.plugins.NSClientInternal.services.NSClientService;
import info.nightscout.utils.SP;
public class AckAlarmReceiver extends BroadcastReceiver {
- private static Logger log = LoggerFactory.getLogger(AckAlarmReceiver.class);
+ private static Logger log = LoggerFactory.getLogger(L.NSCLIENT);
@Override
@@ -32,7 +32,8 @@ public class AckAlarmReceiver extends BroadcastReceiver {
return;
}
if (SP.getBoolean(R.string.key_ns_noupload, false)) {
- log.debug("Upload disabled. Message dropped");
+ if (L.isEnabled(L.NSCLIENT))
+ log.debug("Upload disabled. Message dropped");
return;
}
wakeLock.acquire();
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/receivers/DBAccessReceiver.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/receivers/DBAccessReceiver.java
index 332ccc2ea3..a1300f7b99 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/receivers/DBAccessReceiver.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/receivers/DBAccessReceiver.java
@@ -15,6 +15,7 @@ import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.db.DbRequest;
import info.nightscout.androidaps.interfaces.PluginType;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientPlugin;
import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue;
import info.nightscout.androidaps.plugins.NSClientInternal.broadcasts.BroadcastTreatment;
@@ -22,7 +23,7 @@ import info.nightscout.utils.DateUtil;
import info.nightscout.utils.SP;
public class DBAccessReceiver extends BroadcastReceiver {
- private static Logger log = LoggerFactory.getLogger(DBAccessReceiver.class);
+ private static Logger log = LoggerFactory.getLogger(L.NSCLIENT);
@Override
@@ -43,18 +44,21 @@ public class DBAccessReceiver extends BroadcastReceiver {
try {
collection = bundles.getString("collection");
} catch (Exception e) {
+ log.error("Unhandled exception", e);
}
try {
_id = bundles.getString("_id");
} catch (Exception e) {
+ log.error("Unhandled exception", e);
}
try {
data = new JSONObject(bundles.getString("data"));
} catch (Exception e) {
+ log.error("Unhandled exception", e);
}
if (data == null && !action.equals("dbRemove") || _id == null && action.equals("dbRemove")) {
- log.debug("DBACCESS no data inside record");
+ log.error("DBACCESS no data inside record");
return;
}
@@ -70,7 +74,7 @@ public class DBAccessReceiver extends BroadcastReceiver {
}
if (!isAllowedCollection(collection)) {
- log.debug("DBACCESS wrong collection specified");
+ log.error("DBACCESS wrong collection specified");
return;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/services/NSClientService.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/services/NSClientService.java
index fab9a181c4..d7066705b9 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/services/NSClientService.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/services/NSClientService.java
@@ -9,7 +9,6 @@ import android.os.HandlerThread;
import android.os.IBinder;
import android.os.PowerManager;
-
import com.google.common.base.Charsets;
import com.google.common.hash.Hashing;
import com.j256.ormlite.dao.CloseableIterator;
@@ -23,7 +22,6 @@ import org.slf4j.LoggerFactory;
import java.net.URISyntaxException;
import java.sql.SQLException;
-import java.util.Date;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
@@ -34,6 +32,7 @@ import info.nightscout.androidaps.events.EventAppExit;
import info.nightscout.androidaps.events.EventConfigBuilderChange;
import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.interfaces.PluginType;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientPlugin;
import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue;
import info.nightscout.androidaps.plugins.NSClientInternal.acks.NSAddAck;
@@ -70,7 +69,7 @@ import io.socket.client.Socket;
import io.socket.emitter.Emitter;
public class NSClientService extends Service {
- private static Logger log = LoggerFactory.getLogger(NSClientService.class);
+ private static Logger log = LoggerFactory.getLogger(L.NSCLIENT);
static public PowerManager.WakeLock mWakeLock;
private IBinder mBinder = new NSClientService.LocalBinder();
@@ -156,13 +155,13 @@ public class NSClientService extends Service {
@Subscribe
public void onStatusEvent(EventAppExit event) {
- if (Config.logFunctionCalls)
+ if (L.isEnabled(L.NSCLIENT))
log.debug("EventAppExit received");
destroy();
stopSelf();
- if (Config.logFunctionCalls)
+ if (L.isEnabled(L.NSCLIENT))
log.debug("EventAppExit finished");
}
@@ -250,7 +249,8 @@ public class NSClientService extends Service {
private Emitter.Listener onDisconnect = new Emitter.Listener() {
@Override
public void call(Object... args) {
- log.debug("disconnect reason: {}", args);
+ if (L.isEnabled(L.NSCLIENT))
+ log.debug("disconnect reason: {}", args);
MainApp.bus().post(new EventNSClientNewLog("NSCLIENT", "disconnect event"));
}
};
@@ -326,8 +326,7 @@ public class NSClientService extends Service {
private Emitter.Listener onPing = new Emitter.Listener() {
@Override
public void call(final Object... args) {
- if (Config.detailedLog)
- MainApp.bus().post(new EventNSClientNewLog("PING", "received"));
+ MainApp.bus().post(new EventNSClientNewLog("PING", "received"));
// send data if there is something waiting
resend("Ping received");
}
@@ -352,16 +351,18 @@ public class NSClientService extends Service {
data = (JSONObject) args[0];
} catch (Exception e) {
FabricPrivacy.log("Wrong Announcement from NS: " + args[0]);
+ log.error("Unhandled exception", e);
return;
}
- if (Config.detailedLog)
- try {
- MainApp.bus().post(new EventNSClientNewLog("ANNOUNCEMENT", JsonHelper.safeGetString(data, "message", "received")));
- } catch (Exception e) {
- FabricPrivacy.logException(e);
- }
+ try {
+ MainApp.bus().post(new EventNSClientNewLog("ANNOUNCEMENT", JsonHelper.safeGetString(data, "message", "received")));
+ } catch (Exception e) {
+ FabricPrivacy.logException(e);
+ log.error("Unhandled exception", e);
+ }
BroadcastAnnouncement.handleAnnouncement(data, getApplicationContext());
- log.debug(data.toString());
+ if (L.isEnabled(L.NSCLIENT))
+ log.debug(data.toString());
}
};
@@ -381,17 +382,18 @@ public class NSClientService extends Service {
*/
@Override
public void call(final Object... args) {
- if (Config.detailedLog)
- MainApp.bus().post(new EventNSClientNewLog("ALARM", "received"));
+ MainApp.bus().post(new EventNSClientNewLog("ALARM", "received"));
JSONObject data;
try {
data = (JSONObject) args[0];
} catch (Exception e) {
FabricPrivacy.log("Wrong alarm from NS: " + args[0]);
+ log.error("Unhandled exception", e);
return;
}
BroadcastAlarm.handleAlarm(data, getApplicationContext());
- log.debug(data.toString());
+ if (L.isEnabled(L.NSCLIENT))
+ log.debug(data.toString());
}
};
@@ -416,12 +418,13 @@ public class NSClientService extends Service {
data = (JSONObject) args[0];
} catch (Exception e) {
FabricPrivacy.log("Wrong Urgent alarm from NS: " + args[0]);
+ log.error("Unhandled exception", e);
return;
}
- if (Config.detailedLog)
- MainApp.bus().post(new EventNSClientNewLog("URGENTALARM", "received"));
+ MainApp.bus().post(new EventNSClientNewLog("URGENTALARM", "received"));
BroadcastUrgentAlarm.handleUrgentAlarm(data, getApplicationContext());
- log.debug(data.toString());
+ if (L.isEnabled(L.NSCLIENT))
+ log.debug(data.toString());
}
};
@@ -441,12 +444,13 @@ public class NSClientService extends Service {
data = (JSONObject) args[0];
} catch (Exception e) {
FabricPrivacy.log("Wrong Urgent alarm from NS: " + args[0]);
+ log.error("Unhandled exception", e);
return;
}
- if (Config.detailedLog)
- MainApp.bus().post(new EventNSClientNewLog("CLEARALARM", "received"));
+ MainApp.bus().post(new EventNSClientNewLog("CLEARALARM", "received"));
BroadcastClearAlarm.handleClearAlarm(data, getApplicationContext());
- log.debug(data.toString());
+ if (L.isEnabled(L.NSCLIENT))
+ log.debug(data.toString());
}
};
@@ -743,17 +747,6 @@ public class NSClientService extends Service {
}
}
- private boolean isCurrent(NSTreatment treatment) {
- long now = (new Date()).getTime();
- long minPast = now - nsHours * 60L * 60 * 1000;
- if (treatment.getMills() == null) {
- log.debug("treatment.getMills() == null " + treatment.getData().toString());
- return false;
- }
- if (treatment.getMills() > minPast) return true;
- return false;
- }
-
public void resend(final String reason) {
if (UploadQueue.size() == 0)
return;
@@ -766,7 +759,8 @@ public class NSClientService extends Service {
if (mSocket == null || !mSocket.connected()) return;
if (lastResendTime > System.currentTimeMillis() - 10 * 1000L) {
- log.debug("Skipping resend by lastResendTime: " + ((System.currentTimeMillis() - lastResendTime) / 1000L) + " sec");
+ if (L.isEnabled(L.NSCLIENT))
+ log.debug("Skipping resend by lastResendTime: " + ((System.currentTimeMillis() - lastResendTime) / 1000L) + " sec");
return;
}
lastResendTime = System.currentTimeMillis();
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalAdapterAMAJS.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalAdapterAMAJS.java
index 4c8de10b9c..50e79d1e37 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalAdapterAMAJS.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalAdapterAMAJS.java
@@ -3,7 +3,6 @@ package info.nightscout.androidaps.plugins.OpenAPSAMA;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
-import org.mozilla.javascript.Callable;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Function;
import org.mozilla.javascript.NativeJSON;
@@ -18,7 +17,6 @@ import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
@@ -27,6 +25,7 @@ import info.nightscout.androidaps.data.IobTotal;
import info.nightscout.androidaps.data.MealData;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.db.TemporaryBasal;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
import info.nightscout.androidaps.plugins.Loop.ScriptReader;
import info.nightscout.androidaps.plugins.OpenAPSMA.LoggerCallback;
@@ -35,7 +34,7 @@ import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.utils.SP;
public class DetermineBasalAdapterAMAJS {
- private static Logger log = LoggerFactory.getLogger(DetermineBasalAdapterAMAJS.class);
+ private static Logger log = LoggerFactory.getLogger(L.APS);
private ScriptReader mScriptReader = null;
@@ -56,23 +55,24 @@ public class DetermineBasalAdapterAMAJS {
private String scriptDebug = "";
- public DetermineBasalAdapterAMAJS(ScriptReader scriptReader) throws IOException {
+ public DetermineBasalAdapterAMAJS(ScriptReader scriptReader) {
mScriptReader = scriptReader;
}
public DetermineBasalResultAMA invoke() {
-
- log.debug(">>> Invoking detemine_basal <<<");
- log.debug("Glucose status: " + (storedGlucoseStatus = mGlucoseStatus.toString()));
- log.debug("IOB data: " + (storedIobData = mIobData.toString()));
- log.debug("Current temp: " + (storedCurrentTemp = mCurrentTemp.toString()));
- log.debug("Profile: " + (storedProfile = mProfile.toString()));
- log.debug("Meal data: " + (storedMeal_data = mMealData.toString()));
- if (mAutosensData != null)
- log.debug("Autosens data: " + (storedAutosens_data = mAutosensData.toString()));
- else
- log.debug("Autosens data: " + (storedAutosens_data = "undefined"));
+ if (L.isEnabled(L.APS)) {
+ log.debug(">>> Invoking detemine_basal <<<");
+ log.debug("Glucose status: " + (storedGlucoseStatus = mGlucoseStatus.toString()));
+ log.debug("IOB data: " + (storedIobData = mIobData.toString()));
+ log.debug("Current temp: " + (storedCurrentTemp = mCurrentTemp.toString()));
+ log.debug("Profile: " + (storedProfile = mProfile.toString()));
+ log.debug("Meal data: " + (storedMeal_data = mMealData.toString()));
+ if (mAutosensData != null)
+ log.debug("Autosens data: " + (storedAutosens_data = mAutosensData.toString()));
+ else
+ log.debug("Autosens data: " + (storedAutosens_data = "undefined"));
+ }
DetermineBasalResultAMA determineBasalResultAMA = null;
@@ -119,7 +119,7 @@ public class DetermineBasalAdapterAMAJS {
// Parse the jsResult object to a JSON-String
String result = NativeJSON.stringify(rhino, scope, jsResult, null, null).toString();
- if (Config.logAPSResult)
+ if (L.isEnabled(L.APS))
log.debug("Result: " + result);
try {
determineBasalResultAMA = new DetermineBasalResultAMA(jsResult, new JSONObject(result));
@@ -127,17 +127,13 @@ public class DetermineBasalAdapterAMAJS {
log.error("Unhandled exception", e);
}
} else {
- log.debug("Problem loading JS Functions");
+ log.error("Problem loading JS Functions");
}
} catch (IOException e) {
- log.debug("IOException");
+ log.error("IOException");
} catch (RhinoException e) {
log.error("RhinoException: (" + e.lineNumber() + "," + e.columnNumber() + ") " + e.toString());
- } catch (IllegalAccessException e) {
- log.error(e.toString());
- } catch (InstantiationException e) {
- log.error(e.toString());
- } catch (InvocationTargetException e) {
+ } catch (IllegalAccessException | InstantiationException | InvocationTargetException e) {
log.error(e.toString());
} finally {
Context.exit();
@@ -214,7 +210,7 @@ public class DetermineBasalAdapterAMAJS {
mProfile.put("temptargetSet", tempTargetSet);
mProfile.put("autosens_adjust_targets", SP.getBoolean(R.string.key_openapsama_autosens_adjusttargets, true));
//align with max-absorption model in AMA sensitivity
- if(mealData.usedMinCarbsImpact > 0){
+ if (mealData.usedMinCarbsImpact > 0) {
mProfile.put("min_5m_carbimpact", mealData.usedMinCarbsImpact);
} else {
mProfile.put("min_5m_carbimpact", SP.getDouble(R.string.key_openapsama_min_5m_carbimpact, SMBDefaults.min_5m_carbimpact));
@@ -265,31 +261,21 @@ public class DetermineBasalAdapterAMAJS {
}
- public Object makeParam(JSONObject jsonObject, Context rhino, Scriptable scope) {
+ private Object makeParam(JSONObject jsonObject, Context rhino, Scriptable scope) {
if (jsonObject == null) return Undefined.instance;
- Object param = NativeJSON.parse(rhino, scope, jsonObject.toString(), new Callable() {
- @Override
- public Object call(Context context, Scriptable scriptable, Scriptable scriptable1, Object[] objects) {
- return objects[1];
- }
- });
+ Object param = NativeJSON.parse(rhino, scope, jsonObject.toString(), (context, scriptable, scriptable1, objects) -> objects[1]);
return param;
}
- public Object makeParamArray(JSONArray jsonArray, Context rhino, Scriptable scope) {
+ private Object makeParamArray(JSONArray jsonArray, Context rhino, Scriptable scope) {
//Object param = NativeJSON.parse(rhino, scope, "{myarray: " + jsonArray.toString() + " }", new Callable() {
- Object param = NativeJSON.parse(rhino, scope, jsonArray.toString(), new Callable() {
- @Override
- public Object call(Context context, Scriptable scriptable, Scriptable scriptable1, Object[] objects) {
- return objects[1];
- }
- });
+ Object param = NativeJSON.parse(rhino, scope, jsonArray.toString(), (context, scriptable, scriptable1, objects) -> objects[1]);
return param;
}
- public String readFile(String filename) throws IOException {
+ private String readFile(String filename) throws IOException {
byte[] bytes = mScriptReader.readFile(filename);
String string = new String(bytes, "UTF-8");
if (string.startsWith("#!/usr/bin/env node")) {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalResultAMA.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalResultAMA.java
index ac7a7c2b49..7d57f52efb 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalResultAMA.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalResultAMA.java
@@ -6,11 +6,12 @@ import org.mozilla.javascript.NativeObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Loop.APSResult;
import info.nightscout.utils.DateUtil;
public class DetermineBasalResultAMA extends APSResult {
- private static Logger log = LoggerFactory.getLogger(DetermineBasalResultAMA.class);
+ private static Logger log = LoggerFactory.getLogger(L.APS);
private double eventualBG;
private double snoozeBG;
@@ -47,7 +48,7 @@ public class DetermineBasalResultAMA extends APSResult {
bolusRequested = false;
}
- public DetermineBasalResultAMA() {
+ private DetermineBasalResultAMA() {
hasPredictions = true;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAFragment.java
index f05b0ac696..0eb327c608 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAFragment.java
@@ -2,7 +2,6 @@ package info.nightscout.androidaps.plugins.OpenAPSAMA;
import android.app.Activity;
import android.os.Bundle;
-import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -19,6 +18,7 @@ import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui;
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateResultGui;
@@ -26,7 +26,7 @@ import info.nightscout.utils.FabricPrivacy;
import info.nightscout.utils.JSONFormatter;
public class OpenAPSAMAFragment extends SubscriberFragment implements View.OnClickListener {
- private static Logger log = LoggerFactory.getLogger(OpenAPSAMAFragment.class);
+ private static Logger log = LoggerFactory.getLogger(L.APS);
Button run;
TextView lastRunView;
@@ -43,29 +43,23 @@ public class OpenAPSAMAFragment extends SubscriberFragment implements View.OnCli
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
- try {
- View view = inflater.inflate(R.layout.openapsama_fragment, container, false);
+ View view = inflater.inflate(R.layout.openapsama_fragment, container, false);
- run = (Button) view.findViewById(R.id.openapsma_run);
- run.setOnClickListener(this);
- lastRunView = (TextView) view.findViewById(R.id.openapsma_lastrun);
- glucoseStatusView = (TextView) view.findViewById(R.id.openapsma_glucosestatus);
- currentTempView = (TextView) view.findViewById(R.id.openapsma_currenttemp);
- iobDataView = (TextView) view.findViewById(R.id.openapsma_iobdata);
- profileView = (TextView) view.findViewById(R.id.openapsma_profile);
- mealDataView = (TextView) view.findViewById(R.id.openapsma_mealdata);
- autosensDataView = (TextView) view.findViewById(R.id.openapsma_autosensdata);
- scriptdebugView = (TextView) view.findViewById(R.id.openapsma_scriptdebugdata);
- resultView = (TextView) view.findViewById(R.id.openapsma_result);
- requestView = (TextView) view.findViewById(R.id.openapsma_request);
+ run = (Button) view.findViewById(R.id.openapsma_run);
+ run.setOnClickListener(this);
+ lastRunView = (TextView) view.findViewById(R.id.openapsma_lastrun);
+ glucoseStatusView = (TextView) view.findViewById(R.id.openapsma_glucosestatus);
+ currentTempView = (TextView) view.findViewById(R.id.openapsma_currenttemp);
+ iobDataView = (TextView) view.findViewById(R.id.openapsma_iobdata);
+ profileView = (TextView) view.findViewById(R.id.openapsma_profile);
+ mealDataView = (TextView) view.findViewById(R.id.openapsma_mealdata);
+ autosensDataView = (TextView) view.findViewById(R.id.openapsma_autosensdata);
+ scriptdebugView = (TextView) view.findViewById(R.id.openapsma_scriptdebugdata);
+ resultView = (TextView) view.findViewById(R.id.openapsma_result);
+ requestView = (TextView) view.findViewById(R.id.openapsma_request);
- updateGUI();
- return view;
- } catch (Exception e) {
- FabricPrivacy.logException(e);
- }
-
- return null;
+ updateGUI();
+ return view;
}
@Override
@@ -93,35 +87,32 @@ public class OpenAPSAMAFragment extends SubscriberFragment implements View.OnCli
protected void updateGUI() {
Activity activity = getActivity();
if (activity != null)
- activity.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- DetermineBasalResultAMA lastAPSResult = OpenAPSAMAPlugin.getPlugin().lastAPSResult;
- if (lastAPSResult != null) {
- resultView.setText(JSONFormatter.format(lastAPSResult.json));
- requestView.setText(lastAPSResult.toSpanned());
- }
- DetermineBasalAdapterAMAJS determineBasalAdapterAMAJS = OpenAPSAMAPlugin.getPlugin().lastDetermineBasalAdapterAMAJS;
- if (determineBasalAdapterAMAJS != null) {
- glucoseStatusView.setText(JSONFormatter.format(determineBasalAdapterAMAJS.getGlucoseStatusParam()));
- currentTempView.setText(JSONFormatter.format(determineBasalAdapterAMAJS.getCurrentTempParam()));
- try {
- JSONArray iobArray = new JSONArray(determineBasalAdapterAMAJS.getIobDataParam());
- iobDataView.setText(String.format(MainApp.gs(R.string.array_of_elements), iobArray.length()) + "\n" + JSONFormatter.format(iobArray.getString(0)));
- } catch (JSONException e) {
- log.error("Unhandled exception", e);
- iobDataView.setText("JSONException");
- }
- profileView.setText(JSONFormatter.format(determineBasalAdapterAMAJS.getProfileParam()));
- mealDataView.setText(JSONFormatter.format(determineBasalAdapterAMAJS.getMealDataParam()));
- scriptdebugView.setText(determineBasalAdapterAMAJS.getScriptDebug());
- }
- if (OpenAPSAMAPlugin.getPlugin().lastAPSRun != null) {
- lastRunView.setText(OpenAPSAMAPlugin.getPlugin().lastAPSRun.toLocaleString());
- }
- if (OpenAPSAMAPlugin.getPlugin().lastAutosensResult != null) {
- autosensDataView.setText(JSONFormatter.format(OpenAPSAMAPlugin.getPlugin().lastAutosensResult.json()));
+ activity.runOnUiThread(() -> {
+ DetermineBasalResultAMA lastAPSResult = OpenAPSAMAPlugin.getPlugin().lastAPSResult;
+ if (lastAPSResult != null) {
+ resultView.setText(JSONFormatter.format(lastAPSResult.json));
+ requestView.setText(lastAPSResult.toSpanned());
+ }
+ DetermineBasalAdapterAMAJS determineBasalAdapterAMAJS = OpenAPSAMAPlugin.getPlugin().lastDetermineBasalAdapterAMAJS;
+ if (determineBasalAdapterAMAJS != null) {
+ glucoseStatusView.setText(JSONFormatter.format(determineBasalAdapterAMAJS.getGlucoseStatusParam()));
+ currentTempView.setText(JSONFormatter.format(determineBasalAdapterAMAJS.getCurrentTempParam()));
+ try {
+ JSONArray iobArray = new JSONArray(determineBasalAdapterAMAJS.getIobDataParam());
+ iobDataView.setText(String.format(MainApp.gs(R.string.array_of_elements), iobArray.length()) + "\n" + JSONFormatter.format(iobArray.getString(0)));
+ } catch (JSONException e) {
+ log.error("Unhandled exception", e);
+ iobDataView.setText("JSONException");
}
+ profileView.setText(JSONFormatter.format(determineBasalAdapterAMAJS.getProfileParam()));
+ mealDataView.setText(JSONFormatter.format(determineBasalAdapterAMAJS.getMealDataParam()));
+ scriptdebugView.setText(determineBasalAdapterAMAJS.getScriptDebug());
+ }
+ if (OpenAPSAMAPlugin.getPlugin().lastAPSRun != null) {
+ lastRunView.setText(OpenAPSAMAPlugin.getPlugin().lastAPSRun.toLocaleString());
+ }
+ if (OpenAPSAMAPlugin.getPlugin().lastAutosensResult != null) {
+ autosensDataView.setText(JSONFormatter.format(OpenAPSAMAPlugin.getPlugin().lastAutosensResult.json()));
}
});
}
@@ -129,20 +120,17 @@ public class OpenAPSAMAFragment extends SubscriberFragment implements View.OnCli
void updateResultGUI(final String text) {
Activity activity = getActivity();
if (activity != null)
- activity.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- resultView.setText(text);
- glucoseStatusView.setText("");
- currentTempView.setText("");
- iobDataView.setText("");
- profileView.setText("");
- mealDataView.setText("");
- autosensDataView.setText("");
- scriptdebugView.setText("");
- requestView.setText("");
- lastRunView.setText("");
- }
+ activity.runOnUiThread(() -> {
+ resultView.setText(text);
+ glucoseStatusView.setText("");
+ currentTempView.setText("");
+ iobDataView.setText("");
+ profileView.setText("");
+ mealDataView.setText("");
+ autosensDataView.setText("");
+ scriptdebugView.setText("");
+ requestView.setText("");
+ lastRunView.setText("");
});
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java
index f73752faa2..1c6bf3e39d 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java
@@ -1,14 +1,11 @@
package info.nightscout.androidaps.plugins.OpenAPSAMA;
-import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
import org.json.JSONException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.IOException;
import java.util.Date;
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.GlucoseStatus;
@@ -22,7 +19,9 @@ import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.PumpInterface;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
+import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult;
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
import info.nightscout.androidaps.plugins.Loop.APSResult;
@@ -39,7 +38,7 @@ import info.nightscout.utils.Round;
* Created by mike on 05.08.2016.
*/
public class OpenAPSAMAPlugin extends PluginBase implements APSInterface {
- private static Logger log = LoggerFactory.getLogger(OpenAPSAMAPlugin.class);
+ private static Logger log = LoggerFactory.getLogger(L.APS);
private static OpenAPSAMAPlugin openAPSAMAPlugin;
@@ -91,15 +90,11 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface {
@Override
public void invoke(String initiator, boolean tempBasalFallback) {
- log.debug("invoke from " + initiator + " tempBasalFallback: " + tempBasalFallback);
+ if (L.isEnabled(L.APS))
+ log.debug("invoke from " + initiator + " tempBasalFallback: " + tempBasalFallback);
lastAPSResult = null;
DetermineBasalAdapterAMAJS determineBasalAdapterAMAJS;
- try {
- determineBasalAdapterAMAJS = new DetermineBasalAdapterAMAJS(new ScriptReader(MainApp.instance().getBaseContext()));
- } catch (IOException e) {
- log.error(e.getMessage(), e);
- return;
- }
+ determineBasalAdapterAMAJS = new DetermineBasalAdapterAMAJS(new ScriptReader(MainApp.instance().getBaseContext()));
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
Profile profile = MainApp.getConfigBuilder().getProfile();
@@ -107,21 +102,21 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface {
if (profile == null) {
MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.noprofileselected)));
- if (Config.logAPSResult)
+ if (L.isEnabled(L.APS))
log.debug(MainApp.gs(R.string.noprofileselected));
return;
}
if (!isEnabled(PluginType.APS)) {
MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_disabled)));
- if (Config.logAPSResult)
+ if (L.isEnabled(L.APS))
log.debug(MainApp.gs(R.string.openapsma_disabled));
return;
}
if (glucoseStatus == null) {
MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_noglucosedata)));
- if (Config.logAPSResult)
+ if (L.isEnabled(L.APS))
log.debug(MainApp.gs(R.string.openapsma_noglucosedata));
return;
}
@@ -139,11 +134,13 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface {
Date start = new Date();
Date startPart = new Date();
IobTotal[] iobArray = IobCobCalculatorPlugin.getPlugin().calculateIobArrayInDia(profile);
- Profiler.log(log, "calculateIobArrayInDia()", startPart);
+ if (L.isEnabled(L.APS))
+ Profiler.log(log, "calculateIobArrayInDia()", startPart);
startPart = new Date();
MealData mealData = TreatmentsPlugin.getPlugin().getMealData();
- Profiler.log(log, "getMealData()", startPart);
+ if (L.isEnabled(L.APS))
+ Profiler.log(log, "getMealData()", startPart);
double maxIob = MainApp.getConstraintChecker().getMaxIOBAllowed().value();
@@ -163,7 +160,7 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface {
if (!HardLimits.checkOnlyHardLimits(profile.getDia(), "dia", HardLimits.MINDIA, HardLimits.MAXDIA))
return;
- if (!HardLimits.checkOnlyHardLimits(profile.getIcTimeFromMidnight(profile.secondsFromMidnight()), "carbratio", HardLimits.MINIC, HardLimits.MAXIC))
+ if (!HardLimits.checkOnlyHardLimits(profile.getIcTimeFromMidnight(Profile.secondsFromMidnight()), "carbratio", HardLimits.MINIC, HardLimits.MAXIC))
return;
if (!HardLimits.checkOnlyHardLimits(Profile.toMgdl(profile.getIsf(), units), "sens", HardLimits.MINISF, HardLimits.MAXISF))
return;
@@ -184,8 +181,10 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface {
lastAutosensResult = new AutosensResult();
lastAutosensResult.sensResult = "autosens disabled";
}
- Profiler.log(log, "detectSensitivityandCarbAbsorption()", startPart);
- Profiler.log(log, "AMA data gathering", start);
+ if (L.isEnabled(L.APS))
+ Profiler.log(log, "detectSensitivityandCarbAbsorption()", startPart);
+ if (L.isEnabled(L.APS))
+ Profiler.log(log, "AMA data gathering", start);
start = new Date();
@@ -200,7 +199,8 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface {
DetermineBasalResultAMA determineBasalResultAMA = determineBasalAdapterAMAJS.invoke();
- Profiler.log(log, "AMA calculation", start);
+ if (L.isEnabled(L.APS))
+ Profiler.log(log, "AMA calculation", start);
// Fix bug determine basal
if (determineBasalResultAMA.rate == 0d && determineBasalResultAMA.duration == 0 && !TreatmentsPlugin.getPlugin().isTempBasalInProgress())
determineBasalResultAMA.tempBasalRequested = false;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/DetermineBasalAdapterMAJS.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/DetermineBasalAdapterMAJS.java
index 6275154450..1574665dc4 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/DetermineBasalAdapterMAJS.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/DetermineBasalAdapterMAJS.java
@@ -2,7 +2,6 @@ package info.nightscout.androidaps.plugins.OpenAPSMA;
import org.json.JSONException;
import org.json.JSONObject;
-import org.mozilla.javascript.Callable;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Function;
import org.mozilla.javascript.NativeJSON;
@@ -16,7 +15,6 @@ import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.GlucoseStatus;
@@ -24,14 +22,15 @@ import info.nightscout.androidaps.data.IobTotal;
import info.nightscout.androidaps.data.MealData;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.db.TemporaryBasal;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Loop.ScriptReader;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.utils.SP;
public class DetermineBasalAdapterMAJS {
- private static Logger log = LoggerFactory.getLogger(DetermineBasalAdapterMAJS.class);
+ private static Logger log = LoggerFactory.getLogger(L.APS);
- private ScriptReader mScriptReader = null;
+ private ScriptReader mScriptReader;
private JSONObject mProfile;
private JSONObject mGlucoseStatus;
private JSONObject mIobData;
@@ -39,12 +38,12 @@ public class DetermineBasalAdapterMAJS {
private JSONObject mCurrentTemp;
private String storedCurrentTemp = null;
- public String storedIobData = null;
+ private String storedIobData = null;
private String storedGlucoseStatus = null;
private String storedProfile = null;
private String storedMeal_data = null;
- public DetermineBasalAdapterMAJS(ScriptReader scriptReader) throws IOException {
+ DetermineBasalAdapterMAJS(ScriptReader scriptReader) {
mScriptReader = scriptReader;
}
@@ -97,7 +96,7 @@ public class DetermineBasalAdapterMAJS {
// Parse the jsResult object to a JSON-String
String result = NativeJSON.stringify(rhino, scope, jsResult, null, null).toString();
- if (Config.logAPSResult)
+ if (L.isEnabled(L.APS))
log.debug("Result: " + result);
try {
determineBasalResultMA = new DetermineBasalResultMA(jsResult, new JSONObject(result));
@@ -108,14 +107,10 @@ public class DetermineBasalAdapterMAJS {
log.debug("Problem loading JS Functions");
}
} catch (IOException e) {
- log.debug("IOException");
+ log.error("IOException");
} catch (RhinoException e) {
log.error("RhinoException: (" + e.lineNumber() + "," + e.columnNumber() + ") " + e.toString());
- } catch (IllegalAccessException e) {
- log.error(e.toString());
- } catch (InstantiationException e) {
- log.error(e.toString());
- } catch (InvocationTargetException e) {
+ } catch (IllegalAccessException | InstantiationException | InvocationTargetException e) {
log.error(e.toString());
} finally {
Context.exit();
@@ -210,7 +205,7 @@ public class DetermineBasalAdapterMAJS {
mMealData.put("boluses", mealData.boluses);
}
- public String readFile(String filename) throws IOException {
+ private String readFile(String filename) throws IOException {
byte[] bytes = mScriptReader.readFile(filename);
String string = new String(bytes, "UTF-8");
if (string.startsWith("#!/usr/bin/env node")) {
@@ -219,13 +214,8 @@ public class DetermineBasalAdapterMAJS {
return string;
}
- public Object makeParam(JSONObject jsonObject, Context rhino, Scriptable scope) {
- Object param = NativeJSON.parse(rhino, scope, jsonObject.toString(), new Callable() {
- @Override
- public Object call(Context context, Scriptable scriptable, Scriptable scriptable1, Object[] objects) {
- return objects[1];
- }
- });
+ private Object makeParam(JSONObject jsonObject, Context rhino, Scriptable scope) {
+ Object param = NativeJSON.parse(rhino, scope, jsonObject.toString(), (context, scriptable, scriptable1, objects) -> objects[1]);
return param;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/DetermineBasalResultMA.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/DetermineBasalResultMA.java
index 75928f09d0..3f0e9abea9 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/DetermineBasalResultMA.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/DetermineBasalResultMA.java
@@ -6,17 +6,18 @@ import org.mozilla.javascript.NativeObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Loop.APSResult;
public class DetermineBasalResultMA extends APSResult {
- private static Logger log = LoggerFactory.getLogger(DetermineBasalResultMA.class);
+ private static Logger log = LoggerFactory.getLogger(L.APS);
public JSONObject json = new JSONObject();
- public double eventualBG;
- public double snoozeBG;
- public String mealAssist;
+ private double eventualBG;
+ private double snoozeBG;
+ private String mealAssist;
- public DetermineBasalResultMA(NativeObject result, JSONObject j) {
+ DetermineBasalResultMA(NativeObject result, JSONObject j) {
json = j;
if (result.containsKey("error")) {
reason = (String) result.get("error");
@@ -49,7 +50,7 @@ public class DetermineBasalResultMA extends APSResult {
}
}
- public DetermineBasalResultMA() {
+ private DetermineBasalResultMA() {
}
@Override
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/LoggerCallback.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/LoggerCallback.java
index 991ec2b25e..8907166951 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/LoggerCallback.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/LoggerCallback.java
@@ -4,8 +4,7 @@ import org.mozilla.javascript.ScriptableObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.MainApp;
-import info.nightscout.utils.ToastUtils;
+import info.nightscout.androidaps.logging.L;
/**
* Created by adrian on 15/10/17.
@@ -14,10 +13,10 @@ import info.nightscout.utils.ToastUtils;
public class LoggerCallback extends ScriptableObject {
- private static Logger log = LoggerFactory.getLogger(DetermineBasalAdapterMAJS.class);
+ private static Logger log = LoggerFactory.getLogger(L.APS);
- static StringBuffer errorBuffer = new StringBuffer();
- static StringBuffer logBuffer = new StringBuffer();
+ private static StringBuffer errorBuffer = new StringBuffer();
+ private static StringBuffer logBuffer = new StringBuffer();
public LoggerCallback() {
@@ -36,26 +35,27 @@ public class LoggerCallback extends ScriptableObject {
}
public void jsFunction_log(Object obj1) {
- log.debug(obj1.toString());
+ if (L.isEnabled(L.APS))
+ log.debug(obj1.toString());
logBuffer.append(obj1.toString());
logBuffer.append(' ');
}
public void jsFunction_error(Object obj1) {
- log.error(obj1.toString());
+ if (L.isEnabled(L.APS))
+ log.error(obj1.toString());
errorBuffer.append(obj1.toString());
errorBuffer.append(' ');
}
-
- public static String getScriptDebug(){
+ public static String getScriptDebug() {
String ret = "";
- if(errorBuffer.length() > 0){
+ if (errorBuffer.length() > 0) {
ret += "e:\n" + errorBuffer.toString();
}
- if(ret.length() > 0 && logBuffer.length() > 0) ret += '\n';
- if(logBuffer.length() > 0){
+ if (ret.length() > 0 && logBuffer.length() > 0) ret += '\n';
+ if (logBuffer.length() > 0) {
ret += "d:\n" + logBuffer.toString();
}
return ret;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAFragment.java
index 7360bb8b2a..bcbc8119f7 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAFragment.java
@@ -2,7 +2,6 @@ package info.nightscout.androidaps.plugins.OpenAPSMA;
import android.app.Activity;
import android.os.Bundle;
-import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -12,10 +11,6 @@ import android.widget.TextView;
import com.crashlytics.android.answers.CustomEvent;
import com.squareup.otto.Subscribe;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui;
@@ -24,8 +19,6 @@ import info.nightscout.utils.FabricPrivacy;
import info.nightscout.utils.JSONFormatter;
public class OpenAPSMAFragment extends SubscriberFragment implements View.OnClickListener {
- private static Logger log = LoggerFactory.getLogger(OpenAPSMAFragment.class);
-
Button run;
TextView lastRunView;
TextView glucoseStatusView;
@@ -87,25 +80,22 @@ public class OpenAPSMAFragment extends SubscriberFragment implements View.OnClic
protected void updateGUI() {
Activity activity = getActivity();
if (activity != null)
- activity.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- DetermineBasalResultMA lastAPSResult = OpenAPSMAPlugin.getPlugin().lastAPSResult;
- if (lastAPSResult != null) {
- resultView.setText(JSONFormatter.format(lastAPSResult.json));
- requestView.setText(lastAPSResult.toSpanned());
- }
- DetermineBasalAdapterMAJS determineBasalAdapterMAJS = OpenAPSMAPlugin.getPlugin().lastDetermineBasalAdapterMAJS;
- if (determineBasalAdapterMAJS != null) {
- glucoseStatusView.setText(JSONFormatter.format(determineBasalAdapterMAJS.getGlucoseStatusParam()));
- currentTempView.setText(JSONFormatter.format(determineBasalAdapterMAJS.getCurrentTempParam()));
- iobDataView.setText(JSONFormatter.format(determineBasalAdapterMAJS.getIobDataParam()));
- profileView.setText(JSONFormatter.format(determineBasalAdapterMAJS.getProfileParam()));
- mealDataView.setText(JSONFormatter.format(determineBasalAdapterMAJS.getMealDataParam()));
- }
- if (OpenAPSMAPlugin.getPlugin().lastAPSRun != null) {
- lastRunView.setText(OpenAPSMAPlugin.getPlugin().lastAPSRun.toLocaleString());
- }
+ activity.runOnUiThread(() -> {
+ DetermineBasalResultMA lastAPSResult = OpenAPSMAPlugin.getPlugin().lastAPSResult;
+ if (lastAPSResult != null) {
+ resultView.setText(JSONFormatter.format(lastAPSResult.json));
+ requestView.setText(lastAPSResult.toSpanned());
+ }
+ DetermineBasalAdapterMAJS determineBasalAdapterMAJS = OpenAPSMAPlugin.getPlugin().lastDetermineBasalAdapterMAJS;
+ if (determineBasalAdapterMAJS != null) {
+ glucoseStatusView.setText(JSONFormatter.format(determineBasalAdapterMAJS.getGlucoseStatusParam()));
+ currentTempView.setText(JSONFormatter.format(determineBasalAdapterMAJS.getCurrentTempParam()));
+ iobDataView.setText(JSONFormatter.format(determineBasalAdapterMAJS.getIobDataParam()));
+ profileView.setText(JSONFormatter.format(determineBasalAdapterMAJS.getProfileParam()));
+ mealDataView.setText(JSONFormatter.format(determineBasalAdapterMAJS.getMealDataParam()));
+ }
+ if (OpenAPSMAPlugin.getPlugin().lastAPSRun != null) {
+ lastRunView.setText(OpenAPSMAPlugin.getPlugin().lastAPSRun.toLocaleString());
}
});
}
@@ -113,18 +103,15 @@ public class OpenAPSMAFragment extends SubscriberFragment implements View.OnClic
private void updateResultGUI(final String text) {
Activity activity = getActivity();
if (activity != null)
- activity.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- resultView.setText(text);
- glucoseStatusView.setText("");
- currentTempView.setText("");
- iobDataView.setText("");
- profileView.setText("");
- mealDataView.setText("");
- requestView.setText("");
- lastRunView.setText("");
- }
+ activity.runOnUiThread(() -> {
+ resultView.setText(text);
+ glucoseStatusView.setText("");
+ currentTempView.setText("");
+ iobDataView.setText("");
+ profileView.setText("");
+ mealDataView.setText("");
+ requestView.setText("");
+ lastRunView.setText("");
});
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java
index 39d05f8ffb..ce350011cd 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java
@@ -4,10 +4,8 @@ import org.json.JSONException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.IOException;
import java.util.Date;
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.GlucoseStatus;
@@ -21,6 +19,7 @@ import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.PumpInterface;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Loop.APSResult;
import info.nightscout.androidaps.plugins.Loop.ScriptReader;
@@ -39,7 +38,7 @@ import static info.nightscout.utils.HardLimits.verifyHardLimits;
* Created by mike on 05.08.2016.
*/
public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
- private static Logger log = LoggerFactory.getLogger(OpenAPSMAPlugin.class);
+ private static Logger log = LoggerFactory.getLogger(L.APS);
private static OpenAPSMAPlugin openAPSMAPlugin;
@@ -90,15 +89,11 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
@Override
public void invoke(String initiator, boolean tempBasalFallback) {
- log.debug("invoke from " + initiator + " tempBasalFallback: " + tempBasalFallback);
+ if (L.isEnabled(L.APS))
+ log.debug("invoke from " + initiator + " tempBasalFallback: " + tempBasalFallback);
lastAPSResult = null;
DetermineBasalAdapterMAJS determineBasalAdapterMAJS = null;
- try {
- determineBasalAdapterMAJS = new DetermineBasalAdapterMAJS(new ScriptReader(MainApp.instance().getBaseContext()));
- } catch (IOException e) {
- log.error(e.getMessage(), e);
- return;
- }
+ determineBasalAdapterMAJS = new DetermineBasalAdapterMAJS(new ScriptReader(MainApp.instance().getBaseContext()));
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
Profile profile = MainApp.getConfigBuilder().getProfile();
@@ -106,21 +101,21 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
if (profile == null) {
MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.noprofileselected)));
- if (Config.logAPSResult)
+ if (L.isEnabled(L.APS))
log.debug(MainApp.gs(R.string.noprofileselected));
return;
}
if (!isEnabled(PluginType.APS)) {
MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_disabled)));
- if (Config.logAPSResult)
+ if (L.isEnabled(L.APS))
log.debug(MainApp.gs(R.string.openapsma_disabled));
return;
}
if (glucoseStatus == null) {
MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_noglucosedata)));
- if (Config.logAPSResult)
+ if (L.isEnabled(L.APS))
log.debug(MainApp.gs(R.string.openapsma_noglucosedata));
return;
}
@@ -147,7 +142,8 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
MealData mealData = TreatmentsPlugin.getPlugin().getMealData();
double maxIob = MainApp.getConstraintChecker().getMaxIOBAllowed().value();
- Profiler.log(log, "MA data gathering", start);
+ if (L.isEnabled(L.APS))
+ Profiler.log(log, "MA data gathering", start);
minBg = verifyHardLimits(minBg, "minBg", HardLimits.VERY_HARD_LIMIT_MIN_BG[0], HardLimits.VERY_HARD_LIMIT_MIN_BG[1]);
maxBg = verifyHardLimits(maxBg, "maxBg", HardLimits.VERY_HARD_LIMIT_MAX_BG[0], HardLimits.VERY_HARD_LIMIT_MAX_BG[1]);
@@ -177,7 +173,8 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
} catch (JSONException e) {
log.error("Unhandled exception", e);
}
- Profiler.log(log, "MA calculation", start);
+ if (L.isEnabled(L.APS))
+ Profiler.log(log, "MA calculation", start);
long now = System.currentTimeMillis();
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/events/EventOpenAPSUpdateResultGui.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/events/EventOpenAPSUpdateResultGui.java
index e65cdd2c57..177133f155 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/events/EventOpenAPSUpdateResultGui.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/events/EventOpenAPSUpdateResultGui.java
@@ -6,7 +6,7 @@ import info.nightscout.androidaps.events.EventUpdateGui;
* Created by mike on 05.08.2016.
*/
public class EventOpenAPSUpdateResultGui extends EventUpdateGui {
- public String text = null;
+ public String text;
public EventOpenAPSUpdateResultGui(String text) {
this.text = text;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/DetermineBasalAdapterSMBJS.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/DetermineBasalAdapterSMBJS.java
index 48a4c16ccd..7ede714c10 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/DetermineBasalAdapterSMBJS.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/DetermineBasalAdapterSMBJS.java
@@ -3,7 +3,6 @@ package info.nightscout.androidaps.plugins.OpenAPSSMB;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
-import org.mozilla.javascript.Callable;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Function;
import org.mozilla.javascript.NativeJSON;
@@ -18,7 +17,6 @@ import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
@@ -27,6 +25,7 @@ import info.nightscout.androidaps.data.IobTotal;
import info.nightscout.androidaps.data.MealData;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.db.TemporaryBasal;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
import info.nightscout.androidaps.plugins.Loop.ScriptReader;
import info.nightscout.androidaps.plugins.OpenAPSMA.LoggerCallback;
@@ -35,10 +34,10 @@ import info.nightscout.utils.SP;
import info.nightscout.utils.SafeParse;
public class DetermineBasalAdapterSMBJS {
- private static Logger log = LoggerFactory.getLogger(DetermineBasalAdapterSMBJS.class);
+ private static Logger log = LoggerFactory.getLogger(L.APS);
- private ScriptReader mScriptReader = null;
+ private ScriptReader mScriptReader;
private JSONObject mProfile;
private JSONObject mGlucoseStatus;
private JSONArray mIobData;
@@ -64,7 +63,7 @@ public class DetermineBasalAdapterSMBJS {
* Main code
*/
- public DetermineBasalAdapterSMBJS(ScriptReader scriptReader) throws IOException {
+ DetermineBasalAdapterSMBJS(ScriptReader scriptReader) {
mScriptReader = scriptReader;
}
@@ -72,19 +71,21 @@ public class DetermineBasalAdapterSMBJS {
public DetermineBasalResultSMB invoke() {
- log.debug(">>> Invoking detemine_basal <<<");
- log.debug("Glucose status: " + (storedGlucoseStatus = mGlucoseStatus.toString()));
- log.debug("IOB data: " + (storedIobData = mIobData.toString()));
- log.debug("Current temp: " + (storedCurrentTemp = mCurrentTemp.toString()));
- log.debug("Profile: " + (storedProfile = mProfile.toString()));
- log.debug("Meal data: " + (storedMeal_data = mMealData.toString()));
- if (mAutosensData != null)
- log.debug("Autosens data: " + (storedAutosens_data = mAutosensData.toString()));
- else
- log.debug("Autosens data: " + (storedAutosens_data = "undefined"));
- log.debug("Reservoir data: " + "undefined");
- log.debug("MicroBolusAllowed: " + (storedMicroBolusAllowed = "" + mMicrobolusAllowed));
- log.debug("SMBAlwaysAllowed: " + (storedSMBAlwaysAllowed = "" + mSMBAlwaysAllowed));
+ if (L.isEnabled(L.APS)) {
+ log.debug(">>> Invoking detemine_basal <<<");
+ log.debug("Glucose status: " + (storedGlucoseStatus = mGlucoseStatus.toString()));
+ log.debug("IOB data: " + (storedIobData = mIobData.toString()));
+ log.debug("Current temp: " + (storedCurrentTemp = mCurrentTemp.toString()));
+ log.debug("Profile: " + (storedProfile = mProfile.toString()));
+ log.debug("Meal data: " + (storedMeal_data = mMealData.toString()));
+ if (mAutosensData != null)
+ log.debug("Autosens data: " + (storedAutosens_data = mAutosensData.toString()));
+ else
+ log.debug("Autosens data: " + (storedAutosens_data = "undefined"));
+ log.debug("Reservoir data: " + "undefined");
+ log.debug("MicroBolusAllowed: " + (storedMicroBolusAllowed = "" + mMicrobolusAllowed));
+ log.debug("SMBAlwaysAllowed: " + (storedSMBAlwaysAllowed = "" + mSMBAlwaysAllowed));
+ }
DetermineBasalResultSMB determineBasalResultSMB = null;
@@ -135,7 +136,7 @@ public class DetermineBasalAdapterSMBJS {
// Parse the jsResult object to a JSON-String
String result = NativeJSON.stringify(rhino, scope, jsResult, null, null).toString();
- if (Config.logAPSResult)
+ if (L.isEnabled(L.APS))
log.debug("Result: " + result);
try {
determineBasalResultSMB = new DetermineBasalResultSMB(new JSONObject(result));
@@ -143,17 +144,13 @@ public class DetermineBasalAdapterSMBJS {
log.error("Unhandled exception", e);
}
} else {
- log.debug("Problem loading JS Functions");
+ log.error("Problem loading JS Functions");
}
} catch (IOException e) {
- log.debug("IOException");
+ log.error("IOException");
} catch (RhinoException e) {
log.error("RhinoException: (" + e.lineNumber() + "," + e.columnNumber() + ") " + e.toString());
- } catch (IllegalAccessException e) {
- log.error(e.toString());
- } catch (InstantiationException e) {
- log.error(e.toString());
- } catch (InvocationTargetException e) {
+ } catch (IllegalAccessException | InstantiationException | InvocationTargetException e) {
log.error(e.toString());
} finally {
Context.exit();
@@ -244,7 +241,7 @@ public class DetermineBasalAdapterSMBJS {
mProfile.put("maxCOB", SMBDefaults.maxCOB);
mProfile.put("skip_neutral_temps", SMBDefaults.skip_neutral_temps);
//align with max-absorption model in AMA sensitivity
- if(mealData.usedMinCarbsImpact > 0){
+ if (mealData.usedMinCarbsImpact > 0) {
mProfile.put("min_5m_carbimpact", mealData.usedMinCarbsImpact);
} else {
mProfile.put("min_5m_carbimpact", SP.getDouble(R.string.key_openapsama_min_5m_carbimpact, SMBDefaults.min_5m_carbimpact));
@@ -319,31 +316,21 @@ public class DetermineBasalAdapterSMBJS {
}
- public Object makeParam(JSONObject jsonObject, Context rhino, Scriptable scope) {
+ private Object makeParam(JSONObject jsonObject, Context rhino, Scriptable scope) {
if (jsonObject == null) return Undefined.instance;
- Object param = NativeJSON.parse(rhino, scope, jsonObject.toString(), new Callable() {
- @Override
- public Object call(Context context, Scriptable scriptable, Scriptable scriptable1, Object[] objects) {
- return objects[1];
- }
- });
+ Object param = NativeJSON.parse(rhino, scope, jsonObject.toString(), (context, scriptable, scriptable1, objects) -> objects[1]);
return param;
}
- public Object makeParamArray(JSONArray jsonArray, Context rhino, Scriptable scope) {
+ private Object makeParamArray(JSONArray jsonArray, Context rhino, Scriptable scope) {
//Object param = NativeJSON.parse(rhino, scope, "{myarray: " + jsonArray.toString() + " }", new Callable() {
- Object param = NativeJSON.parse(rhino, scope, jsonArray.toString(), new Callable() {
- @Override
- public Object call(Context context, Scriptable scriptable, Scriptable scriptable1, Object[] objects) {
- return objects[1];
- }
- });
+ Object param = NativeJSON.parse(rhino, scope, jsonArray.toString(), (context, scriptable, scriptable1, objects) -> objects[1]);
return param;
}
- public String readFile(String filename) throws IOException {
+ private String readFile(String filename) throws IOException {
byte[] bytes = mScriptReader.readFile(filename);
String string = new String(bytes, "UTF-8");
if (string.startsWith("#!/usr/bin/env node")) {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/DetermineBasalResultSMB.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/DetermineBasalResultSMB.java
index d5f108bf4f..bd41120e30 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/DetermineBasalResultSMB.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/DetermineBasalResultSMB.java
@@ -5,11 +5,12 @@ import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Loop.APSResult;
import info.nightscout.utils.DateUtil;
public class DetermineBasalResultSMB extends APSResult {
- private static final Logger log = LoggerFactory.getLogger(DetermineBasalResultSMB.class);
+ private static final Logger log = LoggerFactory.getLogger(L.APS);
private double eventualBG;
private double snoozeBG;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBFragment.java
index 20ccd46b40..91b488e742 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBFragment.java
@@ -21,6 +21,7 @@ import butterknife.ButterKnife;
import butterknife.OnClick;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui;
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateResultGui;
@@ -28,7 +29,7 @@ import info.nightscout.utils.FabricPrivacy;
import info.nightscout.utils.JSONFormatter;
public class OpenAPSSMBFragment extends SubscriberFragment {
- private static Logger log = LoggerFactory.getLogger(OpenAPSSMBFragment.class);
+ private static Logger log = LoggerFactory.getLogger(L.APS);
@BindView(R.id.openapsma_run)
Button run;
@@ -84,40 +85,37 @@ public class OpenAPSSMBFragment extends SubscriberFragment {
protected void updateGUI() {
Activity activity = getActivity();
if (activity != null)
- activity.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- synchronized (OpenAPSSMBFragment.this) {
- if (!isBound()) return;
- OpenAPSSMBPlugin plugin = OpenAPSSMBPlugin.getPlugin();
- DetermineBasalResultSMB lastAPSResult = plugin.lastAPSResult;
- if (lastAPSResult != null) {
- resultView.setText(JSONFormatter.format(lastAPSResult.json));
- requestView.setText(lastAPSResult.toSpanned());
- }
- DetermineBasalAdapterSMBJS determineBasalAdapterSMBJS = plugin.lastDetermineBasalAdapterSMBJS;
- if (determineBasalAdapterSMBJS != null) {
- glucoseStatusView.setText(JSONFormatter.format(determineBasalAdapterSMBJS.getGlucoseStatusParam()).toString().trim());
- currentTempView.setText(JSONFormatter.format(determineBasalAdapterSMBJS.getCurrentTempParam()).toString().trim());
- try {
- JSONArray iobArray = new JSONArray(determineBasalAdapterSMBJS.getIobDataParam());
- iobDataView.setText((String.format(MainApp.gs(R.string.array_of_elements), iobArray.length()) + "\n" + JSONFormatter.format(iobArray.getString(0))).trim());
- } catch (JSONException e) {
- log.error("Unhandled exception", e);
- iobDataView.setText("JSONException see log for details");
- }
- profileView.setText(JSONFormatter.format(determineBasalAdapterSMBJS.getProfileParam()).toString().trim());
- mealDataView.setText(JSONFormatter.format(determineBasalAdapterSMBJS.getMealDataParam()).toString().trim());
- scriptdebugView.setText(determineBasalAdapterSMBJS.getScriptDebug().trim());
- if (lastAPSResult != null && lastAPSResult.inputConstraints != null)
- constraintsView.setText(lastAPSResult.inputConstraints.getReasons().trim());
- }
- if (plugin.lastAPSRun != null) {
- lastRunView.setText(plugin.lastAPSRun.toLocaleString().trim());
- }
- if (plugin.lastAutosensResult != null) {
- autosensDataView.setText(JSONFormatter.format(plugin.lastAutosensResult.json()).toString().trim());
+ activity.runOnUiThread(() -> {
+ synchronized (OpenAPSSMBFragment.this) {
+ if (!isBound()) return;
+ OpenAPSSMBPlugin plugin = OpenAPSSMBPlugin.getPlugin();
+ DetermineBasalResultSMB lastAPSResult = plugin.lastAPSResult;
+ if (lastAPSResult != null) {
+ resultView.setText(JSONFormatter.format(lastAPSResult.json));
+ requestView.setText(lastAPSResult.toSpanned());
+ }
+ DetermineBasalAdapterSMBJS determineBasalAdapterSMBJS = plugin.lastDetermineBasalAdapterSMBJS;
+ if (determineBasalAdapterSMBJS != null) {
+ glucoseStatusView.setText(JSONFormatter.format(determineBasalAdapterSMBJS.getGlucoseStatusParam()).toString().trim());
+ currentTempView.setText(JSONFormatter.format(determineBasalAdapterSMBJS.getCurrentTempParam()).toString().trim());
+ try {
+ JSONArray iobArray = new JSONArray(determineBasalAdapterSMBJS.getIobDataParam());
+ iobDataView.setText((String.format(MainApp.gs(R.string.array_of_elements), iobArray.length()) + "\n" + JSONFormatter.format(iobArray.getString(0))).trim());
+ } catch (JSONException e) {
+ log.error("Unhandled exception", e);
+ iobDataView.setText("JSONException see log for details");
}
+ profileView.setText(JSONFormatter.format(determineBasalAdapterSMBJS.getProfileParam()).toString().trim());
+ mealDataView.setText(JSONFormatter.format(determineBasalAdapterSMBJS.getMealDataParam()).toString().trim());
+ scriptdebugView.setText(determineBasalAdapterSMBJS.getScriptDebug().trim());
+ if (lastAPSResult != null && lastAPSResult.inputConstraints != null)
+ constraintsView.setText(lastAPSResult.inputConstraints.getReasons().trim());
+ }
+ if (plugin.lastAPSRun != null) {
+ lastRunView.setText(plugin.lastAPSRun.toLocaleString().trim());
+ }
+ if (plugin.lastAutosensResult != null) {
+ autosensDataView.setText(JSONFormatter.format(plugin.lastAutosensResult.json()).toString().trim());
}
}
});
@@ -126,22 +124,19 @@ public class OpenAPSSMBFragment extends SubscriberFragment {
void updateResultGUI(final String text) {
Activity activity = getActivity();
if (activity != null)
- activity.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- synchronized (OpenAPSSMBFragment.this) {
- if (isBound()) {
- resultView.setText(text);
- glucoseStatusView.setText("");
- currentTempView.setText("");
- iobDataView.setText("");
- profileView.setText("");
- mealDataView.setText("");
- autosensDataView.setText("");
- scriptdebugView.setText("");
- requestView.setText("");
- lastRunView.setText("");
- }
+ activity.runOnUiThread(() -> {
+ synchronized (OpenAPSSMBFragment.this) {
+ if (isBound()) {
+ resultView.setText(text);
+ glucoseStatusView.setText("");
+ currentTempView.setText("");
+ iobDataView.setText("");
+ profileView.setText("");
+ mealDataView.setText("");
+ autosensDataView.setText("");
+ scriptdebugView.setText("");
+ requestView.setText("");
+ lastRunView.setText("");
}
}
});
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBPlugin.java
index 570b76502f..64daaed9c1 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBPlugin.java
@@ -1,14 +1,11 @@
package info.nightscout.androidaps.plugins.OpenAPSSMB;
-import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
import org.json.JSONException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.IOException;
import java.util.Date;
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.GlucoseStatus;
@@ -23,17 +20,19 @@ import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.PumpInterface;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
+import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult;
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
import info.nightscout.androidaps.plugins.Loop.APSResult;
import info.nightscout.androidaps.plugins.Loop.ScriptReader;
+import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui;
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateResultGui;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.HardLimits;
-import info.nightscout.utils.NSUpload;
import info.nightscout.utils.Profiler;
import info.nightscout.utils.Round;
import info.nightscout.utils.ToastUtils;
@@ -42,7 +41,7 @@ import info.nightscout.utils.ToastUtils;
* Created by mike on 05.08.2016.
*/
public class OpenAPSSMBPlugin extends PluginBase implements APSInterface {
- private static Logger log = LoggerFactory.getLogger(OpenAPSSMBPlugin.class);
+ private static Logger log = LoggerFactory.getLogger(L.APS);
private static OpenAPSSMBPlugin openAPSSMBPlugin;
@@ -94,15 +93,11 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface {
@Override
public void invoke(String initiator, boolean tempBasalFallback) {
- log.debug("invoke from " + initiator + " tempBasalFallback: " + tempBasalFallback);
+ if (L.isEnabled(L.APS))
+ log.debug("invoke from " + initiator + " tempBasalFallback: " + tempBasalFallback);
lastAPSResult = null;
- DetermineBasalAdapterSMBJS determineBasalAdapterSMBJS = null;
- try {
- determineBasalAdapterSMBJS = new DetermineBasalAdapterSMBJS(new ScriptReader(MainApp.instance().getBaseContext()));
- } catch (IOException e) {
- log.error(e.getMessage(), e);
- return;
- }
+ DetermineBasalAdapterSMBJS determineBasalAdapterSMBJS;
+ determineBasalAdapterSMBJS = new DetermineBasalAdapterSMBJS(new ScriptReader(MainApp.instance().getBaseContext()));
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
Profile profile = MainApp.getConfigBuilder().getProfile();
@@ -110,21 +105,21 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface {
if (profile == null) {
MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.noprofileselected)));
- if (Config.logAPSResult)
+ if (L.isEnabled(L.APS))
log.debug(MainApp.gs(R.string.noprofileselected));
return;
}
if (!isEnabled(PluginType.APS)) {
MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_disabled)));
- if (Config.logAPSResult)
+ if (L.isEnabled(L.APS))
log.debug(MainApp.gs(R.string.openapsma_disabled));
return;
}
if (glucoseStatus == null) {
MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_noglucosedata)));
- if (Config.logAPSResult)
+ if (L.isEnabled(L.APS))
log.debug(MainApp.gs(R.string.openapsma_noglucosedata));
return;
}
@@ -146,11 +141,13 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface {
Date start = new Date();
Date startPart = new Date();
IobTotal[] iobArray = IobCobCalculatorPlugin.getPlugin().calculateIobArrayForSMB(profile);
- Profiler.log(log, "calculateIobArrayInDia()", startPart);
+ if (L.isEnabled(L.APS))
+ Profiler.log(log, "calculateIobArrayInDia()", startPart);
startPart = new Date();
MealData mealData = TreatmentsPlugin.getPlugin().getMealData();
- Profiler.log(log, "getMealData()", startPart);
+ if (L.isEnabled(L.APS))
+ Profiler.log(log, "getMealData()", startPart);
double maxIob = MainApp.getConstraintChecker().getMaxIOBAllowed().value();
@@ -170,7 +167,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface {
if (!checkOnlyHardLimits(profile.getDia(), "dia", HardLimits.MINDIA, HardLimits.MAXDIA))
return;
- if (!checkOnlyHardLimits(profile.getIcTimeFromMidnight(profile.secondsFromMidnight()), "carbratio", HardLimits.MINIC, HardLimits.MAXIC))
+ if (!checkOnlyHardLimits(profile.getIcTimeFromMidnight(Profile.secondsFromMidnight()), "carbratio", HardLimits.MINIC, HardLimits.MAXIC))
return;
if (!checkOnlyHardLimits(Profile.toMgdl(profile.getIsf(), units), "sens", HardLimits.MINISF, HardLimits.MAXISF))
return;
@@ -200,8 +197,10 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface {
MainApp.getConstraintChecker().isAdvancedFilteringEnabled(advancedFiltering);
inputConstraints.copyReasons(advancedFiltering);
- Profiler.log(log, "detectSensitivityandCarbAbsorption()", startPart);
- Profiler.log(log, "SMB data gathering", start);
+ if (L.isEnabled(L.APS))
+ Profiler.log(log, "detectSensitivityandCarbAbsorption()", startPart);
+ if (L.isEnabled(L.APS))
+ Profiler.log(log, "SMB data gathering", start);
start = new Date();
try {
@@ -219,7 +218,8 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface {
long now = System.currentTimeMillis();
DetermineBasalResultSMB determineBasalResultSMB = determineBasalAdapterSMBJS.invoke();
- Profiler.log(log, "SMB calculation", start);
+ if (L.isEnabled(L.APS))
+ Profiler.log(log, "SMB calculation", start);
// TODO still needed with oref1?
// Fix bug determine basal
if (determineBasalResultSMB.rate == 0d && determineBasalResultSMB.duration == 0 && !TreatmentsPlugin.getPlugin().isTempBasalInProgress())
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/ErrorDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/ErrorDialog.java
index 7d45c35792..7c05b4398e 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/ErrorDialog.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/ErrorDialog.java
@@ -15,7 +15,7 @@ import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
-import info.nightscout.androidaps.Services.AlarmSoundService;
+import info.nightscout.androidaps.services.AlarmSoundService;
public class ErrorDialog extends DialogFragment implements View.OnClickListener {
private static Logger log = LoggerFactory.getLogger(ErrorDialog.class);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/ErrorHelperActivity.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/ErrorHelperActivity.java
index 90cf9aecd5..c556a6c844 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/ErrorHelperActivity.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/ErrorHelperActivity.java
@@ -4,7 +4,7 @@ import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import info.nightscout.androidaps.R;
-import info.nightscout.utils.NSUpload;
+import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
import info.nightscout.utils.SP;
public class ErrorHelperActivity extends AppCompatActivity {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewCarbsDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewCarbsDialog.java
index b51270938d..cd03cb7b6a 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewCarbsDialog.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewCarbsDialog.java
@@ -21,7 +21,7 @@ import android.widget.RadioButton;
import com.google.common.base.Joiner;
-import info.nightscout.utils.NSUpload;
+import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java
index b5e97a59d8..91dbb29042 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java
@@ -80,13 +80,13 @@ import info.nightscout.androidaps.interfaces.Constraint;
import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.interfaces.PumpInterface;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.ConstraintsObjectives.ObjectivesPlugin;
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
-import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult;
import info.nightscout.androidaps.plugins.IobCobCalculator.CobInfo;
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished;
@@ -115,7 +115,7 @@ import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.DefaultValueHelper;
import info.nightscout.utils.FabricPrivacy;
-import info.nightscout.utils.NSUpload;
+import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
import info.nightscout.utils.OKDialog;
import info.nightscout.utils.Profiler;
import info.nightscout.utils.SP;
@@ -126,7 +126,7 @@ import info.nightscout.utils.ToastUtils;
import static info.nightscout.utils.DateUtil.now;
public class OverviewFragment extends Fragment implements View.OnClickListener, View.OnLongClickListener {
- private static Logger log = LoggerFactory.getLogger(Constants.OVERVIEW);
+ private static Logger log = LoggerFactory.getLogger(L.OVERVIEW);
TextView timeView;
TextView bgView;
@@ -826,7 +826,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
builder.setPositiveButton(MainApp.gs(R.string.ok), (dialog, id) -> {
synchronized (builder) {
if (accepted) {
- if (Config.logOverview)
+ if (L.isEnabled(L.OVERVIEW))
log.debug("guarding: already accepted");
return;
}
@@ -1032,7 +1032,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
@SuppressLint("SetTextI18n")
public void updateGUI(final String from) {
- if (Config.logOverview)
+ if (L.isEnabled(L.OVERVIEW))
log.debug("updateGUI entered from: " + from);
final Date updateGUIStart = new Date();
@@ -1428,7 +1428,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
final long now = System.currentTimeMillis();
// ------------------ 1st graph
- if (Config.logOverview)
+ if (L.isEnabled(L.OVERVIEW))
Profiler.log(log, from + " - 1st graph - START", updateGUIStart);
final GraphData graphData = new GraphData(bgGraph, IobCobCalculatorPlugin.getPlugin());
@@ -1461,7 +1461,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
graphData.addNowLine(now);
// ------------------ 2nd graph
- if (Config.logOverview)
+ if (L.isEnabled(L.OVERVIEW))
Profiler.log(log, from + " - 2nd graph - START", updateGUIStart);
final GraphData secondGraphData = new GraphData(iobGraph, IobCobCalculatorPlugin.getPlugin());
@@ -1516,13 +1516,13 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
// finally enforce drawing of graphs
graphData.performUpdate();
secondGraphData.performUpdate();
- if (Config.logOverview)
+ if (L.isEnabled(L.OVERVIEW))
Profiler.log(log, from + " - onDataChanged", updateGUIStart);
});
}
}).start();
- if (Config.logOverview)
+ if (L.isEnabled(L.OVERVIEW))
Profiler.log(log, from, updateGUIStart);
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewPlugin.java
index eea249c2e2..dfd6b9970c 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewPlugin.java
@@ -7,7 +7,6 @@ import org.json.JSONException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Profile;
@@ -16,6 +15,7 @@ import info.nightscout.androidaps.events.EventRefreshOverview;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.Overview.notifications.NotificationStore;
@@ -25,7 +25,7 @@ import info.nightscout.utils.SP;
* Created by mike on 05.08.2016.
*/
public class OverviewPlugin extends PluginBase {
- private static Logger log = LoggerFactory.getLogger(Constants.OVERVIEW);
+ private static Logger log = LoggerFactory.getLogger(L.OVERVIEW);
private static OverviewPlugin overviewPlugin = new OverviewPlugin();
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/graphData/GraphData.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/graphData/GraphData.java
index d750965d38..72fbbff5a5 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/graphData/GraphData.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/graphData/GraphData.java
@@ -18,7 +18,6 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
@@ -28,6 +27,7 @@ import info.nightscout.androidaps.db.CareportalEvent;
import info.nightscout.androidaps.db.ExtendedBolus;
import info.nightscout.androidaps.db.ProfileSwitch;
import info.nightscout.androidaps.db.TempTarget;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
import info.nightscout.androidaps.plugins.IobCobCalculator.BasalData;
@@ -51,7 +51,7 @@ import info.nightscout.utils.Round;
*/
public class GraphData {
- private static Logger log = LoggerFactory.getLogger(Constants.OVERVIEW);
+ private static Logger log = LoggerFactory.getLogger(L.OVERVIEW);
private GraphView graph;
public double maxY = Double.MIN_VALUE;
@@ -75,7 +75,7 @@ public class GraphData {
List bgListArray = new ArrayList<>();
if (bgReadingsArray == null || bgReadingsArray.size() == 0) {
- if (Config.logOverview)
+ if (L.isEnabled(L.OVERVIEW))
log.debug("No BG data.");
return;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/NotificationRecyclerViewAdapter.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/NotificationRecyclerViewAdapter.java
index 02390154b6..9af6be3be3 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/NotificationRecyclerViewAdapter.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/NotificationRecyclerViewAdapter.java
@@ -15,10 +15,9 @@ import org.slf4j.LoggerFactory;
import java.util.List;
import java.util.Objects;
-import info.nightscout.androidaps.Config;
-import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.NSClientInternal.broadcasts.BroadcastAckAlarm;
import info.nightscout.androidaps.plugins.Overview.OverviewPlugin;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
@@ -26,7 +25,7 @@ import info.nightscout.utils.DateUtil;
import info.nightscout.utils.SP;
public class NotificationRecyclerViewAdapter extends RecyclerView.Adapter {
- private static Logger log = LoggerFactory.getLogger(Constants.NOTIFICATION);
+ private static Logger log = LoggerFactory.getLogger(L.NOTIFICATION);
private List notificationsList;
@@ -98,12 +97,12 @@ public class NotificationRecyclerViewAdapter extends RecyclerView.Adapter store = new ArrayList<>();
private boolean usesChannels;
@@ -52,7 +52,7 @@ public class NotificationStore {
}
public synchronized boolean add(Notification n) {
- if (Config.logNotification)
+ if (L.isEnabled(L.NOTIFICATION))
log.debug("Notification received: " + n.text);
for (Notification storeNotification : store) {
if (storeNotification.id == n.id) {
@@ -108,7 +108,7 @@ public class NotificationStore {
}
public void snoozeTo(long timeToSnooze) {
- if (Config.logNotification)
+ if (L.isEnabled(L.NOTIFICATION))
log.debug("Snoozing alarm until: " + timeToSnooze);
SP.putLong("snoozedTo", timeToSnooze);
}
@@ -118,7 +118,7 @@ public class NotificationStore {
Notification notification = new Notification(Notification.NSALARM, MainApp.gs(R.string.nsalarm_staledata), Notification.URGENT);
SP.putLong("snoozedTo", System.currentTimeMillis());
add(notification);
- if (Config.logNotification)
+ if (L.isEnabled(L.NOTIFICATION))
log.debug("Snoozed to current time and added back notification!");
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileLocal/LocalProfileFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileLocal/LocalProfileFragment.java
index 18060ba1ec..3fab80855a 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileLocal/LocalProfileFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileLocal/LocalProfileFragment.java
@@ -25,20 +25,18 @@ import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.ProfileStore;
import info.nightscout.androidaps.events.EventInitializationChanged;
import info.nightscout.androidaps.interfaces.PumpDescription;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.utils.DecimalFormatter;
-import info.nightscout.utils.FabricPrivacy;
import info.nightscout.utils.NumberPicker;
import info.nightscout.utils.SafeParse;
import info.nightscout.utils.TimeListEdit;
public class LocalProfileFragment extends SubscriberFragment {
- private static Logger log = LoggerFactory.getLogger(LocalProfileFragment.class);
-
NumberPicker diaView;
RadioButton mgdlView;
RadioButton mmolView;
@@ -81,80 +79,72 @@ public class LocalProfileFragment extends SubscriberFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
- try {
+ PumpDescription pumpDescription = ConfigBuilderPlugin.getActivePump().getPumpDescription();
+ View layout = inflater.inflate(R.layout.localprofile_fragment, container, false);
+ diaView = (NumberPicker) layout.findViewById(R.id.localprofile_dia);
+ diaView.setParams(LocalProfilePlugin.getPlugin().dia, 2d, 48d, 0.1d, new DecimalFormat("0.0"), false, textWatch);
+ mgdlView = (RadioButton) layout.findViewById(R.id.localprofile_mgdl);
+ mmolView = (RadioButton) layout.findViewById(R.id.localprofile_mmol);
+ icView = new TimeListEdit(getContext(), layout, R.id.localprofile_ic, MainApp.gs(R.string.nsprofileview_ic_label) + ":", LocalProfilePlugin.getPlugin().ic, null, 0.5, 50d, 0.1d, new DecimalFormat("0.0"), save);
+ isfView = new TimeListEdit(getContext(), layout, R.id.localprofile_isf, MainApp.gs(R.string.nsprofileview_isf_label) + ":", LocalProfilePlugin.getPlugin().isf, null, 0.5, 500d, 0.1d, new DecimalFormat("0.0"), save);
+ basalView = new TimeListEdit(getContext(), layout, R.id.localprofile_basal, MainApp.gs(R.string.nsprofileview_basal_label) + ": " + getSumLabel(), LocalProfilePlugin.getPlugin().basal, null, pumpDescription.basalMinimumRate, 10, 0.01d, new DecimalFormat("0.00"), save);
+ targetView = new TimeListEdit(getContext(), layout, R.id.localprofile_target, MainApp.gs(R.string.nsprofileview_target_label) + ":", LocalProfilePlugin.getPlugin().targetLow, LocalProfilePlugin.getPlugin().targetHigh, 3d, 200, 0.1d, new DecimalFormat("0.0"), save);
+ profileswitchButton = (Button) layout.findViewById(R.id.localprofile_profileswitch);
+ resetButton = (Button) layout.findViewById(R.id.localprofile_reset);
+ saveButton = (Button) layout.findViewById(R.id.localprofile_save);
- PumpDescription pumpDescription = ConfigBuilderPlugin.getActivePump().getPumpDescription();
- View layout = inflater.inflate(R.layout.localprofile_fragment, container, false);
- diaView = (NumberPicker) layout.findViewById(R.id.localprofile_dia);
- diaView.setParams(LocalProfilePlugin.getPlugin().dia, 2d, 48d, 0.1d, new DecimalFormat("0.0"), false, textWatch);
- mgdlView = (RadioButton) layout.findViewById(R.id.localprofile_mgdl);
- mmolView = (RadioButton) layout.findViewById(R.id.localprofile_mmol);
+
+ invalidProfile = (TextView) layout.findViewById(R.id.invalidprofile);
+
+ if (!ConfigBuilderPlugin.getActivePump().getPumpDescription().isTempBasalCapable) {
+ layout.findViewById(R.id.localprofile_basal).setVisibility(View.GONE);
+ }
+
+ mgdlView.setChecked(LocalProfilePlugin.getPlugin().mgdl);
+ mmolView.setChecked(LocalProfilePlugin.getPlugin().mmol);
+
+ mgdlView.setOnClickListener(v -> {
+ LocalProfilePlugin.getPlugin().mgdl = mgdlView.isChecked();
+ LocalProfilePlugin.getPlugin().mmol = !LocalProfilePlugin.getPlugin().mgdl;
+ mmolView.setChecked(LocalProfilePlugin.getPlugin().mmol);
+ doEdit();
+ });
+ mmolView.setOnClickListener(v -> {
+ LocalProfilePlugin.getPlugin().mmol = mmolView.isChecked();
+ LocalProfilePlugin.getPlugin().mgdl = !LocalProfilePlugin.getPlugin().mmol;
+ mgdlView.setChecked(LocalProfilePlugin.getPlugin().mgdl);
+ doEdit();
+ });
+
+ profileswitchButton.setOnClickListener(view -> {
+ NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
+ final OptionsToShow profileswitch = CareportalFragment.PROFILESWITCHDIRECT;
+ profileswitch.executeProfileSwitch = true;
+ newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
+ newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
+ });
+
+ resetButton.setOnClickListener(view -> {
+ LocalProfilePlugin.getPlugin().loadSettings();
+ mgdlView.setChecked(LocalProfilePlugin.getPlugin().mgdl);
+ mmolView.setChecked(LocalProfilePlugin.getPlugin().mmol);
+ diaView.setParams(LocalProfilePlugin.getPlugin().dia, 5d, 12d, 0.1d, new DecimalFormat("0.0"), false, textWatch);
icView = new TimeListEdit(getContext(), layout, R.id.localprofile_ic, MainApp.gs(R.string.nsprofileview_ic_label) + ":", LocalProfilePlugin.getPlugin().ic, null, 0.5, 50d, 0.1d, new DecimalFormat("0.0"), save);
isfView = new TimeListEdit(getContext(), layout, R.id.localprofile_isf, MainApp.gs(R.string.nsprofileview_isf_label) + ":", LocalProfilePlugin.getPlugin().isf, null, 0.5, 500d, 0.1d, new DecimalFormat("0.0"), save);
basalView = new TimeListEdit(getContext(), layout, R.id.localprofile_basal, MainApp.gs(R.string.nsprofileview_basal_label) + ": " + getSumLabel(), LocalProfilePlugin.getPlugin().basal, null, pumpDescription.basalMinimumRate, 10, 0.01d, new DecimalFormat("0.00"), save);
targetView = new TimeListEdit(getContext(), layout, R.id.localprofile_target, MainApp.gs(R.string.nsprofileview_target_label) + ":", LocalProfilePlugin.getPlugin().targetLow, LocalProfilePlugin.getPlugin().targetHigh, 3d, 200, 0.1d, new DecimalFormat("0.0"), save);
- profileswitchButton = (Button) layout.findViewById(R.id.localprofile_profileswitch);
- resetButton = (Button) layout.findViewById(R.id.localprofile_reset);
- saveButton = (Button) layout.findViewById(R.id.localprofile_save);
+ updateGUI();
+ });
-
- invalidProfile = (TextView) layout.findViewById(R.id.invalidprofile);
-
- if (!ConfigBuilderPlugin.getActivePump().getPumpDescription().isTempBasalCapable) {
- layout.findViewById(R.id.localprofile_basal).setVisibility(View.GONE);
+ saveButton.setOnClickListener(view -> {
+ if (!LocalProfilePlugin.getPlugin().isValidEditState()) {
+ return; //Should not happen as saveButton should not be visible if not valid
}
+ LocalProfilePlugin.getPlugin().storeSettings();
+ updateGUI();
+ });
- mgdlView.setChecked(LocalProfilePlugin.getPlugin().mgdl);
- mmolView.setChecked(LocalProfilePlugin.getPlugin().mmol);
-
- mgdlView.setOnClickListener(v -> {
- LocalProfilePlugin.getPlugin().mgdl = mgdlView.isChecked();
- LocalProfilePlugin.getPlugin().mmol = !LocalProfilePlugin.getPlugin().mgdl;
- mmolView.setChecked(LocalProfilePlugin.getPlugin().mmol);
- doEdit();
- });
- mmolView.setOnClickListener(v -> {
- LocalProfilePlugin.getPlugin().mmol = mmolView.isChecked();
- LocalProfilePlugin.getPlugin().mgdl = !LocalProfilePlugin.getPlugin().mmol;
- mgdlView.setChecked(LocalProfilePlugin.getPlugin().mgdl);
- doEdit();
- });
-
- profileswitchButton.setOnClickListener(view -> {
- NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
- final OptionsToShow profileswitch = CareportalFragment.PROFILESWITCHDIRECT;
- profileswitch.executeProfileSwitch = true;
- newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
- newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
- });
-
- resetButton.setOnClickListener(view -> {
- LocalProfilePlugin.getPlugin().loadSettings();
- mgdlView.setChecked(LocalProfilePlugin.getPlugin().mgdl);
- mmolView.setChecked(LocalProfilePlugin.getPlugin().mmol);
- diaView.setParams(LocalProfilePlugin.getPlugin().dia, 5d, 12d, 0.1d, new DecimalFormat("0.0"), false, textWatch);
- icView = new TimeListEdit(getContext(), layout, R.id.localprofile_ic, MainApp.gs(R.string.nsprofileview_ic_label) + ":", LocalProfilePlugin.getPlugin().ic, null, 0.5, 50d, 0.1d, new DecimalFormat("0.0"), save);
- isfView = new TimeListEdit(getContext(), layout, R.id.localprofile_isf, MainApp.gs(R.string.nsprofileview_isf_label) + ":", LocalProfilePlugin.getPlugin().isf, null, 0.5, 500d, 0.1d, new DecimalFormat("0.0"), save);
- basalView = new TimeListEdit(getContext(), layout, R.id.localprofile_basal, MainApp.gs(R.string.nsprofileview_basal_label) + ": " + getSumLabel(), LocalProfilePlugin.getPlugin().basal, null, pumpDescription.basalMinimumRate, 10, 0.01d, new DecimalFormat("0.00"), save);
- targetView = new TimeListEdit(getContext(), layout, R.id.localprofile_target, MainApp.gs(R.string.nsprofileview_target_label) + ":", LocalProfilePlugin.getPlugin().targetLow, LocalProfilePlugin.getPlugin().targetHigh, 3d, 200, 0.1d, new DecimalFormat("0.0"), save);
- updateGUI();
- });
-
- saveButton.setOnClickListener(view -> {
- if(!LocalProfilePlugin.getPlugin().isValidEditState()){
- return; //Should not happen as saveButton should not be visible if not valid
- }
- LocalProfilePlugin.getPlugin().storeSettings();
- updateGUI();
- });
-
- return layout;
- } catch (Exception e) {
- log.error("Unhandled exception: ", e);
- FabricPrivacy.logException(e);
- }
-
- return null;
+ return layout;
}
public void doEdit() {
@@ -203,7 +193,7 @@ public class LocalProfileFragment extends SubscriberFragment {
}
//Show reset button iff data was edited
- if(isEdited) {
+ if (isEdited) {
resetButton.setVisibility(View.VISIBLE);
} else {
resetButton.setVisibility(View.GONE);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileLocal/LocalProfilePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileLocal/LocalProfilePlugin.java
index 8d4e2d6a36..7a06860327 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileLocal/LocalProfilePlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileLocal/LocalProfilePlugin.java
@@ -8,7 +8,6 @@ import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
@@ -18,6 +17,7 @@ import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.ProfileInterface;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.SP;
@@ -26,7 +26,7 @@ import info.nightscout.utils.SP;
*/
public class LocalProfilePlugin extends PluginBase implements ProfileInterface {
public static final String LOCAL_PROFILE = "LocalProfile";
- private static Logger log = LoggerFactory.getLogger(LocalProfilePlugin.class);
+ private static Logger log = LoggerFactory.getLogger(L.PROFILE);
private static LocalProfilePlugin localProfilePlugin;
@@ -81,13 +81,13 @@ public class LocalProfilePlugin extends PluginBase implements ProfileInterface {
createAndStoreConvertedProfile();
edited = false;
- if (Config.logPrefsChange)
+ if (L.isEnabled(L.PROFILE))
log.debug("Storing settings: " + getRawProfile().getData().toString());
MainApp.bus().post(new EventProfileStoreChanged());
}
public synchronized void loadSettings() {
- if (Config.logPrefsChange)
+ if (L.isEnabled(L.PROFILE))
log.debug("Loading stored settings");
mgdl = SP.getBoolean(LOCAL_PROFILE + "mgdl", false);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileNS/NSProfileFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileNS/NSProfileFragment.java
index 6cc9fdf98e..b0f0700fe2 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileNS/NSProfileFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileNS/NSProfileFragment.java
@@ -27,7 +27,6 @@ import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.androidaps.plugins.ProfileNS.events.EventNSProfileUpdateGUI;
import info.nightscout.androidaps.plugins.Treatments.fragments.ProfileGraph;
import info.nightscout.utils.DecimalFormatter;
-import info.nightscout.utils.FabricPrivacy;
import info.nightscout.utils.OKDialog;
import static butterknife.OnItemSelected.Callback.NOTHING_SELECTED;
@@ -62,24 +61,22 @@ public class NSProfileFragment extends SubscriberFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
- try {
- View view = inflater.inflate(R.layout.nsprofile_fragment, container, false);
+ View view = inflater.inflate(R.layout.nsprofile_fragment, container, false);
- unbinder = ButterKnife.bind(this, view);
- updateGUI();
- return view;
- } catch (Exception e) {
- FabricPrivacy.logException(e);
- }
-
- return null;
+ unbinder = ButterKnife.bind(this, view);
+ updateGUI();
+ return view;
}
@Subscribe
public void onStatusEvent(final EventNSProfileUpdateGUI ev) {
Activity activity = getActivity();
if (activity != null)
- activity.runOnUiThread(() -> { synchronized (NSProfileFragment.this) { updateGUI(); } });
+ activity.runOnUiThread(() -> {
+ synchronized (NSProfileFragment.this) {
+ updateGUI();
+ }
+ });
}
@Override
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileNS/NSProfilePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileNS/NSProfilePlugin.java
index ec4cc22055..99e4ad9115 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileNS/NSProfilePlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileNS/NSProfilePlugin.java
@@ -13,7 +13,8 @@ import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
-import info.nightscout.androidaps.Services.Intents;
+import info.nightscout.androidaps.logging.L;
+import info.nightscout.androidaps.services.Intents;
import info.nightscout.androidaps.data.ProfileStore;
import info.nightscout.androidaps.events.EventProfileStoreChanged;
import info.nightscout.androidaps.interfaces.PluginBase;
@@ -27,7 +28,7 @@ import info.nightscout.utils.SP;
* Created by mike on 05.08.2016.
*/
public class NSProfilePlugin extends PluginBase implements ProfileInterface {
- private static Logger log = LoggerFactory.getLogger(NSProfilePlugin.class);
+ private static Logger log = LoggerFactory.getLogger(L.PROFILE);
private static NSProfilePlugin nsProfilePlugin;
@@ -77,7 +78,7 @@ public class NSProfilePlugin extends PluginBase implements ProfileInterface {
MainApp.bus().post(new EventProfileStoreChanged());
MainApp.bus().post(new EventNSProfileUpdateGUI());
}
- if (Config.logIncommingData)
+ if (L.isEnabled(L.PROFILE))
log.debug("Received profileStore: " + activeProfile + " " + profile);
} catch (JSONException e) {
log.error("Unhandled exception", e);
@@ -86,31 +87,29 @@ public class NSProfilePlugin extends PluginBase implements ProfileInterface {
private void storeNSProfile() {
SP.putString("profile", profile.getData().toString());
- if (Config.logPrefsChange)
+ if (L.isEnabled(L.PROFILE))
log.debug("Storing profile");
}
private void loadNSProfile() {
- if (Config.logPrefsChange)
+ if (L.isEnabled(L.PROFILE))
log.debug("Loading stored profile");
String profileString = SP.getString("profile", null);
if (profileString != null) {
- if (Config.logPrefsChange) {
+ if (L.isEnabled(L.PROFILE))
log.debug("Loaded profile: " + profileString);
- try {
- profile = new ProfileStore(new JSONObject(profileString));
- } catch (JSONException e) {
- log.error("Unhandled exception", e);
- profile = null;
- }
+ try {
+ profile = new ProfileStore(new JSONObject(profileString));
+ } catch (JSONException e) {
+ log.error("Unhandled exception", e);
+ profile = null;
}
} else {
- if (Config.logPrefsChange) {
+ if (L.isEnabled(L.PROFILE))
log.debug("Stored profile not found");
- // force restart of nsclient to fetch profile
- Intent restartNSClient = new Intent(Intents.ACTION_RESTART);
- MainApp.instance().getApplicationContext().sendBroadcast(restartNSClient);
- }
+ // force restart of nsclient to fetch profile
+ Intent restartNSClient = new Intent(Intents.ACTION_RESTART);
+ MainApp.instance().getApplicationContext().sendBroadcast(restartNSClient);
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileSimple/SimpleProfileFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileSimple/SimpleProfileFragment.java
index 1315413e38..5e090cd9ba 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileSimple/SimpleProfileFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileSimple/SimpleProfileFragment.java
@@ -26,12 +26,9 @@ import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialo
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
-import info.nightscout.utils.FabricPrivacy;
import info.nightscout.utils.SafeParse;
public class SimpleProfileFragment extends SubscriberFragment {
- private static Logger log = LoggerFactory.getLogger(SimpleProfileFragment.class);
-
EditText diaView;
RadioButton mgdlView;
RadioButton mmolView;
@@ -46,92 +43,86 @@ public class SimpleProfileFragment extends SubscriberFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
- try {
- View layout = inflater.inflate(R.layout.simpleprofile_fragment, container, false);
- diaView = (EditText) layout.findViewById(R.id.simpleprofile_dia);
- mgdlView = (RadioButton) layout.findViewById(R.id.simpleprofile_mgdl);
- mmolView = (RadioButton) layout.findViewById(R.id.simpleprofile_mmol);
- icView = (EditText) layout.findViewById(R.id.simpleprofile_ic);
- isfView = (EditText) layout.findViewById(R.id.simpleprofile_isf);
- basalView = (EditText) layout.findViewById(R.id.simpleprofile_basalrate);
- targetlowView = (EditText) layout.findViewById(R.id.simpleprofile_targetlow);
- targethighView = (EditText) layout.findViewById(R.id.simpleprofile_targethigh);
- profileswitchButton = (Button) layout.findViewById(R.id.simpleprofile_profileswitch);
- invalidProfile = (TextView) layout.findViewById(R.id.invalidprofile);
+ View layout = inflater.inflate(R.layout.simpleprofile_fragment, container, false);
+ diaView = (EditText) layout.findViewById(R.id.simpleprofile_dia);
+ mgdlView = (RadioButton) layout.findViewById(R.id.simpleprofile_mgdl);
+ mmolView = (RadioButton) layout.findViewById(R.id.simpleprofile_mmol);
+ icView = (EditText) layout.findViewById(R.id.simpleprofile_ic);
+ isfView = (EditText) layout.findViewById(R.id.simpleprofile_isf);
+ basalView = (EditText) layout.findViewById(R.id.simpleprofile_basalrate);
+ targetlowView = (EditText) layout.findViewById(R.id.simpleprofile_targetlow);
+ targethighView = (EditText) layout.findViewById(R.id.simpleprofile_targethigh);
+ profileswitchButton = (Button) layout.findViewById(R.id.simpleprofile_profileswitch);
+ invalidProfile = (TextView) layout.findViewById(R.id.invalidprofile);
- if (!ConfigBuilderPlugin.getActivePump().getPumpDescription().isTempBasalCapable) {
- layout.findViewById(R.id.simpleprofile_basalrate).setVisibility(View.GONE);
- layout.findViewById(R.id.simpleprofile_basalrate_label).setVisibility(View.GONE);
- }
-
- mgdlView.setChecked(SimpleProfilePlugin.getPlugin().mgdl);
- mmolView.setChecked(SimpleProfilePlugin.getPlugin().mmol);
- diaView.setText(SimpleProfilePlugin.getPlugin().dia.toString());
- icView.setText(SimpleProfilePlugin.getPlugin().ic.toString());
- isfView.setText(SimpleProfilePlugin.getPlugin().isf.toString());
- basalView.setText(SimpleProfilePlugin.getPlugin().basal.toString());
- targetlowView.setText(SimpleProfilePlugin.getPlugin().targetLow.toString());
- targethighView.setText(SimpleProfilePlugin.getPlugin().targetHigh.toString());
-
- mgdlView.setOnClickListener(v -> {
- SimpleProfilePlugin.getPlugin().mgdl = mgdlView.isChecked();
- SimpleProfilePlugin.getPlugin().mmol = !SimpleProfilePlugin.getPlugin().mgdl;
- mmolView.setChecked(SimpleProfilePlugin.getPlugin().mmol);
- SimpleProfilePlugin.getPlugin().storeSettings();
- });
- mmolView.setOnClickListener(v -> {
- SimpleProfilePlugin.getPlugin().mmol = mmolView.isChecked();
- SimpleProfilePlugin.getPlugin().mgdl = !SimpleProfilePlugin.getPlugin().mmol;
- mgdlView.setChecked(SimpleProfilePlugin.getPlugin().mgdl);
- SimpleProfilePlugin.getPlugin().storeSettings();
- });
-
- profileswitchButton.setOnClickListener(view -> {
- NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
- final OptionsToShow profileswitch = CareportalFragment.PROFILESWITCH;
- profileswitch.executeProfileSwitch = true;
- newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
- newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
- });
-
- TextWatcher textWatch = new TextWatcher() {
-
- @Override
- public void afterTextChanged(Editable s) {
- }
-
- @Override
- public void beforeTextChanged(CharSequence s, int start,
- int count, int after) {
- }
-
- @Override
- public void onTextChanged(CharSequence s, int start,
- int before, int count) {
- SimpleProfilePlugin.getPlugin().dia = SafeParse.stringToDouble(diaView.getText().toString());
- SimpleProfilePlugin.getPlugin().ic = SafeParse.stringToDouble(icView.getText().toString());
- SimpleProfilePlugin.getPlugin().isf = SafeParse.stringToDouble(isfView.getText().toString());
- SimpleProfilePlugin.getPlugin().basal = SafeParse.stringToDouble(basalView.getText().toString());
- SimpleProfilePlugin.getPlugin().targetLow = SafeParse.stringToDouble(targetlowView.getText().toString());
- SimpleProfilePlugin.getPlugin().targetHigh = SafeParse.stringToDouble(targethighView.getText().toString());
- SimpleProfilePlugin.getPlugin().storeSettings();
- updateGUI();
- }
- };
-
- diaView.addTextChangedListener(textWatch);
- icView.addTextChangedListener(textWatch);
- isfView.addTextChangedListener(textWatch);
- basalView.addTextChangedListener(textWatch);
- targetlowView.addTextChangedListener(textWatch);
- targethighView.addTextChangedListener(textWatch);
-
- return layout;
- } catch (Exception e) {
- FabricPrivacy.logException(e);
+ if (!ConfigBuilderPlugin.getActivePump().getPumpDescription().isTempBasalCapable) {
+ layout.findViewById(R.id.simpleprofile_basalrate).setVisibility(View.GONE);
+ layout.findViewById(R.id.simpleprofile_basalrate_label).setVisibility(View.GONE);
}
- return null;
+ mgdlView.setChecked(SimpleProfilePlugin.getPlugin().mgdl);
+ mmolView.setChecked(SimpleProfilePlugin.getPlugin().mmol);
+ diaView.setText(SimpleProfilePlugin.getPlugin().dia.toString());
+ icView.setText(SimpleProfilePlugin.getPlugin().ic.toString());
+ isfView.setText(SimpleProfilePlugin.getPlugin().isf.toString());
+ basalView.setText(SimpleProfilePlugin.getPlugin().basal.toString());
+ targetlowView.setText(SimpleProfilePlugin.getPlugin().targetLow.toString());
+ targethighView.setText(SimpleProfilePlugin.getPlugin().targetHigh.toString());
+
+ mgdlView.setOnClickListener(v -> {
+ SimpleProfilePlugin.getPlugin().mgdl = mgdlView.isChecked();
+ SimpleProfilePlugin.getPlugin().mmol = !SimpleProfilePlugin.getPlugin().mgdl;
+ mmolView.setChecked(SimpleProfilePlugin.getPlugin().mmol);
+ SimpleProfilePlugin.getPlugin().storeSettings();
+ });
+ mmolView.setOnClickListener(v -> {
+ SimpleProfilePlugin.getPlugin().mmol = mmolView.isChecked();
+ SimpleProfilePlugin.getPlugin().mgdl = !SimpleProfilePlugin.getPlugin().mmol;
+ mgdlView.setChecked(SimpleProfilePlugin.getPlugin().mgdl);
+ SimpleProfilePlugin.getPlugin().storeSettings();
+ });
+
+ profileswitchButton.setOnClickListener(view -> {
+ NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
+ final OptionsToShow profileswitch = CareportalFragment.PROFILESWITCH;
+ profileswitch.executeProfileSwitch = true;
+ newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
+ newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
+ });
+
+ TextWatcher textWatch = new TextWatcher() {
+
+ @Override
+ public void afterTextChanged(Editable s) {
+ }
+
+ @Override
+ public void beforeTextChanged(CharSequence s, int start,
+ int count, int after) {
+ }
+
+ @Override
+ public void onTextChanged(CharSequence s, int start,
+ int before, int count) {
+ SimpleProfilePlugin.getPlugin().dia = SafeParse.stringToDouble(diaView.getText().toString());
+ SimpleProfilePlugin.getPlugin().ic = SafeParse.stringToDouble(icView.getText().toString());
+ SimpleProfilePlugin.getPlugin().isf = SafeParse.stringToDouble(isfView.getText().toString());
+ SimpleProfilePlugin.getPlugin().basal = SafeParse.stringToDouble(basalView.getText().toString());
+ SimpleProfilePlugin.getPlugin().targetLow = SafeParse.stringToDouble(targetlowView.getText().toString());
+ SimpleProfilePlugin.getPlugin().targetHigh = SafeParse.stringToDouble(targethighView.getText().toString());
+ SimpleProfilePlugin.getPlugin().storeSettings();
+ updateGUI();
+ }
+ };
+
+ diaView.addTextChangedListener(textWatch);
+ icView.addTextChangedListener(textWatch);
+ isfView.addTextChangedListener(textWatch);
+ basalView.addTextChangedListener(textWatch);
+ targetlowView.addTextChangedListener(textWatch);
+ targethighView.addTextChangedListener(textWatch);
+
+ return layout;
}
@Subscribe
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileSimple/SimpleProfilePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileSimple/SimpleProfilePlugin.java
index bb669289ee..09742bd3f9 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileSimple/SimpleProfilePlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileSimple/SimpleProfilePlugin.java
@@ -9,7 +9,6 @@ import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
@@ -19,13 +18,14 @@ import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.ProfileInterface;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.utils.SP;
/**
* Created by mike on 05.08.2016.
*/
public class SimpleProfilePlugin extends PluginBase implements ProfileInterface {
- private static Logger log = LoggerFactory.getLogger(SimpleProfilePlugin.class);
+ private static Logger log = LoggerFactory.getLogger(L.PROFILE);
private static SimpleProfilePlugin simpleProfilePlugin;
@@ -58,7 +58,7 @@ public class SimpleProfilePlugin extends PluginBase implements ProfileInterface
}
public void storeSettings() {
- if (Config.logPrefsChange)
+ if (L.isEnabled(L.PROFILE))
log.debug("Storing settings");
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
SharedPreferences.Editor editor = settings.edit();
@@ -73,13 +73,13 @@ public class SimpleProfilePlugin extends PluginBase implements ProfileInterface
editor.apply();
createConvertedProfile();
- if (Config.logPrefsChange)
+ if (L.isEnabled(L.PROFILE))
log.debug("Storing settings: " + getRawProfile().getData().toString());
MainApp.bus().post(new EventProfileStoreChanged());
}
private void loadSettings() {
- if (Config.logPrefsChange)
+ if (L.isEnabled(L.PROFILE))
log.debug("Loading stored settings");
mgdl = SP.getBoolean("SimpleProfile" + "mgdl", true);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java
index a16ffbda05..7116056657 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java
@@ -31,8 +31,6 @@ import info.nightscout.androidaps.db.CareportalEvent;
import info.nightscout.androidaps.db.Source;
import info.nightscout.androidaps.db.TDD;
import info.nightscout.androidaps.db.TemporaryBasal;
-import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
-import info.nightscout.androidaps.plugins.Treatments.Treatment;
import info.nightscout.androidaps.events.EventInitializationChanged;
import info.nightscout.androidaps.events.EventRefreshOverview;
import info.nightscout.androidaps.interfaces.Constraint;
@@ -42,6 +40,8 @@ import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.interfaces.PumpInterface;
+import info.nightscout.androidaps.logging.L;
+import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
@@ -60,6 +60,7 @@ import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.Bolus;
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.PumpHistory;
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.PumpHistoryRequest;
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.Tdd;
+import info.nightscout.androidaps.plugins.Treatments.Treatment;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.FabricPrivacy;
@@ -69,7 +70,7 @@ import info.nightscout.utils.SP;
* Created by mike on 05.08.2016.
*/
public class ComboPlugin extends PluginBase implements PumpInterface, ConstraintsInterface {
- private static final Logger log = LoggerFactory.getLogger(ComboPlugin.class);
+ private static final Logger log = LoggerFactory.getLogger(L.PUMP);
static final String COMBO_TBRS_SET = "combo_tbrs_set";
static final String COMBO_BOLUSES_DELIVERED = "combo_boluses_delivered";
@@ -198,7 +199,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
@Override
public void switchAllowed(ConfigBuilderFragment.PluginViewHolder.PluginSwitcher pluginSwitcher, FragmentActivity context) {
boolean allowHardwarePump = SP.getBoolean("allow_hardware_pump", false);
- if (allowHardwarePump || context == null){
+ if (allowHardwarePump || context == null) {
pluginSwitcher.invoke();
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
@@ -207,13 +208,15 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
public void onClick(DialogInterface dialog, int id) {
pluginSwitcher.invoke();
SP.putBoolean("allow_hardware_pump", true);
- log.debug("First time HW pump allowed!");
+ if (L.isEnabled(L.PUMP))
+ log.debug("First time HW pump allowed!");
}
})
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
pluginSwitcher.cancel();
- log.debug("User does not allow switching to HW pump!");
+ if (L.isEnabled(L.PUMP))
+ log.debug("User does not allow switching to HW pump!");
}
});
builder.create().show();
@@ -260,7 +263,8 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
@Override
public void disconnect(String reason) {
- log.debug("Disconnect called with reason: " + reason);
+ if (L.isEnabled(L.PUMP))
+ log.debug("Disconnect called with reason: " + reason);
ruffyScripter.disconnect();
}
@@ -359,7 +363,8 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
*/
@Override
public synchronized void getPumpStatus() {
- log.debug("getPumpStatus called");
+ if (L.isEnabled(L.PUMP))
+ log.debug("getPumpStatus called");
if (!pump.initialized) {
initializePump();
} else {
@@ -371,10 +376,12 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
private synchronized void initializePump() {
long maxWait = System.currentTimeMillis() + 15 * 1000;
while (!ruffyScripter.isPumpAvailable()) {
- log.debug("Waiting for ruffy service to come up ...");
+ if (L.isEnabled(L.PUMP))
+ log.debug("Waiting for ruffy service to come up ...");
SystemClock.sleep(100);
if (System.currentTimeMillis() > maxWait) {
- log.debug("ruffy service unavailable, wtf");
+ if (L.isEnabled(L.PUMP))
+ log.debug("ruffy service unavailable, wtf");
return;
}
}
@@ -393,7 +400,8 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
// note that since the history is checked upon every connect, the above already updated
// the DB with any changed history records
if (pumpHistoryChanged) {
- log.debug("Pump history has changed and was imported");
+ if (L.isEnabled(L.PUMP))
+ log.debug("Pump history has changed and was imported");
pumpHistoryChanged = false;
}
@@ -542,7 +550,8 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
// within the last 1-2 minutes
if (Math.abs(previousBolus.amount - detailedBolusInfo.insulin) < 0.01
&& previousBolus.timestamp + 60 * 1000 > System.currentTimeMillis()) {
- log.debug("Bolu request rejected, same bolus was successfully delivered very recently");
+ if (L.isEnabled(L.PUMP))
+ log.debug("Bolus request rejected, same bolus was successfully delivered very recently");
return new PumpEnactResult().success(false).enacted(false)
.comment(MainApp.gs(R.string.bolus_frequency_exceeded));
}
@@ -562,7 +571,8 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
return new PumpEnactResult().success(false).enacted(false)
.comment(MainApp.gs(R.string.combo_error_no_connection_no_bolus_delivered));
}
- log.debug("Waiting for pump clock to advance for the next unused bolus record timestamp");
+ if (L.isEnabled(L.PUMP))
+ log.debug("Waiting for pump clock to advance for the next unused bolus record timestamp");
SystemClock.sleep(2000);
timeCheckResult = runCommand(null, 0, ruffyScripter::readPumpState);
waitLoops++;
@@ -573,7 +583,8 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION)
.putCustomAttribute("waitTimeSecs", String.valueOf(waitDuration)));
- log.debug("Waited " + waitDuration + "s for pump to switch to a fresh minute before bolusing");
+ if (L.isEnabled(L.PUMP))
+ log.debug("Waited " + waitDuration + "s for pump to switch to a fresh minute before bolusing");
}
if (cancelBolus) {
@@ -735,11 +746,13 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
*/
@Override
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile, boolean force) {
- log.debug("setTempBasalAbsolute called with a rate of " + absoluteRate + " for " + durationInMinutes + " min.");
+ if (L.isEnabled(L.PUMP))
+ log.debug("setTempBasalAbsolute called with a rate of " + absoluteRate + " for " + durationInMinutes + " min.");
int unroundedPercentage = Double.valueOf(absoluteRate / getBaseBasalRate() * 100).intValue();
int roundedPercentage = (int) (Math.round(absoluteRate / getBaseBasalRate() * 10) * 10);
if (unroundedPercentage != roundedPercentage) {
- log.debug("Rounded requested rate " + unroundedPercentage + "% -> " + roundedPercentage + "%");
+ if (L.isEnabled(L.PUMP))
+ log.debug("Rounded requested rate " + unroundedPercentage + "% -> " + roundedPercentage + "%");
}
return setTempBasalPercent(roundedPercentage, durationInMinutes);
@@ -757,7 +770,8 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
}
private PumpEnactResult setTempBasalPercent(Integer percent, final Integer durationInMinutes) {
- log.debug("setTempBasalPercent called with " + percent + "% for " + durationInMinutes + "min");
+ if (L.isEnabled(L.PUMP))
+ log.debug("setTempBasalPercent called with " + percent + "% for " + durationInMinutes + "min");
if (pumpHistoryChanged && percent > 110) {
return new PumpEnactResult().success(false).enacted(false)
@@ -767,13 +781,15 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
int adjustedPercent = percent;
if (adjustedPercent > pumpDescription.maxTempPercent) {
- log.debug("Reducing requested TBR to the maximum support by the pump: " + percent + " -> " + pumpDescription.maxTempPercent);
+ if (L.isEnabled(L.PUMP))
+ log.debug("Reducing requested TBR to the maximum support by the pump: " + percent + " -> " + pumpDescription.maxTempPercent);
adjustedPercent = pumpDescription.maxTempPercent;
}
if (adjustedPercent % 10 != 0) {
Long rounded = Math.round(adjustedPercent / 10d) * 10;
- log.debug("Rounded requested percentage:" + adjustedPercent + " -> " + rounded);
+ if (L.isEnabled(L.PUMP))
+ log.debug("Rounded requested percentage:" + adjustedPercent + " -> " + rounded);
adjustedPercent = rounded.intValue();
}
@@ -822,7 +838,8 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
*/
@Override
public PumpEnactResult cancelTempBasal(boolean enforceNew) {
- log.debug("cancelTempBasal called");
+ if (L.isEnabled(L.PUMP))
+ log.debug("cancelTempBasal called");
final TemporaryBasal activeTemp = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(System.currentTimeMillis());
if (enforceNew) {
CommandResult stateResult = runCommand(MainApp.gs(R.string.combo_pump_action_refreshing), 2, ruffyScripter::readPumpState);
@@ -832,7 +849,8 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
if (!stateResult.state.tbrActive) {
return new PumpEnactResult().success(true).enacted(false);
}
- log.debug("cancelTempBasal: hard-cancelling TBR since force requested");
+ if (L.isEnabled(L.PUMP))
+ log.debug("cancelTempBasal: hard-cancelling TBR since force requested");
CommandResult cancelResult = runCommand(MainApp.gs(R.string.combo_pump_action_cancelling_tbr), 2, ruffyScripter::cancelTbr);
if (!cancelResult.success) {
return new PumpEnactResult().success(false).enacted(false);
@@ -853,7 +871,8 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
// Let fake neutral temp keep run (see below)
// Note that since this runs on the queue a connection is opened regardless, but this
// case doesn't occur all that often, so it's not worth optimizing (1.3k SetTBR vs 4 cancelTBR).
- log.debug("cancelTempBasal: skipping changing tbr since it already is at " + activeTemp.percentRate + "% and running for another " + activeTemp.getPlannedRemainingMinutes() + " mins.");
+ if (L.isEnabled(L.PUMP))
+ log.debug("cancelTempBasal: skipping changing tbr since it already is at " + activeTemp.percentRate + "% and running for another " + activeTemp.getPlannedRemainingMinutes() + " mins.");
return new PumpEnactResult().success(true).enacted(true)
.comment("cancelTempBasal skipping changing tbr since it already is at "
+ activeTemp.percentRate + "% and running for another "
@@ -862,7 +881,8 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
// Set a fake neutral temp to avoid TBR cancel alert. Decide 90% vs 110% based on
// on whether the TBR we're cancelling is above or below 100%.
final int percentage = (activeTemp.percentRate > 100) ? 110 : 90;
- log.debug("cancelTempBasal: changing TBR to " + percentage + "% for 15 mins.");
+ if (L.isEnabled(L.PUMP))
+ log.debug("cancelTempBasal: changing TBR to " + percentage + "% for 15 mins.");
return setTempBasalPercent(percentage, 15);
}
}
@@ -901,7 +921,8 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
if (!commandResult.success && retries > 0) {
for (int retryAttempts = 1; !commandResult.success && retryAttempts <= retries; retryAttempts++) {
- log.debug("Command was not successful, retries requested, doing retry #" + retryAttempts);
+ if (L.isEnabled(L.PUMP))
+ log.debug("Command was not successful, retries requested, doing retry #" + retryAttempts);
commandResult = commandExecution.execute();
}
}
@@ -982,7 +1003,8 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
long now = System.currentTimeMillis();
TemporaryBasal aapsTbr = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(now);
if (aapsTbr == null || aapsTbr.percentRate != 0) {
- log.debug("Creating 15m zero temp since pump is suspended");
+ if (L.isEnabled(L.PUMP))
+ log.debug("Creating 15m zero temp since pump is suspended");
TemporaryBasal newTempBasal = new TemporaryBasal()
.date(now)
.percent(0)
@@ -1042,11 +1064,13 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
if (state.pumpTime == 0) {
// time couldn't be read (e.g. a warning is displayed on the menu , hiding the time field)
} else if (Math.abs(state.pumpTime - System.currentTimeMillis()) >= 10 * 60 * 1000) {
- log.debug("Pump clock needs update, pump time: " + state.pumpTime + " (" + new Date(state.pumpTime) + ")");
+ if (L.isEnabled(L.PUMP))
+ log.debug("Pump clock needs update, pump time: " + state.pumpTime + " (" + new Date(state.pumpTime) + ")");
Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, MainApp.gs(R.string.combo_notification_check_time_date), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification));
} else if (Math.abs(state.pumpTime - System.currentTimeMillis()) >= 3 * 60 * 1000) {
- log.debug("Pump clock needs update, pump time: " + state.pumpTime + " (" + new Date(state.pumpTime) + ")");
+ if (L.isEnabled(L.PUMP))
+ log.debug("Pump clock needs update, pump time: " + state.pumpTime + " (" + new Date(state.pumpTime) + ")");
Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, MainApp.gs(R.string.combo_notification_check_time_date), Notification.NORMAL);
MainApp.bus().post(new EventNewNotification(notification));
}
@@ -1108,7 +1132,8 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
long now = System.currentTimeMillis();
TemporaryBasal aapsTbr = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(now);
if (aapsTbr == null && state.tbrActive && state.tbrRemainingDuration > 2) {
- log.debug("Creating temp basal from pump TBR");
+ if (L.isEnabled(L.PUMP))
+ log.debug("Creating temp basal from pump TBR");
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboTbrMismatch")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION)
@@ -1120,7 +1145,8 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
.source(Source.USER);
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(newTempBasal);
} else if (aapsTbr != null && aapsTbr.getPlannedRemainingMinutes() > 2 && !state.tbrActive) {
- log.debug("Ending AAPS-TBR since pump has no TBR active");
+ if (L.isEnabled(L.PUMP))
+ log.debug("Ending AAPS-TBR since pump has no TBR active");
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboTbrMismatch")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION)
@@ -1133,7 +1159,8 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
} else if (aapsTbr != null && state.tbrActive
&& (aapsTbr.percentRate != state.tbrPercent ||
Math.abs(aapsTbr.getPlannedRemainingMinutes() - state.tbrRemainingDuration) > 2)) {
- log.debug("AAPSs and pump-TBR differ; ending AAPS-TBR and creating new TBR based on pump TBR");
+ if (L.isEnabled(L.PUMP))
+ log.debug("AAPSs and pump-TBR differ; ending AAPS-TBR and creating new TBR based on pump TBR");
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboTbrMismatch")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION)
@@ -1218,7 +1245,8 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
// no history, nothing to check or complain about
if (quickInfoResult.history == null || quickInfoResult.history.bolusHistory.isEmpty()) {
- log.debug("Setting 'pumpHistoryChanged' false");
+ if (L.isEnabled(L.PUMP))
+ log.debug("Setting 'pumpHistoryChanged' false");
pumpHistoryChanged = false;
return null;
}
@@ -1227,13 +1255,15 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
List initialPumpBolusHistory = quickInfoResult.history.bolusHistory;
if (recentBoluses.size() == 1 && initialPumpBolusHistory.size() >= 1
&& recentBoluses.get(0).equals(quickInfoResult.history.bolusHistory.get(0))) {
- log.debug("Setting 'pumpHistoryChanged' false");
+ if (L.isEnabled(L.PUMP))
+ log.debug("Setting 'pumpHistoryChanged' false");
pumpHistoryChanged = false;
return null;
} else if (recentBoluses.size() == 2 && initialPumpBolusHistory.size() >= 2
&& recentBoluses.get(0).equals(quickInfoResult.history.bolusHistory.get(0))
&& recentBoluses.get(1).equals(quickInfoResult.history.bolusHistory.get(1))) {
- log.debug("Setting 'pumpHistoryChanged' false");
+ if (L.isEnabled(L.PUMP))
+ log.debug("Setting 'pumpHistoryChanged' false");
pumpHistoryChanged = false;
return null;
}
@@ -1253,7 +1283,8 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
// for.
HashSet bolusSet = new HashSet<>(historyResult.history.bolusHistory);
if (bolusSet.size() != historyResult.history.bolusHistory.size()) {
- log.debug("Bolus with same amount within the same minute imported. Only one will make it to the DB.");
+ if (L.isEnabled(L.PUMP))
+ log.debug("Bolus with same amount within the same minute imported. Only one will make it to the DB.");
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboBolusToDbError")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION)
@@ -1266,7 +1297,8 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
pumpHistoryChanged = updateDbFromPumpHistory(historyResult.history);
if (pumpHistoryChanged) {
- log.debug("Setting 'pumpHistoryChanged' true");
+ if (L.isEnabled(L.PUMP))
+ log.debug("Setting 'pumpHistoryChanged' true");
}
List updatedPumpBolusHistory = historyResult.history.bolusHistory;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/AbstractDanaRPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/AbstractDanaRPlugin.java
index 1f51979126..81f301b81b 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/AbstractDanaRPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/AbstractDanaRPlugin.java
@@ -5,11 +5,11 @@ import android.support.annotation.Nullable;
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.util.Date;
import info.nightscout.androidaps.BuildConfig;
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Profile;
@@ -26,6 +26,7 @@ import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.ProfileInterface;
import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.interfaces.PumpInterface;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
@@ -43,7 +44,7 @@ import info.nightscout.utils.SP;
*/
public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInterface, DanaRInterface, ConstraintsInterface, ProfileInterface {
- protected Logger log;
+ protected Logger log = LoggerFactory.getLogger(L.PUMP);
protected AbstractDanaRExecutionService sExecutionService;
@@ -133,7 +134,8 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
Double profileValue = profile.getBasalTimeFromMidnight(h * basalIncrement);
if (profileValue == null) return true;
if (Math.abs(pumpValue - profileValue) > getPumpDescription().basalStep) {
- log.debug("Diff found. Hour: " + h + " Pump: " + pumpValue + " Profile: " + profileValue);
+ if (L.isEnabled(L.PUMP))
+ log.debug("Diff found. Hour: " + h + " Pump: " + pumpValue + " Profile: " + profileValue);
return false;
}
}
@@ -183,7 +185,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
result.duration = pump.tempBasalRemainingMin;
result.percent = pump.tempBasalPercent;
result.isPercent = true;
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setTempBasalPercent: Correct value already set");
return result;
}
@@ -197,7 +199,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
result.duration = pump.tempBasalRemainingMin;
result.percent = pump.tempBasalPercent;
result.isPercent = true;
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setTempBasalPercent: OK");
return result;
}
@@ -225,7 +227,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
result.absolute = pump.extendedBolusAbsoluteRate;
result.isPercent = false;
result.isTempCancel = false;
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setExtendedBolus: Correct extended bolus already set. Current: " + pump.extendedBolusAmount + " Asked: " + insulin);
return result;
}
@@ -240,7 +242,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
if (!SP.getBoolean("danar_useextended", false))
result.bolusDelivered = pump.extendedBolusAmount;
result.isPercent = false;
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setExtendedBolus: OK");
return result;
}
@@ -263,7 +265,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
if (!pump.isExtendedInProgress) {
result.success = true;
result.comment = MainApp.gs(R.string.virtualpump_resultok);
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("cancelExtendedBolus: OK");
return result;
} else {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java
index 7288602d65..f261bc470d 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java
@@ -25,12 +25,13 @@ import butterknife.ButterKnife;
import butterknife.OnClick;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
-import info.nightscout.androidaps.TDDStatsActivity;
+import info.nightscout.androidaps.activities.TDDStatsActivity;
import info.nightscout.androidaps.db.ExtendedBolus;
import info.nightscout.androidaps.events.EventExtendedBolusChange;
import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.events.EventTempBasalChange;
import info.nightscout.androidaps.interfaces.PluginType;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.PumpDanaR.Dialogs.ProfileViewDialog;
@@ -42,11 +43,10 @@ import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.androidaps.queue.events.EventQueueChanged;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter;
-import info.nightscout.utils.FabricPrivacy;
import info.nightscout.utils.SetWarnColor;
public class DanaRFragment extends SubscriberFragment {
- private static Logger log = LoggerFactory.getLogger(DanaRFragment.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMP);
private Handler loopHandler = new Handler();
private Runnable refreshLoop = new Runnable() {
@@ -113,18 +113,12 @@ public class DanaRFragment extends SubscriberFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
- try {
- View view = inflater.inflate(R.layout.danar_fragment, container, false);
- unbinder = ButterKnife.bind(this, view);
+ View view = inflater.inflate(R.layout.danar_fragment, container, false);
+ unbinder = ButterKnife.bind(this, view);
- pumpStatusView.setBackgroundColor(MainApp.gc(R.color.colorInitializingBorder));
+ pumpStatusView.setBackgroundColor(MainApp.gc(R.color.colorInitializingBorder));
- return view;
- } catch (Exception e) {
- FabricPrivacy.logException(e);
- }
-
- return null;
+ return view;
}
@OnClick(R.id.danar_history)
@@ -145,11 +139,14 @@ public class DanaRFragment extends SubscriberFragment {
}
@OnClick(R.id.danar_user_options)
- void onUserOptionsClick() { startActivity(new Intent(getContext(), DanaRUserOptionsActivity.class)); }
+ void onUserOptionsClick() {
+ startActivity(new Intent(getContext(), DanaRUserOptionsActivity.class));
+ }
@OnClick(R.id.danar_btconnection)
void onBtConnectionClick() {
- log.debug("Clicked connect to pump");
+ if (L.isEnabled(L.PUMP))
+ log.debug("Clicked connect to pump");
DanaRPump.getInstance().lastConnection = 0;
ConfigBuilderPlugin.getCommandQueue().readStatus("Clicked connect to pump", null);
}
@@ -162,10 +159,11 @@ public class DanaRFragment extends SubscriberFragment {
activity.runOnUiThread(
new Runnable() {
@Override
- public void run() {
- synchronized(DanaRFragment.this){
+ public void run() {
+ synchronized (DanaRFragment.this) {
- if(btConnectionView == null || pumpStatusView == null || pumpStatusLayout == null ) return;
+ if (btConnectionView == null || pumpStatusView == null || pumpStatusLayout == null)
+ return;
if (c.sStatus == EventPumpStatusChanged.CONNECTING)
btConnectionView.setText("{fa-bluetooth-b spin} " + c.sSecondsElapsed + "s");
@@ -216,7 +214,7 @@ public class DanaRFragment extends SubscriberFragment {
@SuppressLint("SetTextI18n")
@Override
public void run() {
- synchronized(DanaRFragment.this) {
+ synchronized (DanaRFragment.this) {
if (!isBound()) return;
DanaRPump pump = DanaRPump.getInstance();
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java
index 144107779d..68ea3fe851 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java
@@ -11,9 +11,6 @@ import android.support.v7.app.AlertDialog;
import com.squareup.otto.Subscribe;
-import org.slf4j.LoggerFactory;
-
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.DetailedBolusInfo;
@@ -21,6 +18,7 @@ import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.db.ExtendedBolus;
import info.nightscout.androidaps.db.TemporaryBasal;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgBolusStartWithSpeed;
import info.nightscout.androidaps.plugins.Treatments.Treatment;
@@ -49,7 +47,6 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
public DanaRPlugin() {
super();
- log = LoggerFactory.getLogger(DanaRPlugin.class);
useExtendedBoluses = SP.getBoolean("danar_useextended", false);
pumpDescription.isBolusCapable = true;
@@ -85,7 +82,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
@Override
public void switchAllowed(ConfigBuilderFragment.PluginViewHolder.PluginSwitcher pluginSwitcher, FragmentActivity context) {
boolean allowHardwarePump = SP.getBoolean("allow_hardware_pump", false);
- if (allowHardwarePump || context == null){
+ if (allowHardwarePump || context == null) {
pluginSwitcher.invoke();
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
@@ -94,13 +91,15 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
public void onClick(DialogInterface dialog, int id) {
pluginSwitcher.invoke();
SP.putBoolean("allow_hardware_pump", true);
- log.debug("First time HW pump allowed!");
+ if (L.isEnabled(L.PUMP))
+ log.debug("First time HW pump allowed!");
}
})
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
pluginSwitcher.cancel();
- log.debug("User does not allow switching to HW pump!");
+ if (L.isEnabled(L.PUMP))
+ log.debug("User does not allow switching to HW pump!");
}
});
builder.create().show();
@@ -127,12 +126,14 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
private ServiceConnection mConnection = new ServiceConnection() {
public void onServiceDisconnected(ComponentName name) {
- log.debug("Service is disconnected");
+ if (L.isEnabled(L.PUMP))
+ log.debug("Service is disconnected");
sExecutionService = null;
}
public void onServiceConnected(ComponentName name, IBinder service) {
- log.debug("Service is connected");
+ if (L.isEnabled(L.PUMP))
+ log.debug("Service is connected");
DanaRExecutionService.LocalBinder mLocalBinder = (DanaRExecutionService.LocalBinder) service;
sExecutionService = mLocalBinder.getServiceInstance();
}
@@ -195,7 +196,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
result.comment = String.format(MainApp.gs(R.string.boluserrorcode), detailedBolusInfo.insulin, t.insulin, MsgBolusStartWithSpeed.errorCode);
else
result.comment = MainApp.gs(R.string.virtualpump_resultok);
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered);
detailedBolusInfo.insulin = t.insulin;
detailedBolusInfo.date = System.currentTimeMillis();
@@ -237,13 +238,13 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
if (doTempOff) {
// If extended in progress
if (activeExtended != null && useExtendedBoluses) {
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: Stopping extended bolus (doTempOff)");
return cancelExtendedBolus();
}
// If temp in progress
if (activeTemp != null) {
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: Stopping temp basal (doTempOff)");
return cancelRealTempBasal();
}
@@ -252,7 +253,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
result.percent = 100;
result.isPercent = true;
result.isTempCancel = true;
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: doTempOff OK");
return result;
}
@@ -264,12 +265,12 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
if (percentRate > getPumpDescription().maxTempPercent) {
percentRate = getPumpDescription().maxTempPercent;
}
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: Calculated percent rate: " + percentRate);
// If extended in progress
if (activeExtended != null && useExtendedBoluses) {
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: Stopping extended bolus (doLowTemp || doHighTemp)");
result = cancelExtendedBolus();
if (!result.success) {
@@ -280,7 +281,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
// Check if some temp is already in progress
if (activeTemp != null) {
// Correct basal already set ?
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: currently running: " + activeTemp.toString());
if (activeTemp.percentRate == percentRate) {
if (enforceNew) {
@@ -292,21 +293,21 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
result.duration = activeTemp.getPlannedRemainingMinutes();
result.isPercent = true;
result.isTempCancel = false;
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: Correct temp basal already set (doLowTemp || doHighTemp)");
return result;
}
}
}
// Convert duration from minutes to hours
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: Setting temp basal " + percentRate + "% for " + durationInMinutes + " mins (doLowTemp || doHighTemp)");
return setTempBasalPercent(percentRate, durationInMinutes, profile, false);
}
if (doExtendedTemp) {
// Check if some temp is already in progress
if (activeTemp != null) {
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: Stopping temp basal (doExtendedTemp)");
result = cancelRealTempBasal();
// Check for proper result
@@ -325,7 +326,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
extendedRateToSet = Round.roundTo(extendedRateToSet, pumpDescription.extendedBolusStep * 2); // *2 because of halfhours
// What is current rate of extended bolusing in u/h?
- if (Config.logPumpActions) {
+ if (L.isEnabled(L.PUMP)) {
log.debug("setTempBasalAbsolute: Extended bolus in progress: " + (activeExtended != null) + " rate: " + pump.extendedBolusAbsoluteRate + "U/h duration remaining: " + pump.extendedBolusRemainingMinutes + "min");
log.debug("setTempBasalAbsolute: Rate to set: " + extendedRateToSet + "U/h");
}
@@ -339,21 +340,21 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
result.duration = pump.extendedBolusRemainingMinutes;
result.isPercent = false;
result.isTempCancel = false;
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: Correct extended already set");
return result;
}
// Now set new extended, no need to to stop previous (if running) because it's replaced
Double extendedAmount = extendedRateToSet / 2 * durationInHalfHours;
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: Setting extended: " + extendedAmount + "U halfhours: " + durationInHalfHours);
result = setExtendedBolus(extendedAmount, durationInMinutes);
if (!result.success) {
log.error("setTempBasalAbsolute: Failed to set extended bolus");
return result;
}
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: Extended bolus set ok");
result.absolute = result.absolute + getBaseBasalRate();
return result;
@@ -392,7 +393,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
result.success = true;
result.isTempCancel = true;
result.comment = MainApp.gs(R.string.virtualpump_resultok);
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("cancelRealTempBasal: OK");
return result;
} else {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPump.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPump.java
index d9bc947b84..b5c1e6030e 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPump.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPump.java
@@ -9,18 +9,18 @@ import org.slf4j.LoggerFactory;
import java.text.DecimalFormat;
import java.util.Date;
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.ProfileStore;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.utils.SP;
/**
* Created by mike on 04.07.2016.
*/
public class DanaRPump {
- private static Logger log = LoggerFactory.getLogger(DanaRPump.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMP);
private static DanaRPump instance = null;
@@ -236,13 +236,13 @@ public class DanaRPump {
return PROFILE_PREFIX + (activeProfile + 1);
}
- public static double[] buildDanaRProfileRecord(Profile nsProfile) {
+ public double[] buildDanaRProfileRecord(Profile nsProfile) {
double[] record = new double[24];
for (Integer hour = 0; hour < 24; hour++) {
//Some values get truncated to the next lower one.
// -> round them to two decimals and make sure we are a small delta larger (that will get truncated)
double value = Math.round(100d * nsProfile.getBasalTimeFromMidnight((Integer) (hour * 60 * 60)))/100d + 0.00001;
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMP))
log.debug("NS basal value for " + hour + ":00 is " + value);
record[hour] = value;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/Dialogs/ProfileViewDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/Dialogs/ProfileViewDialog.java
index d8157281bd..24728f2cf6 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/Dialogs/ProfileViewDialog.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/Dialogs/ProfileViewDialog.java
@@ -33,8 +33,6 @@ import info.nightscout.utils.DecimalFormatter;
* Created by mike on 10.07.2016.
*/
public class ProfileViewDialog extends DialogFragment {
- private static Logger log = LoggerFactory.getLogger(ProfileViewDialog.class);
-
private TextView noProfile;
private TextView units;
private TextView dia;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/SerialIOThread.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/SerialIOThread.java
index 2f377a566a..a319353d63 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/SerialIOThread.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/SerialIOThread.java
@@ -10,7 +10,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import info.nightscout.androidaps.Config;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageHashTable;
import info.nightscout.androidaps.plugins.PumpDanaR.services.AbstractSerialIOThread;
@@ -20,7 +20,7 @@ import info.nightscout.utils.CRC;
* Created by mike on 17.07.2016.
*/
public class SerialIOThread extends AbstractSerialIOThread {
- private static Logger log = LoggerFactory.getLogger(SerialIOThread.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPBTCOMM);
private InputStream mInputStream = null;
private OutputStream mOutputStream = null;
@@ -71,7 +71,7 @@ public class SerialIOThread extends AbstractSerialIOThread {
message = MessageHashTable.findMessage(command);
}
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPBTCOMM))
log.debug("<<<<< " + message.getMessageName() + " " + message.toHexString(extractedBuff));
// process the message content
@@ -83,7 +83,7 @@ public class SerialIOThread extends AbstractSerialIOThread {
}
}
} catch (Exception e) {
- if (Config.logDanaSerialEngine && e.getMessage().indexOf("bt socket closed") < 0)
+ if (e.getMessage().indexOf("bt socket closed") < 0)
log.error("Thread exception: ", e);
mKeepRunning = false;
}
@@ -147,7 +147,7 @@ public class SerialIOThread extends AbstractSerialIOThread {
processedMessage = message;
byte[] messageBytes = message.getRawMessageBytes();
- if (Config.logDanaSerialEngine)
+ if (L.isEnabled(L.PUMPBTCOMM))
log.debug(">>>>> " + message.getMessageName() + " " + message.toHexString(messageBytes));
try {
@@ -169,7 +169,8 @@ public class SerialIOThread extends AbstractSerialIOThread {
log.warn("Reply not received " + message.getMessageName());
if (message.getCommand() == 0xF0F1) {
DanaRPump.getInstance().isNewPump = false;
- log.debug("Old firmware detected");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("Old firmware detected");
}
}
}
@@ -180,24 +181,29 @@ public class SerialIOThread extends AbstractSerialIOThread {
try {
mInputStream.close();
} catch (Exception e) {
- if (Config.logDanaSerialEngine) log.debug(e.getMessage());
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug(e.getMessage());
}
try {
mOutputStream.close();
} catch (Exception e) {
- if (Config.logDanaSerialEngine) log.debug(e.getMessage());
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug(e.getMessage());
}
try {
mRfCommSocket.close();
} catch (Exception e) {
- if (Config.logDanaSerialEngine) log.debug(e.getMessage());
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug(e.getMessage());
}
try {
System.runFinalization();
} catch (Exception e) {
- if (Config.logDanaSerialEngine) log.debug(e.getMessage());
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug(e.getMessage());
}
- if (Config.logDanaSerialEngine) log.debug("Disconnected: " + reason);
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug("Disconnected: " + reason);
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRHistoryActivity.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRHistoryActivity.java
index 97c5569b4b..444a11b5c4 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRHistoryActivity.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRHistoryActivity.java
@@ -31,6 +31,7 @@ import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.db.DanaRHistoryRecord;
import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.interfaces.PluginType;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes;
import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRSyncStatus;
@@ -42,12 +43,9 @@ import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.ToastUtils;
public class DanaRHistoryActivity extends Activity {
- private static Logger log = LoggerFactory.getLogger(DanaRHistoryActivity.class);
-
- private boolean mBounded;
+ private static Logger log = LoggerFactory.getLogger(L.PUMP);
private Handler mHandler;
- private static HandlerThread mHandlerThread;
static Profile profile = null;
@@ -65,7 +63,7 @@ public class DanaRHistoryActivity extends Activity {
public byte type;
String name;
- public TypeList(byte type, String name) {
+ TypeList(byte type, String name) {
this.type = type;
this.name = name;
}
@@ -78,7 +76,7 @@ public class DanaRHistoryActivity extends Activity {
public DanaRHistoryActivity() {
super();
- mHandlerThread = new HandlerThread(DanaRHistoryActivity.class.getSimpleName());
+ HandlerThread mHandlerThread = new HandlerThread(DanaRHistoryActivity.class.getSimpleName());
mHandlerThread.start();
this.mHandler = new Handler(mHandlerThread.getLooper());
}
@@ -116,8 +114,8 @@ public class DanaRHistoryActivity extends Activity {
statusView.setVisibility(View.GONE);
- boolean isKorean = MainApp.getSpecificPlugin(DanaRKoreanPlugin.class) != null && MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).isEnabled(PluginType.PUMP);
- boolean isRS = MainApp.getSpecificPlugin(DanaRSPlugin.class) != null && MainApp.getSpecificPlugin(DanaRSPlugin.class).isEnabled(PluginType.PUMP);
+ boolean isKorean = DanaRKoreanPlugin.getPlugin().isEnabled(PluginType.PUMP);
+ boolean isRS = DanaRSPlugin.getPlugin().isEnabled(PluginType.PUMP);
// Types
@@ -141,10 +139,30 @@ public class DanaRHistoryActivity extends Activity {
R.layout.spinner_centered, typeList);
historyTypeSpinner.setAdapter(spinnerAdapter);
- reloadButton.setOnClickListener(new View.OnClickListener() {
+ reloadButton.setOnClickListener(v -> {
+ final TypeList selected = (TypeList) historyTypeSpinner.getSelectedItem();
+ runOnUiThread(() -> {
+ reloadButton.setVisibility(View.GONE);
+ syncButton.setVisibility(View.GONE);
+ statusView.setVisibility(View.VISIBLE);
+ });
+ clearCardView();
+ ConfigBuilderPlugin.getCommandQueue().loadHistory(selected.type, new Callback() {
+ @Override
+ public void run() {
+ loadDataFromDB(selected.type);
+ runOnUiThread(() -> {
+ reloadButton.setVisibility(View.VISIBLE);
+ syncButton.setVisibility(View.VISIBLE);
+ statusView.setVisibility(View.GONE);
+ });
+ }
+ });
+ });
+
+ syncButton.setOnClickListener(v -> mHandler.post(new Runnable() {
@Override
- public void onClick(View v) {
- final TypeList selected = (TypeList) historyTypeSpinner.getSelectedItem();
+ public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
@@ -153,52 +171,18 @@ public class DanaRHistoryActivity extends Activity {
statusView.setVisibility(View.VISIBLE);
}
});
- clearCardView();
- ConfigBuilderPlugin.getCommandQueue().loadHistory(selected.type, new Callback() {
+ DanaRNSHistorySync sync = new DanaRNSHistorySync(historyList);
+ sync.sync(DanaRNSHistorySync.SYNC_ALL);
+ runOnUiThread(new Runnable() {
@Override
public void run() {
- loadDataFromDB(selected.type);
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- reloadButton.setVisibility(View.VISIBLE);
- syncButton.setVisibility(View.VISIBLE);
- statusView.setVisibility(View.GONE);
- }
- });
+ reloadButton.setVisibility(View.VISIBLE);
+ syncButton.setVisibility(View.VISIBLE);
+ statusView.setVisibility(View.GONE);
}
});
}
- });
-
- syncButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- reloadButton.setVisibility(View.GONE);
- syncButton.setVisibility(View.GONE);
- statusView.setVisibility(View.VISIBLE);
- }
- });
- DanaRNSHistorySync sync = new DanaRNSHistorySync(historyList);
- sync.sync(DanaRNSHistorySync.SYNC_ALL);
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- reloadButton.setVisibility(View.VISIBLE);
- syncButton.setVisibility(View.VISIBLE);
- statusView.setVisibility(View.GONE);
- }
- });
- }
- });
- }
- });
+ }));
historyTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
@@ -324,7 +308,7 @@ public class DanaRHistoryActivity extends Activity {
super.onAttachedToRecyclerView(recyclerView);
}
- public static class HistoryViewHolder extends RecyclerView.ViewHolder {
+ static class HistoryViewHolder extends RecyclerView.ViewHolder {
CardView cv;
TextView time;
TextView value;
@@ -355,45 +339,26 @@ public class DanaRHistoryActivity extends Activity {
private void loadDataFromDB(byte type) {
historyList = MainApp.getDbHelper().getDanaRHistoryRecordsByType(type);
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- recyclerView.swapAdapter(new RecyclerViewAdapter(historyList), false);
- }
- });
+ runOnUiThread(() -> recyclerView.swapAdapter(new RecyclerViewAdapter(historyList), false));
}
private void clearCardView() {
historyList = new ArrayList<>();
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- recyclerView.swapAdapter(new RecyclerViewAdapter(historyList), false);
- }
- });
+ runOnUiThread(() -> recyclerView.swapAdapter(new RecyclerViewAdapter(historyList), false));
}
@Subscribe
public void onStatusEvent(final EventDanaRSyncStatus s) {
- log.debug("EventDanaRSyncStatus: " + s.message);
+ if (L.isEnabled(L.PUMP))
+ log.debug("EventDanaRSyncStatus: " + s.message);
runOnUiThread(
- new Runnable() {
- @Override
- public void run() {
- statusView.setText(s.message);
- }
- });
+ () -> statusView.setText(s.message));
}
@Subscribe
public void onStatusEvent(final EventPumpStatusChanged s) {
runOnUiThread(
- new Runnable() {
- @Override
- public void run() {
- statusView.setText(s.textStatus());
- }
- }
+ () -> statusView.setText(s.textStatus())
);
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRNSHistorySync.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRNSHistorySync.java
index d505443c1d..36bad4f6fa 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRNSHistorySync.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRNSHistorySync.java
@@ -10,22 +10,21 @@ import java.util.List;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
+import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.db.CareportalEvent;
import info.nightscout.androidaps.db.DanaRHistoryRecord;
-import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
-import info.nightscout.androidaps.data.Profile;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes;
import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRSyncStatus;
import info.nightscout.utils.DateUtil;
-import info.nightscout.utils.NSUpload;
-import info.nightscout.utils.ToastUtils;
+import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
/**
* Created by mike on 20.07.2016.
*/
public class DanaRNSHistorySync {
- private static Logger log = LoggerFactory.getLogger(DanaRNSHistorySync.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMP);
private List historyRecords;
public final static int SYNC_BOLUS = 0b00000001;
@@ -50,7 +49,8 @@ public class DanaRNSHistorySync {
long records = historyRecords.size();
long processing = 0;
long uploaded = 0;
- log.debug("Database contains " + records + " records");
+ if (L.isEnabled(L.PUMP))
+ log.debug("Database contains " + records + " records");
EventDanaRSyncStatus ev = new EventDanaRSyncStatus();
for (DanaRHistoryRecord record : historyRecords) {
processing++;
@@ -63,7 +63,8 @@ public class DanaRNSHistorySync {
if ((what & SYNC_BOLUS) == 0) break;
switch (record.bolusType) {
case "S":
- log.debug("Syncing standard bolus record " + record.recordValue + "U " + DateUtil.toISOString(record.recordDate));
+ if (L.isEnabled(L.PUMP))
+ log.debug("Syncing standard bolus record " + record.recordValue + "U " + DateUtil.toISOString(record.recordDate));
nsrec.put(DANARSIGNATURE, record.bytes);
nsrec.put("eventType", "Meal Bolus");
nsrec.put("insulin", record.recordValue);
@@ -75,7 +76,8 @@ public class DanaRNSHistorySync {
break;
case "E":
if (record.recordDuration > 0) {
- log.debug("Syncing extended bolus record " + record.recordValue + "U " + DateUtil.toISOString(record.recordDate));
+ if (L.isEnabled(L.PUMP))
+ log.debug("Syncing extended bolus record " + record.recordValue + "U " + DateUtil.toISOString(record.recordDate));
nsrec.put(DANARSIGNATURE, record.bytes);
nsrec.put("eventType", CareportalEvent.COMBOBOLUS);
nsrec.put("insulin", 0);
@@ -91,11 +93,13 @@ public class DanaRNSHistorySync {
uploaded++;
ev.message += MainApp.gs(R.string.danar_ebolus);
} else {
- log.debug("NOT Syncing extended bolus record " + record.recordValue + "U " + DateUtil.toISOString(record.recordDate) + " zero duration");
+ if (L.isEnabled(L.PUMP))
+ log.debug("NOT Syncing extended bolus record " + record.recordValue + "U " + DateUtil.toISOString(record.recordDate) + " zero duration");
}
break;
case "DS":
- log.debug("Syncing dual(S) bolus record " + record.recordValue + "U " + DateUtil.toISOString(record.recordDate));
+ if (L.isEnabled(L.PUMP))
+ log.debug("Syncing dual(S) bolus record " + record.recordValue + "U " + DateUtil.toISOString(record.recordDate));
nsrec.put(DANARSIGNATURE, record.bytes);
nsrec.put("eventType", CareportalEvent.COMBOBOLUS);
nsrec.put("insulin", record.recordValue);
@@ -108,7 +112,8 @@ public class DanaRNSHistorySync {
ev.message += MainApp.gs(R.string.danar_dsbolus);
break;
case "DE":
- log.debug("Syncing dual(E) bolus record " + record.recordValue + "U " + DateUtil.toISOString(record.recordDate));
+ if (L.isEnabled(L.PUMP))
+ log.debug("Syncing dual(E) bolus record " + record.recordValue + "U " + DateUtil.toISOString(record.recordDate));
nsrec.put(DANARSIGNATURE, record.bytes);
nsrec.put("eventType", CareportalEvent.COMBOBOLUS);
nsrec.put("duration", record.recordDuration);
@@ -124,13 +129,14 @@ public class DanaRNSHistorySync {
ev.message += MainApp.gs(R.string.danar_debolus);
break;
default:
- log.debug("Unknown bolus record");
+ log.error("Unknown bolus record");
break;
}
break;
case RecordTypes.RECORD_TYPE_ERROR:
if ((what & SYNC_ERROR) == 0) break;
- log.debug("Syncing error record " + DateUtil.toISOString(record.recordDate));
+ if (L.isEnabled(L.PUMP))
+ log.debug("Syncing error record " + DateUtil.toISOString(record.recordDate));
nsrec.put(DANARSIGNATURE, record.bytes);
nsrec.put("eventType", "Note");
nsrec.put("notes", "Error");
@@ -142,7 +148,8 @@ public class DanaRNSHistorySync {
break;
case RecordTypes.RECORD_TYPE_REFILL:
if ((what & SYNC_REFILL) == 0) break;
- log.debug("Syncing refill record " + record.recordValue + " " + DateUtil.toISOString(record.recordDate));
+ if (L.isEnabled(L.PUMP))
+ log.debug("Syncing refill record " + record.recordValue + " " + DateUtil.toISOString(record.recordDate));
nsrec.put(DANARSIGNATURE, record.bytes);
nsrec.put("eventType", "Insulin Change");
nsrec.put("notes", "Refill " + record.recordValue + "U");
@@ -154,7 +161,8 @@ public class DanaRNSHistorySync {
break;
case RecordTypes.RECORD_TYPE_BASALHOUR:
if ((what & SYNC_BASALHOURS) == 0) break;
- log.debug("Syncing basal hour record " + record.recordValue + " " + DateUtil.toISOString(record.recordDate));
+ if (L.isEnabled(L.PUMP))
+ log.debug("Syncing basal hour record " + record.recordValue + " " + DateUtil.toISOString(record.recordDate));
nsrec.put(DANARSIGNATURE, record.bytes);
nsrec.put("eventType", CareportalEvent.TEMPBASAL);
nsrec.put("absolute", record.recordValue);
@@ -170,7 +178,8 @@ public class DanaRNSHistorySync {
break;
case RecordTypes.RECORD_TYPE_GLUCOSE:
if ((what & SYNC_GLUCOSE) == 0) break;
- log.debug("Syncing glucose record " + record.recordValue + " " + DateUtil.toISOString(record.recordDate));
+ if (L.isEnabled(L.PUMP))
+ log.debug("Syncing glucose record " + record.recordValue + " " + DateUtil.toISOString(record.recordDate));
nsrec.put(DANARSIGNATURE, record.bytes);
nsrec.put("eventType", "BG Check");
nsrec.put("glucose", Profile.fromMgdlToUnits(record.recordValue, MainApp.getConfigBuilder().getProfileUnits()));
@@ -183,7 +192,8 @@ public class DanaRNSHistorySync {
break;
case RecordTypes.RECORD_TYPE_CARBO:
if ((what & SYNC_CARBO) == 0) break;
- log.debug("Syncing carbo record " + record.recordValue + "g " + DateUtil.toISOString(record.recordDate));
+ if (L.isEnabled(L.PUMP))
+ log.debug("Syncing carbo record " + record.recordValue + "g " + DateUtil.toISOString(record.recordDate));
nsrec.put(DANARSIGNATURE, record.bytes);
nsrec.put("eventType", "Meal Bolus");
nsrec.put("carbs", record.recordValue);
@@ -195,7 +205,8 @@ public class DanaRNSHistorySync {
break;
case RecordTypes.RECORD_TYPE_ALARM:
if ((what & SYNC_ALARM) == 0) break;
- log.debug("Syncing alarm record " + record.recordAlarm + " " + DateUtil.toISOString(record.recordDate));
+ if (L.isEnabled(L.PUMP))
+ log.debug("Syncing alarm record " + record.recordAlarm + " " + DateUtil.toISOString(record.recordDate));
nsrec.put(DANARSIGNATURE, record.bytes);
nsrec.put("eventType", "Note");
nsrec.put("notes", "Alarm: " + record.recordAlarm);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRUserOptionsActivity.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRUserOptionsActivity.java
index bd6a315319..336c526d82 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRUserOptionsActivity.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRUserOptionsActivity.java
@@ -19,6 +19,7 @@ import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.events.EventInitializationChanged;
import info.nightscout.androidaps.interfaces.PluginType;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaRS.DanaRSPlugin;
@@ -30,7 +31,7 @@ import info.nightscout.utils.NumberPicker;
*/
public class DanaRUserOptionsActivity extends Activity {
- private static Logger log = LoggerFactory.getLogger(DanaRUserOptionsActivity.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMP);
Switch timeFormat;
Switch buttonScroll;
@@ -85,14 +86,15 @@ public class DanaRUserOptionsActivity extends Activity {
DanaRPump pump = DanaRPump.getInstance();
//used for debugging
- log.debug("UserOptionsLoaded:" + (System.currentTimeMillis() - pump.lastConnection) / 1000 + " s ago"
- + "\ntimeDisplayType:" + pump.timeDisplayType
- + "\nbuttonScroll:" + pump.buttonScrollOnOff
- + "\ntimeDisplayType:" + pump.timeDisplayType
- + "\nlcdOnTimeSec:" + pump.lcdOnTimeSec
- + "\nbacklight:" + pump.backlightOnTimeSec
- + "\npumpUnits:" + pump.units
- + "\nlowReservoir:" + pump.lowReservoirRate);
+ if (L.isEnabled(L.PUMP))
+ log.debug("UserOptionsLoaded:" + (System.currentTimeMillis() - pump.lastConnection) / 1000 + " s ago"
+ + "\ntimeDisplayType:" + pump.timeDisplayType
+ + "\nbuttonScroll:" + pump.buttonScrollOnOff
+ + "\ntimeDisplayType:" + pump.timeDisplayType
+ + "\nlcdOnTimeSec:" + pump.lcdOnTimeSec
+ + "\nbacklight:" + pump.backlightOnTimeSec
+ + "\npumpUnits:" + pump.units
+ + "\nlowReservoir:" + pump.lowReservoirRate);
screenTimeout.setParams((double) pump.lcdOnTimeSec, 5d, 240d, 5d, new DecimalFormat("1"), false);
backlightTimeout.setParams((double) pump.backlightOnTimeSec, 1d, 60d, 1d, new DecimalFormat("1"), false);
@@ -122,7 +124,7 @@ public class DanaRUserOptionsActivity extends Activity {
break;
}
if (pump.lastSettingsRead == 0)
- log.debug("No settings loaded from pump!");
+ log.error("No settings loaded from pump!");
else
setData();
}
@@ -175,13 +177,13 @@ public class DanaRUserOptionsActivity extends Activity {
// step is 5 seconds
- int screenTimeoutValue = !screenTimeout.getText().isEmpty() ? (Integer.parseInt(screenTimeout.getText().toString()) / 5) * 5: 5;
+ int screenTimeoutValue = !screenTimeout.getText().isEmpty() ? (Integer.parseInt(screenTimeout.getText().toString()) / 5) * 5 : 5;
if (screenTimeoutValue > 4 && screenTimeoutValue < 241) {
pump.lcdOnTimeSec = screenTimeoutValue;
} else {
pump.lcdOnTimeSec = 5;
}
- int backlightTimeoutValue = !backlightTimeout.getText().isEmpty() ? Integer.parseInt(backlightTimeout.getText().toString()): 1;
+ int backlightTimeoutValue = !backlightTimeout.getText().isEmpty() ? Integer.parseInt(backlightTimeout.getText().toString()) : 1;
if (backlightTimeoutValue > 0 && backlightTimeoutValue < 61) {
pump.backlightOnTimeSec = backlightTimeoutValue;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MessageBase.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MessageBase.java
index 2e6c02458e..b48940807d 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MessageBase.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MessageBase.java
@@ -12,7 +12,7 @@ import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
-import info.nightscout.androidaps.Config;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.utils.CRC;
/*
@@ -22,7 +22,7 @@ import info.nightscout.utils.CRC;
*/
public class MessageBase {
- private static Logger log = LoggerFactory.getLogger(MessageBase.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
protected byte[] buffer = new byte[512];
private int position = 6;
@@ -95,7 +95,7 @@ public class MessageBase {
}
public void handleMessage(byte[] bytes) {
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
if (bytes.length > 6) {
int command = (bytes[5] & 0xFF) | ((bytes[4] << 8) & 0xFF00);
log.debug("UNPROCESSED MSG: " + getMessageName() + " Command: " + String.format("%04X", command) + " Data: " + toHexString(bytes));
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MessageHashTable.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MessageHashTable.java
index 4b90b8f02d..e7f1adca07 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MessageHashTable.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MessageHashTable.java
@@ -9,8 +9,6 @@ import java.util.HashMap;
* Created by mike on 28.05.2016.
*/
public class MessageHashTable {
- private static Logger log = LoggerFactory.getLogger(MessageHashTable.class);
-
public static HashMap messages = null;
static {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MessageOriginalNames.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MessageOriginalNames.java
index 3712945094..a285ce5120 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MessageOriginalNames.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MessageOriginalNames.java
@@ -5,13 +5,15 @@ import org.slf4j.LoggerFactory;
import java.util.HashMap;
+import info.nightscout.androidaps.logging.L;
+
/**
* Created by mike on 28.05.2016.
*/
public class MessageOriginalNames {
- private static Logger log = LoggerFactory.getLogger(MessageOriginalNames.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
- public static HashMap messageNames;
+ private static HashMap messageNames;
static {
messageNames = new HashMap<>();
@@ -162,7 +164,7 @@ public class MessageOriginalNames {
if (messageNames.containsKey(command))
return messageNames.get(command);
else {
- log.debug("Unknown command: " + String.format("%04X", command));
+ log.error("Unknown command: " + String.format("%04X", command));
return "UNKNOWN_COMMAND";
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusProgress.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusProgress.java
index cb01a7d901..873824f966 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusProgress.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusProgress.java
@@ -3,14 +3,14 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
-import info.nightscout.androidaps.plugins.Treatments.Treatment;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
+import info.nightscout.androidaps.plugins.Treatments.Treatment;
public class MsgBolusProgress extends MessageBase {
- private static Logger log = LoggerFactory.getLogger(MsgBolusProgress.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
private static Treatment t;
private static double amount;
@@ -27,6 +27,8 @@ public class MsgBolusProgress extends MessageBase {
this.amount = amount;
this.t = t;
lastReceive = System.currentTimeMillis();
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message: amount: " + amount + " treatment: " + t.toString());
}
@Override
@@ -40,7 +42,7 @@ public class MsgBolusProgress extends MessageBase {
bolusingEvent.t = t;
bolusingEvent.percent = Math.min((int) (done / amount * 100), 100);
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Bolus remaining: " + progress + " delivered: " + done);
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStart.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStart.java
index 7586edf825..06200d1f0c 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStart.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStart.java
@@ -3,13 +3,12 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.interfaces.Constraint;
-import info.nightscout.utils.HardLimits;
+import info.nightscout.androidaps.logging.L;
public class MsgBolusStart extends MessageBase {
- private static Logger log = LoggerFactory.getLogger(MsgBolusStart.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public static int errorCode;
@@ -25,7 +24,7 @@ public class MsgBolusStart extends MessageBase {
AddParamInt((int) (amount * 100));
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Bolus start : " + amount);
}
@@ -34,9 +33,10 @@ public class MsgBolusStart extends MessageBase {
errorCode = intFromBuff(bytes, 0, 1);
if (errorCode != 2) {
failed = true;
- log.debug("Messsage response: " + errorCode + " FAILED!!");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("Messsage response: " + errorCode + " FAILED!!");
} else {
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Messsage response: " + errorCode + " OK");
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStartWithSpeed.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStartWithSpeed.java
index dd4251a350..a3160ff887 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStartWithSpeed.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStartWithSpeed.java
@@ -3,13 +3,12 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.interfaces.Constraint;
-import info.nightscout.utils.HardLimits;
+import info.nightscout.androidaps.logging.L;
public class MsgBolusStartWithSpeed extends MessageBase {
- private static Logger log = LoggerFactory.getLogger(MsgBolusStartWithSpeed.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public static int errorCode;
@@ -26,7 +25,7 @@ public class MsgBolusStartWithSpeed extends MessageBase {
AddParamInt((int) (amount * 100));
AddParamByte((byte) speed);
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Bolus start : " + amount + " speed: " + speed);
}
@@ -35,9 +34,10 @@ public class MsgBolusStartWithSpeed extends MessageBase {
errorCode = intFromBuff(bytes, 0, 1);
if (errorCode != 2) {
failed = true;
- log.debug("Messsage response: " + errorCode + " FAILED!!");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("Messsage response: " + errorCode + " FAILED!!");
} else {
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Messsage response: " + errorCode + " OK");
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStop.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStop.java
index 5c677b813e..fe5d47c131 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStop.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStop.java
@@ -5,11 +5,12 @@ import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
-import info.nightscout.androidaps.plugins.Treatments.Treatment;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
+import info.nightscout.androidaps.plugins.Treatments.Treatment;
public class MsgBolusStop extends MessageBase {
- private static Logger log = LoggerFactory.getLogger(MsgBolusStop.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
private static Treatment t;
private static Double amount;
@@ -26,10 +27,14 @@ public class MsgBolusStop extends MessageBase {
this.t = t;
this.amount = amount;
forced = false;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("Bolus stop: amount: " + amount + " treatment: " + t.toString());
}
@Override
public void handleMessage(byte[] bytes) {
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("Messsage received");
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();
stopped = true;
if (!forced) {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgCheckValue.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgCheckValue.java
index 3f0c306940..e04d9243e7 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgCheckValue.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgCheckValue.java
@@ -3,21 +3,21 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
-import info.nightscout.androidaps.R;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
-import info.nightscout.utils.ToastUtils;
/**
* Created by mike on 30.06.2016.
*/
public class MsgCheckValue extends MessageBase {
- private static Logger log = LoggerFactory.getLogger(MsgCheckValue.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgCheckValue() {
SetCommand(0xF0F1);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
@@ -25,7 +25,8 @@ public class MsgCheckValue extends MessageBase {
DanaRPump pump = DanaRPump.getInstance();
pump.isNewPump = true;
- log.debug("New firmware confirmed");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New firmware confirmed");
pump.model = intFromBuff(bytes, 0, 1);
pump.protocol = intFromBuff(bytes, 1, 1);
@@ -35,7 +36,7 @@ public class MsgCheckValue extends MessageBase {
log.debug("Wrong model selected");
}
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Model: " + String.format("%02X ", pump.model));
log.debug("Protocol: " + String.format("%02X ", pump.protocol));
log.debug("Product Code: " + String.format("%02X ", pump.productCode));
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgError.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgError.java
index e42327c3b0..b5d4267203 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgError.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgError.java
@@ -3,17 +3,19 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
-import info.nightscout.utils.NSUpload;
+import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
public class MsgError extends MessageBase {
- private static Logger log = LoggerFactory.getLogger(MsgError.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgError() {
SetCommand(0x0601);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
@@ -47,7 +49,7 @@ public class MsgError extends MessageBase {
bolusingEvent.status = errorString;
MainApp.bus().post(bolusingEvent);
}
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Error detected: " + errorString);
NSUpload.uploadError(errorString);
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryAlarm.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryAlarm.java
index 24ea6d0f37..7adb335e93 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryAlarm.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryAlarm.java
@@ -3,13 +3,17 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import info.nightscout.androidaps.logging.L;
+
/**
* Created by mike on 20.07.2016.
*/
public class MsgHistoryAlarm extends MsgHistoryAll {
- private static Logger log = LoggerFactory.getLogger(MsgHistoryAlarm.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgHistoryAlarm() {
SetCommand(0x3105);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
// Handle message taken from MsgHistoryAll
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryAll.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryAll.java
index 4e4bc759f5..a0e1075056 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryAll.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryAll.java
@@ -7,14 +7,17 @@ import java.util.Date;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.db.DanaRHistoryRecord;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRSyncStatus;
import info.nightscout.utils.DateUtil;
public class MsgHistoryAll extends MessageBase {
- private static Logger log = LoggerFactory.getLogger(MsgHistoryAll.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgHistoryAll() {
SetCommand(0x41F2);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryAllDone.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryAllDone.java
index 6ce3325715..e78771f99d 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryAllDone.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryAllDone.java
@@ -3,21 +3,23 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
+import info.nightscout.androidaps.logging.L;
public class MsgHistoryAllDone extends MessageBase {
- private static Logger log = LoggerFactory.getLogger(MsgHistoryAllDone.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public static boolean received = false;
public MsgHistoryAllDone() {
SetCommand(0x41F1);
received = false;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
public void handleMessage(byte[] bytes) {
received = true;
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("History all done received");
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryBasalHour.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryBasalHour.java
index 3fd97135f0..f56e2af273 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryBasalHour.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryBasalHour.java
@@ -3,13 +3,17 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import info.nightscout.androidaps.logging.L;
+
/**
* Created by mike on 20.07.2016.
*/
public class MsgHistoryBasalHour extends MsgHistoryAll {
- private static Logger log = LoggerFactory.getLogger(MsgHistoryBasalHour.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgHistoryBasalHour() {
SetCommand(0x310A);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
// Handle message taken from MsgHistoryAll
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryBolus.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryBolus.java
index b213ba52fd..d675ddc488 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryBolus.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryBolus.java
@@ -3,13 +3,18 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import info.nightscout.androidaps.logging.L;
+
/**
* Created by mike on 20.07.2016.
*/
public class MsgHistoryBolus extends MsgHistoryAll {
- private static Logger log = LoggerFactory.getLogger(MsgHistoryBolus.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
+
public MsgHistoryBolus() {
SetCommand(0x3101);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
// Handle message taken from MsgHistoryAll
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryCarbo.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryCarbo.java
index 115dc73e02..6755800bba 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryCarbo.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryCarbo.java
@@ -3,13 +3,17 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import info.nightscout.androidaps.logging.L;
+
/**
* Created by mike on 20.07.2016.
*/
public class MsgHistoryCarbo extends MsgHistoryAll {
- private static Logger log = LoggerFactory.getLogger(MsgHistoryCarbo.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgHistoryCarbo() {
SetCommand(0x3107);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
// Handle message taken from MsgHistoryAll
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryDailyInsulin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryDailyInsulin.java
index 77933c40da..68d46f0d20 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryDailyInsulin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryDailyInsulin.java
@@ -3,13 +3,17 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import info.nightscout.androidaps.logging.L;
+
/**
* Created by mike on 20.07.2016.
*/
public class MsgHistoryDailyInsulin extends MsgHistoryAll {
- private static Logger log = LoggerFactory.getLogger(MsgHistoryDailyInsulin.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgHistoryDailyInsulin() {
SetCommand(0x3102);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
// Handle message taken from MsgHistoryAll
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryDone.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryDone.java
index 04d3cb3faf..63e51e24ba 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryDone.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryDone.java
@@ -3,24 +3,26 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
+import info.nightscout.androidaps.logging.L;
/**
* Created by mike on 20.07.2016.
*/
public class MsgHistoryDone extends MessageBase {
- private static Logger log = LoggerFactory.getLogger(MsgHistoryDone.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public static boolean received = false;
public MsgHistoryDone() {
SetCommand(0x31F1);
received = false;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
public void handleMessage(byte[] bytes) {
received = true;
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("History done received");
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryError.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryError.java
index 3358a88fea..8d6d0615d4 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryError.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryError.java
@@ -3,13 +3,18 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import info.nightscout.androidaps.logging.L;
+
/**
* Created by mike on 20.07.2016.
*/
public class MsgHistoryError extends MsgHistoryAll {
- private static Logger log = LoggerFactory.getLogger(MsgHistoryError.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
+
public MsgHistoryError() {
SetCommand(0x3106);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
// Handle message taken from MsgHistoryAll
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryGlucose.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryGlucose.java
index f07b91e9d8..10fd68e3ab 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryGlucose.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryGlucose.java
@@ -3,13 +3,18 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import info.nightscout.androidaps.logging.L;
+
/**
* Created by mike on 20.07.2016.
*/
public class MsgHistoryGlucose extends MsgHistoryAll {
- private static Logger log = LoggerFactory.getLogger(MsgHistoryGlucose.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
+
public MsgHistoryGlucose() {
SetCommand(0x3104);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
// Handle message taken from MsgHistoryAll
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryNew.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryNew.java
index 5de685f65b..01f7197434 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryNew.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryNew.java
@@ -3,13 +3,18 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import info.nightscout.androidaps.logging.L;
+
/**
* Created by mike on 20.07.2016.
*/
public class MsgHistoryNew extends MsgHistoryAll {
- private static Logger log = LoggerFactory.getLogger(MsgHistoryNew.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
+
public MsgHistoryNew() {
SetCommand(0x42F2);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
// Handle message taken from MsgHistoryAll
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryNewDone.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryNewDone.java
index 2cde92bf9a..fb9118e629 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryNewDone.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryNewDone.java
@@ -3,24 +3,26 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
+import info.nightscout.androidaps.logging.L;
/**
* Created by mike on 20.07.2016.
*/
public class MsgHistoryNewDone extends MessageBase {
- private static Logger log = LoggerFactory.getLogger(MsgHistoryNewDone.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public static boolean received = false;
public MsgHistoryNewDone() {
SetCommand(0x42F1);
received = false;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
public void handleMessage(byte[] bytes) {
received = true;
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("History new done received");
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryRefill.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryRefill.java
index daaed79023..238a606cfb 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryRefill.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryRefill.java
@@ -3,13 +3,18 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import info.nightscout.androidaps.logging.L;
+
/**
* Created by mike on 20.07.2016.
*/
public class MsgHistoryRefill extends MsgHistoryAll {
- private static Logger log = LoggerFactory.getLogger(MsgHistoryRefill.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
+
public MsgHistoryRefill() {
SetCommand(0x3108);
- }
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
+ }
// Handle message taken from MsgHistoryAll
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistorySuspend.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistorySuspend.java
index db807a31b5..7182722f97 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistorySuspend.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistorySuspend.java
@@ -3,13 +3,18 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import info.nightscout.androidaps.logging.L;
+
/**
* Created by mike on 20.07.2016.
*/
public class MsgHistorySuspend extends MsgHistoryAll {
- private static Logger log = LoggerFactory.getLogger(MsgHistorySuspend.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
+
public MsgHistorySuspend() {
SetCommand(0x3109);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
// Handle message taken from MsgHistoryAll
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusBasic.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusBasic.java
index e7f6032c00..61150079cd 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusBasic.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusBasic.java
@@ -3,14 +3,16 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
public class MsgInitConnStatusBasic extends MessageBase {
- private static Logger log = LoggerFactory.getLogger(MsgInitConnStatusBasic.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgInitConnStatusBasic() {
SetCommand(0x0303);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
@@ -39,14 +41,17 @@ public class MsgInitConnStatusBasic extends MessageBase {
boolean deliveryStepBolus = (bolusConfig & DanaRPump.DELIVERY_STEP_BOLUS) != 0;
boolean deliveryBasal = (bolusConfig & DanaRPump.DELIVERY_BASAL) != 0;
boolean deliveryExtBolus = (bolusConfig & DanaRPump.DELIVERY_EXT_BOLUS) != 0;
- log.debug("Delivery prime: " + deliveryPrime);
- log.debug("Delivery step bolus: " + deliveryStepBolus);
- log.debug("Delivery basal: " + deliveryBasal);
- log.debug("Delivery ext bolus: " + deliveryExtBolus);
+ if (L.isEnabled(L.PUMPCOMM)) {
+ log.debug("Delivery prime: " + deliveryPrime);
+ log.debug("Delivery step bolus: " + deliveryStepBolus);
+ log.debug("Delivery basal: " + deliveryBasal);
+ log.debug("Delivery ext bolus: " + deliveryExtBolus);
+ }
} catch (Exception e) {
+ log.error("Unhadled exception", e);
}
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Pump suspended: " + pump.pumpSuspended);
log.debug("Calculator enabled: " + pump.calculatorEnabled);
log.debug("Daily total units: " + pump.dailyTotalUnits);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusBolus.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusBolus.java
index 4fc9844b0d..49e00e1bbb 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusBolus.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusBolus.java
@@ -3,22 +3,24 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
-import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
-import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
+import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
+import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
/**
* Created by mike on 28.05.2016.
*/
public class MsgInitConnStatusBolus extends MessageBase {
- private static Logger log = LoggerFactory.getLogger(MsgInitConnStatusBolus.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgInitConnStatusBolus() {
SetCommand(0x0302);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
@@ -34,7 +36,7 @@ public class MsgInitConnStatusBolus extends MessageBase {
pump.maxBolus = intFromBuff(bytes, 2, 2) / 100d;
//int bolusRate = intFromBuff(bytes, 4, 8);
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Is Extended bolus enabled: " + pump.isExtendedBolusEnabled);
log.debug("Bolus increment: " + pump.bolusStep);
log.debug("Bolus max: " + pump.maxBolus);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusOption.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusOption.java
index 560ed8b332..c3b73c0ae1 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusOption.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusOption.java
@@ -3,17 +3,19 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
/**
* Created by mike on 28.05.2016.
*/
public class MsgInitConnStatusOption extends MessageBase {
- private static Logger log = LoggerFactory.getLogger(MsgInitConnStatusOption.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgInitConnStatusOption() {
SetCommand(0x0304);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
@@ -29,7 +31,7 @@ public class MsgInitConnStatusOption extends MessageBase {
//int none = intFromBuff(bytes, 8, 1);
if (bytes.length >= 21) {
DanaRPump.getInstance().password = intFromBuff(bytes, 9, 2) ^ 0x3463;
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Pump password: " + DanaRPump.getInstance().password);
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusTime.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusTime.java
index 84d9c413bf..93bea19218 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusTime.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusTime.java
@@ -5,11 +5,11 @@ import org.slf4j.LoggerFactory;
import java.util.Date;
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.events.EventRefreshGui;
import info.nightscout.androidaps.interfaces.PluginType;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
@@ -18,19 +18,21 @@ import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
public class MsgInitConnStatusTime extends MessageBase {
- private static Logger log = LoggerFactory.getLogger(MsgInitConnStatusTime.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgInitConnStatusTime() {
SetCommand(0x0301);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
public void handleMessage(byte[] bytes) {
if (bytes.length - 10 > 7) {
- Notification notification = new Notification(Notification.WRONG_DRIVER, MainApp.gs(R.string.pumpdrivercorrected), Notification.NORMAL);
+ Notification notification = new Notification(Notification.WRONG_DRIVER, MainApp.gs(R.string.pumpdrivercorrected), Notification.NORMAL);
MainApp.bus().post(new EventNewNotification(notification));
MainApp.getSpecificPlugin(DanaRPlugin.class).disconnect("Wrong Model");
- log.debug("Wrong model selected. Switching to Korean DanaR");
+ log.error("Wrong model selected. Switching to Korean DanaR");
MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setPluginEnabled(PluginType.PUMP, true);
MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setFragmentVisible(PluginType.PUMP, true);
MainApp.getSpecificPlugin(DanaRPlugin.class).setPluginEnabled(PluginType.PUMP, false);
@@ -39,7 +41,7 @@ public class MsgInitConnStatusTime extends MessageBase {
DanaRPump.reset(); // mark not initialized
//If profile coming from pump, switch it as well
- if(MainApp.getSpecificPlugin(DanaRPlugin.class).isEnabled(PluginType.PROFILE)){
+ if (MainApp.getSpecificPlugin(DanaRPlugin.class).isEnabled(PluginType.PROFILE)) {
(MainApp.getSpecificPlugin(DanaRPlugin.class)).setPluginEnabled(PluginType.PROFILE, false);
(MainApp.getSpecificPlugin(DanaRKoreanPlugin.class)).setPluginEnabled(PluginType.PROFILE, true);
}
@@ -53,7 +55,7 @@ public class MsgInitConnStatusTime extends MessageBase {
Date time = dateTimeSecFromBuff(bytes, 0);
int versionCode = intFromBuff(bytes, 6, 1);
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Pump time: " + time);
log.debug("Version code: " + versionCode);
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgPCCommStart.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgPCCommStart.java
index 619bbd9461..6f92c3241c 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgPCCommStart.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgPCCommStart.java
@@ -3,17 +3,20 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
+import info.nightscout.androidaps.logging.L;
public class MsgPCCommStart extends MessageBase {
- private static Logger log = LoggerFactory.getLogger(MsgPCCommStart.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
+
public MsgPCCommStart() {
SetCommand(0x3001);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
public void handleMessage(byte[] bytes) {
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("PC comm start received");
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgPCCommStop.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgPCCommStop.java
index 20dd4e060f..255bb17532 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgPCCommStop.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgPCCommStop.java
@@ -3,17 +3,19 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
+import info.nightscout.androidaps.logging.L;
public class MsgPCCommStop extends MessageBase {
- private static Logger log = LoggerFactory.getLogger(MsgPCCommStop.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgPCCommStop() {
SetCommand(0x3002);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
public void handleMessage(byte[] bytes) {
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("PC comm stop received");
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetActivateBasalProfile.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetActivateBasalProfile.java
index 64ed0488a4..2d222f9601 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetActivateBasalProfile.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetActivateBasalProfile.java
@@ -3,20 +3,22 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
+import info.nightscout.androidaps.logging.L;
public class MsgSetActivateBasalProfile extends MessageBase {
- private static Logger log = LoggerFactory.getLogger(MsgSetActivateBasalProfile.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgSetActivateBasalProfile() {
SetCommand(0x330C);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
// index 0-3
public MsgSetActivateBasalProfile(byte index) {
this();
AddParamByte(index);
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Activate basal profile: " + index);
}
@@ -25,9 +27,10 @@ public class MsgSetActivateBasalProfile extends MessageBase {
int result = intFromBuff(bytes, 0, 1);
if (result != 1) {
failed = true;
- log.debug("Activate basal profile result: " + result + " FAILED!!!");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("Activate basal profile result: " + result + " FAILED!!!");
} else {
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Activate basal profile result: " + result);
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetBasalProfile.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetBasalProfile.java
index 9f945e8b26..3e87e4bf41 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetBasalProfile.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetBasalProfile.java
@@ -3,17 +3,19 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
-import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
+import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
public class MsgSetBasalProfile extends MessageBase {
- private static Logger log = LoggerFactory.getLogger(MsgSetBasalProfile.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgSetBasalProfile() {
SetCommand(0x3306);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
// index 0-3
@@ -23,7 +25,7 @@ public class MsgSetBasalProfile extends MessageBase {
for (Integer i = 0; i < 24; i++) {
AddParamInt((int) (values[i] * 100));
}
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Set basal profile: " + index);
}
@@ -32,11 +34,12 @@ public class MsgSetBasalProfile extends MessageBase {
int result = intFromBuff(bytes, 0, 1);
if (result != 1) {
failed = true;
- log.debug("Set basal profile result: " + result + " FAILED!!!");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("Set basal profile result: " + result + " FAILED!!!");
Notification reportFail = new Notification(Notification.PROFILE_SET_FAILED, MainApp.gs(R.string.profile_set_failed), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(reportFail));
} else {
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Set basal profile result: " + result);
Notification reportOK = new Notification(Notification.PROFILE_SET_OK, MainApp.gs(R.string.profile_set_ok), Notification.INFO, 60);
MainApp.bus().post(new EventNewNotification(reportOK));
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetCarbsEntry.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetCarbsEntry.java
index 4fcd6dee9c..59cbcdafa0 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetCarbsEntry.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetCarbsEntry.java
@@ -5,13 +5,15 @@ import org.slf4j.LoggerFactory;
import java.util.Calendar;
-import info.nightscout.androidaps.Config;
+import info.nightscout.androidaps.logging.L;
public class MsgSetCarbsEntry extends MessageBase {
- private static Logger log = LoggerFactory.getLogger(MsgSetCarbsEntry.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgSetCarbsEntry() {
SetCommand(0x0402);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
public MsgSetCarbsEntry(long time, int amount) {
@@ -27,7 +29,7 @@ public class MsgSetCarbsEntry extends MessageBase {
AddParamByte((byte) (calendar.get(Calendar.SECOND)));
AddParamByte((byte) 0x43); //??
AddParamInt(amount);
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Set carb entry: " + amount + " date " + calendar.getTime().toString());
}
@@ -36,9 +38,10 @@ public class MsgSetCarbsEntry extends MessageBase {
int result = intFromBuff(bytes, 0, 1);
if (result != 1) {
failed = true;
- log.debug("Set carb entry result: " + result + " FAILED!!!");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("Set carb entry result: " + result + " FAILED!!!");
} else {
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Set carb entry result: " + result);
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetExtendedBolusStart.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetExtendedBolusStart.java
index 420f0ccbf9..a7f2a0e1b8 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetExtendedBolusStart.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetExtendedBolusStart.java
@@ -3,16 +3,17 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.interfaces.Constraint;
-import info.nightscout.utils.HardLimits;
+import info.nightscout.androidaps.logging.L;
public class MsgSetExtendedBolusStart extends MessageBase {
- private static Logger log = LoggerFactory.getLogger(MsgSetExtendedBolusStart.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgSetExtendedBolusStart() {
SetCommand(0x0407);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
public MsgSetExtendedBolusStart(double amount, byte halfhours) {
@@ -25,7 +26,7 @@ public class MsgSetExtendedBolusStart extends MessageBase {
AddParamInt((int) (amount * 100));
AddParamByte(halfhours);
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Set extended bolus start: " + (((int) (amount * 100)) / 100d) + "U halfhours: " + (int) halfhours);
}
@@ -34,9 +35,10 @@ public class MsgSetExtendedBolusStart extends MessageBase {
int result = intFromBuff(bytes, 0, 1);
if (result != 1) {
failed = true;
- log.debug("Set extended bolus start result: " + result + " FAILED!!!");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("Set extended bolus start result: " + result + " FAILED!!!");
} else {
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Set extended bolus start result: " + result);
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetExtendedBolusStop.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetExtendedBolusStop.java
index 7084949daa..504db719ea 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetExtendedBolusStop.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetExtendedBolusStop.java
@@ -3,15 +3,15 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
+import info.nightscout.androidaps.logging.L;
public class MsgSetExtendedBolusStop extends MessageBase {
- private static Logger log = LoggerFactory.getLogger(MsgSetExtendedBolusStop.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgSetExtendedBolusStop() {
SetCommand(0x0406);
- if (Config.logDanaMessageDetail)
- log.debug("Set extended bolus stop");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
@@ -19,9 +19,10 @@ public class MsgSetExtendedBolusStop extends MessageBase {
int result = intFromBuff(bytes, 0, 1);
if (result != 1) {
failed = true;
- log.debug("Set extended bolus stop result: " + result + " FAILED!!!");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("Set extended bolus stop result: " + result + " FAILED!!!");
} else {
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Set extended bolus stop result: " + result);
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetSingleBasalProfile.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetSingleBasalProfile.java
index 7dd9ca522b..eabf383b94 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetSingleBasalProfile.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetSingleBasalProfile.java
@@ -3,14 +3,14 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
public class MsgSetSingleBasalProfile extends MessageBase {
- private static Logger log = LoggerFactory.getLogger(MsgSetSingleBasalProfile.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgSetSingleBasalProfile() {
SetCommand(0x3302);
@@ -22,8 +22,8 @@ public class MsgSetSingleBasalProfile extends MessageBase {
for (Integer i = 0; i < 24; i++) {
AddParamInt((int) (values[i] * 100));
}
- if (Config.logDanaMessageDetail)
- log.debug("Set basal profile");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
@@ -31,11 +31,12 @@ public class MsgSetSingleBasalProfile extends MessageBase {
int result = intFromBuff(bytes, 0, 1);
if (result != 1) {
failed = true;
- log.debug("Set basal profile result: " + result + " FAILED!!!");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("Set basal profile result: " + result + " FAILED!!!");
Notification reportFail = new Notification(Notification.PROFILE_SET_FAILED, MainApp.gs(R.string.profile_set_failed), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(reportFail));
} else {
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Set basal profile result: " + result);
Notification reportOK = new Notification(Notification.PROFILE_SET_OK, MainApp.gs(R.string.profile_set_ok), Notification.INFO, 60);
MainApp.bus().post(new EventNewNotification(reportOK));
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetTempBasalStart.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetTempBasalStart.java
index 2b72c35749..c756af3491 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetTempBasalStart.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetTempBasalStart.java
@@ -3,10 +3,10 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
+import info.nightscout.androidaps.logging.L;
public class MsgSetTempBasalStart extends MessageBase {
- private static Logger log = LoggerFactory.getLogger(MsgSetTempBasalStart.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgSetTempBasalStart() {
SetCommand(0x0401);
@@ -24,7 +24,7 @@ public class MsgSetTempBasalStart extends MessageBase {
AddParamByte((byte) (percent & 255));
AddParamByte((byte) (durationInHours & 255));
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Temp basal start percent: " + percent + " duration hours: " + durationInHours);
}
@@ -32,9 +32,10 @@ public class MsgSetTempBasalStart extends MessageBase {
int result = intFromBuff(bytes, 0, 1);
if (result != 1) {
failed = true;
- log.debug("Set temp basal start result: " + result + " FAILED!!!");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("Set temp basal start result: " + result + " FAILED!!!");
} else {
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Set temp basal start result: " + result);
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetTempBasalStop.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetTempBasalStop.java
index 39582ac399..7b14e8e3e3 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetTempBasalStop.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetTempBasalStop.java
@@ -3,14 +3,14 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
+import info.nightscout.androidaps.logging.L;
public class MsgSetTempBasalStop extends MessageBase {
- private static Logger log = LoggerFactory.getLogger(MsgSetTempBasalStop.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgSetTempBasalStop() {
SetCommand(0x0403);
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Temp basal stop");
}
@@ -18,9 +18,10 @@ public class MsgSetTempBasalStop extends MessageBase {
int result = intFromBuff(bytes, 0, 1);
if (result != 1) {
failed = true;
- log.debug("Set temp basal stop result: " + result + " FAILED!!!");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("Set temp basal stop result: " + result + " FAILED!!!");
} else {
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Set temp basal stop result: " + result);
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetTime.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetTime.java
index 3910d52c97..6d33aef8cf 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetTime.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetTime.java
@@ -5,26 +5,29 @@ import org.slf4j.LoggerFactory;
import java.util.Date;
-import info.nightscout.androidaps.Config;
+import info.nightscout.androidaps.logging.L;
+import info.nightscout.utils.DateUtil;
/**
* Created by mike on 09.12.2016.
*/
public class MsgSetTime extends MessageBase {
- private static Logger log = LoggerFactory.getLogger(MsgSetTime.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
private static Date time;
public MsgSetTime(Date time) {
SetCommand(0x330a);
this.time = time;
AddParamDateTime(time);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message: time:" + DateUtil.dateAndTimeString(time));
}
public void handleMessage(byte[] bytes) {
int result = intFromBuff(bytes, 0, 1);
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Result of setting time: " + time + " is " + result);
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetUserOptions.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetUserOptions.java
index 407b19da8d..7484966dba 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetUserOptions.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetUserOptions.java
@@ -2,9 +2,8 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import android.support.v4.internal.view.SupportMenu;
-import info.nightscout.androidaps.Config;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
/**
@@ -12,7 +11,7 @@ import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
*/
public class MsgSetUserOptions extends MessageBase {
- private static Logger log = LoggerFactory.getLogger(MsgSetUserOptions.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public boolean done;
@@ -21,7 +20,7 @@ public class MsgSetUserOptions extends MessageBase {
DanaRPump pump = DanaRPump.getInstance();
if (pump.userOptionsFrompump == null) {
// No options set -> Exitting
- log.debug("NO USER OPTIONS LOADED EXITTING!");
+ log.error("NO USER OPTIONS LOADED EXITTING!");
return;
}
pump.userOptionsFrompump[0] = (byte) (pump.timeDisplayType == 1 ? 0 : 1);
@@ -33,18 +32,21 @@ public class MsgSetUserOptions extends MessageBase {
pump.userOptionsFrompump[8] = (byte) pump.units;
pump.userOptionsFrompump[9] = (byte) pump.shutdownHour;
pump.userOptionsFrompump[27] = (byte) pump.lowReservoirRate;
- for(int i=0; i>>>> @ " + (mBolusingTreatment == null ? "" : mBolusingTreatment.insulin));
MsgBolusStop stop = new MsgBolusStop();
stop.forced = true;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/DanaRExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/DanaRExecutionService.java
index ea4dec25fb..0f1dc5dbf9 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/DanaRExecutionService.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/DanaRExecutionService.java
@@ -7,12 +7,9 @@ import android.os.SystemClock;
import com.squareup.otto.Subscribe;
-import org.slf4j.LoggerFactory;
-
import java.io.IOException;
import java.util.Date;
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
@@ -24,6 +21,7 @@ import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.events.EventProfileSwitchChange;
import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.interfaces.PumpInterface;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressDialog;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
@@ -64,13 +62,12 @@ import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRNewStatus;
import info.nightscout.androidaps.plugins.Treatments.Treatment;
import info.nightscout.androidaps.queue.Callback;
import info.nightscout.androidaps.queue.commands.Command;
-import info.nightscout.utils.NSUpload;
+import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
import info.nightscout.utils.SP;
-public class DanaRExecutionService extends AbstractDanaRExecutionService{
+public class DanaRExecutionService extends AbstractDanaRExecutionService {
public DanaRExecutionService() {
- log = LoggerFactory.getLogger(DanaRExecutionService.class);
mBinder = new LocalBinder();
registerBus();
@@ -100,7 +97,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{
public void connect() {
if (mDanaRPump.password != -1 && mDanaRPump.password != SP.getInt(R.string.key_danar_password, -1)) {
- if(System.currentTimeMillis() > lastWrongPumpPassword + 30 * 1000) {
+ if (System.currentTimeMillis() > lastWrongPumpPassword + 30 * 1000) {
Notification notification = new Notification(Notification.WRONG_PUMP_PASSWORD, MainApp.gs(R.string.wrongpumppassword), Notification.URGENT);
notification.soundId = R.raw.error;
lastWrongPumpPassword = System.currentTimeMillis();
@@ -196,12 +193,14 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime)));
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
long timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
- log.debug("Pump time difference: " + timeDiff + " seconds");
+ if (L.isEnabled(L.PUMP))
+ log.debug("Pump time difference: " + timeDiff + " seconds");
if (Math.abs(timeDiff) > 10) {
mSerialIOThread.sendMessage(new MsgSetTime(new Date()));
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
- log.debug("Pump time difference: " + timeDiff + " seconds");
+ if (L.isEnabled(L.PUMP))
+ log.debug("Pump time difference: " + timeDiff + " seconds");
}
mDanaRPump.lastSettingsRead = now;
}
@@ -210,8 +209,9 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{
MainApp.bus().post(new EventInitializationChanged());
NSUpload.uploadDeviceStatus();
if (mDanaRPump.dailyTotalUnits > mDanaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) {
- log.debug("Approaching daily limit: " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits);
- if(System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) {
+ if (L.isEnabled(L.PUMP))
+ log.debug("Approaching daily limit: " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits);
+ if (System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) {
Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.gs(R.string.approachingdailylimit), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(reportFail));
NSUpload.uploadError(MainApp.gs(R.string.approachingdailylimit) + ": " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits + "U");
@@ -301,7 +301,8 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{
if ((System.currentTimeMillis() - progress.lastReceive) > 15 * 1000L) { // if i didn't receive status for more than 15 sec expecting broken comm
stop.stopped = true;
stop.forced = true;
- log.debug("Communication stopped");
+ if (L.isEnabled(L.PUMP))
+ log.debug("Communication stopped");
}
}
SystemClock.sleep(300);
@@ -344,9 +345,11 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{
public void run() {
if (mDanaRPump.lastBolusTime.getTime() > System.currentTimeMillis() - 60 * 1000L) { // last bolus max 1 min old
t.insulin = mDanaRPump.lastBolusAmount;
- log.debug("Used bolus amount from history: " + mDanaRPump.lastBolusAmount);
+ if (L.isEnabled(L.PUMP))
+ log.debug("Used bolus amount from history: " + mDanaRPump.lastBolusAmount);
} else {
- log.debug("Bolus amount in history too old: " + mDanaRPump.lastBolusTime.toLocaleString());
+ if (L.isEnabled(L.PUMP))
+ log.debug("Bolus amount in history too old: " + mDanaRPump.lastBolusTime.toLocaleString());
}
synchronized (o) {
o.notify();
@@ -386,7 +389,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{
public boolean updateBasalsInPump(final Profile profile) {
if (!isConnected()) return false;
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.updatingbasalrates)));
- double[] basal = DanaRPump.buildDanaRProfileRecord(profile);
+ double[] basal = DanaRPump.getInstance().buildDanaRProfileRecord(profile);
MsgSetBasalProfile msgSet = new MsgSetBasalProfile((byte) 0, basal);
mSerialIOThread.sendMessage(msgSet);
MsgSetActivateBasalProfile msgActivate = new MsgSetActivateBasalProfile((byte) 0);
@@ -399,7 +402,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{
@Subscribe
public void onStatusEvent(EventAppExit event) {
- if (Config.logFunctionCalls)
+ if (L.isEnabled(L.PUMP))
log.debug("EventAppExit received");
if (mSerialIOThread != null)
@@ -408,7 +411,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{
MainApp.instance().getApplicationContext().unregisterReceiver(receiver);
stopSelf();
- if (Config.logFunctionCalls)
+ if (L.isEnabled(L.PUMP))
log.debug("EventAppExit finished");
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java
index 49edb6b096..327a8a5dea 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java
@@ -11,9 +11,6 @@ import android.support.v7.app.AlertDialog;
import com.squareup.otto.Subscribe;
-import org.slf4j.LoggerFactory;
-
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.DetailedBolusInfo;
@@ -26,6 +23,7 @@ import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.interfaces.Constraint;
import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.PumpDescription;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
import info.nightscout.androidaps.plugins.PumpDanaR.AbstractDanaRPlugin;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgBolusStart;
@@ -51,7 +49,6 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
public DanaRKoreanPlugin() {
pluginDescription.description(R.string.description_pump_dana_r_korean);
- log = LoggerFactory.getLogger(DanaRKoreanPlugin.class);
useExtendedBoluses = SP.getBoolean("danar_useextended", false);
pumpDescription.isBolusCapable = true;
@@ -87,7 +84,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
@Override
public void switchAllowed(ConfigBuilderFragment.PluginViewHolder.PluginSwitcher pluginSwitcher, FragmentActivity context) {
boolean allowHardwarePump = SP.getBoolean("allow_hardware_pump", false);
- if (allowHardwarePump || context == null){
+ if (allowHardwarePump || context == null) {
pluginSwitcher.invoke();
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
@@ -96,13 +93,15 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
public void onClick(DialogInterface dialog, int id) {
pluginSwitcher.invoke();
SP.putBoolean("allow_hardware_pump", true);
- log.debug("First time HW pump allowed!");
+ if (L.isEnabled(L.PUMP))
+ log.debug("First time HW pump allowed!");
}
})
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
pluginSwitcher.cancel();
- log.debug("User does not allow switching to HW pump!");
+ if (L.isEnabled(L.PUMP))
+ log.debug("User does not allow switching to HW pump!");
}
});
builder.create().show();
@@ -130,12 +129,14 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
private ServiceConnection mConnection = new ServiceConnection() {
public void onServiceDisconnected(ComponentName name) {
- log.debug("Service is disconnected");
+ if (L.isEnabled(L.PUMP))
+ log.debug("Service is disconnected");
sExecutionService = null;
}
public void onServiceConnected(ComponentName name, IBinder service) {
- log.debug("Service is connected");
+ if (L.isEnabled(L.PUMP))
+ log.debug("Service is connected");
DanaRKoreanExecutionService.LocalBinder mLocalBinder = (DanaRKoreanExecutionService.LocalBinder) service;
sExecutionService = mLocalBinder.getServiceInstance();
}
@@ -198,7 +199,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
result.comment = String.format(MainApp.gs(R.string.boluserrorcode), detailedBolusInfo.insulin, t.insulin, MsgBolusStart.errorCode);
else
result.comment = MainApp.gs(R.string.virtualpump_resultok);
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered);
detailedBolusInfo.insulin = t.insulin;
detailedBolusInfo.date = System.currentTimeMillis();
@@ -240,13 +241,13 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
if (doTempOff) {
// If extended in progress
if (activeExtended != null && useExtendedBoluses) {
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: Stopping extended bolus (doTempOff)");
return cancelExtendedBolus();
}
// If temp in progress
if (activeTemp != null) {
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: Stopping temp basal (doTempOff)");
return cancelRealTempBasal();
}
@@ -255,7 +256,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
result.percent = 100;
result.isPercent = true;
result.isTempCancel = true;
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: doTempOff OK");
return result;
}
@@ -267,12 +268,12 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
if (percentRate > getPumpDescription().maxTempPercent) {
percentRate = getPumpDescription().maxTempPercent;
}
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: Calculated percent rate: " + percentRate);
// If extended in progress
if (activeExtended != null && useExtendedBoluses) {
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: Stopping extended bolus (doLowTemp || doHighTemp)");
result = cancelExtendedBolus();
if (!result.success) {
@@ -283,7 +284,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
// Check if some temp is already in progress
if (activeTemp != null) {
// Correct basal already set ?
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: currently running: " + activeTemp.toString());
if (activeTemp.percentRate == percentRate) {
if (enforceNew) {
@@ -295,21 +296,21 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
result.duration = activeTemp.getPlannedRemainingMinutes();
result.isPercent = true;
result.isTempCancel = false;
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: Correct temp basal already set (doLowTemp || doHighTemp)");
return result;
}
}
}
// Convert duration from minutes to hours
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: Setting temp basal " + percentRate + "% for " + durationInMinutes + " mins (doLowTemp || doHighTemp)");
return setTempBasalPercent(percentRate, durationInMinutes, profile, false);
}
if (doExtendedTemp) {
// Check if some temp is already in progress
if (activeTemp != null) {
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: Stopping temp basal (doExtendedTemp)");
result = cancelRealTempBasal();
// Check for proper result
@@ -328,7 +329,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
extendedRateToSet = Round.roundTo(extendedRateToSet, pumpDescription.extendedBolusStep * 2); // *2 because of halfhours
// What is current rate of extended bolusing in u/h?
- if (Config.logPumpActions) {
+ if (L.isEnabled(L.PUMP)) {
log.debug("setTempBasalAbsolute: Extended bolus in progress: " + (activeExtended != null) + " rate: " + pump.extendedBolusAbsoluteRate + "U/h duration remaining: " + pump.extendedBolusRemainingMinutes + "min");
log.debug("setTempBasalAbsolute: Rate to set: " + extendedRateToSet + "U/h");
}
@@ -342,21 +343,21 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
result.duration = pump.extendedBolusRemainingMinutes;
result.isPercent = false;
result.isTempCancel = false;
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: Correct extended already set");
return result;
}
// Now set new extended, no need to to stop previous (if running) because it's replaced
Double extendedAmount = extendedRateToSet / 2 * durationInHalfHours;
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: Setting extended: " + extendedAmount + "U halfhours: " + durationInHalfHours);
result = setExtendedBolus(extendedAmount, durationInMinutes);
if (!result.success) {
log.error("setTempBasalAbsolute: Failed to set extended bolus");
return result;
}
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: Extended bolus set ok");
result.absolute = result.absolute + getBaseBasalRate();
return result;
@@ -395,7 +396,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
result.success = true;
result.isTempCancel = true;
result.comment = MainApp.gs(R.string.virtualpump_resultok);
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("cancelRealTempBasal: OK");
return result;
} else {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/SerialIOThread.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/SerialIOThread.java
index 9a8f3edb05..ea12b2b9c4 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/SerialIOThread.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/SerialIOThread.java
@@ -10,7 +10,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import info.nightscout.androidaps.Config;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
import info.nightscout.androidaps.plugins.PumpDanaR.services.AbstractSerialIOThread;
@@ -21,7 +21,7 @@ import info.nightscout.utils.CRC;
* Created by mike on 17.07.2016.
*/
public class SerialIOThread extends AbstractSerialIOThread {
- private static Logger log = LoggerFactory.getLogger(SerialIOThread.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPBTCOMM);
private InputStream mInputStream = null;
private OutputStream mOutputStream = null;
@@ -72,7 +72,7 @@ public class SerialIOThread extends AbstractSerialIOThread {
message = MessageHashTable_k.findMessage(command);
}
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPBTCOMM))
log.debug("<<<<< " + message.getMessageName() + " " + message.toHexString(extractedBuff));
// process the message content
@@ -84,7 +84,7 @@ public class SerialIOThread extends AbstractSerialIOThread {
}
}
} catch (Exception e) {
- if (Config.logDanaSerialEngine && e.getMessage().indexOf("bt socket closed") < 0)
+ if (e.getMessage().indexOf("bt socket closed") < 0)
log.error("Thread exception: ", e);
mKeepRunning = false;
}
@@ -148,7 +148,7 @@ public class SerialIOThread extends AbstractSerialIOThread {
processedMessage = message;
byte[] messageBytes = message.getRawMessageBytes();
- if (Config.logDanaSerialEngine)
+ if (L.isEnabled(L.PUMPBTCOMM))
log.debug(">>>>> " + message.getMessageName() + " " + message.toHexString(messageBytes));
try {
@@ -167,10 +167,11 @@ public class SerialIOThread extends AbstractSerialIOThread {
SystemClock.sleep(200);
if (!message.received) {
- log.warn("Reply not received " + message.getMessageName());
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.warn("Reply not received " + message.getMessageName());
if (message.getCommand() == 0xF0F1) {
DanaRPump.getInstance().isNewPump = false;
- log.debug("Old firmware detected");
+ log.error("Old firmware detected");
}
}
}
@@ -181,24 +182,29 @@ public class SerialIOThread extends AbstractSerialIOThread {
try {
mInputStream.close();
} catch (Exception e) {
- if (Config.logDanaSerialEngine) log.debug(e.getMessage());
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug(e.getMessage());
}
try {
mOutputStream.close();
} catch (Exception e) {
- if (Config.logDanaSerialEngine) log.debug(e.getMessage());
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug(e.getMessage());
}
try {
mRfCommSocket.close();
} catch (Exception e) {
- if (Config.logDanaSerialEngine) log.debug(e.getMessage());
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug(e.getMessage());
}
try {
System.runFinalization();
} catch (Exception e) {
- if (Config.logDanaSerialEngine) log.debug(e.getMessage());
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug(e.getMessage());
}
- if (Config.logDanaSerialEngine) log.debug("Disconnected: " + reason);
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug("Disconnected: " + reason);
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgCheckValue_k.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgCheckValue_k.java
index 684fa30997..7bde73d5a1 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgCheckValue_k.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgCheckValue_k.java
@@ -3,22 +3,21 @@ package info.nightscout.androidaps.plugins.PumpDanaRKorean.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-import info.nightscout.androidaps.MainApp;
-import info.nightscout.androidaps.R;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
-import info.nightscout.utils.ToastUtils;
/**
* Created by mike on 30.06.2016.
*/
public class MsgCheckValue_k extends MessageBase {
- private static Logger log = LoggerFactory.getLogger(MsgCheckValue_k.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgCheckValue_k() {
SetCommand(0xF0F1);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
@@ -26,17 +25,18 @@ public class MsgCheckValue_k extends MessageBase {
DanaRPump pump = DanaRPump.getInstance();
pump.isNewPump = true;
- log.debug("New firmware confirmed");
+ if (L.isEnabled(L.PUMP))
+ log.debug("New firmware confirmed");
pump.model = intFromBuff(bytes, 0, 1);
pump.protocol = intFromBuff(bytes, 1, 1);
pump.productCode = intFromBuff(bytes, 2, 1);
if (pump.model != DanaRPump.DOMESTIC_MODEL) {
DanaRKoreanPlugin.getPlugin().disconnect("Wrong Model");
- log.debug("Wrong model selected");
+ log.error("Wrong model selected");
}
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMP)) {
log.debug("Model: " + String.format("%02X ", pump.model));
log.debug("Protocol: " + String.format("%02X ", pump.protocol));
log.debug("Product Code: " + String.format("%02X ", pump.productCode));
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusBasic_k.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusBasic_k.java
index fa28e664ed..46222938d7 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusBasic_k.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusBasic_k.java
@@ -3,20 +3,22 @@ package info.nightscout.androidaps.plugins.PumpDanaRKorean.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
-import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
+import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
public class MsgInitConnStatusBasic_k extends MessageBase {
- private static Logger log = LoggerFactory.getLogger(MsgInitConnStatusBasic_k.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgInitConnStatusBasic_k() {
SetCommand(0x0303);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
@@ -30,7 +32,7 @@ public class MsgInitConnStatusBasic_k extends MessageBase {
pump.isEasyModeEnabled = intFromBuff(bytes, 2, 1) == 1;
int easyUIMode = intFromBuff(bytes, 3, 1);
pump.password = intFromBuff(bytes, 4, 2) ^ 0x3463;
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("isStatusSuspendOn: " + pump.pumpSuspended);
log.debug("isUtilityEnable: " + isUtilityEnable);
log.debug("Is EasyUI Enabled: " + pump.isEasyModeEnabled);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusBolus_k.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusBolus_k.java
index 552511cf7c..4be04f538f 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusBolus_k.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusBolus_k.java
@@ -3,23 +3,25 @@ package info.nightscout.androidaps.plugins.PumpDanaRKorean.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
-import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
-import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
-import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
+import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
+import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
+import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
/**
* Created by mike on 28.05.2016.
*/
public class MsgInitConnStatusBolus_k extends MessageBase {
- private static Logger log = LoggerFactory.getLogger(MsgInitConnStatusBolus_k.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgInitConnStatusBolus_k() {
SetCommand(0x0302);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
@@ -36,7 +38,7 @@ public class MsgInitConnStatusBolus_k extends MessageBase {
//int bolusRate = intFromBuff(bytes, 4, 8);
int deliveryStatus = intFromBuff(bytes, 12, 1);
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Is Extended bolus enabled: " + pump.isExtendedBolusEnabled);
log.debug("Bolus increment: " + pump.bolusStep);
log.debug("Bolus max: " + pump.maxBolus);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusTime_k.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusTime_k.java
index 7553b0cc37..5aadfeae42 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusTime_k.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusTime_k.java
@@ -5,11 +5,11 @@ import org.slf4j.LoggerFactory;
import java.util.Date;
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.events.EventRefreshGui;
import info.nightscout.androidaps.interfaces.PluginType;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
@@ -19,10 +19,12 @@ import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
public class MsgInitConnStatusTime_k extends MessageBase {
- private static Logger log = LoggerFactory.getLogger(MsgInitConnStatusTime_k.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgInitConnStatusTime_k() {
SetCommand(0x0301);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
@@ -32,7 +34,7 @@ public class MsgInitConnStatusTime_k extends MessageBase {
Notification notification = new Notification(Notification.WRONG_DRIVER, MainApp.gs(R.string.pumpdrivercorrected), Notification.NORMAL);
MainApp.bus().post(new EventNewNotification(notification));
DanaRKoreanPlugin.getPlugin().disconnect("Wrong Model");
- log.debug("Wrong model selected. Switching to export DanaR");
+ log.error("Wrong model selected. Switching to export DanaR");
MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setPluginEnabled(PluginType.PUMP, false);
MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setFragmentVisible(PluginType.PUMP, false);
MainApp.getSpecificPlugin(DanaRPlugin.class).setPluginEnabled(PluginType.PUMP, true);
@@ -58,7 +60,7 @@ public class MsgInitConnStatusTime_k extends MessageBase {
int versionCode3 = intFromBuff(bytes, 8, 1);
int versionCode4 = intFromBuff(bytes, 9, 1);
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Pump time: " + time);
log.debug("Version code1: " + versionCode1);
log.debug("Version code2: " + versionCode2);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgSettingBasalProfileAll_k.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgSettingBasalProfileAll_k.java
index 304ec9fc37..2455f59e14 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgSettingBasalProfileAll_k.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgSettingBasalProfileAll_k.java
@@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.PumpDanaRKorean.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
@@ -15,10 +15,12 @@ import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
* THIS IS BROKEN IN PUMP... SENDING ONLY 1 PROFILE
*/
public class MsgSettingBasalProfileAll_k extends MessageBase {
- private static Logger log = LoggerFactory.getLogger(MsgSettingBasalProfileAll_k.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgSettingBasalProfileAll_k() {
SetCommand(0x3206);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
public void handleMessage(byte[] bytes) {
@@ -49,7 +51,7 @@ public class MsgSettingBasalProfileAll_k extends MessageBase {
}
}
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
if (pump.basal48Enable) {
for (int profile = 0; profile < 4; profile++) {
for (int index = 0; index < 24; index++) {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgSettingBasal_k.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgSettingBasal_k.java
index 5c8b40b959..b149ceb2ad 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgSettingBasal_k.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgSettingBasal_k.java
@@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.PumpDanaRKorean.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
@@ -12,10 +12,12 @@ import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
* Created by mike on 05.07.2016.
*/
public class MsgSettingBasal_k extends MessageBase {
- private static Logger log = LoggerFactory.getLogger(MsgSettingBasal_k.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgSettingBasal_k() {
SetCommand(0x3202);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
public void handleMessage(byte[] bytes) {
@@ -28,7 +30,7 @@ public class MsgSettingBasal_k extends MessageBase {
pump.pumpProfiles[pump.activeProfile][index] = basal / 100d;
}
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
for (int index = 0; index < 24; index++) {
log.debug("Basal " + String.format("%02d", index) + "h: " + pump.pumpProfiles[pump.activeProfile][index]);
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgStatusBasic_k.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgStatusBasic_k.java
index 0fcaf17d83..d22c6e376a 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgStatusBasic_k.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgStatusBasic_k.java
@@ -3,16 +3,18 @@ package info.nightscout.androidaps.plugins.PumpDanaRKorean.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
public class MsgStatusBasic_k extends MessageBase {
- private static Logger log = LoggerFactory.getLogger(MsgStatusBasic_k.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgStatusBasic_k() {
SetCommand(0x020A);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
public void handleMessage(byte[] bytes) {
@@ -29,7 +31,7 @@ public class MsgStatusBasic_k extends MessageBase {
pump.currentBasal = currentBasal;
pump.batteryRemaining = batteryRemaining;
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Daily total units: " + dailyTotalUnits);
log.debug("Max daily total units: " + maxDailyTotalUnits);
log.debug("Reservoir remaining units: " + reservoirRemainingUnits);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgStatus_k.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgStatus_k.java
index 1fdcf26917..4d8b012244 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgStatus_k.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgStatus_k.java
@@ -3,15 +3,17 @@ package info.nightscout.androidaps.plugins.PumpDanaRKorean.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
public class MsgStatus_k extends MessageBase {
- private static Logger log = LoggerFactory.getLogger(MsgStatus_k.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgStatus_k() {
SetCommand(0x020B);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
public void handleMessage(byte[] bytes) {
@@ -27,7 +29,7 @@ public class MsgStatus_k extends MessageBase {
// }
pump.iob = intFromBuff(bytes, 15, 2) / 100d;
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Daily total: " + pump.dailyTotalUnits);
log.debug("Is extended bolus running: " + pump.isExtendedInProgress);
log.debug("Extended bolus min: " + pump.extendedBolusMinutes);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/services/DanaRKoreanExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/services/DanaRKoreanExecutionService.java
index 0f4afa4314..e54dd7be83 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/services/DanaRKoreanExecutionService.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/services/DanaRKoreanExecutionService.java
@@ -7,12 +7,9 @@ import android.os.SystemClock;
import com.squareup.otto.Subscribe;
-import org.slf4j.LoggerFactory;
-
import java.io.IOException;
import java.util.Date;
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
@@ -24,6 +21,7 @@ import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.events.EventProfileSwitchChange;
import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.interfaces.PumpInterface;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressDialog;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
@@ -50,20 +48,18 @@ import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgStatusBolusExtended;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgStatusTempBasal;
import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRNewStatus;
import info.nightscout.androidaps.plugins.PumpDanaR.services.AbstractDanaRExecutionService;
-import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
import info.nightscout.androidaps.plugins.PumpDanaRKorean.SerialIOThread;
import info.nightscout.androidaps.plugins.PumpDanaRKorean.comm.MsgCheckValue_k;
import info.nightscout.androidaps.plugins.PumpDanaRKorean.comm.MsgSettingBasal_k;
import info.nightscout.androidaps.plugins.PumpDanaRKorean.comm.MsgStatusBasic_k;
import info.nightscout.androidaps.plugins.Treatments.Treatment;
import info.nightscout.androidaps.queue.commands.Command;
-import info.nightscout.utils.NSUpload;
+import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
import info.nightscout.utils.SP;
public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
public DanaRKoreanExecutionService() {
- log = LoggerFactory.getLogger(DanaRKoreanExecutionService.class);
mBinder = new LocalBinder();
registerBus();
@@ -87,7 +83,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
@Subscribe
public void onStatusEvent(EventAppExit event) {
- if (Config.logFunctionCalls)
+ if (L.isEnabled(L.PUMP))
log.debug("EventAppExit received");
if (mSerialIOThread != null)
@@ -96,7 +92,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
MainApp.instance().getApplicationContext().unregisterReceiver(receiver);
stopSelf();
- if (Config.logFunctionCalls)
+ if (L.isEnabled(L.PUMP))
log.debug("EventAppExit finished");
}
@@ -108,7 +104,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
public void connect() {
if (mDanaRPump.password != -1 && mDanaRPump.password != SP.getInt(R.string.key_danar_password, -1)) {
- if(System.currentTimeMillis() > lastWrongPumpPassword + 30 * 1000) {
+ if (System.currentTimeMillis() > lastWrongPumpPassword + 30 * 1000) {
Notification notification = new Notification(Notification.WRONG_PUMP_PASSWORD, MainApp.gs(R.string.wrongpumppassword), Notification.URGENT);
notification.soundId = R.raw.error;
lastWrongPumpPassword = System.currentTimeMillis();
@@ -119,35 +115,32 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
if (mConnectionInProgress)
return;
- new Thread(new Runnable() {
- @Override
- public void run() {
- mConnectionInProgress = true;
- getBTSocketForSelectedPump();
- if (mRfcommSocket == null || mBTDevice == null) {
- mConnectionInProgress = false;
- return; // Device not found
- }
-
- try {
- mRfcommSocket.connect();
- } catch (IOException e) {
- //log.error("Unhandled exception", e);
- if (e.getMessage().contains("socket closed")) {
- log.error("Unhandled exception", e);
- }
- }
-
- if (isConnected()) {
- if (mSerialIOThread != null) {
- mSerialIOThread.disconnect("Recreate SerialIOThread");
- }
- mSerialIOThread = new SerialIOThread(mRfcommSocket);
- MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTED, 0));
- }
-
+ new Thread(() -> {
+ mConnectionInProgress = true;
+ getBTSocketForSelectedPump();
+ if (mRfcommSocket == null || mBTDevice == null) {
mConnectionInProgress = false;
+ return; // Device not found
}
+
+ try {
+ mRfcommSocket.connect();
+ } catch (IOException e) {
+ //log.error("Unhandled exception", e);
+ if (e.getMessage().contains("socket closed")) {
+ log.error("Unhandled exception", e);
+ }
+ }
+
+ if (isConnected()) {
+ if (mSerialIOThread != null) {
+ mSerialIOThread.disconnect("Recreate SerialIOThread");
+ }
+ mSerialIOThread = new SerialIOThread(mRfcommSocket);
+ MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTED, 0));
+ }
+
+ mConnectionInProgress = false;
}).start();
}
@@ -200,12 +193,14 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime)));
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
long timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
- log.debug("Pump time difference: " + timeDiff + " seconds");
+ if (L.isEnabled(L.PUMP))
+ log.debug("Pump time difference: " + timeDiff + " seconds");
if (Math.abs(timeDiff) > 10) {
mSerialIOThread.sendMessage(new MsgSetTime(new Date()));
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
- log.debug("Pump time difference: " + timeDiff + " seconds");
+ if (L.isEnabled(L.PUMP))
+ log.debug("Pump time difference: " + timeDiff + " seconds");
}
mDanaRPump.lastSettingsRead = now;
}
@@ -214,8 +209,9 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
MainApp.bus().post(new EventInitializationChanged());
NSUpload.uploadDeviceStatus();
if (mDanaRPump.dailyTotalUnits > mDanaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) {
- log.debug("Approaching daily limit: " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits);
- if(System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) {
+ if (L.isEnabled(L.PUMP))
+ log.debug("Approaching daily limit: " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits);
+ if (System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) {
Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.gs(R.string.approachingdailylimit), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(reportFail));
NSUpload.uploadError(MainApp.gs(R.string.approachingdailylimit) + ": " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits + "U");
@@ -300,7 +296,8 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
if ((System.currentTimeMillis() - progress.lastReceive) > 15 * 1000L) { // if i didn't receive status for more than 15 sec expecting broken comm
stop.stopped = true;
stop.forced = true;
- log.debug("Communication stopped");
+ if (L.isEnabled(L.PUMP))
+ log.debug("Communication stopped");
}
}
SystemClock.sleep(300);
@@ -332,7 +329,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
public boolean updateBasalsInPump(final Profile profile) {
if (!isConnected()) return false;
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.updatingbasalrates)));
- double[] basal = DanaRPump.buildDanaRProfileRecord(profile);
+ double[] basal = DanaRPump.getInstance().buildDanaRProfileRecord(profile);
MsgSetSingleBasalProfile msgSet = new MsgSetSingleBasalProfile(basal);
mSerialIOThread.sendMessage(msgSet);
mDanaRPump.lastSettingsRead = 0; // force read full settings
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java
index 36edf1e94f..ae314f77a7 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java
@@ -20,7 +20,6 @@ import org.slf4j.LoggerFactory;
import java.util.Date;
import info.nightscout.androidaps.BuildConfig;
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.DetailedBolusInfo;
@@ -39,6 +38,7 @@ import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.ProfileInterface;
import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.interfaces.PumpInterface;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
import info.nightscout.androidaps.plugins.ConfigBuilder.DetailedBolusInfoStorage;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
@@ -64,7 +64,7 @@ import info.nightscout.utils.T;
*/
public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInterface, ConstraintsInterface, ProfileInterface {
- private static Logger log = LoggerFactory.getLogger(DanaRSPlugin.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMP);
private static DanaRSPlugin plugin = null;
public static DanaRSPlugin getPlugin() {
@@ -155,7 +155,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
@Override
public void switchAllowed(ConfigBuilderFragment.PluginViewHolder.PluginSwitcher pluginSwitcher, FragmentActivity context) {
boolean allowHardwarePump = SP.getBoolean("allow_hardware_pump", false);
- if (allowHardwarePump || context == null){
+ if (allowHardwarePump || context == null) {
pluginSwitcher.invoke();
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
@@ -164,13 +164,15 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
public void onClick(DialogInterface dialog, int id) {
pluginSwitcher.invoke();
SP.putBoolean("allow_hardware_pump", true);
- log.debug("First time HW pump allowed!");
+ if (L.isEnabled(L.PUMP))
+ log.debug("First time HW pump allowed!");
}
})
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
pluginSwitcher.cancel();
- log.debug("User does not allow switching to HW pump!");
+ if (L.isEnabled(L.PUMP))
+ log.debug("User does not allow switching to HW pump!");
}
});
builder.create().show();
@@ -180,12 +182,14 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
private ServiceConnection mConnection = new ServiceConnection() {
public void onServiceDisconnected(ComponentName name) {
- log.debug("Service is disconnected");
+ if (L.isEnabled(L.PUMP))
+ log.debug("Service is disconnected");
danaRSService = null;
}
public void onServiceConnected(ComponentName name, IBinder service) {
- log.debug("Service is connected");
+ if (L.isEnabled(L.PUMP))
+ log.debug("Service is connected");
DanaRSService.LocalBinder mLocalBinder = (DanaRSService.LocalBinder) service;
danaRSService = mLocalBinder.getServiceInstance();
}
@@ -205,7 +209,8 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
@Override
public void connect(String from) {
- log.debug("RS connect from: " + from);
+ if (L.isEnabled(L.PUMP))
+ log.debug("RS connect from: " + from);
if (danaRSService != null && !mDeviceAddress.equals("") && !mDeviceName.equals("")) {
final Object o = new Object();
@@ -225,6 +230,8 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
@Override
public void disconnect(String from) {
+ if (L.isEnabled(L.PUMP))
+ log.debug("RS disconnect from: " + from);
if (danaRSService != null) danaRSService.disconnect(from);
}
@@ -370,7 +377,8 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
Double profileValue = profile.getBasalTimeFromMidnight((Integer) (h * basalIncrement));
if (profileValue == null) return true;
if (Math.abs(pumpValue - profileValue) > getPumpDescription().basalStep) {
- log.debug("Diff found. Hour: " + h + " Pump: " + pumpValue + " Profile: " + profileValue);
+ if (L.isEnabled(L.PUMP))
+ log.debug("Diff found. Hour: " + h + " Pump: " + pumpValue + " Profile: " + profileValue);
return false;
}
}
@@ -430,7 +438,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
result.comment = String.format(MainApp.gs(R.string.boluserrorcode), detailedBolusInfo.insulin, t.insulin, DanaRS_Packet_Bolus_Set_Step_Bolus_Start.errorCode);
else
result.comment = MainApp.gs(R.string.virtualpump_resultok);
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered);
return result;
} else {
@@ -474,7 +482,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
if (doTempOff) {
// If temp in progress
if (TreatmentsPlugin.getPlugin().isTempBasalInProgress()) {
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: Stopping temp basal (doTempOff)");
return cancelTempBasal(false);
}
@@ -483,7 +491,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
result.percent = 100;
result.isPercent = true;
result.isTempCancel = true;
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: doTempOff OK");
return result;
}
@@ -497,7 +505,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
// Check if some temp is already in progress
TemporaryBasal activeTemp = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(System.currentTimeMillis());
if (activeTemp != null) {
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: currently running: " + activeTemp.toString());
// Correct basal already set ?
if (activeTemp.percentRate == percentRate) {
@@ -508,14 +516,14 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
result.duration = activeTemp.getPlannedRemainingMinutes();
result.isPercent = true;
result.isTempCancel = false;
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: Correct temp basal already set (doLowTemp || doHighTemp)");
return result;
}
}
}
// Convert duration from minutes to hours
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: Setting temp basal " + percentRate + "% for " + durationInMinutes + " mins (doLowTemp || doHighTemp)");
if (percentRate == 0 && durationInMinutes > 30) {
result = setTempBasalPercent(percentRate, durationInMinutes, profile, false);
@@ -527,7 +535,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
log.error("setTempBasalAbsolute: Failed to set hightemp basal");
return result;
}
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: hightemp basal set ok");
return result;
}
@@ -562,7 +570,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
result.duration = pump.tempBasalRemainingMin;
result.percent = pump.tempBasalPercent;
result.isPercent = true;
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setTempBasalPercent: Correct value already set");
return result;
}
@@ -581,7 +589,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
result.duration = pump.tempBasalRemainingMin;
result.percent = pump.tempBasalPercent;
result.isPercent = true;
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setTempBasalPercent: OK");
return result;
}
@@ -603,7 +611,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
result.duration = pump.tempBasalRemainingMin;
result.percent = pump.tempBasalPercent;
result.isPercent = true;
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setHighTempBasalPercent: OK");
return result;
}
@@ -630,7 +638,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
result.absolute = pump.extendedBolusAbsoluteRate;
result.isPercent = false;
result.isTempCancel = false;
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setExtendedBolus: Correct extended bolus already set. Current: " + pump.extendedBolusAmount + " Asked: " + insulin);
return result;
}
@@ -644,7 +652,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
result.absolute = pump.extendedBolusAbsoluteRate;
result.bolusDelivered = pump.extendedBolusAmount;
result.isPercent = false;
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setExtendedBolus: OK");
return result;
}
@@ -668,7 +676,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
result.success = true;
result.isTempCancel = true;
result.comment = MainApp.gs(R.string.virtualpump_resultok);
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("cancelRealTempBasal: OK");
return result;
} else {
@@ -692,7 +700,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
if (!pump.isExtendedInProgress) {
result.success = true;
result.comment = MainApp.gs(R.string.virtualpump_resultok);
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("cancelExtendedBolus: OK");
return result;
} else {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/activities/BLEScanActivity.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/activities/BLEScanActivity.java
index 3b6bcaf099..7594e917c5 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/activities/BLEScanActivity.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/activities/BLEScanActivity.java
@@ -31,9 +31,6 @@ import info.nightscout.androidaps.plugins.PumpDanaRS.events.EventDanaRSDeviceCha
import info.nightscout.utils.SP;
public class BLEScanActivity extends AppCompatActivity {
- private static Logger log = LoggerFactory.getLogger(BLEScanActivity.class);
-
-
private ListView listView = null;
private ListAdapter mListAdapter = null;
private ArrayList mDevices = new ArrayList<>();
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/activities/PairingProgressDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/activities/PairingProgressDialog.java
index 9f72e1d08f..5f339cd528 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/activities/PairingProgressDialog.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/activities/PairingProgressDialog.java
@@ -9,7 +9,6 @@ import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.view.Window;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;
@@ -63,46 +62,37 @@ public class PairingProgressDialog extends DialogFragment implements View.OnClic
button.setOnClickListener(this);
setCancelable(false);
- sHandler.post(new Runnable() {
- @Override
- public void run() {
- for (int i = 0; i < 20; i++) {
- if (pairingEnded) {
- Activity activity = getActivity();
- if (activity != null) {
- activity.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- progressBar.setProgress(100);
- statusView.setText(R.string.pairingok);
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- }
- dismiss();
- }
- });
- } else
- dismiss();
- return;
- }
- progressBar.setProgress(i * 5);
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- }
- }
- Activity activity = getActivity();
- if (activity != null) {
- activity.runOnUiThread(new Runnable() {
- @Override
- public void run() {
+ sHandler.post(() -> {
+ for (int i = 0; i < 20; i++) {
+ if (pairingEnded) {
+ Activity activity = getActivity();
+ if (activity != null) {
+ activity.runOnUiThread(() -> {
progressBar.setProgress(100);
- statusView.setText(R.string.pairingtimedout);
- button.setVisibility(View.VISIBLE);
- }
- });
+ statusView.setText(R.string.pairingok);
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException ignored) {
+ }
+ dismiss();
+ });
+ } else
+ dismiss();
+ return;
}
+ progressBar.setProgress(i * 5);
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException ignored) {
+ }
+ }
+ Activity activity = getActivity();
+ if (activity != null) {
+ activity.runOnUiThread(() -> {
+ progressBar.setProgress(100);
+ statusView.setText(R.string.pairingtimedout);
+ button.setVisibility(View.VISIBLE);
+ });
}
});
return view;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRSMessageHashTable.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRSMessageHashTable.java
index 5457bb4155..bda5d42207 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRSMessageHashTable.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRSMessageHashTable.java
@@ -1,25 +1,17 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.util.HashMap;
-import info.nightscout.androidaps.Config;
+import info.nightscout.androidaps.logging.L;
/**
* Created by mike on 28.05.2016.
*/
public class DanaRSMessageHashTable {
- private static Logger log = LoggerFactory.getLogger(DanaRSMessageHashTable.class);
-
public static HashMap messages = null;
static {
if (messages == null) {
- boolean savedState = Config.logDanaMessageDetail;
- Config.logDanaMessageDetail = false;
-
messages = new HashMap<>();
put(new DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal());
put(new DanaRS_Packet_Basal_Get_Basal_Rate());
@@ -89,7 +81,6 @@ public class DanaRSMessageHashTable {
put(new DanaRS_Packet_APS_History_Events());
put(new DanaRS_Packet_APS_Set_Event_History());
- Config.logDanaMessageDetail = savedState;
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.java
index 5da3655ceb..c33cd7b405 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.java
@@ -5,10 +5,10 @@ import com.cozmo.danar.util.BleCommandUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
+import info.nightscout.androidaps.logging.L;
public class DanaRS_Packet_APS_Basal_Set_Temporary_Basal extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_APS_Basal_Set_Temporary_Basal.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
int temporaryBasalRatio;
int temporaryBasalDuration;
@@ -25,6 +25,8 @@ public class DanaRS_Packet_APS_Basal_Set_Temporary_Basal extends DanaRS_Packet {
public DanaRS_Packet_APS_Basal_Set_Temporary_Basal(int percent) {
this();
setParams(percent);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message: percent: " + percent);
}
protected void setParams(int percent) {
@@ -35,16 +37,16 @@ public class DanaRS_Packet_APS_Basal_Set_Temporary_Basal extends DanaRS_Packet {
temporaryBasalRatio = percent;
if (percent < 100) {
temporaryBasalDuration = PARAM30MIN;
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("APS Temp basal start percent: " + percent + " duration 30 min");
} else {
temporaryBasalDuration = PARAM15MIN;
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("APS Temp basal start percent: " + percent + " duration 15 min");
}
}
- public DanaRS_Packet_APS_Basal_Set_Temporary_Basal(int percent, boolean fifteenMinutes, boolean thirtyMinutes ) {
+ public DanaRS_Packet_APS_Basal_Set_Temporary_Basal(int percent, boolean fifteenMinutes, boolean thirtyMinutes) {
this();
setParams(percent, fifteenMinutes, thirtyMinutes);
}
@@ -57,11 +59,11 @@ public class DanaRS_Packet_APS_Basal_Set_Temporary_Basal extends DanaRS_Packet {
temporaryBasalRatio = percent;
if (thirtyMinutes && percent <= 200) { // 30 min is allowed up to 200%
temporaryBasalDuration = PARAM30MIN;
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("APS Temp basal start percent: " + percent + " duration 30 min");
} else {
temporaryBasalDuration = PARAM15MIN;
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("APS Temp basal start percent: " + percent + " duration 15 min");
}
}
@@ -80,10 +82,11 @@ public class DanaRS_Packet_APS_Basal_Set_Temporary_Basal extends DanaRS_Packet {
int result = byteArrayToInt(getBytes(data, DATA_START, 1));
if (result != 0) {
failed = true;
- log.error("Set APS temp basal start result: " + result + " FAILED!!!");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("Set APS temp basal start result: " + result + " FAILED!!!");
} else {
failed = false;
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Set APS temp basal start result: " + result);
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_History_Events.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_History_Events.java
index b8c8aaf2b4..60e640bc77 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_History_Events.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_History_Events.java
@@ -16,13 +16,14 @@ import info.nightscout.androidaps.db.ExtendedBolus;
import info.nightscout.androidaps.db.Source;
import info.nightscout.androidaps.db.TemporaryBasal;
import info.nightscout.androidaps.events.EventPumpStatusChanged;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.DetailedBolusInfoStorage;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.utils.DateUtil;
public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_APS_History_Events.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
private int year = 0;
private int month = 0;
@@ -32,7 +33,6 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet {
private int sec = 0;
public static boolean done;
- private static int totalCount;
public static long lastEventTimeLoaded = 0;
@@ -40,7 +40,6 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet {
super();
opCode = BleCommandUtil.DANAR_PACKET__OPCODE__APS_HISTORY_EVENTS;
done = false;
- totalCount = 0;
}
public DanaRS_Packet_APS_History_Events(long from) {
@@ -56,7 +55,8 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet {
hour = cal.get(Calendar.HOUR_OF_DAY);
min = cal.get(Calendar.MINUTE);
sec = cal.get(Calendar.SECOND);
- log.debug("Loading event history from: " + new Date(cal.getTimeInMillis()).toLocaleString());
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("Loading event history from: " + new Date(cal.getTimeInMillis()).toLocaleString());
}
@Override
@@ -78,7 +78,8 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet {
// Last record
if (recordCode == (byte) 0xFF) {
done = true;
- log.debug("Last record received");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("Last record received");
return;
}
@@ -95,10 +96,12 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet {
DetailedBolusInfo detailedBolusInfo = DetailedBolusInfoStorage.findDetailedBolusInfo(datetime.getTime());
if (detailedBolusInfo == null) {
- log.debug("Detailed bolus info not found for " + datetime.toLocaleString());
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("Detailed bolus info not found for " + datetime.toLocaleString());
detailedBolusInfo = new DetailedBolusInfo();
} else {
- log.debug("Detailed bolus info found: " + detailedBolusInfo);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("Detailed bolus info found: " + detailedBolusInfo);
}
detailedBolusInfo.date = datetime.getTime();
detailedBolusInfo.source = Source.PUMP;
@@ -108,73 +111,86 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet {
switch (recordCode) {
case DanaRPump.TEMPSTART:
- log.debug("EVENT TEMPSTART (" + recordCode + ") " + datetime.toLocaleString() + " Ratio: " + param1 + "% Duration: " + param2 + "min");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("EVENT TEMPSTART (" + recordCode + ") " + datetime.toLocaleString() + " Ratio: " + param1 + "% Duration: " + param2 + "min");
temporaryBasal.percentRate = param1;
temporaryBasal.durationInMinutes = param2;
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(temporaryBasal);
status = "TEMPSTART " + DateUtil.timeString(datetime);
break;
case DanaRPump.TEMPSTOP:
- log.debug("EVENT TEMPSTOP (" + recordCode + ") " + datetime.toLocaleString());
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("EVENT TEMPSTOP (" + recordCode + ") " + datetime.toLocaleString());
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(temporaryBasal);
status = "TEMPSTOP " + DateUtil.timeString(datetime);
break;
case DanaRPump.EXTENDEDSTART:
- log.debug("EVENT EXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("EVENT EXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min");
extendedBolus.insulin = param1 / 100d;
extendedBolus.durationInMinutes = param2;
TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus);
status = "EXTENDEDSTART " + DateUtil.timeString(datetime);
break;
case DanaRPump.EXTENDEDSTOP:
- log.debug("EVENT EXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("EVENT EXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min");
TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus);
status = "EXTENDEDSTOP " + DateUtil.timeString(datetime);
break;
case DanaRPump.BOLUS:
detailedBolusInfo.insulin = param1 / 100d;
boolean newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false);
- log.debug((newRecord ? "**NEW** " : "") + "EVENT BOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug((newRecord ? "**NEW** " : "") + "EVENT BOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min");
DetailedBolusInfoStorage.remove(detailedBolusInfo.date);
status = "BOLUS " + DateUtil.timeString(datetime);
break;
case DanaRPump.DUALBOLUS:
detailedBolusInfo.insulin = param1 / 100d;
newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false);
- log.debug((newRecord ? "**NEW** " : "") + "EVENT DUALBOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug((newRecord ? "**NEW** " : "") + "EVENT DUALBOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min");
DetailedBolusInfoStorage.remove(detailedBolusInfo.date);
status = "DUALBOLUS " + DateUtil.timeString(datetime);
break;
case DanaRPump.DUALEXTENDEDSTART:
- log.debug("EVENT DUALEXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("EVENT DUALEXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min");
extendedBolus.insulin = param1 / 100d;
extendedBolus.durationInMinutes = param2;
TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus);
status = "DUALEXTENDEDSTART " + DateUtil.timeString(datetime);
break;
case DanaRPump.DUALEXTENDEDSTOP:
- log.debug("EVENT DUALEXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("EVENT DUALEXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min");
TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus);
status = "DUALEXTENDEDSTOP " + DateUtil.timeString(datetime);
break;
case DanaRPump.SUSPENDON:
- log.debug("EVENT SUSPENDON (" + recordCode + ") " + datetime.toLocaleString());
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("EVENT SUSPENDON (" + recordCode + ") " + datetime.toLocaleString());
status = "SUSPENDON " + DateUtil.timeString(datetime);
break;
case DanaRPump.SUSPENDOFF:
- log.debug("EVENT SUSPENDOFF (" + recordCode + ") " + datetime.toLocaleString());
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("EVENT SUSPENDOFF (" + recordCode + ") " + datetime.toLocaleString());
status = "SUSPENDOFF " + DateUtil.timeString(datetime);
break;
case DanaRPump.REFILL:
- log.debug("EVENT REFILL (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("EVENT REFILL (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U");
status = "REFILL " + DateUtil.timeString(datetime);
break;
case DanaRPump.PRIME:
- log.debug("EVENT PRIME (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("EVENT PRIME (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U");
status = "PRIME " + DateUtil.timeString(datetime);
break;
case DanaRPump.PROFILECHANGE:
- log.debug("EVENT PROFILECHANGE (" + recordCode + ") " + datetime.toLocaleString() + " No: " + param1 + " CurrentRate: " + (param2 / 100d) + "U/h");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("EVENT PROFILECHANGE (" + recordCode + ") " + datetime.toLocaleString() + " No: " + param1 + " CurrentRate: " + (param2 / 100d) + "U/h");
status = "PROFILECHANGE " + DateUtil.timeString(datetime);
break;
case DanaRPump.CARBS:
@@ -184,15 +200,18 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet {
emptyCarbsInfo.source = Source.PUMP;
emptyCarbsInfo.pumpId = datetime.getTime();
newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(emptyCarbsInfo, false);
- log.debug((newRecord ? "**NEW** " : "") + "EVENT CARBS (" + recordCode + ") " + datetime.toLocaleString() + " Carbs: " + param1 + "g");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug((newRecord ? "**NEW** " : "") + "EVENT CARBS (" + recordCode + ") " + datetime.toLocaleString() + " Carbs: " + param1 + "g");
status = "CARBS " + DateUtil.timeString(datetime);
break;
case DanaRPump.PRIMECANNULA:
- log.debug("EVENT PRIMECANNULA(" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("EVENT PRIMECANNULA(" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U");
status = "PRIMECANNULA " + DateUtil.timeString(datetime);
break;
default:
- log.debug("Event: " + recordCode + " " + datetime.toLocaleString() + " Param1: " + param1 + " Param2: " + param2);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("Event: " + recordCode + " " + datetime.toLocaleString() + " Param1: " + param1 + " Param2: " + param2);
status = "UNKNOWN " + DateUtil.timeString(datetime);
break;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Set_Event_History.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Set_Event_History.java
index 84ead83665..2a5e9eade6 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Set_Event_History.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Set_Event_History.java
@@ -8,16 +8,16 @@ import org.slf4j.LoggerFactory;
import java.util.Calendar;
import java.util.GregorianCalendar;
-import info.nightscout.androidaps.Config;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.utils.DateUtil;
public class DanaRS_Packet_APS_Set_Event_History extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_APS_Set_Event_History.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
private int type;
private long time;
- public int param1;
- public int param2;
+ private int param1;
+ private int param2;
public DanaRS_Packet_APS_Set_Event_History() {
super();
@@ -31,7 +31,7 @@ public class DanaRS_Packet_APS_Set_Event_History extends DanaRS_Packet {
this.time = time;
this.param1 = param1;
this.param2 = param2;
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Set history entry: " + DateUtil.dateAndTimeString(time) + " type: " + type + " param1: " + param1 + " param2: " + param2);
}
@@ -66,9 +66,10 @@ public class DanaRS_Packet_APS_Set_Event_History extends DanaRS_Packet {
int result = intFromBuff(data, 0, 1);
if (result != 0) {
failed = true;
- log.error("Set history entry result: " + result + " FAILED!!!");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.error("Set history entry result: " + result + " FAILED!!!");
} else {
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Set history entry result: " + result);
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Basal_Rate.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Basal_Rate.java
index f3fef0d49d..a067d2976d 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Basal_Rate.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Basal_Rate.java
@@ -1,27 +1,27 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
+import com.cozmo.danar.util.BleCommandUtil;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
-import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
+import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
-import com.cozmo.danar.util.BleCommandUtil;
-
public class DanaRS_Packet_Basal_Get_Basal_Rate extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public DanaRS_Packet_Basal_Get_Basal_Rate() {
super();
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__GET_BASAL_RATE;
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Requesting basal rates");
}
}
@@ -45,7 +45,7 @@ public class DanaRS_Packet_Basal_Get_Basal_Rate extends DanaRS_Packet {
dataSize = 2;
pump.pumpProfiles[pump.activeProfile][i] = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d;
}
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Max basal: " + pump.maxBasal + " U");
log.debug("Basal step: " + pump.basalStep + " U");
for (int index = 0; index < 24; index++)
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Profile_Basal_Rate.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Profile_Basal_Rate.java
index 8eadb8298d..8cc73ac3a6 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Profile_Basal_Rate.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Profile_Basal_Rate.java
@@ -1,14 +1,15 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
+import com.cozmo.danar.util.BleCommandUtil;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-import com.cozmo.danar.util.BleCommandUtil;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
public class DanaRS_Packet_Basal_Get_Profile_Basal_Rate extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Basal_Get_Profile_Basal_Rate.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
private int profileNumber;
@@ -21,7 +22,7 @@ public class DanaRS_Packet_Basal_Get_Profile_Basal_Rate extends DanaRS_Packet {
public DanaRS_Packet_Basal_Get_Profile_Basal_Rate(int profileNumber) {
this();
this.profileNumber = profileNumber;
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Requesting basal rates for profile " + profileNumber);
}
}
@@ -47,7 +48,7 @@ public class DanaRS_Packet_Basal_Get_Profile_Basal_Rate extends DanaRS_Packet {
dataIndex += dataSize;
dataSize = 2;
}
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
for (int index = 0; index < 24; index++)
log.debug("Basal " + String.format("%02d", index) + "h: " + pump.pumpProfiles[profileNumber][index]);
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Profile_Number.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Profile_Number.java
index 39e230a29e..1beadfd705 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Profile_Number.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Profile_Number.java
@@ -1,19 +1,20 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
+import com.cozmo.danar.util.BleCommandUtil;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-import com.cozmo.danar.util.BleCommandUtil;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
public class DanaRS_Packet_Basal_Get_Profile_Number extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Basal_Get_Profile_Number.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public DanaRS_Packet_Basal_Get_Profile_Number() {
super();
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__GET_PROFILE_NUMBER;
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Requesting active profile");
}
}
@@ -25,7 +26,7 @@ public class DanaRS_Packet_Basal_Get_Profile_Number extends DanaRS_Packet {
int dataIndex = DATA_START;
int dataSize = 1;
pump.activeProfile = byteArrayToInt(getBytes(data, dataIndex, dataSize));
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Active profile: " + pump.activeProfile);
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_State.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_State.java
index dbf917874d..c6f434d1ba 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_State.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_State.java
@@ -2,22 +2,23 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
import android.support.annotation.NonNull;
+import com.cozmo.danar.util.BleCommandUtil;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Date;
-import info.nightscout.androidaps.Config;
-import com.cozmo.danar.util.BleCommandUtil;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
public class DanaRS_Packet_Basal_Get_Temporary_Basal_State extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Basal_Get_Temporary_Basal_State.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public DanaRS_Packet_Basal_Get_Temporary_Basal_State() {
super();
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__TEMPORARY_BASAL_STATE;
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Requesting temporary basal status");
}
}
@@ -53,7 +54,7 @@ public class DanaRS_Packet_Basal_Get_Temporary_Basal_State extends DanaRS_Packet
int tempBasalRemainingMin = (pump.tempBasalTotalSec - runningMin * 60) / 60;
Date tempBasalStart = pump.isTempBasalInProgress ? getDateFromTempBasalSecAgo(runningMin * 60) : new Date(0);
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Error code: " + error);
log.debug("Is temp basal running: " + pump.isTempBasalInProgress);
log.debug("Is APS temp basal running: " + isAPSTempBasalInProgress);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Basal_Rate.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Basal_Rate.java
index a64da24bf3..19b53ba53c 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Basal_Rate.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Basal_Rate.java
@@ -3,12 +3,12 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
+import info.nightscout.androidaps.logging.L;
import com.cozmo.danar.util.BleCommandUtil;
public class DanaRS_Packet_Basal_Set_Basal_Rate extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Basal_Set_Basal_Rate.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
private double[] profileBasalRate;
@@ -20,7 +20,7 @@ public class DanaRS_Packet_Basal_Set_Basal_Rate extends DanaRS_Packet {
public DanaRS_Packet_Basal_Set_Basal_Rate(double[] profileBasalRate) {
this();
this.profileBasalRate = profileBasalRate;
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Setting new basal rates");
}
}
@@ -39,7 +39,7 @@ public class DanaRS_Packet_Basal_Set_Basal_Rate extends DanaRS_Packet {
@Override
public void handleMessage(byte[] data) {
int result = intFromBuff(data, 0, 1);
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
if (result == 0)
log.debug("Result OK");
else
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.java
index 538750a45b..e8a288a258 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.java
@@ -1,19 +1,19 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
+import com.cozmo.danar.util.BleCommandUtil;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-
-import com.cozmo.danar.util.BleCommandUtil;
+import info.nightscout.androidaps.logging.L;
public class DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal() {
super();
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__CANCEL_TEMPORARY_BASAL;
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Canceling temp basal");
}
}
@@ -21,7 +21,7 @@ public class DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal extends DanaRS_Packe
@Override
public void handleMessage(byte[] data) {
int result = intFromBuff(data, 0, 1);
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
if (result == 0)
log.debug("Result OK");
else
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_Rate.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_Rate.java
index 66d0e7b4bb..004e9d69b2 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_Rate.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_Rate.java
@@ -1,13 +1,14 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
+import com.cozmo.danar.util.BleCommandUtil;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-import com.cozmo.danar.util.BleCommandUtil;
+import info.nightscout.androidaps.logging.L;
public class DanaRS_Packet_Basal_Set_Profile_Basal_Rate extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Basal_Set_Profile_Basal_Rate.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
private int profileNumber; // 0 - 4
private double[] profileBasalRate;
@@ -21,7 +22,7 @@ public class DanaRS_Packet_Basal_Set_Profile_Basal_Rate extends DanaRS_Packet {
this();
this.profileNumber = profileNumber;
this.profileBasalRate = profileBasalRate;
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Setting new basal rates for profile " + profileNumber);
}
}
@@ -41,7 +42,7 @@ public class DanaRS_Packet_Basal_Set_Profile_Basal_Rate extends DanaRS_Packet {
@Override
public void handleMessage(byte[] data) {
int result = intFromBuff(data, 0, 1);
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
if (result == 0)
log.debug("Result OK");
else
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Profile_Number.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Profile_Number.java
index 69f7eae8dd..613c3d6f8b 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Profile_Number.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Profile_Number.java
@@ -1,48 +1,49 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
+import com.cozmo.danar.util.BleCommandUtil;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-
-import com.cozmo.danar.util.BleCommandUtil;
+import info.nightscout.androidaps.logging.L;
public class DanaRS_Packet_Basal_Set_Profile_Number extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Basal_Set_Profile_Number.class);
- private int profileNumber;
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
+ private int profileNumber;
- public DanaRS_Packet_Basal_Set_Profile_Number() {
+ public DanaRS_Packet_Basal_Set_Profile_Number() {
super();
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__SET_PROFILE_NUMBER;
}
- public DanaRS_Packet_Basal_Set_Profile_Number(int profileNumber) {
- this();
- this.profileNumber = profileNumber;
- if (Config.logDanaMessageDetail) {
- log.debug("Setting profile number " + profileNumber);
- }
- }
- @Override
- public byte[] getRequestParams() {
- byte[] request = new byte[1];
- request[0] = (byte) (profileNumber & 0xff);
- return request;
- }
+ public DanaRS_Packet_Basal_Set_Profile_Number(int profileNumber) {
+ this();
+ this.profileNumber = profileNumber;
+ if (L.isEnabled(L.PUMPCOMM)) {
+ log.debug("Setting profile number " + profileNumber);
+ }
+ }
@Override
- public void handleMessage(byte[] data) {
- int result = intFromBuff(data, 0, 1);
- if (Config.logDanaMessageDetail) {
- if (result == 0)
- log.debug("Result OK");
- else
- log.error("Result Error: " + result);
- }
- }
+ public byte[] getRequestParams() {
+ byte[] request = new byte[1];
+ request[0] = (byte) (profileNumber & 0xff);
+ return request;
+ }
- @Override
- public String getFriendlyName() {
- return "BASAL__SET_PROFILE_NUMBER";
- }
+ @Override
+ public void handleMessage(byte[] data) {
+ int result = intFromBuff(data, 0, 1);
+ if (L.isEnabled(L.PUMPCOMM)) {
+ if (result == 0)
+ log.debug("Result OK");
+ else
+ log.error("Result Error: " + result);
+ }
+ }
+
+ @Override
+ public String getFriendlyName() {
+ return "BASAL__SET_PROFILE_NUMBER";
+ }
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Suspend_Off.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Suspend_Off.java
index 4c78038162..2c4c46eb2e 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Suspend_Off.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Suspend_Off.java
@@ -1,18 +1,19 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
+import com.cozmo.danar.util.BleCommandUtil;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-import com.cozmo.danar.util.BleCommandUtil;
+import info.nightscout.androidaps.logging.L;
public class DanaRS_Packet_Basal_Set_Suspend_Off extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Basal_Set_Suspend_Off.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public DanaRS_Packet_Basal_Set_Suspend_Off() {
super();
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__SET_SUSPEND_OFF;
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Turning off suspend");
}
}
@@ -20,7 +21,7 @@ public class DanaRS_Packet_Basal_Set_Suspend_Off extends DanaRS_Packet {
@Override
public void handleMessage(byte[] data) {
int result = intFromBuff(data, 0, 1);
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
if (result == 0)
log.debug("Result OK");
else
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Suspend_On.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Suspend_On.java
index 75a2a5fada..25d55968a9 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Suspend_On.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Suspend_On.java
@@ -1,18 +1,19 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
+import com.cozmo.danar.util.BleCommandUtil;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-import com.cozmo.danar.util.BleCommandUtil;
+import info.nightscout.androidaps.logging.L;
public class DanaRS_Packet_Basal_Set_Suspend_On extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Basal_Set_Suspend_On.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public DanaRS_Packet_Basal_Set_Suspend_On() {
super();
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__SET_SUSPEND_ON;
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Turning on suspend");
}
}
@@ -20,7 +21,7 @@ public class DanaRS_Packet_Basal_Set_Suspend_On extends DanaRS_Packet {
@Override
public void handleMessage(byte[] data) {
int result = intFromBuff(data, 0, 1);
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
if (result == 0)
log.debug("Result OK");
else
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Temporary_Basal.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Temporary_Basal.java
index d2f68ff864..15de10f742 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Temporary_Basal.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Temporary_Basal.java
@@ -1,13 +1,14 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
+import com.cozmo.danar.util.BleCommandUtil;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-import com.cozmo.danar.util.BleCommandUtil;
+import info.nightscout.androidaps.logging.L;
public class DanaRS_Packet_Basal_Set_Temporary_Basal extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Basal_Set_Temporary_Basal.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
private int temporaryBasalRatio;
private int temporaryBasalDuration;
@@ -21,7 +22,7 @@ public class DanaRS_Packet_Basal_Set_Temporary_Basal extends DanaRS_Packet {
this();
this.temporaryBasalRatio = temporaryBasalRatio;
this.temporaryBasalDuration = temporaryBasalDuration;
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Setting temporary basal of " + temporaryBasalRatio + "% for " + temporaryBasalDuration + " hours");
}
}
@@ -37,7 +38,7 @@ public class DanaRS_Packet_Basal_Set_Temporary_Basal extends DanaRS_Packet {
@Override
public void handleMessage(byte[] data) {
int result = intFromBuff(data, 0, 1);
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
if (result == 0)
log.debug("Result OK");
else
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_Option.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_Option.java
index 69c2f75ba6..e2c5d5fae6 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_Option.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_Option.java
@@ -1,24 +1,26 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
+import com.cozmo.danar.util.BleCommandUtil;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-import com.cozmo.danar.util.BleCommandUtil;
-
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
-import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
+import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
public class DanaRS_Packet_Bolus_Get_Bolus_Option extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Bolus_Get_Bolus_Option.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public DanaRS_Packet_Bolus_Get_Bolus_Option() {
super();
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_BOLUS_OPTION;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
@@ -108,7 +110,7 @@ public class DanaRS_Packet_Bolus_Get_Bolus_Option extends DanaRS_Packet {
MainApp.bus().post(new EventDismissNotification(Notification.EXTENDED_BOLUS_DISABLED));
}
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Extended bolus enabled: " + pump.isExtendedBolusEnabled);
log.debug("Missed bolus config: " + pump.missedBolusConfig);
log.debug("missedBolus01StartHour: " + missedBolus01StartHour);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_CIR_CF_Array.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_CIR_CF_Array.java
index b8a86cc078..2a834806f6 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_CIR_CF_Array.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_CIR_CF_Array.java
@@ -1,21 +1,22 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
+import com.cozmo.danar.util.BleCommandUtil;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-
-import com.cozmo.danar.util.BleCommandUtil;
-
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
public class DanaRS_Packet_Bolus_Get_CIR_CF_Array extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Bolus_Get_CIR_CF_Array.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public DanaRS_Packet_Bolus_Get_CIR_CF_Array() {
super();
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_CIR_CF_ARRAY;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
@@ -118,7 +119,7 @@ public class DanaRS_Packet_Bolus_Get_CIR_CF_Array extends DanaRS_Packet {
pump.nightCF = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d;
}
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Language: " + language);
log.debug("Pump units: " + (pump.units == DanaRPump.UNITS_MGDL ? "MGDL" : "MMOL"));
log.debug("Current pump morning CIR: " + pump.morningCIR);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Calculation_Information.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Calculation_Information.java
index f5acedf3ba..67768df866 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Calculation_Information.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Calculation_Information.java
@@ -1,20 +1,21 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
+import com.cozmo.danar.util.BleCommandUtil;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-
-import com.cozmo.danar.util.BleCommandUtil;
-
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
public class DanaRS_Packet_Bolus_Get_Calculation_Information extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Bolus_Get_Calculation_Information.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public DanaRS_Packet_Bolus_Get_Calculation_Information() {
super();
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_CALCULATION_INFORMATION;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
@@ -58,7 +59,7 @@ public class DanaRS_Packet_Bolus_Get_Calculation_Information extends DanaRS_Pack
pump.currentTarget = pump.currentTarget / 100d;
currentBG = currentBG / 100d;
}
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Result: " + error);
log.debug("Pump units: " + (pump.units == DanaRPump.UNITS_MGDL ? "MGDL" : "MMOL"));
log.debug("Current BG: " + currentBG);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information.java
index c581320c54..ba93dde999 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information.java
@@ -1,20 +1,21 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
+import com.cozmo.danar.util.BleCommandUtil;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-
-import com.cozmo.danar.util.BleCommandUtil;
-
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
public class DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information() {
super();
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_CARBOHYDRATE_CALCULATION_INFORMATION;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
@@ -33,7 +34,7 @@ public class DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information extend
dataSize = 2;
pump.currentCIR = byteArrayToInt(getBytes(data, dataIndex, dataSize));
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Result: " + error);
log.debug("Carbs: " + carbs);
log.debug("Current CIR: " + pump.currentCIR);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Dual_Bolus.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Dual_Bolus.java
index bd7a0b9ee6..230a9d2480 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Dual_Bolus.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Dual_Bolus.java
@@ -1,18 +1,21 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
+import com.cozmo.danar.util.BleCommandUtil;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-import com.cozmo.danar.util.BleCommandUtil;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
public class DanaRS_Packet_Bolus_Get_Dual_Bolus extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Bolus_Get_Dual_Bolus.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public DanaRS_Packet_Bolus_Get_Dual_Bolus() {
super();
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_DUAL_BOLUS;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
@@ -39,7 +42,7 @@ public class DanaRS_Packet_Bolus_Get_Dual_Bolus extends DanaRS_Packet {
dataSize = 1;
double bolusIncrement = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d;
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Result: " + error);
log.debug("Bolus step: " + pump.bolusStep + " U");
log.debug("Extended bolus running: " + pump.extendedBolusAbsoluteRate + " U/h");
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus.java
index 682d9b14bb..695f21c0a1 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus.java
@@ -1,20 +1,21 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
+import com.cozmo.danar.util.BleCommandUtil;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-
-import com.cozmo.danar.util.BleCommandUtil;
-
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
public class DanaRS_Packet_Bolus_Get_Extended_Bolus extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Bolus_Get_Extended_Bolus.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public DanaRS_Packet_Bolus_Get_Extended_Bolus() {
super();
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_EXTENDED_BOLUS;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
@@ -37,7 +38,7 @@ public class DanaRS_Packet_Bolus_Get_Extended_Bolus extends DanaRS_Packet {
dataSize = 1;
pump.bolusStep = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d;
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Result: " + error);
log.debug("Extended bolus running: " + pump.extendedBolusAbsoluteRate + " U/h");
log.debug("Max bolus: " + pump.maxBolus + " U");
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus_State.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus_State.java
index b22a9dfb47..95c96ea322 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus_State.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus_State.java
@@ -1,20 +1,21 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
+import com.cozmo.danar.util.BleCommandUtil;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-
-import com.cozmo.danar.util.BleCommandUtil;
-
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
public class DanaRS_Packet_Bolus_Get_Extended_Bolus_State extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Bolus_Get_Extended_Bolus_State.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public DanaRS_Packet_Bolus_Get_Extended_Bolus_State() {
super();
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_EXTENDED_BOLUS_STATE;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
@@ -45,7 +46,7 @@ public class DanaRS_Packet_Bolus_Get_Extended_Bolus_State extends DanaRS_Packet
dataSize = 2;
pump.extendedBolusDeliveredSoFar = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d;
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Result: " + error);
log.debug("Is extended bolus running: " + pump.isExtendedInProgress);
log.debug("Extended bolus running: " + pump.extendedBolusAbsoluteRate + " U/h");
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State.java
index 5a7ca55e30..fda8778d08 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State.java
@@ -1,20 +1,21 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
+import com.cozmo.danar.util.BleCommandUtil;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-
-import com.cozmo.danar.util.BleCommandUtil;
-
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
public class DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State() {
super();
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_EXTENDED_MENU_OPTION_STATE;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
@@ -29,7 +30,7 @@ public class DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State extends DanaRS_P
dataSize = 1;
pump.isExtendedInProgress = byteArrayToInt(getBytes(data, dataIndex, dataSize)) == 0x01;
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("extendedMenuOption: " + extendedMenuOption);
log.debug("Is extended bolus running: " + pump.isExtendedInProgress);
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Initial_Bolus.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Initial_Bolus.java
index 58fa4674ad..d52bd50ea1 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Initial_Bolus.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Initial_Bolus.java
@@ -1,17 +1,20 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
+import com.cozmo.danar.util.BleCommandUtil;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-import com.cozmo.danar.util.BleCommandUtil;
+import info.nightscout.androidaps.logging.L;
public class DanaRS_Packet_Bolus_Get_Initial_Bolus extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Bolus_Get_Initial_Bolus.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public DanaRS_Packet_Bolus_Get_Initial_Bolus() {
super();
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_BOLUS_RATE;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
@@ -31,7 +34,7 @@ public class DanaRS_Packet_Bolus_Get_Initial_Bolus extends DanaRS_Packet {
dataIndex += dataSize;
dataSize = 2;
double initialBolusValue04 = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d;
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Initial bolus amount 01: " + initialBolusValue01);
log.debug("Initial bolus amount 02: " + initialBolusValue02);
log.debug("Initial bolus amount 03: " + initialBolusValue03);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_Information.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_Information.java
index 6166f7b0fb..ce38e0ba28 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_Information.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_Information.java
@@ -1,20 +1,23 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
+import com.cozmo.danar.util.BleCommandUtil;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Date;
-import info.nightscout.androidaps.Config;
-import com.cozmo.danar.util.BleCommandUtil;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
public class DanaRS_Packet_Bolus_Get_Step_Bolus_Information extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Bolus_Get_Step_Bolus_Information.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public DanaRS_Packet_Bolus_Get_Step_Bolus_Information() {
super();
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_STEP_BOLUS_INFORMATION;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
@@ -54,7 +57,7 @@ public class DanaRS_Packet_Bolus_Get_Step_Bolus_Information extends DanaRS_Packe
dataSize = 1;
pump.bolusStep = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d;
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Result: " + error);
log.debug("BolusType: " + bolusType);
log.debug("Initial bolus amount: " + pump.initialBolusAmount + " U");
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_Option.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_Option.java
index 103bac3ecf..4f53ba9632 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_Option.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_Option.java
@@ -1,13 +1,14 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
+import com.cozmo.danar.util.BleCommandUtil;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-import com.cozmo.danar.util.BleCommandUtil;
+import info.nightscout.androidaps.logging.L;
public class DanaRS_Packet_Bolus_Set_Bolus_Option extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Bolus_Set_Bolus_Option.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
private int extendedBolusOptionOnOff;
private int bolusCalculationOption;
@@ -75,7 +76,7 @@ public class DanaRS_Packet_Bolus_Set_Bolus_Option extends DanaRS_Packet {
this.missedBolus04EndHour = missedBolus04EndHour;
this.missedBolus04EndMin = missedBolus04EndMin;
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Setting bolus options");
}
}
@@ -112,7 +113,7 @@ public class DanaRS_Packet_Bolus_Set_Bolus_Option extends DanaRS_Packet {
@Override
public void handleMessage(byte[] data) {
int result = intFromBuff(data, 0, 1);
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
if (result == 0)
log.debug("Result OK");
else
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_Array.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_Array.java
index 062ae00712..23581d4d0c 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_Array.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_Array.java
@@ -1,13 +1,14 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
+import com.cozmo.danar.util.BleCommandUtil;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-import com.cozmo.danar.util.BleCommandUtil;
+import info.nightscout.androidaps.logging.L;
public class DanaRS_Packet_Bolus_Set_CIR_CF_Array extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Bolus_Set_CIR_CF_Array.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
private int cir01;
private int cir02;
@@ -45,6 +46,8 @@ public class DanaRS_Packet_Bolus_Set_CIR_CF_Array extends DanaRS_Packet {
this.cf05 = cf05;
this.cf06 = cf06;
this.cf07 = cf07;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
@@ -84,7 +87,7 @@ public class DanaRS_Packet_Bolus_Set_CIR_CF_Array extends DanaRS_Packet {
@Override
public void handleMessage(byte[] data) {
int result = intFromBuff(data, 0, 1);
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
if (result == 0)
log.debug("Result OK");
else
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Dual_Bolus.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Dual_Bolus.java
index e769bea195..8953ce020e 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Dual_Bolus.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Dual_Bolus.java
@@ -1,13 +1,14 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
+import com.cozmo.danar.util.BleCommandUtil;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-import com.cozmo.danar.util.BleCommandUtil;
+import info.nightscout.androidaps.logging.L;
public class DanaRS_Packet_Bolus_Set_Dual_Bolus extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Bolus_Set_Dual_Bolus.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
private double amount;
private double extendedAmount;
@@ -24,7 +25,7 @@ public class DanaRS_Packet_Bolus_Set_Dual_Bolus extends DanaRS_Packet {
this.extendedAmount = extendedAmount;
this.extendedBolusDurationInHalfHours = extendedBolusDurationInHalfHours;
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Dual bolus start : " + amount + " U extended: " + extendedAmount + " U halfhours: " + extendedBolusDurationInHalfHours);
}
@@ -45,7 +46,7 @@ public class DanaRS_Packet_Bolus_Set_Dual_Bolus extends DanaRS_Packet {
@Override
public void handleMessage(byte[] data) {
int result = intFromBuff(data, 0, 1);
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
if (result == 0)
log.debug("Result OK");
else
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus.java
index 887a9d852a..fb899b73d6 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus.java
@@ -1,14 +1,14 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
+import com.cozmo.danar.util.BleCommandUtil;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-
-import com.cozmo.danar.util.BleCommandUtil;
+import info.nightscout.androidaps.logging.L;
public class DanaRS_Packet_Bolus_Set_Extended_Bolus extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Bolus_Set_Extended_Bolus.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
private double extendedAmount;
private int extendedBolusDurationInHalfHours;
@@ -23,7 +23,7 @@ public class DanaRS_Packet_Bolus_Set_Extended_Bolus extends DanaRS_Packet {
this.extendedAmount = extendedAmount;
this.extendedBolusDurationInHalfHours = extendedBolusDurationInHalfHours;
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Extended bolus start : " + extendedAmount + " U halfhours: " + extendedBolusDurationInHalfHours);
}
@@ -41,7 +41,7 @@ public class DanaRS_Packet_Bolus_Set_Extended_Bolus extends DanaRS_Packet {
@Override
public void handleMessage(byte[] data) {
int result = intFromBuff(data, 0, 1);
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
if (result == 0)
log.debug("Result OK");
else
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel.java
index 132de649cf..ab887c0fab 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel.java
@@ -1,26 +1,27 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
+import com.cozmo.danar.util.BleCommandUtil;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-import com.cozmo.danar.util.BleCommandUtil;
+import info.nightscout.androidaps.logging.L;
public class DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel() {
super();
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__SET_EXTENDED_BOLUS_CANCEL;
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Cancel extended bolus");
}
@Override
public void handleMessage(byte[] data) {
int result = intFromBuff(data, 0, 1);
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
if (result == 0)
log.debug("Result OK");
else
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Initial_Bolus.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Initial_Bolus.java
index a174d39b53..faaf505293 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Initial_Bolus.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Initial_Bolus.java
@@ -1,14 +1,14 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
+import com.cozmo.danar.util.BleCommandUtil;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-
-import com.cozmo.danar.util.BleCommandUtil;
+import info.nightscout.androidaps.logging.L;
public class DanaRS_Packet_Bolus_Set_Initial_Bolus extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Bolus_Set_Initial_Bolus.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
private int bolusRate01;
private int bolusRate02;
@@ -26,6 +26,8 @@ public class DanaRS_Packet_Bolus_Set_Initial_Bolus extends DanaRS_Packet {
this.bolusRate02 = (int) (bolusRate02 / 100d);
this.bolusRate03 = (int) (bolusRate03 / 100d);
this.bolusRate04 = (int) (bolusRate04 / 100d);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
@@ -45,7 +47,7 @@ public class DanaRS_Packet_Bolus_Set_Initial_Bolus extends DanaRS_Packet {
@Override
public void handleMessage(byte[] data) {
int result = intFromBuff(data, 0, 1);
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
if (result == 0)
log.debug("Result OK");
else
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.java
index 44e5d308dc..2d423eb7ef 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.java
@@ -5,14 +5,12 @@ import com.cozmo.danar.util.BleCommandUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
-import info.nightscout.androidaps.R;
import info.nightscout.androidaps.interfaces.Constraint;
-import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
+import info.nightscout.androidaps.logging.L;
public class DanaRS_Packet_Bolus_Set_Step_Bolus_Start extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Bolus_Set_Step_Bolus_Start.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
private double amount;
private int speed;
@@ -35,7 +33,7 @@ public class DanaRS_Packet_Bolus_Set_Step_Bolus_Start extends DanaRS_Packet {
this.amount = amount;
this.speed = speed;
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Bolus start : " + amount + " speed: " + speed);
}
@@ -52,7 +50,7 @@ public class DanaRS_Packet_Bolus_Set_Step_Bolus_Start extends DanaRS_Packet {
@Override
public void handleMessage(byte[] data) {
errorCode = intFromBuff(data, 0, 1);
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
if (errorCode == 0) {
log.debug("Result OK");
failed = false;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.java
index 78548ecab3..eef9afe0e5 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.java
@@ -3,17 +3,17 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import com.cozmo.danar.util.BleCommandUtil;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Treatments.Treatment;
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
public class DanaRS_Packet_Bolus_Set_Step_Bolus_Stop extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
private static Treatment t;
private static Double amount;
@@ -31,12 +31,14 @@ public class DanaRS_Packet_Bolus_Set_Step_Bolus_Stop extends DanaRS_Packet {
this.amount = amount;
forced = false;
stopped = false;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("Stop bolus: amount: " + amount + " treatment: " + t.toString());
}
@Override
public void handleMessage(byte[] data) {
int result = intFromBuff(data, 0, 1);
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
if (result == 0)
log.debug("Result OK");
else
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Etc_Keep_Connection.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Etc_Keep_Connection.java
index d30be3abf8..071ca66410 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Etc_Keep_Connection.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Etc_Keep_Connection.java
@@ -3,16 +3,18 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
+import info.nightscout.androidaps.logging.L;
import com.cozmo.danar.util.BleCommandUtil;
public class DanaRS_Packet_Etc_Keep_Connection extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Etc_Keep_Connection.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public DanaRS_Packet_Etc_Keep_Connection() {
super();
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_ETC__KEEP_CONNECTION;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
@@ -20,7 +22,7 @@ public class DanaRS_Packet_Etc_Keep_Connection extends DanaRS_Packet {
int dataIndex = DATA_START;
int dataSize = 1;
int error = byteArrayToInt(getBytes(data, dataIndex, dataSize));
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Result: " + error);
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Etc_Set_History_Save.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Etc_Set_History_Save.java
index 6538b77932..a7ace37421 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Etc_Set_History_Save.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Etc_Set_History_Save.java
@@ -3,12 +3,12 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
+import info.nightscout.androidaps.logging.L;
import com.cozmo.danar.util.BleCommandUtil;
public class DanaRS_Packet_Etc_Set_History_Save extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Etc_Set_History_Save.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
private int historyType;
private int historyYear;
@@ -36,6 +36,8 @@ public class DanaRS_Packet_Etc_Set_History_Save extends DanaRS_Packet {
this.historySecond = historySecond;
this.historyCode = historyCode;
this.historyValue = historyValue;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
@@ -59,7 +61,7 @@ public class DanaRS_Packet_Etc_Set_History_Save extends DanaRS_Packet {
int dataIndex = DATA_START;
int dataSize = 1;
int error = byteArrayToInt(getBytes(data, dataIndex, dataSize));
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Result: " + error);
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Delivery_Status.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Delivery_Status.java
index d9e2599eb2..f505f9c619 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Delivery_Status.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Delivery_Status.java
@@ -1,18 +1,20 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
+import com.cozmo.danar.util.BleCommandUtil;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-
-import com.cozmo.danar.util.BleCommandUtil;
+import info.nightscout.androidaps.logging.L;
public class DanaRS_Packet_General_Delivery_Status extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_General_Delivery_Status.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public DanaRS_Packet_General_Delivery_Status() {
super();
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__DELIVERY_STATUS;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
@@ -20,7 +22,7 @@ public class DanaRS_Packet_General_Delivery_Status extends DanaRS_Packet {
int dataIndex = DATA_START;
int dataSize = 1;
int status = byteArrayToInt(getBytes(data, dataIndex, dataSize));
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Status: " + status);
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_More_Information.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_More_Information.java
index cd2de4094f..24bfc4b8a7 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_More_Information.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_More_Information.java
@@ -1,45 +1,48 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
+import com.cozmo.danar.util.BleCommandUtil;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Date;
-import info.nightscout.androidaps.Config;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
-import com.cozmo.danar.util.BleCommandUtil;
public class DanaRS_Packet_General_Get_More_Information extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_General_Get_More_Information.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
- public DanaRS_Packet_General_Get_More_Information() {
- super();
- opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__GET_MORE_INFORMATION;
- }
+ public DanaRS_Packet_General_Get_More_Information() {
+ super();
+ opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__GET_MORE_INFORMATION;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
+ }
- @Override
- public void handleMessage(byte[] data) {
- DanaRPump pump = DanaRPump.getInstance();
+ @Override
+ public void handleMessage(byte[] data) {
+ DanaRPump pump = DanaRPump.getInstance();
- int dataIndex = DATA_START;
- int dataSize = 2;
- pump.iob = byteArrayToInt(getBytes(data, dataIndex, dataSize));
+ int dataIndex = DATA_START;
+ int dataSize = 2;
+ pump.iob = byteArrayToInt(getBytes(data, dataIndex, dataSize));
- dataIndex += dataSize;
- dataSize = 2;
- pump.dailyTotalUnits = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d;
+ dataIndex += dataSize;
+ dataSize = 2;
+ pump.dailyTotalUnits = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d;
- dataIndex += dataSize;
- dataSize = 1;
- pump.isExtendedInProgress = byteArrayToInt(getBytes(data, dataIndex, dataSize)) == 0x01;
+ dataIndex += dataSize;
+ dataSize = 1;
+ pump.isExtendedInProgress = byteArrayToInt(getBytes(data, dataIndex, dataSize)) == 0x01;
- dataIndex += dataSize;
- dataSize = 2;
- pump.extendedBolusRemainingMinutes = byteArrayToInt(getBytes(data, dataIndex, dataSize));
+ dataIndex += dataSize;
+ dataSize = 2;
+ pump.extendedBolusRemainingMinutes = byteArrayToInt(getBytes(data, dataIndex, dataSize));
- dataIndex += dataSize;
- dataSize = 2;
- double remainRate = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d;
+ dataIndex += dataSize;
+ dataSize = 2;
+ double remainRate = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d;
Date lastBolusTime = new Date(); // it doesn't provide day only hour+min, workaround: expecting today
dataIndex += dataSize;
@@ -50,21 +53,21 @@ public class DanaRS_Packet_General_Get_More_Information extends DanaRS_Packet {
dataSize = 1;
lastBolusTime.setMinutes(byteArrayToInt(getBytes(data, dataIndex, dataSize)));
- dataIndex += dataSize;
- dataSize = 2;
- pump.lastBolusAmount = byteArrayToInt(getBytes(data, dataIndex, dataSize));
+ dataIndex += dataSize;
+ dataSize = 2;
+ pump.lastBolusAmount = byteArrayToInt(getBytes(data, dataIndex, dataSize));
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Daily total units: " + pump.dailyTotalUnits + " U");
log.debug("Is extended in progress: " + pump.isExtendedInProgress);
log.debug("Extended bolus remaining minutes: " + pump.extendedBolusRemainingMinutes);
log.debug("Last bolus time: " + lastBolusTime.toLocaleString());
log.debug("Last bolus amount: " + pump.lastBolusAmount);
}
- }
+ }
- @Override
- public String getFriendlyName() {
- return "REVIEW__GET_MORE_INFORMATION";
- }
+ @Override
+ public String getFriendlyName() {
+ return "REVIEW__GET_MORE_INFORMATION";
+ }
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Password.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Password.java
index 0d250db919..276653ff0f 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Password.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Password.java
@@ -1,20 +1,21 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
+import com.cozmo.danar.util.BleCommandUtil;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-
-import com.cozmo.danar.util.BleCommandUtil;
-
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
public class DanaRS_Packet_General_Get_Password extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_General_Get_Password.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public DanaRS_Packet_General_Get_Password() {
super();
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__GET_PASSWORD;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
@@ -24,7 +25,7 @@ public class DanaRS_Packet_General_Get_Password extends DanaRS_Packet {
int pass = ((data[DATA_START + 1] & 0x000000FF) << 8) + (data[DATA_START + 0] & 0x000000FF);
pass = pass ^ 3463;
pump.rs_password = Integer.toHexString(pass);
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Pump password: " + pump.rs_password);
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Pump_Check.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Pump_Check.java
index bdc5ab8d9b..618ea29ed0 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Pump_Check.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Pump_Check.java
@@ -5,19 +5,21 @@ import com.cozmo.danar.util.BleCommandUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
public class DanaRS_Packet_General_Get_Pump_Check extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_General_Get_Pump_Check.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public DanaRS_Packet_General_Get_Pump_Check() {
super();
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__GET_PUMP_CHECK;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
@@ -36,7 +38,7 @@ public class DanaRS_Packet_General_Get_Pump_Check extends DanaRS_Packet {
dataSize = 1;
pump.productCode = byteArrayToInt(getBytes(data, dataIndex, dataSize));
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Model: " + String.format("%02X ", pump.model));
log.debug("Protocol: " + String.format("%02X ", pump.protocol));
log.debug("Product Code: " + String.format("%02X ", pump.productCode));
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Shipping_Information.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Shipping_Information.java
index 2cf9b1f124..fe7f9b40ed 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Shipping_Information.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Shipping_Information.java
@@ -1,46 +1,48 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
+import com.cozmo.danar.util.BleCommandUtil;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
-import com.cozmo.danar.util.BleCommandUtil;
-
public class DanaRS_Packet_General_Get_Shipping_Information extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
- public DanaRS_Packet_General_Get_Shipping_Information() {
- super();
- opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__GET_SHIPPING_INFORMATION;
- }
+ public DanaRS_Packet_General_Get_Shipping_Information() {
+ super();
+ opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__GET_SHIPPING_INFORMATION;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
+ }
- @Override
- public void handleMessage(byte[] data) {
- DanaRPump pump = DanaRPump.getInstance();
+ @Override
+ public void handleMessage(byte[] data) {
+ DanaRPump pump = DanaRPump.getInstance();
- int dataIndex = DATA_START;
- int dataSize = 10;
- pump.serialNumber = stringFromBuff(data, dataIndex, dataSize);
+ int dataIndex = DATA_START;
+ int dataSize = 10;
+ pump.serialNumber = stringFromBuff(data, dataIndex, dataSize);
- dataIndex += dataSize;
- dataSize = 3;
- pump.shippingDate = dateFromBuff(data, dataIndex);
+ dataIndex += dataSize;
+ dataSize = 3;
+ pump.shippingDate = dateFromBuff(data, dataIndex);
- dataIndex += dataSize;
- dataSize = 3;
- pump.shippingCountry = asciiStringFromBuff(data, dataIndex, dataSize);
+ dataIndex += dataSize;
+ dataSize = 3;
+ pump.shippingCountry = asciiStringFromBuff(data, dataIndex, dataSize);
- if (Config.logDanaMessageDetail) {
- log.debug("Serial number: " + pump.serialNumber);
- log.debug("Shipping date: " + pump.shippingDate);
- log.debug("Shipping country: " + pump.shippingCountry);
- }
- }
+ if (L.isEnabled(L.PUMPCOMM)) {
+ log.debug("Serial number: " + pump.serialNumber);
+ log.debug("Shipping date: " + pump.shippingDate);
+ log.debug("Shipping country: " + pump.shippingCountry);
+ }
+ }
- @Override
- public String getFriendlyName() {
- return "REVIEW__GET_SHIPPING_INFORMATION";
- }
+ @Override
+ public String getFriendlyName() {
+ return "REVIEW__GET_SHIPPING_INFORMATION";
+ }
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Today_Delivery_Total.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Today_Delivery_Total.java
index a40d572611..aa686aaa05 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Today_Delivery_Total.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Today_Delivery_Total.java
@@ -1,47 +1,48 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
+import com.cozmo.danar.util.BleCommandUtil;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-
-import com.cozmo.danar.util.BleCommandUtil;
-
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
public class DanaRS_Packet_General_Get_Today_Delivery_Total extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_General_Get_Today_Delivery_Total.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
- public DanaRS_Packet_General_Get_Today_Delivery_Total() {
- super();
- opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__GET_TODAY_DELIVERY_TOTAL;
- }
+ public DanaRS_Packet_General_Get_Today_Delivery_Total() {
+ super();
+ opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__GET_TODAY_DELIVERY_TOTAL;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
+ }
- @Override
- public void handleMessage(byte[] data) {
- DanaRPump pump = DanaRPump.getInstance();
+ @Override
+ public void handleMessage(byte[] data) {
+ DanaRPump pump = DanaRPump.getInstance();
- int dataIndex = DATA_START;
- int dataSize = 2;
- pump.dailyTotalUnits = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d;
+ int dataIndex = DATA_START;
+ int dataSize = 2;
+ pump.dailyTotalUnits = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d;
- dataIndex += dataSize;
- dataSize = 2;
- pump.dailyTotalBasalUnits = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d;
+ dataIndex += dataSize;
+ dataSize = 2;
+ pump.dailyTotalBasalUnits = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d;
- dataIndex += dataSize;
- dataSize = 2;
- pump.dailyTotalBolusUnits = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d;
+ dataIndex += dataSize;
+ dataSize = 2;
+ pump.dailyTotalBolusUnits = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d;
- if (Config.logDanaMessageDetail) {
- log.debug("Daily total: " + pump.dailyTotalUnits + " U");
- log.debug("Daily total bolus: " + pump.dailyTotalBolusUnits + " U");
- log.debug("Daily total basal: " + pump.dailyTotalBasalUnits + " U");
- }
- }
+ if (L.isEnabled(L.PUMPCOMM)) {
+ log.debug("Daily total: " + pump.dailyTotalUnits + " U");
+ log.debug("Daily total bolus: " + pump.dailyTotalBolusUnits + " U");
+ log.debug("Daily total basal: " + pump.dailyTotalBasalUnits + " U");
+ }
+ }
- @Override
- public String getFriendlyName() {
- return "REVIEW__GET_TODAY_DELIVERY_TOTAL";
- }
+ @Override
+ public String getFriendlyName() {
+ return "REVIEW__GET_TODAY_DELIVERY_TOTAL";
+ }
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_User_Time_Change_Flag.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_User_Time_Change_Flag.java
index 695e3eace4..156c5acc4f 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_User_Time_Change_Flag.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_User_Time_Change_Flag.java
@@ -1,17 +1,20 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
+import com.cozmo.danar.util.BleCommandUtil;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-import com.cozmo.danar.util.BleCommandUtil;
+import info.nightscout.androidaps.logging.L;
public class DanaRS_Packet_General_Get_User_Time_Change_Flag extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_General_Get_User_Time_Change_Flag.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public DanaRS_Packet_General_Get_User_Time_Change_Flag() {
super();
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__GET_USER_TIME_CHANGE_FLAG;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
@@ -20,7 +23,7 @@ public class DanaRS_Packet_General_Get_User_Time_Change_Flag extends DanaRS_Pack
int dataSize = 1;
int userTimeChangeFlag = byteArrayToInt(getBytes(data, dataIndex, dataSize));
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("UserTimeChangeFlag: " + userTimeChangeFlag);
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Initial_Screen_Information.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Initial_Screen_Information.java
index d05777d20d..6b8f569c6d 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Initial_Screen_Information.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Initial_Screen_Information.java
@@ -1,21 +1,22 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
+import com.cozmo.danar.util.BleCommandUtil;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-
-import com.cozmo.danar.util.BleCommandUtil;
-
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
public class DanaRS_Packet_General_Initial_Screen_Information extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Bolus_Get_Step_Bolus_Information.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public DanaRS_Packet_General_Initial_Screen_Information() {
super();
type = BleCommandUtil.DANAR_PACKET__TYPE_RESPONSE;
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__INITIAL_SCREEN_INFORMATION;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
@@ -63,7 +64,7 @@ public class DanaRS_Packet_General_Initial_Screen_Information extends DanaRS_Pac
dataSize = 2;
pump.iob = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d;
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Pump suspended: " + pump.pumpSuspended);
log.debug("Temp basal in progress: " + pump.isTempBasalInProgress);
log.debug("Extended in progress: " + pump.isExtendedInProgress);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Set_History_Upload_Mode.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Set_History_Upload_Mode.java
index 878cfd64dd..cd5a843336 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Set_History_Upload_Mode.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Set_History_Upload_Mode.java
@@ -1,13 +1,14 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
+import com.cozmo.danar.util.BleCommandUtil;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-import com.cozmo.danar.util.BleCommandUtil;
+import info.nightscout.androidaps.logging.L;
public class DanaRS_Packet_General_Set_History_Upload_Mode extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_General_Set_History_Upload_Mode.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
private int mode;
@@ -19,6 +20,8 @@ public class DanaRS_Packet_General_Set_History_Upload_Mode extends DanaRS_Packet
public DanaRS_Packet_General_Set_History_Upload_Mode(int mode) {
this();
this.mode = mode;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message: mode: " + mode);
}
@Override
@@ -32,7 +35,7 @@ public class DanaRS_Packet_General_Set_History_Upload_Mode extends DanaRS_Packet
@Override
public void handleMessage(byte[] data) {
int result = intFromBuff(data, 0, 1);
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
if (result == 0)
log.debug("Result OK");
else
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear.java
index 3917f31050..07403d6908 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear.java
@@ -1,24 +1,26 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
+import com.cozmo.danar.util.BleCommandUtil;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-
-import com.cozmo.danar.util.BleCommandUtil;
+import info.nightscout.androidaps.logging.L;
public class DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear() {
super();
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__SET_USER_TIME_CHANGE_FLAG_CLEAR;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
public void handleMessage(byte[] data) {
int result = intFromBuff(data, 0, 1);
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
if (result == 0)
log.debug("Result OK");
else
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_.java
index 6bae4ab8c1..70fece9864 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_.java
@@ -1,7 +1,5 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
-import com.cozmo.danar.util.BleCommandUtil;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -11,12 +9,13 @@ import java.util.GregorianCalendar;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.db.DanaRHistoryRecord;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes;
import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRSyncStatus;
import info.nightscout.utils.DateUtil;
public abstract class DanaRS_Packet_History_ extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_History_.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
private int year = 0;
private int month = 0;
@@ -47,7 +46,8 @@ public abstract class DanaRS_Packet_History_ extends DanaRS_Packet {
hour = cal.get(Calendar.HOUR_OF_DAY);
min = cal.get(Calendar.MINUTE);
sec = cal.get(Calendar.SECOND);
- log.debug("Loading event history from: " + new Date(cal.getTimeInMillis()).toLocaleString());
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("Loading event history from: " + new Date(cal.getTimeInMillis()).toLocaleString());
}
@Override
@@ -71,7 +71,8 @@ public abstract class DanaRS_Packet_History_ extends DanaRS_Packet {
int dataSize = 1;
error = byteArrayToInt(getBytes(data, dataIndex, dataSize));
done = true;
- log.debug("History end. Code: " + error + " Success: " + (error == 0x00));
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("History end. Code: " + error + " Success: " + (error == 0x00));
} else if (data.length == 5) {
int dataIndex = DATA_START;
int dataSize = 1;
@@ -81,11 +82,12 @@ public abstract class DanaRS_Packet_History_ extends DanaRS_Packet {
dataIndex += dataSize;
dataSize = 2;
totalCount = byteArrayToInt(getBytes(data, dataIndex, dataSize));
- log.debug("History end. Code: " + error + " Success: " + (error == 0x00) + " Toatal count: " + totalCount);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("History end. Code: " + error + " Success: " + (error == 0x00) + " Toatal count: " + totalCount);
} else {
int recordCode = byteArrayToInt(getBytes(data, DATA_START, 1));
int historyYear = byteArrayToInt(getBytes(data, DATA_START + 1, 1));
- int historyMonth = byteArrayToInt(getBytes(data, DATA_START +2 , 1));
+ int historyMonth = byteArrayToInt(getBytes(data, DATA_START + 2, 1));
int historyDay = byteArrayToInt(getBytes(data, DATA_START + 3, 1));
int historyHour = byteArrayToInt(getBytes(data, DATA_START + 4, 1));
double dailyBasal = (((data[DATA_START + 4] & 0xFF) << 8) + (data[DATA_START + 5] & 0xFF)) * 0.01d;
@@ -103,7 +105,8 @@ public abstract class DanaRS_Packet_History_ extends DanaRS_Packet {
int value = ((data[DATA_START + 8] & 0xFF) << 8) + (data[DATA_START + 9] & 0xFF);
- log.debug("History packet: " + recordCode + " Date: " + datetimewihtsec.toLocaleString() + " Code: " + historyCode + " Value: " + value);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("History packet: " + recordCode + " Date: " + datetimewihtsec.toLocaleString() + " Code: " + historyCode + " Value: " + value);
EventDanaRSyncStatus ev = new EventDanaRSyncStatus();
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Alarm.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Alarm.java
index 5fe57fefe4..541091954f 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Alarm.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Alarm.java
@@ -1,10 +1,16 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
-import java.util.Date;
-
import com.cozmo.danar.util.BleCommandUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Date;
+
+import info.nightscout.androidaps.logging.L;
+
public class DanaRS_Packet_History_Alarm extends DanaRS_Packet_History_ {
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public DanaRS_Packet_History_Alarm() {
super();
@@ -14,6 +20,8 @@ public class DanaRS_Packet_History_Alarm extends DanaRS_Packet_History_ {
public DanaRS_Packet_History_Alarm(Date from) {
super(from);
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__ALARM;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_All_History.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_All_History.java
index a514d4eac7..1bf2bd302a 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_All_History.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_All_History.java
@@ -1,10 +1,16 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
-import java.util.Date;
-
import com.cozmo.danar.util.BleCommandUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Date;
+
+import info.nightscout.androidaps.logging.L;
+
public class DanaRS_Packet_History_All_History extends DanaRS_Packet_History_ {
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public DanaRS_Packet_History_All_History() {
super();
@@ -14,6 +20,8 @@ public class DanaRS_Packet_History_All_History extends DanaRS_Packet_History_ {
public DanaRS_Packet_History_All_History(Date from) {
super(from);
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__ALL_HISTORY;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Basal.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Basal.java
index 4aec1d0352..917e3956f4 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Basal.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Basal.java
@@ -1,10 +1,16 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
-import java.util.Date;
-
import com.cozmo.danar.util.BleCommandUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Date;
+
+import info.nightscout.androidaps.logging.L;
+
public class DanaRS_Packet_History_Basal extends DanaRS_Packet_History_ {
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public DanaRS_Packet_History_Basal() {
super();
@@ -14,6 +20,8 @@ public class DanaRS_Packet_History_Basal extends DanaRS_Packet_History_ {
public DanaRS_Packet_History_Basal(Date from) {
super(from);
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BASAL;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Blood_Glucose.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Blood_Glucose.java
index 22bb3b5c2e..176d92b1fb 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Blood_Glucose.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Blood_Glucose.java
@@ -1,10 +1,16 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
-import java.util.Date;
-
import com.cozmo.danar.util.BleCommandUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Date;
+
+import info.nightscout.androidaps.logging.L;
+
public class DanaRS_Packet_History_Blood_Glucose extends DanaRS_Packet_History_ {
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public DanaRS_Packet_History_Blood_Glucose() {
super();
@@ -14,6 +20,8 @@ public class DanaRS_Packet_History_Blood_Glucose extends DanaRS_Packet_History_
public DanaRS_Packet_History_Blood_Glucose(Date from) {
super(from);
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BLOOD_GLUCOSE;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Bolus.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Bolus.java
index 7451f921be..e1b8ac1010 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Bolus.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Bolus.java
@@ -1,23 +1,31 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
-import java.util.Date;
-
import com.cozmo.danar.util.BleCommandUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Date;
+
+import info.nightscout.androidaps.logging.L;
+
public class DanaRS_Packet_History_Bolus extends DanaRS_Packet_History_ {
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
- public DanaRS_Packet_History_Bolus() {
- super();
- opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BOLUS;
- }
+ public DanaRS_Packet_History_Bolus() {
+ super();
+ opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BOLUS;
+ }
- public DanaRS_Packet_History_Bolus(Date from) {
- super(from);
- opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BOLUS;
- }
+ public DanaRS_Packet_History_Bolus(Date from) {
+ super(from);
+ opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BOLUS;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
+ }
- @Override
- public String getFriendlyName() {
- return "REVIEW__BOLUS";
- }
+ @Override
+ public String getFriendlyName() {
+ return "REVIEW__BOLUS";
+ }
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Carbohydrate.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Carbohydrate.java
index df2f5c762d..47a9b8fe11 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Carbohydrate.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Carbohydrate.java
@@ -1,23 +1,31 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
-import java.util.Date;
-
import com.cozmo.danar.util.BleCommandUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Date;
+
+import info.nightscout.androidaps.logging.L;
+
public class DanaRS_Packet_History_Carbohydrate extends DanaRS_Packet_History_ {
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
- public DanaRS_Packet_History_Carbohydrate() {
- super();
- opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__CARBOHYDRATE;
- }
+ public DanaRS_Packet_History_Carbohydrate() {
+ super();
+ opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__CARBOHYDRATE;
+ }
- public DanaRS_Packet_History_Carbohydrate(Date from) {
- super(from);
- opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__CARBOHYDRATE;
- }
+ public DanaRS_Packet_History_Carbohydrate(Date from) {
+ super(from);
+ opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__CARBOHYDRATE;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
+ }
- @Override
- public String getFriendlyName() {
- return "REVIEW__CARBOHYDRATE";
- }
+ @Override
+ public String getFriendlyName() {
+ return "REVIEW__CARBOHYDRATE";
+ }
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Daily.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Daily.java
index b55754ba2f..12b7abc35b 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Daily.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Daily.java
@@ -1,10 +1,16 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
-import java.util.Date;
-
import com.cozmo.danar.util.BleCommandUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Date;
+
+import info.nightscout.androidaps.logging.L;
+
public class DanaRS_Packet_History_Daily extends DanaRS_Packet_History_ {
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public DanaRS_Packet_History_Daily() {
super();
@@ -14,6 +20,8 @@ public class DanaRS_Packet_History_Daily extends DanaRS_Packet_History_ {
public DanaRS_Packet_History_Daily(Date from) {
super(from);
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__DAILY;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Prime.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Prime.java
index b5dbf7ff93..6a5de90813 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Prime.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Prime.java
@@ -1,10 +1,16 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
-import java.util.Date;
-
import com.cozmo.danar.util.BleCommandUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Date;
+
+import info.nightscout.androidaps.logging.L;
+
public class DanaRS_Packet_History_Prime extends DanaRS_Packet_History_ {
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public DanaRS_Packet_History_Prime() {
super();
@@ -14,6 +20,8 @@ public class DanaRS_Packet_History_Prime extends DanaRS_Packet_History_ {
public DanaRS_Packet_History_Prime(Date from) {
super(from);
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__PRIME;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Refill.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Refill.java
index 66094e3fb6..4566bb54b3 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Refill.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Refill.java
@@ -1,23 +1,31 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
-import java.util.Date;
-
import com.cozmo.danar.util.BleCommandUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Date;
+
+import info.nightscout.androidaps.logging.L;
+
public class DanaRS_Packet_History_Refill extends DanaRS_Packet_History_ {
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
- public DanaRS_Packet_History_Refill() {
- super();
- opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__REFILL;
- }
+ public DanaRS_Packet_History_Refill() {
+ super();
+ opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__REFILL;
+ }
- public DanaRS_Packet_History_Refill(Date from) {
- super(from);
- opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__REFILL;
- }
+ public DanaRS_Packet_History_Refill(Date from) {
+ super(from);
+ opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__REFILL;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
+ }
- @Override
- public String getFriendlyName() {
- return "REVIEW__REFILL";
- }
+ @Override
+ public String getFriendlyName() {
+ return "REVIEW__REFILL";
+ }
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Suspend.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Suspend.java
index 20f1c3d6ff..5d83f48a65 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Suspend.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Suspend.java
@@ -1,10 +1,16 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
-import java.util.Date;
-
import com.cozmo.danar.util.BleCommandUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Date;
+
+import info.nightscout.androidaps.logging.L;
+
public class DanaRS_Packet_History_Suspend extends DanaRS_Packet_History_ {
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public DanaRS_Packet_History_Suspend() {
super();
@@ -14,6 +20,8 @@ public class DanaRS_Packet_History_Suspend extends DanaRS_Packet_History_ {
public DanaRS_Packet_History_Suspend(Date from) {
super(from);
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__SUSPEND;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Temporary.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Temporary.java
index 7d63e1bfff..ce362574eb 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Temporary.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Temporary.java
@@ -1,10 +1,16 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
-import java.util.Date;
-
import com.cozmo.danar.util.BleCommandUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Date;
+
+import info.nightscout.androidaps.logging.L;
+
public class DanaRS_Packet_History_Temporary extends DanaRS_Packet_History_ {
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public DanaRS_Packet_History_Temporary() {
super();
@@ -14,6 +20,8 @@ public class DanaRS_Packet_History_Temporary extends DanaRS_Packet_History_ {
public DanaRS_Packet_History_Temporary(Date from) {
super(from);
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__TEMPORARY;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Alarm.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Alarm.java
index 04737f0bdc..58f362f1ad 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Alarm.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Alarm.java
@@ -1,18 +1,17 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
+import com.cozmo.danar.util.BleCommandUtil;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
-
-import com.cozmo.danar.util.BleCommandUtil;
-
-import info.nightscout.utils.NSUpload;
+import info.nightscout.androidaps.logging.L;
+import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
public class DanaRS_Packet_Notify_Alarm extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Notify_Alarm.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
private int alarmCode;
@@ -20,6 +19,8 @@ public class DanaRS_Packet_Notify_Alarm extends DanaRS_Packet {
super();
type = BleCommandUtil.DANAR_PACKET__TYPE_NOTIFY;
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_NOTIFY__ALARM;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
@@ -76,7 +77,7 @@ public class DanaRS_Packet_Notify_Alarm extends DanaRS_Packet {
break;
}
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Error detected: " + errorString);
NSUpload.uploadError(errorString);
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Delivery_Complete.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Delivery_Complete.java
index 2598c5efc9..836a52cb65 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Delivery_Complete.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Delivery_Complete.java
@@ -1,19 +1,18 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
+import com.cozmo.danar.util.BleCommandUtil;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
-
-import com.cozmo.danar.util.BleCommandUtil;
-
-import info.nightscout.androidaps.plugins.Treatments.Treatment;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
+import info.nightscout.androidaps.plugins.Treatments.Treatment;
public class DanaRS_Packet_Notify_Delivery_Complete extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Notify_Delivery_Complete.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
private static Treatment t;
private static double amount;
@@ -30,6 +29,8 @@ public class DanaRS_Packet_Notify_Delivery_Complete extends DanaRS_Packet {
this.amount = amount;
this.t = t;
done = false;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message: amount: " + amount + " treatment: " + t.toString());
}
@Override
@@ -46,7 +47,7 @@ public class DanaRS_Packet_Notify_Delivery_Complete extends DanaRS_Packet {
MainApp.bus().post(bolusingEvent);
}
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Delivered insulin: " + deliveredInsulin);
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_Display.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_Display.java
index 34621d07ee..30d7eeaf46 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_Display.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_Display.java
@@ -1,17 +1,18 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
+import com.cozmo.danar.util.BleCommandUtil;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
-import com.cozmo.danar.util.BleCommandUtil;
-import info.nightscout.androidaps.plugins.Treatments.Treatment;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
+import info.nightscout.androidaps.plugins.Treatments.Treatment;
public class DanaRS_Packet_Notify_Delivery_Rate_Display extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Notify_Delivery_Rate_Display.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
private static Treatment t;
private static double amount;
@@ -29,6 +30,8 @@ public class DanaRS_Packet_Notify_Delivery_Rate_Display extends DanaRS_Packet {
this.amount = amount;
this.t = t;
lastReceive = System.currentTimeMillis();
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message: amount: " + amount + " treatment: " + t.toString());
}
@Override
@@ -45,7 +48,7 @@ public class DanaRS_Packet_Notify_Delivery_Rate_Display extends DanaRS_Packet {
MainApp.bus().post(bolusingEvent);
}
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Delivered insulin so far: " + deliveredInsulin);
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Missed_Bolus_Alarm.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Missed_Bolus_Alarm.java
index 3af0c209b5..7110d8425c 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Missed_Bolus_Alarm.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Missed_Bolus_Alarm.java
@@ -1,19 +1,21 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
+import com.cozmo.danar.util.BleCommandUtil;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-
-import com.cozmo.danar.util.BleCommandUtil;
+import info.nightscout.androidaps.logging.L;
public class DanaRS_Packet_Notify_Missed_Bolus_Alarm extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Notify_Missed_Bolus_Alarm.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public DanaRS_Packet_Notify_Missed_Bolus_Alarm() {
super();
type = BleCommandUtil.DANAR_PACKET__TYPE_NOTIFY;
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_NOTIFY__MISSED_BOLUS_ALARM;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
@@ -38,7 +40,7 @@ public class DanaRS_Packet_Notify_Missed_Bolus_Alarm extends DanaRS_Packet {
dataIndex += dataSize;
dataSize = 1;
endMin = byteArrayToInt(getBytes(data, dataIndex, dataSize));
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Start hour: " + startHour);
log.debug("Start min: " + startMin);
log.debug("End hour: " + endHour);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Get_Pump_Time.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Get_Pump_Time.java
index 4bfebb5211..aacf859ef3 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Get_Pump_Time.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Get_Pump_Time.java
@@ -1,21 +1,22 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
+import com.cozmo.danar.util.BleCommandUtil;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Date;
-import info.nightscout.androidaps.Config;
-import com.cozmo.danar.util.BleCommandUtil;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
public class DanaRS_Packet_Option_Get_Pump_Time extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Option_Get_Pump_Time.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public DanaRS_Packet_Option_Get_Pump_Time() {
super();
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_OPTION__GET_PUMP_TIME;
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Requesting pump time");
}
}
@@ -49,7 +50,7 @@ public class DanaRS_Packet_Option_Get_Pump_Time extends DanaRS_Packet {
Date time = new Date(100 + year, month - 1, day, hour, min, sec);
DanaRPump.getInstance().pumpTime = time;
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Pump time " + time.toLocaleString());
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Get_User_Option.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Get_User_Option.java
index b4df373f9c..4873775e86 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Get_User_Option.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Get_User_Option.java
@@ -1,114 +1,115 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
+import com.cozmo.danar.util.BleCommandUtil;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
-import com.cozmo.danar.util.BleCommandUtil;
public class DanaRS_Packet_Option_Get_User_Option extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Option_Get_User_Option.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
- public DanaRS_Packet_Option_Get_User_Option() {
- super();
- opCode = BleCommandUtil.DANAR_PACKET__OPCODE_OPTION__GET_USER_OPTION;
- if (Config.logDanaMessageDetail) {
- log.debug("Requesting user settings");
- }
- }
+ public DanaRS_Packet_Option_Get_User_Option() {
+ super();
+ opCode = BleCommandUtil.DANAR_PACKET__OPCODE_OPTION__GET_USER_OPTION;
+ if (L.isEnabled(L.PUMPCOMM)) {
+ log.debug("Requesting user settings");
+ }
+ }
- @Override
- public void handleMessage(byte[] data) {
- DanaRPump pump = DanaRPump.getInstance();
+ @Override
+ public void handleMessage(byte[] data) {
+ DanaRPump pump = DanaRPump.getInstance();
- int dataIndex = DATA_START;
- int dataSize = 1;
- pump.timeDisplayType = byteArrayToInt(getBytes(data, dataIndex, dataSize));
+ int dataIndex = DATA_START;
+ int dataSize = 1;
+ pump.timeDisplayType = byteArrayToInt(getBytes(data, dataIndex, dataSize));
- dataIndex += dataSize;
- dataSize = 1;
- pump.buttonScrollOnOff = byteArrayToInt(getBytes(data, dataIndex, dataSize));
+ dataIndex += dataSize;
+ dataSize = 1;
+ pump.buttonScrollOnOff = byteArrayToInt(getBytes(data, dataIndex, dataSize));
- dataIndex += dataSize;
- dataSize = 1;
- pump.beepAndAlarm = byteArrayToInt(getBytes(data, dataIndex, dataSize));
+ dataIndex += dataSize;
+ dataSize = 1;
+ pump.beepAndAlarm = byteArrayToInt(getBytes(data, dataIndex, dataSize));
- dataIndex += dataSize;
- dataSize = 1;
- pump.lcdOnTimeSec = byteArrayToInt(getBytes(data, dataIndex, dataSize));
+ dataIndex += dataSize;
+ dataSize = 1;
+ pump.lcdOnTimeSec = byteArrayToInt(getBytes(data, dataIndex, dataSize));
- dataIndex += dataSize;
- dataSize = 1;
- pump.backlightOnTimeSec = byteArrayToInt(getBytes(data, dataIndex, dataSize));
+ dataIndex += dataSize;
+ dataSize = 1;
+ pump.backlightOnTimeSec = byteArrayToInt(getBytes(data, dataIndex, dataSize));
- dataIndex += dataSize;
- dataSize = 1;
- pump.selectedLanguage = byteArrayToInt(getBytes(data, dataIndex, dataSize));
+ dataIndex += dataSize;
+ dataSize = 1;
+ pump.selectedLanguage = byteArrayToInt(getBytes(data, dataIndex, dataSize));
- dataIndex += dataSize;
- dataSize = 1;
- pump.units = byteArrayToInt(getBytes(data, dataIndex, dataSize));
+ dataIndex += dataSize;
+ dataSize = 1;
+ pump.units = byteArrayToInt(getBytes(data, dataIndex, dataSize));
- dataIndex += dataSize;
- dataSize = 1;
- pump.shutdownHour = byteArrayToInt(getBytes(data, dataIndex, dataSize));
+ dataIndex += dataSize;
+ dataSize = 1;
+ pump.shutdownHour = byteArrayToInt(getBytes(data, dataIndex, dataSize));
- dataIndex += dataSize;
- dataSize = 1;
- pump.lowReservoirRate = byteArrayToInt(getBytes(data, dataIndex, dataSize));
+ dataIndex += dataSize;
+ dataSize = 1;
+ pump.lowReservoirRate = byteArrayToInt(getBytes(data, dataIndex, dataSize));
- dataIndex += dataSize;
- dataSize = 2;
- pump.cannulaVolume = byteArrayToInt(getBytes(data, dataIndex, dataSize));
+ dataIndex += dataSize;
+ dataSize = 2;
+ pump.cannulaVolume = byteArrayToInt(getBytes(data, dataIndex, dataSize));
- dataIndex += dataSize;
- dataSize = 2;
- pump.refillAmount = byteArrayToInt(getBytes(data, dataIndex, dataSize));
+ dataIndex += dataSize;
+ dataSize = 2;
+ pump.refillAmount = byteArrayToInt(getBytes(data, dataIndex, dataSize));
- dataIndex += dataSize;
- dataSize = 1;
- int selectableLanguage1 = byteArrayToInt(getBytes(data, dataIndex, dataSize));
+ dataIndex += dataSize;
+ dataSize = 1;
+ int selectableLanguage1 = byteArrayToInt(getBytes(data, dataIndex, dataSize));
- dataIndex += dataSize;
- dataSize = 1;
- int selectableLanguage2 = byteArrayToInt(getBytes(data, dataIndex, dataSize));
+ dataIndex += dataSize;
+ dataSize = 1;
+ int selectableLanguage2 = byteArrayToInt(getBytes(data, dataIndex, dataSize));
- dataIndex += dataSize;
- dataSize = 1;
- int selectableLanguage3 = byteArrayToInt(getBytes(data, dataIndex, dataSize));
+ dataIndex += dataSize;
+ dataSize = 1;
+ int selectableLanguage3 = byteArrayToInt(getBytes(data, dataIndex, dataSize));
- dataIndex += dataSize;
- dataSize = 1;
- int selectableLanguage4 = byteArrayToInt(getBytes(data, dataIndex, dataSize));
+ dataIndex += dataSize;
+ dataSize = 1;
+ int selectableLanguage4 = byteArrayToInt(getBytes(data, dataIndex, dataSize));
- dataIndex += dataSize;
- dataSize = 1;
- int selectableLanguage5 = byteArrayToInt(getBytes(data, dataIndex, dataSize));
+ dataIndex += dataSize;
+ dataSize = 1;
+ int selectableLanguage5 = byteArrayToInt(getBytes(data, dataIndex, dataSize));
- if (Config.logDanaMessageDetail) {
- log.debug("timeDisplayType: " + pump.timeDisplayType);
- log.debug("buttonScrollOnOff: " + pump.buttonScrollOnOff);
- log.debug("beepAndAlarm: " + pump.beepAndAlarm);
- log.debug("lcdOnTimeSec: " + pump.lcdOnTimeSec);
- log.debug("backlightOnTimeSec: " + pump.backlightOnTimeSec);
- log.debug("selectedLanguage: " + pump.selectedLanguage);
- log.debug("Pump units: " + (pump.units == DanaRPump.UNITS_MGDL ? "MGDL" : "MMOL"));
- log.debug("shutdownHour: " + pump.shutdownHour);
- log.debug("lowReservoirRate: " + pump.lowReservoirRate);
- log.debug("refillAmount: " + pump.refillAmount);
- log.debug("selectableLanguage1: " + selectableLanguage1);
- log.debug("selectableLanguage2: " + selectableLanguage2);
- log.debug("selectableLanguage3: " + selectableLanguage3);
- log.debug("selectableLanguage4: " + selectableLanguage4);
- log.debug("selectableLanguage5: " + selectableLanguage5);
- }
- }
+ if (L.isEnabled(L.PUMPCOMM)) {
+ log.debug("timeDisplayType: " + pump.timeDisplayType);
+ log.debug("buttonScrollOnOff: " + pump.buttonScrollOnOff);
+ log.debug("beepAndAlarm: " + pump.beepAndAlarm);
+ log.debug("lcdOnTimeSec: " + pump.lcdOnTimeSec);
+ log.debug("backlightOnTimeSec: " + pump.backlightOnTimeSec);
+ log.debug("selectedLanguage: " + pump.selectedLanguage);
+ log.debug("Pump units: " + (pump.units == DanaRPump.UNITS_MGDL ? "MGDL" : "MMOL"));
+ log.debug("shutdownHour: " + pump.shutdownHour);
+ log.debug("lowReservoirRate: " + pump.lowReservoirRate);
+ log.debug("refillAmount: " + pump.refillAmount);
+ log.debug("selectableLanguage1: " + selectableLanguage1);
+ log.debug("selectableLanguage2: " + selectableLanguage2);
+ log.debug("selectableLanguage3: " + selectableLanguage3);
+ log.debug("selectableLanguage4: " + selectableLanguage4);
+ log.debug("selectableLanguage5: " + selectableLanguage5);
+ }
+ }
- @Override
- public String getFriendlyName() {
- return "OPTION__GET_USER_OPTION";
- }
+ @Override
+ public String getFriendlyName() {
+ return "OPTION__GET_USER_OPTION";
+ }
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.java
index 007623afca..5f92036ef1 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.java
@@ -1,16 +1,16 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
+import com.cozmo.danar.util.BleCommandUtil;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Date;
-import info.nightscout.androidaps.Config;
-
-import com.cozmo.danar.util.BleCommandUtil;
+import info.nightscout.androidaps.logging.L;
public class DanaRS_Packet_Option_Set_Pump_Time extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Option_Set_Pump_Time.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
private Date date;
public int error;
@@ -22,7 +22,7 @@ public class DanaRS_Packet_Option_Set_Pump_Time extends DanaRS_Packet {
public DanaRS_Packet_Option_Set_Pump_Time(Date date) {
this();
this.date = date;
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Setting pump time " + date.toLocaleString());
}
}
@@ -44,7 +44,7 @@ public class DanaRS_Packet_Option_Set_Pump_Time extends DanaRS_Packet {
int dataIndex = DATA_START;
int dataSize = 1;
error = byteArrayToInt(getBytes(data, dataIndex, dataSize));
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
if (error == 0)
log.debug("Result OK");
else
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Set_User_Option.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Set_User_Option.java
index 40577aaa5d..3e11aa93fa 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Set_User_Option.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Set_User_Option.java
@@ -1,21 +1,22 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
+import com.cozmo.danar.util.BleCommandUtil;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-import com.cozmo.danar.util.BleCommandUtil;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
public class DanaRS_Packet_Option_Set_User_Option extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Option_Set_User_Option.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
private int error;
public DanaRS_Packet_Option_Set_User_Option() {
super();
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_OPTION__SET_USER_OPTION;
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Setting user settings");
}
}
@@ -23,14 +24,15 @@ public class DanaRS_Packet_Option_Set_User_Option extends DanaRS_Packet {
@Override
public byte[] getRequestParams() {
DanaRPump pump = DanaRPump.getInstance();
- log.debug("UserOptions:"+(System.currentTimeMillis() - pump.lastConnection)/1000+" s ago"
- +"\ntimeDisplayType:"+pump.timeDisplayType
- +"\nbuttonScroll:"+pump.buttonScrollOnOff
- +"\ntimeDisplayType:"+pump.timeDisplayType
- +"\nlcdOnTimeSec:"+pump.lcdOnTimeSec
- +"\nbacklight:"+pump.backlightOnTimeSec
- +"\npumpUnits:"+pump.units
- +"\nlowReservoir:"+pump.lowReservoirRate);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("UserOptions:" + (System.currentTimeMillis() - pump.lastConnection) / 1000 + " s ago"
+ + "\ntimeDisplayType:" + pump.timeDisplayType
+ + "\nbuttonScroll:" + pump.buttonScrollOnOff
+ + "\ntimeDisplayType:" + pump.timeDisplayType
+ + "\nlcdOnTimeSec:" + pump.lcdOnTimeSec
+ + "\nbacklight:" + pump.backlightOnTimeSec
+ + "\npumpUnits:" + pump.units
+ + "\nlowReservoir:" + pump.lowReservoirRate);
byte[] request = new byte[13];
request[0] = (byte) (pump.timeDisplayType & 0xff);
request[1] = (byte) (pump.buttonScrollOnOff & 0xff);
@@ -53,7 +55,7 @@ public class DanaRS_Packet_Option_Set_User_Option extends DanaRS_Packet {
int dataIndex = DATA_START;
int dataSize = 1;
error = byteArrayToInt(getBytes(data, dataIndex, dataSize));
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
if (error == 0)
log.debug("Result OK");
else
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Review_Bolus_Avg.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Review_Bolus_Avg.java
index e8440b12d2..6c43908309 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Review_Bolus_Avg.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Review_Bolus_Avg.java
@@ -1,18 +1,20 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
+import com.cozmo.danar.util.BleCommandUtil;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-
-import com.cozmo.danar.util.BleCommandUtil;
+import info.nightscout.androidaps.logging.L;
public class DanaRS_Packet_Review_Bolus_Avg extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Review_Bolus_Avg.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public DanaRS_Packet_Review_Bolus_Avg() {
super();
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BOLUS_AVG;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
@@ -36,7 +38,7 @@ public class DanaRS_Packet_Review_Bolus_Avg extends DanaRS_Packet {
dataIndex += dataSize;
dataSize = 2;
double bolusAvg28 = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d;
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Bolus average 3d: " + bolusAvg03 + " U");
log.debug("Bolus average 7d: " + bolusAvg07 + " U");
log.debug("Bolus average 14d: " + bolusAvg14 + " U");
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/BLEComm.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/BLEComm.java
index e15f6f23c0..be241dbbfd 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/BLEComm.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/BLEComm.java
@@ -25,6 +25,7 @@ import java.util.concurrent.ScheduledFuture;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.events.EventPumpStatusChanged;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
@@ -34,7 +35,7 @@ import info.nightscout.androidaps.plugins.PumpDanaRS.comm.DanaRSMessageHashTable
import info.nightscout.androidaps.plugins.PumpDanaRS.comm.DanaRS_Packet;
import info.nightscout.androidaps.plugins.PumpDanaRS.events.EventDanaRSPacket;
import info.nightscout.androidaps.plugins.PumpDanaRS.events.EventDanaRSPairingSuccess;
-import info.nightscout.utils.NSUpload;
+import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
import info.nightscout.utils.SP;
/**
@@ -42,12 +43,12 @@ import info.nightscout.utils.SP;
*/
public class BLEComm {
- private static Logger log = LoggerFactory.getLogger(BLEComm.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPBTCOMM);
- private static final long WRITE_DELAY_MILLIS = 50;
+ private final long WRITE_DELAY_MILLIS = 50;
- private static String UART_READ_UUID = "0000fff1-0000-1000-8000-00805f9b34fb";
- private static String UART_WRITE_UUID = "0000fff2-0000-1000-8000-00805f9b34fb";
+ private String UART_READ_UUID = "0000fff1-0000-1000-8000-00805f9b34fb";
+ private String UART_WRITE_UUID = "0000fff2-0000-1000-8000-00805f9b34fb";
private final byte PACKET_START_BYTE = (byte) 0xA5;
private final byte PACKET_END_BYTE = (byte) 0x5A;
@@ -83,19 +84,20 @@ public class BLEComm {
}
private boolean initialize() {
- log.debug("Initializing BLEComm.");
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug("Initializing BLEComm.");
if (mBluetoothManager == null) {
mBluetoothManager = ((BluetoothManager) MainApp.instance().getApplicationContext().getSystemService(Context.BLUETOOTH_SERVICE));
if (mBluetoothManager == null) {
- log.debug("Unable to initialize BluetoothManager.");
+ log.error("Unable to initialize BluetoothManager.");
return false;
}
}
mBluetoothAdapter = mBluetoothManager.getAdapter();
if (mBluetoothAdapter == null) {
- log.debug("Unable to obtain a BluetoothAdapter.");
+ log.error("Unable to obtain a BluetoothAdapter.");
return false;
}
@@ -128,7 +130,7 @@ public class BLEComm {
}
if (address == null) {
- log.debug("unspecified address.");
+ log.error("unspecified address.");
return false;
}
@@ -136,11 +138,12 @@ public class BLEComm {
BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);
if (device == null) {
- log.debug("Device not found. Unable to connect from: " + from);
+ log.error("Device not found. Unable to connect from: " + from);
return false;
}
- log.debug("Trying to create a new connection from: " + from);
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug("Trying to create a new connection from: " + from);
mBluetoothGatt = device.connectGatt(service.getApplicationContext(), false, mGattCallback);
setCharacteristicNotification(getUARTReadBTGattChar(), true);
mBluetoothDeviceName = device.getName();
@@ -152,7 +155,8 @@ public class BLEComm {
}
public synchronized void disconnect(String from) {
- log.debug("disconnect from: " + from);
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug("disconnect from: " + from);
// cancel previous scheduled disconnection to prevent closing upcomming connection
if (scheduledDisconnection != null)
@@ -160,8 +164,8 @@ public class BLEComm {
scheduledDisconnection = null;
if ((mBluetoothAdapter == null) || (mBluetoothGatt == null)) {
- log.debug("disconnect not possible: (mBluetoothAdapter == null) " + (mBluetoothAdapter == null));
- log.debug("disconnect not possible: (mBluetoothGatt == null) " + (mBluetoothGatt == null));
+ log.error("disconnect not possible: (mBluetoothAdapter == null) " + (mBluetoothAdapter == null));
+ log.error("disconnect not possible: (mBluetoothGatt == null) " + (mBluetoothGatt == null));
return;
}
setCharacteristicNotification(getUARTReadBTGattChar(), false);
@@ -171,7 +175,8 @@ public class BLEComm {
}
public synchronized void close() {
- log.debug("BluetoothAdapter close");
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug("BluetoothAdapter close");
if (mBluetoothGatt == null) {
return;
}
@@ -191,7 +196,8 @@ public class BLEComm {
}
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
- log.debug("onServicesDiscovered");
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug("onServicesDiscovered");
if (status == BluetoothGatt.GATT_SUCCESS) {
findCharacteristic();
}
@@ -200,19 +206,22 @@ public class BLEComm {
}
public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
- log.debug("onCharacteristicRead" + (characteristic != null ? ":" + DanaRS_Packet.toHexString(characteristic.getValue()) : ""));
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug("onCharacteristicRead" + (characteristic != null ? ":" + DanaRS_Packet.toHexString(characteristic.getValue()) : ""));
addToReadBuffer(characteristic.getValue());
readDataParsing();
}
public void onCharacteristicChanged(BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic) {
- log.debug("onCharacteristicChanged" + (characteristic != null ? ":" + DanaRS_Packet.toHexString(characteristic.getValue()) : ""));
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug("onCharacteristicChanged" + (characteristic != null ? ":" + DanaRS_Packet.toHexString(characteristic.getValue()) : ""));
addToReadBuffer(characteristic.getValue());
new Thread(() -> readDataParsing()).start();
}
public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
- log.debug("onCharacteristicWrite" + (characteristic != null ? ":" + DanaRS_Packet.toHexString(characteristic.getValue()) : ""));
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug("onCharacteristicWrite" + (characteristic != null ? ":" + DanaRS_Packet.toHexString(characteristic.getValue()) : ""));
new Thread(() -> {
synchronized (mSendQueue) {
// after message sent, check if there is the rest of the message waiting and send it
@@ -227,9 +236,10 @@ public class BLEComm {
};
private synchronized void setCharacteristicNotification(BluetoothGattCharacteristic characteristic, boolean enabled) {
- log.debug("setCharacteristicNotification");
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug("setCharacteristicNotification");
if ((mBluetoothAdapter == null) || (mBluetoothGatt == null)) {
- log.debug("BluetoothAdapter not initialized_ERROR");
+ log.error("BluetoothAdapter not initialized_ERROR");
isConnecting = false;
isConnected = false;
return;
@@ -238,9 +248,10 @@ public class BLEComm {
}
public synchronized void readCharacteristic(BluetoothGattCharacteristic characteristic) {
- log.debug("readCharacteristic");
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug("readCharacteristic");
if ((mBluetoothAdapter == null) || (mBluetoothGatt == null)) {
- log.debug("BluetoothAdapter not initialized_ERROR");
+ log.error("BluetoothAdapter not initialized_ERROR");
isConnecting = false;
isConnected = false;
return;
@@ -253,7 +264,7 @@ public class BLEComm {
SystemClock.sleep(WRITE_DELAY_MILLIS);
if ((mBluetoothAdapter == null) || (mBluetoothGatt == null)) {
- log.debug("BluetoothAdapter not initialized_ERROR");
+ log.error("BluetoothAdapter not initialized_ERROR");
isConnecting = false;
isConnected = false;
return;
@@ -261,7 +272,8 @@ public class BLEComm {
characteristic.setValue(data);
characteristic.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE);
- log.debug("writeCharacteristic:" + DanaRS_Packet.toHexString(data));
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug("writeCharacteristic:" + DanaRS_Packet.toHexString(data));
mBluetoothGatt.writeCharacteristic(characteristic);
}).start();
}
@@ -281,9 +293,10 @@ public class BLEComm {
}
private List getSupportedGattServices() {
- log.debug("getSupportedGattServices");
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug("getSupportedGattServices");
if ((mBluetoothAdapter == null) || (mBluetoothGatt == null)) {
- log.debug("BluetoothAdapter not initialized_ERROR");
+ log.error("BluetoothAdapter not initialized_ERROR");
isConnecting = false;
isConnected = false;
return null;
@@ -315,8 +328,9 @@ public class BLEComm {
}
}
- public synchronized void onConnectionStateChangeSynchronized(BluetoothGatt gatt, int status, int newState) {
- log.debug("onConnectionStateChange");
+ private synchronized void onConnectionStateChangeSynchronized(BluetoothGatt gatt, int status, int newState) {
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug("onConnectionStateChange");
if (newState == BluetoothProfile.STATE_CONNECTED) {
mBluetoothGatt.discoverServices();
@@ -325,7 +339,8 @@ public class BLEComm {
isConnected = false;
isConnecting = false;
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTED));
- log.debug("Device was disconnected " + gatt.getDevice().getName());//Device was disconnected
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug("Device was disconnected " + gatt.getDevice().getName());//Device was disconnected
}
}
@@ -360,7 +375,8 @@ public class BLEComm {
if ((readBuffer[idxStartByte] == PACKET_START_BYTE) && (readBuffer[idxStartByte + 1] == PACKET_START_BYTE)) {
if (idxStartByte > 0) {
// if buffer doesn't start with signature remove the leading trash
- log.debug("Shifting the input buffer by " + idxStartByte + " bytes");
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug("Shifting the input buffer by " + idxStartByte + " bytes");
System.arraycopy(readBuffer, idxStartByte, readBuffer, 0, bufferLength - idxStartByte);
bufferLength -= idxStartByte;
}
@@ -390,7 +406,7 @@ public class BLEComm {
try {
System.arraycopy(readBuffer, length + 7, readBuffer, 0, bufferLength - (length + 7));
} catch (Exception e) {
- log.debug("length: " + length + "bufferLength: " + bufferLength);
+ log.error("length: " + length + "bufferLength: " + bufferLength);
throw e;
}
bufferLength -= (length + 7);
@@ -403,7 +419,7 @@ public class BLEComm {
inputBuffer = BleCommandUtil.getInstance().getDecryptedPacket(inputBuffer);
if (inputBuffer == null) {
- log.debug("Null decryptedInputBuffer");
+ log.error("Null decryptedInputBuffer");
return;
}
@@ -414,14 +430,17 @@ public class BLEComm {
// 1st packet
case (byte) BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__PUMP_CHECK:
if (inputBuffer.length == 4 && inputBuffer[2] == 'O' && inputBuffer[3] == 'K') {
- log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (OK)" + " " + DanaRS_Packet.toHexString(inputBuffer));
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (OK)" + " " + DanaRS_Packet.toHexString(inputBuffer));
// Grab pairing key from preferences if exists
String pairingKey = SP.getString(MainApp.gs(R.string.key_danars_pairingkey) + DanaRSPlugin.mDeviceName, null);
- log.debug("Using stored pairing key: " + pairingKey);
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug("Using stored pairing key: " + pairingKey);
if (pairingKey != null) {
byte[] encodedPairingKey = DanaRS_Packet.hexToBytes(pairingKey);
byte[] bytes = BleCommandUtil.getInstance().getEncryptedPacket(BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__CHECK_PASSKEY, encodedPairingKey, null);
- log.debug(">>>>> " + "ENCRYPTION__CHECK_PASSKEY" + " " + DanaRS_Packet.toHexString(bytes));
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug(">>>>> " + "ENCRYPTION__CHECK_PASSKEY" + " " + DanaRS_Packet.toHexString(bytes));
writeCharacteristic_NO_RESPONSE(getUARTWriteBTGattChar(), bytes);
} else {
// Stored pairing key does not exists, request pairing
@@ -429,19 +448,22 @@ public class BLEComm {
}
} else if (inputBuffer.length == 6 && inputBuffer[2] == 'P' && inputBuffer[3] == 'U' && inputBuffer[4] == 'M' && inputBuffer[5] == 'P') {
- log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (PUMP)" + " " + DanaRS_Packet.toHexString(inputBuffer));
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (PUMP)" + " " + DanaRS_Packet.toHexString(inputBuffer));
mSendQueue.clear();
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTED, MainApp.gs(R.string.pumperror)));
NSUpload.uploadError(MainApp.gs(R.string.pumperror));
Notification n = new Notification(Notification.PUMPERROR, MainApp.gs(R.string.pumperror), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(n));
} else if (inputBuffer.length == 6 && inputBuffer[2] == 'B' && inputBuffer[3] == 'U' && inputBuffer[4] == 'S' && inputBuffer[5] == 'Y') {
- log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (BUSY)" + " " + DanaRS_Packet.toHexString(inputBuffer));
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (BUSY)" + " " + DanaRS_Packet.toHexString(inputBuffer));
mSendQueue.clear();
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTED, MainApp.gs(R.string.pumpbusy)));
} else {
// ERROR in response, wrong serial number
- log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (ERROR)" + " " + DanaRS_Packet.toHexString(inputBuffer));
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (ERROR)" + " " + DanaRS_Packet.toHexString(inputBuffer));
mSendQueue.clear();
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTED, MainApp.gs(R.string.connectionerror)));
SP.remove(MainApp.gs(R.string.key_danars_pairingkey) + DanaRSPlugin.mDeviceName);
@@ -451,7 +473,8 @@ public class BLEComm {
break;
// 2nd packet, pairing key
case (byte) BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__CHECK_PASSKEY:
- log.debug("<<<<< " + "ENCRYPTION__CHECK_PASSKEY" + " " + DanaRS_Packet.toHexString(inputBuffer));
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug("<<<<< " + "ENCRYPTION__CHECK_PASSKEY" + " " + DanaRS_Packet.toHexString(inputBuffer));
if (inputBuffer[2] == (byte) 0x00) {
// Paring is not requested, sending time info
SendTimeInfo();
@@ -461,35 +484,41 @@ public class BLEComm {
}
break;
case (byte) BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_REQUEST:
- log.debug("<<<<< " + "ENCRYPTION__PASSKEY_REQUEST " + DanaRS_Packet.toHexString(inputBuffer));
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug("<<<<< " + "ENCRYPTION__PASSKEY_REQUEST " + DanaRS_Packet.toHexString(inputBuffer));
if (inputBuffer[2] != (byte) 0x00) {
disconnect("passkey request failed");
}
break;
// Paring response, OK button on pump pressed
case (byte) BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_RETURN:
- log.debug("<<<<< " + "ENCRYPTION__PASSKEY_RETURN " + DanaRS_Packet.toHexString(inputBuffer));
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug("<<<<< " + "ENCRYPTION__PASSKEY_RETURN " + DanaRS_Packet.toHexString(inputBuffer));
// Paring is successfull, sending time info
MainApp.bus().post(new EventDanaRSPairingSuccess());
SendTimeInfo();
byte[] pairingKey = {inputBuffer[2], inputBuffer[3]};
// store pairing key to preferences
SP.putString(MainApp.gs(R.string.key_danars_pairingkey) + DanaRSPlugin.mDeviceName, DanaRS_Packet.bytesToHex(pairingKey));
- log.debug("Got pairing key: " + DanaRS_Packet.bytesToHex(pairingKey));
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug("Got pairing key: " + DanaRS_Packet.bytesToHex(pairingKey));
break;
// time and user password information. last packet in handshake
case (byte) BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__TIME_INFORMATION:
- log.debug("<<<<< " + "ENCRYPTION__TIME_INFORMATION " + /*message.getMessageName() + " " + */ DanaRS_Packet.toHexString(inputBuffer));
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug("<<<<< " + "ENCRYPTION__TIME_INFORMATION " + /*message.getMessageName() + " " + */ DanaRS_Packet.toHexString(inputBuffer));
int size = inputBuffer.length;
int pass = ((inputBuffer[size - 1] & 0x000000FF) << 8) + ((inputBuffer[size - 2] & 0x000000FF));
pass = pass ^ 3463;
DanaRPump.getInstance().rs_password = Integer.toHexString(pass);
- log.debug("Pump user password: " + Integer.toHexString(pass));
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug("Pump user password: " + Integer.toHexString(pass));
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTED));
isConnected = true;
isConnecting = false;
- log.debug("RS connected and status read");
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug("RS connected and status read");
break;
}
break;
@@ -507,7 +536,8 @@ public class BLEComm {
message = DanaRSMessageHashTable.findMessage(receivedCommand);
}
if (message != null) {
- log.debug("<<<<< " + message.getFriendlyName() + " " + DanaRS_Packet.toHexString(inputBuffer));
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug("<<<<< " + message.getFriendlyName() + " " + DanaRS_Packet.toHexString(inputBuffer));
// process received data
message.handleMessage(inputBuffer);
message.setReceived();
@@ -544,7 +574,8 @@ public class BLEComm {
byte[] command = {(byte) message.getType(), (byte) message.getOpCode()};
byte[] params = message.getRequestParams();
- log.debug(">>>>> " + message.getFriendlyName() + " " + DanaRS_Packet.toHexString(command) + " " + DanaRS_Packet.toHexString(params));
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug(">>>>> " + message.getFriendlyName() + " " + DanaRS_Packet.toHexString(command) + " " + DanaRS_Packet.toHexString(params));
byte[] bytes = BleCommandUtil.getInstance().getEncryptedPacket(message.getOpCode(), params, null);
// If there is another message not completely sent, add to queue only
if (mSendQueue.size() > 0) {
@@ -624,20 +655,23 @@ public class BLEComm {
MainApp.instance().startActivity(i);
byte[] bytes = BleCommandUtil.getInstance().getEncryptedPacket(BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_REQUEST, null, null);
- log.debug(">>>>> " + "ENCRYPTION__PASSKEY_REQUEST" + " " + DanaRS_Packet.toHexString(bytes));
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug(">>>>> " + "ENCRYPTION__PASSKEY_REQUEST" + " " + DanaRS_Packet.toHexString(bytes));
writeCharacteristic_NO_RESPONSE(getUARTWriteBTGattChar(), bytes);
}
private void SendPumpCheck() {
// 1st message sent to pump after connect
byte[] bytes = BleCommandUtil.getInstance().getEncryptedPacket(BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__PUMP_CHECK, null, getConnectDeviceName());
- log.debug(">>>>> " + "ENCRYPTION__PUMP_CHECK (0x00)" + " " + DanaRS_Packet.toHexString(bytes));
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug(">>>>> " + "ENCRYPTION__PUMP_CHECK (0x00)" + " " + DanaRS_Packet.toHexString(bytes));
writeCharacteristic_NO_RESPONSE(getUARTWriteBTGattChar(), bytes);
}
private void SendTimeInfo() {
byte[] bytes = BleCommandUtil.getInstance().getEncryptedPacket(BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__TIME_INFORMATION, null, null);
- log.debug(">>>>> " + "ENCRYPTION__TIME_INFORMATION" + " " + DanaRS_Packet.toHexString(bytes));
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug(">>>>> " + "ENCRYPTION__TIME_INFORMATION" + " " + DanaRS_Packet.toHexString(bytes));
writeCharacteristic_NO_RESPONSE(getUARTWriteBTGattChar(), bytes);
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/DanaRSService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/DanaRSService.java
index fae0430adc..23618f2b18 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/DanaRSService.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/DanaRSService.java
@@ -13,7 +13,6 @@ import org.slf4j.LoggerFactory;
import java.util.Date;
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
@@ -24,6 +23,7 @@ import info.nightscout.androidaps.events.EventInitializationChanged;
import info.nightscout.androidaps.events.EventProfileSwitchChange;
import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.interfaces.PumpInterface;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressDialog;
import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity;
@@ -78,12 +78,12 @@ import info.nightscout.androidaps.plugins.Treatments.Treatment;
import info.nightscout.androidaps.queue.Callback;
import info.nightscout.androidaps.queue.commands.Command;
import info.nightscout.utils.DateUtil;
-import info.nightscout.utils.NSUpload;
+import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
import info.nightscout.utils.SP;
import info.nightscout.utils.T;
public class DanaRSService extends Service {
- private static Logger log = LoggerFactory.getLogger(DanaRSService.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
private BLEComm bleComm = BLEComm.getInstance(this);
@@ -156,10 +156,12 @@ public class DanaRSService extends Service {
bleComm.sendMessage(new DanaRS_Packet_Option_Get_Pump_Time());
long timeDiff = (danaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
- log.debug("Pump time difference: " + timeDiff + " seconds");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("Pump time difference: " + timeDiff + " seconds");
if (Math.abs(timeDiff) > 3) {
- if (Math.abs(timeDiff) > 60*60*1.5) {
- log.debug("Pump time difference: " + timeDiff + " seconds - large difference");
+ if (Math.abs(timeDiff) > 60 * 60 * 1.5) {
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("Pump time difference: " + timeDiff + " seconds - large difference");
//If time-diff is very large, warn user until we can synchronize history readings properly
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
i.putExtra("soundid", R.raw.error);
@@ -179,7 +181,8 @@ public class DanaRSService extends Service {
bleComm.sendMessage(new DanaRS_Packet_Option_Set_Pump_Time(new Date(DateUtil.now() + T.secs(10).msecs())));
bleComm.sendMessage(new DanaRS_Packet_Option_Get_Pump_Time());
timeDiff = (danaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
- log.debug("Pump time difference: " + timeDiff + " seconds");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("Pump time difference: " + timeDiff + " seconds");
}
}
@@ -203,8 +206,9 @@ public class DanaRSService extends Service {
MainApp.bus().post(new EventInitializationChanged());
NSUpload.uploadDeviceStatus();
if (danaRPump.dailyTotalUnits > danaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) {
- log.debug("Approaching daily limit: " + danaRPump.dailyTotalUnits + "/" + danaRPump.maxDailyTotalUnits);
- if(System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) {
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("Approaching daily limit: " + danaRPump.dailyTotalUnits + "/" + danaRPump.maxDailyTotalUnits);
+ if (System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) {
Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.gs(R.string.approachingdailylimit), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(reportFail));
NSUpload.uploadError(MainApp.gs(R.string.approachingdailylimit) + ": " + danaRPump.dailyTotalUnits + "/" + danaRPump.maxDailyTotalUnits + "U");
@@ -214,12 +218,13 @@ public class DanaRSService extends Service {
} catch (Exception e) {
log.error("Unhandled exception", e);
}
- log.debug("Pump status loaded");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("Pump status loaded");
}
public PumpEnactResult loadEvents() {
- if(!MainApp.getSpecificPlugin(DanaRSPlugin.class).isInitialized()){
+ if (!MainApp.getSpecificPlugin(DanaRSPlugin.class).isInitialized()) {
PumpEnactResult result = new PumpEnactResult().success(false);
result.comment = "pump not initialized";
return result;
@@ -230,10 +235,12 @@ public class DanaRSService extends Service {
DanaRS_Packet_APS_History_Events msg;
if (lastHistoryFetched == 0) {
msg = new DanaRS_Packet_APS_History_Events(0);
- log.debug("Loading complete event history");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("Loading complete event history");
} else {
msg = new DanaRS_Packet_APS_History_Events(lastHistoryFetched);
- log.debug("Loading event history from: " + new Date(lastHistoryFetched).toLocaleString());
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("Loading event history from: " + new Date(lastHistoryFetched).toLocaleString());
}
bleComm.sendMessage(msg);
while (!msg.done && bleComm.isConnected()) {
@@ -243,7 +250,8 @@ public class DanaRSService extends Service {
lastHistoryFetched = DanaRS_Packet_APS_History_Events.lastEventTimeLoaded - T.mins(1).msecs();
else
lastHistoryFetched = 0;
- log.debug("Events loaded");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("Events loaded");
danaRPump.lastConnection = System.currentTimeMillis();
return new PumpEnactResult().success(true);
}
@@ -290,7 +298,8 @@ public class DanaRSService extends Service {
if ((System.currentTimeMillis() - progress.lastReceive) > 15 * 1000L) { // if i didn't receive status for more than 20 sec expecting broken comm
stop.stopped = true;
stop.forced = true;
- log.debug("Communication stopped");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("Communication stopped");
}
}
}
@@ -335,7 +344,7 @@ public class DanaRSService extends Service {
}
public void bolusStop() {
- if (Config.logDanaBTComm)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("bolusStop >>>>> @ " + (bolusingTreatment == null ? "" : bolusingTreatment.insulin));
DanaRS_Packet_Bolus_Set_Step_Bolus_Stop stop = new DanaRS_Packet_Bolus_Set_Step_Bolus_Stop();
stop.forced = true;
@@ -433,7 +442,7 @@ public class DanaRSService extends Service {
public boolean updateBasalsInPump(Profile profile) {
if (!isConnected()) return false;
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.updatingbasalrates)));
- double[] basal = DanaRPump.buildDanaRProfileRecord(profile);
+ double[] basal = DanaRPump.getInstance().buildDanaRProfileRecord(profile);
DanaRS_Packet_Basal_Set_Profile_Basal_Rate msgSet = new DanaRS_Packet_Basal_Set_Profile_Basal_Rate(0, basal);
bleComm.sendMessage(msgSet);
DanaRS_Packet_Basal_Set_Profile_Number msgActivate = new DanaRS_Packet_Basal_Set_Profile_Number(0);
@@ -512,11 +521,11 @@ public class DanaRSService extends Service {
@Subscribe
public void onStatusEvent(EventAppExit event) {
- if (Config.logFunctionCalls)
+ if (L.isEnabled(L.PUMP))
log.debug("EventAppExit received");
stopSelf();
- if (Config.logFunctionCalls)
+ if (L.isEnabled(L.PUMP))
log.debug("EventAppExit finished");
}
@@ -526,7 +535,7 @@ public class DanaRSService extends Service {
long timeToWholeMinute = (60000 - time % 60000);
if (timeToWholeMinute > 59800 || timeToWholeMinute < 300)
break;
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.waitingfortimesynchronization, (int)(timeToWholeMinute / 1000))));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.waitingfortimesynchronization, (int) (timeToWholeMinute / 1000))));
SystemClock.sleep(Math.min(timeToWholeMinute, 100));
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java
index e83f9d9435..1f1dc90eb1 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java
@@ -11,9 +11,6 @@ import android.support.v7.app.AlertDialog;
import com.squareup.otto.Subscribe;
-import org.slf4j.LoggerFactory;
-
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.DetailedBolusInfo;
@@ -23,6 +20,7 @@ import info.nightscout.androidaps.db.TemporaryBasal;
import info.nightscout.androidaps.events.EventAppExit;
import info.nightscout.androidaps.interfaces.Constraint;
import info.nightscout.androidaps.interfaces.PumpDescription;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
import info.nightscout.androidaps.plugins.ConfigBuilder.DetailedBolusInfoStorage;
import info.nightscout.androidaps.plugins.PumpDanaR.AbstractDanaRPlugin;
@@ -51,7 +49,6 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
private DanaRv2Plugin() {
pluginDescription.description(R.string.description_pump_dana_r_v2);
- log = LoggerFactory.getLogger(DanaRv2Plugin.class);
useExtendedBoluses = false;
pumpDescription.isBolusCapable = true;
@@ -107,12 +104,14 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
private ServiceConnection mConnection = new ServiceConnection() {
public void onServiceDisconnected(ComponentName name) {
- log.debug("Service is disconnected");
+ if (L.isEnabled(L.PUMP))
+ log.debug("Service is disconnected");
sExecutionService = null;
}
public void onServiceConnected(ComponentName name, IBinder service) {
- log.debug("Service is connected");
+ if (L.isEnabled(L.PUMP))
+ log.debug("Service is connected");
DanaRv2ExecutionService.LocalBinder mLocalBinder = (DanaRv2ExecutionService.LocalBinder) service;
sExecutionService = mLocalBinder.getServiceInstance();
}
@@ -157,13 +156,15 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
public void onClick(DialogInterface dialog, int id) {
pluginSwitcher.invoke();
SP.putBoolean("allow_hardware_pump", true);
- log.debug("First time HW pump allowed!");
+ if (L.isEnabled(L.PUMP))
+ log.debug("First time HW pump allowed!");
}
})
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
pluginSwitcher.cancel();
- log.debug("User does not allow switching to HW pump!");
+ if (L.isEnabled(L.PUMP))
+ log.debug("User does not allow switching to HW pump!");
}
});
builder.create().show();
@@ -214,7 +215,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
result.comment = String.format(MainApp.gs(R.string.boluserrorcode), detailedBolusInfo.insulin, t.insulin, MsgBolusStartWithSpeed.errorCode);
else
result.comment = MainApp.gs(R.string.virtualpump_resultok);
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered);
// remove carbs because it's get from history seprately
return result;
@@ -258,7 +259,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
if (doTempOff) {
// If temp in progress
if (TreatmentsPlugin.getPlugin().isTempBasalInProgress()) {
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: Stopping temp basal (doTempOff)");
return cancelTempBasal(false);
}
@@ -267,7 +268,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
result.percent = 100;
result.isPercent = true;
result.isTempCancel = true;
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: doTempOff OK");
return result;
}
@@ -290,14 +291,14 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
result.duration = activeTemp.getPlannedRemainingMinutes();
result.isPercent = true;
result.isTempCancel = false;
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: Correct temp basal already set (doLowTemp || doHighTemp)");
return result;
}
}
}
// Convert duration from minutes to hours
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: Setting temp basal " + percentRate + "% for " + durationInMinutes + " mins (doLowTemp || doHighTemp)");
if (percentRate == 0 && durationInMinutes > 30) {
result = setTempBasalPercent(percentRate, durationInMinutes, profile, false);
@@ -309,7 +310,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
log.error("setTempBasalAbsolute: Failed to set hightemp basal");
return result;
}
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: hightemp basal set ok");
return result;
}
@@ -344,7 +345,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
result.duration = pump.tempBasalRemainingMin;
result.percent = pump.tempBasalPercent;
result.isPercent = true;
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setTempBasalPercent: Correct value already set");
return result;
}
@@ -363,7 +364,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
result.duration = pump.tempBasalRemainingMin;
result.percent = pump.tempBasalPercent;
result.isPercent = true;
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setTempBasalPercent: OK");
return result;
}
@@ -385,7 +386,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
result.duration = pump.tempBasalRemainingMin;
result.percent = pump.tempBasalPercent;
result.isPercent = true;
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("setHighTempBasalPercent: OK");
return result;
}
@@ -409,7 +410,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
result.success = true;
result.isTempCancel = true;
result.comment = MainApp.gs(R.string.virtualpump_resultok);
- if (Config.logPumpActions)
+ if (L.isEnabled(L.PUMP))
log.debug("cancelRealTempBasal: OK");
return result;
} else {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/SerialIOThread.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/SerialIOThread.java
index a12e2085aa..61047a8d5a 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/SerialIOThread.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/SerialIOThread.java
@@ -10,7 +10,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import info.nightscout.androidaps.Config;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
import info.nightscout.androidaps.plugins.PumpDanaR.services.AbstractSerialIOThread;
@@ -21,7 +21,7 @@ import info.nightscout.utils.CRC;
* Created by mike on 17.07.2016.
*/
public class SerialIOThread extends AbstractSerialIOThread {
- private static Logger log = LoggerFactory.getLogger(SerialIOThread.class);
+ private static Logger log = LoggerFactory.getLogger(L.PUMPBTCOMM);
private InputStream mInputStream = null;
private OutputStream mOutputStream = null;
@@ -72,7 +72,7 @@ public class SerialIOThread extends AbstractSerialIOThread {
message = MessageHashTable_v2.findMessage(command);
}
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPBTCOMM))
log.debug("<<<<< " + message.getMessageName() + " " + message.toHexString(extractedBuff));
// process the message content
@@ -84,7 +84,7 @@ public class SerialIOThread extends AbstractSerialIOThread {
}
}
} catch (Exception e) {
- if (Config.logDanaSerialEngine && e.getMessage().indexOf("bt socket closed") < 0)
+ if (e.getMessage().indexOf("bt socket closed") < 0)
log.error("Thread exception: ", e);
mKeepRunning = false;
}
@@ -148,7 +148,7 @@ public class SerialIOThread extends AbstractSerialIOThread {
processedMessage = message;
byte[] messageBytes = message.getRawMessageBytes();
- if (Config.logDanaSerialEngine)
+ if (L.isEnabled(L.PUMPBTCOMM))
log.debug(">>>>> " + message.getMessageName() + " " + message.toHexString(messageBytes));
try {
@@ -167,10 +167,10 @@ public class SerialIOThread extends AbstractSerialIOThread {
SystemClock.sleep(200);
if (!message.received) {
- log.warn("Reply not received " + message.getMessageName());
+ log.error("Reply not received " + message.getMessageName());
if (message.getCommand() == 0xF0F1) {
DanaRPump.getInstance().isNewPump = false;
- log.debug("Old firmware detected");
+ log.error("Old firmware detected");
}
}
}
@@ -181,24 +181,29 @@ public class SerialIOThread extends AbstractSerialIOThread {
try {
mInputStream.close();
} catch (Exception e) {
- if (Config.logDanaSerialEngine) log.debug(e.getMessage());
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug(e.getMessage());
}
try {
mOutputStream.close();
} catch (Exception e) {
- if (Config.logDanaSerialEngine) log.debug(e.getMessage());
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug(e.getMessage());
}
try {
mRfCommSocket.close();
} catch (Exception e) {
- if (Config.logDanaSerialEngine) log.debug(e.getMessage());
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug(e.getMessage());
}
try {
System.runFinalization();
} catch (Exception e) {
- if (Config.logDanaSerialEngine) log.debug(e.getMessage());
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug(e.getMessage());
}
- if (Config.logDanaSerialEngine) log.debug("Disconnected: " + reason);
+ if (L.isEnabled(L.PUMPBTCOMM))
+ log.debug("Disconnected: " + reason);
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MessageHashTable_v2.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MessageHashTable_v2.java
index 8d1cd12be1..c95a800128 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MessageHashTable_v2.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MessageHashTable_v2.java
@@ -1,8 +1,5 @@
package info.nightscout.androidaps.plugins.PumpDanaRv2.comm;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.util.HashMap;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
@@ -13,8 +10,6 @@ import info.nightscout.androidaps.plugins.PumpDanaR.comm.*;
* Created by mike on 28.05.2016.
*/
public class MessageHashTable_v2 {
- private static Logger log = LoggerFactory.getLogger(MessageHashTable_v2.class);
-
public static HashMap messages = null;
static {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgCheckValue_v2.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgCheckValue_v2.java
index 0869844a1c..8810edb815 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgCheckValue_v2.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgCheckValue_v2.java
@@ -3,11 +3,11 @@ package info.nightscout.androidaps.plugins.PumpDanaRv2.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.events.EventRefreshGui;
import info.nightscout.androidaps.interfaces.PluginType;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
@@ -21,10 +21,12 @@ import info.nightscout.androidaps.plugins.PumpDanaRv2.DanaRv2Plugin;
* Created by mike on 30.06.2016.
*/
public class MsgCheckValue_v2 extends MessageBase {
- private static Logger log = LoggerFactory.getLogger(MsgCheckValue_v2.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgCheckValue_v2() {
SetCommand(0xF0F1);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
@@ -32,7 +34,8 @@ public class MsgCheckValue_v2 extends MessageBase {
DanaRPump pump = DanaRPump.getInstance();
pump.isNewPump = true;
- log.debug("New firmware confirmed");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New firmware confirmed");
pump.model = intFromBuff(bytes, 0, 1);
pump.protocol = intFromBuff(bytes, 1, 1);
@@ -42,7 +45,7 @@ public class MsgCheckValue_v2 extends MessageBase {
Notification notification = new Notification(Notification.WRONG_DRIVER, MainApp.gs(R.string.pumpdrivercorrected), Notification.NORMAL);
MainApp.bus().post(new EventNewNotification(notification));
MainApp.getSpecificPlugin(DanaRPlugin.class).disconnect("Wrong Model");
- log.debug("Wrong model selected. Switching to Korean DanaR");
+ log.error("Wrong model selected. Switching to Korean DanaR");
MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setPluginEnabled(PluginType.PUMP, true);
MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setFragmentVisible(PluginType.PUMP, true);
MainApp.getSpecificPlugin(DanaRPlugin.class).setPluginEnabled(PluginType.PUMP, false);
@@ -67,7 +70,7 @@ public class MsgCheckValue_v2 extends MessageBase {
Notification notification = new Notification(Notification.WRONG_DRIVER, MainApp.gs(R.string.pumpdrivercorrected), Notification.NORMAL);
MainApp.bus().post(new EventNewNotification(notification));
DanaRKoreanPlugin.getPlugin().disconnect("Wrong Model");
- log.debug("Wrong model selected. Switching to non APS DanaR");
+ log.error("Wrong model selected. Switching to non APS DanaR");
(MainApp.getSpecificPlugin(DanaRv2Plugin.class)).setPluginEnabled(PluginType.PUMP, false);
(MainApp.getSpecificPlugin(DanaRv2Plugin.class)).setFragmentVisible(PluginType.PUMP, false);
(MainApp.getSpecificPlugin(DanaRPlugin.class)).setPluginEnabled(PluginType.PUMP, true);
@@ -84,7 +87,7 @@ public class MsgCheckValue_v2 extends MessageBase {
ConfigBuilderPlugin.getCommandQueue().readStatus("PumpDriverChange", null); // force new connection
return;
}
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Model: " + String.format("%02X ", pump.model));
log.debug("Protocol: " + String.format("%02X ", pump.protocol));
log.debug("Product Code: " + String.format("%02X ", pump.productCode));
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgHistoryEvents_v2.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgHistoryEvents_v2.java
index 91c01ba38c..04eb6a1a78 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgHistoryEvents_v2.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgHistoryEvents_v2.java
@@ -13,6 +13,7 @@ import info.nightscout.androidaps.db.ExtendedBolus;
import info.nightscout.androidaps.db.Source;
import info.nightscout.androidaps.db.TemporaryBasal;
import info.nightscout.androidaps.events.EventPumpStatusChanged;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.DetailedBolusInfoStorage;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
@@ -20,7 +21,7 @@ import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.utils.DateUtil;
public class MsgHistoryEvents_v2 extends MessageBase {
- private static Logger log = LoggerFactory.getLogger(MsgHistoryEvents_v2.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public boolean done;
public static long lastEventTimeLoaded = 0;
@@ -31,6 +32,8 @@ public class MsgHistoryEvents_v2 extends MessageBase {
gfrom.setTimeInMillis(from);
AddParamDate(gfrom);
done = false;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
public MsgHistoryEvents_v2() {
@@ -41,6 +44,8 @@ public class MsgHistoryEvents_v2 extends MessageBase {
AddParamByte((byte) 0);
AddParamByte((byte) 0);
done = false;
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
@Override
@@ -69,10 +74,12 @@ public class MsgHistoryEvents_v2 extends MessageBase {
DetailedBolusInfo detailedBolusInfo = DetailedBolusInfoStorage.findDetailedBolusInfo(datetime.getTime());
if (detailedBolusInfo == null) {
- log.debug("Detailed bolus info not found for " + datetime.toLocaleString());
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("Detailed bolus info not found for " + datetime.toLocaleString());
detailedBolusInfo = new DetailedBolusInfo();
} else {
- log.debug("Detailed bolus info found: " + detailedBolusInfo);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("Detailed bolus info found: " + detailedBolusInfo);
}
detailedBolusInfo.date = datetime.getTime();
detailedBolusInfo.source = Source.PUMP;
@@ -82,73 +89,86 @@ public class MsgHistoryEvents_v2 extends MessageBase {
switch (recordCode) {
case DanaRPump.TEMPSTART:
- log.debug("EVENT TEMPSTART (" + recordCode + ") " + datetime.toLocaleString() + " Ratio: " + param1 + "% Duration: " + param2 + "min");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("EVENT TEMPSTART (" + recordCode + ") " + datetime.toLocaleString() + " Ratio: " + param1 + "% Duration: " + param2 + "min");
temporaryBasal.percentRate = param1;
temporaryBasal.durationInMinutes = param2;
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(temporaryBasal);
status = "TEMPSTART " + DateUtil.timeString(datetime);
break;
case DanaRPump.TEMPSTOP:
- log.debug("EVENT TEMPSTOP (" + recordCode + ") " + datetime.toLocaleString());
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("EVENT TEMPSTOP (" + recordCode + ") " + datetime.toLocaleString());
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(temporaryBasal);
status = "TEMPSTOP " + DateUtil.timeString(datetime);
break;
case DanaRPump.EXTENDEDSTART:
- log.debug("EVENT EXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("EVENT EXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min");
extendedBolus.insulin = param1 / 100d;
extendedBolus.durationInMinutes = param2;
TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus);
status = "EXTENDEDSTART " + DateUtil.timeString(datetime);
break;
case DanaRPump.EXTENDEDSTOP:
- log.debug("EVENT EXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("EVENT EXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min");
TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus);
status = "EXTENDEDSTOP " + DateUtil.timeString(datetime);
break;
case DanaRPump.BOLUS:
detailedBolusInfo.insulin = param1 / 100d;
boolean newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false);
- log.debug((newRecord ? "**NEW** " : "") + "EVENT BOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug((newRecord ? "**NEW** " : "") + "EVENT BOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min");
DetailedBolusInfoStorage.remove(detailedBolusInfo.date);
status = "BOLUS " + DateUtil.timeString(datetime);
break;
case DanaRPump.DUALBOLUS:
detailedBolusInfo.insulin = param1 / 100d;
newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false);
- log.debug((newRecord ? "**NEW** " : "") + "EVENT DUALBOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug((newRecord ? "**NEW** " : "") + "EVENT DUALBOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min");
DetailedBolusInfoStorage.remove(detailedBolusInfo.date);
status = "DUALBOLUS " + DateUtil.timeString(datetime);
break;
case DanaRPump.DUALEXTENDEDSTART:
- log.debug("EVENT DUALEXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("EVENT DUALEXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min");
extendedBolus.insulin = param1 / 100d;
extendedBolus.durationInMinutes = param2;
TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus);
status = "DUALEXTENDEDSTART " + DateUtil.timeString(datetime);
break;
case DanaRPump.DUALEXTENDEDSTOP:
- log.debug("EVENT DUALEXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("EVENT DUALEXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min");
TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus);
status = "DUALEXTENDEDSTOP " + DateUtil.timeString(datetime);
break;
case DanaRPump.SUSPENDON:
- log.debug("EVENT SUSPENDON (" + recordCode + ") " + datetime.toLocaleString());
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("EVENT SUSPENDON (" + recordCode + ") " + datetime.toLocaleString());
status = "SUSPENDON " + DateUtil.timeString(datetime);
break;
case DanaRPump.SUSPENDOFF:
- log.debug("EVENT SUSPENDOFF (" + recordCode + ") " + datetime.toLocaleString());
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("EVENT SUSPENDOFF (" + recordCode + ") " + datetime.toLocaleString());
status = "SUSPENDOFF " + DateUtil.timeString(datetime);
break;
case DanaRPump.REFILL:
- log.debug("EVENT REFILL (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("EVENT REFILL (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U");
status = "REFILL " + DateUtil.timeString(datetime);
break;
case DanaRPump.PRIME:
- log.debug("EVENT PRIME (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("EVENT PRIME (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U");
status = "PRIME " + DateUtil.timeString(datetime);
break;
case DanaRPump.PROFILECHANGE:
- log.debug("EVENT PROFILECHANGE (" + recordCode + ") " + datetime.toLocaleString() + " No: " + param1 + " CurrentRate: " + (param2 / 100d) + "U/h");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("EVENT PROFILECHANGE (" + recordCode + ") " + datetime.toLocaleString() + " No: " + param1 + " CurrentRate: " + (param2 / 100d) + "U/h");
status = "PROFILECHANGE " + DateUtil.timeString(datetime);
break;
case DanaRPump.CARBS:
@@ -158,11 +178,13 @@ public class MsgHistoryEvents_v2 extends MessageBase {
emptyCarbsInfo.source = Source.PUMP;
emptyCarbsInfo.pumpId = datetime.getTime();
newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(emptyCarbsInfo, false);
- log.debug((newRecord ? "**NEW** " : "") + "EVENT CARBS (" + recordCode + ") " + datetime.toLocaleString() + " Carbs: " + param1 + "g");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug((newRecord ? "**NEW** " : "") + "EVENT CARBS (" + recordCode + ") " + datetime.toLocaleString() + " Carbs: " + param1 + "g");
status = "CARBS " + DateUtil.timeString(datetime);
break;
default:
- log.debug("Event: " + recordCode + " " + datetime.toLocaleString() + " Param1: " + param1 + " Param2: " + param2);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("Event: " + recordCode + " " + datetime.toLocaleString() + " Param1: " + param1 + " Param2: " + param2);
status = "UNKNOWN " + DateUtil.timeString(datetime);
break;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgSetAPSTempBasalStart_v2.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgSetAPSTempBasalStart_v2.java
index 6b6e3045de..42964a64c6 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgSetAPSTempBasalStart_v2.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgSetAPSTempBasalStart_v2.java
@@ -3,11 +3,11 @@ package info.nightscout.androidaps.plugins.PumpDanaRv2.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
public class MsgSetAPSTempBasalStart_v2 extends MessageBase {
- private static Logger log = LoggerFactory.getLogger(MsgSetAPSTempBasalStart_v2.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
protected final int PARAM30MIN = 160;
protected final int PARAM15MIN = 150;
@@ -19,6 +19,8 @@ public class MsgSetAPSTempBasalStart_v2 extends MessageBase {
public MsgSetAPSTempBasalStart_v2(int percent) {
this();
setParams(percent);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message: percent: " + percent);
}
protected void setParams(int percent) {
@@ -29,11 +31,11 @@ public class MsgSetAPSTempBasalStart_v2 extends MessageBase {
AddParamInt(percent);
if (percent < 100) {
AddParamByte((byte) PARAM30MIN);
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("APS Temp basal start percent: " + percent + " duration 30 min");
} else {
AddParamByte((byte) PARAM15MIN);
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("APS Temp basal start percent: " + percent + " duration 15 min");
}
}
@@ -51,11 +53,11 @@ public class MsgSetAPSTempBasalStart_v2 extends MessageBase {
AddParamInt(percent);
if (thirtyMinutes && percent <= 200) { // 30 min is allowed up to 200%
AddParamByte((byte) PARAM30MIN);
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("APS Temp basal start percent: " + percent + " duration 30 min");
} else {
AddParamByte((byte) PARAM15MIN);
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("APS Temp basal start percent: " + percent + " duration 15 min");
}
}
@@ -64,10 +66,11 @@ public class MsgSetAPSTempBasalStart_v2 extends MessageBase {
int result = intFromBuff(bytes, 0, 1);
if (result != 1) {
failed = true;
- log.debug("Set APS temp basal start result: " + result + " FAILED!!!");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("Set APS temp basal start result: " + result + " FAILED!!!");
} else {
failed = false;
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Set APS temp basal start result: " + result);
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgSetHistoryEntry_v2.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgSetHistoryEntry_v2.java
index abeb656f03..0c55b29a3f 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgSetHistoryEntry_v2.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgSetHistoryEntry_v2.java
@@ -6,11 +6,11 @@ import org.slf4j.LoggerFactory;
import java.util.Date;
import java.util.GregorianCalendar;
-import info.nightscout.androidaps.Config;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
public class MsgSetHistoryEntry_v2 extends MessageBase {
- private static Logger log = LoggerFactory.getLogger(MsgSetHistoryEntry_v2.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgSetHistoryEntry_v2() {
SetCommand(0xE004);
@@ -25,7 +25,7 @@ public class MsgSetHistoryEntry_v2 extends MessageBase {
AddParamDateTime(gtime);
AddParamInt(param1);
AddParamInt(param2);
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Set history entry: type: " + type + " date: " + new Date(time).toString() + " param1: " + param1 + " param2: " + param2);
}
@@ -34,9 +34,10 @@ public class MsgSetHistoryEntry_v2 extends MessageBase {
int result = intFromBuff(bytes, 0, 1);
if (result != 1) {
failed = true;
- log.debug("Set history entry result: " + result + " FAILED!!!");
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("Set history entry result: " + result + " FAILED!!!");
} else {
- if (Config.logDanaMessageDetail)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Set history entry result: " + result);
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgStatusAPS_v2.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgStatusAPS_v2.java
index c2f87ee36a..5d0238f2f7 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgStatusAPS_v2.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgStatusAPS_v2.java
@@ -3,15 +3,17 @@ package info.nightscout.androidaps.plugins.PumpDanaRv2.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
public class MsgStatusAPS_v2 extends MessageBase {
- private static Logger log = LoggerFactory.getLogger(MsgStatusAPS_v2.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgStatusAPS_v2() {
SetCommand(0xE001);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
public void handleMessage(byte[] bytes) {
@@ -21,7 +23,7 @@ public class MsgStatusAPS_v2 extends MessageBase {
DanaRPump pump = DanaRPump.getInstance();
pump.iob = iob;
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Delivered so far: " + deliveredSoFar);
log.debug("Current pump IOB: " + iob);
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgStatusBolusExtended_v2.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgStatusBolusExtended_v2.java
index f695f6a792..c9a2446cd9 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgStatusBolusExtended_v2.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgStatusBolusExtended_v2.java
@@ -7,18 +7,17 @@ import org.slf4j.LoggerFactory;
import java.util.Date;
-import info.nightscout.androidaps.Config;
-import info.nightscout.androidaps.MainApp;
-import info.nightscout.androidaps.db.ExtendedBolus;
-import info.nightscout.androidaps.interfaces.TreatmentsInterface;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
public class MsgStatusBolusExtended_v2 extends MessageBase {
- private static Logger log = LoggerFactory.getLogger(MsgStatusBolusExtended_v2.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgStatusBolusExtended_v2() {
SetCommand(0x0207);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
public void handleMessage(byte[] bytes) {
@@ -46,7 +45,7 @@ public class MsgStatusBolusExtended_v2 extends MessageBase {
pump.extendedBolusStart = extendedBolusStart;
pump.extendedBolusRemainingMinutes = extendedBolusRemainingMinutes;
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Is extended bolus running: " + isExtendedInProgress);
log.debug("Extended bolus min: " + extendedBolusMinutes);
log.debug("Extended bolus amount: " + extendedBolusAmount);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgStatusTempBasal_v2.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgStatusTempBasal_v2.java
index 256fa4cd8a..992b15e9ca 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgStatusTempBasal_v2.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgStatusTempBasal_v2.java
@@ -7,18 +7,17 @@ import org.slf4j.LoggerFactory;
import java.util.Date;
-import info.nightscout.androidaps.Config;
-import info.nightscout.androidaps.MainApp;
-import info.nightscout.androidaps.db.TemporaryBasal;
-import info.nightscout.androidaps.interfaces.TreatmentsInterface;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
public class MsgStatusTempBasal_v2 extends MessageBase {
- private static Logger log = LoggerFactory.getLogger(MsgStatusTempBasal_v2.class);
+ private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgStatusTempBasal_v2() {
SetCommand(0x0205);
+ if (L.isEnabled(L.PUMPCOMM))
+ log.debug("New message");
}
public void handleMessage(byte[] bytes) {
@@ -41,7 +40,7 @@ public class MsgStatusTempBasal_v2 extends MessageBase {
pump.tempBasalTotalSec = tempBasalTotalSec;
pump.tempBasalStart = tempBasalStart;
- if (Config.logDanaMessageDetail) {
+ if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Is temp basal running: " + isTempBasalInProgress);
log.debug("Is APS temp basal running: " + isAPSTempBasalInProgress);
log.debug("Current temp basal percent: " + tempBasalPercent);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java
index 1229f23f4e..4065d1624d 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java
@@ -8,12 +8,9 @@ import android.os.SystemClock;
import com.squareup.otto.Subscribe;
-import org.slf4j.LoggerFactory;
-
import java.io.IOException;
import java.util.Date;
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
@@ -25,6 +22,7 @@ import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.events.EventProfileSwitchChange;
import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.interfaces.PumpInterface;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressDialog;
import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity;
@@ -72,7 +70,7 @@ import info.nightscout.androidaps.plugins.Treatments.Treatment;
import info.nightscout.androidaps.queue.Callback;
import info.nightscout.androidaps.queue.commands.Command;
import info.nightscout.utils.DateUtil;
-import info.nightscout.utils.NSUpload;
+import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
import info.nightscout.utils.SP;
import info.nightscout.utils.T;
@@ -81,7 +79,6 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
private long lastHistoryFetched = 0;
public DanaRv2ExecutionService() {
- log = LoggerFactory.getLogger(DanaRv2ExecutionService.class);
mBinder = new LocalBinder();
registerBus();
@@ -105,7 +102,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
@Subscribe
public void onStatusEvent(EventAppExit event) {
- if (Config.logFunctionCalls)
+ if (L.isEnabled(L.PUMP))
log.debug("EventAppExit received");
if (mSerialIOThread != null)
@@ -114,7 +111,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
MainApp.instance().getApplicationContext().unregisterReceiver(receiver);
stopSelf();
- if (Config.logFunctionCalls)
+ if (L.isEnabled(L.PUMP))
log.debug("EventAppExit finished");
}
@@ -126,7 +123,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
public void connect() {
if (mDanaRPump.password != -1 && mDanaRPump.password != SP.getInt(R.string.key_danar_password, -1)) {
- if(System.currentTimeMillis() > lastWrongPumpPassword + 30 * 1000) {
+ if (System.currentTimeMillis() > lastWrongPumpPassword + 30 * 1000) {
Notification notification = new Notification(Notification.WRONG_PUMP_PASSWORD, MainApp.gs(R.string.wrongpumppassword), Notification.URGENT);
notification.soundId = R.raw.error;
lastWrongPumpPassword = System.currentTimeMillis();
@@ -208,10 +205,12 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime)));
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
long timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
- log.debug("Pump time difference: " + timeDiff + " seconds");
+ if (L.isEnabled(L.PUMP))
+ log.debug("Pump time difference: " + timeDiff + " seconds");
if (Math.abs(timeDiff) > 3) {
- if (Math.abs(timeDiff) > 60*60*1.5) {
- log.debug("Pump time difference: " + timeDiff + " seconds - large difference");
+ if (Math.abs(timeDiff) > 60 * 60 * 1.5) {
+ if (L.isEnabled(L.PUMP))
+ log.debug("Pump time difference: " + timeDiff + " seconds - large difference");
//If time-diff is very large, warn user until we can synchronize history readings properly
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
i.putExtra("soundid", R.raw.error);
@@ -231,7 +230,8 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
mSerialIOThread.sendMessage(new MsgSetTime(new Date(DateUtil.now() + T.secs(10).msecs())));
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
- log.debug("Pump time difference: " + timeDiff + " seconds");
+ if (L.isEnabled(L.PUMP))
+ log.debug("Pump time difference: " + timeDiff + " seconds");
}
}
@@ -258,8 +258,9 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
MainApp.bus().post(new EventInitializationChanged());
NSUpload.uploadDeviceStatus();
if (mDanaRPump.dailyTotalUnits > mDanaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) {
- log.debug("Approaching daily limit: " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits);
- if(System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) {
+ if (L.isEnabled(L.PUMP))
+ log.debug("Approaching daily limit: " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits);
+ if (System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) {
Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.gs(R.string.approachingdailylimit), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(reportFail));
NSUpload.uploadError(MainApp.gs(R.string.approachingdailylimit) + ": " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits + "U");
@@ -315,7 +316,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
SystemClock.sleep(500);
}
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.settingtempbasal)));
- mSerialIOThread.sendMessage(new MsgSetAPSTempBasalStart_v2(percent, durationInMinutes == 15, durationInMinutes == 30));
+ mSerialIOThread.sendMessage(new MsgSetAPSTempBasalStart_v2(percent, durationInMinutes == 15, durationInMinutes == 30));
mSerialIOThread.sendMessage(new MsgStatusTempBasal_v2());
loadEvents();
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
@@ -389,7 +390,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
if ((System.currentTimeMillis() - progress.lastReceive) > 15 * 1000L) { // if i didn't receive status for more than 15 sec expecting broken comm
stop.stopped = true;
stop.forced = true;
- log.debug("Communication stopped");
+ log.error("Communication stopped");
}
}
}
@@ -434,7 +435,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
}
public void bolusStop() {
- if (Config.logDanaBTComm)
+ if (L.isEnabled(L.PUMP))
log.debug("bolusStop >>>>> @ " + (mBolusingTreatment == null ? "" : mBolusingTreatment.insulin));
MsgBolusStop stop = new MsgBolusStop();
stop.forced = true;
@@ -461,23 +462,25 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
public PumpEnactResult loadEvents() {
- if(!MainApp.getSpecificPlugin(DanaRv2Plugin.class).isInitialized()){
+ if (!MainApp.getSpecificPlugin(DanaRv2Plugin.class).isInitialized()) {
PumpEnactResult result = new PumpEnactResult().success(false);
result.comment = "pump not initialized";
return result;
}
-
-
+
+
if (!isConnected())
return new PumpEnactResult().success(false);
SystemClock.sleep(300);
MsgHistoryEvents_v2 msg;
if (lastHistoryFetched == 0) {
msg = new MsgHistoryEvents_v2();
- log.debug("Loading complete event history");
+ if (L.isEnabled(L.PUMP))
+ log.debug("Loading complete event history");
} else {
msg = new MsgHistoryEvents_v2(lastHistoryFetched);
- log.debug("Loading event history from: " + new Date(lastHistoryFetched).toLocaleString());
+ if (L.isEnabled(L.PUMP))
+ log.debug("Loading event history from: " + new Date(lastHistoryFetched).toLocaleString());
}
mSerialIOThread.sendMessage(msg);
while (!msg.done && mRfcommSocket.isConnected()) {
@@ -495,7 +498,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
public boolean updateBasalsInPump(final Profile profile) {
if (!isConnected()) return false;
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.updatingbasalrates)));
- double[] basal = DanaRPump.buildDanaRProfileRecord(profile);
+ double[] basal = DanaRPump.getInstance().buildDanaRProfileRecord(profile);
MsgSetBasalProfile msgSet = new MsgSetBasalProfile((byte) 0, basal);
mSerialIOThread.sendMessage(msgSet);
MsgSetActivateBasalProfile msgActivate = new MsgSetActivateBasalProfile((byte) 0);
@@ -512,7 +515,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
long timeToWholeMinute = (60000 - time % 60000);
if (timeToWholeMinute > 59800 || timeToWholeMinute < 3000)
break;
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.waitingfortimesynchronization, (int)(timeToWholeMinute / 1000))));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.waitingfortimesynchronization, (int) (timeToWholeMinute / 1000))));
SystemClock.sleep(Math.min(timeToWholeMinute, 100));
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/InsightPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/InsightPlugin.java
index 5fd8e25f26..661ed0b0a5 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/InsightPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/InsightPlugin.java
@@ -31,6 +31,7 @@ import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.interfaces.PumpInterface;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
@@ -51,7 +52,7 @@ import info.nightscout.androidaps.plugins.PumpInsight.utils.StatusItem;
import info.nightscout.androidaps.plugins.Treatments.Treatment;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.utils.DateUtil;
-import info.nightscout.utils.NSUpload;
+import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
import info.nightscout.utils.SP;
import sugar.free.sightparser.applayer.descriptors.ActiveBolus;
import sugar.free.sightparser.applayer.descriptors.ActiveBolusType;
@@ -460,7 +461,7 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
log.debug("Failure to deliver treatment");
}
- if (Config.logPumpComm)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Delivering treatment insulin: " + detailedBolusInfo.insulin + "U carbs: " + detailedBolusInfo.carbs + "g " + result);
updateGui();
@@ -556,7 +557,7 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
.source(Source.USER);
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempBasal);
updateGui();
- if (Config.logPumpComm) log.debug("Set temp basal " + percent + "% for " + durationInMinutes + "m");
+ if (L.isEnabled(L.PUMPCOMM)) log.debug("Set temp basal " + percent + "% for " + durationInMinutes + "m");
connector.requestHistorySync(5000);
connector.tryToGetPumpStatusAgain();
return new PumpEnactResult().success(true).enacted(true).percent(percent);
@@ -574,7 +575,7 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
cancelExtendedBolus();
realTBRCancel();
updateGui();
- if (Config.logPumpComm) log.debug("Canceling temp basal");
+ if (L.isEnabled(L.PUMPCOMM)) log.debug("Canceling temp basal");
connector.requestHistorySync(5000);
connector.tryToGetPumpStatusAgain();
return new PumpEnactResult().success(true).enacted(true).isTempCancel(true);
@@ -611,7 +612,7 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
updateGui();
connector.requestHistorySync(30000);
connector.tryToGetPumpStatusAgain();
- if (Config.logPumpComm)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Setting extended bolus: " + insulin + " mins:" + durationInMinutes);
return new PumpEnactResult().success(true).enacted(true).duration(durationInMinutes).bolusDelivered(insulin);
} catch (Exception e) {
@@ -632,7 +633,7 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
exStop.source = Source.USER;
TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(exStop);
}
- if (Config.logPumpComm) log.debug("Cancel extended bolus:");
+ if (L.isEnabled(L.PUMPCOMM)) log.debug("Cancel extended bolus:");
if (bolusId != null) connector.requestHistorySync(5000);
connector.tryToGetPumpStatusAgain();
updateGui();
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/history/HistoryIntentAdapter.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/history/HistoryIntentAdapter.java
index 2c2235bf47..87e427737b 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/history/HistoryIntentAdapter.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/history/HistoryIntentAdapter.java
@@ -6,7 +6,7 @@ import info.nightscout.androidaps.R;
import info.nightscout.androidaps.db.CareportalEvent;
import info.nightscout.androidaps.db.TDD;
import info.nightscout.utils.DateUtil;
-import info.nightscout.utils.NSUpload;
+import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
import info.nightscout.utils.SP;
import org.json.JSONException;
import org.json.JSONObject;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMDI/MDIPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMDI/MDIPlugin.java
index fb41a72e88..209d24d193 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMDI/MDIPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMDI/MDIPlugin.java
@@ -8,7 +8,6 @@ import org.slf4j.LoggerFactory;
import java.util.Date;
import info.nightscout.androidaps.BuildConfig;
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.DetailedBolusInfo;
@@ -19,6 +18,7 @@ import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.interfaces.PumpInterface;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.utils.DateUtil;
@@ -149,7 +149,7 @@ public class MDIPlugin extends PluginBase implements PumpInterface {
PumpEnactResult result = new PumpEnactResult();
result.success = false;
result.comment = MainApp.gs(R.string.pumperror);
- if (Config.logPumpComm)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Setting temp basal absolute: " + result);
return result;
}
@@ -159,7 +159,7 @@ public class MDIPlugin extends PluginBase implements PumpInterface {
PumpEnactResult result = new PumpEnactResult();
result.success = false;
result.comment = MainApp.gs(R.string.pumperror);
- if (Config.logPumpComm)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Settings temp basal percent: " + result);
return result;
}
@@ -169,7 +169,7 @@ public class MDIPlugin extends PluginBase implements PumpInterface {
PumpEnactResult result = new PumpEnactResult();
result.success = false;
result.comment = MainApp.gs(R.string.pumperror);
- if (Config.logPumpComm)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Setting extended bolus: " + result);
return result;
}
@@ -179,7 +179,7 @@ public class MDIPlugin extends PluginBase implements PumpInterface {
PumpEnactResult result = new PumpEnactResult();
result.success = false;
result.comment = MainApp.gs(R.string.pumperror);
- if (Config.logPumpComm)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Cancel temp basal: " + result);
return result;
}
@@ -189,7 +189,7 @@ public class MDIPlugin extends PluginBase implements PumpInterface {
PumpEnactResult result = new PumpEnactResult();
result.success = false;
result.comment = MainApp.gs(R.string.pumperror);
- if (Config.logPumpComm)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Canceling extended basal: " + result);
return result;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java
index 12977b89bf..7aae82b8f8 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java
@@ -24,13 +24,14 @@ import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.interfaces.PumpInterface;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
import info.nightscout.androidaps.plugins.PumpVirtual.events.EventVirtualPumpUpdateGui;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.utils.DateUtil;
-import info.nightscout.utils.NSUpload;
+import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
import info.nightscout.utils.SP;
/**
@@ -222,7 +223,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
bolusingEvent.percent = 100;
MainApp.bus().post(bolusingEvent);
SystemClock.sleep(1000);
- if (Config.logPumpComm)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Delivering treatment insulin: " + detailedBolusInfo.insulin + "U carbs: " + detailedBolusInfo.carbs + "g " + result);
MainApp.bus().post(new EventVirtualPumpUpdateGui());
lastDataTime = new Date();
@@ -250,7 +251,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
result.duration = durationInMinutes;
result.comment = MainApp.gs(R.string.virtualpump_resultok);
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempBasal);
- if (Config.logPumpComm)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Setting temp basal absolute: " + result);
MainApp.bus().post(new EventVirtualPumpUpdateGui());
lastDataTime = new Date();
@@ -278,7 +279,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
result.duration = durationInMinutes;
result.comment = MainApp.gs(R.string.virtualpump_resultok);
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempBasal);
- if (Config.logPumpComm)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Settings temp basal percent: " + result);
MainApp.bus().post(new EventVirtualPumpUpdateGui());
lastDataTime = new Date();
@@ -302,7 +303,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
result.duration = durationInMinutes;
result.comment = MainApp.gs(R.string.virtualpump_resultok);
TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus);
- if (Config.logPumpComm)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Setting extended bolus: " + result);
MainApp.bus().post(new EventVirtualPumpUpdateGui());
lastDataTime = new Date();
@@ -320,7 +321,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
TemporaryBasal tempStop = new TemporaryBasal().date(System.currentTimeMillis()).source(Source.USER);
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempStop);
//tempBasal = null;
- if (Config.logPumpComm)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Canceling temp basal: " + result);
MainApp.bus().post(new EventVirtualPumpUpdateGui());
}
@@ -340,7 +341,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
result.enacted = true;
result.isTempCancel = true;
result.comment = MainApp.gs(R.string.virtualpump_resultok);
- if (Config.logPumpComm)
+ if (L.isEnabled(L.PUMPCOMM))
log.debug("Canceling extended basal: " + result);
MainApp.bus().post(new EventVirtualPumpUpdateGui());
lastDataTime = new Date();
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/AbstractSensitivityPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/AbstractSensitivityPlugin.java
index 3e43b6a3d0..9f72f1b119 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/AbstractSensitivityPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/AbstractSensitivityPlugin.java
@@ -3,12 +3,11 @@ package info.nightscout.androidaps.plugins.Sensitivity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.SensitivityInterface;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult;
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
import info.nightscout.utils.Round;
@@ -17,7 +16,7 @@ import info.nightscout.utils.SafeParse;
public abstract class AbstractSensitivityPlugin extends PluginBase implements SensitivityInterface {
- private static final Logger log = LoggerFactory.getLogger(Constants.AUTOSENS);
+ private static final Logger log = LoggerFactory.getLogger(L.AUTOSENS);
public AbstractSensitivityPlugin(PluginDescription pluginDescription) {
super(pluginDescription);
@@ -54,7 +53,7 @@ public abstract class AbstractSensitivityPlugin extends PluginBase implements Se
if (ratio != rawRatio) {
ratioLimit += "Ratio limited from " + rawRatio + " to " + ratio;
- if (Config.logAutosensData)
+ if (L.isEnabled(L.AUTOSENS))
log.debug(ratioLimit);
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityAAPSPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityAAPSPlugin.java
index e5949e7298..350769ec24 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityAAPSPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityAAPSPlugin.java
@@ -10,14 +10,13 @@ import java.util.Arrays;
import java.util.Date;
import java.util.List;
-import info.nightscout.androidaps.Config;
-import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.db.CareportalEvent;
import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult;
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
@@ -29,7 +28,7 @@ import info.nightscout.utils.SP;
*/
public class SensitivityAAPSPlugin extends AbstractSensitivityPlugin {
- private static Logger log = LoggerFactory.getLogger(Constants.AUTOSENS);
+ private static Logger log = LoggerFactory.getLogger(L.AUTOSENS);
static SensitivityAAPSPlugin plugin = null;
@@ -63,18 +62,20 @@ public class SensitivityAAPSPlugin extends AbstractSensitivityPlugin {
Profile profile = MainApp.getConfigBuilder().getProfile();
if (profile == null) {
- log.debug("No profile");
+ log.error("No profile");
return new AutosensResult();
}
if (autosensDataTable == null || autosensDataTable.size() < 4) {
- log.debug("No autosens data available. lastDataTime=" + iobCobCalculatorPlugin.lastDataTime());
+ if (L.isEnabled(L.AUTOSENS))
+ log.debug("No autosens data available. lastDataTime=" + iobCobCalculatorPlugin.lastDataTime());
return new AutosensResult();
}
AutosensData current = iobCobCalculatorPlugin.getAutosensData(toTime); // this is running inside lock already
if (current == null) {
- log.debug("No autosens data available. toTime: " + DateUtil.dateAndTimeString(toTime) + " lastDataTime: " + iobCobCalculatorPlugin.lastDataTime());
+ if (L.isEnabled(L.AUTOSENS))
+ log.debug("No autosens data available. toTime: " + DateUtil.dateAndTimeString(toTime) + " lastDataTime: " + iobCobCalculatorPlugin.lastDataTime());
return new AutosensResult();
}
@@ -132,7 +133,7 @@ public class SensitivityAAPSPlugin extends AbstractSensitivityPlugin {
String ratioLimit = "";
String sensResult = "";
- if (Config.logAutosensData)
+ if (L.isEnabled(L.AUTOSENS))
log.debug("Records: " + index + " " + pastSensitivity);
Arrays.sort(deviations);
@@ -149,13 +150,13 @@ public class SensitivityAAPSPlugin extends AbstractSensitivityPlugin {
sensResult = "Sensitivity normal";
}
- if (Config.logAutosensData)
+ if (L.isEnabled(L.AUTOSENS))
log.debug(sensResult);
AutosensResult output = fillResult(ratio, current.cob, pastSensitivity, ratioLimit,
sensResult, deviationsArray.size());
- if (Config.logAutosensData) {
+ if (L.isEnabled(L.AUTOSENS)) {
log.debug("Sensitivity to: {}, percentile: {} ratio: {} mealCOB: ",
new Date(toTime).toLocaleString(),
percentile, output.ratio, ratio, current.cob);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityOref0Plugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityOref0Plugin.java
index 142feba8da..2ddf402763 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityOref0Plugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityOref0Plugin.java
@@ -10,14 +10,13 @@ import java.util.Arrays;
import java.util.Date;
import java.util.List;
-import info.nightscout.androidaps.Config;
-import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.db.CareportalEvent;
import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult;
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
@@ -28,7 +27,7 @@ import info.nightscout.utils.DateUtil;
*/
public class SensitivityOref0Plugin extends AbstractSensitivityPlugin {
- private static Logger log = LoggerFactory.getLogger(Constants.AUTOSENS);
+ private static Logger log = LoggerFactory.getLogger(L.AUTOSENS);
static SensitivityOref0Plugin plugin = null;
@@ -58,18 +57,20 @@ public class SensitivityOref0Plugin extends AbstractSensitivityPlugin {
Profile profile = MainApp.getConfigBuilder().getProfile();
if (profile == null) {
- log.debug("No profile");
+ log.error("No profile");
return new AutosensResult();
}
if (autosensDataTable == null || autosensDataTable.size() < 4) {
- log.debug("No autosens data available. lastDataTime=" + iobCobCalculatorPlugin.lastDataTime());
+ if (L.isEnabled(L.AUTOSENS))
+ log.debug("No autosens data available. lastDataTime=" + iobCobCalculatorPlugin.lastDataTime());
return new AutosensResult();
}
AutosensData current = iobCobCalculatorPlugin.getAutosensData(toTime); // this is running inside lock already
if (current == null) {
- log.debug("No autosens data available. toTime: " + DateUtil.dateAndTimeString(toTime) + " lastDataTime: " + iobCobCalculatorPlugin.lastDataTime());
+ if (L.isEnabled(L.AUTOSENS))
+ log.debug("No autosens data available. toTime: " + DateUtil.dateAndTimeString(toTime) + " lastDataTime: " + iobCobCalculatorPlugin.lastDataTime());
return new AutosensResult();
}
@@ -127,14 +128,14 @@ public class SensitivityOref0Plugin extends AbstractSensitivityPlugin {
String ratioLimit = "";
String sensResult = "";
- if (Config.logAutosensData)
+ if (L.isEnabled(L.AUTOSENS))
log.debug("Records: " + index + " " + pastSensitivity);
Arrays.sort(deviations);
for (double i = 0.9; i > 0.1; i = i - 0.02) {
if (IobCobCalculatorPlugin.percentile(deviations, (i + 0.02)) >= 0 && IobCobCalculatorPlugin.percentile(deviations, i) < 0) {
- if (Config.logAutosensData)
+ if (L.isEnabled(L.AUTOSENS))
log.debug(Math.round(100 * i) + "% of non-meal deviations negative (target 45%-50%)");
}
}
@@ -153,7 +154,7 @@ public class SensitivityOref0Plugin extends AbstractSensitivityPlugin {
sensResult = "Sensitivity normal";
}
- if (Config.logAutosensData)
+ if (L.isEnabled(L.AUTOSENS))
log.debug(sensResult);
ratio = 1 + (basalOff / profile.getMaxDailyBasal());
@@ -161,7 +162,7 @@ public class SensitivityOref0Plugin extends AbstractSensitivityPlugin {
AutosensResult output = fillResult(ratio, current.cob, pastSensitivity, ratioLimit,
sensResult, deviationsArray.size());
- if (Config.logAutosensData)
+ if (L.isEnabled(L.AUTOSENS))
log.debug("Sensitivity to: {} ratio: {} mealCOB: {}",
new Date(toTime).toLocaleString(), output.ratio, current.cob);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityOref1Plugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityOref1Plugin.java
index 4eb67cc69f..fe56899fea 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityOref1Plugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityOref1Plugin.java
@@ -10,14 +10,13 @@ import java.util.Arrays;
import java.util.Date;
import java.util.List;
-import info.nightscout.androidaps.Config;
-import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.db.CareportalEvent;
import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult;
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
@@ -28,7 +27,7 @@ import info.nightscout.utils.DateUtil;
*/
public class SensitivityOref1Plugin extends AbstractSensitivityPlugin {
- private static Logger log = LoggerFactory.getLogger(Constants.AUTOSENS);
+ private static Logger log = LoggerFactory.getLogger(L.AUTOSENS);
static SensitivityOref1Plugin plugin = null;
@@ -57,19 +56,21 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin {
Profile profile = MainApp.getConfigBuilder().getProfile();
if (profile == null) {
- log.debug("No profile");
+ log.error("No profile");
return new AutosensResult();
}
if (autosensDataTable == null || autosensDataTable.size() < 4) {
- log.debug("No autosens data available. lastDataTime=" + iobCobCalculatorPlugin.lastDataTime());
+ if (L.isEnabled(L.AUTOSENS))
+ log.debug("No autosens data available. lastDataTime=" + iobCobCalculatorPlugin.lastDataTime());
return new AutosensResult();
}
// the current
AutosensData current = iobCobCalculatorPlugin.getAutosensData(toTime); // this is running inside lock already
if (current == null) {
- log.debug("No autosens data available. toTime: " + DateUtil.dateAndTimeString(toTime) + " lastDataTime: " + iobCobCalculatorPlugin.lastDataTime());
+ if (L.isEnabled(L.AUTOSENS))
+ log.debug("No autosens data available. toTime: " + DateUtil.dateAndTimeString(toTime) + " lastDataTime: " + iobCobCalculatorPlugin.lastDataTime());
return new AutosensResult();
}
@@ -121,11 +122,11 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin {
// when we have less than 8h worth of deviation data, add up to 90m of zero deviations
// this dampens any large sensitivity changes detected based on too little data, without ignoring them completely
- if (Config.logAutosensData)
+ if (L.isEnabled(L.AUTOSENS))
log.debug("Using most recent " + deviationsArray.size() + " deviations");
if (deviationsArray.size() < 96) {
int pad = Math.round((1 - deviationsArray.size() / 96) * 18);
- if (Config.logAutosensData)
+ if (L.isEnabled(L.AUTOSENS))
log.debug("Adding " + pad + " more zero deviations");
for (int d = 0; d < pad; d++) {
//process.stderr.write(".");
@@ -142,18 +143,18 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin {
String ratioLimit = "";
String sensResult = "";
- if (Config.logAutosensData)
+ if (L.isEnabled(L.AUTOSENS))
log.debug("Records: " + index + " " + pastSensitivity);
Arrays.sort(deviations);
for (double i = 0.9; i > 0.1; i = i - 0.01) {
if (IobCobCalculatorPlugin.percentile(deviations, (i + 0.01)) >= 0 && IobCobCalculatorPlugin.percentile(deviations, i) < 0) {
- if (Config.logAutosensData)
+ if (L.isEnabled(L.AUTOSENS))
log.debug(Math.round(100 * i) + "% of non-meal deviations negative (>50% = sensitivity)");
}
if (IobCobCalculatorPlugin.percentile(deviations, (i + 0.01)) > 0 && IobCobCalculatorPlugin.percentile(deviations, i) <= 0) {
- if (Config.logAutosensData)
+ if (L.isEnabled(L.AUTOSENS))
log.debug(Math.round(100 * i) + "% of non-meal deviations negative (>50% = resistance)");
}
}
@@ -172,7 +173,7 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin {
sensResult = "Sensitivity normal";
}
- if (Config.logAutosensData)
+ if (L.isEnabled(L.AUTOSENS))
log.debug(sensResult);
ratio = 1 + (basalOff / profile.getMaxDailyBasal());
@@ -180,7 +181,7 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin {
AutosensResult output = fillResult(ratio, current.cob, pastSensitivity, ratioLimit,
sensResult, deviationsArray.size());
- if (Config.logAutosensData)
+ if (L.isEnabled(L.AUTOSENS))
log.debug("Sensitivity to: {} ratio: {} mealCOB: {}",
new Date(toTime).toLocaleString(), output.ratio, current.cob);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityWeightedAveragePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityWeightedAveragePlugin.java
index 0a98b19289..82c3d04d91 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityWeightedAveragePlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityWeightedAveragePlugin.java
@@ -8,14 +8,13 @@ import org.slf4j.LoggerFactory;
import java.util.Date;
import java.util.List;
-import info.nightscout.androidaps.Config;
-import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.db.CareportalEvent;
import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult;
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
@@ -27,7 +26,7 @@ import info.nightscout.utils.SP;
*/
public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin {
- private static Logger log = LoggerFactory.getLogger(Constants.AUTOSENS);
+ private static Logger log = LoggerFactory.getLogger(L.AUTOSENS);
private static SensitivityWeightedAveragePlugin plugin = null;
@@ -59,13 +58,14 @@ public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin
int hoursForDetection = SP.getInt(R.string.key_openapsama_autosens_period, defaultHours);
if (autosensDataTable == null || autosensDataTable.size() < 4) {
- log.debug("No autosens data available. lastDataTime=" + iobCobCalculatorPlugin.lastDataTime());
+ if (L.isEnabled(L.AUTOSENS))
+ log.debug("No autosens data available. lastDataTime=" + iobCobCalculatorPlugin.lastDataTime());
return new AutosensResult();
}
AutosensData current = iobCobCalculatorPlugin.getAutosensData(toTime); // this is running inside lock already
if (current == null) {
- if (Config.logAutosensData)
+ if (L.isEnabled(L.AUTOSENS))
log.debug("No autosens data available. toTime: " + DateUtil.dateAndTimeString(toTime) + " lastDataTime: " + iobCobCalculatorPlugin.lastDataTime());
return new AutosensResult();
}
@@ -73,7 +73,7 @@ public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin
Profile profile = MainApp.getConfigBuilder().getProfile();
if (profile == null) {
- if (Config.logAutosensData)
+ if (L.isEnabled(L.AUTOSENS))
log.debug("No profile available");
return new AutosensResult();
}
@@ -131,11 +131,11 @@ public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin
}
if (data.size() == 0) {
- if (Config.logAutosensData)
+ if (L.isEnabled(L.AUTOSENS))
log.debug("Data size: " + data.size() + " fromTime: " + DateUtil.dateAndTimeString(fromTime) + " toTime: " + DateUtil.dateAndTimeString(toTime));
return new AutosensResult();
} else {
- if (Config.logAutosensData)
+ if (L.isEnabled(L.AUTOSENS))
log.debug("Data size: " + data.size() + " fromTime: " + DateUtil.dateAndTimeString(fromTime) + " toTime: " + DateUtil.dateAndTimeString(toTime));
}
@@ -160,7 +160,7 @@ public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin
String ratioLimit = "";
String sensResult;
- if (Config.logAutosensData)
+ if (L.isEnabled(L.AUTOSENS))
log.debug("Records: " + index + " " + pastSensitivity);
double average = weightedsum / weights;
@@ -175,13 +175,13 @@ public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin
sensResult = "Sensitivity normal";
}
- if (Config.logAutosensData)
+ if (L.isEnabled(L.AUTOSENS))
log.debug(sensResult);
AutosensResult output = fillResult(ratio, current.cob, pastSensitivity, ratioLimit,
sensResult, data.size());
- if (Config.logAutosensData)
+ if (L.isEnabled(L.AUTOSENS))
log.debug("Sensitivity to: {} weightedaverage: {} ratio: {} mealCOB: {}", new Date(toTime).toLocaleString(),
average, output.ratio, current.cob);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java
index 55f7ee9e50..b372ca7cb8 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java
@@ -21,7 +21,7 @@ import java.util.List;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
-import info.nightscout.androidaps.Services.Intents;
+import info.nightscout.androidaps.services.Intents;
import info.nightscout.androidaps.data.DetailedBolusInfo;
import info.nightscout.androidaps.data.GlucoseStatus;
import info.nightscout.androidaps.data.IobTotal;
@@ -45,7 +45,7 @@ import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.androidaps.queue.Callback;
import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.FabricPrivacy;
-import info.nightscout.utils.NSUpload;
+import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
import info.nightscout.utils.SP;
import info.nightscout.utils.SafeParse;
import info.nightscout.utils.T;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Source/BGSourceFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Source/BGSourceFragment.java
index 3e9a79d459..cdd77ca1b2 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Source/BGSourceFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Source/BGSourceFragment.java
@@ -27,7 +27,7 @@ import info.nightscout.androidaps.events.EventNewBG;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.FabricPrivacy;
-import info.nightscout.utils.NSUpload;
+import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
/**
* Created by mike on 16.10.2017.
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceDexcomG5Plugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceDexcomG5Plugin.java
index b47f8ae1e1..46d138c73d 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceDexcomG5Plugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceDexcomG5Plugin.java
@@ -10,7 +10,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config;
-import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.db.BgReading;
@@ -18,7 +17,8 @@ import info.nightscout.androidaps.interfaces.BgSourceInterface;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType;
-import info.nightscout.utils.NSUpload;
+import info.nightscout.androidaps.logging.L;
+import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
import info.nightscout.utils.SP;
/**
@@ -26,7 +26,7 @@ import info.nightscout.utils.SP;
*/
public class SourceDexcomG5Plugin extends PluginBase implements BgSourceInterface {
- private static Logger log = LoggerFactory.getLogger(Constants.BGSOURCE);
+ private static Logger log = LoggerFactory.getLogger(L.BGSOURCE);
private static SourceDexcomG5Plugin plugin = null;
@@ -65,12 +65,12 @@ public class SourceDexcomG5Plugin extends PluginBase implements BgSourceInterfac
BgReading bgReading = new BgReading();
String data = bundle.getString("data");
- if (Config.logBgSource)
+ if (L.isEnabled(L.BGSOURCE))
log.debug("Received Dexcom Data", data);
try {
JSONArray jsonArray = new JSONArray(data);
- if (Config.logBgSource)
+ if (L.isEnabled(L.BGSOURCE))
log.debug("Received Dexcom Data size:" + jsonArray.length());
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject json = jsonArray.getJSONObject(i);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceGlimpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceGlimpPlugin.java
index 761457d296..07fdba51ee 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceGlimpPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceGlimpPlugin.java
@@ -6,8 +6,6 @@ import android.os.Bundle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.db.BgReading;
@@ -15,13 +13,14 @@ import info.nightscout.androidaps.interfaces.BgSourceInterface;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType;
-import info.nightscout.utils.BundleLogger;
+import info.nightscout.androidaps.logging.BundleLogger;
+import info.nightscout.androidaps.logging.L;
/**
* Created by mike on 05.08.2016.
*/
public class SourceGlimpPlugin extends PluginBase implements BgSourceInterface {
- private static Logger log = LoggerFactory.getLogger(Constants.BGSOURCE);
+ private static Logger log = LoggerFactory.getLogger(L.BGSOURCE);
private static SourceGlimpPlugin plugin = null;
@@ -53,7 +52,7 @@ public class SourceGlimpPlugin extends PluginBase implements BgSourceInterface {
Bundle bundle = intent.getExtras();
if (bundle == null) return;
- if (Config.logBgSource)
+ if (L.isEnabled(L.BGSOURCE))
log.debug("Received Glimp Data: " + BundleLogger.log(bundle));
BgReading bgReading = new BgReading();
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceMM640gPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceMM640gPlugin.java
index e96ea1b318..8bc6811ef4 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceMM640gPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceMM640gPlugin.java
@@ -9,8 +9,6 @@ import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.db.BgReading;
@@ -18,12 +16,13 @@ import info.nightscout.androidaps.interfaces.BgSourceInterface;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType;
+import info.nightscout.androidaps.logging.L;
/**
* Created by mike on 05.08.2016.
*/
public class SourceMM640gPlugin extends PluginBase implements BgSourceInterface {
- private static Logger log = LoggerFactory.getLogger(Constants.BGSOURCE);
+ private static Logger log = LoggerFactory.getLogger(L.BGSOURCE);
private static SourceMM640gPlugin plugin = null;
@@ -60,7 +59,7 @@ public class SourceMM640gPlugin extends PluginBase implements BgSourceInterface
if (collection.equals("entries")) {
final String data = bundle.getString("data");
- if (Config.logBgSource)
+ if (L.isEnabled(L.BGSOURCE))
log.debug("Received MM640g Data: ", data);
if ((data != null) && (data.length() > 0)) {
@@ -81,7 +80,7 @@ public class SourceMM640gPlugin extends PluginBase implements BgSourceInterface
MainApp.getDbHelper().createIfNotExists(bgReading, "MM640g");
break;
default:
- if (Config.logBgSource)
+ if (L.isEnabled(L.BGSOURCE))
log.debug("Unknown entries type: " + type);
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceNSClientPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceNSClientPlugin.java
index 89408d3e46..eb901ca1b7 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceNSClientPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceNSClientPlugin.java
@@ -9,7 +9,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config;
-import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.db.BgReading;
@@ -17,6 +16,7 @@ import info.nightscout.androidaps.interfaces.BgSourceInterface;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConstraintsObjectives.ObjectivesPlugin;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSgv;
import info.nightscout.utils.JsonHelper;
@@ -26,7 +26,7 @@ import info.nightscout.utils.SP;
* Created by mike on 05.08.2016.
*/
public class SourceNSClientPlugin extends PluginBase implements BgSourceInterface {
- private static Logger log = LoggerFactory.getLogger(Constants.BGSOURCE);
+ private static Logger log = LoggerFactory.getLogger(L.BGSOURCE);
private static SourceNSClientPlugin plugin = null;
@@ -66,7 +66,7 @@ public class SourceNSClientPlugin extends PluginBase implements BgSourceInterfac
try {
if (bundles.containsKey("sgv")) {
String sgvstring = bundles.getString("sgv");
- if (Config.logBgSource)
+ if (L.isEnabled(L.BGSOURCE))
log.debug("Received NS Data: " + sgvstring);
JSONObject sgvJson = new JSONObject(sgvstring);
@@ -75,7 +75,7 @@ public class SourceNSClientPlugin extends PluginBase implements BgSourceInterfac
if (bundles.containsKey("sgvs")) {
String sgvstring = bundles.getString("sgvs");
- if (Config.logBgSource)
+ if (L.isEnabled(L.BGSOURCE))
log.debug("Received NS Data: " + sgvstring);
JSONArray jsonArray = new JSONArray(sgvstring);
for (int i = 0; i < jsonArray.length(); i++) {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourcePoctechPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourcePoctechPlugin.java
index 071943065d..4cdd8dd810 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourcePoctechPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourcePoctechPlugin.java
@@ -18,15 +18,16 @@ import info.nightscout.androidaps.interfaces.BgSourceInterface;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.utils.JsonHelper;
-import info.nightscout.utils.NSUpload;
+import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
import info.nightscout.utils.SP;
/**
* Created by mike on 05.08.2016.
*/
public class SourcePoctechPlugin extends PluginBase implements BgSourceInterface {
- private static Logger log = LoggerFactory.getLogger(Constants.BGSOURCE);
+ private static Logger log = LoggerFactory.getLogger(L.BGSOURCE);
private static SourcePoctechPlugin plugin = null;
@@ -63,12 +64,12 @@ public class SourcePoctechPlugin extends PluginBase implements BgSourceInterface
BgReading bgReading = new BgReading();
String data = bundle.getString("data");
- if (Config.logBgSource)
+ if (L.isEnabled(L.BGSOURCE))
log.debug("Received Poctech Data", data);
try {
JSONArray jsonArray = new JSONArray(data);
- if (Config.logBgSource)
+ if (L.isEnabled(L.BGSOURCE))
log.debug("Received Poctech Data size:" + jsonArray.length());
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject json = jsonArray.getJSONObject(i);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceXdripPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceXdripPlugin.java
index 77cf5e61d0..eeffa87324 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceXdripPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceXdripPlugin.java
@@ -6,23 +6,22 @@ import android.os.Bundle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
-import info.nightscout.androidaps.Services.Intents;
+import info.nightscout.androidaps.logging.L;
+import info.nightscout.androidaps.services.Intents;
import info.nightscout.androidaps.db.BgReading;
import info.nightscout.androidaps.interfaces.BgSourceInterface;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType;
-import info.nightscout.utils.BundleLogger;
+import info.nightscout.androidaps.logging.BundleLogger;
/**
* Created by mike on 05.08.2016.
*/
public class SourceXdripPlugin extends PluginBase implements BgSourceInterface {
- private static Logger log = LoggerFactory.getLogger(Constants.BGSOURCE);
+ private static Logger log = LoggerFactory.getLogger(L.BGSOURCE);
private static SourceXdripPlugin plugin = null;
@@ -56,7 +55,7 @@ public class SourceXdripPlugin extends PluginBase implements BgSourceInterface {
Bundle bundle = intent.getExtras();
if (bundle == null) return;
- if (Config.logBgSource)
+ if (L.isEnabled(L.BGSOURCE))
log.debug("Received xDrip data: " + BundleLogger.log(intent.getExtras()));
BgReading bgReading = new BgReading();
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/Treatment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/Treatment.java
index 73423c0eab..401d808e60 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/Treatment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/Treatment.java
@@ -29,8 +29,6 @@ import info.nightscout.utils.JsonHelper;
@DatabaseTable(tableName = Treatment.TABLE_TREATMENTS)
public class Treatment implements DataPointWithLabelInterface {
- private static Logger log = LoggerFactory.getLogger(Treatment.class);
-
public static final String TABLE_TREATMENTS = "Treatments";
@DatabaseField(id = true)
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentService.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentService.java
index e701986e89..ab2e6b4e87 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentService.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentService.java
@@ -37,6 +37,7 @@ import info.nightscout.androidaps.events.Event;
import info.nightscout.androidaps.events.EventNsTreatment;
import info.nightscout.androidaps.events.EventReloadTreatmentData;
import info.nightscout.androidaps.events.EventTreatmentChange;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventNewHistoryData;
import info.nightscout.utils.JsonHelper;
@@ -46,7 +47,7 @@ import info.nightscout.utils.JsonHelper;
*/
public class TreatmentService extends OrmLiteBaseService {
- private static Logger log = LoggerFactory.getLogger(TreatmentService.class);
+ private static Logger log = LoggerFactory.getLogger(L.DATATREATMENTS);
private static final ScheduledExecutorService treatmentEventWorker = Executors.newSingleThreadScheduledExecutor();
private static ScheduledFuture> scheduledTreatmentEventPost = null;
@@ -102,7 +103,8 @@ public class TreatmentService extends OrmLiteBaseService {
public void onCreate() {
super.onCreate();
try {
- log.info("onCreate");
+ if (L.isEnabled(L.DATATREATMENTS))
+ log.info("onCreate");
TableUtils.createTableIfNotExists(this.getConnectionSource(), Treatment.class);
} catch (SQLException e) {
log.error("Can't create database", e);
@@ -121,7 +123,8 @@ public class TreatmentService extends OrmLiteBaseService {
throw new RuntimeException(e);
}
} else {
- log.info("onUpgrade");
+ if (L.isEnabled(L.DATATREATMENTS))
+ log.info("onUpgrade");
// this.resetFood();
}
}
@@ -161,10 +164,14 @@ public class TreatmentService extends OrmLiteBaseService {
class PostRunnable implements Runnable {
public void run() {
- log.debug("Firing EventFoodChange");
+ if (L.isEnabled(L.DATATREATMENTS))
+ log.debug("Firing EventReloadTreatmentData");
MainApp.bus().post(event);
- if (DatabaseHelper.earliestDataChange != null)
+ if (DatabaseHelper.earliestDataChange != null) {
+ if (L.isEnabled(L.DATATREATMENTS))
+ log.debug("Firing EventNewHistoryData");
MainApp.bus().post(new EventNewHistoryData(DatabaseHelper.earliestDataChange));
+ }
DatabaseHelper.earliestDataChange = null;
callback.setPost(null);
}
@@ -252,13 +259,14 @@ public class TreatmentService extends OrmLiteBaseService {
if (existingTreatment != null) {
boolean equalRePumpHistory = existingTreatment.equalsRePumpHistory(treatment);
boolean sameSource = existingTreatment.source == treatment.source;
- if(!equalRePumpHistory) {
+ if (!equalRePumpHistory) {
// another treatment exists. Update it with the treatment coming from the pump
- log.debug("TREATMENT: Pump record already found in database: " + existingTreatment.toString() + " wanting to add " + treatment.toString());
+ if (L.isEnabled(L.DATATREATMENTS))
+ log.debug("Pump record already found in database: " + existingTreatment.toString() + " wanting to add " + treatment.toString());
long oldDate = existingTreatment.date;
//preserve carbs
- if(existingTreatment.isValid && existingTreatment.carbs > 0 && treatment.carbs == 0){
+ if (existingTreatment.isValid && existingTreatment.carbs > 0 && treatment.carbs == 0) {
treatment.carbs = existingTreatment.carbs;
}
@@ -278,13 +286,14 @@ public class TreatmentService extends OrmLiteBaseService {
boolean equalRePumpHistory = existingTreatment.equalsRePumpHistory(treatment);
boolean sameSource = existingTreatment.source == treatment.source;
long oldDate = existingTreatment.date;
- log.debug("TREATMENT: Pump record already found in database: " + existingTreatment.toString() + " wanting to add " + treatment.toString());
+ if (L.isEnabled(L.DATATREATMENTS))
+ log.debug("Pump record already found in database: " + existingTreatment.toString() + " wanting to add " + treatment.toString());
//preserve carbs
- if(existingTreatment.isValid && existingTreatment.carbs > 0 && treatment.carbs == 0){
+ if (existingTreatment.isValid && existingTreatment.carbs > 0 && treatment.carbs == 0) {
treatment.carbs = existingTreatment.carbs;
}
-
+
getDao().delete(existingTreatment); // need to delete/create because date may change too
existingTreatment.copyFrom(treatment);
getDao().create(existingTreatment);
@@ -294,7 +303,8 @@ public class TreatmentService extends OrmLiteBaseService {
return new UpdateReturn(equalRePumpHistory || sameSource, false);
}
getDao().create(treatment);
- log.debug("TREATMENT: New record from: " + Source.getString(treatment.source) + " " + treatment.toString());
+ if (L.isEnabled(L.DATATREATMENTS))
+ log.debug("New record from: " + Source.getString(treatment.source) + " " + treatment.toString());
DatabaseHelper.updateEarliestDataChange(treatment.date);
scheduleTreatmentChange(treatment);
return new UpdateReturn(true, true);
@@ -308,7 +318,8 @@ public class TreatmentService extends OrmLiteBaseService {
getDao().delete(old); // need to delete/create because date may change too
old.copyFrom(treatment);
getDao().create(old);
- log.debug("TREATMENT: Updating record by date from: " + Source.getString(treatment.source) + " " + old.toString());
+ if (L.isEnabled(L.DATATREATMENTS))
+ log.debug("Updating record by date from: " + Source.getString(treatment.source) + " " + old.toString());
if (historyChange) {
DatabaseHelper.updateEarliestDataChange(oldDate);
DatabaseHelper.updateEarliestDataChange(old.date);
@@ -328,7 +339,8 @@ public class TreatmentService extends OrmLiteBaseService {
getDao().delete(old); // need to delete/create because date may change too
old.copyFrom(treatment);
getDao().create(old);
- log.debug("TREATMENT: Updating record by _id from: " + Source.getString(treatment.source) + " " + old.toString());
+ if (L.isEnabled(L.DATATREATMENTS))
+ log.debug("Updating record by _id from: " + Source.getString(treatment.source) + " " + old.toString());
if (historyChange) {
DatabaseHelper.updateEarliestDataChange(oldDate);
DatabaseHelper.updateEarliestDataChange(old.date);
@@ -339,14 +351,16 @@ public class TreatmentService extends OrmLiteBaseService {
}
}
getDao().create(treatment);
- log.debug("TREATMENT: New record from: " + Source.getString(treatment.source) + " " + treatment.toString());
+ if (L.isEnabled(L.DATATREATMENTS))
+ log.debug("New record from: " + Source.getString(treatment.source) + " " + treatment.toString());
DatabaseHelper.updateEarliestDataChange(treatment.date);
scheduleTreatmentChange(treatment);
return new UpdateReturn(true, true);
}
if (treatment.source == Source.USER) {
getDao().create(treatment);
- log.debug("TREATMENT: New record from: " + Source.getString(treatment.source) + " " + treatment.toString());
+ if (L.isEnabled(L.DATATREATMENTS))
+ log.debug("New record from: " + Source.getString(treatment.source) + " " + treatment.toString());
DatabaseHelper.updateEarliestDataChange(treatment.date);
scheduleTreatmentChange(treatment);
return new UpdateReturn(true, true);
@@ -357,8 +371,10 @@ public class TreatmentService extends OrmLiteBaseService {
return new UpdateReturn(false, false);
}
- /** Returns the record for the given id, null if none, throws RuntimeException
- * if multiple records with the same pump id exist. */
+ /**
+ * Returns the record for the given id, null if none, throws RuntimeException
+ * if multiple records with the same pump id exist.
+ */
@Nullable
public Treatment getPumpRecordById(long pumpId) {
try {
@@ -368,9 +384,12 @@ public class TreatmentService extends OrmLiteBaseService {
PreparedQuery preparedQuery = queryBuilder.prepare();
List result = getDao().query(preparedQuery);
switch (result.size()) {
- case 0: return null;
- case 1: return result.get(0);
- default: throw new RuntimeException("Multiple records with the same pump id found: " + result.toString());
+ case 0:
+ return null;
+ case 1:
+ return result.get(0);
+ default:
+ throw new RuntimeException("Multiple records with the same pump id found: " + result.toString());
}
} catch (SQLException e) {
throw new RuntimeException(e);
@@ -393,7 +412,8 @@ public class TreatmentService extends OrmLiteBaseService {
private void deleteByNSId(String _id) {
Treatment stored = findByNSId(_id);
if (stored != null) {
- log.debug("TREATMENT: Removing Treatment record from database: " + stored.toString());
+ if (L.isEnabled(L.DATATREATMENTS))
+ log.debug("Removing Treatment record from database: " + stored.toString());
delete(stored);
DatabaseHelper.updateEarliestDataChange(stored.date);
scheduleTreatmentChange(null);
@@ -480,10 +500,11 @@ public class TreatmentService extends OrmLiteBaseService {
}
public class UpdateReturn {
- public UpdateReturn(boolean success, boolean newRecord){
+ public UpdateReturn(boolean success, boolean newRecord) {
this.success = success;
this.newRecord = newRecord;
}
+
boolean newRecord;
boolean success;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsFragment.java
index ea75dfad6a..550522313d 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsFragment.java
@@ -27,8 +27,6 @@ import info.nightscout.androidaps.plugins.Treatments.fragments.TreatmentsTempora
import info.nightscout.utils.FabricPrivacy;
public class TreatmentsFragment extends SubscriberFragment implements View.OnClickListener {
- private static Logger log = LoggerFactory.getLogger(TreatmentsFragment.class);
-
TextView treatmentsTab;
TextView extendedBolusesTab;
TextView tempBasalsTab;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java
index b701f66afc..5c952b58f1 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java
@@ -37,6 +37,7 @@ import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
@@ -47,7 +48,7 @@ import info.nightscout.androidaps.plugins.Sensitivity.SensitivityAAPSPlugin;
import info.nightscout.androidaps.plugins.Sensitivity.SensitivityWeightedAveragePlugin;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.FabricPrivacy;
-import info.nightscout.utils.NSUpload;
+import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
import info.nightscout.utils.SP;
import info.nightscout.utils.T;
@@ -55,7 +56,7 @@ import info.nightscout.utils.T;
* Created by mike on 05.08.2016.
*/
public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface {
- private static Logger log = LoggerFactory.getLogger(TreatmentsPlugin.class);
+ private Logger log = LoggerFactory.getLogger(L.DATATREATMENTS);
private static TreatmentsPlugin treatmentsPlugin;
@@ -109,6 +110,8 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
}
private void initializeTreatmentData() {
+ if (L.isEnabled(L.DATATREATMENTS))
+ log.debug("initializeTreatmentData");
double dia = Constants.defaultDIA;
if (MainApp.getConfigBuilder() != null && MainApp.getConfigBuilder().getProfile() != null)
dia = MainApp.getConfigBuilder().getProfile().getDia();
@@ -120,6 +123,8 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
}
private void initializeTempBasalData() {
+ if (L.isEnabled(L.DATATREATMENTS))
+ log.debug("initializeTempBasalData");
double dia = Constants.defaultDIA;
if (MainApp.getConfigBuilder() != null && MainApp.getConfigBuilder().getProfile() != null)
dia = MainApp.getConfigBuilder().getProfile().getDia();
@@ -132,6 +137,8 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
}
private void initializeExtendedBolusData() {
+ if (L.isEnabled(L.DATATREATMENTS))
+ log.debug("initializeExtendedBolusData");
double dia = Constants.defaultDIA;
if (MainApp.getConfigBuilder() != null && MainApp.getConfigBuilder().getProfile() != null)
dia = MainApp.getConfigBuilder().getProfile().getDia();
@@ -144,6 +151,8 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
}
private void initializeTempTargetData() {
+ if (L.isEnabled(L.DATATREATMENTS))
+ log.debug("initializeTempTargetData");
synchronized (tempTargets) {
long fromMills = System.currentTimeMillis() - 60 * 60 * 1000L * 24;
tempTargets.reset().add(MainApp.getDbHelper().getTemptargetsDataFromTime(fromMills, false));
@@ -151,6 +160,8 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
}
private void initializeProfileSwitchData() {
+ if (L.isEnabled(L.DATATREATMENTS))
+ log.debug("initializeProfileSwitchData");
synchronized (profiles) {
profiles.reset().add(MainApp.getDbHelper().getProfileSwitchData(false));
}
@@ -294,6 +305,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
last = t.date;
}
}
+ if (L.isEnabled(L.DATATREATMENTS))
log.debug("Last bolus time: " + new Date(last).toLocaleString());
return last;
}
@@ -322,6 +334,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
@Subscribe
public void onStatusEvent(final EventReloadTreatmentData ev) {
+ if (L.isEnabled(L.DATATREATMENTS))
log.debug("EventReloadTreatmentData");
initializeTreatmentData();
initializeExtendedBolusData();
@@ -332,6 +345,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
@Subscribe
@SuppressWarnings("unused")
public void onStatusEvent(final EventReloadTempBasalData ev) {
+ if (L.isEnabled(L.DATATREATMENTS))
log.debug("EventReloadTempBasalData");
initializeTempBasalData();
updateTotalIOBTempBasals();
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/ProfileViewerDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/ProfileViewerDialog.java
index 5f758c8a06..c2263d81b5 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/ProfileViewerDialog.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/ProfileViewerDialog.java
@@ -31,8 +31,6 @@ public class ProfileViewerDialog extends DialogFragment {
private long time;
- private static Logger log = LoggerFactory.getLogger(ProfileViewDialog.class);
-
@BindView(R.id.profileview_noprofile)
TextView noProfile;
@BindView(R.id.profileview_invalidprofile)
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsBolusFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsBolusFragment.java
index 0faceb2382..aa6204cbe2 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsBolusFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsBolusFragment.java
@@ -20,14 +20,11 @@ import android.widget.TextView;
import com.crashlytics.android.answers.CustomEvent;
import com.squareup.otto.Subscribe;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.util.List;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
-import info.nightscout.androidaps.Services.Intents;
+import info.nightscout.androidaps.services.Intents;
import info.nightscout.androidaps.data.Iob;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.db.Source;
@@ -40,14 +37,12 @@ import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.utils.FabricPrivacy;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter;
-import info.nightscout.utils.NSUpload;
+import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
import info.nightscout.utils.SP;
import static info.nightscout.utils.DateUtil.now;
public class TreatmentsBolusFragment extends SubscriberFragment implements View.OnClickListener {
- private static Logger log = LoggerFactory.getLogger(TreatmentsBolusFragment.class);
-
RecyclerView recyclerView;
LinearLayoutManager llm;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsCareportalFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsCareportalFragment.java
index 7e69883a3d..56709963f7 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsCareportalFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsCareportalFragment.java
@@ -22,13 +22,13 @@ import java.util.List;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
-import info.nightscout.androidaps.Services.Intents;
+import info.nightscout.androidaps.services.Intents;
import info.nightscout.androidaps.db.CareportalEvent;
import info.nightscout.androidaps.events.EventCareportalEventChange;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue;
import info.nightscout.utils.DateUtil;
-import info.nightscout.utils.NSUpload;
+import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
import info.nightscout.utils.SP;
import info.nightscout.utils.Translator;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsExtendedBolusesFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsExtendedBolusesFragment.java
index 05e18bfdc3..037a1a0023 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsExtendedBolusesFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsExtendedBolusesFragment.java
@@ -18,9 +18,6 @@ import android.widget.TextView;
import com.crashlytics.android.answers.CustomEvent;
import com.squareup.otto.Subscribe;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Intervals;
@@ -35,12 +32,10 @@ import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.FabricPrivacy;
-import info.nightscout.utils.NSUpload;
+import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
public class TreatmentsExtendedBolusesFragment extends SubscriberFragment {
- private static Logger log = LoggerFactory.getLogger(TreatmentsExtendedBolusesFragment.class);
-
RecyclerView recyclerView;
LinearLayoutManager llm;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsProfileSwitchFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsProfileSwitchFragment.java
index 307f9c8ee6..903a075dca 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsProfileSwitchFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsProfileSwitchFragment.java
@@ -24,7 +24,7 @@ import java.util.List;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
-import info.nightscout.androidaps.Services.Intents;
+import info.nightscout.androidaps.services.Intents;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.db.ProfileSwitch;
import info.nightscout.androidaps.db.Source;
@@ -33,7 +33,7 @@ import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter;
-import info.nightscout.utils.NSUpload;
+import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
import info.nightscout.utils.SP;
/**
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsTempTargetFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsTempTargetFragment.java
index df67349839..96b559d89d 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsTempTargetFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsTempTargetFragment.java
@@ -21,7 +21,7 @@ import com.squareup.otto.Subscribe;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
-import info.nightscout.androidaps.Services.Intents;
+import info.nightscout.androidaps.services.Intents;
import info.nightscout.androidaps.data.Intervals;
import info.nightscout.androidaps.db.Source;
import info.nightscout.androidaps.db.TempTarget;
@@ -31,7 +31,7 @@ import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter;
-import info.nightscout.utils.NSUpload;
+import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
import info.nightscout.utils.SP;
/**
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsTemporaryBasalsFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsTemporaryBasalsFragment.java
index 957c5c02f1..9b61eba2ae 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsTemporaryBasalsFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsTemporaryBasalsFragment.java
@@ -33,7 +33,7 @@ import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.FabricPrivacy;
-import info.nightscout.utils.NSUpload;
+import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
public class TreatmentsTemporaryBasalsFragment extends SubscriberFragment {
diff --git a/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java b/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java
index 07ef303dbf..4df1e65c2c 100644
--- a/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java
+++ b/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java
@@ -12,8 +12,6 @@ import org.slf4j.LoggerFactory;
import java.util.LinkedList;
-import info.nightscout.androidaps.Config;
-import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.DetailedBolusInfo;
@@ -22,6 +20,7 @@ import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.events.EventBolusRequested;
import info.nightscout.androidaps.interfaces.Constraint;
import info.nightscout.androidaps.interfaces.PumpInterface;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressDialog;
import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressHelperActivity;
@@ -77,10 +76,10 @@ import info.nightscout.androidaps.queue.commands.CommandTempBasalPercent;
*/
public class CommandQueue {
- private Logger log = LoggerFactory.getLogger(Constants.QUEUE);
+ private Logger log = LoggerFactory.getLogger(L.PUMPQUEUE);
private final LinkedList queue = new LinkedList<>();
- protected Command performing;
+ Command performing;
private QueueThread thread = null;
@@ -111,13 +110,13 @@ public class CommandQueue {
private synchronized void inject(Command command) {
// inject as a first command
- if (Config.logQueue)
+ if (L.isEnabled(L.PUMPQUEUE))
log.debug("Adding as first: " + command.getClass().getSimpleName() + " - " + command.status());
queue.addFirst(command);
}
private synchronized void add(Command command) {
- if (Config.logQueue)
+ if (L.isEnabled(L.PUMPQUEUE))
log.debug("Adding: " + command.getClass().getSimpleName() + " - " + command.status());
queue.add(command);
}
@@ -151,17 +150,17 @@ public class CommandQueue {
// start thread again if not already running
protected synchronized void notifyAboutNewCommand() {
while (thread != null && thread.getState() != Thread.State.TERMINATED && thread.waitingForDisconnect) {
- if (Config.logQueue)
+ if (L.isEnabled(L.PUMPQUEUE))
log.debug("Waiting for previous thread finish");
SystemClock.sleep(500);
}
if (thread == null || thread.getState() == Thread.State.TERMINATED) {
thread = new QueueThread(this);
thread.start();
- if (Config.logQueue)
+ if (L.isEnabled(L.PUMPQUEUE))
log.debug("Starting new thread");
} else {
- if (Config.logQueue)
+ if (L.isEnabled(L.PUMPQUEUE))
log.debug("Thread is already running");
}
}
@@ -187,12 +186,12 @@ public class CommandQueue {
if (type == Command.CommandType.SMB_BOLUS) {
if (isRunning(Command.CommandType.BOLUS) || bolusInQueue()) {
- if (Config.logQueue)
+ if (L.isEnabled(L.PUMPQUEUE))
log.debug("Rejecting SMB since a bolus is queue/running");
return false;
}
if (detailedBolusInfo.lastKnownBolusTime < TreatmentsPlugin.getPlugin().getLastBolusTime()) {
- if (Config.logQueue)
+ if (L.isEnabled(L.PUMPQUEUE))
log.debug("Rejecting bolus, another bolus was issued since request time");
return false;
}
@@ -346,7 +345,7 @@ public class CommandQueue {
// returns true if command is queued
public boolean setProfile(Profile profile, Callback callback) {
if (isThisProfileSet(profile)) {
- if (Config.logQueue)
+ if (L.isEnabled(L.PUMPQUEUE))
log.debug("Correct profile already set");
if (callback != null)
callback.result(new PumpEnactResult().success(true).enacted(false)).run();
@@ -391,7 +390,7 @@ public class CommandQueue {
// returns true if command is queued
public boolean readStatus(String reason, Callback callback) {
if (isLastScheduled(Command.CommandType.READSTATUS)) {
- if (Config.logQueue)
+ if (L.isEnabled(L.PUMPQUEUE))
log.debug("READSTATUS " + reason + " ignored as duplicated");
if (callback != null)
callback.result(executingNowError()).run();
@@ -507,7 +506,7 @@ public class CommandQueue {
if (activePump != null && current != null) {
boolean result = activePump.isThisProfileSet(profile);
if (!result) {
- if (Config.logQueue) {
+ if (L.isEnabled(L.PUMPQUEUE)) {
log.debug("Current profile: " + current.toString());
log.debug("New profile: " + profile.toString());
}
diff --git a/app/src/main/java/info/nightscout/androidaps/queue/QueueThread.java b/app/src/main/java/info/nightscout/androidaps/queue/QueueThread.java
index 3073ecb950..83414b23fe 100644
--- a/app/src/main/java/info/nightscout/androidaps/queue/QueueThread.java
+++ b/app/src/main/java/info/nightscout/androidaps/queue/QueueThread.java
@@ -8,17 +8,14 @@ import android.os.SystemClock;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
-import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.interfaces.PumpInterface;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissBolusprogressIfRunning;
-import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
-import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
import info.nightscout.androidaps.queue.events.EventQueueChanged;
import info.nightscout.utils.SP;
@@ -27,7 +24,7 @@ import info.nightscout.utils.SP;
*/
public class QueueThread extends Thread {
- private Logger log = LoggerFactory.getLogger(Constants.QUEUE);
+ private Logger log = LoggerFactory.getLogger(L.PUMPQUEUE);
private CommandQueue queue;
@@ -55,7 +52,7 @@ public class QueueThread extends Thread {
while (true) {
PumpInterface pump = ConfigBuilderPlugin.getActivePump();
if (pump == null) {
- if (Config.logQueue)
+ if (L.isEnabled(L.PUMPQUEUE))
log.debug("pump == null");
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.pumpNotInitialized)));
SystemClock.sleep(1000);
@@ -66,7 +63,7 @@ public class QueueThread extends Thread {
if (!pump.isConnected() && secondsElapsed > Constants.PUMP_MAX_CONNECTION_TIME_IN_SECONDS) {
MainApp.bus().post(new EventDismissBolusprogressIfRunning(null));
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.connectiontimedout)));
- if (Config.logQueue)
+ if (L.isEnabled(L.PUMPQUEUE))
log.debug("timed out");
pump.stopConnecting();
@@ -75,7 +72,7 @@ public class QueueThread extends Thread {
long last_watchdog = SP.getLong(R.string.key_btwatchdog_lastbark, 0l);
watchdog = watchdog && System.currentTimeMillis() - last_watchdog > (Constants.MIN_WATCHDOG_INTERVAL_IN_SECONDS * 1000);
if (watchdog) {
- if (Config.logQueue)
+ if (L.isEnabled(L.PUMPQUEUE))
log.debug("BT watchdog - toggeling the phonest bluetooth");
//write time
SP.putLong(R.string.key_btwatchdog_lastbark, System.currentTimeMillis());
@@ -95,7 +92,7 @@ public class QueueThread extends Thread {
pump.connect("watchdog");
} else {
queue.clear();
- if (Config.logQueue)
+ if (L.isEnabled(L.PUMPQUEUE))
log.debug("no connection possible");
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
pump.disconnect("Queue empty");
@@ -105,7 +102,7 @@ public class QueueThread extends Thread {
}
if (pump.isConnecting()) {
- if (Config.logQueue)
+ if (L.isEnabled(L.PUMPQUEUE))
log.debug("connecting " + secondsElapsed);
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTING, (int) secondsElapsed));
SystemClock.sleep(1000);
@@ -114,7 +111,7 @@ public class QueueThread extends Thread {
if (!pump.isConnected()) {
- if (Config.logQueue)
+ if (L.isEnabled(L.PUMPQUEUE))
log.debug("connect");
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTING, (int) secondsElapsed));
pump.connect("Connection needed");
@@ -125,13 +122,13 @@ public class QueueThread extends Thread {
if (queue.performing() == null) {
if (!connectLogged) {
connectLogged = true;
- if (Config.logQueue)
+ if (L.isEnabled(L.PUMPQUEUE))
log.debug("connection time " + secondsElapsed + "s");
}
// Pickup 1st command and set performing variable
if (queue.size() > 0) {
queue.pickup();
- if (Config.logQueue)
+ if (L.isEnabled(L.PUMPQUEUE))
log.debug("performing " + queue.performing().status());
MainApp.bus().post(new EventQueueChanged());
queue.performing().execute();
@@ -147,16 +144,16 @@ public class QueueThread extends Thread {
long secondsFromLastCommand = (System.currentTimeMillis() - lastCommandTime) / 1000;
if (secondsFromLastCommand >= 5) {
waitingForDisconnect = true;
- if (Config.logQueue)
+ if (L.isEnabled(L.PUMPQUEUE))
log.debug("queue empty. disconnect");
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
pump.disconnect("Queue empty");
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTED));
- if (Config.logQueue)
+ if (L.isEnabled(L.PUMPQUEUE))
log.debug("disconnected");
return;
} else {
- if (Config.logQueue)
+ if (L.isEnabled(L.PUMPQUEUE))
log.debug("waiting for disconnect");
SystemClock.sleep(1000);
}
diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/Command.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/Command.java
index 13208fb9f1..7207f5b8d1 100644
--- a/app/src/main/java/info/nightscout/androidaps/queue/commands/Command.java
+++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/Command.java
@@ -3,18 +3,17 @@ package info.nightscout.androidaps.queue.commands;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.PumpEnactResult;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.queue.Callback;
/**
* Created by mike on 09.11.2017.
*/
public abstract class Command {
- private Logger log = LoggerFactory.getLogger(Constants.QUEUE);
+ private Logger log = LoggerFactory.getLogger(L.PUMPQUEUE);
public enum CommandType {
BOLUS,
@@ -40,7 +39,7 @@ public abstract class Command {
PumpEnactResult result = new PumpEnactResult();
result.success = false;
result.comment = MainApp.gs(R.string.connectiontimedout);
- if (Config.logQueue)
+ if (L.isEnabled(L.PUMPQUEUE))
log.debug("Result cancel");
if (callback != null)
callback.result(result).run();
diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandBolus.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandBolus.java
index c0c2090177..7e17e831e9 100644
--- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandBolus.java
+++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandBolus.java
@@ -3,11 +3,10 @@ package info.nightscout.androidaps.queue.commands;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.data.DetailedBolusInfo;
import info.nightscout.androidaps.data.PumpEnactResult;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressDialog;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissBolusprogressIfRunning;
@@ -19,9 +18,9 @@ import info.nightscout.utils.DecimalFormatter;
*/
public class CommandBolus extends Command {
- private Logger log = LoggerFactory.getLogger(Constants.QUEUE);
+ private Logger log = LoggerFactory.getLogger(L.PUMPQUEUE);
- DetailedBolusInfo detailedBolusInfo;
+ private DetailedBolusInfo detailedBolusInfo;
public CommandBolus(DetailedBolusInfo detailedBolusInfo, Callback callback, CommandType type) {
commandType = type;
@@ -35,7 +34,7 @@ public class CommandBolus extends Command {
BolusProgressDialog.bolusEnded = true;
MainApp.bus().post(new EventDismissBolusprogressIfRunning(r));
- if (Config.logQueue)
+ if (L.isEnabled(L.PUMPQUEUE))
log.debug("Result success: " + r.success + " enacted: " + r.enacted);
if (callback != null)
diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandCancelExtendedBolus.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandCancelExtendedBolus.java
index e5d69e2b6d..164a049647 100644
--- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandCancelExtendedBolus.java
+++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandCancelExtendedBolus.java
@@ -3,9 +3,8 @@ package info.nightscout.androidaps.queue.commands;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.data.PumpEnactResult;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.queue.Callback;
@@ -14,7 +13,7 @@ import info.nightscout.androidaps.queue.Callback;
*/
public class CommandCancelExtendedBolus extends Command {
- private Logger log = LoggerFactory.getLogger(Constants.QUEUE);
+ private Logger log = LoggerFactory.getLogger(L.PUMPQUEUE);
public CommandCancelExtendedBolus(Callback callback) {
commandType = CommandType.EXTENDEDBOLUS;
@@ -24,7 +23,7 @@ public class CommandCancelExtendedBolus extends Command {
@Override
public void execute() {
PumpEnactResult r = ConfigBuilderPlugin.getActivePump().cancelExtendedBolus();
- if (Config.logQueue)
+ if (L.isEnabled(L.PUMPQUEUE))
log.debug("Result success: " + r.success + " enacted: " + r.enacted);
if (callback != null)
callback.result(r).run();
diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandCancelTempBasal.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandCancelTempBasal.java
index a79df63569..5daa0e38e4 100644
--- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandCancelTempBasal.java
+++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandCancelTempBasal.java
@@ -3,9 +3,8 @@ package info.nightscout.androidaps.queue.commands;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.data.PumpEnactResult;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.queue.Callback;
@@ -14,9 +13,9 @@ import info.nightscout.androidaps.queue.Callback;
*/
public class CommandCancelTempBasal extends Command {
- private Logger log = LoggerFactory.getLogger(Constants.QUEUE);
+ private Logger log = LoggerFactory.getLogger(L.PUMPQUEUE);
- boolean enforceNew;
+ private boolean enforceNew;
public CommandCancelTempBasal(boolean enforceNew, Callback callback) {
commandType = CommandType.TEMPBASAL;
@@ -27,7 +26,7 @@ public class CommandCancelTempBasal extends Command {
@Override
public void execute() {
PumpEnactResult r = ConfigBuilderPlugin.getActivePump().cancelTempBasal(enforceNew);
- if (Config.logQueue)
+ if (L.isEnabled(L.PUMPQUEUE))
log.debug("Result success: " + r.success + " enacted: " + r.enacted);
if (callback != null)
callback.result(r).run();
diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandExtendedBolus.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandExtendedBolus.java
index b3470e6e48..ea329c04d7 100644
--- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandExtendedBolus.java
+++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandExtendedBolus.java
@@ -3,9 +3,8 @@ package info.nightscout.androidaps.queue.commands;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.data.PumpEnactResult;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.queue.Callback;
@@ -14,7 +13,7 @@ import info.nightscout.androidaps.queue.Callback;
*/
public class CommandExtendedBolus extends Command {
- private Logger log = LoggerFactory.getLogger(Constants.QUEUE);
+ private Logger log = LoggerFactory.getLogger(L.PUMPQUEUE);
private double insulin;
private int durationInMinutes;
@@ -29,7 +28,7 @@ public class CommandExtendedBolus extends Command {
@Override
public void execute() {
PumpEnactResult r = ConfigBuilderPlugin.getActivePump().setExtendedBolus(insulin, durationInMinutes);
- if (Config.logQueue)
+ if (L.isEnabled(L.PUMPQUEUE))
log.debug("Result rate: " + insulin + " durationInMinutes: " + durationInMinutes + " success: " + r.success + " enacted: " + r.enacted);
if (callback != null)
callback.result(r).run();
diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadEvents.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadEvents.java
index da307b0c21..5cc954f5ff 100644
--- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadEvents.java
+++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadEvents.java
@@ -3,11 +3,10 @@ package info.nightscout.androidaps.queue.commands;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.interfaces.DanaRInterface;
import info.nightscout.androidaps.interfaces.PumpInterface;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.queue.Callback;
@@ -16,7 +15,7 @@ import info.nightscout.androidaps.queue.Callback;
*/
public class CommandLoadEvents extends Command {
- private Logger log = LoggerFactory.getLogger(Constants.QUEUE);
+ private Logger log = LoggerFactory.getLogger(L.PUMPQUEUE);
public CommandLoadEvents(Callback callback) {
commandType = CommandType.LOADEVENTS;
@@ -29,7 +28,7 @@ public class CommandLoadEvents extends Command {
if (pump instanceof DanaRInterface) {
DanaRInterface danaPump = (DanaRInterface) pump;
PumpEnactResult r = danaPump.loadEvents();
- if (Config.logQueue)
+ if (L.isEnabled(L.PUMPQUEUE))
log.debug("Result success: " + r.success + " enacted: " + r.enacted);
if (callback != null)
callback.result(r).run();
diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadHistory.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadHistory.java
index 065e194ef0..1259812676 100644
--- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadHistory.java
+++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadHistory.java
@@ -3,11 +3,10 @@ package info.nightscout.androidaps.queue.commands;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.interfaces.DanaRInterface;
import info.nightscout.androidaps.interfaces.PumpInterface;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.queue.Callback;
@@ -16,9 +15,9 @@ import info.nightscout.androidaps.queue.Callback;
*/
public class CommandLoadHistory extends Command {
- private Logger log = LoggerFactory.getLogger(Constants.QUEUE);
+ private Logger log = LoggerFactory.getLogger(L.PUMPQUEUE);
- byte type;
+ private byte type;
public CommandLoadHistory(byte type, Callback callback) {
commandType = CommandType.LOADHISTORY;
@@ -32,7 +31,7 @@ public class CommandLoadHistory extends Command {
if (pump instanceof DanaRInterface) {
DanaRInterface danaPump = (DanaRInterface) pump;
PumpEnactResult r = danaPump.loadHistory(type);
- if (Config.logQueue)
+ if (L.isEnabled(L.PUMPQUEUE))
log.debug("Result success: " + r.success + " enacted: " + r.enacted);
if (callback != null)
callback.result(r).run();
diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadTDDs.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadTDDs.java
index 77a74369f2..1212303e82 100644
--- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadTDDs.java
+++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadTDDs.java
@@ -3,10 +3,9 @@ package info.nightscout.androidaps.queue.commands;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.interfaces.PumpInterface;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.queue.Callback;
@@ -15,7 +14,7 @@ import info.nightscout.androidaps.queue.Callback;
*/
public class CommandLoadTDDs extends Command {
- private Logger log = LoggerFactory.getLogger(Constants.QUEUE);
+ private Logger log = LoggerFactory.getLogger(L.PUMPQUEUE);
public CommandLoadTDDs(Callback callback) {
@@ -27,7 +26,7 @@ public class CommandLoadTDDs extends Command {
public void execute() {
PumpInterface pump = ConfigBuilderPlugin.getActivePump();
PumpEnactResult r = pump.loadTDDs();
- if (Config.logQueue)
+ if (L.isEnabled(L.PUMPQUEUE))
log.debug("Result success: " + r.success + " enacted: " + r.enacted);
if (callback != null)
callback.result(r).run();
diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandReadStatus.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandReadStatus.java
index 78e4f3cdf1..b014b66969 100644
--- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandReadStatus.java
+++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandReadStatus.java
@@ -3,8 +3,7 @@ package info.nightscout.androidaps.queue.commands;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-import info.nightscout.androidaps.Constants;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.queue.Callback;
import info.nightscout.utils.LocalAlertUtils;
@@ -14,9 +13,9 @@ import info.nightscout.utils.LocalAlertUtils;
*/
public class CommandReadStatus extends Command {
- private Logger log = LoggerFactory.getLogger(Constants.QUEUE);
+ private Logger log = LoggerFactory.getLogger(L.PUMPQUEUE);
- String reason;
+ private String reason;
public CommandReadStatus(String reason, Callback callback) {
commandType = CommandType.READSTATUS;
@@ -28,7 +27,7 @@ public class CommandReadStatus extends Command {
public void execute() {
ConfigBuilderPlugin.getActivePump().getPumpStatus();
LocalAlertUtils.notifyPumpStatusRead();
- if (Config.logQueue)
+ if (L.isEnabled(L.PUMPQUEUE))
log.debug("CommandReadStatus executed. Reason: " + reason);
if (callback != null)
callback.result(null).run();
diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSMBBolus.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSMBBolus.java
index c4e613e04b..affc7aed22 100644
--- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSMBBolus.java
+++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSMBBolus.java
@@ -3,14 +3,10 @@ package info.nightscout.androidaps.queue.commands;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-import info.nightscout.androidaps.Constants;
-import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.data.DetailedBolusInfo;
import info.nightscout.androidaps.data.PumpEnactResult;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
-import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressDialog;
-import info.nightscout.androidaps.plugins.Overview.events.EventDismissBolusprogressIfRunning;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.androidaps.queue.Callback;
import info.nightscout.utils.DateUtil;
@@ -22,9 +18,9 @@ import info.nightscout.utils.T;
*/
public class CommandSMBBolus extends Command {
- private Logger log = LoggerFactory.getLogger(Constants.QUEUE);
+ private Logger log = LoggerFactory.getLogger(L.PUMPQUEUE);
- DetailedBolusInfo detailedBolusInfo;
+ private DetailedBolusInfo detailedBolusInfo;
public CommandSMBBolus(DetailedBolusInfo detailedBolusInfo, Callback callback) {
commandType = CommandType.SMB_BOLUS;
@@ -37,18 +33,18 @@ public class CommandSMBBolus extends Command {
PumpEnactResult r;
long lastBolusTime = TreatmentsPlugin.getPlugin().getLastBolusTime();
if (lastBolusTime != 0 && lastBolusTime + T.mins(3).msecs() > DateUtil.now()) {
- if (Config.logQueue)
+ if (L.isEnabled(L.PUMPQUEUE))
log.debug("SMB requsted but still in 3 min interval");
r = new PumpEnactResult().enacted(false).success(false).comment("SMB requsted but still in 3 min interval");
} else if (detailedBolusInfo.deliverAt != 0 && detailedBolusInfo.deliverAt + T.mins(1).msecs() > System.currentTimeMillis()) {
r = ConfigBuilderPlugin.getActivePump().deliverTreatment(detailedBolusInfo);
} else {
r = new PumpEnactResult().enacted(false).success(false).comment("SMB request too old");
- if (Config.logQueue)
+ if (L.isEnabled(L.PUMPQUEUE))
log.debug("SMB bolus canceled. delivetAt: " + DateUtil.dateAndTimeString(detailedBolusInfo.deliverAt));
}
- if (Config.logQueue)
+ if (L.isEnabled(L.PUMPQUEUE))
log.debug("Result success: " + r.success + " enacted: " + r.enacted);
if (callback != null)
diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetProfile.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetProfile.java
index 3fa375cfac..b62ef576d3 100644
--- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetProfile.java
+++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetProfile.java
@@ -3,8 +3,6 @@ package info.nightscout.androidaps.queue.commands;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Profile;
@@ -12,6 +10,7 @@ import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.db.ProfileSwitch;
import info.nightscout.androidaps.db.Source;
import info.nightscout.androidaps.interfaces.PluginType;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.SmsCommunicator.SmsCommunicatorPlugin;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
@@ -22,7 +21,7 @@ import info.nightscout.androidaps.queue.Callback;
*/
public class CommandSetProfile extends Command {
- private Logger log = LoggerFactory.getLogger(Constants.QUEUE);
+ private Logger log = LoggerFactory.getLogger(L.PUMPQUEUE);
private Profile profile;
@@ -35,7 +34,7 @@ public class CommandSetProfile extends Command {
@Override
public void execute() {
if (ConfigBuilderPlugin.getCommandQueue().isThisProfileSet(profile)) {
- if (Config.logQueue)
+ if (L.isEnabled(L.PUMPQUEUE))
log.debug("Correct profile already set. profile: " + profile.toString());
if (callback != null)
callback.result(new PumpEnactResult().success(true).enacted(false)).run();
@@ -43,7 +42,7 @@ public class CommandSetProfile extends Command {
}
PumpEnactResult r = ConfigBuilderPlugin.getActivePump().setNewBasalProfile(profile);
- if (Config.logQueue)
+ if (L.isEnabled(L.PUMPQUEUE))
log.debug("Result success: " + r.success + " enacted: " + r.enacted + " profile: " + profile.toString());
if (callback != null)
callback.result(r).run();
diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetUserSettings.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetUserSettings.java
index 59f0fe3ba9..8a9ae21c70 100644
--- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetUserSettings.java
+++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetUserSettings.java
@@ -3,11 +3,10 @@ package info.nightscout.androidaps.queue.commands;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.interfaces.DanaRInterface;
import info.nightscout.androidaps.interfaces.PumpInterface;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.queue.Callback;
@@ -16,7 +15,7 @@ import info.nightscout.androidaps.queue.Callback;
*/
public class CommandSetUserSettings extends Command {
- private Logger log = LoggerFactory.getLogger(Constants.QUEUE);
+ private Logger log = LoggerFactory.getLogger(L.PUMPQUEUE);
public CommandSetUserSettings(Callback callback) {
commandType = CommandType.SETUSERSETTINGS;
@@ -29,7 +28,7 @@ public class CommandSetUserSettings extends Command {
if (pump instanceof DanaRInterface) {
DanaRInterface danaPump = (DanaRInterface) pump;
PumpEnactResult r = danaPump.setUserOptions();
- if (Config.logQueue)
+ if (L.isEnabled(L.PUMPQUEUE))
log.debug("Result success: " + r.success + " enacted: " + r.enacted);
if (callback != null)
callback.result(r).run();
diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandTempBasalAbsolute.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandTempBasalAbsolute.java
index 6e1a174364..a2787cabb6 100644
--- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandTempBasalAbsolute.java
+++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandTempBasalAbsolute.java
@@ -3,11 +3,9 @@ package info.nightscout.androidaps.queue.commands;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-import info.nightscout.androidaps.Constants;
-import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.PumpEnactResult;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.queue.Callback;
@@ -16,12 +14,12 @@ import info.nightscout.androidaps.queue.Callback;
*/
public class CommandTempBasalAbsolute extends Command {
- private Logger log = LoggerFactory.getLogger(Constants.QUEUE);
+ private Logger log = LoggerFactory.getLogger(L.PUMPQUEUE);
- int durationInMinutes;
- double absoluteRate;
- boolean enforceNew;
- Profile profile;
+ private int durationInMinutes;
+ private double absoluteRate;
+ private boolean enforceNew;
+ private Profile profile;
public CommandTempBasalAbsolute(double absoluteRate, int durationInMinutes, boolean enforceNew, Profile profile, Callback callback) {
commandType = CommandType.TEMPBASAL;
@@ -35,7 +33,7 @@ public class CommandTempBasalAbsolute extends Command {
@Override
public void execute() {
PumpEnactResult r = ConfigBuilderPlugin.getActivePump().setTempBasalAbsolute(absoluteRate, durationInMinutes, profile, enforceNew);
- if (Config.logQueue)
+ if (L.isEnabled(L.PUMPQUEUE))
log.debug("Result rate: " + absoluteRate + " durationInMinutes: " + durationInMinutes + " success: " + r.success + " enacted: " + r.enacted);
if (callback != null)
callback.result(r).run();
diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandTempBasalPercent.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandTempBasalPercent.java
index 8b210de2c4..efdfca0a69 100644
--- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandTempBasalPercent.java
+++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandTempBasalPercent.java
@@ -3,10 +3,9 @@ package info.nightscout.androidaps.queue.commands;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
-import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.PumpEnactResult;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.queue.Callback;
@@ -15,12 +14,12 @@ import info.nightscout.androidaps.queue.Callback;
*/
public class CommandTempBasalPercent extends Command {
- private Logger log = LoggerFactory.getLogger(Constants.QUEUE);
+ private Logger log = LoggerFactory.getLogger(L.PUMPQUEUE);
- int durationInMinutes;
- int percent;
- boolean enforceNew;
- Profile profile;
+ private int durationInMinutes;
+ private int percent;
+ private boolean enforceNew;
+ private Profile profile;
public CommandTempBasalPercent(int percent, int durationInMinutes, boolean enforceNew, Profile profile, Callback callback) {
commandType = CommandType.TEMPBASAL;
@@ -34,7 +33,7 @@ public class CommandTempBasalPercent extends Command {
@Override
public void execute() {
PumpEnactResult r = ConfigBuilderPlugin.getActivePump().setTempBasalPercent(percent, durationInMinutes, profile, enforceNew);
- if (Config.logQueue)
+ if (L.isEnabled(L.PUMPQUEUE))
log.debug("Result percent: " + percent + " durationInMinutes: " + durationInMinutes + " success: " + r.success + " enacted: " + r.enacted);
if (callback != null)
callback.result(r).run();
diff --git a/app/src/main/java/info/nightscout/androidaps/receivers/DataReceiver.java b/app/src/main/java/info/nightscout/androidaps/receivers/DataReceiver.java
index aa767bb154..087cd3a5f5 100644
--- a/app/src/main/java/info/nightscout/androidaps/receivers/DataReceiver.java
+++ b/app/src/main/java/info/nightscout/androidaps/receivers/DataReceiver.java
@@ -7,15 +7,15 @@ import android.support.v4.content.WakefulBroadcastReceiver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Services.DataService;
-import info.nightscout.androidaps.Config;
+import info.nightscout.androidaps.logging.L;
+import info.nightscout.androidaps.services.DataService;
public class DataReceiver extends WakefulBroadcastReceiver {
- private static Logger log = LoggerFactory.getLogger(DataReceiver.class);
+ private static Logger log = LoggerFactory.getLogger(L.DATASERVICE);
@Override
public void onReceive(Context context, Intent intent) {
- if (Config.logFunctionCalls)
+ if (L.isEnabled(L.DATASERVICE))
log.debug("onReceive " + intent);
startWakefulService(context, new Intent(context, DataService.class)
.setAction(intent.getAction())
diff --git a/app/src/main/java/info/nightscout/androidaps/receivers/NSAlarmReceiver.java b/app/src/main/java/info/nightscout/androidaps/receivers/NSAlarmReceiver.java
index 95bb5e17b3..329bc2e4f9 100644
--- a/app/src/main/java/info/nightscout/androidaps/receivers/NSAlarmReceiver.java
+++ b/app/src/main/java/info/nightscout/androidaps/receivers/NSAlarmReceiver.java
@@ -11,7 +11,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.MainApp;
-import info.nightscout.androidaps.Services.Intents;
+import info.nightscout.androidaps.services.Intents;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSAlarm;
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
diff --git a/app/src/main/java/info/nightscout/androidaps/Services/AlarmSoundService.java b/app/src/main/java/info/nightscout/androidaps/services/AlarmSoundService.java
similarity index 81%
rename from app/src/main/java/info/nightscout/androidaps/Services/AlarmSoundService.java
rename to app/src/main/java/info/nightscout/androidaps/services/AlarmSoundService.java
index f453b04d36..43fbae83eb 100644
--- a/app/src/main/java/info/nightscout/androidaps/Services/AlarmSoundService.java
+++ b/app/src/main/java/info/nightscout/androidaps/services/AlarmSoundService.java
@@ -1,4 +1,4 @@
-package info.nightscout.androidaps.Services;
+package info.nightscout.androidaps.services;
import android.app.Service;
import android.content.Context;
@@ -15,9 +15,10 @@ import java.io.IOException;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
+import info.nightscout.androidaps.logging.L;
public class AlarmSoundService extends Service {
- private static Logger log = LoggerFactory.getLogger(AlarmSoundService.class);
+ private static Logger log = LoggerFactory.getLogger(L.ALARM);
MediaPlayer player;
int resourceId = R.raw.error;
@@ -34,13 +35,15 @@ public class AlarmSoundService extends Service {
@Override
public void onCreate() {
super.onCreate();
- log.debug("onCreate");
+ if (L.isEnabled(L.ALARM))
+ log.debug("onCreate");
}
public int onStartCommand(Intent intent, int flags, int startId) {
if (player != null && player.isPlaying())
player.stop();
- log.debug("onStartCommand");
+ if (L.isEnabled(L.ALARM))
+ log.debug("onStartCommand");
if (intent != null && intent.hasExtra("soundid"))
resourceId = intent.getIntExtra("soundid", R.raw.error);
@@ -55,7 +58,7 @@ public class AlarmSoundService extends Service {
log.error("Unhandled exception", e);
}
player.setLooping(true); // Set looping
- AudioManager manager = (AudioManager)this.getSystemService(Context.AUDIO_SERVICE);
+ AudioManager manager = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);
if (manager == null || !manager.isMusicActive()) {
player.setVolume(100, 100);
}
@@ -74,5 +77,7 @@ public class AlarmSoundService extends Service {
public void onDestroy() {
player.stop();
player.release();
+ if (L.isEnabled(L.ALARM))
+ log.debug("onDestroy");
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/Services/DataService.java b/app/src/main/java/info/nightscout/androidaps/services/DataService.java
similarity index 64%
rename from app/src/main/java/info/nightscout/androidaps/Services/DataService.java
rename to app/src/main/java/info/nightscout/androidaps/services/DataService.java
index a254f9bf5f..c0cfe07370 100644
--- a/app/src/main/java/info/nightscout/androidaps/Services/DataService.java
+++ b/app/src/main/java/info/nightscout/androidaps/services/DataService.java
@@ -1,8 +1,7 @@
-package info.nightscout.androidaps.Services;
+package info.nightscout.androidaps.services;
import android.app.IntentService;
import android.content.Intent;
-import android.content.pm.PackageManager;
import android.os.Bundle;
import android.provider.Telephony;
@@ -12,19 +11,15 @@ import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.db.CareportalEvent;
import info.nightscout.androidaps.events.EventNsFood;
import info.nightscout.androidaps.events.EventNsTreatment;
-import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
-import info.nightscout.androidaps.plugins.ConstraintsObjectives.ObjectivesPlugin;
+import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSDeviceStatus;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSMbg;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSettingsStatus;
-import info.nightscout.androidaps.plugins.Overview.OverviewPlugin;
-import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
import info.nightscout.androidaps.plugins.ProfileNS.NSProfilePlugin;
@@ -37,13 +32,13 @@ import info.nightscout.androidaps.plugins.Source.SourceNSClientPlugin;
import info.nightscout.androidaps.plugins.Source.SourcePoctechPlugin;
import info.nightscout.androidaps.plugins.Source.SourceXdripPlugin;
import info.nightscout.androidaps.receivers.DataReceiver;
-import info.nightscout.utils.BundleLogger;
+import info.nightscout.androidaps.logging.BundleLogger;
import info.nightscout.utils.JsonHelper;
import info.nightscout.utils.SP;
public class DataService extends IntentService {
- private static Logger log = LoggerFactory.getLogger(DataService.class);
+ private Logger log = LoggerFactory.getLogger(L.DATASERVICE);
public DataService() {
super("DataService");
@@ -52,8 +47,10 @@ public class DataService extends IntentService {
@Override
protected void onHandleIntent(final Intent intent) {
- if (Config.logFunctionCalls)
+ if (L.isEnabled(L.DATASERVICE)) {
+ log.debug("onHandleIntent " + intent);
log.debug("onHandleIntent " + BundleLogger.log(intent.getExtras()));
+ }
boolean acceptNSData = !SP.getBoolean(R.string.key_ns_upload_only, false);
Bundle bundles = intent.getExtras();
@@ -78,15 +75,23 @@ public class DataService extends IntentService {
} else if (Intents.ACTION_NEW_PROFILE.equals(action)) {
// always handle Profile if NSProfile is enabled without looking at nsUploadOnly
NSProfilePlugin.getPlugin().handleNewData(intent);
+ } else if (Intents.ACTION_NEW_DEVICESTATUS.equals(action)) {
+ NSDeviceStatus.getInstance().handleNewData(intent);
+ } else if (Intents.ACTION_NEW_STATUS.equals(action)) {
+ NSSettingsStatus.getInstance().handleNewData(intent);
+ } else if (Intents.ACTION_NEW_FOOD.equals(action)) {
+ EventNsFood evt = new EventNsFood(EventNsFood.ADD, bundles);
+ MainApp.bus().post(evt);
+ } else if (Intents.ACTION_CHANGED_FOOD.equals(action)) {
+ EventNsFood evt = new EventNsFood(EventNsFood.UPDATE, bundles);
+ MainApp.bus().post(evt);
+ } else if (Intents.ACTION_REMOVED_FOOD.equals(action)) {
+ EventNsFood evt = new EventNsFood(EventNsFood.REMOVE, bundles);
+ MainApp.bus().post(evt);
} else if (acceptNSData &&
(Intents.ACTION_NEW_TREATMENT.equals(action) ||
Intents.ACTION_CHANGED_TREATMENT.equals(action) ||
Intents.ACTION_REMOVED_TREATMENT.equals(action) ||
- Intents.ACTION_NEW_STATUS.equals(action) ||
- Intents.ACTION_NEW_DEVICESTATUS.equals(action) ||
- Intents.ACTION_NEW_FOOD.equals(action) ||
- Intents.ACTION_CHANGED_FOOD.equals(action) ||
- Intents.ACTION_REMOVED_FOOD.equals(action) ||
Intents.ACTION_NEW_CAL.equals(action) ||
Intents.ACTION_NEW_MBG.equals(action))
) {
@@ -95,7 +100,7 @@ public class DataService extends IntentService {
SmsCommunicatorPlugin.getPlugin().handleNewData(intent);
}
- if (Config.logFunctionCalls)
+ if (L.isEnabled(L.DATASERVICE))
log.debug("onHandleIntent exit " + intent);
DataReceiver.completeWakefulIntent(intent);
}
@@ -118,83 +123,10 @@ public class DataService extends IntentService {
private void handleNewDataFromNSClient(Intent intent) {
Bundle bundles = intent.getExtras();
if (bundles == null) return;
- if (Config.logIncommingData)
+ if (L.isEnabled(L.DATASERVICE))
log.debug("Got intent: " + intent.getAction());
- if (intent.getAction().equals(Intents.ACTION_NEW_STATUS)) {
- if (bundles.containsKey("nsclientversioncode")) {
- ConfigBuilderPlugin.nightscoutVersionCode = bundles.getInt("nightscoutversioncode"); // for ver 1.2.3 contains 10203
- ConfigBuilderPlugin.nightscoutVersionName = bundles.getString("nightscoutversionname");
- ConfigBuilderPlugin.nsClientVersionCode = bundles.getInt("nsclientversioncode"); // for ver 1.17 contains 117
- ConfigBuilderPlugin.nsClientVersionName = bundles.getString("nsclientversionname");
- log.debug("Got versions: NSClient: " + ConfigBuilderPlugin.nsClientVersionName + " Nightscout: " + ConfigBuilderPlugin.nightscoutVersionName);
- try {
- if (ConfigBuilderPlugin.nsClientVersionCode < MainApp.instance().getPackageManager().getPackageInfo(MainApp.instance().getPackageName(), 0).versionCode) {
- Notification notification = new Notification(Notification.OLD_NSCLIENT, MainApp.gs(R.string.unsupportedclientver), Notification.URGENT);
- MainApp.bus().post(new EventNewNotification(notification));
- } else {
- MainApp.bus().post(new EventDismissNotification(Notification.OLD_NSCLIENT));
- }
- } catch (PackageManager.NameNotFoundException e) {
- log.error("Unhandled exception", e);
- }
- if (ConfigBuilderPlugin.nightscoutVersionCode < Config.SUPPORTEDNSVERSION) {
- Notification notification = new Notification(Notification.OLD_NS, MainApp.gs(R.string.unsupportednsversion), Notification.NORMAL);
- MainApp.bus().post(new EventNewNotification(notification));
- } else {
- MainApp.bus().post(new EventDismissNotification(Notification.OLD_NS));
- }
- } else {
- Notification notification = new Notification(Notification.OLD_NSCLIENT, MainApp.gs(R.string.unsupportedclientver), Notification.URGENT);
- MainApp.bus().post(new EventNewNotification(notification));
- }
- if (bundles.containsKey("status")) {
- try {
- JSONObject statusJson = new JSONObject(bundles.getString("status"));
- NSSettingsStatus.getInstance().setData(statusJson);
- if (Config.logIncommingData)
- log.debug("Received status: " + statusJson.toString());
- Double targetHigh = NSSettingsStatus.getInstance().getThreshold("bgTargetTop");
- Double targetlow = NSSettingsStatus.getInstance().getThreshold("bgTargetBottom");
- if (targetHigh != null)
- OverviewPlugin.bgTargetHigh = targetHigh;
- if (targetlow != null)
- OverviewPlugin.bgTargetLow = targetlow;
- } catch (JSONException e) {
- log.error("Unhandled exception", e);
- }
- }
- }
- if (intent.getAction().equals(Intents.ACTION_NEW_DEVICESTATUS)) {
- try {
- if (bundles.containsKey("devicestatus")) {
- JSONObject devicestatusJson = new JSONObject(bundles.getString("devicestatus"));
- NSDeviceStatus.getInstance().setData(devicestatusJson);
- if (devicestatusJson.has("pump")) {
- // Objectives 0
- ObjectivesPlugin.pumpStatusIsAvailableInNS = true;
- ObjectivesPlugin.saveProgress();
- }
- }
- if (bundles.containsKey("devicestatuses")) {
- String devicestatusesstring = bundles.getString("devicestatuses");
- JSONArray jsonArray = new JSONArray(devicestatusesstring);
- for (int i = 0; i < jsonArray.length(); i++) {
- JSONObject devicestatusJson = jsonArray.getJSONObject(i);
- NSDeviceStatus.getInstance().setData(devicestatusJson);
- if (devicestatusJson.has("pump")) {
- // Objectives 0
- ObjectivesPlugin.pumpStatusIsAvailableInNS = true;
- ObjectivesPlugin.saveProgress();
- }
- }
- }
- } catch (Exception e) {
- log.error("Unhandled exception", e);
- }
- }
-
if (intent.getAction().equals(Intents.ACTION_NEW_TREATMENT) || intent.getAction().equals(Intents.ACTION_CHANGED_TREATMENT)) {
try {
if (bundles.containsKey("treatment")) {
@@ -219,7 +151,7 @@ public class DataService extends IntentService {
if (bundles.containsKey("treatment")) {
String trstring = bundles.getString("treatment");
JSONObject json = new JSONObject(trstring);
- handleTreatmentFromNS(json);
+ handleRemovedTreatmentFromNS(json);
}
if (bundles.containsKey("treatments")) {
@@ -227,7 +159,7 @@ public class DataService extends IntentService {
JSONArray jsonArray = new JSONArray(trstring);
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject json = jsonArray.getJSONObject(i);
- handleTreatmentFromNS(json);
+ handleRemovedTreatmentFromNS(json);
}
}
} catch (JSONException e) {
@@ -255,21 +187,9 @@ public class DataService extends IntentService {
log.error("Unhandled exception", e);
}
}
-
- if (intent.getAction().equals(Intents.ACTION_NEW_FOOD)
- || intent.getAction().equals(Intents.ACTION_CHANGED_FOOD)) {
- int mode = Intents.ACTION_NEW_FOOD.equals(intent.getAction()) ? EventNsFood.ADD : EventNsFood.UPDATE;
- EventNsFood evt = new EventNsFood(mode, bundles);
- MainApp.bus().post(evt);
- }
-
- if (intent.getAction().equals(Intents.ACTION_REMOVED_FOOD)) {
- EventNsFood evt = new EventNsFood(EventNsFood.REMOVE, bundles);
- MainApp.bus().post(evt);
- }
}
- private void handleTreatmentFromNS(JSONObject json) {
+ private void handleRemovedTreatmentFromNS(JSONObject json) {
// new DB model
EventNsTreatment evtTreatment = new EventNsTreatment(EventNsTreatment.REMOVE, json);
MainApp.bus().post(evtTreatment);
@@ -333,7 +253,7 @@ public class DataService extends IntentService {
NSMbg nsMbg = new NSMbg(mbgJson);
CareportalEvent careportalEvent = new CareportalEvent(nsMbg);
MainApp.getDbHelper().createOrUpdate(careportalEvent);
- if (Config.logIncommingData)
+ if (L.isEnabled(L.DATASERVICE))
log.debug("Adding/Updating new MBG: " + careportalEvent.log());
}
diff --git a/app/src/main/java/info/nightscout/androidaps/Services/Intents.java b/app/src/main/java/info/nightscout/androidaps/services/Intents.java
similarity index 98%
rename from app/src/main/java/info/nightscout/androidaps/Services/Intents.java
rename to app/src/main/java/info/nightscout/androidaps/services/Intents.java
index 25485fb34d..6d3daf1ea9 100644
--- a/app/src/main/java/info/nightscout/androidaps/Services/Intents.java
+++ b/app/src/main/java/info/nightscout/androidaps/services/Intents.java
@@ -1,4 +1,4 @@
-package info.nightscout.androidaps.Services;
+package info.nightscout.androidaps.services;
public interface Intents {
// NSClient -> App
diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.java b/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.java
index c1669b73d0..acd967f24a 100644
--- a/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.java
+++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.java
@@ -1,13 +1,8 @@
package info.nightscout.androidaps.setupwizard;
import android.Manifest;
-import android.content.ActivityNotFoundException;
-import android.content.Context;
import android.content.Intent;
-import android.net.Uri;
import android.os.Build;
-import android.os.PowerManager;
-import android.provider.Settings;
import android.support.v7.app.AppCompatActivity;
import com.squareup.otto.Subscribe;
@@ -21,7 +16,7 @@ import java.util.List;
import info.nightscout.androidaps.BuildConfig;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
-import info.nightscout.androidaps.PreferencesActivity;
+import info.nightscout.androidaps.activities.PreferencesActivity;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.events.EventConfigBuilderChange;
import info.nightscout.androidaps.events.EventPumpStatusChanged;
@@ -59,7 +54,6 @@ import info.nightscout.utils.ImportExportPrefs;
import info.nightscout.utils.LocaleHelper;
import info.nightscout.utils.PasswordProtection;
import info.nightscout.utils.SP;
-import info.nightscout.utils.ToastUtils;
public class SWDefinition {
private static Logger log = LoggerFactory.getLogger(SWDefinition.class);
diff --git a/app/src/main/java/info/nightscout/utils/HardLimits.java b/app/src/main/java/info/nightscout/utils/HardLimits.java
index 8e1a05db0d..1a36561b62 100644
--- a/app/src/main/java/info/nightscout/utils/HardLimits.java
+++ b/app/src/main/java/info/nightscout/utils/HardLimits.java
@@ -5,6 +5,7 @@ import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
+import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
/**
* Created by mike on 22.02.2017.
diff --git a/app/src/main/java/info/nightscout/utils/LocalAlertUtils.java b/app/src/main/java/info/nightscout/utils/LocalAlertUtils.java
index 5556cae935..9fabe03ec2 100644
--- a/app/src/main/java/info/nightscout/utils/LocalAlertUtils.java
+++ b/app/src/main/java/info/nightscout/utils/LocalAlertUtils.java
@@ -14,6 +14,7 @@ import info.nightscout.androidaps.db.DatabaseHelper;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
+import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
diff --git a/app/src/main/java/info/nightscout/utils/XdripCalibrations.java b/app/src/main/java/info/nightscout/utils/XdripCalibrations.java
index 66ec6bd3df..8ac6433676 100644
--- a/app/src/main/java/info/nightscout/utils/XdripCalibrations.java
+++ b/app/src/main/java/info/nightscout/utils/XdripCalibrations.java
@@ -10,14 +10,12 @@ import android.support.v7.app.AlertDialog;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.Date;
import java.util.List;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
-import info.nightscout.androidaps.Services.Intents;
-import info.nightscout.androidaps.data.Profile;
+import info.nightscout.androidaps.services.Intents;
/**
* Created by mike on 10.02.2017.
diff --git a/app/src/main/res/layout/activity_agreement.xml b/app/src/main/res/layout/activity_agreement.xml
index e5f5c8ddf1..9a17432930 100644
--- a/app/src/main/res/layout/activity_agreement.xml
+++ b/app/src/main/res/layout/activity_agreement.xml
@@ -4,7 +4,7 @@ android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizo
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
-tools:context="info.nightscout.androidaps.AgreementActivity">
+tools:context="info.nightscout.androidaps.activities.AgreementActivity">
+ tools:context="info.nightscout.androidaps.activities.HistoryBrowseActivity">