Exemple #1
0
 /// <summary>
 /// Метод выводящий осциллограмму в зависимости от выбранного номера измерения
 /// </summary>
 /// <param name="Plot1">Объект для обновления</param>
 public void IsComboBoxChanged(object Plot1)
 {
     OxyPlot.Wpf.Plot Plotva = Plot1 as OxyPlot.Wpf.Plot;
     if (IsComboBoxForNumberOfMeasureEnabled == true)
     {
         //Если выбран 0, то построить все измерения на одном графике
         if (Convert.ToInt32(SelectedNumberOfMeasureInComboBox) == 0)
         {
             PlotModel.Series.Clear();
             for (int i = 0; i < CounterForCombo; i++)
             {
                 LoadData(i);
                 TextBlockOfVoltage = UForCombo.ToString() + " B";
                 Plotva.RefreshPlot(true);
             }
         }
         else
         {
             //построить в соответствии с выбранным номером
             PlotModel.Series.Clear();
             LoadData(Convert.ToInt32(SelectedNumberOfMeasureInComboBox) - 1);
             TextBlockOfVoltage = UForCombo.ToString() + " B";
             Plotva.RefreshPlot(true);
         }
     }
 }
Exemple #2
0
        public void Init(OxyPlot.Wpf.Plot plot, OxyPlot.Wpf.TimeSpanAxis x, OxyPlot.Wpf.LinearAxis y, OxyPlot.Wpf.LineSeries series)
        {
            Plot       = plot;
            X          = x;
            Y          = y;
            LineSeries = series;

            Samples = new ObservableCollection <TestData>
            {
                new TestData {
                    Time = new TimeSpan(0, 0, 0), Value = 0, Tag = "A"
                },
                new TestData {
                    Time = new TimeSpan(0, 0, 1), Value = 2, Tag = "B"
                },
                new TestData {
                    Time = new TimeSpan(0, 0, 2), Value = 4, Tag = "C"
                },
                new TestData {
                    Time = new TimeSpan(0, 0, 3), Value = 6, Tag = "D"
                },
                new TestData {
                    Time = new TimeSpan(0, 0, 4), Value = 0, Tag = "E"
                },
                new TestData {
                    Time = new TimeSpan(0, 0, 5), Value = 2, Tag = "F"
                },
            };

            Plot.Title = "WPF Plot";
        }
 /// <summary>
 /// Конструктор класса. Все графические пострения проходят через методы экземпляра этого класса
 /// ВНИМАНИЕ. ВЫЗЫВАЕТСЯ ТОЛЬКО ИЗ ОКНА ДЛЯ ПОСТРОЕНИЯ ЛИНИЙ ТОКА ПРИ ОБТЕКАНИИ ПРЯМОУГОЛЬНИКА
 /// </summary>
 internal PlotWindowModel(OxyPlot.Wpf.Plot plot, System.Windows.Window callerWindow)
 {
     if (callerWindow is HeatMapWindow)
     {
         PlotModel = plot.ActualModel;
     }
     else
     {
         throw new InvalidOperationException("ВЫЗЫВАЕТСЯ ТОЛЬКО ИЗ ОКНА ДЛЯ ПОСТРОЕНИЯ ЛИНИЙ ТОКА ПРИ ОБТЕКАНИИ ПРЯМОУГОЛЬНИКА");
     }
 }
Exemple #4
0
 public void InitializeControls()
 {
     CompositionTarget.Rendering += CompositionTarget_Rendering;
     ChartPlotter       = Recorder.plotter;
     ChartPlotModel     = new PlotModel();
     ChartPlotter.Model = ChartPlotModel;
     ChartPlotModel.Axes.Add(BottomAxis);
     ChartPlotModel.Axes.Add(LeftAngularAxis);
     ChartPlotModel.Axes.Add(LeftSignalAxis);
     Recorder.ZoomDirection.SelectionChanged += new SelectionChangedEventHandler(ZoomDirection_SelectionChanged);
     Recorder.ZoomDirection.SelectedIndex     = 0;
     Recorder.SaveImageButton.Click          += new RoutedEventHandler(SaveImage_Click);
 }
