// Add 100 new data to DataSeries's private void OnNewData(object sender, EventArgs e) { _tick++; if (_tick == 2) { _tick = 0; _step = _random.Next(0, 11); } var massVal = new double[100]; for (int i = 0; i < 100; i++) { double y = _step * Math.Sin(((2 * Math.PI) * 0.4) * t) + _random.NextDouble() * 2; _yValues[i] = y; _tValues[i] = t; massVal[i] = y + 10; t += dt; } var sortData = massVal.OrderByDescending(x => x); using (_series0.SuspendUpdates()) using (_series1.SuspendUpdates()) using (_series2.SuspendUpdates()) { _series0.Append(_tValues, _yValues); _series1.PushRow(sortData.ToArray()); _series2.PushRow(sortData.ToArray()); } }
//public void prepareDataReceiver(){ // _ploted = new TripleSeries(50000); // _receivedPackets = new List<List<byte[]>>(40); // for (int i = 0; i < 40; i++){ // _receivedPackets.Add(new List<byte[]>(50000)); // } // _receivingPackets = _receivedPackets[0]; //} public void finishedReadingData() { IsScrollingVisible = true; IsShowingHistory = true; Task.Factory.StartNew( () => { /*do a last refreshing of graph cuz scichart seems to not work properly sometimes*/ try { //give time for Thread.Sleep((int)(RefreshTime * 3)); double[] y_1; double[] y_2; double[] xs; lock (MonitorupdateSeries) { lock (MonitordataReceived) { y_1 = _ploted.Select(y1 => y1.Y1).ToArray(); y_2 = _ploted.Select(y2 => y2.Y2).ToArray(); xs = _ploted.Select(x => x.X).ToArray(); using (_series0.SuspendUpdates()) { using (_series1.SuspendUpdates()) { _series0.Clear(); _series1.Clear(); _series0.Append(xs, y_1); _series1.Append(xs, y_2); } } } } } catch { Debugger.Break(); } Thread.Sleep(250); ResetZoom(); }); }
private void OnLoaded(object sender, RoutedEventArgs routedEventArgs) { XWorldAcc.DataSeries = xWorldAcc; YWorldAcc.DataSeries = yWorldAcc; ZWorldAcc.DataSeries = zWorldAcc; XDeviceAcc.DataSeries = xDeviceAcc; YDeviceAcc.DataSeries = yDeviceAcc; ZDeviceAcc.DataSeries = zDeviceAcc; XWorldVel.DataSeries = xWorldVel; YWorldVel.DataSeries = yWorldVel; ZWorldVel.DataSeries = zWorldVel; XDeviceVel.DataSeries = xDeviceVel; YDeviceVel.DataSeries = yDeviceVel; ZDeviceVel.DataSeries = zDeviceVel; XRealSenseVel.DataSeries = xRealVel; YRealSenseVel.DataSeries = yRealVel; ZRealSenseVel.DataSeries = zRealVel; PositionGraph.DataSeries = positionVec; RealSensePositionGraph.DataSeries = realSensePositionVec; var timer = new DispatcherTimer(DispatcherPriority.Render); timer.Interval = TimeSpan.FromMilliseconds(100); timer.Tick += (s, e) => { // This updates the graph when the program is running! using (xWorldAcc.SuspendUpdates()) using (yWorldAcc.SuspendUpdates()) using (zWorldAcc.SuspendUpdates()) using (xDeviceAcc.SuspendUpdates()) using (yDeviceAcc.SuspendUpdates()) using (zDeviceAcc.SuspendUpdates()) using (xWorldVel.SuspendUpdates()) using (yWorldVel.SuspendUpdates()) using (zWorldVel.SuspendUpdates()) using (xDeviceVel.SuspendUpdates()) using (yDeviceVel.SuspendUpdates()) using (zDeviceVel.SuspendUpdates()) using (xRealVel.SuspendUpdates()) using (yRealVel.SuspendUpdates()) using (zRealVel.SuspendUpdates()) { sciChartSurface.ZoomExtents(); sciChartSurface1.ZoomExtents(); sciChartSurface2.ZoomExtents(); sciChartSurface3.ZoomExtents(); sciRealSenseVel.ZoomExtents(); RotateTransform rotateTransform = new RotateTransform(udpServer.getCompassAngle() + 90); arrow.RenderTransform = rotateTransform; RotateTransform rotateTransform1 = new RotateTransform(udpServer.getCameraPointingAngle()); CamArrow.RenderTransform = rotateTransform1; RotateTransform rotateTransform2 = new RotateTransform(udpServer.getDeviceTiltAngle()); CamSpin.RenderTransform = rotateTransform2; } }; timer.Start(); }
private void DataAppendLoop() { // if timer was released in another thread - skip all further processing if (_timer == null) { return; } // By nesting multiple updates inside a SuspendUpdates using block, you get one redraw at the end using (_mainSeries.SuspendUpdates()) { // Preload previous value with k-1 sample, or 0.0 if the count is zero int xValue = _mainSeries.Count > 0 ? _mainSeries.XValues[_mainSeries.Count - 1] : 0; double yValue = _mainSeries.Count > 0 ? _mainSeries.YValues[_mainSeries.Count - 1] : 10.0f; // Add N points at a time. We want to get to the higher point counts // quickly to demonstrate performance. // Also, it is more efficient to buffer and block update the chart // even if you use SuspendUpdates due to the overhead of calculating min, max // for a series for (int i = 0; i < BufferSize; i++) { // Generate a new X,Y value in the random walk and buffer xValue = xValue + 1; yValue = (double)(yValue + (_random.NextDouble() - 0.5)); _xBuffer[i] = xValue; _yBuffer[i] = yValue; // Update moving averages _maLowBuffer[i] = (double)_maLow.Push(yValue).Current; _maHighBuffer[i] = (double)_maHigh.Push(yValue).Current; } // Append block of values to all three series _mainSeries.Append(_xBuffer, _yBuffer); _maLowSeries.Append(_xBuffer, _maLowBuffer); _maHighSeries.Append(_xBuffer, _maHighBuffer); } // Render the total point count (all series) to the screen int numPoints = 3 * _mainSeries.Count; if (numPoints > 10000 && _reached < 10000) { _reached = 10000; } if (numPoints > 100000 && _reached < 100000) { _reached = 100000; } if (numPoints > 300000 && _reached < 300000) { _reached = 300000; } if (numPoints > 500000 && _reached < 500000) { _reached = 500000; } if (numPoints > 1000000 && _reached < 1000000) { _reached = 1000000; } if (numPoints > 3000000 && _reached < 3000000) { Messages.Add("Reached 3,000,000 Points!"); _reached = 3000000; } if (numPoints > 5000000 && _reached < 5000000) { Messages.Add("Reached 5,000,000 Points!"); _reached = 5000000; } if (numPoints > MaxCount) { Messages.Add("Reached 10M points!"); Messages.Add(".. and I'm still going!"); _timer.Stop(); _timer = null; BoundRange = AutoRange.Never; this.ShowInstructionsToUser(); } }