Exemple #1
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            //make sure curvelist isnt empty
            if (zedGraphControl1.GraphPane.CurveList.Count <= 0)
            {
                return;
            }

            //get first curve in graph
            LineItem curve = zedGraphControl1.GraphPane.CurveList[0] as LineItem;

            if (curve == null)
            {
                return;
            }

            IPointListEdit list = curve.Points as IPointListEdit;

            if (addindex < portdata.Count)
            {
                list.Add(counter, (double)portdata[addindex]);

                addindex = addindex + 20;
                counter  = counter + .02;
            }


            zedGraphControl1.GraphPane.XAxis.Scale.Max = counter + 5;
            zedGraphControl1.GraphPane.XAxis.Scale.Min = zedGraphControl1.GraphPane.XAxis.Scale.Max - 10;
            zedGraphControl1.AxisChange();
            zedGraphControl1.Invalidate();
            zedGraphControl1.Refresh();
        }
Exemple #2
0
        /// <summary>
        /// 添加数据点
        /// </summary>
        /// <param name="curveName"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        public virtual void AddXYPoint(string curveName, PointPair xypoint)
        {
            //---异步调用
            if (this.zedGraphControl_myChart.InvokeRequired)
            {
                this.zedGraphControl_myChart.Invoke((EventHandler)
                                                    (delegate
                {
                    //---增加坐标XY轴的点
                    IPointListEdit ip = this.zedGraphControl_myChart.GraphPane.CurveList[curveName].Points as IPointListEdit;
                    if (ip != null)
                    {
                        ip.Add(xypoint);

                        //---刷新显示
                        this.RefreshZedGraph();
                    }
                }));
            }
            else
            {
                //---增加坐标XY轴的点
                IPointListEdit ip = this.zedGraphControl_myChart.GraphPane.CurveList[curveName].Points as IPointListEdit;
                if (ip != null)
                {
                    ip.Add(xypoint);

                    //---刷新显示
                    this.RefreshZedGraph();
                }
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            openFileDialog1.Title    = "Open File...";
            openFileDialog1.FileName = "";
            openFileDialog1.Filter   = "CSV (comma delimited)|*.csv|All Files|*.*";

            if (openFileDialog1.ShowDialog() == DialogResult.Cancel)
            {
                MessageBox.Show("Choice Cancelled");
            }
            else
            {
                data          = File.ReadAllLines(openFileDialog1.FileName);
                dataMagnitude = data.Select(x => double.Parse(x)).ToArray();

                N     = Enumerable.Range(1, dataMagnitude.Length).ToArray();
                dataN = Array.ConvertAll <int, double>(N, Convert.ToDouble);

                LineItem       kurvaMagnitude = zedGraphControl1.GraphPane.CurveList[0] as LineItem;
                IPointListEdit listMagnitude  = kurvaMagnitude.Points as IPointListEdit;
                listMagnitude.Clear();
                for (int i = 1; i < dataMagnitude.Length; i++)
                {
                    listMagnitude.Add(dataN[i], dataMagnitude[i]);
                }
                zedGraphControl1.AxisChange();
                zedGraphControl1.Invalidate();
            }
        }
        private void DrawGraph(ZedGraphControl DoThi, List <PredicResults> results)
        {
            //ve gia tri
            LineItem curve2_1 = DoThi.GraphPane.CurveList[0] as LineItem;
            LineItem curve2_2 = DoThi.GraphPane.CurveList[1] as LineItem;

            //init do thi.

            // Get the PointPairList
            IPointListEdit list21 = curve2_1.Points as IPointListEdit;
            IPointListEdit list22 = curve2_2.Points as IPointListEdit;

            list21.Clear();
            list22.Clear();
            DoThi.AxisChange();
            DoThi.Invalidate();
            int i = 0;

            foreach (var item in results)
            {
                var xdate = new XDate(item.Date);
                list21.Add(xdate, item.ActualClose);
                list22.Add(xdate, item.PredictedClose);
                // đoạn chương trình thực hiện vẽ đồ thị
                Scale xScale = DoThi.GraphPane.XAxis.Scale;
                i++;
            }
            // Vẽ đồ thị
            DoThi.AxisChange();
            // Force a redraw
            DoThi.Invalidate();
        }
 public void UpdateLineGraph(double xValue, double yValue)
 {
     try
     {
         GraphPane pane = masterPane.PaneList[0];
         if (pane.CurveList.Count > 0)
         {
             LineItem item = pane.CurveList[0] as LineItem;
             if (item != null)
             {
                 IPointListEdit points = item.Points as IPointListEdit;
                 if (points != null)
                 {
                     points.Add(xValue, yValue);
                     pane.AxisChange();
                     graph.Invalidate();
                 }
             }
         }
     }
     catch
     {
         throw new Exception("While updating data graph");
     }
 }
Exemple #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="_x1"></param>
        /// <param name="_y1"></param>
        /// <param name="_x2"></param>
        /// <param name="_y2"></param>
        private void draw(double _x1, double _y1)
        {
            if (zed.GraphPane.CurveList.Count <= 0)
            {
                return;
            }
            LineItem curve = zed.GraphPane.CurveList[0] as LineItem;

            if (curve == null)
            {
                return;
            }

            IPointListEdit list = curve.Points as IPointListEdit;

            if (list == null)
            {
                return;
            }

            list.Add(_x1, _y1);


            if (_x1 > (zed.GraphPane.XAxis.Scale.Max - zed.GraphPane.XAxis.Scale.MajorStep + 20))
            {
                zed.GraphPane.XAxis.Scale.Max = _x1 + 120;
                // zed.GraphPane.XAxis.Scale.Min += 60;
            }
            zed.AxisChange();
            zed.Invalidate();
            zed.Refresh();
        }
        public void Draw(string setpoint)
        {
            double insetpoint;

            double.TryParse(setpoint, out insetpoint);
            LineItem curve = zedGraphControl1.GraphPane.CurveList[0] as LineItem;

            if (curve == null)
            {
                return;
            }
            IPointListEdit list = curve.Points as IPointListEdit;

            forPointAnalysis = list;
            if (list == null)
            {
                return;
            }
            list.Add(xAxis * 0.03, insetpoint);

            if (xAxis * 0.03 > 25)
            {
                zedGraphControl1.GraphPane.XAxis.Scale.Max  = xAxis * 0.03 + 2.03;
                zedGraphControl1.GraphPane.XAxis.Scale.Min += 0.03;
            }

            zedGraphControl1.AxisChange();
            zedGraphControl1.Invalidate();
            if (MAP < insetpoint)
            {
                MAP = insetpoint;
            }
            xAxis++;
        }
Exemple #8
0
    public void SetLine(String lineTitle, short[] values)
    {
        IPointListEdit ip  = zgcGraph.GraphPane.CurveList[lineTitle].Points as IPointListEdit;
        int            tmp = Math.Min(ip.Count, values.Length);
        int            i   = 0;

        peakX = values.Length;

        while (i < tmp)
        {
            if (values[i] > peakY)
            {
                peakY = values[i];
            }
            ip[i].X = i;
            ip[i].Y = values[i];
            i++;
        }
        while (ip.Count < values.Count)
        {
            if (values[i] > peakY)
            {
                peakY = values[i];
            }
            ip.Add(i, values[i]);
            i++;
        }
        while (values.Count > ip.Count)
        {
            ip.RemoveAt(ip.Count - 1);
        }
    }
        public void Draw(double data, double data1, double data2)
        {
            if (zedGraphControl.GraphPane.CurveList.Count <= 0)
            {
                return;
            }

            LineItem curve  = zedGraphControl.GraphPane.CurveList[0] as LineItem;
            LineItem curve1 = zedGraphControl.GraphPane.CurveList[1] as LineItem;
            LineItem curve2 = zedGraphControl.GraphPane.CurveList[2] as LineItem;

            if (curve == null)
            {
                return;
            }
            if (curve1 == null)
            {
                return;
            }

            IPointListEdit list  = curve.Points as IPointListEdit;
            IPointListEdit list1 = curve1.Points as IPointListEdit;
            IPointListEdit list2 = curve2.Points as IPointListEdit;

            if (list == null)
            {
                return;
            }

            // Time is measured in seconds
            double time = (Environment.TickCount - TickStart) / 1000.0;

            list.Add(time, data); // Thêm điểm trên đồ thị
            list1.Add(time, data1);
            list2.Add(time, data2);

            Scale xScale = zedGraphControl.GraphPane.XAxis.Scale;
            Scale yScale = zedGraphControl.GraphPane.YAxis.Scale;

            // Tự động Scale theo trục x
            if (time > xScale.Max - xScale.MajorStep)
            {
                xScale.Max = time + xScale.MajorStep;
                xScale.Min = xScale.Max - 30;
            }

            // Tự động Scale theo trục y
            if (data > yScale.Max - yScale.MajorStep)
            {
                yScale.Max = data + yScale.MajorStep;
            }
            else if (data < yScale.Min + yScale.MajorStep)
            {
                yScale.Min = data - yScale.MajorStep;
            }

            zedGraphControl.AxisChange();
            zedGraphControl.Invalidate();
            zedGraphControl.Refresh();
        }
Exemple #10
0
        public void DrawGraph(List <MyError> results)
        {
            //ve gia tri
            LineItem curve2_1 = DoThi_Error.GraphPane.CurveList[0] as LineItem;
            // LineItem curve2_2 = DoThi.GraphPane.CurveList[1] as LineItem;

            //init do thi.

            // Get the PointPairList
            IPointListEdit list21 = curve2_1.Points as IPointListEdit;

            list21.Clear();

            DoThi_Error.AxisChange();
            DoThi_Error.Invalidate();
            int i = 0;

            foreach (var item in results)
            {
                list21.Add(item.index, item.value);

                // đoạn chương trình thực hiện vẽ đồ thị
                Scale xScale = DoThi_Error.GraphPane.XAxis.Scale;
                i++;
            }

            // Vẽ đồ thị
            DoThi_Error.AxisChange();
            // Force a redraw
            DoThi_Error.Invalidate();

            //if (AppGlobol.IsAutoRun)
            //    DoThi_Error.GetImage().Save(AppGlobol.FolderPath + "/Error.png");
        }
Exemple #11
0
        /// <summary>
        /// Updates the ZedGraph
        /// </summary>
        /// <param name="zedGraph"></param>
        /// <param name="Data"></param>
        /// <param name="time"></param>
        public void UpdateZedGraph(ZedGraphControl zedGraph, Int16[] Data, int time)
        {
            if (zedGraph.GraphPane == null)
            {
                return;
            }

            int    localTime = 0;
            double seconds   = 0;

            rect = new Rectangle((int)zedGraph.GraphPane.Chart.Rect.X, (int)zedGraph.GraphPane.Chart.Rect.Y, (int)zedGraph.GraphPane.Chart.Rect.Width, (int)zedGraph.GraphPane.Chart.Rect.Height);

            // Make sure that the curvelist has at least one curve
            if (zedGraph.GraphPane.CurveList.Count <= 0)
            {
                return;
            }

            // Get the first CurveItem in the graph
            LineItem curve = zedGraph.GraphPane.CurveList[0] as LineItem;

            if (curve == null)
            {
                return;
            }

            // Get the PointPairList
            IPointListEdit list = curve.Points as IPointListEdit;

            //If time hits zero, Graph gets cleared and redrawn
            if (time == 0)
            {
                list.Clear();
                // Force a redraw
                //zedGraph.Invalidate();
            }

            // If this is null, it means the reference at curve.Points does not
            // support IPointListEdit, so we won't be able to modify it
            if (list == null)
            {
                return;
            }

            for (int i = 0; i < Data.Length; i++)
            {
                seconds = (double)(time + localTime) / Statics.FS;
                // Time is measured in seconds
                localTime++;
                // 3 seconds per cycle
                list.Add(seconds, Data[i]);
            }

            //Only redraw a certain area
            var xPix = (int)zedGraph.GraphPane.XAxis.Scale.Transform(seconds);

            rect.X     = xPix - ((int)zedGraph.GraphPane.Chart.Rect.Width / 6); //- 20;
            rect.Width = (int)zedGraph.GraphPane.Chart.Rect.Width / 6 + 10;
            zedGraph.Invalidate(rect);
        }
Exemple #12
0
        /// <summary>
        /// ZedGraph 드로잉(X가 30이상이면 Shifting)
        /// </summary>
        /// <param name="zed">ZedGraphControl</param>
        /// <param name="current">X값</param>
        private void drawZed(ZedGraphControl zed, double current)
        {
            if (zed.GraphPane.CurveList.Count <= 0)
            {
                return;
            }

            LineItem curve = zed.GraphPane.CurveList[0] as LineItem;

            if (curve == null)
            {
                return;
            }

            IPointListEdit list = curve.Points as IPointListEdit;

            if (list == null)
            {
                return;
            }

            list.Add(zedCnt, current);

            Scale xScale = zed.GraphPane.XAxis.Scale;

            if (zedCnt > xScale.Max - xScale.MajorStep)
            {
                xScale.Max = zedCnt + xScale.MajorStep;
                xScale.Min = xScale.Max - 30.0;
            }

            zed.AxisChange();
            zed.Invalidate();
        }
 public void UpdateLineGraph(double xValue, double yValue)
 {
     try
     {
         GraphPane graphPane = this.masterPane.PaneList[0];
         if (graphPane.CurveList.Count <= 0)
         {
             return;
         }
         LineItem lineItem = graphPane.CurveList[0] as LineItem;
         if (lineItem == null)
         {
             return;
         }
         IPointListEdit pointListEdit = lineItem.Points as IPointListEdit;
         if (pointListEdit == null)
         {
             return;
         }
         pointListEdit.Add(xValue, yValue);
         graphPane.AxisChange();
         this.graph.Invalidate();
     }
     catch
     {
         throw new Exception("While updating data graph");
     }
 }
Exemple #14
0
        // Update the graph with the data points
        public void UpdateGraph(double time, double analog1, double analog2)
        {
            // set window width
            const double windowWidth = 30.0;

            // Add data points to the circular lists
            _analog1List.Add(time, analog1);
            _analog2List.Add(time, analog2);

            // Because updating the chart is computationally expensive if
            // there are many data points, we do this only every 100 ms, that is 10 Hz
            if (!TimeUtils.HasExpired(ref _previousChartUpdate, 100))
            {
                return;
            }

            Console.WriteLine("Update chart");

            // get and update x-scale to scroll with data with an certain window
            var xScale = chartControl.GraphPane.XAxis.Scale;

            xScale.Max = time + xScale.MajorStep;
            xScale.Min = xScale.Max - windowWidth;

            // Make sure the axes are rescaled to accommodate actual data
            chartControl.AxisChange();

            // Force a redraw
            chartControl.Invalidate();
        }
Exemple #15
0
 public void UpdateLineGraph(int serie, double time, double value)
 {
     try
     {
         GraphPane pane = masterPane.PaneList[0];
         if (pane.CurveList.Count > 0)
         {
             LineItem item = pane.CurveList[serie] as LineItem;
             if (item != null)
             {
                 IPointListEdit points = item.Points as IPointListEdit;
                 if (points != null)
                 {
                     points.Add(time, value);
                     if ((time > pane.XAxis.Scale.Max) || (pane.XAxis.Scale.Max > 10.0))
                     {
                         pane.XAxis.Scale.Max = time;
                         pane.XAxis.Scale.Min = pane.XAxis.Scale.Max - 10.0;
                     }
                     pane.AxisChange();
                     graph.Invalidate();
                 }
             }
         }
     }
     catch
     {
         throw new Exception("While updating data graph");
     }
 }
Exemple #16
0
        private void Draw(double x, double y)
        {
            LineItem curve = Graph.GraphPane.CurveList[0] as LineItem;

            if (curve == null)
            {
                return;
            }

            IPointListEdit list = curve.Points as IPointListEdit;

            if (list == null)
            {
                return;
            }

            //double time = (Environment.TickCount - TickStart) / 1000;

            i++;
            list.Add(x, y);
            curve = Graph.GraphPane.AddCurve(null, list, Color.Blue, SymbolType.None);

            Scale xScale = Graph.GraphPane.XAxis.Scale;

            if (x > (xScale.Max - xScale.MajorStep))
            {
                xScale.Max = xScale.Max + xScale.MinorStep;
                xScale.Min = xScale.Max - 30;
            }

            Graph.AxisChange();
            Graph.Invalidate();
        }
        void AddDataPoint(double dataX)
        {
            // Make sure that the curvelist has at least one curve
            //确保CurveList不为空
            if (zedgraph.GraphPane.CurveList.Count <= 0)
            {
                return;
            }

            // Get the  first CurveItem in the graph

            //取Graph第一个曲线,也就是第一步:在 GraphPane.CurveList 集合中查找 CurveItem
            for (int idxList = 0; idxList < zedgraph.GraphPane.CurveList.Count; idxList++)
            {
                LineItem curve = zedgraph.GraphPane.CurveList[idxList] as LineItem;
                if (curve == null)
                {
                    return;
                }

                // Get the PointPairList
                //第二步:在CurveItem中访问PointPairList(或者其它的IPointList),根据自己的需要增加新数据或修改已存在的数据

                IPointListEdit list = curve.Points as IPointListEdit;

                // If this is null, it means the reference at curve.Points does not
                // support IPointListEdit, so we won't be able to modify it

                if (list == null)
                {
                    return;
                }


                // Time is measured in seconds
                double time = (Environment.TickCount - tickStart) / 1000.0;
                // 3 seconds per cycle

                list.Add(time, dataX);

                // Keep the X scale at a rolling 30 second interval, with one

                // major step between the max X value and the end of the axis
                Scale xScale = zedgraph.GraphPane.XAxis.Scale;
                if (time > xScale.Max - xScale.MajorStep)
                {
                    xScale.Max = time + xScale.MajorStep;
                    xScale.Min = xScale.Max - 30.0;
                }
            }
            // Make sure the Y axis is rescaled to accommodate actual data
            //第三步:调用ZedGraphControl.AxisChange()方法更新X和Y轴的范围


            zedgraph.AxisChange(); // Force a redraw
                                   //第四步:调用Form.Invalidate()方法更新图表


            zedgraph.Invalidate();
        }
Exemple #18
0
 public void UpdateLineGraph(int serie, double time, double value)
 {
     try
     {
         GraphPane graphPane = this.masterPane.PaneList[0];
         if (graphPane.CurveList.Count <= 0)
         {
             return;
         }
         LineItem lineItem = graphPane.CurveList[serie] as LineItem;
         if (lineItem == null)
         {
             return;
         }
         IPointListEdit pointListEdit = lineItem.Points as IPointListEdit;
         if (pointListEdit == null)
         {
             return;
         }
         pointListEdit.Add(time, value);
         if (time > graphPane.XAxis.Scale.Max || graphPane.XAxis.Scale.Max > 10.0)
         {
             graphPane.XAxis.Scale.Max = time;
             graphPane.XAxis.Scale.Min = graphPane.XAxis.Scale.Max - 10.0;
         }
         graphPane.AxisChange();
         this.graph.Invalidate();
     }
     catch
     {
         throw new Exception("While updating data graph");
     }
 }
Exemple #19
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            // Make sure that the curvelist has at least one curve
            if (zedGraphControl1.GraphPane.CurveList.Count <= 0)
            {
                return;
            }

            // Get the first CurveItem in the graph
            LineItem xcurve = zedGraphControl1.GraphPane.CurveList[0] as LineItem;
            LineItem ycurve = zedGraphControl1.GraphPane.CurveList[1] as LineItem;
            LineItem zcurve = zedGraphControl1.GraphPane.CurveList[2] as LineItem;

            if (xcurve == null || ycurve == null || zcurve == null)
            {
                return;
            }

            // Get the PointPairList
            IPointListEdit xlist = xcurve.Points as IPointListEdit;
            IPointListEdit ylist = ycurve.Points as IPointListEdit;
            IPointListEdit zlist = zcurve.Points as IPointListEdit;

            // If this is null, it means the reference at curve.Points does not
            // support IPointListEdit, so we won't be able to modify it
            if (xlist == null || ylist == null || zlist == null)
            {
                return;
            }

            // Time is measured in seconds
            //double time = (Environment.TickCount - tickStart) / 1000.0;
            double time = a_page.gps_time / 1000.0;

            // 3 seconds per cycle
            //list.Add(time, Math.Sin(2.0 * Math.PI * time / 3.0));
            xlist.Add(time, a_page.cal_ax);
            ylist.Add(time, a_page.cal_ay);
            zlist.Add(time, a_page.cal_az);

            // Keep the X scale at a rolling 30 second interval, with one
            // major step between the max X value and the end of the axis
            Scale xScale = zedGraphControl1.GraphPane.XAxis.Scale;

            //if (time > xScale.Max - xScale.MajorStep)
            //{
            xScale.Max = time + (double)numericUpDown1.Value / 8;
            xScale.Min = xScale.Max - (double)numericUpDown1.Value;
            //}
            if (xScale.Min < 0)
            {
                xScale.Min = 0;
            }

            // Make sure the Y axis is rescaled to accommodate actual data
            zedGraphControl1.AxisChange();
            // Force a redraw
            zedGraphControl1.Invalidate();
        }
