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);
        }
예제 #2
0
        private void cmdImageAcquisitionLiveOrOpenCommand_Click(System.Object sender, System.EventArgs e)
        {
            txtCurrentIndex.Text = (AppGen.Inst.LoadTray.CurrIndex + 1).ToString();
            //Clear graphics, assuming a new image will be in the display once user
            //completes either Live Video or Open File operation, therefore, graphics
            //will be out of sync.
            CogDisplay1.StaticGraphics.Clear();
            CogDisplay1.InteractiveGraphics.Clear();
            cogRecordDisplay1.StaticGraphics.Clear();
            cogRecordDisplay1.InteractiveGraphics.Clear();

            ROIParams = myAcqFifo.OwnedROIParams;
            if (AppGen.Inst.MDImain.frmVisionMain.FrmLoadtray.flagFullTray)
            {
                //PatMaxSearchRegion.SetXYWidthHeight(0, 0, 349.08, 296.54);
                //cogPMAlignTool.SearchRegion = PatMaxSearchRegion;
                PatMaxSearchRegion.SetCenterWidthHeight(StartXIndx, StartYIndx, MaxXWidth + 555, MaxYWidth + 555);
                cogPMAlignTool.SearchRegion = PatMaxSearchRegion;
            }
            else
            {
                cogTransform2DLinearN2N = CalibNPointTool.Calibration.GetComputedUncalibratedFromCalibratedTransform() as CogTransform2DLinear;
                PatMaxSearchRegion.SetCenterWidthHeight(173 + (AppGen.Inst.LoadTray.
                                                               IndexList[AppGen.Inst.LoadTray.CurrIndex].X_file),
                                                        (593.7 - AppGen.Inst.LoadTray.IndexList[AppGen.Inst.LoadTray.CurrIndex].Y_file),
                                                        (xSearchReg), (ySearchReg));
                cogPMAlignTool.SearchRegion = PatMaxSearchRegion;
                //if ((cogPMAlignTool.SearchRegion != null))
                //{
                //    cogRecordDisplay1.StaticGraphics.Add(cogPMAlignTool.SearchRegion as ICogGraphic, "test");
                //    cogToolBlockEditV21.Subject.Inputs["Image"].Value = cogRecordDisplay1.Image;
                //}
            }

            //"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; //!!!!! Need to solve why pic doesn't get into tool
            }
            cogRecordDisplay1.Fit(true);
        }