public static synchronized void refreshNoiseIfOlderThan(long timestamp) { if (noise_processed_till_timestamp < timestamp) { Log.d(TAG, "Refreshing Noise as Older: " + JoH.dateTimeText((long) noise_processed_till_timestamp) + " vs " + JoH.dateTimeText(timestamp)); // new only the last hour worth of data for this, simple mode should work for this calculation (new BgGraphBuilder(xdrip.getAppContext(), System.currentTimeMillis() - 60 * 60 * 1000, System.currentTimeMillis() + 5 * 60 * 1000, 24, true)).addBgReadingValues(true); } }
public static synchronized void refreshNoiseIfOlderThan(long timestamp) { if (noise_processed_till_timestamp < timestamp) { Log.d(TAG, "Refreshing Noise as Older: " + JoH.dateTimeText((long) noise_processed_till_timestamp) + " vs " + JoH.dateTimeText(timestamp)); // new only the last hour worth of data for this, simple mode should work for this calculation (new BgGraphBuilder(xdrip.getAppContext(), System.currentTimeMillis() - 60 * 60 * 1000, System.currentTimeMillis() + 5 * 60 * 1000, 24, true)).addBgReadingValues(true); } }
public static synchronized double getCurrentLowOccursAt() { try { final long last_bg_reading_timestamp = BgReading.last().timestamp; // TODO remove any duplication by using refreshNoiseIfOlderThan() if (low_occurs_at_processed_till_timestamp < last_bg_reading_timestamp) { Log.d(TAG, "Recalculating lowOccursAt: " + JoH.dateTimeText((long) low_occurs_at_processed_till_timestamp) + " vs " + JoH.dateTimeText(last_bg_reading_timestamp)); // new only the last hour worth of data for this (new BgGraphBuilder(xdrip.getAppContext(), System.currentTimeMillis() - 60 * 60 * 1000, System.currentTimeMillis() + 5 * 60 * 1000, 24, true)).addBgReadingValues(false); } else { Log.d(TAG, "Cached current low timestamp ok: " + JoH.dateTimeText((long) low_occurs_at_processed_till_timestamp) + " vs " + JoH.dateTimeText(last_bg_reading_timestamp)); } } catch (Exception e) { Log.e(TAG, "Got exception in getCurrentLowOccursAt() " + e); } return low_occurs_at; }
public static synchronized double getCurrentLowOccursAt() { try { final long last_bg_reading_timestamp = BgReading.last().timestamp; // TODO remove any duplication by using refreshNoiseIfOlderThan() if (low_occurs_at_processed_till_timestamp < last_bg_reading_timestamp) { Log.d(TAG, "Recalculating lowOccursAt: " + JoH.dateTimeText((long) low_occurs_at_processed_till_timestamp) + " vs " + JoH.dateTimeText(last_bg_reading_timestamp)); // new only the last hour worth of data for this (new BgGraphBuilder(xdrip.getAppContext(), System.currentTimeMillis() - 60 * 60 * 1000, System.currentTimeMillis() + 5 * 60 * 1000, 24, true)).addBgReadingValues(false); } else { Log.d(TAG, "Cached current low timestamp ok: " + JoH.dateTimeText((long) low_occurs_at_processed_till_timestamp) + " vs " + JoH.dateTimeText(last_bg_reading_timestamp)); } } catch (Exception e) { Log.e(TAG, "Got exception in getCurrentLowOccursAt() " + e); } return low_occurs_at; }
public void start() { if (mService == null) { Log.e(TAG, "SERVICE IS NULL - CANNOT START!"); return; } if (run_service_in_foreground) { Log.d(TAG, "should be moving to foreground"); // mHandler.post(new Runnable() { // @Override // public void run() { // TODO use constants final long end = System.currentTimeMillis() + (60000 * 5); final long start = end - (60000 * 60 * 3) - (60000 * 10); foregroundStatus(); Log.d(TAG, "CALLING START FOREGROUND: " + mService.getClass().getSimpleName()); mService.startForeground(ongoingNotificationId, new Notifications().createOngoingNotification(new BgGraphBuilder(mContext, start, end), mContext)); // } // }); } }
public void start() { if (mService == null) { Log.e(TAG, "SERVICE IS NULL - CANNOT START!"); return; } if (run_service_in_foreground) { Log.d(TAG, "should be moving to foreground"); // mHandler.post(new Runnable() { // @Override // public void run() { // TODO use constants final long end = System.currentTimeMillis() + (60000 * 5); final long start = end - (60000 * 60 * 3) - (60000 * 10); foregroundStatus(); Log.d(TAG, "CALLING START FOREGROUND: " + mService.getClass().getSimpleName()); mService.startForeground(ongoingNotificationId, new Notifications().createOngoingNotification(new BgGraphBuilder(mContext, start, end), mContext)); // } // }); } }
@Override public void onCreate() { super.onCreate(); context = getApplicationContext(); bgGraphBuilder = new BgGraphBuilder(context); initPebbleDisplays(); PebbleUtil.pebbleDisplayType = getCurrentBroadcastToPebbleSetting(); Log.d(TAG,"onCreate for: "+PebbleUtil.pebbleDisplayType.toString()); currentWatchFaceUUID = getActivePebbleDisplay().watchfaceUUID(); init(); }
private void setupCharts() { dateButton1.setText(dateFormatter.format(date1.getTime())); Calendar endDate = (GregorianCalendar) date1.clone(); endDate.add(Calendar.DATE, noDays); int numValues = noDays * (60 / 2) * 24; // LimiTTer sample rate 1 per 2 minutes BgGraphBuilder bgGraphBuilder = new BgGraphBuilder(this, date1.getTimeInMillis(), endDate.getTimeInMillis(), numValues, false); chart = (LineChartView) findViewById(R.id.chart); chart.setZoomType(ZoomType.HORIZONTAL); previewChart = (PreviewLineChartView) findViewById(R.id.chart_preview); previewChart.setZoomType(ZoomType.HORIZONTAL); chart.setLineChartData(bgGraphBuilder.lineData()); chart.setOnValueTouchListener(bgGraphBuilder.getOnValueSelectTooltipListener(this)); previewChart.setLineChartData(bgGraphBuilder.previewLineData(chart.getLineChartData())); previewChart.setViewportCalculationEnabled(true); chart.setViewportCalculationEnabled(true); previewChart.setViewportChangeListener(new ViewportListener()); chart.setViewportChangeListener(new ChartViewPortListener()); setupStatistics(date1.getTimeInMillis(), endDate.getTimeInMillis()); }
@Override public void onCreate() { super.onCreate(); context = getApplicationContext(); bgGraphBuilder = new BgGraphBuilder(context); initPebbleDisplays(); PebbleUtil.pebbleDisplayType = getCurrentBroadcastToPebbleSetting(); Log.d(TAG,"onCreate for: "+PebbleUtil.pebbleDisplayType.toString()); currentWatchFaceUUID = getActivePebbleDisplay().watchfaceUUID(); init(); }
public static synchronized double getCurrentLowOccursAt() {//KS TODO implement low predictions try { final long last_bg_reading_timestamp = BgReading.last().timestamp; if (low_occurs_at_processed_till_timestamp < last_bg_reading_timestamp) { Log.d(TAG, "Recalculating lowOccursAt: " + JoH.dateTimeText((long) low_occurs_at_processed_till_timestamp) + " vs " + JoH.dateTimeText(last_bg_reading_timestamp)); // new only the last hour worth of data for this (new BgGraphBuilder(xdrip.getAppContext(), System.currentTimeMillis() - 60 * 60 * 1000, System.currentTimeMillis() + 5 * 60 * 1000, 24, true)).addBgReadingValues(false); } else { Log.d(TAG, "Cached current low timestamp ok: " + JoH.dateTimeText((long) low_occurs_at_processed_till_timestamp) + " vs " + JoH.dateTimeText(last_bg_reading_timestamp)); } } catch (Exception e) { Log.e(TAG, "Got exception in getCurrentLowOccursAt() " + e); } return low_occurs_at; }
protected void refreshView(View view) { LineChartView chart = (LineChartView) view.findViewById(R.id.example_linechart); BgGraphBuilder bgGraphBuilder = new BgGraphBuilder(getContext()); chart.setLineChartData(bgGraphBuilder.lineData()); Viewport viewport = chart.getMaximumViewport(); chart.setViewportCalculationEnabled(false); chart.setInteractive(false); chart.setCurrentViewport(viewport); chart.setPadding(0, 0, 0, 0); chart.setLeft(0); chart.setTop(0); Log.d(TAG, "onBindExampleChart: refreshview " + chart.getHeight()); }
protected void refreshView(View view) { LineChartView chart = (LineChartView) view.findViewById(R.id.example_linechart); BgGraphBuilder bgGraphBuilder = new BgGraphBuilder(getContext()); chart.setLineChartData(bgGraphBuilder.lineData()); Viewport viewport = chart.getMaximumViewport(); chart.setViewportCalculationEnabled(false); chart.setInteractive(false); chart.setCurrentViewport(viewport); chart.setPadding(0, 0, 0, 0); chart.setLeft(0); chart.setTop(0); Log.d(TAG, "onBindExampleChart: refreshview " + chart.getHeight()); }
private void updateGraph() { long end = System.currentTimeMillis() + (60000 * 5); long start = end - (60000 * 60 * 3) - (60000 * 10); BgGraphBuilder bgGraphBuilder = new BgGraphBuilder(this, start, end); final Bitmap dreamBitmap = new BgSparklineBuilder(this) .setBgGraphBuilder(bgGraphBuilder) .setWidthPx(graph_width) .setHeightPx(graph_height) .showHighLine() .showLowLine() .setStart(System.currentTimeMillis() - 60000 * 60 * 3) .showAxes(true) .setBackgroundColor(getCol(ColorCache.X.color_notification_chart_background)) .setShowFiltered(DexCollectionType.hasFiltered() && Pref.getBooleanDefaultFalse("show_filtered_curve")) .build(); graphimage.setImageBitmap(dreamBitmap); }
private void updateGraph() { long end = System.currentTimeMillis() + (60000 * 5); long start = end - (60000 * 60 * 3) - (60000 * 10); BgGraphBuilder bgGraphBuilder = new BgGraphBuilder(this, start, end); final Bitmap dreamBitmap = new BgSparklineBuilder(this) .setBgGraphBuilder(bgGraphBuilder) .setWidthPx(graph_width) .setHeightPx(graph_height) .showHighLine() .showLowLine() .setStart(System.currentTimeMillis() - 60000 * 60 * 3) .showAxes(true) .setBackgroundColor(getCol(ColorCache.X.color_notification_chart_background)) .setShowFiltered(DexCollectionType.hasFiltered() && Pref.getBooleanDefaultFalse("show_filtered_curve")) .build(); graphimage.setImageBitmap(dreamBitmap); }
private void sendData() { BgReading bg = BgReading.last(); if (bg != null) { forceGoogleApiConnect(); if (wear_integration) { final int battery = PowerStateReceiver.getBatteryLevel(getApplicationContext()); new SendToDataLayerThread(WEARABLE_DATA_PATH, googleApiClient).executeOnExecutor(xdrip.executor, dataMap(bg, mPrefs, new BgGraphBuilder(getApplicationContext()), battery)); } } }
private boolean resetDataToLatest(DataMap dataMap, Context context) {//KS if (dataMap != null) { Double dmTimestamp = dataMap.getDouble("timestamp"); Log.d(TAG, "resetDataToLatest dataMap.datetime=" + JoH.dateTimeText(dmTimestamp.longValue()) + " dataMap.sgvDouble=" + dataMap.getDouble("sgvDouble")); // todo ratelimit Sensor.InitDb(context);//ensure database has already been initialized final BgReading last = BgReading.last(); if (last != null) { long bgTimestamp = last.timestamp; Log.d(TAG, "resetDataToLatest last.timestamp=" + JoH.dateTimeText(bgTimestamp) + " last.calculated_value=" + last.calculated_value); if (bgTimestamp > dmTimestamp) { dataMap(dataMap, last, mPrefs, new com.eveningoutpost.dexdrip.UtilityModels.BgGraphBuilder(context)); return true; } } } return false; }
private void sendData() { BgReading bg = BgReading.last(); if (bg != null) { forceGoogleApiConnect(); if (wear_integration) { final int battery = PowerStateReceiver.getBatteryLevel(getApplicationContext()); new SendToDataLayerThread(WEARABLE_DATA_PATH, googleApiClient).executeOnExecutor(xdrip.executor, dataMap(bg, mPrefs, new BgGraphBuilder(getApplicationContext()), battery)); } } }
private Bitmap createWearBitmap(long start, long end) { return new BgSparklineBuilder(mContext) .setBgGraphBuilder(new BgGraphBuilder(mContext)) .setStart(start) .setEnd(end) .showHighLine() .showLowLine() .showAxes() .setWidthPx(400) .setHeightPx(400) .setSmallDots() .build(); }
private Bitmap createWearBitmap(long start, long end) { return new BgSparklineBuilder(mContext) .setBgGraphBuilder(new BgGraphBuilder(mContext)) .setStart(start) .setEnd(end) .showHighLine() .showLowLine() .showAxes() .setWidthPx(400) .setHeightPx(400) .setSmallDots() .build(); }
private Bitmap createWearBitmap(long start, long end) { return new BgSparklineBuilder(mContext) .setBgGraphBuilder(new BgGraphBuilder(mContext)) .setStart(start) .setEnd(end) .showHighLine() .showLowLine() .showAxes() .setWidthPx(400) .setHeightPx(400) .setSmallDots() .build(); }