예제 #1
0
        /// <summary>
        /// 根据当前所选ProductID更新Map控件
        /// </summary>
        /// <param name="recipeID"></param>
        void UpdateMappingByProdID(string recipeID)
        {
            if (string.IsNullOrEmpty(recipeID))
            {
                mappCtrl.Initial(0, 0, _dctDieStateColor, "未检测");
                mappCtrl.IsShowBottomBar = true;
                return;
            }
            JFDLAFRecipeManager rm = JFHubCenter.Instance.RecipeManager as JFDLAFRecipeManager;

            _currRecipe = rm.GetRecipe(MainStation.SCN_CategotyProd, recipeID) as JFDLAFProductRecipe;
            if (null == _currRecipe)
            {
                mappCtrl.Initial(0, 0, _dctDieStateColor, "未检测");
                mappCtrl.IsShowBottomBar = true;

                return;
            }


            int dieRow = _currRecipe.RowNumber;;      //料片中的die行数
            int dieCol = _currRecipe.ColumnNumber * _currRecipe.BlockNumber;;


            mappCtrl.Initial(dieRow, dieCol, _dctDieStateColor, "未检测");
            mappCtrl.MinCellHeight   = 5;
            mappCtrl.MinCellWidth    = 5;
            mappCtrl.IsShowBottomBar = true;



            cbTaskImgShow.Items.Clear();
            List <string> allTaskNames = new List <string>();

            string[] allFovNames = _currRecipe.FovNames();
            if (null != allFovNames)
            {
                List <string> taskNamesExisted = new List <string>();
                foreach (string fovName in allFovNames)
                {
                    string[] taskNames = _currRecipe.TaskNames(fovName);
                    if (taskNames != null)
                    {
                        foreach (string taskName in taskNames)
                        {
                            if (!taskNamesExisted.Contains(taskName))
                            {
                                taskNamesExisted.Add(taskName);
                                cbTaskImgShow.Items.Add(taskName);
                            }
                        }
                    }
                }
            }

            if (cbTaskImgShow.Items.Count > 0)
            {
                cbTaskImgShow.SelectedIndex = 0;
            }
        }
예제 #2
0
        private void cbIcCol_SelectedIndexChanged(object sender, EventArgs e)
        {
            string recipeID = cbRecipeID.Text;

            if (string.IsNullOrEmpty(recipeID))
            {
                return;
            }
            JFDLAFRecipeManager rm     = JFHubCenter.Instance.RecipeManager as JFDLAFRecipeManager;
            JFDLAFProductRecipe recipe = rm.GetRecipe(CategoteProduct, cbRecipeID.Text) as JFDLAFProductRecipe;

            if (null == recipe)
            {
                return;
            }
            if (cbIcRow.SelectedIndex < 0)
            {
                return;
            }
            if (cbIcCol.SelectedIndex < 0)
            {
                return;
            }


            double x, y;

            recipe.GetICSnapCenter(Convert.ToInt32(cbIcRow.SelectedItem), Convert.ToInt32(cbIcCol.SelectedItem), out x, out y);
            lbICPos.Text = string.Format("x:{0:F3} y:{1:F3}", x, y);
        }
예제 #3
0
        void AdjustStationView()
        {
            if (InvokeRequired)
            {
                Invoke(new Action(AdjustStationView));
                return;
            }
            JFDLAFRecipeManager rm = JFHubCenter.Instance.RecipeManager as JFDLAFRecipeManager;

            if (null == rm || !rm.IsInitOK)
            {
                btEditSave.Enabled      = false;
                cbRecipeID.Text         = "配方管理器无效";
                rchDetectInfo.Text      = "配方管理器无效";
                lstBoxPieceIDs.Enabled  = false;
                btUpdateInspect.Enabled = false;
                return;
            }

            if (_station != null)
            {
                cbRecipeID.Text   = _station.RecipeID;
                cbLotID.Text      = _station.LotID;
                rchPicFolder.Text = _station.TestPicFolder;
            }

            UpdateParamPanel();
            UpdateMapCtrl();
            UpdatePieceIDList();
        }