Exemple #20
0
        public void draw(double setpoint1)
        {
            //make sure that curvelist has at least one curve
            if (zedGraphControl1.GraphPane.CurveList.Count <= 0)
            {
                return; // Kiểm tra việc khởi tạo các đường curve
            }
            LineItem curve1 = zedGraphControl1.GraphPane.CurveList[0] as LineItem;

            //LineItem curve2 = zedGraphControl1.GraphPane.CurveList[1] as LineItem;
            if (curve1 == null)
            {
                return;
            }
            //if (curve2 == null)
            //    return;

            IPointListEdit list1 = curve1.Points as IPointListEdit;

            //IPointListEdit list2 = curve2.Points as IPointListEdit;
            if (list1 == null)
            {
                return;
            }
            //if (list2 == null)
            //    return;

            tickStart = tickStart + 1;
            double time = tickStart;

            //time = (Environment.TickCount - tickStart) / 500.0;

            list1.Add(time, setpoint1);// Đây chính là hàm hiển thị dữ liệu của mình lên đồ thị
            //list2.Add(time, setpoint1 + 20);

            //keep the X scale at a rolling 30 seconed interval, with one major step
            //between the max X value and the end of the axis
            Scale xScale = zedGraphControl1.GraphPane.XAxis.Scale;

            if (time > xScale.Max - xScale.MajorStep)
            {
                if (CheDo == _enCheDo.Compact)
                {
                    xScale.Max = time + xScale.MajorStep;
                    xScale.Min = xScale.Max - 30.0;
                }
                else
                {
                    xScale.Max = time + xScale.MajorStep;
                    xScale.Min = 0;
                }
            }

            //make sure the y axis is rescaled to accommodate actual data
            zedGraphControl1.AxisChange();
            // Force a redraw
            zedGraphControl1.Invalidate();
        }
        private void Draw(float setpoint)
        {
            float intsetpoint = setpoint;

            // float intcurrent = current;

            // Debug.WriteLine($"DEBUG ZED GRAPH------------- {setpoint}, {current}");


            if (zed.GraphPane.CurveList.Count <= 0)
            {
                return;
            }

            LineItem curve = zed.GraphPane.CurveList[0] as LineItem;

            // LineItem curve1 = zed.GraphPane.CurveList[1] as LineItem;
            if (curve == null)
            {
                return;
            }
            //if (curve1 == null)
            //return;

            IPointListEdit list = curve.Points as IPointListEdit;

            // IPointListEdit list1 = curve1.Points as IPointListEdit;

            if (list == null)
            {
                return;
            }
            // if (list1 == null)
            // return;
            double time = (Environment.TickCount - TickStart) / 1000.0;

            list.Add(time, intsetpoint);
            //  list1.Add(time, intcurrent);

            Scale xScale = zed.GraphPane.XAxis.Scale;

            if (time > xScale.Max - xScale.MajorStep)
            {
                if (intMode == 1)
                {
                    xScale.Max = time + xScale.MajorStep;
                    xScale.Min = xScale.Max - 30.0;
                }
                else
                {
                    xScale.Max = time + xScale.MajorStep;
                    xScale.Min = 0;
                }
            }

            zed.AxisChange();
            zed.Invalidate();
        }
        private void Draw(float setpoint, float value2)
        {
            float intsetpoint = setpoint;
            float intcurrent  = value2;

            if (zed.GraphPane.CurveList.Count <= 0)
            {
                return;
            }

            LineItem curve  = zed.GraphPane.CurveList[0] as LineItem;
            LineItem curve1 = zed.GraphPane.CurveList[1] as LineItem;

            if (curve == null)
            {
                return;
            }
            if (curve1 == null)
            {
                return;
            }

            IPointListEdit list  = curve.Points as IPointListEdit;
            IPointListEdit list1 = curve1.Points as IPointListEdit;

            if (list == null)
            {
                return;
            }
            if (list1 == null)
            {
                return;
            }
            double time = (Environment.TickCount - TickStart) / 1000.0;

            list.Add(time, intsetpoint);
            list1.Add(time, intcurrent);

            Scale xScale = zed.GraphPane.XAxis.Scale;

            if (time > xScale.Max - xScale.MajorStep)
            {
                if (intMode == 1)
                {
                    xScale.Max = time + xScale.MajorStep;
                    xScale.Min = xScale.Max - 30.0;
                }
                else
                {
                    xScale.Max = time + xScale.MajorStep;
                    xScale.Min = 0;
                }
            }

            zed.AxisChange();
            zed.Invalidate();
        }
