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); }
protected override bool ActionGenuine(out string errorInfo) { errorInfo = "已作废,未实现功能!"; return(false); #if false try { IJFImage[] imgs = GetMethodInputValue("TaskImages") as IJFImage[]; if (null == imgs || 0 == imgs.Length) { errorInfo = "输入参数项:TaskImages为空"; return(false); } string recipeID = GetMethodInputValue("RecipeID") as string; if (string.IsNullOrEmpty(recipeID)) { errorInfo = "RecipeID未设置"; return(false); } string fovName = GetMethodInputValue("FovName") as string; if (string.IsNullOrEmpty(fovName)) { errorInfo = "FovName未设置"; return(false); } string[] taskNames = ((JFHubCenter.Instance.RecipeManager as JFDLAFRecipeManager).GetRecipe("Product", recipeID) as JFDLAFProductRecipe).TaskNames(fovName); Inspect_Node node = JFDLAFInspectionManager.Instance.GetInspectNode(recipeID, fovName); if (null == node) { errorInfo = "Recipe_Fov对应的InspectNode未初始化"; return(false); } List <HObject> lsthimgs = new List <HObject>(); for (int i = 0; i < imgs.Length; i++) { object hoImg = null; int ret = imgs[i].GenHalcon(out hoImg); if (ret != 0) { errorInfo = "JFImage to halcon failed:" + imgs[i].GetErrorInfo(ret); return(false); } lsthimgs.Add(hoImg as HObject); } List <int[]> diesErrorCodes = null; string[] dieErrorInfos = null; //string errorInfo = "Unknown-Error"; HObject BondContours; HObject Wires; HObject FailRegs; string optErrorInfo = ""; if (!node.InspectImage(lsthimgs.ToArray(), taskNames, out optErrorInfo, out diesErrorCodes, out dieErrorInfos, out BondContours, out Wires, out FailRegs)) { SetOutputParamValue("DetectResult", false); SetOutputParamValue("DetectErrorInfo", optErrorInfo); SetOutputParamValue("DieErrorCodes", null); SetOutputParamValue("DieErrorInfos", null); SetOutputParamValue("BondRegions", null); SetOutputParamValue("WiresRegions", null); SetOutputParamValue("FailRegions", null); errorInfo = "Inspect_Node.InspectImage failed errorInfo:" + optErrorInfo; return(true); //此处只表示Action执行成功,但是检测出错 } SetOutputParamValue("DetectResult", true); SetOutputParamValue("DetectErrorInfo", optErrorInfo); SetOutputParamValue("DiesErrorCodes", diesErrorCodes); SetOutputParamValue("DieErrorInfos", dieErrorInfos); SetOutputParamValue("BondRegions", BondContours); SetOutputParamValue("WiresRegions", Wires); SetOutputParamValue("FailRegions", FailRegs); errorInfo = "Success"; return(true); } catch (Exception ex) { errorInfo = ex.Message; return(false); } #endif //false }
protected override bool ActionGenuine(out string errorInfo) { try { IJFImage img = GetMethodInputValue("Image") as IJFImage; if (null == img) { errorInfo = "输入图像为空"; return(false); } string recipeID = GetMethodInputValue("RecipeID") as string; if (string.IsNullOrEmpty(recipeID)) { errorInfo = "RecipeID未设置"; return(false); } string fovName = GetMethodInputValue("FovName") as string; if (string.IsNullOrEmpty(fovName)) { errorInfo = "FovName未设置"; return(false); } Inspect_Node node = JFDLAFInspectionManager.Instance.GetInspectNode(recipeID, fovName); if (null == node) { errorInfo = "RecipeID对应的InspectNode未初始化"; return(false); } object hoImg = null; int ret = img.GenHalcon(out hoImg); if (ret != 0) { errorInfo = "JFImage to halcon failed:" + img.GetErrorInfo(ret); return(false); } int errorCode = -1; //string errorInfo = "Unknown-Error"; HObject BondContours; HObject Wires; HObject FailRegs; string optErrorInfo = ""; if (!node.InspectImage(hoImg as HObject, out errorCode, out optErrorInfo, out BondContours, out Wires, out FailRegs)) { errorInfo = optErrorInfo; SetOutputParamValue("ErrorCode", errorCode); SetOutputParamValue("ErrorInfo", optErrorInfo); SetOutputParamValue("焊点区域", null); SetOutputParamValue("金线区域", null); SetOutputParamValue("失败区域", null); errorInfo = "Success"; return(false); } SetOutputParamValue("ErrorCode", errorCode); SetOutputParamValue("ErrorInfo", optErrorInfo); SetOutputParamValue("焊点区域", BondContours); SetOutputParamValue("金线区域", Wires); SetOutputParamValue("失败区域", FailRegs); errorInfo = "Success"; return(true); } catch (Exception ex) { errorInfo = ex.Message; return(false); } }