Ejemplo n.º 1
0
        /// <summary>
        /// 读卡回调函数
        /// </summary>
        /// <param name="paramObject"></param>
        private void MonitorCard(object paramObject)
        {
            uint  cardNo;
            short result = Rf32Controller.rf_card(_icDev, 0, out cardNo);

            //Debug.WriteLine("jianshi:" + result);
            if (result != 0)
            {
                _monitorCardNumNoReadCount++;
            }
            else
            {
                // Rf32Controller.rf_reset(_icDev, 3);
                _monitorCardNumNoReadCount = 0;
            }
            if (_monitorCardNumNoReadCount >= 3)
            {
                //触发移卡事件
                if (OnRemoveCard != null)
                {
                    //_monitorCardNoTimer.Change(-1, -1);
                    _monitorCardNumNoReadCount = 0;
                    OnRemoveCard(_icCardCfg.ComPort);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 读取卡号
        /// </summary>
        /// <returns></returns>
        public string ReadCardOrgNo()
        {
            string result = string.Empty;

            try
            {
                if (this._icDev <= 0)
                {
                    this.Open();
                }
                if (this._icDev > 0)
                {
                    short num = Rf32Controller.rf_card(this._icDev, 0, out this.cardNo);
                    if (num == 0)
                    {
                        result = this.cardNo.ToString();
                        Rf32Controller.rf_beep(_icDev, 20);
                    }
                    else
                    {
                        IcCardReaderLogger.Error(string.Format("ReadCardOrgNo读卡失败,原因:{0}", num));
                    }
                }
                else
                {
                    IcCardReaderLogger.Error("ReadCardOrgNo打开IC读卡器失败!_icDev=" + _icDev.ToString());
                }
            }
            catch (Exception ex)
            {
                IcCardReaderLogger.Error("ReadCardOrgNo执行异常!_icDev=" + _icDev.ToString(), ex);
            }
            return(result);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 读卡回调函数
        /// </summary>
        /// <param name="paramObject"></param>
        private void Alarm()
        {
            int temp = 1000;//默认寻卡时间

            int.TryParse(_icCardCfg.Interval, out temp);
            IcCardReaderLogger.Debug("读取IC读卡器寻卡时间!Interval=" + temp);
            while (_searchCard)
            {
                short result = Rf32Controller.rf_card(_icDev, 0, out cardNo);
                IcCardReaderLogger.Debug("IC读卡器寻卡!result=" + result.ToString());
                if (result == 0)
                {
                    Rf32Controller.rf_beep(_icDev, 20);
                    IcCardReaderLogger.Debug("读卡成功");
                    if (OnReadCardNo != null && _canReadCard)
                    {
                        if (_isDebug)
                        {
                            OnReadCardNo(_icCardCfg.ComPort, "B35CADE2");
                        }
                        else
                        {
                            IcCardReaderLogger.Debug(string.Format("触发读卡事件。ComPort={0},cardNo={1}", _icCardCfg.ComPort, cardNo.ToString()));
                            OnReadCardNo(_icCardCfg.ComPort, cardNo.ToString());
                        }
                    }

                    ////启动监控定时器
                    //TimerCallback callBack = new TimerCallback(MonitorCard);
                    //_monitorCardNoTimer = new Timer(MonitorCard, null, Timeout.Infinite, 500);
                    //_monitorCardNoTimer.Change(100, 500);
                }
                Thread.Sleep(temp);
            }
        }