Ejemplo n.º 1
0
        private void start_Click(object sender, EventArgs e)
        {
            bicycle_num             = this.bicycle_num_input.Text;
            mysql                   = new Mysql();
            this.redPoint.Parent    = this.bicycle_img;
            this.redPoint.BackColor = Color.Transparent;
            for (int i = 1; i < RxStringArray.Length; i++)
            {
                xyzStringArray    = RxStringArray[i].Split(',');
                redPoint.Location = red[i];
                redPoint.Image    = Properties.Resources.紅點;
                redPoint.Size     = new Size(37, 37);
                redPoint.SizeMode = PictureBoxSizeMode.StretchImage;
                Ax = Convert.ToSingle(xyzStringArray[1]);
                Ay = Convert.ToSingle(xyzStringArray[2]);
                Az = Convert.ToSingle(xyzStringArray[3]);
                Bx = Convert.ToSingle(xyzStringArray[4]);
                By = Convert.ToSingle(xyzStringArray[5]);
                Bz = Convert.ToSingle(xyzStringArray[6]);
                Cx = Convert.ToSingle(xyzStringArray[7]);
                Cy = Convert.ToSingle(xyzStringArray[8]);
                Cz = Convert.ToSingle(xyzStringArray[9]);

                bicycle = new Coordinate_calculation(Ax, Ay, Az, Bx, By, Bz, Cx, Cy, Cz);
                Vector3 a = new Vector3(0.0f, -41.5f, 0.0f);
                Vector3 b = new Vector3(489.7286f, -5f, 468.5091f);
                double  bbbb;
                bbbb = Math.Acos(bicycle.get_Vectical(a, b)) * 180 / Math.PI;//向量垂直度運算
                MessageBox.Show(bbbb.ToString());

                switch (xyzStringArray[0])
                {
                case "1":
                    point1_r.Text      = "半徑:" + bicycle.get_radius().ToString();
                    point1_center.Text = "圓心:(" + bicycle.get_center().X.ToString() + "," + bicycle.get_center().Y.ToString() + "," + bicycle.get_center().Z.ToString() + ")";
                    readTextBox.AppendText("量測點 :(" + xyzStringArray[0].ToString() + ")" + "\n");
                    readTextBox.AppendText("中心點座標 :(" + bicycle.get_center().X.ToString() + "," + bicycle.get_center().Y.ToString() + "," + bicycle.get_center().Z.ToString() + ")" + "\n");
                    readTextBox.AppendText("半徑r : " + bicycle.get_radius().ToString() + "\n");
                    //c1_Axle_Center = bicycle.get_center().X.ToString() + "," + bicycle.get_center().Y.ToString() + "," + bicycle.get_center().Z.ToString();
                    //c1_Axle_r = bicycle.get_radius().ToString();
                    Axle[0] = bicycle.get_center().X.ToString() + "," + bicycle.get_center().Y.ToString() + "," + bicycle.get_center().Z.ToString();
                    Axle[1] = bicycle.get_radius().ToString();

                    break;

                case "2":
                    point2_r.Text      = "半徑:" + bicycle.get_radius().ToString();
                    point2_center.Text = "圓心:(" + bicycle.get_center().X.ToString() + "," + bicycle.get_center().Y.ToString() + "," + bicycle.get_center().Z.ToString() + ")";
                    readTextBox.AppendText("量測點 :(" + xyzStringArray[0].ToString() + ")" + "\n");
                    readTextBox.AppendText("中心點座標 :(" + bicycle.get_center().X.ToString() + "," + bicycle.get_center().Y.ToString() + "," + bicycle.get_center().Z.ToString() + ")" + "\n");
                    readTextBox.AppendText("半徑r : " + bicycle.get_radius().ToString() + "\n");
                    //d1_Axle_Center = bicycle.get_center().X.ToString() + "," + bicycle.get_center().Y.ToString() + "," + bicycle.get_center().Z.ToString();
                    //d1_Axle_r = bicycle.get_radius().ToString();
                    Axle[2] = bicycle.get_center().X.ToString() + "," + bicycle.get_center().Y.ToString() + "," + bicycle.get_center().Z.ToString();
                    Axle[3] = bicycle.get_radius().ToString();

                    break;

                case "3":
                    point3_r.Text      = "半徑:" + bicycle.get_radius().ToString();
                    point3_center.Text = "圓心:(" + bicycle.get_center().X.ToString() + "," + bicycle.get_center().Y.ToString() + "," + bicycle.get_center().Z.ToString() + ")";
                    readTextBox.AppendText("量測點 :(" + xyzStringArray[0].ToString() + ")" + "\n");
                    readTextBox.AppendText("中心點座標 :(" + bicycle.get_center().X.ToString() + "," + bicycle.get_center().Y.ToString() + "," + bicycle.get_center().Z.ToString() + ")" + "\n");
                    readTextBox.AppendText("半徑r : " + bicycle.get_radius().ToString() + "\n");
                    //b1_Axle_Center = bicycle.get_center().X.ToString() + "," + bicycle.get_center().Y.ToString() + "," + bicycle.get_center().Z.ToString();
                    //b1_Axle_r = bicycle.get_radius().ToString();
                    Axle[4] = bicycle.get_center().X.ToString() + "," + bicycle.get_center().Y.ToString() + "," + bicycle.get_center().Z.ToString();
                    Axle[5] = bicycle.get_radius().ToString();

                    break;

                case "4":
                    point4_r.Text      = "半徑:" + bicycle.get_radius().ToString();
                    point4_center.Text = "圓心:(" + bicycle.get_center().X.ToString() + "," + bicycle.get_center().Y.ToString() + "," + bicycle.get_center().Z.ToString() + ")";
                    readTextBox.AppendText("量測點 :(" + xyzStringArray[0].ToString() + ")" + "\n");
                    readTextBox.AppendText("中心點座標 :(" + bicycle.get_center().X.ToString() + "," + bicycle.get_center().Y.ToString() + "," + bicycle.get_center().Z.ToString() + ")" + "\n");
                    readTextBox.AppendText("半徑r : " + bicycle.get_radius().ToString() + "\n");
                    //f1_Axle_Center = bicycle.get_center().X.ToString() + "," + bicycle.get_center().Y.ToString() + "," + bicycle.get_center().Z.ToString();
                    //f1_Axle_r = bicycle.get_radius().ToString();
                    Axle[6] = bicycle.get_center().X.ToString() + "," + bicycle.get_center().Y.ToString() + "," + bicycle.get_center().Z.ToString();
                    Axle[7] = bicycle.get_radius().ToString();

                    break;

                case "5":
                    point5_r.Text      = "半徑:" + bicycle.get_radius().ToString();
                    point5_center.Text = "圓心:(" + bicycle.get_center().X.ToString() + "," + bicycle.get_center().Y.ToString() + "," + bicycle.get_center().Z.ToString() + ")";
                    readTextBox.AppendText("量測點 :(" + xyzStringArray[0].ToString() + ")" + "\n");
                    readTextBox.AppendText("中心點座標 :(" + bicycle.get_center().X.ToString() + "," + bicycle.get_center().Y.ToString() + "," + bicycle.get_center().Z.ToString() + ")" + "\n");
                    readTextBox.AppendText("半徑r : " + bicycle.get_radius().ToString() + "\n");
                    //f2_Axle_Center = bicycle.get_center().X.ToString() + "," + bicycle.get_center().Y.ToString() + "," + bicycle.get_center().Z.ToString();
                    //f2_Axle_r = bicycle.get_radius().ToString();
                    Axle[8] = bicycle.get_center().X.ToString() + "," + bicycle.get_center().Y.ToString() + "," + bicycle.get_center().Z.ToString();
                    Axle[9] = bicycle.get_radius().ToString();

                    break;
                }
            }

            /*
             * string q = "INSERT INTO a( `c1_Axle_Center`, `c1_Axle_r`, `d1_Axle_Center`, `d1_Axle_r`, `b1_Axle_Center`, `b1_Axle_r`, `f1_Axle_Center`, `f1_Axle_r`, `f2_Axle_Center`, `f2_Axle_r`, `c2_Axle_Center`, `c2_Axle_r`, `d2_Axle_Center`, `d2_Axle_r`, `b2_Axle_Center`, `b2_Axle_r`, `流水號`) " +
             *  "VALUES("+ c1_Axle_Center + c2_Axle_Center+ c1_Axle_r + c2_Axle_r + d1_Axle_Center + d2_Axle_Center + d1_Axle_r + d2_Axle_r + b1_Axle_Center + b2_Axle_Center + b1_Axle_r + b2_Axle_r + f1_Axle_Center+ f2_Axle_Center +f1_Axle_r +f2_Axle_r + bicycle_num+")";
             * mysql.mysql_Insert(q);
             */

            mysql.mysql_Insert(Axle, bicycle_num);

            //清空Array
            Array.Clear(Axle, 0, Axle.Length);
        }
