restrict aproaching daily limit to once every 30 minutes RS

This commit is contained in:
AdrianLxM 2018-05-05 21:10:15 +02:00
parent 5458df0907
commit d99fafe375

View file

@ -87,6 +87,7 @@ public class DanaRSService extends Service {
private Treatment bolusingTreatment = null; private Treatment bolusingTreatment = null;
private long lastHistoryFetched = 0; private long lastHistoryFetched = 0;
private long lastApproachingDailyLimit = 0;
public DanaRSService() { public DanaRSService() {
try { try {
@ -165,9 +166,11 @@ public class DanaRSService extends Service {
NSUpload.uploadDeviceStatus(); NSUpload.uploadDeviceStatus();
if (danaRPump.dailyTotalUnits > danaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) { if (danaRPump.dailyTotalUnits > danaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) {
log.debug("Approaching daily limit: " + danaRPump.dailyTotalUnits + "/" + danaRPump.maxDailyTotalUnits); log.debug("Approaching daily limit: " + danaRPump.dailyTotalUnits + "/" + danaRPump.maxDailyTotalUnits);
Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.gs(R.string.approachingdailylimit), Notification.URGENT); if(System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) {
MainApp.bus().post(new EventNewNotification(reportFail)); Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.gs(R.string.approachingdailylimit), Notification.URGENT);
NSUpload.uploadError(MainApp.gs(R.string.approachingdailylimit) + ": " + danaRPump.dailyTotalUnits + "/" + danaRPump.maxDailyTotalUnits + "U"); MainApp.bus().post(new EventNewNotification(reportFail));
NSUpload.uploadError(MainApp.gs(R.string.approachingdailylimit) + ": " + danaRPump.dailyTotalUnits + "/" + danaRPump.maxDailyTotalUnits + "U");
}
} }
} catch (Exception e) { } catch (Exception e) {
log.error("Unhandled exception", e); log.error("Unhandled exception", e);