Example #1
0
 public void conectarAccion()
 {
     try
     {
         reader = new BRIReader(this, null);
         if (reader.Attributes.SetTAGTYPE("EPCC1G2") == true)
         {
             if (reader.IsConnected == true)
             {
                 MessageBox.Show("READER CONECTADO", "EXITO");
                 btnConectar.Enabled = false;
                 btnLeer.Enabled     = true;
                 b = true;
             }
             else
             {
                 MessageBox.Show("No se pudo establecer el protocolo Gen2. Intente conectarse de nuevo o reinicie el lector.", "Error de conexión", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                 b = false;
             }
         }
         else
         {
             MessageBox.Show("No se pudo establecer el protocolo Gen2. Intente conectarse de nuevo o reinicie el lector.", "Error de conexión", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
             b = false;
             reader.Dispose();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         MessageBox.Show("No se pudo establecer el protocolo Gen2. Intente conectarse de nuevo o reinicie el lector.", "Error de conexión", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
         b = false;
     }
 }
        //public void OnTimerResetEvent(object source, EventArgs e)
        //{
        //    Console.WriteLine("GreenEvent - Poll Tags");
        //    brdr.Execute("READ POLL");
        //    if (timerReset.Enabled == true)
        //    {
        //        brdr.PollTags();
        //        tRed = 0;
        //        tAlarm = 0;
        //        tGreen = 0;
        //    }
        //}
        #endregion

        #region Close Reader
        public void CloseReader()
        {
            //delete macros and triggers
            //dispose of IDL reader class
            string sMsg = null;

            try
            {
                if (brdr != null)
                {
                    if (bDebug == true)
                    {
                        System.Console.WriteLine("Deleting triggers and macros...");
                    }
                    sMsg = brdr.Execute("TRIGGER RESET");
                    if (bDebug == true)
                    {
                        System.Console.WriteLine("TRIGGER RESET -> " + sMsg);
                    }
                    brdr.StopReadingTags();
                    brdr.Dispose();
                }
            }
            catch (Exception Ex)
            {
                Console.WriteLine("EX CloseReader: " + Ex.Message);
            }
        }
Example #3
0
 public void limpia()
 {
     hilo.Abort();
     reader.Dispose();
     button2.Enabled = true;
     b = false;
 }
Example #4
0
 //Botón de conectar el reader con la Hand Held, debe de estar pareado con anterioridad.
 private void btnConectar_Click(object sender, EventArgs e)
 {
     Cursor.Current = Cursors.WaitCursor;
     try {
         reader = new BRIReader(this, null);
         if (reader.Attributes.SetTAGTYPE("EPCC1G2") == true)
         {
             if (reader.IsConnected == true)
             {
                 lblStatus.Text      = "READER CONECTADO";
                 btnConectar.Enabled = false;
                 btnLeer.Enabled     = true;
                 b = true;
                 btnLeer.Focus();
             }
             else
             {
                 MessageBox.Show("No se pudo establecer el protocolo Gen2. Intente conectarse de nuevo o reinicie el lector.", "Error de conexión", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                 b = false;
             }
         }
         else
         {
             MessageBox.Show("No se pudo establecer el protocolo Gen2. Intente conectarse de nuevo o reinicie el lector.", "Error de conexión", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
             b = false;
             reader.Dispose();
         }
     } catch (Exception ex) {
         MessageBox.Show(ex.Message);
         MessageBox.Show("No se pudo establecer el protocolo Gen2. Intente conectarse de nuevo o reinicie el lector.", "Error de conexión", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
         b = false;
     }
     Cursor.Current = Cursors.Default;
 }
Example #5
0
 private void btnConectar_Click(object sender, EventArgs e)
 {
     try
     {
         reader = new BRIReader(this, null);
         if (reader.Attributes.SetTAGTYPE("EPCC1G2") == true)
         {
             if (reader.IsConnected == true)
             {
                 MessageBox.Show("READER CONECTADO", "Exito");
                 btnConectar.Enabled = false;
                 btnDetener.Enabled  = true;
                 b = true;
             }
             else
             {
                 MessageBox.Show("Sin conexion al reader. Intente conectarse de nuevo o reinicie el lector.", "Error de conexión", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                 b = false;
             }
         }
         else
         {
             MessageBox.Show("Sin conexion al reader. Intente conectarse de nuevo o reinicie el lector.", "Error de conexión", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
             b = false;
             reader.Dispose();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         MessageBox.Show("Sin conexion al reader. Intente conectarse de nuevo o reinicie el lector.", "Error de conexión", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
         b = false;
     }
 }
Example #6
0
        /// <summary>
        /// 读取数据 达州
        /// </summary>
        /// <param name="strPort"></param>
        /// <param name="nBaudrate"></param>
        /// <param name="errString"></param>
        /// <returns></returns>
        //public List<string> LoadTagList(string strPort, int nBaudrate, out string errString)
        //{
        //    List<string> listRfid = new List<string>();
        //    errString = string.Empty;
        //    string[] MyTagList = new string[100];
        //    try
        //    {
        //        brdr = new BRIReader(null, "SERIAL://" + strPort);
        //        DateTime now = DateTime.Now;
        //        do
        //        {
        //            bool state = brdr.Read();
        //            if (brdr.TagCount > 0)
        //            {
        //                foreach (Tag tt in brdr.Tags)
        //                {
        //                    listRfid.Add(tt.ToString());
        //                    //MyTagList[++iTagCount] = tt.ToString();
        //                    //if (tt.TagFields.ItemCount > 0)
        //                    //{
        //                    //    foreach (TagField tf in tt.TagFields.FieldArray)
        //                    //    {
        //                    //        if (tf.Status < 0)
        //                    //        {
        //                    //            //code to handle read or write error on this field
        //                    //        }
        //                    //        else
        //                    //        {
        //                    //            //get field data such as ANT, COUNT, TIME, AFI, etc.
        //                    //            MyTagList[iTagCount] += " " + tf.ToString();
        //                    //        }
        //                    //    }
        //                    //}
        //                    //listRfid.Add(MyTagList[iTagCount]);
        //                }
        //            }
        //            if (listRfid.Count != 0)//读取到数据就跳出
        //            {
        //                break;
        //            }
        //        } while (((TimeSpan)(DateTime.Now - now)).TotalSeconds < 8);//5秒后无数据就返回
        //        brdr.Dispose();
        //        // this.CloseCom();
        //        return listRfid;
        //    }
        //    catch (Exception e)
        //    {
        //        brdr.Dispose();
        //        throw new Exception("错误:" + e.Message + "," + errString + ",数据:" + listRfid.ToArray());
        //    }
        //}

        public List <string> LoadTagList(string strPort, int nBaudrate, out string errString)
        {
            List <string> listRfid = new List <string>();

            errString = string.Empty;
            string[] MyTagList = new string[100];
            try
            {
                brdr = new BRIReader(null, "SERIAL://" + strPort);
            }
            catch (Exception ex)
            {
                THOKUtil.ShowError("BRIReader读取串口 [ " + strPort + " ] 失败!" + "内部:" + ex.Message);
                //throw new Exception("BRI读取串口:" + ex.Message);
                return(null);
            }
            try
            {
                DateTime now = DateTime.Now;
                do
                {
                    bool state = brdr.Read();
                    if (brdr.TagCount > 0)
                    {
                        foreach (Tag tt in brdr.Tags)
                        {
                            listRfid.Add(tt.ToString());
                        }
                    }
                    if (listRfid.Count != 0)//读取到数据就跳出
                    {
                        break;
                    }
                }while (((TimeSpan)(DateTime.Now - now)).TotalSeconds < 8);//5秒后无数据就返回
                brdr.Dispose();
                return(listRfid);
            }
            catch (Exception e)
            {
                brdr.Dispose();
                THOKUtil.ShowError("方法LoadTagList错误:" + e.Message + "," + errString + ",数据:" + listRfid.ToArray());
                return(null);
            }
        }
Example #7
0
 private void Cleanup()
 {
     if (reader != null)
     {
         reader.StopReadingTags();
         reader.Dispose();
     }
     if (db != null && dbAdonis != null)
     {
         db.CloseConnection();
         dbAdonis.CloseConnection();
     }
 }
Example #8
0
        public void conectarAccion()
        {
            try
            {
                /*
                 * // DETECCION DE EMULADOR PRUEBAS
                 * if (TestEmulator.isEmulator())
                 * {
                 *  MessageBox.Show("READER CONECTADO", "EXITO");
                 *  btnConectar.Enabled = false;
                 *  btnFinalizar.Enabled = true;
                 *  b = true;
                 *
                 *
                 *  return;
                 * }
                 * // FIN DETECCION DE EMULADOR PRUEBAS
                 * /**/



                reader = new BRIReader(this, null);
                if (reader.Attributes.SetTAGTYPE("EPCC1G2") == true)
                {
                    if (reader.IsConnected == true)
                    {
                        MessageBox.Show("READER CONECTADO", "EXITO");
                        btnConectar.Enabled  = false;
                        btnFinalizar.Enabled = true;
                        b = true;
                    }
                    else
                    {
                        MessageBox.Show("No se pudo establecer el protocolo Gen2. Intente conectarse de nuevo o reinicie el lector.", "Error de conexión", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                        b = false;
                    }
                }
                else
                {
                    MessageBox.Show("No se pudo establecer el protocolo Gen2. Intente conectarse de nuevo o reinicie el lector.", "Error de conexión", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    b = false;
                    reader.Dispose();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                MessageBox.Show("No se pudo establecer el protocolo Gen2. Intente conectarse de nuevo o reinicie el lector.", "Error de conexión", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                b = false;
            }
        }
Example #9
0
 public void Dispose()
 {
     if (_BRIReader != null)
     {
         _BRIReader.Dispose();
         _BRIReader = null;
     }
     if (_SSAPI != null)
     {
         _SSAPI.Dispose();
         _SSAPI = null;
     }
     base.Dispose();
 }
Example #10
0
        /// <summary>
        /// 关闭读取器连接
        /// </summary>
        /// <returns></returns>
        public ReturnMessage CloseReaderConnection()
        {
            ReturnMessage returnMsg = new ReturnMessage();

            DeleteTriggers();

            if (m_RFIDReader != null)
            {
                m_RFIDReader.Dispose();
                m_RFIDReader = null;
            }

            returnMsg.CallStatus  = true;
            returnMsg.CallMessage = "关闭成功";
            return(returnMsg);
        }
Example #11
0
        private void btnConectar_Click(object sender, EventArgs e)
        {
            try
            {
                /*
                 * // DETECCION DE EMULADOR PRUEBAS
                 * if (TestEmulator.isEmulator())
                 * {
                 *  lblEstatus.Text = "READER CONECTADO";
                 *  btnConectar.Enabled = false;
                 *  btnDetener.Enabled = true;
                 *  b = true;
                 *
                 *  return;
                 * }*/
                // FIN DETECCION DE EMULADOR PRUEBAS

                reader = new BRIReader(this, null);
                if (reader.Attributes.SetTAGTYPE("EPCC1G2") == true)
                {
                    if (reader.IsConnected == true)
                    {
                        lblEstatus.Text     = "READER CONECTADO";
                        btnConectar.Enabled = false;
                        btnDetener.Enabled  = true;
                        b = true;
                    }
                    else
                    {
                        MessageBox.Show("No se pudo establecer el protocolo Gen2. Intente conectarse de nuevo o reinicie el lector.", "Error de conexión", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                        b = false;
                    }
                }
                else
                {
                    MessageBox.Show("No se pudo establecer el protocolo Gen2. Intente conectarse de nuevo o reinicie el lector.", "Error de conexión", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    b = false;
                    reader.Dispose();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                MessageBox.Show("No se pudo establecer el protocolo Gen2. Intente conectarse de nuevo o reinicie el lector.", "Error de conexión", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                b = false;
            }
        }
Example #12
0
 public void limpia()
 {
     if (hilo != null)
     {
         hilo.Abort();
     }
     if (reader != null)
     {
         reader.Dispose();
     }
     if (btnConectar.Enabled == false)
     {
         btnConectar.Enabled = true;
     }
     b = false;
     this.Close();
 }
Example #13
0
 public void conectarAccion()
 {
     try
     {
         reader = new BRIReader(this, null);
         if (reader.Attributes.SetTAGTYPE("EPCC1G2") == true)
         {
             if (reader.IsConnected == true)
             {
                 MessageBox.Show("READER CONECTADO", "EXITO");
                 comboArticulo.Enabled = true;
                 btnConectar.Enabled   = true;
                 btnLeer.Enabled       = true;
                 btnLeer.Visible       = true;
                 //menuItem2.Enabled = true;
                 b = true;
             }
             else
             {
                 MessageBox.Show("Intente conectarse de nuevo o reinicie el lector.", "Error de conexión", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                 b       = false;
                 elimina = cm.deleteRemision(remi);
             }
         }
         else
         {
             MessageBox.Show("Intente conectarse de nuevo o reinicie el lector.", "Error de conexión", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
             elimina = cm.deleteRemision(remi);
             b       = false;
             reader.Dispose();
         }
     }
     catch (Exception ex)
     {
         error   = ex.Message;
         elimina = cm.deleteRemision(remi);
         MessageBox.Show("Intente conectarse de nuevo o reinicie el lector.", "Error de conexión", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
         b = false;
     }
 }
Example #14
0
 /// <summary>
 /// 读取数据 达州
 /// </summary>
 /// <param name="strPort"></param>
 /// <param name="nBaudrate"></param>
 /// <param name="errString"></param>
 /// <returns></returns>
 //public List<string> LoadTagList(string strPort, int nBaudrate, out string errString)
 //{
 //    List<string> listRfid = new List<string>();
 //    errString = string.Empty;
 //    string[] MyTagList = new string[100];
 //    try
 //    {
 //        brdr = new BRIReader(null, "SERIAL://" + strPort);
 //        DateTime now = DateTime.Now;
 //        do
 //        {
 //            bool state = brdr.Read();
 //            if (brdr.TagCount > 0)
 //            {
 //                foreach (Tag tt in brdr.Tags)
 //                {
 //                    listRfid.Add(tt.ToString());
 //                    //MyTagList[++iTagCount] = tt.ToString();
 //                    //if (tt.TagFields.ItemCount > 0)
 //                    //{
 //                    //    foreach (TagField tf in tt.TagFields.FieldArray)
 //                    //    {
 //                    //        if (tf.Status < 0)
 //                    //        {
 //                    //            //code to handle read or write error on this field
 //                    //        }
 //                    //        else
 //                    //        {
 //                    //            //get field data such as ANT, COUNT, TIME, AFI, etc.
 //                    //            MyTagList[iTagCount] += " " + tf.ToString();
 //                    //        }
 //                    //    }
 //                    //}
 //                    //listRfid.Add(MyTagList[iTagCount]);
 //                }
 //            }
 //            if (listRfid.Count != 0)//读取到数据就跳出
 //            {
 //                break;
 //            }
 //        } while (((TimeSpan)(DateTime.Now - now)).TotalSeconds < 8);//5秒后无数据就返回
 //        brdr.Dispose();
 //        // this.CloseCom();
 //        return listRfid;
 //    }
 //    catch (Exception e)
 //    {
 //        brdr.Dispose();
 //        throw new Exception("错误:" + e.Message + "," + errString + ",数据:" + listRfid.ToArray());
 //    }
 //}
 public List<string> LoadTagList(string strPort, int nBaudrate, out string errString)
 {
     List<string> listRfid = new List<string>();
     errString = string.Empty;
     string[] MyTagList = new string[100];
     try
     {
         brdr = new BRIReader(null, "SERIAL://" + strPort);
     }
     catch (Exception ex)
     {
         THOKUtil.ShowError("BRIReader读取串口 [ " + strPort + " ] 失败!" + "内部:" + ex.Message);
         //throw new Exception("BRI读取串口:" + ex.Message);
         return null;
     }
     try
     {
         DateTime now = DateTime.Now;
         do
         {
             bool state = brdr.Read();
             if (brdr.TagCount > 0)
             {
                 foreach (Tag tt in brdr.Tags)
                 {
                     listRfid.Add(tt.ToString());
                 }
             }
             if (listRfid.Count != 0)//读取到数据就跳出
             {
                 break;
             }
         }
         while (((TimeSpan)(DateTime.Now - now)).TotalSeconds < 8);//5秒后无数据就返回
         brdr.Dispose();
         return listRfid;
     }
     catch (Exception e)
     {
         brdr.Dispose();
         THOKUtil.ShowError("方法LoadTagList错误:" + e.Message + "," + errString + ",数据:" + listRfid.ToArray());
         return null;
     }
 }