예제 #4
0
        /// <summary>
        /// Fov 选择改变
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cbFovName_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cbFovName.SelectedIndex < 0)
            {
                cbTaskName.Text  = "";
                btFixFov.Enabled = false;
                return;
            }
            string currFovName         = cbFovName.Text;
            string currTaskName        = cbTaskName.Text;
            JFDLAFRecipeManager rm     = JFHubCenter.Instance.RecipeManager as JFDLAFRecipeManager;
            JFDLAFProductRecipe recipe = rm.GetRecipe(CategoteProduct, cbRecipeID.Text) as JFDLAFProductRecipe;

            string[] allFovNames = recipe.FovNames();
            if (!allFovNames.Contains(currFovName))
            {
                MessageBox.Show("当前Recipe未包含FovName:" + currFovName);
                cbTaskName.Text  = "";
                btFixFov.Enabled = false;
                return;
            }

            btFixFov.Enabled = true;

            double x, y;

            recipe.GetFovOffset(currFovName, out x, out y);
            lbFovOffset.Text = string.Format("x:{0:F3} y:{1:F3}", x, y);


            string[] allTaskNames = recipe.TaskNames(currFovName);
            cbTaskName.Items.Clear();
            if (null != allTaskNames)
            {
                foreach (string s in allTaskNames)
                {
                    cbTaskName.Items.Add(s);
                }
            }
            if (!string.IsNullOrEmpty(currTaskName))
            {
                if (_isTaskVcEditting)
                {
                    _isTaskVcEditting          = false;
                    cbTaskVc.Enabled           = false;
                    btTaskVcEditCancel.Enabled = false;
                    btTaskVcEditSave.Text      = "设置";
                }
                cbTaskName.Text = currTaskName;

                if (allTaskNames != null && allTaskNames.Contains(currTaskName))
                {
                    cbTaskName.BackColor = SystemColors.Control;
                }
                else
                {
                    cbTaskName.BackColor = Color.OrangeRed;
                }
            }
        }
예제 #5
0
        private void cbTaskName_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cbTaskName.SelectedIndex < 0)
            {
                return;
            }

            string currFovName         = cbFovName.Text;
            string currTaskName        = cbTaskName.Text;
            JFDLAFRecipeManager rm     = JFHubCenter.Instance.RecipeManager as JFDLAFRecipeManager;
            JFDLAFProductRecipe recipe = rm.GetRecipe(CategoteProduct, cbRecipeID.Text) as JFDLAFProductRecipe;
            string taskVcName          = recipe.VisionCfgName(currFovName, currTaskName);

            if (string.IsNullOrEmpty(taskVcName))
            {
                cbTaskVc.SelectedIndex = -1;
                return;
            }

            cbTaskVc.Text = taskVcName;

            string[] allVcNames = JFHubCenter.Instance.VisionMgr.SingleVisionCfgNameByOwner(cbRecipeID.Text);
            if (allVcNames != null && allVcNames.Contains(taskVcName))
            {
                cbTaskVc.BackColor = SystemColors.Control;
            }
            else
            {
                cbTaskVc.BackColor = Color.OrangeRed;
            }
        }
예제 #6
0
        HObject _hoFullImg = null; //Recipe全图

        void UpdateMapCtrl()
        {
            string currSelRecipeID = cbRecipeID.Text;

            if (string.IsNullOrEmpty(currSelRecipeID))
            {
                mapDetectCells.Initial(1, 1, _dctDieStateColor, "未检测");
                htFullImg.Refresh();
                return;
            }
            JFDLAFRecipeManager rm = JFHubCenter.Instance.RecipeManager as JFDLAFRecipeManager;

            if (null == rm || !rm.IsInitOK)
            {
                mapDetectCells.Initial(1, 1, _dctDieStateColor, "未检测");
                htFullImg.Refresh();
                return;
            }
            JFDLAFProductRecipe recipe = rm.GetRecipe("Product", currSelRecipeID) as JFDLAFProductRecipe;

            if (null == recipe)
            {
                mapDetectCells.Initial(1, 1, _dctDieStateColor, "未检测");
                htFullImg.Refresh();
                return;
            }

            {
                int row = recipe.RowCount;
                int col = recipe.ColCount * recipe.FovCount;
                mapDetectCells.Initial(row, col, _dctDieStateColor, "未检测");
            }

            string fullImgPath = recipe.GetFrameMapImgFullPath(currSelRecipeID);

            if (string.IsNullOrEmpty(fullImgPath))
            {
                htFullImg.Refresh();
                return;
            }

            if (!File.Exists(fullImgPath))
            {
                htFullImg.Refresh();
                return;
            }

            if (null != _hoFullImg)
            {
                _hoFullImg.Dispose();
                _hoFullImg = null;
            }
            HOperatorSet.GenEmptyObj(out _hoFullImg);
            HOperatorSet.ReadImage(out _hoFullImg, fullImgPath);
            htFullImg.DispImage(_hoFullImg);
        }
예제 #7
0
        /// <summary>
        /// 取消 Task参数编辑
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btTaskVcEditCancel_Click(object sender, EventArgs e)
        {
            _isTaskVcEditting          = false;
            cbTaskName.Enabled         = true;
            cbTaskVc.Enabled           = false;
            btTaskVcEditSave.Text      = "编辑";
            btTaskVcEditCancel.Enabled = false;
            JFDLAFRecipeManager rm     = JFHubCenter.Instance.RecipeManager as JFDLAFRecipeManager;
            JFDLAFProductRecipe recipe = rm.GetRecipe(CategoteProduct, cbRecipeID.Text) as JFDLAFProductRecipe;

            string taskVcName = recipe.VisionCfgName(cbFovName.Text, cbTaskName.Text);

            cbTaskVc.Text = taskVcName;
        }