Ejemplo n.º 2
0
        private void s1_DataReceived(object s, EventArgs e)
        {
            //redPoint指Form1紅點照片物件
            //bicycle_img指Form1車架照片

            try
            {
                switch (xyzStringArray[0])
                {
                case "1":

                    redPoint.Location = red[1];
                    redPoint.Image    = Properties.Resources.紅點;
                    redPoint.Size     = new Size(37, 37);
                    // StretchImage 值會將影像放大或縮小為PictureBox Size大小
                    redPoint.SizeMode = PictureBoxSizeMode.StretchImage;

                    Ax = Convert.ToSingle(xyzStringArray[1]);
                    Ay = Convert.ToSingle(xyzStringArray[2]);
                    Az = Convert.ToSingle(xyzStringArray[3]);
                    Bx = Convert.ToSingle(xyzStringArray[4]);
                    By = Convert.ToSingle(xyzStringArray[5]);
                    Bz = Convert.ToSingle(xyzStringArray[6]);
                    Cx = Convert.ToSingle(xyzStringArray[7]);
                    Cy = Convert.ToSingle(xyzStringArray[8]);
                    Cz = Convert.ToSingle(xyzStringArray[9]);


                    bicycle = new Coordinate_calculation(Ax, Ay, Az, Bx, By, Bz, Cx, Cy, Cz);
                    readTextBox.AppendText("量測點 :(" + xyzStringArray[0].ToString() + ")" + "\n");
                    readTextBox.AppendText("中心點座標 :(" + bicycle.get_center().X.ToString() + "," + bicycle.get_center().Y.ToString() + "," + bicycle.get_center().Z.ToString() + ")" + "\n");
                    readTextBox.AppendText("半徑r : " + bicycle.get_radius().ToString() + "\n");

                    point1_r.Text      = "半徑:" + bicycle.get_radius().ToString();
                    point1_center.Text = "圓心:(" + bicycle.get_center().X.ToString() + "," + bicycle.get_center().Y.ToString() + "," + bicycle.get_center().Z.ToString() + ")";
                    //serialPORT1.DiscardInBuffer();
                    break;

                case "2":
                    redPoint.Location = red[2];
                    redPoint.Image    = Properties.Resources.紅點;
                    redPoint.Size     = new Size(37, 37);
                    redPoint.SizeMode = PictureBoxSizeMode.StretchImage;

                    Ax = Convert.ToSingle(xyzStringArray[1]);
                    Ay = Convert.ToSingle(xyzStringArray[2]);
                    Az = Convert.ToSingle(xyzStringArray[3]);
                    Bx = Convert.ToSingle(xyzStringArray[4]);
                    By = Convert.ToSingle(xyzStringArray[5]);
                    Bz = Convert.ToSingle(xyzStringArray[6]);
                    Cx = Convert.ToSingle(xyzStringArray[7]);
                    Cy = Convert.ToSingle(xyzStringArray[8]);
                    Cz = Convert.ToSingle(xyzStringArray[9]);

                    bicycle = new Coordinate_calculation(Ax, Ay, Az, Bx, By, Bz, Cx, Cy, Cz);
                    readTextBox.AppendText("量測點 :(" + xyzStringArray[0].ToString() + ")" + "\n");
                    readTextBox.AppendText("中心點座標 :(" + bicycle.get_center().X.ToString() + "," + bicycle.get_center().Y.ToString() + "," + bicycle.get_center().Z.ToString() + ")" + "\n");
                    readTextBox.AppendText("半徑r : " + bicycle.get_radius().ToString() + "\n");

                    point2_r.Text      = bicycle.get_radius().ToString();
                    point2_center.Text = "(" + bicycle.get_center().X.ToString() + "," + bicycle.get_center().Y.ToString() + "," + bicycle.get_center().Z.ToString() + ")";
                    //serialPORT1.DiscardInBuffer();
                    break;

                case "3":
                    redPoint.Location = red[3];
                    redPoint.Image    = Properties.Resources.紅點;
                    redPoint.Size     = new Size(37, 37);
                    redPoint.SizeMode = PictureBoxSizeMode.StretchImage;

                    Ax = Convert.ToSingle(xyzStringArray[1]);
                    Ay = Convert.ToSingle(xyzStringArray[2]);
                    Az = Convert.ToSingle(xyzStringArray[3]);
                    Bx = Convert.ToSingle(xyzStringArray[4]);
                    By = Convert.ToSingle(xyzStringArray[5]);
                    Bz = Convert.ToSingle(xyzStringArray[6]);
                    Cx = Convert.ToSingle(xyzStringArray[7]);
                    Cy = Convert.ToSingle(xyzStringArray[8]);
                    Cz = Convert.ToSingle(xyzStringArray[9]);

                    bicycle = new Coordinate_calculation(Ax, Ay, Az, Bx, By, Bz, Cx, Cy, Cz);
                    readTextBox.AppendText("量測點 :(" + xyzStringArray[0].ToString() + ")" + "\n");
                    readTextBox.AppendText("中心點座標 :(" + bicycle.get_center().X.ToString() + "," + bicycle.get_center().Y.ToString() + "," + bicycle.get_center().Z.ToString() + ")" + "\n");
                    readTextBox.AppendText("半徑r : " + bicycle.get_radius().ToString() + "\n");

                    point3_r.Text      = bicycle.get_radius().ToString();
                    point3_center.Text = "(" + bicycle.get_center().X.ToString() + "," + bicycle.get_center().Y.ToString() + "," + bicycle.get_center().Z.ToString() + ")";
                    //serialPORT1.DiscardInBuffer();
                    break;

                case "4":
                    redPoint.Location = red[4];
                    redPoint.Image    = Properties.Resources.紅點;
                    redPoint.Size     = new Size(37, 37);
                    redPoint.SizeMode = PictureBoxSizeMode.StretchImage;

                    Ax = Convert.ToSingle(xyzStringArray[1]);
                    Ay = Convert.ToSingle(xyzStringArray[2]);
                    Az = Convert.ToSingle(xyzStringArray[3]);
                    Bx = Convert.ToSingle(xyzStringArray[4]);
                    By = Convert.ToSingle(xyzStringArray[5]);
                    Bz = Convert.ToSingle(xyzStringArray[6]);
                    Cx = Convert.ToSingle(xyzStringArray[7]);
                    Cy = Convert.ToSingle(xyzStringArray[8]);
                    Cz = Convert.ToSingle(xyzStringArray[9]);

                    bicycle = new Coordinate_calculation(Ax, Ay, Az, Bx, By, Bz, Cx, Cy, Cz);
                    readTextBox.AppendText("量測點 :(" + xyzStringArray[0].ToString() + ")" + "\n");
                    readTextBox.AppendText("中心點座標 :(" + bicycle.get_center().X.ToString() + "," + bicycle.get_center().Y.ToString() + "," + bicycle.get_center().Z.ToString() + ")" + "\n");
                    readTextBox.AppendText("半徑r : " + bicycle.get_radius().ToString() + "\n");

                    point4_r.Text      = bicycle.get_radius().ToString();
                    point4_center.Text = "(" + bicycle.get_center().X.ToString() + "," + bicycle.get_center().Y.ToString() + "," + bicycle.get_center().Z.ToString() + ")";
                    //serialPORT1.DiscardInBuffer();
                    break;

                case "5":
                    redPoint.Location = red[5];
                    redPoint.Image    = Properties.Resources.紅點;
                    redPoint.Size     = new Size(37, 37);
                    redPoint.SizeMode = PictureBoxSizeMode.StretchImage;

                    Ax = Convert.ToSingle(xyzStringArray[1]);
                    Ay = Convert.ToSingle(xyzStringArray[2]);
                    Az = Convert.ToSingle(xyzStringArray[3]);
                    Bx = Convert.ToSingle(xyzStringArray[4]);
                    By = Convert.ToSingle(xyzStringArray[5]);
                    Bz = Convert.ToSingle(xyzStringArray[6]);
                    Cx = Convert.ToSingle(xyzStringArray[7]);
                    Cy = Convert.ToSingle(xyzStringArray[8]);
                    Cz = Convert.ToSingle(xyzStringArray[9]);

                    bicycle = new Coordinate_calculation(Ax, Ay, Az, Bx, By, Bz, Cx, Cy, Cz);
                    readTextBox.AppendText("量測點 :(" + xyzStringArray[0].ToString() + ")" + "\n");
                    readTextBox.AppendText("中心點座標 :(" + bicycle.get_center().X.ToString() + "," + bicycle.get_center().Y.ToString() + "," + bicycle.get_center().Z.ToString() + ")" + "\n");
                    readTextBox.AppendText("半徑r : " + bicycle.get_radius().ToString() + "\n");

                    point5_r.Text      = bicycle.get_radius().ToString();
                    point5_center.Text = "(" + bicycle.get_center().X.ToString() + "," + bicycle.get_center().Y.ToString() + "," + bicycle.get_center().Z.ToString() + ")";
                    //serialPORT1.DiscardInBuffer();
                    break;

                case "6":
                    redPoint.Location = red[6];
                    redPoint.Image    = Properties.Resources.紅點;
                    redPoint.Size     = new Size(37, 37);
                    redPoint.SizeMode = PictureBoxSizeMode.StretchImage;

                    Ax = Convert.ToSingle(xyzStringArray[1]);
                    Ay = Convert.ToSingle(xyzStringArray[2]);
                    Az = Convert.ToSingle(xyzStringArray[3]);
                    Bx = Convert.ToSingle(xyzStringArray[4]);
                    By = Convert.ToSingle(xyzStringArray[5]);
                    Bz = Convert.ToSingle(xyzStringArray[6]);
                    Cx = Convert.ToSingle(xyzStringArray[7]);
                    Cy = Convert.ToSingle(xyzStringArray[8]);
                    Cz = Convert.ToSingle(xyzStringArray[9]);

                    bicycle = new Coordinate_calculation(Ax, Ay, Az, Bx, By, Bz, Cx, Cy, Cz);
                    readTextBox.AppendText("量測點 :(" + xyzStringArray[0].ToString() + ")" + "\n");
                    readTextBox.AppendText("中心點座標 :(" + bicycle.get_center().X.ToString() + "," + bicycle.get_center().Y.ToString() + "," + bicycle.get_center().Z.ToString() + ")" + "\n");
                    readTextBox.AppendText("半徑r : " + bicycle.get_radius().ToString() + "\n");

                    //serialPORT1.DiscardInBuffer();
                    break;

                case "7":
                    redPoint.Location = red[7];
                    redPoint.Image    = Properties.Resources.紅點;
                    redPoint.Size     = new Size(37, 37);
                    redPoint.SizeMode = PictureBoxSizeMode.StretchImage;

                    Ax = Convert.ToSingle(xyzStringArray[1]);
                    Ay = Convert.ToSingle(xyzStringArray[2]);
                    Az = Convert.ToSingle(xyzStringArray[3]);
                    Bx = Convert.ToSingle(xyzStringArray[4]);
                    By = Convert.ToSingle(xyzStringArray[5]);
                    Bz = Convert.ToSingle(xyzStringArray[6]);
                    Cx = Convert.ToSingle(xyzStringArray[7]);
                    Cy = Convert.ToSingle(xyzStringArray[8]);
                    Cz = Convert.ToSingle(xyzStringArray[9]);

                    bicycle = new Coordinate_calculation(Ax, Ay, Az, Bx, By, Bz, Cx, Cy, Cz);
                    readTextBox.AppendText("量測點 :(" + xyzStringArray[0].ToString() + ")" + "\n");
                    readTextBox.AppendText("中心點座標 :(" + bicycle.get_center().X.ToString() + "," + bicycle.get_center().Y.ToString() + "," + bicycle.get_center().Z.ToString() + ")" + "\n");
                    readTextBox.AppendText("半徑r : " + bicycle.get_radius().ToString() + "\n");

                    //serialPORT1.DiscardInBuffer();
                    break;

                case "8":

                    redPoint.Location = red[8];
                    redPoint.Image    = Properties.Resources.紅點;
                    redPoint.Size     = new Size(37, 37);
                    redPoint.SizeMode = PictureBoxSizeMode.StretchImage;

                    Ax = Convert.ToSingle(xyzStringArray[1]);
                    Ay = Convert.ToSingle(xyzStringArray[2]);
                    Az = Convert.ToSingle(xyzStringArray[3]);
                    Bx = Convert.ToSingle(xyzStringArray[4]);
                    By = Convert.ToSingle(xyzStringArray[5]);
                    Bz = Convert.ToSingle(xyzStringArray[6]);
                    Cx = Convert.ToSingle(xyzStringArray[7]);
                    Cy = Convert.ToSingle(xyzStringArray[8]);
                    Cz = Convert.ToSingle(xyzStringArray[9]);

                    bicycle = new Coordinate_calculation(Ax, Ay, Az, Bx, By, Bz, Cx, Cy, Cz);
                    readTextBox.AppendText("量測點 :(" + xyzStringArray[0].ToString() + ")" + "\n");
                    readTextBox.AppendText("中心點座標 :(" + bicycle.get_center().X.ToString() + "," + bicycle.get_center().Y.ToString() + "," + bicycle.get_center().Z.ToString() + ")" + "\n");
                    readTextBox.AppendText("半徑r : " + bicycle.get_radius().ToString() + "\n");

                    //serialPORT1.DiscardInBuffer();
                    break;
                }
            }
            catch (Exception epp)
            {
                MessageBox.Show(epp.ToString());
            }
        }