Beispiel #1
0
        public bool CalibRotateCenter(string cellName, Point2D pt2Mark1, Point2D pt2Mark2,
                                      double rotateAngle, BaseParComprehensive parComprehensive)
        {
            try
            {
                //获取旋转中心cell
                BaseParCalibrate baseParComprehensive = parComprehensive.GetCellParCalibrate(cellName);
                //获取旋转中心算子
                ParCalibRotate parCalibRotate = (ParCalibRotate)baseParComprehensive;
                //根据参数求旋转中心
                Point2D rc = new FunCalibRotate().GetOriginPoint(rotateAngle, pt2Mark1, pt2Mark2);
                //把旋转中心存入算子
                parCalibRotate.XRC = rc.DblValue1;
                parCalibRotate.YRC = rc.DblValue2;
                //讲计算结果写入xml
                parComprehensive.WriteXmlDoc(cellName);
                //将参数保存到结果类
                new FunCalibRotate().SaveParToResult(HtResult_Cam1, parCalibRotate);
                //输出计算结果
                string info = string.Format("相机{0}旋转中心标定完成,X:{1},Y:{2}", g_NoCamera,
                                            parCalibRotate.XRC.ToString(), parCalibRotate.YRC.ToString());
                ShowState(info);

                return(true);
            }
            catch (Exception ex)
            {
                Log.L_I.WriteError(NameClass, ex);
                return(false);
            }
        }
Beispiel #2
0
        public void DualLocation(int index)
        {
            if (Camera1Done & Camera2Done)
            {
                ShowState("开始计算工位" + index + "偏差");
                BaseParCalibrate baseParComprehensive = ParComprehensive2.P_I.GetCellParCalibrate(Camera2RC);
                ParCalibRotate   parCalibRotate       = (ParCalibRotate)baseParComprehensive;
                double           angle = Math.Atan(
                    (Pt2Mark2.DblValue2
                     - Pt2Mark1.DblValue2)
                    * AMP
                    / Protocols.confDisMark) * 180 / Math.PI
                                         - StationDataMngr.CalibPos_L[index - 1].DblValue4;
                ShowState("工位" + index + "逆时针角度偏差: " + angle);


                FunCalibRotate fcr             = new FunCalibRotate();
                Point2D        MarkAfterRotate = fcr.GetPoint_AfterRotation(
                    angle / 180 * Math.PI, parCalibRotate.PointRC, Pt2Mark2);

                double deltaY = MarkAfterRotate.DblValue1 - StationDataMngr.CalibPos_L[index - 1].DblValue1;
                double deltaX = MarkAfterRotate.DblValue2 - StationDataMngr.CalibPos_L[index - 1].DblValue2;
                deltaX *= AMP;
                deltaY *= -AMP;

                Point2D delta = TransDelta(new Point2D(deltaX, deltaY),
                                           Protocols.ConfPlaceAngle, Protocols.ConfPreciseAngle);
                ShowState(string.Format("工位{0}X方向补偿{1},Y方向补偿{2}", index, delta.DblValue1.ToString(ReserveDigits), delta.DblValue2.ToString(ReserveDigits)));

                int     num = (StationNum - 1) * 2 + index;
                Point4D pos = new Point4D
                {
                    DblValue1 = delta.DblValue1
                                + StationDataMngr.PlacePos_L[index - 1].DblValue1
                                + ParAdjust.Value1("adj" + num),

                    DblValue2 = delta.DblValue2
                                + StationDataMngr.PlacePos_L[index - 1].DblValue2
                                + ParAdjust.Value2("adj" + num),

                    DblValue3 = StationDataMngr.PlacePos_L[index - 1].DblValue3,
                    DblValue4 = Protocols.ConfPlaceAngle + angle + ParAdjust.Value3("adj" + num)
                };

                LogicRobot.L_I.WriteRobotCMD(pos, Protocols.BotCmd_StationPos);
                ShowState("发送机器人放片坐标:" + pos.DblValue1.ToString("f3") + @"/" + pos.DblValue2.ToString("f3"));
            }
        }
