/// <summary>
        /// 事件构造函数
        /// </summary>
        /// <param name="info">条码信息</param>
        /// <param name="weight">重量</param>
        internal EmbraceEventArgs(BarCodeDescribe info, Double weight)
        {
            // 一维码信息
            this._BarCode = info;

            // 初始化揽件重量
            _Weight = weight;
        }
Esempio n. 2
0
        /// <summary>
        /// 事件克隆
        /// </summary>
        /// <returns>克隆对象结果</returns>
        public BarCodeDescribe Clone()
        {
            BarCodeDescribe newObj = new BarCodeDescribe();

            newObj.Code      = this.Code;
            newObj.Type      = this.Type;
            newObj.Regions   = this.Regions;
            newObj.GrabImage = this.GrabImage;
            return(newObj);
        }
Esempio n. 3
0
        /// <summary>
        /// 称重事件回调
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void OnWight(object sender, WeightEventArgs e)
        {
            if (e._bNeedOutPut)
            {
                //称的触发 移动 到客户端 否则由底层控制不合适
                //_BarCodeCamera[0].IoOutput( 800 );
                //_BarCodeCamera[1].IoOutput(20);
                //_BarCodeCamera[0].IoOutput(20);
            }

            if (Interlocked.Read(ref _bBinding) == 1)
            {
                if (WeightHandle != null)
                {
                    WeightHandle(this, e);
                }
            }

            if (e.RealWeight)
            {
                // 实时数据绑定
                Interlocked.CompareExchange(ref _bBinding, 0, 1);

                //条码通知
                Interlocked.CompareExchange(ref _bBarCodeNotifyFlag, 0, 1);

                if (_BarCodeInfo != null)
                {
                    /*
                     * if (_BarCodeCamera != null)
                     * {
                     *  // 相机Io输出
                     *  _BarCodeCamera.IoOutput(100);
                     * }
                     */
                    // 绑定数据信息
                    if (EmbraceHandle != null)
                    {
                        EmbraceHandle(this, new EmbraceEventArgs(_BarCodeInfo, e.Weight));
                    }

                    // 清理一维码数据
                    _BarCodeInfo = null;
                }
                // 兼容手动获取重量
                else
                {
                    if (WeightHandle != null)
                    {
                        WeightHandle(sender, e);
                    }
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 一维码事件回调
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void OnBarCode(object sender, BarCodeEventArgs e)
        {
            // 1.非有效条码信息,回调图像数据
            // 2.条码数量大于1
            if (e.Result.Code == string.Empty)
            {
                if (BarCodeHandle != null)
                {
                    BarCodeHandle(this, e);
                }
                return;
            }

            if (Interlocked.Read(ref _bBarCodeNotifyFlag) == 1)
            {
                return;
            }

            // 判断是否为重复条码数据
            if (_BarcodeCache.IsIn(e.Result.Code))
            {
                BarcodeSustaining.Stop();
                long t = BarcodeSustaining.ElapsedMilliseconds;


                if (t <= MvBarCode.MvBarCodeGlobalVar.BarcodeValidTime)
                {
                    BarcodeSustaining.Start();
                    return;
                }
            }

            BarcodeSustaining.Reset();
            BarcodeSustaining.Start();

            // 条码事件,直接回调
            if (BarCodeHandle != null)
            {
                //MvBarCode.MvBarCodeGlobalVar.Log.InfoFormat("DeviceLayer读取到条码:{0}",e.Result.Code);
                //读条形码
                BarCodeHandle(this, e);
            }

            // 记录条码数据信息
            if (Interlocked.CompareExchange(ref _bBarCodeNotifyFlag, 1, 0) == 0)
            {
                // 添加条码到缓冲中
                _BarcodeCache.Push(e.Result.Code);

                // 记录绑定标识
                Interlocked.Exchange(ref _bBinding, 1);

                // 记录一维码信息
                _BarCodeInfo = e.Result;

                // 检测到一维码后开始获取称数据
                if (_Scale != null)
                {
                    _Scale.AsyncPost(e.Result.Code);

                    // 启动重量检测超时定时器
                }
                else
                {
                    Interlocked.CompareExchange(ref _bBarCodeNotifyFlag, 0, 1);
                }
            }
        }
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="item">一维码描述信息</param>
 internal BarCodeEventArgs(BarCodeDescribe item)
 {
     _Result = item;
 }