QUEUE logging cleanup
This commit is contained in:
parent
3d57d52271
commit
bfccda21cb
19 changed files with 172 additions and 67 deletions
|
@ -33,9 +33,9 @@ public class Config {
|
|||
public static final boolean logNSUpload = true;
|
||||
public static final boolean logPumpActions = true;
|
||||
public static final boolean logCongigBuilderActions = true;
|
||||
public static final boolean logQueue = true;
|
||||
public static final boolean logAutosensData = false;
|
||||
public static final boolean logEvents = false;
|
||||
public static final boolean logProfile = false;
|
||||
|
||||
// DanaR specific
|
||||
public static final boolean logDanaBTComm = true;
|
||||
|
|
|
@ -71,4 +71,5 @@ public class Constants {
|
|||
// logging
|
||||
public static final String AUTOSENS = "AUTOSENS";
|
||||
public static final String EVENTS = "EVENTS";
|
||||
public static final String QUEUE = "QUEUE";
|
||||
}
|
||||
|
|
|
@ -52,6 +52,14 @@ public class Profile {
|
|||
protected Profile() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (json != null)
|
||||
return json.toString();
|
||||
else
|
||||
return "Profile has no JSON";
|
||||
}
|
||||
|
||||
// Constructor from profileStore JSON
|
||||
public Profile(JSONObject json, String units) {
|
||||
init(json, 100, 0);
|
||||
|
@ -295,8 +303,6 @@ public class Profile {
|
|||
Integer getShitfTimeSecs(Integer originalTime) {
|
||||
Integer shiftedTime = originalTime + timeshift * 60 * 60;
|
||||
shiftedTime = (shiftedTime + 24 * 60 * 60) % (24 * 60 * 60);
|
||||
if (timeshift != 0 && Config.logProfile)
|
||||
log.debug("(Sec) Original time: " + originalTime + " ShiftedTime: " + shiftedTime);
|
||||
return shiftedTime;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import java.util.LinkedList;
|
||||
|
||||
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;
|
||||
|
@ -75,7 +77,7 @@ import info.nightscout.androidaps.queue.commands.CommandTempBasalPercent;
|
|||
*/
|
||||
|
||||
public class CommandQueue {
|
||||
private static Logger log = LoggerFactory.getLogger(CommandQueue.class);
|
||||
private Logger log = LoggerFactory.getLogger(Constants.QUEUE);
|
||||
|
||||
private final LinkedList<Command> queue = new LinkedList<>();
|
||||
protected Command performing;
|
||||
|
@ -109,12 +111,14 @@ public class CommandQueue {
|
|||
|
||||
private synchronized void inject(Command command) {
|
||||
// inject as a first command
|
||||
log.debug("QUEUE: Adding as first: " + command.getClass().getSimpleName() + " - " + command.status());
|
||||
if (Config.logQueue)
|
||||
log.debug("Adding as first: " + command.getClass().getSimpleName() + " - " + command.status());
|
||||
queue.addFirst(command);
|
||||
}
|
||||
|
||||
private synchronized void add(Command command) {
|
||||
log.debug("QUEUE: Adding: " + command.getClass().getSimpleName() + " - " + command.status());
|
||||
if (Config.logQueue)
|
||||
log.debug("Adding: " + command.getClass().getSimpleName() + " - " + command.status());
|
||||
queue.add(command);
|
||||
}
|
||||
|
||||
|
@ -147,15 +151,18 @@ public class CommandQueue {
|
|||
// start thread again if not already running
|
||||
protected synchronized void notifyAboutNewCommand() {
|
||||
while (thread != null && thread.getState() != Thread.State.TERMINATED && thread.waitingForDisconnect) {
|
||||
log.debug("QUEUE: Waiting for previous thread finish");
|
||||
if (Config.logQueue)
|
||||
log.debug("Waiting for previous thread finish");
|
||||
SystemClock.sleep(500);
|
||||
}
|
||||
if (thread == null || thread.getState() == Thread.State.TERMINATED) {
|
||||
thread = new QueueThread(this);
|
||||
thread.start();
|
||||
log.debug("QUEUE: Starting new thread");
|
||||
if (Config.logQueue)
|
||||
log.debug("Starting new thread");
|
||||
} else {
|
||||
log.debug("QUEUE: Thread is already running");
|
||||
if (Config.logQueue)
|
||||
log.debug("Thread is already running");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -164,8 +171,8 @@ public class CommandQueue {
|
|||
tempCommandQueue.readStatus(reason, callback);
|
||||
}
|
||||
|
||||
public synchronized boolean bolusInQueue(){
|
||||
if(isRunning(Command.CommandType.BOLUS)) return true;
|
||||
public synchronized boolean bolusInQueue() {
|
||||
if (isRunning(Command.CommandType.BOLUS)) return true;
|
||||
for (int i = 0; i < queue.size(); i++) {
|
||||
if (queue.get(i).commandType == Command.CommandType.BOLUS) {
|
||||
return true;
|
||||
|
@ -180,17 +187,19 @@ public class CommandQueue {
|
|||
|
||||
if (type == Command.CommandType.SMB_BOLUS) {
|
||||
if (isRunning(Command.CommandType.BOLUS) || bolusInQueue()) {
|
||||
log.debug("Rejecting SMB since a bolus is queue/running");
|
||||
if (Config.logQueue)
|
||||
log.debug("Rejecting SMB since a bolus is queue/running");
|
||||
return false;
|
||||
}
|
||||
if (detailedBolusInfo.lastKnownBolusTime < TreatmentsPlugin.getPlugin().getLastBolusTime()) {
|
||||
log.debug("Rejecting bolus, another bolus was issued since request time");
|
||||
if (Config.logQueue)
|
||||
log.debug("Rejecting bolus, another bolus was issued since request time");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(type.equals(Command.CommandType.BOLUS) && detailedBolusInfo.carbs > 0 && detailedBolusInfo.insulin == 0){
|
||||
if (type.equals(Command.CommandType.BOLUS) && detailedBolusInfo.carbs > 0 && detailedBolusInfo.insulin == 0) {
|
||||
type = Command.CommandType.CARBS_ONLY_TREATMENT;
|
||||
//Carbs only can be added in parallel as they can be "in the future".
|
||||
} else {
|
||||
|
@ -213,7 +222,7 @@ public class CommandQueue {
|
|||
add(new CommandSMBBolus(detailedBolusInfo, callback));
|
||||
} else {
|
||||
add(new CommandBolus(detailedBolusInfo, callback, type));
|
||||
if(type.equals(Command.CommandType.BOLUS)) {
|
||||
if (type.equals(Command.CommandType.BOLUS)) {
|
||||
// Bring up bolus progress dialog (start here, so the dialog is shown when the bolus is requested,
|
||||
// not when the Bolus command is starting. The command closes the dialog upon completion).
|
||||
showBolusProgressDialog(detailedBolusInfo.insulin, detailedBolusInfo.context);
|
||||
|
@ -337,7 +346,8 @@ public class CommandQueue {
|
|||
// returns true if command is queued
|
||||
public boolean setProfile(Profile profile, Callback callback) {
|
||||
if (isThisProfileSet(profile)) {
|
||||
log.debug("QUEUE: Correct profile already set");
|
||||
if (Config.logQueue)
|
||||
log.debug("Correct profile already set");
|
||||
if (callback != null)
|
||||
callback.result(new PumpEnactResult().success(true).enacted(false)).run();
|
||||
return false;
|
||||
|
@ -381,7 +391,8 @@ public class CommandQueue {
|
|||
// returns true if command is queued
|
||||
public boolean readStatus(String reason, Callback callback) {
|
||||
if (isLastScheduled(Command.CommandType.READSTATUS)) {
|
||||
log.debug("QUEUE: READSTATUS " + reason + " ignored as duplicated");
|
||||
if (Config.logQueue)
|
||||
log.debug("READSTATUS " + reason + " ignored as duplicated");
|
||||
if (callback != null)
|
||||
callback.result(executingNowError()).run();
|
||||
return false;
|
||||
|
@ -496,8 +507,10 @@ public class CommandQueue {
|
|||
if (activePump != null && current != null) {
|
||||
boolean result = activePump.isThisProfileSet(profile);
|
||||
if (!result) {
|
||||
log.debug("Current profile: " + current.getData().toString());
|
||||
log.debug("New profile: " + profile.getData().toString());
|
||||
if (Config.logQueue) {
|
||||
log.debug("Current profile: " + current.toString());
|
||||
log.debug("New profile: " + profile.toString());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
} else return true;
|
||||
|
|
|
@ -8,6 +8,7 @@ import android.os.SystemClock;
|
|||
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;
|
||||
|
@ -26,7 +27,7 @@ import info.nightscout.utils.SP;
|
|||
*/
|
||||
|
||||
public class QueueThread extends Thread {
|
||||
private static Logger log = LoggerFactory.getLogger(QueueThread.class);
|
||||
private Logger log = LoggerFactory.getLogger(Constants.QUEUE);
|
||||
|
||||
private CommandQueue queue;
|
||||
|
||||
|
@ -54,7 +55,8 @@ public class QueueThread extends Thread {
|
|||
while (true) {
|
||||
PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
if (pump == null) {
|
||||
log.debug("QUEUE: pump == null");
|
||||
if (Config.logQueue)
|
||||
log.debug("pump == null");
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.pumpNotInitialized)));
|
||||
SystemClock.sleep(1000);
|
||||
continue;
|
||||
|
@ -64,15 +66,17 @@ public class QueueThread extends Thread {
|
|||
if (!pump.isConnected() && secondsElapsed > Constants.PUMP_MAX_CONNECTION_TIME_IN_SECONDS) {
|
||||
MainApp.bus().post(new EventDismissBolusprogressIfRunning(null));
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.connectiontimedout)));
|
||||
log.debug("QUEUE: timed out");
|
||||
if (Config.logQueue)
|
||||
log.debug("timed out");
|
||||
pump.stopConnecting();
|
||||
|
||||
//BLUETOOTH-WATCHDOG
|
||||
boolean watchdog = SP.getBoolean(R.string.key_btwatchdog, false);
|
||||
long last_watchdog = SP.getLong(R.string.key_btwatchdog_lastbark, 0l);
|
||||
watchdog = watchdog && System.currentTimeMillis() - last_watchdog > (Constants.MIN_WATCHDOG_INTERVAL_IN_SECONDS * 1000);
|
||||
if(watchdog) {
|
||||
log.debug("BT watchdog - toggeling the phonest bluetooth");
|
||||
if (watchdog) {
|
||||
if (Config.logQueue)
|
||||
log.debug("BT watchdog - toggeling the phonest bluetooth");
|
||||
//write time
|
||||
SP.putLong(R.string.key_btwatchdog_lastbark, System.currentTimeMillis());
|
||||
//toggle BT
|
||||
|
@ -91,7 +95,8 @@ public class QueueThread extends Thread {
|
|||
pump.connect("watchdog");
|
||||
} else {
|
||||
queue.clear();
|
||||
log.debug("QUEUE: no connection possible");
|
||||
if (Config.logQueue)
|
||||
log.debug("no connection possible");
|
||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
||||
pump.disconnect("Queue empty");
|
||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTED));
|
||||
|
@ -100,7 +105,8 @@ public class QueueThread extends Thread {
|
|||
}
|
||||
|
||||
if (pump.isConnecting()) {
|
||||
log.debug("QUEUE: connecting " + secondsElapsed);
|
||||
if (Config.logQueue)
|
||||
log.debug("connecting " + secondsElapsed);
|
||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTING, (int) secondsElapsed));
|
||||
SystemClock.sleep(1000);
|
||||
continue;
|
||||
|
@ -108,7 +114,8 @@ public class QueueThread extends Thread {
|
|||
|
||||
|
||||
if (!pump.isConnected()) {
|
||||
log.debug("QUEUE: connect");
|
||||
if (Config.logQueue)
|
||||
log.debug("connect");
|
||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTING, (int) secondsElapsed));
|
||||
pump.connect("Connection needed");
|
||||
SystemClock.sleep(1000);
|
||||
|
@ -118,12 +125,14 @@ public class QueueThread extends Thread {
|
|||
if (queue.performing() == null) {
|
||||
if (!connectLogged) {
|
||||
connectLogged = true;
|
||||
log.debug("QUEUE: connection time " + secondsElapsed + "s");
|
||||
if (Config.logQueue)
|
||||
log.debug("connection time " + secondsElapsed + "s");
|
||||
}
|
||||
// Pickup 1st command and set performing variable
|
||||
if (queue.size() > 0) {
|
||||
queue.pickup();
|
||||
log.debug("QUEUE: performing " + queue.performing().status());
|
||||
if (Config.logQueue)
|
||||
log.debug("performing " + queue.performing().status());
|
||||
MainApp.bus().post(new EventQueueChanged());
|
||||
queue.performing().execute();
|
||||
queue.resetPerforming();
|
||||
|
@ -138,14 +147,17 @@ public class QueueThread extends Thread {
|
|||
long secondsFromLastCommand = (System.currentTimeMillis() - lastCommandTime) / 1000;
|
||||
if (secondsFromLastCommand >= 5) {
|
||||
waitingForDisconnect = true;
|
||||
log.debug("QUEUE: queue empty. disconnect");
|
||||
if (Config.logQueue)
|
||||
log.debug("queue empty. disconnect");
|
||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
||||
pump.disconnect("Queue empty");
|
||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTED));
|
||||
log.debug("QUEUE: disconnected");
|
||||
if (Config.logQueue)
|
||||
log.debug("disconnected");
|
||||
return;
|
||||
} else {
|
||||
log.debug("QUEUE: waiting for disconnect");
|
||||
if (Config.logQueue)
|
||||
log.debug("waiting for disconnect");
|
||||
SystemClock.sleep(1000);
|
||||
}
|
||||
}
|
||||
|
@ -154,6 +166,4 @@ public class QueueThread extends Thread {
|
|||
mWakeLock.release();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
package info.nightscout.androidaps.queue.commands;
|
||||
|
||||
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.data.PumpEnactResult;
|
||||
|
@ -9,6 +14,8 @@ import info.nightscout.androidaps.queue.Callback;
|
|||
* Created by mike on 09.11.2017.
|
||||
*/
|
||||
public abstract class Command {
|
||||
private Logger log = LoggerFactory.getLogger(Constants.QUEUE);
|
||||
|
||||
public enum CommandType {
|
||||
BOLUS,
|
||||
SMB_BOLUS,
|
||||
|
@ -33,6 +40,8 @@ public abstract class Command {
|
|||
PumpEnactResult result = new PumpEnactResult();
|
||||
result.success = false;
|
||||
result.comment = MainApp.gs(R.string.connectiontimedout);
|
||||
if (Config.logQueue)
|
||||
log.debug("Result cancel");
|
||||
if (callback != null)
|
||||
callback.result(result).run();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
package info.nightscout.androidaps.queue.commands;
|
||||
|
||||
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.data.DetailedBolusInfo;
|
||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||
|
@ -14,6 +19,8 @@ import info.nightscout.utils.DecimalFormatter;
|
|||
*/
|
||||
|
||||
public class CommandBolus extends Command {
|
||||
private Logger log = LoggerFactory.getLogger(Constants.QUEUE);
|
||||
|
||||
DetailedBolusInfo detailedBolusInfo;
|
||||
|
||||
public CommandBolus(DetailedBolusInfo detailedBolusInfo, Callback callback, CommandType type) {
|
||||
|
@ -28,6 +35,8 @@ public class CommandBolus extends Command {
|
|||
|
||||
BolusProgressDialog.bolusEnded = true;
|
||||
MainApp.bus().post(new EventDismissBolusprogressIfRunning(r));
|
||||
if (Config.logQueue)
|
||||
log.debug("Result success: " + r.success + " enacted: " + r.enacted);
|
||||
|
||||
if (callback != null)
|
||||
callback.result(r).run();
|
||||
|
|
|
@ -4,7 +4,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.queue.Callback;
|
||||
|
@ -14,7 +14,7 @@ import info.nightscout.androidaps.queue.Callback;
|
|||
*/
|
||||
|
||||
public class CommandCancelExtendedBolus extends Command {
|
||||
private static Logger log = LoggerFactory.getLogger(CommandCancelExtendedBolus.class);
|
||||
private Logger log = LoggerFactory.getLogger(Constants.QUEUE);
|
||||
|
||||
public CommandCancelExtendedBolus(Callback callback) {
|
||||
commandType = CommandType.EXTENDEDBOLUS;
|
||||
|
@ -24,8 +24,8 @@ public class CommandCancelExtendedBolus extends Command {
|
|||
@Override
|
||||
public void execute() {
|
||||
PumpEnactResult r = ConfigBuilderPlugin.getActivePump().cancelExtendedBolus();
|
||||
if (Config.logCongigBuilderActions)
|
||||
log.debug("cancelExtendedBolus success: " + r.success + " enacted: " + r.enacted);
|
||||
if (Config.logQueue)
|
||||
log.debug("Result success: " + r.success + " enacted: " + r.enacted);
|
||||
if (callback != null)
|
||||
callback.result(r).run();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
package info.nightscout.androidaps.queue.commands;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.queue.Callback;
|
||||
|
@ -10,6 +14,8 @@ import info.nightscout.androidaps.queue.Callback;
|
|||
*/
|
||||
|
||||
public class CommandCancelTempBasal extends Command {
|
||||
private Logger log = LoggerFactory.getLogger(Constants.QUEUE);
|
||||
|
||||
boolean enforceNew;
|
||||
|
||||
public CommandCancelTempBasal(boolean enforceNew, Callback callback) {
|
||||
|
@ -21,6 +27,8 @@ public class CommandCancelTempBasal extends Command {
|
|||
@Override
|
||||
public void execute() {
|
||||
PumpEnactResult r = ConfigBuilderPlugin.getActivePump().cancelTempBasal(enforceNew);
|
||||
if (Config.logQueue)
|
||||
log.debug("Result success: " + r.success + " enacted: " + r.enacted);
|
||||
if (callback != null)
|
||||
callback.result(r).run();
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.queue.Callback;
|
||||
|
@ -14,7 +14,7 @@ import info.nightscout.androidaps.queue.Callback;
|
|||
*/
|
||||
|
||||
public class CommandExtendedBolus extends Command {
|
||||
private static Logger log = LoggerFactory.getLogger(CommandExtendedBolus.class);
|
||||
private Logger log = LoggerFactory.getLogger(Constants.QUEUE);
|
||||
|
||||
private double insulin;
|
||||
private int durationInMinutes;
|
||||
|
@ -29,8 +29,8 @@ public class CommandExtendedBolus extends Command {
|
|||
@Override
|
||||
public void execute() {
|
||||
PumpEnactResult r = ConfigBuilderPlugin.getActivePump().setExtendedBolus(insulin, durationInMinutes);
|
||||
if (Config.logCongigBuilderActions)
|
||||
log.debug("setExtendedBolus rate: " + insulin + " durationInMinutes: " + durationInMinutes + " success: " + r.success + " enacted: " + r.enacted);
|
||||
if (Config.logQueue)
|
||||
log.debug("Result rate: " + insulin + " durationInMinutes: " + durationInMinutes + " success: " + r.success + " enacted: " + r.enacted);
|
||||
if (callback != null)
|
||||
callback.result(r).run();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
package info.nightscout.androidaps.queue.commands;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||
import info.nightscout.androidaps.interfaces.DanaRInterface;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
|
@ -11,6 +16,8 @@ import info.nightscout.androidaps.queue.Callback;
|
|||
*/
|
||||
|
||||
public class CommandLoadEvents extends Command {
|
||||
private Logger log = LoggerFactory.getLogger(Constants.QUEUE);
|
||||
|
||||
public CommandLoadEvents(Callback callback) {
|
||||
commandType = CommandType.LOADEVENTS;
|
||||
this.callback = callback;
|
||||
|
@ -22,6 +29,8 @@ public class CommandLoadEvents extends Command {
|
|||
if (pump instanceof DanaRInterface) {
|
||||
DanaRInterface danaPump = (DanaRInterface) pump;
|
||||
PumpEnactResult r = danaPump.loadEvents();
|
||||
if (Config.logQueue)
|
||||
log.debug("Result success: " + r.success + " enacted: " + r.enacted);
|
||||
if (callback != null)
|
||||
callback.result(r).run();
|
||||
}
|
||||
|
|
|
@ -1,17 +1,23 @@
|
|||
package info.nightscout.androidaps.queue.commands;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||
import info.nightscout.androidaps.interfaces.DanaRInterface;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.queue.Callback;
|
||||
import info.nightscout.androidaps.queue.commands.Command;
|
||||
|
||||
/**
|
||||
* Created by mike on 10.11.2017.
|
||||
*/
|
||||
|
||||
public class CommandLoadHistory extends Command {
|
||||
private Logger log = LoggerFactory.getLogger(Constants.QUEUE);
|
||||
|
||||
byte type;
|
||||
|
||||
public CommandLoadHistory(byte type, Callback callback) {
|
||||
|
@ -26,6 +32,8 @@ public class CommandLoadHistory extends Command {
|
|||
if (pump instanceof DanaRInterface) {
|
||||
DanaRInterface danaPump = (DanaRInterface) pump;
|
||||
PumpEnactResult r = danaPump.loadHistory(type);
|
||||
if (Config.logQueue)
|
||||
log.debug("Result success: " + r.success + " enacted: " + r.enacted);
|
||||
if (callback != null)
|
||||
callback.result(r).run();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
package info.nightscout.androidaps.queue.commands;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
|
@ -10,6 +15,8 @@ import info.nightscout.androidaps.queue.Callback;
|
|||
*/
|
||||
|
||||
public class CommandLoadTDDs extends Command {
|
||||
private Logger log = LoggerFactory.getLogger(Constants.QUEUE);
|
||||
|
||||
|
||||
public CommandLoadTDDs(Callback callback) {
|
||||
commandType = CommandType.LOADHISTORY; //belongs to the history group of commands
|
||||
|
@ -20,9 +27,11 @@ public class CommandLoadTDDs extends Command {
|
|||
public void execute() {
|
||||
PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
PumpEnactResult r = pump.loadTDDs();
|
||||
if (Config.logQueue)
|
||||
log.debug("Result success: " + r.success + " enacted: " + r.enacted);
|
||||
if (callback != null)
|
||||
callback.result(r).run();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String status() {
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
package info.nightscout.androidaps.queue.commands;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.queue.Callback;
|
||||
import info.nightscout.utils.LocalAlertUtils;
|
||||
|
@ -9,6 +14,8 @@ import info.nightscout.utils.LocalAlertUtils;
|
|||
*/
|
||||
|
||||
public class CommandReadStatus extends Command {
|
||||
private Logger log = LoggerFactory.getLogger(Constants.QUEUE);
|
||||
|
||||
String reason;
|
||||
|
||||
public CommandReadStatus(String reason, Callback callback) {
|
||||
|
@ -21,6 +28,8 @@ public class CommandReadStatus extends Command {
|
|||
public void execute() {
|
||||
ConfigBuilderPlugin.getActivePump().getPumpStatus();
|
||||
LocalAlertUtils.notifyPumpStatusRead();
|
||||
if (Config.logQueue)
|
||||
log.debug("CommandReadStatus executed. Reason: " + reason);
|
||||
if (callback != null)
|
||||
callback.result(null).run();
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ package info.nightscout.androidaps.queue.commands;
|
|||
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.data.DetailedBolusInfo;
|
||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||
|
@ -20,7 +22,8 @@ import info.nightscout.utils.T;
|
|||
*/
|
||||
|
||||
public class CommandSMBBolus extends Command {
|
||||
private static Logger log = LoggerFactory.getLogger(CommandSMBBolus.class);
|
||||
private Logger log = LoggerFactory.getLogger(Constants.QUEUE);
|
||||
|
||||
DetailedBolusInfo detailedBolusInfo;
|
||||
|
||||
public CommandSMBBolus(DetailedBolusInfo detailedBolusInfo, Callback callback) {
|
||||
|
@ -34,20 +37,25 @@ public class CommandSMBBolus extends Command {
|
|||
PumpEnactResult r;
|
||||
long lastBolusTime = TreatmentsPlugin.getPlugin().getLastBolusTime();
|
||||
if (lastBolusTime != 0 && lastBolusTime + T.mins(3).msecs() > DateUtil.now()) {
|
||||
log.debug("SMB requsted but still in 3 min interval");
|
||||
if (Config.logQueue)
|
||||
log.debug("SMB requsted but still in 3 min interval");
|
||||
r = new PumpEnactResult().enacted(false).success(false).comment("SMB requsted but still in 3 min interval");
|
||||
} else if (detailedBolusInfo.deliverAt != 0 && detailedBolusInfo.deliverAt + T.mins(1).msecs() > System.currentTimeMillis())
|
||||
} else if (detailedBolusInfo.deliverAt != 0 && detailedBolusInfo.deliverAt + T.mins(1).msecs() > System.currentTimeMillis()) {
|
||||
r = ConfigBuilderPlugin.getActivePump().deliverTreatment(detailedBolusInfo);
|
||||
else {
|
||||
} else {
|
||||
r = new PumpEnactResult().enacted(false).success(false).comment("SMB request too old");
|
||||
log.debug("SMB bolus canceled. delivetAt=" + detailedBolusInfo.deliverAt + " now=" + System.currentTimeMillis());
|
||||
if (Config.logQueue)
|
||||
log.debug("SMB bolus canceled. delivetAt: " + DateUtil.dateAndTimeString(detailedBolusInfo.deliverAt));
|
||||
}
|
||||
|
||||
if (Config.logQueue)
|
||||
log.debug("Result success: " + r.success + " enacted: " + r.enacted);
|
||||
|
||||
if (callback != null)
|
||||
callback.result(r).run();
|
||||
}
|
||||
|
||||
public String status() {
|
||||
return "SMBBOLUS " + DecimalFormatter.to1Decimal(detailedBolusInfo.insulin) + "U";
|
||||
return "SMBBOLUS " + DecimalFormatter.to2Decimal(detailedBolusInfo.insulin) + "U";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ package info.nightscout.androidaps.queue.commands;
|
|||
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.data.Profile;
|
||||
|
@ -20,7 +22,8 @@ import info.nightscout.androidaps.queue.Callback;
|
|||
*/
|
||||
|
||||
public class CommandSetProfile extends Command {
|
||||
private static Logger log = LoggerFactory.getLogger(CommandSetProfile.class);
|
||||
private Logger log = LoggerFactory.getLogger(Constants.QUEUE);
|
||||
|
||||
private Profile profile;
|
||||
|
||||
public CommandSetProfile(Profile profile, Callback callback) {
|
||||
|
@ -32,13 +35,16 @@ public class CommandSetProfile extends Command {
|
|||
@Override
|
||||
public void execute() {
|
||||
if (ConfigBuilderPlugin.getCommandQueue().isThisProfileSet(profile)) {
|
||||
log.debug("QUEUE: Correct profile already set");
|
||||
if (Config.logQueue)
|
||||
log.debug("Correct profile already set. profile: " + profile.toString());
|
||||
if (callback != null)
|
||||
callback.result(new PumpEnactResult().success(true).enacted(false)).run();
|
||||
return;
|
||||
}
|
||||
|
||||
PumpEnactResult r = ConfigBuilderPlugin.getActivePump().setNewBasalProfile(profile);
|
||||
if (Config.logQueue)
|
||||
log.debug("Result success: " + r.success + " enacted: " + r.enacted + " profile: " + profile.toString());
|
||||
if (callback != null)
|
||||
callback.result(r).run();
|
||||
|
||||
|
|
|
@ -3,13 +3,12 @@ package info.nightscout.androidaps.queue.commands;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||
import info.nightscout.androidaps.interfaces.DanaRInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaRv2.DanaRv2Plugin;
|
||||
import info.nightscout.androidaps.queue.Callback;
|
||||
|
||||
/**
|
||||
|
@ -17,7 +16,8 @@ import info.nightscout.androidaps.queue.Callback;
|
|||
*/
|
||||
|
||||
public class CommandSetUserSettings extends Command {
|
||||
private static Logger log = LoggerFactory.getLogger(CommandSetUserSettings.class);
|
||||
private Logger log = LoggerFactory.getLogger(Constants.QUEUE);
|
||||
|
||||
public CommandSetUserSettings(Callback callback) {
|
||||
commandType = CommandType.SETUSERSETTINGS;
|
||||
this.callback = callback;
|
||||
|
@ -28,11 +28,9 @@ public class CommandSetUserSettings extends Command {
|
|||
PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
if (pump instanceof DanaRInterface) {
|
||||
DanaRInterface danaPump = (DanaRInterface) pump;
|
||||
boolean isDanaRv2 = MainApp.getSpecificPlugin(DanaRv2Plugin.class) != null && MainApp.getSpecificPlugin(DanaRv2Plugin.class).isEnabled(PluginType.PUMP);
|
||||
if(isDanaRv2){
|
||||
log.debug("MsgSetUserOptions detected for DanaRv2");
|
||||
}
|
||||
PumpEnactResult r = danaPump.setUserOptions();
|
||||
if (Config.logQueue)
|
||||
log.debug("Result success: " + r.success + " enacted: " + r.enacted);
|
||||
if (callback != null)
|
||||
callback.result(r).run();
|
||||
}
|
||||
|
|
|
@ -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.data.Profile;
|
||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||
|
@ -15,7 +16,7 @@ import info.nightscout.androidaps.queue.Callback;
|
|||
*/
|
||||
|
||||
public class CommandTempBasalAbsolute extends Command {
|
||||
private static Logger log = LoggerFactory.getLogger(CommandTempBasalAbsolute.class);
|
||||
private Logger log = LoggerFactory.getLogger(Constants.QUEUE);
|
||||
|
||||
int durationInMinutes;
|
||||
double absoluteRate;
|
||||
|
@ -34,8 +35,8 @@ public class CommandTempBasalAbsolute extends Command {
|
|||
@Override
|
||||
public void execute() {
|
||||
PumpEnactResult r = ConfigBuilderPlugin.getActivePump().setTempBasalAbsolute(absoluteRate, durationInMinutes, profile, enforceNew);
|
||||
if (Config.logCongigBuilderActions)
|
||||
log.debug("setTempBasalAbsolute rate: " + absoluteRate + " durationInMinutes: " + durationInMinutes + " success: " + r.success + " enacted: " + r.enacted);
|
||||
if (Config.logQueue)
|
||||
log.debug("Result rate: " + absoluteRate + " durationInMinutes: " + durationInMinutes + " success: " + r.success + " enacted: " + r.enacted);
|
||||
if (callback != null)
|
||||
callback.result(r).run();
|
||||
}
|
||||
|
|
|
@ -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.data.Profile;
|
||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
|
@ -14,7 +15,7 @@ import info.nightscout.androidaps.queue.Callback;
|
|||
*/
|
||||
|
||||
public class CommandTempBasalPercent extends Command {
|
||||
private static Logger log = LoggerFactory.getLogger(CommandTempBasalPercent.class);
|
||||
private Logger log = LoggerFactory.getLogger(Constants.QUEUE);
|
||||
|
||||
int durationInMinutes;
|
||||
int percent;
|
||||
|
@ -33,8 +34,8 @@ public class CommandTempBasalPercent extends Command {
|
|||
@Override
|
||||
public void execute() {
|
||||
PumpEnactResult r = ConfigBuilderPlugin.getActivePump().setTempBasalPercent(percent, durationInMinutes, profile, enforceNew);
|
||||
if (Config.logCongigBuilderActions)
|
||||
log.debug("setTempBasalPercent percent: " + percent + " durationInMinutes: " + durationInMinutes + " success: " + r.success + " enacted: " + r.enacted);
|
||||
if (Config.logQueue)
|
||||
log.debug("Result percent: " + percent + " durationInMinutes: " + durationInMinutes + " success: " + r.success + " enacted: " + r.enacted);
|
||||
if (callback != null)
|
||||
callback.result(r).run();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue