Пример #1
0
        /// <summary>
        /// Initialize this Component
        /// </summary>
        public override void Initialize()
        {
            // Initialize
            if (Simulate == eSimulate.SimulateDontAsk)
            {
                throw new ForceSimulateException("Always Simulate");
            }

            try
            {
                CogFrameGrabbers.Refresh();
                U.SleepWithEvents(100);
                _framegrabberCams = new CogFrameGrabbers();
                if (_framegrabberCams.Count < 6)
                {
                    int jjb = 0;
                }
                Simulate = eSimulate.None;

                // Continue with children
                base.Initialize();
            }
            catch (ForceSimulateException fsex)
            {
                throw fsex;
            }
            catch (Exception ex)
            {
                throw new ForceSimulateException(ex);
            }
        }
        /// <summary>
        /// Obtain a list of camera.  Also assigns the frame grabber if it matches the ID
        /// </summary>
        /// <returns></returns>
        public override string[] GetCameraIDs()
        {
            List <string>    list         = new List <string>();
            ICogFrameGrabber foundGrabber = null;

            if (Parent is Cognex8)
            {
                lock (_lockAcqFifo)
                {
                    CogFrameGrabbers grabbers = (Parent as Cognex8).FramegrabberCams;
                    if (grabbers != null)
                    {
                        foreach (ICogFrameGrabber grabber in grabbers)
                        {
                            list.Add(BuildCameraID(grabber));
                            if (BuildCameraID(grabber) == CameraID)
                            {
                                foundGrabber = grabber;
                            }
                        }
                    }
                }
                _frameGrabber = foundGrabber;
                if (_frameGrabber == null)
                {
                    U.LogError("Camera not found! : '{0}'", CameraID);
                }
            }
            return(list.ToArray());
        }
Пример #3
0
        public MainWindow()
        {
            InitializeComponent();

            camList  = new List <GigECamInfo>();
            grabbers = new CogFrameGrabbers();

            if (grabbers.Count != 0)
            {
                for (int i = 0; i < grabbers.Count; i++)
                {
                    ICogFrameGrabber grabber    = grabbers[i];
                    ICogGigEAccess   gigEAccess = grabber.OwnedGigEAccess;
                    string           vendor     = gigEAccess.GetFeature("DeviceVendorName");

                    camList.Add(new GigECamInfo()
                    {
                        Name = grabber.Name, SerialNumber = grabber.SerialNumber, VendorName = vendor
                    });
                }
            }

            dataGrid.ItemsSource = camList;

            display   = new CogDisplay();
            WFH.Child = display;

            fifo                   = grabbers[0].CreateAcqFifo("Generic GigEVision (Mono)", CogAcqFifoPixelFormatConstants.Format8Grey, 0, false);
            textBlock.Text         = grabbers[0].Name;
            dataGrid.SelectedIndex = 0;
        }
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            #region CognexShutDown
            try
            {
                //Close all open Framegrabbers due to RuntimeError R6025
                CogFrameGrabbers frameGrabbers = new CogFrameGrabbers();
                foreach (ICogFrameGrabber fg in frameGrabbers)
                {
                    fg.Disconnect(false);
                }

                //End Starting of Cognex in separate Thread
                if (cognexLoader != null)
                {
                    cognexLoader.Abort();
                }
                // Be sure to shudown the CogJobManager!!
                if (myJobManager != null)
                {
                    myJobManager.Shutdown();
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine("Vision-Pro shutdown. Excepiton:" + ex.Message);
            }
            #endregion
        }
Пример #5
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());

            CogFrameGrabbers frameGrabbers = new CogFrameGrabbers();

            for (int i = 0; i < frameGrabbers.Count; i++)
            {
                frameGrabbers[i].Disconnect(false);
            }
        }
Пример #6
0
        private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            crdLiveImage.StopLiveDisplay();
            var frameGrabbers = new CogFrameGrabbers();

            foreach (ICogFrameGrabber fg in frameGrabbers)
            {
                fg.Disconnect(false);
            }
            Thread.Sleep(100);
            Process.GetCurrentProcess().Kill();
            Thread.Sleep(100);
            Environment.Exit(0);
        }
Пример #7
0
        private void CogForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            if (m_JobManager != null)
            {
                m_JobManager.Shutdown();
            }
            cogDisplay1.Dispose();
            CogFrameGrabbers grabbers = new CogFrameGrabbers();

            foreach (ICogFrameGrabber fg in grabbers)
            {
                fg.Disconnect(false);
            }
        }
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            CogFrameGrabbers frameGrabbers = new CogFrameGrabbers();

            foreach (ICogFrameGrabber fg in frameGrabbers)
            {
                fg.Disconnect(false);
            }

            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }
        private void brightnessUpDown_ValueChanged(object sender, EventArgs e)
        {
            myFrameGrabbers = new CogFrameGrabbers();
            myFrameGrabber  = myFrameGrabbers[0];

            myAcqFifo = AcqFifoTool.Operator;
            myAcqFifo.OwnedBrightnessParams.Brightness = cogAcqTool.Operator.OwnedBrightnessParams.Brightness;
            brightnessParams = myAcqFifo.OwnedBrightnessParams;
            if (brightnessParams != null)
            {
                brightnessParams.Brightness = Convert.ToDouble(brightnessUpDown.Value);
                myAcqFifo.OwnedBrightnessParams.Brightness           = brightnessParams.Brightness;
                cogAcqTool.Operator.OwnedBrightnessParams.Brightness = brightnessParams.Brightness;
            }
        }
Пример #10
0
        private void InitializeFifo()
        {
            const string VIDEO_FORMAT = "Sony XC75 640x480";
            ICogAcqROI   ROIParams;

            myFrameGrabbers = new CogFrameGrabbers();
            myFrameGrabber  = myFrameGrabbers[0];
            myAcqFifo       = myFrameGrabber.CreateAcqFifo(VIDEO_FORMAT,
                                                           Cognex.VisionPro.CogAcqFifoPixelFormatConstants.Format8Grey, 0, false);

            ROIParams = myAcqFifo.OwnedROIParams;
            if (ROIParams != null)
            {
                ROIParams.SetROIXYWidthHeight(10, 20, 300, 200);
            }
        }
Пример #11
0
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            #region CognexShutDown
            try
            {
                //Close all open Framegrabbers due to RuntimeError R6025
                CogFrameGrabbers frameGrabbers = new CogFrameGrabbers();
                foreach (ICogFrameGrabber fg in frameGrabbers)
                    fg.Disconnect(false);

                //End Starting of Cognex in separate Thread
                if (cognexLoader != null) cognexLoader.Abort();
                // Be sure to shudown the CogJobManager!!
                if (myJobManager != null) myJobManager.Shutdown();
            }
            catch (Exception ex)
            {
                Trace.WriteLine("Vision-Pro shutdown. Excepiton:" + ex.Message);
            }
            #endregion
        }