Пример #1
0
        /// <summary>
        /// ��жF6B����
        /// </summary>
        /// <returns></returns>
        private bool ReaderF6B(out int flag)
        {
            bool isRight = false;

            flag = 0;
            Reader reader = null;

            try
            {
                reader = RfidAdapter.CreateReader(RFIDModule.F6B, irpName);
                string prdno = "";
                string err   = "";
                bool   ret   = false;

                RfidControl.Active();
                Thread.Sleep(400);
                for (int i = 0; i < 1; i++)
                {
                    if (!reader.IsConnected)
                    {
                        reader.Connect();
                        Thread.Sleep(100);
                        if (!reader.IsConnected)
                        {
                            continue;
                        }
                    }
                    ret = RfidConfigration_6C.GetProductNo(out prdno, out err);
                    if (ret)
                    {
                        break;
                    }
                }

                if (ret)
                {
                    if (prdno.Length >= 4 &&
                        prdno.IndexOf("F6BE", 0) > -1)
                    {
                        flag    = 2;
                        isRight = true;
                    }
                    else if (prdno.Length >= 3 &&
                             prdno.IndexOf("F6B", 0) > -1)
                    {
                        flag    = 1;
                        isRight = true;
                    }
                }
            }
            catch { }
            finally
            {
                if (reader != null)
                {
                    reader.Disconnect();
                    reader.Dispose();
                    reader = null;
                }
                RfidControl.Deactive();
            }

            return(isRight);
        }
Пример #2
0
        /// <summary>
        /// ��жF6C����
        /// </summary>
        /// <returns></returns>
        private bool ReaderF6C()
        {
            bool   isRight   = false;
            Reader reader    = null;
            int    sleepspan = 400;

            try
            {
                reader = RfidAdapter.CreateReader(RFIDModule.F6C, irpName);
                string prdno = "";
                string err   = "";
                bool   ret   = false;

                if (_pdamodel == PDAInfo.DevModel.XC2903)
                {
                    RfidControl.SwitchRfid(RfidControl.RFIDModuleFlag.Internal);
                }
                else
                {
                    RfidControl.Active();
                }

                ////if (devicetype == "2903")
                ////{
                ////    RfidControl.SwitchRfid(RfidControl.RFIDModuleFlag.Internal);
                ////}
                ////else
                ////{
                ////    RfidControl.Active();
                ////}
                Thread.Sleep(sleepspan);
                if (!reader.IsConnected)
                {
                    reader.Connect();
                    Thread.Sleep(sleepspan);
                }
                for (int i = 0; i < 2; i++)
                {
                    if (reader.IsConnected)
                    {
                        ret = RfidConfigration_6C.GetProductNo(out prdno, out err);
                    }
                    //if (!ret && devicetype == "2903")
                    if (!ret && _pdamodel == PDAInfo.DevModel.XC2903)
                    {
                        bool isext = RfidControl.IsExtRfid();
                        if (!isext)
                        {
                            break;
                        }
                        RfidControl.Deactive();
                        Thread.Sleep(sleepspan);
                        RfidControl.SwitchRfid(RfidControl.RFIDModuleFlag.Extern);
                        Thread.Sleep(sleepspan);
                    }
                    else
                    {
                        break;
                    }
                }

                if (ret && !string.IsNullOrEmpty(prdno))
                {
                    if (prdno.Length >= 4 &&
                        (prdno.IndexOf("802", 0) > -1))
                    {
                        isRight = true;
                    }
                }
                else
                {
                    if (!reader.IsConnected)
                    {
                        Log.Debug("Fail to open port");
                    }
                    else if (!ret)
                    {
                        Log.Debug("Fail to get rfid data");
                    }
                }
            }
            catch (Exception ex)
            {
                string strex = ex.Message;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Disconnect();
                    reader.Dispose();
                    reader = null;
                }
                RfidControl.Deactive();
            }
            return(isRight);
        }