Example #1
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 #2
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;
                }
            }
        }