Ejemplo n.º 1
0
 public static bool EmergencyStop()
 {
     try
     {
         Globals.LedCmd.Cmd = Globals.DevData.EmgLedCmd.Cmd;
         ReportCmdKeyProgress(CmdKey.S0093);
         bool flag = X_Axis.JogStop();
         flag       &= Y_Axis.JogStop();
         flag       &= T_Axis.JogStop();
         flag       &= Z_Axis.JogStop();
         flag       &= Z_Axis.AxisJogAbsWork(Globals.MacData.ZStartPos);
         Globals.EMG = false;
         return(flag);
     }
     catch
     {
         Common.ReportCmdKeyProgress(CmdKey.S0091);
         return(false);
     }
 }
Ejemplo n.º 2
0
        public static bool RunLineCut(CutLine line, bool preCut = false)
        {
            do
            {
                switch (line.CutStep)
                {
                case CutStep.Ready:                                                            //等待各轴移动到位
                {
                    if (line.SinDir || !line.Dual || (line.Dual && Globals.DevData.DualZlife)) //如果为单项划切或者必须返回
                    {
                        Z_Axis.AxisJogAbsWork(line.SelfPos);                                   //划切一刀 必须Z轴上升到安全位
                    }
                    if (WaitAxisMoveDone())                                                    //判断各轴是否到位
                    {
                        line.Cutting  = true;                                                  //开始切割
                        line.FirstCut = true;
                        if (line.Seg != null && !line.Abs)
                        {
                            line.Seg.RepairXPosAndLength(Y_Axis.RealPos + line.StartPos.Y, line); //修正起始位置和长度
                        }
                        if (preCut)                                                               //根据是否预划切 修正划切速度
                        {
                            float s = Globals.Group.PreCut.GetPreDataSpeed();
                            if (s > 0 && s < line.Speed)        //预划切值有效且小于当前划切速度
                            {
                                line.Speed = s;
                            }
                            else
                            {
                                Globals.PreCut = false;
                            }
                        }
                        line.CutStep = CutStep.ST1;
                    }
                    else
                    {
                        return(false);
                    }
                }
                break;

                case CutStep.ST1:                                                                //X 轴移动到划切位置  需要根据当前Y轴位置重新计算X轴起点和划切长度
                {
                    X_Axis.JogAbs(line.BackSpeed, Globals.MacData.XCutBackAcc, line.StartPos.X); //设置X返回加速度
                    if (line.Abs)
                    {
                        Y_Axis.AxisJogAbsWork(line.StartPos.Y);
                    }
                    else
                    {
                        //float v = Math.Abs(line.StartPos.Y / line.Length * line.BackSpeed);
                        //Y_Axis.JogInc(v, 0.1f, line.StartPos.Y);
                        Y_Axis.AxisJogIncWork(line.StartPos.Y);        //相对位置
                    }
                    WaitAxisMoveDone(Y_Axis);
                    if (WaitAxisMoveDone(X_Axis))
                    {
                        line.CutStep = CutStep.ST2;
                    }
                    else
                    {
                        return(false);
                    }
                }
                break;

                case CutStep.ST2:    //Z轴下落到划切位置1
                {
                    float pos = line.ReDepth + Globals.TestHeightValue - Globals.BldData.RealCompensatedValue;
                    if (pos < Globals.TestHeightValue)        //防止切割到工作台
                    {
                        pos = Globals.TestHeightValue;
                    }
                    Z_Axis.JogAbs(Globals.MacData.ZCutSpeed, Globals.MacData.ZCutAcc, pos);        //Z轴下落到位 必须等候Z到位
                    if (WaitAxisMoveDone(Z_Axis))
                    {
                        line.CutStep = CutStep.ST3;
                    }
                    else
                    {
                        return(false);
                    }
                }
                break;

                case CutStep.ST3:                                                                              //X轴进行划切操作
                {
                    X_Axis.JogInc(line.Speed, Globals.MacData.XCutAcc, line.Dir ? -line.Length : line.Length); //X轴开始缓慢划切  判断划切方向
                    if (WaitAxisMoveDone(X_Axis))
                    {
                        line.CutStep = CutStep.ST4;
                        Globals.BldData.AddCutedLinesAndLength(1, line.Length / 1000);           //已划切刀数
                    }
                    else
                    {
                        return(false);
                    }
                }
                break;

                case CutStep.ST4:                                                              //Z轴是否抬刀
                {
                    if (line.SinDir || !line.Dual || (line.Dual && Globals.DevData.DualZlife)) //如果为单项划切或者必须返回
                    {
                        Z_Axis.AxisJogAbsWork(line.SelfPos);                                   //划切一刀 必须Z轴上升到安全位
                        if (!WaitAxisMoveDone(Z_Axis))
                        {
                            return(false);
                        }
                    }
                    if (line.Dual)
                    {
                        line.CutStep = CutStep.ST5;
                    }
                    else
                    {
                        line.CutStep = CutStep.CutStop;
                    }
                }
                break;

                case CutStep.ST5:    //X轴返回到划切位置
                {
                    line.FirstCut = false;
                    if (line.SinDir)                                                                 //如果是单向划切X轴必须返回到划切位置
                    {
                        X_Axis.JogAbs(line.BackSpeed, Globals.MacData.XCutBackAcc, line.StartPos.X); //需要重新设置X划切返回速度
                        if (!WaitAxisMoveDone(X_Axis))
                        {
                            return(false);
                        }
                    }
                    line.CutStep = CutStep.ST6;
                }
                break;

                case CutStep.ST6:    //Z轴下落到划切位置
                {
                    if (preCut)      //根据是否预划切 修正划切速度
                    {
                        float s = Globals.Group.PreCut.GetPreDataSpeed();
                        if (s > 0 && s < line.Speed)        //预划切值有效且小于当前划切速度
                        {
                            line.Speed = s;
                        }
                        else
                        {
                            Globals.PreCut = false;
                        }
                    }
                    float pos = line.ReDepth2 + Globals.TestHeightValue - Globals.BldData.RealCompensatedValue;
                    if (pos < Globals.TestHeightValue)
                    {
                        pos = Globals.TestHeightValue;
                    }
                    Z_Axis.JogAbs(Globals.MacData.ZCutSpeed, Globals.MacData.ZCutAcc, pos);        //Z轴下落到位置2
                    if (WaitAxisMoveDone(Z_Axis))
                    {
                        line.CutStep = CutStep.ST7;
                    }
                    else
                    {
                        return(false);
                    }
                }
                break;

                case CutStep.ST7:    //X轴开始划切
                {
                    if (line.SinDir)
                    {
                        X_Axis.JogInc(line.Speed, Globals.MacData.XCutAcc, line.Dir ? -line.Length : line.Length);        //需要设置返回加速度
                    }
                    else
                    {
                        X_Axis.JogInc(line.Speed, Globals.MacData.XCutAcc, line.Dir ? line.Length : -line.Length);
                    }
                    if (WaitAxisMoveDone(X_Axis))
                    {
                        line.CutStep = CutStep.ST8;
                        Globals.BldData.AddCutedLinesAndLength(1, line.Length / 1000);           //已划切刀数
                    }
                    else
                    {
                        return(false);
                    }
                }
                break;

                case CutStep.ST8:                            //Z轴进行抬刀操作
                {
                    if (line.SinDir || !line.Dual)           //如果为单项划切或者必须返回
                    {
                        Z_Axis.AxisJogAbsWork(line.SelfPos); //划切一刀 必须Z轴上升到安全位
                    }
                    line.Cutting = false;
                    line.CutStep = CutStep.CutStop;
                }
                break;

                case CutStep.CutStop:    //划切结束
                {
                    if (line.Pause)
                    {
                        line.CutStep = CutStep.Pause;
                    }
                    else
                    {
                        line.CutStep = CutStep.STEnd;        //当前先判断为切割完成 后续需要判断是否暂停 刀痕检测  和测高
                    }
                    ReportWorkingProgress(ProcessCmd.CutLineCmd, line);
                }
                break;

                case CutStep.KniefCheck:    //进行刀痕检测
                {
                }
                break;

                case CutStep.TestHeigh:    //进行非接触式测高
                {
                }
                break;

                case CutStep.Pause:
                {
                    ReportCmdKeyProgress(CmdKey.P0105);
                    line.CutStep = CutStep.STEnd;           //配置为划切完成
                    return(false);                          //中断当前划切操作
                }

                case CutStep.STEnd:
                {
                    line.Complate = true;
                }
                break;

                default:
                {
                }
                break;
                }
                if (Globals.CutStop)
                {
                    return(false);
                }
                ReportWorkingProgress(ProcessCmd.CutLineCmd, line);
                CuttingCheckStatus();
                Thread.Sleep(10);
            } while (!line.Complate);//没有完成就一直循环
            return(true);
        }//划切线
