Esempio n. 1
0
        private void SetPropertyCheckedBitInReg(int index, bool active, uint bitMask)
        {
            try
            {
                uint uiValue  = 0;
                uint address  = GetPropertyValueRegAddress(index);
                uint regValue = m_camera.ReadRegister(address);

                if (active)
                {
                    uiValue = regValue | bitMask;
                }
                else
                {
                    uiValue = regValue & (~bitMask);
                }

                m_camera.WriteRegister(address, uiValue);
            }
            catch (FC2Exception ex)
            {
                BasePage.ShowErrorMessageDialog(
                    "Error setting independent property(" + m_propertyType.ToString() + ") control register.",
                    ex);
                return;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 抓取相机的图像,输出所有的格式
        /// </summary>
        public override ImageAll GrabImageAll()
        {
            g_MtGrabImage.WaitOne();
            ImageAll imageAll = new ImageAll();

            try
            {
                if (!BlOpen)//如果相机打开失败
                {
                    return(null);
                }
#if (SDK)
                try
                {
                    SetTrriggerMode();//设置软触发
                    g_ManagedCameraBase.RetrieveBuffer(g_RawImage);
                }
                catch (Exception ex)
                {
                    Log.L_I.WriteError(NameClass, ex);
                    try
                    {
                        if (g_BaseParCamera.BlUsingTrigger)                       //使用软触发
                        {
                            g_ManagedCameraBase.WriteRegister(0x62C, 0x80000000); //发送软触发指令
                        }
                        g_ManagedCameraBase.RetrieveBuffer(g_RawImage);
                    }
                    catch
                    {
                        if (g_BaseParCamera.BlUsingTrigger)                       //使用软触发
                        {
                            g_ManagedCameraBase.WriteRegister(0x62C, 0x80000000); //发送软触发指令
                        }
                        g_ManagedCameraBase.RetrieveBuffer(g_RawImage);
                    }
                }

                //将图像转换为Halcon格式
                imageAll.Ho_Image     = ConvertHobject();
                imageAll.BitmapSource = ConvertImageBitmap();
                PathDirectory p = new PathDirectory();
                imageAll.Time = p.GetShortTimeName();
#endif
                return(imageAll);
            }
            catch (Exception ex)
            {
                Log.L_I.WriteError(NameClass, ex);
                return(null);
            }
            finally
            {
                g_MtGrabImage.ReleaseMutex();
            }
        }