Ejemplo n.º 1
0
        private void RefreshCumulativeDataChart()
        {
            // Get the cumulative marked and unmarked batches and add them to the graph

            InitializeCumulativeDataChart();

            //// Format the chart
            ////standardSeries.ChartType = SeriesChartType.RangeColumn;
            ////standardSeries.BorderWidth = 1;
            ////standardSeries.BorderDashStyle = ChartDashStyle.Solid;
            ////standardSeries.BorderColor = Color.Black;
            ////standardSeries.Color = Color.Blue;
            //CumulativeChart.Series.Clear();
            //CumulativeChart.Titles.Clear();
            //CumulativeChart.Titles.Add("Cumulative Capture Packet Probability Distribution");
            ////CumulativeChart.Legends[0].Position.Auto = true; //ElementPosition
            //CumulativeChart.Legends[0].IsDockedInsideChartArea = true;
            //CumulativeChart.Legends[0].Docking = Docking.Bottom;
            //CumulativeChart.Legends[0].Alignment = StringAlignment.Center;
            //CumulativeChart.ChartAreas[0].AxisX.Title = "Packets per Interval";
            //CumulativeChart.ChartAreas[0].AxisX.Minimum = 0;
            ////CumulativeChart.ChartAreas[0].AxisX.Maximum =

            //// Get the type of chart to display
            //string chartType = ChartTypeComboBox.Items[ChartTypeComboBox.SelectedIndex].ToString();

            //// Marked probabilities series
            //CumulativeChart.Series.Add("MarkedProbabilities");
            ////CumulativeChart.Series["MarkedProbabilities"].ChartType = SeriesChartType.Line;
            //CumulativeChart.Series["MarkedProbabilities"].ChartType = chartType == "Bar" ? SeriesChartType.Column : SeriesChartType.Line;
            //CumulativeChart.Series["MarkedProbabilities"].IsVisibleInLegend = true;
            //CumulativeChart.Series["MarkedProbabilities"].LegendText = "Marked";

            //// Unmarked probabilities series
            //CumulativeChart.Series.Add("UnmarkedProbabilities");
            ////CumulativeChart.Series["UnmarkedProbabilities"].ChartType = SeriesChartType.Line;
            //CumulativeChart.Series["UnmarkedProbabilities"].ChartType = chartType == "Bar" ? SeriesChartType.Column : SeriesChartType.Line;
            //CumulativeChart.Series["UnmarkedProbabilities"].IsVisibleInLegend = true;
            //CumulativeChart.Series["UnmarkedProbabilities"].LegendText = "Unmarked";

            //// Get the cumulative interval counts

            // Retrieve the cumulative histogram probabilities from the database
            ProcessCapturePackets pcp = new ProcessCapturePackets();

            //BindingList<CumulativeInterval> cumulativeIntervals = new BindingList<CumulativeInterval>();
            //cumulativeIntervals = pcp.GetCumulativeIntervals();

            //// Get the batch intervals
            //BindingList<BatchIntervalMarked> unmarkedBatchIntervals = new BindingList<BatchIntervalMarked>();
            //BindingList<BatchIntervalMarked> markedBatchIntervals = new BindingList<BatchIntervalMarked>();

            //foreach (CumulativeInterval ci in cumulativeIntervals)
            //{
            //    if (ci.Marked)
            //    {
            //        BatchIntervalMarked bim = new BatchIntervalMarked();
            //        bim.BatchIntervalId = 0;
            //        bim.CaptureBatchId = 0;
            //        bim.IntervalNumber = ci.CumulativeIntervalNumber;
            //        bim.Marked = CaptureState.Marked;
            //        bim.PacketCount = ci.PacketCount;
            //        markedBatchIntervals.Add(bim);
            //    }
            //    else
            //    {
            //        BatchIntervalMarked bim = new BatchIntervalMarked();
            //        bim.BatchIntervalId = 0;
            //        bim.CaptureBatchId = 0;
            //        bim.IntervalNumber = ci.CumulativeIntervalNumber;
            //        bim.Marked = CaptureState.Unmarked;
            //        bim.PacketCount = ci.PacketCount;
            //        unmarkedBatchIntervals.Add(bim);
            //    }
            //}

            //int histogramBinSize = Convert.ToInt32(HistogramBinSize);
            ////SortedDictionary<int, decimal> markedProbabilities = new CalculateProbability(markedBatchIntervals).GetProbabilityByPacketRange(_trimZeroPacketIntervals, histogramBinSize);
            ////SortedDictionary<int, decimal> unmarkedProbabilities = new CalculateProbability(unmarkedBatchIntervals).GetProbabilityByPacketRange(_trimZeroPacketIntervals, histogramBinSize);
            //_CumulativeMarkedProbabilities = new CalculateProbability(markedBatchIntervals).GetProbabilityByPacketRange(_trimZeroPacketIntervals, histogramBinSize);
            //_CumulativeUnmarkedProbabilities = new CalculateProbability(unmarkedBatchIntervals).GetProbabilityByPacketRange(_trimZeroPacketIntervals, histogramBinSize);

            // Get marked probabilities, convert to sorted dictionary, and update the chart
            BindingList<CumulativeHistogram> markedHistogramProbabilityList = new BindingList<CumulativeHistogram>();
            markedHistogramProbabilityList = pcp.GetCumulativeHistogramData(CaptureState.Marked);
            SortedDictionary<int, decimal> markedProbabilities = new SortedDictionary<int, decimal>();
            foreach (CumulativeHistogram hist in markedHistogramProbabilityList)
            {
                markedProbabilities.Add(hist.Interval, hist.Probability);
            }

            CumulativeChart.Series["MarkedProbabilities"].Color = Color.CornflowerBlue;

            foreach (KeyValuePair<int, decimal> pair in markedProbabilities)
            {
                CumulativeChart.Series["MarkedProbabilities"].Points.AddXY(Convert.ToDouble(pair.Key), Convert.ToDouble(pair.Value));
            }

            // Get unmarked probabilities, convert to sorted dictionary, and update the chart
            BindingList<CumulativeHistogram> unmarkedHistogramProbabilityList = new BindingList<CumulativeHistogram>();
            unmarkedHistogramProbabilityList = pcp.GetCumulativeHistogramData(CaptureState.Unmarked);
            SortedDictionary<int, decimal> unmarkedProbabilities = new SortedDictionary<int, decimal>();
            foreach (CumulativeHistogram hist in unmarkedHistogramProbabilityList)
            {
                unmarkedProbabilities.Add(hist.Interval, hist.Probability);
            }

            CumulativeChart.Series["UnmarkedProbabilities"].Color = Color.Red;

            foreach (KeyValuePair<int, decimal> pair in unmarkedProbabilities)
            {
                CumulativeChart.Series["UnmarkedProbabilities"].Points.AddXY(Convert.ToDouble(pair.Key), Convert.ToDouble(pair.Value));
            }
        }