Ejemplo n.º 3
0
 public static bool AutoFocus(IVideoProvider provider, float maxPos, float minPos, float step = 0.2f)
 {
     try
     {
         if (provider == null)
         {
             return(false);
         }
         bool isCapture = provider.IsRunning;
         Dictionary <double, float> pos = new Dictionary <double, float>();
         Z_Axis.AxisJogAbsWork(maxPos);
         if (!WaitAxisMoveDone())
         {
             return(false);
         }
         if (!isCapture)
         {
             provider.StartCapture();
         }
         int    stepTick  = (int)((maxPos - minPos) / step);
         double scalValue = 0;
         int    tick      = 0;
         for (int i = 0; i < stepTick; i++)
         {
             Z_Axis.AxisJogIncWork(-step, true);
             Thread.Sleep(20);
             Bitmap map = provider.GetCurrentFrame();
             double qua = map.GetLinearQuality();
             if (!pos.ContainsKey(qua))
             {
                 if (qua < scalValue)
                 {
                     if (tick++ > 3)
                     {
                         break;
                     }
                 }
                 else
                 {
                     tick = 0;
                 }
                 scalValue = qua;
                 pos.Add(qua, z_Axis.RealPos);
             }
         }
         double maxKey = pos.Max(r => r.Key);
         float  desPos = pos[maxKey];
         Z_Axis.AxisJogAbsWork(desPos);
         if (!isCapture)
         {
             provider.StopCapture();
         }
         pos.Clear();
         GC.Collect();
         if (step / 20 < 0.005)
         {
             return(true);
         }
         else
         {
             return(AutoFocus(provider, desPos + step, desPos - step, step / 10));
         }
     }
     catch
     {
         return(false);
     }
 }
