This commit is contained in:
Milos Kozak 2018-07-29 14:39:56 +02:00
parent ce9e5b9165
commit 54c83dc374
243 changed files with 1406 additions and 1544 deletions

View file

@ -10,8 +10,8 @@ import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.events.Event; import info.nightscout.androidaps.events.Event;
import info.nightscout.androidaps.logging.L;
/** Logs events has they're being posted to and dispatched from the event bus. /** Logs events has they're being posted to and dispatched from the event bus.
* *
@ -19,7 +19,7 @@ import info.nightscout.androidaps.events.Event;
* after 10s (after startup) and then again every 60s. * after 10s (after startup) and then again every 60s.
* */ * */
public class LoggingBus extends Bus { public class LoggingBus extends Bus {
private static Logger log = LoggerFactory.getLogger(Constants.EVENTS); private static Logger log = LoggerFactory.getLogger(L.EVENTS);
private static long everyMinute = System.currentTimeMillis() + 10 * 1000; private static long everyMinute = System.currentTimeMillis() + 10 * 1000;
private Map<String, Set<String>> event2Receiver = new HashMap<>(); private Map<String, Set<String>> event2Receiver = new HashMap<>();

View file

@ -27,22 +27,5 @@ public class Config {
public static boolean logPrefsChange = true; public static boolean logPrefsChange = true;
public static boolean logConfigBuilder = true; public static boolean logConfigBuilder = true;
public static boolean logCongigBuilderActions = true; public static boolean logCongigBuilderActions = true;
public static boolean logAutosensData = false;
public static boolean logEvents = false;
public static boolean logQueue = true;
public static boolean logBgSource = true;
public static boolean logOverview = true;
public static boolean logNotification = true;
public static boolean logAlarm = false;
public static boolean logDataService = true;
public static boolean logDataFood = true;
public static boolean logDataTreatments = true;
public static boolean logDatabase = true;
public static boolean logNsclient = true;
public static boolean logObjectives = false;
public static boolean logPump = true;
public static boolean logPumpComm = true;
public static boolean logPumpBtComm = false;
public static boolean logAps = true;
} }

View file

@ -68,21 +68,4 @@ public class Constants {
//SMS Communicator //SMS Communicator
public static final long SMS_CONFIRM_TIMEOUT = T.mins(5).msecs(); public static final long SMS_CONFIRM_TIMEOUT = T.mins(5).msecs();
// logging
public static final String AUTOSENS = "AUTOSENS";
public static final String EVENTS = "EVENTS";
public static final String BGSOURCE = "BGSOURCE";
public static final String OVERVIEW = "OVERVIEW";
public static final String NOTIFICATION = "NOTIFICATION";
public static final String ALARM = "ALARM";
public static final String DATASERVICE = "DATASERVICE";
public static final String DATAFOOD = "DATAFOOD";
public static final String DATATREATMENTS = "DATATREATMENTS";
public static final String NSCLIENT = "NSCLIENT";
public static final String OBJECTIVES = "OBJECTIVES";
public static final String PUMP = "PUMP";
public static final String PUMPQUEUE = "PUMPQUEUE";
public static final String PUMPCOMM = "PUMPCOMM";
public static final String PUMPBTCOMM = "PUMPBTCOMM";
public static final String APS = "APS";
} }

View file

@ -24,6 +24,7 @@ import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import ch.qos.logback.classic.LoggerContext; import ch.qos.logback.classic.LoggerContext;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.services.Intents; import info.nightscout.androidaps.services.Intents;
import info.nightscout.androidaps.data.ConstraintChecker; import info.nightscout.androidaps.data.ConstraintChecker;
import info.nightscout.androidaps.db.DatabaseHelper; import info.nightscout.androidaps.db.DatabaseHelper;
@ -132,7 +133,7 @@ public class MainApp extends Application {
engineeringMode = engineeringModeSemaphore.exists() && engineeringModeSemaphore.isFile(); engineeringMode = engineeringModeSemaphore.exists() && engineeringModeSemaphore.isFile();
devBranch = BuildConfig.VERSION.contains("dev"); devBranch = BuildConfig.VERSION.contains("dev");
sBus = Config.logEvents ? new LoggingBus(ThreadEnforcer.ANY) : new Bus(ThreadEnforcer.ANY); sBus = L.isEnabled(L.EVENTS) ? new LoggingBus(ThreadEnforcer.ANY) : new Bus(ThreadEnforcer.ANY);
registerLocalBroadcastReceiver(); registerLocalBroadcastReceiver();

View file

@ -27,7 +27,6 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.data.OverlappingIntervals; import info.nightscout.androidaps.data.OverlappingIntervals;
import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.Profile;
@ -42,12 +41,13 @@ import info.nightscout.androidaps.events.EventReloadTempBasalData;
import info.nightscout.androidaps.events.EventReloadTreatmentData; import info.nightscout.androidaps.events.EventReloadTreatmentData;
import info.nightscout.androidaps.events.EventTempBasalChange; import info.nightscout.androidaps.events.EventTempBasalChange;
import info.nightscout.androidaps.events.EventTempTargetChange; import info.nightscout.androidaps.events.EventTempTargetChange;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventNewHistoryData; import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventNewHistoryData;
import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
import info.nightscout.androidaps.plugins.PumpDanaR.activities.DanaRNSHistorySync; import info.nightscout.androidaps.plugins.PumpDanaR.activities.DanaRNSHistorySync;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes; import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes;
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin; import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
import info.nightscout.utils.JsonHelper; import info.nightscout.utils.JsonHelper;
import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
import info.nightscout.utils.PercentageSplitter; import info.nightscout.utils.PercentageSplitter;
import info.nightscout.utils.ToastUtils; import info.nightscout.utils.ToastUtils;
@ -60,7 +60,7 @@ import info.nightscout.utils.ToastUtils;
* direct calls to the corresponding methods (eg. resetDatabases) should be done by a central service. * direct calls to the corresponding methods (eg. resetDatabases) should be done by a central service.
*/ */
public class DatabaseHelper extends OrmLiteSqliteOpenHelper { public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
private static Logger log = LoggerFactory.getLogger(DatabaseHelper.class); private static Logger log = LoggerFactory.getLogger(L.DATABASE);
public static final String DATABASE_NAME = "AndroidAPSDb"; public static final String DATABASE_NAME = "AndroidAPSDb";
public static final String DATABASE_BGREADINGS = "BgReadings"; public static final String DATABASE_BGREADINGS = "BgReadings";
@ -107,7 +107,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
@Override @Override
public void onCreate(SQLiteDatabase database, ConnectionSource connectionSource) { public void onCreate(SQLiteDatabase database, ConnectionSource connectionSource) {
try { try {
log.info("onCreate"); if (L.isEnabled(L.DATABASE))
log.info("onCreate");
TableUtils.createTableIfNotExists(connectionSource, TempTarget.class); TableUtils.createTableIfNotExists(connectionSource, TempTarget.class);
TableUtils.createTableIfNotExists(connectionSource, BgReading.class); TableUtils.createTableIfNotExists(connectionSource, BgReading.class);
TableUtils.createTableIfNotExists(connectionSource, DanaRHistoryRecord.class); TableUtils.createTableIfNotExists(connectionSource, DanaRHistoryRecord.class);
@ -325,15 +326,18 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
BgReading old = getDaoBgReadings().queryForId(bgReading.date); BgReading old = getDaoBgReadings().queryForId(bgReading.date);
if (old == null) { if (old == null) {
getDaoBgReadings().create(bgReading); getDaoBgReadings().create(bgReading);
log.debug("BG: New record from: " + from + " " + bgReading.toString()); if (L.isEnabled(L.DATABASE))
log.debug("BG: New record from: " + from + " " + bgReading.toString());
scheduleBgChange(bgReading); scheduleBgChange(bgReading);
return true; return true;
} }
if (!old.isEqual(bgReading)) { if (!old.isEqual(bgReading)) {
log.debug("BG: Similiar found: " + old.toString()); if (L.isEnabled(L.DATABASE))
log.debug("BG: Similiar found: " + old.toString());
old.copyFrom(bgReading); old.copyFrom(bgReading);
getDaoBgReadings().update(old); getDaoBgReadings().update(old);
log.debug("BG: Updating record from: " + from + " New data: " + old.toString()); if (L.isEnabled(L.DATABASE))
log.debug("BG: Updating record from: " + from + " New data: " + old.toString());
scheduleBgChange(bgReading); scheduleBgChange(bgReading);
return false; return false;
} }
@ -355,7 +359,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
private static void scheduleBgChange(@Nullable final BgReading bgReading) { private static void scheduleBgChange(@Nullable final BgReading bgReading) {
class PostRunnable implements Runnable { class PostRunnable implements Runnable {
public void run() { public void run() {
log.debug("Firing EventNewBg"); if (L.isEnabled(L.DATABASE))
log.debug("Firing EventNewBg");
MainApp.bus().post(new EventNewBG(bgReading)); MainApp.bus().post(new EventNewBG(bgReading));
scheduledBgPost = null; scheduledBgPost = null;
} }
@ -387,7 +392,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
bgList = daoBgReadings.query(preparedQuery); bgList = daoBgReadings.query(preparedQuery);
} catch (SQLException e) { } catch (SQLException e) {
log.debug(e.getMessage(), e); log.error("Unhandled exception", e);
} }
if (bgList != null && bgList.size() > 0) if (bgList != null && bgList.size() > 0)
return bgList.get(0); return bgList.get(0);
@ -595,7 +600,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
getDaoTempTargets().delete(old); // need to delete/create because date may change too getDaoTempTargets().delete(old); // need to delete/create because date may change too
old.copyFrom(tempTarget); old.copyFrom(tempTarget);
getDaoTempTargets().create(old); getDaoTempTargets().create(old);
log.debug("TEMPTARGET: Updating record by date from: " + Source.getString(tempTarget.source) + " " + old.toString()); if (L.isEnabled(L.DATABASE))
log.debug("TEMPTARGET: Updating record by date from: " + Source.getString(tempTarget.source) + " " + old.toString());
scheduleTemporaryTargetChange(); scheduleTemporaryTargetChange();
return true; return true;
} }
@ -614,20 +620,23 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
getDaoTempTargets().delete(old); // need to delete/create because date may change too getDaoTempTargets().delete(old); // need to delete/create because date may change too
old.copyFrom(tempTarget); old.copyFrom(tempTarget);
getDaoTempTargets().create(old); getDaoTempTargets().create(old);
log.debug("TEMPTARGET: Updating record by _id from: " + Source.getString(tempTarget.source) + " " + old.toString()); if (L.isEnabled(L.DATABASE))
log.debug("TEMPTARGET: Updating record by _id from: " + Source.getString(tempTarget.source) + " " + old.toString());
scheduleTemporaryTargetChange(); scheduleTemporaryTargetChange();
return true; return true;
} }
} }
} }
getDaoTempTargets().create(tempTarget); getDaoTempTargets().create(tempTarget);
log.debug("TEMPTARGET: New record from: " + Source.getString(tempTarget.source) + " " + tempTarget.toString()); if (L.isEnabled(L.DATABASE))
log.debug("TEMPTARGET: New record from: " + Source.getString(tempTarget.source) + " " + tempTarget.toString());
scheduleTemporaryTargetChange(); scheduleTemporaryTargetChange();
return true; return true;
} }
if (tempTarget.source == Source.USER) { if (tempTarget.source == Source.USER) {
getDaoTempTargets().create(tempTarget); getDaoTempTargets().create(tempTarget);
log.debug("TEMPTARGET: New record from: " + Source.getString(tempTarget.source) + " " + tempTarget.toString()); if (L.isEnabled(L.DATABASE))
log.debug("TEMPTARGET: New record from: " + Source.getString(tempTarget.source) + " " + tempTarget.toString());
scheduleTemporaryTargetChange(); scheduleTemporaryTargetChange();
return true; return true;
} }
@ -649,7 +658,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
private static void scheduleTemporaryTargetChange() { private static void scheduleTemporaryTargetChange() {
class PostRunnable implements Runnable { class PostRunnable implements Runnable {
public void run() { public void run() {
log.debug("Firing EventTempTargetChange"); if (L.isEnabled(L.DATABASE))
log.debug("Firing EventTempTargetChange");
MainApp.bus().post(new EventTempTargetChange()); MainApp.bus().post(new EventTempTargetChange());
scheduledTemTargetPost = null; scheduledTemTargetPost = null;
} }
@ -769,7 +779,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
} else if (list.size() == 1) { } else if (list.size() == 1) {
DanaRHistoryRecord record = list.get(0); DanaRHistoryRecord record = list.get(0);
if (record._id == null || !record._id.equals(trJson.getString("_id"))) { if (record._id == null || !record._id.equals(trJson.getString("_id"))) {
if (Config.logDatabase) if (L.isEnabled(L.DATABASE))
log.debug("Updating _id in DanaR history database: " + trJson.getString("_id")); log.debug("Updating _id in DanaR history database: " + trJson.getString("_id"));
record._id = trJson.getString("_id"); record._id = trJson.getString("_id");
getDaoDanaRHistory().update(record); getDaoDanaRHistory().update(record);
@ -799,11 +809,13 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
List<TemporaryBasal> trList = getDaoTemporaryBasal().query(preparedQuery); List<TemporaryBasal> trList = getDaoTemporaryBasal().query(preparedQuery);
if (trList.size() > 0) { if (trList.size() > 0) {
// do nothing, pump history record cannot be changed // do nothing, pump history record cannot be changed
log.debug("TEMPBASAL: Already exists from: " + Source.getString(tempBasal.source) + " " + tempBasal.toString()); if (L.isEnabled(L.DATABASE))
log.debug("TEMPBASAL: Already exists from: " + Source.getString(tempBasal.source) + " " + tempBasal.toString());
return false; return false;
} }
getDaoTemporaryBasal().create(tempBasal); getDaoTemporaryBasal().create(tempBasal);
log.debug("TEMPBASAL: New record from: " + Source.getString(tempBasal.source) + " " + tempBasal.toString()); if (L.isEnabled(L.DATABASE))
log.debug("TEMPBASAL: New record from: " + Source.getString(tempBasal.source) + " " + tempBasal.toString());
updateEarliestDataChange(tempBasal.date); updateEarliestDataChange(tempBasal.date);
scheduleTemporaryBasalChange(); scheduleTemporaryBasalChange();
return true; return true;
@ -820,7 +832,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
getDaoTemporaryBasal().delete(old); // need to delete/create because date may change too getDaoTemporaryBasal().delete(old); // need to delete/create because date may change too
old.copyFrom(tempBasal); old.copyFrom(tempBasal);
getDaoTemporaryBasal().create(old); getDaoTemporaryBasal().create(old);
log.debug("TEMPBASAL: Updating record by date from: " + Source.getString(tempBasal.source) + " " + old.toString()); if (L.isEnabled(L.DATABASE))
log.debug("TEMPBASAL: Updating record by date from: " + Source.getString(tempBasal.source) + " " + old.toString());
updateEarliestDataChange(oldDate); updateEarliestDataChange(oldDate);
updateEarliestDataChange(old.date); updateEarliestDataChange(old.date);
scheduleTemporaryBasalChange(); scheduleTemporaryBasalChange();
@ -842,7 +855,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
getDaoTemporaryBasal().delete(old); // need to delete/create because date may change too getDaoTemporaryBasal().delete(old); // need to delete/create because date may change too
old.copyFrom(tempBasal); old.copyFrom(tempBasal);
getDaoTemporaryBasal().create(old); getDaoTemporaryBasal().create(old);
log.debug("TEMPBASAL: Updating record by _id from: " + Source.getString(tempBasal.source) + " " + old.toString()); if (L.isEnabled(L.DATABASE))
log.debug("TEMPBASAL: Updating record by _id from: " + Source.getString(tempBasal.source) + " " + old.toString());
updateEarliestDataChange(oldDate); updateEarliestDataChange(oldDate);
updateEarliestDataChange(old.date); updateEarliestDataChange(old.date);
scheduleTemporaryBasalChange(); scheduleTemporaryBasalChange();
@ -851,14 +865,16 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
} }
} }
getDaoTemporaryBasal().create(tempBasal); getDaoTemporaryBasal().create(tempBasal);
log.debug("TEMPBASAL: New record from: " + Source.getString(tempBasal.source) + " " + tempBasal.toString()); if (L.isEnabled(L.DATABASE))
log.debug("TEMPBASAL: New record from: " + Source.getString(tempBasal.source) + " " + tempBasal.toString());
updateEarliestDataChange(tempBasal.date); updateEarliestDataChange(tempBasal.date);
scheduleTemporaryBasalChange(); scheduleTemporaryBasalChange();
return true; return true;
} }
if (tempBasal.source == Source.USER) { if (tempBasal.source == Source.USER) {
getDaoTemporaryBasal().create(tempBasal); getDaoTemporaryBasal().create(tempBasal);
log.debug("TEMPBASAL: New record from: " + Source.getString(tempBasal.source) + " " + tempBasal.toString()); if (L.isEnabled(L.DATABASE))
log.debug("TEMPBASAL: New record from: " + Source.getString(tempBasal.source) + " " + tempBasal.toString());
updateEarliestDataChange(tempBasal.date); updateEarliestDataChange(tempBasal.date);
scheduleTemporaryBasalChange(); scheduleTemporaryBasalChange();
return true; return true;
@ -898,7 +914,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
private static void scheduleTemporaryBasalChange() { private static void scheduleTemporaryBasalChange() {
class PostRunnable implements Runnable { class PostRunnable implements Runnable {
public void run() { public void run() {
log.debug("Firing EventTempBasalChange"); if (L.isEnabled(L.DATABASE))
log.debug("Firing EventTempBasalChange");
MainApp.bus().post(new EventReloadTempBasalData()); MainApp.bus().post(new EventReloadTempBasalData());
MainApp.bus().post(new EventTempBasalChange()); MainApp.bus().post(new EventTempBasalChange());
if (earliestDataChange != null) if (earliestDataChange != null)
@ -990,7 +1007,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
public void deleteTempBasalById(String _id) { public void deleteTempBasalById(String _id) {
TemporaryBasal stored = findTempBasalById(_id); TemporaryBasal stored = findTempBasalById(_id);
if (stored != null) { if (stored != null) {
log.debug("TEMPBASAL: Removing TempBasal record from database: " + stored.toString()); if (L.isEnabled(L.DATABASE))
log.debug("TEMPBASAL: Removing TempBasal record from database: " + stored.toString());
delete(stored); delete(stored);
updateEarliestDataChange(stored.date); updateEarliestDataChange(stored.date);
scheduleTemporaryBasalChange(); scheduleTemporaryBasalChange();
@ -1036,7 +1054,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return false; return false;
} }
getDaoExtendedBolus().create(extendedBolus); getDaoExtendedBolus().create(extendedBolus);
log.debug("EXTENDEDBOLUS: New record from: " + Source.getString(extendedBolus.source) + " " + extendedBolus.toString()); if (L.isEnabled(L.DATABASE))
log.debug("EXTENDEDBOLUS: New record from: " + Source.getString(extendedBolus.source) + " " + extendedBolus.toString());
updateEarliestDataChange(extendedBolus.date); updateEarliestDataChange(extendedBolus.date);
scheduleExtendedBolusChange(); scheduleExtendedBolusChange();
return true; return true;
@ -1049,7 +1068,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
getDaoExtendedBolus().delete(old); // need to delete/create because date may change too getDaoExtendedBolus().delete(old); // need to delete/create because date may change too
old.copyFrom(extendedBolus); old.copyFrom(extendedBolus);
getDaoExtendedBolus().create(old); getDaoExtendedBolus().create(old);
log.debug("EXTENDEDBOLUS: Updating record by date from: " + Source.getString(extendedBolus.source) + " " + old.toString()); if (L.isEnabled(L.DATABASE))
log.debug("EXTENDEDBOLUS: Updating record by date from: " + Source.getString(extendedBolus.source) + " " + old.toString());
updateEarliestDataChange(oldDate); updateEarliestDataChange(oldDate);
updateEarliestDataChange(old.date); updateEarliestDataChange(old.date);
scheduleExtendedBolusChange(); scheduleExtendedBolusChange();
@ -1071,7 +1091,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
getDaoExtendedBolus().delete(old); // need to delete/create because date may change too getDaoExtendedBolus().delete(old); // need to delete/create because date may change too
old.copyFrom(extendedBolus); old.copyFrom(extendedBolus);
getDaoExtendedBolus().create(old); getDaoExtendedBolus().create(old);
log.debug("EXTENDEDBOLUS: Updating record by _id from: " + Source.getString(extendedBolus.source) + " " + old.toString()); if (L.isEnabled(L.DATABASE))
log.debug("EXTENDEDBOLUS: Updating record by _id from: " + Source.getString(extendedBolus.source) + " " + old.toString());
updateEarliestDataChange(oldDate); updateEarliestDataChange(oldDate);
updateEarliestDataChange(old.date); updateEarliestDataChange(old.date);
scheduleExtendedBolusChange(); scheduleExtendedBolusChange();
@ -1080,14 +1101,16 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
} }
} }
getDaoExtendedBolus().create(extendedBolus); getDaoExtendedBolus().create(extendedBolus);
log.debug("EXTENDEDBOLUS: New record from: " + Source.getString(extendedBolus.source) + " " + extendedBolus.toString()); if (L.isEnabled(L.DATABASE))
log.debug("EXTENDEDBOLUS: New record from: " + Source.getString(extendedBolus.source) + " " + extendedBolus.toString());
updateEarliestDataChange(extendedBolus.date); updateEarliestDataChange(extendedBolus.date);
scheduleExtendedBolusChange(); scheduleExtendedBolusChange();
return true; return true;
} }
if (extendedBolus.source == Source.USER) { if (extendedBolus.source == Source.USER) {
getDaoExtendedBolus().create(extendedBolus); getDaoExtendedBolus().create(extendedBolus);
log.debug("EXTENDEDBOLUS: New record from: " + Source.getString(extendedBolus.source) + " " + extendedBolus.toString()); if (L.isEnabled(L.DATABASE))
log.debug("EXTENDEDBOLUS: New record from: " + Source.getString(extendedBolus.source) + " " + extendedBolus.toString());
updateEarliestDataChange(extendedBolus.date); updateEarliestDataChange(extendedBolus.date);
scheduleExtendedBolusChange(); scheduleExtendedBolusChange();
return true; return true;
@ -1127,7 +1150,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
public void deleteExtendedBolusById(String _id) { public void deleteExtendedBolusById(String _id) {
ExtendedBolus stored = findExtendedBolusById(_id); ExtendedBolus stored = findExtendedBolusById(_id);
if (stored != null) { if (stored != null) {
log.debug("EXTENDEDBOLUS: Removing ExtendedBolus record from database: " + stored.toString()); if (L.isEnabled(L.DATABASE))
log.debug("EXTENDEDBOLUS: Removing ExtendedBolus record from database: " + stored.toString());
delete(stored); delete(stored);
updateEarliestDataChange(stored.date); updateEarliestDataChange(stored.date);
scheduleExtendedBolusChange(); scheduleExtendedBolusChange();
@ -1180,7 +1204,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
private static void scheduleExtendedBolusChange() { private static void scheduleExtendedBolusChange() {
class PostRunnable implements Runnable { class PostRunnable implements Runnable {
public void run() { public void run() {
log.debug("Firing EventExtendedBolusChange"); if (L.isEnabled(L.DATABASE))
log.debug("Firing EventExtendedBolusChange");
MainApp.bus().post(new EventReloadTreatmentData(new EventExtendedBolusChange())); MainApp.bus().post(new EventReloadTreatmentData(new EventExtendedBolusChange()));
if (earliestDataChange != null) if (earliestDataChange != null)
MainApp.bus().post(new EventNewHistoryData(earliestDataChange)); MainApp.bus().post(new EventNewHistoryData(earliestDataChange));
@ -1320,11 +1345,11 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
if (list.size() == 1) { if (list.size() == 1) {
CareportalEvent record = list.get(0); CareportalEvent record = list.get(0);
if (Config.logDatabase) if (L.isEnabled(L.DATABASE))
log.debug("Removing CareportalEvent record from database: " + record.log()); log.debug("Removing CareportalEvent record from database: " + record.log());
delete(record); delete(record);
} else { } else {
if (Config.logDatabase) if (L.isEnabled(L.DATABASE))
log.debug("CareportalEvent not found database: " + _id); log.debug("CareportalEvent not found database: " + _id);
} }
} catch (SQLException e) { } catch (SQLException e) {
@ -1344,12 +1369,12 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
if (list.size() == 0) { if (list.size() == 0) {
careportalEvent = new CareportalEvent(); careportalEvent = new CareportalEvent();
careportalEvent.source = Source.NIGHTSCOUT; careportalEvent.source = Source.NIGHTSCOUT;
if (Config.logDatabase) if (L.isEnabled(L.DATABASE))
log.debug("Adding CareportalEvent record to database: " + trJson.toString()); log.debug("Adding CareportalEvent record to database: " + trJson.toString());
// Record does not exists. add // Record does not exists. add
} else if (list.size() == 1) { } else if (list.size() == 1) {
careportalEvent = list.get(0); careportalEvent = list.get(0);
if (Config.logDatabase) if (L.isEnabled(L.DATABASE))
log.debug("Updating CareportalEvent record in database: " + trJson.toString()); log.debug("Updating CareportalEvent record in database: " + trJson.toString());
} else { } else {
log.error("Something went wrong"); log.error("Something went wrong");
@ -1368,7 +1393,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
private static void scheduleCareportalEventChange() { private static void scheduleCareportalEventChange() {
class PostRunnable implements Runnable { class PostRunnable implements Runnable {
public void run() { public void run() {
log.debug("Firing scheduleCareportalEventChange"); if (L.isEnabled(L.DATABASE))
log.debug("Firing scheduleCareportalEventChange");
MainApp.bus().post(new EventCareportalEventChange()); MainApp.bus().post(new EventCareportalEventChange());
scheduledCareportalEventPost = null; scheduledCareportalEventPost = null;
} }
@ -1414,7 +1440,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
profileSwitch.profileName = old.profileName; // preserver profileName to prevent multiple CPP extension profileSwitch.profileName = old.profileName; // preserver profileName to prevent multiple CPP extension
getDaoProfileSwitch().delete(old); // need to delete/create because date may change too getDaoProfileSwitch().delete(old); // need to delete/create because date may change too
getDaoProfileSwitch().create(profileSwitch); getDaoProfileSwitch().create(profileSwitch);
log.debug("PROFILESWITCH: Updating record by date from: " + Source.getString(profileSwitch.source) + " " + old.toString()); if (L.isEnabled(L.DATABASE))
log.debug("PROFILESWITCH: Updating record by date from: " + Source.getString(profileSwitch.source) + " " + old.toString());
scheduleProfileSwitchChange(); scheduleProfileSwitchChange();
return true; return true;
} }
@ -1433,7 +1460,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
getDaoProfileSwitch().delete(old); // need to delete/create because date may change too getDaoProfileSwitch().delete(old); // need to delete/create because date may change too
old.copyFrom(profileSwitch); old.copyFrom(profileSwitch);
getDaoProfileSwitch().create(old); getDaoProfileSwitch().create(old);
log.debug("PROFILESWITCH: Updating record by _id from: " + Source.getString(profileSwitch.source) + " " + old.toString()); if (L.isEnabled(L.DATABASE))
log.debug("PROFILESWITCH: Updating record by _id from: " + Source.getString(profileSwitch.source) + " " + old.toString());
scheduleProfileSwitchChange(); scheduleProfileSwitchChange();
return true; return true;
} }
@ -1442,13 +1470,15 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
// look for already added percentage from NS // look for already added percentage from NS
profileSwitch.profileName = PercentageSplitter.pureName(profileSwitch.profileName); profileSwitch.profileName = PercentageSplitter.pureName(profileSwitch.profileName);
getDaoProfileSwitch().create(profileSwitch); getDaoProfileSwitch().create(profileSwitch);
log.debug("PROFILESWITCH: New record from: " + Source.getString(profileSwitch.source) + " " + profileSwitch.toString()); if (L.isEnabled(L.DATABASE))
log.debug("PROFILESWITCH: New record from: " + Source.getString(profileSwitch.source) + " " + profileSwitch.toString());
scheduleProfileSwitchChange(); scheduleProfileSwitchChange();
return true; return true;
} }
if (profileSwitch.source == Source.USER) { if (profileSwitch.source == Source.USER) {
getDaoProfileSwitch().create(profileSwitch); getDaoProfileSwitch().create(profileSwitch);
log.debug("PROFILESWITCH: New record from: " + Source.getString(profileSwitch.source) + " " + profileSwitch.toString()); if (L.isEnabled(L.DATABASE))
log.debug("PROFILESWITCH: New record from: " + Source.getString(profileSwitch.source) + " " + profileSwitch.toString());
scheduleProfileSwitchChange(); scheduleProfileSwitchChange();
return true; return true;
} }
@ -1470,7 +1500,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
private static void scheduleProfileSwitchChange() { private static void scheduleProfileSwitchChange() {
class PostRunnable implements Runnable { class PostRunnable implements Runnable {
public void run() { public void run() {
log.debug("Firing EventProfileSwitchChange"); if (L.isEnabled(L.DATABASE))
log.debug("Firing EventProfileSwitchChange");
MainApp.bus().post(new EventReloadProfileSwitchData()); MainApp.bus().post(new EventReloadProfileSwitchData());
MainApp.bus().post(new EventProfileSwitchChange()); MainApp.bus().post(new EventProfileSwitchChange());
scheduledProfileSwitchEventPost = null; scheduledProfileSwitchEventPost = null;
@ -1520,15 +1551,18 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
Profile profile = store.getSpecificProfile(profileSwitch.profileName); Profile profile = store.getSpecificProfile(profileSwitch.profileName);
if (profile != null) { if (profile != null) {
profileSwitch.profileJson = profile.getData().toString(); profileSwitch.profileJson = profile.getData().toString();
log.debug("Profile switch prefilled with JSON from local store"); if (L.isEnabled(L.DATABASE))
log.debug("Profile switch prefilled with JSON from local store");
// Update data in NS // Update data in NS
NSUpload.updateProfileSwitch(profileSwitch); NSUpload.updateProfileSwitch(profileSwitch);
} else { } else {
log.debug("JSON for profile switch doesn't exist. Ignoring: " + trJson.toString()); if (L.isEnabled(L.DATABASE))
log.debug("JSON for profile switch doesn't exist. Ignoring: " + trJson.toString());
return; return;
} }
} else { } else {
log.debug("Store for profile switch doesn't exist. Ignoring: " + trJson.toString()); if (L.isEnabled(L.DATABASE))
log.debug("Store for profile switch doesn't exist. Ignoring: " + trJson.toString());
return; return;
} }
} }
@ -1543,7 +1577,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
public void deleteProfileSwitchById(String _id) { public void deleteProfileSwitchById(String _id) {
ProfileSwitch stored = findProfileSwitchById(_id); ProfileSwitch stored = findProfileSwitchById(_id);
if (stored != null) { if (stored != null) {
log.debug("PROFILESWITCH: Removing ProfileSwitch record from database: " + stored.toString()); if (L.isEnabled(L.DATABASE))
log.debug("PROFILESWITCH: Removing ProfileSwitch record from database: " + stored.toString());
delete(stored); delete(stored);
scheduleTemporaryTargetChange(); scheduleTemporaryTargetChange();
} }

View file

@ -1,4 +1,4 @@
package info.nightscout.utils; package info.nightscout.androidaps.logging;
import android.os.Bundle; import android.os.Bundle;

View file

@ -6,19 +6,17 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.data.DetailedBolusInfo; import info.nightscout.androidaps.data.DetailedBolusInfo;
import info.nightscout.androidaps.logging.L;
/** /**
* Created by mike on 08.08.2017. * Created by mike on 08.08.2017.
*/ */
public class DetailedBolusInfoStorage { public class DetailedBolusInfoStorage {
private static Logger log = LoggerFactory.getLogger(Constants.PUMP); private static Logger log = LoggerFactory.getLogger(L.PUMP);
private static List<DetailedBolusInfo> store = new ArrayList<>(); private static List<DetailedBolusInfo> store = new ArrayList<>();
public static synchronized void add(DetailedBolusInfo detailedBolusInfo) { public static synchronized void add(DetailedBolusInfo detailedBolusInfo) {
@ -31,7 +29,7 @@ public class DetailedBolusInfoStorage {
DetailedBolusInfo found = null; DetailedBolusInfo found = null;
for (int i = 0; i < store.size(); i++) { for (int i = 0; i < store.size(); i++) {
long infoTime = store.get(i).date; long infoTime = store.get(i).date;
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("Existing bolus info: " + store.get(i)); log.debug("Existing bolus info: " + store.get(i));
if (bolustime > infoTime - 60 * 1000 && bolustime < infoTime + 60 * 1000) { if (bolustime > infoTime - 60 * 1000 && bolustime < infoTime + 60 * 1000) {
found = store.get(i); found = store.get(i);
@ -45,7 +43,7 @@ public class DetailedBolusInfoStorage {
for (int i = 0; i < store.size(); i++) { for (int i = 0; i < store.size(); i++) {
long infoTime = store.get(i).date; long infoTime = store.get(i).date;
if (bolustime > infoTime - 60 * 1000 && bolustime < infoTime + 60 * 1000) { if (bolustime > infoTime - 60 * 1000 && bolustime < infoTime + 60 * 1000) {
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("Removing bolus info: " + store.get(i)); log.debug("Removing bolus info: " + store.get(i));
store.remove(i); store.remove(i);
break; break;

View file

@ -7,7 +7,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.interfaces.Constraint; import info.nightscout.androidaps.interfaces.Constraint;
@ -16,6 +15,7 @@ import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.ConstraintsObjectives.events.EventObjectivesSaved; import info.nightscout.androidaps.plugins.ConstraintsObjectives.events.EventObjectivesSaved;
import info.nightscout.androidaps.plugins.ConstraintsObjectives.objectives.Objective; import info.nightscout.androidaps.plugins.ConstraintsObjectives.objectives.Objective;
@ -33,7 +33,7 @@ import info.nightscout.utils.SP;
* Created by mike on 05.08.2016. * Created by mike on 05.08.2016.
*/ */
public class ObjectivesPlugin extends PluginBase implements ConstraintsInterface { public class ObjectivesPlugin extends PluginBase implements ConstraintsInterface {
private static Logger log = LoggerFactory.getLogger(Constants.OBJECTIVES); private static Logger log = LoggerFactory.getLogger(L.OBJECTIVES);
private static ObjectivesPlugin objectivesPlugin; private static ObjectivesPlugin objectivesPlugin;
@ -95,7 +95,7 @@ public class ObjectivesPlugin extends PluginBase implements ConstraintsInterface
SP.putBoolean("Objectives" + "bgIsAvailableInNS", bgIsAvailableInNS); SP.putBoolean("Objectives" + "bgIsAvailableInNS", bgIsAvailableInNS);
SP.putBoolean("Objectives" + "pumpStatusIsAvailableInNS", pumpStatusIsAvailableInNS); SP.putBoolean("Objectives" + "pumpStatusIsAvailableInNS", pumpStatusIsAvailableInNS);
SP.putString("Objectives" + "manualEnacts", Integer.toString(manualEnacts)); SP.putString("Objectives" + "manualEnacts", Integer.toString(manualEnacts));
if (Config.logObjectives) if (L.isEnabled(L.OBJECTIVES))
log.debug("Objectives stored"); log.debug("Objectives stored");
MainApp.bus().post(new EventObjectivesSaved()); MainApp.bus().post(new EventObjectivesSaved());
} }
@ -108,7 +108,7 @@ public class ObjectivesPlugin extends PluginBase implements ConstraintsInterface
} catch (Exception e) { } catch (Exception e) {
log.error("Unhandled exception", e); log.error("Unhandled exception", e);
} }
if (Config.logObjectives) if (L.isEnabled(L.OBJECTIVES))
log.debug("Objectives loaded"); log.debug("Objectives loaded");
} }

View file

@ -27,21 +27,20 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.db.DatabaseHelper; import info.nightscout.androidaps.db.DatabaseHelper;
import info.nightscout.androidaps.db.ICallback; import info.nightscout.androidaps.db.ICallback;
import info.nightscout.androidaps.events.Event; import info.nightscout.androidaps.events.Event;
import info.nightscout.androidaps.events.EventFoodDatabaseChanged; import info.nightscout.androidaps.events.EventFoodDatabaseChanged;
import info.nightscout.androidaps.events.EventNsFood; import info.nightscout.androidaps.events.EventNsFood;
import info.nightscout.androidaps.logging.L;
/** /**
* Created by mike on 24.09.2017. * Created by mike on 24.09.2017.
*/ */
public class FoodService extends OrmLiteBaseService<DatabaseHelper> { public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
private Logger log = LoggerFactory.getLogger(Constants.DATAFOOD); private Logger log = LoggerFactory.getLogger(L.DATAFOOD);
private static final ScheduledExecutorService foodEventWorker = Executors.newSingleThreadScheduledExecutor(); private static final ScheduledExecutorService foodEventWorker = Executors.newSingleThreadScheduledExecutor();
private static ScheduledFuture<?> scheduledFoodEventPost = null; private static ScheduledFuture<?> scheduledFoodEventPost = null;
@ -112,7 +111,7 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
try { try {
if (Config.logDataFood) if (L.isEnabled(L.DATAFOOD))
log.info("onCreate"); log.info("onCreate");
TableUtils.createTableIfNotExists(this.getConnectionSource(), Food.class); TableUtils.createTableIfNotExists(this.getConnectionSource(), Food.class);
} catch (SQLException e) { } catch (SQLException e) {
@ -125,7 +124,7 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
if (oldVersion == 7 && newVersion == 8) { if (oldVersion == 7 && newVersion == 8) {
log.debug("Upgrading database from v7 to v8"); log.debug("Upgrading database from v7 to v8");
} else { } else {
if (Config.logDataFood) if (L.isEnabled(L.DATAFOOD))
log.info("onUpgrade"); log.info("onUpgrade");
// this.resetFood(); // this.resetFood();
} }
@ -165,7 +164,7 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
class PostRunnable implements Runnable { class PostRunnable implements Runnable {
public void run() { public void run() {
if (Config.logDataFood) if (L.isEnabled(L.DATAFOOD))
log.debug("Firing EventFoodChange"); log.debug("Firing EventFoodChange");
MainApp.bus().post(event); MainApp.bus().post(event);
callback.setPost(null); callback.setPost(null);
@ -276,7 +275,7 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
public void deleteByNSId(String _id) throws SQLException { public void deleteByNSId(String _id) throws SQLException {
Food stored = this.findByNSId(_id); Food stored = this.findByNSId(_id);
if (stored != null) { if (stored != null) {
if (Config.logDataFood) if (L.isEnabled(L.DATAFOOD))
log.debug("Removing Food record from database: " + stored.toString()); log.debug("Removing Food record from database: " + stored.toString());
this.delete(stored); this.delete(stored);
} }
@ -330,7 +329,7 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
public void createOrUpdate(Food food) { public void createOrUpdate(Food food) {
try { try {
this.getDao().createOrUpdate(food); this.getDao().createOrUpdate(food);
if (Config.logDataFood) if (L.isEnabled(L.DATAFOOD))
log.debug("Created or Updated: " + food.toString()); log.debug("Created or Updated: " + food.toString());
} catch (SQLException e) { } catch (SQLException e) {
log.error("Unable to createOrUpdate Food", e); log.error("Unable to createOrUpdate Food", e);
@ -341,7 +340,7 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
public void create(Food food) { public void create(Food food) {
try { try {
this.getDao().create(food); this.getDao().create(food);
if (Config.logDataFood) if (L.isEnabled(L.DATAFOOD))
log.debug("New record: " + food.toString()); log.debug("New record: " + food.toString());
} catch (SQLException e) { } catch (SQLException e) {
log.error("Unable to create Food", e); log.error("Unable to create Food", e);

View file

@ -12,6 +12,7 @@ import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.OpenAPSSMB.SMBDefaults; import info.nightscout.androidaps.plugins.OpenAPSSMB.SMBDefaults;
import info.nightscout.androidaps.plugins.Overview.graphExtensions.DataPointWithLabelInterface; import info.nightscout.androidaps.plugins.Overview.graphExtensions.DataPointWithLabelInterface;
import info.nightscout.androidaps.plugins.Overview.graphExtensions.PointsWithLabelGraphSeries; import info.nightscout.androidaps.plugins.Overview.graphExtensions.PointsWithLabelGraphSeries;
@ -26,7 +27,7 @@ import info.nightscout.utils.SP;
*/ */
public class AutosensData implements DataPointWithLabelInterface { public class AutosensData implements DataPointWithLabelInterface {
private static Logger log = LoggerFactory.getLogger(Constants.AUTOSENS); private static Logger log = LoggerFactory.getLogger(L.AUTOSENS);
public void setChartTime(long chartTime) { public void setChartTime(long chartTime) {
this.chartTime = chartTime; this.chartTime = chartTime;
@ -48,7 +49,8 @@ public class AutosensData implements DataPointWithLabelInterface {
double sens = Profile.toMgdl(profile.getIsf(t.date), profile.getUnits()); double sens = Profile.toMgdl(profile.getIsf(t.date), profile.getUnits());
double ic = profile.getIc(t.date); double ic = profile.getIc(t.date);
min5minCarbImpact = t.carbs / (maxAbsorptionHours * 60 / 5) * sens / ic; min5minCarbImpact = t.carbs / (maxAbsorptionHours * 60 / 5) * sens / ic;
log.debug("Min 5m carbs impact for " + carbs + "g @" + new Date(t.date).toLocaleString() + " for " + maxAbsorptionHours + "h calculated to " + min5minCarbImpact + " ISF: " + sens + " IC: " + ic); if (L.isEnabled(L.AUTOSENS))
log.debug("Min 5m carbs impact for " + carbs + "g @" + new Date(t.date).toLocaleString() + " for " + maxAbsorptionHours + "h calculated to " + min5minCarbImpact + " ISF: " + sens + " IC: " + ic);
} else { } else {
min5minCarbImpact = SP.getDouble(R.string.key_openapsama_min_5m_carbimpact, SMBDefaults.min_5m_carbimpact); min5minCarbImpact = SP.getDouble(R.string.key_openapsama_min_5m_carbimpact, SMBDefaults.min_5m_carbimpact);
} }
@ -107,7 +109,8 @@ public class AutosensData implements DataPointWithLabelInterface {
activeCarbsList.remove(i--); activeCarbsList.remove(i--);
if (c.remaining > 0) if (c.remaining > 0)
cob -= c.remaining; cob -= c.remaining;
log.debug("Removing carbs at " + new Date(toTime).toLocaleString() + " + after " + maxAbsorptionHours + "h :" + new Date(c.time).toLocaleString()); if (L.isEnabled(L.AUTOSENS))
log.debug("Removing carbs at " + new Date(toTime).toLocaleString() + " + after " + maxAbsorptionHours + "h :" + new Date(c.time).toLocaleString());
} }
} }
} }

View file

@ -5,13 +5,13 @@ import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.logging.L;
/** /**
* Created by mike on 06.01.2017. * Created by mike on 06.01.2017.
*/ */
public class AutosensResult { public class AutosensResult {
private static Logger log = LoggerFactory.getLogger(Constants.AUTOSENS); private static Logger log = LoggerFactory.getLogger(L.AUTOSENS);
//default values to show when autosens algorithm is not called //default values to show when autosens algorithm is not called
public double ratio = 1d; public double ratio = 1d;

View file

@ -1,7 +1,6 @@
package info.nightscout.androidaps.plugins.IobCobCalculator; package info.nightscout.androidaps.plugins.IobCobCalculator;
import android.os.SystemClock; import android.os.SystemClock;
import android.provider.SyncStateContract;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.util.LongSparseArray; import android.support.v4.util.LongSparseArray;
@ -16,7 +15,6 @@ import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
@ -33,6 +31,7 @@ import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventNewHistoryData; import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventNewHistoryData;
import info.nightscout.androidaps.plugins.OpenAPSSMB.OpenAPSSMBPlugin; import info.nightscout.androidaps.plugins.OpenAPSSMB.OpenAPSSMBPlugin;
@ -49,7 +48,7 @@ import static info.nightscout.utils.DateUtil.now;
*/ */
public class IobCobCalculatorPlugin extends PluginBase { public class IobCobCalculatorPlugin extends PluginBase {
private Logger log = LoggerFactory.getLogger(Constants.AUTOSENS); private Logger log = LoggerFactory.getLogger(L.AUTOSENS);
private static IobCobCalculatorPlugin plugin = null; private static IobCobCalculatorPlugin plugin = null;
@ -112,13 +111,15 @@ public class IobCobCalculatorPlugin extends PluginBase {
//log.debug("Locking getBucketedData"); //log.debug("Locking getBucketedData");
synchronized (dataLock) { synchronized (dataLock) {
if (bucketed_data == null) { if (bucketed_data == null) {
log.debug("No bucketed data available"); if (L.isEnabled(L.AUTOSENS))
log.debug("No bucketed data available");
return null; return null;
} }
int index = indexNewerThan(fromTime); int index = indexNewerThan(fromTime);
if (index > -1) { if (index > -1) {
List<BgReading> part = bucketed_data.subList(0, index); List<BgReading> part = bucketed_data.subList(0, index);
log.debug("Bucketed data striped off: " + part.size() + "/" + bucketed_data.size()); if (L.isEnabled(L.AUTOSENS))
log.debug("Bucketed data striped off: " + part.size() + "/" + bucketed_data.size());
return part; return part;
} }
} }
@ -144,7 +145,8 @@ public class IobCobCalculatorPlugin extends PluginBase {
void loadBgData(long now) { void loadBgData(long now) {
long start = (long) (now - 60 * 60 * 1000L * (24 + dia)); long start = (long) (now - 60 * 60 * 1000L * (24 + dia));
bgReadings = MainApp.getDbHelper().getBgreadingsDataFromTime(start, now, false); bgReadings = MainApp.getDbHelper().getBgreadingsDataFromTime(start, now, false);
log.debug("BG data loaded. Size: " + bgReadings.size() + " Start date: " + DateUtil.dateAndTimeString(start) + " End date: " + DateUtil.dateAndTimeString(now)); if (L.isEnabled(L.AUTOSENS))
log.debug("BG data loaded. Size: " + bgReadings.size() + " Start date: " + DateUtil.dateAndTimeString(start) + " End date: " + DateUtil.dateAndTimeString(now));
} }
private boolean isAbout5minData() { private boolean isAbout5minData() {
@ -160,13 +162,15 @@ public class IobCobCalculatorPlugin extends PluginBase {
totalDiff += diff; totalDiff += diff;
if (diff > 30 * 1000 && diff < 270 * 1000) { // 0:30 - 4:30 if (diff > 30 * 1000 && diff < 270 * 1000) { // 0:30 - 4:30
log.debug("Interval detection: values: " + bgReadings.size() + " diff: " + (diff / 1000) + "sec is5minData: " + false); log.debug("Interval detection: values: " + bgReadings.size() + " diff: " + (diff / 1000) + "sec is5minData: " + false);
return false; if (L.isEnabled(L.AUTOSENS))
return false;
} }
} }
double intervals = totalDiff / (5 * 60 * 1000d); double intervals = totalDiff / (5 * 60 * 1000d);
double variability = Math.abs(intervals - Math.round(intervals)); double variability = Math.abs(intervals - Math.round(intervals));
boolean is5mindata = variability < 0.02; boolean is5mindata = variability < 0.02;
log.debug("Interval detection: values: " + bgReadings.size() + " variability: " + variability + " is5minData: " + is5mindata); if (L.isEnabled(L.AUTOSENS))
log.debug("Interval detection: values: " + bgReadings.size() + " variability: " + variability + " is5minData: " + is5mindata);
return is5mindata; return is5mindata;
} }
} }
@ -293,7 +297,8 @@ public class IobCobCalculatorPlugin extends PluginBase {
//log.error("***** Average"); //log.error("***** Average");
} }
} }
log.debug("Bucketed data created. Size: " + bucketed_data.size()); if (L.isEnabled(L.AUTOSENS))
log.debug("Bucketed data created. Size: " + bucketed_data.size());
} }
public long calculateDetectionStart(long from, boolean limitDataToOldestAvailable) { public long calculateDetectionStart(long from, boolean limitDataToOldestAvailable) {
@ -306,7 +311,8 @@ public class IobCobCalculatorPlugin extends PluginBase {
if (limitDataToOldestAvailable) { if (limitDataToOldestAvailable) {
getBGDataFrom = Math.max(oldestDataAvailable, (long) (from - T.hours(1).msecs() * (24 + dia))); getBGDataFrom = Math.max(oldestDataAvailable, (long) (from - T.hours(1).msecs() * (24 + dia)));
if (getBGDataFrom == oldestDataAvailable) if (getBGDataFrom == oldestDataAvailable)
log.debug("Limiting data to oldest available temps: " + new Date(oldestDataAvailable).toString()); if (L.isEnabled(L.AUTOSENS))
log.debug("Limiting data to oldest available temps: " + new Date(oldestDataAvailable).toString());
} else } else
getBGDataFrom = (long) (from - T.hours(1).msecs() * (24 + dia)); getBGDataFrom = (long) (from - T.hours(1).msecs() * (24 + dia));
return getBGDataFrom; return getBGDataFrom;
@ -413,12 +419,14 @@ public class IobCobCalculatorPlugin extends PluginBase {
@Nullable @Nullable
public AutosensData getLastAutosensDataSynchronized(String reason) { public AutosensData getLastAutosensDataSynchronized(String reason) {
if (thread != null && thread.isAlive()) { if (thread != null && thread.isAlive()) {
log.debug("AUTOSENSDATA is waiting for calculation thread: " + reason); if (L.isEnabled(L.AUTOSENS))
log.debug("AUTOSENSDATA is waiting for calculation thread: " + reason);
try { try {
thread.join(5000); thread.join(5000);
} catch (InterruptedException ignored) { } catch (InterruptedException ignored) {
} }
log.debug("AUTOSENSDATA finished waiting for calculation thread: " + reason); if (L.isEnabled(L.AUTOSENS))
log.debug("AUTOSENSDATA finished waiting for calculation thread: " + reason);
} }
synchronized (dataLock) { synchronized (dataLock) {
return getLastAutosensData(reason); return getLastAutosensData(reason);
@ -456,7 +464,8 @@ public class IobCobCalculatorPlugin extends PluginBase {
@Nullable @Nullable
public AutosensData getLastAutosensData(String reason) { public AutosensData getLastAutosensData(String reason) {
if (autosensDataTable.size() < 1) { if (autosensDataTable.size() < 1) {
log.debug("AUTOSENSDATA null: autosensDataTable empty (" + reason + ")"); if (L.isEnabled(L.AUTOSENS))
log.debug("AUTOSENSDATA null: autosensDataTable empty (" + reason + ")");
return null; return null;
} }
AutosensData data; AutosensData data;
@ -470,10 +479,12 @@ public class IobCobCalculatorPlugin extends PluginBase {
return null; return null;
} }
if (data.time < System.currentTimeMillis() - 11 * 60 * 1000) { if (data.time < System.currentTimeMillis() - 11 * 60 * 1000) {
log.debug("AUTOSENSDATA null: data is old (" + reason + ") size()=" + autosensDataTable.size() + " lastdata=" + DateUtil.dateAndTimeString(data.time)); if (L.isEnabled(L.AUTOSENS))
log.debug("AUTOSENSDATA null: data is old (" + reason + ") size()=" + autosensDataTable.size() + " lastdata=" + DateUtil.dateAndTimeString(data.time));
return null; return null;
} else { } else {
log.debug("AUTOSENSDATA (" + reason + ") " + data.toString()); if (L.isEnabled(L.AUTOSENS))
log.debug("AUTOSENSDATA (" + reason + ") " + data.toString());
return data; return data;
} }
} }
@ -535,7 +546,8 @@ public class IobCobCalculatorPlugin extends PluginBase {
@SuppressWarnings("unused") @SuppressWarnings("unused")
public void onEventAppInitialized(EventAppInitialized ev) { public void onEventAppInitialized(EventAppInitialized ev) {
if (this != getPlugin()) { if (this != getPlugin()) {
log.debug("Ignoring event for non default instance"); if (L.isEnabled(L.AUTOSENS))
log.debug("Ignoring event for non default instance");
return; return;
} }
runCalculation("onEventAppInitialized", System.currentTimeMillis(), true, true, ev); runCalculation("onEventAppInitialized", System.currentTimeMillis(), true, true, ev);
@ -545,7 +557,8 @@ public class IobCobCalculatorPlugin extends PluginBase {
@SuppressWarnings("unused") @SuppressWarnings("unused")
public void onEventNewBG(EventNewBG ev) { public void onEventNewBG(EventNewBG ev) {
if (this != getPlugin()) { if (this != getPlugin()) {
log.debug("Ignoring event for non default instance"); if (L.isEnabled(L.AUTOSENS))
log.debug("Ignoring event for non default instance");
return; return;
} }
stopCalculation("onEventNewBG"); stopCalculation("onEventNewBG");
@ -555,16 +568,19 @@ public class IobCobCalculatorPlugin extends PluginBase {
public void stopCalculation(String from) { public void stopCalculation(String from) {
if (thread != null && thread.getState() != Thread.State.TERMINATED) { if (thread != null && thread.getState() != Thread.State.TERMINATED) {
stopCalculationTrigger = true; stopCalculationTrigger = true;
log.debug("Stopping calculation thread: " + from); if (L.isEnabled(L.AUTOSENS))
log.debug("Stopping calculation thread: " + from);
while (thread.getState() != Thread.State.TERMINATED) { while (thread.getState() != Thread.State.TERMINATED) {
SystemClock.sleep(100); SystemClock.sleep(100);
} }
log.debug("Calculation thread stopped: " + from); if (L.isEnabled(L.AUTOSENS))
log.debug("Calculation thread stopped: " + from);
} }
} }
public void runCalculation(String from, long end, boolean bgDataReload, boolean limitDataToOldestAvailable, Event cause) { public void runCalculation(String from, long end, boolean bgDataReload, boolean limitDataToOldestAvailable, Event cause) {
log.debug("Starting calculation thread: " + from + " to " + DateUtil.dateAndTimeString(end)); if (L.isEnabled(L.AUTOSENS))
log.debug("Starting calculation thread: " + from + " to " + DateUtil.dateAndTimeString(end));
if (thread == null || thread.getState() == Thread.State.TERMINATED) { if (thread == null || thread.getState() == Thread.State.TERMINATED) {
if (SensitivityOref1Plugin.getPlugin().isEnabled(PluginType.SENSITIVITY)) if (SensitivityOref1Plugin.getPlugin().isEnabled(PluginType.SENSITIVITY))
thread = new IobCobOref1Thread(this, from, end, bgDataReload, limitDataToOldestAvailable, cause); thread = new IobCobOref1Thread(this, from, end, bgDataReload, limitDataToOldestAvailable, cause);
@ -577,7 +593,8 @@ public class IobCobCalculatorPlugin extends PluginBase {
@Subscribe @Subscribe
public void onNewProfile(EventNewBasalProfile ev) { public void onNewProfile(EventNewBasalProfile ev) {
if (this != getPlugin()) { if (this != getPlugin()) {
log.debug("Ignoring event for non default instance"); if (L.isEnabled(L.AUTOSENS))
log.debug("Ignoring event for non default instance");
return; return;
} }
if (MainApp.getConfigBuilder() == null) if (MainApp.getConfigBuilder() == null)
@ -591,7 +608,8 @@ public class IobCobCalculatorPlugin extends PluginBase {
} }
stopCalculation("onNewProfile"); stopCalculation("onNewProfile");
synchronized (dataLock) { synchronized (dataLock) {
log.debug("Invalidating cached data because of new profile. IOB: " + iobTable.size() + " Autosens: " + autosensDataTable.size() + " records"); if (L.isEnabled(L.AUTOSENS))
log.debug("Invalidating cached data because of new profile. IOB: " + iobTable.size() + " Autosens: " + autosensDataTable.size() + " records");
iobTable = new LongSparseArray<>(); iobTable = new LongSparseArray<>();
autosensDataTable = new LongSparseArray<>(); autosensDataTable = new LongSparseArray<>();
} }
@ -601,7 +619,8 @@ public class IobCobCalculatorPlugin extends PluginBase {
@Subscribe @Subscribe
public void onEventPreferenceChange(EventPreferenceChange ev) { public void onEventPreferenceChange(EventPreferenceChange ev) {
if (this != getPlugin()) { if (this != getPlugin()) {
log.debug("Ignoring event for non default instance"); if (L.isEnabled(L.AUTOSENS))
log.debug("Ignoring event for non default instance");
return; return;
} }
if (ev.isChanged(R.string.key_openapsama_autosens_period) || if (ev.isChanged(R.string.key_openapsama_autosens_period) ||
@ -614,7 +633,8 @@ public class IobCobCalculatorPlugin extends PluginBase {
) { ) {
stopCalculation("onEventPreferenceChange"); stopCalculation("onEventPreferenceChange");
synchronized (dataLock) { synchronized (dataLock) {
log.debug("Invalidating cached data because of preference change. IOB: " + iobTable.size() + " Autosens: " + autosensDataTable.size() + " records"); if (L.isEnabled(L.AUTOSENS))
log.debug("Invalidating cached data because of preference change. IOB: " + iobTable.size() + " Autosens: " + autosensDataTable.size() + " records");
iobTable = new LongSparseArray<>(); iobTable = new LongSparseArray<>();
autosensDataTable = new LongSparseArray<>(); autosensDataTable = new LongSparseArray<>();
} }
@ -625,12 +645,14 @@ public class IobCobCalculatorPlugin extends PluginBase {
@Subscribe @Subscribe
public void onEventConfigBuilderChange(EventConfigBuilderChange ev) { public void onEventConfigBuilderChange(EventConfigBuilderChange ev) {
if (this != getPlugin()) { if (this != getPlugin()) {
log.debug("Ignoring event for non default instance"); if (L.isEnabled(L.AUTOSENS))
log.debug("Ignoring event for non default instance");
return; return;
} }
stopCalculation("onEventConfigBuilderChange"); stopCalculation("onEventConfigBuilderChange");
synchronized (dataLock) { synchronized (dataLock) {
log.debug("Invalidating cached data because of configuration change. IOB: " + iobTable.size() + " Autosens: " + autosensDataTable.size() + " records"); if (L.isEnabled(L.AUTOSENS))
log.debug("Invalidating cached data because of configuration change. IOB: " + iobTable.size() + " Autosens: " + autosensDataTable.size() + " records");
iobTable = new LongSparseArray<>(); iobTable = new LongSparseArray<>();
autosensDataTable = new LongSparseArray<>(); autosensDataTable = new LongSparseArray<>();
} }
@ -641,7 +663,8 @@ public class IobCobCalculatorPlugin extends PluginBase {
@Subscribe @Subscribe
public void onEventNewHistoryData(EventNewHistoryData ev) { public void onEventNewHistoryData(EventNewHistoryData ev) {
if (this != getPlugin()) { if (this != getPlugin()) {
log.debug("Ignoring event for non default instance"); if (L.isEnabled(L.AUTOSENS))
log.debug("Ignoring event for non default instance");
return; return;
} }
//log.debug("Locking onNewHistoryData"); //log.debug("Locking onNewHistoryData");
@ -649,10 +672,11 @@ public class IobCobCalculatorPlugin extends PluginBase {
synchronized (dataLock) { synchronized (dataLock) {
// clear up 5 min back for proper COB calculation // clear up 5 min back for proper COB calculation
long time = ev.time - 5 * 60 * 1000L; long time = ev.time - 5 * 60 * 1000L;
log.debug("Invalidating cached data to: " + new Date(time).toLocaleString()); if (L.isEnabled(L.AUTOSENS))
log.debug("Invalidating cached data to: " + new Date(time).toLocaleString());
for (int index = iobTable.size() - 1; index >= 0; index--) { for (int index = iobTable.size() - 1; index >= 0; index--) {
if (iobTable.keyAt(index) > time) { if (iobTable.keyAt(index) > time) {
if (Config.logAutosensData) if (L.isEnabled(L.AUTOSENS))
log.debug("Removing from iobTable: " + new Date(iobTable.keyAt(index)).toLocaleString()); log.debug("Removing from iobTable: " + new Date(iobTable.keyAt(index)).toLocaleString());
iobTable.removeAt(index); iobTable.removeAt(index);
} else { } else {
@ -661,7 +685,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
} }
for (int index = autosensDataTable.size() - 1; index >= 0; index--) { for (int index = autosensDataTable.size() - 1; index >= 0; index--) {
if (autosensDataTable.keyAt(index) > time) { if (autosensDataTable.keyAt(index) > time) {
if (Config.logAutosensData) if (L.isEnabled(L.AUTOSENS))
log.debug("Removing from autosensDataTable: " + new Date(autosensDataTable.keyAt(index)).toLocaleString()); log.debug("Removing from autosensDataTable: " + new Date(autosensDataTable.keyAt(index)).toLocaleString());
autosensDataTable.removeAt(index); autosensDataTable.removeAt(index);
} else { } else {
@ -670,7 +694,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
} }
for (int index = basalDataTable.size() - 1; index >= 0; index--) { for (int index = basalDataTable.size() - 1; index >= 0; index--) {
if (basalDataTable.keyAt(index) > time) { if (basalDataTable.keyAt(index) > time) {
if (Config.logAutosensData) if (L.isEnabled(L.AUTOSENS))
log.debug("Removing from basalDataTable: " + new Date(basalDataTable.keyAt(index)).toLocaleString()); log.debug("Removing from basalDataTable: " + new Date(basalDataTable.keyAt(index)).toLocaleString());
basalDataTable.removeAt(index); basalDataTable.removeAt(index);
} else { } else {
@ -684,7 +708,8 @@ public class IobCobCalculatorPlugin extends PluginBase {
public void clearCache() { public void clearCache() {
synchronized (dataLock) { synchronized (dataLock) {
log.debug("Clearing cached data."); if (L.isEnabled(L.AUTOSENS))
log.debug("Clearing cached data.");
iobTable = new LongSparseArray<>(); iobTable = new LongSparseArray<>();
autosensDataTable = new LongSparseArray<>(); autosensDataTable = new LongSparseArray<>();
} }

View file

@ -17,7 +17,6 @@ import java.util.GregorianCalendar;
import java.util.List; import java.util.List;
import info.nightscout.androidaps.BuildConfig; import info.nightscout.androidaps.BuildConfig;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
@ -26,6 +25,7 @@ import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.db.BgReading; import info.nightscout.androidaps.db.BgReading;
import info.nightscout.androidaps.db.TempTarget; import info.nightscout.androidaps.db.TempTarget;
import info.nightscout.androidaps.events.Event; import info.nightscout.androidaps.events.Event;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished; import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished;
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventIobCalculationProgress; import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventIobCalculationProgress;
import info.nightscout.androidaps.plugins.OpenAPSSMB.SMBDefaults; import info.nightscout.androidaps.plugins.OpenAPSSMB.SMBDefaults;
@ -43,7 +43,7 @@ import static java.util.Calendar.MINUTE;
*/ */
public class IobCobOref1Thread extends Thread { public class IobCobOref1Thread extends Thread {
private static Logger log = LoggerFactory.getLogger(Constants.AUTOSENS); private static Logger log = LoggerFactory.getLogger(L.AUTOSENS);
private final Event cause; private final Event cause;
private IobCobCalculatorPlugin iobCobCalculatorPlugin; private IobCobCalculatorPlugin iobCobCalculatorPlugin;
@ -72,13 +72,16 @@ public class IobCobOref1Thread extends Thread {
public final void run() { public final void run() {
mWakeLock.acquire(); mWakeLock.acquire();
try { try {
log.debug("AUTOSENSDATA thread started: " + from); if (L.isEnabled(L.AUTOSENS))
log.debug("AUTOSENSDATA thread started: " + from);
if (MainApp.getConfigBuilder() == null) { if (MainApp.getConfigBuilder() == null) {
log.debug("Aborting calculation thread (ConfigBuilder not ready): " + from); if (L.isEnabled(L.AUTOSENS))
log.debug("Aborting calculation thread (ConfigBuilder not ready): " + from);
return; // app still initializing return; // app still initializing
} }
if (!MainApp.getConfigBuilder().isProfileValid("IobCobThread")) { if (!MainApp.getConfigBuilder().isProfileValid("IobCobThread")) {
log.debug("Aborting calculation thread (No profile): " + from); if (L.isEnabled(L.AUTOSENS))
log.debug("Aborting calculation thread (No profile): " + from);
return; // app still initializing return; // app still initializing
} }
//log.debug("Locking calculateSensitivityData"); //log.debug("Locking calculateSensitivityData");
@ -94,12 +97,14 @@ public class IobCobOref1Thread extends Thread {
LongSparseArray<AutosensData> autosensDataTable = iobCobCalculatorPlugin.getAutosensDataTable(); LongSparseArray<AutosensData> autosensDataTable = iobCobCalculatorPlugin.getAutosensDataTable();
if (bucketed_data == null || bucketed_data.size() < 3) { 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; return;
} }
long prevDataTime = IobCobCalculatorPlugin.roundUpTime(bucketed_data.get(bucketed_data.size() - 3).date); 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); AutosensData previous = autosensDataTable.get(prevDataTime);
// start from oldest to be able sub cob // start from oldest to be able sub cob
for (int i = bucketed_data.size() - 4; i >= 0; i--) { for (int i = bucketed_data.size() - 4; i >= 0; i--) {
@ -108,7 +113,8 @@ public class IobCobOref1Thread extends Thread {
if (iobCobCalculatorPlugin.stopCalculationTrigger) { if (iobCobCalculatorPlugin.stopCalculationTrigger) {
iobCobCalculatorPlugin.stopCalculationTrigger = false; iobCobCalculatorPlugin.stopCalculationTrigger = false;
log.debug("Aborting calculation thread (trigger): " + from); if (L.isEnabled(L.AUTOSENS))
log.debug("Aborting calculation thread (trigger): " + from);
return; return;
} }
// check if data already exists // check if data already exists
@ -125,11 +131,12 @@ public class IobCobOref1Thread extends Thread {
Profile profile = MainApp.getConfigBuilder().getProfile(bgTime); Profile profile = MainApp.getConfigBuilder().getProfile(bgTime);
if (profile == null) { 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 return; // profile not set yet
} }
if (Config.logAutosensData) if (L.isEnabled(L.AUTOSENS))
log.debug("Processing calculation thread: " + from + " (" + i + "/" + bucketed_data.size() + ")"); log.debug("Processing calculation thread: " + from + " (" + i + "/" + bucketed_data.size() + ")");
double sens = Profile.toMgdl(profile.getIsf(bgTime), profile.getUnits()); double sens = Profile.toMgdl(profile.getIsf(bgTime), profile.getUnits());
@ -171,7 +178,7 @@ public class IobCobOref1Thread extends Thread {
AutosensData hourAgoData = iobCobCalculatorPlugin.getAutosensData(hourago); AutosensData hourAgoData = iobCobCalculatorPlugin.getAutosensData(hourago);
if (hourAgoData != null) { if (hourAgoData != null) {
int initialIndex = autosensDataTable.indexOfKey(hourAgoData.time); 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()); log.debug(">>>>> bucketed_data.size()=" + bucketed_data.size() + " i=" + i + "hourAgoData=" + hourAgoData.toString());
int past = 1; int past = 1;
try { try {
@ -187,7 +194,7 @@ public class IobCobOref1Thread extends Thread {
minDeviation = ad.avgDeviation; 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); // log.debug("Deviations: " + new Date(bgTime) + new Date(ad.time) + " avgDeviation=" + avgDeviation + " deviationSlope=" + deviationSlope + " slopeFromMaxDeviation=" + slopeFromMaxDeviation + " slopeFromMinDeviation=" + slopeFromMinDeviation);
} }
} catch (Exception e) { } catch (Exception e) {
@ -340,13 +347,13 @@ public class IobCobOref1Thread extends Thread {
previous = autosensData; previous = autosensData;
if (bgTime < now()) if (bgTime < now())
autosensDataTable.put(bgTime, autosensData); 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()); log.debug("Running detectSensitivity from: " + DateUtil.dateAndTimeString(oldestTimeWithData) + " to: " + DateUtil.dateAndTimeString(bgTime) + " lastDataTime:" + iobCobCalculatorPlugin.lastDataTime());
AutosensResult sensitivity = iobCobCalculatorPlugin.detectSensitivityWithLock(oldestTimeWithData, bgTime); AutosensResult sensitivity = iobCobCalculatorPlugin.detectSensitivityWithLock(oldestTimeWithData, bgTime);
if (Config.logAutosensData) if (L.isEnabled(L.AUTOSENS))
log.debug("Sensitivity result: " + sensitivity.toString()); log.debug("Sensitivity result: " + sensitivity.toString());
autosensData.autosensResult = sensitivity; autosensData.autosensResult = sensitivity;
if (Config.logAutosensData) if (L.isEnabled(L.AUTOSENS))
log.debug(autosensData.toString()); log.debug(autosensData.toString());
} }
} }
@ -357,7 +364,8 @@ public class IobCobOref1Thread extends Thread {
} finally { } finally {
mWakeLock.release(); mWakeLock.release();
MainApp.bus().post(new EventIobCalculationProgress("")); MainApp.bus().post(new EventIobCalculationProgress(""));
log.debug("AUTOSENSDATA thread ended: " + from); if (L.isEnabled(L.AUTOSENS))
log.debug("AUTOSENSDATA thread ended: " + from);
} }
} }

View file

@ -15,7 +15,6 @@ import java.util.Date;
import java.util.List; import java.util.List;
import info.nightscout.androidaps.BuildConfig; import info.nightscout.androidaps.BuildConfig;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
@ -24,6 +23,7 @@ import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.db.BgReading; import info.nightscout.androidaps.db.BgReading;
import info.nightscout.androidaps.events.Event; import info.nightscout.androidaps.events.Event;
import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished; import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished;
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventIobCalculationProgress; import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventIobCalculationProgress;
import info.nightscout.androidaps.plugins.OpenAPSSMB.SMBDefaults; import info.nightscout.androidaps.plugins.OpenAPSSMB.SMBDefaults;
@ -42,7 +42,7 @@ import static info.nightscout.utils.DateUtil.now;
*/ */
public class IobCobThread extends Thread { public class IobCobThread extends Thread {
private static Logger log = LoggerFactory.getLogger(Constants.AUTOSENS); private static Logger log = LoggerFactory.getLogger(L.AUTOSENS);
private final Event cause; private final Event cause;
private IobCobCalculatorPlugin iobCobCalculatorPlugin; private IobCobCalculatorPlugin iobCobCalculatorPlugin;
@ -71,13 +71,16 @@ public class IobCobThread extends Thread {
public final void run() { public final void run() {
mWakeLock.acquire(); mWakeLock.acquire();
try { try {
log.debug("AUTOSENSDATA thread started: " + from); if (L.isEnabled(L.AUTOSENS))
log.debug("AUTOSENSDATA thread started: " + from);
if (MainApp.getConfigBuilder() == null) { if (MainApp.getConfigBuilder() == null) {
log.debug("Aborting calculation thread (ConfigBuilder not ready): " + from); if (L.isEnabled(L.AUTOSENS))
log.debug("Aborting calculation thread (ConfigBuilder not ready): " + from);
return; // app still initializing return; // app still initializing
} }
if (!MainApp.getConfigBuilder().isProfileValid("IobCobThread")) { if (!MainApp.getConfigBuilder().isProfileValid("IobCobThread")) {
log.debug("Aborting calculation thread (No profile): " + from); if (L.isEnabled(L.AUTOSENS))
log.debug("Aborting calculation thread (No profile): " + from);
return; // app still initializing return; // app still initializing
} }
//log.debug("Locking calculateSensitivityData"); //log.debug("Locking calculateSensitivityData");
@ -93,12 +96,14 @@ public class IobCobThread extends Thread {
LongSparseArray<AutosensData> autosensDataTable = iobCobCalculatorPlugin.getAutosensDataTable(); LongSparseArray<AutosensData> autosensDataTable = iobCobCalculatorPlugin.getAutosensDataTable();
if (bucketed_data == null || bucketed_data.size() < 3) { 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; return;
} }
long prevDataTime = IobCobCalculatorPlugin.roundUpTime(bucketed_data.get(bucketed_data.size() - 3).date); 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); AutosensData previous = autosensDataTable.get(prevDataTime);
// start from oldest to be able sub cob // start from oldest to be able sub cob
for (int i = bucketed_data.size() - 4; i >= 0; i--) { for (int i = bucketed_data.size() - 4; i >= 0; i--) {
@ -107,7 +112,8 @@ public class IobCobThread extends Thread {
if (iobCobCalculatorPlugin.stopCalculationTrigger) { if (iobCobCalculatorPlugin.stopCalculationTrigger) {
iobCobCalculatorPlugin.stopCalculationTrigger = false; iobCobCalculatorPlugin.stopCalculationTrigger = false;
log.debug("Aborting calculation thread (trigger): " + from); if (L.isEnabled(L.AUTOSENS))
log.debug("Aborting calculation thread (trigger): " + from);
return; return;
} }
// check if data already exists // check if data already exists
@ -124,11 +130,12 @@ public class IobCobThread extends Thread {
Profile profile = MainApp.getConfigBuilder().getProfile(bgTime); Profile profile = MainApp.getConfigBuilder().getProfile(bgTime);
if (profile == null) { 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 return; // profile not set yet
} }
if (Config.logAutosensData) if (L.isEnabled(L.AUTOSENS))
log.debug("Processing calculation thread: " + from + " (" + i + "/" + bucketed_data.size() + ")"); log.debug("Processing calculation thread: " + from + " (" + i + "/" + bucketed_data.size() + ")");
double sens = Profile.toMgdl(profile.getIsf(bgTime), profile.getUnits()); double sens = Profile.toMgdl(profile.getIsf(bgTime), profile.getUnits());
@ -170,7 +177,7 @@ public class IobCobThread extends Thread {
AutosensData hourAgoData = iobCobCalculatorPlugin.getAutosensData(hourago); AutosensData hourAgoData = iobCobCalculatorPlugin.getAutosensData(hourago);
if (hourAgoData != null) { if (hourAgoData != null) {
int initialIndex = autosensDataTable.indexOfKey(hourAgoData.time); 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()); log.debug(">>>>> bucketed_data.size()=" + bucketed_data.size() + " i=" + i + "hourAgoData=" + hourAgoData.toString());
int past = 1; int past = 1;
try { try {
@ -186,7 +193,7 @@ public class IobCobThread extends Thread {
minDeviation = ad.avgDeviation; 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); // log.debug("Deviations: " + new Date(bgTime) + new Date(ad.time) + " avgDeviation=" + avgDeviation + " deviationSlope=" + deviationSlope + " slopeFromMaxDeviation=" + slopeFromMaxDeviation + " slopeFromMinDeviation=" + slopeFromMinDeviation);
} }
} catch (Exception e) { } catch (Exception e) {
@ -267,13 +274,13 @@ public class IobCobThread extends Thread {
previous = autosensData; previous = autosensData;
if (bgTime < now()) if (bgTime < now())
autosensDataTable.put(bgTime, autosensData); 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()); log.debug("Running detectSensitivity from: " + DateUtil.dateAndTimeString(oldestTimeWithData) + " to: " + DateUtil.dateAndTimeString(bgTime) + " lastDataTime:" + iobCobCalculatorPlugin.lastDataTime());
AutosensResult sensitivity = iobCobCalculatorPlugin.detectSensitivityWithLock(oldestTimeWithData, bgTime); AutosensResult sensitivity = iobCobCalculatorPlugin.detectSensitivityWithLock(oldestTimeWithData, bgTime);
if (Config.logAutosensData) if (L.isEnabled(L.AUTOSENS))
log.debug("Sensitivity result: " + sensitivity.toString()); log.debug("Sensitivity result: " + sensitivity.toString());
autosensData.autosensResult = sensitivity; autosensData.autosensResult = sensitivity;
if (Config.logAutosensData) if (L.isEnabled(L.AUTOSENS))
log.debug(autosensData.toString()); log.debug(autosensData.toString());
} }
} }
@ -284,7 +291,8 @@ public class IobCobThread extends Thread {
} finally { } finally {
mWakeLock.release(); mWakeLock.release();
MainApp.bus().post(new EventIobCalculationProgress("")); MainApp.bus().post(new EventIobCalculationProgress(""));
log.debug("AUTOSENSDATA thread ended: " + from); if (L.isEnabled(L.AUTOSENS))
log.debug("AUTOSENSDATA thread ended: " + from);
} }
} }

View file

@ -12,13 +12,13 @@ import org.slf4j.LoggerFactory;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.data.IobTotal;
import info.nightscout.androidaps.db.BgReading; import info.nightscout.androidaps.db.BgReading;
import info.nightscout.androidaps.interfaces.Constraint; import info.nightscout.androidaps.interfaces.Constraint;
import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.utils.DecimalFormatter; import info.nightscout.utils.DecimalFormatter;
@ -26,7 +26,7 @@ import info.nightscout.utils.DecimalFormatter;
* Created by mike on 09.06.2016. * Created by mike on 09.06.2016.
*/ */
public class APSResult { public class APSResult {
private static Logger log = LoggerFactory.getLogger(Constants.APS); private static Logger log = LoggerFactory.getLogger(L.APS);
public long date = 0; public long date = 0;
public String reason; public String reason;

View file

@ -5,7 +5,7 @@ import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.logging.L;
/* /*
{ {
@ -365,7 +365,7 @@ import info.nightscout.androidaps.Constants;
*/ */
public class DeviceStatus { public class DeviceStatus {
private static Logger log = LoggerFactory.getLogger(Constants.APS); private static Logger log = LoggerFactory.getLogger(L.APS);
public String device = null; public String device = null;
public JSONObject pump = null; public JSONObject pump = null;

View file

@ -21,7 +21,6 @@ import org.slf4j.LoggerFactory;
import java.util.Date; import java.util.Date;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainActivity; import info.nightscout.androidaps.MainActivity;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
@ -38,6 +37,7 @@ import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished; import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished;
import info.nightscout.androidaps.plugins.Loop.events.EventLoopSetLastRunGui; import info.nightscout.androidaps.plugins.Loop.events.EventLoopSetLastRunGui;
@ -54,7 +54,7 @@ import info.nightscout.utils.SP;
* Created by mike on 05.08.2016. * Created by mike on 05.08.2016.
*/ */
public class LoopPlugin extends PluginBase { public class LoopPlugin extends PluginBase {
private static Logger log = LoggerFactory.getLogger(Constants.APS); private static Logger log = LoggerFactory.getLogger(L.APS);
private static final String CHANNEL_ID = "AndroidAPS-Openloop"; private static final String CHANNEL_ID = "AndroidAPS-Openloop";
@ -254,13 +254,13 @@ public class LoopPlugin extends PluginBase {
public synchronized void invoke(String initiator, boolean allowNotification, boolean tempBasalFallback) { public synchronized void invoke(String initiator, boolean allowNotification, boolean tempBasalFallback) {
try { try {
if (Config.logAps) if (L.isEnabled(L.APS))
log.debug("invoke from " + initiator); log.debug("invoke from " + initiator);
Constraint<Boolean> loopEnabled = MainApp.getConstraintChecker().isLoopInvokationAllowed(); Constraint<Boolean> loopEnabled = MainApp.getConstraintChecker().isLoopInvokationAllowed();
if (!loopEnabled.value()) { if (!loopEnabled.value()) {
String message = MainApp.gs(R.string.loopdisabled) + "\n" + loopEnabled.getReasons(); String message = MainApp.gs(R.string.loopdisabled) + "\n" + loopEnabled.getReasons();
if (Config.logAps) if (L.isEnabled(L.APS))
log.debug(message); log.debug(message);
MainApp.bus().post(new EventLoopSetLastRunGui(message)); MainApp.bus().post(new EventLoopSetLastRunGui(message));
return; return;
@ -274,7 +274,7 @@ public class LoopPlugin extends PluginBase {
Profile profile = MainApp.getConfigBuilder().getProfile(); Profile profile = MainApp.getConfigBuilder().getProfile();
if (!MainApp.getConfigBuilder().isProfileValid("Loop")) { if (!MainApp.getConfigBuilder().isProfileValid("Loop")) {
if (Config.logAps) if (L.isEnabled(L.APS))
log.debug(MainApp.gs(R.string.noprofileselected)); log.debug(MainApp.gs(R.string.noprofileselected));
MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.gs(R.string.noprofileselected))); MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.gs(R.string.noprofileselected)));
return; return;
@ -305,7 +305,7 @@ public class LoopPlugin extends PluginBase {
// safety check for multiple SMBs // safety check for multiple SMBs
long lastBolusTime = TreatmentsPlugin.getPlugin().getLastBolusTime(); long lastBolusTime = TreatmentsPlugin.getPlugin().getLastBolusTime();
if (lastBolusTime != 0 && lastBolusTime + 3 * 60 * 1000 > System.currentTimeMillis()) { if (lastBolusTime != 0 && lastBolusTime + 3 * 60 * 1000 > System.currentTimeMillis()) {
if (Config.logAps) if (L.isEnabled(L.APS))
log.debug("SMB requsted but still in 3 min interval"); log.debug("SMB requsted but still in 3 min interval");
resultAfterConstraints.smb = 0; resultAfterConstraints.smb = 0;
} }
@ -321,14 +321,14 @@ public class LoopPlugin extends PluginBase {
NSUpload.uploadDeviceStatus(); NSUpload.uploadDeviceStatus();
if (isSuspended()) { if (isSuspended()) {
if (Config.logAps) if (L.isEnabled(L.APS))
log.debug(MainApp.gs(R.string.loopsuspended)); log.debug(MainApp.gs(R.string.loopsuspended));
MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.gs(R.string.loopsuspended))); MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.gs(R.string.loopsuspended)));
return; return;
} }
if (pump.isSuspended()) { if (pump.isSuspended()) {
if (Config.logAps) if (L.isEnabled(L.APS))
log.debug(MainApp.gs(R.string.pumpsuspended)); log.debug(MainApp.gs(R.string.pumpsuspended));
MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.gs(R.string.pumpsuspended))); MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.gs(R.string.pumpsuspended)));
return; return;
@ -416,7 +416,7 @@ public class LoopPlugin extends PluginBase {
MainApp.bus().post(new EventLoopUpdateGui()); MainApp.bus().post(new EventLoopUpdateGui());
} finally { } finally {
if (Config.logAps) if (L.isEnabled(L.APS))
log.debug("invoke end"); log.debug("invoke end");
} }
} }

View file

@ -29,6 +29,7 @@ import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType; 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.EventNSClientNewLog;
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientStatus; import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientStatus;
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientUpdateGUI; import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientUpdateGUI;
@ -37,7 +38,7 @@ import info.nightscout.utils.SP;
import info.nightscout.utils.ToastUtils; import info.nightscout.utils.ToastUtils;
public class NSClientPlugin extends PluginBase { public class NSClientPlugin extends PluginBase {
private Logger log = LoggerFactory.getLogger(Constants.NSCLIENT); private Logger log = LoggerFactory.getLogger(L.NSCLIENT);
static NSClientPlugin nsClientPlugin; static NSClientPlugin nsClientPlugin;
@ -132,13 +133,13 @@ public class NSClientPlugin extends PluginBase {
private ServiceConnection mConnection = new ServiceConnection() { private ServiceConnection mConnection = new ServiceConnection() {
public void onServiceDisconnected(ComponentName name) { public void onServiceDisconnected(ComponentName name) {
if (Config.logNsclient) if (L.isEnabled(L.NSCLIENT))
log.debug("Service is disconnected"); log.debug("Service is disconnected");
nsClientService = null; nsClientService = null;
} }
public void onServiceConnected(ComponentName name, IBinder service) { public void onServiceConnected(ComponentName name, IBinder service) {
if (Config.logNsclient) if (L.isEnabled(L.NSCLIENT))
log.debug("Service is connected"); log.debug("Service is connected");
NSClientService.LocalBinder mLocalBinder = (NSClientService.LocalBinder) service; NSClientService.LocalBinder mLocalBinder = (NSClientService.LocalBinder) service;
if (mLocalBinder != null) // is null when running in roboelectric if (mLocalBinder != null) // is null when running in roboelectric
@ -157,7 +158,7 @@ public class NSClientPlugin extends PluginBase {
@Subscribe @Subscribe
public void onStatusEvent(final EventNSClientNewLog ev) { public void onStatusEvent(final EventNSClientNewLog ev) {
addToLog(ev); addToLog(ev);
if (Config.logNsclient) if (L.isEnabled(L.NSCLIENT))
log.debug(ev.action + " " + ev.logText); log.debug(ev.action + " " + ev.logText);
} }

View file

@ -21,10 +21,9 @@ import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.services.Intents; import info.nightscout.androidaps.services.Intents;
import info.nightscout.androidaps.data.DetailedBolusInfo; import info.nightscout.androidaps.data.DetailedBolusInfo;
import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.Profile;
@ -48,7 +47,7 @@ import info.nightscout.utils.SP;
*/ */
public class NSUpload { public class NSUpload {
private static Logger log = LoggerFactory.getLogger(Constants.NSCLIENT); private static Logger log = LoggerFactory.getLogger(L.NSCLIENT);
public static void uploadTempBasalStartAbsolute(TemporaryBasal temporaryBasal, Double originalExtendedAmount) { public static void uploadTempBasalStartAbsolute(TemporaryBasal temporaryBasal, Double originalExtendedAmount) {
try { try {
@ -237,7 +236,7 @@ public class NSUpload {
deviceStatus.enacted.put("requested", requested); deviceStatus.enacted.put("requested", requested);
} }
} else { } else {
if (Config.logNsclient) if (L.isEnabled(L.NSCLIENT))
log.debug("OpenAPS data too old to upload"); log.debug("OpenAPS data too old to upload");
} }
deviceStatus.device = "openaps://" + Build.MANUFACTURER + " " + Build.MODEL; deviceStatus.device = "openaps://" + Build.MANUFACTURER + " " + Build.MODEL;

View file

@ -13,18 +13,17 @@ import org.slf4j.LoggerFactory;
import java.sql.SQLException; import java.sql.SQLException;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.db.DatabaseHelper; import info.nightscout.androidaps.db.DatabaseHelper;
import info.nightscout.androidaps.db.DbRequest; import info.nightscout.androidaps.db.DbRequest;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.NSClientInternal.services.NSClientService; import info.nightscout.androidaps.plugins.NSClientInternal.services.NSClientService;
/** /**
* Created by mike on 21.02.2016. * Created by mike on 21.02.2016.
*/ */
public class UploadQueue { public class UploadQueue {
private static Logger log = LoggerFactory.getLogger(Constants.NSCLIENT); private static Logger log = LoggerFactory.getLogger(L.NSCLIENT);
public static String status() { public static String status() {
return "QUEUE: " + MainApp.getDbHelper().size(DatabaseHelper.DATABASE_DBREQUESTS); return "QUEUE: " + MainApp.getDbHelper().size(DatabaseHelper.DATABASE_DBREQUESTS);
@ -46,7 +45,7 @@ public class UploadQueue {
startService(); startService();
if (NSClientService.handler != null) { if (NSClientService.handler != null) {
NSClientService.handler.post(() -> { NSClientService.handler.post(() -> {
if (Config.logNsclient) if (L.isEnabled(L.NSCLIENT))
log.debug("Adding to queue: " + dbr.data); log.debug("Adding to queue: " + dbr.data);
MainApp.getDbHelper().create(dbr); MainApp.getDbHelper().create(dbr);
NSClientPlugin plugin = NSClientPlugin.getPlugin(); NSClientPlugin plugin = NSClientPlugin.getPlugin();
@ -61,10 +60,10 @@ public class UploadQueue {
startService(); startService();
if (NSClientService.handler != null) { if (NSClientService.handler != null) {
NSClientService.handler.post(() -> { NSClientService.handler.post(() -> {
if (Config.logNsclient) if (L.isEnabled(L.NSCLIENT))
log.debug("ClearQueue"); log.debug("ClearQueue");
MainApp.getDbHelper().deleteAllDbRequests(); MainApp.getDbHelper().deleteAllDbRequests();
if (Config.logNsclient) if (L.isEnabled(L.NSCLIENT))
log.debug(status()); log.debug(status());
}); });
} }
@ -82,7 +81,7 @@ public class UploadQueue {
return; return;
} }
if (MainApp.getDbHelper().deleteDbRequest(id) == 1) { if (MainApp.getDbHelper().deleteDbRequest(id) == 1) {
if (Config.logNsclient) if (L.isEnabled(L.NSCLIENT))
log.debug("Removed item from UploadQueue. " + UploadQueue.status()); log.debug("Removed item from UploadQueue. " + UploadQueue.status());
} }
} catch (JSONException e) { } catch (JSONException e) {
@ -99,7 +98,7 @@ public class UploadQueue {
if (NSClientService.handler != null) { if (NSClientService.handler != null) {
NSClientService.handler.post(() -> { NSClientService.handler.post(() -> {
MainApp.getDbHelper().deleteDbRequestbyMongoId(action, _id); MainApp.getDbHelper().deleteDbRequestbyMongoId(action, _id);
if (Config.logNsclient) if (L.isEnabled(L.NSCLIENT))
log.debug("Removing " + _id + " from UploadQueue. " + UploadQueue.status()); log.debug("Removing " + _id + " from UploadQueue. " + UploadQueue.status());
}); });
} }

View file

@ -5,10 +5,9 @@ import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.events.Event; import info.nightscout.androidaps.events.Event;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientRestart; import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientRestart;
import io.socket.client.Ack; import io.socket.client.Ack;
@ -16,7 +15,7 @@ import io.socket.client.Ack;
* Created by mike on 29.12.2015. * Created by mike on 29.12.2015.
*/ */
public class NSAddAck extends Event implements Ack { public class NSAddAck extends Event implements Ack {
private static Logger log = LoggerFactory.getLogger(Constants.NSCLIENT); private static Logger log = LoggerFactory.getLogger(L.NSCLIENT);
public String _id = null; public String _id = null;
public String nsClientID = null; public String nsClientID = null;
public JSONObject json = null; public JSONObject json = null;
@ -48,7 +47,7 @@ public class NSAddAck extends Event implements Ack {
MainApp.bus().post(new EventNSClientRestart()); MainApp.bus().post(new EventNSClientRestart());
return; return;
} }
if (Config.logNsclient) if (L.isEnabled(L.NSCLIENT))
log.debug("DBACCESS " + response.getString("result")); log.debug("DBACCESS " + response.getString("result"));
} }
return; return;

View file

@ -5,16 +5,16 @@ import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.events.Event; import info.nightscout.androidaps.events.Event;
import info.nightscout.androidaps.logging.L;
import io.socket.client.Ack; import io.socket.client.Ack;
/** /**
* Created by mike on 21.02.2016. * Created by mike on 21.02.2016.
*/ */
public class NSUpdateAck extends Event implements Ack { public class NSUpdateAck extends Event implements Ack {
private static Logger log = LoggerFactory.getLogger(Constants.NSCLIENT); private static Logger log = LoggerFactory.getLogger(L.NSCLIENT);
public boolean result = false; public boolean result = false;
public String _id; public String _id;
public String action; public String action;

View file

@ -9,9 +9,9 @@ import android.support.v4.content.LocalBroadcastManager;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.services.Intents; import info.nightscout.androidaps.services.Intents;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSettingsStatus; import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSettingsStatus;
import info.nightscout.androidaps.plugins.NSClientInternal.services.NSClientService; import info.nightscout.androidaps.plugins.NSClientInternal.services.NSClientService;
@ -21,7 +21,7 @@ import info.nightscout.utils.SP;
* Created by mike on 24.02.2016. * Created by mike on 24.02.2016.
*/ */
public class BroadcastStatus { public class BroadcastStatus {
private static Logger log = LoggerFactory.getLogger(Constants.NSCLIENT); private static Logger log = LoggerFactory.getLogger(L.NSCLIENT);
public static void handleNewStatus(NSSettingsStatus status, Context context, boolean isDelta) { public static void handleNewStatus(NSSettingsStatus status, Context context, boolean isDelta) {
LocalBroadcastManager.getInstance(MainApp.instance()) LocalBroadcastManager.getInstance(MainApp.instance())

View file

@ -13,9 +13,9 @@ import org.slf4j.LoggerFactory;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.services.Intents; import info.nightscout.androidaps.services.Intents;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
@ -23,7 +23,7 @@ import info.nightscout.utils.SP;
* Created by mike on 20.02.2016. * Created by mike on 20.02.2016.
*/ */
public class BroadcastTreatment { public class BroadcastTreatment {
private static Logger log = LoggerFactory.getLogger(Constants.NSCLIENT); private static Logger log = LoggerFactory.getLogger(L.NSCLIENT);
public static void handleNewTreatment(JSONObject treatment, boolean isDelta, boolean isLocalBypass) { public static void handleNewTreatment(JSONObject treatment, boolean isDelta, boolean isLocalBypass) {

View file

@ -8,25 +8,24 @@ import org.slf4j.LoggerFactory;
import java.util.List; import java.util.List;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.logging.L;
import info.nightscout.utils.ToastUtils; import info.nightscout.utils.ToastUtils;
/** /**
* Created by mike on 02.07.2016. * Created by mike on 02.07.2016.
*/ */
public class DbLogger { public class DbLogger {
private static Logger log = LoggerFactory.getLogger(Constants.NSCLIENT); private static Logger log = LoggerFactory.getLogger(L.NSCLIENT);
public static void dbAdd(Intent intent, String data) { public static void dbAdd(Intent intent, String data) {
List<ResolveInfo> q = MainApp.instance().getApplicationContext().getPackageManager().queryBroadcastReceivers(intent, 0); List<ResolveInfo> q = MainApp.instance().getApplicationContext().getPackageManager().queryBroadcastReceivers(intent, 0);
if (q.size() < 1) { 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"); log.error("DBADD No receivers");
} else if (Config.logNsclient) { } else if (L.isEnabled(L.NSCLIENT)) {
if (Config.logNsclient) if (L.isEnabled(L.NSCLIENT))
log.debug("DBADD dbAdd " + q.size() + " receivers " + data); log.debug("DBADD dbAdd " + q.size() + " receivers " + data);
} }
} }
@ -36,8 +35,8 @@ public class DbLogger {
if (q.size() < 1) { 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"); log.error("DBREMOVE No receivers");
} else if (Config.logNsclient) { } else if (L.isEnabled(L.NSCLIENT)) {
if (Config.logNsclient) if (L.isEnabled(L.NSCLIENT))
log.debug("DBREMOVE dbRemove " + q.size() + " receivers " + data); log.debug("DBREMOVE dbRemove " + q.size() + " receivers " + data);
} }
} }

View file

@ -5,14 +5,14 @@ import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.logging.L;
/** /**
* Created by mike on 11.06.2017. * Created by mike on 11.06.2017.
*/ */
public class NSAlarm { public class NSAlarm {
private static Logger log = LoggerFactory.getLogger(Constants.NSCLIENT); private static Logger log = LoggerFactory.getLogger(L.NSCLIENT);
JSONObject data; JSONObject data;

View file

@ -5,10 +5,10 @@ import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.logging.L;
public class NSCal { public class NSCal {
private static Logger log = LoggerFactory.getLogger(Constants.NSCLIENT); private static Logger log = LoggerFactory.getLogger(L.NSCLIENT);
public long date; public long date;
public double slope; public double slope;
public double intercept; public double intercept;

View file

@ -15,12 +15,11 @@ import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConstraintsObjectives.ObjectivesPlugin; import info.nightscout.androidaps.plugins.ConstraintsObjectives.ObjectivesPlugin;
import info.nightscout.androidaps.plugins.Loop.APSResult; import info.nightscout.androidaps.plugins.Loop.APSResult;
import info.nightscout.utils.BundleLogger; import info.nightscout.androidaps.logging.BundleLogger;
import info.nightscout.utils.DateUtil; import info.nightscout.utils.DateUtil;
import info.nightscout.utils.Round; import info.nightscout.utils.Round;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
@ -80,7 +79,7 @@ import info.nightscout.utils.SP;
} }
*/ */
public class NSDeviceStatus { public class NSDeviceStatus {
private Logger log = LoggerFactory.getLogger(Constants.NSCLIENT); private Logger log = LoggerFactory.getLogger(L.NSCLIENT);
private static NSDeviceStatus instance = null; private static NSDeviceStatus instance = null;
@ -99,7 +98,7 @@ public class NSDeviceStatus {
Bundle bundle = intent.getExtras(); Bundle bundle = intent.getExtras();
if (bundle == null) return; if (bundle == null) return;
if (Config.logNsclient) if (L.isEnabled(L.NSCLIENT))
log.debug("Got NS devicestatus: " + BundleLogger.log(bundle)); log.debug("Got NS devicestatus: " + BundleLogger.log(bundle));
try { try {

View file

@ -5,10 +5,10 @@ import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.logging.L;
public class NSMbg { public class NSMbg {
private static Logger log = LoggerFactory.getLogger(Constants.NSCLIENT); private static Logger log = LoggerFactory.getLogger(L.NSCLIENT);
public long date; public long date;
public double mbg; public double mbg;
public String json; public String json;

View file

@ -14,14 +14,14 @@ import java.util.Date;
import java.util.Objects; import java.util.Objects;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Overview.OverviewPlugin; import info.nightscout.androidaps.plugins.Overview.OverviewPlugin;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.Overview.notifications.Notification; import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
import info.nightscout.utils.BundleLogger; import info.nightscout.androidaps.logging.BundleLogger;
/* /*
{ {
@ -114,7 +114,7 @@ import info.nightscout.utils.BundleLogger;
} }
*/ */
public class NSSettingsStatus { public class NSSettingsStatus {
private Logger log = LoggerFactory.getLogger(Constants.NSCLIENT); private Logger log = LoggerFactory.getLogger(L.NSCLIENT);
private static NSSettingsStatus instance = null; private static NSSettingsStatus instance = null;
@ -140,7 +140,7 @@ public class NSSettingsStatus {
Bundle bundle = intent.getExtras(); Bundle bundle = intent.getExtras();
if (bundle == null) return; if (bundle == null) return;
if (Config.logNsclient) if (L.isEnabled(L.NSCLIENT))
log.debug("Got NS status: " + BundleLogger.log(bundle)); log.debug("Got NS status: " + BundleLogger.log(bundle));
if (bundle.containsKey("nsclientversioncode")) { if (bundle.containsKey("nsclientversioncode")) {
@ -149,7 +149,7 @@ public class NSSettingsStatus {
nightscoutVersionName = bundle.getString("nightscoutversionname"); nightscoutVersionName = bundle.getString("nightscoutversionname");
Integer nsClientVersionCode = bundle.getInt("nsclientversioncode"); Integer nsClientVersionCode = bundle.getInt("nsclientversioncode");
String nsClientVersionName = bundle.getString("nsclientversionname"); String nsClientVersionName = bundle.getString("nsclientversionname");
if (Config.logNsclient) if (L.isEnabled(L.NSCLIENT))
log.debug("Got versions: NSClient: " + nsClientVersionName + " Nightscout: " + nightscoutVersionName); log.debug("Got versions: NSClient: " + nsClientVersionName + " Nightscout: " + nightscoutVersionName);
try { try {
if (nsClientVersionCode < MainApp.instance().getPackageManager().getPackageInfo(MainApp.instance().getPackageName(), 0).versionCode) { if (nsClientVersionCode < MainApp.instance().getPackageManager().getPackageInfo(MainApp.instance().getPackageName(), 0).versionCode) {
@ -175,7 +175,7 @@ public class NSSettingsStatus {
try { try {
JSONObject statusJson = new JSONObject(bundle.getString("status")); JSONObject statusJson = new JSONObject(bundle.getString("status"));
setData(statusJson); setData(statusJson);
if (Config.logNsclient) if (L.isEnabled(L.NSCLIENT))
log.debug("Received status: " + statusJson.toString()); log.debug("Received status: " + statusJson.toString());
Double targetHigh = getThreshold("bgTargetTop"); Double targetHigh = getThreshold("bgTargetTop");
Double targetlow = getThreshold("bgTargetBottom"); Double targetlow = getThreshold("bgTargetBottom");

View file

@ -5,14 +5,14 @@ import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.logging.L;
/** /**
* *
* {"mgdl":105,"mills":1455136282375,"device":"xDrip-BluetoothWixel","direction":"Flat","filtered":98272,"unfiltered":98272,"noise":1,"rssi":100} * {"mgdl":105,"mills":1455136282375,"device":"xDrip-BluetoothWixel","direction":"Flat","filtered":98272,"unfiltered":98272,"noise":1,"rssi":100}
*/ */
public class NSSgv { public class NSSgv {
private static Logger log = LoggerFactory.getLogger(Constants.NSCLIENT); private static Logger log = LoggerFactory.getLogger(L.NSCLIENT);
private JSONObject data; private JSONObject data;

View file

@ -7,10 +7,10 @@ import org.slf4j.LoggerFactory;
import java.util.Date; import java.util.Date;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.logging.L;
public class NSTreatment { public class NSTreatment {
private static Logger log = LoggerFactory.getLogger(Constants.NSCLIENT); private static Logger log = LoggerFactory.getLogger(L.NSCLIENT);
private JSONObject data; private JSONObject data;
private String action = null; // "update", "remove" or null (add) private String action = null; // "update", "remove" or null (add)

View file

@ -9,19 +9,17 @@ import android.os.PowerManager;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginType; 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.NSClientPlugin;
import info.nightscout.androidaps.plugins.NSClientInternal.data.AlarmAck; import info.nightscout.androidaps.plugins.NSClientInternal.data.AlarmAck;
import info.nightscout.androidaps.plugins.NSClientInternal.services.NSClientService; import info.nightscout.androidaps.plugins.NSClientInternal.services.NSClientService;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
public class AckAlarmReceiver extends BroadcastReceiver { public class AckAlarmReceiver extends BroadcastReceiver {
private static Logger log = LoggerFactory.getLogger(Constants.NSCLIENT); private static Logger log = LoggerFactory.getLogger(L.NSCLIENT);
@Override @Override
@ -34,7 +32,7 @@ public class AckAlarmReceiver extends BroadcastReceiver {
return; return;
} }
if (SP.getBoolean(R.string.key_ns_noupload, false)) { if (SP.getBoolean(R.string.key_ns_noupload, false)) {
if (Config.logNsclient) if (L.isEnabled(L.NSCLIENT))
log.debug("Upload disabled. Message dropped"); log.debug("Upload disabled. Message dropped");
return; return;
} }

View file

@ -11,11 +11,11 @@ import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.db.DbRequest; import info.nightscout.androidaps.db.DbRequest;
import info.nightscout.androidaps.interfaces.PluginType; 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.NSClientPlugin;
import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue; import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue;
import info.nightscout.androidaps.plugins.NSClientInternal.broadcasts.BroadcastTreatment; import info.nightscout.androidaps.plugins.NSClientInternal.broadcasts.BroadcastTreatment;
@ -23,7 +23,7 @@ import info.nightscout.utils.DateUtil;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
public class DBAccessReceiver extends BroadcastReceiver { public class DBAccessReceiver extends BroadcastReceiver {
private static Logger log = LoggerFactory.getLogger(Constants.NSCLIENT); private static Logger log = LoggerFactory.getLogger(L.NSCLIENT);
@Override @Override

View file

@ -24,7 +24,6 @@ import java.net.URISyntaxException;
import java.sql.SQLException; import java.sql.SQLException;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.ProfileStore; import info.nightscout.androidaps.data.ProfileStore;
@ -33,6 +32,7 @@ import info.nightscout.androidaps.events.EventAppExit;
import info.nightscout.androidaps.events.EventConfigBuilderChange; import info.nightscout.androidaps.events.EventConfigBuilderChange;
import info.nightscout.androidaps.events.EventPreferenceChange; import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.interfaces.PluginType; 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.NSClientPlugin;
import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue; import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue;
import info.nightscout.androidaps.plugins.NSClientInternal.acks.NSAddAck; import info.nightscout.androidaps.plugins.NSClientInternal.acks.NSAddAck;
@ -69,7 +69,7 @@ import io.socket.client.Socket;
import io.socket.emitter.Emitter; import io.socket.emitter.Emitter;
public class NSClientService extends Service { public class NSClientService extends Service {
private static Logger log = LoggerFactory.getLogger(Constants.NSCLIENT); private static Logger log = LoggerFactory.getLogger(L.NSCLIENT);
static public PowerManager.WakeLock mWakeLock; static public PowerManager.WakeLock mWakeLock;
private IBinder mBinder = new NSClientService.LocalBinder(); private IBinder mBinder = new NSClientService.LocalBinder();
@ -155,13 +155,13 @@ public class NSClientService extends Service {
@Subscribe @Subscribe
public void onStatusEvent(EventAppExit event) { public void onStatusEvent(EventAppExit event) {
if (Config.logNsclient) if (L.isEnabled(L.NSCLIENT))
log.debug("EventAppExit received"); log.debug("EventAppExit received");
destroy(); destroy();
stopSelf(); stopSelf();
if (Config.logNsclient) if (L.isEnabled(L.NSCLIENT))
log.debug("EventAppExit finished"); log.debug("EventAppExit finished");
} }
@ -249,7 +249,7 @@ public class NSClientService extends Service {
private Emitter.Listener onDisconnect = new Emitter.Listener() { private Emitter.Listener onDisconnect = new Emitter.Listener() {
@Override @Override
public void call(Object... args) { public void call(Object... args) {
if (Config.logNsclient) if (L.isEnabled(L.NSCLIENT))
log.debug("disconnect reason: {}", args); log.debug("disconnect reason: {}", args);
MainApp.bus().post(new EventNSClientNewLog("NSCLIENT", "disconnect event")); MainApp.bus().post(new EventNSClientNewLog("NSCLIENT", "disconnect event"));
} }
@ -361,7 +361,7 @@ public class NSClientService extends Service {
log.error("Unhandled exception", e); log.error("Unhandled exception", e);
} }
BroadcastAnnouncement.handleAnnouncement(data, getApplicationContext()); BroadcastAnnouncement.handleAnnouncement(data, getApplicationContext());
if (Config.logNsclient) if (L.isEnabled(L.NSCLIENT))
log.debug(data.toString()); log.debug(data.toString());
} }
}; };
@ -392,7 +392,7 @@ public class NSClientService extends Service {
return; return;
} }
BroadcastAlarm.handleAlarm(data, getApplicationContext()); BroadcastAlarm.handleAlarm(data, getApplicationContext());
if (Config.logNsclient) if (L.isEnabled(L.NSCLIENT))
log.debug(data.toString()); log.debug(data.toString());
} }
}; };
@ -423,7 +423,7 @@ public class NSClientService extends Service {
} }
MainApp.bus().post(new EventNSClientNewLog("URGENTALARM", "received")); MainApp.bus().post(new EventNSClientNewLog("URGENTALARM", "received"));
BroadcastUrgentAlarm.handleUrgentAlarm(data, getApplicationContext()); BroadcastUrgentAlarm.handleUrgentAlarm(data, getApplicationContext());
if (Config.logNsclient) if (L.isEnabled(L.NSCLIENT))
log.debug(data.toString()); log.debug(data.toString());
} }
}; };
@ -449,7 +449,7 @@ public class NSClientService extends Service {
} }
MainApp.bus().post(new EventNSClientNewLog("CLEARALARM", "received")); MainApp.bus().post(new EventNSClientNewLog("CLEARALARM", "received"));
BroadcastClearAlarm.handleClearAlarm(data, getApplicationContext()); BroadcastClearAlarm.handleClearAlarm(data, getApplicationContext());
if (Config.logNsclient) if (L.isEnabled(L.NSCLIENT))
log.debug(data.toString()); log.debug(data.toString());
} }
}; };
@ -759,7 +759,7 @@ public class NSClientService extends Service {
if (mSocket == null || !mSocket.connected()) return; if (mSocket == null || !mSocket.connected()) return;
if (lastResendTime > System.currentTimeMillis() - 10 * 1000L) { if (lastResendTime > System.currentTimeMillis() - 10 * 1000L) {
if (Config.logNsclient) if (L.isEnabled(L.NSCLIENT))
log.debug("Skipping resend by lastResendTime: " + ((System.currentTimeMillis() - lastResendTime) / 1000L) + " sec"); log.debug("Skipping resend by lastResendTime: " + ((System.currentTimeMillis() - lastResendTime) / 1000L) + " sec");
return; return;
} }

View file

@ -17,7 +17,6 @@ import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
@ -26,6 +25,7 @@ import info.nightscout.androidaps.data.IobTotal;
import info.nightscout.androidaps.data.MealData; import info.nightscout.androidaps.data.MealData;
import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.db.TemporaryBasal; import info.nightscout.androidaps.db.TemporaryBasal;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin; import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
import info.nightscout.androidaps.plugins.Loop.ScriptReader; import info.nightscout.androidaps.plugins.Loop.ScriptReader;
import info.nightscout.androidaps.plugins.OpenAPSMA.LoggerCallback; import info.nightscout.androidaps.plugins.OpenAPSMA.LoggerCallback;
@ -34,7 +34,7 @@ import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
public class DetermineBasalAdapterAMAJS { public class DetermineBasalAdapterAMAJS {
private static Logger log = LoggerFactory.getLogger(Constants.APS); private static Logger log = LoggerFactory.getLogger(L.APS);
private ScriptReader mScriptReader = null; private ScriptReader mScriptReader = null;
@ -61,7 +61,7 @@ public class DetermineBasalAdapterAMAJS {
public DetermineBasalResultAMA invoke() { public DetermineBasalResultAMA invoke() {
if (Config.logAps) { if (L.isEnabled(L.APS)) {
log.debug(">>> Invoking detemine_basal <<<"); log.debug(">>> Invoking detemine_basal <<<");
log.debug("Glucose status: " + (storedGlucoseStatus = mGlucoseStatus.toString())); log.debug("Glucose status: " + (storedGlucoseStatus = mGlucoseStatus.toString()));
log.debug("IOB data: " + (storedIobData = mIobData.toString())); log.debug("IOB data: " + (storedIobData = mIobData.toString()));
@ -119,7 +119,7 @@ public class DetermineBasalAdapterAMAJS {
// Parse the jsResult object to a JSON-String // Parse the jsResult object to a JSON-String
String result = NativeJSON.stringify(rhino, scope, jsResult, null, null).toString(); String result = NativeJSON.stringify(rhino, scope, jsResult, null, null).toString();
if (Config.logAps) if (L.isEnabled(L.APS))
log.debug("Result: " + result); log.debug("Result: " + result);
try { try {
determineBasalResultAMA = new DetermineBasalResultAMA(jsResult, new JSONObject(result)); determineBasalResultAMA = new DetermineBasalResultAMA(jsResult, new JSONObject(result));

View file

@ -6,12 +6,12 @@ import org.mozilla.javascript.NativeObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Loop.APSResult; import info.nightscout.androidaps.plugins.Loop.APSResult;
import info.nightscout.utils.DateUtil; import info.nightscout.utils.DateUtil;
public class DetermineBasalResultAMA extends APSResult { public class DetermineBasalResultAMA extends APSResult {
private static Logger log = LoggerFactory.getLogger(Constants.APS); private static Logger log = LoggerFactory.getLogger(L.APS);
private double eventualBG; private double eventualBG;
private double snoozeBG; private double snoozeBG;

View file

@ -16,9 +16,9 @@ import org.json.JSONException;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment; import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui; import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui;
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateResultGui; import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateResultGui;
@ -26,7 +26,7 @@ import info.nightscout.utils.FabricPrivacy;
import info.nightscout.utils.JSONFormatter; import info.nightscout.utils.JSONFormatter;
public class OpenAPSAMAFragment extends SubscriberFragment implements View.OnClickListener { public class OpenAPSAMAFragment extends SubscriberFragment implements View.OnClickListener {
private static Logger log = LoggerFactory.getLogger(Constants.APS); private static Logger log = LoggerFactory.getLogger(L.APS);
Button run; Button run;
TextView lastRunView; TextView lastRunView;

View file

@ -6,8 +6,6 @@ import org.slf4j.LoggerFactory;
import java.util.Date; import java.util.Date;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.GlucoseStatus; 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.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData; import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult; import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult;
@ -39,7 +38,7 @@ import info.nightscout.utils.Round;
* Created by mike on 05.08.2016. * Created by mike on 05.08.2016.
*/ */
public class OpenAPSAMAPlugin extends PluginBase implements APSInterface { public class OpenAPSAMAPlugin extends PluginBase implements APSInterface {
private static Logger log = LoggerFactory.getLogger(Constants.APS); private static Logger log = LoggerFactory.getLogger(L.APS);
private static OpenAPSAMAPlugin openAPSAMAPlugin; private static OpenAPSAMAPlugin openAPSAMAPlugin;
@ -91,7 +90,7 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface {
@Override @Override
public void invoke(String initiator, boolean tempBasalFallback) { public void invoke(String initiator, boolean tempBasalFallback) {
if (Config.logAps) if (L.isEnabled(L.APS))
log.debug("invoke from " + initiator + " tempBasalFallback: " + tempBasalFallback); log.debug("invoke from " + initiator + " tempBasalFallback: " + tempBasalFallback);
lastAPSResult = null; lastAPSResult = null;
DetermineBasalAdapterAMAJS determineBasalAdapterAMAJS; DetermineBasalAdapterAMAJS determineBasalAdapterAMAJS;
@ -103,21 +102,21 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface {
if (profile == null) { if (profile == null) {
MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.noprofileselected))); MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.noprofileselected)));
if (Config.logAps) if (L.isEnabled(L.APS))
log.debug(MainApp.gs(R.string.noprofileselected)); log.debug(MainApp.gs(R.string.noprofileselected));
return; return;
} }
if (!isEnabled(PluginType.APS)) { if (!isEnabled(PluginType.APS)) {
MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_disabled))); MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_disabled)));
if (Config.logAps) if (L.isEnabled(L.APS))
log.debug(MainApp.gs(R.string.openapsma_disabled)); log.debug(MainApp.gs(R.string.openapsma_disabled));
return; return;
} }
if (glucoseStatus == null) { if (glucoseStatus == null) {
MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_noglucosedata))); MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_noglucosedata)));
if (Config.logAps) if (L.isEnabled(L.APS))
log.debug(MainApp.gs(R.string.openapsma_noglucosedata)); log.debug(MainApp.gs(R.string.openapsma_noglucosedata));
return; return;
} }
@ -135,12 +134,12 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface {
Date start = new Date(); Date start = new Date();
Date startPart = new Date(); Date startPart = new Date();
IobTotal[] iobArray = IobCobCalculatorPlugin.getPlugin().calculateIobArrayInDia(profile); IobTotal[] iobArray = IobCobCalculatorPlugin.getPlugin().calculateIobArrayInDia(profile);
if (Config.logAps) if (L.isEnabled(L.APS))
Profiler.log(log, "calculateIobArrayInDia()", startPart); Profiler.log(log, "calculateIobArrayInDia()", startPart);
startPart = new Date(); startPart = new Date();
MealData mealData = TreatmentsPlugin.getPlugin().getMealData(); MealData mealData = TreatmentsPlugin.getPlugin().getMealData();
if (Config.logAps) if (L.isEnabled(L.APS))
Profiler.log(log, "getMealData()", startPart); Profiler.log(log, "getMealData()", startPart);
double maxIob = MainApp.getConstraintChecker().getMaxIOBAllowed().value(); double maxIob = MainApp.getConstraintChecker().getMaxIOBAllowed().value();
@ -182,9 +181,9 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface {
lastAutosensResult = new AutosensResult(); lastAutosensResult = new AutosensResult();
lastAutosensResult.sensResult = "autosens disabled"; lastAutosensResult.sensResult = "autosens disabled";
} }
if (Config.logAps) if (L.isEnabled(L.APS))
Profiler.log(log, "detectSensitivityandCarbAbsorption()", startPart); Profiler.log(log, "detectSensitivityandCarbAbsorption()", startPart);
if (Config.logAps) if (L.isEnabled(L.APS))
Profiler.log(log, "AMA data gathering", start); Profiler.log(log, "AMA data gathering", start);
start = new Date(); start = new Date();
@ -200,7 +199,7 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface {
DetermineBasalResultAMA determineBasalResultAMA = determineBasalAdapterAMAJS.invoke(); DetermineBasalResultAMA determineBasalResultAMA = determineBasalAdapterAMAJS.invoke();
if (Config.logAps) if (L.isEnabled(L.APS))
Profiler.log(log, "AMA calculation", start); Profiler.log(log, "AMA calculation", start);
// Fix bug determine basal // Fix bug determine basal
if (determineBasalResultAMA.rate == 0d && determineBasalResultAMA.duration == 0 && !TreatmentsPlugin.getPlugin().isTempBasalInProgress()) if (determineBasalResultAMA.rate == 0d && determineBasalResultAMA.duration == 0 && !TreatmentsPlugin.getPlugin().isTempBasalInProgress())

View file

@ -15,7 +15,6 @@ import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.GlucoseStatus; import info.nightscout.androidaps.data.GlucoseStatus;
@ -23,12 +22,13 @@ import info.nightscout.androidaps.data.IobTotal;
import info.nightscout.androidaps.data.MealData; import info.nightscout.androidaps.data.MealData;
import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.db.TemporaryBasal; import info.nightscout.androidaps.db.TemporaryBasal;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Loop.ScriptReader; import info.nightscout.androidaps.plugins.Loop.ScriptReader;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin; import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
public class DetermineBasalAdapterMAJS { public class DetermineBasalAdapterMAJS {
private static Logger log = LoggerFactory.getLogger(Constants.APS); private static Logger log = LoggerFactory.getLogger(L.APS);
private ScriptReader mScriptReader; private ScriptReader mScriptReader;
private JSONObject mProfile; private JSONObject mProfile;
@ -96,7 +96,7 @@ public class DetermineBasalAdapterMAJS {
// Parse the jsResult object to a JSON-String // Parse the jsResult object to a JSON-String
String result = NativeJSON.stringify(rhino, scope, jsResult, null, null).toString(); String result = NativeJSON.stringify(rhino, scope, jsResult, null, null).toString();
if (Config.logAps) if (L.isEnabled(L.APS))
log.debug("Result: " + result); log.debug("Result: " + result);
try { try {
determineBasalResultMA = new DetermineBasalResultMA(jsResult, new JSONObject(result)); determineBasalResultMA = new DetermineBasalResultMA(jsResult, new JSONObject(result));

View file

@ -6,11 +6,11 @@ import org.mozilla.javascript.NativeObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Loop.APSResult; import info.nightscout.androidaps.plugins.Loop.APSResult;
public class DetermineBasalResultMA extends APSResult { public class DetermineBasalResultMA extends APSResult {
private static Logger log = LoggerFactory.getLogger(Constants.APS); private static Logger log = LoggerFactory.getLogger(L.APS);
public JSONObject json = new JSONObject(); public JSONObject json = new JSONObject();
private double eventualBG; private double eventualBG;

View file

@ -4,8 +4,7 @@ import org.mozilla.javascript.ScriptableObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.Constants;
/** /**
* Created by adrian on 15/10/17. * Created by adrian on 15/10/17.
@ -14,7 +13,7 @@ import info.nightscout.androidaps.Constants;
public class LoggerCallback extends ScriptableObject { public class LoggerCallback extends ScriptableObject {
private static Logger log = LoggerFactory.getLogger(Constants.APS); private static Logger log = LoggerFactory.getLogger(L.APS);
private static StringBuffer errorBuffer = new StringBuffer(); private static StringBuffer errorBuffer = new StringBuffer();
private static StringBuffer logBuffer = new StringBuffer(); private static StringBuffer logBuffer = new StringBuffer();
@ -36,14 +35,14 @@ public class LoggerCallback extends ScriptableObject {
} }
public void jsFunction_log(Object obj1) { public void jsFunction_log(Object obj1) {
if (Config.logAps) if (L.isEnabled(L.APS))
log.debug(obj1.toString()); log.debug(obj1.toString());
logBuffer.append(obj1.toString()); logBuffer.append(obj1.toString());
logBuffer.append(' '); logBuffer.append(' ');
} }
public void jsFunction_error(Object obj1) { public void jsFunction_error(Object obj1) {
if (Config.logAps) if (L.isEnabled(L.APS))
log.error(obj1.toString()); log.error(obj1.toString());
errorBuffer.append(obj1.toString()); errorBuffer.append(obj1.toString());
errorBuffer.append(' '); errorBuffer.append(' ');

View file

@ -6,8 +6,6 @@ import org.slf4j.LoggerFactory;
import java.util.Date; import java.util.Date;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.GlucoseStatus; 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.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Loop.APSResult; import info.nightscout.androidaps.plugins.Loop.APSResult;
import info.nightscout.androidaps.plugins.Loop.ScriptReader; import info.nightscout.androidaps.plugins.Loop.ScriptReader;
@ -39,7 +38,7 @@ import static info.nightscout.utils.HardLimits.verifyHardLimits;
* Created by mike on 05.08.2016. * Created by mike on 05.08.2016.
*/ */
public class OpenAPSMAPlugin extends PluginBase implements APSInterface { public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
private static Logger log = LoggerFactory.getLogger(Constants.APS); private static Logger log = LoggerFactory.getLogger(L.APS);
private static OpenAPSMAPlugin openAPSMAPlugin; private static OpenAPSMAPlugin openAPSMAPlugin;
@ -90,7 +89,7 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
@Override @Override
public void invoke(String initiator, boolean tempBasalFallback) { public void invoke(String initiator, boolean tempBasalFallback) {
if (Config.logAps) if (L.isEnabled(L.APS))
log.debug("invoke from " + initiator + " tempBasalFallback: " + tempBasalFallback); log.debug("invoke from " + initiator + " tempBasalFallback: " + tempBasalFallback);
lastAPSResult = null; lastAPSResult = null;
DetermineBasalAdapterMAJS determineBasalAdapterMAJS = null; DetermineBasalAdapterMAJS determineBasalAdapterMAJS = null;
@ -102,21 +101,21 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
if (profile == null) { if (profile == null) {
MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.noprofileselected))); MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.noprofileselected)));
if (Config.logAps) if (L.isEnabled(L.APS))
log.debug(MainApp.gs(R.string.noprofileselected)); log.debug(MainApp.gs(R.string.noprofileselected));
return; return;
} }
if (!isEnabled(PluginType.APS)) { if (!isEnabled(PluginType.APS)) {
MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_disabled))); MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_disabled)));
if (Config.logAps) if (L.isEnabled(L.APS))
log.debug(MainApp.gs(R.string.openapsma_disabled)); log.debug(MainApp.gs(R.string.openapsma_disabled));
return; return;
} }
if (glucoseStatus == null) { if (glucoseStatus == null) {
MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_noglucosedata))); MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_noglucosedata)));
if (Config.logAps) if (L.isEnabled(L.APS))
log.debug(MainApp.gs(R.string.openapsma_noglucosedata)); log.debug(MainApp.gs(R.string.openapsma_noglucosedata));
return; return;
} }
@ -143,7 +142,7 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
MealData mealData = TreatmentsPlugin.getPlugin().getMealData(); MealData mealData = TreatmentsPlugin.getPlugin().getMealData();
double maxIob = MainApp.getConstraintChecker().getMaxIOBAllowed().value(); double maxIob = MainApp.getConstraintChecker().getMaxIOBAllowed().value();
if (Config.logAps) if (L.isEnabled(L.APS))
Profiler.log(log, "MA data gathering", start); 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]); minBg = verifyHardLimits(minBg, "minBg", HardLimits.VERY_HARD_LIMIT_MIN_BG[0], HardLimits.VERY_HARD_LIMIT_MIN_BG[1]);
@ -174,7 +173,7 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
} catch (JSONException e) { } catch (JSONException e) {
log.error("Unhandled exception", e); log.error("Unhandled exception", e);
} }
if (Config.logAps) if (L.isEnabled(L.APS))
Profiler.log(log, "MA calculation", start); Profiler.log(log, "MA calculation", start);

View file

@ -17,7 +17,6 @@ import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
@ -26,6 +25,7 @@ import info.nightscout.androidaps.data.IobTotal;
import info.nightscout.androidaps.data.MealData; import info.nightscout.androidaps.data.MealData;
import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.db.TemporaryBasal; import info.nightscout.androidaps.db.TemporaryBasal;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin; import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
import info.nightscout.androidaps.plugins.Loop.ScriptReader; import info.nightscout.androidaps.plugins.Loop.ScriptReader;
import info.nightscout.androidaps.plugins.OpenAPSMA.LoggerCallback; import info.nightscout.androidaps.plugins.OpenAPSMA.LoggerCallback;
@ -34,7 +34,7 @@ import info.nightscout.utils.SP;
import info.nightscout.utils.SafeParse; import info.nightscout.utils.SafeParse;
public class DetermineBasalAdapterSMBJS { public class DetermineBasalAdapterSMBJS {
private static Logger log = LoggerFactory.getLogger(Constants.APS); private static Logger log = LoggerFactory.getLogger(L.APS);
private ScriptReader mScriptReader; private ScriptReader mScriptReader;
@ -71,7 +71,7 @@ public class DetermineBasalAdapterSMBJS {
public DetermineBasalResultSMB invoke() { public DetermineBasalResultSMB invoke() {
if (Config.logAps) { if (L.isEnabled(L.APS)) {
log.debug(">>> Invoking detemine_basal <<<"); log.debug(">>> Invoking detemine_basal <<<");
log.debug("Glucose status: " + (storedGlucoseStatus = mGlucoseStatus.toString())); log.debug("Glucose status: " + (storedGlucoseStatus = mGlucoseStatus.toString()));
log.debug("IOB data: " + (storedIobData = mIobData.toString())); log.debug("IOB data: " + (storedIobData = mIobData.toString()));
@ -136,7 +136,7 @@ public class DetermineBasalAdapterSMBJS {
// Parse the jsResult object to a JSON-String // Parse the jsResult object to a JSON-String
String result = NativeJSON.stringify(rhino, scope, jsResult, null, null).toString(); String result = NativeJSON.stringify(rhino, scope, jsResult, null, null).toString();
if (Config.logAps) if (L.isEnabled(L.APS))
log.debug("Result: " + result); log.debug("Result: " + result);
try { try {
determineBasalResultSMB = new DetermineBasalResultSMB(new JSONObject(result)); determineBasalResultSMB = new DetermineBasalResultSMB(new JSONObject(result));

View file

@ -5,12 +5,12 @@ import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Loop.APSResult; import info.nightscout.androidaps.plugins.Loop.APSResult;
import info.nightscout.utils.DateUtil; import info.nightscout.utils.DateUtil;
public class DetermineBasalResultSMB extends APSResult { public class DetermineBasalResultSMB extends APSResult {
private static final Logger log = LoggerFactory.getLogger(Constants.APS); private static final Logger log = LoggerFactory.getLogger(L.APS);
private double eventualBG; private double eventualBG;
private double snoozeBG; private double snoozeBG;

View file

@ -19,9 +19,9 @@ import org.slf4j.LoggerFactory;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.OnClick; import butterknife.OnClick;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment; import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui; import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui;
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateResultGui; import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateResultGui;
@ -29,7 +29,7 @@ import info.nightscout.utils.FabricPrivacy;
import info.nightscout.utils.JSONFormatter; import info.nightscout.utils.JSONFormatter;
public class OpenAPSSMBFragment extends SubscriberFragment { public class OpenAPSSMBFragment extends SubscriberFragment {
private static Logger log = LoggerFactory.getLogger(Constants.APS); private static Logger log = LoggerFactory.getLogger(L.APS);
@BindView(R.id.openapsma_run) @BindView(R.id.openapsma_run)
Button run; Button run;

View file

@ -6,8 +6,6 @@ import org.slf4j.LoggerFactory;
import java.util.Date; import java.util.Date;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.GlucoseStatus; import info.nightscout.androidaps.data.GlucoseStatus;
@ -22,6 +20,7 @@ import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData; import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult; import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult;
@ -42,7 +41,7 @@ import info.nightscout.utils.ToastUtils;
* Created by mike on 05.08.2016. * Created by mike on 05.08.2016.
*/ */
public class OpenAPSSMBPlugin extends PluginBase implements APSInterface { public class OpenAPSSMBPlugin extends PluginBase implements APSInterface {
private static Logger log = LoggerFactory.getLogger(Constants.APS); private static Logger log = LoggerFactory.getLogger(L.APS);
private static OpenAPSSMBPlugin openAPSSMBPlugin; private static OpenAPSSMBPlugin openAPSSMBPlugin;
@ -94,7 +93,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface {
@Override @Override
public void invoke(String initiator, boolean tempBasalFallback) { public void invoke(String initiator, boolean tempBasalFallback) {
if (Config.logAps) if (L.isEnabled(L.APS))
log.debug("invoke from " + initiator + " tempBasalFallback: " + tempBasalFallback); log.debug("invoke from " + initiator + " tempBasalFallback: " + tempBasalFallback);
lastAPSResult = null; lastAPSResult = null;
DetermineBasalAdapterSMBJS determineBasalAdapterSMBJS; DetermineBasalAdapterSMBJS determineBasalAdapterSMBJS;
@ -106,21 +105,21 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface {
if (profile == null) { if (profile == null) {
MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.noprofileselected))); MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.noprofileselected)));
if (Config.logAps) if (L.isEnabled(L.APS))
log.debug(MainApp.gs(R.string.noprofileselected)); log.debug(MainApp.gs(R.string.noprofileselected));
return; return;
} }
if (!isEnabled(PluginType.APS)) { if (!isEnabled(PluginType.APS)) {
MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_disabled))); MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_disabled)));
if (Config.logAps) if (L.isEnabled(L.APS))
log.debug(MainApp.gs(R.string.openapsma_disabled)); log.debug(MainApp.gs(R.string.openapsma_disabled));
return; return;
} }
if (glucoseStatus == null) { if (glucoseStatus == null) {
MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_noglucosedata))); MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_noglucosedata)));
if (Config.logAps) if (L.isEnabled(L.APS))
log.debug(MainApp.gs(R.string.openapsma_noglucosedata)); log.debug(MainApp.gs(R.string.openapsma_noglucosedata));
return; return;
} }
@ -142,12 +141,12 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface {
Date start = new Date(); Date start = new Date();
Date startPart = new Date(); Date startPart = new Date();
IobTotal[] iobArray = IobCobCalculatorPlugin.getPlugin().calculateIobArrayForSMB(profile); IobTotal[] iobArray = IobCobCalculatorPlugin.getPlugin().calculateIobArrayForSMB(profile);
if (Config.logAps) if (L.isEnabled(L.APS))
Profiler.log(log, "calculateIobArrayInDia()", startPart); Profiler.log(log, "calculateIobArrayInDia()", startPart);
startPart = new Date(); startPart = new Date();
MealData mealData = TreatmentsPlugin.getPlugin().getMealData(); MealData mealData = TreatmentsPlugin.getPlugin().getMealData();
if (Config.logAps) if (L.isEnabled(L.APS))
Profiler.log(log, "getMealData()", startPart); Profiler.log(log, "getMealData()", startPart);
double maxIob = MainApp.getConstraintChecker().getMaxIOBAllowed().value(); double maxIob = MainApp.getConstraintChecker().getMaxIOBAllowed().value();
@ -198,9 +197,9 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface {
MainApp.getConstraintChecker().isAdvancedFilteringEnabled(advancedFiltering); MainApp.getConstraintChecker().isAdvancedFilteringEnabled(advancedFiltering);
inputConstraints.copyReasons(advancedFiltering); inputConstraints.copyReasons(advancedFiltering);
if (Config.logAps) if (L.isEnabled(L.APS))
Profiler.log(log, "detectSensitivityandCarbAbsorption()", startPart); Profiler.log(log, "detectSensitivityandCarbAbsorption()", startPart);
if (Config.logAps) if (L.isEnabled(L.APS))
Profiler.log(log, "SMB data gathering", start); Profiler.log(log, "SMB data gathering", start);
start = new Date(); start = new Date();
@ -219,7 +218,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
DetermineBasalResultSMB determineBasalResultSMB = determineBasalAdapterSMBJS.invoke(); DetermineBasalResultSMB determineBasalResultSMB = determineBasalAdapterSMBJS.invoke();
if (Config.logAps) if (L.isEnabled(L.APS))
Profiler.log(log, "SMB calculation", start); Profiler.log(log, "SMB calculation", start);
// TODO still needed with oref1? // TODO still needed with oref1?
// Fix bug determine basal // Fix bug determine basal

View file

@ -80,6 +80,7 @@ import info.nightscout.androidaps.interfaces.Constraint;
import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Careportal.CareportalFragment; import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog; import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow; import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
@ -125,7 +126,7 @@ import info.nightscout.utils.ToastUtils;
import static info.nightscout.utils.DateUtil.now; import static info.nightscout.utils.DateUtil.now;
public class OverviewFragment extends Fragment implements View.OnClickListener, View.OnLongClickListener { 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 timeView;
TextView bgView; TextView bgView;
@ -825,7 +826,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
builder.setPositiveButton(MainApp.gs(R.string.ok), (dialog, id) -> { builder.setPositiveButton(MainApp.gs(R.string.ok), (dialog, id) -> {
synchronized (builder) { synchronized (builder) {
if (accepted) { if (accepted) {
if (Config.logOverview) if (L.isEnabled(L.OVERVIEW))
log.debug("guarding: already accepted"); log.debug("guarding: already accepted");
return; return;
} }
@ -1031,7 +1032,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
public void updateGUI(final String from) { public void updateGUI(final String from) {
if (Config.logOverview) if (L.isEnabled(L.OVERVIEW))
log.debug("updateGUI entered from: " + from); log.debug("updateGUI entered from: " + from);
final Date updateGUIStart = new Date(); final Date updateGUIStart = new Date();
@ -1427,7 +1428,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
final long now = System.currentTimeMillis(); final long now = System.currentTimeMillis();
// ------------------ 1st graph // ------------------ 1st graph
if (Config.logOverview) if (L.isEnabled(L.OVERVIEW))
Profiler.log(log, from + " - 1st graph - START", updateGUIStart); Profiler.log(log, from + " - 1st graph - START", updateGUIStart);
final GraphData graphData = new GraphData(bgGraph, IobCobCalculatorPlugin.getPlugin()); final GraphData graphData = new GraphData(bgGraph, IobCobCalculatorPlugin.getPlugin());
@ -1460,7 +1461,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
graphData.addNowLine(now); graphData.addNowLine(now);
// ------------------ 2nd graph // ------------------ 2nd graph
if (Config.logOverview) if (L.isEnabled(L.OVERVIEW))
Profiler.log(log, from + " - 2nd graph - START", updateGUIStart); Profiler.log(log, from + " - 2nd graph - START", updateGUIStart);
final GraphData secondGraphData = new GraphData(iobGraph, IobCobCalculatorPlugin.getPlugin()); final GraphData secondGraphData = new GraphData(iobGraph, IobCobCalculatorPlugin.getPlugin());
@ -1515,13 +1516,13 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
// finally enforce drawing of graphs // finally enforce drawing of graphs
graphData.performUpdate(); graphData.performUpdate();
secondGraphData.performUpdate(); secondGraphData.performUpdate();
if (Config.logOverview) if (L.isEnabled(L.OVERVIEW))
Profiler.log(log, from + " - onDataChanged", updateGUIStart); Profiler.log(log, from + " - onDataChanged", updateGUIStart);
}); });
} }
}).start(); }).start();
if (Config.logOverview) if (L.isEnabled(L.OVERVIEW))
Profiler.log(log, from, updateGUIStart); Profiler.log(log, from, updateGUIStart);
} }

View file

@ -7,7 +7,6 @@ import org.json.JSONException;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Profile; 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.PluginBase;
import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType; 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.EventDismissNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.Overview.notifications.NotificationStore; import info.nightscout.androidaps.plugins.Overview.notifications.NotificationStore;
@ -25,7 +25,7 @@ import info.nightscout.utils.SP;
* Created by mike on 05.08.2016. * Created by mike on 05.08.2016.
*/ */
public class OverviewPlugin extends PluginBase { 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(); private static OverviewPlugin overviewPlugin = new OverviewPlugin();

View file

@ -18,7 +18,6 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; 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.ExtendedBolus;
import info.nightscout.androidaps.db.ProfileSwitch; import info.nightscout.androidaps.db.ProfileSwitch;
import info.nightscout.androidaps.db.TempTarget; import info.nightscout.androidaps.db.TempTarget;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData; import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
import info.nightscout.androidaps.plugins.IobCobCalculator.BasalData; import info.nightscout.androidaps.plugins.IobCobCalculator.BasalData;
@ -51,7 +51,7 @@ import info.nightscout.utils.Round;
*/ */
public class GraphData { public class GraphData {
private static Logger log = LoggerFactory.getLogger(Constants.OVERVIEW); private static Logger log = LoggerFactory.getLogger(L.OVERVIEW);
private GraphView graph; private GraphView graph;
public double maxY = Double.MIN_VALUE; public double maxY = Double.MIN_VALUE;
@ -75,7 +75,7 @@ public class GraphData {
List<DataPointWithLabelInterface> bgListArray = new ArrayList<>(); List<DataPointWithLabelInterface> bgListArray = new ArrayList<>();
if (bgReadingsArray == null || bgReadingsArray.size() == 0) { if (bgReadingsArray == null || bgReadingsArray.size() == 0) {
if (Config.logOverview) if (L.isEnabled(L.OVERVIEW))
log.debug("No BG data."); log.debug("No BG data.");
return; return;
} }

View file

@ -15,10 +15,9 @@ import org.slf4j.LoggerFactory;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.NSClientInternal.broadcasts.BroadcastAckAlarm; import info.nightscout.androidaps.plugins.NSClientInternal.broadcasts.BroadcastAckAlarm;
import info.nightscout.androidaps.plugins.Overview.OverviewPlugin; import info.nightscout.androidaps.plugins.Overview.OverviewPlugin;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
@ -26,7 +25,7 @@ import info.nightscout.utils.DateUtil;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
public class NotificationRecyclerViewAdapter extends RecyclerView.Adapter<NotificationRecyclerViewAdapter.NotificationsViewHolder> { public class NotificationRecyclerViewAdapter extends RecyclerView.Adapter<NotificationRecyclerViewAdapter.NotificationsViewHolder> {
private static Logger log = LoggerFactory.getLogger(Constants.NOTIFICATION); private static Logger log = LoggerFactory.getLogger(L.NOTIFICATION);
private List<Notification> notificationsList; private List<Notification> notificationsList;
@ -98,12 +97,12 @@ public class NotificationRecyclerViewAdapter extends RecyclerView.Adapter<Notifi
BroadcastAckAlarm.handleClearAlarm(notification.nsAlarm, MainApp.instance().getApplicationContext(), 60 * 60 * 1000L); BroadcastAckAlarm.handleClearAlarm(notification.nsAlarm, MainApp.instance().getApplicationContext(), 60 * 60 * 1000L);
} }
// Adding current time to snooze if we got staleData // Adding current time to snooze if we got staleData
if (Config.logNotification) if (L.isEnabled(L.NOTIFICATION))
log.debug("Notification text is: " + notification.text); log.debug("Notification text is: " + notification.text);
if (notification.text.equals(MainApp.gs(R.string.nsalarm_staledata))) { if (notification.text.equals(MainApp.gs(R.string.nsalarm_staledata))) {
NotificationStore nstore = OverviewPlugin.getPlugin().notificationStore; NotificationStore nstore = OverviewPlugin.getPlugin().notificationStore;
long msToSnooze = SP.getInt("nsalarm_staledatavalue", 15) * 60 * 1000L; long msToSnooze = SP.getInt("nsalarm_staledatavalue", 15) * 60 * 1000L;
if (Config.logNotification) if (L.isEnabled(L.NOTIFICATION))
log.debug("snooze nsalarm_staledatavalue in minutes is " + SP.getInt("nsalarm_staledatavalue", 15) + "\n in ms is: " + msToSnooze + " currentTimeMillis is: " + System.currentTimeMillis()); log.debug("snooze nsalarm_staledatavalue in minutes is " + SP.getInt("nsalarm_staledatavalue", 15) + "\n in ms is: " + msToSnooze + " currentTimeMillis is: " + System.currentTimeMillis());
nstore.snoozeTo(System.currentTimeMillis() + (SP.getInt("nsalarm_staledatavalue", 15) * 60 * 1000L)); nstore.snoozeTo(System.currentTimeMillis() + (SP.getInt("nsalarm_staledatavalue", 15) * 60 * 1000L));
} }

View file

@ -22,9 +22,9 @@ import java.util.Comparator;
import java.util.List; import java.util.List;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.services.AlarmSoundService; import info.nightscout.androidaps.services.AlarmSoundService;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
@ -36,7 +36,7 @@ public class NotificationStore {
private static final String CHANNEL_ID = "AndroidAPS-Overview"; private static final String CHANNEL_ID = "AndroidAPS-Overview";
private static Logger log = LoggerFactory.getLogger(Constants.NOTIFICATION); private static Logger log = LoggerFactory.getLogger(L.NOTIFICATION);
public List<Notification> store = new ArrayList<>(); public List<Notification> store = new ArrayList<>();
private boolean usesChannels; private boolean usesChannels;
@ -52,7 +52,7 @@ public class NotificationStore {
} }
public synchronized boolean add(Notification n) { public synchronized boolean add(Notification n) {
if (Config.logNotification) if (L.isEnabled(L.NOTIFICATION))
log.debug("Notification received: " + n.text); log.debug("Notification received: " + n.text);
for (Notification storeNotification : store) { for (Notification storeNotification : store) {
if (storeNotification.id == n.id) { if (storeNotification.id == n.id) {
@ -108,7 +108,7 @@ public class NotificationStore {
} }
public void snoozeTo(long timeToSnooze) { public void snoozeTo(long timeToSnooze) {
if (Config.logNotification) if (L.isEnabled(L.NOTIFICATION))
log.debug("Snoozing alarm until: " + timeToSnooze); log.debug("Snoozing alarm until: " + timeToSnooze);
SP.putLong("snoozedTo", 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); Notification notification = new Notification(Notification.NSALARM, MainApp.gs(R.string.nsalarm_staledata), Notification.URGENT);
SP.putLong("snoozedTo", System.currentTimeMillis()); SP.putLong("snoozedTo", System.currentTimeMillis());
add(notification); add(notification);
if (Config.logNotification) if (L.isEnabled(L.NOTIFICATION))
log.debug("Snoozed to current time and added back notification!"); log.debug("Snoozed to current time and added back notification!");
} }
} }

View file

@ -13,6 +13,7 @@ import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.services.Intents; import info.nightscout.androidaps.services.Intents;
import info.nightscout.androidaps.data.ProfileStore; import info.nightscout.androidaps.data.ProfileStore;
import info.nightscout.androidaps.events.EventProfileStoreChanged; import info.nightscout.androidaps.events.EventProfileStoreChanged;
@ -77,7 +78,7 @@ public class NSProfilePlugin extends PluginBase implements ProfileInterface {
MainApp.bus().post(new EventProfileStoreChanged()); MainApp.bus().post(new EventProfileStoreChanged());
MainApp.bus().post(new EventNSProfileUpdateGUI()); MainApp.bus().post(new EventNSProfileUpdateGUI());
} }
if (Config.logNsclient) if (L.isEnabled(L.NSCLIENT))
log.debug("Received profileStore: " + activeProfile + " " + profile); log.debug("Received profileStore: " + activeProfile + " " + profile);
} catch (JSONException e) { } catch (JSONException e) {
log.error("Unhandled exception", e); log.error("Unhandled exception", e);

View file

@ -22,8 +22,6 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import info.nightscout.androidaps.BuildConfig; import info.nightscout.androidaps.BuildConfig;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.DetailedBolusInfo; import info.nightscout.androidaps.data.DetailedBolusInfo;
@ -42,6 +40,7 @@ import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
@ -71,7 +70,7 @@ import info.nightscout.utils.SP;
* Created by mike on 05.08.2016. * Created by mike on 05.08.2016.
*/ */
public class ComboPlugin extends PluginBase implements PumpInterface, ConstraintsInterface { public class ComboPlugin extends PluginBase implements PumpInterface, ConstraintsInterface {
private static final Logger log = LoggerFactory.getLogger(Constants.PUMP); private static final Logger log = LoggerFactory.getLogger(L.PUMP);
static final String COMBO_TBRS_SET = "combo_tbrs_set"; static final String COMBO_TBRS_SET = "combo_tbrs_set";
static final String COMBO_BOLUSES_DELIVERED = "combo_boluses_delivered"; static final String COMBO_BOLUSES_DELIVERED = "combo_boluses_delivered";
@ -209,14 +208,14 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
pluginSwitcher.invoke(); pluginSwitcher.invoke();
SP.putBoolean("allow_hardware_pump", true); SP.putBoolean("allow_hardware_pump", true);
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("First time HW pump allowed!"); log.debug("First time HW pump allowed!");
} }
}) })
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
pluginSwitcher.cancel(); pluginSwitcher.cancel();
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("User does not allow switching to HW pump!"); log.debug("User does not allow switching to HW pump!");
} }
}); });
@ -264,7 +263,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
@Override @Override
public void disconnect(String reason) { public void disconnect(String reason) {
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("Disconnect called with reason: " + reason); log.debug("Disconnect called with reason: " + reason);
ruffyScripter.disconnect(); ruffyScripter.disconnect();
} }
@ -364,7 +363,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
*/ */
@Override @Override
public synchronized void getPumpStatus() { public synchronized void getPumpStatus() {
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("getPumpStatus called"); log.debug("getPumpStatus called");
if (!pump.initialized) { if (!pump.initialized) {
initializePump(); initializePump();
@ -377,11 +376,11 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
private synchronized void initializePump() { private synchronized void initializePump() {
long maxWait = System.currentTimeMillis() + 15 * 1000; long maxWait = System.currentTimeMillis() + 15 * 1000;
while (!ruffyScripter.isPumpAvailable()) { while (!ruffyScripter.isPumpAvailable()) {
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("Waiting for ruffy service to come up ..."); log.debug("Waiting for ruffy service to come up ...");
SystemClock.sleep(100); SystemClock.sleep(100);
if (System.currentTimeMillis() > maxWait) { if (System.currentTimeMillis() > maxWait) {
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("ruffy service unavailable, wtf"); log.debug("ruffy service unavailable, wtf");
return; return;
} }
@ -401,7 +400,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
// note that since the history is checked upon every connect, the above already updated // note that since the history is checked upon every connect, the above already updated
// the DB with any changed history records // the DB with any changed history records
if (pumpHistoryChanged) { if (pumpHistoryChanged) {
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("Pump history has changed and was imported"); log.debug("Pump history has changed and was imported");
pumpHistoryChanged = false; pumpHistoryChanged = false;
} }
@ -551,7 +550,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
// within the last 1-2 minutes // within the last 1-2 minutes
if (Math.abs(previousBolus.amount - detailedBolusInfo.insulin) < 0.01 if (Math.abs(previousBolus.amount - detailedBolusInfo.insulin) < 0.01
&& previousBolus.timestamp + 60 * 1000 > System.currentTimeMillis()) { && previousBolus.timestamp + 60 * 1000 > System.currentTimeMillis()) {
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("Bolus request rejected, same bolus was successfully delivered very recently"); log.debug("Bolus request rejected, same bolus was successfully delivered very recently");
return new PumpEnactResult().success(false).enacted(false) return new PumpEnactResult().success(false).enacted(false)
.comment(MainApp.gs(R.string.bolus_frequency_exceeded)); .comment(MainApp.gs(R.string.bolus_frequency_exceeded));
@ -572,7 +571,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
return new PumpEnactResult().success(false).enacted(false) return new PumpEnactResult().success(false).enacted(false)
.comment(MainApp.gs(R.string.combo_error_no_connection_no_bolus_delivered)); .comment(MainApp.gs(R.string.combo_error_no_connection_no_bolus_delivered));
} }
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("Waiting for pump clock to advance for the next unused bolus record timestamp"); log.debug("Waiting for pump clock to advance for the next unused bolus record timestamp");
SystemClock.sleep(2000); SystemClock.sleep(2000);
timeCheckResult = runCommand(null, 0, ruffyScripter::readPumpState); timeCheckResult = runCommand(null, 0, ruffyScripter::readPumpState);
@ -584,7 +583,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION) .putCustomAttribute("version", BuildConfig.VERSION)
.putCustomAttribute("waitTimeSecs", String.valueOf(waitDuration))); .putCustomAttribute("waitTimeSecs", String.valueOf(waitDuration)));
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("Waited " + waitDuration + "s for pump to switch to a fresh minute before bolusing"); log.debug("Waited " + waitDuration + "s for pump to switch to a fresh minute before bolusing");
} }
@ -747,12 +746,12 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
*/ */
@Override @Override
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile, boolean force) { public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile, boolean force) {
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute called with a rate of " + absoluteRate + " for " + durationInMinutes + " min."); log.debug("setTempBasalAbsolute called with a rate of " + absoluteRate + " for " + durationInMinutes + " min.");
int unroundedPercentage = Double.valueOf(absoluteRate / getBaseBasalRate() * 100).intValue(); int unroundedPercentage = Double.valueOf(absoluteRate / getBaseBasalRate() * 100).intValue();
int roundedPercentage = (int) (Math.round(absoluteRate / getBaseBasalRate() * 10) * 10); int roundedPercentage = (int) (Math.round(absoluteRate / getBaseBasalRate() * 10) * 10);
if (unroundedPercentage != roundedPercentage) { if (unroundedPercentage != roundedPercentage) {
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("Rounded requested rate " + unroundedPercentage + "% -> " + roundedPercentage + "%"); log.debug("Rounded requested rate " + unroundedPercentage + "% -> " + roundedPercentage + "%");
} }
@ -771,7 +770,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
} }
private PumpEnactResult setTempBasalPercent(Integer percent, final Integer durationInMinutes) { private PumpEnactResult setTempBasalPercent(Integer percent, final Integer durationInMinutes) {
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("setTempBasalPercent called with " + percent + "% for " + durationInMinutes + "min"); log.debug("setTempBasalPercent called with " + percent + "% for " + durationInMinutes + "min");
if (pumpHistoryChanged && percent > 110) { if (pumpHistoryChanged && percent > 110) {
@ -782,14 +781,14 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
int adjustedPercent = percent; int adjustedPercent = percent;
if (adjustedPercent > pumpDescription.maxTempPercent) { if (adjustedPercent > pumpDescription.maxTempPercent) {
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("Reducing requested TBR to the maximum support by the pump: " + percent + " -> " + pumpDescription.maxTempPercent); log.debug("Reducing requested TBR to the maximum support by the pump: " + percent + " -> " + pumpDescription.maxTempPercent);
adjustedPercent = pumpDescription.maxTempPercent; adjustedPercent = pumpDescription.maxTempPercent;
} }
if (adjustedPercent % 10 != 0) { if (adjustedPercent % 10 != 0) {
Long rounded = Math.round(adjustedPercent / 10d) * 10; Long rounded = Math.round(adjustedPercent / 10d) * 10;
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("Rounded requested percentage:" + adjustedPercent + " -> " + rounded); log.debug("Rounded requested percentage:" + adjustedPercent + " -> " + rounded);
adjustedPercent = rounded.intValue(); adjustedPercent = rounded.intValue();
} }
@ -839,7 +838,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
*/ */
@Override @Override
public PumpEnactResult cancelTempBasal(boolean enforceNew) { public PumpEnactResult cancelTempBasal(boolean enforceNew) {
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("cancelTempBasal called"); log.debug("cancelTempBasal called");
final TemporaryBasal activeTemp = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(System.currentTimeMillis()); final TemporaryBasal activeTemp = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(System.currentTimeMillis());
if (enforceNew) { if (enforceNew) {
@ -850,7 +849,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
if (!stateResult.state.tbrActive) { if (!stateResult.state.tbrActive) {
return new PumpEnactResult().success(true).enacted(false); return new PumpEnactResult().success(true).enacted(false);
} }
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("cancelTempBasal: hard-cancelling TBR since force requested"); log.debug("cancelTempBasal: hard-cancelling TBR since force requested");
CommandResult cancelResult = runCommand(MainApp.gs(R.string.combo_pump_action_cancelling_tbr), 2, ruffyScripter::cancelTbr); CommandResult cancelResult = runCommand(MainApp.gs(R.string.combo_pump_action_cancelling_tbr), 2, ruffyScripter::cancelTbr);
if (!cancelResult.success) { if (!cancelResult.success) {
@ -872,7 +871,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
// Let fake neutral temp keep run (see below) // Let fake neutral temp keep run (see below)
// Note that since this runs on the queue a connection is opened regardless, but this // 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). // case doesn't occur all that often, so it's not worth optimizing (1.3k SetTBR vs 4 cancelTBR).
if (Config.logPump) 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."); 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) return new PumpEnactResult().success(true).enacted(true)
.comment("cancelTempBasal skipping changing tbr since it already is at " .comment("cancelTempBasal skipping changing tbr since it already is at "
@ -882,7 +881,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
// Set a fake neutral temp to avoid TBR cancel alert. Decide 90% vs 110% based on // 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%. // on whether the TBR we're cancelling is above or below 100%.
final int percentage = (activeTemp.percentRate > 100) ? 110 : 90; final int percentage = (activeTemp.percentRate > 100) ? 110 : 90;
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("cancelTempBasal: changing TBR to " + percentage + "% for 15 mins."); log.debug("cancelTempBasal: changing TBR to " + percentage + "% for 15 mins.");
return setTempBasalPercent(percentage, 15); return setTempBasalPercent(percentage, 15);
} }
@ -922,7 +921,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
if (!commandResult.success && retries > 0) { if (!commandResult.success && retries > 0) {
for (int retryAttempts = 1; !commandResult.success && retryAttempts <= retries; retryAttempts++) { for (int retryAttempts = 1; !commandResult.success && retryAttempts <= retries; retryAttempts++) {
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("Command was not successful, retries requested, doing retry #" + retryAttempts); log.debug("Command was not successful, retries requested, doing retry #" + retryAttempts);
commandResult = commandExecution.execute(); commandResult = commandExecution.execute();
} }
@ -1004,7 +1003,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
TemporaryBasal aapsTbr = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(now); TemporaryBasal aapsTbr = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(now);
if (aapsTbr == null || aapsTbr.percentRate != 0) { if (aapsTbr == null || aapsTbr.percentRate != 0) {
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("Creating 15m zero temp since pump is suspended"); log.debug("Creating 15m zero temp since pump is suspended");
TemporaryBasal newTempBasal = new TemporaryBasal() TemporaryBasal newTempBasal = new TemporaryBasal()
.date(now) .date(now)
@ -1065,12 +1064,12 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
if (state.pumpTime == 0) { if (state.pumpTime == 0) {
// time couldn't be read (e.g. a warning is displayed on the menu , hiding the time field) // 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) { } else if (Math.abs(state.pumpTime - System.currentTimeMillis()) >= 10 * 60 * 1000) {
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("Pump clock needs update, pump time: " + state.pumpTime + " (" + new Date(state.pumpTime) + ")"); 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); 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)); MainApp.bus().post(new EventNewNotification(notification));
} else if (Math.abs(state.pumpTime - System.currentTimeMillis()) >= 3 * 60 * 1000) { } else if (Math.abs(state.pumpTime - System.currentTimeMillis()) >= 3 * 60 * 1000) {
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("Pump clock needs update, pump time: " + state.pumpTime + " (" + new Date(state.pumpTime) + ")"); 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); 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)); MainApp.bus().post(new EventNewNotification(notification));
@ -1133,7 +1132,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
TemporaryBasal aapsTbr = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(now); TemporaryBasal aapsTbr = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(now);
if (aapsTbr == null && state.tbrActive && state.tbrRemainingDuration > 2) { if (aapsTbr == null && state.tbrActive && state.tbrRemainingDuration > 2) {
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("Creating temp basal from pump TBR"); log.debug("Creating temp basal from pump TBR");
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboTbrMismatch") FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboTbrMismatch")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
@ -1146,7 +1145,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
.source(Source.USER); .source(Source.USER);
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(newTempBasal); TreatmentsPlugin.getPlugin().addToHistoryTempBasal(newTempBasal);
} else if (aapsTbr != null && aapsTbr.getPlannedRemainingMinutes() > 2 && !state.tbrActive) { } else if (aapsTbr != null && aapsTbr.getPlannedRemainingMinutes() > 2 && !state.tbrActive) {
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("Ending AAPS-TBR since pump has no TBR active"); log.debug("Ending AAPS-TBR since pump has no TBR active");
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboTbrMismatch") FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboTbrMismatch")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
@ -1160,7 +1159,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
} else if (aapsTbr != null && state.tbrActive } else if (aapsTbr != null && state.tbrActive
&& (aapsTbr.percentRate != state.tbrPercent || && (aapsTbr.percentRate != state.tbrPercent ||
Math.abs(aapsTbr.getPlannedRemainingMinutes() - state.tbrRemainingDuration) > 2)) { Math.abs(aapsTbr.getPlannedRemainingMinutes() - state.tbrRemainingDuration) > 2)) {
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("AAPSs and pump-TBR differ; ending AAPS-TBR and creating new TBR based on pump TBR"); log.debug("AAPSs and pump-TBR differ; ending AAPS-TBR and creating new TBR based on pump TBR");
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboTbrMismatch") FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboTbrMismatch")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
@ -1246,7 +1245,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
// no history, nothing to check or complain about // no history, nothing to check or complain about
if (quickInfoResult.history == null || quickInfoResult.history.bolusHistory.isEmpty()) { if (quickInfoResult.history == null || quickInfoResult.history.bolusHistory.isEmpty()) {
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("Setting 'pumpHistoryChanged' false"); log.debug("Setting 'pumpHistoryChanged' false");
pumpHistoryChanged = false; pumpHistoryChanged = false;
return null; return null;
@ -1256,14 +1255,14 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
List<Bolus> initialPumpBolusHistory = quickInfoResult.history.bolusHistory; List<Bolus> initialPumpBolusHistory = quickInfoResult.history.bolusHistory;
if (recentBoluses.size() == 1 && initialPumpBolusHistory.size() >= 1 if (recentBoluses.size() == 1 && initialPumpBolusHistory.size() >= 1
&& recentBoluses.get(0).equals(quickInfoResult.history.bolusHistory.get(0))) { && recentBoluses.get(0).equals(quickInfoResult.history.bolusHistory.get(0))) {
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("Setting 'pumpHistoryChanged' false"); log.debug("Setting 'pumpHistoryChanged' false");
pumpHistoryChanged = false; pumpHistoryChanged = false;
return null; return null;
} else if (recentBoluses.size() == 2 && initialPumpBolusHistory.size() >= 2 } else if (recentBoluses.size() == 2 && initialPumpBolusHistory.size() >= 2
&& recentBoluses.get(0).equals(quickInfoResult.history.bolusHistory.get(0)) && recentBoluses.get(0).equals(quickInfoResult.history.bolusHistory.get(0))
&& recentBoluses.get(1).equals(quickInfoResult.history.bolusHistory.get(1))) { && recentBoluses.get(1).equals(quickInfoResult.history.bolusHistory.get(1))) {
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("Setting 'pumpHistoryChanged' false"); log.debug("Setting 'pumpHistoryChanged' false");
pumpHistoryChanged = false; pumpHistoryChanged = false;
return null; return null;
@ -1284,7 +1283,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
// for. // for.
HashSet<Bolus> bolusSet = new HashSet<>(historyResult.history.bolusHistory); HashSet<Bolus> bolusSet = new HashSet<>(historyResult.history.bolusHistory);
if (bolusSet.size() != historyResult.history.bolusHistory.size()) { if (bolusSet.size() != historyResult.history.bolusHistory.size()) {
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("Bolus with same amount within the same minute imported. Only one will make it to the DB."); 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") FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboBolusToDbError")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
@ -1298,7 +1297,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
pumpHistoryChanged = updateDbFromPumpHistory(historyResult.history); pumpHistoryChanged = updateDbFromPumpHistory(historyResult.history);
if (pumpHistoryChanged) { if (pumpHistoryChanged) {
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("Setting 'pumpHistoryChanged' true"); log.debug("Setting 'pumpHistoryChanged' true");
} }

View file

@ -10,8 +10,6 @@ import org.slf4j.LoggerFactory;
import java.util.Date; import java.util.Date;
import info.nightscout.androidaps.BuildConfig; import info.nightscout.androidaps.BuildConfig;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.Profile;
@ -28,6 +26,7 @@ import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.ProfileInterface; import info.nightscout.androidaps.interfaces.ProfileInterface;
import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.Overview.notifications.Notification; import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
@ -45,7 +44,7 @@ import info.nightscout.utils.SP;
*/ */
public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInterface, DanaRInterface, ConstraintsInterface, ProfileInterface { public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInterface, DanaRInterface, ConstraintsInterface, ProfileInterface {
protected Logger log = LoggerFactory.getLogger(Constants.PUMP); protected Logger log = LoggerFactory.getLogger(L.PUMP);
protected AbstractDanaRExecutionService sExecutionService; protected AbstractDanaRExecutionService sExecutionService;
@ -135,7 +134,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
Double profileValue = profile.getBasalTimeFromMidnight(h * basalIncrement); Double profileValue = profile.getBasalTimeFromMidnight(h * basalIncrement);
if (profileValue == null) return true; if (profileValue == null) return true;
if (Math.abs(pumpValue - profileValue) > getPumpDescription().basalStep) { if (Math.abs(pumpValue - profileValue) > getPumpDescription().basalStep) {
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("Diff found. Hour: " + h + " Pump: " + pumpValue + " Profile: " + profileValue); log.debug("Diff found. Hour: " + h + " Pump: " + pumpValue + " Profile: " + profileValue);
return false; return false;
} }
@ -186,7 +185,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
result.duration = pump.tempBasalRemainingMin; result.duration = pump.tempBasalRemainingMin;
result.percent = pump.tempBasalPercent; result.percent = pump.tempBasalPercent;
result.isPercent = true; result.isPercent = true;
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("setTempBasalPercent: Correct value already set"); log.debug("setTempBasalPercent: Correct value already set");
return result; return result;
} }
@ -200,7 +199,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
result.duration = pump.tempBasalRemainingMin; result.duration = pump.tempBasalRemainingMin;
result.percent = pump.tempBasalPercent; result.percent = pump.tempBasalPercent;
result.isPercent = true; result.isPercent = true;
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("setTempBasalPercent: OK"); log.debug("setTempBasalPercent: OK");
return result; return result;
} }
@ -228,7 +227,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
result.absolute = pump.extendedBolusAbsoluteRate; result.absolute = pump.extendedBolusAbsoluteRate;
result.isPercent = false; result.isPercent = false;
result.isTempCancel = false; result.isTempCancel = false;
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("setExtendedBolus: Correct extended bolus already set. Current: " + pump.extendedBolusAmount + " Asked: " + insulin); log.debug("setExtendedBolus: Correct extended bolus already set. Current: " + pump.extendedBolusAmount + " Asked: " + insulin);
return result; return result;
} }
@ -243,7 +242,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
if (!SP.getBoolean("danar_useextended", false)) if (!SP.getBoolean("danar_useextended", false))
result.bolusDelivered = pump.extendedBolusAmount; result.bolusDelivered = pump.extendedBolusAmount;
result.isPercent = false; result.isPercent = false;
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("setExtendedBolus: OK"); log.debug("setExtendedBolus: OK");
return result; return result;
} }
@ -266,7 +265,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
if (!pump.isExtendedInProgress) { if (!pump.isExtendedInProgress) {
result.success = true; result.success = true;
result.comment = MainApp.gs(R.string.virtualpump_resultok); result.comment = MainApp.gs(R.string.virtualpump_resultok);
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("cancelExtendedBolus: OK"); log.debug("cancelExtendedBolus: OK");
return result; return result;
} else { } else {

View file

@ -23,8 +23,6 @@ import org.slf4j.LoggerFactory;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.OnClick; import butterknife.OnClick;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.activities.TDDStatsActivity; import info.nightscout.androidaps.activities.TDDStatsActivity;
@ -33,6 +31,7 @@ import info.nightscout.androidaps.events.EventExtendedBolusChange;
import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.events.EventTempBasalChange; import info.nightscout.androidaps.events.EventTempBasalChange;
import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment; import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.PumpDanaR.Dialogs.ProfileViewDialog; import info.nightscout.androidaps.plugins.PumpDanaR.Dialogs.ProfileViewDialog;
@ -47,7 +46,7 @@ import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.SetWarnColor; import info.nightscout.utils.SetWarnColor;
public class DanaRFragment extends SubscriberFragment { public class DanaRFragment extends SubscriberFragment {
private static Logger log = LoggerFactory.getLogger(Constants.PUMP); private static Logger log = LoggerFactory.getLogger(L.PUMP);
private Handler loopHandler = new Handler(); private Handler loopHandler = new Handler();
private Runnable refreshLoop = new Runnable() { private Runnable refreshLoop = new Runnable() {
@ -146,7 +145,7 @@ public class DanaRFragment extends SubscriberFragment {
@OnClick(R.id.danar_btconnection) @OnClick(R.id.danar_btconnection)
void onBtConnectionClick() { void onBtConnectionClick() {
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("Clicked connect to pump"); log.debug("Clicked connect to pump");
DanaRPump.getInstance().lastConnection = 0; DanaRPump.getInstance().lastConnection = 0;
ConfigBuilderPlugin.getCommandQueue().readStatus("Clicked connect to pump", null); ConfigBuilderPlugin.getCommandQueue().readStatus("Clicked connect to pump", null);

View file

@ -11,9 +11,6 @@ import android.support.v7.app.AlertDialog;
import com.squareup.otto.Subscribe; import com.squareup.otto.Subscribe;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.DetailedBolusInfo; 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.data.PumpEnactResult;
import info.nightscout.androidaps.db.ExtendedBolus; import info.nightscout.androidaps.db.ExtendedBolus;
import info.nightscout.androidaps.db.TemporaryBasal; import info.nightscout.androidaps.db.TemporaryBasal;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgBolusStartWithSpeed; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgBolusStartWithSpeed;
import info.nightscout.androidaps.plugins.Treatments.Treatment; import info.nightscout.androidaps.plugins.Treatments.Treatment;
@ -93,14 +91,14 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
pluginSwitcher.invoke(); pluginSwitcher.invoke();
SP.putBoolean("allow_hardware_pump", true); SP.putBoolean("allow_hardware_pump", true);
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("First time HW pump allowed!"); log.debug("First time HW pump allowed!");
} }
}) })
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
pluginSwitcher.cancel(); pluginSwitcher.cancel();
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("User does not allow switching to HW pump!"); log.debug("User does not allow switching to HW pump!");
} }
}); });
@ -128,13 +126,13 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
private ServiceConnection mConnection = new ServiceConnection() { private ServiceConnection mConnection = new ServiceConnection() {
public void onServiceDisconnected(ComponentName name) { public void onServiceDisconnected(ComponentName name) {
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("Service is disconnected"); log.debug("Service is disconnected");
sExecutionService = null; sExecutionService = null;
} }
public void onServiceConnected(ComponentName name, IBinder service) { public void onServiceConnected(ComponentName name, IBinder service) {
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("Service is connected"); log.debug("Service is connected");
DanaRExecutionService.LocalBinder mLocalBinder = (DanaRExecutionService.LocalBinder) service; DanaRExecutionService.LocalBinder mLocalBinder = (DanaRExecutionService.LocalBinder) service;
sExecutionService = mLocalBinder.getServiceInstance(); sExecutionService = mLocalBinder.getServiceInstance();
@ -198,7 +196,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
result.comment = String.format(MainApp.gs(R.string.boluserrorcode), detailedBolusInfo.insulin, t.insulin, MsgBolusStartWithSpeed.errorCode); result.comment = String.format(MainApp.gs(R.string.boluserrorcode), detailedBolusInfo.insulin, t.insulin, MsgBolusStartWithSpeed.errorCode);
else else
result.comment = MainApp.gs(R.string.virtualpump_resultok); result.comment = MainApp.gs(R.string.virtualpump_resultok);
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered); log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered);
detailedBolusInfo.insulin = t.insulin; detailedBolusInfo.insulin = t.insulin;
detailedBolusInfo.date = System.currentTimeMillis(); detailedBolusInfo.date = System.currentTimeMillis();
@ -240,13 +238,13 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
if (doTempOff) { if (doTempOff) {
// If extended in progress // If extended in progress
if (activeExtended != null && useExtendedBoluses) { if (activeExtended != null && useExtendedBoluses) {
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: Stopping extended bolus (doTempOff)"); log.debug("setTempBasalAbsolute: Stopping extended bolus (doTempOff)");
return cancelExtendedBolus(); return cancelExtendedBolus();
} }
// If temp in progress // If temp in progress
if (activeTemp != null) { if (activeTemp != null) {
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: Stopping temp basal (doTempOff)"); log.debug("setTempBasalAbsolute: Stopping temp basal (doTempOff)");
return cancelRealTempBasal(); return cancelRealTempBasal();
} }
@ -255,7 +253,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
result.percent = 100; result.percent = 100;
result.isPercent = true; result.isPercent = true;
result.isTempCancel = true; result.isTempCancel = true;
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: doTempOff OK"); log.debug("setTempBasalAbsolute: doTempOff OK");
return result; return result;
} }
@ -267,12 +265,12 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
if (percentRate > getPumpDescription().maxTempPercent) { if (percentRate > getPumpDescription().maxTempPercent) {
percentRate = getPumpDescription().maxTempPercent; percentRate = getPumpDescription().maxTempPercent;
} }
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: Calculated percent rate: " + percentRate); log.debug("setTempBasalAbsolute: Calculated percent rate: " + percentRate);
// If extended in progress // If extended in progress
if (activeExtended != null && useExtendedBoluses) { if (activeExtended != null && useExtendedBoluses) {
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: Stopping extended bolus (doLowTemp || doHighTemp)"); log.debug("setTempBasalAbsolute: Stopping extended bolus (doLowTemp || doHighTemp)");
result = cancelExtendedBolus(); result = cancelExtendedBolus();
if (!result.success) { if (!result.success) {
@ -283,7 +281,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
// Check if some temp is already in progress // Check if some temp is already in progress
if (activeTemp != null) { if (activeTemp != null) {
// Correct basal already set ? // Correct basal already set ?
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: currently running: " + activeTemp.toString()); log.debug("setTempBasalAbsolute: currently running: " + activeTemp.toString());
if (activeTemp.percentRate == percentRate) { if (activeTemp.percentRate == percentRate) {
if (enforceNew) { if (enforceNew) {
@ -295,21 +293,21 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
result.duration = activeTemp.getPlannedRemainingMinutes(); result.duration = activeTemp.getPlannedRemainingMinutes();
result.isPercent = true; result.isPercent = true;
result.isTempCancel = false; result.isTempCancel = false;
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: Correct temp basal already set (doLowTemp || doHighTemp)"); log.debug("setTempBasalAbsolute: Correct temp basal already set (doLowTemp || doHighTemp)");
return result; return result;
} }
} }
} }
// Convert duration from minutes to hours // Convert duration from minutes to hours
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: Setting temp basal " + percentRate + "% for " + durationInMinutes + " mins (doLowTemp || doHighTemp)"); log.debug("setTempBasalAbsolute: Setting temp basal " + percentRate + "% for " + durationInMinutes + " mins (doLowTemp || doHighTemp)");
return setTempBasalPercent(percentRate, durationInMinutes, profile, false); return setTempBasalPercent(percentRate, durationInMinutes, profile, false);
} }
if (doExtendedTemp) { if (doExtendedTemp) {
// Check if some temp is already in progress // Check if some temp is already in progress
if (activeTemp != null) { if (activeTemp != null) {
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: Stopping temp basal (doExtendedTemp)"); log.debug("setTempBasalAbsolute: Stopping temp basal (doExtendedTemp)");
result = cancelRealTempBasal(); result = cancelRealTempBasal();
// Check for proper result // Check for proper result
@ -328,7 +326,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
extendedRateToSet = Round.roundTo(extendedRateToSet, pumpDescription.extendedBolusStep * 2); // *2 because of halfhours extendedRateToSet = Round.roundTo(extendedRateToSet, pumpDescription.extendedBolusStep * 2); // *2 because of halfhours
// What is current rate of extended bolusing in u/h? // What is current rate of extended bolusing in u/h?
if (Config.logPump) { 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: 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"); log.debug("setTempBasalAbsolute: Rate to set: " + extendedRateToSet + "U/h");
} }
@ -342,21 +340,21 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
result.duration = pump.extendedBolusRemainingMinutes; result.duration = pump.extendedBolusRemainingMinutes;
result.isPercent = false; result.isPercent = false;
result.isTempCancel = false; result.isTempCancel = false;
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: Correct extended already set"); log.debug("setTempBasalAbsolute: Correct extended already set");
return result; return result;
} }
// Now set new extended, no need to to stop previous (if running) because it's replaced // Now set new extended, no need to to stop previous (if running) because it's replaced
Double extendedAmount = extendedRateToSet / 2 * durationInHalfHours; Double extendedAmount = extendedRateToSet / 2 * durationInHalfHours;
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: Setting extended: " + extendedAmount + "U halfhours: " + durationInHalfHours); log.debug("setTempBasalAbsolute: Setting extended: " + extendedAmount + "U halfhours: " + durationInHalfHours);
result = setExtendedBolus(extendedAmount, durationInMinutes); result = setExtendedBolus(extendedAmount, durationInMinutes);
if (!result.success) { if (!result.success) {
log.error("setTempBasalAbsolute: Failed to set extended bolus"); log.error("setTempBasalAbsolute: Failed to set extended bolus");
return result; return result;
} }
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("setTempBasalAbsolute: Extended bolus set ok"); log.debug("setTempBasalAbsolute: Extended bolus set ok");
result.absolute = result.absolute + getBaseBasalRate(); result.absolute = result.absolute + getBaseBasalRate();
return result; return result;
@ -395,7 +393,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
result.success = true; result.success = true;
result.isTempCancel = true; result.isTempCancel = true;
result.comment = MainApp.gs(R.string.virtualpump_resultok); result.comment = MainApp.gs(R.string.virtualpump_resultok);
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("cancelRealTempBasal: OK"); log.debug("cancelRealTempBasal: OK");
return result; return result;
} else { } else {

View file

@ -9,18 +9,18 @@ import org.slf4j.LoggerFactory;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.Date; import java.util.Date;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.ProfileStore; import info.nightscout.androidaps.data.ProfileStore;
import info.nightscout.androidaps.logging.L;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
/** /**
* Created by mike on 04.07.2016. * Created by mike on 04.07.2016.
*/ */
public class DanaRPump { public class DanaRPump {
private Logger log = LoggerFactory.getLogger(Constants.PUMP); private Logger log = LoggerFactory.getLogger(L.PUMP);
private static DanaRPump instance = null; private static DanaRPump instance = null;
@ -242,7 +242,7 @@ public class DanaRPump {
//Some values get truncated to the next lower one. //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) // -> 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; double value = Math.round(100d * nsProfile.getBasalTimeFromMidnight((Integer) (hour * 60 * 60)))/100d + 0.00001;
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("NS basal value for " + hour + ":00 is " + value); log.debug("NS basal value for " + hour + ":00 is " + value);
record[hour] = value; record[hour] = value;
} }

View file

@ -10,8 +10,7 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageHashTable; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageHashTable;
import info.nightscout.androidaps.plugins.PumpDanaR.services.AbstractSerialIOThread; import info.nightscout.androidaps.plugins.PumpDanaR.services.AbstractSerialIOThread;
@ -21,7 +20,7 @@ import info.nightscout.utils.CRC;
* Created by mike on 17.07.2016. * Created by mike on 17.07.2016.
*/ */
public class SerialIOThread extends AbstractSerialIOThread { public class SerialIOThread extends AbstractSerialIOThread {
private static Logger log = LoggerFactory.getLogger(Constants.PUMPBTCOMM); private static Logger log = LoggerFactory.getLogger(L.PUMPBTCOMM);
private InputStream mInputStream = null; private InputStream mInputStream = null;
private OutputStream mOutputStream = null; private OutputStream mOutputStream = null;
@ -72,7 +71,7 @@ public class SerialIOThread extends AbstractSerialIOThread {
message = MessageHashTable.findMessage(command); message = MessageHashTable.findMessage(command);
} }
if (Config.logPumpBtComm) if (L.isEnabled(L.PUMPBTCOMM))
log.debug("<<<<< " + message.getMessageName() + " " + message.toHexString(extractedBuff)); log.debug("<<<<< " + message.getMessageName() + " " + message.toHexString(extractedBuff));
// process the message content // process the message content
@ -148,7 +147,7 @@ public class SerialIOThread extends AbstractSerialIOThread {
processedMessage = message; processedMessage = message;
byte[] messageBytes = message.getRawMessageBytes(); byte[] messageBytes = message.getRawMessageBytes();
if (Config.logPumpBtComm) if (L.isEnabled(L.PUMPBTCOMM))
log.debug(">>>>> " + message.getMessageName() + " " + message.toHexString(messageBytes)); log.debug(">>>>> " + message.getMessageName() + " " + message.toHexString(messageBytes));
try { try {
@ -170,7 +169,7 @@ public class SerialIOThread extends AbstractSerialIOThread {
log.warn("Reply not received " + message.getMessageName()); log.warn("Reply not received " + message.getMessageName());
if (message.getCommand() == 0xF0F1) { if (message.getCommand() == 0xF0F1) {
DanaRPump.getInstance().isNewPump = false; DanaRPump.getInstance().isNewPump = false;
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("Old firmware detected"); log.debug("Old firmware detected");
} }
} }
@ -182,28 +181,28 @@ public class SerialIOThread extends AbstractSerialIOThread {
try { try {
mInputStream.close(); mInputStream.close();
} catch (Exception e) { } catch (Exception e) {
if (Config.logPumpBtComm) if (L.isEnabled(L.PUMPBTCOMM))
log.debug(e.getMessage()); log.debug(e.getMessage());
} }
try { try {
mOutputStream.close(); mOutputStream.close();
} catch (Exception e) { } catch (Exception e) {
if (Config.logPumpBtComm) if (L.isEnabled(L.PUMPBTCOMM))
log.debug(e.getMessage()); log.debug(e.getMessage());
} }
try { try {
mRfCommSocket.close(); mRfCommSocket.close();
} catch (Exception e) { } catch (Exception e) {
if (Config.logPumpBtComm) if (L.isEnabled(L.PUMPBTCOMM))
log.debug(e.getMessage()); log.debug(e.getMessage());
} }
try { try {
System.runFinalization(); System.runFinalization();
} catch (Exception e) { } catch (Exception e) {
if (Config.logPumpBtComm) if (L.isEnabled(L.PUMPBTCOMM))
log.debug(e.getMessage()); log.debug(e.getMessage());
} }
if (Config.logPumpBtComm) if (L.isEnabled(L.PUMPBTCOMM))
log.debug("Disconnected: " + reason); log.debug("Disconnected: " + reason);
} }

View file

@ -24,7 +24,6 @@ import org.slf4j.LoggerFactory;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
@ -32,6 +31,7 @@ import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.db.DanaRHistoryRecord; import info.nightscout.androidaps.db.DanaRHistoryRecord;
import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes; import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes;
import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRSyncStatus; import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRSyncStatus;
@ -43,7 +43,7 @@ import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.ToastUtils; import info.nightscout.utils.ToastUtils;
public class DanaRHistoryActivity extends Activity { public class DanaRHistoryActivity extends Activity {
private static Logger log = LoggerFactory.getLogger(Constants.PUMP); private static Logger log = LoggerFactory.getLogger(L.PUMP);
private Handler mHandler; private Handler mHandler;
@ -349,7 +349,7 @@ public class DanaRHistoryActivity extends Activity {
@Subscribe @Subscribe
public void onStatusEvent(final EventDanaRSyncStatus s) { public void onStatusEvent(final EventDanaRSyncStatus s) {
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("EventDanaRSyncStatus: " + s.message); log.debug("EventDanaRSyncStatus: " + s.message);
runOnUiThread( runOnUiThread(
() -> statusView.setText(s.message)); () -> statusView.setText(s.message));

View file

@ -8,13 +8,12 @@ import org.slf4j.LoggerFactory;
import java.util.Calendar; import java.util.Calendar;
import java.util.List; import java.util.List;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.db.CareportalEvent; import info.nightscout.androidaps.db.CareportalEvent;
import info.nightscout.androidaps.db.DanaRHistoryRecord; 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.comm.RecordTypes;
import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRSyncStatus; import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRSyncStatus;
import info.nightscout.utils.DateUtil; import info.nightscout.utils.DateUtil;
@ -25,7 +24,7 @@ import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
*/ */
public class DanaRNSHistorySync { public class DanaRNSHistorySync {
private static Logger log = LoggerFactory.getLogger(Constants.PUMP); private static Logger log = LoggerFactory.getLogger(L.PUMP);
private List<DanaRHistoryRecord> historyRecords; private List<DanaRHistoryRecord> historyRecords;
public final static int SYNC_BOLUS = 0b00000001; public final static int SYNC_BOLUS = 0b00000001;
@ -50,7 +49,7 @@ public class DanaRNSHistorySync {
long records = historyRecords.size(); long records = historyRecords.size();
long processing = 0; long processing = 0;
long uploaded = 0; long uploaded = 0;
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("Database contains " + records + " records"); log.debug("Database contains " + records + " records");
EventDanaRSyncStatus ev = new EventDanaRSyncStatus(); EventDanaRSyncStatus ev = new EventDanaRSyncStatus();
for (DanaRHistoryRecord record : historyRecords) { for (DanaRHistoryRecord record : historyRecords) {
@ -64,7 +63,7 @@ public class DanaRNSHistorySync {
if ((what & SYNC_BOLUS) == 0) break; if ((what & SYNC_BOLUS) == 0) break;
switch (record.bolusType) { switch (record.bolusType) {
case "S": case "S":
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("Syncing standard bolus record " + record.recordValue + "U " + DateUtil.toISOString(record.recordDate)); log.debug("Syncing standard bolus record " + record.recordValue + "U " + DateUtil.toISOString(record.recordDate));
nsrec.put(DANARSIGNATURE, record.bytes); nsrec.put(DANARSIGNATURE, record.bytes);
nsrec.put("eventType", "Meal Bolus"); nsrec.put("eventType", "Meal Bolus");
@ -77,7 +76,7 @@ public class DanaRNSHistorySync {
break; break;
case "E": case "E":
if (record.recordDuration > 0) { if (record.recordDuration > 0) {
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("Syncing extended bolus record " + record.recordValue + "U " + DateUtil.toISOString(record.recordDate)); log.debug("Syncing extended bolus record " + record.recordValue + "U " + DateUtil.toISOString(record.recordDate));
nsrec.put(DANARSIGNATURE, record.bytes); nsrec.put(DANARSIGNATURE, record.bytes);
nsrec.put("eventType", CareportalEvent.COMBOBOLUS); nsrec.put("eventType", CareportalEvent.COMBOBOLUS);
@ -94,12 +93,12 @@ public class DanaRNSHistorySync {
uploaded++; uploaded++;
ev.message += MainApp.gs(R.string.danar_ebolus); ev.message += MainApp.gs(R.string.danar_ebolus);
} else { } else {
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("NOT Syncing extended bolus record " + record.recordValue + "U " + DateUtil.toISOString(record.recordDate) + " zero duration"); log.debug("NOT Syncing extended bolus record " + record.recordValue + "U " + DateUtil.toISOString(record.recordDate) + " zero duration");
} }
break; break;
case "DS": case "DS":
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("Syncing dual(S) bolus record " + record.recordValue + "U " + DateUtil.toISOString(record.recordDate)); log.debug("Syncing dual(S) bolus record " + record.recordValue + "U " + DateUtil.toISOString(record.recordDate));
nsrec.put(DANARSIGNATURE, record.bytes); nsrec.put(DANARSIGNATURE, record.bytes);
nsrec.put("eventType", CareportalEvent.COMBOBOLUS); nsrec.put("eventType", CareportalEvent.COMBOBOLUS);
@ -113,7 +112,7 @@ public class DanaRNSHistorySync {
ev.message += MainApp.gs(R.string.danar_dsbolus); ev.message += MainApp.gs(R.string.danar_dsbolus);
break; break;
case "DE": case "DE":
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("Syncing dual(E) bolus record " + record.recordValue + "U " + DateUtil.toISOString(record.recordDate)); log.debug("Syncing dual(E) bolus record " + record.recordValue + "U " + DateUtil.toISOString(record.recordDate));
nsrec.put(DANARSIGNATURE, record.bytes); nsrec.put(DANARSIGNATURE, record.bytes);
nsrec.put("eventType", CareportalEvent.COMBOBOLUS); nsrec.put("eventType", CareportalEvent.COMBOBOLUS);
@ -136,7 +135,7 @@ public class DanaRNSHistorySync {
break; break;
case RecordTypes.RECORD_TYPE_ERROR: case RecordTypes.RECORD_TYPE_ERROR:
if ((what & SYNC_ERROR) == 0) break; if ((what & SYNC_ERROR) == 0) break;
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("Syncing error record " + DateUtil.toISOString(record.recordDate)); log.debug("Syncing error record " + DateUtil.toISOString(record.recordDate));
nsrec.put(DANARSIGNATURE, record.bytes); nsrec.put(DANARSIGNATURE, record.bytes);
nsrec.put("eventType", "Note"); nsrec.put("eventType", "Note");
@ -149,7 +148,7 @@ public class DanaRNSHistorySync {
break; break;
case RecordTypes.RECORD_TYPE_REFILL: case RecordTypes.RECORD_TYPE_REFILL:
if ((what & SYNC_REFILL) == 0) break; if ((what & SYNC_REFILL) == 0) break;
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("Syncing refill record " + record.recordValue + " " + DateUtil.toISOString(record.recordDate)); log.debug("Syncing refill record " + record.recordValue + " " + DateUtil.toISOString(record.recordDate));
nsrec.put(DANARSIGNATURE, record.bytes); nsrec.put(DANARSIGNATURE, record.bytes);
nsrec.put("eventType", "Insulin Change"); nsrec.put("eventType", "Insulin Change");
@ -162,7 +161,7 @@ public class DanaRNSHistorySync {
break; break;
case RecordTypes.RECORD_TYPE_BASALHOUR: case RecordTypes.RECORD_TYPE_BASALHOUR:
if ((what & SYNC_BASALHOURS) == 0) break; if ((what & SYNC_BASALHOURS) == 0) break;
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("Syncing basal hour record " + record.recordValue + " " + DateUtil.toISOString(record.recordDate)); log.debug("Syncing basal hour record " + record.recordValue + " " + DateUtil.toISOString(record.recordDate));
nsrec.put(DANARSIGNATURE, record.bytes); nsrec.put(DANARSIGNATURE, record.bytes);
nsrec.put("eventType", CareportalEvent.TEMPBASAL); nsrec.put("eventType", CareportalEvent.TEMPBASAL);
@ -179,7 +178,7 @@ public class DanaRNSHistorySync {
break; break;
case RecordTypes.RECORD_TYPE_GLUCOSE: case RecordTypes.RECORD_TYPE_GLUCOSE:
if ((what & SYNC_GLUCOSE) == 0) break; if ((what & SYNC_GLUCOSE) == 0) break;
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("Syncing glucose record " + record.recordValue + " " + DateUtil.toISOString(record.recordDate)); log.debug("Syncing glucose record " + record.recordValue + " " + DateUtil.toISOString(record.recordDate));
nsrec.put(DANARSIGNATURE, record.bytes); nsrec.put(DANARSIGNATURE, record.bytes);
nsrec.put("eventType", "BG Check"); nsrec.put("eventType", "BG Check");
@ -193,7 +192,7 @@ public class DanaRNSHistorySync {
break; break;
case RecordTypes.RECORD_TYPE_CARBO: case RecordTypes.RECORD_TYPE_CARBO:
if ((what & SYNC_CARBO) == 0) break; if ((what & SYNC_CARBO) == 0) break;
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("Syncing carbo record " + record.recordValue + "g " + DateUtil.toISOString(record.recordDate)); log.debug("Syncing carbo record " + record.recordValue + "g " + DateUtil.toISOString(record.recordDate));
nsrec.put(DANARSIGNATURE, record.bytes); nsrec.put(DANARSIGNATURE, record.bytes);
nsrec.put("eventType", "Meal Bolus"); nsrec.put("eventType", "Meal Bolus");
@ -206,7 +205,7 @@ public class DanaRNSHistorySync {
break; break;
case RecordTypes.RECORD_TYPE_ALARM: case RecordTypes.RECORD_TYPE_ALARM:
if ((what & SYNC_ALARM) == 0) break; if ((what & SYNC_ALARM) == 0) break;
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("Syncing alarm record " + record.recordAlarm + " " + DateUtil.toISOString(record.recordDate)); log.debug("Syncing alarm record " + record.recordAlarm + " " + DateUtil.toISOString(record.recordDate));
nsrec.put(DANARSIGNATURE, record.bytes); nsrec.put(DANARSIGNATURE, record.bytes);
nsrec.put("eventType", "Note"); nsrec.put("eventType", "Note");

View file

@ -14,12 +14,12 @@ import org.slf4j.LoggerFactory;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.events.EventInitializationChanged; import info.nightscout.androidaps.events.EventInitializationChanged;
import info.nightscout.androidaps.interfaces.PluginType; 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.DanaRPlugin;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaRS.DanaRSPlugin; import info.nightscout.androidaps.plugins.PumpDanaRS.DanaRSPlugin;
@ -31,7 +31,7 @@ import info.nightscout.utils.NumberPicker;
*/ */
public class DanaRUserOptionsActivity extends Activity { public class DanaRUserOptionsActivity extends Activity {
private static Logger log = LoggerFactory.getLogger(Constants.PUMP); private static Logger log = LoggerFactory.getLogger(L.PUMP);
Switch timeFormat; Switch timeFormat;
Switch buttonScroll; Switch buttonScroll;
@ -86,7 +86,7 @@ public class DanaRUserOptionsActivity extends Activity {
DanaRPump pump = DanaRPump.getInstance(); DanaRPump pump = DanaRPump.getInstance();
//used for debugging //used for debugging
if (Config.logPump) if (L.isEnabled(L.PUMP))
log.debug("UserOptionsLoaded:" + (System.currentTimeMillis() - pump.lastConnection) / 1000 + " s ago" log.debug("UserOptionsLoaded:" + (System.currentTimeMillis() - pump.lastConnection) / 1000 + " s ago"
+ "\ntimeDisplayType:" + pump.timeDisplayType + "\ntimeDisplayType:" + pump.timeDisplayType
+ "\nbuttonScroll:" + pump.buttonScrollOnOff + "\nbuttonScroll:" + pump.buttonScrollOnOff

View file

@ -12,8 +12,7 @@ import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.Constants;
import info.nightscout.utils.CRC; import info.nightscout.utils.CRC;
/* /*
@ -23,7 +22,7 @@ import info.nightscout.utils.CRC;
*/ */
public class MessageBase { public class MessageBase {
private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
protected byte[] buffer = new byte[512]; protected byte[] buffer = new byte[512];
private int position = 6; private int position = 6;
@ -96,7 +95,7 @@ public class MessageBase {
} }
public void handleMessage(byte[] bytes) { public void handleMessage(byte[] bytes) {
if (Config.logPumpComm) { if (L.isEnabled(L.PUMPCOMM)) {
if (bytes.length > 6) { if (bytes.length > 6) {
int command = (bytes[5] & 0xFF) | ((bytes[4] << 8) & 0xFF00); int command = (bytes[5] & 0xFF) | ((bytes[4] << 8) & 0xFF00);
log.debug("UNPROCESSED MSG: " + getMessageName() + " Command: " + String.format("%04X", command) + " Data: " + toHexString(bytes)); log.debug("UNPROCESSED MSG: " + getMessageName() + " Command: " + String.format("%04X", command) + " Data: " + toHexString(bytes));

View file

@ -5,13 +5,13 @@ import org.slf4j.LoggerFactory;
import java.util.HashMap; import java.util.HashMap;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.logging.L;
/** /**
* Created by mike on 28.05.2016. * Created by mike on 28.05.2016.
*/ */
public class MessageOriginalNames { public class MessageOriginalNames {
private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
private static HashMap<Integer, String> messageNames; private static HashMap<Integer, String> messageNames;

View file

@ -3,15 +3,14 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress; import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
import info.nightscout.androidaps.plugins.Treatments.Treatment; import info.nightscout.androidaps.plugins.Treatments.Treatment;
public class MsgBolusProgress extends MessageBase { public class MsgBolusProgress extends MessageBase {
private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
private static Treatment t; private static Treatment t;
private static double amount; private static double amount;
@ -28,7 +27,7 @@ public class MsgBolusProgress extends MessageBase {
this.amount = amount; this.amount = amount;
this.t = t; this.t = t;
lastReceive = System.currentTimeMillis(); lastReceive = System.currentTimeMillis();
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("New message: amount: " + amount + " treatment: " + t.toString()); log.debug("New message: amount: " + amount + " treatment: " + t.toString());
} }
@ -43,7 +42,7 @@ public class MsgBolusProgress extends MessageBase {
bolusingEvent.t = t; bolusingEvent.t = t;
bolusingEvent.percent = Math.min((int) (done / amount * 100), 100); bolusingEvent.percent = Math.min((int) (done / amount * 100), 100);
if (Config.logPumpComm) { if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Bolus remaining: " + progress + " delivered: " + done); log.debug("Bolus remaining: " + progress + " delivered: " + done);
} }

View file

@ -3,13 +3,12 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.interfaces.Constraint; import info.nightscout.androidaps.interfaces.Constraint;
import info.nightscout.androidaps.logging.L;
public class MsgBolusStart extends MessageBase { public class MsgBolusStart extends MessageBase {
private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public static int errorCode; public static int errorCode;
@ -25,7 +24,7 @@ public class MsgBolusStart extends MessageBase {
AddParamInt((int) (amount * 100)); AddParamInt((int) (amount * 100));
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("Bolus start : " + amount); log.debug("Bolus start : " + amount);
} }
@ -34,10 +33,10 @@ public class MsgBolusStart extends MessageBase {
errorCode = intFromBuff(bytes, 0, 1); errorCode = intFromBuff(bytes, 0, 1);
if (errorCode != 2) { if (errorCode != 2) {
failed = true; failed = true;
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("Messsage response: " + errorCode + " FAILED!!"); log.debug("Messsage response: " + errorCode + " FAILED!!");
} else { } else {
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("Messsage response: " + errorCode + " OK"); log.debug("Messsage response: " + errorCode + " OK");
} }
} }

View file

@ -3,13 +3,12 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.interfaces.Constraint; import info.nightscout.androidaps.interfaces.Constraint;
import info.nightscout.androidaps.logging.L;
public class MsgBolusStartWithSpeed extends MessageBase { public class MsgBolusStartWithSpeed extends MessageBase {
private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public static int errorCode; public static int errorCode;
@ -26,7 +25,7 @@ public class MsgBolusStartWithSpeed extends MessageBase {
AddParamInt((int) (amount * 100)); AddParamInt((int) (amount * 100));
AddParamByte((byte) speed); AddParamByte((byte) speed);
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("Bolus start : " + amount + " speed: " + speed); log.debug("Bolus start : " + amount + " speed: " + speed);
} }
@ -35,10 +34,10 @@ public class MsgBolusStartWithSpeed extends MessageBase {
errorCode = intFromBuff(bytes, 0, 1); errorCode = intFromBuff(bytes, 0, 1);
if (errorCode != 2) { if (errorCode != 2) {
failed = true; failed = true;
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("Messsage response: " + errorCode + " FAILED!!"); log.debug("Messsage response: " + errorCode + " FAILED!!");
} else { } else {
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("Messsage response: " + errorCode + " OK"); log.debug("Messsage response: " + errorCode + " OK");
} }
} }

View file

@ -3,15 +3,14 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress; import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
import info.nightscout.androidaps.plugins.Treatments.Treatment; import info.nightscout.androidaps.plugins.Treatments.Treatment;
public class MsgBolusStop extends MessageBase { public class MsgBolusStop extends MessageBase {
private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
private static Treatment t; private static Treatment t;
private static Double amount; private static Double amount;
@ -28,13 +27,13 @@ public class MsgBolusStop extends MessageBase {
this.t = t; this.t = t;
this.amount = amount; this.amount = amount;
forced = false; forced = false;
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("Bolus stop: amount: " + amount + " treatment: " + t.toString()); log.debug("Bolus stop: amount: " + amount + " treatment: " + t.toString());
} }
@Override @Override
public void handleMessage(byte[] bytes) { public void handleMessage(byte[] bytes) {
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("Messsage received"); log.debug("Messsage received");
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance(); EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();
stopped = true; stopped = true;

View file

@ -3,9 +3,8 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
@ -13,11 +12,11 @@ import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
* Created by mike on 30.06.2016. * Created by mike on 30.06.2016.
*/ */
public class MsgCheckValue extends MessageBase { public class MsgCheckValue extends MessageBase {
private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgCheckValue() { public MsgCheckValue() {
SetCommand(0xF0F1); SetCommand(0xF0F1);
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("New message"); log.debug("New message");
} }
@ -26,7 +25,7 @@ public class MsgCheckValue extends MessageBase {
DanaRPump pump = DanaRPump.getInstance(); DanaRPump pump = DanaRPump.getInstance();
pump.isNewPump = true; pump.isNewPump = true;
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("New firmware confirmed"); log.debug("New firmware confirmed");
pump.model = intFromBuff(bytes, 0, 1); pump.model = intFromBuff(bytes, 0, 1);
@ -37,7 +36,7 @@ public class MsgCheckValue extends MessageBase {
log.debug("Wrong model selected"); log.debug("Wrong model selected");
} }
if (Config.logPumpComm) { if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Model: " + String.format("%02X ", pump.model)); log.debug("Model: " + String.format("%02X ", pump.model));
log.debug("Protocol: " + String.format("%02X ", pump.protocol)); log.debug("Protocol: " + String.format("%02X ", pump.protocol));
log.debug("Product Code: " + String.format("%02X ", pump.productCode)); log.debug("Product Code: " + String.format("%02X ", pump.productCode));

View file

@ -3,19 +3,18 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress; import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload; import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
public class MsgError extends MessageBase { public class MsgError extends MessageBase {
private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgError() { public MsgError() {
SetCommand(0x0601); SetCommand(0x0601);
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("New message"); log.debug("New message");
} }
@ -50,7 +49,7 @@ public class MsgError extends MessageBase {
bolusingEvent.status = errorString; bolusingEvent.status = errorString;
MainApp.bus().post(bolusingEvent); MainApp.bus().post(bolusingEvent);
} }
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("Error detected: " + errorString); log.debug("Error detected: " + errorString);
NSUpload.uploadError(errorString); NSUpload.uploadError(errorString);
} }

View file

@ -3,17 +3,16 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.Constants;
/** /**
* Created by mike on 20.07.2016. * Created by mike on 20.07.2016.
*/ */
public class MsgHistoryAlarm extends MsgHistoryAll { public class MsgHistoryAlarm extends MsgHistoryAll {
private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgHistoryAlarm() { public MsgHistoryAlarm() {
SetCommand(0x3105); SetCommand(0x3105);
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("New message"); log.debug("New message");
} }
// Handle message taken from MsgHistoryAll // Handle message taken from MsgHistoryAll

View file

@ -5,19 +5,18 @@ import org.slf4j.LoggerFactory;
import java.util.Date; import java.util.Date;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.db.DanaRHistoryRecord; import info.nightscout.androidaps.db.DanaRHistoryRecord;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRSyncStatus; import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRSyncStatus;
import info.nightscout.utils.DateUtil; import info.nightscout.utils.DateUtil;
public class MsgHistoryAll extends MessageBase { public class MsgHistoryAll extends MessageBase {
private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgHistoryAll() { public MsgHistoryAll() {
SetCommand(0x41F2); SetCommand(0x41F2);
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("New message"); log.debug("New message");
} }

View file

@ -3,24 +3,23 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.Constants;
public class MsgHistoryAllDone extends MessageBase { public class MsgHistoryAllDone extends MessageBase {
private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public static boolean received = false; public static boolean received = false;
public MsgHistoryAllDone() { public MsgHistoryAllDone() {
SetCommand(0x41F1); SetCommand(0x41F1);
received = false; received = false;
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("New message"); log.debug("New message");
} }
@Override @Override
public void handleMessage(byte[] bytes) { public void handleMessage(byte[] bytes) {
received = true; received = true;
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("History all done received"); log.debug("History all done received");
} }
} }

View file

@ -3,17 +3,16 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.Constants;
/** /**
* Created by mike on 20.07.2016. * Created by mike on 20.07.2016.
*/ */
public class MsgHistoryBasalHour extends MsgHistoryAll { public class MsgHistoryBasalHour extends MsgHistoryAll {
private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgHistoryBasalHour() { public MsgHistoryBasalHour() {
SetCommand(0x310A); SetCommand(0x310A);
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("New message"); log.debug("New message");
} }
// Handle message taken from MsgHistoryAll // Handle message taken from MsgHistoryAll

View file

@ -3,18 +3,17 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.Constants;
/** /**
* Created by mike on 20.07.2016. * Created by mike on 20.07.2016.
*/ */
public class MsgHistoryBolus extends MsgHistoryAll { public class MsgHistoryBolus extends MsgHistoryAll {
private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgHistoryBolus() { public MsgHistoryBolus() {
SetCommand(0x3101); SetCommand(0x3101);
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("New message"); log.debug("New message");
} }
// Handle message taken from MsgHistoryAll // Handle message taken from MsgHistoryAll

View file

@ -3,17 +3,16 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.Constants;
/** /**
* Created by mike on 20.07.2016. * Created by mike on 20.07.2016.
*/ */
public class MsgHistoryCarbo extends MsgHistoryAll { public class MsgHistoryCarbo extends MsgHistoryAll {
private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgHistoryCarbo() { public MsgHistoryCarbo() {
SetCommand(0x3107); SetCommand(0x3107);
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("New message"); log.debug("New message");
} }
// Handle message taken from MsgHistoryAll // Handle message taken from MsgHistoryAll

View file

@ -3,17 +3,16 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.Constants;
/** /**
* Created by mike on 20.07.2016. * Created by mike on 20.07.2016.
*/ */
public class MsgHistoryDailyInsulin extends MsgHistoryAll { public class MsgHistoryDailyInsulin extends MsgHistoryAll {
private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgHistoryDailyInsulin() { public MsgHistoryDailyInsulin() {
SetCommand(0x3102); SetCommand(0x3102);
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("New message"); log.debug("New message");
} }
// Handle message taken from MsgHistoryAll // Handle message taken from MsgHistoryAll

View file

@ -3,27 +3,26 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.Constants;
/** /**
* Created by mike on 20.07.2016. * Created by mike on 20.07.2016.
*/ */
public class MsgHistoryDone extends MessageBase { public class MsgHistoryDone extends MessageBase {
private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public static boolean received = false; public static boolean received = false;
public MsgHistoryDone() { public MsgHistoryDone() {
SetCommand(0x31F1); SetCommand(0x31F1);
received = false; received = false;
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("New message"); log.debug("New message");
} }
@Override @Override
public void handleMessage(byte[] bytes) { public void handleMessage(byte[] bytes) {
received = true; received = true;
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("History done received"); log.debug("History done received");
} }

View file

@ -3,18 +3,17 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.Constants;
/** /**
* Created by mike on 20.07.2016. * Created by mike on 20.07.2016.
*/ */
public class MsgHistoryError extends MsgHistoryAll { public class MsgHistoryError extends MsgHistoryAll {
private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgHistoryError() { public MsgHistoryError() {
SetCommand(0x3106); SetCommand(0x3106);
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("New message"); log.debug("New message");
} }
// Handle message taken from MsgHistoryAll // Handle message taken from MsgHistoryAll

View file

@ -3,18 +3,17 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.Constants;
/** /**
* Created by mike on 20.07.2016. * Created by mike on 20.07.2016.
*/ */
public class MsgHistoryGlucose extends MsgHistoryAll { public class MsgHistoryGlucose extends MsgHistoryAll {
private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgHistoryGlucose() { public MsgHistoryGlucose() {
SetCommand(0x3104); SetCommand(0x3104);
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("New message"); log.debug("New message");
} }
// Handle message taken from MsgHistoryAll // Handle message taken from MsgHistoryAll

View file

@ -3,18 +3,17 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.Constants;
/** /**
* Created by mike on 20.07.2016. * Created by mike on 20.07.2016.
*/ */
public class MsgHistoryNew extends MsgHistoryAll { public class MsgHistoryNew extends MsgHistoryAll {
private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgHistoryNew() { public MsgHistoryNew() {
SetCommand(0x42F2); SetCommand(0x42F2);
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("New message"); log.debug("New message");
} }
// Handle message taken from MsgHistoryAll // Handle message taken from MsgHistoryAll

View file

@ -3,27 +3,26 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.Constants;
/** /**
* Created by mike on 20.07.2016. * Created by mike on 20.07.2016.
*/ */
public class MsgHistoryNewDone extends MessageBase { public class MsgHistoryNewDone extends MessageBase {
private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public static boolean received = false; public static boolean received = false;
public MsgHistoryNewDone() { public MsgHistoryNewDone() {
SetCommand(0x42F1); SetCommand(0x42F1);
received = false; received = false;
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("New message"); log.debug("New message");
} }
@Override @Override
public void handleMessage(byte[] bytes) { public void handleMessage(byte[] bytes) {
received = true; received = true;
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("History new done received"); log.debug("History new done received");
} }
} }

View file

@ -3,18 +3,17 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.Constants;
/** /**
* Created by mike on 20.07.2016. * Created by mike on 20.07.2016.
*/ */
public class MsgHistoryRefill extends MsgHistoryAll { public class MsgHistoryRefill extends MsgHistoryAll {
private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgHistoryRefill() { public MsgHistoryRefill() {
SetCommand(0x3108); SetCommand(0x3108);
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("New message"); log.debug("New message");
} }
// Handle message taken from MsgHistoryAll // Handle message taken from MsgHistoryAll

View file

@ -3,18 +3,17 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.Constants;
/** /**
* Created by mike on 20.07.2016. * Created by mike on 20.07.2016.
*/ */
public class MsgHistorySuspend extends MsgHistoryAll { public class MsgHistorySuspend extends MsgHistoryAll {
private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgHistorySuspend() { public MsgHistorySuspend() {
SetCommand(0x3109); SetCommand(0x3109);
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("New message"); log.debug("New message");
} }
// Handle message taken from MsgHistoryAll // Handle message taken from MsgHistoryAll

View file

@ -3,16 +3,15 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
public class MsgInitConnStatusBasic extends MessageBase { public class MsgInitConnStatusBasic extends MessageBase {
private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgInitConnStatusBasic() { public MsgInitConnStatusBasic() {
SetCommand(0x0303); SetCommand(0x0303);
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("New message"); log.debug("New message");
} }
@ -42,7 +41,7 @@ public class MsgInitConnStatusBasic extends MessageBase {
boolean deliveryStepBolus = (bolusConfig & DanaRPump.DELIVERY_STEP_BOLUS) != 0; boolean deliveryStepBolus = (bolusConfig & DanaRPump.DELIVERY_STEP_BOLUS) != 0;
boolean deliveryBasal = (bolusConfig & DanaRPump.DELIVERY_BASAL) != 0; boolean deliveryBasal = (bolusConfig & DanaRPump.DELIVERY_BASAL) != 0;
boolean deliveryExtBolus = (bolusConfig & DanaRPump.DELIVERY_EXT_BOLUS) != 0; boolean deliveryExtBolus = (bolusConfig & DanaRPump.DELIVERY_EXT_BOLUS) != 0;
if (Config.logPumpComm) { if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Delivery prime: " + deliveryPrime); log.debug("Delivery prime: " + deliveryPrime);
log.debug("Delivery step bolus: " + deliveryStepBolus); log.debug("Delivery step bolus: " + deliveryStepBolus);
log.debug("Delivery basal: " + deliveryBasal); log.debug("Delivery basal: " + deliveryBasal);
@ -52,7 +51,7 @@ public class MsgInitConnStatusBasic extends MessageBase {
log.error("Unhadled exception", e); log.error("Unhadled exception", e);
} }
if (Config.logPumpComm) { if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Pump suspended: " + pump.pumpSuspended); log.debug("Pump suspended: " + pump.pumpSuspended);
log.debug("Calculator enabled: " + pump.calculatorEnabled); log.debug("Calculator enabled: " + pump.calculatorEnabled);
log.debug("Daily total units: " + pump.dailyTotalUnits); log.debug("Daily total units: " + pump.dailyTotalUnits);

View file

@ -3,10 +3,9 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.Overview.notifications.Notification; import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
@ -16,11 +15,11 @@ import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
* Created by mike on 28.05.2016. * Created by mike on 28.05.2016.
*/ */
public class MsgInitConnStatusBolus extends MessageBase { public class MsgInitConnStatusBolus extends MessageBase {
private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgInitConnStatusBolus() { public MsgInitConnStatusBolus() {
SetCommand(0x0302); SetCommand(0x0302);
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("New message"); log.debug("New message");
} }
@ -37,7 +36,7 @@ public class MsgInitConnStatusBolus extends MessageBase {
pump.maxBolus = intFromBuff(bytes, 2, 2) / 100d; pump.maxBolus = intFromBuff(bytes, 2, 2) / 100d;
//int bolusRate = intFromBuff(bytes, 4, 8); //int bolusRate = intFromBuff(bytes, 4, 8);
if (Config.logPumpComm) { if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Is Extended bolus enabled: " + pump.isExtendedBolusEnabled); log.debug("Is Extended bolus enabled: " + pump.isExtendedBolusEnabled);
log.debug("Bolus increment: " + pump.bolusStep); log.debug("Bolus increment: " + pump.bolusStep);
log.debug("Bolus max: " + pump.maxBolus); log.debug("Bolus max: " + pump.maxBolus);

View file

@ -3,19 +3,18 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
/** /**
* Created by mike on 28.05.2016. * Created by mike on 28.05.2016.
*/ */
public class MsgInitConnStatusOption extends MessageBase { public class MsgInitConnStatusOption extends MessageBase {
private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgInitConnStatusOption() { public MsgInitConnStatusOption() {
SetCommand(0x0304); SetCommand(0x0304);
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("New message"); log.debug("New message");
} }
@ -32,7 +31,7 @@ public class MsgInitConnStatusOption extends MessageBase {
//int none = intFromBuff(bytes, 8, 1); //int none = intFromBuff(bytes, 8, 1);
if (bytes.length >= 21) { if (bytes.length >= 21) {
DanaRPump.getInstance().password = intFromBuff(bytes, 9, 2) ^ 0x3463; DanaRPump.getInstance().password = intFromBuff(bytes, 9, 2) ^ 0x3463;
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("Pump password: " + DanaRPump.getInstance().password); log.debug("Pump password: " + DanaRPump.getInstance().password);
} }
} }

View file

@ -5,12 +5,11 @@ import org.slf4j.LoggerFactory;
import java.util.Date; import java.util.Date;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.events.EventRefreshGui; import info.nightscout.androidaps.events.EventRefreshGui;
import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.Overview.notifications.Notification; import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
@ -19,11 +18,11 @@ import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin; import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
public class MsgInitConnStatusTime extends MessageBase { public class MsgInitConnStatusTime extends MessageBase {
private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgInitConnStatusTime() { public MsgInitConnStatusTime() {
SetCommand(0x0301); SetCommand(0x0301);
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("New message"); log.debug("New message");
} }
@ -56,7 +55,7 @@ public class MsgInitConnStatusTime extends MessageBase {
Date time = dateTimeSecFromBuff(bytes, 0); Date time = dateTimeSecFromBuff(bytes, 0);
int versionCode = intFromBuff(bytes, 6, 1); int versionCode = intFromBuff(bytes, 6, 1);
if (Config.logPumpComm) { if (L.isEnabled(L.PUMPCOMM)) {
log.debug("Pump time: " + time); log.debug("Pump time: " + time);
log.debug("Version code: " + versionCode); log.debug("Version code: " + versionCode);
} }

View file

@ -3,21 +3,20 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.Constants;
public class MsgPCCommStart extends MessageBase { public class MsgPCCommStart extends MessageBase {
private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgPCCommStart() { public MsgPCCommStart() {
SetCommand(0x3001); SetCommand(0x3001);
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("New message"); log.debug("New message");
} }
@Override @Override
public void handleMessage(byte[] bytes) { public void handleMessage(byte[] bytes) {
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("PC comm start received"); log.debug("PC comm start received");
} }
} }

View file

@ -3,20 +3,19 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.Constants;
public class MsgPCCommStop extends MessageBase { public class MsgPCCommStop extends MessageBase {
private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgPCCommStop() { public MsgPCCommStop() {
SetCommand(0x3002); SetCommand(0x3002);
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("New message"); log.debug("New message");
} }
@Override @Override
public void handleMessage(byte[] bytes) { public void handleMessage(byte[] bytes) {
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("PC comm stop received"); log.debug("PC comm stop received");
} }
} }

View file

@ -3,15 +3,14 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.Constants;
public class MsgSetActivateBasalProfile extends MessageBase { public class MsgSetActivateBasalProfile extends MessageBase {
private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgSetActivateBasalProfile() { public MsgSetActivateBasalProfile() {
SetCommand(0x330C); SetCommand(0x330C);
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("New message"); log.debug("New message");
} }
@ -19,7 +18,7 @@ public class MsgSetActivateBasalProfile extends MessageBase {
public MsgSetActivateBasalProfile(byte index) { public MsgSetActivateBasalProfile(byte index) {
this(); this();
AddParamByte(index); AddParamByte(index);
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("Activate basal profile: " + index); log.debug("Activate basal profile: " + index);
} }
@ -28,10 +27,10 @@ public class MsgSetActivateBasalProfile extends MessageBase {
int result = intFromBuff(bytes, 0, 1); int result = intFromBuff(bytes, 0, 1);
if (result != 1) { if (result != 1) {
failed = true; failed = true;
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("Activate basal profile result: " + result + " FAILED!!!"); log.debug("Activate basal profile result: " + result + " FAILED!!!");
} else { } else {
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("Activate basal profile result: " + result); log.debug("Activate basal profile result: " + result);
} }
} }

View file

@ -3,19 +3,18 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; 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.events.EventNewNotification;
import info.nightscout.androidaps.plugins.Overview.notifications.Notification; import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
public class MsgSetBasalProfile extends MessageBase { public class MsgSetBasalProfile extends MessageBase {
private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgSetBasalProfile() { public MsgSetBasalProfile() {
SetCommand(0x3306); SetCommand(0x3306);
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("New message"); log.debug("New message");
} }
@ -26,7 +25,7 @@ public class MsgSetBasalProfile extends MessageBase {
for (Integer i = 0; i < 24; i++) { for (Integer i = 0; i < 24; i++) {
AddParamInt((int) (values[i] * 100)); AddParamInt((int) (values[i] * 100));
} }
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("Set basal profile: " + index); log.debug("Set basal profile: " + index);
} }
@ -35,12 +34,12 @@ public class MsgSetBasalProfile extends MessageBase {
int result = intFromBuff(bytes, 0, 1); int result = intFromBuff(bytes, 0, 1);
if (result != 1) { if (result != 1) {
failed = true; failed = true;
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("Set basal profile result: " + result + " FAILED!!!"); 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); Notification reportFail = new Notification(Notification.PROFILE_SET_FAILED, MainApp.gs(R.string.profile_set_failed), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(reportFail)); MainApp.bus().post(new EventNewNotification(reportFail));
} else { } else {
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("Set basal profile result: " + result); 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); Notification reportOK = new Notification(Notification.PROFILE_SET_OK, MainApp.gs(R.string.profile_set_ok), Notification.INFO, 60);
MainApp.bus().post(new EventNewNotification(reportOK)); MainApp.bus().post(new EventNewNotification(reportOK));

View file

@ -5,15 +5,14 @@ import org.slf4j.LoggerFactory;
import java.util.Calendar; import java.util.Calendar;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.Constants;
public class MsgSetCarbsEntry extends MessageBase { public class MsgSetCarbsEntry extends MessageBase {
private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgSetCarbsEntry() { public MsgSetCarbsEntry() {
SetCommand(0x0402); SetCommand(0x0402);
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("New message"); log.debug("New message");
} }
@ -30,7 +29,7 @@ public class MsgSetCarbsEntry extends MessageBase {
AddParamByte((byte) (calendar.get(Calendar.SECOND))); AddParamByte((byte) (calendar.get(Calendar.SECOND)));
AddParamByte((byte) 0x43); //?? AddParamByte((byte) 0x43); //??
AddParamInt(amount); AddParamInt(amount);
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("Set carb entry: " + amount + " date " + calendar.getTime().toString()); log.debug("Set carb entry: " + amount + " date " + calendar.getTime().toString());
} }
@ -39,10 +38,10 @@ public class MsgSetCarbsEntry extends MessageBase {
int result = intFromBuff(bytes, 0, 1); int result = intFromBuff(bytes, 0, 1);
if (result != 1) { if (result != 1) {
failed = true; failed = true;
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("Set carb entry result: " + result + " FAILED!!!"); log.debug("Set carb entry result: " + result + " FAILED!!!");
} else { } else {
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("Set carb entry result: " + result); log.debug("Set carb entry result: " + result);
} }
} }

View file

@ -3,17 +3,16 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.interfaces.Constraint; import info.nightscout.androidaps.interfaces.Constraint;
import info.nightscout.androidaps.logging.L;
public class MsgSetExtendedBolusStart extends MessageBase { public class MsgSetExtendedBolusStart extends MessageBase {
private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgSetExtendedBolusStart() { public MsgSetExtendedBolusStart() {
SetCommand(0x0407); SetCommand(0x0407);
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("New message"); log.debug("New message");
} }
@ -27,7 +26,7 @@ public class MsgSetExtendedBolusStart extends MessageBase {
AddParamInt((int) (amount * 100)); AddParamInt((int) (amount * 100));
AddParamByte(halfhours); AddParamByte(halfhours);
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("Set extended bolus start: " + (((int) (amount * 100)) / 100d) + "U halfhours: " + (int) halfhours); log.debug("Set extended bolus start: " + (((int) (amount * 100)) / 100d) + "U halfhours: " + (int) halfhours);
} }
@ -36,10 +35,10 @@ public class MsgSetExtendedBolusStart extends MessageBase {
int result = intFromBuff(bytes, 0, 1); int result = intFromBuff(bytes, 0, 1);
if (result != 1) { if (result != 1) {
failed = true; failed = true;
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("Set extended bolus start result: " + result + " FAILED!!!"); log.debug("Set extended bolus start result: " + result + " FAILED!!!");
} else { } else {
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("Set extended bolus start result: " + result); log.debug("Set extended bolus start result: " + result);
} }
} }

View file

@ -3,15 +3,14 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.Constants;
public class MsgSetExtendedBolusStop extends MessageBase { public class MsgSetExtendedBolusStop extends MessageBase {
private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgSetExtendedBolusStop() { public MsgSetExtendedBolusStop() {
SetCommand(0x0406); SetCommand(0x0406);
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("New message"); log.debug("New message");
} }
@ -20,10 +19,10 @@ public class MsgSetExtendedBolusStop extends MessageBase {
int result = intFromBuff(bytes, 0, 1); int result = intFromBuff(bytes, 0, 1);
if (result != 1) { if (result != 1) {
failed = true; failed = true;
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("Set extended bolus stop result: " + result + " FAILED!!!"); log.debug("Set extended bolus stop result: " + result + " FAILED!!!");
} else { } else {
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("Set extended bolus stop result: " + result); log.debug("Set extended bolus stop result: " + result);
} }
} }

View file

@ -3,15 +3,14 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; 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.notifications.Notification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
public class MsgSetSingleBasalProfile extends MessageBase { public class MsgSetSingleBasalProfile extends MessageBase {
private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgSetSingleBasalProfile() { public MsgSetSingleBasalProfile() {
SetCommand(0x3302); SetCommand(0x3302);
@ -23,7 +22,7 @@ public class MsgSetSingleBasalProfile extends MessageBase {
for (Integer i = 0; i < 24; i++) { for (Integer i = 0; i < 24; i++) {
AddParamInt((int) (values[i] * 100)); AddParamInt((int) (values[i] * 100));
} }
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("New message"); log.debug("New message");
} }
@ -32,12 +31,12 @@ public class MsgSetSingleBasalProfile extends MessageBase {
int result = intFromBuff(bytes, 0, 1); int result = intFromBuff(bytes, 0, 1);
if (result != 1) { if (result != 1) {
failed = true; failed = true;
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("Set basal profile result: " + result + " FAILED!!!"); 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); Notification reportFail = new Notification(Notification.PROFILE_SET_FAILED, MainApp.gs(R.string.profile_set_failed), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(reportFail)); MainApp.bus().post(new EventNewNotification(reportFail));
} else { } else {
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("Set basal profile result: " + result); 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); Notification reportOK = new Notification(Notification.PROFILE_SET_OK, MainApp.gs(R.string.profile_set_ok), Notification.INFO, 60);
MainApp.bus().post(new EventNewNotification(reportOK)); MainApp.bus().post(new EventNewNotification(reportOK));

View file

@ -3,11 +3,10 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.Constants;
public class MsgSetTempBasalStart extends MessageBase { public class MsgSetTempBasalStart extends MessageBase {
private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgSetTempBasalStart() { public MsgSetTempBasalStart() {
SetCommand(0x0401); SetCommand(0x0401);
@ -25,7 +24,7 @@ public class MsgSetTempBasalStart extends MessageBase {
AddParamByte((byte) (percent & 255)); AddParamByte((byte) (percent & 255));
AddParamByte((byte) (durationInHours & 255)); AddParamByte((byte) (durationInHours & 255));
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("Temp basal start percent: " + percent + " duration hours: " + durationInHours); log.debug("Temp basal start percent: " + percent + " duration hours: " + durationInHours);
} }
@ -33,10 +32,10 @@ public class MsgSetTempBasalStart extends MessageBase {
int result = intFromBuff(bytes, 0, 1); int result = intFromBuff(bytes, 0, 1);
if (result != 1) { if (result != 1) {
failed = true; failed = true;
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("Set temp basal start result: " + result + " FAILED!!!"); log.debug("Set temp basal start result: " + result + " FAILED!!!");
} else { } else {
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("Set temp basal start result: " + result); log.debug("Set temp basal start result: " + result);
} }
} }

View file

@ -3,15 +3,14 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.Constants;
public class MsgSetTempBasalStop extends MessageBase { public class MsgSetTempBasalStop extends MessageBase {
private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public MsgSetTempBasalStop() { public MsgSetTempBasalStop() {
SetCommand(0x0403); SetCommand(0x0403);
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("Temp basal stop"); log.debug("Temp basal stop");
} }
@ -19,10 +18,10 @@ public class MsgSetTempBasalStop extends MessageBase {
int result = intFromBuff(bytes, 0, 1); int result = intFromBuff(bytes, 0, 1);
if (result != 1) { if (result != 1) {
failed = true; failed = true;
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("Set temp basal stop result: " + result + " FAILED!!!"); log.debug("Set temp basal stop result: " + result + " FAILED!!!");
} else { } else {
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("Set temp basal stop result: " + result); log.debug("Set temp basal stop result: " + result);
} }
} }

View file

@ -5,8 +5,7 @@ import org.slf4j.LoggerFactory;
import java.util.Date; import java.util.Date;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.Constants;
import info.nightscout.utils.DateUtil; import info.nightscout.utils.DateUtil;
/** /**
@ -14,21 +13,21 @@ import info.nightscout.utils.DateUtil;
*/ */
public class MsgSetTime extends MessageBase { public class MsgSetTime extends MessageBase {
private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
private static Date time; private static Date time;
public MsgSetTime(Date time) { public MsgSetTime(Date time) {
SetCommand(0x330a); SetCommand(0x330a);
this.time = time; this.time = time;
AddParamDateTime(time); AddParamDateTime(time);
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("New message: time:" + DateUtil.dateAndTimeString(time)); log.debug("New message: time:" + DateUtil.dateAndTimeString(time));
} }
public void handleMessage(byte[] bytes) { public void handleMessage(byte[] bytes) {
int result = intFromBuff(bytes, 0, 1); int result = intFromBuff(bytes, 0, 1);
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("Result of setting time: " + time + " is " + result); log.debug("Result of setting time: " + time + " is " + result);
} }
} }

View file

@ -3,8 +3,7 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
/** /**
@ -12,7 +11,7 @@ import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
*/ */
public class MsgSetUserOptions extends MessageBase { public class MsgSetUserOptions extends MessageBase {
private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
public boolean done; public boolean done;
@ -36,7 +35,7 @@ public class MsgSetUserOptions extends MessageBase {
for (int i = 0; i < pump.userOptionsFrompump.length; i++) { for (int i = 0; i < pump.userOptionsFrompump.length; i++) {
AddParamByte(pump.userOptionsFrompump[i]); AddParamByte(pump.userOptionsFrompump[i]);
} }
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("New message"); log.debug("New message");
} }
@ -44,10 +43,10 @@ public class MsgSetUserOptions extends MessageBase {
int result = intFromBuff(bytes, 0, 1); int result = intFromBuff(bytes, 0, 1);
if (result != 1) { if (result != 1) {
failed = true; failed = true;
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("Setting user options: " + result + " FAILED!!!"); log.debug("Setting user options: " + result + " FAILED!!!");
} else { } else {
if (Config.logPumpComm) if (L.isEnabled(L.PUMPCOMM))
log.debug("Setting user options: " + result); log.debug("Setting user options: " + result);
} }
} }

Some files were not shown because too many files have changed in this diff Show more