예제 #8
0
        /// <summary>
        /// 切换当前产品ID
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btSetProdID_Click(object sender, EventArgs e)
        {
            FormObtainBarcode dlg = new FormObtainBarcode();

            dlg.StartPosition = FormStartPosition.CenterScreen;
            dlg.Text          = "输入产品ID";
            string lastProdID = _ms.CurrRecipeID;

            if (string.IsNullOrEmpty(lastProdID))
            {
                lastProdID = JFHubCenter.Instance.SystemCfg.GetItemValue(MainStation.SCN_CurrentRecipeID) as string;
            }
            dlg.SetInitBarcode(lastProdID);
            JFDLAFRecipeManager rm = JFHubCenter.Instance.RecipeManager as JFDLAFRecipeManager;

            if (null != rm && rm.IsInitOK)
            {
                string[] allRecipeIDs = rm.AllRecipeIDsInCategoty(MainStation.SCN_CategotyProd);
                dlg.SetBarcodeOptions(allRecipeIDs);
            }

            dlg.ObtainMode = FormObtainBarcode.OBMode.Scanner;
            while (DialogResult.OK == dlg.ShowDialog())
            {
                string errorInfo;
                if (_ms.CurrRecipeID == dlg.Barcode && !string.IsNullOrEmpty(dlg.Barcode))
                {
                    return;
                }
                bool isSetProdIDOK = _ms.SetCurrRecipeID(dlg.Barcode, out errorInfo);
                if (isSetProdIDOK)
                {
                    lbProdID.Text      = dlg.Barcode;
                    lbProdID.ForeColor = Color.Black;
                    UpdateMappingByProdID(dlg.Barcode);
                    //if (!string.IsNullOrEmpty(_ms.CurrLotID))
                    //    _detectResultTransfer.SetRecipeLot(_ms.CurrRecipeID, _ms.CurrLotID, out string err);
                    break;
                }
                else
                {
                    if (DialogResult.Yes != MessageBox.Show("设置产品ID失败,错误信息:" + errorInfo + "是否重新输入?", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
                    {
                        break;
                    }
                }
            }
        }
        /// <summary>
        /// 设置产品信号/批次号
        /// </summary>
        /// <param name="recipeID"></param>
        /// <param name="lotID"></param>
        /// <param name="errorInfo"></param>
        /// <returns></returns>
        public bool SetRecipeLot(string recipeID, string lotID, out string errorInfo)
        {
            if (string.IsNullOrEmpty(recipeID))
            {
                errorInfo = "参数RecipeID为空字串";
                _recipeID = null;
                return(false);
            }
            JFDLAFRecipeManager rm = JFHubCenter.Instance.RecipeManager as JFDLAFRecipeManager;

            if (null == rm || !rm.IsInitOK)
            {
                errorInfo = "配方管理器未设置/未初始化!";
                _recipeID = null;
                return(false);
            }
            string[] allRecipeIDS = rm.AllRecipeIDsInCategoty("Product");
            if (null == allRecipeIDS || !allRecipeIDS.Contains(recipeID))
            {
                errorInfo = "RecipeID:\"" + recipeID + "\"在配方管理器中不存在!";
                _recipeID = null;
                return(false);
            }
            _recipeID = recipeID;
            _recipe   = rm.GetRecipe("Product", _recipeID) as JFDLAFProductRecipe;


            if (string.IsNullOrEmpty(lotID))
            {
                _lotID    = null;
                errorInfo = "参数项LotID为空值";
                return(false);
            }

            _lotID = lotID;

            int fovCountInPiece = _recipe.FovCount * _recipe.ICCount;//料片所有Fov数量

            _fovResults  = new DlafFovDetectResult[fovCountInPiece];
            _fovCounteds = new bool[fovCountInPiece];



            errorInfo = "Success";
            return(true);
        }
예제 #10
0
        public bool SetCurrRecipeID(string recipeID, out string errorInfo)
        {
            if (string.IsNullOrEmpty(recipeID))
            {
                errorInfo = "产品ID为null/空字串";
                return(false);
            }
            if (!CheckRecipeMgr(out errorInfo))
            {
                return(false);
            }

            JFDLAFRecipeManager rm = JFHubCenter.Instance.RecipeManager as JFDLAFRecipeManager;

            string[] allRecipeIDs = rm.AllRecipeIDsInCategoty(SCN_CategotyProd);
            if (null == allRecipeIDs || !allRecipeIDs.Contains(recipeID))
            {
                errorInfo = "产品ID:\"" + recipeID + "\"在配方管理器中不存在";
                return(false);
            }
            if (WorkStatus == JFWorkStatus.Running || WorkStatus == JFWorkStatus.Interactiving || WorkStatus == JFWorkStatus.Pausing)
            {
                errorInfo = "正在运行,不能修改产品ID";
                return(false);
            }

            IJFDataPool dp   = JFHubCenter.Instance.DataPool;
            bool        isOK = dp.SetItemValue(SDN_CurrRecipeID, recipeID);

            if (!isOK)
            {
                errorInfo = "写入数据池失败";
            }
            else
            {
                //将当前产品信息写入SystemCfg
                JFXCfg sysCfg = JFHubCenter.Instance.SystemCfg;
                if (sysCfg.ContainsItem(SCN_CurrentRecipeID))
                {
                    sysCfg.SetItemValue(SCN_CurrentRecipeID, recipeID); //将当前产品ID 加到配置项中
                    sysCfg.Save();
                }
                errorInfo = "Success";
            }
            return(isOK);
        }
예제 #11
0
        public bool InitInspectNode(string recipeID, out string errorInfo)
        {
            if (string.IsNullOrEmpty(recipeID))
            {
                errorInfo = "参数recipeID 为空字串";
                return(false);
            }
            Inspect_Node node;

            if (!_dctInspect.ContainsKey(recipeID))
            {
                string recipePath      = "";
                string modelPath       = "";
                JFDLAFRecipeManager rm = JFHubCenter.Instance.RecipeManager as JFDLAFRecipeManager;
                if (rm == null)
                {
                    errorInfo = "配方管理器为空!";
                    return(false);
                }

                if (!rm.IsInitOK)
                {
                    errorInfo = "配方管理器未初始化:" + rm.GetInitErrorInfo();
                    return(false);
                }

                string rmPath = rm.GetInitParamValue("配方保存路径") as string;

                recipePath = rmPath + "\\" + recipeID + "\\Recipe\\";
                modelPath  = rmPath + "\\" + recipeID + "\\Models\\";


                node = new Inspect_Node(null, modelPath, recipePath);
                _dctInspect.Add(recipeID, node);
            }

            node = _dctInspect[recipeID];

            if (!node.InitInspectParam(out errorInfo))
            {
                return(false);
            }
            errorInfo = "Success";
            return(true);
        }
예제 #12
0
        /// <summary>
        /// 调整视觉配置为当前Task所选
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btFixTask_Click(object sender, EventArgs e)
        {
            string recipeID = cbRecipeID.Text;
            string fovName  = cbFovName.Text;
            string taskName = cbTaskName.Text;

            if (string.IsNullOrEmpty(recipeID))
            {
                MessageBox.Show("请选择RecipeID");
                return;
            }
            if (string.IsNullOrEmpty(fovName))
            {
                MessageBox.Show("请选择Fov Name");
                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;
            }

            string taskVc = recipe.VisionCfgName(fovName, taskName);

            if (string.IsNullOrEmpty(taskVc))
            {
                MessageBox.Show("请先设置视觉配置");
                return;
            }

            string errorInfo = "";

            if (!_station.FixTaskVisionCfg(taskName, out errorInfo))
            {
                MessageBox.Show("操作失败:" + errorInfo);
                return;
            }
        }
예제 #13
0
        /// <summary>
        /// 更新视觉算子
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btUpdateInspect_Click(object sender, EventArgs e)
        {
            if (_station != null && _station.IsWorking())
            {
                MessageBox.Show("工站正在运行,不能更新算子");
                return;
            }
            if (ParamEditEnabled)
            {
                MessageBox.Show("请先完成参数设置!");
                return;
            }
            string recipeID = cbRecipeID.Text;

            if (string.IsNullOrEmpty(recipeID))
            {
                MessageBox.Show("请先选择RecipeID");
                return;
            }
            JFDLAFRecipeManager rm = JFHubCenter.Instance.RecipeManager as JFDLAFRecipeManager;

            if (null == rm || !rm.IsInitOK)
            {
                MessageBox.Show("配方管理器未设置/未初始化!");
                return;
            }
            JFDLAFInspectionManager inspMgr = JFDLAFInspectionManager.Instance;

            inspMgr.Clear();
            string errorInfo;

            if (!inspMgr.InitInspectNode(recipeID, out errorInfo))
            {
                MessageBox.Show("更新视觉算子失败,ErrorInfo:" + errorInfo);
                return;
            }
            MessageBox.Show("视觉算子已更新");
        }
예제 #14
0
        /// <summary>
        /// 设置/保存 Task视觉参数配置
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btTaskVcEditSave_Click(object sender, EventArgs e)
        {
            if (!_isTaskVcEditting)
            {
                string taskName = cbTaskName.Text;
                if (string.IsNullOrEmpty(taskName))
                {
                    MessageBox.Show("请选择需要设置的Task");
                    return;
                }

                _isTaskVcEditting          = true;
                cbTaskName.Enabled         = false;
                cbTaskVc.Enabled           = true;
                btTaskVcEditSave.Text      = "保存";
                btTaskVcEditCancel.Enabled = true;
            }
            else
            {
                string taskVcName = cbTaskVc.Text;
                if (string.IsNullOrEmpty(taskVcName))
                {
                    MessageBox.Show("请选择需要保存的视觉配置名称");
                    return;
                }
                _isTaskVcEditting          = false;
                cbTaskName.Enabled         = true;
                cbTaskVc.Enabled           = false;
                btTaskVcEditSave.Text      = "编辑";
                btTaskVcEditCancel.Enabled = false;
                JFDLAFRecipeManager rm     = JFHubCenter.Instance.RecipeManager as JFDLAFRecipeManager;
                JFDLAFProductRecipe recipe = rm.GetRecipe(CategoteProduct, cbRecipeID.Text) as JFDLAFProductRecipe;
                recipe.SetVisionCfgName(cbFovName.Text, cbTaskName.Text, taskVcName);
                JFTipsDelayClose.Show("已保存\"taskVcName\" 到:" + cbTaskName.Text, 1);
            }
        }
예제 #15
0
 private void btMark2EditSave_Click(object sender, EventArgs e)
 {
     if (!_isMark2VcEdit)
     {
         _isMark2VcEdit       = true;
         cbMarkVc2.Enabled    = true;
         btMark2EditSave.Text = "Sv";
     }
     else
     {
         string vcName = cbMarkVc2.Text;
         if (string.IsNullOrEmpty(vcName))
         {
             MessageBox.Show("请选择视觉配置名称");
             return;
         }
         JFDLAFRecipeManager rm     = JFHubCenter.Instance.RecipeManager as JFDLAFRecipeManager;
         JFDLAFProductRecipe recipe = rm.GetRecipe(CategoteProduct, cbRecipeID.Text) as JFDLAFProductRecipe;
         recipe.SetMark2LightCfg(vcName);
         _isMark2VcEdit       = false;
         cbMarkVc2.Enabled    = false;
         btMark2EditSave.Text = "Vc";
     }
 }
예제 #16
0
        protected override bool ActionGenuine(out string errorInfo)
        {
            string recipeID = GetMethodInputValue("RecipeID") as string;

            if (string.IsNullOrEmpty(recipeID))
            {
                errorInfo = "输入参数RecipeID 为空字串";
                return(false);
            }

            IJFImage markImg1 = GetMethodInputValue("MarkImage1") as IJFImage;

            if (null == markImg1)
            {
                errorInfo = "MarkImage1 is null";
                return(false);
            }

            IJFImage markImg2 = GetMethodInputValue("MarkImage2") as IJFImage;

            if (null == markImg1)
            {
                errorInfo = "MarkImage1 is null";
                return(false);
            }

            IDLAFProductFixReceiver rcver = GetMethodInputValue("定位结果接收者") as IDLAFProductFixReceiver;

            if (null == rcver)
            {
                errorInfo = "定位结果接收者 未设置";
                return(false);
            }
            double markSnapX1 = Convert.ToDouble(GetMethodInputValue("MarkSanpX1"));
            double markSnapY1 = Convert.ToDouble(GetMethodInputValue("MarkSanpY1"));
            double markSnapX2 = Convert.ToDouble(GetMethodInputValue("MarkSanpX2"));
            double markSnapY2 = Convert.ToDouble(GetMethodInputValue("MarkSanpY2"));

            double[] icCenterX    = null;
            double[] icCenterY    = null;
            double[] fovOffsetX   = null;
            double[] fovOffsetY   = null;
            int      fixErrorCode = -1;
            string   fixErrorInfo = "软件功能未实现";
            //////////////////////////////////////////////添加定位算法流程

            IJFRecipeManager irm = JFHubCenter.Instance.RecipeManager;

            if (null == irm)
            {
                errorInfo         = "配方管理器未设置";
                rcver.PFErrorInfo = errorInfo;
                rcver.PFErrorCode = -1;

                return(false);
            }

            if (!irm.IsInitOK)
            {
                errorInfo         = "配方管理器未初始化 :" + irm.GetInitErrorInfo();
                rcver.PFErrorInfo = errorInfo;
                rcver.PFErrorCode = -1;
                return(false);
            }
            JFDLAFRecipeManager rm = irm as JFDLAFRecipeManager;

            if (null == rm)
            {
                errorInfo         = "配方管理器类型错误 :" + irm.GetType().Name;
                rcver.PFErrorInfo = errorInfo;
                rcver.PFErrorCode = -1;
                return(false);
            }

            JFDLAFProductRecipe recipe = rm.GetRecipe("Product", recipeID) as JFDLAFProductRecipe;

            if (null == recipe)
            {
                errorInfo         = "RecipeID =\"" + recipeID + "\" 在配方管理器中不存在";
                rcver.PFErrorInfo = errorInfo;
                rcver.PFErrorCode = -1;
                return(false);
            }

            ///使用原始拍照点位
            icCenterX = new double[recipe.ICCount];
            icCenterY = new double[recipe.ICCount];
            for (int i = 0; i < recipe.RowCount; i++)
            {
                for (int j = 0; j < recipe.ColCount; j++)
                {
                    recipe.GetICSnapCenter(i, j, out icCenterX[i * recipe.ColCount + j], out icCenterY[i * recipe.ColCount + j]);
                }
            }

            ///使用原始Fov偏移量
            fovOffsetX = new double[recipe.FovCount];
            fovOffsetY = new double[recipe.FovCount];
            for (int i = 0; i < recipe.FovCount; i++)
            {
                recipe.GetFovOffset(recipe.FovNames()[i], out fovOffsetX[i], out fovOffsetY[i]);
            }
            fixErrorCode = 0;


            //当前为演示代码,返回模板图像拍照位置
            rcver.PFRecipeID   = recipeID;
            rcver.PFErrorInfo  = fixErrorInfo;
            rcver.PFICCenterX  = icCenterX;
            rcver.PFICCenterY  = icCenterY;
            rcver.PFFovOffsetX = fovOffsetX;
            rcver.PFFovOffsetY = fovOffsetY;
            rcver.PFErrorCode  = fixErrorCode;


            errorInfo = "Success";
            return(true);
        }
예제 #17
0
        public virtual bool Start(out string errorInfo)//开始运行
        {
            errorInfo = "Unknown Error";
            if (IsAlarming)
            {
                errorInfo = "当前处于报警状态";
                return(false);
            }
            if (IsStationRunning(WorkStatus))
            {
                errorInfo = "Success";
                return(true);
            }

            JFDLAFRecipeManager rm = JFHubCenter.Instance.RecipeManager as JFDLAFRecipeManager;

            if (null == rm)
            {
                errorInfo = "配方管理器未创建!";
                return(false);
            }
            if (!rm.IsInitOK)
            {
                errorInfo = "配方管理器初始化未完成,ErrorInfo:" + rm.GetInitErrorInfo();
                return(false);
            }



            JFStationManager stationMgr = JFHubCenter.Instance.StationMgr;


            string[] allEnableStationNames = stationMgr.AllEnabledStationNames();
            if (null == allEnableStationNames || 0 == allEnableStationNames.Length)
            {
                errorInfo = "不存在使能的工站";
                return(false);
            }

            foreach (string stationName in allEnableStationNames) // 先检查有没有正在运行的工站
            {
                IJFStation station = stationMgr.GetStation(stationName);
                if (IsStationRunning(station.CurrWorkStatus))
                {
                    errorInfo = "启动失败,工站:" + station.Name + " 当前状态:" + station.CurrWorkStatus.ToString();
                    return(false);
                }
            }

            ///检查当前RecipeID 和 LotID
            if (string.IsNullOrEmpty(CurrRecipeID))
            {
                errorInfo = "启动失败:当前产品ID未设置";
                return(false);
            }

            string[] allRecipeIDs = rm.AllRecipeIDsInCategoty(SCN_CategotyProd);
            if (null == allRecipeIDs || !allRecipeIDs.Contains(CurrRecipeID))
            {
                errorInfo = "启动失败,当前产品ID:" + CurrRecipeID + " 在配方管理器中不存在";
                return(false);
            }


            if (string.IsNullOrEmpty(CurrLotID))
            {
                errorInfo = "启动失败:当前批次号未设置!";
                return(false);
            }



            int failedIndex = -1; //启动失败的工站号

            foreach (string stationName in allEnableStationNames)
            {
                IJFStation      station = stationMgr.GetStation(stationName);
                JFWorkCmdResult ret     = station.Start();
                if (ret != JFWorkCmdResult.Success)
                {
                    errorInfo = "工站:" + station.Name + " 启动失败,Error:" + ret.ToString();
                    break;
                }
            }

            if (failedIndex > -1)
            {
                for (int i = 0; i < failedIndex + 1; i++)
                {
                    IJFStation station = stationMgr.GetStation(allEnableStationNames[i]);
                    if (JFWorkCmdResult.Success != station.Stop(100))
                    {
                        station.Abort();
                    }
                }
                return(false);
            }
            WorkStatus = JFWorkStatus.Running;
            errorInfo  = "Success";
            return(true);
        }
예제 #18
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;
                }
            }
        }