Ejemplo n.º 4
0
        public static bool TouchTestingHeight()
        {
            TabData data = Globals.TabData;
            int     tick = 30;

            ReportCmdKeyProgress(CmdKey.H0001);
            Globals.TestCancel   = false;
            Globals.Testing      = true;
            Globals.TestedHeight = false;   //清零系统标志位
            RunSpd(Globals.TabData.SpdSpeed, Globals.DevData.TestTime);
            Globals.LedCmd.Cmd = Globals.DevData.TestingLedCmd.Cmd;
            Z_Axis.AxisJogAbsWork(Z_Axis.Param.StartPos, true); //Z轴先返回到最高点
            if (data.UsedTable.RotateType)                      //圆盘测高
            {
                data.UsedTable.CurTpos += Globals.MacData.TTestOffset;
                if (data.UsedTable.CurTpos > data.MaxTpos)
                {
                    data.UsedTable.CurTpos = data.UsedTable.StartTpos;
                }
            }
            else//方盘测高
            {
                data.UsedTable.CurYpos += Globals.MacData.YTestOffset;
                data.UsedTable.CurTpos  = data.UsedTable.StartTpos;
                if (data.UsedTable.CurYpos - data.UsedTable.StartYpos > data.UsedTable.Length)
                {
                    data.UsedTable.CurYpos = data.UsedTable.StartYpos;
                }
            }
            X_Axis.AxisJogAbsWork(data.UsedTable.CurXpos);   //X值坐标位置
            Y_Axis.AxisJogAbsWork(data.UsedTable.CurYpos);   //Y值坐标位置
            WaitAxisMoveDone();                              //等待X Y T移动到位
            Z_Axis.AxisJogAbsWork(data.UsedTable.ZLowPos);   //Z轴移动到高速位置
            ReportCmdKeyProgress(CmdKey.H0003);
            do
            {
                if (!TesttingCheckStatus())
                {
                    return(false);
                }
                Thread.Sleep(50);
            } while (!Z_Axis.IsInPosition);                 //等待Z轴到位
            Z_Axis.SetLimitSwitch(false);
            float[] num        = new float[data.TestTick];
            float   startPos   = 30;
            float   homeOffset = Globals.MacData.ZRiseValue;//Z轴上升高度
            float   counterPos = Z_Axis.PhyPos;

            for (int i = 0; i < data.TestTick; i++)
            {
                ReportCmdKeyProgress((CmdKey)((int)CmdKey.H0004 + i));
                Z_Axis.GoHome(Limit.UserLimit, Globals.MacData.ZTestSpeed, Globals.MacData.ZTestAcc, homeOffset); //Z轴开始向下测高操作 ,每次操作限时60S
                tick = 600;
                do
                {
                    if (!TesttingCheckStatus())
                    {
                        return(false);
                    }
                    tick--;
                    Thread.Sleep(100);
                } while (!Z_Axis.HomeIsSuccessful && tick > 0);                   //等待回零完成
                startPos = (Z_Axis.PhyPos - counterPos) + data.UsedTable.ZLowPos; //计算当前实际位置
                Z_Axis.SetPrePosition(startPos);                                  //设置起始位置
                num[i] = startPos - homeOffset;
                ReportWorkingProgress(ProcessCmd.CsTestingTickCmd, num[i]);
            }
            if (num.Max() - num.Min() > data.CsMaxErrValue)//测高误差过大
            {
                ReportCmdKeyProgress(CmdKey.H0007);
                return(false);
            }
            else
            {
                data.CsTestValue        = num.Average();
                Globals.TestHeightValue = data.CsTestValue;
                Globals.TestedHeight    = true;//系统测高标志位
                ReportCmdKeyProgress(CmdKey.H0008);
                return(true);
            }
        }
