コード例 #1
0
        /// <summary>
        /// 打开指定IP地址的识别器
        /// </summary>
        /// <param name="ip">识别器IP地址</param>
        /// <returns></returns>
        public string Open(string ip)
        {
            //已经打开直接返回,关闭时同步退出打开状态检查
            if (IntPtr.Zero != this.m_Hv && this.ipaddr == ip)
                return "";
            this.Close();
            this.m_Hv = HVDLLFun.OpenHv(ip);
            if (m_Hv == IntPtr.Zero)
            {
                this.m_Hv = IntPtr.Zero;
                this.ipaddr = "";
                resultFirst.m_Hv = resultSecond.m_Hv = IntPtr.Zero;
                return "连接设备失败!";
            }
            this.ipaddr = ip;
            resultFirst.m_Hv = resultSecond.m_Hv = this.m_Hv;
            //创建参数
            //第一通道参数
            IntPtr argfirst = Marshal.GetIUnknownForObject(this.resultFirst);
            //第二通道参数
            IntPtr argsecond = Marshal.GetIUnknownForObject(this.resultSecond);

            //车牌号回调
            plateCallback = new HVDLLFun.PLATE_NO_CALLBACK(onPlateNoCallBack);
            IntPtr ptfunPlt = Marshal.GetFunctionPointerForDelegate(plateCallback);
            UInt16 streamtype = Convert.ToUInt16(HvStreamType.PlateStr);
            int f = HVDLLFun.SetHvCallBack(this.m_Hv, ptfunPlt, argfirst, 0, streamtype);
            if (f > -1)
                f = HVDLLFun.SetHvCallBack(this.m_Hv, ptfunPlt, argsecond, 1, streamtype);
            if (f > -1)
            {
                //车牌小图回调
                unsafe
                {
                    sImgCallback = new HVDLLFun.SMALL_IMAGE_CALLBACK(onSmallImgCallBack);
                    IntPtr ptfunImgsmall = Marshal.GetFunctionPointerForDelegate(sImgCallback);
                    streamtype = Convert.ToUInt16(HvStreamType.SmallImage);
                    f = HVDLLFun.SetHvCallBack(this.m_Hv, ptfunImgsmall, argfirst, 0, streamtype);
                    if(f>-1)
                        f = HVDLLFun.SetHvCallBack(this.m_Hv, ptfunImgsmall, argsecond, 1, streamtype);
                }
            }
            if (f > -1)
            {
                //大图回调
                unsafe
                {
                    bImgCallbak = new HVDLLFun.BIG_IMAGE_CALLBACK(onBigImgCallBack);
                    IntPtr ptfunImgbig = Marshal.GetFunctionPointerForDelegate(bImgCallbak);
                    streamtype = Convert.ToUInt16(HvStreamType.BigImage);
                    f = HVDLLFun.SetHvCallBack(this.m_Hv, ptfunImgbig, argfirst, 0, streamtype);
                    if(f>-1)
                        f = HVDLLFun.SetHvCallBack(this.m_Hv, ptfunImgbig, argsecond, 1, streamtype);
                }
            }
            if (f > -1)
            {
                //视频回调
                unsafe
                {
                    videoCallback = new HVDLLFun.VIDEO_CALLBACK(onVideoCallBack);
                    IntPtr ptfunVideo = Marshal.GetFunctionPointerForDelegate(videoCallback);
                    streamtype = Convert.ToUInt16(HvStreamType.FullCmpImage);
                    f = HVDLLFun.SetHvCallBack(this.m_Hv, ptfunVideo, argfirst, 0, streamtype);
                    if(f>-1)
                        f = HVDLLFun.SetHvCallBack(this.m_Hv, ptfunVideo, argsecond, 1, streamtype);
                }
            }
            if (f < 0)
            {
                this.Close();
                return "回调设置失败!";
            }
            ThreadManager.QueueUserWorkItem(delegate(object obj) { this.checkedOpened(); }, null);
            return "";
        }