Exemple #5
0
 public void Close()
 {
     IsClosing = true;
     if (PointSchedulerTask != null)
     {
         Primitives.Interrupt(PointSchedulerTask);
         PointSchedulerTask = null;
     }
     ResetCache();
     ResetSeries();
     ChartPlotModel  = null;
     ChartPlotter    = null;
     BottomAxis      = null;
     LeftAngularAxis = null;
     LeftSignalAxis  = null;
     ChartCache      = null;
 }
Exemple #6
0
 public RecorderChart(RecorderControl recorder)
 {
     Recorder         = recorder;
     ChartPlotter     = null;
     IsClosing        = false;
     IsYZoom          = false;
     NumPointsPerPlot = POINTS_PER_PLOT;
     CurrentRelativeChartCacheIndex = 0;
     CurrentChartImageFileName      = null;
     ChartCache                  = new DataCache(recorder.ShellId, false, true, true, 0);
     BottomAxis                  = new RecorderTimeLineAxis(this);
     LeftAngularAxis             = new RecorderLeftAngularAxis(this);
     LeftSignalAxis              = new RecorderLeftSignalAxis(this);
     AxisPointTaskQueue          = new LinkedBlockingCollection <RecorderAxisPoint>();
     PointSchedulerTask          = new Thread(new ThreadStart(AxisPointScheduler));
     PointSchedulerTask.Name     = "AxisPointSchedulerThread:" + recorder.ShellId;
     PointSchedulerTask.Priority = ThreadPriority.Normal;
     PointSchedulerTask.Start();
 }
        public override void PlotValues(OxyPlot.Wpf.Plot chart)
        {
            chart.Title = "Vácuo (bar) x Tempo(min)";
            List <double> xValues, yValues;

            GenerateValues(out xValues, out yValues);
            List <DataPoint> valueList = new List <DataPoint>();

            for (int i = 0; i < xValues.Count; i++)
            {
                valueList.Add(new DataPoint(xValues[i], yValues[i]));
            }
            chart.Series[0].ItemsSource = null;
            chart.Series[0].ItemsSource = valueList;
            Color myRgbColor = new Color();

            myRgbColor            = Color.FromRgb(0, 0, 0);
            chart.Series[0].Color = myRgbColor;
            chart.Series[0].TrackerFormatString = "X : {2:0.00} " + Environment.NewLine + "Y: {4:0.00} ";
        }
        public void InitializeGraphic(List <double> ratings)
        {
            OxyPlot.Wpf.Plot       plot   = new OxyPlot.Wpf.Plot();
            OxyPlot.Wpf.LineSeries series = new OxyPlot.Wpf.LineSeries();

            for (int i = 0; i < ratings.Count; i++)
            {
                series.Items.Add(new DataPoint(i, ratings.ElementAt(i)));
            }

            plot.Series.Add(new OxyPlot.Wpf.LineSeries());
            plot.Series[0].ItemsSource = series.Items;

            plot.Axes.Add(new OxyPlot.Wpf.LinearAxis());
            plot.Axes[0].Position = OxyPlot.Axes.AxisPosition.Bottom;
            plot.Axes[0].Title    = "Номер популяции";

            plot.Axes.Add(new OxyPlot.Wpf.LinearAxis());
            plot.Axes[1].Position = OxyPlot.Axes.AxisPosition.Left;
            plot.Axes[1].Title    = "Целевая функция";

            chartGrid.Children.Add(plot);
        }
