Exemple #1
0
        /// <summary>
        /// 获取型号模板列表
        /// </summary>
        /// <param name="productModels"></param>
        /// <returns></returns>
        public static bool GetProductModelList(out List <ProductModel> productModels)
        {
            productModels = new List <ProductModel>();
            if (!MyRun.havInit)
            {
                StrErrorMsg = "视觉模块未初始化";
                return(false);
            }
            try
            {
                string path = MyRun.appPath + "\\model";
                Directory.CreateDirectory(path);
                DirectoryInfo   theFolder        = new DirectoryInfo(path);
                DirectoryInfo[] thedirectoryInfo = theFolder.GetDirectories();

                foreach (var directory in thedirectoryInfo)
                {
                    ProductModel model = MyRun.ReadModelJS(directory.Name);
                    if (model != null)
                    {
                        productModels.Add(model);
                    }
                }
            }
            catch (Exception e)
            {
                StrErrorMsg = "模板型号列表获取失败" + e.Message;
                return(false);
            }
            return(true);
        }
Exemple #2
0
        public static bool GetTemplateImage(string modelName, string itemName, out Bitmap bigImage, out Bitmap smallImage)
        {
            bigImage   = null;
            smallImage = null;
            if (!MyRun.havInit)
            {
                StrErrorMsg = "视觉模块未初始化";
                return(false);
            }
            ProductModel model = MyRun.ReadModelJS(modelName);

            if (model is null)
            {
                StrErrorMsg = "模板" + modelName + "不存在";
                return(false);
            }
            if (MyRun.GetTemplateImage(modelName, itemName, out bigImage, out smallImage))
            {
                return(true);
            }
            else
            {
                StrErrorMsg = MyRun.StrErrorMsg;
                return(false);
            }
        }
        public static void GetProductModelNameList(out List <string> modelNameList)
        {
            modelNameList = new List <string>();
            string path = MyRun.appPath + "\\model";

            Directory.CreateDirectory(path);
            DirectoryInfo theFolder = new DirectoryInfo(path);

            DirectoryInfo[] thedirectoryInfo = theFolder.GetDirectories();

            foreach (var directory in thedirectoryInfo)
            {
                ProductModel model = MyRun.ReadModelJS(directory.Name);
                if (model != null)
                {
                    modelNameList.Add(model.modelName);
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// 切换型号模板
        /// </summary>
        /// <param name="modelName">模板名</param>
        /// <returns></returns>
        public static bool PrepareModel(string modelName)
        {
            if (!MyRun.havInit)
            {
                StrErrorMsg = "视觉模块未初始化";
                return(false);
            }
            UseModel = MyRun.ReadModelJS(modelName);
            if (UseModel is null)
            {
                StrErrorMsg = "模板" + modelName + "不存在";
                return(false);
            }

            UseCamsName.Clear();
            foreach (var cam in UseModel.cams)
            {
                UseCamsName.Add(cam.CamName);
                if (!MyRun.IsCamConnect(cam.CamName))
                {
                    StrErrorMsg = "相机" + cam.CamName + "未连接";
                }
            }

            UseMatchingFun.Clear();
            foreach (var matching in UseModel.matchings)
            {
                MatchingFun matchingFun = MyRun.GetMatchingFun(matching.Type);
                matchingFun.Read(MyRun.appPath + "\\model\\" + UseModel.modelName, matching);
                UseMatchingFun.Add(matchingFun);
            }

            UseTestItems.Clear();
            foreach (var testItem in UseModel.testItems)
            {
                UseTestItems.Add(MyRun.GetTestItem(testItem));
            }

            return(true);
        }