insulincurves - notification on short DIA

This commit is contained in:
AdrianLxM 2017-08-14 20:41:24 +02:00
parent f23c3e7ae1
commit ee7b3cca22
2 changed files with 16 additions and 1 deletions

View file

@ -7,6 +7,8 @@ import info.nightscout.androidaps.data.Iob;
import info.nightscout.androidaps.db.Treatment;
import info.nightscout.androidaps.interfaces.InsulinInterface;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.plugins.Overview.Notification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
/**
* Created by adrian on 13.08.2017.
@ -16,6 +18,8 @@ public abstract class InsulinOrefBasePlugin implements PluginBase, InsulinInterf
public static double MIN_DIA = 5;
long lastWarned = 0;
@Override
public int getType() {
return INSULIN;
@ -44,7 +48,16 @@ public abstract class InsulinOrefBasePlugin implements PluginBase, InsulinInterf
@Override
public double getDia() {
double dia = getUserDefinedDia();
return Math.max(MIN_DIA, dia);
if(dia >= MIN_DIA){
return dia;
} else {
if((System.currentTimeMillis() - lastWarned) > 60*1000) {
lastWarned = System.currentTimeMillis();
Notification notification = new Notification(Notification.SHORT_DIA, String.format(MainApp.sResources.getString(R.string.dia_too_short), dia, MIN_DIA), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification));
}
return MIN_DIA;
}
}
public double getUserDefinedDia() {

View file

@ -47,6 +47,8 @@ public class Notification {
public static final int NSANNOUNCEMENT = 18;
public static final int NSALARM = 19;
public static final int NSURGENTALARM = 20;
public static final int SHORT_DIA = 21;
public int id;
public Date date;