Java Code Examples for com.eveningoutpost.dexdrip.Models.BgReading#latestForGraph()
The following examples show how to use
com.eveningoutpost.dexdrip.Models.BgReading#latestForGraph() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BgGraphBuilder.java From xDrip with GNU General Public License v3.0 | 6 votes |
public BgGraphBuilder(Context context, long start, long end, int numValues){ end_time = end; start_time = start; bgReadings = BgReading.latestForGraph( numValues, start, end); calibrations = Calibration.latestForGraph( numValues, start, end); this.context = context; this.prefs = PreferenceManager.getDefaultSharedPreferences(context); this.highMark = Double.parseDouble(prefs.getString("highValue", "170")); this.lowMark = Double.parseDouble(prefs.getString("lowValue", "70")); this.doMgdl = (prefs.getString("units", "mgdl").equals("mgdl")); defaultMinY = unitized(40); defaultMaxY = unitized(250); pointSize = isXLargeTablet(context) ? 5 : 3; axisTextSize = isXLargeTablet(context) ? 20 : Axis.DEFAULT_TEXT_SIZE_SP; previewAxisTextSize = isXLargeTablet(context) ? 12 : 5; hoursPreviewStep = isXLargeTablet(context) ? 2 : 1; }
Example 2
Source File: WatchUpdaterService.java From xDrip with GNU General Public License v3.0 | 6 votes |
private void resendData(long since) { Log.d(TAG, "resendData ENTER"); forceGoogleApiConnect(); final long startTime = since == 0 ? new Date().getTime() - (60000 * 60 * 24) : since; Log.d(TAG, "resendData googleApiClient connected ENTER, sending since: " + JoH.dateTimeText(startTime)); final BgReading last_bg = BgReading.last(); if (last_bg != null) { List<BgReading> graph_bgs = BgReading.latestForGraph(60, startTime); BgGraphBuilder bgGraphBuilder = new BgGraphBuilder(getApplicationContext()); if (!graph_bgs.isEmpty()) { final int battery = PowerStateReceiver.getBatteryLevel(getApplicationContext()); DataMap entries = dataMap(last_bg, mPrefs, bgGraphBuilder, battery); final ArrayList<DataMap> dataMaps = new ArrayList<>(graph_bgs.size()); for (BgReading bg : graph_bgs) { dataMaps.add(dataMap(bg, mPrefs, bgGraphBuilder, battery)); } entries.putLong("time", new Date().getTime()); // MOST IMPORTANT LINE FOR TIMESTAMP entries.putDataMapArrayList("entries", dataMaps); if (mPrefs.getBoolean("extra_status_line", false)) { entries.putString("extra_status_line", StatusLine.extraStatusLine()); } new SendToDataLayerThread(WEARABLE_DATA_PATH, googleApiClient).executeOnExecutor(xdrip.executor, entries); } } }
Example 3
Source File: BgGraphBuilder.java From xDrip-plus with GNU General Public License v3.0 | 6 votes |
public BgGraphBuilder(Context context, long start, long end, int numValues){ end_time = end; start_time = start; bgReadings = BgReading.latestForGraph( numValues, start, end); calibrations = Calibration.latestForGraph( numValues, start, end); this.context = context; this.prefs = PreferenceManager.getDefaultSharedPreferences(context); this.highMark = Double.parseDouble(prefs.getString("highValue", "170")); this.lowMark = Double.parseDouble(prefs.getString("lowValue", "70")); this.doMgdl = (prefs.getString("units", "mgdl").equals("mgdl")); defaultMinY = unitized(40); defaultMaxY = unitized(250); pointSize = isXLargeTablet(context) ? 5 : 3; axisTextSize = isXLargeTablet(context) ? 20 : Axis.DEFAULT_TEXT_SIZE_SP; previewAxisTextSize = isXLargeTablet(context) ? 12 : 5; hoursPreviewStep = isXLargeTablet(context) ? 2 : 1; }
Example 4
Source File: WatchUpdaterService.java From xDrip-plus with GNU General Public License v3.0 | 6 votes |
private void resendData(long since) { Log.d(TAG, "resendData ENTER"); forceGoogleApiConnect(); final long startTime = since == 0 ? new Date().getTime() - (60000 * 60 * 24) : since; Log.d(TAG, "resendData googleApiClient connected ENTER, sending since: " + JoH.dateTimeText(startTime)); final BgReading last_bg = BgReading.last(); if (last_bg != null) { List<BgReading> graph_bgs = BgReading.latestForGraph(60, startTime); BgGraphBuilder bgGraphBuilder = new BgGraphBuilder(getApplicationContext()); if (!graph_bgs.isEmpty()) { final int battery = PowerStateReceiver.getBatteryLevel(getApplicationContext()); DataMap entries = dataMap(last_bg, mPrefs, bgGraphBuilder, battery); final ArrayList<DataMap> dataMaps = new ArrayList<>(graph_bgs.size()); for (BgReading bg : graph_bgs) { dataMaps.add(dataMap(bg, mPrefs, bgGraphBuilder, battery)); } entries.putLong("time", new Date().getTime()); // MOST IMPORTANT LINE FOR TIMESTAMP entries.putDataMapArrayList("entries", dataMaps); if (mPrefs.getBoolean("extra_status_line", false)) { entries.putString("extra_status_line", StatusLine.extraStatusLine()); } new SendToDataLayerThread(WEARABLE_DATA_PATH, googleApiClient).executeOnExecutor(xdrip.executor, entries); } } }
Example 5
Source File: BgGraphBuilder.java From xDrip-Experimental with GNU General Public License v3.0 | 6 votes |
public BgGraphBuilder(Context context, long start, long end, int numValues){ end_time = end; start_time = start; bgReadings = BgReading.latestForGraph( numValues, start, end); calibrations = Calibration.latestForGraph( numValues, start, end); this.context = context; this.prefs = PreferenceManager.getDefaultSharedPreferences(context); this.highMark = Double.parseDouble(prefs.getString("highValue", "170")); this.lowMark = Double.parseDouble(prefs.getString("lowValue", "70")); this.doMgdl = (prefs.getString("units", "mgdl").equals("mgdl")); defaultMinY = unitized(40); defaultMaxY = unitized(250); pointSize = isXLargeTablet(context) ? 5 : 3; axisTextSize = isXLargeTablet(context) ? 20 : Axis.DEFAULT_TEXT_SIZE_SP; previewAxisTextSize = isXLargeTablet(context) ? 12 : 5; hoursPreviewStep = isXLargeTablet(context) ? 2 : 1; }
Example 6
Source File: WatchUpdaterService.java From xDrip-Experimental with GNU General Public License v3.0 | 6 votes |
private void resendData() { if(googleApiClient != null && !googleApiClient.isConnected() && !googleApiClient.isConnecting()) { googleApiConnect(); } long startTime = new Date().getTime() - (60000 * 60 * 24); BgReading last_bg = BgReading.last(); List<BgReading> graph_bgs = BgReading.latestForGraph(60, startTime); BgGraphBuilder bgGraphBuilder = new BgGraphBuilder(getApplicationContext()); if (!graph_bgs.isEmpty()) { DataMap entries = dataMap(last_bg, mPrefs, bgGraphBuilder); final ArrayList<DataMap> dataMaps = new ArrayList<>(graph_bgs.size()); for (BgReading bg : graph_bgs) { dataMaps.add(dataMap(bg, mPrefs, bgGraphBuilder)); } entries.putDataMapArrayList("entries", dataMaps); new SendToDataLayerThread(WEARABLE_DATA_PATH, googleApiClient).execute(entries); } }
Example 7
Source File: BgSendQueue.java From xDrip with GNU General Public License v3.0 | 5 votes |
public static void resendData(Context context, int battery) {//KS Log.d("BgSendQueue", "resendData enter battery=" + battery); long startTime = new Date().getTime() - (60000 * 60 * 24); Intent messageIntent = new Intent(); messageIntent.setAction(Intent.ACTION_SEND); messageIntent.putExtra("message", "ACTION_G5BG"); BgReading last_bg = BgReading.last(); if (last_bg != null) { Log.d("BgSendQueue", "resendData last_bg.timestamp:" + JoH.dateTimeText(last_bg.timestamp)); } List<BgReading> graph_bgs = BgReading.latestForGraph(60, startTime); BgGraphBuilder bgGraphBuilder = new BgGraphBuilder(context.getApplicationContext()); if (!graph_bgs.isEmpty()) { Log.d("BgSendQueue", "resendData graph_bgs size=" + graph_bgs.size()); final ArrayList<DataMap> dataMaps = new ArrayList<>(graph_bgs.size()); SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext()); DataMap entries = dataMap(last_bg, sharedPrefs, bgGraphBuilder, context, battery); for (BgReading bg : graph_bgs) { dataMaps.add(dataMap(bg, sharedPrefs, bgGraphBuilder, context, battery)); } entries.putDataMapArrayList("entries", dataMaps); if (sharedPrefs.getBoolean("extra_status_line", false)) { //messageIntent.putExtra("extra_status_line", extraStatusLine(sharedPrefs)); entries.putString("extra_status_line", extraStatusLine(sharedPrefs)); } Log.d("BgSendQueue", "resendData entries=" + entries); messageIntent.putExtra("data", entries.toBundle()); DataMap stepsDataMap = getSensorSteps(sharedPrefs); if (stepsDataMap != null) { messageIntent.putExtra("steps", stepsDataMap.toBundle()); } LocalBroadcastManager.getInstance(context).sendBroadcast(messageIntent); } }
Example 8
Source File: BgReadingTable.java From xDrip with GNU General Public License v3.0 | 5 votes |
private void getData() { final long startTime = new Date().getTime() - (60000 * 60 * 24 * 3);//3 days final List<BgReading> latest = BgReading.latestForGraph(216, startTime); ListAdapter adapter = new BgReadingAdapter(this, latest); this.setListAdapter(adapter); String msg = ""; int size = 0; if (latest != null) size = latest.size(); if (size == 0) { msg = getResources().getString(R.string.notify_table_size, "BgReading", size); JoH.static_toast(xdrip.getAppContext(), msg, Toast.LENGTH_SHORT); } }
Example 9
Source File: LibreTrendGraph.java From xDrip with GNU General Public License v3.0 | 5 votes |
private static ArrayList<Float> getLatestBg(LibreBlock libreBlock) { ReadingData readingData = NFCReaderX.getTrend(libreBlock); if(readingData == null) { Log.e(TAG, "NFCReaderX.getTrend returned null"); return null; } if(readingData.trend.size() == 0 || readingData.trend.get(0).glucoseLevelRaw == 0) { Log.e(TAG, "libreBlock exists but no trend data exists, or first value is zero "); return null; } ArrayList<Float> ret = new ArrayList<Float>(); double factor = libreBlock.calculated_bg / readingData.trend.get(0).glucoseLevelRaw; if(factor == 0) { // We don't have the calculated value, but we do have the raw value. (No calibration exists) // I want to show raw data. Log.w(TAG, "Bg data was not calculated, working on raw data"); List<BgReading> latestReading = BgReading.latestForGraph (1, libreBlock.timestamp - 1000, libreBlock.timestamp + 1000); if(latestReading == null || latestReading.size() == 0) { Log.e(TAG, "libreBlock exists but no matching bg record exists"); return null; } factor = latestReading.get(0).raw_data / readingData.trend.get(0).glucoseLevelRaw; } for (GlucoseData data : readingData.trend) { ret.add(new Float(factor * data.glucoseLevelRaw)); } return ret; }
Example 10
Source File: LibreTrendGraph.java From xDrip with GNU General Public License v3.0 | 5 votes |
private static ArrayList<Float> getLatestBgForXMinutes(int NumberOfMinutes) { Log.i(TAG, "getLatestBgForXMinutes number of minutes = " + NumberOfMinutes); List<LibreTrendPoint> LibreTrendPoints = LibreTrendUtil.getInstance().getData(JoH.tsl() - NumberOfMinutes * 60 * 1000, JoH.tsl()); if(LibreTrendPoints == null || LibreTrendPoints.size() == 0) { Log.e(TAG, "Error getting data from getLatestBgForXMinutes"); return null; } LibreTrendLatest libreTrendLatest = LibreTrendUtil.getInstance().getLibreTrendLatest(); if(libreTrendLatest.glucoseLevelRaw == 0) { Log.e(TAG, "libreBlock exists but libreTrendLatest.glucoseLevelRaw is zero "); return null; } ArrayList<Float> ret = new ArrayList<Float>(); double factor = libreTrendLatest.bg / libreTrendLatest.glucoseLevelRaw; if(factor == 0) { // We don't have the calculated value, but we do have the raw value. (No calibration exists) // I want to show raw data. Log.w(TAG, "Bg data was not calculated, working on raw data"); List<BgReading> latestReading = BgReading.latestForGraph (1, libreTrendLatest.timestamp - 1000, libreTrendLatest.timestamp + 1000); if(latestReading == null || latestReading.size() == 0) { Log.e(TAG, "libreBlock exists but no matching bg record exists"); return null; } factor = latestReading.get(0).raw_data / libreTrendLatest.glucoseLevelRaw; } int count = 0; for(int i = libreTrendLatest.id ; i >= 0 && count < NumberOfMinutes; i--) { count ++; ret.add(new Float(factor * LibreTrendPoints.get(i).rawSensorValue)); } return ret; }
Example 11
Source File: BgSendQueue.java From xDrip-plus with GNU General Public License v3.0 | 5 votes |
public static void resendData(Context context, int battery) {//KS Log.d("BgSendQueue", "resendData enter battery=" + battery); long startTime = new Date().getTime() - (60000 * 60 * 24); Intent messageIntent = new Intent(); messageIntent.setAction(Intent.ACTION_SEND); messageIntent.putExtra("message", "ACTION_G5BG"); BgReading last_bg = BgReading.last(); if (last_bg != null) { Log.d("BgSendQueue", "resendData last_bg.timestamp:" + JoH.dateTimeText(last_bg.timestamp)); } List<BgReading> graph_bgs = BgReading.latestForGraph(60, startTime); BgGraphBuilder bgGraphBuilder = new BgGraphBuilder(context.getApplicationContext()); if (!graph_bgs.isEmpty()) { Log.d("BgSendQueue", "resendData graph_bgs size=" + graph_bgs.size()); final ArrayList<DataMap> dataMaps = new ArrayList<>(graph_bgs.size()); SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext()); DataMap entries = dataMap(last_bg, sharedPrefs, bgGraphBuilder, context, battery); for (BgReading bg : graph_bgs) { dataMaps.add(dataMap(bg, sharedPrefs, bgGraphBuilder, context, battery)); } entries.putDataMapArrayList("entries", dataMaps); if (sharedPrefs.getBoolean("extra_status_line", false)) { //messageIntent.putExtra("extra_status_line", extraStatusLine(sharedPrefs)); entries.putString("extra_status_line", extraStatusLine(sharedPrefs)); } Log.d("BgSendQueue", "resendData entries=" + entries); messageIntent.putExtra("data", entries.toBundle()); DataMap stepsDataMap = getSensorSteps(sharedPrefs); if (stepsDataMap != null) { messageIntent.putExtra("steps", stepsDataMap.toBundle()); } LocalBroadcastManager.getInstance(context).sendBroadcast(messageIntent); } }
Example 12
Source File: BgReadingTable.java From xDrip-plus with GNU General Public License v3.0 | 5 votes |
private void getData() { final long startTime = new Date().getTime() - (60000 * 60 * 24 * 3);//3 days final List<BgReading> latest = BgReading.latestForGraph(216, startTime); ListAdapter adapter = new BgReadingAdapter(this, latest); this.setListAdapter(adapter); String msg = ""; int size = 0; if (latest != null) size = latest.size(); if (size == 0) { msg = getResources().getString(R.string.notify_table_size, "BgReading", size); JoH.static_toast(xdrip.getAppContext(), msg, Toast.LENGTH_SHORT); } }
Example 13
Source File: LibreTrendGraph.java From xDrip-plus with GNU General Public License v3.0 | 5 votes |
private static ArrayList<Float> getLatestBg(LibreBlock libreBlock) { ReadingData readingData = NFCReaderX.getTrend(libreBlock); if(readingData == null) { Log.e(TAG, "NFCReaderX.getTrend returned null"); return null; } if(readingData.trend.size() == 0 || readingData.trend.get(0).glucoseLevelRaw == 0) { Log.e(TAG, "libreBlock exists but no trend data exists, or first value is zero "); return null; } ArrayList<Float> ret = new ArrayList<Float>(); double factor = libreBlock.calculated_bg / readingData.trend.get(0).glucoseLevelRaw; if(factor == 0) { // We don't have the calculated value, but we do have the raw value. (No calibration exists) // I want to show raw data. Log.w(TAG, "Bg data was not calculated, working on raw data"); List<BgReading> latestReading = BgReading.latestForGraph (1, libreBlock.timestamp - 1000, libreBlock.timestamp + 1000); if(latestReading == null || latestReading.size() == 0) { Log.e(TAG, "libreBlock exists but no matching bg record exists"); return null; } factor = latestReading.get(0).raw_data / readingData.trend.get(0).glucoseLevelRaw; } for (GlucoseData data : readingData.trend) { ret.add(new Float(factor * data.glucoseLevelRaw)); } return ret; }
Example 14
Source File: LibreTrendGraph.java From xDrip-plus with GNU General Public License v3.0 | 5 votes |
private static ArrayList<Float> getLatestBgForXMinutes(int NumberOfMinutes) { Log.i(TAG, "getLatestBgForXMinutes number of minutes = " + NumberOfMinutes); List<LibreTrendPoint> LibreTrendPoints = LibreTrendUtil.getInstance().getData(JoH.tsl() - NumberOfMinutes * 60 * 1000, JoH.tsl()); if(LibreTrendPoints == null || LibreTrendPoints.size() == 0) { Log.e(TAG, "Error getting data from getLatestBgForXMinutes"); return null; } LibreTrendLatest libreTrendLatest = LibreTrendUtil.getInstance().getLibreTrendLatest(); if(libreTrendLatest.glucoseLevelRaw == 0) { Log.e(TAG, "libreBlock exists but libreTrendLatest.glucoseLevelRaw is zero "); return null; } ArrayList<Float> ret = new ArrayList<Float>(); double factor = libreTrendLatest.bg / libreTrendLatest.glucoseLevelRaw; if(factor == 0) { // We don't have the calculated value, but we do have the raw value. (No calibration exists) // I want to show raw data. Log.w(TAG, "Bg data was not calculated, working on raw data"); List<BgReading> latestReading = BgReading.latestForGraph (1, libreTrendLatest.timestamp - 1000, libreTrendLatest.timestamp + 1000); if(latestReading == null || latestReading.size() == 0) { Log.e(TAG, "libreBlock exists but no matching bg record exists"); return null; } factor = latestReading.get(0).raw_data / libreTrendLatest.glucoseLevelRaw; } int count = 0; for(int i = libreTrendLatest.id ; i >= 0 && count < NumberOfMinutes; i--) { count ++; ret.add(new Float(factor * LibreTrendPoints.get(i).rawSensorValue)); } return ret; }
Example 15
Source File: BgGraphBuilder.java From xDrip with GNU General Public License v3.0 | 4 votes |
public BgGraphBuilder(Context context, long start, long end, int numValues, boolean show_prediction, final boolean useArchive) { // swap argument order if needed if (start > end) { long temp = end; end = start; start = temp; if (d) Log.d(TAG, "Swapping timestamps"); } if (d) Log.d(TAG, "Called timestamps: " + JoH.dateTimeText(start) + " -> " + JoH.dateTimeText(end)); this.prefs = PreferenceManager.getDefaultSharedPreferences(context); prediction_enabled = show_prediction; if (prediction_enabled) simulation_enabled = prefs.getBoolean("simulations_enabled", true); end_time = end / FUZZER; start_time = start / FUZZER; readings_lock.lock(); try { // store the initialization values used for this instance loaded_numValues=numValues; loaded_start=start; loaded_end=end; bgReadings = BgReading.latestForGraph(numValues, start, end); if (DexCollectionType.getDexCollectionType() == DexCollectionType.LibreReceiver) Libre2RawValues = Libre2RawValue.latestForGraph(numValues * 5, start, end); plugin_adjusted = false; } finally { readings_lock.unlock(); } if ((end - start) > 80000000) { try { capturePercentage = ((bgReadings.size() * 100) / ((end - start) / 300000)); //Log.d(TAG, "CPTIMEPERIOD: " + Long.toString(end - start) + " percentage: " + JoH.qs(capturePercentage)); } catch (Exception e) { capturePercentage = -1; // invalid reading } } bloodtests = BloodTest.latestForGraph(numValues, start, end); // get extra calibrations so we can use them for historical readings calibrations = Calibration.latestForGraph(numValues, start - (3 * Constants.DAY_IN_MS), end); treatments = Treatments.latestForGraph(numValues, start, end + (120 * 60 * 1000)); this.context = context; this.highMark = tolerantParseDouble(prefs.getString("highValue", "170")); this.lowMark = tolerantParseDouble(prefs.getString("lowValue", "70")); this.doMgdl = (prefs.getString("units", "mgdl").equals("mgdl")); defaultMinY = unitized(40); defaultMaxY = unitized(250); pointSize = isXLargeTablet(context) ? 5 : 3; axisTextSize = isXLargeTablet(context) ? 20 : Axis.DEFAULT_TEXT_SIZE_SP; previewAxisTextSize = isXLargeTablet(context) ? 12 : 5; hoursPreviewStep = isXLargeTablet(context) ? 2 : 1; }
Example 16
Source File: BgGraphBuilder.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
public BgGraphBuilder(Context context, long start, long end, int numValues, boolean show_prediction, final boolean useArchive) { // swap argument order if needed if (start > end) { long temp = end; end = start; start = temp; if (d) Log.d(TAG, "Swapping timestamps"); } if (d) Log.d(TAG, "Called timestamps: " + JoH.dateTimeText(start) + " -> " + JoH.dateTimeText(end)); this.prefs = PreferenceManager.getDefaultSharedPreferences(context); prediction_enabled = show_prediction; if (prediction_enabled) simulation_enabled = prefs.getBoolean("simulations_enabled", true); end_time = end / FUZZER; start_time = start / FUZZER; readings_lock.lock(); try { // store the initialization values used for this instance loaded_numValues=numValues; loaded_start=start; loaded_end=end; bgReadings = BgReading.latestForGraph(numValues, start, end); if (DexCollectionType.getDexCollectionType() == DexCollectionType.LibreReceiver) Libre2RawValues = Libre2RawValue.latestForGraph(numValues * 5, start, end); plugin_adjusted = false; } finally { readings_lock.unlock(); } if ((end - start) > 80000000) { try { capturePercentage = ((bgReadings.size() * 100) / ((end - start) / 300000)); //Log.d(TAG, "CPTIMEPERIOD: " + Long.toString(end - start) + " percentage: " + JoH.qs(capturePercentage)); } catch (Exception e) { capturePercentage = -1; // invalid reading } } bloodtests = BloodTest.latestForGraph(numValues, start, end); // get extra calibrations so we can use them for historical readings calibrations = Calibration.latestForGraph(numValues, start - (3 * Constants.DAY_IN_MS), end); treatments = Treatments.latestForGraph(numValues, start, end + (120 * 60 * 1000)); this.context = context; this.highMark = tolerantParseDouble(prefs.getString("highValue", "170")); this.lowMark = tolerantParseDouble(prefs.getString("lowValue", "70")); this.doMgdl = (prefs.getString("units", "mgdl").equals("mgdl")); defaultMinY = unitized(40); defaultMaxY = unitized(250); pointSize = isXLargeTablet(context) ? 5 : 3; axisTextSize = isXLargeTablet(context) ? 20 : Axis.DEFAULT_TEXT_SIZE_SP; previewAxisTextSize = isXLargeTablet(context) ? 12 : 5; hoursPreviewStep = isXLargeTablet(context) ? 2 : 1; }