PUMP logging

This commit is contained in:
Milos Kozak 2018-07-28 23:38:39 +02:00
parent 8a66b4db2e
commit 6e902cb9ca
181 changed files with 1819 additions and 1261 deletions

View file

@ -27,11 +27,9 @@ public class Config {
public static final boolean logFunctionCalls = true; public static final boolean logFunctionCalls = true;
public static final boolean logIncommingData = true; public static final boolean logIncommingData = true;
public static final boolean logAPSResult = true; public static final boolean logAPSResult = true;
public static final boolean logPumpComm = true;
public static final boolean logPrefsChange = true; public static final boolean logPrefsChange = true;
public static final boolean logConfigBuilder = true; public static final boolean logConfigBuilder = true;
public static final boolean logNSUpload = true; public static final boolean logNSUpload = true;
public static final boolean logPumpActions = true;
public static final boolean logCongigBuilderActions = true; public static final boolean logCongigBuilderActions = true;
public static final boolean logAutosensData = false; public static final boolean logAutosensData = false;
public static final boolean logEvents = false; public static final boolean logEvents = false;
@ -45,9 +43,8 @@ public class Config {
public static final boolean logDataTreatments = true; public static final boolean logDataTreatments = true;
public static final boolean logNsclient = true; public static final boolean logNsclient = true;
public static final boolean logObjectives = false; 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;
} }

View file

@ -71,7 +71,6 @@ public class Constants {
// logging // logging
public static final String AUTOSENS = "AUTOSENS"; public static final String AUTOSENS = "AUTOSENS";
public static final String EVENTS = "EVENTS"; public static final String EVENTS = "EVENTS";
public static final String QUEUE = "QUEUE";
public static final String BGSOURCE = "BGSOURCE"; public static final String BGSOURCE = "BGSOURCE";
public static final String OVERVIEW = "OVERVIEW"; public static final String OVERVIEW = "OVERVIEW";
public static final String NOTIFICATION = "NOTIFICATION"; public static final String NOTIFICATION = "NOTIFICATION";
@ -81,4 +80,8 @@ public class Constants {
public static final String DATATREATMENTS = "DATATREATMENTS"; public static final String DATATREATMENTS = "DATATREATMENTS";
public static final String NSCLIENT = "NSCLIENT"; public static final String NSCLIENT = "NSCLIENT";
public static final String OBJECTIVES = "OBJECTIVES"; 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";
} }

View file

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

View file

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

View file

