public void AutoMove()
        {
            AutoStep = 1;



            while (AutoStep != 0)
            {
                switch (AutoStep)
                {
                case 1:
                {
Auto1:
                    AxisMove(3, VarClass.AutoSpeed[3], VarClass.XAxis_Location[0]);           //X轴到换料位
                    AxisMove(4, VarClass.AutoSpeed[4], VarClass.YAxis_Location[0]);           //Y轴到换料位
                    //读取下标为3.4轴的运动状态
                    while ((LTDMC.dmc_check_done(0, 3) == 0) || (VarClass.XAxis_Location[0] != VarClass.Pulse_Current[3]) ||
                           (LTDMC.dmc_check_done(0, 4) == 0) || (VarClass.YAxis_Location[0] != VarClass.Pulse_Current[4]))
                    {
                        Thread.Sleep(5);
                        while (VarClass.Pause_Flag)
                        {
                            PublicClass.AxisStop(0, 3, 0);           //XAxis停止
                            PublicClass.AxisStop(0, 4, 0);           //YAxis轴停止

                            Thread.Sleep(5);
                            if (!VarClass.Pause_Flag)
                            {
                                goto Auto1;
                            }
                        }
                    }
                    if (VarClass.StopState == "outing")
                    {
                        VarClass.StopState = "outed";
                        myFrMain.Invoke((MethodInvoker) delegate
                            {
                                myFrMain.addLog("XY轴到换料位,下步点击进入按钮", Color.Black);
                            });
                    }
                    else
                    {
                        myFrMain.Invoke((MethodInvoker) delegate
                            {
                                myFrMain.addLog("XY轴到换料位,选择测试", Color.Black);
                            });
                    }
                    ///saoma
                    AutoStep = 2;
                    break;
                }

                case 2:
                {
                    while ((VarClass.TestNumber == 0) || (VarClass.StopState != ""))         //开始测试
                    {
                        Thread.Sleep(5);
                        while (VarClass.Pause_Flag)
                        {
                            Thread.Sleep(5);
                        }
                    }

                    myFrMain.Invoke((MethodInvoker) delegate
                        {
                            myFrMain.addLog("选择测试完成,下步双手启动", Color.Black);
                        });
                    while (!VarClass.ReadIN[0] || !VarClass.ReadIN[1])           //双手启动
                    {
                        VarClass.HandsStart = true;
                        Thread.Sleep(5);
                        while (VarClass.Pause_Flag)
                        {
                            Thread.Sleep(5);
                        }
                    }
                    VarClass.HandsStart = false;
                    while (!VarClass.ReadIN[5])           //接近感应器
                    {
                        MessageBox.Show("接近没有感应到");
                        Thread.Sleep(5);
                        while (VarClass.Pause_Flag)
                        {
                            Thread.Sleep(5);
                        }
                    }
                    myFrMain.Invoke((MethodInvoker) delegate
                        {
                            myFrMain.addLog("接近感应到,下步XY轴去扫码位", Color.Black);
                        });
Auto2:
                    AxisMove(3, VarClass.AutoSpeed[3], VarClass.XAxis_Location[1]);           //X轴到扫码位
                    AxisMove(4, VarClass.AutoSpeed[4], VarClass.YAxis_Location[1]);           //Y轴到扫码位
                    while ((LTDMC.dmc_check_done(0, 3) == 0) || (VarClass.XAxis_Location[1] != VarClass.Pulse_Current[3]) || (LTDMC.dmc_check_done(0, 4) == 0) || (VarClass.YAxis_Location[1] != VarClass.Pulse_Current[4]))
                    {
                        Thread.Sleep(5);
                        while (VarClass.Pause_Flag)
                        {
                            PublicClass.AxisStop(0, 3, 0);           //XAxis停止
                            PublicClass.AxisStop(0, 4, 0);           //YAxis轴停止

                            Thread.Sleep(5);
                            if (!VarClass.Pause_Flag)
                            {
                                goto Auto2;
                            }
                        }
                    }
                    myFrMain.Invoke((MethodInvoker) delegate
                        {
                            myFrMain.addLog("下步XY轴到扫码位,下步扫码Z轴去扫码位", Color.Black);
                        });
                    Auto50 : PublicClass.AxisMove(2, VarClass.AutoSpeed[2], VarClass.ScanZ_Location[1]);      //扫码Z轴到扫描位
                    while ((LTDMC.dmc_check_done(0, 2) == 0) || (VarClass.ScanZ_Location[1] != VarClass.Pulse_Current[2]))
                    {
                        Thread.Sleep(5);

                        while (VarClass.Pause_Flag)
                        {
                            PublicClass.AxisStop(0, 2, 0);           //扫码Z轴停止

                            Thread.Sleep(5);
                            if (!VarClass.Pause_Flag)
                            {
                                goto Auto50;
                            }
                        }
                    }



                    myFrMain.Invoke((MethodInvoker) delegate
                        {
                            myFrMain.addLog("扫码Z轴到扫码位,下步扫码", Color.Black);
                        });



                    while (!VarClass.IsScanOK)
                    {
                        VarClass.ClientString[1] = "";
                        // Scan.ClientSend1("T");
                        Scan.ClientSend3("T");

                        // Scan.ClientSend3("T");
                        Thread.Sleep(2000);
                        if ((VarClass.ClientString[2] != "NG") && (VarClass.ClientString[2] != ""))
                        {
                            string ScanString = HttpVar.barcode = VarClass.ClientString[2];


                            VarClass.IsScanOK = true;
                            myFrMain.Invoke((MethodInvoker) delegate
                                {
                                    myFrMain.addLog("扫码成功:" + HttpVar.barcode + ",下步XY去测料位", Color.Black);
                                });
                        }
                        else
                        {
                            MessageBox.Show("扫码失败");
                            myFrMain.Invoke((MethodInvoker) delegate
                                {
                                    myFrMain.addLog("扫码失败", Color.Black);
                                });
                        }
                    }
                    VarClass.IsScanOK = false;
                    AutoStep          = 3;
                    break;
                }

                case 3:
                {
Auto3:
                    AxisMove(3, VarClass.AutoSpeed[3], VarClass.XAxis_Location[2]);           //X轴到测料位
                    AxisMove(4, VarClass.AutoSpeed[4], VarClass.YAxis_Location[2]);           //Y轴到测料位
                    while ((LTDMC.dmc_check_done(0, 3) == 0) || (VarClass.XAxis_Location[2] != VarClass.Pulse_Current[3]) || (LTDMC.dmc_check_done(0, 3) == 0) || (VarClass.YAxis_Location[2] != VarClass.Pulse_Current[4]))
                    {
                        Thread.Sleep(5);
                        while (VarClass.Pause_Flag)
                        {
                            PublicClass.AxisStop(0, 3, 0);           //XAxis停止
                            PublicClass.AxisStop(0, 4, 0);           //YAxis轴停止

                            Thread.Sleep(5);
                            if (!VarClass.Pause_Flag)
                            {
                                goto Auto3;
                            }
                        }
                    }
                    myFrMain.Invoke((MethodInvoker) delegate
                        {
                            myFrMain.addLog("XY轴到测料位,下步大轴下", Color.Black);
                        });
                    AutoStep = 4;
                    break;
                }

                case 4:
                {
Auto4:
                    PublicClass.AxisJogMove(0, VarClass.AutoSpeed[0], 0); //大轴下,速度,方向

                    while (!VarClass.ReadIN[10])                          //对射光纤
                    {
                        Thread.Sleep(5);
                        while (VarClass.Pause_Flag)
                        {
                            PublicClass.AxisStop(0, 0, 0);           //XAxis停止


                            Thread.Sleep(5);
                            if (!VarClass.Pause_Flag)
                            {
                                goto Auto4;
                            }
                        }
                    }
                    PublicClass.AxisStop(0, 0, 0);           //XAxis停止

                    myFrMain.Invoke((MethodInvoker) delegate
                        {
                            myFrMain.addLog("大轴到位,下步左右气缸回", Color.Black);
                        });

                    //PublicClass.WriteOUT(0, 12, 1);//左气缸回
                    //PublicClass.WriteOUT(0, 13, 0);

                    AutoStep = 5;
                    break;
                }

                case 5:
                {
                    PublicClass.WriteOUT(0, 6, 1);                       //左右气缸回
                    PublicClass.WriteOUT(0, 7, 0);
                    while (!VarClass.ReadIN[14] || !VarClass.ReadIN[17]) //左,右气缸回限
                    {
                        Thread.Sleep(5);
                        while (VarClass.Pause_Flag)
                        {
                            Thread.Sleep(5);
                        }
                    }
                    Thread.Sleep(500);
                    myFrMain.Invoke((MethodInvoker) delegate
                        {
                            myFrMain.addLog("左,右气缸到回限,下步小Z轴下", Color.Black);
                        });
Auto5:
                    AxisMove(1, VarClass.AutoSpeed[1], VarClass.SmallZ_Location[1]);           //小Z轴下

                    while ((LTDMC.dmc_check_done(0, 1) == 0) || (VarClass.SmallZ_Location[1] != VarClass.Pulse_Current[1]))
                    {
                        Thread.Sleep(5);
                        while (VarClass.Pause_Flag)
                        {
                            PublicClass.AxisStop(0, 1, 0);           //XAxis停止


                            Thread.Sleep(5);
                            if (!VarClass.Pause_Flag)
                            {
                                goto Auto5;
                            }
                        }
                    }
                    VarClass.ImpactCurrentNum[VarClass.TestNumber - 1] = VarClass.ImpactCurrentNum[VarClass.TestNumber - 1] + 1;
                    myFrMain.Invoke((MethodInvoker) delegate
                        {
                            myFrMain.addLog("小轴到位,下步左右气缸出", Color.Black);
                        });
                    AutoStep = 10;
                    break;
                }

                case 10:
                {
                    //PublicClass.WriteOUT(0, 12, 0);//左气缸出
                    //PublicClass.WriteOUT(0, 13, 1);
                    PublicClass.WriteOUT(0, 6, 0);                       //左右气缸出
                    PublicClass.WriteOUT(0, 7, 1);
                    while (!VarClass.ReadIN[13] || !VarClass.ReadIN[16]) //左,右气缸出限
                    {
                        Thread.Sleep(5);
                        while (VarClass.Pause_Flag)
                        {
                            Thread.Sleep(5);
                        }
                    }

                    if ((VarClass.ImpactCurrentNum[VarClass.TestNumber - 1] < Convert.ToInt32(VarClass.Excel_specificationsNum[VarClass.TestNumber - 1])) && VarClass.StopState != "outing")
                    {
                        myFrMain.Invoke((MethodInvoker) delegate
                            {
                                myFrMain.addLog("左,右气缸到出限,下步小Z轴上", Color.Black);
                            });
Auto10:
                        AxisMove(1, VarClass.AutoSpeed[1], VarClass.SmallZ_Location[0]);           //小Z轴到上位
                        while ((LTDMC.dmc_check_done(0, 1) == 0) || (VarClass.SmallZ_Location[0] != VarClass.Pulse_Current[1]))
                        {
                            while (VarClass.Pause_Flag)
                            {
                                PublicClass.AxisStop(0, 1, 0);           //XIAOZ轴轴停止

                                Thread.Sleep(5);
                                if (!VarClass.Pause_Flag)
                                {
                                    goto Auto10;
                                }
                            }
                        }

                        AutoStep = 5;
                        break;
                    }
                    else
                    {
                        myFrMain.Invoke((MethodInvoker) delegate
                            {
                                myFrMain.addLog("左,右气缸到出限,下步大小Z轴上", Color.Black);
                            });
                        //  VarClass.ImpactCurrentNum[VarClass.TestNum-1] = 0;
                        AutoStep = 6;
                        break;
                    }
                }

                case 6:
                {
Auto6:
                    AxisMove(0, VarClass.AutoSpeed[0], VarClass.BigZ_Location[0]);           //大Z轴到上位
                    AxisMove(1, VarClass.AutoSpeed[1], VarClass.SmallZ_Location[0]);         //小Z轴到上位
                    while ((LTDMC.dmc_check_done(0, 0) == 0) || (VarClass.BigZ_Location[0] != VarClass.Pulse_Current[0]) || (LTDMC.dmc_check_done(0, 1) == 0) || (VarClass.SmallZ_Location[0] != VarClass.Pulse_Current[1]))
                    {
                        Thread.Sleep(5);
                        while (VarClass.Pause_Flag)
                        {
                            PublicClass.AxisStop(0, 0, 0);           //大Z轴停止
                            PublicClass.AxisStop(0, 1, 0);           //大Z轴轴停止

                            Thread.Sleep(5);
                            if (!VarClass.Pause_Flag)
                            {
                                goto Auto6;
                            }
                        }
                    }

                    if (VarClass.StopState == "outing")
                    {
                    }
                    else

                    {
                        HttpVar.end_time[VarClass.TestNumber - 1] = (DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")).ToString();
                        VarClass.TestEnd[VarClass.TestNumber - 1] = true;        //测试完成
                        VarClass.Testing = false;
                    }


                    myFrMain.Invoke((MethodInvoker) delegate
                        {
                            myFrMain.addLog("大小轴到位,下步XY轴到换料位", Color.Black);
                        });
                    AutoStep = 1;
                    break;
                }
                }
            }
        }