private void ClientOnDataChanged(object sender, EventArgs e) { var handler = e as DataChangedEventArgs; if (handler != null) { _opcValue = handler.Value; _opcDistanceNow = handler.DistanceNow; _opcDistanceEnd = handler.DistanceEnd; _opcDimension = handler.Dimension; } if (!TitleY) { return; } if (!_isAxisSetted && _opcDimension.Demenision != null) { var yAxis = _plot.Axes.SingleOrDefault(axe => axe.Key.Equals("Y")); if (yAxis != null) { SetYAxis(yAxis as UserLinearAxis); } } }
public override void UpdatePlot() { #region Line if (_opcValue != null) { var currentSeries = _plot.Series.LastOrDefault() as LineSeries; if (currentSeries == null) { currentSeries = new LineSeries(); currentSeries.StrokeThickness = 22; currentSeries.LineStyle = LineStyle.Dot; currentSeries.Color = OxyColors.Black; _plot.Series.Add(currentSeries); _plot.InvalidatePlot(true); } if (_opcValue.Quality >= OpcValueResult.GoodQuality) { if (currentSeries.LineStyle != LineStyle.Solid) { currentSeries = new LineSeries(); currentSeries.LineStyle = LineStyle.Solid; currentSeries.Color = OxyColors.Brown; currentSeries.XAxisKey = "X"; if ((_plot.Series.Last() as LineSeries).Points.Count != 0) { currentSeries.Points.Add((_plot.Series.Last() as LineSeries).Points.Last()); } _plot.Series.Add(currentSeries); _plot.InvalidatePlot(true); } } else if (_opcValue.Quality < OpcValueResult.GoodQuality) { if (currentSeries.LineStyle != LineStyle.Dot) { currentSeries = new LineSeries(); currentSeries.LineStyle = LineStyle.Dot; currentSeries.Color = OxyColors.Brown; currentSeries.XAxisKey = "X"; if ((_plot.Series.Last() as LineSeries).Points.Count != 0) { currentSeries.Points.Add((_plot.Series.Last() as LineSeries).Points.Last()); } _plot.Series.Add(currentSeries); _plot.InvalidatePlot(true); } } #endregion _point = new OpcValueResult(); var points = currentSeries.Points; var lastPoint = points.LastOrDefault(); currentSeries.Points.Add(new DataPoint(_opcDistanceNow.Value, _opcValue.Value)); if (_opcDistanceNow.Value == 0) { points.Clear(); maxxy = 0; } points.Add(new DataPoint(DateTimeAxis.ToDouble(_opcDistanceNow.Value), _opcValue.Value)); _point.Value = _opcValue.Value; _opcValue = null; //Минимальное и максимальное значение по оси x (_plot.Axes[0] as UserLinearAxis).SetMinimum(0); if (_opcDistanceEnd == null) { return; } (_plot.Axes[0] as UserLinearAxis).SetMaximum(Convert.ToDouble(_opcDistanceEnd.Value)); test = _opcDimension.Demenision; if (_point.Value >= maxxy) { maxxy = _point.Value; } (_plot.Axes[1] as UserLinearAxis).SetMinimum(0); (_plot.Axes[1] as UserLinearAxis).SetMaximum(maxxy + 15); } }