Ejemplo n.º 5
0
        }//划切分度

        private static bool RunningChannelCut(CutChannel c)
        {
            bool flag = true;

            Globals.Channel = c;
            Z_Axis.AxisJogAbsWork(c.SelfPos);             //Z轴移动到安全位置
            WaitAxisMoveDone(Z_Axis);
            T_Axis.AxisJogAbsWork(c.AlignT + c.TPosAdj);  //T轴移动到偏移位置
            X_Axis.AxisJogAbsWork(c.PausePos.X);          //X轴移动到暂停位置
            Y_Axis.AxisJogAbsWork(c.PausePos.Y);          //Y轴移动到暂停位置(第一次划切默认为起始位置)
            WaitAxisMoveDone();                           //等待各轴运动成功
            c.Cutting = true;
            if (!c.Rotated)
            {
                ReportWorkingProgress(ProcessCmd.CutChStartCmd, c); //开始划切当前通道
                c.Rotated = true;
            }
            if (c.StandMode)
            {
                flag = RunSegmentCut(c);//标准模式划切
            }
            else
            {
                foreach (var item in c.Segs)
                {
                    if (!item.Complate)
                    {
                        ReportWorkingProgress(ProcessCmd.CutSegStartCmd, c); //进行通道划切完成
                        item.Complate = RunSegmentCut(item);
                        if (item.Complate)
                        {
                            c.CuttingIndex += item.Count;
                        }
                        else
                        {
                            flag = false;
                            break;//退出当前循环
                        }
                    }
                    flag &= item.Complate;
                }
            }
            if (flag)
            {
                c.Cutting = false;
                ReportCmdKeyProgress(CmdKey.P0109);
                ReportWorkingProgress(ProcessCmd.CutChEndCmd, c); //当前通道划切完成
            }
            else
            {
                c.PausePos.Y = Y_Axis.RealPos;               //设置Y暂停位置为当前的位置
                c.PausePos.X = Globals.ViewCenter.X;         //设置X暂停位置为显微镜中心位置
                Z_Axis.AxisJogAbsWork(c.SelfPos);            //Z轴移动到安全位置
                WaitAxisMoveDone(Z_Axis);
                X_Axis.AxisJogAbsWork(Globals.ViewCenter.X); //移动到显微镜视野
                Y_Axis.AxisJogIncWork(Globals.KniefAdj);     //划切位置+刀痕偏移值 将线移动到显微镜下面
                WaitAxisMoveDone();                          //等待移动停止
                if (!Globals.CutStop)                        //判断是因为暂停导致的返回
                {
                    ReportWorkingProgress(ProcessCmd.CutPauseCmd, c);
                }
            }
            c.Complate = flag;
            return(c.Complate);
        }