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 logIncommingData = true;
public static final boolean logAPSResult = true;
public static final boolean logPumpComm = true;
public static final boolean logPrefsChange = true;
public static final boolean logConfigBuilder = true;
public static final boolean logNSUpload = true;
public static final boolean logPumpActions = true;
public static final boolean logCongigBuilderActions = true;
public static final boolean logAutosensData = false;
public static final boolean logEvents = false;
@ -45,9 +43,8 @@ public class Config {
public static final boolean logDataTreatments = true;
public static final boolean logNsclient = true;
public static final boolean logObjectives = false;
public static final boolean logPump = true;
public static boolean logPumpComm = true;
public static final boolean logPumpBtComm = false;
// DanaR specific
public static final boolean logDanaBTComm = true;
public static boolean logDanaMessageDetail = true;
public static final boolean logDanaSerialEngine = true;
}

View file

@ -71,7 +71,6 @@ public class Constants {
// logging
public static final String AUTOSENS = "AUTOSENS";
public static final String EVENTS = "EVENTS";
public static final String QUEUE = "QUEUE";
public static final String BGSOURCE = "BGSOURCE";
public static final String OVERVIEW = "OVERVIEW";
public static final String NOTIFICATION = "NOTIFICATION";
@ -81,4 +80,8 @@ public class Constants {
public static final String DATATREATMENTS = "DATATREATMENTS";
public static final String NSCLIENT = "NSCLIENT";
public static final String OBJECTIVES = "OBJECTIVES";
public static final String PUMP = "PUMP";
public static final String PUMPQUEUE = "PUMPQUEUE";
public static final String PUMPCOMM = "PUMPCOMM";
public static final String PUMPBTCOMM = "PUMPBTCOMM";
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -14,6 +14,7 @@ import org.slf4j.LoggerFactory;
import java.text.DecimalFormat;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
@ -30,7 +31,7 @@ import info.nightscout.utils.NumberPicker;
*/
public class DanaRUserOptionsActivity extends Activity {
private static Logger log = LoggerFactory.getLogger(DanaRUserOptionsActivity.class);
private static Logger log = LoggerFactory.getLogger(Constants.PUMP);
Switch timeFormat;
Switch buttonScroll;
@ -85,14 +86,15 @@ public class DanaRUserOptionsActivity extends Activity {
DanaRPump pump = DanaRPump.getInstance();
//used for debugging
log.debug("UserOptionsLoaded:" + (System.currentTimeMillis() - pump.lastConnection) / 1000 + " s ago"
+ "\ntimeDisplayType:" + pump.timeDisplayType
+ "\nbuttonScroll:" + pump.buttonScrollOnOff
+ "\ntimeDisplayType:" + pump.timeDisplayType
+ "\nlcdOnTimeSec:" + pump.lcdOnTimeSec
+ "\nbacklight:" + pump.backlightOnTimeSec
+ "\npumpUnits:" + pump.units
+ "\nlowReservoir:" + pump.lowReservoirRate);
if (Config.logPump)
log.debug("UserOptionsLoaded:" + (System.currentTimeMillis() - pump.lastConnection) / 1000 + " s ago"
+ "\ntimeDisplayType:" + pump.timeDisplayType
+ "\nbuttonScroll:" + pump.buttonScrollOnOff
+ "\ntimeDisplayType:" + pump.timeDisplayType
+ "\nlcdOnTimeSec:" + pump.lcdOnTimeSec
+ "\nbacklight:" + pump.backlightOnTimeSec
+ "\npumpUnits:" + pump.units
+ "\nlowReservoir:" + pump.lowReservoirRate);
screenTimeout.setParams((double) pump.lcdOnTimeSec, 5d, 240d, 5d, new DecimalFormat("1"), false);
backlightTimeout.setParams((double) pump.backlightOnTimeSec, 1d, 60d, 1d, new DecimalFormat("1"), false);
@ -122,7 +124,7 @@ public class DanaRUserOptionsActivity extends Activity {
break;
}
if (pump.lastSettingsRead == 0)
log.debug("No settings loaded from pump!");
log.error("No settings loaded from pump!");
else
setData();
}
@ -175,13 +177,13 @@ public class DanaRUserOptionsActivity extends Activity {
// step is 5 seconds
int screenTimeoutValue = !screenTimeout.getText().isEmpty() ? (Integer.parseInt(screenTimeout.getText().toString()) / 5) * 5: 5;
int screenTimeoutValue = !screenTimeout.getText().isEmpty() ? (Integer.parseInt(screenTimeout.getText().toString()) / 5) * 5 : 5;
if (screenTimeoutValue > 4 && screenTimeoutValue < 241) {
pump.lcdOnTimeSec = screenTimeoutValue;
} else {
pump.lcdOnTimeSec = 5;
}
int backlightTimeoutValue = !backlightTimeout.getText().isEmpty() ? Integer.parseInt(backlightTimeout.getText().toString()): 1;
int backlightTimeoutValue = !backlightTimeout.getText().isEmpty() ? Integer.parseInt(backlightTimeout.getText().toString()) : 1;
if (backlightTimeoutValue > 0 && backlightTimeoutValue < 61) {
pump.backlightOnTimeSec = backlightTimeoutValue;
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -6,6 +6,7 @@ import org.slf4j.LoggerFactory;
import java.util.Date;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.events.EventRefreshGui;
@ -18,19 +19,21 @@ import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
public class MsgInitConnStatusTime extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgInitConnStatusTime.class);
private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM);
public MsgInitConnStatusTime() {
SetCommand(0x0301);
if (Config.logPumpComm)
log.debug("New message");
}
@Override
public void handleMessage(byte[] bytes) {
if (bytes.length - 10 > 7) {
Notification notification = new Notification(Notification.WRONG_DRIVER, MainApp.gs(R.string.pumpdrivercorrected), Notification.NORMAL);
Notification notification = new Notification(Notification.WRONG_DRIVER, MainApp.gs(R.string.pumpdrivercorrected), Notification.NORMAL);
MainApp.bus().post(new EventNewNotification(notification));
MainApp.getSpecificPlugin(DanaRPlugin.class).disconnect("Wrong Model");
log.debug("Wrong model selected. Switching to Korean DanaR");
log.error("Wrong model selected. Switching to Korean DanaR");
MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setPluginEnabled(PluginType.PUMP, true);
MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setFragmentVisible(PluginType.PUMP, true);
MainApp.getSpecificPlugin(DanaRPlugin.class).setPluginEnabled(PluginType.PUMP, false);
@ -39,7 +42,7 @@ public class MsgInitConnStatusTime extends MessageBase {
DanaRPump.reset(); // mark not initialized
//If profile coming from pump, switch it as well
if(MainApp.getSpecificPlugin(DanaRPlugin.class).isEnabled(PluginType.PROFILE)){
if (MainApp.getSpecificPlugin(DanaRPlugin.class).isEnabled(PluginType.PROFILE)) {
(MainApp.getSpecificPlugin(DanaRPlugin.class)).setPluginEnabled(PluginType.PROFILE, false);
(MainApp.getSpecificPlugin(DanaRKoreanPlugin.class)).setPluginEnabled(PluginType.PROFILE, true);
}
@ -53,7 +56,7 @@ public class MsgInitConnStatusTime extends MessageBase {
Date time = dateTimeSecFromBuff(bytes, 0);
int versionCode = intFromBuff(bytes, 6, 1);
if (Config.logDanaMessageDetail) {
if (Config.logPumpComm) {
log.debug("Pump time: " + time);
log.debug("Version code: " + versionCode);
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -4,16 +4,19 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
/**
* Created by mike on 05.07.2016.
*/
public class MsgSettingProfileRatios extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgSettingProfileRatios.class);
private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM);
public MsgSettingProfileRatios() {
SetCommand(0x3204);
if (Config.logPumpComm)
log.debug("New message");
}
public void handleMessage(byte[] bytes) {
@ -32,7 +35,7 @@ public class MsgSettingProfileRatios extends MessageBase {
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("Current pump CIR: " + pump.currentCIR);
log.debug("Current pump CF: " + pump.currentCF);

View file

@ -4,16 +4,19 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
/**
* Created by mike on 05.07.2016.
*/
public class MsgSettingProfileRatiosAll extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgSettingProfileRatiosAll.class);
private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM);
public MsgSettingProfileRatiosAll() {
SetCommand(0x320D);
if (Config.logPumpComm)
log.debug("New message");
}
public void handleMessage(byte[] bytes) {
@ -38,7 +41,7 @@ public class MsgSettingProfileRatiosAll extends MessageBase {
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("Current pump morning CIR: " + pump.morningCIR);
log.debug("Current pump morning CF: " + pump.morningCF);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -4,16 +4,19 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
/**
* Created by mike on 05.07.2016.
*/
public class MsgStatusProfile extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgStatusProfile.class);
private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM);
public MsgStatusProfile() {
SetCommand(0x0204);
if (Config.logPumpComm)
log.debug("New message");
}
public void handleMessage(byte[] bytes) {
@ -30,7 +33,7 @@ public class MsgStatusProfile extends MessageBase {
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("Current pump CIR: " + pump.currentCIR);
log.debug("Current pump CF: " + pump.currentCF);

View file

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

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() {
}
EventDanaRSyncStatus(String message) {
this.message = message;
}
}
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -6,6 +6,7 @@ import org.slf4j.LoggerFactory;
import java.util.Date;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.events.EventRefreshGui;
@ -19,10 +20,12 @@ import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
public class MsgInitConnStatusTime_k extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgInitConnStatusTime_k.class);
private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM);
public MsgInitConnStatusTime_k() {
SetCommand(0x0301);
if (Config.logPumpComm)
log.debug("New message");
}
@Override
@ -32,7 +35,7 @@ public class MsgInitConnStatusTime_k extends MessageBase {
Notification notification = new Notification(Notification.WRONG_DRIVER, MainApp.gs(R.string.pumpdrivercorrected), Notification.NORMAL);
MainApp.bus().post(new EventNewNotification(notification));
DanaRKoreanPlugin.getPlugin().disconnect("Wrong Model");
log.debug("Wrong model selected. Switching to export DanaR");
log.error("Wrong model selected. Switching to export DanaR");
MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setPluginEnabled(PluginType.PUMP, false);
MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setFragmentVisible(PluginType.PUMP, false);
MainApp.getSpecificPlugin(DanaRPlugin.class).setPluginEnabled(PluginType.PUMP, true);
@ -58,7 +61,7 @@ public class MsgInitConnStatusTime_k extends MessageBase {
int versionCode3 = intFromBuff(bytes, 8, 1);
int versionCode4 = intFromBuff(bytes, 9, 1);
if (Config.logDanaMessageDetail) {
if (Config.logPumpComm) {
log.debug("Pump time: " + time);
log.debug("Version code1: " + versionCode1);
log.debug("Version code2: " + versionCode2);

View file

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

View file

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

View file

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

View file

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

View file

@ -7,8 +7,6 @@ import android.os.SystemClock;
import com.squareup.otto.Subscribe;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.Date;
@ -50,7 +48,6 @@ import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgStatusBolusExtended;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgStatusTempBasal;
import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRNewStatus;
import info.nightscout.androidaps.plugins.PumpDanaR.services.AbstractDanaRExecutionService;
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
import info.nightscout.androidaps.plugins.PumpDanaRKorean.SerialIOThread;
import info.nightscout.androidaps.plugins.PumpDanaRKorean.comm.MsgCheckValue_k;
import info.nightscout.androidaps.plugins.PumpDanaRKorean.comm.MsgSettingBasal_k;
@ -63,7 +60,6 @@ import info.nightscout.utils.SP;
public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
public DanaRKoreanExecutionService() {
log = LoggerFactory.getLogger(DanaRKoreanExecutionService.class);
mBinder = new LocalBinder();
registerBus();
@ -87,7 +83,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
@Subscribe
public void onStatusEvent(EventAppExit event) {
if (Config.logFunctionCalls)
if (Config.logPump)
log.debug("EventAppExit received");
if (mSerialIOThread != null)
@ -96,7 +92,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
MainApp.instance().getApplicationContext().unregisterReceiver(receiver);
stopSelf();
if (Config.logFunctionCalls)
if (Config.logPump)
log.debug("EventAppExit finished");
}
@ -108,7 +104,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
public void connect() {
if (mDanaRPump.password != -1 && mDanaRPump.password != SP.getInt(R.string.key_danar_password, -1)) {
if(System.currentTimeMillis() > lastWrongPumpPassword + 30 * 1000) {
if (System.currentTimeMillis() > lastWrongPumpPassword + 30 * 1000) {
Notification notification = new Notification(Notification.WRONG_PUMP_PASSWORD, MainApp.gs(R.string.wrongpumppassword), Notification.URGENT);
notification.soundId = R.raw.error;
lastWrongPumpPassword = System.currentTimeMillis();
@ -119,35 +115,32 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
if (mConnectionInProgress)
return;
new Thread(new Runnable() {
@Override
public void run() {
mConnectionInProgress = true;
getBTSocketForSelectedPump();
if (mRfcommSocket == null || mBTDevice == null) {
mConnectionInProgress = false;
return; // Device not found
}
try {
mRfcommSocket.connect();
} catch (IOException e) {
//log.error("Unhandled exception", e);
if (e.getMessage().contains("socket closed")) {
log.error("Unhandled exception", e);
}
}
if (isConnected()) {
if (mSerialIOThread != null) {
mSerialIOThread.disconnect("Recreate SerialIOThread");
}
mSerialIOThread = new SerialIOThread(mRfcommSocket);
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTED, 0));
}
new Thread(() -> {
mConnectionInProgress = true;
getBTSocketForSelectedPump();
if (mRfcommSocket == null || mBTDevice == null) {
mConnectionInProgress = false;
return; // Device not found
}
try {
mRfcommSocket.connect();
} catch (IOException e) {
//log.error("Unhandled exception", e);
if (e.getMessage().contains("socket closed")) {
log.error("Unhandled exception", e);
}
}
if (isConnected()) {
if (mSerialIOThread != null) {
mSerialIOThread.disconnect("Recreate SerialIOThread");
}
mSerialIOThread = new SerialIOThread(mRfcommSocket);
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTED, 0));
}
mConnectionInProgress = false;
}).start();
}
@ -200,12 +193,14 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime)));
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
long timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
log.debug("Pump time difference: " + timeDiff + " seconds");
if (Config.logPump)
log.debug("Pump time difference: " + timeDiff + " seconds");
if (Math.abs(timeDiff) > 10) {
mSerialIOThread.sendMessage(new MsgSetTime(new Date()));
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
log.debug("Pump time difference: " + timeDiff + " seconds");
if (Config.logPump)
log.debug("Pump time difference: " + timeDiff + " seconds");
}
mDanaRPump.lastSettingsRead = now;
}
@ -214,8 +209,9 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
MainApp.bus().post(new EventInitializationChanged());
NSUpload.uploadDeviceStatus();
if (mDanaRPump.dailyTotalUnits > mDanaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) {
log.debug("Approaching daily limit: " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits);
if(System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) {
if (Config.logPump)
log.debug("Approaching daily limit: " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits);
if (System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) {
Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.gs(R.string.approachingdailylimit), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(reportFail));
NSUpload.uploadError(MainApp.gs(R.string.approachingdailylimit) + ": " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits + "U");
@ -300,7 +296,8 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
if ((System.currentTimeMillis() - progress.lastReceive) > 15 * 1000L) { // if i didn't receive status for more than 15 sec expecting broken comm
stop.stopped = true;
stop.forced = true;
log.debug("Communication stopped");
if (Config.logPump)
log.debug("Communication stopped");
}
}
SystemClock.sleep(300);
@ -332,7 +329,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
public boolean updateBasalsInPump(final Profile profile) {
if (!isConnected()) return false;
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.updatingbasalrates)));
double[] basal = DanaRPump.buildDanaRProfileRecord(profile);
double[] basal = DanaRPump.getInstance().buildDanaRProfileRecord(profile);
MsgSetSingleBasalProfile msgSet = new MsgSetSingleBasalProfile(basal);
mSerialIOThread.sendMessage(msgSet);
mDanaRPump.lastSettingsRead = 0; // force read full settings

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,48 +1,50 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
import com.cozmo.danar.util.BleCommandUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config;
import com.cozmo.danar.util.BleCommandUtil;
import info.nightscout.androidaps.Constants;
public class DanaRS_Packet_Basal_Set_Profile_Number extends DanaRS_Packet {
private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Basal_Set_Profile_Number.class);
private int profileNumber;
private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM);
private int profileNumber;
public DanaRS_Packet_Basal_Set_Profile_Number() {
public DanaRS_Packet_Basal_Set_Profile_Number() {
super();
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__SET_PROFILE_NUMBER;
}
public DanaRS_Packet_Basal_Set_Profile_Number(int profileNumber) {
this();
this.profileNumber = profileNumber;
if (Config.logDanaMessageDetail) {
log.debug("Setting profile number " + profileNumber);
}
}
@Override
public byte[] getRequestParams() {
byte[] request = new byte[1];
request[0] = (byte) (profileNumber & 0xff);
return request;
}
public DanaRS_Packet_Basal_Set_Profile_Number(int profileNumber) {
this();
this.profileNumber = profileNumber;
if (Config.logPumpComm) {
log.debug("Setting profile number " + profileNumber);
}
}
@Override
public void handleMessage(byte[] data) {
int result = intFromBuff(data, 0, 1);
if (Config.logDanaMessageDetail) {
if (result == 0)
log.debug("Result OK");
else
log.error("Result Error: " + result);
}
}
public byte[] getRequestParams() {
byte[] request = new byte[1];
request[0] = (byte) (profileNumber & 0xff);
return request;
}
@Override
public String getFriendlyName() {
return "BASAL__SET_PROFILE_NUMBER";
}
@Override
public void handleMessage(byte[] data) {
int result = intFromBuff(data, 0, 1);
if (Config.logPumpComm) {
if (result == 0)
log.debug("Result OK");
else
log.error("Result Error: " + result);
}
}
@Override
public String getFriendlyName() {
return "BASAL__SET_PROFILE_NUMBER";
}
}

View file

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

View file

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

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