diff --git a/app/src/main/java/info/nightscout/androidaps/Config.java b/app/src/main/java/info/nightscout/androidaps/Config.java index d419b67411..3ee273207a 100644 --- a/app/src/main/java/info/nightscout/androidaps/Config.java +++ b/app/src/main/java/info/nightscout/androidaps/Config.java @@ -27,11 +27,9 @@ public class Config { public static final boolean logFunctionCalls = true; public static final boolean logIncommingData = true; public static final boolean logAPSResult = true; - public static final boolean logPumpComm = true; public static final boolean logPrefsChange = true; public static final boolean logConfigBuilder = true; public static final boolean logNSUpload = true; - public static final boolean logPumpActions = true; public static final boolean logCongigBuilderActions = true; public static final boolean logAutosensData = false; public static final boolean logEvents = false; @@ -45,9 +43,8 @@ public class Config { public static final boolean logDataTreatments = true; public static final boolean logNsclient = true; public static final boolean logObjectives = false; + public static final boolean logPump = true; + public static boolean logPumpComm = true; + public static final boolean logPumpBtComm = false; - // DanaR specific - public static final boolean logDanaBTComm = true; - public static boolean logDanaMessageDetail = true; - public static final boolean logDanaSerialEngine = true; } diff --git a/app/src/main/java/info/nightscout/androidaps/Constants.java b/app/src/main/java/info/nightscout/androidaps/Constants.java index 6cb7519ccb..bb6d8d5655 100644 --- a/app/src/main/java/info/nightscout/androidaps/Constants.java +++ b/app/src/main/java/info/nightscout/androidaps/Constants.java @@ -71,7 +71,6 @@ public class Constants { // logging public static final String AUTOSENS = "AUTOSENS"; public static final String EVENTS = "EVENTS"; - public static final String QUEUE = "QUEUE"; public static final String BGSOURCE = "BGSOURCE"; public static final String OVERVIEW = "OVERVIEW"; public static final String NOTIFICATION = "NOTIFICATION"; @@ -81,4 +80,8 @@ public class Constants { 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"; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/DetailedBolusInfoStorage.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/DetailedBolusInfoStorage.java index 7a4e99b584..d469faa568 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/DetailedBolusInfoStorage.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/DetailedBolusInfoStorage.java @@ -9,6 +9,8 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; +import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.data.DetailedBolusInfo; /** @@ -16,7 +18,7 @@ import info.nightscout.androidaps.data.DetailedBolusInfo; */ public class DetailedBolusInfoStorage { - private static Logger log = LoggerFactory.getLogger(DetailedBolusInfoStorage.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMP); private static List store = new ArrayList<>(); public static synchronized void add(DetailedBolusInfo detailedBolusInfo) { @@ -29,7 +31,8 @@ public class DetailedBolusInfoStorage { DetailedBolusInfo found = null; for (int i = 0; i < store.size(); i++) { long infoTime = store.get(i).date; - log.debug("Existing bolus info: " + store.get(i)); + if (Config.logPump) + log.debug("Existing bolus info: " + store.get(i)); if (bolustime > infoTime - 60 * 1000 && bolustime < infoTime + 60 * 1000) { found = store.get(i); break; @@ -42,7 +45,8 @@ public class DetailedBolusInfoStorage { for (int i = 0; i < store.size(); i++) { long infoTime = store.get(i).date; if (bolustime > infoTime - 60 * 1000 && bolustime < infoTime + 60 * 1000) { - log.debug("Removing bolus info: " + store.get(i)); + if (Config.logPump) + log.debug("Removing bolus info: " + store.get(i)); store.remove(i); break; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java index a16ffbda05..7361f15850 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java @@ -22,6 +22,8 @@ import java.util.HashSet; import java.util.List; import info.nightscout.androidaps.BuildConfig; +import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.DetailedBolusInfo; @@ -31,8 +33,6 @@ import info.nightscout.androidaps.db.CareportalEvent; import info.nightscout.androidaps.db.Source; import info.nightscout.androidaps.db.TDD; import info.nightscout.androidaps.db.TemporaryBasal; -import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment; -import info.nightscout.androidaps.plugins.Treatments.Treatment; import info.nightscout.androidaps.events.EventInitializationChanged; import info.nightscout.androidaps.events.EventRefreshOverview; import info.nightscout.androidaps.interfaces.Constraint; @@ -42,6 +42,7 @@ import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; @@ -60,6 +61,7 @@ import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.Bolus; import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.PumpHistory; import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.PumpHistoryRequest; import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.Tdd; +import info.nightscout.androidaps.plugins.Treatments.Treatment; import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin; import info.nightscout.utils.DateUtil; import info.nightscout.utils.FabricPrivacy; @@ -69,7 +71,7 @@ import info.nightscout.utils.SP; * Created by mike on 05.08.2016. */ public class ComboPlugin extends PluginBase implements PumpInterface, ConstraintsInterface { - private static final Logger log = LoggerFactory.getLogger(ComboPlugin.class); + private static final Logger log = LoggerFactory.getLogger(Constants.PUMP); static final String COMBO_TBRS_SET = "combo_tbrs_set"; static final String COMBO_BOLUSES_DELIVERED = "combo_boluses_delivered"; @@ -198,7 +200,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint @Override public void switchAllowed(ConfigBuilderFragment.PluginViewHolder.PluginSwitcher pluginSwitcher, FragmentActivity context) { boolean allowHardwarePump = SP.getBoolean("allow_hardware_pump", false); - if (allowHardwarePump || context == null){ + if (allowHardwarePump || context == null) { pluginSwitcher.invoke(); } else { AlertDialog.Builder builder = new AlertDialog.Builder(context); @@ -207,13 +209,15 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint public void onClick(DialogInterface dialog, int id) { pluginSwitcher.invoke(); SP.putBoolean("allow_hardware_pump", true); - log.debug("First time HW pump allowed!"); + if (Config.logPump) + log.debug("First time HW pump allowed!"); } }) .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { pluginSwitcher.cancel(); - log.debug("User does not allow switching to HW pump!"); + if (Config.logPump) + log.debug("User does not allow switching to HW pump!"); } }); builder.create().show(); @@ -260,7 +264,8 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint @Override public void disconnect(String reason) { - log.debug("Disconnect called with reason: " + reason); + if (Config.logPump) + log.debug("Disconnect called with reason: " + reason); ruffyScripter.disconnect(); } @@ -359,7 +364,8 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint */ @Override public synchronized void getPumpStatus() { - log.debug("getPumpStatus called"); + if (Config.logPump) + log.debug("getPumpStatus called"); if (!pump.initialized) { initializePump(); } else { @@ -371,10 +377,12 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint private synchronized void initializePump() { long maxWait = System.currentTimeMillis() + 15 * 1000; while (!ruffyScripter.isPumpAvailable()) { - log.debug("Waiting for ruffy service to come up ..."); + if (Config.logPump) + log.debug("Waiting for ruffy service to come up ..."); SystemClock.sleep(100); if (System.currentTimeMillis() > maxWait) { - log.debug("ruffy service unavailable, wtf"); + if (Config.logPump) + log.debug("ruffy service unavailable, wtf"); return; } } @@ -393,7 +401,8 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint // note that since the history is checked upon every connect, the above already updated // the DB with any changed history records if (pumpHistoryChanged) { - log.debug("Pump history has changed and was imported"); + if (Config.logPump) + log.debug("Pump history has changed and was imported"); pumpHistoryChanged = false; } @@ -542,7 +551,8 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint // within the last 1-2 minutes if (Math.abs(previousBolus.amount - detailedBolusInfo.insulin) < 0.01 && previousBolus.timestamp + 60 * 1000 > System.currentTimeMillis()) { - log.debug("Bolu request rejected, same bolus was successfully delivered very recently"); + if (Config.logPump) + log.debug("Bolus request rejected, same bolus was successfully delivered very recently"); return new PumpEnactResult().success(false).enacted(false) .comment(MainApp.gs(R.string.bolus_frequency_exceeded)); } @@ -562,7 +572,8 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint return new PumpEnactResult().success(false).enacted(false) .comment(MainApp.gs(R.string.combo_error_no_connection_no_bolus_delivered)); } - log.debug("Waiting for pump clock to advance for the next unused bolus record timestamp"); + if (Config.logPump) + log.debug("Waiting for pump clock to advance for the next unused bolus record timestamp"); SystemClock.sleep(2000); timeCheckResult = runCommand(null, 0, ruffyScripter::readPumpState); waitLoops++; @@ -573,7 +584,8 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) .putCustomAttribute("version", BuildConfig.VERSION) .putCustomAttribute("waitTimeSecs", String.valueOf(waitDuration))); - log.debug("Waited " + waitDuration + "s for pump to switch to a fresh minute before bolusing"); + if (Config.logPump) + log.debug("Waited " + waitDuration + "s for pump to switch to a fresh minute before bolusing"); } if (cancelBolus) { @@ -735,11 +747,13 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint */ @Override public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile, boolean force) { - log.debug("setTempBasalAbsolute called with a rate of " + absoluteRate + " for " + durationInMinutes + " min."); + if (Config.logPump) + log.debug("setTempBasalAbsolute called with a rate of " + absoluteRate + " for " + durationInMinutes + " min."); int unroundedPercentage = Double.valueOf(absoluteRate / getBaseBasalRate() * 100).intValue(); int roundedPercentage = (int) (Math.round(absoluteRate / getBaseBasalRate() * 10) * 10); if (unroundedPercentage != roundedPercentage) { - log.debug("Rounded requested rate " + unroundedPercentage + "% -> " + roundedPercentage + "%"); + if (Config.logPump) + log.debug("Rounded requested rate " + unroundedPercentage + "% -> " + roundedPercentage + "%"); } return setTempBasalPercent(roundedPercentage, durationInMinutes); @@ -757,7 +771,8 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint } private PumpEnactResult setTempBasalPercent(Integer percent, final Integer durationInMinutes) { - log.debug("setTempBasalPercent called with " + percent + "% for " + durationInMinutes + "min"); + if (Config.logPump) + log.debug("setTempBasalPercent called with " + percent + "% for " + durationInMinutes + "min"); if (pumpHistoryChanged && percent > 110) { return new PumpEnactResult().success(false).enacted(false) @@ -767,13 +782,15 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint int adjustedPercent = percent; if (adjustedPercent > pumpDescription.maxTempPercent) { - log.debug("Reducing requested TBR to the maximum support by the pump: " + percent + " -> " + pumpDescription.maxTempPercent); + if (Config.logPump) + log.debug("Reducing requested TBR to the maximum support by the pump: " + percent + " -> " + pumpDescription.maxTempPercent); adjustedPercent = pumpDescription.maxTempPercent; } if (adjustedPercent % 10 != 0) { Long rounded = Math.round(adjustedPercent / 10d) * 10; - log.debug("Rounded requested percentage:" + adjustedPercent + " -> " + rounded); + if (Config.logPump) + log.debug("Rounded requested percentage:" + adjustedPercent + " -> " + rounded); adjustedPercent = rounded.intValue(); } @@ -822,7 +839,8 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint */ @Override public PumpEnactResult cancelTempBasal(boolean enforceNew) { - log.debug("cancelTempBasal called"); + if (Config.logPump) + log.debug("cancelTempBasal called"); final TemporaryBasal activeTemp = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(System.currentTimeMillis()); if (enforceNew) { CommandResult stateResult = runCommand(MainApp.gs(R.string.combo_pump_action_refreshing), 2, ruffyScripter::readPumpState); @@ -832,7 +850,8 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint if (!stateResult.state.tbrActive) { return new PumpEnactResult().success(true).enacted(false); } - log.debug("cancelTempBasal: hard-cancelling TBR since force requested"); + if (Config.logPump) + log.debug("cancelTempBasal: hard-cancelling TBR since force requested"); CommandResult cancelResult = runCommand(MainApp.gs(R.string.combo_pump_action_cancelling_tbr), 2, ruffyScripter::cancelTbr); if (!cancelResult.success) { return new PumpEnactResult().success(false).enacted(false); @@ -853,7 +872,8 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint // Let fake neutral temp keep run (see below) // Note that since this runs on the queue a connection is opened regardless, but this // case doesn't occur all that often, so it's not worth optimizing (1.3k SetTBR vs 4 cancelTBR). - log.debug("cancelTempBasal: skipping changing tbr since it already is at " + activeTemp.percentRate + "% and running for another " + activeTemp.getPlannedRemainingMinutes() + " mins."); + if (Config.logPump) + log.debug("cancelTempBasal: skipping changing tbr since it already is at " + activeTemp.percentRate + "% and running for another " + activeTemp.getPlannedRemainingMinutes() + " mins."); return new PumpEnactResult().success(true).enacted(true) .comment("cancelTempBasal skipping changing tbr since it already is at " + activeTemp.percentRate + "% and running for another " @@ -862,7 +882,8 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint // Set a fake neutral temp to avoid TBR cancel alert. Decide 90% vs 110% based on // on whether the TBR we're cancelling is above or below 100%. final int percentage = (activeTemp.percentRate > 100) ? 110 : 90; - log.debug("cancelTempBasal: changing TBR to " + percentage + "% for 15 mins."); + if (Config.logPump) + log.debug("cancelTempBasal: changing TBR to " + percentage + "% for 15 mins."); return setTempBasalPercent(percentage, 15); } } @@ -901,7 +922,8 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint if (!commandResult.success && retries > 0) { for (int retryAttempts = 1; !commandResult.success && retryAttempts <= retries; retryAttempts++) { - log.debug("Command was not successful, retries requested, doing retry #" + retryAttempts); + if (Config.logPump) + log.debug("Command was not successful, retries requested, doing retry #" + retryAttempts); commandResult = commandExecution.execute(); } } @@ -982,7 +1004,8 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint long now = System.currentTimeMillis(); TemporaryBasal aapsTbr = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(now); if (aapsTbr == null || aapsTbr.percentRate != 0) { - log.debug("Creating 15m zero temp since pump is suspended"); + if (Config.logPump) + log.debug("Creating 15m zero temp since pump is suspended"); TemporaryBasal newTempBasal = new TemporaryBasal() .date(now) .percent(0) @@ -1042,11 +1065,13 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint if (state.pumpTime == 0) { // time couldn't be read (e.g. a warning is displayed on the menu , hiding the time field) } else if (Math.abs(state.pumpTime - System.currentTimeMillis()) >= 10 * 60 * 1000) { - log.debug("Pump clock needs update, pump time: " + state.pumpTime + " (" + new Date(state.pumpTime) + ")"); + if (Config.logPump) + log.debug("Pump clock needs update, pump time: " + state.pumpTime + " (" + new Date(state.pumpTime) + ")"); Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, MainApp.gs(R.string.combo_notification_check_time_date), Notification.URGENT); MainApp.bus().post(new EventNewNotification(notification)); } else if (Math.abs(state.pumpTime - System.currentTimeMillis()) >= 3 * 60 * 1000) { - log.debug("Pump clock needs update, pump time: " + state.pumpTime + " (" + new Date(state.pumpTime) + ")"); + if (Config.logPump) + log.debug("Pump clock needs update, pump time: " + state.pumpTime + " (" + new Date(state.pumpTime) + ")"); Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, MainApp.gs(R.string.combo_notification_check_time_date), Notification.NORMAL); MainApp.bus().post(new EventNewNotification(notification)); } @@ -1108,7 +1133,8 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint long now = System.currentTimeMillis(); TemporaryBasal aapsTbr = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(now); if (aapsTbr == null && state.tbrActive && state.tbrRemainingDuration > 2) { - log.debug("Creating temp basal from pump TBR"); + if (Config.logPump) + log.debug("Creating temp basal from pump TBR"); FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboTbrMismatch") .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) .putCustomAttribute("version", BuildConfig.VERSION) @@ -1120,7 +1146,8 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint .source(Source.USER); TreatmentsPlugin.getPlugin().addToHistoryTempBasal(newTempBasal); } else if (aapsTbr != null && aapsTbr.getPlannedRemainingMinutes() > 2 && !state.tbrActive) { - log.debug("Ending AAPS-TBR since pump has no TBR active"); + if (Config.logPump) + log.debug("Ending AAPS-TBR since pump has no TBR active"); FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboTbrMismatch") .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) .putCustomAttribute("version", BuildConfig.VERSION) @@ -1133,7 +1160,8 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint } else if (aapsTbr != null && state.tbrActive && (aapsTbr.percentRate != state.tbrPercent || Math.abs(aapsTbr.getPlannedRemainingMinutes() - state.tbrRemainingDuration) > 2)) { - log.debug("AAPSs and pump-TBR differ; ending AAPS-TBR and creating new TBR based on pump TBR"); + if (Config.logPump) + log.debug("AAPSs and pump-TBR differ; ending AAPS-TBR and creating new TBR based on pump TBR"); FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboTbrMismatch") .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) .putCustomAttribute("version", BuildConfig.VERSION) @@ -1218,7 +1246,8 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint // no history, nothing to check or complain about if (quickInfoResult.history == null || quickInfoResult.history.bolusHistory.isEmpty()) { - log.debug("Setting 'pumpHistoryChanged' false"); + if (Config.logPump) + log.debug("Setting 'pumpHistoryChanged' false"); pumpHistoryChanged = false; return null; } @@ -1227,13 +1256,15 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint List initialPumpBolusHistory = quickInfoResult.history.bolusHistory; if (recentBoluses.size() == 1 && initialPumpBolusHistory.size() >= 1 && recentBoluses.get(0).equals(quickInfoResult.history.bolusHistory.get(0))) { - log.debug("Setting 'pumpHistoryChanged' false"); + if (Config.logPump) + log.debug("Setting 'pumpHistoryChanged' false"); pumpHistoryChanged = false; return null; } else if (recentBoluses.size() == 2 && initialPumpBolusHistory.size() >= 2 && recentBoluses.get(0).equals(quickInfoResult.history.bolusHistory.get(0)) && recentBoluses.get(1).equals(quickInfoResult.history.bolusHistory.get(1))) { - log.debug("Setting 'pumpHistoryChanged' false"); + if (Config.logPump) + log.debug("Setting 'pumpHistoryChanged' false"); pumpHistoryChanged = false; return null; } @@ -1253,7 +1284,8 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint // for. HashSet bolusSet = new HashSet<>(historyResult.history.bolusHistory); if (bolusSet.size() != historyResult.history.bolusHistory.size()) { - log.debug("Bolus with same amount within the same minute imported. Only one will make it to the DB."); + if (Config.logPump) + log.debug("Bolus with same amount within the same minute imported. Only one will make it to the DB."); FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboBolusToDbError") .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) .putCustomAttribute("version", BuildConfig.VERSION) @@ -1266,7 +1298,8 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint pumpHistoryChanged = updateDbFromPumpHistory(historyResult.history); if (pumpHistoryChanged) { - log.debug("Setting 'pumpHistoryChanged' true"); + if (Config.logPump) + log.debug("Setting 'pumpHistoryChanged' true"); } List updatedPumpBolusHistory = historyResult.history.bolusHistory; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/AbstractDanaRPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/AbstractDanaRPlugin.java index 1f51979126..434630d14a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/AbstractDanaRPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/AbstractDanaRPlugin.java @@ -5,11 +5,13 @@ import android.support.annotation.Nullable; import org.json.JSONException; import org.json.JSONObject; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.Date; import info.nightscout.androidaps.BuildConfig; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.Profile; @@ -43,7 +45,7 @@ import info.nightscout.utils.SP; */ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInterface, DanaRInterface, ConstraintsInterface, ProfileInterface { - protected Logger log; + protected Logger log = LoggerFactory.getLogger(Constants.PUMP); protected AbstractDanaRExecutionService sExecutionService; @@ -133,7 +135,8 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte Double profileValue = profile.getBasalTimeFromMidnight(h * basalIncrement); if (profileValue == null) return true; if (Math.abs(pumpValue - profileValue) > getPumpDescription().basalStep) { - log.debug("Diff found. Hour: " + h + " Pump: " + pumpValue + " Profile: " + profileValue); + if (Config.logPump) + log.debug("Diff found. Hour: " + h + " Pump: " + pumpValue + " Profile: " + profileValue); return false; } } @@ -183,7 +186,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte result.duration = pump.tempBasalRemainingMin; result.percent = pump.tempBasalPercent; result.isPercent = true; - if (Config.logPumpActions) + if (Config.logPump) log.debug("setTempBasalPercent: Correct value already set"); return result; } @@ -197,7 +200,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte result.duration = pump.tempBasalRemainingMin; result.percent = pump.tempBasalPercent; result.isPercent = true; - if (Config.logPumpActions) + if (Config.logPump) log.debug("setTempBasalPercent: OK"); return result; } @@ -225,7 +228,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte result.absolute = pump.extendedBolusAbsoluteRate; result.isPercent = false; result.isTempCancel = false; - if (Config.logPumpActions) + if (Config.logPump) log.debug("setExtendedBolus: Correct extended bolus already set. Current: " + pump.extendedBolusAmount + " Asked: " + insulin); return result; } @@ -240,7 +243,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte if (!SP.getBoolean("danar_useextended", false)) result.bolusDelivered = pump.extendedBolusAmount; result.isPercent = false; - if (Config.logPumpActions) + if (Config.logPump) log.debug("setExtendedBolus: OK"); return result; } @@ -263,7 +266,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte if (!pump.isExtendedInProgress) { result.success = true; result.comment = MainApp.gs(R.string.virtualpump_resultok); - if (Config.logPumpActions) + if (Config.logPump) log.debug("cancelExtendedBolus: OK"); return result; } else { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java index 7288602d65..bbb363cc9d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java @@ -23,6 +23,8 @@ import org.slf4j.LoggerFactory; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; +import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.TDDStatsActivity; @@ -46,7 +48,7 @@ import info.nightscout.utils.FabricPrivacy; import info.nightscout.utils.SetWarnColor; public class DanaRFragment extends SubscriberFragment { - private static Logger log = LoggerFactory.getLogger(DanaRFragment.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMP); private Handler loopHandler = new Handler(); private Runnable refreshLoop = new Runnable() { @@ -113,18 +115,12 @@ public class DanaRFragment extends SubscriberFragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - try { - View view = inflater.inflate(R.layout.danar_fragment, container, false); - unbinder = ButterKnife.bind(this, view); + View view = inflater.inflate(R.layout.danar_fragment, container, false); + unbinder = ButterKnife.bind(this, view); - pumpStatusView.setBackgroundColor(MainApp.gc(R.color.colorInitializingBorder)); + pumpStatusView.setBackgroundColor(MainApp.gc(R.color.colorInitializingBorder)); - return view; - } catch (Exception e) { - FabricPrivacy.logException(e); - } - - return null; + return view; } @OnClick(R.id.danar_history) @@ -145,11 +141,14 @@ public class DanaRFragment extends SubscriberFragment { } @OnClick(R.id.danar_user_options) - void onUserOptionsClick() { startActivity(new Intent(getContext(), DanaRUserOptionsActivity.class)); } + void onUserOptionsClick() { + startActivity(new Intent(getContext(), DanaRUserOptionsActivity.class)); + } @OnClick(R.id.danar_btconnection) void onBtConnectionClick() { - log.debug("Clicked connect to pump"); + if (Config.logPump) + log.debug("Clicked connect to pump"); DanaRPump.getInstance().lastConnection = 0; ConfigBuilderPlugin.getCommandQueue().readStatus("Clicked connect to pump", null); } @@ -162,10 +161,11 @@ public class DanaRFragment extends SubscriberFragment { activity.runOnUiThread( new Runnable() { @Override - public void run() { - synchronized(DanaRFragment.this){ + public void run() { + synchronized (DanaRFragment.this) { - if(btConnectionView == null || pumpStatusView == null || pumpStatusLayout == null ) return; + if (btConnectionView == null || pumpStatusView == null || pumpStatusLayout == null) + return; if (c.sStatus == EventPumpStatusChanged.CONNECTING) btConnectionView.setText("{fa-bluetooth-b spin} " + c.sSecondsElapsed + "s"); @@ -216,7 +216,7 @@ public class DanaRFragment extends SubscriberFragment { @SuppressLint("SetTextI18n") @Override public void run() { - synchronized(DanaRFragment.this) { + synchronized (DanaRFragment.this) { if (!isBound()) return; DanaRPump pump = DanaRPump.getInstance(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java index 144107779d..b600417a3a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java @@ -49,7 +49,6 @@ public class DanaRPlugin extends AbstractDanaRPlugin { public DanaRPlugin() { super(); - log = LoggerFactory.getLogger(DanaRPlugin.class); useExtendedBoluses = SP.getBoolean("danar_useextended", false); pumpDescription.isBolusCapable = true; @@ -85,7 +84,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin { @Override public void switchAllowed(ConfigBuilderFragment.PluginViewHolder.PluginSwitcher pluginSwitcher, FragmentActivity context) { boolean allowHardwarePump = SP.getBoolean("allow_hardware_pump", false); - if (allowHardwarePump || context == null){ + if (allowHardwarePump || context == null) { pluginSwitcher.invoke(); } else { AlertDialog.Builder builder = new AlertDialog.Builder(context); @@ -94,13 +93,15 @@ public class DanaRPlugin extends AbstractDanaRPlugin { public void onClick(DialogInterface dialog, int id) { pluginSwitcher.invoke(); SP.putBoolean("allow_hardware_pump", true); - log.debug("First time HW pump allowed!"); + if (Config.logPump) + log.debug("First time HW pump allowed!"); } }) .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { pluginSwitcher.cancel(); - log.debug("User does not allow switching to HW pump!"); + if (Config.logPump) + log.debug("User does not allow switching to HW pump!"); } }); builder.create().show(); @@ -127,12 +128,14 @@ public class DanaRPlugin extends AbstractDanaRPlugin { private ServiceConnection mConnection = new ServiceConnection() { public void onServiceDisconnected(ComponentName name) { - log.debug("Service is disconnected"); + if (Config.logPump) + log.debug("Service is disconnected"); sExecutionService = null; } public void onServiceConnected(ComponentName name, IBinder service) { - log.debug("Service is connected"); + if (Config.logPump) + log.debug("Service is connected"); DanaRExecutionService.LocalBinder mLocalBinder = (DanaRExecutionService.LocalBinder) service; sExecutionService = mLocalBinder.getServiceInstance(); } @@ -195,7 +198,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin { result.comment = String.format(MainApp.gs(R.string.boluserrorcode), detailedBolusInfo.insulin, t.insulin, MsgBolusStartWithSpeed.errorCode); else result.comment = MainApp.gs(R.string.virtualpump_resultok); - if (Config.logPumpActions) + if (Config.logPump) log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered); detailedBolusInfo.insulin = t.insulin; detailedBolusInfo.date = System.currentTimeMillis(); @@ -237,13 +240,13 @@ public class DanaRPlugin extends AbstractDanaRPlugin { if (doTempOff) { // If extended in progress if (activeExtended != null && useExtendedBoluses) { - if (Config.logPumpActions) + if (Config.logPump) log.debug("setTempBasalAbsolute: Stopping extended bolus (doTempOff)"); return cancelExtendedBolus(); } // If temp in progress if (activeTemp != null) { - if (Config.logPumpActions) + if (Config.logPump) log.debug("setTempBasalAbsolute: Stopping temp basal (doTempOff)"); return cancelRealTempBasal(); } @@ -252,7 +255,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin { result.percent = 100; result.isPercent = true; result.isTempCancel = true; - if (Config.logPumpActions) + if (Config.logPump) log.debug("setTempBasalAbsolute: doTempOff OK"); return result; } @@ -264,12 +267,12 @@ public class DanaRPlugin extends AbstractDanaRPlugin { if (percentRate > getPumpDescription().maxTempPercent) { percentRate = getPumpDescription().maxTempPercent; } - if (Config.logPumpActions) + if (Config.logPump) log.debug("setTempBasalAbsolute: Calculated percent rate: " + percentRate); // If extended in progress if (activeExtended != null && useExtendedBoluses) { - if (Config.logPumpActions) + if (Config.logPump) log.debug("setTempBasalAbsolute: Stopping extended bolus (doLowTemp || doHighTemp)"); result = cancelExtendedBolus(); if (!result.success) { @@ -280,7 +283,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin { // Check if some temp is already in progress if (activeTemp != null) { // Correct basal already set ? - if (Config.logPumpActions) + if (Config.logPump) log.debug("setTempBasalAbsolute: currently running: " + activeTemp.toString()); if (activeTemp.percentRate == percentRate) { if (enforceNew) { @@ -292,21 +295,21 @@ public class DanaRPlugin extends AbstractDanaRPlugin { result.duration = activeTemp.getPlannedRemainingMinutes(); result.isPercent = true; result.isTempCancel = false; - if (Config.logPumpActions) + if (Config.logPump) log.debug("setTempBasalAbsolute: Correct temp basal already set (doLowTemp || doHighTemp)"); return result; } } } // Convert duration from minutes to hours - if (Config.logPumpActions) + if (Config.logPump) log.debug("setTempBasalAbsolute: Setting temp basal " + percentRate + "% for " + durationInMinutes + " mins (doLowTemp || doHighTemp)"); return setTempBasalPercent(percentRate, durationInMinutes, profile, false); } if (doExtendedTemp) { // Check if some temp is already in progress if (activeTemp != null) { - if (Config.logPumpActions) + if (Config.logPump) log.debug("setTempBasalAbsolute: Stopping temp basal (doExtendedTemp)"); result = cancelRealTempBasal(); // Check for proper result @@ -325,7 +328,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin { extendedRateToSet = Round.roundTo(extendedRateToSet, pumpDescription.extendedBolusStep * 2); // *2 because of halfhours // What is current rate of extended bolusing in u/h? - if (Config.logPumpActions) { + if (Config.logPump) { log.debug("setTempBasalAbsolute: Extended bolus in progress: " + (activeExtended != null) + " rate: " + pump.extendedBolusAbsoluteRate + "U/h duration remaining: " + pump.extendedBolusRemainingMinutes + "min"); log.debug("setTempBasalAbsolute: Rate to set: " + extendedRateToSet + "U/h"); } @@ -339,21 +342,21 @@ public class DanaRPlugin extends AbstractDanaRPlugin { result.duration = pump.extendedBolusRemainingMinutes; result.isPercent = false; result.isTempCancel = false; - if (Config.logPumpActions) + if (Config.logPump) log.debug("setTempBasalAbsolute: Correct extended already set"); return result; } // Now set new extended, no need to to stop previous (if running) because it's replaced Double extendedAmount = extendedRateToSet / 2 * durationInHalfHours; - if (Config.logPumpActions) + if (Config.logPump) log.debug("setTempBasalAbsolute: Setting extended: " + extendedAmount + "U halfhours: " + durationInHalfHours); result = setExtendedBolus(extendedAmount, durationInMinutes); if (!result.success) { log.error("setTempBasalAbsolute: Failed to set extended bolus"); return result; } - if (Config.logPumpActions) + if (Config.logPump) log.debug("setTempBasalAbsolute: Extended bolus set ok"); result.absolute = result.absolute + getBaseBasalRate(); return result; @@ -392,7 +395,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin { result.success = true; result.isTempCancel = true; result.comment = MainApp.gs(R.string.virtualpump_resultok); - if (Config.logPumpActions) + if (Config.logPump) log.debug("cancelRealTempBasal: OK"); return result; } else { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPump.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPump.java index d9bc947b84..f5c7f7f652 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPump.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPump.java @@ -20,7 +20,7 @@ import info.nightscout.utils.SP; * Created by mike on 04.07.2016. */ public class DanaRPump { - private static Logger log = LoggerFactory.getLogger(DanaRPump.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMP); private static DanaRPump instance = null; @@ -236,13 +236,13 @@ public class DanaRPump { return PROFILE_PREFIX + (activeProfile + 1); } - public static double[] buildDanaRProfileRecord(Profile nsProfile) { + public double[] buildDanaRProfileRecord(Profile nsProfile) { double[] record = new double[24]; for (Integer hour = 0; hour < 24; hour++) { //Some values get truncated to the next lower one. // -> round them to two decimals and make sure we are a small delta larger (that will get truncated) double value = Math.round(100d * nsProfile.getBasalTimeFromMidnight((Integer) (hour * 60 * 60)))/100d + 0.00001; - if (Config.logDanaMessageDetail) + if (Config.logPump) log.debug("NS basal value for " + hour + ":00 is " + value); record[hour] = value; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/Dialogs/ProfileViewDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/Dialogs/ProfileViewDialog.java index d8157281bd..24728f2cf6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/Dialogs/ProfileViewDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/Dialogs/ProfileViewDialog.java @@ -33,8 +33,6 @@ import info.nightscout.utils.DecimalFormatter; * Created by mike on 10.07.2016. */ public class ProfileViewDialog extends DialogFragment { - private static Logger log = LoggerFactory.getLogger(ProfileViewDialog.class); - private TextView noProfile; private TextView units; private TextView dia; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/SerialIOThread.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/SerialIOThread.java index 2f377a566a..295393cc1a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/SerialIOThread.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/SerialIOThread.java @@ -11,6 +11,7 @@ import java.io.InputStream; import java.io.OutputStream; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageHashTable; import info.nightscout.androidaps.plugins.PumpDanaR.services.AbstractSerialIOThread; @@ -20,7 +21,7 @@ import info.nightscout.utils.CRC; * Created by mike on 17.07.2016. */ public class SerialIOThread extends AbstractSerialIOThread { - private static Logger log = LoggerFactory.getLogger(SerialIOThread.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPBTCOMM); private InputStream mInputStream = null; private OutputStream mOutputStream = null; @@ -71,7 +72,7 @@ public class SerialIOThread extends AbstractSerialIOThread { message = MessageHashTable.findMessage(command); } - if (Config.logDanaMessageDetail) + if (Config.logPumpBtComm) log.debug("<<<<< " + message.getMessageName() + " " + message.toHexString(extractedBuff)); // process the message content @@ -83,7 +84,7 @@ public class SerialIOThread extends AbstractSerialIOThread { } } } catch (Exception e) { - if (Config.logDanaSerialEngine && e.getMessage().indexOf("bt socket closed") < 0) + if (e.getMessage().indexOf("bt socket closed") < 0) log.error("Thread exception: ", e); mKeepRunning = false; } @@ -147,7 +148,7 @@ public class SerialIOThread extends AbstractSerialIOThread { processedMessage = message; byte[] messageBytes = message.getRawMessageBytes(); - if (Config.logDanaSerialEngine) + if (Config.logPumpBtComm) log.debug(">>>>> " + message.getMessageName() + " " + message.toHexString(messageBytes)); try { @@ -169,7 +170,8 @@ public class SerialIOThread extends AbstractSerialIOThread { log.warn("Reply not received " + message.getMessageName()); if (message.getCommand() == 0xF0F1) { DanaRPump.getInstance().isNewPump = false; - log.debug("Old firmware detected"); + if (Config.logPumpComm) + log.debug("Old firmware detected"); } } } @@ -180,24 +182,29 @@ public class SerialIOThread extends AbstractSerialIOThread { try { mInputStream.close(); } catch (Exception e) { - if (Config.logDanaSerialEngine) log.debug(e.getMessage()); + if (Config.logPumpBtComm) + log.debug(e.getMessage()); } try { mOutputStream.close(); } catch (Exception e) { - if (Config.logDanaSerialEngine) log.debug(e.getMessage()); + if (Config.logPumpBtComm) + log.debug(e.getMessage()); } try { mRfCommSocket.close(); } catch (Exception e) { - if (Config.logDanaSerialEngine) log.debug(e.getMessage()); + if (Config.logPumpBtComm) + log.debug(e.getMessage()); } try { System.runFinalization(); } catch (Exception e) { - if (Config.logDanaSerialEngine) log.debug(e.getMessage()); + if (Config.logPumpBtComm) + log.debug(e.getMessage()); } - if (Config.logDanaSerialEngine) log.debug("Disconnected: " + reason); + if (Config.logPumpBtComm) + log.debug("Disconnected: " + reason); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRHistoryActivity.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRHistoryActivity.java index 97c5569b4b..154c08ee95 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRHistoryActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRHistoryActivity.java @@ -24,6 +24,7 @@ import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.List; +import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; @@ -42,12 +43,9 @@ import info.nightscout.utils.DecimalFormatter; import info.nightscout.utils.ToastUtils; public class DanaRHistoryActivity extends Activity { - private static Logger log = LoggerFactory.getLogger(DanaRHistoryActivity.class); - - private boolean mBounded; + private static Logger log = LoggerFactory.getLogger(Constants.PUMP); private Handler mHandler; - private static HandlerThread mHandlerThread; static Profile profile = null; @@ -65,7 +63,7 @@ public class DanaRHistoryActivity extends Activity { public byte type; String name; - public TypeList(byte type, String name) { + TypeList(byte type, String name) { this.type = type; this.name = name; } @@ -78,7 +76,7 @@ public class DanaRHistoryActivity extends Activity { public DanaRHistoryActivity() { super(); - mHandlerThread = new HandlerThread(DanaRHistoryActivity.class.getSimpleName()); + HandlerThread mHandlerThread = new HandlerThread(DanaRHistoryActivity.class.getSimpleName()); mHandlerThread.start(); this.mHandler = new Handler(mHandlerThread.getLooper()); } @@ -116,8 +114,8 @@ public class DanaRHistoryActivity extends Activity { statusView.setVisibility(View.GONE); - boolean isKorean = MainApp.getSpecificPlugin(DanaRKoreanPlugin.class) != null && MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).isEnabled(PluginType.PUMP); - boolean isRS = MainApp.getSpecificPlugin(DanaRSPlugin.class) != null && MainApp.getSpecificPlugin(DanaRSPlugin.class).isEnabled(PluginType.PUMP); + boolean isKorean = DanaRKoreanPlugin.getPlugin().isEnabled(PluginType.PUMP); + boolean isRS = DanaRSPlugin.getPlugin().isEnabled(PluginType.PUMP); // Types @@ -141,10 +139,30 @@ public class DanaRHistoryActivity extends Activity { R.layout.spinner_centered, typeList); historyTypeSpinner.setAdapter(spinnerAdapter); - reloadButton.setOnClickListener(new View.OnClickListener() { + reloadButton.setOnClickListener(v -> { + final TypeList selected = (TypeList) historyTypeSpinner.getSelectedItem(); + runOnUiThread(() -> { + reloadButton.setVisibility(View.GONE); + syncButton.setVisibility(View.GONE); + statusView.setVisibility(View.VISIBLE); + }); + clearCardView(); + ConfigBuilderPlugin.getCommandQueue().loadHistory(selected.type, new Callback() { + @Override + public void run() { + loadDataFromDB(selected.type); + runOnUiThread(() -> { + reloadButton.setVisibility(View.VISIBLE); + syncButton.setVisibility(View.VISIBLE); + statusView.setVisibility(View.GONE); + }); + } + }); + }); + + syncButton.setOnClickListener(v -> mHandler.post(new Runnable() { @Override - public void onClick(View v) { - final TypeList selected = (TypeList) historyTypeSpinner.getSelectedItem(); + public void run() { runOnUiThread(new Runnable() { @Override public void run() { @@ -153,52 +171,18 @@ public class DanaRHistoryActivity extends Activity { statusView.setVisibility(View.VISIBLE); } }); - clearCardView(); - ConfigBuilderPlugin.getCommandQueue().loadHistory(selected.type, new Callback() { + DanaRNSHistorySync sync = new DanaRNSHistorySync(historyList); + sync.sync(DanaRNSHistorySync.SYNC_ALL); + runOnUiThread(new Runnable() { @Override public void run() { - loadDataFromDB(selected.type); - runOnUiThread(new Runnable() { - @Override - public void run() { - reloadButton.setVisibility(View.VISIBLE); - syncButton.setVisibility(View.VISIBLE); - statusView.setVisibility(View.GONE); - } - }); + reloadButton.setVisibility(View.VISIBLE); + syncButton.setVisibility(View.VISIBLE); + statusView.setVisibility(View.GONE); } }); } - }); - - syncButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - mHandler.post(new Runnable() { - @Override - public void run() { - runOnUiThread(new Runnable() { - @Override - public void run() { - reloadButton.setVisibility(View.GONE); - syncButton.setVisibility(View.GONE); - statusView.setVisibility(View.VISIBLE); - } - }); - DanaRNSHistorySync sync = new DanaRNSHistorySync(historyList); - sync.sync(DanaRNSHistorySync.SYNC_ALL); - runOnUiThread(new Runnable() { - @Override - public void run() { - reloadButton.setVisibility(View.VISIBLE); - syncButton.setVisibility(View.VISIBLE); - statusView.setVisibility(View.GONE); - } - }); - } - }); - } - }); + })); historyTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override @@ -324,7 +308,7 @@ public class DanaRHistoryActivity extends Activity { super.onAttachedToRecyclerView(recyclerView); } - public static class HistoryViewHolder extends RecyclerView.ViewHolder { + static class HistoryViewHolder extends RecyclerView.ViewHolder { CardView cv; TextView time; TextView value; @@ -355,45 +339,26 @@ public class DanaRHistoryActivity extends Activity { private void loadDataFromDB(byte type) { historyList = MainApp.getDbHelper().getDanaRHistoryRecordsByType(type); - runOnUiThread(new Runnable() { - @Override - public void run() { - recyclerView.swapAdapter(new RecyclerViewAdapter(historyList), false); - } - }); + runOnUiThread(() -> recyclerView.swapAdapter(new RecyclerViewAdapter(historyList), false)); } private void clearCardView() { historyList = new ArrayList<>(); - runOnUiThread(new Runnable() { - @Override - public void run() { - recyclerView.swapAdapter(new RecyclerViewAdapter(historyList), false); - } - }); + runOnUiThread(() -> recyclerView.swapAdapter(new RecyclerViewAdapter(historyList), false)); } @Subscribe public void onStatusEvent(final EventDanaRSyncStatus s) { - log.debug("EventDanaRSyncStatus: " + s.message); + if (Config.logPump) + log.debug("EventDanaRSyncStatus: " + s.message); runOnUiThread( - new Runnable() { - @Override - public void run() { - statusView.setText(s.message); - } - }); + () -> statusView.setText(s.message)); } @Subscribe public void onStatusEvent(final EventPumpStatusChanged s) { runOnUiThread( - new Runnable() { - @Override - public void run() { - statusView.setText(s.textStatus()); - } - } + () -> statusView.setText(s.textStatus()) ); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRNSHistorySync.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRNSHistorySync.java index d505443c1d..0967952240 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRNSHistorySync.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRNSHistorySync.java @@ -8,24 +8,24 @@ import org.slf4j.LoggerFactory; import java.util.Calendar; import java.util.List; +import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; +import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.db.CareportalEvent; import info.nightscout.androidaps.db.DanaRHistoryRecord; -import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; -import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes; import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRSyncStatus; import info.nightscout.utils.DateUtil; import info.nightscout.utils.NSUpload; -import info.nightscout.utils.ToastUtils; /** * Created by mike on 20.07.2016. */ public class DanaRNSHistorySync { - private static Logger log = LoggerFactory.getLogger(DanaRNSHistorySync.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMP); private List historyRecords; public final static int SYNC_BOLUS = 0b00000001; @@ -50,7 +50,8 @@ public class DanaRNSHistorySync { long records = historyRecords.size(); long processing = 0; long uploaded = 0; - log.debug("Database contains " + records + " records"); + if (Config.logPump) + log.debug("Database contains " + records + " records"); EventDanaRSyncStatus ev = new EventDanaRSyncStatus(); for (DanaRHistoryRecord record : historyRecords) { processing++; @@ -63,7 +64,8 @@ public class DanaRNSHistorySync { if ((what & SYNC_BOLUS) == 0) break; switch (record.bolusType) { case "S": - log.debug("Syncing standard bolus record " + record.recordValue + "U " + DateUtil.toISOString(record.recordDate)); + if (Config.logPump) + log.debug("Syncing standard bolus record " + record.recordValue + "U " + DateUtil.toISOString(record.recordDate)); nsrec.put(DANARSIGNATURE, record.bytes); nsrec.put("eventType", "Meal Bolus"); nsrec.put("insulin", record.recordValue); @@ -75,7 +77,8 @@ public class DanaRNSHistorySync { break; case "E": if (record.recordDuration > 0) { - log.debug("Syncing extended bolus record " + record.recordValue + "U " + DateUtil.toISOString(record.recordDate)); + if (Config.logPump) + log.debug("Syncing extended bolus record " + record.recordValue + "U " + DateUtil.toISOString(record.recordDate)); nsrec.put(DANARSIGNATURE, record.bytes); nsrec.put("eventType", CareportalEvent.COMBOBOLUS); nsrec.put("insulin", 0); @@ -91,11 +94,13 @@ public class DanaRNSHistorySync { uploaded++; ev.message += MainApp.gs(R.string.danar_ebolus); } else { - log.debug("NOT Syncing extended bolus record " + record.recordValue + "U " + DateUtil.toISOString(record.recordDate) + " zero duration"); + if (Config.logPump) + log.debug("NOT Syncing extended bolus record " + record.recordValue + "U " + DateUtil.toISOString(record.recordDate) + " zero duration"); } break; case "DS": - log.debug("Syncing dual(S) bolus record " + record.recordValue + "U " + DateUtil.toISOString(record.recordDate)); + if (Config.logPump) + log.debug("Syncing dual(S) bolus record " + record.recordValue + "U " + DateUtil.toISOString(record.recordDate)); nsrec.put(DANARSIGNATURE, record.bytes); nsrec.put("eventType", CareportalEvent.COMBOBOLUS); nsrec.put("insulin", record.recordValue); @@ -108,7 +113,8 @@ public class DanaRNSHistorySync { ev.message += MainApp.gs(R.string.danar_dsbolus); break; case "DE": - log.debug("Syncing dual(E) bolus record " + record.recordValue + "U " + DateUtil.toISOString(record.recordDate)); + if (Config.logPump) + log.debug("Syncing dual(E) bolus record " + record.recordValue + "U " + DateUtil.toISOString(record.recordDate)); nsrec.put(DANARSIGNATURE, record.bytes); nsrec.put("eventType", CareportalEvent.COMBOBOLUS); nsrec.put("duration", record.recordDuration); @@ -124,13 +130,14 @@ public class DanaRNSHistorySync { ev.message += MainApp.gs(R.string.danar_debolus); break; default: - log.debug("Unknown bolus record"); + log.error("Unknown bolus record"); break; } break; case RecordTypes.RECORD_TYPE_ERROR: if ((what & SYNC_ERROR) == 0) break; - log.debug("Syncing error record " + DateUtil.toISOString(record.recordDate)); + if (Config.logPump) + log.debug("Syncing error record " + DateUtil.toISOString(record.recordDate)); nsrec.put(DANARSIGNATURE, record.bytes); nsrec.put("eventType", "Note"); nsrec.put("notes", "Error"); @@ -142,7 +149,8 @@ public class DanaRNSHistorySync { break; case RecordTypes.RECORD_TYPE_REFILL: if ((what & SYNC_REFILL) == 0) break; - log.debug("Syncing refill record " + record.recordValue + " " + DateUtil.toISOString(record.recordDate)); + if (Config.logPump) + log.debug("Syncing refill record " + record.recordValue + " " + DateUtil.toISOString(record.recordDate)); nsrec.put(DANARSIGNATURE, record.bytes); nsrec.put("eventType", "Insulin Change"); nsrec.put("notes", "Refill " + record.recordValue + "U"); @@ -154,7 +162,8 @@ public class DanaRNSHistorySync { break; case RecordTypes.RECORD_TYPE_BASALHOUR: if ((what & SYNC_BASALHOURS) == 0) break; - log.debug("Syncing basal hour record " + record.recordValue + " " + DateUtil.toISOString(record.recordDate)); + if (Config.logPump) + log.debug("Syncing basal hour record " + record.recordValue + " " + DateUtil.toISOString(record.recordDate)); nsrec.put(DANARSIGNATURE, record.bytes); nsrec.put("eventType", CareportalEvent.TEMPBASAL); nsrec.put("absolute", record.recordValue); @@ -170,7 +179,8 @@ public class DanaRNSHistorySync { break; case RecordTypes.RECORD_TYPE_GLUCOSE: if ((what & SYNC_GLUCOSE) == 0) break; - log.debug("Syncing glucose record " + record.recordValue + " " + DateUtil.toISOString(record.recordDate)); + if (Config.logPump) + log.debug("Syncing glucose record " + record.recordValue + " " + DateUtil.toISOString(record.recordDate)); nsrec.put(DANARSIGNATURE, record.bytes); nsrec.put("eventType", "BG Check"); nsrec.put("glucose", Profile.fromMgdlToUnits(record.recordValue, MainApp.getConfigBuilder().getProfileUnits())); @@ -183,7 +193,8 @@ public class DanaRNSHistorySync { break; case RecordTypes.RECORD_TYPE_CARBO: if ((what & SYNC_CARBO) == 0) break; - log.debug("Syncing carbo record " + record.recordValue + "g " + DateUtil.toISOString(record.recordDate)); + if (Config.logPump) + log.debug("Syncing carbo record " + record.recordValue + "g " + DateUtil.toISOString(record.recordDate)); nsrec.put(DANARSIGNATURE, record.bytes); nsrec.put("eventType", "Meal Bolus"); nsrec.put("carbs", record.recordValue); @@ -195,7 +206,8 @@ public class DanaRNSHistorySync { break; case RecordTypes.RECORD_TYPE_ALARM: if ((what & SYNC_ALARM) == 0) break; - log.debug("Syncing alarm record " + record.recordAlarm + " " + DateUtil.toISOString(record.recordDate)); + if (Config.logPump) + log.debug("Syncing alarm record " + record.recordAlarm + " " + DateUtil.toISOString(record.recordDate)); nsrec.put(DANARSIGNATURE, record.bytes); nsrec.put("eventType", "Note"); nsrec.put("notes", "Alarm: " + record.recordAlarm); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRUserOptionsActivity.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRUserOptionsActivity.java index bd6a315319..f0af9c863a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRUserOptionsActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRUserOptionsActivity.java @@ -14,6 +14,7 @@ import org.slf4j.LoggerFactory; import java.text.DecimalFormat; +import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; @@ -30,7 +31,7 @@ import info.nightscout.utils.NumberPicker; */ public class DanaRUserOptionsActivity extends Activity { - private static Logger log = LoggerFactory.getLogger(DanaRUserOptionsActivity.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMP); Switch timeFormat; Switch buttonScroll; @@ -85,14 +86,15 @@ public class DanaRUserOptionsActivity extends Activity { DanaRPump pump = DanaRPump.getInstance(); //used for debugging - log.debug("UserOptionsLoaded:" + (System.currentTimeMillis() - pump.lastConnection) / 1000 + " s ago" - + "\ntimeDisplayType:" + pump.timeDisplayType - + "\nbuttonScroll:" + pump.buttonScrollOnOff - + "\ntimeDisplayType:" + pump.timeDisplayType - + "\nlcdOnTimeSec:" + pump.lcdOnTimeSec - + "\nbacklight:" + pump.backlightOnTimeSec - + "\npumpUnits:" + pump.units - + "\nlowReservoir:" + pump.lowReservoirRate); + if (Config.logPump) + log.debug("UserOptionsLoaded:" + (System.currentTimeMillis() - pump.lastConnection) / 1000 + " s ago" + + "\ntimeDisplayType:" + pump.timeDisplayType + + "\nbuttonScroll:" + pump.buttonScrollOnOff + + "\ntimeDisplayType:" + pump.timeDisplayType + + "\nlcdOnTimeSec:" + pump.lcdOnTimeSec + + "\nbacklight:" + pump.backlightOnTimeSec + + "\npumpUnits:" + pump.units + + "\nlowReservoir:" + pump.lowReservoirRate); screenTimeout.setParams((double) pump.lcdOnTimeSec, 5d, 240d, 5d, new DecimalFormat("1"), false); backlightTimeout.setParams((double) pump.backlightOnTimeSec, 1d, 60d, 1d, new DecimalFormat("1"), false); @@ -122,7 +124,7 @@ public class DanaRUserOptionsActivity extends Activity { break; } if (pump.lastSettingsRead == 0) - log.debug("No settings loaded from pump!"); + log.error("No settings loaded from pump!"); else setData(); } @@ -175,13 +177,13 @@ public class DanaRUserOptionsActivity extends Activity { // step is 5 seconds - int screenTimeoutValue = !screenTimeout.getText().isEmpty() ? (Integer.parseInt(screenTimeout.getText().toString()) / 5) * 5: 5; + int screenTimeoutValue = !screenTimeout.getText().isEmpty() ? (Integer.parseInt(screenTimeout.getText().toString()) / 5) * 5 : 5; if (screenTimeoutValue > 4 && screenTimeoutValue < 241) { pump.lcdOnTimeSec = screenTimeoutValue; } else { pump.lcdOnTimeSec = 5; } - int backlightTimeoutValue = !backlightTimeout.getText().isEmpty() ? Integer.parseInt(backlightTimeout.getText().toString()): 1; + int backlightTimeoutValue = !backlightTimeout.getText().isEmpty() ? Integer.parseInt(backlightTimeout.getText().toString()) : 1; if (backlightTimeoutValue > 0 && backlightTimeoutValue < 61) { pump.backlightOnTimeSec = backlightTimeoutValue; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MessageBase.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MessageBase.java index 2e6c02458e..31da5c9f21 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MessageBase.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MessageBase.java @@ -13,6 +13,7 @@ import java.util.Date; import java.util.GregorianCalendar; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.utils.CRC; /* @@ -22,7 +23,7 @@ import info.nightscout.utils.CRC; */ public class MessageBase { - private static Logger log = LoggerFactory.getLogger(MessageBase.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); protected byte[] buffer = new byte[512]; private int position = 6; @@ -95,7 +96,7 @@ public class MessageBase { } public void handleMessage(byte[] bytes) { - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { if (bytes.length > 6) { int command = (bytes[5] & 0xFF) | ((bytes[4] << 8) & 0xFF00); log.debug("UNPROCESSED MSG: " + getMessageName() + " Command: " + String.format("%04X", command) + " Data: " + toHexString(bytes)); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MessageHashTable.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MessageHashTable.java index 4b90b8f02d..e7f1adca07 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MessageHashTable.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MessageHashTable.java @@ -9,8 +9,6 @@ import java.util.HashMap; * Created by mike on 28.05.2016. */ public class MessageHashTable { - private static Logger log = LoggerFactory.getLogger(MessageHashTable.class); - public static HashMap messages = null; static { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MessageOriginalNames.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MessageOriginalNames.java index 3712945094..1c656060f0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MessageOriginalNames.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MessageOriginalNames.java @@ -5,13 +5,15 @@ import org.slf4j.LoggerFactory; import java.util.HashMap; +import info.nightscout.androidaps.Constants; + /** * Created by mike on 28.05.2016. */ public class MessageOriginalNames { - private static Logger log = LoggerFactory.getLogger(MessageOriginalNames.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); - public static HashMap messageNames; + private static HashMap messageNames; static { messageNames = new HashMap<>(); @@ -162,7 +164,7 @@ public class MessageOriginalNames { if (messageNames.containsKey(command)) return messageNames.get(command); else { - log.debug("Unknown command: " + String.format("%04X", command)); + log.error("Unknown command: " + String.format("%04X", command)); return "UNKNOWN_COMMAND"; } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusProgress.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusProgress.java index cb01a7d901..dbff4ec3dc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusProgress.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusProgress.java @@ -4,13 +4,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; -import info.nightscout.androidaps.plugins.Treatments.Treatment; import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress; +import info.nightscout.androidaps.plugins.Treatments.Treatment; public class MsgBolusProgress extends MessageBase { - private static Logger log = LoggerFactory.getLogger(MsgBolusProgress.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private static Treatment t; private static double amount; @@ -27,6 +28,8 @@ public class MsgBolusProgress extends MessageBase { this.amount = amount; this.t = t; lastReceive = System.currentTimeMillis(); + if (Config.logPumpComm) + log.debug("New message: amount: " + amount + " treatment: " + t.toString()); } @Override @@ -40,7 +43,7 @@ public class MsgBolusProgress extends MessageBase { bolusingEvent.t = t; bolusingEvent.percent = Math.min((int) (done / amount * 100), 100); - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Bolus remaining: " + progress + " delivered: " + done); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStart.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStart.java index 7586edf825..7932db46a3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStart.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStart.java @@ -4,12 +4,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.interfaces.Constraint; -import info.nightscout.utils.HardLimits; public class MsgBolusStart extends MessageBase { - private static Logger log = LoggerFactory.getLogger(MsgBolusStart.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public static int errorCode; @@ -25,7 +25,7 @@ public class MsgBolusStart extends MessageBase { AddParamInt((int) (amount * 100)); - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("Bolus start : " + amount); } @@ -34,9 +34,10 @@ public class MsgBolusStart extends MessageBase { errorCode = intFromBuff(bytes, 0, 1); if (errorCode != 2) { failed = true; - log.debug("Messsage response: " + errorCode + " FAILED!!"); + if (Config.logPumpComm) + log.debug("Messsage response: " + errorCode + " FAILED!!"); } else { - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("Messsage response: " + errorCode + " OK"); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStartWithSpeed.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStartWithSpeed.java index dd4251a350..5f2a368a58 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStartWithSpeed.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStartWithSpeed.java @@ -4,12 +4,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.interfaces.Constraint; -import info.nightscout.utils.HardLimits; public class MsgBolusStartWithSpeed extends MessageBase { - private static Logger log = LoggerFactory.getLogger(MsgBolusStartWithSpeed.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public static int errorCode; @@ -26,7 +26,7 @@ public class MsgBolusStartWithSpeed extends MessageBase { AddParamInt((int) (amount * 100)); AddParamByte((byte) speed); - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("Bolus start : " + amount + " speed: " + speed); } @@ -35,9 +35,10 @@ public class MsgBolusStartWithSpeed extends MessageBase { errorCode = intFromBuff(bytes, 0, 1); if (errorCode != 2) { failed = true; - log.debug("Messsage response: " + errorCode + " FAILED!!"); + if (Config.logPumpComm) + log.debug("Messsage response: " + errorCode + " FAILED!!"); } else { - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("Messsage response: " + errorCode + " OK"); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStop.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStop.java index 5c677b813e..d03a12ea84 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStop.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStop.java @@ -3,13 +3,15 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; -import info.nightscout.androidaps.plugins.Treatments.Treatment; import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress; +import info.nightscout.androidaps.plugins.Treatments.Treatment; public class MsgBolusStop extends MessageBase { - private static Logger log = LoggerFactory.getLogger(MsgBolusStop.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private static Treatment t; private static Double amount; @@ -26,10 +28,14 @@ public class MsgBolusStop extends MessageBase { this.t = t; this.amount = amount; forced = false; + if (Config.logPumpComm) + log.debug("Bolus stop: amount: " + amount + " treatment: " + t.toString()); } @Override public void handleMessage(byte[] bytes) { + if (Config.logPumpComm) + log.debug("Messsage received"); EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance(); stopped = true; if (!forced) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgCheckValue.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgCheckValue.java index 3f0c306940..a8171774b6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgCheckValue.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgCheckValue.java @@ -4,20 +4,21 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; -import info.nightscout.androidaps.R; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; -import info.nightscout.utils.ToastUtils; /** * Created by mike on 30.06.2016. */ public class MsgCheckValue extends MessageBase { - private static Logger log = LoggerFactory.getLogger(MsgCheckValue.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public MsgCheckValue() { SetCommand(0xF0F1); + if (Config.logPumpComm) + log.debug("New message"); } @Override @@ -25,7 +26,8 @@ public class MsgCheckValue extends MessageBase { DanaRPump pump = DanaRPump.getInstance(); pump.isNewPump = true; - log.debug("New firmware confirmed"); + if (Config.logPumpComm) + log.debug("New firmware confirmed"); pump.model = intFromBuff(bytes, 0, 1); pump.protocol = intFromBuff(bytes, 1, 1); @@ -35,7 +37,7 @@ public class MsgCheckValue extends MessageBase { log.debug("Wrong model selected"); } - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Model: " + String.format("%02X ", pump.model)); log.debug("Protocol: " + String.format("%02X ", pump.protocol)); log.debug("Product Code: " + String.format("%02X ", pump.productCode)); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgError.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgError.java index e42327c3b0..dcd6a4c819 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgError.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgError.java @@ -4,16 +4,19 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress; import info.nightscout.utils.NSUpload; public class MsgError extends MessageBase { - private static Logger log = LoggerFactory.getLogger(MsgError.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public MsgError() { SetCommand(0x0601); + if (Config.logPumpComm) + log.debug("New message"); } @Override @@ -47,7 +50,7 @@ public class MsgError extends MessageBase { bolusingEvent.status = errorString; MainApp.bus().post(bolusingEvent); } - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("Error detected: " + errorString); NSUpload.uploadError(errorString); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryAlarm.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryAlarm.java index 24ea6d0f37..686bb3eb85 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryAlarm.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryAlarm.java @@ -3,13 +3,18 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; + /** * Created by mike on 20.07.2016. */ public class MsgHistoryAlarm extends MsgHistoryAll { - private static Logger log = LoggerFactory.getLogger(MsgHistoryAlarm.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public MsgHistoryAlarm() { SetCommand(0x3105); + if (Config.logPumpComm) + log.debug("New message"); } // Handle message taken from MsgHistoryAll } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryAll.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryAll.java index 4e4bc759f5..e9da6ef92a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryAll.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryAll.java @@ -5,16 +5,20 @@ import org.slf4j.LoggerFactory; import java.util.Date; +import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.db.DanaRHistoryRecord; import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRSyncStatus; import info.nightscout.utils.DateUtil; public class MsgHistoryAll extends MessageBase { - private static Logger log = LoggerFactory.getLogger(MsgHistoryAll.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public MsgHistoryAll() { SetCommand(0x41F2); + if (Config.logPumpComm) + log.debug("New message"); } @Override diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryAllDone.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryAllDone.java index 6ce3325715..c4c27da436 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryAllDone.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryAllDone.java @@ -4,20 +4,23 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; public class MsgHistoryAllDone extends MessageBase { - private static Logger log = LoggerFactory.getLogger(MsgHistoryAllDone.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public static boolean received = false; public MsgHistoryAllDone() { SetCommand(0x41F1); received = false; + if (Config.logPumpComm) + log.debug("New message"); } @Override public void handleMessage(byte[] bytes) { received = true; - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("History all done received"); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryBasalHour.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryBasalHour.java index 3fd97135f0..d288914395 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryBasalHour.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryBasalHour.java @@ -3,13 +3,18 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; + /** * Created by mike on 20.07.2016. */ public class MsgHistoryBasalHour extends MsgHistoryAll { - private static Logger log = LoggerFactory.getLogger(MsgHistoryBasalHour.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public MsgHistoryBasalHour() { SetCommand(0x310A); + if (Config.logPumpComm) + log.debug("New message"); } // Handle message taken from MsgHistoryAll } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryBolus.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryBolus.java index b213ba52fd..d89891e652 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryBolus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryBolus.java @@ -3,13 +3,19 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; + /** * Created by mike on 20.07.2016. */ public class MsgHistoryBolus extends MsgHistoryAll { - private static Logger log = LoggerFactory.getLogger(MsgHistoryBolus.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + public MsgHistoryBolus() { SetCommand(0x3101); + if (Config.logPumpComm) + log.debug("New message"); } // Handle message taken from MsgHistoryAll } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryCarbo.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryCarbo.java index 115dc73e02..5114b190c6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryCarbo.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryCarbo.java @@ -3,13 +3,18 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; + /** * Created by mike on 20.07.2016. */ public class MsgHistoryCarbo extends MsgHistoryAll { - private static Logger log = LoggerFactory.getLogger(MsgHistoryCarbo.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public MsgHistoryCarbo() { SetCommand(0x3107); + if (Config.logPumpComm) + log.debug("New message"); } // Handle message taken from MsgHistoryAll } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryDailyInsulin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryDailyInsulin.java index 77933c40da..51765af0d1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryDailyInsulin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryDailyInsulin.java @@ -3,13 +3,18 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; + /** * Created by mike on 20.07.2016. */ public class MsgHistoryDailyInsulin extends MsgHistoryAll { - private static Logger log = LoggerFactory.getLogger(MsgHistoryDailyInsulin.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public MsgHistoryDailyInsulin() { SetCommand(0x3102); + if (Config.logPumpComm) + log.debug("New message"); } // Handle message taken from MsgHistoryAll } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryDone.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryDone.java index 04d3cb3faf..a507bef445 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryDone.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryDone.java @@ -4,23 +4,26 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; /** * Created by mike on 20.07.2016. */ public class MsgHistoryDone extends MessageBase { - private static Logger log = LoggerFactory.getLogger(MsgHistoryDone.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public static boolean received = false; public MsgHistoryDone() { SetCommand(0x31F1); received = false; + if (Config.logPumpComm) + log.debug("New message"); } @Override public void handleMessage(byte[] bytes) { received = true; - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("History done received"); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryError.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryError.java index 3358a88fea..5c57a4f9f3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryError.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryError.java @@ -3,13 +3,19 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; + /** * Created by mike on 20.07.2016. */ public class MsgHistoryError extends MsgHistoryAll { - private static Logger log = LoggerFactory.getLogger(MsgHistoryError.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + public MsgHistoryError() { SetCommand(0x3106); + if (Config.logPumpComm) + log.debug("New message"); } // Handle message taken from MsgHistoryAll } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryGlucose.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryGlucose.java index f07b91e9d8..2eeee09057 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryGlucose.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryGlucose.java @@ -3,13 +3,19 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; + /** * Created by mike on 20.07.2016. */ public class MsgHistoryGlucose extends MsgHistoryAll { - private static Logger log = LoggerFactory.getLogger(MsgHistoryGlucose.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + public MsgHistoryGlucose() { SetCommand(0x3104); + if (Config.logPumpComm) + log.debug("New message"); } // Handle message taken from MsgHistoryAll } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryNew.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryNew.java index 5de685f65b..7213ddef9d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryNew.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryNew.java @@ -3,13 +3,19 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; + /** * Created by mike on 20.07.2016. */ public class MsgHistoryNew extends MsgHistoryAll { - private static Logger log = LoggerFactory.getLogger(MsgHistoryNew.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + public MsgHistoryNew() { SetCommand(0x42F2); + if (Config.logPumpComm) + log.debug("New message"); } // Handle message taken from MsgHistoryAll } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryNewDone.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryNewDone.java index 2cde92bf9a..33c820d158 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryNewDone.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryNewDone.java @@ -4,23 +4,26 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; /** * Created by mike on 20.07.2016. */ public class MsgHistoryNewDone extends MessageBase { - private static Logger log = LoggerFactory.getLogger(MsgHistoryNewDone.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public static boolean received = false; public MsgHistoryNewDone() { SetCommand(0x42F1); received = false; + if (Config.logPumpComm) + log.debug("New message"); } @Override public void handleMessage(byte[] bytes) { received = true; - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("History new done received"); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryRefill.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryRefill.java index daaed79023..582e76e3ff 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryRefill.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryRefill.java @@ -3,13 +3,19 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; + /** * Created by mike on 20.07.2016. */ public class MsgHistoryRefill extends MsgHistoryAll { - private static Logger log = LoggerFactory.getLogger(MsgHistoryRefill.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + public MsgHistoryRefill() { SetCommand(0x3108); - } + if (Config.logPumpComm) + log.debug("New message"); + } // Handle message taken from MsgHistoryAll } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistorySuspend.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistorySuspend.java index db807a31b5..8d209fc13e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistorySuspend.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistorySuspend.java @@ -3,13 +3,19 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; + /** * Created by mike on 20.07.2016. */ public class MsgHistorySuspend extends MsgHistoryAll { - private static Logger log = LoggerFactory.getLogger(MsgHistorySuspend.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + public MsgHistorySuspend() { SetCommand(0x3109); + if (Config.logPumpComm) + log.debug("New message"); } // Handle message taken from MsgHistoryAll } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusBasic.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusBasic.java index e7f6032c00..8d71ed9e1d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusBasic.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusBasic.java @@ -4,13 +4,16 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class MsgInitConnStatusBasic extends MessageBase { - private static Logger log = LoggerFactory.getLogger(MsgInitConnStatusBasic.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public MsgInitConnStatusBasic() { SetCommand(0x0303); + if (Config.logPumpComm) + log.debug("New message"); } @Override @@ -39,14 +42,17 @@ public class MsgInitConnStatusBasic extends MessageBase { boolean deliveryStepBolus = (bolusConfig & DanaRPump.DELIVERY_STEP_BOLUS) != 0; boolean deliveryBasal = (bolusConfig & DanaRPump.DELIVERY_BASAL) != 0; boolean deliveryExtBolus = (bolusConfig & DanaRPump.DELIVERY_EXT_BOLUS) != 0; - log.debug("Delivery prime: " + deliveryPrime); - log.debug("Delivery step bolus: " + deliveryStepBolus); - log.debug("Delivery basal: " + deliveryBasal); - log.debug("Delivery ext bolus: " + deliveryExtBolus); + if (Config.logPumpComm) { + log.debug("Delivery prime: " + deliveryPrime); + log.debug("Delivery step bolus: " + deliveryStepBolus); + log.debug("Delivery basal: " + deliveryBasal); + log.debug("Delivery ext bolus: " + deliveryExtBolus); + } } catch (Exception e) { + log.error("Unhadled exception", e); } - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Pump suspended: " + pump.pumpSuspended); log.debug("Calculator enabled: " + pump.calculatorEnabled); log.debug("Daily total units: " + pump.dailyTotalUnits); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusBolus.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusBolus.java index 4fc9844b0d..163bf7d252 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusBolus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusBolus.java @@ -4,21 +4,24 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; -import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; -import info.nightscout.androidaps.plugins.Overview.notifications.Notification; import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; +import info.nightscout.androidaps.plugins.Overview.notifications.Notification; +import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; /** * Created by mike on 28.05.2016. */ public class MsgInitConnStatusBolus extends MessageBase { - private static Logger log = LoggerFactory.getLogger(MsgInitConnStatusBolus.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public MsgInitConnStatusBolus() { SetCommand(0x0302); + if (Config.logPumpComm) + log.debug("New message"); } @Override @@ -34,7 +37,7 @@ public class MsgInitConnStatusBolus extends MessageBase { pump.maxBolus = intFromBuff(bytes, 2, 2) / 100d; //int bolusRate = intFromBuff(bytes, 4, 8); - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Is Extended bolus enabled: " + pump.isExtendedBolusEnabled); log.debug("Bolus increment: " + pump.bolusStep); log.debug("Bolus max: " + pump.maxBolus); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusOption.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusOption.java index 560ed8b332..2ff0e77636 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusOption.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusOption.java @@ -4,16 +4,19 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; /** * Created by mike on 28.05.2016. */ public class MsgInitConnStatusOption extends MessageBase { - private static Logger log = LoggerFactory.getLogger(MsgInitConnStatusOption.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public MsgInitConnStatusOption() { SetCommand(0x0304); + if (Config.logPumpComm) + log.debug("New message"); } @Override @@ -29,7 +32,7 @@ public class MsgInitConnStatusOption extends MessageBase { //int none = intFromBuff(bytes, 8, 1); if (bytes.length >= 21) { DanaRPump.getInstance().password = intFromBuff(bytes, 9, 2) ^ 0x3463; - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("Pump password: " + DanaRPump.getInstance().password); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusTime.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusTime.java index 84d9c413bf..1cb10b0d28 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusTime.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusTime.java @@ -6,6 +6,7 @@ import org.slf4j.LoggerFactory; import java.util.Date; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.events.EventRefreshGui; @@ -18,19 +19,21 @@ import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin; public class MsgInitConnStatusTime extends MessageBase { - private static Logger log = LoggerFactory.getLogger(MsgInitConnStatusTime.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public MsgInitConnStatusTime() { SetCommand(0x0301); + if (Config.logPumpComm) + log.debug("New message"); } @Override public void handleMessage(byte[] bytes) { if (bytes.length - 10 > 7) { - Notification notification = new Notification(Notification.WRONG_DRIVER, MainApp.gs(R.string.pumpdrivercorrected), Notification.NORMAL); + Notification notification = new Notification(Notification.WRONG_DRIVER, MainApp.gs(R.string.pumpdrivercorrected), Notification.NORMAL); MainApp.bus().post(new EventNewNotification(notification)); MainApp.getSpecificPlugin(DanaRPlugin.class).disconnect("Wrong Model"); - log.debug("Wrong model selected. Switching to Korean DanaR"); + log.error("Wrong model selected. Switching to Korean DanaR"); MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setPluginEnabled(PluginType.PUMP, true); MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setFragmentVisible(PluginType.PUMP, true); MainApp.getSpecificPlugin(DanaRPlugin.class).setPluginEnabled(PluginType.PUMP, false); @@ -39,7 +42,7 @@ public class MsgInitConnStatusTime extends MessageBase { DanaRPump.reset(); // mark not initialized //If profile coming from pump, switch it as well - if(MainApp.getSpecificPlugin(DanaRPlugin.class).isEnabled(PluginType.PROFILE)){ + if (MainApp.getSpecificPlugin(DanaRPlugin.class).isEnabled(PluginType.PROFILE)) { (MainApp.getSpecificPlugin(DanaRPlugin.class)).setPluginEnabled(PluginType.PROFILE, false); (MainApp.getSpecificPlugin(DanaRKoreanPlugin.class)).setPluginEnabled(PluginType.PROFILE, true); } @@ -53,7 +56,7 @@ public class MsgInitConnStatusTime extends MessageBase { Date time = dateTimeSecFromBuff(bytes, 0); int versionCode = intFromBuff(bytes, 6, 1); - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Pump time: " + time); log.debug("Version code: " + versionCode); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgPCCommStart.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgPCCommStart.java index 619bbd9461..ea01c94ad3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgPCCommStart.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgPCCommStart.java @@ -4,16 +4,20 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; public class MsgPCCommStart extends MessageBase { - private static Logger log = LoggerFactory.getLogger(MsgPCCommStart.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + public MsgPCCommStart() { SetCommand(0x3001); + if (Config.logPumpComm) + log.debug("New message"); } @Override public void handleMessage(byte[] bytes) { - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("PC comm start received"); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgPCCommStop.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgPCCommStop.java index 20dd4e060f..e53d71b611 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgPCCommStop.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgPCCommStop.java @@ -4,16 +4,19 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; public class MsgPCCommStop extends MessageBase { - private static Logger log = LoggerFactory.getLogger(MsgPCCommStop.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public MsgPCCommStop() { SetCommand(0x3002); + if (Config.logPumpComm) + log.debug("New message"); } @Override public void handleMessage(byte[] bytes) { - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("PC comm stop received"); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetActivateBasalProfile.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetActivateBasalProfile.java index 64ed0488a4..8da1f48586 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetActivateBasalProfile.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetActivateBasalProfile.java @@ -4,19 +4,22 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; public class MsgSetActivateBasalProfile extends MessageBase { - private static Logger log = LoggerFactory.getLogger(MsgSetActivateBasalProfile.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public MsgSetActivateBasalProfile() { SetCommand(0x330C); + if (Config.logPumpComm) + log.debug("New message"); } // index 0-3 public MsgSetActivateBasalProfile(byte index) { this(); AddParamByte(index); - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("Activate basal profile: " + index); } @@ -25,9 +28,10 @@ public class MsgSetActivateBasalProfile extends MessageBase { int result = intFromBuff(bytes, 0, 1); if (result != 1) { failed = true; - log.debug("Activate basal profile result: " + result + " FAILED!!!"); + if (Config.logPumpComm) + log.debug("Activate basal profile result: " + result + " FAILED!!!"); } else { - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("Activate basal profile result: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetBasalProfile.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetBasalProfile.java index 9f945e8b26..c95a49f89f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetBasalProfile.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetBasalProfile.java @@ -4,16 +4,19 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; -import info.nightscout.androidaps.plugins.Overview.notifications.Notification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; +import info.nightscout.androidaps.plugins.Overview.notifications.Notification; public class MsgSetBasalProfile extends MessageBase { - private static Logger log = LoggerFactory.getLogger(MsgSetBasalProfile.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public MsgSetBasalProfile() { SetCommand(0x3306); + if (Config.logPumpComm) + log.debug("New message"); } // index 0-3 @@ -23,7 +26,7 @@ public class MsgSetBasalProfile extends MessageBase { for (Integer i = 0; i < 24; i++) { AddParamInt((int) (values[i] * 100)); } - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("Set basal profile: " + index); } @@ -32,11 +35,12 @@ public class MsgSetBasalProfile extends MessageBase { int result = intFromBuff(bytes, 0, 1); if (result != 1) { failed = true; - log.debug("Set basal profile result: " + result + " FAILED!!!"); + if (Config.logPumpComm) + log.debug("Set basal profile result: " + result + " FAILED!!!"); Notification reportFail = new Notification(Notification.PROFILE_SET_FAILED, MainApp.gs(R.string.profile_set_failed), Notification.URGENT); MainApp.bus().post(new EventNewNotification(reportFail)); } else { - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("Set basal profile result: " + result); Notification reportOK = new Notification(Notification.PROFILE_SET_OK, MainApp.gs(R.string.profile_set_ok), Notification.INFO, 60); MainApp.bus().post(new EventNewNotification(reportOK)); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetCarbsEntry.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetCarbsEntry.java index 4fcd6dee9c..e446c2498a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetCarbsEntry.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetCarbsEntry.java @@ -6,12 +6,15 @@ import org.slf4j.LoggerFactory; import java.util.Calendar; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; public class MsgSetCarbsEntry extends MessageBase { - private static Logger log = LoggerFactory.getLogger(MsgSetCarbsEntry.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public MsgSetCarbsEntry() { SetCommand(0x0402); + if (Config.logPumpComm) + log.debug("New message"); } public MsgSetCarbsEntry(long time, int amount) { @@ -27,7 +30,7 @@ public class MsgSetCarbsEntry extends MessageBase { AddParamByte((byte) (calendar.get(Calendar.SECOND))); AddParamByte((byte) 0x43); //?? AddParamInt(amount); - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("Set carb entry: " + amount + " date " + calendar.getTime().toString()); } @@ -36,9 +39,10 @@ public class MsgSetCarbsEntry extends MessageBase { int result = intFromBuff(bytes, 0, 1); if (result != 1) { failed = true; - log.debug("Set carb entry result: " + result + " FAILED!!!"); + if (Config.logPumpComm) + log.debug("Set carb entry result: " + result + " FAILED!!!"); } else { - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("Set carb entry result: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetExtendedBolusStart.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetExtendedBolusStart.java index 420f0ccbf9..6de2fc251c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetExtendedBolusStart.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetExtendedBolusStart.java @@ -4,15 +4,17 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.interfaces.Constraint; -import info.nightscout.utils.HardLimits; public class MsgSetExtendedBolusStart extends MessageBase { - private static Logger log = LoggerFactory.getLogger(MsgSetExtendedBolusStart.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public MsgSetExtendedBolusStart() { SetCommand(0x0407); + if (Config.logPumpComm) + log.debug("New message"); } public MsgSetExtendedBolusStart(double amount, byte halfhours) { @@ -25,7 +27,7 @@ public class MsgSetExtendedBolusStart extends MessageBase { AddParamInt((int) (amount * 100)); AddParamByte(halfhours); - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("Set extended bolus start: " + (((int) (amount * 100)) / 100d) + "U halfhours: " + (int) halfhours); } @@ -34,9 +36,10 @@ public class MsgSetExtendedBolusStart extends MessageBase { int result = intFromBuff(bytes, 0, 1); if (result != 1) { failed = true; - log.debug("Set extended bolus start result: " + result + " FAILED!!!"); + if (Config.logPumpComm) + log.debug("Set extended bolus start result: " + result + " FAILED!!!"); } else { - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("Set extended bolus start result: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetExtendedBolusStop.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetExtendedBolusStop.java index 7084949daa..01060b290d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetExtendedBolusStop.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetExtendedBolusStop.java @@ -4,14 +4,15 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; public class MsgSetExtendedBolusStop extends MessageBase { - private static Logger log = LoggerFactory.getLogger(MsgSetExtendedBolusStop.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public MsgSetExtendedBolusStop() { SetCommand(0x0406); - if (Config.logDanaMessageDetail) - log.debug("Set extended bolus stop"); + if (Config.logPumpComm) + log.debug("New message"); } @Override @@ -19,9 +20,10 @@ public class MsgSetExtendedBolusStop extends MessageBase { int result = intFromBuff(bytes, 0, 1); if (result != 1) { failed = true; - log.debug("Set extended bolus stop result: " + result + " FAILED!!!"); + if (Config.logPumpComm) + log.debug("Set extended bolus stop result: " + result + " FAILED!!!"); } else { - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("Set extended bolus stop result: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetSingleBasalProfile.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetSingleBasalProfile.java index 7dd9ca522b..9d84650d01 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetSingleBasalProfile.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetSingleBasalProfile.java @@ -4,13 +4,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.plugins.Overview.notifications.Notification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; public class MsgSetSingleBasalProfile extends MessageBase { - private static Logger log = LoggerFactory.getLogger(MsgSetSingleBasalProfile.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public MsgSetSingleBasalProfile() { SetCommand(0x3302); @@ -22,8 +23,8 @@ public class MsgSetSingleBasalProfile extends MessageBase { for (Integer i = 0; i < 24; i++) { AddParamInt((int) (values[i] * 100)); } - if (Config.logDanaMessageDetail) - log.debug("Set basal profile"); + if (Config.logPumpComm) + log.debug("New message"); } @Override @@ -31,11 +32,12 @@ public class MsgSetSingleBasalProfile extends MessageBase { int result = intFromBuff(bytes, 0, 1); if (result != 1) { failed = true; - log.debug("Set basal profile result: " + result + " FAILED!!!"); + if (Config.logPumpComm) + log.debug("Set basal profile result: " + result + " FAILED!!!"); Notification reportFail = new Notification(Notification.PROFILE_SET_FAILED, MainApp.gs(R.string.profile_set_failed), Notification.URGENT); MainApp.bus().post(new EventNewNotification(reportFail)); } else { - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("Set basal profile result: " + result); Notification reportOK = new Notification(Notification.PROFILE_SET_OK, MainApp.gs(R.string.profile_set_ok), Notification.INFO, 60); MainApp.bus().post(new EventNewNotification(reportOK)); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetTempBasalStart.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetTempBasalStart.java index 2b72c35749..d688fd9698 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetTempBasalStart.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetTempBasalStart.java @@ -4,9 +4,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; public class MsgSetTempBasalStart extends MessageBase { - private static Logger log = LoggerFactory.getLogger(MsgSetTempBasalStart.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public MsgSetTempBasalStart() { SetCommand(0x0401); @@ -24,7 +25,7 @@ public class MsgSetTempBasalStart extends MessageBase { AddParamByte((byte) (percent & 255)); AddParamByte((byte) (durationInHours & 255)); - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("Temp basal start percent: " + percent + " duration hours: " + durationInHours); } @@ -32,9 +33,10 @@ public class MsgSetTempBasalStart extends MessageBase { int result = intFromBuff(bytes, 0, 1); if (result != 1) { failed = true; - log.debug("Set temp basal start result: " + result + " FAILED!!!"); + if (Config.logPumpComm) + log.debug("Set temp basal start result: " + result + " FAILED!!!"); } else { - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("Set temp basal start result: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetTempBasalStop.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetTempBasalStop.java index 39582ac399..dc9812a225 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetTempBasalStop.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetTempBasalStop.java @@ -4,13 +4,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; public class MsgSetTempBasalStop extends MessageBase { - private static Logger log = LoggerFactory.getLogger(MsgSetTempBasalStop.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public MsgSetTempBasalStop() { SetCommand(0x0403); - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("Temp basal stop"); } @@ -18,9 +19,10 @@ public class MsgSetTempBasalStop extends MessageBase { int result = intFromBuff(bytes, 0, 1); if (result != 1) { failed = true; - log.debug("Set temp basal stop result: " + result + " FAILED!!!"); + if (Config.logPumpComm) + log.debug("Set temp basal stop result: " + result + " FAILED!!!"); } else { - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("Set temp basal stop result: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetTime.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetTime.java index 3910d52c97..a5ef58fbd6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetTime.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetTime.java @@ -6,25 +6,29 @@ import org.slf4j.LoggerFactory; import java.util.Date; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; +import info.nightscout.utils.DateUtil; /** * Created by mike on 09.12.2016. */ public class MsgSetTime extends MessageBase { - private static Logger log = LoggerFactory.getLogger(MsgSetTime.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private static Date time; public MsgSetTime(Date time) { SetCommand(0x330a); this.time = time; AddParamDateTime(time); + if (Config.logPumpComm) + log.debug("New message: time:" + DateUtil.dateAndTimeString(time)); } public void handleMessage(byte[] bytes) { int result = intFromBuff(bytes, 0, 1); - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("Result of setting time: " + time + " is " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetUserOptions.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetUserOptions.java index 407b19da8d..02c16aff69 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetUserOptions.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetUserOptions.java @@ -2,9 +2,9 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import android.support.v4.internal.view.SupportMenu; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; /** @@ -12,7 +12,7 @@ import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; */ public class MsgSetUserOptions extends MessageBase { - private static Logger log = LoggerFactory.getLogger(MsgSetUserOptions.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public boolean done; @@ -21,7 +21,7 @@ public class MsgSetUserOptions extends MessageBase { DanaRPump pump = DanaRPump.getInstance(); if (pump.userOptionsFrompump == null) { // No options set -> Exitting - log.debug("NO USER OPTIONS LOADED EXITTING!"); + log.error("NO USER OPTIONS LOADED EXITTING!"); return; } pump.userOptionsFrompump[0] = (byte) (pump.timeDisplayType == 1 ? 0 : 1); @@ -33,18 +33,21 @@ public class MsgSetUserOptions extends MessageBase { pump.userOptionsFrompump[8] = (byte) pump.units; pump.userOptionsFrompump[9] = (byte) pump.shutdownHour; pump.userOptionsFrompump[27] = (byte) pump.lowReservoirRate; - for(int i=0; i>>>> @ " + (mBolusingTreatment == null ? "" : mBolusingTreatment.insulin)); MsgBolusStop stop = new MsgBolusStop(); stop.forced = true; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/DanaRExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/DanaRExecutionService.java index ea4dec25fb..730c43643b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/DanaRExecutionService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/DanaRExecutionService.java @@ -7,8 +7,6 @@ import android.os.SystemClock; import com.squareup.otto.Subscribe; -import org.slf4j.LoggerFactory; - import java.io.IOException; import java.util.Date; @@ -67,10 +65,9 @@ import info.nightscout.androidaps.queue.commands.Command; import info.nightscout.utils.NSUpload; import info.nightscout.utils.SP; -public class DanaRExecutionService extends AbstractDanaRExecutionService{ +public class DanaRExecutionService extends AbstractDanaRExecutionService { public DanaRExecutionService() { - log = LoggerFactory.getLogger(DanaRExecutionService.class); mBinder = new LocalBinder(); registerBus(); @@ -100,7 +97,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{ public void connect() { if (mDanaRPump.password != -1 && mDanaRPump.password != SP.getInt(R.string.key_danar_password, -1)) { - if(System.currentTimeMillis() > lastWrongPumpPassword + 30 * 1000) { + if (System.currentTimeMillis() > lastWrongPumpPassword + 30 * 1000) { Notification notification = new Notification(Notification.WRONG_PUMP_PASSWORD, MainApp.gs(R.string.wrongpumppassword), Notification.URGENT); notification.soundId = R.raw.error; lastWrongPumpPassword = System.currentTimeMillis(); @@ -196,12 +193,14 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime))); mSerialIOThread.sendMessage(new MsgSettingPumpTime()); long timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L; - log.debug("Pump time difference: " + timeDiff + " seconds"); + if (Config.logPump) + log.debug("Pump time difference: " + timeDiff + " seconds"); if (Math.abs(timeDiff) > 10) { mSerialIOThread.sendMessage(new MsgSetTime(new Date())); mSerialIOThread.sendMessage(new MsgSettingPumpTime()); timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L; - log.debug("Pump time difference: " + timeDiff + " seconds"); + if (Config.logPump) + log.debug("Pump time difference: " + timeDiff + " seconds"); } mDanaRPump.lastSettingsRead = now; } @@ -210,8 +209,9 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{ MainApp.bus().post(new EventInitializationChanged()); NSUpload.uploadDeviceStatus(); if (mDanaRPump.dailyTotalUnits > mDanaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) { - log.debug("Approaching daily limit: " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits); - if(System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) { + if (Config.logPump) + log.debug("Approaching daily limit: " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits); + if (System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) { Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.gs(R.string.approachingdailylimit), Notification.URGENT); MainApp.bus().post(new EventNewNotification(reportFail)); NSUpload.uploadError(MainApp.gs(R.string.approachingdailylimit) + ": " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits + "U"); @@ -301,7 +301,8 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{ if ((System.currentTimeMillis() - progress.lastReceive) > 15 * 1000L) { // if i didn't receive status for more than 15 sec expecting broken comm stop.stopped = true; stop.forced = true; - log.debug("Communication stopped"); + if (Config.logPump) + log.debug("Communication stopped"); } } SystemClock.sleep(300); @@ -344,9 +345,11 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{ public void run() { if (mDanaRPump.lastBolusTime.getTime() > System.currentTimeMillis() - 60 * 1000L) { // last bolus max 1 min old t.insulin = mDanaRPump.lastBolusAmount; - log.debug("Used bolus amount from history: " + mDanaRPump.lastBolusAmount); + if (Config.logPump) + log.debug("Used bolus amount from history: " + mDanaRPump.lastBolusAmount); } else { - log.debug("Bolus amount in history too old: " + mDanaRPump.lastBolusTime.toLocaleString()); + if (Config.logPump) + log.debug("Bolus amount in history too old: " + mDanaRPump.lastBolusTime.toLocaleString()); } synchronized (o) { o.notify(); @@ -386,7 +389,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{ public boolean updateBasalsInPump(final Profile profile) { if (!isConnected()) return false; MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.updatingbasalrates))); - double[] basal = DanaRPump.buildDanaRProfileRecord(profile); + double[] basal = DanaRPump.getInstance().buildDanaRProfileRecord(profile); MsgSetBasalProfile msgSet = new MsgSetBasalProfile((byte) 0, basal); mSerialIOThread.sendMessage(msgSet); MsgSetActivateBasalProfile msgActivate = new MsgSetActivateBasalProfile((byte) 0); @@ -399,7 +402,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{ @Subscribe public void onStatusEvent(EventAppExit event) { - if (Config.logFunctionCalls) + if (Config.logPump) log.debug("EventAppExit received"); if (mSerialIOThread != null) @@ -408,7 +411,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{ MainApp.instance().getApplicationContext().unregisterReceiver(receiver); stopSelf(); - if (Config.logFunctionCalls) + if (Config.logPump) log.debug("EventAppExit finished"); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java index 49edb6b096..2e8aac4643 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java @@ -11,8 +11,6 @@ import android.support.v7.app.AlertDialog; import com.squareup.otto.Subscribe; -import org.slf4j.LoggerFactory; - import info.nightscout.androidaps.Config; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; @@ -51,7 +49,6 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin { public DanaRKoreanPlugin() { pluginDescription.description(R.string.description_pump_dana_r_korean); - log = LoggerFactory.getLogger(DanaRKoreanPlugin.class); useExtendedBoluses = SP.getBoolean("danar_useextended", false); pumpDescription.isBolusCapable = true; @@ -87,7 +84,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin { @Override public void switchAllowed(ConfigBuilderFragment.PluginViewHolder.PluginSwitcher pluginSwitcher, FragmentActivity context) { boolean allowHardwarePump = SP.getBoolean("allow_hardware_pump", false); - if (allowHardwarePump || context == null){ + if (allowHardwarePump || context == null) { pluginSwitcher.invoke(); } else { AlertDialog.Builder builder = new AlertDialog.Builder(context); @@ -96,13 +93,15 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin { public void onClick(DialogInterface dialog, int id) { pluginSwitcher.invoke(); SP.putBoolean("allow_hardware_pump", true); - log.debug("First time HW pump allowed!"); + if (Config.logPump) + log.debug("First time HW pump allowed!"); } }) .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { pluginSwitcher.cancel(); - log.debug("User does not allow switching to HW pump!"); + if (Config.logPump) + log.debug("User does not allow switching to HW pump!"); } }); builder.create().show(); @@ -130,12 +129,14 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin { private ServiceConnection mConnection = new ServiceConnection() { public void onServiceDisconnected(ComponentName name) { - log.debug("Service is disconnected"); + if (Config.logPump) + log.debug("Service is disconnected"); sExecutionService = null; } public void onServiceConnected(ComponentName name, IBinder service) { - log.debug("Service is connected"); + if (Config.logPump) + log.debug("Service is connected"); DanaRKoreanExecutionService.LocalBinder mLocalBinder = (DanaRKoreanExecutionService.LocalBinder) service; sExecutionService = mLocalBinder.getServiceInstance(); } @@ -198,7 +199,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin { result.comment = String.format(MainApp.gs(R.string.boluserrorcode), detailedBolusInfo.insulin, t.insulin, MsgBolusStart.errorCode); else result.comment = MainApp.gs(R.string.virtualpump_resultok); - if (Config.logPumpActions) + if (Config.logPump) log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered); detailedBolusInfo.insulin = t.insulin; detailedBolusInfo.date = System.currentTimeMillis(); @@ -240,13 +241,13 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin { if (doTempOff) { // If extended in progress if (activeExtended != null && useExtendedBoluses) { - if (Config.logPumpActions) + if (Config.logPump) log.debug("setTempBasalAbsolute: Stopping extended bolus (doTempOff)"); return cancelExtendedBolus(); } // If temp in progress if (activeTemp != null) { - if (Config.logPumpActions) + if (Config.logPump) log.debug("setTempBasalAbsolute: Stopping temp basal (doTempOff)"); return cancelRealTempBasal(); } @@ -255,7 +256,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin { result.percent = 100; result.isPercent = true; result.isTempCancel = true; - if (Config.logPumpActions) + if (Config.logPump) log.debug("setTempBasalAbsolute: doTempOff OK"); return result; } @@ -267,12 +268,12 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin { if (percentRate > getPumpDescription().maxTempPercent) { percentRate = getPumpDescription().maxTempPercent; } - if (Config.logPumpActions) + if (Config.logPump) log.debug("setTempBasalAbsolute: Calculated percent rate: " + percentRate); // If extended in progress if (activeExtended != null && useExtendedBoluses) { - if (Config.logPumpActions) + if (Config.logPump) log.debug("setTempBasalAbsolute: Stopping extended bolus (doLowTemp || doHighTemp)"); result = cancelExtendedBolus(); if (!result.success) { @@ -283,7 +284,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin { // Check if some temp is already in progress if (activeTemp != null) { // Correct basal already set ? - if (Config.logPumpActions) + if (Config.logPump) log.debug("setTempBasalAbsolute: currently running: " + activeTemp.toString()); if (activeTemp.percentRate == percentRate) { if (enforceNew) { @@ -295,21 +296,21 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin { result.duration = activeTemp.getPlannedRemainingMinutes(); result.isPercent = true; result.isTempCancel = false; - if (Config.logPumpActions) + if (Config.logPump) log.debug("setTempBasalAbsolute: Correct temp basal already set (doLowTemp || doHighTemp)"); return result; } } } // Convert duration from minutes to hours - if (Config.logPumpActions) + if (Config.logPump) log.debug("setTempBasalAbsolute: Setting temp basal " + percentRate + "% for " + durationInMinutes + " mins (doLowTemp || doHighTemp)"); return setTempBasalPercent(percentRate, durationInMinutes, profile, false); } if (doExtendedTemp) { // Check if some temp is already in progress if (activeTemp != null) { - if (Config.logPumpActions) + if (Config.logPump) log.debug("setTempBasalAbsolute: Stopping temp basal (doExtendedTemp)"); result = cancelRealTempBasal(); // Check for proper result @@ -328,7 +329,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin { extendedRateToSet = Round.roundTo(extendedRateToSet, pumpDescription.extendedBolusStep * 2); // *2 because of halfhours // What is current rate of extended bolusing in u/h? - if (Config.logPumpActions) { + if (Config.logPump) { log.debug("setTempBasalAbsolute: Extended bolus in progress: " + (activeExtended != null) + " rate: " + pump.extendedBolusAbsoluteRate + "U/h duration remaining: " + pump.extendedBolusRemainingMinutes + "min"); log.debug("setTempBasalAbsolute: Rate to set: " + extendedRateToSet + "U/h"); } @@ -342,21 +343,21 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin { result.duration = pump.extendedBolusRemainingMinutes; result.isPercent = false; result.isTempCancel = false; - if (Config.logPumpActions) + if (Config.logPump) log.debug("setTempBasalAbsolute: Correct extended already set"); return result; } // Now set new extended, no need to to stop previous (if running) because it's replaced Double extendedAmount = extendedRateToSet / 2 * durationInHalfHours; - if (Config.logPumpActions) + if (Config.logPump) log.debug("setTempBasalAbsolute: Setting extended: " + extendedAmount + "U halfhours: " + durationInHalfHours); result = setExtendedBolus(extendedAmount, durationInMinutes); if (!result.success) { log.error("setTempBasalAbsolute: Failed to set extended bolus"); return result; } - if (Config.logPumpActions) + if (Config.logPump) log.debug("setTempBasalAbsolute: Extended bolus set ok"); result.absolute = result.absolute + getBaseBasalRate(); return result; @@ -395,7 +396,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin { result.success = true; result.isTempCancel = true; result.comment = MainApp.gs(R.string.virtualpump_resultok); - if (Config.logPumpActions) + if (Config.logPump) log.debug("cancelRealTempBasal: OK"); return result; } else { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/SerialIOThread.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/SerialIOThread.java index 9a8f3edb05..6a36e565a9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/SerialIOThread.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/SerialIOThread.java @@ -11,6 +11,7 @@ import java.io.InputStream; import java.io.OutputStream; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; import info.nightscout.androidaps.plugins.PumpDanaR.services.AbstractSerialIOThread; @@ -21,7 +22,7 @@ import info.nightscout.utils.CRC; * Created by mike on 17.07.2016. */ public class SerialIOThread extends AbstractSerialIOThread { - private static Logger log = LoggerFactory.getLogger(SerialIOThread.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPBTCOMM); private InputStream mInputStream = null; private OutputStream mOutputStream = null; @@ -72,7 +73,7 @@ public class SerialIOThread extends AbstractSerialIOThread { message = MessageHashTable_k.findMessage(command); } - if (Config.logDanaMessageDetail) + if (Config.logPumpBtComm) log.debug("<<<<< " + message.getMessageName() + " " + message.toHexString(extractedBuff)); // process the message content @@ -84,7 +85,7 @@ public class SerialIOThread extends AbstractSerialIOThread { } } } catch (Exception e) { - if (Config.logDanaSerialEngine && e.getMessage().indexOf("bt socket closed") < 0) + if (e.getMessage().indexOf("bt socket closed") < 0) log.error("Thread exception: ", e); mKeepRunning = false; } @@ -148,7 +149,7 @@ public class SerialIOThread extends AbstractSerialIOThread { processedMessage = message; byte[] messageBytes = message.getRawMessageBytes(); - if (Config.logDanaSerialEngine) + if (Config.logPumpBtComm) log.debug(">>>>> " + message.getMessageName() + " " + message.toHexString(messageBytes)); try { @@ -167,10 +168,11 @@ public class SerialIOThread extends AbstractSerialIOThread { SystemClock.sleep(200); if (!message.received) { - log.warn("Reply not received " + message.getMessageName()); + if (Config.logPumpBtComm) + log.warn("Reply not received " + message.getMessageName()); if (message.getCommand() == 0xF0F1) { DanaRPump.getInstance().isNewPump = false; - log.debug("Old firmware detected"); + log.error("Old firmware detected"); } } } @@ -181,24 +183,29 @@ public class SerialIOThread extends AbstractSerialIOThread { try { mInputStream.close(); } catch (Exception e) { - if (Config.logDanaSerialEngine) log.debug(e.getMessage()); + if (Config.logPumpBtComm) + log.debug(e.getMessage()); } try { mOutputStream.close(); } catch (Exception e) { - if (Config.logDanaSerialEngine) log.debug(e.getMessage()); + if (Config.logPumpBtComm) + log.debug(e.getMessage()); } try { mRfCommSocket.close(); } catch (Exception e) { - if (Config.logDanaSerialEngine) log.debug(e.getMessage()); + if (Config.logPumpBtComm) + log.debug(e.getMessage()); } try { System.runFinalization(); } catch (Exception e) { - if (Config.logDanaSerialEngine) log.debug(e.getMessage()); + if (Config.logPumpBtComm) + log.debug(e.getMessage()); } - if (Config.logDanaSerialEngine) log.debug("Disconnected: " + reason); + if (Config.logPumpBtComm) + log.debug("Disconnected: " + reason); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgCheckValue_k.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgCheckValue_k.java index 684fa30997..0f08000a5a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgCheckValue_k.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgCheckValue_k.java @@ -4,6 +4,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; @@ -15,10 +16,12 @@ import info.nightscout.utils.ToastUtils; * Created by mike on 30.06.2016. */ public class MsgCheckValue_k extends MessageBase { - private static Logger log = LoggerFactory.getLogger(MsgCheckValue_k.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public MsgCheckValue_k() { SetCommand(0xF0F1); + if (Config.logPumpComm) + log.debug("New message"); } @Override @@ -26,17 +29,18 @@ public class MsgCheckValue_k extends MessageBase { DanaRPump pump = DanaRPump.getInstance(); pump.isNewPump = true; - log.debug("New firmware confirmed"); + if (Config.logPump) + log.debug("New firmware confirmed"); pump.model = intFromBuff(bytes, 0, 1); pump.protocol = intFromBuff(bytes, 1, 1); pump.productCode = intFromBuff(bytes, 2, 1); if (pump.model != DanaRPump.DOMESTIC_MODEL) { DanaRKoreanPlugin.getPlugin().disconnect("Wrong Model"); - log.debug("Wrong model selected"); + log.error("Wrong model selected"); } - if (Config.logDanaMessageDetail) { + if (Config.logPump) { log.debug("Model: " + String.format("%02X ", pump.model)); log.debug("Protocol: " + String.format("%02X ", pump.protocol)); log.debug("Product Code: " + String.format("%02X ", pump.productCode)); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusBasic_k.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusBasic_k.java index fa28e664ed..6eefefe34c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusBasic_k.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusBasic_k.java @@ -4,19 +4,22 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; -import info.nightscout.androidaps.plugins.Overview.notifications.Notification; import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; +import info.nightscout.androidaps.plugins.Overview.notifications.Notification; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; public class MsgInitConnStatusBasic_k extends MessageBase { - private static Logger log = LoggerFactory.getLogger(MsgInitConnStatusBasic_k.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public MsgInitConnStatusBasic_k() { SetCommand(0x0303); + if (Config.logPumpComm) + log.debug("New message"); } @Override @@ -30,7 +33,7 @@ public class MsgInitConnStatusBasic_k extends MessageBase { pump.isEasyModeEnabled = intFromBuff(bytes, 2, 1) == 1; int easyUIMode = intFromBuff(bytes, 3, 1); pump.password = intFromBuff(bytes, 4, 2) ^ 0x3463; - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("isStatusSuspendOn: " + pump.pumpSuspended); log.debug("isUtilityEnable: " + isUtilityEnable); log.debug("Is EasyUI Enabled: " + pump.isEasyModeEnabled); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusBolus_k.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusBolus_k.java index 552511cf7c..4412457b09 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusBolus_k.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusBolus_k.java @@ -4,22 +4,25 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; -import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; -import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; -import info.nightscout.androidaps.plugins.Overview.notifications.Notification; import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; +import info.nightscout.androidaps.plugins.Overview.notifications.Notification; +import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; +import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; /** * Created by mike on 28.05.2016. */ public class MsgInitConnStatusBolus_k extends MessageBase { - private static Logger log = LoggerFactory.getLogger(MsgInitConnStatusBolus_k.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public MsgInitConnStatusBolus_k() { SetCommand(0x0302); + if (Config.logPumpComm) + log.debug("New message"); } @Override @@ -36,7 +39,7 @@ public class MsgInitConnStatusBolus_k extends MessageBase { //int bolusRate = intFromBuff(bytes, 4, 8); int deliveryStatus = intFromBuff(bytes, 12, 1); - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Is Extended bolus enabled: " + pump.isExtendedBolusEnabled); log.debug("Bolus increment: " + pump.bolusStep); log.debug("Bolus max: " + pump.maxBolus); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusTime_k.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusTime_k.java index 7553b0cc37..8f4642999a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusTime_k.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusTime_k.java @@ -6,6 +6,7 @@ import org.slf4j.LoggerFactory; import java.util.Date; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.events.EventRefreshGui; @@ -19,10 +20,12 @@ import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin; public class MsgInitConnStatusTime_k extends MessageBase { - private static Logger log = LoggerFactory.getLogger(MsgInitConnStatusTime_k.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public MsgInitConnStatusTime_k() { SetCommand(0x0301); + if (Config.logPumpComm) + log.debug("New message"); } @Override @@ -32,7 +35,7 @@ public class MsgInitConnStatusTime_k extends MessageBase { Notification notification = new Notification(Notification.WRONG_DRIVER, MainApp.gs(R.string.pumpdrivercorrected), Notification.NORMAL); MainApp.bus().post(new EventNewNotification(notification)); DanaRKoreanPlugin.getPlugin().disconnect("Wrong Model"); - log.debug("Wrong model selected. Switching to export DanaR"); + log.error("Wrong model selected. Switching to export DanaR"); MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setPluginEnabled(PluginType.PUMP, false); MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setFragmentVisible(PluginType.PUMP, false); MainApp.getSpecificPlugin(DanaRPlugin.class).setPluginEnabled(PluginType.PUMP, true); @@ -58,7 +61,7 @@ public class MsgInitConnStatusTime_k extends MessageBase { int versionCode3 = intFromBuff(bytes, 8, 1); int versionCode4 = intFromBuff(bytes, 9, 1); - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Pump time: " + time); log.debug("Version code1: " + versionCode1); log.debug("Version code2: " + versionCode2); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgSettingBasalProfileAll_k.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgSettingBasalProfileAll_k.java index 304ec9fc37..9890201485 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgSettingBasalProfileAll_k.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgSettingBasalProfileAll_k.java @@ -4,6 +4,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; @@ -15,10 +16,12 @@ import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; * THIS IS BROKEN IN PUMP... SENDING ONLY 1 PROFILE */ public class MsgSettingBasalProfileAll_k extends MessageBase { - private static Logger log = LoggerFactory.getLogger(MsgSettingBasalProfileAll_k.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public MsgSettingBasalProfileAll_k() { SetCommand(0x3206); + if (Config.logPumpComm) + log.debug("New message"); } public void handleMessage(byte[] bytes) { @@ -49,7 +52,7 @@ public class MsgSettingBasalProfileAll_k extends MessageBase { } } - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { if (pump.basal48Enable) { for (int profile = 0; profile < 4; profile++) { for (int index = 0; index < 24; index++) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgSettingBasal_k.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgSettingBasal_k.java index 5c8b40b959..c5767e1bbc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgSettingBasal_k.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgSettingBasal_k.java @@ -4,6 +4,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin; @@ -12,10 +13,12 @@ import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin; * Created by mike on 05.07.2016. */ public class MsgSettingBasal_k extends MessageBase { - private static Logger log = LoggerFactory.getLogger(MsgSettingBasal_k.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public MsgSettingBasal_k() { SetCommand(0x3202); + if (Config.logPumpComm) + log.debug("New message"); } public void handleMessage(byte[] bytes) { @@ -28,7 +31,7 @@ public class MsgSettingBasal_k extends MessageBase { pump.pumpProfiles[pump.activeProfile][index] = basal / 100d; } - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) for (int index = 0; index < 24; index++) { log.debug("Basal " + String.format("%02d", index) + "h: " + pump.pumpProfiles[pump.activeProfile][index]); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgStatusBasic_k.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgStatusBasic_k.java index 0fcaf17d83..f905593db0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgStatusBasic_k.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgStatusBasic_k.java @@ -4,15 +4,18 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; public class MsgStatusBasic_k extends MessageBase { - private static Logger log = LoggerFactory.getLogger(MsgStatusBasic_k.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public MsgStatusBasic_k() { SetCommand(0x020A); + if (Config.logPumpComm) + log.debug("New message"); } public void handleMessage(byte[] bytes) { @@ -29,7 +32,7 @@ public class MsgStatusBasic_k extends MessageBase { pump.currentBasal = currentBasal; pump.batteryRemaining = batteryRemaining; - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Daily total units: " + dailyTotalUnits); log.debug("Max daily total units: " + maxDailyTotalUnits); log.debug("Reservoir remaining units: " + reservoirRemainingUnits); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgStatus_k.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgStatus_k.java index 1fdcf26917..c81f010f16 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgStatus_k.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgStatus_k.java @@ -4,14 +4,17 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; public class MsgStatus_k extends MessageBase { - private static Logger log = LoggerFactory.getLogger(MsgStatus_k.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public MsgStatus_k() { SetCommand(0x020B); + if (Config.logPumpComm) + log.debug("New message"); } public void handleMessage(byte[] bytes) { @@ -27,7 +30,7 @@ public class MsgStatus_k extends MessageBase { // } pump.iob = intFromBuff(bytes, 15, 2) / 100d; - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Daily total: " + pump.dailyTotalUnits); log.debug("Is extended bolus running: " + pump.isExtendedInProgress); log.debug("Extended bolus min: " + pump.extendedBolusMinutes); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/services/DanaRKoreanExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/services/DanaRKoreanExecutionService.java index 0f4afa4314..25a4e21b72 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/services/DanaRKoreanExecutionService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/services/DanaRKoreanExecutionService.java @@ -7,8 +7,6 @@ import android.os.SystemClock; import com.squareup.otto.Subscribe; -import org.slf4j.LoggerFactory; - import java.io.IOException; import java.util.Date; @@ -50,7 +48,6 @@ import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgStatusBolusExtended; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgStatusTempBasal; import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRNewStatus; import info.nightscout.androidaps.plugins.PumpDanaR.services.AbstractDanaRExecutionService; -import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin; import info.nightscout.androidaps.plugins.PumpDanaRKorean.SerialIOThread; import info.nightscout.androidaps.plugins.PumpDanaRKorean.comm.MsgCheckValue_k; import info.nightscout.androidaps.plugins.PumpDanaRKorean.comm.MsgSettingBasal_k; @@ -63,7 +60,6 @@ import info.nightscout.utils.SP; public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService { public DanaRKoreanExecutionService() { - log = LoggerFactory.getLogger(DanaRKoreanExecutionService.class); mBinder = new LocalBinder(); registerBus(); @@ -87,7 +83,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService { @Subscribe public void onStatusEvent(EventAppExit event) { - if (Config.logFunctionCalls) + if (Config.logPump) log.debug("EventAppExit received"); if (mSerialIOThread != null) @@ -96,7 +92,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService { MainApp.instance().getApplicationContext().unregisterReceiver(receiver); stopSelf(); - if (Config.logFunctionCalls) + if (Config.logPump) log.debug("EventAppExit finished"); } @@ -108,7 +104,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService { public void connect() { if (mDanaRPump.password != -1 && mDanaRPump.password != SP.getInt(R.string.key_danar_password, -1)) { - if(System.currentTimeMillis() > lastWrongPumpPassword + 30 * 1000) { + if (System.currentTimeMillis() > lastWrongPumpPassword + 30 * 1000) { Notification notification = new Notification(Notification.WRONG_PUMP_PASSWORD, MainApp.gs(R.string.wrongpumppassword), Notification.URGENT); notification.soundId = R.raw.error; lastWrongPumpPassword = System.currentTimeMillis(); @@ -119,35 +115,32 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService { if (mConnectionInProgress) return; - new Thread(new Runnable() { - @Override - public void run() { - mConnectionInProgress = true; - getBTSocketForSelectedPump(); - if (mRfcommSocket == null || mBTDevice == null) { - mConnectionInProgress = false; - return; // Device not found - } - - try { - mRfcommSocket.connect(); - } catch (IOException e) { - //log.error("Unhandled exception", e); - if (e.getMessage().contains("socket closed")) { - log.error("Unhandled exception", e); - } - } - - if (isConnected()) { - if (mSerialIOThread != null) { - mSerialIOThread.disconnect("Recreate SerialIOThread"); - } - mSerialIOThread = new SerialIOThread(mRfcommSocket); - MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTED, 0)); - } - + new Thread(() -> { + mConnectionInProgress = true; + getBTSocketForSelectedPump(); + if (mRfcommSocket == null || mBTDevice == null) { mConnectionInProgress = false; + return; // Device not found } + + try { + mRfcommSocket.connect(); + } catch (IOException e) { + //log.error("Unhandled exception", e); + if (e.getMessage().contains("socket closed")) { + log.error("Unhandled exception", e); + } + } + + if (isConnected()) { + if (mSerialIOThread != null) { + mSerialIOThread.disconnect("Recreate SerialIOThread"); + } + mSerialIOThread = new SerialIOThread(mRfcommSocket); + MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTED, 0)); + } + + mConnectionInProgress = false; }).start(); } @@ -200,12 +193,14 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService { MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime))); mSerialIOThread.sendMessage(new MsgSettingPumpTime()); long timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L; - log.debug("Pump time difference: " + timeDiff + " seconds"); + if (Config.logPump) + log.debug("Pump time difference: " + timeDiff + " seconds"); if (Math.abs(timeDiff) > 10) { mSerialIOThread.sendMessage(new MsgSetTime(new Date())); mSerialIOThread.sendMessage(new MsgSettingPumpTime()); timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L; - log.debug("Pump time difference: " + timeDiff + " seconds"); + if (Config.logPump) + log.debug("Pump time difference: " + timeDiff + " seconds"); } mDanaRPump.lastSettingsRead = now; } @@ -214,8 +209,9 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService { MainApp.bus().post(new EventInitializationChanged()); NSUpload.uploadDeviceStatus(); if (mDanaRPump.dailyTotalUnits > mDanaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) { - log.debug("Approaching daily limit: " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits); - if(System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) { + if (Config.logPump) + log.debug("Approaching daily limit: " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits); + if (System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) { Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.gs(R.string.approachingdailylimit), Notification.URGENT); MainApp.bus().post(new EventNewNotification(reportFail)); NSUpload.uploadError(MainApp.gs(R.string.approachingdailylimit) + ": " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits + "U"); @@ -300,7 +296,8 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService { if ((System.currentTimeMillis() - progress.lastReceive) > 15 * 1000L) { // if i didn't receive status for more than 15 sec expecting broken comm stop.stopped = true; stop.forced = true; - log.debug("Communication stopped"); + if (Config.logPump) + log.debug("Communication stopped"); } } SystemClock.sleep(300); @@ -332,7 +329,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService { public boolean updateBasalsInPump(final Profile profile) { if (!isConnected()) return false; MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.updatingbasalrates))); - double[] basal = DanaRPump.buildDanaRProfileRecord(profile); + double[] basal = DanaRPump.getInstance().buildDanaRProfileRecord(profile); MsgSetSingleBasalProfile msgSet = new MsgSetSingleBasalProfile(basal); mSerialIOThread.sendMessage(msgSet); mDanaRPump.lastSettingsRead = 0; // force read full settings diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java index 36edf1e94f..613d77a44d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java @@ -21,6 +21,7 @@ import java.util.Date; import info.nightscout.androidaps.BuildConfig; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.DetailedBolusInfo; @@ -64,7 +65,7 @@ import info.nightscout.utils.T; */ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInterface, ConstraintsInterface, ProfileInterface { - private static Logger log = LoggerFactory.getLogger(DanaRSPlugin.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMP); private static DanaRSPlugin plugin = null; public static DanaRSPlugin getPlugin() { @@ -155,7 +156,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte @Override public void switchAllowed(ConfigBuilderFragment.PluginViewHolder.PluginSwitcher pluginSwitcher, FragmentActivity context) { boolean allowHardwarePump = SP.getBoolean("allow_hardware_pump", false); - if (allowHardwarePump || context == null){ + if (allowHardwarePump || context == null) { pluginSwitcher.invoke(); } else { AlertDialog.Builder builder = new AlertDialog.Builder(context); @@ -164,13 +165,15 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte public void onClick(DialogInterface dialog, int id) { pluginSwitcher.invoke(); SP.putBoolean("allow_hardware_pump", true); - log.debug("First time HW pump allowed!"); + if (Config.logPump) + log.debug("First time HW pump allowed!"); } }) .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { pluginSwitcher.cancel(); - log.debug("User does not allow switching to HW pump!"); + if (Config.logPump) + log.debug("User does not allow switching to HW pump!"); } }); builder.create().show(); @@ -180,12 +183,14 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte private ServiceConnection mConnection = new ServiceConnection() { public void onServiceDisconnected(ComponentName name) { - log.debug("Service is disconnected"); + if (Config.logPump) + log.debug("Service is disconnected"); danaRSService = null; } public void onServiceConnected(ComponentName name, IBinder service) { - log.debug("Service is connected"); + if (Config.logPump) + log.debug("Service is connected"); DanaRSService.LocalBinder mLocalBinder = (DanaRSService.LocalBinder) service; danaRSService = mLocalBinder.getServiceInstance(); } @@ -205,7 +210,8 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte @Override public void connect(String from) { - log.debug("RS connect from: " + from); + if (Config.logPump) + log.debug("RS connect from: " + from); if (danaRSService != null && !mDeviceAddress.equals("") && !mDeviceName.equals("")) { final Object o = new Object(); @@ -225,6 +231,8 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte @Override public void disconnect(String from) { + if (Config.logPump) + log.debug("RS disconnect from: " + from); if (danaRSService != null) danaRSService.disconnect(from); } @@ -370,7 +378,8 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte Double profileValue = profile.getBasalTimeFromMidnight((Integer) (h * basalIncrement)); if (profileValue == null) return true; if (Math.abs(pumpValue - profileValue) > getPumpDescription().basalStep) { - log.debug("Diff found. Hour: " + h + " Pump: " + pumpValue + " Profile: " + profileValue); + if (Config.logPump) + log.debug("Diff found. Hour: " + h + " Pump: " + pumpValue + " Profile: " + profileValue); return false; } } @@ -430,7 +439,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte result.comment = String.format(MainApp.gs(R.string.boluserrorcode), detailedBolusInfo.insulin, t.insulin, DanaRS_Packet_Bolus_Set_Step_Bolus_Start.errorCode); else result.comment = MainApp.gs(R.string.virtualpump_resultok); - if (Config.logPumpActions) + if (Config.logPump) log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered); return result; } else { @@ -474,7 +483,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte if (doTempOff) { // If temp in progress if (TreatmentsPlugin.getPlugin().isTempBasalInProgress()) { - if (Config.logPumpActions) + if (Config.logPump) log.debug("setTempBasalAbsolute: Stopping temp basal (doTempOff)"); return cancelTempBasal(false); } @@ -483,7 +492,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte result.percent = 100; result.isPercent = true; result.isTempCancel = true; - if (Config.logPumpActions) + if (Config.logPump) log.debug("setTempBasalAbsolute: doTempOff OK"); return result; } @@ -497,7 +506,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte // Check if some temp is already in progress TemporaryBasal activeTemp = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(System.currentTimeMillis()); if (activeTemp != null) { - if (Config.logPumpActions) + if (Config.logPump) log.debug("setTempBasalAbsolute: currently running: " + activeTemp.toString()); // Correct basal already set ? if (activeTemp.percentRate == percentRate) { @@ -508,14 +517,14 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte result.duration = activeTemp.getPlannedRemainingMinutes(); result.isPercent = true; result.isTempCancel = false; - if (Config.logPumpActions) + if (Config.logPump) log.debug("setTempBasalAbsolute: Correct temp basal already set (doLowTemp || doHighTemp)"); return result; } } } // Convert duration from minutes to hours - if (Config.logPumpActions) + if (Config.logPump) log.debug("setTempBasalAbsolute: Setting temp basal " + percentRate + "% for " + durationInMinutes + " mins (doLowTemp || doHighTemp)"); if (percentRate == 0 && durationInMinutes > 30) { result = setTempBasalPercent(percentRate, durationInMinutes, profile, false); @@ -527,7 +536,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte log.error("setTempBasalAbsolute: Failed to set hightemp basal"); return result; } - if (Config.logPumpActions) + if (Config.logPump) log.debug("setTempBasalAbsolute: hightemp basal set ok"); return result; } @@ -562,7 +571,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte result.duration = pump.tempBasalRemainingMin; result.percent = pump.tempBasalPercent; result.isPercent = true; - if (Config.logPumpActions) + if (Config.logPump) log.debug("setTempBasalPercent: Correct value already set"); return result; } @@ -581,7 +590,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte result.duration = pump.tempBasalRemainingMin; result.percent = pump.tempBasalPercent; result.isPercent = true; - if (Config.logPumpActions) + if (Config.logPump) log.debug("setTempBasalPercent: OK"); return result; } @@ -603,7 +612,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte result.duration = pump.tempBasalRemainingMin; result.percent = pump.tempBasalPercent; result.isPercent = true; - if (Config.logPumpActions) + if (Config.logPump) log.debug("setHighTempBasalPercent: OK"); return result; } @@ -630,7 +639,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte result.absolute = pump.extendedBolusAbsoluteRate; result.isPercent = false; result.isTempCancel = false; - if (Config.logPumpActions) + if (Config.logPump) log.debug("setExtendedBolus: Correct extended bolus already set. Current: " + pump.extendedBolusAmount + " Asked: " + insulin); return result; } @@ -644,7 +653,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte result.absolute = pump.extendedBolusAbsoluteRate; result.bolusDelivered = pump.extendedBolusAmount; result.isPercent = false; - if (Config.logPumpActions) + if (Config.logPump) log.debug("setExtendedBolus: OK"); return result; } @@ -668,7 +677,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte result.success = true; result.isTempCancel = true; result.comment = MainApp.gs(R.string.virtualpump_resultok); - if (Config.logPumpActions) + if (Config.logPump) log.debug("cancelRealTempBasal: OK"); return result; } else { @@ -692,7 +701,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte if (!pump.isExtendedInProgress) { result.success = true; result.comment = MainApp.gs(R.string.virtualpump_resultok); - if (Config.logPumpActions) + if (Config.logPump) log.debug("cancelExtendedBolus: OK"); return result; } else { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/activities/BLEScanActivity.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/activities/BLEScanActivity.java index 3b6bcaf099..7594e917c5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/activities/BLEScanActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/activities/BLEScanActivity.java @@ -31,9 +31,6 @@ import info.nightscout.androidaps.plugins.PumpDanaRS.events.EventDanaRSDeviceCha import info.nightscout.utils.SP; public class BLEScanActivity extends AppCompatActivity { - private static Logger log = LoggerFactory.getLogger(BLEScanActivity.class); - - private ListView listView = null; private ListAdapter mListAdapter = null; private ArrayList mDevices = new ArrayList<>(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/activities/PairingProgressDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/activities/PairingProgressDialog.java index 9f72e1d08f..5f339cd528 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/activities/PairingProgressDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/activities/PairingProgressDialog.java @@ -9,7 +9,6 @@ import android.support.v4.app.DialogFragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.view.Window; import android.widget.Button; import android.widget.ProgressBar; import android.widget.TextView; @@ -63,46 +62,37 @@ public class PairingProgressDialog extends DialogFragment implements View.OnClic button.setOnClickListener(this); setCancelable(false); - sHandler.post(new Runnable() { - @Override - public void run() { - for (int i = 0; i < 20; i++) { - if (pairingEnded) { - Activity activity = getActivity(); - if (activity != null) { - activity.runOnUiThread(new Runnable() { - @Override - public void run() { - progressBar.setProgress(100); - statusView.setText(R.string.pairingok); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - } - dismiss(); - } - }); - } else - dismiss(); - return; - } - progressBar.setProgress(i * 5); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - } - } - Activity activity = getActivity(); - if (activity != null) { - activity.runOnUiThread(new Runnable() { - @Override - public void run() { + sHandler.post(() -> { + for (int i = 0; i < 20; i++) { + if (pairingEnded) { + Activity activity = getActivity(); + if (activity != null) { + activity.runOnUiThread(() -> { progressBar.setProgress(100); - statusView.setText(R.string.pairingtimedout); - button.setVisibility(View.VISIBLE); - } - }); + statusView.setText(R.string.pairingok); + try { + Thread.sleep(1000); + } catch (InterruptedException ignored) { + } + dismiss(); + }); + } else + dismiss(); + return; } + progressBar.setProgress(i * 5); + try { + Thread.sleep(1000); + } catch (InterruptedException ignored) { + } + } + Activity activity = getActivity(); + if (activity != null) { + activity.runOnUiThread(() -> { + progressBar.setProgress(100); + statusView.setText(R.string.pairingtimedout); + button.setVisibility(View.VISIBLE); + }); } }); return view; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRSMessageHashTable.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRSMessageHashTable.java index 5457bb4155..9827d42ba7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRSMessageHashTable.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRSMessageHashTable.java @@ -11,14 +11,12 @@ import info.nightscout.androidaps.Config; * Created by mike on 28.05.2016. */ public class DanaRSMessageHashTable { - private static Logger log = LoggerFactory.getLogger(DanaRSMessageHashTable.class); - public static HashMap messages = null; static { if (messages == null) { - boolean savedState = Config.logDanaMessageDetail; - Config.logDanaMessageDetail = false; + boolean savedState = Config.logPumpComm; + Config.logPumpComm = false; messages = new HashMap<>(); put(new DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal()); @@ -89,7 +87,7 @@ public class DanaRSMessageHashTable { put(new DanaRS_Packet_APS_History_Events()); put(new DanaRS_Packet_APS_Set_Event_History()); - Config.logDanaMessageDetail = savedState; + Config.logPumpComm = savedState; } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.java index 5da3655ceb..b145c0d8fe 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.java @@ -6,9 +6,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; public class DanaRS_Packet_APS_Basal_Set_Temporary_Basal extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_APS_Basal_Set_Temporary_Basal.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); int temporaryBasalRatio; int temporaryBasalDuration; @@ -25,6 +26,8 @@ public class DanaRS_Packet_APS_Basal_Set_Temporary_Basal extends DanaRS_Packet { public DanaRS_Packet_APS_Basal_Set_Temporary_Basal(int percent) { this(); setParams(percent); + if (Config.logPumpComm) + log.debug("New message: percent: " + percent); } protected void setParams(int percent) { @@ -35,16 +38,16 @@ public class DanaRS_Packet_APS_Basal_Set_Temporary_Basal extends DanaRS_Packet { temporaryBasalRatio = percent; if (percent < 100) { temporaryBasalDuration = PARAM30MIN; - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("APS Temp basal start percent: " + percent + " duration 30 min"); } else { temporaryBasalDuration = PARAM15MIN; - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("APS Temp basal start percent: " + percent + " duration 15 min"); } } - public DanaRS_Packet_APS_Basal_Set_Temporary_Basal(int percent, boolean fifteenMinutes, boolean thirtyMinutes ) { + public DanaRS_Packet_APS_Basal_Set_Temporary_Basal(int percent, boolean fifteenMinutes, boolean thirtyMinutes) { this(); setParams(percent, fifteenMinutes, thirtyMinutes); } @@ -57,11 +60,11 @@ public class DanaRS_Packet_APS_Basal_Set_Temporary_Basal extends DanaRS_Packet { temporaryBasalRatio = percent; if (thirtyMinutes && percent <= 200) { // 30 min is allowed up to 200% temporaryBasalDuration = PARAM30MIN; - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("APS Temp basal start percent: " + percent + " duration 30 min"); } else { temporaryBasalDuration = PARAM15MIN; - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("APS Temp basal start percent: " + percent + " duration 15 min"); } } @@ -80,10 +83,11 @@ public class DanaRS_Packet_APS_Basal_Set_Temporary_Basal extends DanaRS_Packet { int result = byteArrayToInt(getBytes(data, DATA_START, 1)); if (result != 0) { failed = true; - log.error("Set APS temp basal start result: " + result + " FAILED!!!"); + if (Config.logPumpComm) + log.debug("Set APS temp basal start result: " + result + " FAILED!!!"); } else { failed = false; - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("Set APS temp basal start result: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_History_Events.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_History_Events.java index b8c8aaf2b4..76994861fb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_History_Events.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_History_Events.java @@ -9,6 +9,8 @@ import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; +import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.DetailedBolusInfo; @@ -22,7 +24,7 @@ import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin; import info.nightscout.utils.DateUtil; public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_APS_History_Events.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private int year = 0; private int month = 0; @@ -32,7 +34,6 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet { private int sec = 0; public static boolean done; - private static int totalCount; public static long lastEventTimeLoaded = 0; @@ -40,7 +41,6 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE__APS_HISTORY_EVENTS; done = false; - totalCount = 0; } public DanaRS_Packet_APS_History_Events(long from) { @@ -56,7 +56,8 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet { hour = cal.get(Calendar.HOUR_OF_DAY); min = cal.get(Calendar.MINUTE); sec = cal.get(Calendar.SECOND); - log.debug("Loading event history from: " + new Date(cal.getTimeInMillis()).toLocaleString()); + if (Config.logPumpComm) + log.debug("Loading event history from: " + new Date(cal.getTimeInMillis()).toLocaleString()); } @Override @@ -78,7 +79,8 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet { // Last record if (recordCode == (byte) 0xFF) { done = true; - log.debug("Last record received"); + if (Config.logPumpComm) + log.debug("Last record received"); return; } @@ -95,10 +97,12 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet { DetailedBolusInfo detailedBolusInfo = DetailedBolusInfoStorage.findDetailedBolusInfo(datetime.getTime()); if (detailedBolusInfo == null) { - log.debug("Detailed bolus info not found for " + datetime.toLocaleString()); + if (Config.logPumpComm) + log.debug("Detailed bolus info not found for " + datetime.toLocaleString()); detailedBolusInfo = new DetailedBolusInfo(); } else { - log.debug("Detailed bolus info found: " + detailedBolusInfo); + if (Config.logPumpComm) + log.debug("Detailed bolus info found: " + detailedBolusInfo); } detailedBolusInfo.date = datetime.getTime(); detailedBolusInfo.source = Source.PUMP; @@ -108,73 +112,86 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet { switch (recordCode) { case DanaRPump.TEMPSTART: - log.debug("EVENT TEMPSTART (" + recordCode + ") " + datetime.toLocaleString() + " Ratio: " + param1 + "% Duration: " + param2 + "min"); + if (Config.logPumpComm) + log.debug("EVENT TEMPSTART (" + recordCode + ") " + datetime.toLocaleString() + " Ratio: " + param1 + "% Duration: " + param2 + "min"); temporaryBasal.percentRate = param1; temporaryBasal.durationInMinutes = param2; TreatmentsPlugin.getPlugin().addToHistoryTempBasal(temporaryBasal); status = "TEMPSTART " + DateUtil.timeString(datetime); break; case DanaRPump.TEMPSTOP: - log.debug("EVENT TEMPSTOP (" + recordCode + ") " + datetime.toLocaleString()); + if (Config.logPumpComm) + log.debug("EVENT TEMPSTOP (" + recordCode + ") " + datetime.toLocaleString()); TreatmentsPlugin.getPlugin().addToHistoryTempBasal(temporaryBasal); status = "TEMPSTOP " + DateUtil.timeString(datetime); break; case DanaRPump.EXTENDEDSTART: - log.debug("EVENT EXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min"); + if (Config.logPumpComm) + log.debug("EVENT EXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min"); extendedBolus.insulin = param1 / 100d; extendedBolus.durationInMinutes = param2; TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus); status = "EXTENDEDSTART " + DateUtil.timeString(datetime); break; case DanaRPump.EXTENDEDSTOP: - log.debug("EVENT EXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min"); + if (Config.logPumpComm) + log.debug("EVENT EXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min"); TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus); status = "EXTENDEDSTOP " + DateUtil.timeString(datetime); break; case DanaRPump.BOLUS: detailedBolusInfo.insulin = param1 / 100d; boolean newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false); - log.debug((newRecord ? "**NEW** " : "") + "EVENT BOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min"); + if (Config.logPumpComm) + log.debug((newRecord ? "**NEW** " : "") + "EVENT BOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min"); DetailedBolusInfoStorage.remove(detailedBolusInfo.date); status = "BOLUS " + DateUtil.timeString(datetime); break; case DanaRPump.DUALBOLUS: detailedBolusInfo.insulin = param1 / 100d; newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false); - log.debug((newRecord ? "**NEW** " : "") + "EVENT DUALBOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min"); + if (Config.logPumpComm) + log.debug((newRecord ? "**NEW** " : "") + "EVENT DUALBOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min"); DetailedBolusInfoStorage.remove(detailedBolusInfo.date); status = "DUALBOLUS " + DateUtil.timeString(datetime); break; case DanaRPump.DUALEXTENDEDSTART: - log.debug("EVENT DUALEXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min"); + if (Config.logPumpComm) + log.debug("EVENT DUALEXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min"); extendedBolus.insulin = param1 / 100d; extendedBolus.durationInMinutes = param2; TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus); status = "DUALEXTENDEDSTART " + DateUtil.timeString(datetime); break; case DanaRPump.DUALEXTENDEDSTOP: - log.debug("EVENT DUALEXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min"); + if (Config.logPumpComm) + log.debug("EVENT DUALEXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min"); TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus); status = "DUALEXTENDEDSTOP " + DateUtil.timeString(datetime); break; case DanaRPump.SUSPENDON: - log.debug("EVENT SUSPENDON (" + recordCode + ") " + datetime.toLocaleString()); + if (Config.logPumpComm) + log.debug("EVENT SUSPENDON (" + recordCode + ") " + datetime.toLocaleString()); status = "SUSPENDON " + DateUtil.timeString(datetime); break; case DanaRPump.SUSPENDOFF: - log.debug("EVENT SUSPENDOFF (" + recordCode + ") " + datetime.toLocaleString()); + if (Config.logPumpComm) + log.debug("EVENT SUSPENDOFF (" + recordCode + ") " + datetime.toLocaleString()); status = "SUSPENDOFF " + DateUtil.timeString(datetime); break; case DanaRPump.REFILL: - log.debug("EVENT REFILL (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U"); + if (Config.logPumpComm) + log.debug("EVENT REFILL (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U"); status = "REFILL " + DateUtil.timeString(datetime); break; case DanaRPump.PRIME: - log.debug("EVENT PRIME (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U"); + if (Config.logPumpComm) + log.debug("EVENT PRIME (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U"); status = "PRIME " + DateUtil.timeString(datetime); break; case DanaRPump.PROFILECHANGE: - log.debug("EVENT PROFILECHANGE (" + recordCode + ") " + datetime.toLocaleString() + " No: " + param1 + " CurrentRate: " + (param2 / 100d) + "U/h"); + if (Config.logPumpComm) + log.debug("EVENT PROFILECHANGE (" + recordCode + ") " + datetime.toLocaleString() + " No: " + param1 + " CurrentRate: " + (param2 / 100d) + "U/h"); status = "PROFILECHANGE " + DateUtil.timeString(datetime); break; case DanaRPump.CARBS: @@ -184,15 +201,18 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet { emptyCarbsInfo.source = Source.PUMP; emptyCarbsInfo.pumpId = datetime.getTime(); newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(emptyCarbsInfo, false); - log.debug((newRecord ? "**NEW** " : "") + "EVENT CARBS (" + recordCode + ") " + datetime.toLocaleString() + " Carbs: " + param1 + "g"); + if (Config.logPumpComm) + log.debug((newRecord ? "**NEW** " : "") + "EVENT CARBS (" + recordCode + ") " + datetime.toLocaleString() + " Carbs: " + param1 + "g"); status = "CARBS " + DateUtil.timeString(datetime); break; case DanaRPump.PRIMECANNULA: - log.debug("EVENT PRIMECANNULA(" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U"); + if (Config.logPumpComm) + log.debug("EVENT PRIMECANNULA(" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U"); status = "PRIMECANNULA " + DateUtil.timeString(datetime); break; default: - log.debug("Event: " + recordCode + " " + datetime.toLocaleString() + " Param1: " + param1 + " Param2: " + param2); + if (Config.logPumpComm) + log.debug("Event: " + recordCode + " " + datetime.toLocaleString() + " Param1: " + param1 + " Param2: " + param2); status = "UNKNOWN " + DateUtil.timeString(datetime); break; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Set_Event_History.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Set_Event_History.java index 84ead83665..efd3aaa8f4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Set_Event_History.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Set_Event_History.java @@ -9,15 +9,16 @@ import java.util.Calendar; import java.util.GregorianCalendar; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.utils.DateUtil; public class DanaRS_Packet_APS_Set_Event_History extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_APS_Set_Event_History.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private int type; private long time; - public int param1; - public int param2; + private int param1; + private int param2; public DanaRS_Packet_APS_Set_Event_History() { super(); @@ -31,7 +32,7 @@ public class DanaRS_Packet_APS_Set_Event_History extends DanaRS_Packet { this.time = time; this.param1 = param1; this.param2 = param2; - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("Set history entry: " + DateUtil.dateAndTimeString(time) + " type: " + type + " param1: " + param1 + " param2: " + param2); } @@ -66,9 +67,10 @@ public class DanaRS_Packet_APS_Set_Event_History extends DanaRS_Packet { int result = intFromBuff(data, 0, 1); if (result != 0) { failed = true; - log.error("Set history entry result: " + result + " FAILED!!!"); + if (Config.logPumpComm) + log.error("Set history entry result: " + result + " FAILED!!!"); } else { - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("Set history entry result: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Basal_Rate.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Basal_Rate.java index f3fef0d49d..f358cbdcd0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Basal_Rate.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Basal_Rate.java @@ -1,27 +1,28 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; +import com.cozmo.danar.util.BleCommandUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; -import info.nightscout.androidaps.plugins.Overview.notifications.Notification; import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; +import info.nightscout.androidaps.plugins.Overview.notifications.Notification; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; -import com.cozmo.danar.util.BleCommandUtil; - public class DanaRS_Packet_Basal_Get_Basal_Rate extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public DanaRS_Packet_Basal_Get_Basal_Rate() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__GET_BASAL_RATE; - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Requesting basal rates"); } } @@ -45,7 +46,7 @@ public class DanaRS_Packet_Basal_Get_Basal_Rate extends DanaRS_Packet { dataSize = 2; pump.pumpProfiles[pump.activeProfile][i] = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d; } - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Max basal: " + pump.maxBasal + " U"); log.debug("Basal step: " + pump.basalStep + " U"); for (int index = 0; index < 24; index++) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Profile_Basal_Rate.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Profile_Basal_Rate.java index 8eadb8298d..2b4e830644 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Profile_Basal_Rate.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Profile_Basal_Rate.java @@ -1,14 +1,16 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; +import com.cozmo.danar.util.BleCommandUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; -import com.cozmo.danar.util.BleCommandUtil; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class DanaRS_Packet_Basal_Get_Profile_Basal_Rate extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Basal_Get_Profile_Basal_Rate.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private int profileNumber; @@ -21,7 +23,7 @@ public class DanaRS_Packet_Basal_Get_Profile_Basal_Rate extends DanaRS_Packet { public DanaRS_Packet_Basal_Get_Profile_Basal_Rate(int profileNumber) { this(); this.profileNumber = profileNumber; - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Requesting basal rates for profile " + profileNumber); } } @@ -47,7 +49,7 @@ public class DanaRS_Packet_Basal_Get_Profile_Basal_Rate extends DanaRS_Packet { dataIndex += dataSize; dataSize = 2; } - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { for (int index = 0; index < 24; index++) log.debug("Basal " + String.format("%02d", index) + "h: " + pump.pumpProfiles[profileNumber][index]); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Profile_Number.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Profile_Number.java index 39e230a29e..c376a35cba 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Profile_Number.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Profile_Number.java @@ -1,19 +1,21 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; +import com.cozmo.danar.util.BleCommandUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; -import com.cozmo.danar.util.BleCommandUtil; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class DanaRS_Packet_Basal_Get_Profile_Number extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Basal_Get_Profile_Number.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public DanaRS_Packet_Basal_Get_Profile_Number() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__GET_PROFILE_NUMBER; - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Requesting active profile"); } } @@ -25,7 +27,7 @@ public class DanaRS_Packet_Basal_Get_Profile_Number extends DanaRS_Packet { int dataIndex = DATA_START; int dataSize = 1; pump.activeProfile = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Active profile: " + pump.activeProfile); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_State.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_State.java index dbf917874d..0b892c8335 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_State.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_State.java @@ -2,22 +2,24 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; import android.support.annotation.NonNull; +import com.cozmo.danar.util.BleCommandUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.Date; import info.nightscout.androidaps.Config; -import com.cozmo.danar.util.BleCommandUtil; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class DanaRS_Packet_Basal_Get_Temporary_Basal_State extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Basal_Get_Temporary_Basal_State.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public DanaRS_Packet_Basal_Get_Temporary_Basal_State() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__TEMPORARY_BASAL_STATE; - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Requesting temporary basal status"); } } @@ -53,7 +55,7 @@ public class DanaRS_Packet_Basal_Get_Temporary_Basal_State extends DanaRS_Packet int tempBasalRemainingMin = (pump.tempBasalTotalSec - runningMin * 60) / 60; Date tempBasalStart = pump.isTempBasalInProgress ? getDateFromTempBasalSecAgo(runningMin * 60) : new Date(0); - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Error code: " + error); log.debug("Is temp basal running: " + pump.isTempBasalInProgress); log.debug("Is APS temp basal running: " + isAPSTempBasalInProgress); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Basal_Rate.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Basal_Rate.java index a64da24bf3..bf6f6922a0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Basal_Rate.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Basal_Rate.java @@ -4,11 +4,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import com.cozmo.danar.util.BleCommandUtil; public class DanaRS_Packet_Basal_Set_Basal_Rate extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Basal_Set_Basal_Rate.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private double[] profileBasalRate; @@ -20,7 +21,7 @@ public class DanaRS_Packet_Basal_Set_Basal_Rate extends DanaRS_Packet { public DanaRS_Packet_Basal_Set_Basal_Rate(double[] profileBasalRate) { this(); this.profileBasalRate = profileBasalRate; - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Setting new basal rates"); } } @@ -39,7 +40,7 @@ public class DanaRS_Packet_Basal_Set_Basal_Rate extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { int result = intFromBuff(data, 0, 1); - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { if (result == 0) log.debug("Result OK"); else diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.java index 538750a45b..667360202d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.java @@ -1,19 +1,20 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; +import com.cozmo.danar.util.BleCommandUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; - -import com.cozmo.danar.util.BleCommandUtil; +import info.nightscout.androidaps.Constants; public class DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__CANCEL_TEMPORARY_BASAL; - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Canceling temp basal"); } } @@ -21,7 +22,7 @@ public class DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal extends DanaRS_Packe @Override public void handleMessage(byte[] data) { int result = intFromBuff(data, 0, 1); - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { if (result == 0) log.debug("Result OK"); else diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_Rate.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_Rate.java index 66d0e7b4bb..29df6e69ac 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_Rate.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_Rate.java @@ -1,13 +1,15 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; +import com.cozmo.danar.util.BleCommandUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; -import com.cozmo.danar.util.BleCommandUtil; +import info.nightscout.androidaps.Constants; public class DanaRS_Packet_Basal_Set_Profile_Basal_Rate extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Basal_Set_Profile_Basal_Rate.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private int profileNumber; // 0 - 4 private double[] profileBasalRate; @@ -21,7 +23,7 @@ public class DanaRS_Packet_Basal_Set_Profile_Basal_Rate extends DanaRS_Packet { this(); this.profileNumber = profileNumber; this.profileBasalRate = profileBasalRate; - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Setting new basal rates for profile " + profileNumber); } } @@ -41,7 +43,7 @@ public class DanaRS_Packet_Basal_Set_Profile_Basal_Rate extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { int result = intFromBuff(data, 0, 1); - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { if (result == 0) log.debug("Result OK"); else diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Profile_Number.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Profile_Number.java index 69f7eae8dd..dcb03a89ae 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Profile_Number.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Profile_Number.java @@ -1,48 +1,50 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; +import com.cozmo.danar.util.BleCommandUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; - -import com.cozmo.danar.util.BleCommandUtil; +import info.nightscout.androidaps.Constants; public class DanaRS_Packet_Basal_Set_Profile_Number extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Basal_Set_Profile_Number.class); - private int profileNumber; + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private int profileNumber; - public DanaRS_Packet_Basal_Set_Profile_Number() { + public DanaRS_Packet_Basal_Set_Profile_Number() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__SET_PROFILE_NUMBER; } - public DanaRS_Packet_Basal_Set_Profile_Number(int profileNumber) { - this(); - this.profileNumber = profileNumber; - if (Config.logDanaMessageDetail) { - log.debug("Setting profile number " + profileNumber); - } - } - @Override - public byte[] getRequestParams() { - byte[] request = new byte[1]; - request[0] = (byte) (profileNumber & 0xff); - return request; - } + public DanaRS_Packet_Basal_Set_Profile_Number(int profileNumber) { + this(); + this.profileNumber = profileNumber; + if (Config.logPumpComm) { + log.debug("Setting profile number " + profileNumber); + } + } @Override - public void handleMessage(byte[] data) { - int result = intFromBuff(data, 0, 1); - if (Config.logDanaMessageDetail) { - if (result == 0) - log.debug("Result OK"); - else - log.error("Result Error: " + result); - } - } + public byte[] getRequestParams() { + byte[] request = new byte[1]; + request[0] = (byte) (profileNumber & 0xff); + return request; + } - @Override - public String getFriendlyName() { - return "BASAL__SET_PROFILE_NUMBER"; - } + @Override + public void handleMessage(byte[] data) { + int result = intFromBuff(data, 0, 1); + if (Config.logPumpComm) { + if (result == 0) + log.debug("Result OK"); + else + log.error("Result Error: " + result); + } + } + + @Override + public String getFriendlyName() { + return "BASAL__SET_PROFILE_NUMBER"; + } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Suspend_Off.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Suspend_Off.java index 4c78038162..7614488a78 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Suspend_Off.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Suspend_Off.java @@ -1,18 +1,20 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; +import com.cozmo.danar.util.BleCommandUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; -import com.cozmo.danar.util.BleCommandUtil; +import info.nightscout.androidaps.Constants; public class DanaRS_Packet_Basal_Set_Suspend_Off extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Basal_Set_Suspend_Off.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public DanaRS_Packet_Basal_Set_Suspend_Off() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__SET_SUSPEND_OFF; - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Turning off suspend"); } } @@ -20,7 +22,7 @@ public class DanaRS_Packet_Basal_Set_Suspend_Off extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { int result = intFromBuff(data, 0, 1); - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { if (result == 0) log.debug("Result OK"); else diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Suspend_On.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Suspend_On.java index 75a2a5fada..72049bc033 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Suspend_On.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Suspend_On.java @@ -1,18 +1,20 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; +import com.cozmo.danar.util.BleCommandUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; -import com.cozmo.danar.util.BleCommandUtil; +import info.nightscout.androidaps.Constants; public class DanaRS_Packet_Basal_Set_Suspend_On extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Basal_Set_Suspend_On.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public DanaRS_Packet_Basal_Set_Suspend_On() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__SET_SUSPEND_ON; - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Turning on suspend"); } } @@ -20,7 +22,7 @@ public class DanaRS_Packet_Basal_Set_Suspend_On extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { int result = intFromBuff(data, 0, 1); - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { if (result == 0) log.debug("Result OK"); else diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Temporary_Basal.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Temporary_Basal.java index d2f68ff864..fa23fa08f8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Temporary_Basal.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Temporary_Basal.java @@ -1,13 +1,15 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; +import com.cozmo.danar.util.BleCommandUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; -import com.cozmo.danar.util.BleCommandUtil; +import info.nightscout.androidaps.Constants; public class DanaRS_Packet_Basal_Set_Temporary_Basal extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Basal_Set_Temporary_Basal.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private int temporaryBasalRatio; private int temporaryBasalDuration; @@ -21,7 +23,7 @@ public class DanaRS_Packet_Basal_Set_Temporary_Basal extends DanaRS_Packet { this(); this.temporaryBasalRatio = temporaryBasalRatio; this.temporaryBasalDuration = temporaryBasalDuration; - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Setting temporary basal of " + temporaryBasalRatio + "% for " + temporaryBasalDuration + " hours"); } } @@ -37,7 +39,7 @@ public class DanaRS_Packet_Basal_Set_Temporary_Basal extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { int result = intFromBuff(data, 0, 1); - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { if (result == 0) log.debug("Result OK"); else diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_Option.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_Option.java index 69c2f75ba6..84b0bf1736 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_Option.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_Option.java @@ -1,24 +1,27 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; +import com.cozmo.danar.util.BleCommandUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; -import com.cozmo.danar.util.BleCommandUtil; - +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; -import info.nightscout.androidaps.plugins.Overview.notifications.Notification; import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; +import info.nightscout.androidaps.plugins.Overview.notifications.Notification; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class DanaRS_Packet_Bolus_Get_Bolus_Option extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Bolus_Get_Bolus_Option.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public DanaRS_Packet_Bolus_Get_Bolus_Option() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_BOLUS_OPTION; + if (Config.logPumpComm) + log.debug("New message"); } @Override @@ -108,7 +111,7 @@ public class DanaRS_Packet_Bolus_Get_Bolus_Option extends DanaRS_Packet { MainApp.bus().post(new EventDismissNotification(Notification.EXTENDED_BOLUS_DISABLED)); } - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Extended bolus enabled: " + pump.isExtendedBolusEnabled); log.debug("Missed bolus config: " + pump.missedBolusConfig); log.debug("missedBolus01StartHour: " + missedBolus01StartHour); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_CIR_CF_Array.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_CIR_CF_Array.java index b8a86cc078..fd4f942d1b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_CIR_CF_Array.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_CIR_CF_Array.java @@ -1,21 +1,23 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; +import com.cozmo.danar.util.BleCommandUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; - -import com.cozmo.danar.util.BleCommandUtil; - +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class DanaRS_Packet_Bolus_Get_CIR_CF_Array extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Bolus_Get_CIR_CF_Array.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public DanaRS_Packet_Bolus_Get_CIR_CF_Array() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_CIR_CF_ARRAY; + if (Config.logPumpComm) + log.debug("New message"); } @Override @@ -118,7 +120,7 @@ public class DanaRS_Packet_Bolus_Get_CIR_CF_Array extends DanaRS_Packet { pump.nightCF = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d; } - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Language: " + language); log.debug("Pump units: " + (pump.units == DanaRPump.UNITS_MGDL ? "MGDL" : "MMOL")); log.debug("Current pump morning CIR: " + pump.morningCIR); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Calculation_Information.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Calculation_Information.java index f5acedf3ba..a16368a8b3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Calculation_Information.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Calculation_Information.java @@ -1,20 +1,22 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; +import com.cozmo.danar.util.BleCommandUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; - -import com.cozmo.danar.util.BleCommandUtil; - +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class DanaRS_Packet_Bolus_Get_Calculation_Information extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Bolus_Get_Calculation_Information.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public DanaRS_Packet_Bolus_Get_Calculation_Information() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_CALCULATION_INFORMATION; + if (Config.logPumpComm) + log.debug("New message"); } @Override @@ -58,7 +60,7 @@ public class DanaRS_Packet_Bolus_Get_Calculation_Information extends DanaRS_Pack pump.currentTarget = pump.currentTarget / 100d; currentBG = currentBG / 100d; } - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Result: " + error); log.debug("Pump units: " + (pump.units == DanaRPump.UNITS_MGDL ? "MGDL" : "MMOL")); log.debug("Current BG: " + currentBG); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information.java index c581320c54..deb68ebac9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information.java @@ -1,20 +1,22 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; +import com.cozmo.danar.util.BleCommandUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; - -import com.cozmo.danar.util.BleCommandUtil; - +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_CARBOHYDRATE_CALCULATION_INFORMATION; + if (Config.logPumpComm) + log.debug("New message"); } @Override @@ -33,7 +35,7 @@ public class DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information extend dataSize = 2; pump.currentCIR = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Result: " + error); log.debug("Carbs: " + carbs); log.debug("Current CIR: " + pump.currentCIR); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Dual_Bolus.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Dual_Bolus.java index bd7a0b9ee6..7c5aaf7e9e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Dual_Bolus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Dual_Bolus.java @@ -1,18 +1,22 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; +import com.cozmo.danar.util.BleCommandUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; -import com.cozmo.danar.util.BleCommandUtil; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class DanaRS_Packet_Bolus_Get_Dual_Bolus extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Bolus_Get_Dual_Bolus.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public DanaRS_Packet_Bolus_Get_Dual_Bolus() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_DUAL_BOLUS; + if (Config.logPumpComm) + log.debug("New message"); } @Override @@ -39,7 +43,7 @@ public class DanaRS_Packet_Bolus_Get_Dual_Bolus extends DanaRS_Packet { dataSize = 1; double bolusIncrement = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d; - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Result: " + error); log.debug("Bolus step: " + pump.bolusStep + " U"); log.debug("Extended bolus running: " + pump.extendedBolusAbsoluteRate + " U/h"); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus.java index 682d9b14bb..bd7b1fb38a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus.java @@ -1,20 +1,22 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; +import com.cozmo.danar.util.BleCommandUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; - -import com.cozmo.danar.util.BleCommandUtil; - +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class DanaRS_Packet_Bolus_Get_Extended_Bolus extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Bolus_Get_Extended_Bolus.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public DanaRS_Packet_Bolus_Get_Extended_Bolus() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_EXTENDED_BOLUS; + if (Config.logPumpComm) + log.debug("New message"); } @Override @@ -37,7 +39,7 @@ public class DanaRS_Packet_Bolus_Get_Extended_Bolus extends DanaRS_Packet { dataSize = 1; pump.bolusStep = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d; - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Result: " + error); log.debug("Extended bolus running: " + pump.extendedBolusAbsoluteRate + " U/h"); log.debug("Max bolus: " + pump.maxBolus + " U"); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus_State.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus_State.java index b22a9dfb47..a793de020c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus_State.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus_State.java @@ -1,20 +1,22 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; +import com.cozmo.danar.util.BleCommandUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; - -import com.cozmo.danar.util.BleCommandUtil; - +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class DanaRS_Packet_Bolus_Get_Extended_Bolus_State extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Bolus_Get_Extended_Bolus_State.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public DanaRS_Packet_Bolus_Get_Extended_Bolus_State() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_EXTENDED_BOLUS_STATE; + if (Config.logPumpComm) + log.debug("New message"); } @Override @@ -45,7 +47,7 @@ public class DanaRS_Packet_Bolus_Get_Extended_Bolus_State extends DanaRS_Packet dataSize = 2; pump.extendedBolusDeliveredSoFar = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d; - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Result: " + error); log.debug("Is extended bolus running: " + pump.isExtendedInProgress); log.debug("Extended bolus running: " + pump.extendedBolusAbsoluteRate + " U/h"); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State.java index 5a7ca55e30..e6512522a8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State.java @@ -1,20 +1,22 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; +import com.cozmo.danar.util.BleCommandUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; - -import com.cozmo.danar.util.BleCommandUtil; - +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_EXTENDED_MENU_OPTION_STATE; + if (Config.logPumpComm) + log.debug("New message"); } @Override @@ -29,7 +31,7 @@ public class DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State extends DanaRS_P dataSize = 1; pump.isExtendedInProgress = byteArrayToInt(getBytes(data, dataIndex, dataSize)) == 0x01; - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("extendedMenuOption: " + extendedMenuOption); log.debug("Is extended bolus running: " + pump.isExtendedInProgress); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Initial_Bolus.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Initial_Bolus.java index 58fa4674ad..6b67bd66e7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Initial_Bolus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Initial_Bolus.java @@ -1,17 +1,21 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; +import com.cozmo.danar.util.BleCommandUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; -import com.cozmo.danar.util.BleCommandUtil; +import info.nightscout.androidaps.Constants; public class DanaRS_Packet_Bolus_Get_Initial_Bolus extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Bolus_Get_Initial_Bolus.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public DanaRS_Packet_Bolus_Get_Initial_Bolus() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_BOLUS_RATE; + if (Config.logPumpComm) + log.debug("New message"); } @Override @@ -31,7 +35,7 @@ public class DanaRS_Packet_Bolus_Get_Initial_Bolus extends DanaRS_Packet { dataIndex += dataSize; dataSize = 2; double initialBolusValue04 = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d; - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Initial bolus amount 01: " + initialBolusValue01); log.debug("Initial bolus amount 02: " + initialBolusValue02); log.debug("Initial bolus amount 03: " + initialBolusValue03); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_Information.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_Information.java index 6166f7b0fb..a4cdd49416 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_Information.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_Information.java @@ -1,20 +1,24 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; +import com.cozmo.danar.util.BleCommandUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.Date; import info.nightscout.androidaps.Config; -import com.cozmo.danar.util.BleCommandUtil; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class DanaRS_Packet_Bolus_Get_Step_Bolus_Information extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Bolus_Get_Step_Bolus_Information.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public DanaRS_Packet_Bolus_Get_Step_Bolus_Information() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_STEP_BOLUS_INFORMATION; + if (Config.logPumpComm) + log.debug("New message"); } @Override @@ -54,7 +58,7 @@ public class DanaRS_Packet_Bolus_Get_Step_Bolus_Information extends DanaRS_Packe dataSize = 1; pump.bolusStep = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d; - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Result: " + error); log.debug("BolusType: " + bolusType); log.debug("Initial bolus amount: " + pump.initialBolusAmount + " U"); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_Option.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_Option.java index 103bac3ecf..7d9fe980e1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_Option.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_Option.java @@ -1,13 +1,15 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; +import com.cozmo.danar.util.BleCommandUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; -import com.cozmo.danar.util.BleCommandUtil; +import info.nightscout.androidaps.Constants; public class DanaRS_Packet_Bolus_Set_Bolus_Option extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Bolus_Set_Bolus_Option.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private int extendedBolusOptionOnOff; private int bolusCalculationOption; @@ -75,7 +77,7 @@ public class DanaRS_Packet_Bolus_Set_Bolus_Option extends DanaRS_Packet { this.missedBolus04EndHour = missedBolus04EndHour; this.missedBolus04EndMin = missedBolus04EndMin; - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Setting bolus options"); } } @@ -112,7 +114,7 @@ public class DanaRS_Packet_Bolus_Set_Bolus_Option extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { int result = intFromBuff(data, 0, 1); - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { if (result == 0) log.debug("Result OK"); else diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_Array.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_Array.java index 062ae00712..9a468457c9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_Array.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_Array.java @@ -1,13 +1,15 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; +import com.cozmo.danar.util.BleCommandUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; -import com.cozmo.danar.util.BleCommandUtil; +import info.nightscout.androidaps.Constants; public class DanaRS_Packet_Bolus_Set_CIR_CF_Array extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Bolus_Set_CIR_CF_Array.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private int cir01; private int cir02; @@ -45,6 +47,8 @@ public class DanaRS_Packet_Bolus_Set_CIR_CF_Array extends DanaRS_Packet { this.cf05 = cf05; this.cf06 = cf06; this.cf07 = cf07; + if (Config.logPumpComm) + log.debug("New message"); } @Override @@ -84,7 +88,7 @@ public class DanaRS_Packet_Bolus_Set_CIR_CF_Array extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { int result = intFromBuff(data, 0, 1); - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { if (result == 0) log.debug("Result OK"); else diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Dual_Bolus.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Dual_Bolus.java index e769bea195..079da8b688 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Dual_Bolus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Dual_Bolus.java @@ -1,13 +1,15 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; +import com.cozmo.danar.util.BleCommandUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; -import com.cozmo.danar.util.BleCommandUtil; +import info.nightscout.androidaps.Constants; public class DanaRS_Packet_Bolus_Set_Dual_Bolus extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Bolus_Set_Dual_Bolus.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private double amount; private double extendedAmount; @@ -24,7 +26,7 @@ public class DanaRS_Packet_Bolus_Set_Dual_Bolus extends DanaRS_Packet { this.extendedAmount = extendedAmount; this.extendedBolusDurationInHalfHours = extendedBolusDurationInHalfHours; - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("Dual bolus start : " + amount + " U extended: " + extendedAmount + " U halfhours: " + extendedBolusDurationInHalfHours); } @@ -45,7 +47,7 @@ public class DanaRS_Packet_Bolus_Set_Dual_Bolus extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { int result = intFromBuff(data, 0, 1); - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { if (result == 0) log.debug("Result OK"); else diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus.java index 887a9d852a..2d444ded1d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus.java @@ -1,14 +1,15 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; +import com.cozmo.danar.util.BleCommandUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; - -import com.cozmo.danar.util.BleCommandUtil; +import info.nightscout.androidaps.Constants; public class DanaRS_Packet_Bolus_Set_Extended_Bolus extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Bolus_Set_Extended_Bolus.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private double extendedAmount; private int extendedBolusDurationInHalfHours; @@ -23,7 +24,7 @@ public class DanaRS_Packet_Bolus_Set_Extended_Bolus extends DanaRS_Packet { this.extendedAmount = extendedAmount; this.extendedBolusDurationInHalfHours = extendedBolusDurationInHalfHours; - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("Extended bolus start : " + extendedAmount + " U halfhours: " + extendedBolusDurationInHalfHours); } @@ -41,7 +42,7 @@ public class DanaRS_Packet_Bolus_Set_Extended_Bolus extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { int result = intFromBuff(data, 0, 1); - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { if (result == 0) log.debug("Result OK"); else diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel.java index 132de649cf..d012c380e3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel.java @@ -1,26 +1,28 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; +import com.cozmo.danar.util.BleCommandUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; -import com.cozmo.danar.util.BleCommandUtil; +import info.nightscout.androidaps.Constants; public class DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__SET_EXTENDED_BOLUS_CANCEL; - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("Cancel extended bolus"); } @Override public void handleMessage(byte[] data) { int result = intFromBuff(data, 0, 1); - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { if (result == 0) log.debug("Result OK"); else diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Initial_Bolus.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Initial_Bolus.java index a174d39b53..c30c803688 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Initial_Bolus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Initial_Bolus.java @@ -1,14 +1,15 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; +import com.cozmo.danar.util.BleCommandUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; - -import com.cozmo.danar.util.BleCommandUtil; +import info.nightscout.androidaps.Constants; public class DanaRS_Packet_Bolus_Set_Initial_Bolus extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Bolus_Set_Initial_Bolus.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private int bolusRate01; private int bolusRate02; @@ -26,6 +27,8 @@ public class DanaRS_Packet_Bolus_Set_Initial_Bolus extends DanaRS_Packet { this.bolusRate02 = (int) (bolusRate02 / 100d); this.bolusRate03 = (int) (bolusRate03 / 100d); this.bolusRate04 = (int) (bolusRate04 / 100d); + if (Config.logPumpComm) + log.debug("New message"); } @Override @@ -45,7 +48,7 @@ public class DanaRS_Packet_Bolus_Set_Initial_Bolus extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { int result = intFromBuff(data, 0, 1); - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { if (result == 0) log.debug("Result OK"); else diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.java index 44e5d308dc..06be965ee3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.java @@ -6,13 +6,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; -import info.nightscout.androidaps.R; import info.nightscout.androidaps.interfaces.Constraint; -import info.nightscout.androidaps.plugins.Overview.notifications.Notification; public class DanaRS_Packet_Bolus_Set_Step_Bolus_Start extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Bolus_Set_Step_Bolus_Start.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private double amount; private int speed; @@ -35,7 +34,7 @@ public class DanaRS_Packet_Bolus_Set_Step_Bolus_Start extends DanaRS_Packet { this.amount = amount; this.speed = speed; - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("Bolus start : " + amount + " speed: " + speed); } @@ -52,7 +51,7 @@ public class DanaRS_Packet_Bolus_Set_Step_Bolus_Start extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { errorCode = intFromBuff(data, 0, 1); - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { if (errorCode == 0) { log.debug("Result OK"); failed = false; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.java index 78548ecab3..f5f4736b21 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.java @@ -4,6 +4,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; @@ -13,7 +14,7 @@ import info.nightscout.androidaps.plugins.Treatments.Treatment; import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress; public class DanaRS_Packet_Bolus_Set_Step_Bolus_Stop extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private static Treatment t; private static Double amount; @@ -31,12 +32,14 @@ public class DanaRS_Packet_Bolus_Set_Step_Bolus_Stop extends DanaRS_Packet { this.amount = amount; forced = false; stopped = false; + if (Config.logPumpComm) + log.debug("Stop bolus: amount: " + amount + " treatment: " + t.toString()); } @Override public void handleMessage(byte[] data) { int result = intFromBuff(data, 0, 1); - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { if (result == 0) log.debug("Result OK"); else diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Etc_Keep_Connection.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Etc_Keep_Connection.java index d30be3abf8..7f8c41fa8a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Etc_Keep_Connection.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Etc_Keep_Connection.java @@ -4,15 +4,18 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import com.cozmo.danar.util.BleCommandUtil; public class DanaRS_Packet_Etc_Keep_Connection extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Etc_Keep_Connection.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public DanaRS_Packet_Etc_Keep_Connection() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_ETC__KEEP_CONNECTION; + if (Config.logPumpComm) + log.debug("New message"); } @Override @@ -20,7 +23,7 @@ public class DanaRS_Packet_Etc_Keep_Connection extends DanaRS_Packet { int dataIndex = DATA_START; int dataSize = 1; int error = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Result: " + error); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Etc_Set_History_Save.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Etc_Set_History_Save.java index 6538b77932..f09c81da2c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Etc_Set_History_Save.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Etc_Set_History_Save.java @@ -4,11 +4,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import com.cozmo.danar.util.BleCommandUtil; public class DanaRS_Packet_Etc_Set_History_Save extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Etc_Set_History_Save.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private int historyType; private int historyYear; @@ -36,6 +37,8 @@ public class DanaRS_Packet_Etc_Set_History_Save extends DanaRS_Packet { this.historySecond = historySecond; this.historyCode = historyCode; this.historyValue = historyValue; + if (Config.logPumpComm) + log.debug("New message"); } @Override @@ -59,7 +62,7 @@ public class DanaRS_Packet_Etc_Set_History_Save extends DanaRS_Packet { int dataIndex = DATA_START; int dataSize = 1; int error = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Result: " + error); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Delivery_Status.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Delivery_Status.java index d9e2599eb2..991f588de7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Delivery_Status.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Delivery_Status.java @@ -1,18 +1,21 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; +import com.cozmo.danar.util.BleCommandUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; - -import com.cozmo.danar.util.BleCommandUtil; +import info.nightscout.androidaps.Constants; public class DanaRS_Packet_General_Delivery_Status extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_General_Delivery_Status.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public DanaRS_Packet_General_Delivery_Status() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__DELIVERY_STATUS; + if (Config.logPumpComm) + log.debug("New message"); } @Override @@ -20,7 +23,7 @@ public class DanaRS_Packet_General_Delivery_Status extends DanaRS_Packet { int dataIndex = DATA_START; int dataSize = 1; int status = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Status: " + status); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_More_Information.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_More_Information.java index cd2de4094f..9199264377 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_More_Information.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_More_Information.java @@ -1,45 +1,49 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; +import com.cozmo.danar.util.BleCommandUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.Date; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; -import com.cozmo.danar.util.BleCommandUtil; public class DanaRS_Packet_General_Get_More_Information extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_General_Get_More_Information.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); - public DanaRS_Packet_General_Get_More_Information() { - super(); - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__GET_MORE_INFORMATION; - } + public DanaRS_Packet_General_Get_More_Information() { + super(); + opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__GET_MORE_INFORMATION; + if (Config.logPumpComm) + log.debug("New message"); + } - @Override - public void handleMessage(byte[] data) { - DanaRPump pump = DanaRPump.getInstance(); + @Override + public void handleMessage(byte[] data) { + DanaRPump pump = DanaRPump.getInstance(); - int dataIndex = DATA_START; - int dataSize = 2; - pump.iob = byteArrayToInt(getBytes(data, dataIndex, dataSize)); + int dataIndex = DATA_START; + int dataSize = 2; + pump.iob = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - dataIndex += dataSize; - dataSize = 2; - pump.dailyTotalUnits = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d; + dataIndex += dataSize; + dataSize = 2; + pump.dailyTotalUnits = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d; - dataIndex += dataSize; - dataSize = 1; - pump.isExtendedInProgress = byteArrayToInt(getBytes(data, dataIndex, dataSize)) == 0x01; + dataIndex += dataSize; + dataSize = 1; + pump.isExtendedInProgress = byteArrayToInt(getBytes(data, dataIndex, dataSize)) == 0x01; - dataIndex += dataSize; - dataSize = 2; - pump.extendedBolusRemainingMinutes = byteArrayToInt(getBytes(data, dataIndex, dataSize)); + dataIndex += dataSize; + dataSize = 2; + pump.extendedBolusRemainingMinutes = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - dataIndex += dataSize; - dataSize = 2; - double remainRate = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d; + dataIndex += dataSize; + dataSize = 2; + double remainRate = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d; Date lastBolusTime = new Date(); // it doesn't provide day only hour+min, workaround: expecting today dataIndex += dataSize; @@ -50,21 +54,21 @@ public class DanaRS_Packet_General_Get_More_Information extends DanaRS_Packet { dataSize = 1; lastBolusTime.setMinutes(byteArrayToInt(getBytes(data, dataIndex, dataSize))); - dataIndex += dataSize; - dataSize = 2; - pump.lastBolusAmount = byteArrayToInt(getBytes(data, dataIndex, dataSize)); + dataIndex += dataSize; + dataSize = 2; + pump.lastBolusAmount = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Daily total units: " + pump.dailyTotalUnits + " U"); log.debug("Is extended in progress: " + pump.isExtendedInProgress); log.debug("Extended bolus remaining minutes: " + pump.extendedBolusRemainingMinutes); log.debug("Last bolus time: " + lastBolusTime.toLocaleString()); log.debug("Last bolus amount: " + pump.lastBolusAmount); } - } + } - @Override - public String getFriendlyName() { - return "REVIEW__GET_MORE_INFORMATION"; - } + @Override + public String getFriendlyName() { + return "REVIEW__GET_MORE_INFORMATION"; + } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Password.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Password.java index 0d250db919..9c23754a47 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Password.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Password.java @@ -1,20 +1,22 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; +import com.cozmo.danar.util.BleCommandUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; - -import com.cozmo.danar.util.BleCommandUtil; - +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class DanaRS_Packet_General_Get_Password extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_General_Get_Password.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public DanaRS_Packet_General_Get_Password() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__GET_PASSWORD; + if (Config.logPumpComm) + log.debug("New message"); } @Override @@ -24,7 +26,7 @@ public class DanaRS_Packet_General_Get_Password extends DanaRS_Packet { int pass = ((data[DATA_START + 1] & 0x000000FF) << 8) + (data[DATA_START + 0] & 0x000000FF); pass = pass ^ 3463; pump.rs_password = Integer.toHexString(pass); - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Pump password: " + pump.rs_password); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Pump_Check.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Pump_Check.java index bdc5ab8d9b..0a893791c0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Pump_Check.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Pump_Check.java @@ -6,6 +6,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; @@ -13,11 +14,13 @@ import info.nightscout.androidaps.plugins.Overview.notifications.Notification; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class DanaRS_Packet_General_Get_Pump_Check extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_General_Get_Pump_Check.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public DanaRS_Packet_General_Get_Pump_Check() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__GET_PUMP_CHECK; + if (Config.logPumpComm) + log.debug("New message"); } @Override @@ -36,7 +39,7 @@ public class DanaRS_Packet_General_Get_Pump_Check extends DanaRS_Packet { dataSize = 1; pump.productCode = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Model: " + String.format("%02X ", pump.model)); log.debug("Protocol: " + String.format("%02X ", pump.protocol)); log.debug("Product Code: " + String.format("%02X ", pump.productCode)); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Shipping_Information.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Shipping_Information.java index 2cf9b1f124..1e7668568a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Shipping_Information.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Shipping_Information.java @@ -1,46 +1,49 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; +import com.cozmo.danar.util.BleCommandUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; -import com.cozmo.danar.util.BleCommandUtil; - public class DanaRS_Packet_General_Get_Shipping_Information extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); - public DanaRS_Packet_General_Get_Shipping_Information() { - super(); - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__GET_SHIPPING_INFORMATION; - } + public DanaRS_Packet_General_Get_Shipping_Information() { + super(); + opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__GET_SHIPPING_INFORMATION; + if (Config.logPumpComm) + log.debug("New message"); + } - @Override - public void handleMessage(byte[] data) { - DanaRPump pump = DanaRPump.getInstance(); + @Override + public void handleMessage(byte[] data) { + DanaRPump pump = DanaRPump.getInstance(); - int dataIndex = DATA_START; - int dataSize = 10; - pump.serialNumber = stringFromBuff(data, dataIndex, dataSize); + int dataIndex = DATA_START; + int dataSize = 10; + pump.serialNumber = stringFromBuff(data, dataIndex, dataSize); - dataIndex += dataSize; - dataSize = 3; - pump.shippingDate = dateFromBuff(data, dataIndex); + dataIndex += dataSize; + dataSize = 3; + pump.shippingDate = dateFromBuff(data, dataIndex); - dataIndex += dataSize; - dataSize = 3; - pump.shippingCountry = asciiStringFromBuff(data, dataIndex, dataSize); + dataIndex += dataSize; + dataSize = 3; + pump.shippingCountry = asciiStringFromBuff(data, dataIndex, dataSize); - if (Config.logDanaMessageDetail) { - log.debug("Serial number: " + pump.serialNumber); - log.debug("Shipping date: " + pump.shippingDate); - log.debug("Shipping country: " + pump.shippingCountry); - } - } + if (Config.logPumpComm) { + log.debug("Serial number: " + pump.serialNumber); + log.debug("Shipping date: " + pump.shippingDate); + log.debug("Shipping country: " + pump.shippingCountry); + } + } - @Override - public String getFriendlyName() { - return "REVIEW__GET_SHIPPING_INFORMATION"; - } + @Override + public String getFriendlyName() { + return "REVIEW__GET_SHIPPING_INFORMATION"; + } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Today_Delivery_Total.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Today_Delivery_Total.java index a40d572611..3fded09f97 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Today_Delivery_Total.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Today_Delivery_Total.java @@ -1,47 +1,49 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; +import com.cozmo.danar.util.BleCommandUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; - -import com.cozmo.danar.util.BleCommandUtil; - +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class DanaRS_Packet_General_Get_Today_Delivery_Total extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_General_Get_Today_Delivery_Total.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); - public DanaRS_Packet_General_Get_Today_Delivery_Total() { - super(); - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__GET_TODAY_DELIVERY_TOTAL; - } + public DanaRS_Packet_General_Get_Today_Delivery_Total() { + super(); + opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__GET_TODAY_DELIVERY_TOTAL; + if (Config.logPumpComm) + log.debug("New message"); + } - @Override - public void handleMessage(byte[] data) { - DanaRPump pump = DanaRPump.getInstance(); + @Override + public void handleMessage(byte[] data) { + DanaRPump pump = DanaRPump.getInstance(); - int dataIndex = DATA_START; - int dataSize = 2; - pump.dailyTotalUnits = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d; + int dataIndex = DATA_START; + int dataSize = 2; + pump.dailyTotalUnits = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d; - dataIndex += dataSize; - dataSize = 2; - pump.dailyTotalBasalUnits = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d; + dataIndex += dataSize; + dataSize = 2; + pump.dailyTotalBasalUnits = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d; - dataIndex += dataSize; - dataSize = 2; - pump.dailyTotalBolusUnits = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d; + dataIndex += dataSize; + dataSize = 2; + pump.dailyTotalBolusUnits = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d; - if (Config.logDanaMessageDetail) { - log.debug("Daily total: " + pump.dailyTotalUnits + " U"); - log.debug("Daily total bolus: " + pump.dailyTotalBolusUnits + " U"); - log.debug("Daily total basal: " + pump.dailyTotalBasalUnits + " U"); - } - } + if (Config.logPumpComm) { + log.debug("Daily total: " + pump.dailyTotalUnits + " U"); + log.debug("Daily total bolus: " + pump.dailyTotalBolusUnits + " U"); + log.debug("Daily total basal: " + pump.dailyTotalBasalUnits + " U"); + } + } - @Override - public String getFriendlyName() { - return "REVIEW__GET_TODAY_DELIVERY_TOTAL"; - } + @Override + public String getFriendlyName() { + return "REVIEW__GET_TODAY_DELIVERY_TOTAL"; + } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_User_Time_Change_Flag.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_User_Time_Change_Flag.java index 695e3eace4..e97e366ba4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_User_Time_Change_Flag.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_User_Time_Change_Flag.java @@ -1,17 +1,21 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; +import com.cozmo.danar.util.BleCommandUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; -import com.cozmo.danar.util.BleCommandUtil; +import info.nightscout.androidaps.Constants; public class DanaRS_Packet_General_Get_User_Time_Change_Flag extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_General_Get_User_Time_Change_Flag.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public DanaRS_Packet_General_Get_User_Time_Change_Flag() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__GET_USER_TIME_CHANGE_FLAG; + if (Config.logPumpComm) + log.debug("New message"); } @Override @@ -20,7 +24,7 @@ public class DanaRS_Packet_General_Get_User_Time_Change_Flag extends DanaRS_Pack int dataSize = 1; int userTimeChangeFlag = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("UserTimeChangeFlag: " + userTimeChangeFlag); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Initial_Screen_Information.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Initial_Screen_Information.java index d05777d20d..195a3ce846 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Initial_Screen_Information.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Initial_Screen_Information.java @@ -1,21 +1,23 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; +import com.cozmo.danar.util.BleCommandUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; - -import com.cozmo.danar.util.BleCommandUtil; - +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class DanaRS_Packet_General_Initial_Screen_Information extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Bolus_Get_Step_Bolus_Information.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public DanaRS_Packet_General_Initial_Screen_Information() { super(); type = BleCommandUtil.DANAR_PACKET__TYPE_RESPONSE; opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__INITIAL_SCREEN_INFORMATION; + if (Config.logPumpComm) + log.debug("New message"); } @Override @@ -63,7 +65,7 @@ public class DanaRS_Packet_General_Initial_Screen_Information extends DanaRS_Pac dataSize = 2; pump.iob = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d; - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Pump suspended: " + pump.pumpSuspended); log.debug("Temp basal in progress: " + pump.isTempBasalInProgress); log.debug("Extended in progress: " + pump.isExtendedInProgress); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Set_History_Upload_Mode.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Set_History_Upload_Mode.java index 878cfd64dd..1b5658ebcd 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Set_History_Upload_Mode.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Set_History_Upload_Mode.java @@ -1,13 +1,15 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; +import com.cozmo.danar.util.BleCommandUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; -import com.cozmo.danar.util.BleCommandUtil; +import info.nightscout.androidaps.Constants; public class DanaRS_Packet_General_Set_History_Upload_Mode extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_General_Set_History_Upload_Mode.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private int mode; @@ -19,6 +21,8 @@ public class DanaRS_Packet_General_Set_History_Upload_Mode extends DanaRS_Packet public DanaRS_Packet_General_Set_History_Upload_Mode(int mode) { this(); this.mode = mode; + if (Config.logPumpComm) + log.debug("New message: mode: " + mode); } @Override @@ -32,7 +36,7 @@ public class DanaRS_Packet_General_Set_History_Upload_Mode extends DanaRS_Packet @Override public void handleMessage(byte[] data) { int result = intFromBuff(data, 0, 1); - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { if (result == 0) log.debug("Result OK"); else diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear.java index 3917f31050..ebdcd4c976 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear.java @@ -1,24 +1,27 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; +import com.cozmo.danar.util.BleCommandUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; - -import com.cozmo.danar.util.BleCommandUtil; +import info.nightscout.androidaps.Constants; public class DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__SET_USER_TIME_CHANGE_FLAG_CLEAR; + if (Config.logPumpComm) + log.debug("New message"); } @Override public void handleMessage(byte[] data) { int result = intFromBuff(data, 0, 1); - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { if (result == 0) log.debug("Result OK"); else diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_.java index 6bae4ab8c1..c882e5afbb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_.java @@ -1,7 +1,5 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; -import com.cozmo.danar.util.BleCommandUtil; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -9,6 +7,8 @@ import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; +import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.db.DanaRHistoryRecord; import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes; @@ -16,7 +16,7 @@ import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRSyncStatus; import info.nightscout.utils.DateUtil; public abstract class DanaRS_Packet_History_ extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_History_.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private int year = 0; private int month = 0; @@ -47,7 +47,8 @@ public abstract class DanaRS_Packet_History_ extends DanaRS_Packet { hour = cal.get(Calendar.HOUR_OF_DAY); min = cal.get(Calendar.MINUTE); sec = cal.get(Calendar.SECOND); - log.debug("Loading event history from: " + new Date(cal.getTimeInMillis()).toLocaleString()); + if (Config.logPumpComm) + log.debug("Loading event history from: " + new Date(cal.getTimeInMillis()).toLocaleString()); } @Override @@ -71,7 +72,8 @@ public abstract class DanaRS_Packet_History_ extends DanaRS_Packet { int dataSize = 1; error = byteArrayToInt(getBytes(data, dataIndex, dataSize)); done = true; - log.debug("History end. Code: " + error + " Success: " + (error == 0x00)); + if (Config.logPumpComm) + log.debug("History end. Code: " + error + " Success: " + (error == 0x00)); } else if (data.length == 5) { int dataIndex = DATA_START; int dataSize = 1; @@ -81,11 +83,12 @@ public abstract class DanaRS_Packet_History_ extends DanaRS_Packet { dataIndex += dataSize; dataSize = 2; totalCount = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - log.debug("History end. Code: " + error + " Success: " + (error == 0x00) + " Toatal count: " + totalCount); + if (Config.logPumpComm) + log.debug("History end. Code: " + error + " Success: " + (error == 0x00) + " Toatal count: " + totalCount); } else { int recordCode = byteArrayToInt(getBytes(data, DATA_START, 1)); int historyYear = byteArrayToInt(getBytes(data, DATA_START + 1, 1)); - int historyMonth = byteArrayToInt(getBytes(data, DATA_START +2 , 1)); + int historyMonth = byteArrayToInt(getBytes(data, DATA_START + 2, 1)); int historyDay = byteArrayToInt(getBytes(data, DATA_START + 3, 1)); int historyHour = byteArrayToInt(getBytes(data, DATA_START + 4, 1)); double dailyBasal = (((data[DATA_START + 4] & 0xFF) << 8) + (data[DATA_START + 5] & 0xFF)) * 0.01d; @@ -103,7 +106,8 @@ public abstract class DanaRS_Packet_History_ extends DanaRS_Packet { int value = ((data[DATA_START + 8] & 0xFF) << 8) + (data[DATA_START + 9] & 0xFF); - log.debug("History packet: " + recordCode + " Date: " + datetimewihtsec.toLocaleString() + " Code: " + historyCode + " Value: " + value); + if (Config.logPumpComm) + log.debug("History packet: " + recordCode + " Date: " + datetimewihtsec.toLocaleString() + " Code: " + historyCode + " Value: " + value); EventDanaRSyncStatus ev = new EventDanaRSyncStatus(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Alarm.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Alarm.java index 5fe57fefe4..7744e22ecd 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Alarm.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Alarm.java @@ -1,10 +1,17 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; -import java.util.Date; - import com.cozmo.danar.util.BleCommandUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Date; + +import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; + public class DanaRS_Packet_History_Alarm extends DanaRS_Packet_History_ { + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public DanaRS_Packet_History_Alarm() { super(); @@ -14,6 +21,8 @@ public class DanaRS_Packet_History_Alarm extends DanaRS_Packet_History_ { public DanaRS_Packet_History_Alarm(Date from) { super(from); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__ALARM; + if (Config.logPumpComm) + log.debug("New message"); } @Override diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_All_History.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_All_History.java index a514d4eac7..19ce9b6da0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_All_History.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_All_History.java @@ -1,10 +1,17 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; -import java.util.Date; - import com.cozmo.danar.util.BleCommandUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Date; + +import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; + public class DanaRS_Packet_History_All_History extends DanaRS_Packet_History_ { + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public DanaRS_Packet_History_All_History() { super(); @@ -14,6 +21,8 @@ public class DanaRS_Packet_History_All_History extends DanaRS_Packet_History_ { public DanaRS_Packet_History_All_History(Date from) { super(from); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__ALL_HISTORY; + if (Config.logPumpComm) + log.debug("New message"); } @Override diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Basal.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Basal.java index 4aec1d0352..a8797a49f9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Basal.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Basal.java @@ -1,10 +1,17 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; -import java.util.Date; - import com.cozmo.danar.util.BleCommandUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Date; + +import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; + public class DanaRS_Packet_History_Basal extends DanaRS_Packet_History_ { + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public DanaRS_Packet_History_Basal() { super(); @@ -14,6 +21,8 @@ public class DanaRS_Packet_History_Basal extends DanaRS_Packet_History_ { public DanaRS_Packet_History_Basal(Date from) { super(from); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BASAL; + if (Config.logPumpComm) + log.debug("New message"); } @Override diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Blood_Glucose.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Blood_Glucose.java index 22bb3b5c2e..423f4345d3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Blood_Glucose.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Blood_Glucose.java @@ -1,10 +1,17 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; -import java.util.Date; - import com.cozmo.danar.util.BleCommandUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Date; + +import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; + public class DanaRS_Packet_History_Blood_Glucose extends DanaRS_Packet_History_ { + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public DanaRS_Packet_History_Blood_Glucose() { super(); @@ -14,6 +21,8 @@ public class DanaRS_Packet_History_Blood_Glucose extends DanaRS_Packet_History_ public DanaRS_Packet_History_Blood_Glucose(Date from) { super(from); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BLOOD_GLUCOSE; + if (Config.logPumpComm) + log.debug("New message"); } @Override diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Bolus.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Bolus.java index 7451f921be..3f25c37ec0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Bolus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Bolus.java @@ -1,23 +1,32 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; -import java.util.Date; - import com.cozmo.danar.util.BleCommandUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Date; + +import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; + public class DanaRS_Packet_History_Bolus extends DanaRS_Packet_History_ { + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); - public DanaRS_Packet_History_Bolus() { - super(); - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BOLUS; - } + public DanaRS_Packet_History_Bolus() { + super(); + opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BOLUS; + } - public DanaRS_Packet_History_Bolus(Date from) { - super(from); - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BOLUS; - } + public DanaRS_Packet_History_Bolus(Date from) { + super(from); + opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BOLUS; + if (Config.logPumpComm) + log.debug("New message"); + } - @Override - public String getFriendlyName() { - return "REVIEW__BOLUS"; - } + @Override + public String getFriendlyName() { + return "REVIEW__BOLUS"; + } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Carbohydrate.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Carbohydrate.java index df2f5c762d..5cdec9f3e7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Carbohydrate.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Carbohydrate.java @@ -1,23 +1,32 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; -import java.util.Date; - import com.cozmo.danar.util.BleCommandUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Date; + +import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; + public class DanaRS_Packet_History_Carbohydrate extends DanaRS_Packet_History_ { + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); - public DanaRS_Packet_History_Carbohydrate() { - super(); - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__CARBOHYDRATE; - } + public DanaRS_Packet_History_Carbohydrate() { + super(); + opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__CARBOHYDRATE; + } - public DanaRS_Packet_History_Carbohydrate(Date from) { - super(from); - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__CARBOHYDRATE; - } + public DanaRS_Packet_History_Carbohydrate(Date from) { + super(from); + opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__CARBOHYDRATE; + if (Config.logPumpComm) + log.debug("New message"); + } - @Override - public String getFriendlyName() { - return "REVIEW__CARBOHYDRATE"; - } + @Override + public String getFriendlyName() { + return "REVIEW__CARBOHYDRATE"; + } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Daily.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Daily.java index b55754ba2f..90b16d4ce5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Daily.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Daily.java @@ -1,10 +1,17 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; -import java.util.Date; - import com.cozmo.danar.util.BleCommandUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Date; + +import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; + public class DanaRS_Packet_History_Daily extends DanaRS_Packet_History_ { + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public DanaRS_Packet_History_Daily() { super(); @@ -14,6 +21,8 @@ public class DanaRS_Packet_History_Daily extends DanaRS_Packet_History_ { public DanaRS_Packet_History_Daily(Date from) { super(from); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__DAILY; + if (Config.logPumpComm) + log.debug("New message"); } @Override diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Prime.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Prime.java index b5dbf7ff93..98a3c13e6c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Prime.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Prime.java @@ -1,10 +1,17 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; -import java.util.Date; - import com.cozmo.danar.util.BleCommandUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Date; + +import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; + public class DanaRS_Packet_History_Prime extends DanaRS_Packet_History_ { + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public DanaRS_Packet_History_Prime() { super(); @@ -14,6 +21,8 @@ public class DanaRS_Packet_History_Prime extends DanaRS_Packet_History_ { public DanaRS_Packet_History_Prime(Date from) { super(from); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__PRIME; + if (Config.logPumpComm) + log.debug("New message"); } @Override diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Refill.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Refill.java index 66094e3fb6..d5b138eba8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Refill.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Refill.java @@ -1,23 +1,32 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; -import java.util.Date; - import com.cozmo.danar.util.BleCommandUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Date; + +import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; + public class DanaRS_Packet_History_Refill extends DanaRS_Packet_History_ { + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); - public DanaRS_Packet_History_Refill() { - super(); - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__REFILL; - } + public DanaRS_Packet_History_Refill() { + super(); + opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__REFILL; + } - public DanaRS_Packet_History_Refill(Date from) { - super(from); - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__REFILL; - } + public DanaRS_Packet_History_Refill(Date from) { + super(from); + opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__REFILL; + if (Config.logPumpComm) + log.debug("New message"); + } - @Override - public String getFriendlyName() { - return "REVIEW__REFILL"; - } + @Override + public String getFriendlyName() { + return "REVIEW__REFILL"; + } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Suspend.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Suspend.java index 20f1c3d6ff..6c92a437fd 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Suspend.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Suspend.java @@ -1,10 +1,17 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; -import java.util.Date; - import com.cozmo.danar.util.BleCommandUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Date; + +import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; + public class DanaRS_Packet_History_Suspend extends DanaRS_Packet_History_ { + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public DanaRS_Packet_History_Suspend() { super(); @@ -14,6 +21,8 @@ public class DanaRS_Packet_History_Suspend extends DanaRS_Packet_History_ { public DanaRS_Packet_History_Suspend(Date from) { super(from); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__SUSPEND; + if (Config.logPumpComm) + log.debug("New message"); } @Override diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Temporary.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Temporary.java index 7d63e1bfff..62aa5c274b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Temporary.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Temporary.java @@ -1,10 +1,17 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; -import java.util.Date; - import com.cozmo.danar.util.BleCommandUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Date; + +import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; + public class DanaRS_Packet_History_Temporary extends DanaRS_Packet_History_ { + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public DanaRS_Packet_History_Temporary() { super(); @@ -14,6 +21,8 @@ public class DanaRS_Packet_History_Temporary extends DanaRS_Packet_History_ { public DanaRS_Packet_History_Temporary(Date from) { super(from); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__TEMPORARY; + if (Config.logPumpComm) + log.debug("New message"); } @Override diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Alarm.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Alarm.java index 04737f0bdc..2723dc03a4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Alarm.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Alarm.java @@ -1,18 +1,18 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; +import com.cozmo.danar.util.BleCommandUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; - -import com.cozmo.danar.util.BleCommandUtil; - import info.nightscout.utils.NSUpload; public class DanaRS_Packet_Notify_Alarm extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Notify_Alarm.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private int alarmCode; @@ -20,6 +20,8 @@ public class DanaRS_Packet_Notify_Alarm extends DanaRS_Packet { super(); type = BleCommandUtil.DANAR_PACKET__TYPE_NOTIFY; opCode = BleCommandUtil.DANAR_PACKET__OPCODE_NOTIFY__ALARM; + if (Config.logPumpComm) + log.debug("New message"); } @Override @@ -76,7 +78,7 @@ public class DanaRS_Packet_Notify_Alarm extends DanaRS_Packet { break; } - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("Error detected: " + errorString); NSUpload.uploadError(errorString); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Delivery_Complete.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Delivery_Complete.java index 2598c5efc9..86ff1d121e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Delivery_Complete.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Delivery_Complete.java @@ -1,19 +1,19 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; +import com.cozmo.danar.util.BleCommandUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; - -import com.cozmo.danar.util.BleCommandUtil; - -import info.nightscout.androidaps.plugins.Treatments.Treatment; import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress; +import info.nightscout.androidaps.plugins.Treatments.Treatment; public class DanaRS_Packet_Notify_Delivery_Complete extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Notify_Delivery_Complete.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private static Treatment t; private static double amount; @@ -30,6 +30,8 @@ public class DanaRS_Packet_Notify_Delivery_Complete extends DanaRS_Packet { this.amount = amount; this.t = t; done = false; + if (Config.logPumpComm) + log.debug("New message: amount: " + amount + " treatment: " + t.toString()); } @Override @@ -46,7 +48,7 @@ public class DanaRS_Packet_Notify_Delivery_Complete extends DanaRS_Packet { MainApp.bus().post(bolusingEvent); } - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("Delivered insulin: " + deliveredInsulin); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_Display.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_Display.java index 34621d07ee..96b98c8d80 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_Display.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_Display.java @@ -1,17 +1,19 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; +import com.cozmo.danar.util.BleCommandUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; -import com.cozmo.danar.util.BleCommandUtil; -import info.nightscout.androidaps.plugins.Treatments.Treatment; import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress; +import info.nightscout.androidaps.plugins.Treatments.Treatment; public class DanaRS_Packet_Notify_Delivery_Rate_Display extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Notify_Delivery_Rate_Display.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private static Treatment t; private static double amount; @@ -29,6 +31,8 @@ public class DanaRS_Packet_Notify_Delivery_Rate_Display extends DanaRS_Packet { this.amount = amount; this.t = t; lastReceive = System.currentTimeMillis(); + if (Config.logPumpComm) + log.debug("New message: amount: " + amount + " treatment: " + t.toString()); } @Override @@ -45,7 +49,7 @@ public class DanaRS_Packet_Notify_Delivery_Rate_Display extends DanaRS_Packet { MainApp.bus().post(bolusingEvent); } - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("Delivered insulin so far: " + deliveredInsulin); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Missed_Bolus_Alarm.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Missed_Bolus_Alarm.java index 3af0c209b5..7f2049af13 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Missed_Bolus_Alarm.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Missed_Bolus_Alarm.java @@ -1,19 +1,22 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; +import com.cozmo.danar.util.BleCommandUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; - -import com.cozmo.danar.util.BleCommandUtil; +import info.nightscout.androidaps.Constants; public class DanaRS_Packet_Notify_Missed_Bolus_Alarm extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Notify_Missed_Bolus_Alarm.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public DanaRS_Packet_Notify_Missed_Bolus_Alarm() { super(); type = BleCommandUtil.DANAR_PACKET__TYPE_NOTIFY; opCode = BleCommandUtil.DANAR_PACKET__OPCODE_NOTIFY__MISSED_BOLUS_ALARM; + if (Config.logPumpComm) + log.debug("New message"); } @Override @@ -38,7 +41,7 @@ public class DanaRS_Packet_Notify_Missed_Bolus_Alarm extends DanaRS_Packet { dataIndex += dataSize; dataSize = 1; endMin = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Start hour: " + startHour); log.debug("Start min: " + startMin); log.debug("End hour: " + endHour); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Get_Pump_Time.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Get_Pump_Time.java index 4bfebb5211..33c1722fc8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Get_Pump_Time.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Get_Pump_Time.java @@ -1,21 +1,23 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; +import com.cozmo.danar.util.BleCommandUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.Date; import info.nightscout.androidaps.Config; -import com.cozmo.danar.util.BleCommandUtil; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class DanaRS_Packet_Option_Get_Pump_Time extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Option_Get_Pump_Time.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public DanaRS_Packet_Option_Get_Pump_Time() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_OPTION__GET_PUMP_TIME; - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Requesting pump time"); } } @@ -49,7 +51,7 @@ public class DanaRS_Packet_Option_Get_Pump_Time extends DanaRS_Packet { Date time = new Date(100 + year, month - 1, day, hour, min, sec); DanaRPump.getInstance().pumpTime = time; - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Pump time " + time.toLocaleString()); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Get_User_Option.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Get_User_Option.java index b4df373f9c..7a3d8a7093 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Get_User_Option.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Get_User_Option.java @@ -1,114 +1,116 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; +import com.cozmo.danar.util.BleCommandUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; -import com.cozmo.danar.util.BleCommandUtil; public class DanaRS_Packet_Option_Get_User_Option extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Option_Get_User_Option.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); - public DanaRS_Packet_Option_Get_User_Option() { - super(); - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_OPTION__GET_USER_OPTION; - if (Config.logDanaMessageDetail) { - log.debug("Requesting user settings"); - } - } + public DanaRS_Packet_Option_Get_User_Option() { + super(); + opCode = BleCommandUtil.DANAR_PACKET__OPCODE_OPTION__GET_USER_OPTION; + if (Config.logPumpComm) { + log.debug("Requesting user settings"); + } + } - @Override - public void handleMessage(byte[] data) { - DanaRPump pump = DanaRPump.getInstance(); + @Override + public void handleMessage(byte[] data) { + DanaRPump pump = DanaRPump.getInstance(); - int dataIndex = DATA_START; - int dataSize = 1; - pump.timeDisplayType = byteArrayToInt(getBytes(data, dataIndex, dataSize)); + int dataIndex = DATA_START; + int dataSize = 1; + pump.timeDisplayType = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - dataIndex += dataSize; - dataSize = 1; - pump.buttonScrollOnOff = byteArrayToInt(getBytes(data, dataIndex, dataSize)); + dataIndex += dataSize; + dataSize = 1; + pump.buttonScrollOnOff = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - dataIndex += dataSize; - dataSize = 1; - pump.beepAndAlarm = byteArrayToInt(getBytes(data, dataIndex, dataSize)); + dataIndex += dataSize; + dataSize = 1; + pump.beepAndAlarm = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - dataIndex += dataSize; - dataSize = 1; - pump.lcdOnTimeSec = byteArrayToInt(getBytes(data, dataIndex, dataSize)); + dataIndex += dataSize; + dataSize = 1; + pump.lcdOnTimeSec = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - dataIndex += dataSize; - dataSize = 1; - pump.backlightOnTimeSec = byteArrayToInt(getBytes(data, dataIndex, dataSize)); + dataIndex += dataSize; + dataSize = 1; + pump.backlightOnTimeSec = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - dataIndex += dataSize; - dataSize = 1; - pump.selectedLanguage = byteArrayToInt(getBytes(data, dataIndex, dataSize)); + dataIndex += dataSize; + dataSize = 1; + pump.selectedLanguage = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - dataIndex += dataSize; - dataSize = 1; - pump.units = byteArrayToInt(getBytes(data, dataIndex, dataSize)); + dataIndex += dataSize; + dataSize = 1; + pump.units = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - dataIndex += dataSize; - dataSize = 1; - pump.shutdownHour = byteArrayToInt(getBytes(data, dataIndex, dataSize)); + dataIndex += dataSize; + dataSize = 1; + pump.shutdownHour = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - dataIndex += dataSize; - dataSize = 1; - pump.lowReservoirRate = byteArrayToInt(getBytes(data, dataIndex, dataSize)); + dataIndex += dataSize; + dataSize = 1; + pump.lowReservoirRate = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - dataIndex += dataSize; - dataSize = 2; - pump.cannulaVolume = byteArrayToInt(getBytes(data, dataIndex, dataSize)); + dataIndex += dataSize; + dataSize = 2; + pump.cannulaVolume = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - dataIndex += dataSize; - dataSize = 2; - pump.refillAmount = byteArrayToInt(getBytes(data, dataIndex, dataSize)); + dataIndex += dataSize; + dataSize = 2; + pump.refillAmount = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - dataIndex += dataSize; - dataSize = 1; - int selectableLanguage1 = byteArrayToInt(getBytes(data, dataIndex, dataSize)); + dataIndex += dataSize; + dataSize = 1; + int selectableLanguage1 = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - dataIndex += dataSize; - dataSize = 1; - int selectableLanguage2 = byteArrayToInt(getBytes(data, dataIndex, dataSize)); + dataIndex += dataSize; + dataSize = 1; + int selectableLanguage2 = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - dataIndex += dataSize; - dataSize = 1; - int selectableLanguage3 = byteArrayToInt(getBytes(data, dataIndex, dataSize)); + dataIndex += dataSize; + dataSize = 1; + int selectableLanguage3 = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - dataIndex += dataSize; - dataSize = 1; - int selectableLanguage4 = byteArrayToInt(getBytes(data, dataIndex, dataSize)); + dataIndex += dataSize; + dataSize = 1; + int selectableLanguage4 = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - dataIndex += dataSize; - dataSize = 1; - int selectableLanguage5 = byteArrayToInt(getBytes(data, dataIndex, dataSize)); + dataIndex += dataSize; + dataSize = 1; + int selectableLanguage5 = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - if (Config.logDanaMessageDetail) { - log.debug("timeDisplayType: " + pump.timeDisplayType); - log.debug("buttonScrollOnOff: " + pump.buttonScrollOnOff); - log.debug("beepAndAlarm: " + pump.beepAndAlarm); - log.debug("lcdOnTimeSec: " + pump.lcdOnTimeSec); - log.debug("backlightOnTimeSec: " + pump.backlightOnTimeSec); - log.debug("selectedLanguage: " + pump.selectedLanguage); - log.debug("Pump units: " + (pump.units == DanaRPump.UNITS_MGDL ? "MGDL" : "MMOL")); - log.debug("shutdownHour: " + pump.shutdownHour); - log.debug("lowReservoirRate: " + pump.lowReservoirRate); - log.debug("refillAmount: " + pump.refillAmount); - log.debug("selectableLanguage1: " + selectableLanguage1); - log.debug("selectableLanguage2: " + selectableLanguage2); - log.debug("selectableLanguage3: " + selectableLanguage3); - log.debug("selectableLanguage4: " + selectableLanguage4); - log.debug("selectableLanguage5: " + selectableLanguage5); - } - } + if (Config.logPumpComm) { + log.debug("timeDisplayType: " + pump.timeDisplayType); + log.debug("buttonScrollOnOff: " + pump.buttonScrollOnOff); + log.debug("beepAndAlarm: " + pump.beepAndAlarm); + log.debug("lcdOnTimeSec: " + pump.lcdOnTimeSec); + log.debug("backlightOnTimeSec: " + pump.backlightOnTimeSec); + log.debug("selectedLanguage: " + pump.selectedLanguage); + log.debug("Pump units: " + (pump.units == DanaRPump.UNITS_MGDL ? "MGDL" : "MMOL")); + log.debug("shutdownHour: " + pump.shutdownHour); + log.debug("lowReservoirRate: " + pump.lowReservoirRate); + log.debug("refillAmount: " + pump.refillAmount); + log.debug("selectableLanguage1: " + selectableLanguage1); + log.debug("selectableLanguage2: " + selectableLanguage2); + log.debug("selectableLanguage3: " + selectableLanguage3); + log.debug("selectableLanguage4: " + selectableLanguage4); + log.debug("selectableLanguage5: " + selectableLanguage5); + } + } - @Override - public String getFriendlyName() { - return "OPTION__GET_USER_OPTION"; - } + @Override + public String getFriendlyName() { + return "OPTION__GET_USER_OPTION"; + } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.java index 007623afca..ea90615c78 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.java @@ -1,16 +1,17 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; +import com.cozmo.danar.util.BleCommandUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.Date; import info.nightscout.androidaps.Config; - -import com.cozmo.danar.util.BleCommandUtil; +import info.nightscout.androidaps.Constants; public class DanaRS_Packet_Option_Set_Pump_Time extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Option_Set_Pump_Time.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private Date date; public int error; @@ -22,7 +23,7 @@ public class DanaRS_Packet_Option_Set_Pump_Time extends DanaRS_Packet { public DanaRS_Packet_Option_Set_Pump_Time(Date date) { this(); this.date = date; - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Setting pump time " + date.toLocaleString()); } } @@ -44,7 +45,7 @@ public class DanaRS_Packet_Option_Set_Pump_Time extends DanaRS_Packet { int dataIndex = DATA_START; int dataSize = 1; error = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { if (error == 0) log.debug("Result OK"); else diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Set_User_Option.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Set_User_Option.java index 40577aaa5d..3709709fab 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Set_User_Option.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Set_User_Option.java @@ -1,21 +1,23 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; +import com.cozmo.danar.util.BleCommandUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; -import com.cozmo.danar.util.BleCommandUtil; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class DanaRS_Packet_Option_Set_User_Option extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Option_Set_User_Option.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private int error; public DanaRS_Packet_Option_Set_User_Option() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_OPTION__SET_USER_OPTION; - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Setting user settings"); } } @@ -23,14 +25,15 @@ public class DanaRS_Packet_Option_Set_User_Option extends DanaRS_Packet { @Override public byte[] getRequestParams() { DanaRPump pump = DanaRPump.getInstance(); - log.debug("UserOptions:"+(System.currentTimeMillis() - pump.lastConnection)/1000+" s ago" - +"\ntimeDisplayType:"+pump.timeDisplayType - +"\nbuttonScroll:"+pump.buttonScrollOnOff - +"\ntimeDisplayType:"+pump.timeDisplayType - +"\nlcdOnTimeSec:"+pump.lcdOnTimeSec - +"\nbacklight:"+pump.backlightOnTimeSec - +"\npumpUnits:"+pump.units - +"\nlowReservoir:"+pump.lowReservoirRate); + if (Config.logPumpComm) + log.debug("UserOptions:" + (System.currentTimeMillis() - pump.lastConnection) / 1000 + " s ago" + + "\ntimeDisplayType:" + pump.timeDisplayType + + "\nbuttonScroll:" + pump.buttonScrollOnOff + + "\ntimeDisplayType:" + pump.timeDisplayType + + "\nlcdOnTimeSec:" + pump.lcdOnTimeSec + + "\nbacklight:" + pump.backlightOnTimeSec + + "\npumpUnits:" + pump.units + + "\nlowReservoir:" + pump.lowReservoirRate); byte[] request = new byte[13]; request[0] = (byte) (pump.timeDisplayType & 0xff); request[1] = (byte) (pump.buttonScrollOnOff & 0xff); @@ -53,7 +56,7 @@ public class DanaRS_Packet_Option_Set_User_Option extends DanaRS_Packet { int dataIndex = DATA_START; int dataSize = 1; error = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { if (error == 0) log.debug("Result OK"); else diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Review_Bolus_Avg.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Review_Bolus_Avg.java index e8440b12d2..d557d43853 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Review_Bolus_Avg.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Review_Bolus_Avg.java @@ -1,18 +1,21 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; +import com.cozmo.danar.util.BleCommandUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; - -import com.cozmo.danar.util.BleCommandUtil; +import info.nightscout.androidaps.Constants; public class DanaRS_Packet_Review_Bolus_Avg extends DanaRS_Packet { - private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Review_Bolus_Avg.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public DanaRS_Packet_Review_Bolus_Avg() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BOLUS_AVG; + if (Config.logPumpComm) + log.debug("New message"); } @Override @@ -36,7 +39,7 @@ public class DanaRS_Packet_Review_Bolus_Avg extends DanaRS_Packet { dataIndex += dataSize; dataSize = 2; double bolusAvg28 = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d; - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Bolus average 3d: " + bolusAvg03 + " U"); log.debug("Bolus average 7d: " + bolusAvg07 + " U"); log.debug("Bolus average 14d: " + bolusAvg14 + " U"); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/BLEComm.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/BLEComm.java index e15f6f23c0..5e948c09f5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/BLEComm.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/BLEComm.java @@ -22,6 +22,8 @@ import java.util.List; import java.util.UUID; import java.util.concurrent.ScheduledFuture; +import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.events.EventPumpStatusChanged; @@ -42,12 +44,12 @@ import info.nightscout.utils.SP; */ public class BLEComm { - private static Logger log = LoggerFactory.getLogger(BLEComm.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPBTCOMM); - private static final long WRITE_DELAY_MILLIS = 50; + private final long WRITE_DELAY_MILLIS = 50; - private static String UART_READ_UUID = "0000fff1-0000-1000-8000-00805f9b34fb"; - private static String UART_WRITE_UUID = "0000fff2-0000-1000-8000-00805f9b34fb"; + private String UART_READ_UUID = "0000fff1-0000-1000-8000-00805f9b34fb"; + private String UART_WRITE_UUID = "0000fff2-0000-1000-8000-00805f9b34fb"; private final byte PACKET_START_BYTE = (byte) 0xA5; private final byte PACKET_END_BYTE = (byte) 0x5A; @@ -83,19 +85,20 @@ public class BLEComm { } private boolean initialize() { - log.debug("Initializing BLEComm."); + if (Config.logPumpBtComm) + log.debug("Initializing BLEComm."); if (mBluetoothManager == null) { mBluetoothManager = ((BluetoothManager) MainApp.instance().getApplicationContext().getSystemService(Context.BLUETOOTH_SERVICE)); if (mBluetoothManager == null) { - log.debug("Unable to initialize BluetoothManager."); + log.error("Unable to initialize BluetoothManager."); return false; } } mBluetoothAdapter = mBluetoothManager.getAdapter(); if (mBluetoothAdapter == null) { - log.debug("Unable to obtain a BluetoothAdapter."); + log.error("Unable to obtain a BluetoothAdapter."); return false; } @@ -128,7 +131,7 @@ public class BLEComm { } if (address == null) { - log.debug("unspecified address."); + log.error("unspecified address."); return false; } @@ -136,11 +139,12 @@ public class BLEComm { BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address); if (device == null) { - log.debug("Device not found. Unable to connect from: " + from); + log.error("Device not found. Unable to connect from: " + from); return false; } - log.debug("Trying to create a new connection from: " + from); + if (Config.logPumpBtComm) + log.debug("Trying to create a new connection from: " + from); mBluetoothGatt = device.connectGatt(service.getApplicationContext(), false, mGattCallback); setCharacteristicNotification(getUARTReadBTGattChar(), true); mBluetoothDeviceName = device.getName(); @@ -152,7 +156,8 @@ public class BLEComm { } public synchronized void disconnect(String from) { - log.debug("disconnect from: " + from); + if (Config.logPumpBtComm) + log.debug("disconnect from: " + from); // cancel previous scheduled disconnection to prevent closing upcomming connection if (scheduledDisconnection != null) @@ -160,8 +165,8 @@ public class BLEComm { scheduledDisconnection = null; if ((mBluetoothAdapter == null) || (mBluetoothGatt == null)) { - log.debug("disconnect not possible: (mBluetoothAdapter == null) " + (mBluetoothAdapter == null)); - log.debug("disconnect not possible: (mBluetoothGatt == null) " + (mBluetoothGatt == null)); + log.error("disconnect not possible: (mBluetoothAdapter == null) " + (mBluetoothAdapter == null)); + log.error("disconnect not possible: (mBluetoothGatt == null) " + (mBluetoothGatt == null)); return; } setCharacteristicNotification(getUARTReadBTGattChar(), false); @@ -171,7 +176,8 @@ public class BLEComm { } public synchronized void close() { - log.debug("BluetoothAdapter close"); + if (Config.logPumpBtComm) + log.debug("BluetoothAdapter close"); if (mBluetoothGatt == null) { return; } @@ -191,7 +197,8 @@ public class BLEComm { } public void onServicesDiscovered(BluetoothGatt gatt, int status) { - log.debug("onServicesDiscovered"); + if (Config.logPumpBtComm) + log.debug("onServicesDiscovered"); if (status == BluetoothGatt.GATT_SUCCESS) { findCharacteristic(); } @@ -200,19 +207,22 @@ public class BLEComm { } public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) { - log.debug("onCharacteristicRead" + (characteristic != null ? ":" + DanaRS_Packet.toHexString(characteristic.getValue()) : "")); + if (Config.logPumpBtComm) + log.debug("onCharacteristicRead" + (characteristic != null ? ":" + DanaRS_Packet.toHexString(characteristic.getValue()) : "")); addToReadBuffer(characteristic.getValue()); readDataParsing(); } public void onCharacteristicChanged(BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic) { - log.debug("onCharacteristicChanged" + (characteristic != null ? ":" + DanaRS_Packet.toHexString(characteristic.getValue()) : "")); + if (Config.logPumpBtComm) + log.debug("onCharacteristicChanged" + (characteristic != null ? ":" + DanaRS_Packet.toHexString(characteristic.getValue()) : "")); addToReadBuffer(characteristic.getValue()); new Thread(() -> readDataParsing()).start(); } public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) { - log.debug("onCharacteristicWrite" + (characteristic != null ? ":" + DanaRS_Packet.toHexString(characteristic.getValue()) : "")); + if (Config.logPumpBtComm) + log.debug("onCharacteristicWrite" + (characteristic != null ? ":" + DanaRS_Packet.toHexString(characteristic.getValue()) : "")); new Thread(() -> { synchronized (mSendQueue) { // after message sent, check if there is the rest of the message waiting and send it @@ -227,9 +237,10 @@ public class BLEComm { }; private synchronized void setCharacteristicNotification(BluetoothGattCharacteristic characteristic, boolean enabled) { - log.debug("setCharacteristicNotification"); + if (Config.logPumpBtComm) + log.debug("setCharacteristicNotification"); if ((mBluetoothAdapter == null) || (mBluetoothGatt == null)) { - log.debug("BluetoothAdapter not initialized_ERROR"); + log.error("BluetoothAdapter not initialized_ERROR"); isConnecting = false; isConnected = false; return; @@ -238,9 +249,10 @@ public class BLEComm { } public synchronized void readCharacteristic(BluetoothGattCharacteristic characteristic) { - log.debug("readCharacteristic"); + if (Config.logPumpBtComm) + log.debug("readCharacteristic"); if ((mBluetoothAdapter == null) || (mBluetoothGatt == null)) { - log.debug("BluetoothAdapter not initialized_ERROR"); + log.error("BluetoothAdapter not initialized_ERROR"); isConnecting = false; isConnected = false; return; @@ -253,7 +265,7 @@ public class BLEComm { SystemClock.sleep(WRITE_DELAY_MILLIS); if ((mBluetoothAdapter == null) || (mBluetoothGatt == null)) { - log.debug("BluetoothAdapter not initialized_ERROR"); + log.error("BluetoothAdapter not initialized_ERROR"); isConnecting = false; isConnected = false; return; @@ -261,7 +273,8 @@ public class BLEComm { characteristic.setValue(data); characteristic.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE); - log.debug("writeCharacteristic:" + DanaRS_Packet.toHexString(data)); + if (Config.logPumpBtComm) + log.debug("writeCharacteristic:" + DanaRS_Packet.toHexString(data)); mBluetoothGatt.writeCharacteristic(characteristic); }).start(); } @@ -281,9 +294,10 @@ public class BLEComm { } private List getSupportedGattServices() { - log.debug("getSupportedGattServices"); + if (Config.logPumpBtComm) + log.debug("getSupportedGattServices"); if ((mBluetoothAdapter == null) || (mBluetoothGatt == null)) { - log.debug("BluetoothAdapter not initialized_ERROR"); + log.error("BluetoothAdapter not initialized_ERROR"); isConnecting = false; isConnected = false; return null; @@ -315,8 +329,9 @@ public class BLEComm { } } - public synchronized void onConnectionStateChangeSynchronized(BluetoothGatt gatt, int status, int newState) { - log.debug("onConnectionStateChange"); + private synchronized void onConnectionStateChangeSynchronized(BluetoothGatt gatt, int status, int newState) { + if (Config.logPumpBtComm) + log.debug("onConnectionStateChange"); if (newState == BluetoothProfile.STATE_CONNECTED) { mBluetoothGatt.discoverServices(); @@ -325,7 +340,8 @@ public class BLEComm { isConnected = false; isConnecting = false; MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTED)); - log.debug("Device was disconnected " + gatt.getDevice().getName());//Device was disconnected + if (Config.logPumpBtComm) + log.debug("Device was disconnected " + gatt.getDevice().getName());//Device was disconnected } } @@ -360,7 +376,8 @@ public class BLEComm { if ((readBuffer[idxStartByte] == PACKET_START_BYTE) && (readBuffer[idxStartByte + 1] == PACKET_START_BYTE)) { if (idxStartByte > 0) { // if buffer doesn't start with signature remove the leading trash - log.debug("Shifting the input buffer by " + idxStartByte + " bytes"); + if (Config.logPumpBtComm) + log.debug("Shifting the input buffer by " + idxStartByte + " bytes"); System.arraycopy(readBuffer, idxStartByte, readBuffer, 0, bufferLength - idxStartByte); bufferLength -= idxStartByte; } @@ -390,7 +407,7 @@ public class BLEComm { try { System.arraycopy(readBuffer, length + 7, readBuffer, 0, bufferLength - (length + 7)); } catch (Exception e) { - log.debug("length: " + length + "bufferLength: " + bufferLength); + log.error("length: " + length + "bufferLength: " + bufferLength); throw e; } bufferLength -= (length + 7); @@ -403,7 +420,7 @@ public class BLEComm { inputBuffer = BleCommandUtil.getInstance().getDecryptedPacket(inputBuffer); if (inputBuffer == null) { - log.debug("Null decryptedInputBuffer"); + log.error("Null decryptedInputBuffer"); return; } @@ -414,14 +431,17 @@ public class BLEComm { // 1st packet case (byte) BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__PUMP_CHECK: if (inputBuffer.length == 4 && inputBuffer[2] == 'O' && inputBuffer[3] == 'K') { - log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (OK)" + " " + DanaRS_Packet.toHexString(inputBuffer)); + if (Config.logPumpBtComm) + log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (OK)" + " " + DanaRS_Packet.toHexString(inputBuffer)); // Grab pairing key from preferences if exists String pairingKey = SP.getString(MainApp.gs(R.string.key_danars_pairingkey) + DanaRSPlugin.mDeviceName, null); - log.debug("Using stored pairing key: " + pairingKey); + if (Config.logPumpBtComm) + log.debug("Using stored pairing key: " + pairingKey); if (pairingKey != null) { byte[] encodedPairingKey = DanaRS_Packet.hexToBytes(pairingKey); byte[] bytes = BleCommandUtil.getInstance().getEncryptedPacket(BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__CHECK_PASSKEY, encodedPairingKey, null); - log.debug(">>>>> " + "ENCRYPTION__CHECK_PASSKEY" + " " + DanaRS_Packet.toHexString(bytes)); + if (Config.logPumpBtComm) + log.debug(">>>>> " + "ENCRYPTION__CHECK_PASSKEY" + " " + DanaRS_Packet.toHexString(bytes)); writeCharacteristic_NO_RESPONSE(getUARTWriteBTGattChar(), bytes); } else { // Stored pairing key does not exists, request pairing @@ -429,19 +449,22 @@ public class BLEComm { } } else if (inputBuffer.length == 6 && inputBuffer[2] == 'P' && inputBuffer[3] == 'U' && inputBuffer[4] == 'M' && inputBuffer[5] == 'P') { - log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (PUMP)" + " " + DanaRS_Packet.toHexString(inputBuffer)); + if (Config.logPumpBtComm) + log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (PUMP)" + " " + DanaRS_Packet.toHexString(inputBuffer)); mSendQueue.clear(); MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTED, MainApp.gs(R.string.pumperror))); NSUpload.uploadError(MainApp.gs(R.string.pumperror)); Notification n = new Notification(Notification.PUMPERROR, MainApp.gs(R.string.pumperror), Notification.URGENT); MainApp.bus().post(new EventNewNotification(n)); } else if (inputBuffer.length == 6 && inputBuffer[2] == 'B' && inputBuffer[3] == 'U' && inputBuffer[4] == 'S' && inputBuffer[5] == 'Y') { - log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (BUSY)" + " " + DanaRS_Packet.toHexString(inputBuffer)); + if (Config.logPumpBtComm) + log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (BUSY)" + " " + DanaRS_Packet.toHexString(inputBuffer)); mSendQueue.clear(); MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTED, MainApp.gs(R.string.pumpbusy))); } else { // ERROR in response, wrong serial number - log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (ERROR)" + " " + DanaRS_Packet.toHexString(inputBuffer)); + if (Config.logPumpBtComm) + log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (ERROR)" + " " + DanaRS_Packet.toHexString(inputBuffer)); mSendQueue.clear(); MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTED, MainApp.gs(R.string.connectionerror))); SP.remove(MainApp.gs(R.string.key_danars_pairingkey) + DanaRSPlugin.mDeviceName); @@ -451,7 +474,8 @@ public class BLEComm { break; // 2nd packet, pairing key case (byte) BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__CHECK_PASSKEY: - log.debug("<<<<< " + "ENCRYPTION__CHECK_PASSKEY" + " " + DanaRS_Packet.toHexString(inputBuffer)); + if (Config.logPumpBtComm) + log.debug("<<<<< " + "ENCRYPTION__CHECK_PASSKEY" + " " + DanaRS_Packet.toHexString(inputBuffer)); if (inputBuffer[2] == (byte) 0x00) { // Paring is not requested, sending time info SendTimeInfo(); @@ -461,35 +485,41 @@ public class BLEComm { } break; case (byte) BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_REQUEST: - log.debug("<<<<< " + "ENCRYPTION__PASSKEY_REQUEST " + DanaRS_Packet.toHexString(inputBuffer)); + if (Config.logPumpBtComm) + log.debug("<<<<< " + "ENCRYPTION__PASSKEY_REQUEST " + DanaRS_Packet.toHexString(inputBuffer)); if (inputBuffer[2] != (byte) 0x00) { disconnect("passkey request failed"); } break; // Paring response, OK button on pump pressed case (byte) BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_RETURN: - log.debug("<<<<< " + "ENCRYPTION__PASSKEY_RETURN " + DanaRS_Packet.toHexString(inputBuffer)); + if (Config.logPumpBtComm) + log.debug("<<<<< " + "ENCRYPTION__PASSKEY_RETURN " + DanaRS_Packet.toHexString(inputBuffer)); // Paring is successfull, sending time info MainApp.bus().post(new EventDanaRSPairingSuccess()); SendTimeInfo(); byte[] pairingKey = {inputBuffer[2], inputBuffer[3]}; // store pairing key to preferences SP.putString(MainApp.gs(R.string.key_danars_pairingkey) + DanaRSPlugin.mDeviceName, DanaRS_Packet.bytesToHex(pairingKey)); - log.debug("Got pairing key: " + DanaRS_Packet.bytesToHex(pairingKey)); + if (Config.logPumpBtComm) + log.debug("Got pairing key: " + DanaRS_Packet.bytesToHex(pairingKey)); break; // time and user password information. last packet in handshake case (byte) BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__TIME_INFORMATION: - log.debug("<<<<< " + "ENCRYPTION__TIME_INFORMATION " + /*message.getMessageName() + " " + */ DanaRS_Packet.toHexString(inputBuffer)); + if (Config.logPumpBtComm) + log.debug("<<<<< " + "ENCRYPTION__TIME_INFORMATION " + /*message.getMessageName() + " " + */ DanaRS_Packet.toHexString(inputBuffer)); int size = inputBuffer.length; int pass = ((inputBuffer[size - 1] & 0x000000FF) << 8) + ((inputBuffer[size - 2] & 0x000000FF)); pass = pass ^ 3463; DanaRPump.getInstance().rs_password = Integer.toHexString(pass); - log.debug("Pump user password: " + Integer.toHexString(pass)); + if (Config.logPumpBtComm) + log.debug("Pump user password: " + Integer.toHexString(pass)); MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTED)); isConnected = true; isConnecting = false; - log.debug("RS connected and status read"); + if (Config.logPumpBtComm) + log.debug("RS connected and status read"); break; } break; @@ -507,7 +537,8 @@ public class BLEComm { message = DanaRSMessageHashTable.findMessage(receivedCommand); } if (message != null) { - log.debug("<<<<< " + message.getFriendlyName() + " " + DanaRS_Packet.toHexString(inputBuffer)); + if (Config.logPumpBtComm) + log.debug("<<<<< " + message.getFriendlyName() + " " + DanaRS_Packet.toHexString(inputBuffer)); // process received data message.handleMessage(inputBuffer); message.setReceived(); @@ -544,7 +575,8 @@ public class BLEComm { byte[] command = {(byte) message.getType(), (byte) message.getOpCode()}; byte[] params = message.getRequestParams(); - log.debug(">>>>> " + message.getFriendlyName() + " " + DanaRS_Packet.toHexString(command) + " " + DanaRS_Packet.toHexString(params)); + if (Config.logPumpBtComm) + log.debug(">>>>> " + message.getFriendlyName() + " " + DanaRS_Packet.toHexString(command) + " " + DanaRS_Packet.toHexString(params)); byte[] bytes = BleCommandUtil.getInstance().getEncryptedPacket(message.getOpCode(), params, null); // If there is another message not completely sent, add to queue only if (mSendQueue.size() > 0) { @@ -624,20 +656,23 @@ public class BLEComm { MainApp.instance().startActivity(i); byte[] bytes = BleCommandUtil.getInstance().getEncryptedPacket(BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_REQUEST, null, null); - log.debug(">>>>> " + "ENCRYPTION__PASSKEY_REQUEST" + " " + DanaRS_Packet.toHexString(bytes)); + if (Config.logPumpBtComm) + log.debug(">>>>> " + "ENCRYPTION__PASSKEY_REQUEST" + " " + DanaRS_Packet.toHexString(bytes)); writeCharacteristic_NO_RESPONSE(getUARTWriteBTGattChar(), bytes); } private void SendPumpCheck() { // 1st message sent to pump after connect byte[] bytes = BleCommandUtil.getInstance().getEncryptedPacket(BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__PUMP_CHECK, null, getConnectDeviceName()); - log.debug(">>>>> " + "ENCRYPTION__PUMP_CHECK (0x00)" + " " + DanaRS_Packet.toHexString(bytes)); + if (Config.logPumpBtComm) + log.debug(">>>>> " + "ENCRYPTION__PUMP_CHECK (0x00)" + " " + DanaRS_Packet.toHexString(bytes)); writeCharacteristic_NO_RESPONSE(getUARTWriteBTGattChar(), bytes); } private void SendTimeInfo() { byte[] bytes = BleCommandUtil.getInstance().getEncryptedPacket(BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__TIME_INFORMATION, null, null); - log.debug(">>>>> " + "ENCRYPTION__TIME_INFORMATION" + " " + DanaRS_Packet.toHexString(bytes)); + if (Config.logPumpBtComm) + log.debug(">>>>> " + "ENCRYPTION__TIME_INFORMATION" + " " + DanaRS_Packet.toHexString(bytes)); writeCharacteristic_NO_RESPONSE(getUARTWriteBTGattChar(), bytes); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/DanaRSService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/DanaRSService.java index fae0430adc..0264e2148a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/DanaRSService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/DanaRSService.java @@ -83,7 +83,7 @@ import info.nightscout.utils.SP; import info.nightscout.utils.T; public class DanaRSService extends Service { - private static Logger log = LoggerFactory.getLogger(DanaRSService.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); private BLEComm bleComm = BLEComm.getInstance(this); @@ -156,10 +156,12 @@ public class DanaRSService extends Service { bleComm.sendMessage(new DanaRS_Packet_Option_Get_Pump_Time()); long timeDiff = (danaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L; - log.debug("Pump time difference: " + timeDiff + " seconds"); + if (Config.logPumpComm) + log.debug("Pump time difference: " + timeDiff + " seconds"); if (Math.abs(timeDiff) > 3) { - if (Math.abs(timeDiff) > 60*60*1.5) { - log.debug("Pump time difference: " + timeDiff + " seconds - large difference"); + if (Math.abs(timeDiff) > 60 * 60 * 1.5) { + if (Config.logPumpComm) + log.debug("Pump time difference: " + timeDiff + " seconds - large difference"); //If time-diff is very large, warn user until we can synchronize history readings properly Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class); i.putExtra("soundid", R.raw.error); @@ -179,7 +181,8 @@ public class DanaRSService extends Service { bleComm.sendMessage(new DanaRS_Packet_Option_Set_Pump_Time(new Date(DateUtil.now() + T.secs(10).msecs()))); bleComm.sendMessage(new DanaRS_Packet_Option_Get_Pump_Time()); timeDiff = (danaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L; - log.debug("Pump time difference: " + timeDiff + " seconds"); + if (Config.logPumpComm) + log.debug("Pump time difference: " + timeDiff + " seconds"); } } @@ -203,8 +206,9 @@ public class DanaRSService extends Service { MainApp.bus().post(new EventInitializationChanged()); NSUpload.uploadDeviceStatus(); if (danaRPump.dailyTotalUnits > danaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) { - log.debug("Approaching daily limit: " + danaRPump.dailyTotalUnits + "/" + danaRPump.maxDailyTotalUnits); - if(System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) { + if (Config.logPumpComm) + log.debug("Approaching daily limit: " + danaRPump.dailyTotalUnits + "/" + danaRPump.maxDailyTotalUnits); + if (System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) { Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.gs(R.string.approachingdailylimit), Notification.URGENT); MainApp.bus().post(new EventNewNotification(reportFail)); NSUpload.uploadError(MainApp.gs(R.string.approachingdailylimit) + ": " + danaRPump.dailyTotalUnits + "/" + danaRPump.maxDailyTotalUnits + "U"); @@ -214,12 +218,13 @@ public class DanaRSService extends Service { } catch (Exception e) { log.error("Unhandled exception", e); } - log.debug("Pump status loaded"); + if (Config.logPumpComm) + log.debug("Pump status loaded"); } public PumpEnactResult loadEvents() { - if(!MainApp.getSpecificPlugin(DanaRSPlugin.class).isInitialized()){ + if (!MainApp.getSpecificPlugin(DanaRSPlugin.class).isInitialized()) { PumpEnactResult result = new PumpEnactResult().success(false); result.comment = "pump not initialized"; return result; @@ -230,10 +235,12 @@ public class DanaRSService extends Service { DanaRS_Packet_APS_History_Events msg; if (lastHistoryFetched == 0) { msg = new DanaRS_Packet_APS_History_Events(0); - log.debug("Loading complete event history"); + if (Config.logPumpComm) + log.debug("Loading complete event history"); } else { msg = new DanaRS_Packet_APS_History_Events(lastHistoryFetched); - log.debug("Loading event history from: " + new Date(lastHistoryFetched).toLocaleString()); + if (Config.logPumpComm) + log.debug("Loading event history from: " + new Date(lastHistoryFetched).toLocaleString()); } bleComm.sendMessage(msg); while (!msg.done && bleComm.isConnected()) { @@ -243,7 +250,8 @@ public class DanaRSService extends Service { lastHistoryFetched = DanaRS_Packet_APS_History_Events.lastEventTimeLoaded - T.mins(1).msecs(); else lastHistoryFetched = 0; - log.debug("Events loaded"); + if (Config.logPumpComm) + log.debug("Events loaded"); danaRPump.lastConnection = System.currentTimeMillis(); return new PumpEnactResult().success(true); } @@ -290,7 +298,8 @@ public class DanaRSService extends Service { if ((System.currentTimeMillis() - progress.lastReceive) > 15 * 1000L) { // if i didn't receive status for more than 20 sec expecting broken comm stop.stopped = true; stop.forced = true; - log.debug("Communication stopped"); + if (Config.logPumpComm) + log.debug("Communication stopped"); } } } @@ -335,7 +344,7 @@ public class DanaRSService extends Service { } public void bolusStop() { - if (Config.logDanaBTComm) + if (Config.logPumpComm) log.debug("bolusStop >>>>> @ " + (bolusingTreatment == null ? "" : bolusingTreatment.insulin)); DanaRS_Packet_Bolus_Set_Step_Bolus_Stop stop = new DanaRS_Packet_Bolus_Set_Step_Bolus_Stop(); stop.forced = true; @@ -433,7 +442,7 @@ public class DanaRSService extends Service { public boolean updateBasalsInPump(Profile profile) { if (!isConnected()) return false; MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.updatingbasalrates))); - double[] basal = DanaRPump.buildDanaRProfileRecord(profile); + double[] basal = DanaRPump.getInstance().buildDanaRProfileRecord(profile); DanaRS_Packet_Basal_Set_Profile_Basal_Rate msgSet = new DanaRS_Packet_Basal_Set_Profile_Basal_Rate(0, basal); bleComm.sendMessage(msgSet); DanaRS_Packet_Basal_Set_Profile_Number msgActivate = new DanaRS_Packet_Basal_Set_Profile_Number(0); @@ -512,11 +521,11 @@ public class DanaRSService extends Service { @Subscribe public void onStatusEvent(EventAppExit event) { - if (Config.logFunctionCalls) + if (Config.logPump) log.debug("EventAppExit received"); stopSelf(); - if (Config.logFunctionCalls) + if (Config.logPump) log.debug("EventAppExit finished"); } @@ -526,7 +535,7 @@ public class DanaRSService extends Service { long timeToWholeMinute = (60000 - time % 60000); if (timeToWholeMinute > 59800 || timeToWholeMinute < 300) break; - MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.waitingfortimesynchronization, (int)(timeToWholeMinute / 1000)))); + MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.waitingfortimesynchronization, (int) (timeToWholeMinute / 1000)))); SystemClock.sleep(Math.min(timeToWholeMinute, 100)); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java index e83f9d9435..49d945bdaa 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java @@ -11,8 +11,6 @@ import android.support.v7.app.AlertDialog; import com.squareup.otto.Subscribe; -import org.slf4j.LoggerFactory; - import info.nightscout.androidaps.Config; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; @@ -51,7 +49,6 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin { private DanaRv2Plugin() { pluginDescription.description(R.string.description_pump_dana_r_v2); - log = LoggerFactory.getLogger(DanaRv2Plugin.class); useExtendedBoluses = false; pumpDescription.isBolusCapable = true; @@ -107,12 +104,14 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin { private ServiceConnection mConnection = new ServiceConnection() { public void onServiceDisconnected(ComponentName name) { - log.debug("Service is disconnected"); + if (Config.logPump) + log.debug("Service is disconnected"); sExecutionService = null; } public void onServiceConnected(ComponentName name, IBinder service) { - log.debug("Service is connected"); + if (Config.logPump) + log.debug("Service is connected"); DanaRv2ExecutionService.LocalBinder mLocalBinder = (DanaRv2ExecutionService.LocalBinder) service; sExecutionService = mLocalBinder.getServiceInstance(); } @@ -157,13 +156,15 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin { public void onClick(DialogInterface dialog, int id) { pluginSwitcher.invoke(); SP.putBoolean("allow_hardware_pump", true); - log.debug("First time HW pump allowed!"); + if (Config.logPump) + log.debug("First time HW pump allowed!"); } }) .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { pluginSwitcher.cancel(); - log.debug("User does not allow switching to HW pump!"); + if (Config.logPump) + log.debug("User does not allow switching to HW pump!"); } }); builder.create().show(); @@ -214,7 +215,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin { result.comment = String.format(MainApp.gs(R.string.boluserrorcode), detailedBolusInfo.insulin, t.insulin, MsgBolusStartWithSpeed.errorCode); else result.comment = MainApp.gs(R.string.virtualpump_resultok); - if (Config.logPumpActions) + if (Config.logPump) log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered); // remove carbs because it's get from history seprately return result; @@ -258,7 +259,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin { if (doTempOff) { // If temp in progress if (TreatmentsPlugin.getPlugin().isTempBasalInProgress()) { - if (Config.logPumpActions) + if (Config.logPump) log.debug("setTempBasalAbsolute: Stopping temp basal (doTempOff)"); return cancelTempBasal(false); } @@ -267,7 +268,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin { result.percent = 100; result.isPercent = true; result.isTempCancel = true; - if (Config.logPumpActions) + if (Config.logPump) log.debug("setTempBasalAbsolute: doTempOff OK"); return result; } @@ -290,14 +291,14 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin { result.duration = activeTemp.getPlannedRemainingMinutes(); result.isPercent = true; result.isTempCancel = false; - if (Config.logPumpActions) + if (Config.logPump) log.debug("setTempBasalAbsolute: Correct temp basal already set (doLowTemp || doHighTemp)"); return result; } } } // Convert duration from minutes to hours - if (Config.logPumpActions) + if (Config.logPump) log.debug("setTempBasalAbsolute: Setting temp basal " + percentRate + "% for " + durationInMinutes + " mins (doLowTemp || doHighTemp)"); if (percentRate == 0 && durationInMinutes > 30) { result = setTempBasalPercent(percentRate, durationInMinutes, profile, false); @@ -309,7 +310,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin { log.error("setTempBasalAbsolute: Failed to set hightemp basal"); return result; } - if (Config.logPumpActions) + if (Config.logPump) log.debug("setTempBasalAbsolute: hightemp basal set ok"); return result; } @@ -344,7 +345,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin { result.duration = pump.tempBasalRemainingMin; result.percent = pump.tempBasalPercent; result.isPercent = true; - if (Config.logPumpActions) + if (Config.logPump) log.debug("setTempBasalPercent: Correct value already set"); return result; } @@ -363,7 +364,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin { result.duration = pump.tempBasalRemainingMin; result.percent = pump.tempBasalPercent; result.isPercent = true; - if (Config.logPumpActions) + if (Config.logPump) log.debug("setTempBasalPercent: OK"); return result; } @@ -385,7 +386,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin { result.duration = pump.tempBasalRemainingMin; result.percent = pump.tempBasalPercent; result.isPercent = true; - if (Config.logPumpActions) + if (Config.logPump) log.debug("setHighTempBasalPercent: OK"); return result; } @@ -409,7 +410,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin { result.success = true; result.isTempCancel = true; result.comment = MainApp.gs(R.string.virtualpump_resultok); - if (Config.logPumpActions) + if (Config.logPump) log.debug("cancelRealTempBasal: OK"); return result; } else { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/SerialIOThread.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/SerialIOThread.java index a12e2085aa..49060192b5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/SerialIOThread.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/SerialIOThread.java @@ -11,6 +11,7 @@ import java.io.InputStream; import java.io.OutputStream; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; import info.nightscout.androidaps.plugins.PumpDanaR.services.AbstractSerialIOThread; @@ -21,7 +22,7 @@ import info.nightscout.utils.CRC; * Created by mike on 17.07.2016. */ public class SerialIOThread extends AbstractSerialIOThread { - private static Logger log = LoggerFactory.getLogger(SerialIOThread.class); + private static Logger log = LoggerFactory.getLogger(Constants.PUMPBTCOMM); private InputStream mInputStream = null; private OutputStream mOutputStream = null; @@ -72,7 +73,7 @@ public class SerialIOThread extends AbstractSerialIOThread { message = MessageHashTable_v2.findMessage(command); } - if (Config.logDanaMessageDetail) + if (Config.logPumpBtComm) log.debug("<<<<< " + message.getMessageName() + " " + message.toHexString(extractedBuff)); // process the message content @@ -84,7 +85,7 @@ public class SerialIOThread extends AbstractSerialIOThread { } } } catch (Exception e) { - if (Config.logDanaSerialEngine && e.getMessage().indexOf("bt socket closed") < 0) + if (e.getMessage().indexOf("bt socket closed") < 0) log.error("Thread exception: ", e); mKeepRunning = false; } @@ -148,7 +149,7 @@ public class SerialIOThread extends AbstractSerialIOThread { processedMessage = message; byte[] messageBytes = message.getRawMessageBytes(); - if (Config.logDanaSerialEngine) + if (Config.logPumpBtComm) log.debug(">>>>> " + message.getMessageName() + " " + message.toHexString(messageBytes)); try { @@ -167,10 +168,10 @@ public class SerialIOThread extends AbstractSerialIOThread { SystemClock.sleep(200); if (!message.received) { - log.warn("Reply not received " + message.getMessageName()); + log.error("Reply not received " + message.getMessageName()); if (message.getCommand() == 0xF0F1) { DanaRPump.getInstance().isNewPump = false; - log.debug("Old firmware detected"); + log.error("Old firmware detected"); } } } @@ -181,24 +182,29 @@ public class SerialIOThread extends AbstractSerialIOThread { try { mInputStream.close(); } catch (Exception e) { - if (Config.logDanaSerialEngine) log.debug(e.getMessage()); + if (Config.logPumpBtComm) + log.debug(e.getMessage()); } try { mOutputStream.close(); } catch (Exception e) { - if (Config.logDanaSerialEngine) log.debug(e.getMessage()); + if (Config.logPumpBtComm) + log.debug(e.getMessage()); } try { mRfCommSocket.close(); } catch (Exception e) { - if (Config.logDanaSerialEngine) log.debug(e.getMessage()); + if (Config.logPumpBtComm) + log.debug(e.getMessage()); } try { System.runFinalization(); } catch (Exception e) { - if (Config.logDanaSerialEngine) log.debug(e.getMessage()); + if (Config.logPumpBtComm) + log.debug(e.getMessage()); } - if (Config.logDanaSerialEngine) log.debug("Disconnected: " + reason); + if (Config.logPumpBtComm) + log.debug("Disconnected: " + reason); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MessageHashTable_v2.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MessageHashTable_v2.java index 8d1cd12be1..c95a800128 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MessageHashTable_v2.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MessageHashTable_v2.java @@ -1,8 +1,5 @@ package info.nightscout.androidaps.plugins.PumpDanaRv2.comm; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.util.HashMap; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; @@ -13,8 +10,6 @@ import info.nightscout.androidaps.plugins.PumpDanaR.comm.*; * Created by mike on 28.05.2016. */ public class MessageHashTable_v2 { - private static Logger log = LoggerFactory.getLogger(MessageHashTable_v2.class); - public static HashMap messages = null; static { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgCheckValue_v2.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgCheckValue_v2.java index 0869844a1c..dcd2c5aace 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgCheckValue_v2.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgCheckValue_v2.java @@ -4,6 +4,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.events.EventRefreshGui; @@ -21,10 +22,12 @@ import info.nightscout.androidaps.plugins.PumpDanaRv2.DanaRv2Plugin; * Created by mike on 30.06.2016. */ public class MsgCheckValue_v2 extends MessageBase { - private static Logger log = LoggerFactory.getLogger(MsgCheckValue_v2.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public MsgCheckValue_v2() { SetCommand(0xF0F1); + if (Config.logPumpComm) + log.debug("New message"); } @Override @@ -32,7 +35,8 @@ public class MsgCheckValue_v2 extends MessageBase { DanaRPump pump = DanaRPump.getInstance(); pump.isNewPump = true; - log.debug("New firmware confirmed"); + if (Config.logPumpComm) + log.debug("New firmware confirmed"); pump.model = intFromBuff(bytes, 0, 1); pump.protocol = intFromBuff(bytes, 1, 1); @@ -42,7 +46,7 @@ public class MsgCheckValue_v2 extends MessageBase { Notification notification = new Notification(Notification.WRONG_DRIVER, MainApp.gs(R.string.pumpdrivercorrected), Notification.NORMAL); MainApp.bus().post(new EventNewNotification(notification)); MainApp.getSpecificPlugin(DanaRPlugin.class).disconnect("Wrong Model"); - log.debug("Wrong model selected. Switching to Korean DanaR"); + log.error("Wrong model selected. Switching to Korean DanaR"); MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setPluginEnabled(PluginType.PUMP, true); MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setFragmentVisible(PluginType.PUMP, true); MainApp.getSpecificPlugin(DanaRPlugin.class).setPluginEnabled(PluginType.PUMP, false); @@ -67,7 +71,7 @@ public class MsgCheckValue_v2 extends MessageBase { Notification notification = new Notification(Notification.WRONG_DRIVER, MainApp.gs(R.string.pumpdrivercorrected), Notification.NORMAL); MainApp.bus().post(new EventNewNotification(notification)); DanaRKoreanPlugin.getPlugin().disconnect("Wrong Model"); - log.debug("Wrong model selected. Switching to non APS DanaR"); + log.error("Wrong model selected. Switching to non APS DanaR"); (MainApp.getSpecificPlugin(DanaRv2Plugin.class)).setPluginEnabled(PluginType.PUMP, false); (MainApp.getSpecificPlugin(DanaRv2Plugin.class)).setFragmentVisible(PluginType.PUMP, false); (MainApp.getSpecificPlugin(DanaRPlugin.class)).setPluginEnabled(PluginType.PUMP, true); @@ -84,7 +88,7 @@ public class MsgCheckValue_v2 extends MessageBase { ConfigBuilderPlugin.getCommandQueue().readStatus("PumpDriverChange", null); // force new connection return; } - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Model: " + String.format("%02X ", pump.model)); log.debug("Protocol: " + String.format("%02X ", pump.protocol)); log.debug("Product Code: " + String.format("%02X ", pump.productCode)); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgHistoryEvents_v2.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgHistoryEvents_v2.java index 91c01ba38c..2fe09d93bc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgHistoryEvents_v2.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgHistoryEvents_v2.java @@ -6,6 +6,8 @@ import org.slf4j.LoggerFactory; import java.util.Date; import java.util.GregorianCalendar; +import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.DetailedBolusInfo; @@ -20,7 +22,7 @@ import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin; import info.nightscout.utils.DateUtil; public class MsgHistoryEvents_v2 extends MessageBase { - private static Logger log = LoggerFactory.getLogger(MsgHistoryEvents_v2.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public boolean done; public static long lastEventTimeLoaded = 0; @@ -31,6 +33,8 @@ public class MsgHistoryEvents_v2 extends MessageBase { gfrom.setTimeInMillis(from); AddParamDate(gfrom); done = false; + if (Config.logPumpComm) + log.debug("New message"); } public MsgHistoryEvents_v2() { @@ -41,6 +45,8 @@ public class MsgHistoryEvents_v2 extends MessageBase { AddParamByte((byte) 0); AddParamByte((byte) 0); done = false; + if (Config.logPumpComm) + log.debug("New message"); } @Override @@ -69,10 +75,12 @@ public class MsgHistoryEvents_v2 extends MessageBase { DetailedBolusInfo detailedBolusInfo = DetailedBolusInfoStorage.findDetailedBolusInfo(datetime.getTime()); if (detailedBolusInfo == null) { - log.debug("Detailed bolus info not found for " + datetime.toLocaleString()); + if (Config.logPumpComm) + log.debug("Detailed bolus info not found for " + datetime.toLocaleString()); detailedBolusInfo = new DetailedBolusInfo(); } else { - log.debug("Detailed bolus info found: " + detailedBolusInfo); + if (Config.logPumpComm) + log.debug("Detailed bolus info found: " + detailedBolusInfo); } detailedBolusInfo.date = datetime.getTime(); detailedBolusInfo.source = Source.PUMP; @@ -82,73 +90,86 @@ public class MsgHistoryEvents_v2 extends MessageBase { switch (recordCode) { case DanaRPump.TEMPSTART: - log.debug("EVENT TEMPSTART (" + recordCode + ") " + datetime.toLocaleString() + " Ratio: " + param1 + "% Duration: " + param2 + "min"); + if (Config.logPumpComm) + log.debug("EVENT TEMPSTART (" + recordCode + ") " + datetime.toLocaleString() + " Ratio: " + param1 + "% Duration: " + param2 + "min"); temporaryBasal.percentRate = param1; temporaryBasal.durationInMinutes = param2; TreatmentsPlugin.getPlugin().addToHistoryTempBasal(temporaryBasal); status = "TEMPSTART " + DateUtil.timeString(datetime); break; case DanaRPump.TEMPSTOP: - log.debug("EVENT TEMPSTOP (" + recordCode + ") " + datetime.toLocaleString()); + if (Config.logPumpComm) + log.debug("EVENT TEMPSTOP (" + recordCode + ") " + datetime.toLocaleString()); TreatmentsPlugin.getPlugin().addToHistoryTempBasal(temporaryBasal); status = "TEMPSTOP " + DateUtil.timeString(datetime); break; case DanaRPump.EXTENDEDSTART: - log.debug("EVENT EXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min"); + if (Config.logPumpComm) + log.debug("EVENT EXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min"); extendedBolus.insulin = param1 / 100d; extendedBolus.durationInMinutes = param2; TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus); status = "EXTENDEDSTART " + DateUtil.timeString(datetime); break; case DanaRPump.EXTENDEDSTOP: - log.debug("EVENT EXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min"); + if (Config.logPumpComm) + log.debug("EVENT EXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min"); TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus); status = "EXTENDEDSTOP " + DateUtil.timeString(datetime); break; case DanaRPump.BOLUS: detailedBolusInfo.insulin = param1 / 100d; boolean newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false); - log.debug((newRecord ? "**NEW** " : "") + "EVENT BOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min"); + if (Config.logPumpComm) + log.debug((newRecord ? "**NEW** " : "") + "EVENT BOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min"); DetailedBolusInfoStorage.remove(detailedBolusInfo.date); status = "BOLUS " + DateUtil.timeString(datetime); break; case DanaRPump.DUALBOLUS: detailedBolusInfo.insulin = param1 / 100d; newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false); - log.debug((newRecord ? "**NEW** " : "") + "EVENT DUALBOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min"); + if (Config.logPumpComm) + log.debug((newRecord ? "**NEW** " : "") + "EVENT DUALBOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min"); DetailedBolusInfoStorage.remove(detailedBolusInfo.date); status = "DUALBOLUS " + DateUtil.timeString(datetime); break; case DanaRPump.DUALEXTENDEDSTART: - log.debug("EVENT DUALEXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min"); + if (Config.logPumpComm) + log.debug("EVENT DUALEXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min"); extendedBolus.insulin = param1 / 100d; extendedBolus.durationInMinutes = param2; TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus); status = "DUALEXTENDEDSTART " + DateUtil.timeString(datetime); break; case DanaRPump.DUALEXTENDEDSTOP: - log.debug("EVENT DUALEXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min"); + if (Config.logPumpComm) + log.debug("EVENT DUALEXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min"); TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus); status = "DUALEXTENDEDSTOP " + DateUtil.timeString(datetime); break; case DanaRPump.SUSPENDON: - log.debug("EVENT SUSPENDON (" + recordCode + ") " + datetime.toLocaleString()); + if (Config.logPumpComm) + log.debug("EVENT SUSPENDON (" + recordCode + ") " + datetime.toLocaleString()); status = "SUSPENDON " + DateUtil.timeString(datetime); break; case DanaRPump.SUSPENDOFF: - log.debug("EVENT SUSPENDOFF (" + recordCode + ") " + datetime.toLocaleString()); + if (Config.logPumpComm) + log.debug("EVENT SUSPENDOFF (" + recordCode + ") " + datetime.toLocaleString()); status = "SUSPENDOFF " + DateUtil.timeString(datetime); break; case DanaRPump.REFILL: - log.debug("EVENT REFILL (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U"); + if (Config.logPumpComm) + log.debug("EVENT REFILL (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U"); status = "REFILL " + DateUtil.timeString(datetime); break; case DanaRPump.PRIME: - log.debug("EVENT PRIME (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U"); + if (Config.logPumpComm) + log.debug("EVENT PRIME (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U"); status = "PRIME " + DateUtil.timeString(datetime); break; case DanaRPump.PROFILECHANGE: - log.debug("EVENT PROFILECHANGE (" + recordCode + ") " + datetime.toLocaleString() + " No: " + param1 + " CurrentRate: " + (param2 / 100d) + "U/h"); + if (Config.logPumpComm) + log.debug("EVENT PROFILECHANGE (" + recordCode + ") " + datetime.toLocaleString() + " No: " + param1 + " CurrentRate: " + (param2 / 100d) + "U/h"); status = "PROFILECHANGE " + DateUtil.timeString(datetime); break; case DanaRPump.CARBS: @@ -158,11 +179,13 @@ public class MsgHistoryEvents_v2 extends MessageBase { emptyCarbsInfo.source = Source.PUMP; emptyCarbsInfo.pumpId = datetime.getTime(); newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(emptyCarbsInfo, false); - log.debug((newRecord ? "**NEW** " : "") + "EVENT CARBS (" + recordCode + ") " + datetime.toLocaleString() + " Carbs: " + param1 + "g"); + if (Config.logPumpComm) + log.debug((newRecord ? "**NEW** " : "") + "EVENT CARBS (" + recordCode + ") " + datetime.toLocaleString() + " Carbs: " + param1 + "g"); status = "CARBS " + DateUtil.timeString(datetime); break; default: - log.debug("Event: " + recordCode + " " + datetime.toLocaleString() + " Param1: " + param1 + " Param2: " + param2); + if (Config.logPumpComm) + log.debug("Event: " + recordCode + " " + datetime.toLocaleString() + " Param1: " + param1 + " Param2: " + param2); status = "UNKNOWN " + DateUtil.timeString(datetime); break; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgSetAPSTempBasalStart_v2.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgSetAPSTempBasalStart_v2.java index 6b6e3045de..428352d6a8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgSetAPSTempBasalStart_v2.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgSetAPSTempBasalStart_v2.java @@ -4,10 +4,11 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; public class MsgSetAPSTempBasalStart_v2 extends MessageBase { - private static Logger log = LoggerFactory.getLogger(MsgSetAPSTempBasalStart_v2.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); protected final int PARAM30MIN = 160; protected final int PARAM15MIN = 150; @@ -19,6 +20,8 @@ public class MsgSetAPSTempBasalStart_v2 extends MessageBase { public MsgSetAPSTempBasalStart_v2(int percent) { this(); setParams(percent); + if (Config.logPumpComm) + log.debug("New message: percent: " + percent); } protected void setParams(int percent) { @@ -29,11 +32,11 @@ public class MsgSetAPSTempBasalStart_v2 extends MessageBase { AddParamInt(percent); if (percent < 100) { AddParamByte((byte) PARAM30MIN); - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("APS Temp basal start percent: " + percent + " duration 30 min"); } else { AddParamByte((byte) PARAM15MIN); - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("APS Temp basal start percent: " + percent + " duration 15 min"); } } @@ -51,11 +54,11 @@ public class MsgSetAPSTempBasalStart_v2 extends MessageBase { AddParamInt(percent); if (thirtyMinutes && percent <= 200) { // 30 min is allowed up to 200% AddParamByte((byte) PARAM30MIN); - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("APS Temp basal start percent: " + percent + " duration 30 min"); } else { AddParamByte((byte) PARAM15MIN); - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("APS Temp basal start percent: " + percent + " duration 15 min"); } } @@ -64,10 +67,11 @@ public class MsgSetAPSTempBasalStart_v2 extends MessageBase { int result = intFromBuff(bytes, 0, 1); if (result != 1) { failed = true; - log.debug("Set APS temp basal start result: " + result + " FAILED!!!"); + if (Config.logPumpComm) + log.debug("Set APS temp basal start result: " + result + " FAILED!!!"); } else { failed = false; - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("Set APS temp basal start result: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgSetHistoryEntry_v2.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgSetHistoryEntry_v2.java index abeb656f03..4a044df0a0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgSetHistoryEntry_v2.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgSetHistoryEntry_v2.java @@ -7,10 +7,11 @@ import java.util.Date; import java.util.GregorianCalendar; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; public class MsgSetHistoryEntry_v2 extends MessageBase { - private static Logger log = LoggerFactory.getLogger(MsgSetHistoryEntry_v2.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public MsgSetHistoryEntry_v2() { SetCommand(0xE004); @@ -25,7 +26,7 @@ public class MsgSetHistoryEntry_v2 extends MessageBase { AddParamDateTime(gtime); AddParamInt(param1); AddParamInt(param2); - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("Set history entry: type: " + type + " date: " + new Date(time).toString() + " param1: " + param1 + " param2: " + param2); } @@ -34,9 +35,10 @@ public class MsgSetHistoryEntry_v2 extends MessageBase { int result = intFromBuff(bytes, 0, 1); if (result != 1) { failed = true; - log.debug("Set history entry result: " + result + " FAILED!!!"); + if (Config.logPumpComm) + log.debug("Set history entry result: " + result + " FAILED!!!"); } else { - if (Config.logDanaMessageDetail) + if (Config.logPumpComm) log.debug("Set history entry result: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgStatusAPS_v2.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgStatusAPS_v2.java index c2f87ee36a..19827c484f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgStatusAPS_v2.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgStatusAPS_v2.java @@ -4,14 +4,17 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; public class MsgStatusAPS_v2 extends MessageBase { - private static Logger log = LoggerFactory.getLogger(MsgStatusAPS_v2.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public MsgStatusAPS_v2() { SetCommand(0xE001); + if (Config.logPumpComm) + log.debug("New message"); } public void handleMessage(byte[] bytes) { @@ -21,7 +24,7 @@ public class MsgStatusAPS_v2 extends MessageBase { DanaRPump pump = DanaRPump.getInstance(); pump.iob = iob; - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Delivered so far: " + deliveredSoFar); log.debug("Current pump IOB: " + iob); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgStatusBolusExtended_v2.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgStatusBolusExtended_v2.java index f695f6a792..8ec4e991a7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgStatusBolusExtended_v2.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgStatusBolusExtended_v2.java @@ -8,17 +8,17 @@ import org.slf4j.LoggerFactory; import java.util.Date; import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.MainApp; -import info.nightscout.androidaps.db.ExtendedBolus; -import info.nightscout.androidaps.interfaces.TreatmentsInterface; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; public class MsgStatusBolusExtended_v2 extends MessageBase { - private static Logger log = LoggerFactory.getLogger(MsgStatusBolusExtended_v2.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public MsgStatusBolusExtended_v2() { SetCommand(0x0207); + if (Config.logPumpComm) + log.debug("New message"); } public void handleMessage(byte[] bytes) { @@ -46,7 +46,7 @@ public class MsgStatusBolusExtended_v2 extends MessageBase { pump.extendedBolusStart = extendedBolusStart; pump.extendedBolusRemainingMinutes = extendedBolusRemainingMinutes; - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Is extended bolus running: " + isExtendedInProgress); log.debug("Extended bolus min: " + extendedBolusMinutes); log.debug("Extended bolus amount: " + extendedBolusAmount); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgStatusTempBasal_v2.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgStatusTempBasal_v2.java index 256fa4cd8a..2ece5ab47e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgStatusTempBasal_v2.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgStatusTempBasal_v2.java @@ -8,17 +8,17 @@ import org.slf4j.LoggerFactory; import java.util.Date; import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.MainApp; -import info.nightscout.androidaps.db.TemporaryBasal; -import info.nightscout.androidaps.interfaces.TreatmentsInterface; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; public class MsgStatusTempBasal_v2 extends MessageBase { - private static Logger log = LoggerFactory.getLogger(MsgStatusTempBasal_v2.class); + private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); public MsgStatusTempBasal_v2() { SetCommand(0x0205); + if (Config.logPumpComm) + log.debug("New message"); } public void handleMessage(byte[] bytes) { @@ -41,7 +41,7 @@ public class MsgStatusTempBasal_v2 extends MessageBase { pump.tempBasalTotalSec = tempBasalTotalSec; pump.tempBasalStart = tempBasalStart; - if (Config.logDanaMessageDetail) { + if (Config.logPumpComm) { log.debug("Is temp basal running: " + isTempBasalInProgress); log.debug("Is APS temp basal running: " + isAPSTempBasalInProgress); log.debug("Current temp basal percent: " + tempBasalPercent); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java index 1229f23f4e..770af49e75 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java @@ -8,8 +8,6 @@ import android.os.SystemClock; import com.squareup.otto.Subscribe; -import org.slf4j.LoggerFactory; - import java.io.IOException; import java.util.Date; @@ -81,7 +79,6 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { private long lastHistoryFetched = 0; public DanaRv2ExecutionService() { - log = LoggerFactory.getLogger(DanaRv2ExecutionService.class); mBinder = new LocalBinder(); registerBus(); @@ -105,7 +102,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { @Subscribe public void onStatusEvent(EventAppExit event) { - if (Config.logFunctionCalls) + if (Config.logPump) log.debug("EventAppExit received"); if (mSerialIOThread != null) @@ -114,7 +111,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { MainApp.instance().getApplicationContext().unregisterReceiver(receiver); stopSelf(); - if (Config.logFunctionCalls) + if (Config.logPump) log.debug("EventAppExit finished"); } @@ -126,7 +123,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { public void connect() { if (mDanaRPump.password != -1 && mDanaRPump.password != SP.getInt(R.string.key_danar_password, -1)) { - if(System.currentTimeMillis() > lastWrongPumpPassword + 30 * 1000) { + if (System.currentTimeMillis() > lastWrongPumpPassword + 30 * 1000) { Notification notification = new Notification(Notification.WRONG_PUMP_PASSWORD, MainApp.gs(R.string.wrongpumppassword), Notification.URGENT); notification.soundId = R.raw.error; lastWrongPumpPassword = System.currentTimeMillis(); @@ -208,10 +205,12 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime))); mSerialIOThread.sendMessage(new MsgSettingPumpTime()); long timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L; - log.debug("Pump time difference: " + timeDiff + " seconds"); + if (Config.logPump) + log.debug("Pump time difference: " + timeDiff + " seconds"); if (Math.abs(timeDiff) > 3) { - if (Math.abs(timeDiff) > 60*60*1.5) { - log.debug("Pump time difference: " + timeDiff + " seconds - large difference"); + if (Math.abs(timeDiff) > 60 * 60 * 1.5) { + if (Config.logPump) + log.debug("Pump time difference: " + timeDiff + " seconds - large difference"); //If time-diff is very large, warn user until we can synchronize history readings properly Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class); i.putExtra("soundid", R.raw.error); @@ -231,7 +230,8 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { mSerialIOThread.sendMessage(new MsgSetTime(new Date(DateUtil.now() + T.secs(10).msecs()))); mSerialIOThread.sendMessage(new MsgSettingPumpTime()); timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L; - log.debug("Pump time difference: " + timeDiff + " seconds"); + if (Config.logPump) + log.debug("Pump time difference: " + timeDiff + " seconds"); } } @@ -258,8 +258,9 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { MainApp.bus().post(new EventInitializationChanged()); NSUpload.uploadDeviceStatus(); if (mDanaRPump.dailyTotalUnits > mDanaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) { - log.debug("Approaching daily limit: " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits); - if(System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) { + if (Config.logPump) + log.debug("Approaching daily limit: " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits); + if (System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) { Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.gs(R.string.approachingdailylimit), Notification.URGENT); MainApp.bus().post(new EventNewNotification(reportFail)); NSUpload.uploadError(MainApp.gs(R.string.approachingdailylimit) + ": " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits + "U"); @@ -315,7 +316,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { SystemClock.sleep(500); } MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.settingtempbasal))); - mSerialIOThread.sendMessage(new MsgSetAPSTempBasalStart_v2(percent, durationInMinutes == 15, durationInMinutes == 30)); + mSerialIOThread.sendMessage(new MsgSetAPSTempBasalStart_v2(percent, durationInMinutes == 15, durationInMinutes == 30)); mSerialIOThread.sendMessage(new MsgStatusTempBasal_v2()); loadEvents(); MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING)); @@ -389,7 +390,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { if ((System.currentTimeMillis() - progress.lastReceive) > 15 * 1000L) { // if i didn't receive status for more than 15 sec expecting broken comm stop.stopped = true; stop.forced = true; - log.debug("Communication stopped"); + log.error("Communication stopped"); } } } @@ -434,7 +435,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { } public void bolusStop() { - if (Config.logDanaBTComm) + if (Config.logPump) log.debug("bolusStop >>>>> @ " + (mBolusingTreatment == null ? "" : mBolusingTreatment.insulin)); MsgBolusStop stop = new MsgBolusStop(); stop.forced = true; @@ -461,23 +462,25 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { public PumpEnactResult loadEvents() { - if(!MainApp.getSpecificPlugin(DanaRv2Plugin.class).isInitialized()){ + if (!MainApp.getSpecificPlugin(DanaRv2Plugin.class).isInitialized()) { PumpEnactResult result = new PumpEnactResult().success(false); result.comment = "pump not initialized"; return result; } - - + + if (!isConnected()) return new PumpEnactResult().success(false); SystemClock.sleep(300); MsgHistoryEvents_v2 msg; if (lastHistoryFetched == 0) { msg = new MsgHistoryEvents_v2(); - log.debug("Loading complete event history"); + if (Config.logPump) + log.debug("Loading complete event history"); } else { msg = new MsgHistoryEvents_v2(lastHistoryFetched); - log.debug("Loading event history from: " + new Date(lastHistoryFetched).toLocaleString()); + if (Config.logPump) + log.debug("Loading event history from: " + new Date(lastHistoryFetched).toLocaleString()); } mSerialIOThread.sendMessage(msg); while (!msg.done && mRfcommSocket.isConnected()) { @@ -495,7 +498,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { public boolean updateBasalsInPump(final Profile profile) { if (!isConnected()) return false; MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.updatingbasalrates))); - double[] basal = DanaRPump.buildDanaRProfileRecord(profile); + double[] basal = DanaRPump.getInstance().buildDanaRProfileRecord(profile); MsgSetBasalProfile msgSet = new MsgSetBasalProfile((byte) 0, basal); mSerialIOThread.sendMessage(msgSet); MsgSetActivateBasalProfile msgActivate = new MsgSetActivateBasalProfile((byte) 0); @@ -512,7 +515,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { long timeToWholeMinute = (60000 - time % 60000); if (timeToWholeMinute > 59800 || timeToWholeMinute < 3000) break; - MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.waitingfortimesynchronization, (int)(timeToWholeMinute / 1000)))); + MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.waitingfortimesynchronization, (int) (timeToWholeMinute / 1000)))); SystemClock.sleep(Math.min(timeToWholeMinute, 100)); } } diff --git a/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java b/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java index 07ef303dbf..96f550128d 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java @@ -77,10 +77,10 @@ import info.nightscout.androidaps.queue.commands.CommandTempBasalPercent; */ public class CommandQueue { - private Logger log = LoggerFactory.getLogger(Constants.QUEUE); + private Logger log = LoggerFactory.getLogger(Constants.PUMPQUEUE); private final LinkedList queue = new LinkedList<>(); - protected Command performing; + Command performing; private QueueThread thread = null; diff --git a/app/src/main/java/info/nightscout/androidaps/queue/QueueThread.java b/app/src/main/java/info/nightscout/androidaps/queue/QueueThread.java index 3073ecb950..252c537b9b 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/QueueThread.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/QueueThread.java @@ -12,13 +12,10 @@ import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; -import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.Overview.events.EventDismissBolusprogressIfRunning; -import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; -import info.nightscout.androidaps.plugins.Overview.notifications.Notification; import info.nightscout.androidaps.queue.events.EventQueueChanged; import info.nightscout.utils.SP; @@ -27,7 +24,7 @@ import info.nightscout.utils.SP; */ public class QueueThread extends Thread { - private Logger log = LoggerFactory.getLogger(Constants.QUEUE); + private Logger log = LoggerFactory.getLogger(Constants.PUMPQUEUE); private CommandQueue queue; diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/Command.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/Command.java index 13208fb9f1..e21fb3f276 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/Command.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/Command.java @@ -14,7 +14,7 @@ import info.nightscout.androidaps.queue.Callback; * Created by mike on 09.11.2017. */ public abstract class Command { - private Logger log = LoggerFactory.getLogger(Constants.QUEUE); + private Logger log = LoggerFactory.getLogger(Constants.PUMPQUEUE); public enum CommandType { BOLUS, diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandBolus.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandBolus.java index c0c2090177..89ebfb88b4 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandBolus.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandBolus.java @@ -19,9 +19,9 @@ import info.nightscout.utils.DecimalFormatter; */ public class CommandBolus extends Command { - private Logger log = LoggerFactory.getLogger(Constants.QUEUE); + private Logger log = LoggerFactory.getLogger(Constants.PUMPQUEUE); - DetailedBolusInfo detailedBolusInfo; + private DetailedBolusInfo detailedBolusInfo; public CommandBolus(DetailedBolusInfo detailedBolusInfo, Callback callback, CommandType type) { commandType = type; diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandCancelExtendedBolus.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandCancelExtendedBolus.java index e5d69e2b6d..5874e56585 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandCancelExtendedBolus.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandCancelExtendedBolus.java @@ -14,7 +14,7 @@ import info.nightscout.androidaps.queue.Callback; */ public class CommandCancelExtendedBolus extends Command { - private Logger log = LoggerFactory.getLogger(Constants.QUEUE); + private Logger log = LoggerFactory.getLogger(Constants.PUMPQUEUE); public CommandCancelExtendedBolus(Callback callback) { commandType = CommandType.EXTENDEDBOLUS; diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandCancelTempBasal.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandCancelTempBasal.java index a79df63569..0394e3a40a 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandCancelTempBasal.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandCancelTempBasal.java @@ -14,9 +14,9 @@ import info.nightscout.androidaps.queue.Callback; */ public class CommandCancelTempBasal extends Command { - private Logger log = LoggerFactory.getLogger(Constants.QUEUE); + private Logger log = LoggerFactory.getLogger(Constants.PUMPQUEUE); - boolean enforceNew; + private boolean enforceNew; public CommandCancelTempBasal(boolean enforceNew, Callback callback) { commandType = CommandType.TEMPBASAL; diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandExtendedBolus.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandExtendedBolus.java index b3470e6e48..25c73f24f5 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandExtendedBolus.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandExtendedBolus.java @@ -14,7 +14,7 @@ import info.nightscout.androidaps.queue.Callback; */ public class CommandExtendedBolus extends Command { - private Logger log = LoggerFactory.getLogger(Constants.QUEUE); + private Logger log = LoggerFactory.getLogger(Constants.PUMPQUEUE); private double insulin; private int durationInMinutes; diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadEvents.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadEvents.java index da307b0c21..6a0abe712b 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadEvents.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadEvents.java @@ -16,7 +16,7 @@ import info.nightscout.androidaps.queue.Callback; */ public class CommandLoadEvents extends Command { - private Logger log = LoggerFactory.getLogger(Constants.QUEUE); + private Logger log = LoggerFactory.getLogger(Constants.PUMPQUEUE); public CommandLoadEvents(Callback callback) { commandType = CommandType.LOADEVENTS; diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadHistory.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadHistory.java index 065e194ef0..0dcff6bffe 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadHistory.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadHistory.java @@ -16,9 +16,9 @@ import info.nightscout.androidaps.queue.Callback; */ public class CommandLoadHistory extends Command { - private Logger log = LoggerFactory.getLogger(Constants.QUEUE); + private Logger log = LoggerFactory.getLogger(Constants.PUMPQUEUE); - byte type; + private byte type; public CommandLoadHistory(byte type, Callback callback) { commandType = CommandType.LOADHISTORY; diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadTDDs.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadTDDs.java index 77a74369f2..0c419c332e 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadTDDs.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadTDDs.java @@ -15,7 +15,7 @@ import info.nightscout.androidaps.queue.Callback; */ public class CommandLoadTDDs extends Command { - private Logger log = LoggerFactory.getLogger(Constants.QUEUE); + private Logger log = LoggerFactory.getLogger(Constants.PUMPQUEUE); public CommandLoadTDDs(Callback callback) { diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandReadStatus.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandReadStatus.java index 78e4f3cdf1..3e4ccd58f3 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandReadStatus.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandReadStatus.java @@ -14,9 +14,9 @@ import info.nightscout.utils.LocalAlertUtils; */ public class CommandReadStatus extends Command { - private Logger log = LoggerFactory.getLogger(Constants.QUEUE); + private Logger log = LoggerFactory.getLogger(Constants.PUMPQUEUE); - String reason; + private String reason; public CommandReadStatus(String reason, Callback callback) { commandType = CommandType.READSTATUS; diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSMBBolus.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSMBBolus.java index c4e613e04b..2cadda3a44 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSMBBolus.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSMBBolus.java @@ -5,12 +5,9 @@ import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Constants; -import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.data.DetailedBolusInfo; import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; -import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressDialog; -import info.nightscout.androidaps.plugins.Overview.events.EventDismissBolusprogressIfRunning; import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin; import info.nightscout.androidaps.queue.Callback; import info.nightscout.utils.DateUtil; @@ -22,9 +19,9 @@ import info.nightscout.utils.T; */ public class CommandSMBBolus extends Command { - private Logger log = LoggerFactory.getLogger(Constants.QUEUE); + private Logger log = LoggerFactory.getLogger(Constants.PUMPQUEUE); - DetailedBolusInfo detailedBolusInfo; + private DetailedBolusInfo detailedBolusInfo; public CommandSMBBolus(DetailedBolusInfo detailedBolusInfo, Callback callback) { commandType = CommandType.SMB_BOLUS; diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetProfile.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetProfile.java index 3fa375cfac..20c406e59e 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetProfile.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetProfile.java @@ -22,7 +22,7 @@ import info.nightscout.androidaps.queue.Callback; */ public class CommandSetProfile extends Command { - private Logger log = LoggerFactory.getLogger(Constants.QUEUE); + private Logger log = LoggerFactory.getLogger(Constants.PUMPQUEUE); private Profile profile; diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetUserSettings.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetUserSettings.java index 59f0fe3ba9..af358604bc 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetUserSettings.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetUserSettings.java @@ -16,7 +16,7 @@ import info.nightscout.androidaps.queue.Callback; */ public class CommandSetUserSettings extends Command { - private Logger log = LoggerFactory.getLogger(Constants.QUEUE); + private Logger log = LoggerFactory.getLogger(Constants.PUMPQUEUE); public CommandSetUserSettings(Callback callback) { commandType = CommandType.SETUSERSETTINGS; diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandTempBasalAbsolute.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandTempBasalAbsolute.java index 6e1a174364..1ed0737bc0 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandTempBasalAbsolute.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandTempBasalAbsolute.java @@ -5,7 +5,6 @@ import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Constants; -import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; @@ -16,12 +15,12 @@ import info.nightscout.androidaps.queue.Callback; */ public class CommandTempBasalAbsolute extends Command { - private Logger log = LoggerFactory.getLogger(Constants.QUEUE); + private Logger log = LoggerFactory.getLogger(Constants.PUMPQUEUE); - int durationInMinutes; - double absoluteRate; - boolean enforceNew; - Profile profile; + private int durationInMinutes; + private double absoluteRate; + private boolean enforceNew; + private Profile profile; public CommandTempBasalAbsolute(double absoluteRate, int durationInMinutes, boolean enforceNew, Profile profile, Callback callback) { commandType = CommandType.TEMPBASAL; diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandTempBasalPercent.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandTempBasalPercent.java index 8b210de2c4..8aaaf91d52 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandTempBasalPercent.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandTempBasalPercent.java @@ -15,12 +15,12 @@ import info.nightscout.androidaps.queue.Callback; */ public class CommandTempBasalPercent extends Command { - private Logger log = LoggerFactory.getLogger(Constants.QUEUE); + private Logger log = LoggerFactory.getLogger(Constants.PUMPQUEUE); - int durationInMinutes; - int percent; - boolean enforceNew; - Profile profile; + private int durationInMinutes; + private int percent; + private boolean enforceNew; + private Profile profile; public CommandTempBasalPercent(int percent, int durationInMinutes, boolean enforceNew, Profile profile, Callback callback) { commandType = CommandType.TEMPBASAL;