Exemple #1
0
        protected NPoint Add(params double[] doubleList)
        {
            NPoint point = new NPoint(_dimension);

            point.Coordinate = doubleList;

            Add(point);

            return(point);
        }
Exemple #2
0
        // Methods -------------------------------------------------------------
        new public NPoint AddPoint(params double[] doubleList)
        {
            NPoint point = Add(doubleList);

            Calculate();

            CallHandler();

            return(point);
        }
Exemple #3
0
 public void ShallowClone(NPoint point)
 {
     this.space          = point.space;
     this.dimensionNames = point.dimensionNames;
     this.timeStamp      = point.timeStamp;
     this.dimension      = point.dimension;
     this.name           = point.name;
     this.pointID        = point.pointID;
     this.misc           = point.misc;
 }
Exemple #4
0
        public NPoint AddPoint(String name, params double[] doubleList)
        {
            NPoint point = new NPoint(name, _dimension);

            point.Coordinate = doubleList;

            Add(point);
            CallHandler();

            return(point);
        }
        public void ShallowClone(TeachPoint point)
        {
            NPoint npoint = point as NPoint;

            base.ShallowClone(npoint);

            // clone the rest
            this.History = point.History;

            // initialize history
            PointHistory.LoadInit(this);
        }
        // Methods -------------------------------------------------------------
        
        public void ArchiveTeachPoint(TeachPoint point)
        {
            NPoint pt = new NPoint(point);
            history.Add(pt);

            UpdateStatistics(point);

            // remove oldest element(s) added (fifo)
            while (history.Count > queueSize) 
                history.RemoveAt(0);

            LoadHistoryTable();
        }
Exemple #7
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            NPoint o = obj as NPoint;

            if (o != null)
            {
                return(this == o);
            }
            return(false);
        }
Exemple #8
0
        public void Copy(GenericPointStorage src)
        {
            _storageName = src._storageName;
            _dimension   = src._dimension;
            _maxSize     = src._maxSize;
            _name        = src._name;
            _order       = src._order;

            _values = src._values.Clone() as ArrayList;     // shallow copy

            // make it a deep copy
            for (int i = 0; i < _values.Count; i++)
            {
                _values[i] = new NPoint(src._values[i] as NPoint);
            }
        }
Exemple #9
0
        public NPoint(NPoint point)
        {
            this.name           = point.name;
            this.pointID        = point.pointID;
            this.dimension      = point.dimension;
            this.space          = new double[dimension];
            this.dimensionNames = new string[dimension];

            for (int i = 0; i < dimension; i++)
            {
                this.space[i]          = point.space[i];
                this.dimensionNames[i] = point.dimensionNames[i];
            }

            this.timeStamp = new DateTime(timeStamp.Ticks);
            this.misc      = point.misc;
        }
        public void Recalculate()
        {
            ResetStatistics();

            for (int index=0; index<history.Count; index++)
            {
                NPoint pt = ((NPoint)history[index]);
                for (int i=0; i<dimension; i++)
                {
                    if (index == 0) 
                    {
                        sum[i]   = pt.Coordinate[i];
                        sumX2[i] = pt.Coordinate[i] * pt.Coordinate[i];
                        max[i]   = pt.Coordinate[i];
                        min[i]   = pt.Coordinate[i];
                    }
                    else
                    {
                        sum[i]   += pt.Coordinate[i];
                        sumX2[i] += (pt.Coordinate[i] * pt.Coordinate[i]);
                        if (pt.Coordinate[i] > max[i]) max[i] = pt.Coordinate[i];
                        if (pt.Coordinate[i] < min[i]) min[i] = pt.Coordinate[i];
                    }
                }

            }

            double tempVal = 0;
            for (int i=0; i<dimension; i++)
            {
                average[i] = sum[i]/history.Count;
                if (history.Count>1)
                {
                    tempVal = (history.Count*sumX2[i] - sum[i]*sum[i])/(history.Count*(history.Count-1));
                }
                if (tempVal > 0)
                    stdev[i] = Math.Sqrt(tempVal);
                else
                    stdev[i] = 0;
            }
        }