@ -5,11 +5,13 @@ import android.support.annotation.Nullable;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Date; import java.util.Date;
import info.nightscout.androidaps.BuildConfig; import info.nightscout.androidaps.BuildConfig;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.Profile;
@ -43,7 +45,7 @@ import info.nightscout.utils.SP;
*/ */
public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInterface, DanaRInterface, ConstraintsInterface, ProfileInterface { public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInterface, DanaRInterface, ConstraintsInterface, ProfileInterface {
protected Logger log; protected Logger log = LoggerFactory.getLogger(Constants.PUMP);
protected AbstractDanaRExecutionService sExecutionService; protected AbstractDanaRExecutionService sExecutionService;
@ -133,6 +135,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
Double profileValue = profile.getBasalTimeFromMidnight(h * basalIncrement); Double profileValue = profile.getBasalTimeFromMidnight(h * basalIncrement);
if (profileValue == null) return true; if (profileValue == null) return true;
if (Math.abs(pumpValue - profileValue) > getPumpDescription().basalStep) { if (Math.abs(pumpValue - profileValue) > getPumpDescription().basalStep) {
if (Config.logPump)
log.debug("Diff found. Hour: " + h + " Pump: " + pumpValue + " Profile: " + profileValue); log.debug("Diff found. Hour: " + h + " Pump: " + pumpValue + " Profile: " + profileValue);
return false; return false;
} }
@ -183,7 +186,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
result.duration = pump.tempBasalRemainingMin; result.duration = pump.tempBasalRemainingMin;
result.percent = pump.tempBasalPercent; result.percent = pump.tempBasalPercent;
result.isPercent = true; result.isPercent = true;
if (Config.logPumpActions) if (Config.logPump)
log.debug("setTempBasalPercent: Correct value already set"); log.debug("setTempBasalPercent: Correct value already set");
return result; return result;
} }
@ -197,7 +200,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
result.duration = pump.tempBasalRemainingMin; result.duration = pump.tempBasalRemainingMin;
result.percent = pump.tempBasalPercent; result.percent = pump.tempBasalPercent;
result.isPercent = true; result.isPercent = true;
if (Config.logPumpActions) if (Config.logPump)
log.debug("setTempBasalPercent: OK"); log.debug("setTempBasalPercent: OK");
return result; return result;
} }
@ -225,7 +228,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
result.absolute = pump.extendedBolusAbsoluteRate; result.absolute = pump.extendedBolusAbsoluteRate;
result.isPercent = false; result.isPercent = false;
result.isTempCancel = false; result.isTempCancel = false;
if (Config.logPumpActions) if (Config.logPump)
log.debug("setExtendedBolus: Correct extended bolus already set. Current: " + pump.extendedBolusAmount + " Asked: " + insulin); log.debug("setExtendedBolus: Correct extended bolus already set. Current: " + pump.extendedBolusAmount + " Asked: " + insulin);
return result; return result;
} }
@ -240,7 +243,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
if (!SP.getBoolean("danar_useextended", false)) if (!SP.getBoolean("danar_useextended", false))
result.bolusDelivered = pump.extendedBolusAmount; result.bolusDelivered = pump.extendedBolusAmount;
result.isPercent = false; result.isPercent = false;
if (Config.logPumpActions) if (Config.logPump)
log.debug("setExtendedBolus: OK"); log.debug("setExtendedBolus: OK");
return result; return result;
} }
@ -263,7 +266,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
if (!pump.isExtendedInProgress) { if (!pump.isExtendedInProgress) {
result.success = true; result.success = true;
result.comment = MainApp.gs(R.string.virtualpump_resultok); result.comment = MainApp.gs(R.string.virtualpump_resultok);
if (Config.logPumpActions) if (Config.logPump)
log.debug("cancelExtendedBolus: OK"); log.debug("cancelExtendedBolus: OK");
return result; return result;
} else { } else {

View file

@ -23,6 +23,8 @@ import org.slf4j.LoggerFactory;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.OnClick; import butterknife.OnClick;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.TDDStatsActivity; import info.nightscout.androidaps.TDDStatsActivity;
@ -46,7 +48,7 @@ import info.nightscout.utils.FabricPrivacy;
import info.nightscout.utils.SetWarnColor; import info.nightscout.utils.SetWarnColor;
public class DanaRFragment extends SubscriberFragment { public class DanaRFragment extends SubscriberFragment {
private static Logger log = LoggerFactory.getLogger(DanaRFragment.class); private static Logger log = LoggerFactory.getLogger(Constants.PUMP);
private Handler loopHandler = new Handler(); private Handler loopHandler = new Handler();
private Runnable refreshLoop = new Runnable() { private Runnable refreshLoop = new Runnable() {
@ -113,18 +115,12 @@ public class DanaRFragment extends SubscriberFragment {
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
try {
View view = inflater.inflate(R.layout.danar_fragment, container, false); View view = inflater.inflate(R.layout.danar_fragment, container, false);
unbinder = ButterKnife.bind(this, view); unbinder = ButterKnife.bind(this, view);
pumpStatusView.setBackgroundColor(MainApp.gc(R.color.colorInitializingBorder)); pumpStatusView.setBackgroundColor(MainApp.gc(R.color.colorInitializingBorder));
return view; return view;
} catch (Exception e) {
FabricPrivacy.logException(e);
}
return null;
} }
@OnClick(R.id.danar_history) @OnClick(R.id.danar_history)
@ -145,10 +141,13 @@ public class DanaRFragment extends SubscriberFragment {
} }
@OnClick(R.id.danar_user_options) @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) @OnClick(R.id.danar_btconnection)
void onBtConnectionClick() { void onBtConnectionClick() {
if (Config.logPump)
log.debug("Clicked connect to pump"); log.debug("Clicked connect to pump");
DanaRPump.getInstance().lastConnection = 0; DanaRPump.getInstance().lastConnection = 0;
ConfigBuilderPlugin.getCommandQueue().readStatus("Clicked connect to pump", null); ConfigBuilderPlugin.getCommandQueue().readStatus("Clicked connect to pump", null);
@ -163,9 +162,10 @@ public class DanaRFragment extends SubscriberFragment {
new Runnable() { new Runnable() {
@Override @Override
public void run() { public void run() {
synchronized(DanaRFragment.this){ synchronized (DanaRFragment.this) {
if(btConnectionView == null || pumpStatusView == null || pumpStatusLayout == null ) return; if (btConnectionView == null || pumpStatusView == null || pumpStatusLayout == null)
return;
if (c.sStatus == EventPumpStatusChanged.CONNECTING) if (c.sStatus == EventPumpStatusChanged.CONNECTING)
btConnectionView.setText("{fa-bluetooth-b spin} " + c.sSecondsElapsed + "s"); btConnectionView.setText("{fa-bluetooth-b spin} " + c.sSecondsElapsed + "s");
@ -216,7 +216,7 @@ public class DanaRFragment extends SubscriberFragment {
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
@Override @Override
public void run() { public void run() {
synchronized(DanaRFragment.this) { synchronized (DanaRFragment.this) {
if (!isBound()) return; if (!isBound()) return;
DanaRPump pump = DanaRPump.getInstance(); DanaRPump pump = DanaRPump.getInstance();

View file

@ -49,7 +49,6 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
public DanaRPlugin() { public DanaRPlugin() {
super(); super();
log = LoggerFactory.getLogger(DanaRPlugin.class);
useExtendedBoluses = SP.getBoolean("danar_useextended", false); useExtendedBoluses = SP.getBoolean("danar_useextended", false);
pumpDescription.isBolusCapable = true; pumpDescription.isBolusCapable = true;
@ -85,7 +84,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
@Override @Override
public void switchAllowed(ConfigBuilderFragment.PluginViewHolder.PluginSwitcher pluginSwitcher, FragmentActivity context) { public void switchAllowed(ConfigBuilderFragment.PluginViewHolder.PluginSwitcher pluginSwitcher, FragmentActivity context) {
boolean allowHardwarePump = SP.getBoolean("allow_hardware_pump", false); boolean allowHardwarePump = SP.getBoolean("allow_hardware_pump", false);
if (allowHardwarePump || context == null){ if (allowHardwarePump || context == null) {
pluginSwitcher.invoke(); pluginSwitcher.invoke();
} else { } else {
AlertDialog.Builder builder = new AlertDialog.Builder(context); AlertDialog.Builder builder = new AlertDialog.Builder(context);
@ -94,12 +93,14 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
pluginSwitcher.invoke(); pluginSwitcher.invoke();
SP.putBoolean("allow_hardware_pump", true); SP.putBoolean("allow_hardware_pump", true);
if (Config.logPump)
log.debug("First time HW pump allowed!"); log.debug("First time HW pump allowed!");
} }
}) })
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
pluginSwitcher.cancel(); pluginSwitcher.cancel();
if (Config.logPump)
log.debug("User does not allow switching to HW pump!"); log.debug("User does not allow switching to HW pump!");
} }
}); });
@ -127,11 +128,13 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
private ServiceConnection mConnection = new ServiceConnection() { private ServiceConnection mConnection = new ServiceConnection() {
public void onServiceDisconnected(ComponentName name) { public void onServiceDisconnected(ComponentName name) {
if (Config.logPump)
log.debug("Service is disconnected"); log.debug("Service is disconnected");
sExecutionService = null; sExecutionService = null;
} }
public void onServiceConnected(ComponentName name, IBinder service) { public void onServiceConnected(ComponentName name, IBinder service) {
if (Config.logPump)
log.debug("Service is connected"); log.debug("Service is connected");
DanaRExecutionService.LocalBinder mLocalBinder = (DanaRExecutionService.LocalBinder) service; DanaRExecutionService.LocalBinder mLocalBinder = (DanaRExecutionService.LocalBinder) service;
sExecutionService = mLocalBinder.getServiceInstance(); sExecutionService = mLocalBinder.getServiceInstance();
@ -195,7 +198,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
result.comment = String.format(MainApp.gs(R.string.boluserrorcode), detailedBolusInfo.insulin, t.insulin, MsgBolusStartWithSpeed.errorCode); result.comment = String.format(MainApp.gs(R.string.boluserrorcode), detailedBolusInfo.insulin, t.insulin, MsgBolusStartWithSpeed.errorCode);
else else
result.comment = MainApp.gs(R.string.virtualpump_resultok); result.comment = MainApp.gs(R.string.virtualpump_resultok);
if (Config.logPumpActions) if (Config.logPump)
log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered); log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered);
detailedBolusInfo.insulin = t.insulin; detailedBolusInfo.insulin = t.insulin;
detailedBolusInfo.date = System.currentTimeMillis(); detailedBolusInfo.date = System.currentTimeMillis();
@ -237,13 +240,13 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
if (doTempOff) { if (doTempOff) {
// If extended in progress // If extended in progress
if (activeExtended != null && useExtendedBoluses) { if (activeExtended != null && useExtendedBoluses) {
if (Config.logPumpActions) if (Config.logPump)
log.debug("setTempBasalAbsolute: Stopping extended bolus (doTempOff)"); log.debug("setTempBasalAbsolute: Stopping extended bolus (doTempOff)");
return cancelExtendedBolus(); return cancelExtendedBolus();
} }
// If temp in progress // If temp in progress
if (activeTemp != null) { if (activeTemp != null) {
if (Config.logPumpActions) if (Config.logPump)
log.debug("setTempBasalAbsolute: Stopping temp basal (doTempOff)"); log.debug("setTempBasalAbsolute: Stopping temp basal (doTempOff)");
return cancelRealTempBasal(); return cancelRealTempBasal();
} }
@ -252,7 +255,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
result.percent = 100; result.percent = 100;
result.isPercent = true; result.isPercent = true;
result.isTempCancel = true; result.isTempCancel = true;
if (Config.logPumpActions) if (Config.logPump)
log.debug("setTempBasalAbsolute: doTempOff OK"); log.debug("setTempBasalAbsolute: doTempOff OK");
return result; return result;
} }
@ -264,12 +267,12 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
if (percentRate > getPumpDescription().maxTempPercent) { if (percentRate > getPumpDescription().maxTempPercent) {
percentRate = getPumpDescription().maxTempPercent; percentRate = getPumpDescription().maxTempPercent;
} }
if (Config.logPumpActions) if (Config.logPump)
log.debug("setTempBasalAbsolute: Calculated percent rate: " + percentRate); log.debug("setTempBasalAbsolute: Calculated percent rate: " + percentRate);
// If extended in progress // If extended in progress
if (activeExtended != null && useExtendedBoluses) { if (activeExtended != null && useExtendedBoluses) {
if (Config.logPumpActions) if (Config.logPump)
log.debug("setTempBasalAbsolute: Stopping extended bolus (doLowTemp || doHighTemp)"); log.debug("setTempBasalAbsolute: Stopping extended bolus (doLowTemp || doHighTemp)");
result = cancelExtendedBolus(); result = cancelExtendedBolus();
if (!result.success) { if (!result.success) {
@ -280,7 +283,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
// Check if some temp is already in progress // Check if some temp is already in progress
if (activeTemp != null) { if (activeTemp != null) {
// Correct basal already set ? // Correct basal already set ?
if (Config.logPumpActions) if (Config.logPump)
log.debug("setTempBasalAbsolute: currently running: " + activeTemp.toString()); log.debug("setTempBasalAbsolute: currently running: " + activeTemp.toString());
if (activeTemp.percentRate == percentRate) { if (activeTemp.percentRate == percentRate) {
if (enforceNew) { if (enforceNew) {
@ -292,21 +295,21 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
result.duration = activeTemp.getPlannedRemainingMinutes(); result.duration = activeTemp.getPlannedRemainingMinutes();
result.isPercent = true; result.isPercent = true;
result.isTempCancel = false; result.isTempCancel = false;
if (Config.logPumpActions) if (Config.logPump)
log.debug("setTempBasalAbsolute: Correct temp basal already set (doLowTemp || doHighTemp)"); log.debug("setTempBasalAbsolute: Correct temp basal already set (doLowTemp || doHighTemp)");
return result; return result;
} }
} }
} }
// Convert duration from minutes to hours // Convert duration from minutes to hours
if (Config.logPumpActions) if (Config.logPump)
log.debug("setTempBasalAbsolute: Setting temp basal " + percentRate + "% for " + durationInMinutes + " mins (doLowTemp || doHighTemp)"); log.debug("setTempBasalAbsolute: Setting temp basal " + percentRate + "% for " + durationInMinutes + " mins (doLowTemp || doHighTemp)");
return setTempBasalPercent(percentRate, durationInMinutes, profile, false); return setTempBasalPercent(percentRate, durationInMinutes, profile, false);
} }
if (doExtendedTemp) { if (doExtendedTemp) {
// Check if some temp is already in progress // Check if some temp is already in progress
if (activeTemp != null) { if (activeTemp != null) {
if (Config.logPumpActions) if (Config.logPump)
log.debug("setTempBasalAbsolute: Stopping temp basal (doExtendedTemp)"); log.debug("setTempBasalAbsolute: Stopping temp basal (doExtendedTemp)");
result = cancelRealTempBasal(); result = cancelRealTempBasal();
// Check for proper result // Check for proper result
@ -325,7 +328,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
extendedRateToSet = Round.roundTo(extendedRateToSet, pumpDescription.extendedBolusStep * 2); // *2 because of halfhours extendedRateToSet = Round.roundTo(extendedRateToSet, pumpDescription.extendedBolusStep * 2); // *2 because of halfhours
// What is current rate of extended bolusing in u/h? // What is current rate of extended bolusing in u/h?
if (Config.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: Extended bolus in progress: " + (activeExtended != null) + " rate: " + pump.extendedBolusAbsoluteRate + "U/h duration remaining: " + pump.extendedBolusRemainingMinutes + "min");
log.debug("setTempBasalAbsolute: Rate to set: " + extendedRateToSet + "U/h"); log.debug("setTempBasalAbsolute: Rate to set: " + extendedRateToSet + "U/h");
} }
@ -339,21 +342,21 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
result.duration = pump.extendedBolusRemainingMinutes; result.duration = pump.extendedBolusRemainingMinutes;
result.isPercent = false; result.isPercent = false;
result.isTempCancel = false; result.isTempCancel = false;
if (Config.logPumpActions) if (Config.logPump)
log.debug("setTempBasalAbsolute: Correct extended already set"); log.debug("setTempBasalAbsolute: Correct extended already set");
return result; return result;
} }
// Now set new extended, no need to to stop previous (if running) because it's replaced // Now set new extended, no need to to stop previous (if running) because it's replaced
Double extendedAmount = extendedRateToSet / 2 * durationInHalfHours; Double extendedAmount = extendedRateToSet / 2 * durationInHalfHours;
if (Config.logPumpActions) if (Config.logPump)
log.debug("setTempBasalAbsolute: Setting extended: " + extendedAmount + "U halfhours: " + durationInHalfHours); log.debug("setTempBasalAbsolute: Setting extended: " + extendedAmount + "U halfhours: " + durationInHalfHours);
result = setExtendedBolus(extendedAmount, durationInMinutes); result = setExtendedBolus(extendedAmount, durationInMinutes);
if (!result.success) { if (!result.success) {
log.error("setTempBasalAbsolute: Failed to set extended bolus"); log.error("setTempBasalAbsolute: Failed to set extended bolus");
return result; return result;
} }
if (Config.logPumpActions) if (Config.logPump)
log.debug("setTempBasalAbsolute: Extended bolus set ok"); log.debug("setTempBasalAbsolute: Extended bolus set ok");
result.absolute = result.absolute + getBaseBasalRate(); result.absolute = result.absolute + getBaseBasalRate();
return result; return result;
@ -392,7 +395,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
result.success = true; result.success = true;
result.isTempCancel = true; result.isTempCancel = true;
result.comment = MainApp.gs(R.string.virtualpump_resultok); result.comment = MainApp.gs(R.string.virtualpump_resultok);
if (Config.logPumpActions) if (Config.logPump)
log.debug("cancelRealTempBasal: OK"); log.debug("cancelRealTempBasal: OK");
return result; return result;
} else { } else {

View file

@ -20,7 +20,7 @@ import info.nightscout.utils.SP;
* Created by mike on 04.07.2016. * Created by mike on 04.07.2016.
*/ */
public class DanaRPump { public class DanaRPump {
private static Logger log = LoggerFactory.getLogger(DanaRPump.class); private Logger log = LoggerFactory.getLogger(Constants.PUMP);
private static DanaRPump instance = null; private static DanaRPump instance = null;
@ -236,13 +236,13 @@ public class DanaRPump {
return PROFILE_PREFIX + (activeProfile + 1); return PROFILE_PREFIX + (activeProfile + 1);
} }
public static double[] buildDanaRProfileRecord(Profile nsProfile) { public double[] buildDanaRProfileRecord(Profile nsProfile) {
double[] record = new double[24]; double[] record = new double[24];
for (Integer hour = 0; hour < 24; hour++) { for (Integer hour = 0; hour < 24; hour++) {
//Some values get truncated to the next lower one. //Some values get truncated to the next lower one.
// -> round them to two decimals and make sure we are a small delta larger (that will get truncated) // -> round them to two decimals and make sure we are a small delta larger (that will get truncated)
double value = Math.round(100d * nsProfile.getBasalTimeFromMidnight((Integer) (hour * 60 * 60)))/100d + 0.00001; double value = Math.round(100d * nsProfile.getBasalTimeFromMidnight((Integer) (hour * 60 * 60)))/100d + 0.00001;
if (Config.logDanaMessageDetail) if (Config.logPump)
log.debug("NS basal value for " + hour + ":00 is " + value); log.debug("NS basal value for " + hour + ":00 is " + value);
record[hour] = value; record[hour] = value;
} }

View file

@ -33,8 +33,6 @@ import info.nightscout.utils.DecimalFormatter;
* Created by mike on 10.07.2016. * Created by mike on 10.07.2016.
*/ */
public class ProfileViewDialog extends DialogFragment { public class ProfileViewDialog extends DialogFragment {
private static Logger log = LoggerFactory.getLogger(ProfileViewDialog.class);
private TextView noProfile; private TextView noProfile;
private TextView units; private TextView units;
private TextView dia; private TextView dia;

View file

@ -11,6 +11,7 @@ import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import info.nightscout.androidaps.Config; 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.MessageBase;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageHashTable; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageHashTable;
import info.nightscout.androidaps.plugins.PumpDanaR.services.AbstractSerialIOThread; import info.nightscout.androidaps.plugins.PumpDanaR.services.AbstractSerialIOThread;
@ -20,7 +21,7 @@ import info.nightscout.utils.CRC;
* Created by mike on 17.07.2016. * Created by mike on 17.07.2016.
*/ */
public class SerialIOThread extends AbstractSerialIOThread { public class SerialIOThread extends AbstractSerialIOThread {
private static Logger log = LoggerFactory.getLogger(SerialIOThread.class); private static Logger log = LoggerFactory.getLogger(Constants.PUMPBTCOMM);
private InputStream mInputStream = null; private InputStream mInputStream = null;
private OutputStream mOutputStream = null; private OutputStream mOutputStream = null;
@ -71,7 +72,7 @@ public class SerialIOThread extends AbstractSerialIOThread {
message = MessageHashTable.findMessage(command); message = MessageHashTable.findMessage(command);
} }
if (Config.logDanaMessageDetail) if (Config.logPumpBtComm)
log.debug("<<<<< " + message.getMessageName() + " " + message.toHexString(extractedBuff)); log.debug("<<<<< " + message.getMessageName() + " " + message.toHexString(extractedBuff));
// process the message content // process the message content
@ -83,7 +84,7 @@ public class SerialIOThread extends AbstractSerialIOThread {
} }
} }
} catch (Exception e) { } 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); log.error("Thread exception: ", e);
mKeepRunning = false; mKeepRunning = false;
} }
@ -147,7 +148,7 @@ public class SerialIOThread extends AbstractSerialIOThread {
processedMessage = message; processedMessage = message;
byte[] messageBytes = message.getRawMessageBytes(); byte[] messageBytes = message.getRawMessageBytes();
if (Config.logDanaSerialEngine) if (Config.logPumpBtComm)
log.debug(">>>>> " + message.getMessageName() + " " + message.toHexString(messageBytes)); log.debug(">>>>> " + message.getMessageName() + " " + message.toHexString(messageBytes));
try { try {
@ -169,6 +170,7 @@ public class SerialIOThread extends AbstractSerialIOThread {
log.warn("Reply not received " + message.getMessageName()); log.warn("Reply not received " + message.getMessageName());
if (message.getCommand() == 0xF0F1) { if (message.getCommand() == 0xF0F1) {
DanaRPump.getInstance().isNewPump = false; DanaRPump.getInstance().isNewPump = false;
if (Config.logPumpComm)
log.debug("Old firmware detected"); log.debug("Old firmware detected");
} }
} }
@ -180,24 +182,29 @@ public class SerialIOThread extends AbstractSerialIOThread {
try { try {
mInputStream.close(); mInputStream.close();
} catch (Exception e) { } catch (Exception e) {
if (Config.logDanaSerialEngine) log.debug(e.getMessage()); if (Config.logPumpBtComm)
log.debug(e.getMessage());
} }
try { try {
mOutputStream.close(); mOutputStream.close();
} catch (Exception e) { } catch (Exception e) {
if (Config.logDanaSerialEngine) log.debug(e.getMessage()); if (Config.logPumpBtComm)
log.debug(e.getMessage());
} }
try { try {
mRfCommSocket.close(); mRfCommSocket.close();
} catch (Exception e) { } catch (Exception e) {
if (Config.logDanaSerialEngine) log.debug(e.getMessage()); if (Config.logPumpBtComm)
log.debug(e.getMessage());
} }
try { try {
System.runFinalization(); System.runFinalization();
} catch (Exception e) { } 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);
} }
} }

View file

@ -24,6 +24,7 @@ import org.slf4j.LoggerFactory;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
@ -42,12 +43,9 @@ import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.ToastUtils; import info.nightscout.utils.ToastUtils;
public class DanaRHistoryActivity extends Activity { public class DanaRHistoryActivity extends Activity {
private static Logger log = LoggerFactory.getLogger(DanaRHistoryActivity.class); private static Logger log = LoggerFactory.getLogger(Constants.PUMP);
private boolean mBounded;
private Handler mHandler; private Handler mHandler;
private static HandlerThread mHandlerThread;
static Profile profile = null; static Profile profile = null;
@ -65,7 +63,7 @@ public class DanaRHistoryActivity extends Activity {
public byte type; public byte type;
String name; String name;
public TypeList(byte type, String name) { TypeList(byte type, String name) {
this.type = type; this.type = type;
this.name = name; this.name = name;
} }
@ -78,7 +76,7 @@ public class DanaRHistoryActivity extends Activity {
public DanaRHistoryActivity() { public DanaRHistoryActivity() {
super(); super();
mHandlerThread = new HandlerThread(DanaRHistoryActivity.class.getSimpleName()); HandlerThread mHandlerThread = new HandlerThread(DanaRHistoryActivity.class.getSimpleName());
mHandlerThread.start(); mHandlerThread.start();
this.mHandler = new Handler(mHandlerThread.getLooper()); this.mHandler = new Handler(mHandlerThread.getLooper());
} }
@ -116,8 +114,8 @@ public class DanaRHistoryActivity extends Activity {
statusView.setVisibility(View.GONE); statusView.setVisibility(View.GONE);
boolean isKorean = MainApp.getSpecificPlugin(DanaRKoreanPlugin.class) != null && MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).isEnabled(PluginType.PUMP); boolean isKorean = DanaRKoreanPlugin.getPlugin().isEnabled(PluginType.PUMP);
boolean isRS = MainApp.getSpecificPlugin(DanaRSPlugin.class) != null && MainApp.getSpecificPlugin(DanaRSPlugin.class).isEnabled(PluginType.PUMP); boolean isRS = DanaRSPlugin.getPlugin().isEnabled(PluginType.PUMP);
// Types // Types
@ -141,40 +139,28 @@ public class DanaRHistoryActivity extends Activity {
R.layout.spinner_centered, typeList); R.layout.spinner_centered, typeList);
historyTypeSpinner.setAdapter(spinnerAdapter); historyTypeSpinner.setAdapter(spinnerAdapter);
reloadButton.setOnClickListener(new View.OnClickListener() { reloadButton.setOnClickListener(v -> {
@Override
public void onClick(View v) {
final TypeList selected = (TypeList) historyTypeSpinner.getSelectedItem(); final TypeList selected = (TypeList) historyTypeSpinner.getSelectedItem();
runOnUiThread(new Runnable() { runOnUiThread(() -> {
@Override
public void run() {
reloadButton.setVisibility(View.GONE); reloadButton.setVisibility(View.GONE);
syncButton.setVisibility(View.GONE); syncButton.setVisibility(View.GONE);
statusView.setVisibility(View.VISIBLE); statusView.setVisibility(View.VISIBLE);
}
}); });
clearCardView(); clearCardView();
ConfigBuilderPlugin.getCommandQueue().loadHistory(selected.type, new Callback() { ConfigBuilderPlugin.getCommandQueue().loadHistory(selected.type, new Callback() {
@Override @Override
public void run() { public void run() {
loadDataFromDB(selected.type); loadDataFromDB(selected.type);
runOnUiThread(new Runnable() { runOnUiThread(() -> {
@Override
public void run() {
reloadButton.setVisibility(View.VISIBLE); reloadButton.setVisibility(View.VISIBLE);
syncButton.setVisibility(View.VISIBLE); syncButton.setVisibility(View.VISIBLE);
statusView.setVisibility(View.GONE); statusView.setVisibility(View.GONE);
}
}); });
} }
}); });
}
}); });
syncButton.setOnClickListener(new View.OnClickListener() { syncButton.setOnClickListener(v -> mHandler.post(new Runnable() {
@Override
public void onClick(View v) {
mHandler.post(new Runnable() {
@Override @Override
public void run() { public void run() {
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@ -196,9 +182,7 @@ public class DanaRHistoryActivity extends Activity {
} }
}); });
} }
}); }));
}
});
historyTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { historyTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override @Override
@ -324,7 +308,7 @@ public class DanaRHistoryActivity extends Activity {
super.onAttachedToRecyclerView(recyclerView); super.onAttachedToRecyclerView(recyclerView);
} }
public static class HistoryViewHolder extends RecyclerView.ViewHolder { static class HistoryViewHolder extends RecyclerView.ViewHolder {
CardView cv; CardView cv;
TextView time; TextView time;
TextView value; TextView value;
@ -355,45 +339,26 @@ public class DanaRHistoryActivity extends Activity {
private void loadDataFromDB(byte type) { private void loadDataFromDB(byte type) {
historyList = MainApp.getDbHelper().getDanaRHistoryRecordsByType(type); historyList = MainApp.getDbHelper().getDanaRHistoryRecordsByType(type);
runOnUiThread(new Runnable() { runOnUiThread(() -> recyclerView.swapAdapter(new RecyclerViewAdapter(historyList), false));
@Override
public void run() {
recyclerView.swapAdapter(new RecyclerViewAdapter(historyList), false);
}
});
} }
private void clearCardView() { private void clearCardView() {
historyList = new ArrayList<>(); historyList = new ArrayList<>();
runOnUiThread(new Runnable() { runOnUiThread(() -> recyclerView.swapAdapter(new RecyclerViewAdapter(historyList), false));
@Override
public void run() {
recyclerView.swapAdapter(new RecyclerViewAdapter(historyList), false);
}
});
} }
@Subscribe @Subscribe
public void onStatusEvent(final EventDanaRSyncStatus s) { public void onStatusEvent(final EventDanaRSyncStatus s) {
if (Config.logPump)
log.debug("EventDanaRSyncStatus: " + s.message); log.debug("EventDanaRSyncStatus: " + s.message);
runOnUiThread( runOnUiThread(
new Runnable() { () -> statusView.setText(s.message));
@Override
public void run() {
statusView.setText(s.message);
}
});
} }
@Subscribe @Subscribe
public void onStatusEvent(final EventPumpStatusChanged s) { public void onStatusEvent(final EventPumpStatusChanged s) {
runOnUiThread( runOnUiThread(
new Runnable() { () -> statusView.setText(s.textStatus())
@Override
public void run() {
statusView.setText(s.textStatus());
}
}
); );
} }

View file

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

View file

@ -14,6 +14,7 @@ import org.slf4j.LoggerFactory;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
@ -30,7 +31,7 @@ import info.nightscout.utils.NumberPicker;
*/ */
public class DanaRUserOptionsActivity extends Activity { public class DanaRUserOptionsActivity extends Activity {
private static Logger log = LoggerFactory.getLogger(DanaRUserOptionsActivity.class); private static Logger log = LoggerFactory.getLogger(Constants.PUMP);
Switch timeFormat; Switch timeFormat;
Switch buttonScroll; Switch buttonScroll;
@ -85,6 +86,7 @@ public class DanaRUserOptionsActivity extends Activity {
DanaRPump pump = DanaRPump.getInstance(); DanaRPump pump = DanaRPump.getInstance();
//used for debugging //used for debugging
if (Config.logPump)
log.debug("UserOptionsLoaded:" + (System.currentTimeMillis() - pump.lastConnection) / 1000 + " s ago" log.debug("UserOptionsLoaded:" + (System.currentTimeMillis() - pump.lastConnection) / 1000 + " s ago"
+ "\ntimeDisplayType:" + pump.timeDisplayType + "\ntimeDisplayType:" + pump.timeDisplayType
+ "\nbuttonScroll:" + pump.buttonScrollOnOff + "\nbuttonScroll:" + pump.buttonScrollOnOff
@ -122,7 +124,7 @@ public class DanaRUserOptionsActivity extends Activity {
break; break;
} }
if (pump.lastSettingsRead == 0) if (pump.lastSettingsRead == 0)
log.debug("No settings loaded from pump!"); log.error("No settings loaded from pump!");
else else
setData(); setData();
} }
@ -175,13 +177,13 @@ public class DanaRUserOptionsActivity extends Activity {
// step is 5 seconds // 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) { if (screenTimeoutValue > 4 && screenTimeoutValue < 241) {
pump.lcdOnTimeSec = screenTimeoutValue; pump.lcdOnTimeSec = screenTimeoutValue;
} else { } else {
pump.lcdOnTimeSec = 5; 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) { if (backlightTimeoutValue > 0 && backlightTimeoutValue < 61) {
pump.backlightOnTimeSec = backlightTimeoutValue; pump.backlightOnTimeSec = backlightTimeoutValue;
} }

View file

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

View file

@ -9,8 +9,6 @@ import java.util.HashMap;
* Created by mike on 28.05.2016. * Created by mike on 28.05.2016.
*/ */
public class MessageHashTable { public class MessageHashTable {
private static Logger log = LoggerFactory.getLogger(MessageHashTable.class);
public static HashMap<Integer, MessageBase> messages = null; public static HashMap<Integer, MessageBase> messages = null;
static { static {

View file

@ -5,13 +5,15 @@ import org.slf4j.LoggerFactory;
import java.util.HashMap; import java.util.HashMap;
import info.nightscout.androidaps.Constants;
/** /**
* Created by mike on 28.05.2016. * Created by mike on 28.05.2016.
*/ */
public class MessageOriginalNames { public class MessageOriginalNames {
private static Logger log = LoggerFactory.getLogger(MessageOriginalNames.class); private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM);
public static HashMap<Integer, String> messageNames; private static HashMap<Integer, String> messageNames;
static { static {
messageNames = new HashMap<>(); messageNames = new HashMap<>();
@ -162,7 +164,7 @@ public class MessageOriginalNames {
if (messageNames.containsKey(command)) if (messageNames.containsKey(command))
return messageNames.get(command); return messageNames.get(command);
else { else {
log.debug("Unknown command: " + String.format("%04X", command)); log.error("Unknown command: " + String.format("%04X", command));
return "UNKNOWN_COMMAND"; return "UNKNOWN_COMMAND";
} }
} }

View file

@ -4,13 +4,14 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.Treatments.Treatment;
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress; import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
import info.nightscout.androidaps.plugins.Treatments.Treatment;
public class MsgBolusProgress extends MessageBase { 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 Treatment t;
private static double amount; private static double amount;
@ -27,6 +28,8 @@ public class MsgBolusProgress extends MessageBase {
this.amount = amount; this.amount = amount;
this.t = t; this.t = t;
lastReceive = System.currentTimeMillis(); lastReceive = System.currentTimeMillis();
if (Config.logPumpComm)
log.debug("New message: amount: " + amount + " treatment: " + t.toString());
} }
@Override @Override
@ -40,7 +43,7 @@ public class MsgBolusProgress extends MessageBase {
bolusingEvent.t = t; bolusingEvent.t = t;
bolusingEvent.percent = Math.min((int) (done / amount * 100), 100); bolusingEvent.percent = Math.min((int) (done / amount * 100), 100);
if (Config.logDanaMessageDetail) { if (Config.logPumpComm) {
log.debug("Bolus remaining: " + progress + " delivered: " + done); log.debug("Bolus remaining: " + progress + " delivered: " + done);
} }

View file

@ -4,12 +4,12 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.interfaces.Constraint; import info.nightscout.androidaps.interfaces.Constraint;
import info.nightscout.utils.HardLimits;
public class MsgBolusStart extends MessageBase { 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; public static int errorCode;
@ -25,7 +25,7 @@ public class MsgBolusStart extends MessageBase {
AddParamInt((int) (amount * 100)); AddParamInt((int) (amount * 100));
if (Config.logDanaMessageDetail) if (Config.logPumpComm)
log.debug("Bolus start : " + amount); log.debug("Bolus start : " + amount);
} }
@ -34,9 +34,10 @@ public class MsgBolusStart extends MessageBase {
errorCode = intFromBuff(bytes, 0, 1); errorCode = intFromBuff(bytes, 0, 1);
if (errorCode != 2) { if (errorCode != 2) {
failed = true; failed = true;
if (Config.logPumpComm)
log.debug("Messsage response: " + errorCode + " FAILED!!"); log.debug("Messsage response: " + errorCode + " FAILED!!");
} else { } else {
if (Config.logDanaMessageDetail) if (Config.logPumpComm)
log.debug("Messsage response: " + errorCode + " OK"); log.debug("Messsage response: " + errorCode + " OK");
} }
} }

View file

@ -4,12 +4,12 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.interfaces.Constraint; import info.nightscout.androidaps.interfaces.Constraint;
import info.nightscout.utils.HardLimits;
public class MsgBolusStartWithSpeed extends MessageBase { 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; public static int errorCode;
@ -26,7 +26,7 @@ public class MsgBolusStartWithSpeed extends MessageBase {
AddParamInt((int) (amount * 100)); AddParamInt((int) (amount * 100));
AddParamByte((byte) speed); AddParamByte((byte) speed);
if (Config.logDanaMessageDetail) if (Config.logPumpComm)
log.debug("Bolus start : " + amount + " speed: " + speed); log.debug("Bolus start : " + amount + " speed: " + speed);
} }
@ -35,9 +35,10 @@ public class MsgBolusStartWithSpeed extends MessageBase {
errorCode = intFromBuff(bytes, 0, 1); errorCode = intFromBuff(bytes, 0, 1);
if (errorCode != 2) { if (errorCode != 2) {
failed = true; failed = true;
if (Config.logPumpComm)
log.debug("Messsage response: " + errorCode + " FAILED!!"); log.debug("Messsage response: " + errorCode + " FAILED!!");
} else { } else {
if (Config.logDanaMessageDetail) if (Config.logPumpComm)
log.debug("Messsage response: " + errorCode + " OK"); log.debug("Messsage response: " + errorCode + " OK");
} }
} }

View file

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

View file

@ -4,20 +4,21 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.utils.ToastUtils;
/** /**
* Created by mike on 30.06.2016. * Created by mike on 30.06.2016.
*/ */
public class MsgCheckValue extends MessageBase { public class MsgCheckValue extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgCheckValue.class); private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM);
public MsgCheckValue() { public MsgCheckValue() {
SetCommand(0xF0F1); SetCommand(0xF0F1);
if (Config.logPumpComm)
log.debug("New message");
} }
@Override @Override
@ -25,6 +26,7 @@ public class MsgCheckValue extends MessageBase {
DanaRPump pump = DanaRPump.getInstance(); DanaRPump pump = DanaRPump.getInstance();
pump.isNewPump = true; pump.isNewPump = true;
if (Config.logPumpComm)
log.debug("New firmware confirmed"); log.debug("New firmware confirmed");
pump.model = intFromBuff(bytes, 0, 1); pump.model = intFromBuff(bytes, 0, 1);
@ -35,7 +37,7 @@ public class MsgCheckValue extends MessageBase {
log.debug("Wrong model selected"); log.debug("Wrong model selected");
} }
if (Config.logDanaMessageDetail) { if (Config.logPumpComm) {
log.debug("Model: " + String.format("%02X ", pump.model)); log.debug("Model: " + String.format("%02X ", pump.model));
log.debug("Protocol: " + String.format("%02X ", pump.protocol)); log.debug("Protocol: " + String.format("%02X ", pump.protocol));
log.debug("Product Code: " + String.format("%02X ", pump.productCode)); log.debug("Product Code: " + String.format("%02X ", pump.productCode));

View file

@ -4,16 +4,19 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress; import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
import info.nightscout.utils.NSUpload; import info.nightscout.utils.NSUpload;
public class MsgError extends MessageBase { public class MsgError extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgError.class); private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM);
public MsgError() { public MsgError() {
SetCommand(0x0601); SetCommand(0x0601);
if (Config.logPumpComm)
log.debug("New message");
} }
@Override @Override
@ -47,7 +50,7 @@ public class MsgError extends MessageBase {
bolusingEvent.status = errorString; bolusingEvent.status = errorString;
MainApp.bus().post(bolusingEvent); MainApp.bus().post(bolusingEvent);
} }
if (Config.logDanaMessageDetail) if (Config.logPumpComm)
log.debug("Error detected: " + errorString); log.debug("Error detected: " + errorString);
NSUpload.uploadError(errorString); NSUpload.uploadError(errorString);
} }

View file

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

View file

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

View file

@ -4,20 +4,23 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
public class MsgHistoryAllDone extends MessageBase { 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 static boolean received = false;
public MsgHistoryAllDone() { public MsgHistoryAllDone() {
SetCommand(0x41F1); SetCommand(0x41F1);
received = false; received = false;
if (Config.logPumpComm)
log.debug("New message");
} }
@Override @Override
public void handleMessage(byte[] bytes) { public void handleMessage(byte[] bytes) {
received = true; received = true;
if (Config.logDanaMessageDetail) if (Config.logPumpComm)
log.debug("History all done received"); log.debug("History all done received");
} }
} }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -4,13 +4,16 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
public class MsgInitConnStatusBasic extends MessageBase { public class MsgInitConnStatusBasic extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgInitConnStatusBasic.class); private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM);
public MsgInitConnStatusBasic() { public MsgInitConnStatusBasic() {
SetCommand(0x0303); SetCommand(0x0303);
if (Config.logPumpComm)
log.debug("New message");
} }
@Override @Override
@ -39,14 +42,17 @@ public class MsgInitConnStatusBasic extends MessageBase {
boolean deliveryStepBolus = (bolusConfig & DanaRPump.DELIVERY_STEP_BOLUS) != 0; boolean deliveryStepBolus = (bolusConfig & DanaRPump.DELIVERY_STEP_BOLUS) != 0;
boolean deliveryBasal = (bolusConfig & DanaRPump.DELIVERY_BASAL) != 0; boolean deliveryBasal = (bolusConfig & DanaRPump.DELIVERY_BASAL) != 0;
boolean deliveryExtBolus = (bolusConfig & DanaRPump.DELIVERY_EXT_BOLUS) != 0; boolean deliveryExtBolus = (bolusConfig & DanaRPump.DELIVERY_EXT_BOLUS) != 0;
if (Config.logPumpComm) {
log.debug("Delivery prime: " + deliveryPrime); log.debug("Delivery prime: " + deliveryPrime);
log.debug("Delivery step bolus: " + deliveryStepBolus); log.debug("Delivery step bolus: " + deliveryStepBolus);
log.debug("Delivery basal: " + deliveryBasal); log.debug("Delivery basal: " + deliveryBasal);
log.debug("Delivery ext bolus: " + deliveryExtBolus); log.debug("Delivery ext bolus: " + deliveryExtBolus);
}
} catch (Exception e) { } catch (Exception e) {
log.error("Unhadled exception", e);
} }
if (Config.logDanaMessageDetail) { if (Config.logPumpComm) {
log.debug("Pump suspended: " + pump.pumpSuspended); log.debug("Pump suspended: " + pump.pumpSuspended);
log.debug("Calculator enabled: " + pump.calculatorEnabled); log.debug("Calculator enabled: " + pump.calculatorEnabled);
log.debug("Daily total units: " + pump.dailyTotalUnits); log.debug("Daily total units: " + pump.dailyTotalUnits);

View file

@ -4,21 +4,24 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.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.EventDismissNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
/** /**
* Created by mike on 28.05.2016. * Created by mike on 28.05.2016.
*/ */
public class MsgInitConnStatusBolus extends MessageBase { public class MsgInitConnStatusBolus extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgInitConnStatusBolus.class); private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM);
public MsgInitConnStatusBolus() { public MsgInitConnStatusBolus() {
SetCommand(0x0302); SetCommand(0x0302);
if (Config.logPumpComm)
log.debug("New message");
} }
@Override @Override
@ -34,7 +37,7 @@ public class MsgInitConnStatusBolus extends MessageBase {
pump.maxBolus = intFromBuff(bytes, 2, 2) / 100d; pump.maxBolus = intFromBuff(bytes, 2, 2) / 100d;
//int bolusRate = intFromBuff(bytes, 4, 8); //int bolusRate = intFromBuff(bytes, 4, 8);
if (Config.logDanaMessageDetail) { if (Config.logPumpComm) {
log.debug("Is Extended bolus enabled: " + pump.isExtendedBolusEnabled); log.debug("Is Extended bolus enabled: " + pump.isExtendedBolusEnabled);
log.debug("Bolus increment: " + pump.bolusStep); log.debug("Bolus increment: " + pump.bolusStep);
log.debug("Bolus max: " + pump.maxBolus); log.debug("Bolus max: " + pump.maxBolus);

View file

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

View file

@ -6,6 +6,7 @@ import org.slf4j.LoggerFactory;
import java.util.Date; import java.util.Date;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.events.EventRefreshGui; import info.nightscout.androidaps.events.EventRefreshGui;
@ -18,10 +19,12 @@ import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin; import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
public class MsgInitConnStatusTime extends MessageBase { public class MsgInitConnStatusTime extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgInitConnStatusTime.class); private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM);
public MsgInitConnStatusTime() { public MsgInitConnStatusTime() {
SetCommand(0x0301); SetCommand(0x0301);
if (Config.logPumpComm)
log.debug("New message");
} }
@Override @Override
@ -30,7 +33,7 @@ public class MsgInitConnStatusTime extends MessageBase {
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.bus().post(new EventNewNotification(notification));
MainApp.getSpecificPlugin(DanaRPlugin.class).disconnect("Wrong Model"); 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).setPluginEnabled(PluginType.PUMP, true);
MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setFragmentVisible(PluginType.PUMP, true); MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setFragmentVisible(PluginType.PUMP, true);
MainApp.getSpecificPlugin(DanaRPlugin.class).setPluginEnabled(PluginType.PUMP, false); MainApp.getSpecificPlugin(DanaRPlugin.class).setPluginEnabled(PluginType.PUMP, false);
@ -39,7 +42,7 @@ public class MsgInitConnStatusTime extends MessageBase {
DanaRPump.reset(); // mark not initialized DanaRPump.reset(); // mark not initialized
//If profile coming from pump, switch it as well //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(DanaRPlugin.class)).setPluginEnabled(PluginType.PROFILE, false);
(MainApp.getSpecificPlugin(DanaRKoreanPlugin.class)).setPluginEnabled(PluginType.PROFILE, true); (MainApp.getSpecificPlugin(DanaRKoreanPlugin.class)).setPluginEnabled(PluginType.PROFILE, true);
} }
@ -53,7 +56,7 @@ public class MsgInitConnStatusTime extends MessageBase {
Date time = dateTimeSecFromBuff(bytes, 0); Date time = dateTimeSecFromBuff(bytes, 0);
int versionCode = intFromBuff(bytes, 6, 1); int versionCode = intFromBuff(bytes, 6, 1);
if (Config.logDanaMessageDetail) { if (Config.logPumpComm) {
log.debug("Pump time: " + time); log.debug("Pump time: " + time);
log.debug("Version code: " + versionCode); log.debug("Version code: " + versionCode);
} }

View file

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

View file

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

View file

@ -4,19 +4,22 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
public class MsgSetActivateBasalProfile extends MessageBase { public class MsgSetActivateBasalProfile extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgSetActivateBasalProfile.class); private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM);
public MsgSetActivateBasalProfile() { public MsgSetActivateBasalProfile() {
SetCommand(0x330C); SetCommand(0x330C);
if (Config.logPumpComm)
log.debug("New message");
} }
// index 0-3 // index 0-3
public MsgSetActivateBasalProfile(byte index) { public MsgSetActivateBasalProfile(byte index) {
this(); this();
AddParamByte(index); AddParamByte(index);
if (Config.logDanaMessageDetail) if (Config.logPumpComm)
log.debug("Activate basal profile: " + index); log.debug("Activate basal profile: " + index);
} }
@ -25,9 +28,10 @@ public class MsgSetActivateBasalProfile extends MessageBase {
int result = intFromBuff(bytes, 0, 1); int result = intFromBuff(bytes, 0, 1);
if (result != 1) { if (result != 1) {
failed = true; failed = true;
if (Config.logPumpComm)
log.debug("Activate basal profile result: " + result + " FAILED!!!"); log.debug("Activate basal profile result: " + result + " FAILED!!!");
} else { } else {
if (Config.logDanaMessageDetail) if (Config.logPumpComm)
log.debug("Activate basal profile result: " + result); log.debug("Activate basal profile result: " + result);
} }
} }

View file

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

View file

@ -6,12 +6,15 @@ import org.slf4j.LoggerFactory;
import java.util.Calendar; import java.util.Calendar;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
public class MsgSetCarbsEntry extends MessageBase { public class MsgSetCarbsEntry extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgSetCarbsEntry.class); private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM);
public MsgSetCarbsEntry() { public MsgSetCarbsEntry() {
SetCommand(0x0402); SetCommand(0x0402);
if (Config.logPumpComm)
log.debug("New message");
} }
public MsgSetCarbsEntry(long time, int amount) { public MsgSetCarbsEntry(long time, int amount) {
@ -27,7 +30,7 @@ public class MsgSetCarbsEntry extends MessageBase {
AddParamByte((byte) (calendar.get(Calendar.SECOND))); AddParamByte((byte) (calendar.get(Calendar.SECOND)));
AddParamByte((byte) 0x43); //?? AddParamByte((byte) 0x43); //??
AddParamInt(amount); AddParamInt(amount);
if (Config.logDanaMessageDetail) if (Config.logPumpComm)
log.debug("Set carb entry: " + amount + " date " + calendar.getTime().toString()); 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); int result = intFromBuff(bytes, 0, 1);
if (result != 1) { if (result != 1) {
failed = true; failed = true;
if (Config.logPumpComm)
log.debug("Set carb entry result: " + result + " FAILED!!!"); log.debug("Set carb entry result: " + result + " FAILED!!!");
} else { } else {
if (Config.logDanaMessageDetail) if (Config.logPumpComm)
log.debug("Set carb entry result: " + result); log.debug("Set carb entry result: " + result);
} }
} }

View file

@ -4,15 +4,17 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.interfaces.Constraint; import info.nightscout.androidaps.interfaces.Constraint;
import info.nightscout.utils.HardLimits;
public class MsgSetExtendedBolusStart extends MessageBase { public class MsgSetExtendedBolusStart extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgSetExtendedBolusStart.class); private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM);
public MsgSetExtendedBolusStart() { public MsgSetExtendedBolusStart() {
SetCommand(0x0407); SetCommand(0x0407);
if (Config.logPumpComm)
log.debug("New message");
} }
public MsgSetExtendedBolusStart(double amount, byte halfhours) { public MsgSetExtendedBolusStart(double amount, byte halfhours) {
@ -25,7 +27,7 @@ public class MsgSetExtendedBolusStart extends MessageBase {
AddParamInt((int) (amount * 100)); AddParamInt((int) (amount * 100));
AddParamByte(halfhours); AddParamByte(halfhours);
if (Config.logDanaMessageDetail) if (Config.logPumpComm)
log.debug("Set extended bolus start: " + (((int) (amount * 100)) / 100d) + "U halfhours: " + (int) halfhours); log.debug("Set extended bolus start: " + (((int) (amount * 100)) / 100d) + "U halfhours: " + (int) halfhours);
} }
@ -34,9 +36,10 @@ public class MsgSetExtendedBolusStart extends MessageBase {
int result = intFromBuff(bytes, 0, 1); int result = intFromBuff(bytes, 0, 1);
if (result != 1) { if (result != 1) {
failed = true; failed = true;
if (Config.logPumpComm)
log.debug("Set extended bolus start result: " + result + " FAILED!!!"); log.debug("Set extended bolus start result: " + result + " FAILED!!!");
} else { } else {
if (Config.logDanaMessageDetail) if (Config.logPumpComm)
log.debug("Set extended bolus start result: " + result); log.debug("Set extended bolus start result: " + result);
} }
} }

View file

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

View file

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

View file

@ -4,9 +4,10 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
public class MsgSetTempBasalStart extends MessageBase { public class MsgSetTempBasalStart extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgSetTempBasalStart.class); private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM);
public MsgSetTempBasalStart() { public MsgSetTempBasalStart() {
SetCommand(0x0401); SetCommand(0x0401);
@ -24,7 +25,7 @@ public class MsgSetTempBasalStart extends MessageBase {
AddParamByte((byte) (percent & 255)); AddParamByte((byte) (percent & 255));
AddParamByte((byte) (durationInHours & 255)); AddParamByte((byte) (durationInHours & 255));
if (Config.logDanaMessageDetail) if (Config.logPumpComm)
log.debug("Temp basal start percent: " + percent + " duration hours: " + durationInHours); 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); int result = intFromBuff(bytes, 0, 1);
if (result != 1) { if (result != 1) {
failed = true; failed = true;
if (Config.logPumpComm)
log.debug("Set temp basal start result: " + result + " FAILED!!!"); log.debug("Set temp basal start result: " + result + " FAILED!!!");
} else { } else {
if (Config.logDanaMessageDetail) if (Config.logPumpComm)
log.debug("Set temp basal start result: " + result); log.debug("Set temp basal start result: " + result);
} }
} }

View file

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

View file

@ -6,25 +6,29 @@ import org.slf4j.LoggerFactory;
import java.util.Date; import java.util.Date;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.utils.DateUtil;
/** /**
* Created by mike on 09.12.2016. * Created by mike on 09.12.2016.
*/ */
public class MsgSetTime extends MessageBase { 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; private static Date time;
public MsgSetTime(Date time) { public MsgSetTime(Date time) {
SetCommand(0x330a); SetCommand(0x330a);
this.time = time; this.time = time;
AddParamDateTime(time); AddParamDateTime(time);
if (Config.logPumpComm)
log.debug("New message: time:" + DateUtil.dateAndTimeString(time));
} }
public void handleMessage(byte[] bytes) { public void handleMessage(byte[] bytes) {
int result = intFromBuff(bytes, 0, 1); int result = intFromBuff(bytes, 0, 1);
if (Config.logDanaMessageDetail) if (Config.logPumpComm)
log.debug("Result of setting time: " + time + " is " + result); log.debug("Result of setting time: " + time + " is " + result);
} }
} }

View file

@ -2,9 +2,9 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import android.support.v4.internal.view.SupportMenu;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
/** /**
@ -12,7 +12,7 @@ import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
*/ */
public class MsgSetUserOptions extends MessageBase { public class MsgSetUserOptions extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgSetUserOptions.class); private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM);
public boolean done; public boolean done;
@ -21,7 +21,7 @@ public class MsgSetUserOptions extends MessageBase {
DanaRPump pump = DanaRPump.getInstance(); DanaRPump pump = DanaRPump.getInstance();
if (pump.userOptionsFrompump == null) { if (pump.userOptionsFrompump == null) {
// No options set -> Exitting // No options set -> Exitting
log.debug("NO USER OPTIONS LOADED EXITTING!"); log.error("NO USER OPTIONS LOADED EXITTING!");
return; return;
} }
pump.userOptionsFrompump[0] = (byte) (pump.timeDisplayType == 1 ? 0 : 1); 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[8] = (byte) pump.units;
pump.userOptionsFrompump[9] = (byte) pump.shutdownHour; pump.userOptionsFrompump[9] = (byte) pump.shutdownHour;
pump.userOptionsFrompump[27] = (byte) pump.lowReservoirRate; pump.userOptionsFrompump[27] = (byte) pump.lowReservoirRate;
for(int i=0; i<pump.userOptionsFrompump.length; i++){ for (int i = 0; i < pump.userOptionsFrompump.length; i++) {
AddParamByte(pump.userOptionsFrompump[i]); AddParamByte(pump.userOptionsFrompump[i]);
} }
if (Config.logPumpComm)
log.debug("New message");
} }
public void handleMessage(byte[] bytes) { public void handleMessage(byte[] bytes) {
int result = intFromBuff(bytes, 0, 1); int result = intFromBuff(bytes, 0, 1);
if (result != 1) { if (result != 1) {
failed = true; failed = true;
if (Config.logPumpComm)
log.debug("Setting user options: " + result + " FAILED!!!"); log.debug("Setting user options: " + result + " FAILED!!!");
} else { } else {
if (Config.logDanaMessageDetail) if (Config.logPumpComm)
log.debug("Setting user options: " + result); log.debug("Setting user options: " + result);
} }
} }

View file

@ -4,22 +4,25 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
/** /**
* Created by mike on 05.07.2016. * Created by mike on 05.07.2016.
*/ */
public class MsgSettingActiveProfile extends MessageBase { public class MsgSettingActiveProfile extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgSettingBasal.class); private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM);
public MsgSettingActiveProfile() { public MsgSettingActiveProfile() {
SetCommand(0x320C); SetCommand(0x320C);
if (Config.logPumpComm)
log.debug("New message");
} }
public void handleMessage(byte[] bytes) { public void handleMessage(byte[] bytes) {
DanaRPump.getInstance().activeProfile = intFromBuff(bytes, 0, 1); DanaRPump.getInstance().activeProfile = intFromBuff(bytes, 0, 1);
if (Config.logDanaMessageDetail) if (Config.logPumpComm)
log.debug("Active profile number: " + DanaRPump.getInstance().activeProfile); log.debug("Active profile number: " + DanaRPump.getInstance().activeProfile);
} }
} }

View file

@ -4,6 +4,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
@ -11,10 +12,12 @@ import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
* Created by mike on 05.07.2016. * Created by mike on 05.07.2016.
*/ */
public class MsgSettingBasal extends MessageBase { public class MsgSettingBasal extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgSettingBasal.class); private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM);
public MsgSettingBasal() { public MsgSettingBasal() {
SetCommand(0x3202); SetCommand(0x3202);
if (Config.logPumpComm)
log.debug("New message");
} }
public void handleMessage(byte[] bytes) { public void handleMessage(byte[] bytes) {
@ -27,7 +30,7 @@ public class MsgSettingBasal extends MessageBase {
pump.pumpProfiles[pump.activeProfile][index] = basal / 100d; pump.pumpProfiles[pump.activeProfile][index] = basal / 100d;
} }
if (Config.logDanaMessageDetail) if (Config.logPumpComm)
for (int index = 0; index < 24; index++) { for (int index = 0; index < 24; index++) {
log.debug("Basal " + String.format("%02d", index) + "h: " + pump.pumpProfiles[pump.activeProfile][index]); log.debug("Basal " + String.format("%02d", index) + "h: " + pump.pumpProfiles[pump.activeProfile][index]);
} }

View file

@ -4,6 +4,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
@ -14,10 +15,12 @@ import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
* THIS IS BROKEN IN PUMP... SENDING ONLY 1 PROFILE * THIS IS BROKEN IN PUMP... SENDING ONLY 1 PROFILE
*/ */
public class MsgSettingBasalProfileAll extends MessageBase { public class MsgSettingBasalProfileAll extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgSettingBasalProfileAll.class); private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM);
public MsgSettingBasalProfileAll() { public MsgSettingBasalProfileAll() {
SetCommand(0x3206); SetCommand(0x3206);
if (Config.logPumpComm)
log.debug("New message");
} }
public void handleMessage(byte[] bytes) { public void handleMessage(byte[] bytes) {
@ -37,18 +40,18 @@ public class MsgSettingBasalProfileAll extends MessageBase {
pump.pumpProfiles = new double[4][]; pump.pumpProfiles = new double[4][];
for (int profile = 0; profile < 4; profile++) { for (int profile = 0; profile < 4; profile++) {
int position = intFromBuff(bytes, 49 * profile, 1); int position = intFromBuff(bytes, 49 * profile, 1);
log.debug("position " + position);
pump.pumpProfiles[position] = new double[24]; pump.pumpProfiles[position] = new double[24];
for (int index = 0; index < 24; index++) { for (int index = 0; index < 24; index++) {
int basal = intFromBuff(bytes, 59 * profile + 2 * index + 1, 2); int basal = intFromBuff(bytes, 59 * profile + 2 * index + 1, 2);
if (basal < 10) basal = 0; if (basal < 10) basal = 0;
if (Config.logPumpComm)
log.debug("position " + position + " index " + index); log.debug("position " + position + " index " + index);
pump.pumpProfiles[position][index] = basal / 100d; pump.pumpProfiles[position][index] = basal / 100d;
} }
} }
} }
if (Config.logDanaMessageDetail) { if (Config.logPumpComm) {
if (pump.basal48Enable) { if (pump.basal48Enable) {
for (int profile = 0; profile < 4; profile++) { for (int profile = 0; profile < 4; profile++) {
for (int index = 0; index < 24; index++) { for (int index = 0; index < 24; index++) {

View file

@ -4,16 +4,19 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
/** /**
* Created by mike on 05.07.2016. * Created by mike on 05.07.2016.
*/ */
public class MsgSettingGlucose extends MessageBase { public class MsgSettingGlucose extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgSettingGlucose.class); private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM);
public MsgSettingGlucose() { public MsgSettingGlucose() {
SetCommand(0x3209); SetCommand(0x3209);
if (Config.logPumpComm)
log.debug("New message");
} }
public void handleMessage(byte[] bytes) { public void handleMessage(byte[] bytes) {
@ -21,7 +24,7 @@ public class MsgSettingGlucose extends MessageBase {
pump.units = intFromBuff(bytes, 0, 1); pump.units = intFromBuff(bytes, 0, 1);
pump.easyBasalMode = intFromBuff(bytes, 1, 1); pump.easyBasalMode = intFromBuff(bytes, 1, 1);
if (Config.logDanaMessageDetail) { if (Config.logPumpComm) {
log.debug("Pump units: " + (pump.units == DanaRPump.UNITS_MGDL ? "MGDL" : "MMOL")); log.debug("Pump units: " + (pump.units == DanaRPump.UNITS_MGDL ? "MGDL" : "MMOL"));
log.debug("Easy basal mode: " + pump.easyBasalMode); log.debug("Easy basal mode: " + pump.easyBasalMode);
} }

View file

@ -4,6 +4,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
@ -11,10 +12,12 @@ import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
* Created by mike on 05.07.2016. * Created by mike on 05.07.2016.
*/ */
public class MsgSettingMaxValues extends MessageBase { public class MsgSettingMaxValues extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgSettingMaxValues.class); private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM);
public MsgSettingMaxValues() { public MsgSettingMaxValues() {
SetCommand(0x3205); SetCommand(0x3205);
if (Config.logPumpComm)
log.debug("New message");
} }
public void handleMessage(byte[] bytes) { public void handleMessage(byte[] bytes) {
@ -23,7 +26,7 @@ public class MsgSettingMaxValues extends MessageBase {
pump.maxBasal = intFromBuff(bytes, 2, 2) / 100d; pump.maxBasal = intFromBuff(bytes, 2, 2) / 100d;
pump.maxDailyTotalUnits = intFromBuff(bytes, 4, 2) / 100; pump.maxDailyTotalUnits = intFromBuff(bytes, 4, 2) / 100;
if (Config.logDanaMessageDetail) { if (Config.logPumpComm) {
log.debug("Max bolus: " + pump.maxBolus); log.debug("Max bolus: " + pump.maxBolus);
log.debug("Max basal: " + pump.maxBasal); log.debug("Max basal: " + pump.maxBasal);
log.debug("Total daily max units: " + pump.maxDailyTotalUnits); log.debug("Total daily max units: " + pump.maxDailyTotalUnits);

View file

@ -4,6 +4,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PluginType;
@ -18,10 +19,12 @@ import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
*/ */
public class MsgSettingMeal extends MessageBase { public class MsgSettingMeal extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgSettingMeal.class); private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM);
public MsgSettingMeal() { public MsgSettingMeal() {
SetCommand(0x3203); SetCommand(0x3203);
if (Config.logPumpComm)
log.debug("New message");
} }
public void handleMessage(byte[] bytes) { public void handleMessage(byte[] bytes) {
@ -33,7 +36,7 @@ public class MsgSettingMeal extends MessageBase {
int blockTime = intFromBuff(bytes, 4, 1); int blockTime = intFromBuff(bytes, 4, 1);
pump.isConfigUD = intFromBuff(bytes, 5, 1) == 1; pump.isConfigUD = intFromBuff(bytes, 5, 1) == 1;
if (Config.logDanaMessageDetail) { if (Config.logPumpComm) {
log.debug("Basal step: " + pump.basalStep); log.debug("Basal step: " + pump.basalStep);
log.debug("Bolus step: " + pump.bolusStep); log.debug("Bolus step: " + pump.bolusStep);
log.debug("Bolus enabled: " + bolusEnabled); log.debug("Bolus enabled: " + bolusEnabled);

View file

@ -4,16 +4,19 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
/** /**
* Created by mike on 05.07.2016. * Created by mike on 05.07.2016.
*/ */
public class MsgSettingProfileRatios extends MessageBase { public class MsgSettingProfileRatios extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgSettingProfileRatios.class); private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM);
public MsgSettingProfileRatios() { public MsgSettingProfileRatios() {
SetCommand(0x3204); SetCommand(0x3204);
if (Config.logPumpComm)
log.debug("New message");
} }
public void handleMessage(byte[] bytes) { public void handleMessage(byte[] bytes) {
@ -32,7 +35,7 @@ public class MsgSettingProfileRatios extends MessageBase {
pump.currentAIDR = intFromBuff(bytes, 8, 1); pump.currentAIDR = intFromBuff(bytes, 8, 1);
} }
if (Config.logDanaMessageDetail) { if (Config.logPumpComm) {
log.debug("Pump units (saved): " + (pump.units == DanaRPump.UNITS_MGDL ? "MGDL" : "MMOL")); log.debug("Pump units (saved): " + (pump.units == DanaRPump.UNITS_MGDL ? "MGDL" : "MMOL"));
log.debug("Current pump CIR: " + pump.currentCIR); log.debug("Current pump CIR: " + pump.currentCIR);
log.debug("Current pump CF: " + pump.currentCF); log.debug("Current pump CF: " + pump.currentCF);

View file

@ -4,16 +4,19 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
/** /**
* Created by mike on 05.07.2016. * Created by mike on 05.07.2016.
*/ */
public class MsgSettingProfileRatiosAll extends MessageBase { public class MsgSettingProfileRatiosAll extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgSettingProfileRatiosAll.class); private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM);
public MsgSettingProfileRatiosAll() { public MsgSettingProfileRatiosAll() {
SetCommand(0x320D); SetCommand(0x320D);
if (Config.logPumpComm)
log.debug("New message");
} }
public void handleMessage(byte[] bytes) { public void handleMessage(byte[] bytes) {
@ -38,7 +41,7 @@ public class MsgSettingProfileRatiosAll extends MessageBase {
pump.nightCF = intFromBuff(bytes, 14, 2) / 100d; pump.nightCF = intFromBuff(bytes, 14, 2) / 100d;
} }
if (Config.logDanaMessageDetail) { if (Config.logPumpComm) {
log.debug("Pump units: " + (pump.units == DanaRPump.UNITS_MGDL ? "MGDL" : "MMOL")); log.debug("Pump units: " + (pump.units == DanaRPump.UNITS_MGDL ? "MGDL" : "MMOL"));
log.debug("Current pump morning CIR: " + pump.morningCIR); log.debug("Current pump morning CIR: " + pump.morningCIR);
log.debug("Current pump morning CF: " + pump.morningCF); log.debug("Current pump morning CF: " + pump.morningCF);

View file

@ -6,13 +6,16 @@ import org.slf4j.LoggerFactory;
import java.util.Date; import java.util.Date;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
public class MsgSettingPumpTime extends MessageBase { public class MsgSettingPumpTime extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgSettingPumpTime.class); private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM);
public MsgSettingPumpTime() { public MsgSettingPumpTime() {
SetCommand(0x320A); SetCommand(0x320A);
if (Config.logPumpComm)
log.debug("New message");
} }
public void handleMessage(byte[] bytes) { public void handleMessage(byte[] bytes) {
@ -26,7 +29,7 @@ public class MsgSettingPumpTime extends MessageBase {
intFromBuff(bytes, 0, 1) intFromBuff(bytes, 0, 1)
); );
if (Config.logDanaMessageDetail) if (Config.logPumpComm)
log.debug("Pump time: " + time + " Phone time: " + new Date()); log.debug("Pump time: " + time + " Phone time: " + new Date());
DanaRPump.getInstance().pumpTime = time; DanaRPump.getInstance().pumpTime = time;

View file

@ -4,16 +4,19 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
/** /**
* Created by mike on 05.07.2016. * Created by mike on 05.07.2016.
*/ */
public class MsgSettingShippingInfo extends MessageBase { public class MsgSettingShippingInfo extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgSettingShippingInfo.class); private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM);
public MsgSettingShippingInfo() { public MsgSettingShippingInfo() {
SetCommand(0x3207); SetCommand(0x3207);
if (Config.logPumpComm)
log.debug("New message");
} }
public void handleMessage(byte[] bytes) { public void handleMessage(byte[] bytes) {
@ -21,7 +24,7 @@ public class MsgSettingShippingInfo extends MessageBase {
pump.serialNumber = stringFromBuff(bytes, 0, 10); pump.serialNumber = stringFromBuff(bytes, 0, 10);
pump.shippingDate = dateFromBuff(bytes, 10); pump.shippingDate = dateFromBuff(bytes, 10);
pump.shippingCountry = asciiStringFromBuff(bytes, 13, 3); pump.shippingCountry = asciiStringFromBuff(bytes, 13, 3);
if (Config.logDanaMessageDetail) { if (Config.logPumpComm) {
log.debug("Serial number: " + pump.serialNumber); log.debug("Serial number: " + pump.serialNumber);
log.debug("Shipping date: " + pump.shippingDate); log.debug("Shipping date: " + pump.shippingDate);
log.debug("Shipping country: " + pump.shippingCountry); log.debug("Shipping country: " + pump.shippingCountry);

View file

@ -6,6 +6,7 @@ import org.slf4j.LoggerFactory;
import java.util.Arrays; import java.util.Arrays;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
/** /**
@ -14,10 +15,12 @@ import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
public class MsgSettingUserOptions extends MessageBase { public class MsgSettingUserOptions extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgSettingUserOptions.class); private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM);
public MsgSettingUserOptions() { public MsgSettingUserOptions() {
SetCommand(0x320B); SetCommand(0x320B);
if (Config.logPumpComm)
log.debug("New message");
} }
public void handleMessage(byte[] packet) { public void handleMessage(byte[] packet) {
@ -43,7 +46,7 @@ public class MsgSettingUserOptions extends MessageBase {
int selectableLanguage5 = bytes[14]; int selectableLanguage5 = bytes[14];
*/ */
if (Config.logDanaMessageDetail) { if (Config.logPumpComm) {
log.debug("timeDisplayType: " + pump.timeDisplayType); log.debug("timeDisplayType: " + pump.timeDisplayType);
log.debug("Button scroll: " + pump.buttonScrollOnOff); log.debug("Button scroll: " + pump.buttonScrollOnOff);

View file

@ -4,13 +4,16 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
public class MsgStatus extends MessageBase { public class MsgStatus extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgStatus.class); private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM);
public MsgStatus() { public MsgStatus() {
SetCommand(0x020B); SetCommand(0x020B);
if (Config.logPumpComm)
log.debug("New message");
} }
public void handleMessage(byte[] bytes) { public void handleMessage(byte[] bytes) {
@ -26,7 +29,7 @@ public class MsgStatus extends MessageBase {
} }
pump.iob = intFromBuff(bytes, 15, 2) / 100d; pump.iob = intFromBuff(bytes, 15, 2) / 100d;
if (Config.logDanaMessageDetail) { if (Config.logPumpComm) {
log.debug("Daily total: " + pump.dailyTotalUnits); log.debug("Daily total: " + pump.dailyTotalUnits);
log.debug("Is extended bolus running: " + pump.isExtendedInProgress); log.debug("Is extended bolus running: " + pump.isExtendedInProgress);
log.debug("Extended bolus min: " + pump.extendedBolusMinutes); log.debug("Extended bolus min: " + pump.extendedBolusMinutes);

View file

@ -4,14 +4,17 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
public class MsgStatusBasic extends MessageBase { public class MsgStatusBasic extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgStatusBasic.class); private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM);
public MsgStatusBasic() { public MsgStatusBasic() {
SetCommand(0x020A); SetCommand(0x020A);
if (Config.logPumpComm)
log.debug("New message");
} }
public void handleMessage(byte[] bytes) { public void handleMessage(byte[] bytes) {
@ -30,7 +33,7 @@ public class MsgStatusBasic extends MessageBase {
//pump.isTempBasalInProgress = intFromBuff(bytes, 15, 1) == 1; //pump.isTempBasalInProgress = intFromBuff(bytes, 15, 1) == 1;
pump.batteryRemaining = intFromBuff(bytes, 20, 1); pump.batteryRemaining = intFromBuff(bytes, 20, 1);
if (Config.logDanaMessageDetail) { if (Config.logPumpComm) {
log.debug("Pump suspended: " + pump.pumpSuspended); log.debug("Pump suspended: " + pump.pumpSuspended);
log.debug("Calculator enabled: " + pump.calculatorEnabled); log.debug("Calculator enabled: " + pump.calculatorEnabled);
log.debug("Daily total units: " + pump.dailyTotalUnits); log.debug("Daily total units: " + pump.dailyTotalUnits);

View file

@ -8,6 +8,7 @@ import org.slf4j.LoggerFactory;
import java.util.Date; import java.util.Date;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.db.ExtendedBolus; import info.nightscout.androidaps.db.ExtendedBolus;
import info.nightscout.androidaps.db.Source; import info.nightscout.androidaps.db.Source;
import info.nightscout.androidaps.interfaces.TreatmentsInterface; import info.nightscout.androidaps.interfaces.TreatmentsInterface;
@ -15,10 +16,12 @@ import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin; import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
public class MsgStatusBolusExtended extends MessageBase { public class MsgStatusBolusExtended extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgStatusBolusExtended.class); private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM);
public MsgStatusBolusExtended() { public MsgStatusBolusExtended() {
SetCommand(0x0207); SetCommand(0x0207);
if (Config.logPumpComm)
log.debug("New message");
} }
public void handleMessage(byte[] bytes) { public void handleMessage(byte[] bytes) {
@ -48,7 +51,7 @@ public class MsgStatusBolusExtended extends MessageBase {
updateExtendedBolusInDB(); updateExtendedBolusInDB();
if (Config.logDanaMessageDetail) { if (Config.logPumpComm) {
log.debug("Is extended bolus running: " + isExtendedInProgress); log.debug("Is extended bolus running: " + isExtendedInProgress);
log.debug("Extended bolus min: " + extendedBolusMinutes); log.debug("Extended bolus min: " + extendedBolusMinutes);
log.debug("Extended bolus amount: " + extendedBolusAmount); log.debug("Extended bolus amount: " + extendedBolusAmount);

View file

@ -4,16 +4,19 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
/** /**
* Created by mike on 05.07.2016. * Created by mike on 05.07.2016.
*/ */
public class MsgStatusProfile extends MessageBase { public class MsgStatusProfile extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgStatusProfile.class); private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM);
public MsgStatusProfile() { public MsgStatusProfile() {
SetCommand(0x0204); SetCommand(0x0204);
if (Config.logPumpComm)
log.debug("New message");
} }
public void handleMessage(byte[] bytes) { public void handleMessage(byte[] bytes) {
@ -30,7 +33,7 @@ public class MsgStatusProfile extends MessageBase {
pump.currentTarget = intFromBuff(bytes, 6, 2) / 100d; pump.currentTarget = intFromBuff(bytes, 6, 2) / 100d;
} }
if (Config.logDanaMessageDetail) { if (Config.logPumpComm) {
log.debug("Pump units (saved): " + (pump.units == DanaRPump.UNITS_MGDL ? "MGDL" : "MMOL")); log.debug("Pump units (saved): " + (pump.units == DanaRPump.UNITS_MGDL ? "MGDL" : "MMOL"));
log.debug("Current pump CIR: " + pump.currentCIR); log.debug("Current pump CIR: " + pump.currentCIR);
log.debug("Current pump CF: " + pump.currentCF); log.debug("Current pump CF: " + pump.currentCF);

View file

@ -8,16 +8,19 @@ import org.slf4j.LoggerFactory;
import java.util.Date; import java.util.Date;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.db.Source; import info.nightscout.androidaps.db.Source;
import info.nightscout.androidaps.db.TemporaryBasal; import info.nightscout.androidaps.db.TemporaryBasal;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin; import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
public class MsgStatusTempBasal extends MessageBase { public class MsgStatusTempBasal extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgStatusTempBasal.class); private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM);
public MsgStatusTempBasal() { public MsgStatusTempBasal() {
SetCommand(0x0205); SetCommand(0x0205);
if (Config.logPumpComm)
log.debug("New message");
} }
public void handleMessage(byte[] bytes) { public void handleMessage(byte[] bytes) {
@ -42,7 +45,7 @@ public class MsgStatusTempBasal extends MessageBase {
updateTempBasalInDB(); updateTempBasalInDB();
if (Config.logDanaMessageDetail) { if (Config.logPumpComm) {
log.debug("Is temp basal running: " + isTempBasalInProgress); log.debug("Is temp basal running: " + isTempBasalInProgress);
log.debug("Is APS temp basal running: " + isAPSTempBasalInProgress); log.debug("Is APS temp basal running: " + isAPSTempBasalInProgress);
log.debug("Current temp basal percent: " + tempBasalPercent); log.debug("Current temp basal percent: " + tempBasalPercent);

View file

@ -1,9 +0,0 @@
package info.nightscout.androidaps.plugins.PumpDanaR.events;
import info.nightscout.androidaps.events.Event;
/**
* Created by mike on 03.08.2016.
*/
public class EventDanaRBolusStart extends Event {
}

View file

@ -11,7 +11,4 @@ public class EventDanaRSyncStatus extends Event {
public EventDanaRSyncStatus() { public EventDanaRSyncStatus() {
} }
EventDanaRSyncStatus(String message) {
this.message = message;
} }
}

View file

@ -11,17 +11,18 @@ import android.os.IBinder;
import android.os.SystemClock; import android.os.SystemClock;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.plugins.Treatments.Treatment;
import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
@ -39,6 +40,7 @@ import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgHistorySuspend;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgPCCommStart; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgPCCommStart;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgPCCommStop; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgPCCommStop;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes; import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes;
import info.nightscout.androidaps.plugins.Treatments.Treatment;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
import info.nightscout.utils.ToastUtils; import info.nightscout.utils.ToastUtils;
@ -47,7 +49,7 @@ import info.nightscout.utils.ToastUtils;
*/ */
public abstract class AbstractDanaRExecutionService extends Service { public abstract class AbstractDanaRExecutionService extends Service {
protected Logger log; protected Logger log = LoggerFactory.getLogger(Constants.PUMP);
protected String mDevName; protected String mDevName;
@ -100,6 +102,7 @@ public abstract class AbstractDanaRExecutionService extends Service {
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
String action = intent.getAction(); String action = intent.getAction();
if (BluetoothDevice.ACTION_ACL_DISCONNECTED.equals(action)) { if (BluetoothDevice.ACTION_ACL_DISCONNECTED.equals(action)) {
if (Config.logPump)
log.debug("Device was disconnected " + device.getName());//Device was disconnected log.debug("Device was disconnected " + device.getName());//Device was disconnected
if (mBTDevice != null && mBTDevice.getName() != null && mBTDevice.getName().equals(device.getName())) { if (mBTDevice != null && mBTDevice.getName() != null && mBTDevice.getName().equals(device.getName())) {
if (mSerialIOThread != null) { if (mSerialIOThread != null) {
@ -166,7 +169,7 @@ public abstract class AbstractDanaRExecutionService extends Service {
} }
public void bolusStop() { public void bolusStop() {
if (Config.logDanaBTComm) if (Config.logPump)
log.debug("bolusStop >>>>> @ " + (mBolusingTreatment == null ? "" : mBolusingTreatment.insulin)); log.debug("bolusStop >>>>> @ " + (mBolusingTreatment == null ? "" : mBolusingTreatment.insulin));
MsgBolusStop stop = new MsgBolusStop(); MsgBolusStop stop = new MsgBolusStop();
stop.forced = true; stop.forced = true;

View file

@ -7,8 +7,6 @@ import android.os.SystemClock;
import com.squareup.otto.Subscribe; import com.squareup.otto.Subscribe;
import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.util.Date; import java.util.Date;
@ -67,10 +65,9 @@ import info.nightscout.androidaps.queue.commands.Command;
import info.nightscout.utils.NSUpload; import info.nightscout.utils.NSUpload;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
public class DanaRExecutionService extends AbstractDanaRExecutionService{ public class DanaRExecutionService extends AbstractDanaRExecutionService {
public DanaRExecutionService() { public DanaRExecutionService() {
log = LoggerFactory.getLogger(DanaRExecutionService.class);
mBinder = new LocalBinder(); mBinder = new LocalBinder();
registerBus(); registerBus();
@ -100,7 +97,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{
public void connect() { public void connect() {
if (mDanaRPump.password != -1 && mDanaRPump.password != SP.getInt(R.string.key_danar_password, -1)) { 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 notification = new Notification(Notification.WRONG_PUMP_PASSWORD, MainApp.gs(R.string.wrongpumppassword), Notification.URGENT);
notification.soundId = R.raw.error; notification.soundId = R.raw.error;
lastWrongPumpPassword = System.currentTimeMillis(); lastWrongPumpPassword = System.currentTimeMillis();
@ -196,11 +193,13 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime))); MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime)));
mSerialIOThread.sendMessage(new MsgSettingPumpTime()); mSerialIOThread.sendMessage(new MsgSettingPumpTime());
long timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L; long timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
if (Config.logPump)
log.debug("Pump time difference: " + timeDiff + " seconds"); log.debug("Pump time difference: " + timeDiff + " seconds");
if (Math.abs(timeDiff) > 10) { if (Math.abs(timeDiff) > 10) {
mSerialIOThread.sendMessage(new MsgSetTime(new Date())); mSerialIOThread.sendMessage(new MsgSetTime(new Date()));
mSerialIOThread.sendMessage(new MsgSettingPumpTime()); mSerialIOThread.sendMessage(new MsgSettingPumpTime());
timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L; timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
if (Config.logPump)
log.debug("Pump time difference: " + timeDiff + " seconds"); log.debug("Pump time difference: " + timeDiff + " seconds");
} }
mDanaRPump.lastSettingsRead = now; mDanaRPump.lastSettingsRead = now;
@ -210,8 +209,9 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{
MainApp.bus().post(new EventInitializationChanged()); MainApp.bus().post(new EventInitializationChanged());
NSUpload.uploadDeviceStatus(); NSUpload.uploadDeviceStatus();
if (mDanaRPump.dailyTotalUnits > mDanaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) { if (mDanaRPump.dailyTotalUnits > mDanaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) {
if (Config.logPump)
log.debug("Approaching daily limit: " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits); log.debug("Approaching daily limit: " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits);
if(System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) { if (System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) {
Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.gs(R.string.approachingdailylimit), Notification.URGENT); Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.gs(R.string.approachingdailylimit), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(reportFail)); MainApp.bus().post(new EventNewNotification(reportFail));
NSUpload.uploadError(MainApp.gs(R.string.approachingdailylimit) + ": " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits + "U"); NSUpload.uploadError(MainApp.gs(R.string.approachingdailylimit) + ": " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits + "U");
@ -301,6 +301,7 @@ 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 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.stopped = true;
stop.forced = true; stop.forced = true;
if (Config.logPump)
log.debug("Communication stopped"); log.debug("Communication stopped");
} }
} }
@ -344,8 +345,10 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{
public void run() { public void run() {
if (mDanaRPump.lastBolusTime.getTime() > System.currentTimeMillis() - 60 * 1000L) { // last bolus max 1 min old if (mDanaRPump.lastBolusTime.getTime() > System.currentTimeMillis() - 60 * 1000L) { // last bolus max 1 min old
t.insulin = mDanaRPump.lastBolusAmount; t.insulin = mDanaRPump.lastBolusAmount;
if (Config.logPump)
log.debug("Used bolus amount from history: " + mDanaRPump.lastBolusAmount); log.debug("Used bolus amount from history: " + mDanaRPump.lastBolusAmount);
} else { } else {
if (Config.logPump)
log.debug("Bolus amount in history too old: " + mDanaRPump.lastBolusTime.toLocaleString()); log.debug("Bolus amount in history too old: " + mDanaRPump.lastBolusTime.toLocaleString());
} }
synchronized (o) { synchronized (o) {
@ -386,7 +389,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{
public boolean updateBasalsInPump(final Profile profile) { public boolean updateBasalsInPump(final Profile profile) {
if (!isConnected()) return false; if (!isConnected()) return false;
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.updatingbasalrates))); 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); MsgSetBasalProfile msgSet = new MsgSetBasalProfile((byte) 0, basal);
mSerialIOThread.sendMessage(msgSet); mSerialIOThread.sendMessage(msgSet);
MsgSetActivateBasalProfile msgActivate = new MsgSetActivateBasalProfile((byte) 0); MsgSetActivateBasalProfile msgActivate = new MsgSetActivateBasalProfile((byte) 0);
@ -399,7 +402,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{
@Subscribe @Subscribe
public void onStatusEvent(EventAppExit event) { public void onStatusEvent(EventAppExit event) {
if (Config.logFunctionCalls) if (Config.logPump)
log.debug("EventAppExit received"); log.debug("EventAppExit received");
if (mSerialIOThread != null) if (mSerialIOThread != null)
@ -408,7 +411,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{
MainApp.instance().getApplicationContext().unregisterReceiver(receiver); MainApp.instance().getApplicationContext().unregisterReceiver(receiver);
stopSelf(); stopSelf();
if (Config.logFunctionCalls) if (Config.logPump)
log.debug("EventAppExit finished"); log.debug("EventAppExit finished");
} }

View file

@ -11,8 +11,6 @@ import android.support.v7.app.AlertDialog;
import com.squareup.otto.Subscribe; import com.squareup.otto.Subscribe;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
@ -51,7 +49,6 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
public DanaRKoreanPlugin() { public DanaRKoreanPlugin() {
pluginDescription.description(R.string.description_pump_dana_r_korean); pluginDescription.description(R.string.description_pump_dana_r_korean);
log = LoggerFactory.getLogger(DanaRKoreanPlugin.class);
useExtendedBoluses = SP.getBoolean("danar_useextended", false); useExtendedBoluses = SP.getBoolean("danar_useextended", false);
pumpDescription.isBolusCapable = true; pumpDescription.isBolusCapable = true;
@ -87,7 +84,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
@Override @Override
public void switchAllowed(ConfigBuilderFragment.PluginViewHolder.PluginSwitcher pluginSwitcher, FragmentActivity context) { public void switchAllowed(ConfigBuilderFragment.PluginViewHolder.PluginSwitcher pluginSwitcher, FragmentActivity context) {
boolean allowHardwarePump = SP.getBoolean("allow_hardware_pump", false); boolean allowHardwarePump = SP.getBoolean("allow_hardware_pump", false);
if (allowHardwarePump || context == null){ if (allowHardwarePump || context == null) {
pluginSwitcher.invoke(); pluginSwitcher.invoke();
} else { } else {
AlertDialog.Builder builder = new AlertDialog.Builder(context); AlertDialog.Builder builder = new AlertDialog.Builder(context);
@ -96,12 +93,14 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
pluginSwitcher.invoke(); pluginSwitcher.invoke();
SP.putBoolean("allow_hardware_pump", true); SP.putBoolean("allow_hardware_pump", true);
if (Config.logPump)
log.debug("First time HW pump allowed!"); log.debug("First time HW pump allowed!");
} }
}) })
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
pluginSwitcher.cancel(); pluginSwitcher.cancel();
if (Config.logPump)
log.debug("User does not allow switching to HW pump!"); log.debug("User does not allow switching to HW pump!");
} }
}); });
@ -130,11 +129,13 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
private ServiceConnection mConnection = new ServiceConnection() { private ServiceConnection mConnection = new ServiceConnection() {
public void onServiceDisconnected(ComponentName name) { public void onServiceDisconnected(ComponentName name) {
if (Config.logPump)
log.debug("Service is disconnected"); log.debug("Service is disconnected");
sExecutionService = null; sExecutionService = null;
} }
public void onServiceConnected(ComponentName name, IBinder service) { public void onServiceConnected(ComponentName name, IBinder service) {
if (Config.logPump)
log.debug("Service is connected"); log.debug("Service is connected");
DanaRKoreanExecutionService.LocalBinder mLocalBinder = (DanaRKoreanExecutionService.LocalBinder) service; DanaRKoreanExecutionService.LocalBinder mLocalBinder = (DanaRKoreanExecutionService.LocalBinder) service;
sExecutionService = mLocalBinder.getServiceInstance(); 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); result.comment = String.format(MainApp.gs(R.string.boluserrorcode), detailedBolusInfo.insulin, t.insulin, MsgBolusStart.errorCode);
else else
result.comment = MainApp.gs(R.string.virtualpump_resultok); result.comment = MainApp.gs(R.string.virtualpump_resultok);
if (Config.logPumpActions) if (Config.logPump)
log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered); log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered);
detailedBolusInfo.insulin = t.insulin; detailedBolusInfo.insulin = t.insulin;
detailedBolusInfo.date = System.currentTimeMillis(); detailedBolusInfo.date = System.currentTimeMillis();
@ -240,13 +241,13 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
if (doTempOff) { if (doTempOff) {
// If extended in progress // If extended in progress
if (activeExtended != null && useExtendedBoluses) { if (activeExtended != null && useExtendedBoluses) {
if (Config.logPumpActions) if (Config.logPump)
log.debug("setTempBasalAbsolute: Stopping extended bolus (doTempOff)"); log.debug("setTempBasalAbsolute: Stopping extended bolus (doTempOff)");
return cancelExtendedBolus(); return cancelExtendedBolus();
} }
// If temp in progress // If temp in progress
if (activeTemp != null) { if (activeTemp != null) {
if (Config.logPumpActions) if (Config.logPump)
log.debug("setTempBasalAbsolute: Stopping temp basal (doTempOff)"); log.debug("setTempBasalAbsolute: Stopping temp basal (doTempOff)");
return cancelRealTempBasal(); return cancelRealTempBasal();
} }
@ -255,7 +256,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
result.percent = 100; result.percent = 100;
result.isPercent = true; result.isPercent = true;
result.isTempCancel = true; result.isTempCancel = true;
if (Config.logPumpActions) if (Config.logPump)
log.debug("setTempBasalAbsolute: doTempOff OK"); log.debug("setTempBasalAbsolute: doTempOff OK");
return result; return result;
} }
@ -267,12 +268,12 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
if (percentRate > getPumpDescription().maxTempPercent) { if (percentRate > getPumpDescription().maxTempPercent) {
percentRate = getPumpDescription().maxTempPercent; percentRate = getPumpDescription().maxTempPercent;
} }
if (Config.logPumpActions) if (Config.logPump)
log.debug("setTempBasalAbsolute: Calculated percent rate: " + percentRate); log.debug("setTempBasalAbsolute: Calculated percent rate: " + percentRate);
// If extended in progress // If extended in progress
if (activeExtended != null && useExtendedBoluses) { if (activeExtended != null && useExtendedBoluses) {
if (Config.logPumpActions) if (Config.logPump)
log.debug("setTempBasalAbsolute: Stopping extended bolus (doLowTemp || doHighTemp)"); log.debug("setTempBasalAbsolute: Stopping extended bolus (doLowTemp || doHighTemp)");
result = cancelExtendedBolus(); result = cancelExtendedBolus();
if (!result.success) { if (!result.success) {
@ -283,7 +284,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
// Check if some temp is already in progress // Check if some temp is already in progress
if (activeTemp != null) { if (activeTemp != null) {
// Correct basal already set ? // Correct basal already set ?
if (Config.logPumpActions) if (Config.logPump)
log.debug("setTempBasalAbsolute: currently running: " + activeTemp.toString()); log.debug("setTempBasalAbsolute: currently running: " + activeTemp.toString());
if (activeTemp.percentRate == percentRate) { if (activeTemp.percentRate == percentRate) {
if (enforceNew) { if (enforceNew) {
@ -295,21 +296,21 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
result.duration = activeTemp.getPlannedRemainingMinutes(); result.duration = activeTemp.getPlannedRemainingMinutes();
result.isPercent = true; result.isPercent = true;
result.isTempCancel = false; result.isTempCancel = false;
if (Config.logPumpActions) if (Config.logPump)
log.debug("setTempBasalAbsolute: Correct temp basal already set (doLowTemp || doHighTemp)"); log.debug("setTempBasalAbsolute: Correct temp basal already set (doLowTemp || doHighTemp)");
return result; return result;
} }
} }
} }
// Convert duration from minutes to hours // Convert duration from minutes to hours
if (Config.logPumpActions) if (Config.logPump)
log.debug("setTempBasalAbsolute: Setting temp basal " + percentRate + "% for " + durationInMinutes + " mins (doLowTemp || doHighTemp)"); log.debug("setTempBasalAbsolute: Setting temp basal " + percentRate + "% for " + durationInMinutes + " mins (doLowTemp || doHighTemp)");
return setTempBasalPercent(percentRate, durationInMinutes, profile, false); return setTempBasalPercent(percentRate, durationInMinutes, profile, false);
} }
if (doExtendedTemp) { if (doExtendedTemp) {
// Check if some temp is already in progress // Check if some temp is already in progress
if (activeTemp != null) { if (activeTemp != null) {
if (Config.logPumpActions) if (Config.logPump)
log.debug("setTempBasalAbsolute: Stopping temp basal (doExtendedTemp)"); log.debug("setTempBasalAbsolute: Stopping temp basal (doExtendedTemp)");
result = cancelRealTempBasal(); result = cancelRealTempBasal();
// Check for proper result // Check for proper result
@ -328,7 +329,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
extendedRateToSet = Round.roundTo(extendedRateToSet, pumpDescription.extendedBolusStep * 2); // *2 because of halfhours extendedRateToSet = Round.roundTo(extendedRateToSet, pumpDescription.extendedBolusStep * 2); // *2 because of halfhours
// What is current rate of extended bolusing in u/h? // What is current rate of extended bolusing in u/h?
if (Config.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: Extended bolus in progress: " + (activeExtended != null) + " rate: " + pump.extendedBolusAbsoluteRate + "U/h duration remaining: " + pump.extendedBolusRemainingMinutes + "min");
log.debug("setTempBasalAbsolute: Rate to set: " + extendedRateToSet + "U/h"); log.debug("setTempBasalAbsolute: Rate to set: " + extendedRateToSet + "U/h");
} }
@ -342,21 +343,21 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
result.duration = pump.extendedBolusRemainingMinutes; result.duration = pump.extendedBolusRemainingMinutes;
result.isPercent = false; result.isPercent = false;
result.isTempCancel = false; result.isTempCancel = false;
if (Config.logPumpActions) if (Config.logPump)
log.debug("setTempBasalAbsolute: Correct extended already set"); log.debug("setTempBasalAbsolute: Correct extended already set");
return result; return result;
} }
// Now set new extended, no need to to stop previous (if running) because it's replaced // Now set new extended, no need to to stop previous (if running) because it's replaced
Double extendedAmount = extendedRateToSet / 2 * durationInHalfHours; Double extendedAmount = extendedRateToSet / 2 * durationInHalfHours;
if (Config.logPumpActions) if (Config.logPump)
log.debug("setTempBasalAbsolute: Setting extended: " + extendedAmount + "U halfhours: " + durationInHalfHours); log.debug("setTempBasalAbsolute: Setting extended: " + extendedAmount + "U halfhours: " + durationInHalfHours);
result = setExtendedBolus(extendedAmount, durationInMinutes); result = setExtendedBolus(extendedAmount, durationInMinutes);
if (!result.success) { if (!result.success) {
log.error("setTempBasalAbsolute: Failed to set extended bolus"); log.error("setTempBasalAbsolute: Failed to set extended bolus");
return result; return result;
} }
if (Config.logPumpActions) if (Config.logPump)
log.debug("setTempBasalAbsolute: Extended bolus set ok"); log.debug("setTempBasalAbsolute: Extended bolus set ok");
result.absolute = result.absolute + getBaseBasalRate(); result.absolute = result.absolute + getBaseBasalRate();
return result; return result;
@ -395,7 +396,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
result.success = true; result.success = true;
result.isTempCancel = true; result.isTempCancel = true;
result.comment = MainApp.gs(R.string.virtualpump_resultok); result.comment = MainApp.gs(R.string.virtualpump_resultok);
if (Config.logPumpActions) if (Config.logPump)
log.debug("cancelRealTempBasal: OK"); log.debug("cancelRealTempBasal: OK");
return result; return result;
} else { } else {

View file

@ -11,6 +11,7 @@ import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
import info.nightscout.androidaps.plugins.PumpDanaR.services.AbstractSerialIOThread; import info.nightscout.androidaps.plugins.PumpDanaR.services.AbstractSerialIOThread;
@ -21,7 +22,7 @@ import info.nightscout.utils.CRC;
* Created by mike on 17.07.2016. * Created by mike on 17.07.2016.
*/ */
public class SerialIOThread extends AbstractSerialIOThread { public class SerialIOThread extends AbstractSerialIOThread {
private static Logger log = LoggerFactory.getLogger(SerialIOThread.class); private static Logger log = LoggerFactory.getLogger(Constants.PUMPBTCOMM);
private InputStream mInputStream = null; private InputStream mInputStream = null;
private OutputStream mOutputStream = null; private OutputStream mOutputStream = null;
@ -72,7 +73,7 @@ public class SerialIOThread extends AbstractSerialIOThread {
message = MessageHashTable_k.findMessage(command); message = MessageHashTable_k.findMessage(command);
} }
if (Config.logDanaMessageDetail) if (Config.logPumpBtComm)
log.debug("<<<<< " + message.getMessageName() + " " + message.toHexString(extractedBuff)); log.debug("<<<<< " + message.getMessageName() + " " + message.toHexString(extractedBuff));
// process the message content // process the message content
@ -84,7 +85,7 @@ public class SerialIOThread extends AbstractSerialIOThread {
} }
} }
} catch (Exception e) { } 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); log.error("Thread exception: ", e);
mKeepRunning = false; mKeepRunning = false;
} }
@ -148,7 +149,7 @@ public class SerialIOThread extends AbstractSerialIOThread {
processedMessage = message; processedMessage = message;
byte[] messageBytes = message.getRawMessageBytes(); byte[] messageBytes = message.getRawMessageBytes();
if (Config.logDanaSerialEngine) if (Config.logPumpBtComm)
log.debug(">>>>> " + message.getMessageName() + " " + message.toHexString(messageBytes)); log.debug(">>>>> " + message.getMessageName() + " " + message.toHexString(messageBytes));
try { try {
@ -167,10 +168,11 @@ public class SerialIOThread extends AbstractSerialIOThread {
SystemClock.sleep(200); SystemClock.sleep(200);
if (!message.received) { if (!message.received) {
if (Config.logPumpBtComm)
log.warn("Reply not received " + message.getMessageName()); log.warn("Reply not received " + message.getMessageName());
if (message.getCommand() == 0xF0F1) { if (message.getCommand() == 0xF0F1) {
DanaRPump.getInstance().isNewPump = false; DanaRPump.getInstance().isNewPump = false;
log.debug("Old firmware detected"); log.error("Old firmware detected");
} }
} }
} }
@ -181,24 +183,29 @@ public class SerialIOThread extends AbstractSerialIOThread {
try { try {
mInputStream.close(); mInputStream.close();
} catch (Exception e) { } catch (Exception e) {
if (Config.logDanaSerialEngine) log.debug(e.getMessage()); if (Config.logPumpBtComm)
log.debug(e.getMessage());
} }
try { try {
mOutputStream.close(); mOutputStream.close();
} catch (Exception e) { } catch (Exception e) {
if (Config.logDanaSerialEngine) log.debug(e.getMessage()); if (Config.logPumpBtComm)
log.debug(e.getMessage());
} }
try { try {
mRfCommSocket.close(); mRfCommSocket.close();
} catch (Exception e) { } catch (Exception e) {
if (Config.logDanaSerialEngine) log.debug(e.getMessage()); if (Config.logPumpBtComm)
log.debug(e.getMessage());
} }
try { try {
System.runFinalization(); System.runFinalization();
} catch (Exception e) { } 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);
} }
} }

View file

@ -4,6 +4,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
@ -15,10 +16,12 @@ import info.nightscout.utils.ToastUtils;
* Created by mike on 30.06.2016. * Created by mike on 30.06.2016.
*/ */
public class MsgCheckValue_k extends MessageBase { 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() { public MsgCheckValue_k() {
SetCommand(0xF0F1); SetCommand(0xF0F1);
if (Config.logPumpComm)
log.debug("New message");
} }
@Override @Override
@ -26,6 +29,7 @@ public class MsgCheckValue_k extends MessageBase {
DanaRPump pump = DanaRPump.getInstance(); DanaRPump pump = DanaRPump.getInstance();
pump.isNewPump = true; pump.isNewPump = true;
if (Config.logPump)
log.debug("New firmware confirmed"); log.debug("New firmware confirmed");
pump.model = intFromBuff(bytes, 0, 1); pump.model = intFromBuff(bytes, 0, 1);
@ -33,10 +37,10 @@ public class MsgCheckValue_k extends MessageBase {
pump.productCode = intFromBuff(bytes, 2, 1); pump.productCode = intFromBuff(bytes, 2, 1);
if (pump.model != DanaRPump.DOMESTIC_MODEL) { if (pump.model != DanaRPump.DOMESTIC_MODEL) {
DanaRKoreanPlugin.getPlugin().disconnect("Wrong 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("Model: " + String.format("%02X ", pump.model));
log.debug("Protocol: " + String.format("%02X ", pump.protocol)); log.debug("Protocol: " + String.format("%02X ", pump.protocol));
log.debug("Product Code: " + String.format("%02X ", pump.productCode)); log.debug("Product Code: " + String.format("%02X ", pump.productCode));

View file

@ -4,19 +4,22 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
public class MsgInitConnStatusBasic_k extends 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() { public MsgInitConnStatusBasic_k() {
SetCommand(0x0303); SetCommand(0x0303);
if (Config.logPumpComm)
log.debug("New message");
} }
@Override @Override
@ -30,7 +33,7 @@ public class MsgInitConnStatusBasic_k extends MessageBase {
pump.isEasyModeEnabled = intFromBuff(bytes, 2, 1) == 1; pump.isEasyModeEnabled = intFromBuff(bytes, 2, 1) == 1;
int easyUIMode = intFromBuff(bytes, 3, 1); int easyUIMode = intFromBuff(bytes, 3, 1);
pump.password = intFromBuff(bytes, 4, 2) ^ 0x3463; pump.password = intFromBuff(bytes, 4, 2) ^ 0x3463;
if (Config.logDanaMessageDetail) { if (Config.logPumpComm) {
log.debug("isStatusSuspendOn: " + pump.pumpSuspended); log.debug("isStatusSuspendOn: " + pump.pumpSuspended);
log.debug("isUtilityEnable: " + isUtilityEnable); log.debug("isUtilityEnable: " + isUtilityEnable);
log.debug("Is EasyUI Enabled: " + pump.isEasyModeEnabled); log.debug("Is EasyUI Enabled: " + pump.isEasyModeEnabled);

View file

@ -4,22 +4,25 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.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.EventDismissNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
/** /**
* Created by mike on 28.05.2016. * Created by mike on 28.05.2016.
*/ */
public class MsgInitConnStatusBolus_k extends MessageBase { 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() { public MsgInitConnStatusBolus_k() {
SetCommand(0x0302); SetCommand(0x0302);
if (Config.logPumpComm)
log.debug("New message");
} }
@Override @Override
@ -36,7 +39,7 @@ public class MsgInitConnStatusBolus_k extends MessageBase {
//int bolusRate = intFromBuff(bytes, 4, 8); //int bolusRate = intFromBuff(bytes, 4, 8);
int deliveryStatus = intFromBuff(bytes, 12, 1); int deliveryStatus = intFromBuff(bytes, 12, 1);
if (Config.logDanaMessageDetail) { if (Config.logPumpComm) {
log.debug("Is Extended bolus enabled: " + pump.isExtendedBolusEnabled); log.debug("Is Extended bolus enabled: " + pump.isExtendedBolusEnabled);
log.debug("Bolus increment: " + pump.bolusStep); log.debug("Bolus increment: " + pump.bolusStep);
log.debug("Bolus max: " + pump.maxBolus); log.debug("Bolus max: " + pump.maxBolus);

View file

@ -6,6 +6,7 @@ import org.slf4j.LoggerFactory;
import java.util.Date; import java.util.Date;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.events.EventRefreshGui; 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; import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
public class MsgInitConnStatusTime_k extends MessageBase { 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() { public MsgInitConnStatusTime_k() {
SetCommand(0x0301); SetCommand(0x0301);
if (Config.logPumpComm)
log.debug("New message");
} }
@Override @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); Notification notification = new Notification(Notification.WRONG_DRIVER, MainApp.gs(R.string.pumpdrivercorrected), Notification.NORMAL);
MainApp.bus().post(new EventNewNotification(notification)); MainApp.bus().post(new EventNewNotification(notification));
DanaRKoreanPlugin.getPlugin().disconnect("Wrong Model"); 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).setPluginEnabled(PluginType.PUMP, false);
MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setFragmentVisible(PluginType.PUMP, false); MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setFragmentVisible(PluginType.PUMP, false);
MainApp.getSpecificPlugin(DanaRPlugin.class).setPluginEnabled(PluginType.PUMP, true); 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 versionCode3 = intFromBuff(bytes, 8, 1);
int versionCode4 = intFromBuff(bytes, 9, 1); int versionCode4 = intFromBuff(bytes, 9, 1);
if (Config.logDanaMessageDetail) { if (Config.logPumpComm) {
log.debug("Pump time: " + time); log.debug("Pump time: " + time);
log.debug("Version code1: " + versionCode1); log.debug("Version code1: " + versionCode1);
log.debug("Version code2: " + versionCode2); log.debug("Version code2: " + versionCode2);

View file

@ -4,6 +4,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; 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 * THIS IS BROKEN IN PUMP... SENDING ONLY 1 PROFILE
*/ */
public class MsgSettingBasalProfileAll_k extends MessageBase { 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() { public MsgSettingBasalProfileAll_k() {
SetCommand(0x3206); SetCommand(0x3206);
if (Config.logPumpComm)
log.debug("New message");
} }
public void handleMessage(byte[] bytes) { public void handleMessage(byte[] bytes) {
@ -49,7 +52,7 @@ public class MsgSettingBasalProfileAll_k extends MessageBase {
} }
} }
if (Config.logDanaMessageDetail) { if (Config.logPumpComm) {
if (pump.basal48Enable) { if (pump.basal48Enable) {
for (int profile = 0; profile < 4; profile++) { for (int profile = 0; profile < 4; profile++) {
for (int index = 0; index < 24; index++) { for (int index = 0; index < 24; index++) {

View file

@ -4,6 +4,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin; 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. * Created by mike on 05.07.2016.
*/ */
public class MsgSettingBasal_k extends MessageBase { 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() { public MsgSettingBasal_k() {
SetCommand(0x3202); SetCommand(0x3202);
if (Config.logPumpComm)
log.debug("New message");
} }
public void handleMessage(byte[] bytes) { public void handleMessage(byte[] bytes) {
@ -28,7 +31,7 @@ public class MsgSettingBasal_k extends MessageBase {
pump.pumpProfiles[pump.activeProfile][index] = basal / 100d; pump.pumpProfiles[pump.activeProfile][index] = basal / 100d;
} }
if (Config.logDanaMessageDetail) if (Config.logPumpComm)
for (int index = 0; index < 24; index++) { for (int index = 0; index < 24; index++) {
log.debug("Basal " + String.format("%02d", index) + "h: " + pump.pumpProfiles[pump.activeProfile][index]); log.debug("Basal " + String.format("%02d", index) + "h: " + pump.pumpProfiles[pump.activeProfile][index]);
} }

View file

@ -4,15 +4,18 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
public class MsgStatusBasic_k extends 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() { public MsgStatusBasic_k() {
SetCommand(0x020A); SetCommand(0x020A);
if (Config.logPumpComm)
log.debug("New message");
} }
public void handleMessage(byte[] bytes) { public void handleMessage(byte[] bytes) {
@ -29,7 +32,7 @@ public class MsgStatusBasic_k extends MessageBase {
pump.currentBasal = currentBasal; pump.currentBasal = currentBasal;
pump.batteryRemaining = batteryRemaining; pump.batteryRemaining = batteryRemaining;
if (Config.logDanaMessageDetail) { if (Config.logPumpComm) {
log.debug("Daily total units: " + dailyTotalUnits); log.debug("Daily total units: " + dailyTotalUnits);
log.debug("Max daily total units: " + maxDailyTotalUnits); log.debug("Max daily total units: " + maxDailyTotalUnits);
log.debug("Reservoir remaining units: " + reservoirRemainingUnits); log.debug("Reservoir remaining units: " + reservoirRemainingUnits);

View file

@ -4,14 +4,17 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
public class MsgStatus_k extends 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() { public MsgStatus_k() {
SetCommand(0x020B); SetCommand(0x020B);
if (Config.logPumpComm)
log.debug("New message");
} }
public void handleMessage(byte[] bytes) { public void handleMessage(byte[] bytes) {
@ -27,7 +30,7 @@ public class MsgStatus_k extends MessageBase {
// } // }
pump.iob = intFromBuff(bytes, 15, 2) / 100d; pump.iob = intFromBuff(bytes, 15, 2) / 100d;
if (Config.logDanaMessageDetail) { if (Config.logPumpComm) {
log.debug("Daily total: " + pump.dailyTotalUnits); log.debug("Daily total: " + pump.dailyTotalUnits);
log.debug("Is extended bolus running: " + pump.isExtendedInProgress); log.debug("Is extended bolus running: " + pump.isExtendedInProgress);
log.debug("Extended bolus min: " + pump.extendedBolusMinutes); log.debug("Extended bolus min: " + pump.extendedBolusMinutes);

View file

@ -7,8 +7,6 @@ import android.os.SystemClock;
import com.squareup.otto.Subscribe; import com.squareup.otto.Subscribe;
import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.util.Date; 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.comm.MsgStatusTempBasal;
import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRNewStatus; import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRNewStatus;
import info.nightscout.androidaps.plugins.PumpDanaR.services.AbstractDanaRExecutionService; 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.SerialIOThread;
import info.nightscout.androidaps.plugins.PumpDanaRKorean.comm.MsgCheckValue_k; import info.nightscout.androidaps.plugins.PumpDanaRKorean.comm.MsgCheckValue_k;
import info.nightscout.androidaps.plugins.PumpDanaRKorean.comm.MsgSettingBasal_k; import info.nightscout.androidaps.plugins.PumpDanaRKorean.comm.MsgSettingBasal_k;
@ -63,7 +60,6 @@ import info.nightscout.utils.SP;
public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService { public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
public DanaRKoreanExecutionService() { public DanaRKoreanExecutionService() {
log = LoggerFactory.getLogger(DanaRKoreanExecutionService.class);
mBinder = new LocalBinder(); mBinder = new LocalBinder();
registerBus(); registerBus();
@ -87,7 +83,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
@Subscribe @Subscribe
public void onStatusEvent(EventAppExit event) { public void onStatusEvent(EventAppExit event) {
if (Config.logFunctionCalls) if (Config.logPump)
log.debug("EventAppExit received"); log.debug("EventAppExit received");
if (mSerialIOThread != null) if (mSerialIOThread != null)
@ -96,7 +92,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
MainApp.instance().getApplicationContext().unregisterReceiver(receiver); MainApp.instance().getApplicationContext().unregisterReceiver(receiver);
stopSelf(); stopSelf();
if (Config.logFunctionCalls) if (Config.logPump)
log.debug("EventAppExit finished"); log.debug("EventAppExit finished");
} }
@ -108,7 +104,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
public void connect() { public void connect() {
if (mDanaRPump.password != -1 && mDanaRPump.password != SP.getInt(R.string.key_danar_password, -1)) { 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 notification = new Notification(Notification.WRONG_PUMP_PASSWORD, MainApp.gs(R.string.wrongpumppassword), Notification.URGENT);
notification.soundId = R.raw.error; notification.soundId = R.raw.error;
lastWrongPumpPassword = System.currentTimeMillis(); lastWrongPumpPassword = System.currentTimeMillis();
@ -119,9 +115,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
if (mConnectionInProgress) if (mConnectionInProgress)
return; return;
new Thread(new Runnable() { new Thread(() -> {
@Override
public void run() {
mConnectionInProgress = true; mConnectionInProgress = true;
getBTSocketForSelectedPump(); getBTSocketForSelectedPump();
if (mRfcommSocket == null || mBTDevice == null) { if (mRfcommSocket == null || mBTDevice == null) {
@ -147,7 +141,6 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
} }
mConnectionInProgress = false; mConnectionInProgress = false;
}
}).start(); }).start();
} }
@ -200,11 +193,13 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime))); MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime)));
mSerialIOThread.sendMessage(new MsgSettingPumpTime()); mSerialIOThread.sendMessage(new MsgSettingPumpTime());
long timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L; long timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
if (Config.logPump)
log.debug("Pump time difference: " + timeDiff + " seconds"); log.debug("Pump time difference: " + timeDiff + " seconds");
if (Math.abs(timeDiff) > 10) { if (Math.abs(timeDiff) > 10) {
mSerialIOThread.sendMessage(new MsgSetTime(new Date())); mSerialIOThread.sendMessage(new MsgSetTime(new Date()));
mSerialIOThread.sendMessage(new MsgSettingPumpTime()); mSerialIOThread.sendMessage(new MsgSettingPumpTime());
timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L; timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
if (Config.logPump)
log.debug("Pump time difference: " + timeDiff + " seconds"); log.debug("Pump time difference: " + timeDiff + " seconds");
} }
mDanaRPump.lastSettingsRead = now; mDanaRPump.lastSettingsRead = now;
@ -214,8 +209,9 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
MainApp.bus().post(new EventInitializationChanged()); MainApp.bus().post(new EventInitializationChanged());
NSUpload.uploadDeviceStatus(); NSUpload.uploadDeviceStatus();
if (mDanaRPump.dailyTotalUnits > mDanaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) { if (mDanaRPump.dailyTotalUnits > mDanaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) {
if (Config.logPump)
log.debug("Approaching daily limit: " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits); log.debug("Approaching daily limit: " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits);
if(System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) { if (System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) {
Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.gs(R.string.approachingdailylimit), Notification.URGENT); Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.gs(R.string.approachingdailylimit), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(reportFail)); MainApp.bus().post(new EventNewNotification(reportFail));
NSUpload.uploadError(MainApp.gs(R.string.approachingdailylimit) + ": " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits + "U"); NSUpload.uploadError(MainApp.gs(R.string.approachingdailylimit) + ": " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits + "U");
@ -300,6 +296,7 @@ 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 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.stopped = true;
stop.forced = true; stop.forced = true;
if (Config.logPump)
log.debug("Communication stopped"); log.debug("Communication stopped");
} }
} }
@ -332,7 +329,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
public boolean updateBasalsInPump(final Profile profile) { public boolean updateBasalsInPump(final Profile profile) {
if (!isConnected()) return false; if (!isConnected()) return false;
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.updatingbasalrates))); 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); MsgSetSingleBasalProfile msgSet = new MsgSetSingleBasalProfile(basal);
mSerialIOThread.sendMessage(msgSet); mSerialIOThread.sendMessage(msgSet);
mDanaRPump.lastSettingsRead = 0; // force read full settings mDanaRPump.lastSettingsRead = 0; // force read full settings

View file

@ -21,6 +21,7 @@ import java.util.Date;
import info.nightscout.androidaps.BuildConfig; import info.nightscout.androidaps.BuildConfig;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.DetailedBolusInfo; 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 { 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; private static DanaRSPlugin plugin = null;
public static DanaRSPlugin getPlugin() { public static DanaRSPlugin getPlugin() {
@ -155,7 +156,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
@Override @Override
public void switchAllowed(ConfigBuilderFragment.PluginViewHolder.PluginSwitcher pluginSwitcher, FragmentActivity context) { public void switchAllowed(ConfigBuilderFragment.PluginViewHolder.PluginSwitcher pluginSwitcher, FragmentActivity context) {
boolean allowHardwarePump = SP.getBoolean("allow_hardware_pump", false); boolean allowHardwarePump = SP.getBoolean("allow_hardware_pump", false);
if (allowHardwarePump || context == null){ if (allowHardwarePump || context == null) {
pluginSwitcher.invoke(); pluginSwitcher.invoke();
} else { } else {
AlertDialog.Builder builder = new AlertDialog.Builder(context); AlertDialog.Builder builder = new AlertDialog.Builder(context);
@ -164,12 +165,14 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
pluginSwitcher.invoke(); pluginSwitcher.invoke();
SP.putBoolean("allow_hardware_pump", true); SP.putBoolean("allow_hardware_pump", true);
if (Config.logPump)
log.debug("First time HW pump allowed!"); log.debug("First time HW pump allowed!");
} }
}) })
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
pluginSwitcher.cancel(); pluginSwitcher.cancel();
if (Config.logPump)
log.debug("User does not allow switching to HW pump!"); log.debug("User does not allow switching to HW pump!");
} }
}); });
@ -180,11 +183,13 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
private ServiceConnection mConnection = new ServiceConnection() { private ServiceConnection mConnection = new ServiceConnection() {
public void onServiceDisconnected(ComponentName name) { public void onServiceDisconnected(ComponentName name) {
if (Config.logPump)
log.debug("Service is disconnected"); log.debug("Service is disconnected");
danaRSService = null; danaRSService = null;
} }
public void onServiceConnected(ComponentName name, IBinder service) { public void onServiceConnected(ComponentName name, IBinder service) {
if (Config.logPump)
log.debug("Service is connected"); log.debug("Service is connected");
DanaRSService.LocalBinder mLocalBinder = (DanaRSService.LocalBinder) service; DanaRSService.LocalBinder mLocalBinder = (DanaRSService.LocalBinder) service;
danaRSService = mLocalBinder.getServiceInstance(); danaRSService = mLocalBinder.getServiceInstance();
@ -205,6 +210,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
@Override @Override
public void connect(String from) { public void connect(String from) {
if (Config.logPump)
log.debug("RS connect from: " + from); log.debug("RS connect from: " + from);
if (danaRSService != null && !mDeviceAddress.equals("") && !mDeviceName.equals("")) { if (danaRSService != null && !mDeviceAddress.equals("") && !mDeviceName.equals("")) {
final Object o = new Object(); final Object o = new Object();
@ -225,6 +231,8 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
@Override @Override
public void disconnect(String from) { public void disconnect(String from) {
if (Config.logPump)
log.debug("RS disconnect from: " + from);
if (danaRSService != null) danaRSService.disconnect(from); if (danaRSService != null) danaRSService.disconnect(from);
} }
@ -370,6 +378,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
Double profileValue = profile.getBasalTimeFromMidnight((Integer) (h * basalIncrement)); Double profileValue = profile.getBasalTimeFromMidnight((Integer) (h * basalIncrement));
if (profileValue == null) return true; if (profileValue == null) return true;
if (Math.abs(pumpValue - profileValue) > getPumpDescription().basalStep) { if (Math.abs(pumpValue - profileValue) > getPumpDescription().basalStep) {
if (Config.logPump)
log.debug("Diff found. Hour: " + h + " Pump: " + pumpValue + " Profile: " + profileValue); log.debug("Diff found. Hour: " + h + " Pump: " + pumpValue + " Profile: " + profileValue);
return false; 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); result.comment = String.format(MainApp.gs(R.string.boluserrorcode), detailedBolusInfo.insulin, t.insulin, DanaRS_Packet_Bolus_Set_Step_Bolus_Start.errorCode);
else else
result.comment = MainApp.gs(R.string.virtualpump_resultok); result.comment = MainApp.gs(R.string.virtualpump_resultok);
if (Config.logPumpActions) if (Config.logPump)
log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered); log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered);
return result; return result;
} else { } else {
@ -474,7 +483,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
if (doTempOff) { if (doTempOff) {
// If temp in progress // If temp in progress
if (TreatmentsPlugin.getPlugin().isTempBasalInProgress()) { if (TreatmentsPlugin.getPlugin().isTempBasalInProgress()) {
if (Config.logPumpActions) if (Config.logPump)
log.debug("setTempBasalAbsolute: Stopping temp basal (doTempOff)"); log.debug("setTempBasalAbsolute: Stopping temp basal (doTempOff)");
return cancelTempBasal(false); return cancelTempBasal(false);
} }
@ -483,7 +492,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
result.percent = 100; result.percent = 100;
result.isPercent = true; result.isPercent = true;
result.isTempCancel = true; result.isTempCancel = true;
if (Config.logPumpActions) if (Config.logPump)
log.debug("setTempBasalAbsolute: doTempOff OK"); log.debug("setTempBasalAbsolute: doTempOff OK");
return result; return result;
} }
@ -497,7 +506,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
// Check if some temp is already in progress // Check if some temp is already in progress
TemporaryBasal activeTemp = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(System.currentTimeMillis()); TemporaryBasal activeTemp = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(System.currentTimeMillis());
if (activeTemp != null) { if (activeTemp != null) {
if (Config.logPumpActions) if (Config.logPump)
log.debug("setTempBasalAbsolute: currently running: " + activeTemp.toString()); log.debug("setTempBasalAbsolute: currently running: " + activeTemp.toString());
// Correct basal already set ? // Correct basal already set ?
if (activeTemp.percentRate == percentRate) { if (activeTemp.percentRate == percentRate) {
@ -508,14 +517,14 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
result.duration = activeTemp.getPlannedRemainingMinutes(); result.duration = activeTemp.getPlannedRemainingMinutes();
result.isPercent = true; result.isPercent = true;
result.isTempCancel = false; result.isTempCancel = false;
if (Config.logPumpActions) if (Config.logPump)
log.debug("setTempBasalAbsolute: Correct temp basal already set (doLowTemp || doHighTemp)"); log.debug("setTempBasalAbsolute: Correct temp basal already set (doLowTemp || doHighTemp)");
return result; return result;
} }
} }
} }
// Convert duration from minutes to hours // Convert duration from minutes to hours
if (Config.logPumpActions) if (Config.logPump)
log.debug("setTempBasalAbsolute: Setting temp basal " + percentRate + "% for " + durationInMinutes + " mins (doLowTemp || doHighTemp)"); log.debug("setTempBasalAbsolute: Setting temp basal " + percentRate + "% for " + durationInMinutes + " mins (doLowTemp || doHighTemp)");
if (percentRate == 0 && durationInMinutes > 30) { if (percentRate == 0 && durationInMinutes > 30) {
result = setTempBasalPercent(percentRate, durationInMinutes, profile, false); 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"); log.error("setTempBasalAbsolute: Failed to set hightemp basal");
return result; return result;
} }
if (Config.logPumpActions) if (Config.logPump)
log.debug("setTempBasalAbsolute: hightemp basal set ok"); log.debug("setTempBasalAbsolute: hightemp basal set ok");
return result; return result;
} }
@ -562,7 +571,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
result.duration = pump.tempBasalRemainingMin; result.duration = pump.tempBasalRemainingMin;
result.percent = pump.tempBasalPercent; result.percent = pump.tempBasalPercent;
result.isPercent = true; result.isPercent = true;
if (Config.logPumpActions) if (Config.logPump)
log.debug("setTempBasalPercent: Correct value already set"); log.debug("setTempBasalPercent: Correct value already set");
return result; return result;
} }
@ -581,7 +590,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
result.duration = pump.tempBasalRemainingMin; result.duration = pump.tempBasalRemainingMin;
result.percent = pump.tempBasalPercent; result.percent = pump.tempBasalPercent;
result.isPercent = true; result.isPercent = true;
if (Config.logPumpActions) if (Config.logPump)
log.debug("setTempBasalPercent: OK"); log.debug("setTempBasalPercent: OK");
return result; return result;
} }
@ -603,7 +612,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
result.duration = pump.tempBasalRemainingMin; result.duration = pump.tempBasalRemainingMin;
result.percent = pump.tempBasalPercent; result.percent = pump.tempBasalPercent;
result.isPercent = true; result.isPercent = true;
if (Config.logPumpActions) if (Config.logPump)
log.debug("setHighTempBasalPercent: OK"); log.debug("setHighTempBasalPercent: OK");
return result; return result;
} }
@ -630,7 +639,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
result.absolute = pump.extendedBolusAbsoluteRate; result.absolute = pump.extendedBolusAbsoluteRate;
result.isPercent = false; result.isPercent = false;
result.isTempCancel = false; result.isTempCancel = false;
if (Config.logPumpActions) if (Config.logPump)
log.debug("setExtendedBolus: Correct extended bolus already set. Current: " + pump.extendedBolusAmount + " Asked: " + insulin); log.debug("setExtendedBolus: Correct extended bolus already set. Current: " + pump.extendedBolusAmount + " Asked: " + insulin);
return result; return result;
} }
@ -644,7 +653,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
result.absolute = pump.extendedBolusAbsoluteRate; result.absolute = pump.extendedBolusAbsoluteRate;
result.bolusDelivered = pump.extendedBolusAmount; result.bolusDelivered = pump.extendedBolusAmount;
result.isPercent = false; result.isPercent = false;
if (Config.logPumpActions) if (Config.logPump)
log.debug("setExtendedBolus: OK"); log.debug("setExtendedBolus: OK");
return result; return result;
} }
@ -668,7 +677,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
result.success = true; result.success = true;
result.isTempCancel = true; result.isTempCancel = true;
result.comment = MainApp.gs(R.string.virtualpump_resultok); result.comment = MainApp.gs(R.string.virtualpump_resultok);
if (Config.logPumpActions) if (Config.logPump)
log.debug("cancelRealTempBasal: OK"); log.debug("cancelRealTempBasal: OK");
return result; return result;
} else { } else {
@ -692,7 +701,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
if (!pump.isExtendedInProgress) { if (!pump.isExtendedInProgress) {
result.success = true; result.success = true;
result.comment = MainApp.gs(R.string.virtualpump_resultok); result.comment = MainApp.gs(R.string.virtualpump_resultok);
if (Config.logPumpActions) if (Config.logPump)
log.debug("cancelExtendedBolus: OK"); log.debug("cancelExtendedBolus: OK");
return result; return result;
} else { } else {

View file

@ -31,9 +31,6 @@ import info.nightscout.androidaps.plugins.PumpDanaRS.events.EventDanaRSDeviceCha
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
public class BLEScanActivity extends AppCompatActivity { public class BLEScanActivity extends AppCompatActivity {
private static Logger log = LoggerFactory.getLogger(BLEScanActivity.class);
private ListView listView = null; private ListView listView = null;
private ListAdapter mListAdapter = null; private ListAdapter mListAdapter = null;
private ArrayList<BluetoothDeviceItem> mDevices = new ArrayList<>(); private ArrayList<BluetoothDeviceItem> mDevices = new ArrayList<>();

View file

@ -9,7 +9,6 @@ import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.Window;
import android.widget.Button; import android.widget.Button;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.TextView; import android.widget.TextView;
@ -63,24 +62,19 @@ public class PairingProgressDialog extends DialogFragment implements View.OnClic
button.setOnClickListener(this); button.setOnClickListener(this);
setCancelable(false); setCancelable(false);
sHandler.post(new Runnable() { sHandler.post(() -> {
@Override
public void run() {
for (int i = 0; i < 20; i++) { for (int i = 0; i < 20; i++) {
if (pairingEnded) { if (pairingEnded) {
Activity activity = getActivity(); Activity activity = getActivity();
if (activity != null) { if (activity != null) {
activity.runOnUiThread(new Runnable() { activity.runOnUiThread(() -> {
@Override
public void run() {
progressBar.setProgress(100); progressBar.setProgress(100);
statusView.setText(R.string.pairingok); statusView.setText(R.string.pairingok);
try { try {
Thread.sleep(1000); Thread.sleep(1000);
} catch (InterruptedException e) { } catch (InterruptedException ignored) {
} }
dismiss(); dismiss();
}
}); });
} else } else
dismiss(); dismiss();
@ -89,21 +83,17 @@ public class PairingProgressDialog extends DialogFragment implements View.OnClic
progressBar.setProgress(i * 5); progressBar.setProgress(i * 5);
try { try {
Thread.sleep(1000); Thread.sleep(1000);
} catch (InterruptedException e) { } catch (InterruptedException ignored) {
} }
} }
Activity activity = getActivity(); Activity activity = getActivity();
if (activity != null) { if (activity != null) {
activity.runOnUiThread(new Runnable() { activity.runOnUiThread(() -> {
@Override
public void run() {
progressBar.setProgress(100); progressBar.setProgress(100);
statusView.setText(R.string.pairingtimedout); statusView.setText(R.string.pairingtimedout);
button.setVisibility(View.VISIBLE); button.setVisibility(View.VISIBLE);
}
}); });
} }
}
}); });
return view; return view;
} }

View file

@ -11,14 +11,12 @@ import info.nightscout.androidaps.Config;
* Created by mike on 28.05.2016. * Created by mike on 28.05.2016.
*/ */
public class DanaRSMessageHashTable { public class DanaRSMessageHashTable {
private static Logger log = LoggerFactory.getLogger(DanaRSMessageHashTable.class);
public static HashMap<Integer, DanaRS_Packet> messages = null; public static HashMap<Integer, DanaRS_Packet> messages = null;
static { static {
if (messages == null) { if (messages == null) {
boolean savedState = Config.logDanaMessageDetail; boolean savedState = Config.logPumpComm;
Config.logDanaMessageDetail = false; Config.logPumpComm = false;
messages = new HashMap<>(); messages = new HashMap<>();
put(new DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal()); 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_History_Events());
put(new DanaRS_Packet_APS_Set_Event_History()); put(new DanaRS_Packet_APS_Set_Event_History());
Config.logDanaMessageDetail = savedState; Config.logPumpComm = savedState;
} }
} }

View file

@ -6,9 +6,10 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
public class DanaRS_Packet_APS_Basal_Set_Temporary_Basal extends DanaRS_Packet { 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 temporaryBasalRatio;
int temporaryBasalDuration; 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) { public DanaRS_Packet_APS_Basal_Set_Temporary_Basal(int percent) {
this(); this();
setParams(percent); setParams(percent);
if (Config.logPumpComm)
log.debug("New message: percent: " + percent);
} }
protected void setParams(int percent) { protected void setParams(int percent) {
@ -35,16 +38,16 @@ public class DanaRS_Packet_APS_Basal_Set_Temporary_Basal extends DanaRS_Packet {
temporaryBasalRatio = percent; temporaryBasalRatio = percent;
if (percent < 100) { if (percent < 100) {
temporaryBasalDuration = PARAM30MIN; temporaryBasalDuration = PARAM30MIN;
if (Config.logDanaMessageDetail) if (Config.logPumpComm)
log.debug("APS Temp basal start percent: " + percent + " duration 30 min"); log.debug("APS Temp basal start percent: " + percent + " duration 30 min");
} else { } else {
temporaryBasalDuration = PARAM15MIN; temporaryBasalDuration = PARAM15MIN;
if (Config.logDanaMessageDetail) if (Config.logPumpComm)
log.debug("APS Temp basal start percent: " + percent + " duration 15 min"); 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(); this();
setParams(percent, fifteenMinutes, thirtyMinutes); setParams(percent, fifteenMinutes, thirtyMinutes);
} }
@ -57,11 +60,11 @@ public class DanaRS_Packet_APS_Basal_Set_Temporary_Basal extends DanaRS_Packet {
temporaryBasalRatio = percent; temporaryBasalRatio = percent;
if (thirtyMinutes && percent <= 200) { // 30 min is allowed up to 200% if (thirtyMinutes && percent <= 200) { // 30 min is allowed up to 200%
temporaryBasalDuration = PARAM30MIN; temporaryBasalDuration = PARAM30MIN;
if (Config.logDanaMessageDetail) if (Config.logPumpComm)
log.debug("APS Temp basal start percent: " + percent + " duration 30 min"); log.debug("APS Temp basal start percent: " + percent + " duration 30 min");
} else { } else {
temporaryBasalDuration = PARAM15MIN; temporaryBasalDuration = PARAM15MIN;
if (Config.logDanaMessageDetail) if (Config.logPumpComm)
log.debug("APS Temp basal start percent: " + percent + " duration 15 min"); 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)); int result = byteArrayToInt(getBytes(data, DATA_START, 1));
if (result != 0) { if (result != 0) {
failed = true; 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 { } else {
failed = false; failed = false;
if (Config.logDanaMessageDetail) if (Config.logPumpComm)
log.debug("Set APS temp basal start result: " + result); log.debug("Set APS temp basal start result: " + result);
} }
} }

View file

@ -9,6 +9,8 @@ import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.DetailedBolusInfo; import info.nightscout.androidaps.data.DetailedBolusInfo;
@ -22,7 +24,7 @@ import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.utils.DateUtil; import info.nightscout.utils.DateUtil;
public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet { 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 year = 0;
private int month = 0; private int month = 0;
@ -32,7 +34,6 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet {
private int sec = 0; private int sec = 0;
public static boolean done; public static boolean done;
private static int totalCount;
public static long lastEventTimeLoaded = 0; public static long lastEventTimeLoaded = 0;
@ -40,7 +41,6 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet {
super(); super();
opCode = BleCommandUtil.DANAR_PACKET__OPCODE__APS_HISTORY_EVENTS; opCode = BleCommandUtil.DANAR_PACKET__OPCODE__APS_HISTORY_EVENTS;
done = false; done = false;
totalCount = 0;
} }
public DanaRS_Packet_APS_History_Events(long from) { public DanaRS_Packet_APS_History_Events(long from) {
@ -56,6 +56,7 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet {
hour = cal.get(Calendar.HOUR_OF_DAY); hour = cal.get(Calendar.HOUR_OF_DAY);
min = cal.get(Calendar.MINUTE); min = cal.get(Calendar.MINUTE);
sec = cal.get(Calendar.SECOND); sec = cal.get(Calendar.SECOND);
if (Config.logPumpComm)
log.debug("Loading event history from: " + new Date(cal.getTimeInMillis()).toLocaleString()); log.debug("Loading event history from: " + new Date(cal.getTimeInMillis()).toLocaleString());
} }
@ -78,6 +79,7 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet {
// Last record // Last record
if (recordCode == (byte) 0xFF) { if (recordCode == (byte) 0xFF) {
done = true; done = true;
if (Config.logPumpComm)
log.debug("Last record received"); log.debug("Last record received");
return; return;
} }
@ -95,9 +97,11 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet {
DetailedBolusInfo detailedBolusInfo = DetailedBolusInfoStorage.findDetailedBolusInfo(datetime.getTime()); DetailedBolusInfo detailedBolusInfo = DetailedBolusInfoStorage.findDetailedBolusInfo(datetime.getTime());
if (detailedBolusInfo == null) { if (detailedBolusInfo == null) {
if (Config.logPumpComm)
log.debug("Detailed bolus info not found for " + datetime.toLocaleString()); log.debug("Detailed bolus info not found for " + datetime.toLocaleString());
detailedBolusInfo = new DetailedBolusInfo(); detailedBolusInfo = new DetailedBolusInfo();
} else { } else {
if (Config.logPumpComm)
log.debug("Detailed bolus info found: " + detailedBolusInfo); log.debug("Detailed bolus info found: " + detailedBolusInfo);
} }
detailedBolusInfo.date = datetime.getTime(); detailedBolusInfo.date = datetime.getTime();
@ -108,6 +112,7 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet {
switch (recordCode) { switch (recordCode) {
case DanaRPump.TEMPSTART: case DanaRPump.TEMPSTART:
if (Config.logPumpComm)
log.debug("EVENT TEMPSTART (" + recordCode + ") " + datetime.toLocaleString() + " Ratio: " + param1 + "% Duration: " + param2 + "min"); log.debug("EVENT TEMPSTART (" + recordCode + ") " + datetime.toLocaleString() + " Ratio: " + param1 + "% Duration: " + param2 + "min");
temporaryBasal.percentRate = param1; temporaryBasal.percentRate = param1;
temporaryBasal.durationInMinutes = param2; temporaryBasal.durationInMinutes = param2;
@ -115,11 +120,13 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet {
status = "TEMPSTART " + DateUtil.timeString(datetime); status = "TEMPSTART " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.TEMPSTOP: case DanaRPump.TEMPSTOP:
if (Config.logPumpComm)
log.debug("EVENT TEMPSTOP (" + recordCode + ") " + datetime.toLocaleString()); log.debug("EVENT TEMPSTOP (" + recordCode + ") " + datetime.toLocaleString());
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(temporaryBasal); TreatmentsPlugin.getPlugin().addToHistoryTempBasal(temporaryBasal);
status = "TEMPSTOP " + DateUtil.timeString(datetime); status = "TEMPSTOP " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.EXTENDEDSTART: case DanaRPump.EXTENDEDSTART:
if (Config.logPumpComm)
log.debug("EVENT EXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min"); log.debug("EVENT EXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min");
extendedBolus.insulin = param1 / 100d; extendedBolus.insulin = param1 / 100d;
extendedBolus.durationInMinutes = param2; extendedBolus.durationInMinutes = param2;
@ -127,6 +134,7 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet {
status = "EXTENDEDSTART " + DateUtil.timeString(datetime); status = "EXTENDEDSTART " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.EXTENDEDSTOP: case DanaRPump.EXTENDEDSTOP:
if (Config.logPumpComm)
log.debug("EVENT EXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min"); log.debug("EVENT EXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min");
TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus); TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus);
status = "EXTENDEDSTOP " + DateUtil.timeString(datetime); status = "EXTENDEDSTOP " + DateUtil.timeString(datetime);
@ -134,6 +142,7 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet {
case DanaRPump.BOLUS: case DanaRPump.BOLUS:
detailedBolusInfo.insulin = param1 / 100d; detailedBolusInfo.insulin = param1 / 100d;
boolean newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false); boolean newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false);
if (Config.logPumpComm)
log.debug((newRecord ? "**NEW** " : "") + "EVENT BOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min"); log.debug((newRecord ? "**NEW** " : "") + "EVENT BOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min");
DetailedBolusInfoStorage.remove(detailedBolusInfo.date); DetailedBolusInfoStorage.remove(detailedBolusInfo.date);
status = "BOLUS " + DateUtil.timeString(datetime); status = "BOLUS " + DateUtil.timeString(datetime);
@ -141,11 +150,13 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet {
case DanaRPump.DUALBOLUS: case DanaRPump.DUALBOLUS:
detailedBolusInfo.insulin = param1 / 100d; detailedBolusInfo.insulin = param1 / 100d;
newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false); newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false);
if (Config.logPumpComm)
log.debug((newRecord ? "**NEW** " : "") + "EVENT DUALBOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min"); log.debug((newRecord ? "**NEW** " : "") + "EVENT DUALBOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min");
DetailedBolusInfoStorage.remove(detailedBolusInfo.date); DetailedBolusInfoStorage.remove(detailedBolusInfo.date);
status = "DUALBOLUS " + DateUtil.timeString(datetime); status = "DUALBOLUS " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.DUALEXTENDEDSTART: case DanaRPump.DUALEXTENDEDSTART:
if (Config.logPumpComm)
log.debug("EVENT DUALEXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min"); log.debug("EVENT DUALEXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min");
extendedBolus.insulin = param1 / 100d; extendedBolus.insulin = param1 / 100d;
extendedBolus.durationInMinutes = param2; extendedBolus.durationInMinutes = param2;
@ -153,27 +164,33 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet {
status = "DUALEXTENDEDSTART " + DateUtil.timeString(datetime); status = "DUALEXTENDEDSTART " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.DUALEXTENDEDSTOP: case DanaRPump.DUALEXTENDEDSTOP:
if (Config.logPumpComm)
log.debug("EVENT DUALEXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min"); log.debug("EVENT DUALEXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min");
TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus); TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus);
status = "DUALEXTENDEDSTOP " + DateUtil.timeString(datetime); status = "DUALEXTENDEDSTOP " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.SUSPENDON: case DanaRPump.SUSPENDON:
if (Config.logPumpComm)
log.debug("EVENT SUSPENDON (" + recordCode + ") " + datetime.toLocaleString()); log.debug("EVENT SUSPENDON (" + recordCode + ") " + datetime.toLocaleString());
status = "SUSPENDON " + DateUtil.timeString(datetime); status = "SUSPENDON " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.SUSPENDOFF: case DanaRPump.SUSPENDOFF:
if (Config.logPumpComm)
log.debug("EVENT SUSPENDOFF (" + recordCode + ") " + datetime.toLocaleString()); log.debug("EVENT SUSPENDOFF (" + recordCode + ") " + datetime.toLocaleString());
status = "SUSPENDOFF " + DateUtil.timeString(datetime); status = "SUSPENDOFF " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.REFILL: case DanaRPump.REFILL:
if (Config.logPumpComm)
log.debug("EVENT REFILL (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U"); log.debug("EVENT REFILL (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U");
status = "REFILL " + DateUtil.timeString(datetime); status = "REFILL " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.PRIME: case DanaRPump.PRIME:
if (Config.logPumpComm)
log.debug("EVENT PRIME (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U"); log.debug("EVENT PRIME (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U");
status = "PRIME " + DateUtil.timeString(datetime); status = "PRIME " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.PROFILECHANGE: case DanaRPump.PROFILECHANGE:
if (Config.logPumpComm)
log.debug("EVENT PROFILECHANGE (" + recordCode + ") " + datetime.toLocaleString() + " No: " + param1 + " CurrentRate: " + (param2 / 100d) + "U/h"); log.debug("EVENT PROFILECHANGE (" + recordCode + ") " + datetime.toLocaleString() + " No: " + param1 + " CurrentRate: " + (param2 / 100d) + "U/h");
status = "PROFILECHANGE " + DateUtil.timeString(datetime); status = "PROFILECHANGE " + DateUtil.timeString(datetime);
break; break;
@ -184,14 +201,17 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet {
emptyCarbsInfo.source = Source.PUMP; emptyCarbsInfo.source = Source.PUMP;
emptyCarbsInfo.pumpId = datetime.getTime(); emptyCarbsInfo.pumpId = datetime.getTime();
newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(emptyCarbsInfo, false); newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(emptyCarbsInfo, false);
if (Config.logPumpComm)
log.debug((newRecord ? "**NEW** " : "") + "EVENT CARBS (" + recordCode + ") " + datetime.toLocaleString() + " Carbs: " + param1 + "g"); log.debug((newRecord ? "**NEW** " : "") + "EVENT CARBS (" + recordCode + ") " + datetime.toLocaleString() + " Carbs: " + param1 + "g");
status = "CARBS " + DateUtil.timeString(datetime); status = "CARBS " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.PRIMECANNULA: case DanaRPump.PRIMECANNULA:
if (Config.logPumpComm)
log.debug("EVENT PRIMECANNULA(" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U"); log.debug("EVENT PRIMECANNULA(" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U");
status = "PRIMECANNULA " + DateUtil.timeString(datetime); status = "PRIMECANNULA " + DateUtil.timeString(datetime);
break; break;
default: default:
if (Config.logPumpComm)
log.debug("Event: " + recordCode + " " + datetime.toLocaleString() + " Param1: " + param1 + " Param2: " + param2); log.debug("Event: " + recordCode + " " + datetime.toLocaleString() + " Param1: " + param1 + " Param2: " + param2);
status = "UNKNOWN " + DateUtil.timeString(datetime); status = "UNKNOWN " + DateUtil.timeString(datetime);
break; break;

View file

@ -9,15 +9,16 @@ import java.util.Calendar;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.utils.DateUtil; import info.nightscout.utils.DateUtil;
public class DanaRS_Packet_APS_Set_Event_History extends DanaRS_Packet { 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 int type;
private long time; private long time;
public int param1; private int param1;
public int param2; private int param2;
public DanaRS_Packet_APS_Set_Event_History() { public DanaRS_Packet_APS_Set_Event_History() {
super(); super();
@ -31,7 +32,7 @@ public class DanaRS_Packet_APS_Set_Event_History extends DanaRS_Packet {
this.time = time; this.time = time;
this.param1 = param1; this.param1 = param1;
this.param2 = param2; this.param2 = param2;
if (Config.logDanaMessageDetail) if (Config.logPumpComm)
log.debug("Set history entry: " + DateUtil.dateAndTimeString(time) + " type: " + type + " param1: " + param1 + " param2: " + param2); 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); int result = intFromBuff(data, 0, 1);
if (result != 0) { if (result != 0) {
failed = true; failed = true;
if (Config.logPumpComm)
log.error("Set history entry result: " + result + " FAILED!!!"); log.error("Set history entry result: " + result + " FAILED!!!");
} else { } else {
if (Config.logDanaMessageDetail) if (Config.logPumpComm)
log.debug("Set history entry result: " + result); log.debug("Set history entry result: " + result);
} }
} }

View file

@ -1,27 +1,28 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm; package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
import com.cozmo.danar.util.BleCommandUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import com.cozmo.danar.util.BleCommandUtil;
public class DanaRS_Packet_Basal_Get_Basal_Rate extends DanaRS_Packet { 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() { public DanaRS_Packet_Basal_Get_Basal_Rate() {
super(); super();
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__GET_BASAL_RATE; opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__GET_BASAL_RATE;
if (Config.logDanaMessageDetail) { if (Config.logPumpComm) {
log.debug("Requesting basal rates"); log.debug("Requesting basal rates");
} }
} }
@ -45,7 +46,7 @@ public class DanaRS_Packet_Basal_Get_Basal_Rate extends DanaRS_Packet {
dataSize = 2; dataSize = 2;
pump.pumpProfiles[pump.activeProfile][i] = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d; 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("Max basal: " + pump.maxBasal + " U");
log.debug("Basal step: " + pump.basalStep + " U"); log.debug("Basal step: " + pump.basalStep + " U");
for (int index = 0; index < 24; index++) for (int index = 0; index < 24; index++)

View file

@ -1,14 +1,16 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm; package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
import com.cozmo.danar.util.BleCommandUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import com.cozmo.danar.util.BleCommandUtil; import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
public class DanaRS_Packet_Basal_Get_Profile_Basal_Rate extends DanaRS_Packet { 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; 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) { public DanaRS_Packet_Basal_Get_Profile_Basal_Rate(int profileNumber) {
this(); this();
this.profileNumber = profileNumber; this.profileNumber = profileNumber;
if (Config.logDanaMessageDetail) { if (Config.logPumpComm) {
log.debug("Requesting basal rates for profile " + profileNumber); 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; dataIndex += dataSize;
dataSize = 2; dataSize = 2;
} }
if (Config.logDanaMessageDetail) { if (Config.logPumpComm) {
for (int index = 0; index < 24; index++) for (int index = 0; index < 24; index++)
log.debug("Basal " + String.format("%02d", index) + "h: " + pump.pumpProfiles[profileNumber][index]); log.debug("Basal " + String.format("%02d", index) + "h: " + pump.pumpProfiles[profileNumber][index]);
} }

View file

@ -1,19 +1,21 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm; package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
import com.cozmo.danar.util.BleCommandUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import com.cozmo.danar.util.BleCommandUtil; import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
public class DanaRS_Packet_Basal_Get_Profile_Number extends DanaRS_Packet { 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() { public DanaRS_Packet_Basal_Get_Profile_Number() {
super(); super();
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__GET_PROFILE_NUMBER; opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__GET_PROFILE_NUMBER;
if (Config.logDanaMessageDetail) { if (Config.logPumpComm) {
log.debug("Requesting active profile"); 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 dataIndex = DATA_START;
int dataSize = 1; int dataSize = 1;
pump.activeProfile = byteArrayToInt(getBytes(data, dataIndex, dataSize)); pump.activeProfile = byteArrayToInt(getBytes(data, dataIndex, dataSize));
if (Config.logDanaMessageDetail) { if (Config.logPumpComm) {
log.debug("Active profile: " + pump.activeProfile); log.debug("Active profile: " + pump.activeProfile);
} }
} }

View file

@ -2,22 +2,24 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import com.cozmo.danar.util.BleCommandUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.Date; import java.util.Date;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import com.cozmo.danar.util.BleCommandUtil; import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
public class DanaRS_Packet_Basal_Get_Temporary_Basal_State extends DanaRS_Packet { 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() { public DanaRS_Packet_Basal_Get_Temporary_Basal_State() {
super(); super();
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__TEMPORARY_BASAL_STATE; opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__TEMPORARY_BASAL_STATE;
if (Config.logDanaMessageDetail) { if (Config.logPumpComm) {
log.debug("Requesting temporary basal status"); 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; int tempBasalRemainingMin = (pump.tempBasalTotalSec - runningMin * 60) / 60;
Date tempBasalStart = pump.isTempBasalInProgress ? getDateFromTempBasalSecAgo(runningMin * 60) : new Date(0); Date tempBasalStart = pump.isTempBasalInProgress ? getDateFromTempBasalSecAgo(runningMin * 60) : new Date(0);
if (Config.logDanaMessageDetail) { if (Config.logPumpComm) {
log.debug("Error code: " + error); log.debug("Error code: " + error);
log.debug("Is temp basal running: " + pump.isTempBasalInProgress); log.debug("Is temp basal running: " + pump.isTempBasalInProgress);
log.debug("Is APS temp basal running: " + isAPSTempBasalInProgress); log.debug("Is APS temp basal running: " + isAPSTempBasalInProgress);

View file

@ -4,11 +4,12 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import com.cozmo.danar.util.BleCommandUtil; import com.cozmo.danar.util.BleCommandUtil;
public class DanaRS_Packet_Basal_Set_Basal_Rate extends DanaRS_Packet { 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; 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) { public DanaRS_Packet_Basal_Set_Basal_Rate(double[] profileBasalRate) {
this(); this();
this.profileBasalRate = profileBasalRate; this.profileBasalRate = profileBasalRate;
if (Config.logDanaMessageDetail) { if (Config.logPumpComm) {
log.debug("Setting new basal rates"); log.debug("Setting new basal rates");
} }
} }
@ -39,7 +40,7 @@ public class DanaRS_Packet_Basal_Set_Basal_Rate extends DanaRS_Packet {
@Override @Override
public void handleMessage(byte[] data) { public void handleMessage(byte[] data) {
int result = intFromBuff(data, 0, 1); int result = intFromBuff(data, 0, 1);
if (Config.logDanaMessageDetail) { if (Config.logPumpComm) {
if (result == 0) if (result == 0)
log.debug("Result OK"); log.debug("Result OK");
else else

View file

@ -1,19 +1,20 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm; package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
import com.cozmo.danar.util.BleCommandUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import com.cozmo.danar.util.BleCommandUtil;
public class DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal extends DanaRS_Packet { 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() { public DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal() {
super(); super();
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__CANCEL_TEMPORARY_BASAL; opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__CANCEL_TEMPORARY_BASAL;
if (Config.logDanaMessageDetail) { if (Config.logPumpComm) {
log.debug("Canceling temp basal"); log.debug("Canceling temp basal");
} }
} }
@ -21,7 +22,7 @@ public class DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal extends DanaRS_Packe
@Override @Override
public void handleMessage(byte[] data) { public void handleMessage(byte[] data) {
int result = intFromBuff(data, 0, 1); int result = intFromBuff(data, 0, 1);
if (Config.logDanaMessageDetail) { if (Config.logPumpComm) {
if (result == 0) if (result == 0)
log.debug("Result OK"); log.debug("Result OK");
else else

View file

@ -1,13 +1,15 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm; package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
import com.cozmo.danar.util.BleCommandUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import com.cozmo.danar.util.BleCommandUtil; import info.nightscout.androidaps.Constants;
public class DanaRS_Packet_Basal_Set_Profile_Basal_Rate extends DanaRS_Packet { 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 int profileNumber; // 0 - 4
private double[] profileBasalRate; private double[] profileBasalRate;
@ -21,7 +23,7 @@ public class DanaRS_Packet_Basal_Set_Profile_Basal_Rate extends DanaRS_Packet {
this(); this();
this.profileNumber = profileNumber; this.profileNumber = profileNumber;
this.profileBasalRate = profileBasalRate; this.profileBasalRate = profileBasalRate;
if (Config.logDanaMessageDetail) { if (Config.logPumpComm) {
log.debug("Setting new basal rates for profile " + profileNumber); 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 @Override
public void handleMessage(byte[] data) { public void handleMessage(byte[] data) {
int result = intFromBuff(data, 0, 1); int result = intFromBuff(data, 0, 1);
if (Config.logDanaMessageDetail) { if (Config.logPumpComm) {
if (result == 0) if (result == 0)
log.debug("Result OK"); log.debug("Result OK");
else else

View file

@ -1,24 +1,26 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm; package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
import com.cozmo.danar.util.BleCommandUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import com.cozmo.danar.util.BleCommandUtil;
public class DanaRS_Packet_Basal_Set_Profile_Number extends DanaRS_Packet { 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 Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM);
private int profileNumber; private int profileNumber;
public DanaRS_Packet_Basal_Set_Profile_Number() { public DanaRS_Packet_Basal_Set_Profile_Number() {
super(); super();
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__SET_PROFILE_NUMBER; opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__SET_PROFILE_NUMBER;
} }
public DanaRS_Packet_Basal_Set_Profile_Number(int profileNumber) { public DanaRS_Packet_Basal_Set_Profile_Number(int profileNumber) {
this(); this();
this.profileNumber = profileNumber; this.profileNumber = profileNumber;
if (Config.logDanaMessageDetail) { if (Config.logPumpComm) {
log.debug("Setting profile number " + profileNumber); log.debug("Setting profile number " + profileNumber);
} }
} }
@ -33,7 +35,7 @@ public class DanaRS_Packet_Basal_Set_Profile_Number extends DanaRS_Packet {
@Override @Override
public void handleMessage(byte[] data) { public void handleMessage(byte[] data) {
int result = intFromBuff(data, 0, 1); int result = intFromBuff(data, 0, 1);
if (Config.logDanaMessageDetail) { if (Config.logPumpComm) {
if (result == 0) if (result == 0)
log.debug("Result OK"); log.debug("Result OK");
else else

View file

@ -1,18 +1,20 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm; package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
import com.cozmo.danar.util.BleCommandUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import com.cozmo.danar.util.BleCommandUtil; import info.nightscout.androidaps.Constants;
public class DanaRS_Packet_Basal_Set_Suspend_Off extends DanaRS_Packet { 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() { public DanaRS_Packet_Basal_Set_Suspend_Off() {
super(); super();
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__SET_SUSPEND_OFF; opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__SET_SUSPEND_OFF;
if (Config.logDanaMessageDetail) { if (Config.logPumpComm) {
log.debug("Turning off suspend"); log.debug("Turning off suspend");
} }
} }
@ -20,7 +22,7 @@ public class DanaRS_Packet_Basal_Set_Suspend_Off extends DanaRS_Packet {
@Override @Override
public void handleMessage(byte[] data) { public void handleMessage(byte[] data) {
int result = intFromBuff(data, 0, 1); int result = intFromBuff(data, 0, 1);
if (Config.logDanaMessageDetail) { if (Config.logPumpComm) {
if (result == 0) if (result == 0)
log.debug("Result OK"); log.debug("Result OK");
else else

View file

@ -1,18 +1,20 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm; package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
import com.cozmo.danar.util.BleCommandUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import com.cozmo.danar.util.BleCommandUtil; import info.nightscout.androidaps.Constants;
public class DanaRS_Packet_Basal_Set_Suspend_On extends DanaRS_Packet { 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() { public DanaRS_Packet_Basal_Set_Suspend_On() {
super(); super();
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__SET_SUSPEND_ON; opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__SET_SUSPEND_ON;
if (Config.logDanaMessageDetail) { if (Config.logPumpComm) {
log.debug("Turning on suspend"); log.debug("Turning on suspend");
} }
} }
@ -20,7 +22,7 @@ public class DanaRS_Packet_Basal_Set_Suspend_On extends DanaRS_Packet {
@Override @Override
public void handleMessage(byte[] data) { public void handleMessage(byte[] data) {
int result = intFromBuff(data, 0, 1); int result = intFromBuff(data, 0, 1);
if (Config.logDanaMessageDetail) { if (Config.logPumpComm) {
if (result == 0) if (result == 0)
log.debug("Result OK"); log.debug("Result OK");
else else

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