Esempio n. 1
0
        //进行一次软触发采图
        public override bool TriggerSoftware()
        {
            try
            {
 #if (SDK)
                g_Camera.StreamGrabber.Stop();
                g_Camera.StreamGrabber.Start(GrabStrategy.LatestImages, GrabLoop.ProvidedByStreamGrabber);
                Thread.Sleep(50);
                //进行软触发,等待100ms,如果相机没有触发则抛出异常
                if (g_Camera.WaitForFrameTriggerReady(100, TimeoutHandling.ThrowException))
                {
                    g_Camera.ExecuteSoftwareTrigger();
                }
                else
                {
                    return(false);
                }
#endif
                return(true);
            }
            catch (Exception ex)
            {
                Log.L_I.WriteError(NameClass, ex);
                return(false);
            }
            finally
            {
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 同步方式抓图
        /// </summary>
        /// <param name="strBarCode">读码结果</param>
        /// <param name="iTimeout">超时时间</param>
        /// <returns></returns>
        public bool GrabImage(out IGrabResult grabResult)//同步单次拍照
        {
            Stopwatch sw = new Stopwatch();

            Exception ex = new Exception("Please open the camera");


            if (!_aca500M_Camera.IsOpen)
            {
                MessageBox.Show(ex.Message);
            }
            if (!_aca500M_Camera.StreamGrabber.IsGrabbing)
            {
                _aca500M_Camera.StreamGrabber.Start(cameraData.maxPictureNumber, GrabStrategy.OneByOne, GrabLoop.ProvidedByUser);
                bAsync = false;
            }
            else
            {
                if (bAsync)
                {
                    _aca500M_Camera.StreamGrabber.Stop();
                    _aca500M_Camera.StreamGrabber.Start(cameraData.maxPictureNumber, GrabStrategy.OneByOne, GrabLoop.ProvidedByUser);
                    bAsync = false;
                }
            }

            try
            {
                sw.Start();
                _aca500M_Camera.WaitForFrameTriggerReady(1000, TimeoutHandling.ThrowException);
                _aca500M_Camera.ExecuteSoftwareTrigger();
                grabResult = _aca500M_Camera.StreamGrabber.RetrieveResult(5000, TimeoutHandling.ThrowException);
                sw.Stop();
            }
            catch (Exception th_ex)
            {
                MessageBox.Show(th_ex.Message);
                grabResult = null;
                return(false);
            }
            return(true);
        }
Esempio n. 3
0
 public override void Grad()
 {
     try
     {
         if (objDev.WaitForFrameTriggerReady(1000, TimeoutHandling.ThrowException))
         {
             objDev.ExecuteSoftwareTrigger(); //发送软触发命令
             stopWatch.Restart();             // ****  重启采集时间计时器   ****
         }
     }
     catch (Exception exception)
     {
         ShowException(exception);
     }
 }
Esempio n. 4
0
 public override void OneShot(Command command)
 {
     try
     {
         if (IsContinuousShot || IsExtTrigger)
         {
             ContinuousShotStop();
         }
         Command = command;
         // Execute the software trigger. Wait up to 1000 ms until the camera is ready for trigger.
         if (g_camera.WaitForFrameTriggerReady(100, TimeoutHandling.ThrowException))
         {
             g_camera.ExecuteSoftwareTrigger();
         }
     }
     catch
     {
         IsLink = false;/*
                         * Util.Notify("相机软触发异常");*/
     }
 }