Beispiel #3
0
 public static bool GetRcFromPar(string cellName, BaseParComprehensive parComprehensive, out Point2D rc)
 {
     rc = new Point2D();
     try
     {
         //获取单元格
         BaseParCalibrate baseParComprehensive = parComprehensive.GetCellParCalibrate(cellName);
         //获取旋转中心算子
         ParCalibRotate parCalibRotate = (ParCalibRotate)baseParComprehensive;
         //计算旋转之后的mark位置
         rc = parCalibRotate.PointRC;
     }
     catch (Exception ex)
     {
         Log.L_I.WriteError(ClassName, ex);
         return(false);
     }
     return(true);
 }
Beispiel #4
0
        public bool SetRotateCenter(string cellName, Point2D rc, BaseParComprehensive parComprehensive)
        {
            //获取旋转中心cell
            BaseParCalibrate baseParComprehensive = parComprehensive.GetCellParCalibrate(cellName);
            //获取旋转中心算子
            ParCalibRotate parCalibRotate = (ParCalibRotate)baseParComprehensive;

            //把旋转中心存入算子
            parCalibRotate.XRC = rc.DblValue1;
            parCalibRotate.YRC = rc.DblValue2;
            //讲计算结果写入xml
            parComprehensive.WriteXmlDoc(cellName);
            //将参数保存到结果类
            new FunCalibRotate().SaveParToResult(HtResult_Cam1, parCalibRotate);
            //输出计算结果
            string info = string.Format("相机{0}旋转中心标定完成,X:{1},Y:{2}", g_NoCamera,
                                        parCalibRotate.XRC.ToString(), parCalibRotate.YRC.ToString());

            ShowState(info);

            return(true);
        }