Exemple #23
0
        private void graphUpdateTimer_Tick(object sender, EventArgs e)
        {
            TimeSpan timerTimeSpan = testParam.testStopwatch.Elapsed;

            if (testGraph.GraphPane.CurveList.Count <= 0)
            {
                return;
            }
            LineItem curve = testGraph.GraphPane.CurveList[0] as LineItem;

            if (curve == null)
            {
                return;
            }
            IPointListEdit list = curve.Points as IPointListEdit;

            if (list == null)
            {
                return;
            }
            double time = testParam.testStopwatch.Elapsed.TotalMilliseconds / 1000.0;

            if (testParam.xAxisUnit == "seconds")
            {
                list.Add(time, testParam.forceReadings[4]);
                Scale xScale = testGraph.GraphPane.XAxis.Scale;
                if (time > xScale.Max - xScale.MajorStep)
                {
                    xScale.Max = time + xScale.MajorStep;
                    xScale.Min = xScale.Max - testParam.XAxisTimeWindow;
                }
            }
            else if (testParam.xAxisUnit == "mm")
            {
                list.Add(testParam.dispReadings[3], testParam.forceReadings[3]);
                Scale xScale = testGraph.GraphPane.XAxis.Scale;
                if (testParam.dispReadings[3] > xScale.Max - xScale.MajorStep)
                {
                    xScale.Max = testParam.dispReadings[4] + xScale.MajorStep;
                    xScale.Min = xScale.Max - testParam.XAxisTimeWindow;
                }
            }
            testGraph.Invalidate();
        }
