protected void load_DoWork(object sender, DoWorkEventArgs e) { int currentProgress = 0; while ((recordedDataLoadProgress < 100) && (!_mustStopNow)) { try { recordedDataLoadProgress = recordedData.loadMore(); } catch (Exception ex) { LogManager.Log(_hwdName + ": load more caused an exception " + ex.ToString()); } if (currentProgress != (int)(recordedDataLoadProgress)) { currentProgress = (int)(recordedDataLoadProgress); LogManager.Log(_hwdName + ": " + currentProgress.ToString() + "% loaded"); ((BackgroundWorker)sender).ReportProgress(currentProgress); } } List <YMeasure> measures = recordedData.get_measures(); loadedData = new List <pointXY>(); for (int i = 0; i < measures.Count; i++) { double t = measures[i].get_endTimeUTC(); loadedData.Add(new pointXY { x = t, y = measures[i].get_averageValue() }); } }
private List <YMeasure> LoadQT(string hwid) { YQt qt = YQt.FindQt(hwid); YDataSet dataset = qt.get_recordedData(0, 0); int progress = 0; do { progress = dataset.loadMore(); } while(progress < 100); Console.WriteLine("Using DataLogger of " + qt.get_friendlyName()); YMeasure summary = dataset.get_summary(); List <YMeasure> res_bad = dataset.get_measures(); List <YMeasure> res = new List <YMeasure>(); foreach (YMeasure m in res_bad) { if (m.get_startTimeUTC() > 100) { res.Add(m); } } String line = String.Format("from {0} to {1} : min={2:0.00} avg={3:0.00} max={4:0.00}", summary.get_startTimeUTC_asDateTime().ToString(fmt), summary.get_endTimeUTC_asDateTime().ToString(fmt), summary.get_minValue(), summary.get_averageValue(), summary.get_maxValue() ); Console.WriteLine(line); return(res); }
protected void preload_DoWork(object sender, DoWorkEventArgs e) { if (_mustStopNow) { return; } recordedData = _sensor.get_recordedData(0, 0); try { recordedDataLoadProgress = recordedData.loadMore(); } catch (Exception ex) { LogManager.Log(_hwdName + ": preload more caused an exception " + ex.ToString()); } globalDataLoadProgress = recordedDataLoadProgress; ((BackgroundWorker)sender).ReportProgress(recordedDataLoadProgress); List <YMeasure> measures = recordedData.get_preview(); previewCurData = new List <pointXY>(); int startIndex = 0; for (int i = startIndex; i < measures.Count; i++) { double t = measures[i].get_endTimeUTC(); previewCurData.Add(new pointXY() { x = t, y = measures[i].get_averageValue() }); } }
public int loadMore() { if (_dataset == null) { throw new Exception("YDataloggerContext data has already been freed"); } _progress = _dataset.loadMore(); if (_progress >= 100) { _data = _dataset.get_measures(); } return(_progress); }
static void dumpSensor(YSensor sensor) { string fmt = "dd MMM yyyy hh:mm:ss,fff"; Console.WriteLine("Using DataLogger of " + sensor.get_friendlyName()); YDataSet dataset = sensor.get_recordedData(0, 0); Console.WriteLine("loading summary... "); dataset.loadMore(); YMeasure summary = dataset.get_summary(); String line = String.Format("from {0} to {1} : min={2:0.00}{5} avg={3:0.00}{5} max={4:0.00}{5}", summary.get_startTimeUTC_asDateTime().ToString(fmt), summary.get_endTimeUTC_asDateTime().ToString(fmt), summary.get_minValue(), summary.get_averageValue(), summary.get_maxValue(), sensor.get_unit()); Console.WriteLine(line); Console.Write("loading details : 0%"); int progress = 0; do { progress = dataset.loadMore(); Console.Write(String.Format("\b\b\b\b{0,3:##0}%", progress)); } while(progress < 100); Console.WriteLine(""); List <YMeasure> details = dataset.get_measures(); foreach (YMeasure m in details) { Console.WriteLine( String.Format("from {0} to {1} : min={2:0.00}{5} avg={3:0.00}{5} max={4:0.00}{5}", m.get_startTimeUTC_asDateTime().ToString(fmt), m.get_endTimeUTC_asDateTime().ToString(fmt), m.get_minValue(), m.get_averageValue(), m.get_maxValue(), sensor.get_unit())); } }
internal YDataloggerContext(YSensor s, int start, int stop) { if (start < 0) { start = 0; } if (stop < 0) { stop = 0; } _sensor = s; _dataset = _sensor.get_recordedData(start, stop); _progress = _dataset.loadMore(); _preview = _dataset.get_preview(); }
// the core function : load data from datalogger to send it to the graph private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { // lets hide the graph wgile updating chart1.Visible = false; comboBox1.Enabled = false; // remove any previous timed report call back for (int i = 0; i < comboBox1.Items.Count; i++) { ((YSensor)comboBox1.Items[i]).registerTimedReportCallback(null); } // allow zooming chart1.ChartAreas[0].CursorX.Interval = 0.001; chart1.ChartAreas[0].CursorX.IsUserEnabled = true; chart1.ChartAreas[0].CursorX.IsUserSelectionEnabled = true; chart1.ChartAreas[0].CursorX.AutoScroll = true; chart1.ChartAreas[0].AxisX.ScaleView.Zoomable = true; chart1.ChartAreas[0].AxisX.ScrollBar.IsPositionedInside = true; int index = comboBox1.SelectedIndex; if (index >= 0) { clearGraph(); } YSensor s = getSelectedSensor(); if (s != null) { FirstPointDate = -1; LastPointDate = -1; // some ui control loading.Visible = true; refreshDatloggerButton(null); progressBar.Visible = true; Status.Text = "Loading data from datalogger..."; for (int i = 0; i < 100; i++) { Application.DoEvents(); // makes sure the UI changes are repainted } // load data from datalogger YDataSet data = s.get_recordedData(0, 0); int progress = data.loadMore(); while (progress < 100) { try { progressBar.Value = progress; } catch { return; } Application.DoEvents(); progress = data.loadMore(); } // sets the unit (because ° is not a ASCII-128 character, Yoctopuce temperature // sensors report unit as 'C , so we fix it). chart1.ChartAreas[0].AxisY.Title = s.get_unit().Replace("'C", "°C"); chart1.ChartAreas[0].AxisY.TitleFont = new Font("Arial", 12, FontStyle.Regular); // send the data to the graph List <YMeasure> alldata = data.get_measures(); for (int i = 0; i < alldata.Count; i++) { chart1.Series[0].Points.AddXY(UnixTimeStampToDateTime(alldata[i].get_endTimeUTC()), alldata[i].get_averageValue()); } // used to compute graph length if (alldata.Count > 0) { FirstPointDate = alldata[0].get_endTimeUTC(); LastPointDate = alldata[alldata.Count - 1].get_endTimeUTC(); } setGraphScale(); // restore UI comboBox1.Enabled = true; progressBar.Visible = false; setSensorCount(); s.set_reportFrequency("3/s"); s.registerTimedReportCallback(newSensorValue); loading.Visible = false; chart1.Visible = true; refreshDatloggerButton(s); } }
internal YDataSetProxy(YDataSet objref) { _objref = objref; _objref.loadMore(); }
/** * <summary> * Loads the the next block of measures from the dataLogger, and updates * the progress indicator. * <para> * </para> * <para> * </para> * </summary> * <returns> * an integer in the range 0 to 100 (percentage of completion), * or a negative error code in case of failure. * </returns> * <para> * On failure, throws an exception or returns a negative error code. * </para> */ public virtual int loadMore() { return(_objref.loadMore()); }