public static String getIOB() { final String statusLine = getLastStatusLine(); if (statusLine.length() == 0) return ""; final String check = statusLine.replaceAll("[^%]", ""); if (check.length() > 0) { UserError.Log.v(TAG, statusLine); return statusLine.substring((statusLine.lastIndexOf('%') + 2), (statusLine.lastIndexOf('%') + 6)); } else if (check.length() == 0) { UserError.Log.v(TAG, statusLine); return statusLine.substring(0, 4); } else return "???"; }
private static boolean isCurrent() { return isCurrent(getLastStatusLineTime()); }
public static Integer getTBRInt() { try { return Integer.parseInt(getTBR().replace("%", "")); } catch (NumberFormatException e) { return null; } }
public static void update(long timestamp, String statusline, boolean receivedLocally) { if (statusline != null) { if (statusline.length() > MAX_LEN) { statusline = statusline.substring(0, MAX_LEN); } // store the data if (isCurrent(timestamp)) { PersistentStore.setString(EXTERNAL_STATUS_STORE, statusline); PersistentStore.setLong(EXTERNAL_STATUS_STORE_TIME, timestamp); } if (statusline.length() > 0) { final Integer percent = getTBRInt(); if (percent != null) { APStatus.createEfficientRecord(timestamp, percent); } else { UserError.Log.wtf(TAG, "Could not parse TBR from: " + statusline); } } // notify observers NewDataObserver.newExternalStatus(receivedLocally); } }
final long last_raw_record_timestamp = ExternalStatusService.getLastStatusLineTime(); final Integer last_recorded_tbr = ExternalStatusService.getTBRInt(); if (last_recorded_tbr != null) { if ((last.basal_percent == last_recorded_tbr) && (JoH.msSince(last.timestamp) < Constants.HOUR_IN_MS * 3) && (JoH.msSince(ExternalStatusService.getLastStatusLineTime()) < Constants.MINUTE_IN_MS * 20)) { results.add(new APStatus(JoH.tsl(), last_recorded_tbr)); UserError.Log.d(TAG, "Adding extension record");
String external_status_line = getLastStatusLine(); item.put("aaps-ts", getLastStatusLineTime()); external_status_line = "";
@Override protected void onHandleIntent(Intent intent) { if (intent == null) return; try { final String action = intent.getAction(); if (action == null) return; if (ACTION_NEW_EXTERNAL_STATUSLINE.equals(action)) { final String statusLine = intent.getStringExtra(EXTRA_STATUSLINE); update(JoH.tsl(), statusLine, true); } } finally { WakefulBroadcastReceiver.completeWakefulIntent(intent); } }
@NonNull public static String getLastStatusLine() { if (isCurrent()) { return PersistentStore.getString(EXTERNAL_STATUS_STORE); } else { return ""; // ignore if more than 8 hours old } }
public ExternalStatusService() { super("ExternalStatusService"); setIntentRedelivery(true); }
public static void update(long timestamp, String statusline, boolean receivedLocally) { if (statusline != null) { if (statusline.length() > MAX_LEN) { statusline = statusline.substring(0, MAX_LEN); } // store the data if (isCurrent(timestamp)) { PersistentStore.setString(EXTERNAL_STATUS_STORE, statusline); PersistentStore.setLong(EXTERNAL_STATUS_STORE_TIME, timestamp); } if (statusline.length() > 0) { final Integer percent = getTBRInt(); if (percent != null) { APStatus.createEfficientRecord(timestamp, percent); } else { UserError.Log.wtf(TAG, "Could not parse TBR from: " + statusline); } } // notify observers NewDataObserver.newExternalStatus(receivedLocally); } }
final long last_raw_record_timestamp = ExternalStatusService.getLastStatusLineTime(); final Integer last_recorded_tbr = ExternalStatusService.getTBRInt(); if (last_recorded_tbr != null) { if ((last.basal_percent == last_recorded_tbr) && (JoH.msSince(last.timestamp) < Constants.HOUR_IN_MS * 3) && (JoH.msSince(ExternalStatusService.getLastStatusLineTime()) < Constants.MINUTE_IN_MS * 20)) { results.add(new APStatus(JoH.tsl(), last_recorded_tbr)); UserError.Log.d(TAG, "Adding extension record");
String external_status_line = getLastStatusLine(); item.put("aaps-ts", getLastStatusLineTime()); external_status_line = "";
@Override protected void onHandleIntent(Intent intent) { if (intent == null) return; try { final String action = intent.getAction(); if (action == null) return; if (ACTION_NEW_EXTERNAL_STATUSLINE.equals(action)) { final String statusLine = intent.getStringExtra(EXTRA_STATUSLINE); update(JoH.tsl(), statusLine, true); } } finally { WakefulBroadcastReceiver.completeWakefulIntent(intent); } }
@NonNull public static String getLastStatusLine() { if (isCurrent()) { return PersistentStore.getString(EXTERNAL_STATUS_STORE); } else { return ""; // ignore if more than 8 hours old } }
public ExternalStatusService() { super("ExternalStatusService"); setIntentRedelivery(true); }
public static String getIOB() { final String statusLine = getLastStatusLine(); if (statusLine.length() == 0) return ""; final String check = statusLine.replaceAll("[^%]", ""); if (check.length() > 0) { UserError.Log.v(TAG, statusLine); return statusLine.substring((statusLine.lastIndexOf('%') + 2), (statusLine.lastIndexOf('%') + 6)); } else if (check.length() == 0) { UserError.Log.v(TAG, statusLine); return statusLine.substring(0, 4); } else return "???"; }
private static boolean isCurrent() { return isCurrent(getLastStatusLineTime()); }
final String[] segments = payload.split("\\^"); try { ExternalStatusService.update(Long.parseLong(segments[0]), segments[1], false); } catch (ArrayIndexOutOfBoundsException | NumberFormatException e) { UserError.Log.wtf(TAG, "Could not split esup payload");
public static Integer getTBRInt() { try { return Integer.parseInt(getTBR().replace("%", "")); } catch (NumberFormatException e) { return null; } }
public static String getTBR() { final String statusLine = getLastStatusLine(); if (statusLine.length() == 0) return ""; final String check = statusLine.replaceAll("[^%]", ""); if (check.length() > 0) { int index1 = 0, index2 = 4; UserError.Log.v(TAG, statusLine); if (statusLine.lastIndexOf('%') == 3) index2 = 4; else if (statusLine.lastIndexOf('%') == 2) index2 = 3; else if (statusLine.lastIndexOf('%') == 1) index2 = 2; return statusLine.substring(index1, index2); } else if (check.length() == 0) return "100%"; else return "???"; }