notify about setting basal profile

This commit is contained in:
Milos Kozak 2016-12-09 16:04:07 +01:00
parent 4103e4bf4a
commit 6ba532d178
6 changed files with 67 additions and 4 deletions

View file

@ -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));
}
}

View file

@ -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));
}
}

View file

@ -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));
}
}

View file

@ -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);
}
}

View file

@ -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<Notification> store = new ArrayList<Notification>();
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;

View file

@ -377,4 +377,6 @@
<string name="danarkoreanpump">DanaR Korean</string>
<string name="wrongpumpdriverselected">Wrong pump driver selected</string>
<string name="basal_rate">Basal rate:</string>
<string name="profile_set_failed">Setting of basal profile failed</string>
<string name="profile_set_ok">Basal profile in pump updated</string>
</resources>