示例#1
0
        public void CalculateCumulativeHistogramData()
        {
            // Delete existing cumulative histogram data - it will be replaced with new data
            CumulativeHistogramData chd = new CumulativeHistogramData(_CaptureState);
            chd.DeleteCumulativeHistogramData();

            ProcessCapturePackets pcp = new ProcessCapturePackets();
            BindingList<BatchIntervalMarked> batchIntervals = new BindingList<BatchIntervalMarked>();

            // Get the batch intervals
            BindingList<BatchIntervalMarked> unmarkedBatchIntervals = new BindingList<BatchIntervalMarked>();
            BindingList<BatchIntervalMarked> markedBatchIntervals = new BindingList<BatchIntervalMarked>();
            BindingList<CumulativeInterval> cumulativeIntervals = new BindingList<CumulativeInterval>();
            cumulativeIntervals = pcp.GetCumulativeIntervals();

            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);
                }
            }

            switch (_CaptureState)
            {
                case CaptureState.Marked:
                    CalculateCumulativeHistogramProbability(markedBatchIntervals, BatchType.Cumulative, CaptureState.Marked);
                    break;
                case CaptureState.Unmarked:
                    CalculateCumulativeHistogramProbability(unmarkedBatchIntervals, BatchType.Cumulative, CaptureState.Unmarked);
                    break;
            }
        }
示例#2
0
        private void CalculateCumulativeHistogramProbability(BindingList<BatchIntervalMarked> batchIntervalsCollection, BatchType batchType, CaptureState captureState)
        {
            BindingList<BatchIntervalMarked> batchIntervals = new BindingList<BatchIntervalMarked>();
            batchIntervals = batchIntervalsCollection;

            SortedDictionary<int, decimal> histogramProbabilities = new SortedDictionary<int, decimal>();

            int histogramBinSize = AnalysisConfiguration.HistogramBinSize;
            histogramProbabilities = new CalculateProbability(batchIntervals).GetProbabilityByPacketRange(_TrimZeroPacketIntervals, histogramBinSize);

            // Update the cumulative intervals for calculating cumulative probability distributions
            switch(captureState)
            {
                case CaptureState.Marked:
                    _CumulativeMarkedProbabilities = histogramProbabilities;
                    break;

                case CaptureState.Unmarked:
                    _CumulativeUnmarkedProbabilities = histogramProbabilities;
                    break;
            }

            // Convert histogram probabilities to Histogram type collection
            BindingList<CumulativeHistogram> cumulativeHistogramProbabilityData = new BindingList<CumulativeHistogram>();
            foreach (KeyValuePair<int, decimal> data in histogramProbabilities)
            {
                CumulativeHistogram h = new CumulativeHistogram();
                h.Interval = data.Key;
                h.Probability = data.Value;
                h.BatchType = Convert.ToInt32(batchType);
                h.CaptureState = Convert.ToInt32(captureState);
                cumulativeHistogramProbabilityData.Add(h);
            }

            // Save histogram data
            CumulativeHistogramData chd = new CumulativeHistogramData(cumulativeHistogramProbabilityData);
            chd.InsertCumulativeHistogramData();
        }
 public BindingList<CumulativeHistogram> GetCumulativeHistogramData(CaptureState captureState)
 {
     BindingList<CumulativeHistogram> probabilities = new BindingList<CumulativeHistogram>();
     CumulativeHistogramData chd = new CumulativeHistogramData(captureState);
     probabilities = chd.GetCumulativeHistogramData();
     return probabilities;
 }