visualize SMB

This commit is contained in:
Milos Kozak 2017-08-21 17:42:26 +02:00
parent 204c39880f
commit aad168c50f
3 changed files with 28 additions and 9 deletions

View file

@ -14,6 +14,7 @@ import java.util.Objects;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Iob; import info.nightscout.androidaps.data.Iob;
import info.nightscout.androidaps.interfaces.InsulinInterface; import info.nightscout.androidaps.interfaces.InsulinInterface;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
@ -160,6 +161,9 @@ public class Treatment implements DataPointWithLabelInterface {
@Override @Override
public PointsWithLabelGraphSeries.Shape getShape() { public PointsWithLabelGraphSeries.Shape getShape() {
if (isSMB)
return PointsWithLabelGraphSeries.Shape.SMB;
else
return PointsWithLabelGraphSeries.Shape.BOLUS; return PointsWithLabelGraphSeries.Shape.BOLUS;
} }
@ -170,6 +174,9 @@ public class Treatment implements DataPointWithLabelInterface {
@Override @Override
public int getColor() { public int getColor() {
if (isSMB)
return MainApp.sResources.getColor(R.color.tempbasal);
else
return Color.CYAN; return Color.CYAN;
} }

View file

@ -1595,6 +1595,9 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
if (!t.isValid) if (!t.isValid)
continue; continue;
if (t.getX() < fromTime || t.getX() > endTime) continue; if (t.getX() < fromTime || t.getX() > endTime) continue;
if (t.isSMB)
t.setY(lowLine);
else
t.setY(getNearestBg((long) t.getX(), bgReadingsArray)); t.setY(getNearestBg((long) t.getX(), bgReadingsArray));
filteredTreatments.add(t); filteredTreatments.add(t);
} }
@ -1734,7 +1737,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
public void onBindViewHolder(NotificationsViewHolder holder, int position) { public void onBindViewHolder(NotificationsViewHolder holder, int position) {
Notification notification = notificationsList.get(position); Notification notification = notificationsList.get(position);
holder.dismiss.setTag(notification); holder.dismiss.setTag(notification);
if(notification.text == MainApp.sResources.getString(R.string.nsalarm_staledata)) if (notification.text == MainApp.sResources.getString(R.string.nsalarm_staledata))
holder.dismiss.setText("snooze"); holder.dismiss.setText("snooze");
holder.text.setText(notification.text); holder.text.setText(notification.text);
holder.time.setText(DateUtil.timeString(notification.date)); holder.time.setText(DateUtil.timeString(notification.date));
@ -1785,12 +1788,12 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
BroadcastAckAlarm.handleClearAlarm(notification.nsAlarm, MainApp.instance().getApplicationContext(), 60 * 60 * 1000L); BroadcastAckAlarm.handleClearAlarm(notification.nsAlarm, MainApp.instance().getApplicationContext(), 60 * 60 * 1000L);
} }
// Adding current time to snooze if we got staleData // Adding current time to snooze if we got staleData
log.debug("Notification text is: "+notification.text); log.debug("Notification text is: " + notification.text);
if(notification.text.equals(MainApp.sResources.getString(R.string.nsalarm_staledata))){ if (notification.text.equals(MainApp.sResources.getString(R.string.nsalarm_staledata))) {
NotificationStore nstore = getPlugin().notificationStore; NotificationStore nstore = getPlugin().notificationStore;
long msToSnooze = SP.getInt("nsalarm_staledatavalue",15)*60*1000L; long msToSnooze = SP.getInt("nsalarm_staledatavalue", 15) * 60 * 1000L;
log.debug("snooze nsalarm_staledatavalue in minutes is "+SP.getInt("nsalarm_staledatavalue",15)+"\n in ms is: "+msToSnooze+" currentTimeMillis is: "+System.currentTimeMillis()); log.debug("snooze nsalarm_staledatavalue in minutes is " + SP.getInt("nsalarm_staledatavalue", 15) + "\n in ms is: " + msToSnooze + " currentTimeMillis is: " + System.currentTimeMillis());
nstore.snoozeTo(System.currentTimeMillis()+(SP.getInt("nsalarm_staledatavalue",15)*60*1000L)); nstore.snoozeTo(System.currentTimeMillis() + (SP.getInt("nsalarm_staledatavalue", 15) * 60 * 1000L));
} }
break; break;
} }

View file

@ -55,6 +55,7 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
TRIANGLE, TRIANGLE,
RECTANGLE, RECTANGLE,
BOLUS, BOLUS,
SMB,
EXTENDEDBOLUS, EXTENDEDBOLUS,
PROFILE, PROFILE,
MBG, MBG,
@ -218,6 +219,14 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
if (value.getLabel() != null) { if (value.getLabel() != null) {
drawLabel45(endX, endY, value, canvas); drawLabel45(endX, endY, value, canvas);
} }
} else if (value.getShape() == Shape.SMB) {
mPaint.setStrokeWidth(2);
Point[] points = new Point[3];
points[0] = new Point((int)endX, (int)(endY-value.getSize()));
points[1] = new Point((int)(endX+value.getSize()), (int)(endY+value.getSize()*0.67));
points[2] = new Point((int)(endX-value.getSize()), (int)(endY+value.getSize()*0.67));
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
drawArrows(points, canvas, mPaint);
} else if (value.getShape() == Shape.EXTENDEDBOLUS) { } else if (value.getShape() == Shape.EXTENDEDBOLUS) {
mPaint.setStrokeWidth(0); mPaint.setStrokeWidth(0);
if (value.getLabel() != null) { if (value.getLabel() != null) {