Exemple #24
0
        private void DrawGraph(ZedGraphControl zedGraphControl, double value)
        {
            if (zedGraphControl.GraphPane.CurveList.Count <= 0)
            {
                return;
            }

            // time is measure in seconds
            double time = (Environment.TickCount - tickStart) / 1000.0;

            LineItem       curve       = zedGraphControl.GraphPane.CurveList[0] as LineItem;
            IPointListEdit pointBuffer = curve.Points as IPointListEdit;

            // add point to buffer to draw
            pointBuffer.Add(time, value);

            if (zedGraphControl == zedGraphVelocity)
            {
                LineItem       curve1       = zedGraphControl.GraphPane.CurveList[1] as LineItem;
                IPointListEdit pointBuffer1 = curve1.Points as IPointListEdit;
                // add point to buffer to draw
                if (Display.Mode == "Real Time")
                {
                    pointBuffer1.Add(time, 15);
                }
                else if (Display.Mode == "Simulation")
                {
                    pointBuffer1.Add(time, 15);
                }
            }

            // make xAxis scroll
            Scale xScale = zedGraphControl.GraphPane.XAxis.Scale;

            if (time > xScale.Max - xScale.MajorStep)
            {
                xScale.Max = time + xScale.MajorStep;
                xScale.Min = xScale.Max - 30.0;
            }

            // re-draw graph
            zedGraphControl.AxisChange();
            zedGraphControl.Invalidate();
        }
