Пример #1
0
 /// <summary>
 /// The Copy Constructor
 /// </summary>
 /// <param name="rhs">The FilteredPointList from which to copy</param>
 public FilteredPointList(FilteredPointList rhs)
 {
     _data = new CompactPt[rhs.Count];
     Array.Copy(rhs._data, _data, rhs.Count);
     _minBoundIndex = rhs._minBoundIndex;
     _maxBoundIndex = rhs._maxBoundIndex;
     MaxPts         = rhs.MaxPts;
 }
Пример #2
0
 /// <summary>
 /// The Copy Constructor
 /// </summary>
 /// <param name="rhs">The FilteredPointList from which to copy</param>
 public FilteredPointList(FilteredPointList rhs)
 {
     _x             = (double[])rhs._x.Clone();
     _y             = (double[])rhs._y.Clone();
     _minBoundIndex = rhs._minBoundIndex;
     _maxBoundIndex = rhs._maxBoundIndex;
     _maxPts        = rhs._maxPts;
 }
        /// <summary>
        /// The Copy Constructor
        /// </summary>
        /// <param name="rhs">The FilteredPointList from which to copy</param>
        public FilteredPointList(FilteredPointList rhs)
        {
            _x = (double[])rhs._x.Clone();
            _y = (double[])rhs._y.Clone();
            //_xMinBound = rhs._xMinBound;
            //_xMaxBound = rhs._xMaxBound;
            _minBoundIndex = rhs._minBoundIndex;
            _maxBoundIndex = rhs._maxBoundIndex;
            _maxPts        = rhs._maxPts;

            _isApplyHighLowLogic = rhs._isApplyHighLowLogic;
        }
		/// <summary>
		/// The Copy Constructor
		/// </summary>
		/// <param name="rhs">The FilteredPointList from which to copy</param>
		public FilteredPointList( FilteredPointList rhs )
		{
			_x = (double[]) rhs._x.Clone();
			_y = (double[]) rhs._y.Clone();
			_minBoundIndex = rhs._minBoundIndex;
			_maxBoundIndex = rhs._maxBoundIndex;
			_maxPts = rhs._maxPts;

		}
Пример #5
0
        private void CreateGraph_FilteredPointList( ZedGraphControl z1 )
        {
            // Get a reference to the GraphPane
            GraphPane myPane = z1.GraphPane;

            // The data will have 10000 points, generated randomly
            const int count = 100000;
            Random rand = new Random();

            // FilteredPointList stores the data as ordinary arrays
            double[] x = new double[count];
            double[] y = new double[count];

            // Loop to calculate all the data values
            for ( int i = 0; i < count; i++ )
            {
                // data are random
                double val = rand.NextDouble();
                double time = Math.Pow( (double) i, 1.5 ) / 1e6;
                x[i] = time + 2.0;
                y[i] = Math.Log( time * 1e6 ) * ( 1 + ( val - 0.5 ) * 0.1 );
            }

            // FilteredPointList requires that the data are monotonically increasing in X
            // FilteredPointList stores its data internally as an ordinary array.  The X, Y arrays
            // below are saved as references (not copies).
            FilteredPointList list = new FilteredPointList( x, y );

            // Create a curve, and show only the symbols with no lines
            LineItem myCurve = z1.GraphPane.AddCurve( "curve", list, Color.Blue, SymbolType.Diamond );
            myCurve.Line.IsVisible = false;

            // The IsApplyHighLowLogic property does not work properly.  This option has been removed as
            // of ZedGraph version 5.1.4.  In the meantime, you should disable it as follows
            //list.IsApplyHighLowLogic = false;

            // Set the range of data of interest.  In effect you can limit the plotted data to only a
            // certain window within the total data range.  In this case, I set the minimum and maximum
            // bounds to include all data points.  Also, all points are initially visible since the
            // maxPts is set to a large value.
            list.SetBounds( 2, 2.5, 5000 );

            // Pretty it up
            //myPane.Title.Text = "FilteredPointList Example\n100,000 Points Total, Filtered to 400 Points Visible";
            myPane.Title.Text = "FilteredPointList Example\n100,000 Points Total, 2.5 seconds of data";
            myPane.Title.FontSpec.Size = 18;
            myPane.XAxis.Title.Text = "Time Span, seconds";
            myPane.YAxis.Title.Text = "Signal Strength";
            myPane.YAxis.Scale.Min = 0;
            myPane.Legend.IsVisible = false;
            myPane.Fill = new Fill( Color.WhiteSmoke, Color.Lavender, 0F );
            myPane.Chart.Fill = new Fill( Color.FromArgb( 255, 255, 245 ),
               Color.FromArgb( 255, 255, 190 ), 90F );
            z1.IsAntiAlias = true;

            z1.AxisChange();
        }
        /// <summary>
        /// The Copy Constructor
        /// </summary>
        /// <param name="rhs">The FilteredPointList from which to copy</param>
        public FilteredPointList( FilteredPointList rhs )
        {
            _x = (double[]) rhs._x.Clone();
            _y = (double[]) rhs._y.Clone();
            //_xMinBound = rhs._xMinBound;
            //_xMaxBound = rhs._xMaxBound;
            _minBoundIndex = rhs._minBoundIndex;
            _maxBoundIndex = rhs._maxBoundIndex;
            _maxPts = rhs._maxPts;

            _isApplyHighLowLogic = rhs._isApplyHighLowLogic;
        }