Exemple #9
0
        void reportGenerator_ResultsChange(object sender, ReportGenerator.ResultsChangedEventArgs results)
        {
            //Updating Charts
            var plotData = results.CurrentResults;
            if (plotData != null && plotData.Tests.Count > 0)
            {
                //Preparing Grid
                System.Windows.Threading.DispatcherOperation
                    dispatcherOp = ChartsGrid.Dispatcher.BeginInvoke(
                        System.Windows.Threading.DispatcherPriority.Normal,
                        new Action(
                            delegate()
                            {
                                if (plotData.Tests.Count != ChartsGrid.RowDefinitions.Count)
                                {
                                    //Removing charts
                                    ChartsGrid.Children.Clear();
                                    ChartsGrid.RowDefinitions.Clear();
                                    //Adding components
                                    var plot1 = new OxyPlot.Wpf.Plot() { Height = 500 };
                                    plot1.Name = "chart0_0";
                                    plot1.SetValue(Grid.RowProperty, 0);
                                    plot1.SetValue(Grid.ColumnProperty, 0);
                                    plot1.BorderBrush = new SolidColorBrush(Colors.Black);
                                    plot1.VerticalAlignment = System.Windows.VerticalAlignment.Top;
                                    var split = new GridSplitter() { Width = 4 };
                                    var plot2 = new OxyPlot.Wpf.Plot() { Height = 500 };
                                    plot2.Name = "chart0_1";
                                    plot2.SetValue(Grid.RowProperty, 0);
                                    plot2.SetValue(Grid.ColumnProperty, 1);
                                    plot2.BorderBrush = new SolidColorBrush(Colors.Black);
                                    plot2.VerticalAlignment = System.Windows.VerticalAlignment.Top;
                                    ChartsGrid.Children.Add(plot1);
                                    ChartsGrid.Children.Add(split);
                                    ChartsGrid.Children.Add(plot2);
                                    ChartsGrid.Height = 700;
                                    ChartsGrid.RowDefinitions.Add(new RowDefinition() { });
                                    if (plotData.Tests.Count > 1)
                                    {
                                        for (int i = 1; i < plotData.Tests.Count; i++)
                                        {
                                            var plot3 = new OxyPlot.Wpf.Plot() { Height = 500 };
                                            plot3.Name = String.Format("chart{0}_0", i);
                                            plot3.SetValue(Grid.RowProperty, i);
                                            plot3.SetValue(Grid.ColumnProperty, 0);
                                            plot3.BorderBrush = new SolidColorBrush(Colors.Black);
                                            plot3.VerticalAlignment = System.Windows.VerticalAlignment.Top;
                                            var split1 = new GridSplitter() { Width = 4 };
                                            split1.SetValue(Grid.RowProperty, i);
                                            var plot4 = new OxyPlot.Wpf.Plot() { Height = 500 };
                                            plot4.Name = String.Format("chart{0}_1", i);
                                            plot4.SetValue(Grid.RowProperty, i);
                                            plot4.SetValue(Grid.ColumnProperty, 1);
                                            plot4.BorderBrush = new SolidColorBrush(Colors.Black);
                                            plot4.VerticalAlignment = System.Windows.VerticalAlignment.Top;
                                            ChartsGrid.Children.Add(plot3);
                                            ChartsGrid.Children.Add(split1);
                                            ChartsGrid.Children.Add(plot4);
                                            ChartsGrid.RowDefinitions.Add(new RowDefinition() { });
                                        }
                                        ChartsGrid.Height = plotData.Tests.Count * 500 + plotData.Tests.Count * 4;
                                    }
                                    ChartsGrid.UpdateLayout();
                                }
                            }));
                //For all Tests in Tests Data
                for (int testIndex = 0; testIndex < plotData.Tests.Count; testIndex++)
                {
                    var test = plotData.Tests[testIndex];
                    //Creating Model for Time
                    var tmp = new PlotModel("Duration", "using OxyPlot and NPerf");
                    if (isLogarithmic)
                    {
                        tmp.Axes.Add(new LogarithmicAxis(AxisPosition.Right, "Logarithmic"));
                    }
                    tmp.Title = "Duration (" + test.Name + ")";
                    int typeIndex = 0;
                    int testIndexInner = testIndex;

                    var runTotal = test.Runs[0];
                    var series =
                        (from PerfResult trun in runTotal.Results
                         select new LineSeries(trun.TestedType) { MarkerType = MarkerType.Circle }).Cast<Series>().ToList();

                    foreach (var run in test.Runs)
                    {
                        typeIndex = 0;
                        foreach (var trun in run.Results)
                        {
                            if (typeIndex < run.Results.Count)
                            {
                                //Series name: run.Results[index].testedtype
                                // Value -> run.Results[index]
                                (series[typeIndex] as LineSeries).Points.Add(new DataPoint(run.Value,
                                                                                           run.Results[typeIndex].
                                                                                               Duration));
                            }
                            typeIndex++;
                        }
                    }
                    tmp.Series = new System.Collections.ObjectModel.Collection<Series>(series);

                    //Creating model for Memory
                    var tmp1 = new PlotModel("Memory", "using OxyPlot and NPerf");
                    if (isLogarithmic)
                    {
                        tmp1.Axes.Add(new LogarithmicAxis(AxisPosition.Right, "Logarithmic"));
                    }
                    typeIndex = 0;
                    tmp1.Title = "Memory (" + test.Name + ")";
                    var runTotal1 = test.Runs[0];
                    var series1 =
                        (from PerfResult trun in runTotal1.Results
                         select new LineSeries(trun.TestedType) { MarkerType = MarkerType.Circle }).Cast<Series>().ToList();
                    foreach (var run in test.Runs)
                    {
                        typeIndex = 0;
                        foreach (var trun in run.Results)
                        {
                            if (typeIndex < run.Results.Count)
                            {
                                //Series name: run.Results[index].testedtype
                                // Value -> run.Results[index]
                                (series1[typeIndex] as LineSeries).Points.Add(new DataPoint(run.Value,
                                                                                            run.Results[typeIndex].
                                                                                                MemoryUsageMb));
                            }
                            typeIndex++;
                        }
                    }
                    tmp1.Series = new System.Collections.ObjectModel.Collection<Series>(series1);

                    System.Windows.Threading.DispatcherOperation
                        dispatcherOp1 = ChartsGrid.Dispatcher.BeginInvoke(
                            System.Windows.Threading.DispatcherPriority.Normal,
                            new Action(
                                delegate()
                                {
                                    //Setting models
                                    foreach (var el in ChartsGrid.Children)
                                    {
                                        if (el is OxyPlot.Wpf.Plot &&
                                            (el as OxyPlot.Wpf.Plot).Name.Equals(String.Format("chart{0}_0",
                                                                                               testIndexInner)))
                                        {
                                            (el as OxyPlot.Wpf.Plot).Model = tmp;
                                            break;
                                        }
                                    }
                                    foreach (var el in ChartsGrid.Children)
                                    {
                                        if (el is OxyPlot.Wpf.Plot &&
                                            (el as OxyPlot.Wpf.Plot).Name.Equals(String.Format("chart{0}_1",
                                                                                               testIndexInner)))
                                        {
                                            (el as OxyPlot.Wpf.Plot).Model = tmp1;
                                            break;
                                        }
                                    }
                                    ChartsGrid.UpdateLayout();
                                }
                                ));
                }
            }
        }
        /// <summary>
        /// Drawing function for waveforms spectrum.
        /// </summary>
        /// <param name="pointCollection">The collection of points.</param>
        /// <param name="valuesArray">The input array.</param>
        /// <param name="plotToDraw">The plot name.</param>
        void DrawSpectrum(Collection <PointClass> pointCollection, double[] valuesArray, OxyPlot.Wpf.Plot plotToDraw, double[] fftFreq = null)
        {
            plotToDraw.Series[0].ItemsSource = pointCollection;

            for (int i = 0; i < valuesArray.Length / 2; i = i + 1)
            {
                pointCollection.Add(
                    new PointClass
                {
                    xPoint = fftFreq[i],
                    yPoint = valuesArray[i],
                });
            }

            plotToDraw.InvalidatePlot(true);
        }
        /// <summary>
        /// Drawing function for waveforms.
        /// </summary>
        /// <param name="pointCollection">The collection of points.</param>
        /// <param name="valuesArray">The input array.</param>
        /// <param name="plotToDraw">The plot name.</param>
        void DrawImpulse(Collection <PointClass> pointCollection, short[] valuesArray, OxyPlot.Wpf.Plot plotToDraw)
        {
            plotToDraw.Series[0].ItemsSource = pointCollection;

            for (int i = 0; i < valuesArray.Length; i = i + 1)
            {
                pointCollection.Add(
                    new PointClass
                {
                    xPoint = i,
                    yPoint = valuesArray[i],
                });
            }

            plotToDraw.InvalidatePlot(true);
        }
        void reportGenerator_ResultsChange(object sender, ReportGenerator.ResultsChangedEventArgs results)
        {
            //Updating Charts
            var plotData = results.CurrentResults;

            if (plotData != null && plotData.Tests.Count > 0)
            {
                //Preparing Grid
                System.Windows.Threading.DispatcherOperation
                dispatcherOp = ChartsGrid.Dispatcher.BeginInvoke(
                    System.Windows.Threading.DispatcherPriority.Normal,
                    new Action(
                        delegate()
                {
                    if (plotData.Tests.Count != ChartsGrid.RowDefinitions.Count)
                    {
                        //Removing charts
                        ChartsGrid.Children.Clear();
                        ChartsGrid.RowDefinitions.Clear();
                        //Adding components
                        var plot1 = new OxyPlot.Wpf.Plot()
                        {
                            Height = 500
                        };
                        plot1.Name = "chart0_0";
                        plot1.SetValue(Grid.RowProperty, 0);
                        plot1.SetValue(Grid.ColumnProperty, 0);
                        plot1.BorderBrush       = new SolidColorBrush(Colors.Black);
                        plot1.VerticalAlignment = System.Windows.VerticalAlignment.Top;
                        var split = new GridSplitter()
                        {
                            Width = 4
                        };
                        var plot2 = new OxyPlot.Wpf.Plot()
                        {
                            Height = 500
                        };
                        plot2.Name = "chart0_1";
                        plot2.SetValue(Grid.RowProperty, 0);
                        plot2.SetValue(Grid.ColumnProperty, 1);
                        plot2.BorderBrush       = new SolidColorBrush(Colors.Black);
                        plot2.VerticalAlignment = System.Windows.VerticalAlignment.Top;
                        ChartsGrid.Children.Add(plot1);
                        ChartsGrid.Children.Add(split);
                        ChartsGrid.Children.Add(plot2);
                        ChartsGrid.Height = 700;
                        ChartsGrid.RowDefinitions.Add(new RowDefinition()
                        {
                        });
                        if (plotData.Tests.Count > 1)
                        {
                            for (int i = 1; i < plotData.Tests.Count; i++)
                            {
                                var plot3 = new OxyPlot.Wpf.Plot()
                                {
                                    Height = 500
                                };
                                plot3.Name = String.Format("chart{0}_0", i);
                                plot3.SetValue(Grid.RowProperty, i);
                                plot3.SetValue(Grid.ColumnProperty, 0);
                                plot3.BorderBrush       = new SolidColorBrush(Colors.Black);
                                plot3.VerticalAlignment = System.Windows.VerticalAlignment.Top;
                                var split1 = new GridSplitter()
                                {
                                    Width = 4
                                };
                                split1.SetValue(Grid.RowProperty, i);
                                var plot4 = new OxyPlot.Wpf.Plot()
                                {
                                    Height = 500
                                };
                                plot4.Name = String.Format("chart{0}_1", i);
                                plot4.SetValue(Grid.RowProperty, i);
                                plot4.SetValue(Grid.ColumnProperty, 1);
                                plot4.BorderBrush       = new SolidColorBrush(Colors.Black);
                                plot4.VerticalAlignment = System.Windows.VerticalAlignment.Top;
                                ChartsGrid.Children.Add(plot3);
                                ChartsGrid.Children.Add(split1);
                                ChartsGrid.Children.Add(plot4);
                                ChartsGrid.RowDefinitions.Add(new RowDefinition()
                                {
                                });
                            }
                            ChartsGrid.Height = plotData.Tests.Count * 500 + plotData.Tests.Count * 4;
                        }
                        ChartsGrid.UpdateLayout();
                    }
                }));
                //For all Tests in Tests Data
                for (int testIndex = 0; testIndex < plotData.Tests.Count; testIndex++)
                {
                    var test = plotData.Tests[testIndex];
                    //Creating Model for Time
                    var tmp = new PlotModel("Duration", "using OxyPlot and NPerf");
                    if (isLogarithmic)
                    {
                        tmp.Axes.Add(new LogarithmicAxis(AxisPosition.Right, "Logarithmic"));
                    }
                    tmp.Title = "Duration (" + test.Name + ")";
                    int typeIndex      = 0;
                    int testIndexInner = testIndex;

                    var runTotal = test.Runs[0];
                    var series   =
                        (from PerfResult trun in runTotal.Results
                         select new LineSeries(trun.TestedType)
                    {
                        MarkerType = MarkerType.Circle
                    }).Cast <Series>().ToList();

                    foreach (var run in test.Runs)
                    {
                        typeIndex = 0;
                        foreach (var trun in run.Results)
                        {
                            if (typeIndex < run.Results.Count)
                            {
                                //Series name: run.Results[index].testedtype
                                // Value -> run.Results[index]
                                (series[typeIndex] as LineSeries).Points.Add(new DataPoint(run.Value,
                                                                                           run.Results[typeIndex].
                                                                                           Duration));
                            }
                            typeIndex++;
                        }
                    }
                    tmp.Series = new System.Collections.ObjectModel.Collection <Series>(series);

                    //Creating model for Memory
                    var tmp1 = new PlotModel("Memory", "using OxyPlot and NPerf");
                    if (isLogarithmic)
                    {
                        tmp1.Axes.Add(new LogarithmicAxis(AxisPosition.Right, "Logarithmic"));
                    }
                    typeIndex  = 0;
                    tmp1.Title = "Memory (" + test.Name + ")";
                    var runTotal1 = test.Runs[0];
                    var series1   =
                        (from PerfResult trun in runTotal1.Results
                         select new LineSeries(trun.TestedType)
                    {
                        MarkerType = MarkerType.Circle
                    }).Cast <Series>().ToList();
                    foreach (var run in test.Runs)
                    {
                        typeIndex = 0;
                        foreach (var trun in run.Results)
                        {
                            if (typeIndex < run.Results.Count)
                            {
                                //Series name: run.Results[index].testedtype
                                // Value -> run.Results[index]
                                (series1[typeIndex] as LineSeries).Points.Add(new DataPoint(run.Value,
                                                                                            run.Results[typeIndex].
                                                                                            MemoryUsageMb));
                            }
                            typeIndex++;
                        }
                    }
                    tmp1.Series = new System.Collections.ObjectModel.Collection <Series>(series1);

                    System.Windows.Threading.DispatcherOperation
                    dispatcherOp1 = ChartsGrid.Dispatcher.BeginInvoke(
                        System.Windows.Threading.DispatcherPriority.Normal,
                        new Action(
                            delegate()
                    {
                        //Setting models
                        foreach (var el in ChartsGrid.Children)
                        {
                            if (el is OxyPlot.Wpf.Plot &&
                                (el as OxyPlot.Wpf.Plot).Name.Equals(String.Format("chart{0}_0",
                                                                                   testIndexInner)))
                            {
                                (el as OxyPlot.Wpf.Plot).Model = tmp;
                                break;
                            }
                        }
                        foreach (var el in ChartsGrid.Children)
                        {
                            if (el is OxyPlot.Wpf.Plot &&
                                (el as OxyPlot.Wpf.Plot).Name.Equals(String.Format("chart{0}_1",
                                                                                   testIndexInner)))
                            {
                                (el as OxyPlot.Wpf.Plot).Model = tmp1;
                                break;
                            }
                        }
                        ChartsGrid.UpdateLayout();
                    }
                            ));
                }
            }
        }