public Boolean LoadFromVPPFile(string FileName)//檔案參數載入 { string ProcID = System.Reflection.MethodInfo.GetCurrentMethod().Name.ToString(); string TempFileName = (string)FileName; try { //從CogTool裡面讀出來 string strFolderPath = @"D:\VPS_File\Product\FindCircleTool\" + @FileName + @"\"; CogToolBlock ToolBlock1 = new CogToolBlock(); FileName = strFolderPath + FileName + "_FCT.vpp"; ToolBlock1 = (CogToolBlock)CogSerializer.LoadObjectFromFile(FileName);//開啟ToolBlock vpp檔案 //依序載入 mFindCircleTool = (CogFindCircleTool)ToolBlock1.Tools[TempFileName + "_FindCircleTool_"]; mFindCircleTool.Run(); SaveLog.Msg_("Data of Find Circle Tool Loaded : " + @FileName); ToolBlock1 = null; FindCircleTool_Status = true; return(true); } catch (Exception ex) { SaveLog.Msg_("Save FindCircleTool Data Failed : " + ModularID + ":\r\n" + ProcID + ":\r\n" + ex.ToString()); FindCircleTool_Status = false; return(false); } }
private bool Inspection(CogImage8Grey _SrcImage) { bool _Result = true; try { FindCircleProc.InputImage = _SrcImage; FindCircleProc.Run(); } catch (System.Exception ex) { CLogManager.AddSystemLog(CLogManager.LOG_TYPE.ERR, "InspectionNeedleCircleFind - Inspection Exception : " + ex.ToString(), CLogManager.LOG_LEVEL.LOW); _Result = false; } return(_Result); }
public Boolean Run(CogRecordDisplay CogRecordDisplay1) { string ProcID = System.Reflection.MethodInfo.GetCurrentMethod().Name.ToString(); FindCircleTool_Status = false; try { mFindCircleTool.InputImage = (CogImage8Grey)CogRecordDisplay1.Image; mFindCircleTool.Run(); CogRecordDisplay1.Record = mFindCircleTool.CreateLastRunRecord().SubRecords["InputImage"]; FindCircleTool_Status = true; return(true); } catch (Exception ex) { SaveLog.Msg_("FindCircleTool Run Failed : " + ModularID + ":\r\n" + ProcID + ":\r\n" + ex.ToString()); return(false); } }
public static List <double> find(int toolNum, int method) { object toolgroup = CogSerializer.LoadObjectFromFile("c://tool.vpp"); object job = CogSerializer.LoadObjectFromFile("QuickBuild1.vpp"); switch (toolNum) { case 0: toolgroup = CogSerializer.LoadObjectFromFile("c://tool0.vpp"); break; case 1: toolgroup = CogSerializer.LoadObjectFromFile("c://tool1.vpp"); break; case 2: toolgroup = CogSerializer.LoadObjectFromFile("c://tool2.vpp"); break; case 3: toolgroup = CogSerializer.LoadObjectFromFile("c://tool3.vpp"); break; default: break; } CogToolGroup ToolGroup1 = toolgroup as CogToolGroup; CogJobManager cojob = job as CogJobManager; CogJob cojob = cojob.Job["CogJob1"] as CogJob; CogImageFileTool myFile = ToolGroup1.Tools["CogImageFileTool1"] as CogImageFileTool; myFile.Run(); CogFindCircleTool myCircleTool = ToolGroup1.Tools["CogFindCircleTool1"] as CogFindCircleTool; CogFindLineTool myLineTool = ToolGroup1.Tools["CogFindLineTool1"] as CogFindLineTool; switch (method) { case 1: myCircleTool.Run(); break; case 2: myLineTool.Run(); break; case 3: myCircleTool.Run(); myLineTool.Run(); break; default: break; } double Lx0 = 0; double Lx1 = 0; double Ly0 = 0; double Ly1 = 0; double Langle = 0; double Cx = 0; double Cy = 0; double Cr = 0; if (method == 1 | method == 3) { Cx = myCircleTool.Results.GetCircle().CenterX; Cy = myCircleTool.Results.GetCircle().CenterY; Cr = myCircleTool.Results.GetCircle().Radius; } if (method == 2 | method == 3) { Lx0 = myLineTool.Results.GetLineSegment().StartX; Ly0 = myLineTool.Results.GetLineSegment().StartY; Lx1 = myLineTool.Results.GetLineSegment().EndX; Ly1 = myLineTool.Results.GetLineSegment().EndY; Langle = myLineTool.Results.GetLine().Rotation; } double[] result = { Cx, Cy, Cr, Lx0, Ly0, Lx1, Ly1, Langle }; return(new List <double>(result)); }