Пример #7
0
 private void LoadBinaryFiles()
 {
     foreach(int stream in streamID)
     {
     foreach(string parName in channelsSelected[stream])
     {
         double[] y = LoadTempData(stream, parName);
         long size = y.LongLength;
         double[] x = new double[size];
         for (int e = 0; e != size;e++ )
         {
             x[e] = e;
         }
         dataToPlot[stream][parName] = new FilteredPointList(x, y);
         x = null;
         y = null;
     }
     }
 }
Пример #8
0
        private void iteratePcaps_Para()
        {
            Dictionary<int, bool> firstTime = new Dictionary<int, bool>(streamData.Count);
            Dictionary<int, Dictionary<string, bool>> storedData = new Dictionary<int, Dictionary<string, bool>>(streamData.Count);
            foreach (int e in streamData.Keys)
            {
            firstTime[e] = true;
            storedData[e] = new Dictionary<string, bool>();
            foreach (string parName in streamData[e].Keys)
            {
                storedData[e][parName] = false;
            }
            }
            System.Diagnostics.Stopwatch save = new System.Diagnostics.Stopwatch();
            int fileCnt = Globals.filePCAP_list.Length;
            double[] dataTMP = null;
            foreach (string p in Globals.filePCAP_list)
            {
            //GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
            //Dictionary<string, double[]> dataPcap_tmp = new Dictionary<string, double[]>();
            LogItems.addStreamInfo(String.Format("Starting to parse {0}", p));
            if (Globals.useDownsample) LoadDataDownSampled(p);
            else LoadData(p);
            System.Threading.Tasks.Parallel.ForEach(streamData, streamPair =>
            {
                int stream = streamPair.Key;
                Dictionary<string, double[]> dataPcap_tmp = new Dictionary<string, double[]>();
                if (channelsSelected[stream].Count != 0)
                {
                    foreach (string parName in streamData[stream].Keys)
                    {
                        dataPcap_tmp[parName] = streamData[stream][parName].ToArray();
                        streamData[stream][parName].Clear();
                        //int len=0;
                        int previousLen = 0;
                        if (firstTime[stream]) previousLen = dataPcap_tmp[parName].Length;
                        else
                        {
                            if (fileCnt == 1)
                            {
                                dataTMP = LoadTempData(stream, parName);
                                if (storedData[stream][parName] == false) previousLen = dataToPlot[stream][parName].Count;
                                previousLen = previousLen + dataTMP.Length + dataPcap_tmp[parName].Length;
                            }
                            else if (storedData[stream][parName] == false)
                            {
                                previousLen = dataToPlot[stream][parName].Count;
                                previousLen = previousLen + dataPcap_tmp[parName].Length;
                            }
                            else previousLen = dataPcap_tmp[parName].Length;
                        }

                        uint cnt = 0;
                        double[] x = new double[previousLen];
                        double[] y = new double[previousLen];

                        /// Below Logic looks like crap
                        /// Possible errors (loosing last million in dat file) and ineficient code
                        /// TOFIX
                        if (firstTime[stream] == false)
                        {
                            if (fileCnt == 1)
                            {
                                int dataSize = dataTMP.Length;
                                //Buffer.BlockCopy(dataTMP, 0, y, dataSize, dataTMP.Length * sizeof(double));
                                //Array.Copy(dataTMP, 0, y, 0, dataTMP.Length);
                                //System.Collections.IEnumerator xEnum = dataTMP.GetEnumerator();
                                //x = Enumerable.Range(0,dataSize).Select(item => (double)item).ToArray<double>();
                                //cnt = (uint)dataSize-1;
                                for (int i = 0; i != dataSize; i++)
                                {
                                    x[cnt] = cnt;
                                    y[cnt] = dataTMP[i];
                                    cnt++;
                                }
                            }
                            if (storedData[stream][parName] == false)
                            {
                                int dataSize = dataToPlot[stream][parName].Count;
                                for (int i = 0; i != dataSize; i++)
                                {
                                    x[cnt] = cnt;
                                    y[cnt] = dataToPlot[stream][parName][i].Y;
                                    cnt++;
                                }
                            }
                            //previousLen = x.Length;
                            foreach (double dataItem in dataPcap_tmp[parName])
                            {
                                x[cnt] = cnt;
                                y[cnt] = dataItem;
                                cnt++;
                            }
                        }
                        else
                        {
                            foreach (double dataItem in dataPcap_tmp[parName])
                            {
                                x[cnt] = cnt;
                                y[cnt] = dataItem;
                                cnt++;
                            }
                        }
                        dataToPlot[stream][parName] = null;

                        if (fileCnt == 1)
                        {
                            dataToPlot[stream][parName] = new FilteredPointList(x, y);
                            dataTMP = null;
                        }
                        else if (cnt > 200000) //store into file if 200000 million points
                        {
                            //save.Start();
                            SaveTempData(stream, parName, y);
                            //save.Stop();
                            //MessageBox.Show(save.Elapsed.ToString());
                            //save.Restart();
                            storedData[stream][parName] = true;
                            //double[] data = LoadTempData(stream, parName);
                            //save.Stop();
                            //MessageBox.Show(save.Elapsed.ToString());
                        }
                        else
                        {
                            dataToPlot[stream][parName] = new FilteredPointList(x, y);
                            storedData[stream][parName] = false;
                        }
                        y = null;
                        //streamData[stream][parName].Clear();
                    }
                    //dataToPlot[parName] = dataTMP;
                    firstTime[stream] = false;
                    //streamData[stream].Clear();
                }
            });
            fileCnt--;
            }
        }