예제 #19
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;
            }
        }
예제 #20
0
        /// <summary>
        ///
        /// </summary>
        void UpdateParamPanel()
        {
            if (_station == null)
            {
                cbLotID.Text      = "";
                cbRecipeID.Text   = "";
                rchPicFolder.Text = "";
                return;
            }
            string        crrSelRecipeID = cbRecipeID.Text;
            List <string> recipeIDsInCb  = new List <string>();

            foreach (object o in cbRecipeID.Items)
            {
                recipeIDsInCb.Add(o.ToString());
            }

            string        currSelLotID = cbLotID.Text;
            List <string> lotIDsInCb   = new List <string>();

            foreach (string o in cbLotID.Items)
            {
                lotIDsInCb.Add(o.ToString());
            }

            string currSelPicFolder = rchPicFolder.Text;

            JFDLAFRecipeManager rm = JFHubCenter.Instance.RecipeManager as JFDLAFRecipeManager;

            string[] allRecipeIDs = rm.AllRecipeIDsInCategoty("Product");
            if (null == allRecipeIDs || 0 == allRecipeIDs.Length)
            {
                cbRecipeID.Items.Clear();
                cbRecipeID.Text = currSelPicFolder;
                cbLotID.Items.Clear();
                cbRecipeID.Text = currSelLotID;
                lstBoxPieceIDs.Items.Clear();
                return;
            }

            bool isNeedResetRecipeCb = false;

            do
            {
                if (allRecipeIDs.Length != recipeIDsInCb.Count())
                {
                    isNeedResetRecipeCb = true;
                    break;
                }
                for (int i = 0; i < allRecipeIDs.Length; i++)
                {
                    if (allRecipeIDs[i] != recipeIDsInCb[i])
                    {
                        isNeedResetRecipeCb = true;
                        break;
                    }
                }
            } while (false);
            if (isNeedResetRecipeCb)
            {
                cbRecipeID.Items.Clear();
                foreach (string s in allRecipeIDs)
                {
                    cbRecipeID.Items.Add(s);
                }
                if (!string.IsNullOrWhiteSpace(crrSelRecipeID))
                {
                    cbRecipeID.Text = crrSelRecipeID;
                }
            }

            if (string.IsNullOrWhiteSpace(cbRecipeID.Text))
            {
                cbLotID.Items.Clear();
                cbLotID.Text = currSelLotID;
                lstBoxPieceIDs.Items.Clear();
                return;
            }
            if (string.IsNullOrWhiteSpace(currSelPicFolder))
            {
                cbLotID.Items.Clear();
                lstBoxPieceIDs.Items.Clear();
                cbLotID.Text = currSelLotID;
                return;
            }

            if (!Directory.Exists(currSelPicFolder))
            {
                cbLotID.Items.Clear();
                lstBoxPieceIDs.Items.Clear();
                cbLotID.Text = currSelLotID;
                return;
            }

            string recipeFolder = currSelPicFolder + "\\" + cbRecipeID.Text;

            if (!Directory.Exists(recipeFolder))
            {
                cbLotID.Items.Clear();
                lstBoxPieceIDs.Items.Clear();
                cbLotID.Text = currSelLotID;
                return;
            }
            string[] lotsFolders = Directory.GetDirectories(recipeFolder);
            if (null == lotsFolders || 0 == lotsFolders.Length)
            {
                cbLotID.Items.Clear();
                lstBoxPieceIDs.Items.Clear();
                cbLotID.Text = currSelLotID;
                return;
            }

            bool isNeedResetLotCb = false;

            do
            {
                if (lotsFolders.Length != lotIDsInCb.Count())
                {
                    isNeedResetLotCb = true;
                    break;
                }
                for (int i = 0; i < lotsFolders.Length; i++)
                {
                    if (lotsFolders[i] != lotIDsInCb[i])
                    {
                        isNeedResetLotCb = true;
                        break;
                    }
                }
            } while (false);

            if (isNeedResetLotCb)
            {
                cbLotID.Items.Clear();
                foreach (string s in lotsFolders)
                {
                    cbLotID.Items.Add(s.Substring(s.LastIndexOf("\\") + 1));
                }
                if (lotsFolders.Contains(currSelLotID))
                {
                    for (int i = 0; i < lotsFolders.Length; i++)
                    {
                        if (lotsFolders[i] == currSelLotID)
                        {
                            cbLotID.SelectedIndex = i;
                            return;
                        }
                    }
                }
                cbLotID.Text = currSelLotID;
            }
        }
