Example #1
0
        /// <summary>
        /// Fov 选择改变
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cbFovName_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cbFovName.SelectedIndex < 0)
            {
                cbTaskName.Text  = "";
                btFixFov.Enabled = false;
                return;
            }
            string currFovName         = cbFovName.Text;
            string currTaskName        = cbTaskName.Text;
            JFDLAFRecipeManager rm     = JFHubCenter.Instance.RecipeManager as JFDLAFRecipeManager;
            JFDLAFProductRecipe recipe = rm.GetRecipe(CategoteProduct, cbRecipeID.Text) as JFDLAFProductRecipe;

            string[] allFovNames = recipe.FovNames();
            if (!allFovNames.Contains(currFovName))
            {
                MessageBox.Show("当前Recipe未包含FovName:" + currFovName);
                cbTaskName.Text  = "";
                btFixFov.Enabled = false;
                return;
            }

            btFixFov.Enabled = true;

            double x, y;

            recipe.GetFovOffset(currFovName, out x, out y);
            lbFovOffset.Text = string.Format("x:{0:F3} y:{1:F3}", x, y);


            string[] allTaskNames = recipe.TaskNames(currFovName);
            cbTaskName.Items.Clear();
            if (null != allTaskNames)
            {
                foreach (string s in allTaskNames)
                {
                    cbTaskName.Items.Add(s);
                }
            }
            if (!string.IsNullOrEmpty(currTaskName))
            {
                if (_isTaskVcEditting)
                {
                    _isTaskVcEditting          = false;
                    cbTaskVc.Enabled           = false;
                    btTaskVcEditCancel.Enabled = false;
                    btTaskVcEditSave.Text      = "设置";
                }
                cbTaskName.Text = currTaskName;

                if (allTaskNames != null && allTaskNames.Contains(currTaskName))
                {
                    cbTaskName.BackColor = SystemColors.Control;
                }
                else
                {
                    cbTaskName.BackColor = Color.OrangeRed;
                }
            }
        }
        /// <summary>
        /// 根据当前所选ProductID更新Map控件
        /// </summary>
        /// <param name="recipeID"></param>
        void UpdateMappingByProdID(string recipeID)
        {
            if (string.IsNullOrEmpty(recipeID))
            {
                mappCtrl.Initial(0, 0, _dctDieStateColor, "未检测");
                mappCtrl.IsShowBottomBar = true;
                return;
            }
            JFDLAFRecipeManager rm = JFHubCenter.Instance.RecipeManager as JFDLAFRecipeManager;

            _currRecipe = rm.GetRecipe(MainStation.SCN_CategotyProd, recipeID) as JFDLAFProductRecipe;
            if (null == _currRecipe)
            {
                mappCtrl.Initial(0, 0, _dctDieStateColor, "未检测");
                mappCtrl.IsShowBottomBar = true;

                return;
            }


            int dieRow = _currRecipe.RowNumber;;      //料片中的die行数
            int dieCol = _currRecipe.ColumnNumber * _currRecipe.BlockNumber;;


            mappCtrl.Initial(dieRow, dieCol, _dctDieStateColor, "未检测");
            mappCtrl.MinCellHeight   = 5;
            mappCtrl.MinCellWidth    = 5;
            mappCtrl.IsShowBottomBar = true;



            cbTaskImgShow.Items.Clear();
            List <string> allTaskNames = new List <string>();

            string[] allFovNames = _currRecipe.FovNames();
            if (null != allFovNames)
            {
                List <string> taskNamesExisted = new List <string>();
                foreach (string fovName in allFovNames)
                {
                    string[] taskNames = _currRecipe.TaskNames(fovName);
                    if (taskNames != null)
                    {
                        foreach (string taskName in taskNames)
                        {
                            if (!taskNamesExisted.Contains(taskName))
                            {
                                taskNamesExisted.Add(taskName);
                                cbTaskImgShow.Items.Add(taskName);
                            }
                        }
                    }
                }
            }

            if (cbTaskImgShow.Items.Count > 0)
            {
                cbTaskImgShow.SelectedIndex = 0;
            }
        }
        /// <summary>
        /// 输入一条Fov的检测结果
        /// </summary>
        /// <param name="fovResult">Fov检测结果</param>
        public void EntryFovResult(DlafFovDetectResult fr /*, out bool isLastFovInPiece*/)
        {
            if (null == fr)
            {
                return;
            }
            int fovIndexInDie = 0;

            string[] allFovNames = _recipe.FovNames();
            for (int i = 0; i < allFovNames.Length; i++)
            {
                if (fr.FovName == allFovNames[i])
                {
                    fovIndexInDie = i;
                    break;
                }
            }

            int idx = (fr.ICRow * _recipe.ColCount + fr.ICCol) * _recipe.FovCount + fovIndexInDie;

            _fovResults[idx]  = fr;
            _fovCounteds[idx] = false;
        }
Example #4
0
 int _FovNameIndex(string fovName)
 {
     if (_currRecipe == null)
     {
         return(-1);
     }
     for (int i = 0; i < _currRecipe.FovCount; i++)
     {
         if (_currRecipe.FovNames()[i] == fovName)
         {
             return(i);
         }
     }
     return(-1);
 }
Example #5
0
        /// <summary>
        /// 生成芯片实际扫描点位
        /// </summary>
        /// <param name="imgs"></param>
        /// <param name="snapX"></param>
        /// <param name="snapY"></param>
        /// <param name="icsCenterX"></param>
        /// <param name="icsCenterY"></param>
        /// <param name="fovsOffsetX"></param>
        /// <param name="fovsOffsetY"></param>
        /// <param name="errorInfo"></param>
        /// <returns></returns>
        public bool CalibProduct(IJFImage[] imgs, double[] snapX, double[] snapY, out double[] icsCenterX, out double[] icsCenterY,
                                 out double[] fovsOffsetX, out double[] fovsOffsetY, out string errorInfo)
        {
            if (!_isInitOK)
            {
                icsCenterX  = null;
                icsCenterY  = null;
                fovsOffsetX = null;
                fovsOffsetY = null;
                errorInfo   = "初始化未完成";
                return(false);
            }

            HObject[] himgs = new HObject[] { null, null };
            object    oi;

            if (0 != imgs[0].GenHalcon(out oi))
            {
                icsCenterX  = null;
                icsCenterY  = null;
                fovsOffsetX = null;
                fovsOffsetY = null;
                errorInfo   = "左Mark图像转Halcon失败!";
                return(false);
            }
            himgs[0] = oi as HObject;

            if (0 != imgs[1].GenHalcon(out oi))
            {
                icsCenterX  = null;
                icsCenterY  = null;
                fovsOffsetX = null;
                fovsOffsetY = null;
                errorInfo   = "右Mark图像转Halcon失败!";
                return(false);
            }
            himgs[1] = oi as HObject;

            //左矫正点
            HTuple hv_iFlag            = new HTuple();
            HTuple hvLeftModeHMap      = new HTuple();
            HTuple hvDefLeft_coorX     = new HTuple();
            HTuple hvDefLeft_coorY     = new HTuple();
            HTuple hvDefLeft_updateX   = new HTuple();
            HTuple hvDefLeft_updateY   = new HTuple();
            HTuple hvDefLeft_updateRow = new HTuple();
            HTuple hvDefLeft_updateCol = new HTuple();

            if (_leftMarkModel.matchRegion == null || !_leftMarkModel.matchRegion.IsInitialized())
            {
                HOperatorSet.GetDomain(himgs[0], out _leftMarkModel.matchRegion);
            }

            VisionMethon.coor_uvToxy_point(himgs[0], _leftMarkModel.defRows, _leftMarkModel.defCols, _recipe.CheckPosX, _recipe.CheckPosY,
                                           _cmrCalibData, out hvDefLeft_coorX, out hvDefLeft_coorY, out hv_iFlag);
            if (hv_iFlag.S != "")
            {
                icsCenterX        = null;
                icsCenterY        = null;
                fovsOffsetX       = null;
                fovsOffsetY       = null;
                hvDefLeft_updateX = null;
                hvDefLeft_updateY = null;
                errorInfo         = "左模板中心像素转换成实际坐标失败!" + hv_iFlag.S;
                return(false);
            }
            VisionMethon.Map_Points_Match(himgs[0], _leftMarkModel.matchRegion, _leftMarkModel.modelType, _leftMarkModel.modelID,
                                          _recipe.CheckPosScoreThresh, _leftMarkModel.defRows, _leftMarkModel.defCols, hvDefLeft_coorX, hvDefLeft_coorY,
                                          _cmrCalibData, out hvLeftModeHMap, out hvDefLeft_updateX, out hvDefLeft_updateY, out hvDefLeft_updateRow, out hvDefLeft_updateCol, out hv_iFlag);
            if (hv_iFlag.S != "")
            {
                icsCenterX        = null;
                icsCenterY        = null;
                fovsOffsetX       = null;
                fovsOffsetY       = null;
                hvDefLeft_updateX = null;
                hvDefLeft_updateY = null;
                errorInfo         = "左矫正点匹配失败!" + hv_iFlag.S;
                return(false);
            }

            //if (showRegion != null) showRegion.Dispose();
            //HOperatorSet.GenCrossContourXld(out showRegion, hvDefLeft_updateRow, hvDefLeft_updateCol, 512, 0);
            //ShowImage(hTWindow, himgs[0], showRegion);

            //左矫正点
            HTuple hvRightModeHMap      = new HTuple();
            HTuple hvDefRight_coorX     = new HTuple();
            HTuple hvDefRight_coorY     = new HTuple();
            HTuple hvDefRight_updateX   = new HTuple();
            HTuple hvDefRight_updateY   = new HTuple();
            HTuple hvDefRight_updateRow = new HTuple();
            HTuple hvDefRight_updateCol = new HTuple();

            if (_rightMarkModel.matchRegion == null || !_rightMarkModel.matchRegion.IsInitialized())
            {
                HOperatorSet.GetDomain(himgs[1], out _rightMarkModel.matchRegion);
            }

            VisionMethon.coor_uvToxy_point(himgs[1], _rightMarkModel.defRows, _rightMarkModel.defCols, _recipe.CheckPosRX, _recipe.CheckPosRY,
                                           _cmrCalibData, out hvDefRight_coorX, out hvDefRight_coorY, out hv_iFlag);
            if (hv_iFlag.S != "")
            {
                icsCenterX  = null;
                icsCenterY  = null;
                fovsOffsetX = null;
                fovsOffsetY = null;
                errorInfo   = "右模板中心像素转换成实际坐标失败!" + hv_iFlag.S;
                return(false);
            }
            VisionMethon.Map_Points_Match(himgs[1], _rightMarkModel.matchRegion, _rightMarkModel.modelType, _rightMarkModel.modelID,
                                          _recipe.CheckPosRScoreThresh, _rightMarkModel.defRows, _rightMarkModel.defCols, hvDefRight_coorX, hvDefRight_coorY,
                                          _cmrCalibData, out hvRightModeHMap, out hvDefRight_updateX, out hvDefRight_updateY, out hvDefRight_updateRow, out hvDefRight_updateCol, out hv_iFlag);
            if (hv_iFlag.S != "")
            {
                icsCenterX  = null;
                icsCenterY  = null;
                fovsOffsetX = null;
                fovsOffsetY = null;
                errorInfo   = "右矫正点匹配失败!" + hv_iFlag.S;
                return(false);
            }

            //if (showRegion != null) showRegion.Dispose();
            //HOperatorSet.GenCrossContourXld(out showRegion, hvDefLeft_updateRow, hvDefLeft_updateCol, 512, 0);
            //ShowImage(hTWindow, himgs[1], showRegion);

            //生成矫正后芯片扫描点位
            HTuple hvAfterFix_SnapX = new HTuple();
            HTuple hvAfterFix_SnapY = new HTuple();
            HTuple hvAfterFix_ICX   = null;
            HTuple hvAfterFix_ICY   = null;
            HTuple hv_du            = null;
            HTuple hv_dv            = null;

            VisionMethon.update_map_correction(_recipe.icMapX, _recipe.icMapY, _recipe.snapMapX, _recipe.snapMapY,
                                               hvDefLeft_coorX, hvDefLeft_coorY, hvDefRight_coorX, hvDefRight_coorY, hvDefLeft_updateX,
                                               hvDefLeft_updateY, hvDefRight_updateX, hvDefRight_updateY, _cmrCalibData, out hvAfterFix_ICX,
                                               out hvAfterFix_ICY, out hvAfterFix_SnapX, out hvAfterFix_SnapY, out hv_iFlag, out hv_du, out hv_dv);
            if (hv_iFlag.S != "")
            {
                icsCenterX  = null;
                icsCenterY  = null;
                fovsOffsetX = null;
                fovsOffsetY = null;
                errorInfo   = "生成矫正点后扫描点位失败!" + hv_iFlag.S;
                return(false);
            }

            //Fov矫正日后添加
            int fovCount = _recipe.FovCount;

            fovsOffsetX = new double[fovCount];
            fovsOffsetY = new double[fovCount];
            for (int i = 0; i < fovCount; i++)
            {
                _recipe.GetFovOffset(_recipe.FovNames()[i], out fovsOffsetX[i], out fovsOffsetY[i]);
            }



            double[] _icsCenterX = new double[hvAfterFix_SnapX.Length];
            double[] _icsCenterY = new double[hvAfterFix_SnapX.Length];
            icsCenterX = new double[hvAfterFix_SnapX.Length];
            icsCenterY = new double[hvAfterFix_SnapX.Length];

            for (int i = 0; i < hvAfterFix_SnapX.Length; i++)
            {
                _icsCenterX[i] = hvAfterFix_SnapX.TupleSelect(i).D;
                _icsCenterY[i] = hvAfterFix_SnapY.TupleSelect(i).D;
            }

            //重新排序每行扫描按照从左到右进行扫描
            int currentIndex = 0;

            for (int m = 0; m < _recipe.RowCount; m++)
            {
                for (int n = 0; n < _recipe.ColCount; n++)
                {
                    int index = 0;
                    if (m % 2 == 0)
                    {
                        index = (int)(m * _recipe.ColCount + n);
                    }
                    else
                    {
                        index = (int)(m * _recipe.ColCount + (_recipe.ColCount - 1 - n));
                    }
                    icsCenterX[currentIndex] = _icsCenterX[index];
                    icsCenterY[currentIndex] = _icsCenterY[index];

                    currentIndex++;
                }
            }
            errorInfo = "Success";
            return(true);
        }
        public bool InitInspectNode(string recipeID, out string errorInfo)
        {
            if (string.IsNullOrEmpty(recipeID))
            {
                errorInfo = "参数recipeID 为空字串";
                return(false);
            }

            JFDLAFRecipeManager rm = JFHubCenter.Instance.RecipeManager as JFDLAFRecipeManager;

            if (rm == null)
            {
                errorInfo = "配方管理器为空!";
                return(false);
            }

            if (!rm.IsInitOK)
            {
                errorInfo = "配方管理器未初始化:" + rm.GetInitErrorInfo();
                return(false);
            }

            string[] allRecipeIds = rm.AllRecipeIDsInCategoty(CategoyProduct);
            if (null == allRecipeIds || 0 == allRecipeIds.Length)
            {
                errorInfo = "配方管理器中不存在任何RecipeID";
                return(false);
            }

            if (!allRecipeIds.Contains(recipeID))
            {
                errorInfo = "配方管理器中不存在RecipeID = " + recipeID;
                return(false);
            }

            Dictionary <string, InspectNode> dctFovInspections = null;

            if (!_dctRecipeInspections.ContainsKey(recipeID)) //当前
            {
                dctFovInspections = new Dictionary <string, InspectNode>();
                _dctRecipeInspections.Add(recipeID, dctFovInspections);


                string rmPath = rm.GetInitParamValue("配方保存路径") as string;


                JFDLAFProductRecipe recipe   = rm.GetRecipe(CategoyProduct, recipeID) as JFDLAFProductRecipe;
                string[]            fovNames = recipe.FovNames();
                foreach (string fovName in fovNames)
                {
                    string recipePath = rmPath + "\\" + recipeID + "\\" + fovName + "\\Recipe\\";
                    string modelPath  = rmPath + "\\" + recipeID + "\\" + fovName + "\\Models\\";

                    InspectNode inspectNode = new InspectNode(modelPath, recipePath);
                    dctFovInspections.Add(fovName, inspectNode);
                }
            }
            string err;

            dctFovInspections = _dctRecipeInspections[recipeID];
            foreach (KeyValuePair <string, InspectNode> kv in dctFovInspections)
            {
                if (!kv.Value.InitInspectParam(out err))
                {
                    errorInfo = "Fov = " + kv.Key + " 初始化失败:" + err;
                    return(false);
                }
            }
            errorInfo = "Success";
            return(true);
        }
Example #7
0
        protected override void RunLoopInWork()
        {
            NotifyCustomizeMsg(SCM_PieceStart, new object[] { _currPiecePicFolder });
            //Inspect_Node inpect = JFDLAFInspectionManager.Instance.GetInspectNode
            int rows = _currRecipe.RowCount;
            int cols = _currRecipe.ColCount;

            string[] fovNames = _currRecipe.FovNames();
            for (int currRow = 0; currRow < rows; currRow++)
            {
                for (int currCol = 0; currCol < cols; currCol++)
                {
                    for (int currFov = 0; currFov < fovNames.Length; currFov++)
                    {
                        CheckCmd(CycleMilliseconds); //检测是否有暂停/恢复/退出 消息
                        string fovName      = fovNames[currFov];
                        string fovSubFolder = "Row_" + currRow + "-" + "Col_" + currCol + "-Fov_" + fovName;
                        string fovFolder    = _currPiecePicFolder + "\\" + fovSubFolder;//存储图片的文件夹
                        if (!Directory.Exists(fovFolder))
                        {
                            ExitWork(WorkExitCode.Error, "Fov图片文件夹:\"" + fovFolder + "\"不存在");
                        }
                        InspectNode fovInspNode = JFDLAFInspectionManager.Instance.GetInspectNode(RecipeID, fovName);
                        if (null == fovInspNode)
                        {
                            ExitWork(WorkExitCode.Error, "算子管理器中不存在 RecipeID = " + RecipeID + " Fov = " + fovName + "  的检测算子");
                        }

                        string[] filesInFovFolder = Directory.GetFiles(fovFolder);//Fov文件夹中现有的文件
                        if (null == filesInFovFolder || filesInFovFolder.Length == 0)
                        {
                            ExitWork(WorkExitCode.Error, "Fov图片文件夹:\"" + fovFolder + "\"中没有文件");
                        }


                        string[]       taskNames = _currRecipe.TaskNames(fovName);
                        List <HObject> taskImgs  = new List <HObject>();
                        foreach (string taskName in taskNames)
                        {
                            HObject hoImg;
                            HOperatorSet.GenEmptyObj(out hoImg);
                            string taskImgFile = null;
                            foreach (string s in filesInFovFolder)
                            {
                                string exn = Path.GetExtension(s);
                                if (string.Compare(exn, ".bmp", true) != 0 &&
                                    string.Compare(exn, ".tiff", true) != 0 &&
                                    string.Compare(exn, ".tif", true) != 0 &&
                                    string.Compare(exn, ".jpg", true) != 0 &&
                                    string.Compare(exn, ".jpeg", true) != 0 &&
                                    string.Compare(exn, ".png", true) != 0)
                                {
                                    continue;                                     //先过滤掉非图像文件
                                }
                                string fnn = Path.GetFileNameWithoutExtension(s); //不带后缀的文件名
                                if (fnn.LastIndexOf(taskName) >= 0 &&
                                    fnn.Length == (fnn.LastIndexOf(taskName) + taskName.Length))
                                {
                                    taskImgFile = s;
                                    break;
                                }
                            }
                            if (null == taskImgFile)
                            {
                                ExitWork(WorkExitCode.Error, "Task = " + taskName + "  图片文件不存在");
                            }

                            HOperatorSet.ReadImage(out hoImg, taskImgFile);
                            taskImgs.Add(hoImg);
                        }

                        DlafFovDetectResult fdr = new DlafFovDetectResult();
                        fdr.FovName   = fovName;
                        fdr.ICRow     = currRow;
                        fdr.ICCol     = currCol;
                        fdr.TaskNames = taskNames;



                        string errorInfo;
                        //检测输入参数
                        HObject dieRegions;
                        int[]   dieRows, dieCols;
                        int     currDieRowCount, currDieColCount;
                        if (!_visionFixer.GetDetectRegionInFov(currRow, currCol, out dieRegions, out dieRows, out dieCols, out currDieRowCount, out currDieColCount, out errorInfo))
                        {
                            ExitWork(WorkExitCode.Error, "GetDetectRegionInFov failed,ErrorInfo:" + errorInfo);
                        }
                        fdr.DetectDiesRows = dieRows;
                        fdr.DetectDiesCols = dieCols;
                        fdr.CurrRowCount   = currDieRowCount;
                        fdr.CurrColCount   = currDieColCount;

                        //fdr.DieInspectResults = new List<InspectResultItem>[currDieRowCount* currDieColCount];
                        //for (int i = 0; i < currDieRowCount * currDieColCount; i++)
                        //    fdr.DieInspectResults[i] = new List<InspectResultItem>();

                        //检测输出参数
                        string          detectErrorInfo; //算子执行信息
                        List <int[]>    diesErrorCodes;  //= new List<int[]>();
                        List <string[]> diesErrorTaskNames;

                        List <HObject[]>             diesFailedRegions;
                        List <string[]>              diesErrorDetails; //错误的详细描述信息
                        Dictionary <string, HObject> detectItems;      //算子中输出的检测项(BondContours/WireRegions 等等)
                        Dictionary <string, string>  detectItemTaskNames;


                        //bool isDetectOK = fovInspNode.InspectImage(taskImgs.ToArray(), taskNames, dieRegions,
                        //                                            out detectErrorInfo, out diesErrorCodes, out diesErrorTaskNames, out diesFailedRegions,out diesErrorDetails,
                        //                                            out detectItems,out detectItemTaskNames);

                        //用于测试新数据结构
                        List <InspectResultItem[]> inspectResults = null;
                        bool isDetectOK = fovInspNode.InspectImage(taskImgs.ToArray(),
                                                                   dieRegions, out detectErrorInfo, out inspectResults);
                        fdr.DieInspectResults = inspectResults; //所有检测项


                        int dieCountInfov = dieRegions.CountObj();
                        //裁剪后的图象(按照Die的检测区域)
                        HObject[] dieImgs = new HObject[dieCountInfov];
                        HTuple    _row1, _col1, _row2, _col2;
                        HTuple    TWidth, THeight;
                        for (int i = 0; i < dieCountInfov; i++)
                        {
                            HOperatorSet.SmallestRectangle1(dieRegions.SelectObj(i + 1), out _row1, out _col1, out _row2, out _col2);
                            if (_row1 < 0)
                            {
                                _row1 = 0;
                            }
                            if (_col1 < 0)
                            {
                                _col1 = 0;
                            }
                            HOperatorSet.GetImageSize(taskImgs[0], out TWidth, out THeight);
                            if (_row2 > THeight)
                            {
                                _row2 = THeight;
                            }
                            if (_col2 > TWidth)
                            {
                                _row2 = TWidth;
                            }

                            HObject hoImages = null; //一颗Die的多通道图
                            HOperatorSet.GenEmptyObj(out hoImages);
                            for (int j = 0; j < taskImgs.Count; j++)
                            {
                                HObject ho;
                                HOperatorSet.CropRectangle1(taskImgs[j], out ho, _row1, _col1, _row2, _col2);
                                HOperatorSet.ConcatObj(hoImages, ho, out hoImages);
                            }
                            dieImgs[i] = hoImages;
                        }
                        fdr.DetectDiesImages = dieImgs;
                        fdr.IsDetectSuccess  = isDetectOK;
                        fdr.DetectErrorInfo  = detectErrorInfo;
                        //if (null != diesErrorCodes)
                        //    fdr.DiesErrorCodes = diesErrorCodes.ToArray();
                        //else
                        //    fdr.DiesErrorCodes = null;

                        //if (null != diesErrorTaskNames)
                        //    fdr.DiesErrorTaskNames = diesErrorTaskNames.ToArray();
                        //else
                        //    fdr.DiesErrorTaskNames = null;

                        //if (null != diesFailedRegions)
                        //    fdr.DiesErrorRegions = diesFailedRegions.ToArray();
                        //else
                        //    fdr.DiesErrorRegions = null;

                        //if (diesErrorDetails != null)
                        //    fdr.DiesErrorDetails = diesErrorDetails.ToArray();
                        //else
                        //    fdr.DiesErrorDetails = null;


                        //fdr.DetectIterms = detectItems;
                        //fdr.DetectItemTaskNames = detectItemTaskNames;
                        //if (fdr.DetectIterms != null && fdr.DetectIterms.ContainsKey("WireRegions"))
                        //{
                        //    fdr.WireRegion = fdr.DetectIterms["WireRegions"];
                        //    fdr.WireRegionTaskName = fdr.DetectItemTaskNames["WireRegions"];
                        //    fdr.DetectIterms.Remove("WireRegions");
                        //    fdr.DetectItemTaskNames.Remove("WireRegions");
                        //}



                        NotifyCustomizeMsg(SCM_FovDetectResult, new object[] {
                            taskImgs, //FOV原图
                            fdr       //测试结果
                        });
                    }
                }
            }
            NotifyCustomizeMsg(SCM_PieceEnd, null);
            ExitWork(WorkExitCode.Normal, "");
        }
Example #8
0
        protected override bool ActionGenuine(out string errorInfo)
        {
            string recipeID = GetMethodInputValue("RecipeID") as string;

            if (string.IsNullOrEmpty(recipeID))
            {
                errorInfo = "输入参数RecipeID 为空字串";
                return(false);
            }

            IJFImage markImg1 = GetMethodInputValue("MarkImage1") as IJFImage;

            if (null == markImg1)
            {
                errorInfo = "MarkImage1 is null";
                return(false);
            }

            IJFImage markImg2 = GetMethodInputValue("MarkImage2") as IJFImage;

            if (null == markImg1)
            {
                errorInfo = "MarkImage1 is null";
                return(false);
            }

            IDLAFProductFixReceiver rcver = GetMethodInputValue("定位结果接收者") as IDLAFProductFixReceiver;

            if (null == rcver)
            {
                errorInfo = "定位结果接收者 未设置";
                return(false);
            }
            double markSnapX1 = Convert.ToDouble(GetMethodInputValue("MarkSanpX1"));
            double markSnapY1 = Convert.ToDouble(GetMethodInputValue("MarkSanpY1"));
            double markSnapX2 = Convert.ToDouble(GetMethodInputValue("MarkSanpX2"));
            double markSnapY2 = Convert.ToDouble(GetMethodInputValue("MarkSanpY2"));

            double[] icCenterX    = null;
            double[] icCenterY    = null;
            double[] fovOffsetX   = null;
            double[] fovOffsetY   = null;
            int      fixErrorCode = -1;
            string   fixErrorInfo = "软件功能未实现";
            //////////////////////////////////////////////添加定位算法流程

            IJFRecipeManager irm = JFHubCenter.Instance.RecipeManager;

            if (null == irm)
            {
                errorInfo         = "配方管理器未设置";
                rcver.PFErrorInfo = errorInfo;
                rcver.PFErrorCode = -1;

                return(false);
            }

            if (!irm.IsInitOK)
            {
                errorInfo         = "配方管理器未初始化 :" + irm.GetInitErrorInfo();
                rcver.PFErrorInfo = errorInfo;
                rcver.PFErrorCode = -1;
                return(false);
            }
            JFDLAFRecipeManager rm = irm as JFDLAFRecipeManager;

            if (null == rm)
            {
                errorInfo         = "配方管理器类型错误 :" + irm.GetType().Name;
                rcver.PFErrorInfo = errorInfo;
                rcver.PFErrorCode = -1;
                return(false);
            }

            JFDLAFProductRecipe recipe = rm.GetRecipe("Product", recipeID) as JFDLAFProductRecipe;

            if (null == recipe)
            {
                errorInfo         = "RecipeID =\"" + recipeID + "\" 在配方管理器中不存在";
                rcver.PFErrorInfo = errorInfo;
                rcver.PFErrorCode = -1;
                return(false);
            }

            ///使用原始拍照点位
            icCenterX = new double[recipe.ICCount];
            icCenterY = new double[recipe.ICCount];
            for (int i = 0; i < recipe.RowCount; i++)
            {
                for (int j = 0; j < recipe.ColCount; j++)
                {
                    recipe.GetICSnapCenter(i, j, out icCenterX[i * recipe.ColCount + j], out icCenterY[i * recipe.ColCount + j]);
                }
            }

            ///使用原始Fov偏移量
            fovOffsetX = new double[recipe.FovCount];
            fovOffsetY = new double[recipe.FovCount];
            for (int i = 0; i < recipe.FovCount; i++)
            {
                recipe.GetFovOffset(recipe.FovNames()[i], out fovOffsetX[i], out fovOffsetY[i]);
            }
            fixErrorCode = 0;


            //当前为演示代码,返回模板图像拍照位置
            rcver.PFRecipeID   = recipeID;
            rcver.PFErrorInfo  = fixErrorInfo;
            rcver.PFICCenterX  = icCenterX;
            rcver.PFICCenterY  = icCenterY;
            rcver.PFFovOffsetX = fovOffsetX;
            rcver.PFFovOffsetY = fovOffsetY;
            rcver.PFErrorCode  = fixErrorCode;


            errorInfo = "Success";
            return(true);
        }
Example #9
0
        /// <summary>
        /// 检查参数列表(是否有未设置选项)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btChkCfg_Click(object sender, EventArgs e)
        {
            string recipeID = cbRecipeID.Text;

            if (string.IsNullOrEmpty(recipeID))
            {
                MessageBox.Show("RecipeID未选择");
                return;
            }

            JFDLAFRecipeManager rm     = JFHubCenter.Instance.RecipeManager as JFDLAFRecipeManager;
            JFDLAFProductRecipe recipe = rm.GetRecipe(CategoteProduct, cbRecipeID.Text) as JFDLAFProductRecipe;

            if (null == recipe)
            {
                MessageBox.Show("RecipeID = \"" + recipeID + "\"产品配方不存在");
                return;
            }

            JFVisionManager vm = JFHubCenter.Instance.VisionMgr;


            bool          isCfgOK   = true;
            StringBuilder errorInfo = new StringBuilder();
            string        mark1Cfg  = recipe.GetMark1LightCfg();

            if (string.IsNullOrEmpty(mark1Cfg))
            {
                isCfgOK = false;
                errorInfo.AppendLine("Mark1视觉配置未设置");
            }
            else
            {
                if (!vm.ContainSingleVisionCfgByName(mark1Cfg))
                {
                    isCfgOK = false;
                    errorInfo.AppendLine("Mark1视觉参数:\"" + mark1Cfg + "\" 在视觉配置表中不存在");
                }
            }


            string mark2Cfg = recipe.GetMark2LightCfg();

            if (string.IsNullOrEmpty(mark2Cfg))
            {
                isCfgOK = false;
                errorInfo.AppendLine("Mark2视觉配置未设置");
            }
            else
            {
                if (!vm.ContainSingleVisionCfgByName(mark2Cfg))
                {
                    isCfgOK = false;
                    errorInfo.AppendLine("Mark2视觉参数:\"" + mark2Cfg + "\" 在视觉配置表中不存在");
                }
            }

            string[] allFovNames = recipe.FovNames();
            if (null != allFovNames)
            {
                foreach (string fovName in allFovNames)
                {
                    string[] taskNames = recipe.TaskNames(fovName);
                    if (null != taskNames)
                    {
                        foreach (string taskName in taskNames)
                        {
                            string vcName = recipe.VisionCfgName(fovName, taskName);
                            if (string.IsNullOrEmpty(vcName))
                            {
                                isCfgOK = false;
                                errorInfo.AppendLine("Fov:\"" + fovName + "\" Task:\"" + taskName + "\" 视觉参数未设置");
                            }
                            else
                            {
                                if (!vm.ContainSingleVisionCfgByName(vcName))
                                {
                                    isCfgOK = false;
                                    errorInfo.AppendLine("Fov:\"" + fovName + "\" Task:\"" + taskName + "\" 视觉参数:\"" + vcName + "\"在视觉配置中不存在");
                                }
                            }
                        }
                    }
                }
            }
            if (isCfgOK)
            {
                MessageBox.Show("所有视觉参数已配置完成!");
                return;
            }
            else
            {
                MessageBox.Show(errorInfo.ToString());
                return;
            }
        }
Example #10
0
        /// <summary>
        /// 产品ID改变
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cbRecipeID_SelectedIndexChanged(object sender, EventArgs e)
        {
            string errorInfo;

            if (cbRecipeID.SelectedIndex < 0)
            {
                _station.SetRecipeID(null, out errorInfo);
                gbFixProduct.Enabled = false;
                gbFixIC.Enabled      = false;
                gbFixFov.Enabled     = false;
                gbTaskSave.Enabled   = false;
                gbVisionGrab.Enabled = false;
                btChkCfg.Enabled     = false;
                btFlushVc.Enabled    = false;

                return;
            }

            if (!_station.SetRecipeID(cbRecipeID.Text, out errorInfo))
            {
                MessageBox.Show(errorInfo);
                cbRecipeID.Text = _station.CurrRecipeID();
                return;
            }
            string currRecipeID    = cbRecipeID.Text;
            JFDLAFRecipeManager rm = JFHubCenter.Instance.RecipeManager as JFDLAFRecipeManager;

            string[] allRecipeIDs = rm.AllRecipeIDsInCategoty(CategoteProduct);
            if (string.IsNullOrEmpty(currRecipeID) ||
                allRecipeIDs == null ||
                !allRecipeIDs.Contains(currRecipeID))
            {
                gbFixProduct.Enabled = false;
                gbFixFov.Enabled     = false;
                gbFixIC.Enabled      = false;
                gbTaskSave.Enabled   = false;
                gbVisionGrab.Enabled = false;
                btChkCfg.Enabled     = false;
                btFlushVc.Enabled    = false;
                return;
            }

            gbFixProduct.Enabled = true;
            gbFixFov.Enabled     = true;
            gbFixIC.Enabled      = true;
            gbTaskSave.Enabled   = true;
            gbVisionGrab.Enabled = true;
            btChkCfg.Enabled     = true;
            btFlushVc.Enabled    = true;

            JFDLAFProductRecipe recipe = rm.GetRecipe(CategoteProduct, currRecipeID) as JFDLAFProductRecipe;

            _isMark1VcEdit = false; //Mark1视觉参数是否正在配置
            _isMark2VcEdit = false;
            //btFixMark1.Text = "Vc"; //Vision Config
            //btFixMark2.Text = "Vc";
            btMark1EditSave.Text = "Vc";
            btMark2EditSave.Text = "Vc";
            // cbMarkVc1.Text = recipe.Mark1VisionCfgName;
            cbMarkVc1.Enabled = false;
            cbMarkVc2.Enabled = false;
            //cbMarkVc2.Text = recipe.Mark2VisionCfgName;
            double x1, y1, x2, y2;

            recipe.GetMarkSnapPos1(out x1, out y1);
            recipe.GetMarkSnapPos2(out x2, out y2);
            lbMarPos.Text = string.Format("x1:{0:F3} y1:{1:F3} \nx2:{2:F3} y2:{3:F3}", x1, y1, x2, y2);
            string mark1VcName = recipe.GetMark1LightCfg();
            string mark2VcName = recipe.GetMark2LightCfg();

            cbMarkVc1.Text = mark1VcName;
            cbMarkVc2.Text = mark2VcName;

            string currRowSel = cbIcRow.Text;
            string currColSel = cbIcCol.Text;

            cbIcRow.Items.Clear();
            for (int i = 0; i < recipe.RowCount; i++)
            {
                cbIcRow.Items.Add(i.ToString());
            }
            if (!string.IsNullOrEmpty(currRowSel))
            {
                if (Convert.ToInt32(currRowSel) < recipe.RowCount)
                {
                    cbIcRow.Text = currRowSel;
                }
                else
                {
                    cbIcRow.Text = "";
                }
            }

            cbIcCol.Items.Clear();
            for (int i = 0; i < recipe.ColCount; i++)
            {
                cbIcCol.Items.Add(i.ToString());
            }
            if (!string.IsNullOrEmpty(currColSel))
            {
                if (Convert.ToInt32(currColSel) < recipe.ColCount)
                {
                    cbIcCol.Text = currColSel;
                }
                else
                {
                    cbIcCol.Text = "";
                }
            }


            string currFovSel = cbFovName.Text;

            string[] allFovNames = recipe.FovNames();
            cbFovName.Items.Clear();
            if (null != allFovNames && allFovNames.Length > 0)
            {
                foreach (string s in allFovNames)
                {
                    cbFovName.Items.Add(s);
                }
            }

            if (!string.IsNullOrEmpty(currFovSel))
            {
                cbFovName.Text = currFovSel;
                if (allFovNames != null && allFovNames.Contains(currFovSel))
                {
                    cbFovName.BackColor = SystemColors.Control;
                }
                else
                {
                    cbFovName.BackColor = Color.OrangeRed;
                }
            }

            string currTaskNameSel = cbTaskName.Text;

            string[] allTaskNames = null;
            cbTaskName.Items.Clear();
            if (!string.IsNullOrEmpty(currFovSel))
            {
                allTaskNames = recipe.TaskNames(currFovSel);
                if (null != allTaskNames && allFovNames.Length > 0)
                {
                    foreach (string s in allTaskNames)
                    {
                        cbTaskName.Items.Add(s);
                    }
                }
            }

            if (!string.IsNullOrEmpty(currTaskNameSel))
            {
                cbTaskName.Text = currTaskNameSel;

                if (allTaskNames != null && allTaskNames.Contains(currTaskNameSel))
                {
                    cbTaskName.BackColor = SystemColors.Control;
                }
                else
                {
                    cbTaskName.BackColor = Color.OrangeRed;
                }
            }
        }