Пример #9
0
        private void iteratePcaps()
        {
            Dictionary<int, bool> firstTime = new Dictionary<int, bool>(streamData.Count);
            foreach (int e in streamData.Keys) firstTime[e] = true;
            foreach (string p in Globals.filePCAP_list)
            {
            //GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
            //Dictionary<string, double[]> dataPcap_tmp = new Dictionary<string, double[]>();
            LogItems.addStreamInfo(String.Format("Starting to parse {0}", p));

            LoadData(p);
            foreach (int stream in streamData.Keys)
            {
                Dictionary<string, double[]> dataPcap_tmp = new Dictionary<string, double[]>();
                if (channelsSelected[stream].Count==0) continue;
                foreach (string parName in streamData[stream].Keys)
                {
                    dataPcap_tmp[parName] = streamData[stream][parName].ToArray();
                    streamData[stream][parName].Clear();
                    //int len=0;
                    int previousLen = 0;
                    if (firstTime[stream]) previousLen = dataPcap_tmp[parName].Length;
                    else
                    {
                        previousLen = dataToPlot[stream][parName].Count;
                        previousLen = previousLen + dataPcap_tmp[parName].Length;
                    }
                    //RollingPointPairList dataTMP = new RollingPointPairList(len);
                    uint cnt = 0;
                    //double[] x = new double[dataPcap_tmp[parName].Length];
                    //double[] y = new double[dataPcap_tmp[parName].Length];
                    double[] x = new double[previousLen];
                    double[] y = new double[previousLen];

                    if (firstTime[stream] == false)
                    {
                        //dataTMP.Add(dataToPlot[parName]);
                        int dataSize = dataToPlot[stream][parName].Count;
                        for (int i = 0; i != dataSize; i++)
                        {
                            x[cnt] = cnt;
                            y[cnt] = dataToPlot[stream][parName][i].Y;
                            cnt++;
                        }
                        //previousLen = x.Length;
                        foreach (double dataItem in dataPcap_tmp[parName])
                        {
                            x[cnt] = cnt;
                            y[cnt] = dataItem;
                            cnt++;
                        }
                    }
                    else
                    {
                        foreach (double dataItem in dataPcap_tmp[parName])
                        {
                            x[cnt] = cnt;
                            y[cnt] = dataItem;
                            cnt++;
                        }
                    }
                    //if (firstTime == false)
                    //{
                    //    dataTMP.Add(dataToPlot[parName]);
                    //}
                    //dataTMP.Add(x, y);
                    dataToPlot[stream][parName] = null;
                    dataToPlot[stream][parName] = new FilteredPointList(x, y);
                    streamData[stream][parName].Clear();
                }
                    //dataToPlot[parName] = dataTMP;
                firstTime[stream] = false;
                //streamData[stream].Clear();
            }

            }
        }