Пример #1
0
        /// <summary>
        /// 保存产品
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void btnSave_Click(object sender, EventArgs e)
        {
            Form_Wait.ShowForm();
            await Task.Run(new Action(() =>
            {
                //需要保存当前产品的相关参数
                if (_operation != null)
                {
                    JFDLAFBoxRecipe jFDLAFBoxRecipe = JFHubCenter.Instance.RecipeManager.GetRecipe("Box", (string)JFHubCenter.Instance.SystemCfg.GetItemValue("CurrentID")) as JFDLAFBoxRecipe;
                    jFDLAFBoxRecipe.MagezineBox = _operation.MagezineBox;
                    jFDLAFBoxRecipe.MgzIdx = _operation.MgzIdx;
                    jFDLAFBoxRecipe.SaveParamsToCfg();
                    _operation.SaveParamsToCfg();

                    JFHubCenter.Instance.RecipeManager.RemoveRecipe("Product", (string)JFHubCenter.Instance.SystemCfg.GetItemValue("CurrentID"));
                    JFHubCenter.Instance.RecipeManager.RemoveRecipe("Box", (string)JFHubCenter.Instance.SystemCfg.GetItemValue("CurrentID"));

                    JFHubCenter.Instance.RecipeManager.AddRecipe(_operation.Categoty, _operation.ID, _operation as IJFRecipe);
                    JFHubCenter.Instance.RecipeManager.AddRecipe("Box", _operation.ID, jFDLAFBoxRecipe as IJFRecipe);
                }

                JFHubCenter.Instance.RecipeManager.Save();
                if (_operation != null)
                {
                    if (_operation.MgzIdx == -1)
                    {
                        HTLog.Error("注意:当前产品未选择料盒型号,开始流程需要选择料盒型号.");
                        return;
                    }
                }
            }));

            Form_Wait.CloseForm();
        }
Пример #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
        /// <summary>
        /// 创建产品
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCreateProduct_Click(object sender, EventArgs e)
        {
            String newfile = "";

            if (!MSG.Inputbox("Copy&New", "请输入新的产品名", out newfile))
            {
                return;
            }

            if (newfile == string.Empty)
            {
                HTUi.PopWarn("命名错误,名字不能为空");
                return;
            }
            //新增Product Recipe到recipe Dictionary中
            JFDLAFProductRecipe jFDLAFProductRecipe = new JFDLAFProductRecipe();

            if (JFHubCenter.Instance.RecipeManager.GetRecipe("Product", (string)JFHubCenter.Instance.SystemCfg.GetItemValue("CurrentID")) != null)
            {
                jFDLAFProductRecipe = ((JFDLAFProductRecipe)JFHubCenter.Instance.RecipeManager.GetRecipe("Product", (string)JFHubCenter.Instance.SystemCfg.GetItemValue("CurrentID"))).Clone();
            }

            jFDLAFProductRecipe.ID       = newfile;
            jFDLAFProductRecipe.Categoty = "Product";
            jFDLAFProductRecipe.SaveParamsToCfg();
            JFHubCenter.Instance.RecipeManager.AddRecipe(jFDLAFProductRecipe.Categoty, jFDLAFProductRecipe.ID, jFDLAFProductRecipe as IJFRecipe);


            ////新增Box Recipe到recipe Dictionary中
            JFDLAFBoxRecipe jFDLAFBoxRecipe = new JFDLAFBoxRecipe();

            if (JFHubCenter.Instance.RecipeManager.GetRecipe("Box", (string)JFHubCenter.Instance.SystemCfg.GetItemValue("CurrentID")) != null)
            {
                jFDLAFBoxRecipe = ((JFDLAFBoxRecipe)JFHubCenter.Instance.RecipeManager.GetRecipe("Box", (string)JFHubCenter.Instance.SystemCfg.GetItemValue("CurrentID"))).Clone();
            }
            jFDLAFBoxRecipe.MagezineBox = jFDLAFProductRecipe.MagezineBox;
            jFDLAFBoxRecipe.MgzIdx      = jFDLAFProductRecipe.MgzIdx;
            jFDLAFBoxRecipe.ID          = newfile;
            jFDLAFBoxRecipe.Categoty    = "Box";
            jFDLAFBoxRecipe.SaveParamsToCfg();
            JFHubCenter.Instance.RecipeManager.AddRecipe(jFDLAFBoxRecipe.Categoty, jFDLAFBoxRecipe.ID, jFDLAFBoxRecipe as IJFRecipe);

            //此处后面需要保存
            JFHubCenter.Instance.RecipeManager.Save();

            var pdtlist = GetProductList();

            foreach (var pdt in pdtlist)
            {
                if (pdt == newfile)
                {
                    HTUi.PopWarn("无法新建,当前产品已存在");
                    return;
                }
            }
            string souce = (string)JFHubCenter.Instance.SystemCfg.GetItemValue("CurrentID");

            if (!CreateProduct(souce, newfile))
            {
                HTUi.PopWarn("产品创建失败!");
                return;
            }
            HTLog.Info("产品创建成功!");
            HTUi.TipHint("产品创建成功!");
            lbxProductCategory.DataSource = GetProductList();
            return;
        }