Пример #1
0
        public void configTM(int power = 3000)
        {
            int[] antennaList = { 1, 2, 3, 4 }; //选择天线1,2,3,4

            mReaderTM.ParamSet("/reader/region/id", Reader.Region.NA);

            SimpleReadPlan plan = new SimpleReadPlan(antennaList, TagProtocol.GEN2, null, null, 1000); //设置天线和协议

            mReaderTM.ParamSet("/reader/read/plan", plan);

            //场景配置,用于隧道机
            Gen2.LinkFrequency blf = Gen2.LinkFrequency.LINK320KHZ;
            mReaderTM.ParamSet("/reader/gen2/BLF", blf);

            Gen2.Tari tari = Gen2.Tari.TARI_6_25US;
            mReaderTM.ParamSet("/reader/gen2/tari", tari);

            Gen2.TagEncoding tagncoding = Gen2.TagEncoding.FM0;
            mReaderTM.ParamSet("/reader/gen2/tagEncoding", tagncoding);

            Gen2.Session session = Gen2.Session.S1;
            mReaderTM.ParamSet("/reader/gen2/session", session);

            Gen2.Target target = Gen2.Target.A;
            mReaderTM.ParamSet("/reader/gen2/target", target);

            //500~3150
            mReaderTM.ParamSet("/reader/radio/readPower", power);
        }
Пример #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="session"></param>
 /// <param name="target"></param>
 /// <param name="filter"></param>
 /// <param name="antID"></param>
 public CustomAntConfigPerAntenna(Gen2.Session session, Gen2.Target target, TagFilter filter, int antID)
 {
     this.session = session;
     this.target  = target;
     this.filter  = filter;
     this.antID   = antID;
 }
Пример #3
0
        public virtual bool ConnectReader()
        {
            try
            {
                if (reader == null)
                {
                    return(false);
                }

                reader.Connect();

                int[] antennaList = { 1, 2, 3, 4 }; //选择天线1,2,3,4

                reader.ParamSet("/reader/region/id", Reader.Region.NA);

                SimpleReadPlan plan = new SimpleReadPlan(antennaList, TagProtocol.GEN2, null, null, 1000); //设置天线和协议
                reader.ParamSet("/reader/read/plan", plan);

                //场景配置,用于隧道机
                Gen2.LinkFrequency blf = Gen2.LinkFrequency.LINK320KHZ;
                reader.ParamSet("/reader/gen2/BLF", blf);

                Gen2.Tari tari = Gen2.Tari.TARI_6_25US;
                reader.ParamSet("/reader/gen2/tari", tari);

                Gen2.TagEncoding tagncoding = Gen2.TagEncoding.FM0;
                reader.ParamSet("/reader/gen2/tagEncoding", tagncoding);

                Gen2.Session session = Gen2.Session.S1;
                reader.ParamSet("/reader/gen2/session", session);

                Gen2.Target target = Gen2.Target.A;
                reader.ParamSet("/reader/gen2/target", target);

                //500~3150
                reader.ParamSet("/reader/radio/readPower", SysConfig.mReaderPower);

                reader.TagRead       += Reader_OnTagReported;
                reader.ReadException += new EventHandler <ReaderExceptionEventArgs>(r_ReadException);
            }
            catch (Exception ex)
            {
                Log4netHelper.LogError(ex);
                return(false);
            }
            return(true);
        }
