restrict aproaching daily limit to once every 30 minutes RS
This commit is contained in:
parent
5458df0907
commit
d99fafe375
1 changed files with 6 additions and 3 deletions
|
@ -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,10 +166,12 @@ 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);
|
||||||
|
if(System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) {
|
||||||
Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.gs(R.string.approachingdailylimit), Notification.URGENT);
|
Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.gs(R.string.approachingdailylimit), Notification.URGENT);
|
||||||
MainApp.bus().post(new EventNewNotification(reportFail));
|
MainApp.bus().post(new EventNewNotification(reportFail));
|
||||||
NSUpload.uploadError(MainApp.gs(R.string.approachingdailylimit) + ": " + danaRPump.dailyTotalUnits + "/" + danaRPump.maxDailyTotalUnits + "U");
|
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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue