private static void prunePeers() { InetAddress toRemove = null; for (final Map.Entry<InetAddress, Long> entry : peers.entrySet()) { if (JoH.msSince(entry.getValue()) > Constants.DAY_IN_MS * 3) { toRemove = entry.getKey(); break; } } if (toRemove != null) peers.remove(toRemove); }
public TimeTx() { init(opcode, length, true); data.put((byte) 0x01); final Calendar cal = Calendar.getInstance(); cal.set(2014, 0, 1, 0, 0, 0); final int secondsSinceReferenceDate = (int) (JoH.msSince(cal.getTimeInMillis()) / 1000); data.putInt(secondsSinceReferenceDate); } }
static List<StatusItem> megaStatus() { final List<StatusItem> l = new ArrayList<>(); for (Map.Entry<String, String> entry : hostStatus.entrySet()) { final long status_time = hostStatusTime.get(entry.getKey()); if (entry.getValue().length() > 0) l.add(new StatusItem(entry.getKey(), entry.getValue() + ((status_time != 0) ? (" " + JoH.niceTimeSince(status_time) + " " + "ago") : ""), JoH.msSince(status_time) <= BgGraphBuilder.DEXCOM_PERIOD ? StatusItem.Highlight.GOOD : JoH.msSince(status_time) <= BgGraphBuilder.DEXCOM_PERIOD * 2 ? StatusItem.Highlight.NOTICE : StatusItem.Highlight.NORMAL)); } return l; }
static List<StatusItem> megaStatus() { final List<StatusItem> l = new ArrayList<>(); for (Map.Entry<String, String> entry : hostStatus.entrySet()) { final long status_time = hostStatusTime.get(entry.getKey()); if (entry.getValue().length() > 0) l.add(new StatusItem(entry.getKey(), entry.getValue() + ((status_time != 0) ? (" " + JoH.niceTimeSince(status_time) + " " + "ago") : ""), JoH.msSince(status_time) <= BgGraphBuilder.DEXCOM_PERIOD ? StatusItem.Highlight.GOOD : JoH.msSince(status_time) <= BgGraphBuilder.DEXCOM_PERIOD * 2 ? StatusItem.Highlight.NOTICE : StatusItem.Highlight.NORMAL)); } return l; }
public static List<String> getActivePeers() { final List<String> list = new ArrayList<>(); if (peers != null) { for (final Map.Entry<InetAddress, Long> entry : peers.entrySet()) { if (JoH.msSince(entry.getValue()) < Constants.HOUR_IN_MS * 3) { list.add(ip(entry.getKey())); } } } return list; }
public static long msSinceLastCalibration() { final Calibration calibration = lastValid(); if (calibration == null) return 86400000000L; return JoH.msSince(calibration.timestamp); }
@NonNull public static String extraStatusLine() { if (JoH.msSince(cacheTime) > Constants.SECOND_IN_MS * 5) { cache = extraStatusLineReal(); cacheTime = JoH.tsl(); if (D) UserError.Log.d(TAG, "Cache Miss"); } else { if (D) UserError.Log.d(TAG, "Cache Hit"); } return cache; }
public static synchronized Pair<Long, Integer> getCalibration() { final long timestamp = PersistentStore.getLong(PENDING_CALIBRATION_TIMESTAMP); final long glucose = PersistentStore.getLong(PENDING_CALIBRATION_GLUCOSE); if (glucose == 0 || timestamp == 0 || msSince(timestamp) > Constants.HOUR_IN_MS * 8) { return null; } else { return new Pair<>(timestamp, (int) glucose); } }
public static boolean isDataStale() { final BgReading last = lastNoSenssor(); if (last == null) return true; return JoH.msSince(last.timestamp) > Home.stale_data_millis(); }
@Override public void run() { if (JoH.msSince(lastProcessedIncomingData) > wait_time) { UserError.Log.d(TAG, "GOT NO REPLY FOR: " + item.description + " @ " + item.retries); item.retries++; if (item.retries <= MAX_QUEUE_RETRIES) { UserError.Log.d(TAG, "Retrying due to no reply: " + item.description); writeQueueItem(queue, item); } } } });
public String bestTime() { final long since = JoH.msSince(timestamp); if (since < Constants.DAY_IN_MS) { return JoH.hourMinuteString(timestamp); } else { return JoH.dateTimeText(timestamp); } }
@Override public void run() { if (JoH.msSince(PersistentStore.getLong("gcm-bgs-batch-time")) > 4000) { Log.d(TAG, "Progressing BGSbatch due to timeout"); processBgsBatch(true); } } }, 5000);
@Override public void run() { if (JoH.msSince(I.lastProcessedIncomingData) > wait_time) { UserError.Log.d(TAG, "GOT NO REPLY FOR: " + item.description + " @ " + item.retries); item.retries++; if (item.retries <= MAX_QUEUE_RETRIES) { UserError.Log.d(TAG, "Retrying due to no reply: " + item.description); writeQueueItem(queue, item); } } } });
public static boolean isDataStale() { final BgReading last = lastNoSenssor(); if (last == null) return true; return JoH.msSince(last.timestamp) > Home.stale_data_millis(); }
public static String getMyRollCall(final String topic) { if (topic != null && topic.equals(getTopic())) { if (myRollCall == null || JoH.msSince(myRollCall.created) > Constants.MINUTE_IN_MS * 15) { myRollCall = new RollCall(); } return myRollCall.toS(); } else { return "Invalid topic"; } }
public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); // TODO time should be absolute not relative!?!? final long time_since = JoH.msSince(bt.timestamp); Home.startHomeWithExtra(xdrip.getAppContext(), Home.BLUETOOTH_METER_CALIBRATION, BgGraphBuilder.unitized_string_static(bt.mgdl), Long.toString(time_since)); bt.addState(BloodTest.STATE_CALIBRATION); GcmActivity.syncBloodTests(); } });
@Override @NonNull protected Result onRunJob(@NonNull Job.Params params) { final long startTime = JoH.tsl(); //DailyIntentService.work(); UserError.Log.uel(TAG, JoH.dateTimeText(JoH.tsl()) + " Job Ran - finished, duration: " + JoH.niceTimeScalar(JoH.msSince(startTime))); return Result.SUCCESS; }
public static boolean isSlopeFlatEnough() { BgReading bgReading = BgReading.last(true); if (bgReading == null) return false; if (JoH.msSince(bgReading.timestamp) > Home.stale_data_millis()) { UserError.Log.d(TAG, "Slope cannot be flat enough as data is stale"); return false; } // TODO check if stale, check previous slope also, check that reading parameters also return isSlopeFlatEnough(bgReading); }
public static String prettyTime() { if (isStarted()) { final long elapsed = JoH.msSince(getStart()); if (elapsed < WARMUP_PERIOD) { return JoH.niceTimeScalar((double) WARMUP_PERIOD - elapsed, 1); } else { return JoH.niceTimeScalar((double) elapsed, 1); } } else { return ""; } }
@Override protected void onResume() { xdrip.checkForcedEnglish(this); setTitle("Nightscout Backfill"); super.onResume(); mNavigationDrawerFragment = (NavigationDrawerFragment) getFragmentManager().findFragmentById(R.id.navigation_drawer); mNavigationDrawerFragment.setUp(R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout), "Nightscout Backfill", this); if (JoH.msSince(locked) < Constants.HOUR_IN_MS) { JoH.static_toast_long("Still processing previous back-fill request!"); finish(); } }