コード例 #2
0
        /// <summary>
        /// 打开指定IP地址的识别器
        /// </summary>
        /// <param name="ip">识别器IP地址</param>
        /// <returns></returns>
        public string Open(string ip)
        {
            //已经打开直接返回,关闭时同步退出打开状态检查
            if (IntPtr.Zero != this.m_Hv && this.ipaddr == ip)
            {
                return("");
            }
            this.Close();
            this.m_Hv = HVDLLFun.OpenHv(ip);
            if (m_Hv == IntPtr.Zero)
            {
                this.m_Hv        = IntPtr.Zero;
                this.ipaddr      = "";
                resultFirst.m_Hv = resultSecond.m_Hv = IntPtr.Zero;
                return("连接设备失败!");
            }
            this.ipaddr      = ip;
            resultFirst.m_Hv = resultSecond.m_Hv = this.m_Hv;
            //创建参数
            //第一通道参数
            IntPtr argfirst = Marshal.GetIUnknownForObject(this.resultFirst);
            //第二通道参数
            IntPtr argsecond = Marshal.GetIUnknownForObject(this.resultSecond);

            //车牌号回调
            plateCallback = new HVDLLFun.PLATE_NO_CALLBACK(onPlateNoCallBack);
            IntPtr ptfunPlt   = Marshal.GetFunctionPointerForDelegate(plateCallback);
            UInt16 streamtype = Convert.ToUInt16(HvStreamType.PlateStr);
            int    f          = HVDLLFun.SetHvCallBack(this.m_Hv, ptfunPlt, argfirst, 0, streamtype);

            if (f > -1)
            {
                f = HVDLLFun.SetHvCallBack(this.m_Hv, ptfunPlt, argsecond, 1, streamtype);
            }
            if (f > -1)
            {
                //车牌小图回调
                unsafe
                {
                    sImgCallback = new HVDLLFun.SMALL_IMAGE_CALLBACK(onSmallImgCallBack);
                    IntPtr ptfunImgsmall = Marshal.GetFunctionPointerForDelegate(sImgCallback);
                    streamtype = Convert.ToUInt16(HvStreamType.SmallImage);
                    f          = HVDLLFun.SetHvCallBack(this.m_Hv, ptfunImgsmall, argfirst, 0, streamtype);
                    if (f > -1)
                    {
                        f = HVDLLFun.SetHvCallBack(this.m_Hv, ptfunImgsmall, argsecond, 1, streamtype);
                    }
                }
            }
            if (f > -1)
            {
                //大图回调
                unsafe
                {
                    bImgCallbak = new HVDLLFun.BIG_IMAGE_CALLBACK(onBigImgCallBack);
                    IntPtr ptfunImgbig = Marshal.GetFunctionPointerForDelegate(bImgCallbak);
                    streamtype = Convert.ToUInt16(HvStreamType.BigImage);
                    f          = HVDLLFun.SetHvCallBack(this.m_Hv, ptfunImgbig, argfirst, 0, streamtype);
                    if (f > -1)
                    {
                        f = HVDLLFun.SetHvCallBack(this.m_Hv, ptfunImgbig, argsecond, 1, streamtype);
                    }
                }
            }
            if (f > -1)
            {
                //视频回调
                unsafe
                {
                    videoCallback = new HVDLLFun.VIDEO_CALLBACK(onVideoCallBack);
                    IntPtr ptfunVideo = Marshal.GetFunctionPointerForDelegate(videoCallback);
                    streamtype = Convert.ToUInt16(HvStreamType.FullCmpImage);
                    f          = HVDLLFun.SetHvCallBack(this.m_Hv, ptfunVideo, argfirst, 0, streamtype);
                    if (f > -1)
                    {
                        f = HVDLLFun.SetHvCallBack(this.m_Hv, ptfunVideo, argsecond, 1, streamtype);
                    }
                }
            }
            if (f < 0)
            {
                this.Close();
                return("回调设置失败!");
            }
            ThreadManager.QueueUserWorkItem(delegate(object obj) { this.checkedOpened(); }, null);
            return("");
        }