cobArray = new ArrayList<>();
Double maxCobValueFound = 0d;
@@ -382,6 +383,10 @@ public class GraphData {
maxCobValueFound = Math.max(maxCobValueFound, cob);
lastCob = cob;
}
+ if (autosensData.failoverToMinAbsorbtionRate) {
+ autosensData.setScale(cobScale);
+ minFailoverActiveList.add(autosensData);
+ }
}
}
@@ -390,8 +395,8 @@ public class GraphData {
cobData = cobArray.toArray(cobData);
cobSeries = new FixedLineGraphSeries<>(cobData);
cobSeries.setDrawBackground(true);
- cobSeries.setBackgroundColor(0xB0FFFFFF & MainApp.sResources.getColor(R.color.cob)); //50%
- cobSeries.setColor(MainApp.sResources.getColor(R.color.cob));
+ cobSeries.setBackgroundColor(0xB0FFFFFF & MainApp.gc(R.color.cob)); //50%
+ cobSeries.setColor(MainApp.gc(R.color.cob));
cobSeries.setThickness(3);
if (useForScale)
@@ -400,6 +405,10 @@ public class GraphData {
cobScale.setMultiplier(maxY * scale / maxCobValueFound);
addSeries(cobSeries);
+
+ DataPointWithLabelInterface[] minFailover = new DataPointWithLabelInterface[minFailoverActiveList.size()];
+ minFailover = minFailoverActiveList.toArray(minFailover);
+ addSeries(new PointsWithLabelGraphSeries<>(minFailover));
}
// scale in % of vertical size (like 0.3)
@@ -468,7 +477,7 @@ public class GraphData {
ScaledDataPoint[] ratioData = new ScaledDataPoint[ratioArray.size()];
ratioData = ratioArray.toArray(ratioData);
ratioSeries = new LineGraphSeries<>(ratioData);
- ratioSeries.setColor(MainApp.sResources.getColor(R.color.ratio));
+ ratioSeries.setColor(MainApp.gc(R.color.ratio));
ratioSeries.setThickness(3);
if (useForScale)
@@ -504,13 +513,13 @@ public class GraphData {
ScaledDataPoint[] ratioMaxData = new ScaledDataPoint[dsMaxArray.size()];
ratioMaxData = dsMaxArray.toArray(ratioMaxData);
dsMaxSeries = new LineGraphSeries<>(ratioMaxData);
- dsMaxSeries.setColor(Color.MAGENTA);
+ dsMaxSeries.setColor(MainApp.gc(R.color.devslopepos));
dsMaxSeries.setThickness(3);
ScaledDataPoint[] ratioMinData = new ScaledDataPoint[dsMinArray.size()];
ratioMinData = dsMinArray.toArray(ratioMinData);
dsMinSeries = new LineGraphSeries<>(ratioMinData);
- dsMinSeries.setColor(Color.YELLOW);
+ dsMinSeries.setColor(MainApp.gc(R.color.devslopeneg));
dsMinSeries.setThickness(3);
if (useForScale)
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/graphExtensions/PointsWithLabelGraphSeries.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/graphExtensions/PointsWithLabelGraphSeries.java
index 9c8e312fb6..8ac3be0ad8 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/graphExtensions/PointsWithLabelGraphSeries.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/graphExtensions/PointsWithLabelGraphSeries.java
@@ -3,42 +3,46 @@ package info.nightscout.androidaps.plugins.Overview.graphExtensions;
/**
* GraphView
* Copyright (C) 2014 Jonas Gehring
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License,
* with the "Linking Exception", which can be found at the license.txt
* file in this program.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* with the "Linking Exception" along with this program; if not,
* write to the author Jonas Gehring .
+ *
+ * Added by mike
*/
/**
* Added by mike
*/
+import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Typeface;
-import android.util.TypedValue;
-// Added by Rumen for scalable text
-import android.content.Context;
-import info.nightscout.androidaps.MainApp;
+
import com.jjoe64.graphview.GraphView;
import com.jjoe64.graphview.series.BaseSeries;
import java.util.Iterator;
+import info.nightscout.androidaps.MainApp;
+
+// Added by Rumen for scalable text
+
/**
* Series that plots the data as points.
* The points can be different shapes or a
@@ -74,7 +78,8 @@ public class PointsWithLabelGraphSeries e
OPENAPSOFFLINE,
EXERCISE,
GENERAL,
- GENERALWITHDURATION
+ GENERALWITHDURATION,
+ COBFAILOVER
}
/**
@@ -148,7 +153,7 @@ public class PointsWithLabelGraphSeries e
float scaleX = (float) (graphWidth / diffX);
- int i=0;
+ int i = 0;
while (values.hasNext()) {
E value = values.next();
@@ -182,7 +187,7 @@ public class PointsWithLabelGraphSeries e
}
/* Fix a bug that continue to show the DOT after Y axis */
- if(x < 0) {
+ if (x < 0) {
overdraw = true;
}
@@ -197,10 +202,10 @@ public class PointsWithLabelGraphSeries e
// draw data point
if (!overdraw) {
- if (value.getShape() == Shape.BG) {
+ if (value.getShape() == Shape.BG || value.getShape() == Shape.COBFAILOVER) {
mPaint.setStyle(Paint.Style.FILL);
mPaint.setStrokeWidth(0);
- canvas.drawCircle(endX, endY, scaledPxSize, mPaint);
+ canvas.drawCircle(endX, endY, value.getSize() * scaledPxSize, mPaint);
} else if (value.getShape() == Shape.PREDICTION) {
mPaint.setColor(value.getColor());
mPaint.setStyle(Paint.Style.FILL);
@@ -211,20 +216,20 @@ public class PointsWithLabelGraphSeries e
mPaint.setStrokeWidth(0);
canvas.drawCircle(endX, endY, scaledPxSize / 3, mPaint);
} else if (value.getShape() == Shape.RECTANGLE) {
- canvas.drawRect(endX-scaledPxSize, endY-scaledPxSize, endX+scaledPxSize, endY+scaledPxSize, mPaint);
+ canvas.drawRect(endX - scaledPxSize, endY - scaledPxSize, endX + scaledPxSize, endY + scaledPxSize, mPaint);
} else if (value.getShape() == Shape.TRIANGLE) {
mPaint.setStrokeWidth(0);
Point[] points = new Point[3];
- points[0] = new Point((int)endX, (int)(endY-scaledPxSize));
- points[1] = new Point((int)(endX+scaledPxSize), (int)(endY+scaledPxSize*0.67));
- points[2] = new Point((int)(endX-scaledPxSize), (int)(endY+scaledPxSize*0.67));
+ points[0] = new Point((int) endX, (int) (endY - scaledPxSize));
+ points[1] = new Point((int) (endX + scaledPxSize), (int) (endY + scaledPxSize * 0.67));
+ points[2] = new Point((int) (endX - scaledPxSize), (int) (endY + scaledPxSize * 0.67));
drawArrows(points, canvas, mPaint);
} else if (value.getShape() == Shape.BOLUS) {
mPaint.setStrokeWidth(0);
Point[] points = new Point[3];
- points[0] = new Point((int)endX, (int)(endY-scaledPxSize));
- points[1] = new Point((int)(endX+scaledPxSize), (int)(endY+scaledPxSize*0.67));
- points[2] = new Point((int)(endX-scaledPxSize), (int)(endY+scaledPxSize*0.67));
+ points[0] = new Point((int) endX, (int) (endY - scaledPxSize));
+ points[1] = new Point((int) (endX + scaledPxSize), (int) (endY + scaledPxSize * 0.67));
+ points[2] = new Point((int) (endX - scaledPxSize), (int) (endY + scaledPxSize * 0.67));
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
drawArrows(points, canvas, mPaint);
if (value.getLabel() != null) {
@@ -234,15 +239,15 @@ public class PointsWithLabelGraphSeries e
mPaint.setStrokeWidth(2);
Point[] points = new Point[3];
float size = value.getSize() * scaledPxSize;
- points[0] = new Point((int)endX, (int)(endY-size));
- points[1] = new Point((int)(endX+size), (int)(endY+size*0.67));
- points[2] = new Point((int)(endX-size), (int)(endY+size*0.67));
+ points[0] = new Point((int) endX, (int) (endY - size));
+ points[1] = new Point((int) (endX + size), (int) (endY + size * 0.67));
+ points[2] = new Point((int) (endX - size), (int) (endY + size * 0.67));
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
drawArrows(points, canvas, mPaint);
} else if (value.getShape() == Shape.EXTENDEDBOLUS) {
mPaint.setStrokeWidth(0);
if (value.getLabel() != null) {
- Rect bounds = new Rect((int)endX, (int)endY + 3, (int) (xpluslength), (int) endY + 8);
+ Rect bounds = new Rect((int) endX, (int) endY + 3, (int) (xpluslength), (int) endY + 8);
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
canvas.drawRect(bounds, mPaint);
mPaint.setTextSize((float) (scaledTextSize));
@@ -254,7 +259,7 @@ public class PointsWithLabelGraphSeries e
mPaint.setStrokeWidth(0);
if (value.getLabel() != null) {
//mPaint.setTextSize((int) (scaledPxSize * 3));
- mPaint.setTextSize((float) (scaledTextSize*1.2));
+ mPaint.setTextSize((float) (scaledTextSize * 1.2));
mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD));
Rect bounds = new Rect();
mPaint.getTextBounds(value.getLabel(), 0, value.getLabel().length(), bounds);
@@ -355,7 +360,7 @@ public class PointsWithLabelGraphSeries e
* @param paint paint object
*/
private void drawArrows(Point[] point, Canvas canvas, Paint paint) {
- float [] points = new float[8];
+ float[] points = new float[8];
points[0] = point[0].x;
points[1] = point[0].y;
points[2] = point[1].x;
@@ -368,10 +373,10 @@ public class PointsWithLabelGraphSeries e
canvas.save();
canvas.drawVertices(Canvas.VertexMode.TRIANGLES, 8, points, 0, null, 0, null, 0, null, 0, 0, paint);
Path path = new Path();
- path.moveTo(point[0].x , point[0].y);
- path.lineTo(point[1].x,point[1].y);
- path.lineTo(point[2].x,point[2].y);
- canvas.drawPath(path,paint);
+ path.moveTo(point[0].x, point[0].y);
+ path.lineTo(point[1].x, point[1].y);
+ path.lineTo(point[2].x, point[2].y);
+ canvas.drawPath(path, paint);
canvas.restore();
}
@@ -381,7 +386,7 @@ public class PointsWithLabelGraphSeries e
float py = endY + scaledPxSize;
canvas.save();
canvas.rotate(-45, px, py);
- mPaint.setTextSize((float) (scaledTextSize*0.8));
+ mPaint.setTextSize((float) (scaledTextSize * 0.8));
mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.NORMAL));
mPaint.setFakeBoldText(true);
mPaint.setTextAlign(Paint.Align.RIGHT);
@@ -393,7 +398,7 @@ public class PointsWithLabelGraphSeries e
float py = endY - scaledPxSize;
canvas.save();
canvas.rotate(-45, px, py);
- mPaint.setTextSize((float) (scaledTextSize*0.8));
+ mPaint.setTextSize((float) (scaledTextSize * 0.8));
mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.NORMAL));
mPaint.setFakeBoldText(true);
canvas.drawText(value.getLabel(), px + scaledPxSize, py, mPaint);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/AbstractDanaRPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/AbstractDanaRPlugin.java
index fc57e72e01..ea83e6d4d6 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/AbstractDanaRPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/AbstractDanaRPlugin.java
@@ -304,7 +304,11 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
@Override
public void getPumpStatus() {
- if (sExecutionService != null) sExecutionService.getPumpStatus();
+ if (sExecutionService != null) {
+ sExecutionService.getPumpStatus();
+ pumpDescription.basalStep = pump.basalStep;
+ pumpDescription.bolusStep = pump.bolusStep;
+ }
}
@Override
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java
index cbcf21cd48..280d37c273 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java
@@ -18,6 +18,7 @@ import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.db.ExtendedBolus;
import info.nightscout.androidaps.db.TemporaryBasal;
+import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgBolusStartWithSpeed;
import info.nightscout.androidaps.plugins.Treatments.Treatment;
import info.nightscout.androidaps.events.EventAppExit;
import info.nightscout.androidaps.events.EventPreferenceChange;
@@ -129,7 +130,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
// Plugin base interface
@Override
public String getName() {
- return MainApp.instance().getString(R.string.danarpump);
+ return MainApp.gs(R.string.danarpump);
}
@Override
@@ -158,10 +159,13 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0)
connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) detailedBolusInfo.carbs, detailedBolusInfo.carbTime, t);
PumpEnactResult result = new PumpEnactResult();
- result.success = connectionOK;
+ result.success = connectionOK && detailedBolusInfo.insulin == t.insulin;
result.bolusDelivered = t.insulin;
result.carbsDelivered = detailedBolusInfo.carbs;
- result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
+ if (!result.success)
+ 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)
log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered);
detailedBolusInfo.insulin = t.insulin;
@@ -173,7 +177,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
result.success = false;
result.bolusDelivered = 0d;
result.carbsDelivered = 0d;
- result.comment = MainApp.instance().getString(R.string.danar_invalidinput);
+ result.comment = MainApp.gs(R.string.danar_invalidinput);
log.error("deliverTreatment: Invalid input");
return result;
}
@@ -342,7 +346,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
PumpEnactResult result = new PumpEnactResult();
result.success = true;
result.enacted = false;
- result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
+ result.comment = MainApp.gs(R.string.virtualpump_resultok);
result.isTempCancel = true;
return result;
}
@@ -358,13 +362,13 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
if (!pump.isTempBasalInProgress) {
result.success = true;
result.isTempCancel = true;
- result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
+ result.comment = MainApp.gs(R.string.virtualpump_resultok);
if (Config.logPumpActions)
log.debug("cancelRealTempBasal: OK");
return result;
} else {
result.success = false;
- result.comment = MainApp.instance().getString(R.string.danar_valuenotsetproperly);
+ result.comment = MainApp.gs(R.string.danar_valuenotsetproperly);
result.isTempCancel = true;
log.error("cancelRealTempBasal: Failed to cancel temp basal");
return result;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStart.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStart.java
index 9173794199..7586edf825 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStart.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStart.java
@@ -11,6 +11,8 @@ import info.nightscout.utils.HardLimits;
public class MsgBolusStart extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgBolusStart.class);
+ public static int errorCode;
+
public MsgBolusStart() {
SetCommand(0x0102);
}
@@ -29,13 +31,13 @@ public class MsgBolusStart extends MessageBase {
@Override
public void handleMessage(byte[] bytes) {
- int result = intFromBuff(bytes, 0, 1);
- if (result != 2) {
+ errorCode = intFromBuff(bytes, 0, 1);
+ if (errorCode != 2) {
failed = true;
- log.debug("Messsage response: " + result + " FAILED!!");
+ log.debug("Messsage response: " + errorCode + " FAILED!!");
} else {
if (Config.logDanaMessageDetail)
- log.debug("Messsage response: " + result);
+ log.debug("Messsage response: " + errorCode + " OK");
}
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStartWithSpeed.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStartWithSpeed.java
index 3a33e9f866..dd4251a350 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStartWithSpeed.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStartWithSpeed.java
@@ -11,6 +11,8 @@ import info.nightscout.utils.HardLimits;
public class MsgBolusStartWithSpeed extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgBolusStartWithSpeed.class);
+ public static int errorCode;
+
public MsgBolusStartWithSpeed() {
SetCommand(0x0104);
}
@@ -30,13 +32,13 @@ public class MsgBolusStartWithSpeed extends MessageBase {
@Override
public void handleMessage(byte[] bytes) {
- int result = intFromBuff(bytes, 0, 1);
- if (result != 2) {
+ errorCode = intFromBuff(bytes, 0, 1);
+ if (errorCode != 2) {
failed = true;
- log.debug("Messsage response: " + result + " FAILED!!");
+ log.debug("Messsage response: " + errorCode + " FAILED!!");
} else {
if (Config.logDanaMessageDetail)
- log.debug("Messsage response: " + result);
+ log.debug("Messsage response: " + errorCode + " OK");
}
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/DanaRExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/DanaRExecutionService.java
index eabf4fc94a..bee8dd1662 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/DanaRExecutionService.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/DanaRExecutionService.java
@@ -339,7 +339,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{
} else {
ConfigBuilderPlugin.getCommandQueue().readStatus("bolusOK", null);
}
- return true;
+ return !start.failed;
}
public boolean carbsEntry(int amount) {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java
index a3a39a30f1..f2150ebb7d 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java
@@ -18,14 +18,15 @@ import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.db.ExtendedBolus;
import info.nightscout.androidaps.db.TemporaryBasal;
-import info.nightscout.androidaps.plugins.Treatments.Treatment;
import info.nightscout.androidaps.events.EventAppExit;
import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.interfaces.Constraint;
import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.plugins.PumpDanaR.AbstractDanaRPlugin;
+import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgBolusStart;
import info.nightscout.androidaps.plugins.PumpDanaRKorean.services.DanaRKoreanExecutionService;
+import info.nightscout.androidaps.plugins.Treatments.Treatment;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.utils.Round;
import info.nightscout.utils.SP;
@@ -130,7 +131,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
// Plugin base interface
@Override
public String getName() {
- return MainApp.instance().getString(R.string.danarkoreanpump);
+ return MainApp.gs(R.string.danarkoreanpump);
}
@Override
@@ -159,10 +160,13 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0)
connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) detailedBolusInfo.carbs, detailedBolusInfo.carbTime, t);
PumpEnactResult result = new PumpEnactResult();
- result.success = connectionOK;
+ result.success = connectionOK && detailedBolusInfo.insulin == t.insulin;
result.bolusDelivered = t.insulin;
result.carbsDelivered = detailedBolusInfo.carbs;
- result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
+ if (!result.success)
+ 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)
log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered);
detailedBolusInfo.insulin = t.insulin;
@@ -174,7 +178,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
result.success = false;
result.bolusDelivered = 0d;
result.carbsDelivered = 0d;
- result.comment = MainApp.instance().getString(R.string.danar_invalidinput);
+ result.comment = MainApp.gs(R.string.danar_invalidinput);
log.error("deliverTreatment: Invalid input");
return result;
}
@@ -343,7 +347,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
PumpEnactResult result = new PumpEnactResult();
result.success = true;
result.enacted = false;
- result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
+ result.comment = MainApp.gs(R.string.virtualpump_resultok);
result.isTempCancel = true;
return result;
}
@@ -359,13 +363,13 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
if (!pump.isTempBasalInProgress) {
result.success = true;
result.isTempCancel = true;
- result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
+ result.comment = MainApp.gs(R.string.virtualpump_resultok);
if (Config.logPumpActions)
log.debug("cancelRealTempBasal: OK");
return result;
} else {
result.success = false;
- result.comment = MainApp.instance().getString(R.string.danar_valuenotsetproperly);
+ result.comment = MainApp.gs(R.string.danar_valuenotsetproperly);
result.isTempCancel = true;
log.error("cancelRealTempBasal: Failed to cancel temp basal");
return result;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/services/DanaRKoreanExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/services/DanaRKoreanExecutionService.java
index c136666d5e..2619453df7 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/services/DanaRKoreanExecutionService.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/services/DanaRKoreanExecutionService.java
@@ -286,7 +286,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
mBolusingTreatment = null;
ConfigBuilderPlugin.getCommandQueue().readStatus("bolusOK", null);
- return true;
+ return !start.failed;
}
public boolean carbsEntry(int amount) {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java
index 7655c0ff46..a2ec13d184 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java
@@ -26,6 +26,7 @@ import info.nightscout.androidaps.data.ProfileStore;
import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.db.ExtendedBolus;
import info.nightscout.androidaps.db.TemporaryBasal;
+import info.nightscout.androidaps.plugins.PumpDanaRS.comm.DanaRS_Packet_Bolus_Set_Step_Bolus_Start;
import info.nightscout.androidaps.plugins.Treatments.Treatment;
import info.nightscout.androidaps.events.EventAppExit;
import info.nightscout.androidaps.interfaces.Constraint;
@@ -178,8 +179,6 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
final Object o = new Object();
danaRSService.connect(from, mDeviceAddress, o);
- pumpDescription.basalStep = pump.basalStep;
- pumpDescription.bolusStep = pump.bolusStep;
}
}
@@ -205,8 +204,11 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
@Override
public void getPumpStatus() {
- if (danaRSService != null)
+ if (danaRSService != null) {
danaRSService.getPumpStatus();
+ pumpDescription.basalStep = pump.basalStep;
+ pumpDescription.bolusStep = pump.bolusStep;
+ }
}
// DanaR interface
@@ -368,7 +370,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
}
// RS stores end time for bolus, we need to adjust time
// default delivery speed is 12 sec/U
- detailedBolusInfo.date = DateUtil.now() + (long)(speed * detailedBolusInfo.insulin * 1000);
+ detailedBolusInfo.date = DateUtil.now() + (long) (speed * detailedBolusInfo.insulin * 1000);
// clean carbs to prevent counting them as twice because they will picked up as another record
// I don't think it's necessary to copy DetailedBolusInfo right now for carbs records
double carbs = detailedBolusInfo.carbs;
@@ -384,10 +386,13 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
if (detailedBolusInfo.insulin > 0 || carbs > 0)
connectionOK = danaRSService.bolus(detailedBolusInfo.insulin, (int) carbs, DateUtil.now() + carbTime * 60 * 1000, t);
PumpEnactResult result = new PumpEnactResult();
- result.success = connectionOK;
+ result.success = connectionOK && detailedBolusInfo.insulin == t.insulin;
result.bolusDelivered = t.insulin;
result.carbsDelivered = detailedBolusInfo.carbs;
- result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
+ if (!result.success)
+ 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)
log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered);
return result;
@@ -396,7 +401,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
result.success = false;
result.bolusDelivered = 0d;
result.carbsDelivered = 0d;
- result.comment = MainApp.instance().getString(R.string.danar_invalidinput);
+ result.comment = MainApp.gs(R.string.danar_invalidinput);
log.error("deliverTreatment: Invalid input");
return result;
}
@@ -500,7 +505,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
result.isTempCancel = false;
result.enacted = false;
result.success = false;
- result.comment = MainApp.instance().getString(R.string.danar_invalidinput);
+ result.comment = MainApp.gs(R.string.danar_invalidinput);
log.error("setTempBasalPercent: Invalid input");
return result;
}
@@ -512,7 +517,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
result.enacted = false;
result.success = true;
result.isTempCancel = false;
- result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
+ result.comment = MainApp.gs(R.string.virtualpump_resultok);
result.duration = pump.tempBasalRemainingMin;
result.percent = pump.tempBasalPercent;
result.isPercent = true;
@@ -530,7 +535,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
if (connectionOK && pump.isTempBasalInProgress && pump.tempBasalPercent == percent) {
result.enacted = true;
result.success = true;
- result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
+ result.comment = MainApp.gs(R.string.virtualpump_resultok);
result.isTempCancel = false;
result.duration = pump.tempBasalRemainingMin;
result.percent = pump.tempBasalPercent;
@@ -541,7 +546,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
}
result.enacted = false;
result.success = false;
- result.comment = MainApp.instance().getString(R.string.tempbasaldeliveryerror);
+ result.comment = MainApp.gs(R.string.tempbasaldeliveryerror);
log.error("setTempBasalPercent: Failed to set temp basal");
return result;
}
@@ -552,7 +557,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
if (connectionOK && pump.isTempBasalInProgress && pump.tempBasalPercent == percent) {
result.enacted = true;
result.success = true;
- result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
+ result.comment = MainApp.gs(R.string.virtualpump_resultok);
result.isTempCancel = false;
result.duration = pump.tempBasalRemainingMin;
result.percent = pump.tempBasalPercent;
@@ -563,7 +568,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
}
result.enacted = false;
result.success = false;
- result.comment = MainApp.instance().getString(R.string.danar_valuenotsetproperly);
+ result.comment = MainApp.gs(R.string.danar_valuenotsetproperly);
log.error("setHighTempBasalPercent: Failed to set temp basal");
return result;
}
@@ -579,7 +584,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
if (runningEB != null && Math.abs(runningEB.insulin - insulin) < getPumpDescription().extendedBolusStep) {
result.enacted = false;
result.success = true;
- result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
+ result.comment = MainApp.gs(R.string.virtualpump_resultok);
result.duration = pump.extendedBolusRemainingMinutes;
result.absolute = pump.extendedBolusAbsoluteRate;
result.isPercent = false;
@@ -592,7 +597,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
if (connectionOK && pump.isExtendedInProgress && Math.abs(pump.extendedBolusAbsoluteRate - insulin) < getPumpDescription().extendedBolusStep) {
result.enacted = true;
result.success = true;
- result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
+ result.comment = MainApp.gs(R.string.virtualpump_resultok);
result.isTempCancel = false;
result.duration = pump.extendedBolusRemainingMinutes;
result.absolute = pump.extendedBolusAbsoluteRate;
@@ -604,7 +609,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
}
result.enacted = false;
result.success = false;
- result.comment = MainApp.instance().getString(R.string.danar_valuenotsetproperly);
+ result.comment = MainApp.gs(R.string.danar_valuenotsetproperly);
log.error("setExtendedBolus: Failed to extended bolus");
return result;
}
@@ -621,13 +626,13 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
if (!pump.isTempBasalInProgress) {
result.success = true;
result.isTempCancel = true;
- result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
+ result.comment = MainApp.gs(R.string.virtualpump_resultok);
if (Config.logPumpActions)
log.debug("cancelRealTempBasal: OK");
return result;
} else {
result.success = false;
- result.comment = MainApp.instance().getString(R.string.danar_valuenotsetproperly);
+ result.comment = MainApp.gs(R.string.danar_valuenotsetproperly);
result.isTempCancel = true;
log.error("cancelRealTempBasal: Failed to cancel temp basal");
return result;
@@ -645,13 +650,13 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
}
if (!pump.isExtendedInProgress) {
result.success = true;
- result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
+ result.comment = MainApp.gs(R.string.virtualpump_resultok);
if (Config.logPumpActions)
log.debug("cancelExtendedBolus: OK");
return result;
} else {
result.success = false;
- result.comment = MainApp.instance().getString(R.string.danar_valuenotsetproperly);
+ result.comment = MainApp.gs(R.string.danar_valuenotsetproperly);
log.error("cancelExtendedBolus: Failed to cancel extended bolus");
return result;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.java
index 12f2fa95c6..f90dd77b74 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.java
@@ -7,58 +7,63 @@ import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
+import info.nightscout.androidaps.R;
import info.nightscout.androidaps.interfaces.Constraint;
-import info.nightscout.utils.HardLimits;
+import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
public class DanaRS_Packet_Bolus_Set_Step_Bolus_Start extends DanaRS_Packet {
- private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Bolus_Set_Step_Bolus_Start.class);
+ private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Bolus_Set_Step_Bolus_Start.class);
- private double amount;
- private int speed;
+ private double amount;
+ private int speed;
- public boolean failed;
+ public boolean failed;
+ public static int errorCode;
- public DanaRS_Packet_Bolus_Set_Step_Bolus_Start() {
+ public DanaRS_Packet_Bolus_Set_Step_Bolus_Start() {
super();
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__SET_STEP_BOLUS_START;
}
// Speed 0 => 12 sec/U, 1 => 30 sec/U, 2 => 60 sec/U
- public DanaRS_Packet_Bolus_Set_Step_Bolus_Start(double amount, int speed) {
- this();
+ public DanaRS_Packet_Bolus_Set_Step_Bolus_Start(double amount, int speed) {
+ this();
- // HARDCODED LIMIT
- amount = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(amount)).value();
+ // HARDCODED LIMIT
+ amount = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(amount)).value();
- this.amount = amount;
- this.speed = speed;
+ this.amount = amount;
+ this.speed = speed;
- if (Config.logDanaMessageDetail)
- log.debug("Bolus start : " + amount + " speed: " + speed);
- }
+ if (Config.logDanaMessageDetail)
+ log.debug("Bolus start : " + amount + " speed: " + speed);
+ }
- @Override
- public byte[] getRequestParams() {
- int stepBolusRate = (int) (amount * 100);
- byte[] request = new byte[3];
- request[0] = (byte) (stepBolusRate & 0xff);
- request[1] = (byte) ((stepBolusRate >>> 8) & 0xff);
- request[2] = (byte) (speed & 0xff);
- return request;
- }
- @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);
- }
- }
+ @Override
+ public byte[] getRequestParams() {
+ int stepBolusRate = (int) (amount * 100);
+ byte[] request = new byte[3];
+ request[0] = (byte) (stepBolusRate & 0xff);
+ request[1] = (byte) ((stepBolusRate >>> 8) & 0xff);
+ request[2] = (byte) (speed & 0xff);
+ return request;
+ }
- @Override
- public String getFriendlyName() {
- return "BOLUS__SET_STEP_BOLUS_START";
- }
+ @Override
+ public void handleMessage(byte[] data) {
+ errorCode = intFromBuff(data, 0, 1);
+ if (Config.logDanaMessageDetail) {
+ if (errorCode == 0)
+ log.debug("Result OK");
+ else {
+ failed = true;
+ log.error("Result Error: " + errorCode);
+ }
+ }
+ }
+
+ @Override
+ public String getFriendlyName() {
+ return "BOLUS__SET_STEP_BOLUS_START";
+ }
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/DanaRSService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/DanaRSService.java
index 384c1a3772..91859c759a 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/DanaRSService.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/DanaRSService.java
@@ -273,7 +273,7 @@ public class DanaRSService extends Service {
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.disconnecting)));
}
});
- return true;
+ return !start.failed;
}
public void bolusStop() {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java
index 81c5d4d944..0ea6f192e4 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java
@@ -22,6 +22,7 @@ import info.nightscout.androidaps.interfaces.Constraint;
import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.plugins.ConfigBuilder.DetailedBolusInfoStorage;
import info.nightscout.androidaps.plugins.PumpDanaR.AbstractDanaRPlugin;
+import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgBolusStartWithSpeed;
import info.nightscout.androidaps.plugins.PumpDanaRv2.services.DanaRv2ExecutionService;
import info.nightscout.androidaps.plugins.Treatments.Treatment;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
@@ -119,7 +120,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
// Plugin base interface
@Override
public String getName() {
- return MainApp.instance().getString(R.string.danarv2pump);
+ return MainApp.gs(R.string.danarv2pump);
}
@Override
@@ -173,10 +174,13 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
if (detailedBolusInfo.insulin > 0 || carbs > 0)
connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) carbs, DateUtil.now() + carbTime * 60 * 1000, t);
PumpEnactResult result = new PumpEnactResult();
- result.success = connectionOK;
+ result.success = connectionOK && detailedBolusInfo.insulin == t.insulin;
result.bolusDelivered = t.insulin;
result.carbsDelivered = detailedBolusInfo.carbs;
- result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
+ if (!result.success)
+ 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)
log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered);
// remove carbs because it's get from history seprately
@@ -186,7 +190,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
result.success = false;
result.bolusDelivered = 0d;
result.carbsDelivered = 0d;
- result.comment = MainApp.instance().getString(R.string.danar_invalidinput);
+ result.comment = MainApp.gs(R.string.danar_invalidinput);
log.error("deliverTreatment: Invalid input");
return result;
}
@@ -287,7 +291,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
result.isTempCancel = false;
result.enacted = false;
result.success = false;
- result.comment = MainApp.instance().getString(R.string.danar_invalidinput);
+ result.comment = MainApp.gs(R.string.danar_invalidinput);
log.error("setTempBasalPercent: Invalid input");
return result;
}
@@ -299,7 +303,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
result.enacted = false;
result.success = true;
result.isTempCancel = false;
- result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
+ result.comment = MainApp.gs(R.string.virtualpump_resultok);
result.duration = pump.tempBasalRemainingMin;
result.percent = pump.tempBasalPercent;
result.isPercent = true;
@@ -317,7 +321,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
if (connectionOK && pump.isTempBasalInProgress && pump.tempBasalPercent == percent) {
result.enacted = true;
result.success = true;
- result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
+ result.comment = MainApp.gs(R.string.virtualpump_resultok);
result.isTempCancel = false;
result.duration = pump.tempBasalRemainingMin;
result.percent = pump.tempBasalPercent;
@@ -328,7 +332,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
}
result.enacted = false;
result.success = false;
- result.comment = MainApp.instance().getString(R.string.tempbasaldeliveryerror);
+ result.comment = MainApp.gs(R.string.tempbasaldeliveryerror);
log.error("setTempBasalPercent: Failed to set temp basal");
return result;
}
@@ -339,7 +343,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
if (connectionOK && pump.isTempBasalInProgress && pump.tempBasalPercent == percent) {
result.enacted = true;
result.success = true;
- result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
+ result.comment = MainApp.gs(R.string.virtualpump_resultok);
result.isTempCancel = false;
result.duration = pump.tempBasalRemainingMin;
result.percent = pump.tempBasalPercent;
@@ -350,7 +354,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
}
result.enacted = false;
result.success = false;
- result.comment = MainApp.instance().getString(R.string.danar_valuenotsetproperly);
+ result.comment = MainApp.gs(R.string.danar_valuenotsetproperly);
log.error("setHighTempBasalPercent: Failed to set temp basal");
return result;
}
@@ -367,13 +371,13 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
if (!pump.isTempBasalInProgress) {
result.success = true;
result.isTempCancel = true;
- result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
+ result.comment = MainApp.gs(R.string.virtualpump_resultok);
if (Config.logPumpActions)
log.debug("cancelRealTempBasal: OK");
return result;
} else {
result.success = false;
- result.comment = MainApp.instance().getString(R.string.danar_valuenotsetproperly);
+ result.comment = MainApp.gs(R.string.danar_valuenotsetproperly);
result.isTempCancel = true;
log.error("cancelRealTempBasal: Failed to cancel temp basal");
return result;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java
index 551c2684c0..25cac9da1c 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java
@@ -386,7 +386,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.disconnecting)));
}
});
- return true;
+ return !start.failed;
}
public void bolusStop() {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/history/HistoryIntentAdapter.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/history/HistoryIntentAdapter.java
index 1ddc4fd4b7..244537af3e 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/history/HistoryIntentAdapter.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/history/HistoryIntentAdapter.java
@@ -161,18 +161,54 @@ class HistoryIntentAdapter {
Date date = getDateExtra(intent, HistoryBroadcast.EXTRA_EVENT_TIME);
String alertType = intent.getStringExtra(HistoryBroadcast.EXTRA_ALERT_TYPE);
if (MainApp.getDbHelper().getCareportalEventFromTimestamp(date.getTime()) != null) return;
- try {
- JSONObject data = new JSONObject();
- String enteredBy = SP.getString("careportal_enteredby", "");
- if (!enteredBy.equals("")) data.put("enteredBy", enteredBy);
- data.put("created_at", DateUtil.toISOString(date));
- data.put("eventType", CareportalEvent.NOTE);
- data.put("notes", MainApp.instance().getString(getAlertText(alertType)));
- NSUpload.uploadCareportalEntryToNS(data);
- } catch (JSONException e) {
- e.printStackTrace();
+ logNote(date, MainApp.instance().getString(getAlertText(alertType)));
+ }
+ }
+
+ void processPumpStatusChangedIntent(Intent intent) {
+ Date newStatusTime = getDateExtra(intent, HistoryBroadcast.EXTRA_EVENT_TIME);
+ if (SP.getBoolean("insight_automatic_careportal_events", false)) {
+ String newStatus = intent.getStringExtra(HistoryBroadcast.EXTRA_NEW_STATUS);
+ switch (newStatus) {
+ case "STARTED":
+ logNote(newStatusTime, MainApp.instance().getString(R.string.pump_started));
+ break;
+ case "STOPPED":
+ logNote(newStatusTime, MainApp.instance().getString(R.string.pump_stopped));
+ break;
+ case "PAUSED":
+ logNote(newStatusTime, MainApp.instance().getString(R.string.pump_paused));
+ break;
}
}
+ if (intent.hasExtra(HistoryBroadcast.EXTRA_OLD_STATUS_TIME)) {
+ String oldStatus = intent.getStringExtra(HistoryBroadcast.EXTRA_OLD_STATUS);
+ if (oldStatus.equals("STOPPED")) {
+ Date oldStatusTime = getDateExtra(intent, HistoryBroadcast.EXTRA_OLD_STATUS_TIME);
+ int duration = (int) ((newStatusTime.getTime() - oldStatusTime.getTime()) / 60000);
+
+ long serialNumber = Long.parseLong(intent.getStringExtra(HistoryBroadcast.EXTRA_PUMP_SERIAL_NUMBER));
+ long recordId = intent.getLongExtra(HistoryBroadcast.EXTRA_EVENT_NUMBER, -1);
+ long uniqueRecordId = getRecordUniqueID(serialNumber, recordId);
+
+ logAdapter.createTBRrecord(oldStatusTime, 0, duration, uniqueRecordId);
+ }
+ }
+ }
+
+ private void logNote(Date date, String note) {
+ try {
+ if (MainApp.getDbHelper().getCareportalEventFromTimestamp(date.getTime()) != null) return;
+ JSONObject data = new JSONObject();
+ String enteredBy = SP.getString("careportal_enteredby", "");
+ if (!enteredBy.equals("")) data.put("enteredBy", enteredBy);
+ data.put("created_at", DateUtil.toISOString(date));
+ data.put("eventType", CareportalEvent.NOTE);
+ data.put("notes", note);
+ NSUpload.uploadCareportalEntryToNS(data);
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
}
private int getAlertText(String type) {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/history/HistoryReceiver.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/history/HistoryReceiver.java
index 0e254e3341..efce8d7a40 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/history/HistoryReceiver.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/history/HistoryReceiver.java
@@ -47,6 +47,7 @@ public class HistoryReceiver {
filter.addAction(ACTION_CARTRIDGE_INSERTED);
filter.addAction(ACTION_BATTERY_INSERTED);
filter.addAction(ACTION_OCCURENCE_OF_ALERT);
+ filter.addAction(ACTION_PUMP_STATUS_CHANGED);
MainApp.instance().registerReceiver(historyReceiver, filter);
}
@@ -108,6 +109,9 @@ public class HistoryReceiver {
case ACTION_OCCURENCE_OF_ALERT:
intentAdapter.processOccurenceOfAlertIntent(intent);
break;
+ case ACTION_PUMP_STATUS_CHANGED:
+ intentAdapter.processPumpStatusChangedIntent(intent);
+ break;
}
}
};
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceXdripPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceXdripPlugin.java
index f47d25abb1..bd3d96162e 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceXdripPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceXdripPlugin.java
@@ -35,6 +35,6 @@ public class SourceXdripPlugin extends PluginBase implements BgSourceInterface {
}
public void setSource(String source) {
- this.advancedFiltering = "G5 Native".equals(source);
+ this.advancedFiltering = source.contains("G5 Native");
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java
index 8f82f71c35..bc5f4a7835 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java
@@ -40,6 +40,8 @@ import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
+import info.nightscout.androidaps.plugins.SensitivityAAPS.SensitivityAAPSPlugin;
+import info.nightscout.androidaps.plugins.SensitivityWeightedAverage.SensitivityWeightedAveragePlugin;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.NSUpload;
import info.nightscout.utils.SP;
@@ -211,22 +213,35 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
if (profile == null) return result;
long now = System.currentTimeMillis();
- long dia_ago = now - (Double.valueOf(1.5d * profile.getDia() * T.hours(1).msecs())).longValue();
+ long dia_ago = now - (Double.valueOf(profile.getDia() * T.hours(1).msecs())).longValue();
+
+ double maxAbsorptionHours = Constants.DEFAULT_MAX_ABSORPTION_TIME;
+ if (SensitivityAAPSPlugin.getPlugin().isEnabled(PluginType.SENSITIVITY) || SensitivityWeightedAveragePlugin.getPlugin().isEnabled(PluginType.SENSITIVITY)) {
+ maxAbsorptionHours = SP.getDouble(R.string.key_absorption_maxtime, Constants.DEFAULT_MAX_ABSORPTION_TIME);
+ } else {
+ maxAbsorptionHours = SP.getDouble(R.string.key_absorption_cutoff, Constants.DEFAULT_MAX_ABSORPTION_TIME);
+ }
+ long absorptionTime_ago = now - (Double.valueOf(maxAbsorptionHours * T.hours(1).msecs())).longValue();
synchronized (treatments) {
for (Treatment treatment : treatments) {
if (!treatment.isValid)
continue;
long t = treatment.date;
+
if (t > dia_ago && t <= now) {
- if (treatment.carbs >= 1) {
- result.carbs += treatment.carbs;
- result.lastCarbTime = t;
- }
if (treatment.insulin > 0 && treatment.mealBolus) {
result.boluses += treatment.insulin;
}
}
+
+ if (t > absorptionTime_ago && t <= now) {
+ if (treatment.carbs >= 1) {
+ result.carbs += treatment.carbs;
+ if(t > result.lastCarbTime)
+ result.lastCarbTime = t;
+ }
+ }
}
}
@@ -235,6 +250,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
result.mealCOB = autosensData.cob;
result.slopeFromMinDeviation = autosensData.slopeFromMinDeviation;
result.slopeFromMaxDeviation = autosensData.slopeFromMaxDeviation;
+ result.usedMinCarbsImpact = autosensData.usedMinCarbsImpact;
}
result.lastBolusTime = getLastBolusTime();
return result;
diff --git a/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java b/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java
index a514a85815..93b6f99db0 100644
--- a/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java
+++ b/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java
@@ -205,7 +205,7 @@ public class CommandQueue {
// returns true if command is queued
public boolean tempBasalAbsolute(double absoluteRate, int durationInMinutes, boolean enforceNew, Profile profile, Callback callback) {
- if (isRunning(Command.CommandType.TEMPBASAL)) {
+ if (!enforceNew && isRunning(Command.CommandType.TEMPBASAL)) {
if (callback != null)
callback.result(executingNowError()).run();
return false;
@@ -226,7 +226,7 @@ public class CommandQueue {
// returns true if command is queued
public boolean tempBasalPercent(Integer percent, int durationInMinutes, boolean enforceNew, Profile profile, Callback callback) {
- if (isRunning(Command.CommandType.TEMPBASAL)) {
+ if (!enforceNew && isRunning(Command.CommandType.TEMPBASAL)) {
if (callback != null)
callback.result(executingNowError()).run();
return false;
@@ -268,7 +268,7 @@ public class CommandQueue {
// returns true if command is queued
public boolean cancelTempBasal(boolean enforceNew, Callback callback) {
- if (isRunning(Command.CommandType.TEMPBASAL)) {
+ if (!enforceNew && isRunning(Command.CommandType.TEMPBASAL)) {
if (callback != null)
callback.result(executingNowError()).run();
return false;
diff --git a/app/src/main/java/info/nightscout/androidaps/receivers/NetworkChangeReceiver.java b/app/src/main/java/info/nightscout/androidaps/receivers/NetworkChangeReceiver.java
new file mode 100644
index 0000000000..b3a99b66ff
--- /dev/null
+++ b/app/src/main/java/info/nightscout/androidaps/receivers/NetworkChangeReceiver.java
@@ -0,0 +1,67 @@
+package info.nightscout.androidaps.receivers;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
+import android.net.wifi.SupplicantState;
+import android.net.wifi.WifiInfo;
+import android.net.wifi.WifiManager;
+import android.os.PowerManager;
+import android.support.annotation.Nullable;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import info.nightscout.androidaps.MainApp;
+import info.nightscout.androidaps.events.EventNetworkChange;
+
+public class NetworkChangeReceiver extends BroadcastReceiver {
+ private static Logger log = LoggerFactory.getLogger(NetworkChangeReceiver.class);
+
+ @Override
+ public void onReceive(final Context context, final Intent intent) {
+ PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
+ if (pm == null) return;
+ PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "NetworkChangeReceiver");
+ wl.acquire(10000);
+
+ EventNetworkChange event = grabNetworkStatus();
+ if (event != null)
+ MainApp.bus().post(event);
+
+ wl.release();
+ }
+
+ @Nullable
+ public static EventNetworkChange grabNetworkStatus() {
+ EventNetworkChange event = new EventNetworkChange();
+
+ ConnectivityManager cm = (ConnectivityManager) MainApp.instance().getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
+ if (cm == null) return null;
+ NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
+
+ if (activeNetwork != null) {
+ if (activeNetwork.getType() == ConnectivityManager.TYPE_WIFI) {
+ event.wifiConnected = true;
+ WifiManager wifiManager = (WifiManager) MainApp.instance().getApplicationContext().getSystemService(Context.WIFI_SERVICE);
+ if (wifiManager != null) {
+ WifiInfo wifiInfo = wifiManager.getConnectionInfo();
+ if (wifiInfo.getSupplicantState() == SupplicantState.COMPLETED) {
+ event.ssid = wifiInfo.getSSID();
+ }
+ log.debug("NETCHANGE: Wifi connected. SSID: " + event.ssid);
+ }
+ }
+ if (activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE) {
+ event.mobileConnected = true;
+ event.roaming = activeNetwork.isRoaming();
+ log.debug("NETCHANGE: Mobile connected. Roaming: " + event.roaming);
+ }
+ } else {
+ log.debug("NETCHANGE: Disconnected.");
+ }
+ return event;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/info/nightscout/utils/DecimalFormatter.java b/app/src/main/java/info/nightscout/utils/DecimalFormatter.java
index 6709b304d9..0f7164b690 100644
--- a/app/src/main/java/info/nightscout/utils/DecimalFormatter.java
+++ b/app/src/main/java/info/nightscout/utils/DecimalFormatter.java
@@ -46,13 +46,13 @@ public class DecimalFormatter {
}
public static String toPumpSupportedBolus(double value) {
- return ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep <= 0.01
+ return ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep <= 0.05
? to2Decimal(value)
: to1Decimal(value);
}
public static DecimalFormat pumpSupportedBolusFormat() {
- return ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep <= 0.01
+ return ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep <= 0.05
? new DecimalFormat("0.00")
: new DecimalFormat("0.0");
}
diff --git a/app/src/main/res/layout/activity_historybrowse.xml b/app/src/main/res/layout/activity_historybrowse.xml
index 88946033f4..1d52560eff 100644
--- a/app/src/main/res/layout/activity_historybrowse.xml
+++ b/app/src/main/res/layout/activity_historybrowse.xml
@@ -96,6 +96,13 @@
android:paddingTop="5dp"
app:srcCompat="@drawable/ic_arrow_drop_down_white_24dp" />
+
+
-
+
-
+
+
+
@@ -299,8 +306,8 @@
+ android:orientation="horizontal"
+ android:paddingRight="5dp">
+
+
+
+
+
+
Zeit/Datum des abgegebenen Boluses auf der Pumpe erscheint falsch, IOB ist wahrscheinlich nicht korrekt. Bitte prüfe Zeit/Datum der Pumpe.
Anzahl TBRs
Anzahl Boluse
+ Pumpe gestoppt
+ Pumpe gestartet
+ Pumpe pausiert
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index a0b229946e..4aa21abf19 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -8,6 +8,8 @@
#ffea00
#ff9500
#FFFFFF
+ #FFFFFF00
+ #FFFF00FF
#00FF00
#FF0000
#FFFF00
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index b38c086103..551d5b8e6a 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -619,6 +619,8 @@
Sensitivity AAPS
Absorption settings
absorption_maxtime
+ absorption_cutoff
+
Meal max absorption time [h]
Time in hours where is expected all carbs from meal will be absorbed
rangetodisplay
@@ -997,7 +999,29 @@
openapsmb_max_iob
Maximum total IOB OpenAPS can\'t go over [U]
This value is called Max IOB in OpenAPS context\nOpenAPS will not add more insulin if current IOB is greater than this value
+ Pump stopped
+ Pump started
+ Pump paused
+ Meal max absorption time [h]
+ Time at which any meal is considered absorbed. Remaining carbs will be cut off.
Time
show_notes_entry_dialogs
Show notes field in treatment dialogs
+ openapsama_min_5m_carbimpact
+ Asked: %.2fU Delivered: %.2fU Error code: %d
+ First insulin increment
+ Second insulin increment
+ Third insulin increment
+ First carbs increment
+ Second carbs increment
+ Third carbs increment
+ CGM
+ ns_wifionly
+ ns_wifi_ssids
+ ns_allowroaming
+ Use WiFi connection only
+ WiFi SSID
+ Connection settings
+ Allowed SSIDs (semicolon separated)
+ Allow connection in roaming
diff --git a/app/src/main/res/xml/pref_absorption_aaps.xml b/app/src/main/res/xml/pref_absorption_aaps.xml
index f86a21ec88..e5dab3128e 100644
--- a/app/src/main/res/xml/pref_absorption_aaps.xml
+++ b/app/src/main/res/xml/pref_absorption_aaps.xml
@@ -6,10 +6,10 @@
android:title="@string/absorptionsettings_title">
+ android:key="@string/key_openapsama_min_5m_carbimpact" />
+
+
diff --git a/app/src/main/res/xml/pref_advanced.xml b/app/src/main/res/xml/pref_advanced.xml
index 260e2c5135..1ca031a94e 100644
--- a/app/src/main/res/xml/pref_advanced.xml
+++ b/app/src/main/res/xml/pref_advanced.xml
@@ -5,29 +5,6 @@
android:key="advanced"
android:title="@string/advancedsettings_title">
-
-
-
-
-
-
-
-
-
+
+
-
-
-
-
-
-
-
+ android:title="@string/nsalarm_urgenthigh" />
+ android:title="@string/nsalarm_high" />
-
+ android:title="@string/nsalarm_low" />
+ android:title="@string/nsalarm_urgentlow" />
+ android:title="@string/nsalarm_staledata" />
+ validate:maxNumber="120"
+ validate:minNumber="15"
+ validate:testType="numericRange" />
+ android:title="@string/nsalarm_urgentstaledata" />
+ validate:maxNumber="180"
+ validate:minNumber="30"
+ validate:testType="numericRange" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/xml/pref_overview.xml b/app/src/main/res/xml/pref_overview.xml
index 7d2ecc4282..5d08cd671e 100644
--- a/app/src/main/res/xml/pref_overview.xml
+++ b/app/src/main/res/xml/pref_overview.xml
@@ -1,120 +1,150 @@
+
+
+
+ android:title="@string/treatments" />
+
+ android:title="@string/overview_calculator_label" />
+ android:title="@string/configbuilder_insulin" />
+
-
+
+
-
+
+
+ android:inputType="numberDecimal|numberSigned"
+ android:key="@string/key_insulin_button_increment_3"
+ android:maxLines="20"
+ android:selectAllOnFocus="true"
+ android:singleLine="true"
+ android:title="@string/thirdinsulinincrement"
+ validate:floatmaxNumber="5.0"
+ validate:floatminNumber="-5.0"
+ validate:testType="floatNumericRange" />
+ android:title="@string/carbs" />
+
-
+
+
-
+
+
+ android:inputType="numberSigned"
+ android:key="@string/key_carbs_button_increment_3"
+ android:maxLines="20"
+ android:selectAllOnFocus="true"
+ android:singleLine="true"
+ android:title="@string/thirdcarbsincrement"
+ validate:maxNumber="50"
+ validate:minNumber="-50"
+ validate:testType="numericRange" />
+ android:summary="@string/show_cgm_button_summary"
+ android:title="@string/cgm" />
+
+ android:summary="@string/show_calibration_button_summary"
+ android:title="@string/overview_calibration" />
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/xml/pref_quickwizard.xml b/app/src/main/res/xml/pref_quickwizard.xml
deleted file mode 100644
index d10e40a7e4..0000000000
--- a/app/src/main/res/xml/pref_quickwizard.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file