示例#1
0
 private void btnBuscar_Click(object sender, EventArgs e)
 {
     if (tag.Trim().Length > 0)
     {
         if (b == true)
         {
             lstEpc.Items.Clear();
             reader.Execute("Attrib ants=" + ant);
             reader.Execute("Attrib fieldstrength=" + att1);
             lblEstatus.Text    = "Lectura iniciada";
             hilo               = new Thread(leer_tag);
             RFID               = true;
             btnBuscar.Visible  = false;
             btnBuscar.Enabled  = false;
             btnDetener.Visible = true;
             btnDetener.Enabled = true;
             hilo.Start();
         }
         else
         {
             //MessageBox.Show("No hay conexión con el reader", "Sin conexión", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2);
             lblEstatus.Text = "Sin conexión";
         }
     }
     else
     {
         MessageBox.Show("No se ha fijado ningun Tag para su búsqueda", "Informacion");
     }
 }
        private void btnLeer_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            try
            {
                if (b == true)
                {
                    epc = "";
                    reader.Execute("Attrib ants=" + ant);
                    reader.Execute("Attrib fieldstrength=" + att1);
                    lblEstatus.Text = "Lectura iniciada";
                    hilo            = new Thread(leer_tag);
                    RFID            = true;
                    // whats this for?
                    btnLeer.Visible = false;
                    btnLeer.Enabled = false;
                    //
                    hilo.Start();
                }
                else
                {
                    lblEstatus.Text = "Sin conexión del reader";
                }
            }
            catch (Exception exp)
            {
                string men  = exp.Message;
                string algo = "";
            }
            Cursor.Current = Cursors.Default;
        }
示例#3
0
        /// <summary>
        /// 设置读写器参数
        /// </summary>
        private void SetReaderAttributes()
        {
            string sRsp = null;

            try
            {
                m_RFIDReader.Attributes.SetIDTRIES(1);
                m_RFIDReader.Attributes.SetANTTRIES(1);
                m_RFIDReader.Attributes.SetWRTRIES(3);
                m_RFIDReader.Attributes.SetTAGTYPE("EPCC1G2");
                m_RFIDReader.Attributes.SetANTS(this.ReaderAntennasList.ToArray());
                sRsp = m_RFIDReader.Execute("ATTRIB");
                if (!string.IsNullOrEmpty(ReaderPowerString))
                {
                    sRsp = m_RFIDReader.Execute("ATTRIBUTE FIELDSTRENGTH=" + this.ReaderPowerString);
                }
                else
                {
                    sRsp = m_RFIDReader.Execute("ATTRIBUTE FIELDSTRENGTH=30dB, 30dB, 30dB, 30dB");
                }
            }
            catch (BasicReaderException ex)
            {
                throw ex;
            }
        }
 public void leerAccion()
 {
     if (b == true)
     {
         reader.Execute("Attrib ants=" + ant);
         reader.Execute("Attrib fieldstrength=" + att1);
         hilo               = new Thread(leer_tag);
         btnLeer.Visible    = false;
         btnLeer.Enabled    = false;
         btnDetener.Visible = true;
         btnDetener.Enabled = true;
         hilo.Start();
     }
     else
     {
         MessageBox.Show("No hay conexión con el reader", "Sin conexión", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2);
     }
 }
示例#5
0
 public void leerAccion()
 {
     if (b == true)
     {
         reader.Execute("Attrib ants=" + ant);
         reader.Execute("Attrib fieldstrength=" + att1);
         hilo               = new Thread(leer_tag);
         RFID               = true;
         btnLeer.Visible    = false;
         btnLeer.Enabled    = false;
         btnDetener.Visible = true;
         btnDetener.Enabled = true;
         hilo.Start();
     }
     else
     {
         elimina        = cm.deleteRemision(remi);
         Cursor.Current = Cursors.Default;
         MessageBox.Show("No hay conexión con el reader", "Sin conexión", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2);
         //button2.Enabled = true;
     }
 }
 public void OnTimerRedEvent(object source, EventArgs e)
 {
     try
     {
         if (tRed > 0)
         {
             brdr.Execute("WRITEGPO 1 ON");
             brdr.Execute("WRITEGPO 2 OFF");
             timerRed.Stop();
         }
     }
     catch (Exception Ex)
     {
         Console.WriteLine("EX OnTimerRedEvent" + Ex.Message);
     }
 }
        public bool CreateReader(string sURL)
        {
            string tMsg    = null;
            bool   bStatus = false;

            if (bDebug == true)
            {
                System.Console.WriteLine("Creating rfid connections...");
            }

            tRed   = 0;
            tAlarm = 0;
            tGreen = 0;

            timerRed.Elapsed      += new System.Timers.ElapsedEventHandler(OnTimerRedEvent);
            timerAlarm.Elapsed    += new System.Timers.ElapsedEventHandler(OnTimerAlarmEvent);
            timerGreen.Elapsed    += new System.Timers.ElapsedEventHandler(OnTimerGreenEvent);
            timerStopRead.Elapsed += new System.Timers.ElapsedEventHandler(timerStopRead_Elapsed);
            timerNA_LED.Elapsed   += new System.Timers.ElapsedEventHandler(timerNA_LED_Elapsed);
            timerArmTimer.Elapsed += new System.Timers.ElapsedEventHandler(timerArmTimer_Elapsed);

            //try connecting to reader till success or 5 attempts
            for (int x = 0; x < 5; x++)
            {
                try
                {
                    //Create reader connection
                    brdr = null;
                    brdr = new BRIReader(null, sURL, 22000, 2000);
                    if (bDebug == true)
                    {
                        System.Console.WriteLine("Connection created");
                    }
                    tMsg = brdr.Execute("VER");
                    if (bDebug == true)
                    {
                        System.Console.WriteLine("VER->" + tMsg);
                    }
                    if (tMsg.IndexOf("OK>") >= 0)
                    {
                        tMsg = brdr.Execute("TRIGGER RESET");
                        if (bDebug == true)
                        {
                            System.Console.WriteLine("TRIGGER RESET->" + tMsg);
                        }
                        //turn off gpio output lines.
                        tMsg = brdr.Execute("WRITEGPIO=15");
                        if (bDebug == true)
                        {
                            System.Console.WriteLine("WRITEGPIO=15->" + tMsg);
                        }
                        bStatus = AddEventHandlers();

                        GPS.bdebug = bDebug;
                        bStatus    = true;
                        break;
                    }
                }
                catch (BasicReaderException eBRI)
                {
                    System.Console.WriteLine("EX CreateReader - BasicReaderException:\r\n" + eBRI.ToString());
                    bStatus = false;
                    return(bStatus);
                }
            }

            if (!bStatus)
            {
                return(bStatus);
            }

            if (bDebug == true)
            {
                System.Console.WriteLine("Reader Ready...starting configuration...");
            }

            //configure reader attributes
            ConfigGen2Settings();

            //create the gpio triggers and macros to execute reads
            if (settings.enable_trigger == "1")
            {
                CreateTriggers();
            }

            return(bStatus);
        }