コード例 #1
0
        int  _ImgCount()
        {
            if (null == _recipe)
            {
                return(-1);
            }
            int count = 0;

            string[] fovNames = _recipe.FovNames();
            foreach (string fov in fovNames)
            {
                count += _recipe.TaskNames(fov).Length;
            }
            return(count);
        }
コード例 #2
0
        /// <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;
            }
        }
コード例 #3
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;
                }
            }
        }
コード例 #4
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, "");
        }
コード例 #5
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;
            }
        }
コード例 #6
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;
                }
            }
        }