Merge pull request #522 from MilosKozak/dev

Dev
This commit is contained in:
AdrianLxM 2017-12-04 17:53:36 +01:00 committed by GitHub
commit aefb0d62df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 121 additions and 119 deletions

View file

@ -7,7 +7,7 @@ android:
components: components:
- platform-tools - platform-tools
- tools - tools
- build-tools-25.0.2 - build-tools-26.0.2
- android-23 - android-23
- extra-google-m2repository - extra-google-m2repository
- extra-android-m2repository - extra-android-m2repository

View file

@ -37,7 +37,7 @@ def generateGitBuild = { ->
android { android {
compileSdkVersion 23 compileSdkVersion 23
buildToolsVersion "25.0.2" buildToolsVersion "26.0.2"
defaultConfig { defaultConfig {
applicationId "info.nightscout.androidaps" applicationId "info.nightscout.androidaps"

View file

@ -54,7 +54,7 @@ public class Constants {
//Screen: Threshold for width/height to go into small width/height layout //Screen: Threshold for width/height to go into small width/height layout
public static final int SMALL_WIDTH = 320; public static final int SMALL_WIDTH = 320;
public static final int SMALL_HEIGHT = 320; public static final int SMALL_HEIGHT = 480;
//Autosens //Autosens
public static final double DEVIATION_TO_BE_EQUAL = 2.0; public static final double DEVIATION_TO_BE_EQUAL = 2.0;

View file

@ -632,6 +632,13 @@ public class NSClientService extends Service {
if (sgv.getMills() > latestDateInReceivedData) if (sgv.getMills() > latestDateInReceivedData)
latestDateInReceivedData = sgv.getMills(); latestDateInReceivedData = sgv.getMills();
} }
// Was that sgv more less 15 mins ago ?
boolean lessThan15MinAgo = false;
if((System.currentTimeMillis()-latestDateInReceivedData)/(60 * 1000L) < 15L )
lessThan15MinAgo = true;
if(Notification.isAlarmForStaleData() && lessThan15MinAgo){
MainApp.bus().post(new EventDismissNotification(Notification.NSALARM));
}
BroadcastSgvs.handleNewSgv(sgvs, MainApp.instance().getApplicationContext(), isDelta); BroadcastSgvs.handleNewSgv(sgvs, MainApp.instance().getApplicationContext(), isDelta);
} }
MainApp.bus().post(new EventNSClientNewLog("LAST", DateUtil.dateAndTimeString(latestDateInReceivedData))); MainApp.bus().post(new EventNSClientNewLog("LAST", DateUtil.dateAndTimeString(latestDateInReceivedData)));

View file

@ -35,6 +35,7 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
static double amount; static double amount;
public static boolean bolusEnded = false; public static boolean bolusEnded = false;
public static boolean running = true; public static boolean running = true;
public static boolean stopPressed = false;
public BolusProgressDialog() { public BolusProgressDialog() {
super(); super();
@ -62,6 +63,7 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
progressBar.setMax(100); progressBar.setMax(100);
statusView.setText(MainApp.sResources.getString(R.string.waitingforpump)); statusView.setText(MainApp.sResources.getString(R.string.waitingforpump));
setCancelable(false); setCancelable(false);
stopPressed = false;
return view; return view;
} }
@ -95,6 +97,7 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
switch (view.getId()) { switch (view.getId()) {
case R.id.overview_bolusprogress_stop: case R.id.overview_bolusprogress_stop:
log.debug("Stop bolus delivery button pressed"); log.debug("Stop bolus delivery button pressed");
stopPressed = true;
stopPressedView.setVisibility(View.VISIBLE); stopPressedView.setVisibility(View.VISIBLE);
stopButton.setVisibility(View.INVISIBLE); stopButton.setVisibility(View.INVISIBLE);
ConfigBuilderPlugin.getActivePump().stopBolusDelivering(); ConfigBuilderPlugin.getActivePump().stopBolusDelivering();

View file

@ -192,8 +192,8 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm); getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
int screen_width = dm.widthPixels; int screen_width = dm.widthPixels;
int screen_height = dm.heightPixels; int screen_height = dm.heightPixels;
smallWidth = screen_width < Constants.SMALL_WIDTH; smallWidth = screen_width <= Constants.SMALL_WIDTH;
smallHeight = screen_height < Constants.SMALL_HEIGHT; smallHeight = screen_height <= Constants.SMALL_HEIGHT;
boolean landscape = screen_height < screen_width; boolean landscape = screen_height < screen_width;
View view; View view;

View file

@ -194,7 +194,7 @@ public class GraphData {
basalsLineSeries = new LineGraphSeries<>(basalLine); basalsLineSeries = new LineGraphSeries<>(basalLine);
Paint paint = new Paint(); Paint paint = new Paint();
paint.setStyle(Paint.Style.STROKE); paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(2); paint.setStrokeWidth(MainApp.instance().getApplicationContext().getResources().getDisplayMetrics().scaledDensity*2);
paint.setPathEffect(new DashPathEffect(new float[]{2, 4}, 0)); paint.setPathEffect(new DashPathEffect(new float[]{2, 4}, 0));
paint.setColor(MainApp.sResources.getColor(R.color.basal)); paint.setColor(MainApp.sResources.getColor(R.color.basal));
basalsLineSeries.setCustomPaint(paint); basalsLineSeries.setCustomPaint(paint);
@ -204,7 +204,7 @@ public class GraphData {
absoluteBasalsLineSeries = new LineGraphSeries<>(absoluteBasalLine); absoluteBasalsLineSeries = new LineGraphSeries<>(absoluteBasalLine);
Paint absolutePaint = new Paint(); Paint absolutePaint = new Paint();
absolutePaint.setStyle(Paint.Style.STROKE); absolutePaint.setStyle(Paint.Style.STROKE);
absolutePaint.setStrokeWidth(4); absolutePaint.setStrokeWidth(MainApp.instance().getApplicationContext().getResources().getDisplayMetrics().scaledDensity*2);
absolutePaint.setColor(MainApp.sResources.getColor(R.color.basal)); absolutePaint.setColor(MainApp.sResources.getColor(R.color.basal));
absoluteBasalsLineSeries.setCustomPaint(absolutePaint); absoluteBasalsLineSeries.setCustomPaint(absolutePaint);

View file

@ -30,7 +30,10 @@ import android.graphics.Path;
import android.graphics.Point; import android.graphics.Point;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.Typeface; 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.GraphView;
import com.jjoe64.graphview.series.BaseSeries; import com.jjoe64.graphview.series.BaseSeries;
@ -44,6 +47,13 @@ import java.util.Iterator;
* @author jjoe64 * @author jjoe64
*/ */
public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> extends BaseSeries<E> { public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> extends BaseSeries<E> {
// Default spSize
int spSize = 12;
// Convert the sp to pixels
Context context = MainApp.instance().getApplicationContext();
float scaledTextSize = spSize * context.getResources().getDisplayMetrics().scaledDensity;
float scaledPxSize = context.getResources().getDisplayMetrics().scaledDensity * 1.5f;
/** /**
* choose a predefined shape to render for * choose a predefined shape to render for
* each data point. * each data point.
@ -193,22 +203,22 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
if (!overdraw) { if (!overdraw) {
if (value.getShape() == Shape.POINT) { if (value.getShape() == Shape.POINT) {
mPaint.setStrokeWidth(0); mPaint.setStrokeWidth(0);
canvas.drawCircle(endX, endY, value.getSize(), mPaint); canvas.drawCircle(endX, endY, scaledPxSize, mPaint);
} else if (value.getShape() == Shape.RECTANGLE) { } else if (value.getShape() == Shape.RECTANGLE) {
canvas.drawRect(endX-value.getSize(), endY-value.getSize(), endX+value.getSize(), endY+value.getSize(), mPaint); canvas.drawRect(endX-scaledPxSize, endY-scaledPxSize, endX+scaledPxSize, endY+scaledPxSize, mPaint);
} else if (value.getShape() == Shape.TRIANGLE) { } else if (value.getShape() == Shape.TRIANGLE) {
mPaint.setStrokeWidth(0); mPaint.setStrokeWidth(0);
Point[] points = new Point[3]; Point[] points = new Point[3];
points[0] = new Point((int)endX, (int)(endY-value.getSize())); points[0] = new Point((int)endX, (int)(endY-scaledPxSize));
points[1] = new Point((int)(endX+value.getSize()), (int)(endY+value.getSize()*0.67)); points[1] = new Point((int)(endX+scaledPxSize), (int)(endY+scaledPxSize*0.67));
points[2] = new Point((int)(endX-value.getSize()), (int)(endY+value.getSize()*0.67)); points[2] = new Point((int)(endX-scaledPxSize), (int)(endY+scaledPxSize*0.67));
drawArrows(points, canvas, mPaint); drawArrows(points, canvas, mPaint);
} else if (value.getShape() == Shape.BOLUS) { } else if (value.getShape() == Shape.BOLUS) {
mPaint.setStrokeWidth(0); mPaint.setStrokeWidth(0);
Point[] points = new Point[3]; Point[] points = new Point[3];
points[0] = new Point((int)endX, (int)(endY-value.getSize())); points[0] = new Point((int)endX, (int)(endY-scaledPxSize));
points[1] = new Point((int)(endX+value.getSize()), (int)(endY+value.getSize()*0.67)); points[1] = new Point((int)(endX+scaledPxSize), (int)(endY+scaledPxSize*0.67));
points[2] = new Point((int)(endX-value.getSize()), (int)(endY+value.getSize()*0.67)); points[2] = new Point((int)(endX-scaledPxSize), (int)(endY+scaledPxSize*0.67));
mPaint.setStyle(Paint.Style.FILL_AND_STROKE); mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
drawArrows(points, canvas, mPaint); drawArrows(points, canvas, mPaint);
if (value.getLabel() != null) { if (value.getLabel() != null) {
@ -220,7 +230,7 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
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); mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
canvas.drawRect(bounds, mPaint); canvas.drawRect(bounds, mPaint);
mPaint.setTextSize((int) (value.getSize() * 2.5)); mPaint.setTextSize((int) (scaledTextSize * 2.5));
mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.NORMAL)); mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.NORMAL));
mPaint.setFakeBoldText(true); mPaint.setFakeBoldText(true);
canvas.drawText(value.getLabel(), endX, endY, mPaint); canvas.drawText(value.getLabel(), endX, endY, mPaint);
@ -228,7 +238,8 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
} else if (value.getShape() == Shape.PROFILE) { } else if (value.getShape() == Shape.PROFILE) {
mPaint.setStrokeWidth(0); mPaint.setStrokeWidth(0);
if (value.getLabel() != null) { if (value.getLabel() != null) {
mPaint.setTextSize((int) (value.getSize() * 3)); //mPaint.setTextSize((int) (scaledPxSize * 3));
mPaint.setTextSize((float) (scaledTextSize*1.2));
mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD)); mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD));
Rect bounds = new Rect(); Rect bounds = new Rect();
mPaint.getTextBounds(value.getLabel(), 0, value.getLabel().length(), bounds); mPaint.getTextBounds(value.getLabel(), 0, value.getLabel().length(), bounds);
@ -245,25 +256,25 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
mPaint.setStyle(Paint.Style.STROKE); mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeWidth(5); mPaint.setStrokeWidth(5);
float w = mPaint.getStrokeWidth(); float w = mPaint.getStrokeWidth();
canvas.drawCircle(endX, endY, value.getSize(), mPaint); canvas.drawCircle(endX, endY, scaledPxSize, mPaint);
} else if (value.getShape() == Shape.BGCHECK) { } else if (value.getShape() == Shape.BGCHECK) {
mPaint.setStyle(Paint.Style.FILL_AND_STROKE); mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
mPaint.setStrokeWidth(0); mPaint.setStrokeWidth(0);
canvas.drawCircle(endX, endY, value.getSize(), mPaint); canvas.drawCircle(endX, endY, scaledPxSize, mPaint);
if (value.getLabel() != null) { if (value.getLabel() != null) {
drawLabel45(endX, endY, value, canvas); drawLabel45(endX, endY, value, canvas);
} }
} else if (value.getShape() == Shape.ANNOUNCEMENT) { } else if (value.getShape() == Shape.ANNOUNCEMENT) {
mPaint.setStyle(Paint.Style.FILL_AND_STROKE); mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
mPaint.setStrokeWidth(0); mPaint.setStrokeWidth(0);
canvas.drawCircle(endX, endY, value.getSize(), mPaint); canvas.drawCircle(endX, endY, scaledPxSize, mPaint);
if (value.getLabel() != null) { if (value.getLabel() != null) {
drawLabel45(endX, endY, value, canvas); drawLabel45(endX, endY, value, canvas);
} }
} else if (value.getShape() == Shape.GENERAL) { } else if (value.getShape() == Shape.GENERAL) {
mPaint.setStyle(Paint.Style.FILL_AND_STROKE); mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
mPaint.setStrokeWidth(0); mPaint.setStrokeWidth(0);
canvas.drawCircle(endX, endY, value.getSize(), mPaint); canvas.drawCircle(endX, endY, scaledPxSize, mPaint);
if (value.getLabel() != null) { if (value.getLabel() != null) {
drawLabel45(endX, endY, value, canvas); drawLabel45(endX, endY, value, canvas);
} }
@ -271,7 +282,7 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
mPaint.setStrokeWidth(0); mPaint.setStrokeWidth(0);
if (value.getLabel() != null) { if (value.getLabel() != null) {
mPaint.setStrokeWidth(0); mPaint.setStrokeWidth(0);
mPaint.setTextSize((int) (value.getSize() * 3)); mPaint.setTextSize((int) (scaledTextSize * 3));
mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD)); mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD));
Rect bounds = new Rect(); Rect bounds = new Rect();
mPaint.getTextBounds(value.getLabel(), 0, value.getLabel().length(), bounds); mPaint.getTextBounds(value.getLabel(), 0, value.getLabel().length(), bounds);
@ -286,7 +297,7 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
mPaint.setStrokeWidth(0); mPaint.setStrokeWidth(0);
if (value.getLabel() != null) { if (value.getLabel() != null) {
mPaint.setStrokeWidth(0); mPaint.setStrokeWidth(0);
mPaint.setTextSize((int) (value.getSize() * 3)); mPaint.setTextSize(scaledTextSize);
mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD)); mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD));
Rect bounds = new Rect(); Rect bounds = new Rect();
mPaint.getTextBounds(value.getLabel(), 0, value.getLabel().length(), bounds); mPaint.getTextBounds(value.getLabel(), 0, value.getLabel().length(), bounds);
@ -301,7 +312,7 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
mPaint.setStrokeWidth(0); mPaint.setStrokeWidth(0);
if (value.getLabel() != null) { if (value.getLabel() != null) {
mPaint.setStrokeWidth(0); mPaint.setStrokeWidth(0);
mPaint.setTextSize((int) (value.getSize() * 3)); mPaint.setTextSize(scaledTextSize * 3);
mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD)); mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD));
Rect bounds = new Rect(); Rect bounds = new Rect();
mPaint.getTextBounds(value.getLabel(), 0, value.getLabel().length(), bounds); mPaint.getTextBounds(value.getLabel(), 0, value.getLabel().length(), bounds);
@ -352,25 +363,25 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
void drawLabel45(float endX, float endY, E value, Canvas canvas) { void drawLabel45(float endX, float endY, E value, Canvas canvas) {
if (value.getLabel().startsWith("~")) { if (value.getLabel().startsWith("~")) {
float px = endX; float px = endX;
float py = endY + value.getSize(); float py = endY + scaledPxSize;
canvas.save(); canvas.save();
canvas.rotate(-45, px, py); canvas.rotate(-45, px, py);
mPaint.setTextSize((int) (value.getSize() * 2.5)); mPaint.setTextSize((float) (scaledTextSize*0.8));
mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.NORMAL)); mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.NORMAL));
mPaint.setFakeBoldText(true); mPaint.setFakeBoldText(true);
mPaint.setTextAlign(Paint.Align.RIGHT); mPaint.setTextAlign(Paint.Align.RIGHT);
canvas.drawText(value.getLabel().substring(1), px - value.getSize(), py, mPaint); canvas.drawText(value.getLabel().substring(1), px - scaledPxSize, py, mPaint);
mPaint.setTextAlign(Paint.Align.LEFT); mPaint.setTextAlign(Paint.Align.LEFT);
canvas.restore(); canvas.restore();
} else { } else {
float px = endX; float px = endX;
float py = endY - value.getSize(); float py = endY - scaledPxSize;
canvas.save(); canvas.save();
canvas.rotate(-45, px, py); canvas.rotate(-45, px, py);
mPaint.setTextSize((int) (value.getSize() * 2.5)); mPaint.setTextSize((float) (scaledTextSize*0.8));
mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.NORMAL)); mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.NORMAL));
mPaint.setFakeBoldText(true); mPaint.setFakeBoldText(true);
canvas.drawText(value.getLabel(), px + value.getSize(), py, mPaint); canvas.drawText(value.getLabel(), px + scaledPxSize, py, mPaint);
canvas.restore(); canvas.restore();
} }
} }

View file

@ -64,6 +64,8 @@ public class Notification {
public NSAlarm nsAlarm = null; public NSAlarm nsAlarm = null;
public Integer soundId = null; public Integer soundId = null;
public Notification() {
}
public Notification(int id, Date date, String text, int level, Date validTo) { public Notification(int id, Date date, String text, int level, Date validTo) {
this.id = id; this.id = id;
@ -175,9 +177,10 @@ public class Notification {
return false; return false;
} }
static boolean isAlarmForStaleData() { public static boolean isAlarmForStaleData(){
if (SP.getLong("snoozedTo", 0L) != 0L) { long snoozedTo = SP.getLong("snoozedTo", 0L);
if (System.currentTimeMillis() < SP.getLong("snoozedTo", 0L)) { if(snoozedTo != 0L){
if(System.currentTimeMillis() < SP.getLong("snoozedTo", 0L)) {
//log.debug("Alarm is snoozed for next "+(SP.getLong("snoozedTo", 0L)-System.currentTimeMillis())/1000+" seconds"); //log.debug("Alarm is snoozed for next "+(SP.getLong("snoozedTo", 0L)-System.currentTimeMillis())/1000+" seconds");
return false; return false;
} }
@ -188,16 +191,17 @@ public class Notification {
long bgReadingAgo = System.currentTimeMillis() - bgReading.date; long bgReadingAgo = System.currentTimeMillis() - bgReading.date;
int bgReadingAgoMin = (int) (bgReadingAgo / (1000 * 60)); int bgReadingAgoMin = (int) (bgReadingAgo / (1000 * 60));
// Added for testing // Added for testing
//bgReadingAgoMin = 20; // bgReadingAgoMin = 20;
log.debug("bgReadingAgoMin value is:" + bgReadingAgoMin);
Double threshold = NSSettingsStatus.getInstance().getThreshold("alarmTimeagoWarnMins");
boolean openAPSEnabledAlerts = NSSettingsStatus.getInstance().openAPSEnabledAlerts(); boolean openAPSEnabledAlerts = NSSettingsStatus.getInstance().openAPSEnabledAlerts();
log.debug("OpenAPS Alerts enabled: " + openAPSEnabledAlerts); //log.debug("bgReadingAgoMin value is:"+bgReadingAgoMin);
//log.debug("Stale alarm snoozed to: "+(System.currentTimeMillis() - snoozedTo)/60000L);
Double threshold = NSSettingsStatus.getInstance().getThreshold("alarmTimeagoWarnMins");
//log.debug("OpenAPS Alerts enabled: "+openAPSEnabledAlerts);
// if no thresshold from Ns get it loccally // if no thresshold from Ns get it loccally
if (threshold == null) threshold = SP.getDouble(R.string.key_nsalarm_staledatavalue, 15D); if(threshold == null) threshold = SP.getDouble(R.string.key_nsalarm_staledatavalue,15D);
// No threshold of OpenAPS Alarm so using the one for BG // No threshold of OpenAPS Alarm so using the one for BG
// Added OpenAPSEnabledAlerts to alarm check // Added OpenAPSEnabledAlerts to alarm check
if ((bgReadingAgoMin > threshold && SP.getBoolean(R.string.key_nsalarm_staledata, false)) || (bgReadingAgoMin > threshold && openAPSEnabledAlerts)) { if((bgReadingAgoMin > threshold && SP.getBoolean(R.string.key_nsalarm_staledata, false))||(bgReadingAgoMin > threshold && openAPSEnabledAlerts)){
return true; return true;
} }
//snoozing for threshold //snoozing for threshold

View file

@ -34,6 +34,7 @@ import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressDialog;
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress; import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
@ -365,6 +366,9 @@ public class DanaRExecutionService extends Service {
} }
public boolean bolus(double amount, int carbs, final Treatment t) { public boolean bolus(double amount, int carbs, final Treatment t) {
if (!isConnected()) return false;
if (BolusProgressDialog.stopPressed) return false;
bolusingTreatment = t; bolusingTreatment = t;
int preferencesSpeed = SP.getInt(R.string.key_danars_bolusspeed, 0); int preferencesSpeed = SP.getInt(R.string.key_danars_bolusspeed, 0);
MessageBase start; MessageBase start;
@ -374,8 +378,6 @@ public class DanaRExecutionService extends Service {
start = new MsgBolusStartWithSpeed(amount, preferencesSpeed); start = new MsgBolusStartWithSpeed(amount, preferencesSpeed);
MsgBolusStop stop = new MsgBolusStop(amount, t); MsgBolusStop stop = new MsgBolusStop(amount, t);
if (!isConnected()) return false;
if (carbs > 0) { if (carbs > 0) {
mSerialIOThread.sendMessage(new MsgSetCarbsEntry(System.currentTimeMillis(), carbs)); mSerialIOThread.sendMessage(new MsgSetCarbsEntry(System.currentTimeMillis(), carbs));
} }
@ -431,7 +433,8 @@ public class DanaRExecutionService extends Service {
} }
final Object o = new Object(); final Object o = new Object();
ConfigBuilderPlugin.getCommandQueue().readStatus("bolusingInterrupted", new Callback() { synchronized(o) {
ConfigBuilderPlugin.getCommandQueue().independentConnect("bolusingInterrupted", new Callback() {
@Override @Override
public void run() { public void run() {
if (danaRPump.lastBolusTime.getTime() > System.currentTimeMillis() - 60 * 1000L) { // last bolus max 1 min old if (danaRPump.lastBolusTime.getTime() > System.currentTimeMillis() - 60 * 1000L) { // last bolus max 1 min old
@ -440,14 +443,17 @@ public class DanaRExecutionService extends Service {
} else { } else {
log.debug("Bolus amount in history too old: " + danaRPump.lastBolusTime.toLocaleString()); log.debug("Bolus amount in history too old: " + danaRPump.lastBolusTime.toLocaleString());
} }
synchronized (o) {
o.notify(); o.notify();
} }
}
}); });
try { try {
o.wait(); o.wait();
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
} }
}
} else { } else {
ConfigBuilderPlugin.getCommandQueue().readStatus("bolusOK", null); ConfigBuilderPlugin.getCommandQueue().readStatus("bolusOK", null);
} }

View file

@ -34,6 +34,7 @@ import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressDialog;
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress; import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
@ -358,12 +359,13 @@ public class DanaRKoreanExecutionService extends Service {
} }
public boolean bolus(double amount, int carbs, final Treatment t) { public boolean bolus(double amount, int carbs, final Treatment t) {
if (!isConnected()) return false;
if (BolusProgressDialog.stopPressed) return false;
bolusingTreatment = t; bolusingTreatment = t;
MsgBolusStart start = new MsgBolusStart(amount); MsgBolusStart start = new MsgBolusStart(amount);
MsgBolusStop stop = new MsgBolusStop(amount, t); MsgBolusStop stop = new MsgBolusStop(amount, t);
if (!isConnected()) return false;
if (carbs > 0) { if (carbs > 0) {
mSerialIOThread.sendMessage(new MsgSetCarbsEntry(System.currentTimeMillis(), carbs)); mSerialIOThread.sendMessage(new MsgSetCarbsEntry(System.currentTimeMillis(), carbs));
} }
@ -387,48 +389,9 @@ public class DanaRKoreanExecutionService extends Service {
} }
waitMsec(300); waitMsec(300);
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();
bolusingEvent.t = t;
bolusingEvent.percent = 99;
bolusingTreatment = null; bolusingTreatment = null;
int speed = 12;
// try to find real amount if bolusing was interrupted or comm failed
if (t.insulin != amount) {
disconnect("bolusingInterrupted");
long bolusDurationInMSec = (long) (amount * speed * 1000);
long expectedEnd = bolusStart + bolusDurationInMSec + 3000;
while (System.currentTimeMillis() < expectedEnd) {
long waitTime = expectedEnd - System.currentTimeMillis();
bolusingEvent.status = String.format(MainApp.sResources.getString(R.string.waitingforestimatedbolusend), waitTime / 1000);
MainApp.bus().post(bolusingEvent);
SystemClock.sleep(1000);
}
final Object o = new Object();
ConfigBuilderPlugin.getCommandQueue().readStatus("bolusingInterrupted", new Callback() {
@Override
public void run() {
if (danaRPump.lastBolusTime.getTime() > System.currentTimeMillis() - 60 * 1000L) { // last bolus max 1 min old
t.insulin = danaRPump.lastBolusAmount;
log.debug("Used bolus amount from history: " + danaRPump.lastBolusAmount);
} else {
log.debug("Bolus amount in history too old: " + danaRPump.lastBolusTime.toLocaleString());
}
o.notify();
}
});
try {
o.wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
} else {
ConfigBuilderPlugin.getCommandQueue().readStatus("bolusOK", null); ConfigBuilderPlugin.getCommandQueue().readStatus("bolusOK", null);
}
return true; return true;
} }

View file

@ -24,6 +24,7 @@ import info.nightscout.androidaps.events.EventAppExit;
import info.nightscout.androidaps.events.EventInitializationChanged; import info.nightscout.androidaps.events.EventInitializationChanged;
import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressDialog;
import info.nightscout.androidaps.plugins.Overview.notifications.Notification; import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress; import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
@ -191,6 +192,9 @@ public class DanaRSService extends Service {
public boolean bolus(final double insulin, int carbs, long carbtime, Treatment t) { public boolean bolus(final double insulin, int carbs, long carbtime, Treatment t) {
if (!isConnected()) return false;
if (BolusProgressDialog.stopPressed) return false;
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.startingbolus))); MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.startingbolus)));
bolusingTreatment = t; bolusingTreatment = t;
final int preferencesSpeed = SP.getInt(R.string.key_danars_bolusspeed, 0); final int preferencesSpeed = SP.getInt(R.string.key_danars_bolusspeed, 0);
@ -198,8 +202,6 @@ public class DanaRSService extends Service {
DanaRS_Packet_Bolus_Set_Step_Bolus_Stop stop = new DanaRS_Packet_Bolus_Set_Step_Bolus_Stop(insulin, t); // initialize static variables DanaRS_Packet_Bolus_Set_Step_Bolus_Stop stop = new DanaRS_Packet_Bolus_Set_Step_Bolus_Stop(insulin, t); // initialize static variables
DanaRS_Packet_Notify_Delivery_Complete complete = new DanaRS_Packet_Notify_Delivery_Complete(insulin, t); // initialize static variables DanaRS_Packet_Notify_Delivery_Complete complete = new DanaRS_Packet_Notify_Delivery_Complete(insulin, t); // initialize static variables
if (!isConnected()) return false;
if (carbs > 0) { if (carbs > 0) {
// MsgSetCarbsEntry msg = new MsgSetCarbsEntry(carbtime, carbs); #### // MsgSetCarbsEntry msg = new MsgSetCarbsEntry(carbtime, carbs); ####
// bleComm.sendMessage(msg); // bleComm.sendMessage(msg);

View file

@ -34,6 +34,7 @@ import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressDialog;
import info.nightscout.androidaps.plugins.Overview.notifications.Notification; import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress; import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
@ -357,6 +358,9 @@ public class DanaRv2ExecutionService extends Service {
} }
public boolean bolus(final double amount, int carbs, long carbtime, final Treatment t) { public boolean bolus(final double amount, int carbs, long carbtime, final Treatment t) {
if (!isConnected()) return false;
if (BolusProgressDialog.stopPressed) return false;
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.startingbolus))); MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.startingbolus)));
bolusingTreatment = t; bolusingTreatment = t;
final int preferencesSpeed = SP.getInt(R.string.key_danars_bolusspeed, 0); final int preferencesSpeed = SP.getInt(R.string.key_danars_bolusspeed, 0);
@ -367,8 +371,6 @@ public class DanaRv2ExecutionService extends Service {
start = new MsgBolusStartWithSpeed(amount, preferencesSpeed); start = new MsgBolusStartWithSpeed(amount, preferencesSpeed);
MsgBolusStop stop = new MsgBolusStop(amount, t); MsgBolusStop stop = new MsgBolusStop(amount, t);
if (!isConnected()) return false;
if (carbs > 0) { if (carbs > 0) {
MsgSetCarbsEntry msg = new MsgSetCarbsEntry(carbtime, carbs); MsgSetCarbsEntry msg = new MsgSetCarbsEntry(carbtime, carbs);
mSerialIOThread.sendMessage(msg); mSerialIOThread.sendMessage(msg);

View file

@ -77,11 +77,7 @@ public class CommandQueue {
private QueueThread thread = null; private QueueThread thread = null;
private PumpEnactResult executingNowError() { private PumpEnactResult executingNowError() {
PumpEnactResult result = new PumpEnactResult(); return new PumpEnactResult().success(false).enacted(false).comment(MainApp.sResources.getString(R.string.executingrightnow));
result.success = false;
result.enacted = false;
result.comment = MainApp.sResources.getString(R.string.executingrightnow);
return result;
} }
public boolean isRunning(Command.CommandType type) { public boolean isRunning(Command.CommandType type) {
@ -139,6 +135,13 @@ public class CommandQueue {
} }
} }
public static void independentConnect(String reason, Callback callback) {
CommandQueue tempCommandQueue = new CommandQueue();
tempCommandQueue.readStatus(reason, callback);
QueueThread tempThread = new QueueThread(tempCommandQueue);
tempThread.start();
}
// returns true if command is queued // returns true if command is queued
public boolean bolus(DetailedBolusInfo detailedBolusInfo, Callback callback) { public boolean bolus(DetailedBolusInfo detailedBolusInfo, Callback callback) {
if (isRunning(Command.CommandType.BOLUS)) { if (isRunning(Command.CommandType.BOLUS)) {

View file

@ -97,8 +97,8 @@ public class QueueThread extends Thread {
if (queue.performing() == null) { if (queue.performing() == null) {
// Pickup 1st command and set performing variable // Pickup 1st command and set performing variable
if (queue.size() > 0) { if (queue.size() > 0) {
log.debug("State: performing");
queue.pickup(); queue.pickup();
log.debug("State: performing " + queue.performing().status());
MainApp.bus().post(new EventQueueChanged()); MainApp.bus().post(new EventQueueChanged());
queue.performing().execute(); queue.performing().execute();
queue.resetPerforming(); queue.resetPerforming();

View file

@ -276,7 +276,7 @@
<string name="overview_bolusprogress_stop">Detener</string> <string name="overview_bolusprogress_stop">Detener</string>
<string name="overview_bolusprogress_stoppressed">Parar pulsado</string> <string name="overview_bolusprogress_stoppressed">Parar pulsado</string>
<string name="waitingforpumpclicktorefresh">Esperando bomba. Click to refresh.</string> <string name="waitingforpumpclicktorefresh">Esperando bomba. Click to refresh.</string>
<string formatted="false" name="overview_bolusprogress_goingtodeliver">Va a entregar% .2fU</string> <string formatted="false" name="overview_bolusprogress_goingtodeliver">Va a entregar %.2fU</string>
<string name="objectives_0_objective">Configuración de visualización y monitoreo, y el análisis de los basales y ratios</string> <string name="objectives_0_objective">Configuración de visualización y monitoreo, y el análisis de los basales y ratios</string>
<string name="objectives_0_gate">Comprobar que los datos de BG están disponibles en Nightscout, y que los datos de la bomba de insulina se están subiendo</string> <string name="objectives_0_gate">Comprobar que los datos de BG están disponibles en Nightscout, y que los datos de la bomba de insulina se están subiendo</string>
<string name="objectives_1_objective">Empezar con bucle abierto</string> <string name="objectives_1_objective">Empezar con bucle abierto</string>

View file

@ -370,7 +370,7 @@
<string name="overview">начало</string> <string name="overview">начало</string>
<string name="overview_bolus_label">болюс</string> <string name="overview_bolus_label">болюс</string>
<string name="overview_bolusprogress_delivered">доставлено</string> <string name="overview_bolusprogress_delivered">доставлено</string>
<string name="overview_bolusprogress_goingtodeliver" formatted="false">будет доставлено %.2 fU е инс</string> <string name="overview_bolusprogress_goingtodeliver" formatted="false">будет доставлено %.2fU е инс</string>
<string name="overview_bolusprogress_stop">стоп</string> <string name="overview_bolusprogress_stop">стоп</string>
<string name="overview_bolusprogress_stoped">остановлено</string> <string name="overview_bolusprogress_stoped">остановлено</string>
<string name="overview_bolusprogress_stoppressed">нажат стоп</string> <string name="overview_bolusprogress_stoppressed">нажат стоп</string>

View file

@ -3,9 +3,10 @@
buildscript { buildscript {
repositories { repositories {
jcenter() jcenter()
google()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:2.3.3' classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files

View file

@ -1,6 +1,6 @@
#Sun Mar 05 11:39:37 CET 2017 #Sun Dec 03 18:20:55 CET 2017
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

View file

@ -23,7 +23,7 @@ def generateGitBuild = { ->
android { android {
compileSdkVersion 23 compileSdkVersion 23
buildToolsVersion "25.0.2" buildToolsVersion "26.0.2"
defaultConfig { defaultConfig {
applicationId "info.nightscout.androidaps" applicationId "info.nightscout.androidaps"