Exemple #11
0
        protected void Add(NPoint point)
        {
            if (_order == StoreOrder.OldestFirst)
            {
                _values.Add(point);

                if (_values.Count > _maxSize)
                {
                    _values.RemoveAt(0);                   // remove oldest element (fifo)
                }
            }
            else
            {
                _values.Insert(0, point);

                if (_values.Count > _maxSize)
                {
                    _values.RemoveAt(_values.Count - 1);    // remove oldest element (fifo)
                }
            }
        }
        // Call this method from the Form_Load method, passing your ZedGraphControl
        public void CreateChart(ZedGraphControl zgc, TeachPoint tPoint)
        {
            // clear previous values
            GraphPane myPane = zgc.GraphPane;

            myPane.CurveList.Clear();

            // Set the titles and axis labels
//             myPane.Title = "Teachpoint shift:" + tPoint.Name;
//             myPane.XAxis.Title = "Updates";
//             myPane.YAxis.Title = "Parameter A";
//             myPane.Y2Axis.Title = "Parameter B";

            // Make up some data points based on the Sine function
            //PointPairList[] list = new PointPairList[tPoint.Dimension];
            //PointPairList list = new PointPairList();
            LineItem   myCurve = null;
            SymbolType simbol  = SymbolType.Circle;

            System.Drawing.Color color = Color.Blue;
            for (int dim = 0; dim < tPoint.Dimension; dim++)
            {
                PointPairList list = new PointPairList();
                list.Clear();
                for (int idx = 0; idx < tPoint.History.History.Count; idx++)
                {
                    NPoint npoint = (NPoint)tPoint.History.History[idx];
                    double y      = npoint.Coordinate[dim];
                    list.Add((double)idx, y);
                }

                myCurve             = myPane.AddCurve(tPoint.DimensionNames[dim], list, color, simbol++);
                myCurve.Symbol.Fill = new Fill(Color.Gray);
            }


            // Associate this curve with the Y2 axis
            //myCurve.IsY2Axis = true;

//             // Show the x axis grid
//            myPane.XAxis.IsShowGrid = true;
//
//             // Make the Y axis scale red
//             myPane.YAxis.ScaleFontSpec.FontColor = Color.Blue;
//             myPane.YAxis.TitleFontSpec.FontColor = Color.Blue;
//             // turn off the opposite tics so the Y tics don't show up on the Y2 axis
//             myPane.YAxis.IsOppositeTic = false;
//             myPane.YAxis.IsMinorOppositeTic = false;
//             // Don't display the Y zero line
//             myPane.YAxis.IsZeroLine = false;
//             // Align the Y axis labels so they are flush to the axis
//             myPane.YAxis.ScaleAlign = AlignP.Inside;
//             // Manually set the axis range
//             //myPane.YAxis.Min = -30;
//             //myPane.YAxis.Max = 30;
//
            // Enable the Y2 axis display
            //myPane.Y2Axis.IsVisible = true;
            // Make the Y2 axis scale blue
            //myPane.Y2Axis.ScaleFontSpec.FontColor = Color.Blue;
            //myPane.Y2Axis.TitleFontSpec.FontColor = Color.Blue;
            // turn off the opposite tics so the Y2 tics don't show up on the Y axis
            //myPane.Y2Axis.IsOppositeTic = false;
            //myPane.Y2Axis.IsMinorOppositeTic = false;
            // Display the Y2 axis grid lines
            //myPane.Y2Axis.IsShowGrid = true;
            // Align the Y2 axis labels so they are flush to the axis
            //myPane.Y2Axis.ScaleAlign = AlignP.Inside;

            // Fill the axis background with a gradient
//            myPane.AxisFill = new Fill( Color.White, Color.LightGray, 45.0f );

            // Calculate the Axis Scale Ranges
            zgc.AxisChange();

            zgc.Refresh();
        }
Exemple #13
0
 public void AddPoint(NPoint point)
 {
     Add(point);
     CallHandler();
 }
        private void LoadStatisticsTable()
        {
            if (history.Count == 0)
                return;

            NPoint tpoint = (NPoint)history[0];
            
            _dtStat.Clear();
            DataRow dr = null;

            // Average
            dr = _dtStat.NewRow();
            dr["Item"] = "Average";                
            for(int dim = 0; dim < tpoint.Dimension; dim++)
            {
                string dimName  = tpoint.DimensionNames[dim];
                double dimValue = tpoint.Coordinate[dim];
                dr[dimName] = average[dim].ToString("F3");
            }
            _dtStat.Rows.Add(dr);

            // stdev
            dr = _dtStat.NewRow();
            dr["Item"] = "stdev";                
            for(int dim = 0; dim < tpoint.Dimension; dim++)
            {
                string dimName  = tpoint.DimensionNames[dim];
                double dimValue = tpoint.Coordinate[dim];
                dr[dimName] = stdev[dim].ToString("F3");
            }
            _dtStat.Rows.Add(dr);

            // sum
            dr = _dtStat.NewRow();
            dr["Item"] = "sum";                
            for(int dim = 0; dim < tpoint.Dimension; dim++)
            {
                string dimName  = tpoint.DimensionNames[dim];
                double dimValue = tpoint.Coordinate[dim];
                dr[dimName] = sum[dim].ToString("F3");
            }
            _dtStat.Rows.Add(dr);

            // sumX2
            dr = _dtStat.NewRow();
            dr["Item"] = "sumX2";                
            for(int dim = 0; dim < tpoint.Dimension; dim++)
            {
                string dimName  = tpoint.DimensionNames[dim];
                double dimValue = tpoint.Coordinate[dim];
                dr[dimName] = sumX2[dim].ToString("F3");
            }
            _dtStat.Rows.Add(dr);

            // min
            dr = _dtStat.NewRow();
            dr["Item"] = "min";                
            for(int dim = 0; dim < tpoint.Dimension; dim++)
            {
                string dimName  = tpoint.DimensionNames[dim];
                double dimValue = tpoint.Coordinate[dim];
                dr[dimName] = min[dim].ToString();
            }
            _dtStat.Rows.Add(dr);

            // max
            dr = _dtStat.NewRow();
            dr["Item"] = "max";                
            for(int dim = 0; dim < tpoint.Dimension; dim++)
            {
                string dimName  = tpoint.DimensionNames[dim];
                double dimValue = tpoint.Coordinate[dim];
                dr[dimName] = max[dim].ToString();
            }
            _dtStat.Rows.Add(dr);
        }