Exemple #25
0
        //画温度和光强曲线函数
        private void drawline(int channel, double data)
        {
            //确保curvelist不为空
            if (zedgraph.GraphPane.CurveList.Count <= 0)
            {
                return;
            }

            LineItem line;

            if (channel == 0)
            {
                //取graph第一个曲线,在GraphPane.CurveList集合中查找CurveItem,对应于温度曲线
                line = zedgraph.GraphPane.CurveList[0] as LineItem;
            }
            else
            {
                //得到对应于光强的曲线
                line = zedgraph.GraphPane.CurveList[1] as LineItem;
            }

            if (line == null)
            {
                return;
            }

            //在CurveItem中访问PointPairList,根据自己的需要增加新数据或修改已存在的数据
            IPointListEdit list = line.Points as IPointListEdit;

            //如果list为null,curve.Point不支持该类型

            if (list == null)
            {
                return;
            }

            //得到时间,加入list中的x轴和y轴
            double time = (Environment.TickCount - tickStart) / 1000.0;

            list.Add(time, data);

            //调整x轴的最大值与最小值
            Scale x = zedgraph.GraphPane.XAxis.Scale;

            if (time > x.Max - x.MajorStep)
            {
                x.Max = time + x.MajorStep;
                x.Min = x.Max - 30.0;
            }

            //force a redraw
            zedgraph.AxisChange();

            //调用方法方法更新图表
            zedgraph.Invalidate();
        }
