diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/comm/MsgSetBasalProfile.java b/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/comm/MsgSetBasalProfile.java index 97eb3844da..9acd5ec824 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/comm/MsgSetBasalProfile.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/comm/MsgSetBasalProfile.java @@ -4,6 +4,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.MainApp; +import info.nightscout.androidaps.R; +import info.nightscout.androidaps.plugins.Overview.Notification; +import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; public class MsgSetBasalProfile extends MessageBase { private static Logger log = LoggerFactory.getLogger(MsgSetBasalProfile.class); @@ -29,9 +33,13 @@ public class MsgSetBasalProfile extends MessageBase { if (result != 1) { failed = true; log.debug("Set basal profile result: " + result + " FAILED!!!"); + Notification reportFail = new Notification(Notification.PROFILE_SET_FAILED, MainApp.sResources.getString(R.string.profile_set_failed), Notification.URGENT); + MainApp.bus().post(new EventNewNotification(reportFail)); } else { if (Config.logDanaMessageDetail) log.debug("Set basal profile result: " + result); + Notification reportOK = new Notification(Notification.PROFILE_SET_OK, MainApp.sResources.getString(R.string.profile_set_ok), Notification.INFO, 60); + MainApp.bus().post(new EventNewNotification(reportOK)); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/comm/MsgSetSingleBasalProfile.java b/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/comm/MsgSetSingleBasalProfile.java index bde02afa21..4e57712b04 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/comm/MsgSetSingleBasalProfile.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/comm/MsgSetSingleBasalProfile.java @@ -1,9 +1,15 @@ package info.nightscout.androidaps.plugins.DanaR.comm; +import com.j256.ormlite.stmt.query.Not; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.MainApp; +import info.nightscout.androidaps.R; +import info.nightscout.androidaps.plugins.Overview.Notification; +import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; public class MsgSetSingleBasalProfile extends MessageBase { private static Logger log = LoggerFactory.getLogger(MsgSetSingleBasalProfile.class); @@ -28,9 +34,13 @@ public class MsgSetSingleBasalProfile extends MessageBase { if (result != 1) { failed = true; log.debug("Set basal profile result: " + result + " FAILED!!!"); + Notification reportFail = new Notification(Notification.PROFILE_SET_FAILED, MainApp.sResources.getString(R.string.profile_set_failed), Notification.URGENT); + MainApp.bus().post(new EventNewNotification(reportFail)); } else { if (Config.logDanaMessageDetail) log.debug("Set basal profile result: " + result); + Notification reportOK = new Notification(Notification.PROFILE_SET_OK, MainApp.sResources.getString(R.string.profile_set_ok), Notification.INFO, 60); + MainApp.bus().post(new EventNewNotification(reportOK)); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/comm/MsgSetSingleBasalProfile.java b/app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/comm/MsgSetSingleBasalProfile.java index 3163ae5c50..ce046bdccc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/comm/MsgSetSingleBasalProfile.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/comm/MsgSetSingleBasalProfile.java @@ -4,7 +4,11 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.MainApp; +import info.nightscout.androidaps.R; import info.nightscout.androidaps.plugins.DanaR.comm.MessageBase; +import info.nightscout.androidaps.plugins.Overview.Notification; +import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; public class MsgSetSingleBasalProfile extends MessageBase { private static Logger log = LoggerFactory.getLogger(MsgSetSingleBasalProfile.class); @@ -29,9 +33,13 @@ public class MsgSetSingleBasalProfile extends MessageBase { if (result != 1) { failed = true; log.debug("Set basal profile result: " + result + " FAILED!!!"); + Notification reportFail = new Notification(Notification.PROFILE_SET_FAILED, MainApp.sResources.getString(R.string.profile_set_failed), Notification.URGENT); + MainApp.bus().post(new EventNewNotification(reportFail)); } else { if (Config.logDanaMessageDetail) log.debug("Set basal profile result: " + result); + Notification reportOK = new Notification(Notification.PROFILE_SET_OK, MainApp.sResources.getString(R.string.profile_set_ok), Notification.INFO, 60); + MainApp.bus().post(new EventNewNotification(reportOK)); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Notification.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Notification.java index abf7858db4..bcbc14a877 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Notification.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Notification.java @@ -12,9 +12,39 @@ public class Notification { public static final int LOW = 2; public static final int INFO = 3; + public static final int PROFILE_SET_FAILED = 0; + public static final int PROFILE_SET_OK = 1; + public int id; - Date date; - String text; - Date validTo = new Date(0); - int level; + public Date date; + public String text; + public int level; + public Date validTo = new Date(0); + + public Notification() { + } + + public Notification(int id, Date date, String text, int level, Date validTo) { + this.id = id; + this.date = date; + this.text = text; + this.level = level; + this.validTo = validTo; + } + + public Notification(int id, String text, int level, int validMinutes) { + this.id = id; + this.date = new Date(); + this.text = text; + this.level = level; + this.validTo = new Date(new Date().getTime() + validMinutes * 60 * 1000L); + } + + public Notification(int id, String text, int level) { + this.id = id; + this.date = new Date(); + this.text = text; + this.level = level; + this.validTo = new Date(0); + } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/NotificationStore.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/NotificationStore.java index 09a5f6e0b4..b4cb02e914 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/NotificationStore.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/NotificationStore.java @@ -1,5 +1,8 @@ package info.nightscout.androidaps.plugins.Overview; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -12,6 +15,7 @@ import java.util.List; */ public class NotificationStore { + private static Logger log = LoggerFactory.getLogger(NotificationStore.class); public List store = new ArrayList(); public NotificationStore() { @@ -29,6 +33,7 @@ public class NotificationStore { } public void add(Notification n) { + log.info("Notification received: " + n.text); for (int i = 0; i < store.size(); i++) { if (get(i).id == n.id) { get(i).date = n.date; diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4123942e34..942455671f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -377,4 +377,6 @@ DanaR Korean Wrong pump driver selected Basal rate: + Setting of basal profile failed + Basal profile in pump updated