예제 #21
0
        protected override void PrepareWhenWorkStart()
        {
            if (string.IsNullOrEmpty(TestPicFolder))
            {
                ExitWork(WorkExitCode.Error, "检测失败:图片文件路径未设置");
            }
            if (!Directory.Exists(TestPicFolder))
            {
                ExitWork(WorkExitCode.Error, "检测失败,图片文件夹不存在:" + TestPicFolder);
            }
            IJFRecipeManager irm = JFHubCenter.Instance.RecipeManager;

            if (null == irm)
            {
                ExitWork(WorkExitCode.Error, "检测失败,配方管理器未设置");
            }
            if (!(irm is JFDLAFRecipeManager))
            {
                ExitWork(WorkExitCode.Error, "检测失败,配方管理器类型错误:" + irm.GetType().Name);
            }
            JFDLAFRecipeManager rm = irm as JFDLAFRecipeManager;

            if (!rm.IsInitOK)
            {
                ExitWork(WorkExitCode.Error, "检测失败,配方管理器未初始化,ErrorInfo:" + rm.GetInitErrorInfo());
            }



            if (string.IsNullOrEmpty(RecipeID))
            {
                ExitWork(WorkExitCode.Error, "检测失败:RecipeID未设置");
            }
            string[] allRecipeIDs = rm.AllRecipeIDsInCategoty("Product");
            if (null == allRecipeIDs || !allRecipeIDs.Contains(RecipeID))
            {
                ExitWork(WorkExitCode.Error, "检测失败,RecipeID:\"" + RecipeID + "\"在配方管理器中不存在");
            }

            if (string.IsNullOrEmpty(LotID))
            {
                ExitWork(WorkExitCode.Error, "检测失败:LotID未设置");
            }
            if (string.IsNullOrEmpty(_pieceID))
            {
                ExitWork(WorkExitCode.Error, "检测失败:未选择料片号");
            }
            _currPiecePicFolder = TestPicFolder + "\\" + RecipeID + "\\" + LotID + "\\" + _pieceID;
            if (!Directory.Exists(_currPiecePicFolder))
            {
                ExitWork(WorkExitCode.Error, "检测失败,产品图片文件夹:\"" + _currPiecePicFolder + "\" 不存在");
            }

            _currRecipe = rm.GetRecipe("Product", RecipeID) as JFDLAFProductRecipe;
            //初始化视觉算子
            string errorInfo;

            _ChangeCS(ODCS.算法初始化);
            JFDLAFInspectionManager.Instance.Clear(); //将所有已初始化的算子释放,重新初始化(适应外部修改配置)
            if (!JFDLAFInspectionManager.Instance.InitInspectNode(RecipeID, out errorInfo))
            {
                ExitWork(WorkExitCode.Error, "检测失败,图像算子初始化失败:" + errorInfo);
            }


            string cmrCalibDataFilePath = GetCfgParamValue("相机标定文件") as string;
            int    imgWidth             = (int)GetCfgParamValue("图像宽度/像素");
            int    imgHeight            = (int)GetCfgParamValue("图像高度/像素");

            if (!_visionFixer.Init(cmrCalibDataFilePath, _currRecipe, imgWidth, imgHeight, out errorInfo))
            {
                ExitWork(WorkExitCode.Error, "检测失败,图像矫正算子初始化失败:" + errorInfo);
            }



            _ChangeCS(ODCS.正在检测);
        }
        public bool InitInspectNode(string recipeID, out string errorInfo)
        {
            if (string.IsNullOrEmpty(recipeID))
            {
                errorInfo = "参数recipeID 为空字串";
                return(false);
            }

            JFDLAFRecipeManager rm = JFHubCenter.Instance.RecipeManager as JFDLAFRecipeManager;

            if (rm == null)
            {
                errorInfo = "配方管理器为空!";
                return(false);
            }

            if (!rm.IsInitOK)
            {
                errorInfo = "配方管理器未初始化:" + rm.GetInitErrorInfo();
                return(false);
            }

            string[] allRecipeIds = rm.AllRecipeIDsInCategoty(CategoyProduct);
            if (null == allRecipeIds || 0 == allRecipeIds.Length)
            {
                errorInfo = "配方管理器中不存在任何RecipeID";
                return(false);
            }

            if (!allRecipeIds.Contains(recipeID))
            {
                errorInfo = "配方管理器中不存在RecipeID = " + recipeID;
                return(false);
            }

            Dictionary <string, InspectNode> dctFovInspections = null;

            if (!_dctRecipeInspections.ContainsKey(recipeID)) //当前
            {
                dctFovInspections = new Dictionary <string, InspectNode>();
                _dctRecipeInspections.Add(recipeID, dctFovInspections);


                string rmPath = rm.GetInitParamValue("配方保存路径") as string;


                JFDLAFProductRecipe recipe   = rm.GetRecipe(CategoyProduct, recipeID) as JFDLAFProductRecipe;
                string[]            fovNames = recipe.FovNames();
                foreach (string fovName in fovNames)
                {
                    string recipePath = rmPath + "\\" + recipeID + "\\" + fovName + "\\Recipe\\";
                    string modelPath  = rmPath + "\\" + recipeID + "\\" + fovName + "\\Models\\";

                    InspectNode inspectNode = new InspectNode(modelPath, recipePath);
                    dctFovInspections.Add(fovName, inspectNode);
                }
            }
            string err;

            dctFovInspections = _dctRecipeInspections[recipeID];
            foreach (KeyValuePair <string, InspectNode> kv in dctFovInspections)
            {
                if (!kv.Value.InitInspectParam(out err))
                {
                    errorInfo = "Fov = " + kv.Key + " 初始化失败:" + err;
                    return(false);
                }
            }
            errorInfo = "Success";
            return(true);
        }