Пример #4
0
        static void Main(string[] args)
        {
            // Program setup
            int[] antennaList = { 1, 2, 3, 4 }; //选择天线1,2,3,4

            try
            {
                Reader.SetSerialTransport("tcp", SerialTransportTCP.CreateSerialReader);

                // Create Reader object, connecting to physical device.
                // Wrap reader in a "using" block to get automatic
                // reader shutdown (using IDisposable interface).
                using (Reader r = Reader.Create("tcp://192.168.8.166:8086")) //创建对象
                {
                    r.Connect();                                             //连接读写器

                    r.ParamSet("/reader/region/id", Reader.Region.NA);

                    // Create a simplereadplan which uses the antenna list created above
                    SimpleReadPlan plan = new SimpleReadPlan(antennaList, TagProtocol.GEN2, null, null, 1000); //设置天线和协议
                    // Set the created readplan
                    r.ParamSet("/reader/read/plan", plan);

                    //场景配置,用于隧道机
                    Gen2.LinkFrequency blf = Gen2.LinkFrequency.LINK320KHZ;
                    r.ParamSet("/reader/gen2/BLF", blf);

                    Gen2.Tari tari = Gen2.Tari.TARI_6_25US;
                    r.ParamSet("/reader/gen2/tari", tari);

                    Gen2.TagEncoding tagncoding = Gen2.TagEncoding.FM0;
                    r.ParamSet("/reader/gen2/tagEncoding", tagncoding);

                    Gen2.Session session = Gen2.Session.S1;
                    r.ParamSet("/reader/gen2/session", session);

                    Gen2.Target target = Gen2.Target.A;
                    r.ParamSet("/reader/gen2/target", target);

                    //500~3150
                    r.ParamSet("/reader/radio/readPower", 3000);

                    // 注册标签数据回调方法
                    r.TagRead += delegate(Object sender, TagReadDataEventArgs e)
                    {
                        Console.WriteLine("Background read: " + e.TagReadData);
                    };
                    //创建异常回调方法
                    r.ReadException += new EventHandler <ReaderExceptionEventArgs>(r_ReadException);

                    // 开始读卡
                    r.StartReading();

                    Console.WriteLine("\r\n<Do other work here>\r\n");
                    Thread.Sleep(5000);
                    Console.WriteLine("\r\n<Do other work here>\r\n");
                    Thread.Sleep(10000);
                    //结束读卡
                    r.StopReading();
                }
            }
            catch (ReaderException re)
            {
                Console.WriteLine("Error: " + re.Message);
                Console.Out.Flush();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message);
            }
        }
        /// <summary>
        /// Populate optimal settings based on reader
        /// </summary>
        private void InitializeOptimalSettings()
        {
            _optimalReaderSettings = new Dictionary <string, string>();
            try
            {
                Gen2.LinkFrequency blf = (Gen2.LinkFrequency)_reader.ParamGet("/reader/gen2/BLF");
                switch (blf)
                {
                case Gen2.LinkFrequency.LINK250KHZ:
                    _optimalReaderSettings["/reader/gen2/BLF"] = "LINK250KHZ"; break;

                case Gen2.LinkFrequency.LINK640KHZ:
                    _optimalReaderSettings["/reader/gen2/BLF"] = "LINK640KHZ";; break;

                default:
                    _optimalReaderSettings.Add("/reader/gen2/BLF", ""); break;
                }
            }
            catch (ArgumentException ex)
            {
                if (ex.Message.Contains("Unknown Link Frequency"))
                {
                    MessageBox.Show("Unknown Link Frequency found, Reverting to defaults.", "Universal Reader Assistant", MessageBoxButton.OK, MessageBoxImage.Warning);
                    _optimalReaderSettings["/reader/gen2/BLF"] = "LINK250KHZ";
                }
                else
                {
                    _optimalReaderSettings.Add("/reader/gen2/BLF", "");
                }
            }

            try
            {
                Gen2.Tari tariVal = (Gen2.Tari)_reader.ParamGet("/reader/gen2/Tari");
                switch (tariVal)
                {
                case Gen2.Tari.TARI_6_25US:
                    _optimalReaderSettings["/reader/gen2/tari"] = "TARI_6_25US"; break;

                case Gen2.Tari.TARI_12_5US:
                    _optimalReaderSettings["/reader/gen2/tari"] = "TARI_12_5US"; break;

                case Gen2.Tari.TARI_25US:
                    _optimalReaderSettings["/reader/gen2/tari"] = "TARI_25US"; break;

                default:
                    _optimalReaderSettings.Add("/reader/gen2/tari", ""); break;
                }
            }
            catch (ArgumentException)
            {
                _optimalReaderSettings.Add("/reader/gen2/tari", "");
            }
            catch (ReaderCodeException)
            {
            }

            try
            {
                Gen2.TagEncoding tagencoding = (Gen2.TagEncoding)_reader.ParamGet("/reader/gen2/tagEncoding");
                switch (tagencoding)
                {
                case Gen2.TagEncoding.FM0:
                    _optimalReaderSettings["/reader/gen2/tagEncoding"] = "FM0"; break;

                case Gen2.TagEncoding.M2:
                    _optimalReaderSettings["/reader/gen2/tagEncoding"] = "M2"; break;

                case Gen2.TagEncoding.M4:
                    _optimalReaderSettings["/reader/gen2/tagEncoding"] = "M4"; break;

                case Gen2.TagEncoding.M8:
                    _optimalReaderSettings["/reader/gen2/tagEncoding"] = "M8"; break;

                default:
                    _optimalReaderSettings.Add("/reader/gen2/tagEncoding", ""); break;
                }
            }
            catch (ArgumentException)
            {
                _optimalReaderSettings.Add("/reader/gen2/tagEncoding", "");
            }
            try
            {
                Gen2.Session session = (Gen2.Session)_reader.ParamGet("/reader/gen2/session");
                switch (session)
                {
                case Gen2.Session.S0:
                    _optimalReaderSettings["/reader/gen2/session"] = "S0"; break;

                case Gen2.Session.S1:
                    _optimalReaderSettings["/reader/gen2/session"] = "S1"; break;

                case Gen2.Session.S2:
                    _optimalReaderSettings["/reader/gen2/session"] = "S2"; break;

                case Gen2.Session.S3:
                    _optimalReaderSettings["/reader/gen2/session"] = "S3"; break;

                default:
                    _optimalReaderSettings.Add("/reader/gen2/session", ""); break;
                }
            }
            catch (ArgumentException)
            {
                _optimalReaderSettings.Add("/reader/gen2/session", "");
            }
            try
            {
                Gen2.Target target = (Gen2.Target)_reader.ParamGet("/reader/gen2/Target");
                switch (target)
                {
                case Gen2.Target.A:
                    _optimalReaderSettings["/reader/gen2/target"] = "A"; break;

                case Gen2.Target.B:
                    _optimalReaderSettings["/reader/gen2/target"] = "B"; break;

                case Gen2.Target.AB:
                    _optimalReaderSettings["/reader/gen2/target"] = "AB"; break;

                case Gen2.Target.BA:
                    _optimalReaderSettings["/reader/gen2/target"] = "BA"; break;

                default: _optimalReaderSettings.Add("Target", ""); break;
                }
            }
            catch (FeatureNotSupportedException)
            {
                _optimalReaderSettings.Add("Target", "");
            }
            try
            {
                Gen2.Q qval = (Gen2.Q)_reader.ParamGet("/reader/gen2/q");

                if (qval.GetType() == typeof(Gen2.DynamicQ))
                {
                    _optimalReaderSettings["/reader/gen2/q"] = "DynamicQ";
                }
                else if (qval.GetType() == typeof(Gen2.StaticQ))
                {
                    Gen2.StaticQ stqval = (Gen2.StaticQ)qval;
                    _optimalReaderSettings["/reader/gen2/q"] = "StaticQ";
                    int countQ = Convert.ToInt32(((Gen2.StaticQ)qval).InitialQ);
                    _optimalReaderSettings["/application/performanceTuning/staticQValue"] = countQ.ToString();
                }
                else
                {
                    _optimalReaderSettings.Add("/reader/gen2/q", "");
                }
            }
            catch (FeatureNotSupportedException)
            {
                _optimalReaderSettings.Add("/reader/gen2/q", "");
            }
        }