public VisionAppObject() { // Khởi tạo Acq cogAcqFifoEdit = new CogAcqFifoEditV2(); cogAcqFifoEdit.Subject = new CogAcqFifoTool(); // Khởi tạo Image file Tool cogImageFileTool = new CogImageFileEditV2(); cogImageFileTool.Subject = new CogImageFileTool(); // Khởi tạo Fixture Tool cogFixtureTool = new CogFixtureEditV2(); cogFixtureTool.Subject = new CogFixtureTool(); // Khởi tạo PM Align Tool pmAlignToolEdit = new CogPMAlignEditV2(); pmAlignToolEdit.Subject = new CogPMAlignTool(); // Khởi tạo Sharpness Tool sharpnessToolEdit1 = new CogImageSharpnessEditV2(); sharpnessToolEdit1.Subject = new CogImageSharpnessTool(); sharpnessToolEdit2 = new CogImageSharpnessEditV2(); sharpnessToolEdit2.Subject = new CogImageSharpnessTool(); // Giá trị max, min Sharpness mặc định minSharpness1 = Settings.Default.MinSharpness1; maxSharpness1 = Settings.Default.MaxSharpness1; minSharpness2 = Settings.Default.MinSharpness2; maxSharpness2 = Settings.Default.MaxSharpness2; // Khởi tạo Cogdisplay cogDisplayMain = new CogRecordDisplay(); // Load Old Job LoadCameraJobFromUrl(); // Xóa Binding cũ if (cogFixtureTool.Subject.DataBindings.Contains("InputImage")) { cogFixtureTool.Subject.DataBindings.Remove("InputImage"); } if (pmAlignToolEdit.Subject.DataBindings.Contains("InputImage")) { pmAlignToolEdit.Subject.DataBindings.Remove("InputImage"); } if (sharpnessToolEdit1.Subject.DataBindings.Contains("InputImage")) { sharpnessToolEdit1.Subject.DataBindings.Remove("InputImage"); } if (sharpnessToolEdit2.Subject.DataBindings.Contains("InputImage")) { sharpnessToolEdit2.Subject.DataBindings.Remove("InputImage"); } cogDisplayMain.DataBindings.Clear(); /// Khởi tạo Binding Image /// cogFixtureTool.Subject.DataBindings.Add("InputImage", cogAcqFifoEdit.Subject, "OutputImage"); pmAlignToolEdit.Subject.DataBindings.Add("InputImage", cogAcqFifoEdit.Subject, "OutputImage"); sharpnessToolEdit1.Subject.DataBindings.Add("InputImage", cogFixtureTool.Subject, "OutputImage"); sharpnessToolEdit2.Subject.DataBindings.Add("InputImage", cogFixtureTool.Subject, "OutputImage"); cogDisplayMain.DataBindings.Add("Image", cogFixtureTool.Subject, "OutputImage", true); cogDisplayMain.BackColor = System.Drawing.Color.Gray; }
public VisionJob() { toolBlockEdit = new CogToolBlockEditV2(); toolGroupEdit = new CogToolGroupEditV2(); // Temp hiển thị tool Imagefile Select imageFileTool = new CogImageFileTool(); imageFileEdit = new CogImageFileEditV2(); imageFileEdit.Subject = imageFileTool; // Thiết lập Camera đầu vào acqFifoTool = new CogAcqFifoEditV2(); acqFifoTool.Subject = new CogAcqFifoTool(); // Load thư viện ảnh mặc định cogDisplayMain = new CogDisplay(); ImageFileTool.Operator.Open(@"C:\Program Files\Cognex\VisionPro\Images\CheckCal.idb", CogImageFileModeConstants.Read); // Link ảnh đầu ra với ảnh đầu vào // Tắt tạm thời ảnh vào từ Imagefile // Load ảnh trực tiếp từ Camera //cogDisplayMain.DataBindings.Add("Image", ImageFileTool, "OutputImage", true); cogDisplayMain.DataBindings.Add("Image", AcqFifoTool.Subject, "OutputImage", true); // Tool Align pmAlignTool = new CogPMAlignEditV2(); pmAlignTool.Subject = new CogPMAlignTool(); //pmAlignTool.Subject.DataBindings.Add("InputImage", ImageFileTool, "OutputImage"); pmAlignTool.Subject.DataBindings.Add("InputImage", AcqFifoTool.Subject, "OutputImage"); // Cấu hình Tool Calib calibGribCBTool = new CogCalibCheckerboardEditV2(); calibGribCBTool.Subject = new CogCalibCheckerboardTool(); // Sửa đầu vào Tool Calib //calibGribCBTool.Subject.DataBindings.Add("InputImage", ImageFileTool, "OutputImage"); calibGribCBTool.Subject.DataBindings.Add("InputImage", AcqFifoTool.Subject, "OutputImage"); calibGribCBTool.Subject.Calibration.Changed += UpdateCalibImage; pmAlignTool.SubjectChanged += UpdateCalibImage; calibGribCBTool.SubjectChanged += UpdateImageSource; // }