Exemple #26
0
        public void drawGraph()
        {
            // Make sure that the curvelist has at least one curve
            if (zedGraphControl1.GraphPane.CurveList.Count <= 0)
            {
                return;
            }

            // Get the first CurveItem in the graph
            LineItem curve1 = zedGraphControl1.GraphPane.CurveList[0] as LineItem;
            LineItem curve2 = zedGraphControl1.GraphPane.CurveList[1] as LineItem;
            LineItem curve3 = zedGraphControl1.GraphPane.CurveList[2] as LineItem;

            if (curve1 == null || curve3 == null || curve2 == null)
            {
                return;
            }

            // Get the PointPairList
            IPointListEdit list1 = curve1.Points as IPointListEdit;
            IPointListEdit list2 = curve2.Points as IPointListEdit;
            IPointListEdit list3 = curve3.Points as IPointListEdit;

            // If this is null, it means the reference at curve.Points does not
            // support IPointListEdit, so we won't be able to modify it
            if (list1 == null || list2 == null || list3 == null)
            {
                return;
            }

            // Time is measured in seconds
            double time = (Environment.TickCount - tickStart) / 1000.0;

            // 3 seconds per cycle
            list1.Add(time, value1);
            list2.Add(time, value2);
            list3.Add(time, value3);

            // Keep the X scale at a rolling 30 second interval, with one
            // major step between the max X value and the end of the axis
            Scale xScale = zedGraphControl1.GraphPane.XAxis.Scale;

            if (time > xScale.Max - xScale.MajorStep)
            {
                xScale.Max = time + xScale.MajorStep;
                xScale.Min = xScale.Max - 10.0;
            }

            // Make sure the Y axis is rescaled to accommodate actual data
            zedGraphControl1.AxisChange();
            // Force a redraw
            zedGraphControl1.Invalidate();
            zedGraphControl1.IsShowPointValues = true;
            zedGraphControl1.PointValueFormat  = "0.000";
            zedGraphControl1.PointDateFormat   = "d";
        }
        private void Draw(double phase, double phase1)
        {
            if (zedGraphControl1.GraphPane.CurveList.Count <= 0)
            {
                return;
            }

            LineItem curve  = zedGraphControl1.GraphPane.CurveList[0] as LineItem;
            LineItem curve1 = zedGraphControl1.GraphPane.CurveList[1] as LineItem;

            if (curve == null)
            {
                return;
            }
            if (curve1 == null)
            {
                return;
            }

            IPointListEdit siji = curve.Points as IPointListEdit;
            IPointListEdit loro = curve1.Points as IPointListEdit;

            if (siji == null)
            {
                return;
            }
            if (loro == null)
            {
                return;
            }

            double waktu = (Environment.TickCount - TickStart) / 10.0;

            siji.Add((waktu), phase);
            loro.Add((waktu), phase1);

            Scale xScale = zedGraphControl1.GraphPane.XAxis.Scale;

            if (waktu > xScale.Max - xScale.MajorStep)
            {
                if (intMode == 1)
                {
                    xScale.Max = waktu + xScale.MajorStep;
                    xScale.Min = xScale.Max - 30.0;
                }
                else
                {
                    xScale.Max = waktu + xScale.MajorStep;
                    xScale.Min = 0;
                }

                zedGraphControl1.AxisChange();
                zedGraphControl1.Invalidate();
            }
        }
Exemple #28
0
        private void draw()
        {
            LineItem       curve  = zedGraphControl1.GraphPane.CurveList[0] as LineItem;
            LineItem       curve1 = zedGraphControl1.GraphPane.CurveList[1] as LineItem;
            IPointListEdit list   = curve.Points as IPointListEdit;
            IPointListEdit list1  = curve1.Points as IPointListEdit;

            list.Add(t, data_point);
            list1.Add(t, st_point);
            Scale xScale = zedGraphControl1.GraphPane.XAxis.Scale;
            Scale yScale = zedGraphControl1.GraphPane.YAxis.Scale;

            LineItem       curve2 = zedGraphControl2.GraphPane.CurveList[0] as LineItem;
            IPointListEdit list2  = curve2.Points as IPointListEdit;

            list2.Add(t, control_point);
            Scale xScale1 = zedGraphControl2.GraphPane.XAxis.Scale;
            Scale yScale1 = zedGraphControl2.GraphPane.YAxis.Scale;

            t += 0.1f;

            if (t > xScale.Max - xScale.MajorStep)
            {
                xScale.Max  = t + xScale.MajorStep;
                xScale.Min  = xScale.Max - 30;
                xScale1.Max = t + xScale1.MajorStep;
                xScale1.Min = xScale1.Max - 30;
            }


            if (data_point > yScale.Max - yScale.MajorStep)
            {
                yScale.Max = data_point + yScale.MajorStep;
            }
            else if (data_point < yScale.Min + yScale.MajorStep)
            {
                yScale.Min = data_point - yScale.MajorStep;
            }
            if (control_point > yScale1.Max - yScale1.MajorStep)
            {
                yScale1.Max = control_point + yScale1.MajorStep;
            }
            else if (control_point < yScale1.Min + yScale1.MajorStep)
            {
                yScale1.Min = control_point - yScale1.MajorStep;
            }

            zedGraphControl1.AxisChange();
            zedGraphControl1.Invalidate();
            zedGraphControl1.Refresh();

            zedGraphControl2.AxisChange();
            zedGraphControl2.Invalidate();
            zedGraphControl2.Refresh();
        }
