From 11b858776830bce7e0a605dfa74a9c7b411252ac Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sat, 23 Jun 2018 20:05:59 +0200 Subject: [PATCH] Warn on long time diffs on Rv2 --- .../PumpDanaRv2/services/DanaRv2ExecutionService.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java index 1ada4c629d..b8071db202 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java @@ -1,6 +1,7 @@ package info.nightscout.androidaps.plugins.PumpDanaRv2.services; import android.bluetooth.BluetoothDevice; +import android.content.Intent; import android.content.IntentFilter; import android.os.Binder; import android.os.SystemClock; @@ -18,6 +19,7 @@ import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.PumpEnactResult; +import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgSettingUserOptions; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgSetUserOptions; import info.nightscout.androidaps.plugins.Treatments.Treatment; @@ -210,6 +212,15 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { waitForWholeMinute(); // Dana can set only whole minute // add 10sec to be sure we are over minute (will be cutted off anyway) mSerialIOThread.sendMessage(new MsgSetTime(new Date(DateUtil.now() + T.secs(10).msecs()))); + if (Math.abs(timeDiff) > 60*60*1.5) { + //If time-diff is very large, warn user until we can synchronize history readings properly + Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class); + i.putExtra("soundid", R.raw.error); + i.putExtra("status", MainApp.gs(R.string.largetimediff)); + i.putExtra("title", MainApp.gs(R.string.largetimedifftitle)); + i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + MainApp.instance().startActivity(i); + } mSerialIOThread.sendMessage(new MsgSettingPumpTime()); timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L; log.debug("Pump time difference: " + timeDiff + " seconds");