Ejemplo n.º 1
0
        /*Danh sách hàm tạo bởi Form*/
        private void Form1_Load(object sender, EventArgs e)
        {
            TexBTenfile.Text = "test";
            string[] portnames  = SerialPort.GetPortNames();
            int[]    PortNumber = new int[portnames.Length];
            for (int i = 0; i < portnames.Length; i++)
            {
                PortNumber[i] = int.Parse(portnames[i].Substring(3));
            }
            Array.Sort(PortNumber);
            foreach (int Number in PortNumber)
            {
                ComBPort.Items.Add("COM" + Number);
            }
            ComBBaud.Items.Add("9600");
            ComBBaud.Items.Add("14400");
            ComBBaud.Items.Add("19200");
            ComBBaud.Items.Add("56000");
            ComBBaud.Items.Add("115200");
            ComBchedo.Items.Add("Chỉ vẽ đồ thị");
            ComBchedo.Items.Add("Vẽ đồ thị và ghi file");
            ComBchedo.SelectedItem = "Chỉ vẽ đồ thị";
            // Array.Sort(portnames);
            //ComBPort.Items.AddRange(portnames);
            // Do Thi
            //ZedGraphGocQuay.GraphPane.Title.Text ="Đồ Thị Góc Quay";
            //ZedGraphGocQuay.GraphPane.XAxis.Title.Text = "Thời Gian, giây";
            //ZedGraphGocQuay.GraphPane.YAxis.Title.Text = "Góc Quay";
            ZedGraphGiaToc.GraphPane.Title.Text       = " Gia tốc, góc quay";
            ZedGraphGiaToc.GraphPane.XAxis.Title.Text = "Thời Gian (giây)";
            ZedGraphGiaToc.GraphPane.YAxis.Title.Text = "Gia tốc (g), góc quay (Rad)";

            LineItem Ax      = ZedGraphGiaToc.GraphPane.AddCurve("Roll x", List_Ax, Color.Blue, SymbolType.None);
            LineItem Ay      = ZedGraphGiaToc.GraphPane.AddCurve("Pitch y", List_Ay, Color.Red, SymbolType.None);
            LineItem Az      = ZedGraphGiaToc.GraphPane.AddCurve("Yaw z", List_Az, Color.Yellow, SymbolType.None);
            LineItem Roll_x  = ZedGraphGiaToc.GraphPane.AddCurve("Ax", List_Roll_x, Color.Violet, SymbolType.None);
            LineItem Pitch_y = ZedGraphGiaToc.GraphPane.AddCurve("Ay", List_Pitch_y, Color.Tomato, SymbolType.None);
            LineItem Yaw_z   = ZedGraphGiaToc.GraphPane.AddCurve("Az", List_Yaw_z, Color.Turquoise, SymbolType.None);

            ZedGraphGiaToc.IsShowPointValues               = false;
            ZedGraphGiaToc.GraphPane.XAxis.Scale.Min       = 0;
            ZedGraphGiaToc.GraphPane.XAxis.Scale.Max       = 10;
            ZedGraphGiaToc.GraphPane.YAxis.Scale.Min       = -3;
            ZedGraphGiaToc.GraphPane.YAxis.Scale.Max       = 3;
            ZedGraphGiaToc.GraphPane.XAxis.Scale.MinorStep = 1;
            //ZedGraphGiaToc.GraphPane.XAxis.Scale.MajorStep = 1;
            ZedGraphGiaToc.AxisChange();
            double k = -1.02345;
            string t = "-1.02345";
            double n = -0.22;

            n = Convert.ToDouble(t);
            //textBox1.Text = k.ToString();
            //textBox2.Text = n.ToString();
        }
Ejemplo n.º 2
0
        private void ClearZedGraph()
        {
            ZedGraphGiaToc.GraphPane.CurveList.Clear();    // Xóa đường
            ZedGraphGiaToc.GraphPane.GraphObjList.Clear(); // Xóa đối tượng

            ZedGraphGiaToc.AxisChange();
            ZedGraphGiaToc.Invalidate();

            GraphPane myPane = ZedGraphGiaToc.GraphPane;

            //myPane.Title.Text = "Đồ thị dữ liệu theo thời gian";
            //myPane.XAxis.Title.Text = "Thời gian (s)";
            //myPane.YAxis.Title.Text = "Dữ liệu";

            //RollingPointPairList list = new RollingPointPairList(60000);
            //LineItem curve = myPane.AddCurve("Dữ liệu", list, Color.Red, SymbolType.None);

            //myPane.XAxis.Scale.Min = 0;
            //myPane.XAxis.Scale.Max = 30;
            // myPane.XAxis.Scale.MinorStep = 1;
            //myPane.XAxis.Scale.MajorStep = 5;
            //myPane.YAxis.Scale.Min = -100;
            //myPane.YAxis.Scale.Max = 100;

            //ZedGraphGiaToc.AxisChange();

            myPane.Title.Text       = " Gia tốc, góc quay";
            myPane.XAxis.Title.Text = "Thời Gian, giây";
            myPane.YAxis.Title.Text = "Gia tốc,vân tốc góc, góc quay";
            List_Ax.Clear();
            List_Ay.Clear();
            List_Az.Clear();
            List_Roll_x.Clear();
            List_Pitch_y.Clear();
            List_Yaw_z.Clear();
            LineItem Ax      = myPane.AddCurve("Roll x", List_Ax, Color.Blue, SymbolType.None);
            LineItem Ay      = myPane.AddCurve("Pitch y", List_Ay, Color.Red, SymbolType.None);
            LineItem Az      = myPane.AddCurve("Yaw z", List_Az, Color.Yellow, SymbolType.None);
            LineItem Roll_x  = myPane.AddCurve("Ax", List_Roll_x, Color.Violet, SymbolType.None);
            LineItem Pitch_y = myPane.AddCurve("Ay", List_Pitch_y, Color.Tomato, SymbolType.None);
            LineItem Yaw_z   = myPane.AddCurve("Az", List_Yaw_z, Color.Turquoise, SymbolType.None);

            myPane.XAxis.Scale.Min       = 0;
            myPane.XAxis.Scale.Max       = 10;
            myPane.YAxis.Scale.Min       = -3;
            myPane.YAxis.Scale.Max       = 3;
            myPane.XAxis.Scale.MinorStep = 1;
            myPane.XAxis.Scale.MajorStep = 1;
            ZedGraphGiaToc.AxisChange();
        }