Exemple #29
0
        private void Draw()
        {
            if (zedGraphControl1.GraphPane.CurveList.Count <= 0)
            {
                return;
            }
            // kiểm tra việc khởi tạo các đường curve
            // đưa vể điểm xuất phát

            LineItem curve = zedGraphControl1.GraphPane.CurveList[0] as LineItem;

            if (curve == null)
            {
                return;
            }
            // list các điểm
            IPointListEdit list = curve.Points as IPointListEdit;

            if (list == null)
            {
                return;
            }
            // realtime được tính bắng ms
            realtime = (Environment.TickCount - tickStart) / 1000.0;

            list.Add(realtime, datanumber); // hàm hiển thị dữ liệu trên đồ thị



            Scale xScale = zedGraphControl1.GraphPane.XAxis.Scale;
            Scale yScale = zedGraphControl1.GraphPane.YAxis.Scale;

            // Tự động Scale theo trục x
            if (realtime > xScale.Max - xScale.MajorStep)
            {
                xScale.Max = realtime + xScale.MajorStep;
                xScale.Min = xScale.Max - 30;
            }


            // Tự động Scale theo trục y
            if (datanumber > yScale.Max - yScale.MajorStep)
            {
                yScale.Max = datanumber + yScale.MajorStep;
            }
            else if (datanumber < yScale.Min + yScale.MajorStep)
            {
                yScale.Min = datanumber - yScale.MajorStep;
            }

            zedGraphControl1.AxisChange();
            zedGraphControl1.Invalidate();
            zedGraphControl1.Refresh();
        }
Exemple #30
0
        // Vẽ đồ thị
        private void Draw()
        {
            LineItem curve = zGrphPlotData.GraphPane.CurveList[0] as LineItem;   //Khai báo đường cong từ danh sách đường cong đồ thị (kế thừa từ heap của dữ liệu ở Form_load)

            if (curve == null)
            {
                return;
            }
            LineItem curve2 = zGrphPlotData.GraphPane.CurveList[1] as LineItem;

            if (curve2 == null)
            {
                return;
            }
            IPointListEdit list = curve.Points as IPointListEdit;   //Khai báo danh sách dữ liệu cho đường cong đồ thị

            if (list == null)
            {
                return;
            }
            IPointListEdit list2 = curve2.Points as IPointListEdit;

            if (list2 == null)
            {
                return;
            }
            list.Add(realtime, setpoint);                        // Thêm điểm trên đồ thị
            list2.Add(realtime, measure);                        // Thêm điểm trên đồ thị

            Scale xScale = zGrphPlotData.GraphPane.XAxis.Scale;  //Giới hạn của đồ thị
            Scale yScale = zGrphPlotData.GraphPane.YAxis.Scale;

            if (enScroll == graphScroll.Scroll)
            {
                // Tự động Scale theo trục x
                if (realtime > xScale.Max - xScale.MajorStep)       //Nếu realtime lớn hơn Max x trừ đi 1 MajorStep (2 vạch lớn)
                {
                    xScale.Max = realtime + xScale.MajorStep;       //Tự dời đồ thị qua 1 MajorStep
                    xScale.Min = xScale.Max - 30;
                }
                // Tự động Scale theo trục y
                if (setpoint > yScale.Max - yScale.MajorStep)          //Nếu datas vượt quá giới hạn trừ 1 MajorStep
                {
                    yScale.Max = setpoint + yScale.MajorStep;          //Thì tăng giới hạn thêm 1 MajorStep
                }
                else if (setpoint < yScale.Min + yScale.MajorStep)
                {
                    yScale.Min = setpoint - yScale.MajorStep;
                }
                zGrphPlotData.AxisChange();                  //Thay đổi trục theo giá trị Scale
            }
            zGrphPlotData.Invalidate();                      //Mở khoá để và vẽ lại
        }
Exemple #31
0
        private PointPair updateCurve(IPointListEdit list, double t, double v)
        {
            PointPair temp = new PointPair();

            list.Add(t, v);

            temp.X = list[0].X;
            temp.Y = t;

            return temp;
            /*
            for (int j = ZedGraphControl1.GraphPane.CurveList[k].NPts - 1; j > 0; j--)
            {
                ZedGraphControl1.GraphPane.CurveList[k].Points[j].Y = ZedGraphControl1.GraphPane.CurveList[k].Points[j - 1].Y;
            }

            //RawTextBox.AppendText(temp.ToString() + "-" + k.ToString() + ", ");
            ZedGraphControl1.GraphPane.CurveList[k].Points[0].X = 0;
            ZedGraphControl1.GraphPane.CurveList[k].Points[0].Y = v;
             */
        }