Merge remote-tracking branch 'origin/dagger3' into rs
This commit is contained in:
commit
7e8c079210
|
@ -37,8 +37,6 @@ import javax.inject.Inject
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
class RealPumpTest {
|
class RealPumpTest {
|
||||||
|
|
||||||
private val log = LoggerFactory.getLogger(L.CORE)
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val R_PASSWORD = 1234
|
const val R_PASSWORD = 1234
|
||||||
const val R_SERIAL = "PBB00013LR_P"
|
const val R_SERIAL = "PBB00013LR_P"
|
||||||
|
@ -120,12 +118,12 @@ class RealPumpTest {
|
||||||
preparePlugins()
|
preparePlugins()
|
||||||
|
|
||||||
while (!pump.isInitialized) {
|
while (!pump.isInitialized) {
|
||||||
log.debug("Waiting for initialization")
|
//log.debug("Waiting for initialization")
|
||||||
SystemClock.sleep(1000)
|
SystemClock.sleep(1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
log.debug("Tick")
|
//log.debug("Tick")
|
||||||
SystemClock.sleep(1000)
|
SystemClock.sleep(1000)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,65 +1,25 @@
|
||||||
package info.nightscout.androidaps.logging
|
package info.nightscout.androidaps.logging
|
||||||
|
|
||||||
import info.nightscout.androidaps.utils.SP
|
import androidx.preference.PreferenceManager
|
||||||
|
import info.nightscout.androidaps.MainApp
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
object L {
|
object L {
|
||||||
private var logElements: MutableList<LogElement> = ArrayList()
|
private var logElements: MutableList<LogElement> = ArrayList()
|
||||||
|
|
||||||
const val CORE = "CORE"
|
const val CORE = "CORE"
|
||||||
const val AUTOSENS = "AUTOSENS"
|
|
||||||
const val AUTOMATION = "AUTOMATION"
|
|
||||||
const val EVENTS = "EVENTS"
|
|
||||||
const val GLUCOSE = "GLUCOSE"
|
|
||||||
const val BGSOURCE = "BGSOURCE"
|
const val BGSOURCE = "BGSOURCE"
|
||||||
const val OVERVIEW = "OVERVIEW"
|
|
||||||
const val NOTIFICATION = "NOTIFICATION"
|
|
||||||
const val DATASERVICE = "DATASERVICE"
|
const val DATASERVICE = "DATASERVICE"
|
||||||
const val DATABASE = "DATABASE"
|
const val DATABASE = "DATABASE"
|
||||||
const val DATAFOOD = "DATAFOOD"
|
const val DATAFOOD = "DATAFOOD"
|
||||||
const val DATATREATMENTS = "DATATREATMENTS"
|
const val DATATREATMENTS = "DATATREATMENTS"
|
||||||
const val NSCLIENT = "NSCLIENT"
|
const val NSCLIENT = "NSCLIENT"
|
||||||
const val TIDEPOOL = "TIDEPOOL"
|
|
||||||
const val CONSTRAINTS = "CONSTRAINTS"
|
|
||||||
const val PUMP = "PUMP"
|
const val PUMP = "PUMP"
|
||||||
const val PUMPQUEUE = "PUMPQUEUE"
|
|
||||||
const val PUMPCOMM = "PUMPCOMM"
|
const val PUMPCOMM = "PUMPCOMM"
|
||||||
const val PUMPBTCOMM = "PUMPBTCOMM"
|
const val PUMPBTCOMM = "PUMPBTCOMM"
|
||||||
const val APS = "APS"
|
|
||||||
const val PROFILE = "PROFILE"
|
|
||||||
const val CONFIGBUILDER = "CONFIGBUILDER"
|
|
||||||
const val UI = "UI"
|
|
||||||
const val LOCATION = "LOCATION"
|
|
||||||
const val SMS = "SMS"
|
|
||||||
const val WEAR = "WEAR"
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
logElements.add(LogElement(APS, defaultValue = true))
|
LTag.values().forEach { logElements.add(LogElement(it)) }
|
||||||
logElements.add(LogElement(AUTOMATION, defaultValue = true))
|
|
||||||
logElements.add(LogElement(AUTOSENS, defaultValue = false))
|
|
||||||
logElements.add(LogElement(BGSOURCE, defaultValue = true))
|
|
||||||
logElements.add(LogElement(GLUCOSE, defaultValue = false))
|
|
||||||
logElements.add(LogElement(CONFIGBUILDER, defaultValue = false))
|
|
||||||
logElements.add(LogElement(CONSTRAINTS, defaultValue = true))
|
|
||||||
logElements.add(LogElement(CORE, defaultValue = true))
|
|
||||||
logElements.add(LogElement(DATABASE, defaultValue = true))
|
|
||||||
logElements.add(LogElement(DATAFOOD, false))
|
|
||||||
logElements.add(LogElement(DATASERVICE, true))
|
|
||||||
logElements.add(LogElement(DATATREATMENTS, true))
|
|
||||||
logElements.add(LogElement(EVENTS, false, requiresRestart = true))
|
|
||||||
logElements.add(LogElement(LOCATION, true))
|
|
||||||
logElements.add(LogElement(NOTIFICATION, true))
|
|
||||||
logElements.add(LogElement(NSCLIENT, true))
|
|
||||||
logElements.add(LogElement(TIDEPOOL, true))
|
|
||||||
logElements.add(LogElement(OVERVIEW, true))
|
|
||||||
logElements.add(LogElement(PROFILE, true))
|
|
||||||
logElements.add(LogElement(PUMP, true))
|
|
||||||
logElements.add(LogElement(PUMPBTCOMM, false))
|
|
||||||
logElements.add(LogElement(PUMPCOMM, true))
|
|
||||||
logElements.add(LogElement(PUMPQUEUE, true))
|
|
||||||
logElements.add(LogElement(SMS, true))
|
|
||||||
logElements.add(LogElement(UI, true))
|
|
||||||
logElements.add(LogElement(WEAR, true))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun findByName(name: String): LogElement {
|
private fun findByName(name: String): LogElement {
|
||||||
|
@ -90,17 +50,13 @@ object L {
|
||||||
var enabled: Boolean
|
var enabled: Boolean
|
||||||
private var requiresRestart = false
|
private var requiresRestart = false
|
||||||
|
|
||||||
internal constructor(name: String, defaultValue: Boolean) {
|
internal constructor(tag: LTag) {
|
||||||
this.name = name
|
this.name = tag.tag
|
||||||
this.defaultValue = defaultValue
|
this.defaultValue = tag.defaultValue
|
||||||
enabled = SP.getBoolean(getSPName(), defaultValue)
|
this.requiresRestart = tag.requiresRestart
|
||||||
}
|
//TODO: remove after getting rid of old logging style "if (L.isEnabled(...))"
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
internal constructor(name: String, defaultValue: Boolean, requiresRestart: Boolean) {
|
enabled = PreferenceManager.getDefaultSharedPreferences(MainApp.instance()).getBoolean(getSPName(), defaultValue)
|
||||||
this.name = name
|
|
||||||
this.defaultValue = defaultValue
|
|
||||||
this.requiresRestart = requiresRestart
|
|
||||||
enabled = SP.getBoolean(getSPName(), defaultValue)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal constructor(defaultValue: Boolean) {
|
internal constructor(defaultValue: Boolean) {
|
||||||
|
@ -113,40 +69,12 @@ object L {
|
||||||
|
|
||||||
fun enable(enabled: Boolean) {
|
fun enable(enabled: Boolean) {
|
||||||
this.enabled = enabled
|
this.enabled = enabled
|
||||||
SP.putBoolean(getSPName(), enabled)
|
@Suppress("DEPRECATION")
|
||||||
|
PreferenceManager.getDefaultSharedPreferences(MainApp.instance()).edit().putBoolean(getSPName(), enabled).apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun resetToDefault() {
|
fun resetToDefault() {
|
||||||
enable(defaultValue)
|
enable(defaultValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
enum class LTag(val tag: String) {
|
|
||||||
CORE("CORE"),
|
|
||||||
AUTOSENS("AUTOSENS"),
|
|
||||||
AUTOMATION("AUTOMATION"),
|
|
||||||
EVENTS("EVENTS"),
|
|
||||||
GLUCOSE("GLUCOSE"),
|
|
||||||
BGSOURCE("BGSOURCE"),
|
|
||||||
OVERVIEW("OVERVIEW"),
|
|
||||||
NOTIFICATION("NOTIFICATION"),
|
|
||||||
DATASERVICE("DATASERVICE"),
|
|
||||||
DATABASE("DATABASE"),
|
|
||||||
DATAFOOD("DATAFOOD"),
|
|
||||||
DATATREATMENTS("DATATREATMENTS"),
|
|
||||||
NSCLIENT("NSCLIENT"),
|
|
||||||
TIDEPOOL("TIDEPOOL"),
|
|
||||||
CONSTRAINTS("CONSTRAINTS"),
|
|
||||||
PUMP("PUMP"),
|
|
||||||
PUMPQUEUE("PUMPQUEUE"),
|
|
||||||
PUMPCOMM("PUMPCOMM"),
|
|
||||||
PUMPBTCOMM("PUMPBTCOMM"),
|
|
||||||
APS("APS"),
|
|
||||||
PROFILE("PROFILE"),
|
|
||||||
CONFIGBUILDER("CONFIGBUILDER"),
|
|
||||||
UI("UI"),
|
|
||||||
LOCATION("LOCATION"),
|
|
||||||
WEAR("WEAR"),
|
|
||||||
SMS("SMS"),
|
|
||||||
}
|
}
|
30
app/src/main/java/info/nightscout/androidaps/logging/LTag.kt
Normal file
30
app/src/main/java/info/nightscout/androidaps/logging/LTag.kt
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
package info.nightscout.androidaps.logging
|
||||||
|
|
||||||
|
enum class LTag(val tag: String, val defaultValue : Boolean = false, val requiresRestart: Boolean = false) {
|
||||||
|
CORE("CORE", defaultValue = false),
|
||||||
|
APS("APS", defaultValue = false),
|
||||||
|
AUTOSENS("AUTOSENS"),
|
||||||
|
AUTOMATION("AUTOMATION", defaultValue = false),
|
||||||
|
BGSOURCE("BGSOURCE", defaultValue = false),
|
||||||
|
CONFIGBUILDER("CONFIGBUILDER"),
|
||||||
|
CONSTRAINTS("CONSTRAINTS", defaultValue = false),
|
||||||
|
DATABASE("DATABASE", defaultValue = false),
|
||||||
|
DATAFOOD("DATAFOOD"),
|
||||||
|
DATASERVICE("DATASERVICE", defaultValue = false),
|
||||||
|
DATATREATMENTS("DATATREATMENTS", defaultValue = false),
|
||||||
|
EVENTS("EVENTS", defaultValue = false, requiresRestart = true),
|
||||||
|
GLUCOSE("GLUCOSE"),
|
||||||
|
LOCATION("LOCATION", defaultValue = false),
|
||||||
|
NOTIFICATION("NOTIFICATION", defaultValue = false),
|
||||||
|
NSCLIENT("NSCLIENT", defaultValue = false),
|
||||||
|
OVERVIEW("OVERVIEW", defaultValue = false),
|
||||||
|
PUMP("PUMP", defaultValue = false),
|
||||||
|
PUMPBTCOMM("PUMPBTCOMM"),
|
||||||
|
PUMPCOMM("PUMPCOMM", defaultValue = false),
|
||||||
|
PUMPQUEUE("PUMPQUEUE", defaultValue = false),
|
||||||
|
PROFILE("PROFILE", defaultValue = false),
|
||||||
|
SMS("SMS", defaultValue = false),
|
||||||
|
TIDEPOOL("TIDEPOOL"),
|
||||||
|
UI("UI", defaultValue = false),
|
||||||
|
WEAR("WEAR")
|
||||||
|
}
|
|
@ -366,7 +366,7 @@ import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class DeviceStatus {
|
public class DeviceStatus {
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.APS);
|
private static Logger log = StacktraceLoggerWrapper.getLogger(L.NSCLIENT);
|
||||||
|
|
||||||
public String device = null;
|
public String device = null;
|
||||||
public JSONObject pump = null;
|
public JSONObject pump = null;
|
||||||
|
|
|
@ -334,8 +334,7 @@ public class LoopPlugin extends PluginBase {
|
||||||
Profile profile = profileFunction.getProfile();
|
Profile profile = profileFunction.getProfile();
|
||||||
|
|
||||||
if (profile == null || !profileFunction.isProfileValid("Loop")) {
|
if (profile == null || !profileFunction.isProfileValid("Loop")) {
|
||||||
if (L.isEnabled(L.APS))
|
getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.noprofileselected));
|
||||||
getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.noprofileselected));
|
|
||||||
rxBus.send(new EventLoopSetLastRunGui(resourceHelper.gs(R.string.noprofileselected)));
|
rxBus.send(new EventLoopSetLastRunGui(resourceHelper.gs(R.string.noprofileselected)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,8 +109,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 (L.isEnabled(L.APS))
|
aapsLogger.debug(LTag.APS, "Result: " + result);
|
||||||
aapsLogger.debug(LTag.APS, "Result: " + result);
|
|
||||||
try {
|
try {
|
||||||
determineBasalResultMA = new DetermineBasalResultMA(injector, jsResult, new JSONObject(result));
|
determineBasalResultMA = new DetermineBasalResultMA(injector, jsResult, new JSONObject(result));
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
|
|
|
@ -2,17 +2,14 @@ package info.nightscout.androidaps.plugins.iob.iobCobCalculator;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 06.01.2017.
|
* Created by mike on 06.01.2017.
|
||||||
*/
|
*/
|
||||||
public class AutosensResult {
|
public class AutosensResult {
|
||||||
private static Logger log = StacktraceLoggerWrapper.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;
|
||||||
|
@ -30,7 +27,7 @@ public class AutosensResult {
|
||||||
ret.put("sensResult", sensResult);
|
ret.put("sensResult", sensResult);
|
||||||
ret.put("ratio", ratio);
|
ret.put("ratio", ratio);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
LoggerFactory.getLogger(LTag.CORE.getTag()).error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,17 +196,15 @@ public class IobCobOref1Thread extends Thread {
|
||||||
try {
|
try {
|
||||||
for (; past < 12; past++) {
|
for (; past < 12; past++) {
|
||||||
AutosensData ad = autosensDataTable.valueAt(initialIndex + past);
|
AutosensData ad = autosensDataTable.valueAt(initialIndex + past);
|
||||||
if (L.isEnabled(L.AUTOSENS)) {
|
aapsLogger.debug(LTag.AUTOSENS, ">>>>> past=" + past + " ad=" + (ad != null ? ad.toString() : null));
|
||||||
aapsLogger.debug(">>>>> past=" + past + " ad=" + (ad != null ? ad.toString() : null));
|
if (ad == null) {
|
||||||
if (ad == null) {
|
aapsLogger.debug(LTag.AUTOSENS, autosensDataTable.toString());
|
||||||
aapsLogger.debug(autosensDataTable.toString());
|
aapsLogger.debug(LTag.AUTOSENS, bucketed_data.toString());
|
||||||
aapsLogger.debug(bucketed_data.toString());
|
aapsLogger.debug(LTag.AUTOSENS, iobCobCalculatorPlugin.getBgReadings().toString());
|
||||||
aapsLogger.debug(iobCobCalculatorPlugin.getBgReadings().toString());
|
Notification notification = new Notification(Notification.SENDLOGFILES, resourceHelper.gs(R.string.sendlogfiles), Notification.LOW);
|
||||||
Notification notification = new Notification(Notification.SENDLOGFILES, resourceHelper.gs(R.string.sendlogfiles), Notification.LOW);
|
rxBus.send(new EventNewNotification(notification));
|
||||||
rxBus.send(new EventNewNotification(notification));
|
sp.putBoolean("log_AUTOSENS", true);
|
||||||
sp.putBoolean("log_AUTOSENS", true);
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// let it here crash on NPE to get more data as i cannot reproduce this bug
|
// let it here crash on NPE to get more data as i cannot reproduce this bug
|
||||||
double deviationSlope = (ad.avgDeviation - avgDeviation) / (ad.time - bgTime) * 1000 * 60 * 5;
|
double deviationSlope = (ad.avgDeviation - avgDeviation) / (ad.time - bgTime) * 1000 * 60 * 5;
|
||||||
|
|
|
@ -21,7 +21,6 @@ import info.nightscout.androidaps.events.Event;
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
import info.nightscout.androidaps.logging.LTag;
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
import info.nightscout.androidaps.plugins.aps.openAPSSMB.SMBDefaults;
|
import info.nightscout.androidaps.plugins.aps.openAPSSMB.SMBDefaults;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
|
@ -193,17 +192,15 @@ public class IobCobThread extends Thread {
|
||||||
try {
|
try {
|
||||||
for (; past < 12; past++) {
|
for (; past < 12; past++) {
|
||||||
AutosensData ad = autosensDataTable.valueAt(initialIndex + past);
|
AutosensData ad = autosensDataTable.valueAt(initialIndex + past);
|
||||||
if (L.isEnabled(L.AUTOSENS)) {
|
aapsLogger.debug(LTag.AUTOSENS, ">>>>> past=" + past + " ad=" + (ad != null ? ad.toString() : null));
|
||||||
aapsLogger.debug(">>>>> past=" + past + " ad=" + (ad != null ? ad.toString() : null));
|
if (ad == null) {
|
||||||
if (ad == null) {
|
aapsLogger.debug(LTag.AUTOSENS, autosensDataTable.toString());
|
||||||
aapsLogger.debug(autosensDataTable.toString());
|
aapsLogger.debug(LTag.AUTOSENS, bucketed_data.toString());
|
||||||
aapsLogger.debug(bucketed_data.toString());
|
aapsLogger.debug(LTag.AUTOSENS, iobCobCalculatorPlugin.getBgReadings().toString());
|
||||||
aapsLogger.debug(iobCobCalculatorPlugin.getBgReadings().toString());
|
Notification notification = new Notification(Notification.SENDLOGFILES, resourceHelper.gs(R.string.sendlogfiles), Notification.LOW);
|
||||||
Notification notification = new Notification(Notification.SENDLOGFILES, resourceHelper.gs(R.string.sendlogfiles), Notification.LOW);
|
rxBus.send(new EventNewNotification(notification));
|
||||||
rxBus.send(new EventNewNotification(notification));
|
sp.putBoolean("log_AUTOSENS", true);
|
||||||
sp.putBoolean("log_AUTOSENS", true);
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// let it here crash on NPE to get more data as i cannot reproduce this bug
|
// let it here crash on NPE to get more data as i cannot reproduce this bug
|
||||||
double deviationSlope = (ad.avgDeviation - avgDeviation) / (ad.time - bgTime) * 1000 * 60 * 5;
|
double deviationSlope = (ad.avgDeviation - avgDeviation) / (ad.time - bgTime) * 1000 * 60 * 5;
|
||||||
|
|
|
@ -39,6 +39,7 @@ object OKDialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun runOnUiThread(theRunnable: Runnable?) {
|
fun runOnUiThread(theRunnable: Runnable?) {
|
||||||
|
@Suppress("DEPRECATION"
|
||||||
val mainHandler = Handler(MainApp.instance().applicationContext.mainLooper)
|
val mainHandler = Handler(MainApp.instance().applicationContext.mainLooper)
|
||||||
theRunnable?.let { mainHandler.post(it) }
|
theRunnable?.let { mainHandler.post(it) }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue