コード例 #1
0
        //----------RFID Module Functions Section----------//


        /// <summary>
        /// Establishes a proper connection with the system and M6e Module.
        /// Config module settings such as [antenna port, region,tag reading/writing protocol]
        /// Creates a "Reader" object from the Mecury API
        /// </summary>
        public void ConnectRFID()
        {
            {
                try
                {
                    //Check reading power settings

                    string uri = "eapi:///com" + COM_Port;                                              //Configurations of COMs "USB Port"
                    reader = ThingMagic.Reader.Create(uri);                                             //Create Reader object
                    reader.Connect();
                    reader.ParamSet("/reader/region/id", ThingMagic.Reader.Region.NA);

                    int readPowerMax = (int)reader.ParamGet("/reader/radio/powerMax");
                    int readPowerMin = (int)reader.ParamGet("/reader/radio/powerMin");

                    Console.WriteLine("Max= " + readPowerMax);
                    Console.WriteLine("Min= " + readPowerMin);
                    reader.ParamSet("/reader/radio/readPower", 2000);
                    int[]  antennaList = null;
                    string str         = "1,1";
                    antennaList = Array.ConvertAll(str.Split(','), int.Parse);                                  //Select antenna 1

                    SimpleReadPlan plan = new SimpleReadPlan(antennaList, TagProtocol.GEN2, null, null, 1000);  //Create "Plan" for module configuration
                    reader.ParamSet("/reader/read/plan", plan);

                    connectiveStatus = true;
                    updateConnectiveStatus();                                                                    //Update UI
                }
                catch (System.IO.IOException e)
                {
                    Console.WriteLine(e.Message);
                    MessageBox.Show("COM " + COM_Port + " is not valid. ");
                }
            }
        }
コード例 #2
0
 public bool Connect()
 {
     try
     {
         _reader.Destroy();
     }
     catch (Exception)
     {
         //throw;
     }
     try
     {
         _reader.Connect();
         _reader.TagRead       += TagsReadHandler;
         _reader.ReadException += _reader_ReadException;
         Connected              = true;
         return(Connected);
     }
     catch (Exception)
     {
         Connected = false;
         throw;
     }
 }