Beispiel #5
0
        public void CalibRC()
        {
            Thread.Sleep(500);
            //double curR= ModuleBase.GetCurAngleByY(Protocols.GlassXInPresize, AMP, Pt2Mark1, Pt2MarkRC);
            BaseParCalibrate baseParComprehensive = ParComprehensive2.P_I.GetCellParCalibrate(Camera2RC);
            ParCalibRotate   parCalibRotate       = (ParCalibRotate)baseParComprehensive;

            Point2D orgPoint = new FunCalibRotate().GetOriginPoint(Protocols.BotRCCalibAngle, Pt2Mark2, Pt2MarkRC);

            ShowState("计算旋转中心X:" + orgPoint.DblValue1 + ",Y:" + orgPoint.DblValue2);
            Point2D offset = new Point2D(Protocols.GlassXInPresize / 2 / AMP, Protocols.GlassYInPresize / 2 / AMP);
            double  r      = ModuleBase.GetCurAngleByY(Protocols.GlassXInPresize, AMP, Pt2Mark1, Pt2Mark2);

            offset = TransDelta(offset, r + 0.5, 0);
            Point2D rc = new Point2D(offset.DblValue1 + Pt2Mark2.DblValue1, offset.DblValue2 + Pt2Mark2.DblValue2);

            ShowState("理论旋转中心X:" + rc.DblValue1 + ",Y:" + rc.DblValue2);
            if (Math.Abs(orgPoint.DblValue1 - rc.DblValue1) < 1000 &&
                Math.Abs(orgPoint.DblValue2 - rc.DblValue2) < 1000)
            {
                ShowState("使用计算旋转中心");
                parCalibRotate.XRC = orgPoint.DblValue1;
                parCalibRotate.YRC = orgPoint.DblValue2;
            }
            else
            {
                ShowState("使用理论旋转中心");
                parCalibRotate.XRC = rc.DblValue1; // orgPoint.DblValue1;
                parCalibRotate.YRC = rc.DblValue2; // orgPoint.DblValue2;
            }

            ParComprehensive2.P_I.WriteXmlDoc(Camera2RC);
            //将参数保存到结果类
            new FunCalibRotate().SaveParToResult(HtResult_Cam2, parCalibRotate);

            ShowState(string.Format("旋转中心标定完成,X_{0},Y_{1}", parCalibRotate.XRC.ToString(), parCalibRotate.YRC.ToString()));

            LogicRobot.L_I.WriteRobotCMD(Protocols.BotCmd_CalibRC);
        }
        /// <summary>
        /// 自动校准旋转中心,1401表示位置1第一次拍照,
        /// </summary>
        /// <param name="pos">算子序号,不表示拍照位置</param>
        /// <param name="index"></param>
        /// <param name="htResult">哈希表结果</param>
        /// <returns></returns>
        bool CalibRotate(int pos, int index, out Hashtable htResult)
        {
            htResult = null;
            Stopwatch sw = new Stopwatch();

            try
            {
                //获取该算子所有的单元格
                List <string> nameCell_L = g_BaseParComprehensive.GetAllNameCellByType("旋转中心变换");
                if (nameCell_L.Count < pos)
                {
                    WinMsgBox.ShowMsgBox("算子个数小于序号!");
                    return(false);
                }
                string nameCell = nameCell_L[pos - 1];//单元格名称

                ParCalibRotate par = g_BaseParComprehensive.GetCellParCalibrate(nameCell) as ParCalibRotate;

                int indexCell = int.Parse(nameCell.Replace("C", ""));//单元格索引

                ParCellExeReference  parCellExeReference  = par.g_ParCellExecuteReference;
                ParGetResultFromCell parGetResultFromCell = par.g_ParGetResultFromCellForRC;//用来计算旋转中心

                //调用执行
                g_BaseDealComprehensive.DealComprehensivePosCell_ForTestRun(g_UCDisplayCamera, parCellExeReference, par.g_ParCellExecuteReference.g_CellExecute_L, out htResult);//执行算法且显示

                string cellError = "";
                if (!GetErrorCell(htResult, pos, out cellError))
                {
                    WinMsgBox.ShowMsgBox(string.Format("相机{0}位置{1},单元格{2}校准计算错误", g_NoCamera.ToString(), pos.ToString(), par.NameCell));
                    return(false);
                }

                FunCellDataReferenc fun = new FunCellDataReferenc();
                fun.GetResultValue(htResult, parGetResultFromCell, index - 1);

                string info = string.Format("相机{0}位置{1},单元格{2}", g_NoCamera.ToString(), pos.ToString(), par.NameCell);
                if (index == 1)
                {
                    info += "旋转中心校准第一次拍照";
                    ShowState(info);

                    SaveStdImage(par, "旋转中心位置1");
                }
                else if (index == 2)
                {
                    info += "旋转中心校准第二次拍照";
                    ShowState(info);
                    SaveStdImage(par, "旋转中心位置2");

                    FunCalibRotate funCalibRotate = new FunCalibRotate();
                    Point2D        point          = funCalibRotate.GetOriginPoint(par);
                    par.XRC = point.DblValue1;
                    par.YRC = point.DblValue2;

                    //显示求取的旋转中心
                    info = string.Format("旋转中心:X{0},Y{1}", par.XRC.ToString(), par.YRC.ToString());

                    ShowState(info);

                    //保存此单元格
                    bool blSave = g_BaseParComprehensive.WriteXmlDoc(par.NameCell);

                    if (blSave)
                    {
                        ShowState(string.Format("将参数旋转中心校准{0}保存到本地成功", par.NameCell));
                    }
                    else
                    {
                        ShowAlarm(string.Format("将参数旋转中心校准{0}保存到本地失败", par.NameCell));
                        return(false);
                    }

                    //将参数保存到结果中
                    bool blSaveResult = g_BaseDealComprehensive.InitCalibRotate(indexCell);
                    if (blSaveResult)
                    {
                        ShowState(string.Format("将参数旋转中心校准{0}保存到结果成功", par.NameCell));
                    }
                    else
                    {
                        ShowAlarm(string.Format("将参数旋转中心校准{0}保存到结果失败", par.NameCell));
                        return(false);
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                ShowAlarm(string.Format("相机{0}旋转中心计算进入Catch", g_NoCamera.ToString()));
                Log.L_I.WriteError(NameClass, ex);
                return(false);
            }
        }