Exemplo n.º 1
0
        //private void InitializeAnalysisMetricsGroupBox()
        //{
        //    // Set the font size for the GroupBox (but not for the controls it contains)
        //    Font analysisMetricsFont = new Font("Microsoft Sans Serif", 8);
        //    AnalysisMetricsGroupBox.Font = analysisMetricsFont;
        //}
        private void RefreshSingleDataChart()
        {
            // Get the last marked and unmarked batches and add them to the graph
            BindingList<CurrentCaptureFile> lastBatchIds = new BindingList<CurrentCaptureFile>();
            ProcessCapturePackets pcp = new ProcessCapturePackets();
            lastBatchIds = pcp.GetLastCaptureBatchIds();

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

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

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

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

            foreach (CurrentCaptureFile file in lastBatchIds)
            {
                if (file != null)
                {
                    //BindingList<BatchIntervalMarked> batchIntervals = new BindingList<BatchIntervalMarked>();

                    // Retrieve the probability data from the database
                    BindingList<SingleHistogram> histogramProbabilityList = new BindingList<SingleHistogram>();
                    histogramProbabilityList = pcp.GetSingleHistogramProbabilityData(file.CaptureBatchId);

                    // Convert the histogram probability data
                    SortedDictionary<int, decimal> probabilities = new SortedDictionary<int, decimal>();
                    //SortedDictionary<int, decimal> markedProbabilities = new SortedDictionary<int, decimal>();
                    //SortedDictionary<int, decimal> unmarkedProbabilities = new SortedDictionary<int, decimal>();

                    foreach (SingleHistogram hist in histogramProbabilityList)
                    {
                        probabilities.Add(hist.Interval, hist.Probability);
                    }

                    //// Calculate probabilities
                    //batchIntervals = pcp.GetMarkedBatchIntervals(file.CaptureBatchId);
                    //int histogramBinSize = Convert.ToInt32(HistogramBinSize);
                    ////SortedDictionary<int, decimal> probabilities = new CalculateProbability(batchIntervals).GetProbabilityByPacketRange(_trimZeroPacketIntervals, histogramBinSize);
                    //SortedDictionary<int, decimal> probabilities = new CalculateProbability(batchIntervals).GetProbabilityByPacketRange(_trimZeroPacketIntervals, histogramBinSize);

                    // Update the chart
                    if (file.CaptureState == CaptureState.Marked)
                    {
                        SingleChart.Series["MarkedProbabilities"].Color = Color.CornflowerBlue;

                        foreach (KeyValuePair<int, decimal> pair in probabilities)
                        {
                            SingleChart.Series["MarkedProbabilities"].Points.AddXY(Convert.ToDouble(pair.Key), Convert.ToDouble(pair.Value));
                        }
                    }
                    else
                    {
                        SingleChart.Series["UnmarkedProbabilities"].Color = Color.Red;

                        foreach (KeyValuePair<int, decimal> pair in probabilities)
                        {
                            SingleChart.Series["UnmarkedProbabilities"].Points.AddXY(Convert.ToDouble(pair.Key), Convert.ToDouble(pair.Value));
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        public bool CalculateSingleBatchStatisticsForLastTwoBatches()
        {
            bool result = false;

            // Calculate single batch statistics
            // Get the last marked and unmarked batches and add them to the graph
            BindingList<CurrentCaptureFile> lastBatchIds = new BindingList<CurrentCaptureFile>();
            ProcessCapturePackets pcp = new ProcessCapturePackets();
            lastBatchIds = pcp.GetLastCaptureBatchIds();

            foreach (CurrentCaptureFile file in lastBatchIds)
            {
                BindingList<BatchIntervalMarked> batchIntervals = new BindingList<BatchIntervalMarked>();

                // Calculate probabilities
                batchIntervals = pcp.GetMarkedBatchIntervals(file.CaptureBatchId);
                int histogramBinSize = Convert.ToInt32(_HistogramBinSize);
                SortedDictionary<int, decimal> probabilities = new CalculateProbability(batchIntervals).GetProbabilityByPacketRange(_TrimZeroPacketIntervals, histogramBinSize);
            }

            return result;
        }
Exemplo n.º 3
0
        private void RefreshSingleBatchStatistics()
        {
            // Get the last marked and unmarked batches
            BindingList<CurrentCaptureFile> lastBatchIds = new BindingList<CurrentCaptureFile>();
            ProcessCapturePackets pcp = new ProcessCapturePackets();
            lastBatchIds = pcp.GetLastCaptureBatchIds();

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

            foreach (CurrentCaptureFile file in lastBatchIds)
            {
                if (file.CaptureState == CaptureState.Marked)
                {
                    markedBatchIntervals = pcp.GetMarkedBatchIntervals(file.CaptureBatchId);
                }
                else if(file.CaptureState == CaptureState.Unmarked)
                {
                    unmarkedBatchIntervals = pcp.GetMarkedBatchIntervals(file.CaptureBatchId);
                }
                else
                {
                    MessageBox.Show("Error retrieving batch intervals: capture state is unknown!", "GetMarkedBatchIntervals by CaptureBatchId", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            BatchStatistics markedSingleStats = new BatchStatistics();
            BatchStatistics unmarkedSingleStats = new BatchStatistics();

            // Get this data from DisplayStatistics table; except on refresh...
            //AnalysisEngine ae = new AnalysisEngine();
            //markedSingleStats = ae.GetBatchStatistics(markedBatchIntervals, CaptureState.Marked, BatchType.Single);
            //unmarkedSingleStats = ae.GetBatchStatistics(unmarkedBatchIntervals, CaptureState.Unmarked, BatchType.Single);

            // Load up the table
            // Single unmarked column
            int row = 0;
            _AnalysisDataGridView.Rows[row++].Cells[1].Value = unmarkedSingleStats.IntervalCount;
            _AnalysisDataGridView.Rows[row++].Cells[1].Value = TrimIntervals == true ? unmarkedSingleStats.IntervalCountTrimmed.ToString() : "N/A";
            _AnalysisDataGridView.Rows[row++].Cells[1].Value = string.Format("{0:N2}", unmarkedSingleStats.PacketCountMean);
            _AnalysisDataGridView.Rows[row++].Cells[1].Value = string.Format("{0:N2}", unmarkedSingleStats.PacketCountStandardDeviation);
            _AnalysisDataGridView.Rows[row++].Cells[1].Value = unmarkedSingleStats.PacketCountMinimum;
            _AnalysisDataGridView.Rows[row++].Cells[1].Value = unmarkedSingleStats.PacketCountMaximum;
            _AnalysisDataGridView.Rows[row++].Cells[1].Value = "N/A";
            _AnalysisDataGridView.Rows[row++].Cells[1].Value = "N/A";
            _AnalysisDataGridView.Rows[row++].Cells[1].Value = "N/A";

            // Single marked column
            row = 0;
            _AnalysisDataGridView.Rows[row++].Cells[2].Value = markedSingleStats.IntervalCount;
            _AnalysisDataGridView.Rows[row++].Cells[2].Value = TrimIntervals == true ? markedSingleStats.IntervalCountTrimmed.ToString() : "N/A";
            _AnalysisDataGridView.Rows[row++].Cells[2].Value = string.Format("{0:N2}", markedSingleStats.PacketCountMean);
            _AnalysisDataGridView.Rows[row++].Cells[2].Value = string.Format("{0:N2}", markedSingleStats.PacketCountStandardDeviation);
            _AnalysisDataGridView.Rows[row++].Cells[2].Value = markedSingleStats.PacketCountMinimum;
            _AnalysisDataGridView.Rows[row++].Cells[2].Value = markedSingleStats.PacketCountMaximum;
            _AnalysisDataGridView.Rows[row++].Cells[2].Value = "N/A";
            _AnalysisDataGridView.Rows[row++].Cells[2].Value = "N/A";
            _AnalysisDataGridView.Rows[row++].Cells[2].Value = "N/A";

            // Single variance column
            row = 0;
            _AnalysisDataGridView.Rows[row++].Cells[3].Value = unmarkedSingleStats.IntervalCount - markedSingleStats.IntervalCount;
            _AnalysisDataGridView.Rows[row++].Cells[3].Value = TrimIntervals == true ? (unmarkedSingleStats.IntervalCountTrimmed - markedSingleStats.IntervalCountTrimmed).ToString() : "N/A";
            _AnalysisDataGridView.Rows[row++].Cells[3].Value = string.Format("{0:N2}", (unmarkedSingleStats.PacketCountMean - markedSingleStats.PacketCountMean));
            _AnalysisDataGridView.Rows[row++].Cells[3].Value = string.Format("{0:N2}",(unmarkedSingleStats.PacketCountStandardDeviation - markedSingleStats.PacketCountStandardDeviation));
            _AnalysisDataGridView.Rows[row++].Cells[3].Value = unmarkedSingleStats.PacketCountMinimum - markedSingleStats.PacketCountMinimum;
            _AnalysisDataGridView.Rows[row++].Cells[3].Value = unmarkedSingleStats.PacketCountMaximum - markedSingleStats.PacketCountMaximum;
            _AnalysisDataGridView.Rows[row++].Cells[3].Value = "N/A";
            _AnalysisDataGridView.Rows[row++].Cells[3].Value = "N/A";
            _AnalysisDataGridView.Rows[row++].Cells[3].Value = "N/A";
        }