private void button1_Click_1(object sender, EventArgs e) { if (indexRunAgain < UnfoundInsertList.Count) { if (indexRunAgain == 0) { numericUpDown1.Value -= Convert.ToDecimal(0.05); PatMaxTool.RunParams.AcceptThreshold = Convert.ToDouble(numericUpDown1.Value); cogPMAlignTool.RunParams.AcceptThreshold = Convert.ToDouble(numericUpDown1.Value); dataGridView1.Rows.Clear(); for (int i = 0; i < UnfoundInsertList.Count; i++) { dataGridView1.Rows.Add(); dataGridView1[0, i].Value = UnfoundInsertList[i].Index.ToString("f2"); dataGridView1[3, i].Value = UnfoundInsertList[i].X_VisRes.ToString("f2"); dataGridView1[4, i].Value = UnfoundInsertList[i].Y_VisRes.ToString("f2"); } } ROIParams.SetROIXYWidthHeight(StartXIndx + Convert.ToInt32(UnfoundInsertList[indexRunAgain].X_file * 6.5), //2.478), StartYIndx - 55 + Convert.ToInt32(UnfoundInsertList[indexRunAgain].Y_VisRes * 6.5), // 2.375), Convert.ToInt32(xSearchReg * 4 * 2), Convert.ToInt32(ySearchReg * 4 * 2)); //PatMaxSearchRegion.SetCenterWidthHeight(UnfoundInsertList[indexRunAgain].X_VisRes - 4, // UnfoundInsertList[indexRunAgain].Y_VisRes, xSearchReg * 1.2, ySearchReg * 1.2); //cogPMAlignTool.SearchRegion = PatMaxSearchRegion; AcqFifoTool.Run(); cogRecordDisplay1.Fit(true); cogRecordDisplay1.Fit(true); cogToolBlockEditV21.Subject.Inputs["Image"].Value = cogRecordDisplay1.Image; indexRunAgain++; } else { MessageBox.Show("No more unfound inserts"); indexRunAgain = 0; numericUpDown1.Value += Convert.ToDecimal(0.05); PatMaxTool.RunParams.AcceptThreshold = Convert.ToDouble(numericUpDown1.Value); cogPMAlignTool.RunParams.AcceptThreshold = Convert.ToDouble(numericUpDown1.Value); dataGridView1.Rows.Clear(); } }
private void cmdImageAcquisitionLiveOrOpenCommand_Click(System.Object sender, System.EventArgs e) { CogDisplay1.StaticGraphics.Clear(); CogDisplay1.InteractiveGraphics.Clear(); cogRecordDisplay1.StaticGraphics.Clear(); cogRecordDisplay1.InteractiveGraphics.Clear(); ROIParams = myAcqFifo.OwnedROIParams; //if (AppGen.Inst.MDImain.frmVisionMain.FrmUnloadCarrier.flagFullTray) //{ ROIParams.SetROIXYWidthHeight(StartXIndx, StartYIndx, MaxXWidth, MaxYWidth); //PatMaxSearchRegion.SetXYWidthHeight(0, 0, 349.08, 296.54); //cogPMAlignTool.SearchRegion = PatMaxSearchRegion; //} //else //{ // // ROIParams.SetROIXYWidthHeight(Convert.ToInt32(StartXIndx * PixFactor), Convert.ToInt32(CurrLineCoord * PixFactor), Convert.ToInt32((xSearchReg + 10) * PixFactor), Convert.ToInt32((ySearchReg + 10) * PixFactor)); // try // { // CurrLineCoord = StartYIndx + (((AppGen.Inst.MainCycle.UnloadCarrierSliceNo - 1) * ySearchReg)); //added 11.06.14 by asaf // //111111 ROIParams.SetROIXYWidthHeight(Convert.ToInt32(StartXIndx * 2.5), Convert.ToInt32(CurrLineCoord), xSearchReg - 1100, ySearchReg + 150); // } // catch (Exception ex) // { // MessageBox.Show(ex.Message, "PatMax Setup Error"); // } //} //"Live Video" & "Stop Live" button when Frame Grabber option is selected. //Using our EnableAll & DisableAll subroutine to force the user stop live //video before doing anything else. if (optImageAcquisitionOptionFrameGrabber.Checked == true) { if (cogRecordDisplay1.LiveDisplayRunning) { cogRecordDisplay1.StopLiveDisplay(); EnableAll(settingLiveVideo); AcqFifoTool.Run(); cogRecordDisplay1.Fit(true); cogToolBlockEditV21.Subject.Inputs["Image"].Value = cogRecordDisplay1.Image; } else if ((AcqFifoTool.Operator != null)) { AcqFifoTool.Run(); cogRecordDisplay1.Fit(true); cogRecordDisplay1.StartLiveDisplay(AcqFifoTool.Operator, false); cogRecordDisplay1.Fit(true); cogToolBlockEditV21.Subject.Inputs["Image"].Value = cogRecordDisplay1.Image; DisableAll(settingLiveVideo); cogRecordDisplay1.Fit(true); } } else { //"Open File" button when image file option is selected //DrawingEnabled is used to simply hide the image while the Fit is performed. //This prevents the image from being diplayed at the initial zoom factor //prior to fit being called. try { DialogResult result = ImageAcquisitionCommonDialog.ShowDialog(); if (result != System.Windows.Forms.DialogResult.Cancel) { ImageFileTool.Operator.Open(ImageAcquisitionCommonDialog.FileName, CogImageFileModeConstants.Read); cogRecordDisplay1.DrawingEnabled = false; ImageFileTool.Run(); cogRecordDisplay1.Fit(true); cogRecordDisplay1.DrawingEnabled = true; } } catch (CogException cogex) { MessageBox.Show("Following Specific Cognex Error Occured:" + cogex.Message); } catch (Exception ex) { MessageBox.Show("Following Error Occured:" + ex.Message); } cogToolBlockEditV21.Subject.Inputs["Image"].Value = cogRecordDisplay1.Image; //!!!!! Neet to solve why pic doesn't get into tool } cogRecordDisplay1.Fit(true); }