private void UpdateData() { bool refresh = false; lock (_pointsMx) { _pointsPsiX.AddRange(_pointsPsi); _pointsPsi.Clear(); _pointsCas2X.AddRange(_pointsCas2); _pointsCas2.Clear(); } if (_pointsPsiX.Count > 0) { foreach (var pt in _pointsPsiX) { _dataPsi.Points.Add(new DataPoint(pt.x, pt.y)); } var tail = _pointsPsiX[_pointsPsiX.Count - 1]; if ((panXCheck.Checked) && (tail.x > _axisTime.ActualMaximum)) { var pan = ((tail.x - _axisTime.ActualMaximum) + (_axisTime.ActualMaximum - _axisTime.ActualMinimum) * 0.5f) * _axisTime.Scale * -1.0f; _axisTime.Pan(pan); } _pointsPsiX.Clear(); refresh = true; } if (_pointsCas2X.Count > 0) { foreach (var pt in _pointsCas2X) { _dataCas2.Points.Add(new DataPoint(pt.x, pt.y)); } _pointsCas2X.Clear(); refresh = true; } if (refresh) { _oxyPlot.InvalidatePlot(false); } int curTicks = Environment.TickCount; int delta = curTicks - _sampleTimer; if (delta >= 1000) { _sampleTimer = curTicks; _sampleHz = _sampleCounter; _sampleCounter = 0; _rxmax = 0; } UpdateStatus(); }
public void ReceivePayload(object _payload, string attribute, string label) { double payload = Convert.ToDouble(_payload); lock (plotModel.SyncRoot) { // Add data in plot if (lineSeriesTable[attribute] != null) { LineSeries series = (LineSeries)lineSeriesTable[attribute]; double timeVal = DateTimeAxis.ToDouble(DateTime.Now); series.Points.Add(new DataPoint(timeVal, payload)); double elapsedTime = timeVal - lastTimeVal; if (DateTime.Now > startTime.AddSeconds(60) && lastTimeVal != 0) { double panStep = -elapsedTime * xAxis.Scale; xAxis.Pan(panStep); } oxPlot.Invalidate(); lastTimeVal = timeVal; } else { Debug.Log("The line series object is null"); } } // Add/update data in live view ThreadHelper.UI_TaskInvoke(this, null, UIliveOutputValuesList, (a) => { LiveDataRow row = new LiveDataRow { name = attribute, value = payload.ToString() }; if (!liveDataList.ContainsKey(row.name)) { row.index = UIliveOutputValuesList.Rows.Add(new string[] { row.name, row.value }); liveDataList.Add(attribute, row); } row = (LiveDataRow)liveDataList[attribute]; row.value = payload.ToString(); UIliveOutputValuesList.Rows[row.index].SetValues(new string[] { row.name, row.value }); }, null); }
private void AddNewData(object sender, ElapsedEventArgs args) { _series1.Points.Add(new DataPoint(_currentX, euler_angles[0])); _series2.Points.Add(new DataPoint(_currentX, euler_angles[1])); _series3.Points.Add(new DataPoint(_currentX, euler_angles[2])); xAxis.Pan(xAxis.Transform(-0.05 + xAxis.Offset)); _currentX += 0.05; uiMainPlot.InvalidatePlot(true); //if (_currentX == 20) // _dataTimer.Stop(); }
private void UpdateTimer_Tick(object sender, EventArgs e) { lock (chartLock) { if (motionLevel > motionTriggerThreshold) { if (!playOnce && enableBeepOnTrigger) { playOnce = true; PlayBeep(); } if (!captureImageOnce && cbEnableSaveImg.IsChecked == true) { captureImageOnce = true; CaptureAsImage(); } } // update data into collection DateTime currentTime = DateTime.Now; double elapsedTime = (currentTime - startTime).TotalSeconds; motionLevelData = new MotionLevelData(elapsedTime, motionLevel, motionTriggerThreshold, startTime, currentTime, detectedObjectsCount); GraphDataCollection.Add(motionLevelData); if (GraphDataCollection.Count > 10000) { GraphDataCollection.RemoveAt(0); } // update sensitivity bar UpdateSensivityBarUI(); // update graph OxyGraph.InvalidatePlot(true); // autoscroll graph x-axis if ((elapsedTime + 0.001) >= xAxis.Maximum) { double panStep = (xAxis.ActualMaximum - xAxis.DataMaximum) * xAxis.Scale; xAxis.Pan(panStep); } // write to log file if (!customIntervalEnabled) { LogData(motionLevelData); } } }