Beispiel #1
0
        private void AutoRun()
        {
            #region Swithch
            switch (AutoRunstep)
            {
            case 10:
                if (PVar.AutoRunFlag)
                {
                    StopWatch_Stop();
                    StopWatch_Reset();
                    AutoRunstep = 20;
                }
                break;

            case 20:    //double start
                if (Globals.Flag_ManualStart || Double_Hands_Start(1000, false))
                {
                    Globals.Flag_ManualStart = false;
                    Double_Hands_Start(1000, true);
                    SetStep("CLEAR", Mycolor.None);
                    SetStep("手动启动或双手启动开始", Mycolor.None);
                    TaskIsWorking = true;
                    StopWatch_Start();
                    AutoRunstep = 25;
                }
                break;

            case 25:
                if (Globals.settingFunc.启用空跑模式)      //空跑不需要条码
                {
                    AutoRunstep = 40;
                }
                else
                {
                    AutoRunstep = 30;
                }
                break;

            case 30:    //check the product sensor and check the fixtrue closed sensor
                if (Gg.GetDi(0, Gg.InPutMMS0.夹具到位金属感应器) == 0)
                {
                    SetStep("夹具到位金属感应器感应异常", Mycolor.ErrorRed);
                    PVar.Ring_EN = true;    //buzzer
                    AutoRunstep  = 8000;
                    break;
                }
                if (Gg.GetDi(0, Gg.InPutMMS0.产品到位光纤感应器) == 0)
                {
                    SetStep("产品到位光纤感应器感应异常", Mycolor.ErrorRed);
                    PVar.Ring_EN = true;    //buzzer
                    AutoRunstep  = 8000;
                    break;
                }
                AutoRunstep = 40;
                break;

            case 40:    //check postion
                if ((Gg.GetEncPosmm(0, BVar.MMSY) - mFunction.Pos.TeachAxis1[0, 0]) > 0.05)
                {
                    SetStep("载具不在初始位置!请回零!", Mycolor.ErrorRed);
                    PVar.Ring_EN = true;    //buzzer
                    AutoRunstep  = 8000;
                    break;
                }
                AutoRunstep = 50;
                break;

            case 45:
                if (Gg.GetDi(0, Gg.InPutMMS0.安全光幕) == 1)
                {
                    SetStep("安全光幕异常", Mycolor.ErrorRed);
                    PVar.Ring_EN = true;    //buzzer
                    AutoRunstep  = 8000;
                    break;
                }
                AutoRunstep = 50;
                break;

            case 50:                            //check barcode
                if (Globals.settingFunc.启用空跑模式) //空跑不需要条码
                {
                    AutoRunstep = 80; break;
                }
                if (PageLogin.loginTp != loginType.Op)
                {
                    if ((Globals.BarcodeSN.Length >= Globals.settingPara.学习条码长度.Length - 2 || Globals.BarcodeSN.Length >= Globals.settingPara.学习条码长度.Length + 2))
                    {
                        SetStep("条码长度OK!", Mycolor.None);
                        DataManager.Instance.CurrentCheckData.SN = Globals.BarcodeSN;
                    }
                    else
                    {
                        SetStep("生成时间条码!", Mycolor.None);
                        DataManager.Instance.CurrentCheckData.SN = DateTime.Now.ToString("yyyMMdd_HHmmss");
                    }
                    TimeOut     = API.GetTickCount();
                    AutoRunstep = 80;
                }
                else    //op
                {
                    if ((Globals.BarcodeSN.Length >= Globals.settingPara.学习条码长度.Length - 5 ||
                         Globals.BarcodeSN.Length >= Globals.settingPara.学习条码长度.Length + 5))  //OP mode ,need check the length of barcode
                    {
                        SetStep("条码长度OK!", Mycolor.None);
                        PVar.Ring_EN = true;    //buzzer
                        DataManager.Instance.CurrentCheckData.SN = Globals.BarcodeSN;
                        TimeOut     = API.GetTickCount();
                        AutoRunstep = 80;
                    }
                    else
                    {
                        SetStep("条码长度异常!", Mycolor.ErrorRed);
                        DataManager.Instance.CurrentCheckData.SN = "";
                        if (OnEngineerSN != null)
                        {
                            OnEngineerSN("");                          //让工程界面的clear SN, foucs on
                        }
                        AutoRunstep = 8000;
                    }
                }
                break;

            case 80:
                if (OnShowSth_OnSSH_Output != null)
                {
                    OnShowSth_OnSSH_Output("");                                    //clear SSHinfo
                }
                if (OnEngineerSN != null)
                {
                    OnEngineerSN("");                          //让工程界面的clear SN, foucs on
                }
                Globals.BarcodeSN = "";

                if (Globals.settingFunc.启用空跑模式)
                {
                    StopWatch_Reset();
                    StopWatch_Start();
                    SetStep("CLEAR", Mycolor.None);
                }
                StationRunMode _runmode = Globals.settingFunc.启用空跑模式 ? StationRunMode.空跑 : StationRunMode.自动运行;
                if (Globals.settingMachineInfo.什么机器 == WhichMachine.MMS)
                {
                    XTaskManager.Instance.FindTaskById((int)TasksId.MMS测试).TaskGo();
                }
                else
                {
                    XTaskManager.Instance.FindTaskById((int)TasksId.测试).TaskGo();
                }
                SetStep("每站自动开始", Mycolor.None);
                TimeOut     = API.GetTickCount();
                AutoRunstep = 90;
                break;

            case 90:
                if (Globals.settingMachineInfo.什么机器 == WhichMachine.MMS)
                {
                    if (XTaskManager.Instance.FindTaskById((int)TasksId.MMS测试).TaskIsWorking == false)
                    {
                        SetStep("自动单循环完成", Mycolor.None);
                        AutoRunstep = 100;
                    }
                }
                else
                {
                    if (XTaskManager.Instance.FindTaskById((int)TasksId.测试).TaskIsWorking == false)
                    {
                        SetStep("自动单循环完成", Mycolor.None);
                        AutoRunstep = 100;
                    }
                }

                if (API.GetTickCount() - TimeOut > 60000)
                {
                    SetStep("自动超时60S,退出主循环!!", Mycolor.ErrorRed);
                    AutoRunstep = 8000;
                }
                break;

            case 100:
                StopWatch_Stop();
                TaskIsWorking = false;
                AutoRunstep   = 10;  //正常结束
                if (Globals.settingFunc.启用空跑模式)
                {
                    SetStep("空跑模式,继续", Mycolor.ErrorRed);
                    Thread.Sleep(1000);
                    AutoRunstep = 80;
                    if (StaStop)    //如果点了停止按钮,把当前的Cycle完成
                    {
                        SetStep("停止中......", Mycolor.ErrorRed);
                        Globals.Flag_ManualStart = false;
                        StaStop     = false;
                        AutoRunstep = 10;
                    }
                }
                break;

            case 8000:
                StopWatch_Stop();
                TaskIsWorking = false;
                AutoRunstep   = 10;
                break;
            }
            SetStepNum(AutoRunstep);
            Task_StopWatchElapsedMilliseconds();//获取CT
            #endregion
        }