Example #1
0
 private void BT_Yaxis_location_Click(object sender, EventArgs e)
 {
     if (VarClass.Manual)
     {
         double Location = Convert.ToDouble(text_Yaxis_location.Text);
         PublicClass.AxisMove(4, VarClass.ManualSpeed[4], Location);
     }
 }
Example #2
0
 private void BT_scan_location_Click(object sender, EventArgs e)    //扫码手动定位
 {
     if (VarClass.Manual)
     {
         double Location = Convert.ToDouble(textZ_Scan_location.Text);
         PublicClass.AxisMove(2, VarClass.ManualSpeed[2], Location);
     }
 }
Example #3
0
 private void BT_SmallZ_location_Click(object sender, EventArgs e)   //小Z轴手动定位
 {
     if (VarClass.Manual)
     {
         double Location = Convert.ToDouble(text_SmallZ_location.Text);
         PublicClass.AxisMove(1, VarClass.ManualSpeed[1], Location);
     }
 }
        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;
                }
                }
            }
        }
        public void HomeMove()
        {
            HomeStep = 1;
            while (HomeStep != 0)
            {
                switch (HomeStep)
                {
                case 1:
                {
                    myFrMain.Invoke((MethodInvoker) delegate
                        {
                            myFrMain.addLog("3个Z轴归零中", Color.Black);
                        });
Home1:
                    PublicClass.AxisHome(0, 0, 7, VarClass.Low_Wel[0], VarClass.High_Wel[0]);         //大Z轴归零
                    PublicClass.AxisHome(0, 1, 7, VarClass.Low_Wel[1], VarClass.High_Wel[1]);         //小Z轴归零
                    PublicClass.AxisHome(0, 2, 7, VarClass.Low_Wel[2], VarClass.High_Wel[2]);         //扫码轴归零

                    ushort BigZstate   = 99;
                    ushort SmallZstate = 99;
                    ushort ScanZstate  = 99;
                    Thread.Sleep(500);
                    while ((LTDMC.dmc_check_done(0, 0) == 0) || (BigZstate != 1) || (LTDMC.dmc_check_done(0, 1) == 0) || (SmallZstate != 1) || (LTDMC.dmc_check_done(0, 2) == 0) || (ScanZstate != 1))            //判断是否回零完
                    {
                        LTDMC.dmc_get_home_result(0, 0, ref BigZstate);
                        LTDMC.dmc_get_home_result(0, 1, ref SmallZstate);
                        LTDMC.dmc_get_home_result(0, 2, ref ScanZstate);


                        while (VarClass.Pause_Flag)
                        {
                            PublicClass.AxisStop(0, 0, 0);          //大Z轴停止
                            PublicClass.AxisStop(0, 1, 0);          //小Z轴停止
                            PublicClass.AxisStop(0, 2, 0);          //大Z轴停止
                            Thread.Sleep(5);
                            if (!VarClass.Pause_Flag)
                            {
                                goto Home1;
                            }
                        }
                    }
                    myFrMain.Invoke((MethodInvoker) delegate
                        {
                            myFrMain.addLog("3个Z轴归零完成,下一步小Z轴归零", Color.Black);
                        });
                    HomeStep = 3;
                    break;
                }



                case 3:
                {
Home3:
                    PublicClass.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);           //小Z轴停止

                            Thread.Sleep(5);
                            if (!VarClass.Pause_Flag)
                            {
                                goto Home3;
                            }
                        }
                    }
                    myFrMain.Invoke((MethodInvoker) delegate
                        {
                            myFrMain.addLog("小Z轴到达低位,下一步左右气缸出", Color.Black);
                        });
                    //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);
                        }
                    }
                    myFrMain.Invoke((MethodInvoker) delegate
                        {
                            myFrMain.addLog("左右气缸出完,下一步小Z轴跑位,扫码Z轴去扫码位", Color.Black);
                        });
                    HomeStep = 4;
                    break;
                }

                case 4:
                {
Home4:
                    Thread.Sleep(500);
                    PublicClass.AxisMove(1, VarClass.AutoSpeed[1], VarClass.SmallZ_Location[0]);           //小 Z轴跑高位
                                                                                                           //  PublicClass.AxisMove(2, VarClass.AutoSpeed[2], VarClass.ScanZ_Location[1]);   //扫码Z轴到扫描位
                    while ((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, 1, 0);           //小Z轴停止


                            Thread.Sleep(5);
                            if (!VarClass.Pause_Flag)
                            {
                                goto Home4;
                            }
                        }
                    }
                    myFrMain.Invoke((MethodInvoker) delegate
                        {
                            myFrMain.addLog("小Z轴到达高位;XY轴归零", Color.Black);
                        });
                    HomeStep = 5;
                    break;
                }

                case 5:
                {
Home5:
                    Thread.Sleep(500);
                    PublicClass.AxisHome(0, 3, 13, VarClass.Low_Wel[3], VarClass.High_Wel[3]);         //X轴归零
                    PublicClass.AxisHome(0, 4, 13, VarClass.Low_Wel[4], VarClass.High_Wel[4]);         //Y轴归零

                    ushort XAixsState = 99;
                    ushort YAixsState = 99;
                    Thread.Sleep(500);
                    while ((LTDMC.dmc_check_done(0, 3) == 0) || (XAixsState != 1) || (LTDMC.dmc_check_done(0, 4) == 0) || (YAixsState != 1))            //判断是否回零完
                    {
                        LTDMC.dmc_get_home_result(0, 3, ref XAixsState);
                        LTDMC.dmc_get_home_result(0, 4, ref YAixsState);

                        Thread.Sleep(10);

                        while (VarClass.Pause_Flag)
                        {
                            PublicClass.AxisStop(0, 3, 0);          //X轴停止
                            PublicClass.AxisStop(0, 4, 0);          //Y轴停止
                            Thread.Sleep(5);
                            if (!VarClass.Pause_Flag)
                            {
                                goto Home5;
                            }
                        }
                    }
                    myFrMain.Invoke((MethodInvoker) delegate
                        {
                            myFrMain.addLog("归零完成", Color.Black);
                        });
                    VarClass.Homeing    = false;       //归零标志
                    VarClass.HomeFinish = true;

                    HomeStep = 0;
                    break;
                }
                }
            }
        }