Exemplo n.º 1
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;
                }
            }
        }