예제 #1
0
        public void Save()
        {
            if (!IsInitOK)
            {
                return;
            }
            JFXmlDictionary <string, List <string[]> > dctRecipesInCfg = _cfg.GetItemValue("Cate-Recipes") as JFXmlDictionary <string, List <string[]> >;

            foreach (string categoty in _dctRecipes.Keys)
            {
                Dictionary <string, JFCommonRecipe> dctMmry = _dctRecipes[categoty]; //所有recipe内存对象
                List <string[]> lstInCfg = dctRecipesInCfg[categoty];
                foreach (KeyValuePair <string, JFCommonRecipe> kv in dctMmry)
                {
                    foreach (string[] idAndTxt in lstInCfg)
                    {
                        if (idAndTxt[0] == kv.Key)
                        {
                            string xmlTxt  = null;
                            string typeTxt = null;
                            JFFunctions.ToXTString(kv.Value.Dict, out xmlTxt, out typeTxt);
                            idAndTxt[1] = xmlTxt;
                            break;
                        }
                    }
                }
            }
            _cfg.Save();
        }
예제 #2
0
        public void SaveStationParams()
        {
            try
            {
                string recipeID = (string)JFHubCenter.Instance.SystemCfg.GetItemValue("CurrentID");
                //工站参数
                SetCfgParamValue(mwidth, width.D);
                SetCfgParamValue(mheight, height.D);
                SetCfgParamValue(mRunMode, RunMode);
                SetCfgParamValue(mNum_Camera, Num_Camera);
                SetCfgParamValue(mSelectIndex, SelectedIndex);
                SetCfgParamValue(mZ_safe, Z_safe);

                //工站中默认的参数
                AddDictItem(mgenMapStartX, genMapStartX);
                AddDictItem(mgenMapStartY, genMapStartY);
                AddDictItem(mgenMapEndX, genMapEndX);
                AddDictItem(mgenMapEndY, genMapEndY);
                AddDictItem(msameSpace, sameSpace);
                AddDictItem(mlctScoreThresh, lctScoreThresh);
                AddDictItem(mcheckMdlMethod, checkMdlMethod);
                AddDictItem(musedoubleCheck, usedoubleCheck);
                //AddDictItem(mZFocus, ZFocus);

                double value = hv_dieWidth.D;
                AddDictItem(mdieWidth, value);
                value = hv_dieHeight.D;
                AddDictItem(mdieHeight, value);

                AddDictItem(mref_x, ref_x);
                AddDictItem(mref_y, ref_y);
                AddDictItem(mref_z, ref_z);
                AddDictItem(mscanRowNum, scanRowNum);
                AddDictItem(mscanColNum, scanColNum);
                AddDictItem(mclipPosNum, clipPosNum);
                AddDictItem(mscanPosNum, scanPosNum);

                string xmlTxt  = null;
                string typeTxt = null;
                JFFunctions.ToXTString(visionCfgParams, out xmlTxt, out typeTxt);
                AddDictItem(mVisionCfgName, xmlTxt);

                AddDictItem(mFovRow, ICFovRow);
                AddDictItem(mFovCol, ICFovCol);

                JFFunctions.ToXTString(Dict, out xmlTxt, out typeTxt);

                //若工站xml配置中不需要保存参数,则注释该行即可,那么工站参数仅会保存在Recipe manager中;
                SetCfgParamValue(recipeID, xmlTxt);

                jFDLAFProductRecipe.AutoMappingStationProInf = xmlTxt;
                jFDLAFProductRecipe.SaveParamsToCfg();
                JFHubCenter.Instance.RecipeManager.Save();
            }
            catch
            {
            }
        }
예제 #3
0
        private void btOK_Click(object sender, EventArgs e)
        {
            if (null == _mgr)
            {
                MessageBox.Show("无效操作,RecipeManager未设置");
                return;
            }

            if (!_mgr.IsInitOK)
            {
                MessageBox.Show("无效操作,RecipeManager未初始化,ErrorInfo:" + _mgr.GetInitErrorInfo());
                return;
            }

            if (string.IsNullOrWhiteSpace(cbGenCate.Text))
            {
                MessageBox.Show("参数项 Categoty 不能为空值!");
                return;
            }

            if (string.IsNullOrWhiteSpace(tbGenID.Text))
            {
                MessageBox.Show("参数项 RecipeID 不能为空值!");
                return;
            }

            string[] existIDs = _mgr.AllRecipeIDsInCategoty(cbGenCate.Text);
            if (null != existIDs && existIDs.Contains(tbGenID.Text))
            {
                MessageBox.Show("添加Recipe失败,Categoty = " + cbGenCate.Text + "已包含当前RecipeID = " + tbGenID.Text);
                return;
            }

            JFCommonRecipe newRecipe = new JFCommonRecipe();

            newRecipe.Categoty = cbGenCate.Text;
            newRecipe.ID       = tbGenID.Text;
            if (chkCopy.Checked) //以拷贝的方式创建新的Recipe
            {
                if (string.IsNullOrEmpty(cbCopyCate.Text))
                {
                    MessageBox.Show("请选择待拷贝的Categoty!");
                    return;
                }

                if (string.IsNullOrEmpty(cbCopyID.Text))
                {
                    MessageBox.Show("请选择待拷贝的RecipeID!");
                    return;
                }

                JFCommonRecipe recipe = _mgr.GetRecipe(cbCopyCate.Text, cbCopyID.Text) as JFCommonRecipe;
                string         xmlTxt;
                string         typeTxt;
                JFFunctions.ToXTString(recipe.Dict, out xmlTxt, out typeTxt);
                newRecipe.Dict = JFFunctions.FromXTString(xmlTxt, typeTxt) as JFXmlDictionary <string, object>;
            }


            _mgr.AddRecipe(cbGenCate.Text, tbGenID.Text, newRecipe);
            _mgr.Save();
            DialogResult = DialogResult.OK;
        }