예제 #1
0
        private void LoadTags(BRIReader tRdr, int iRdrIndex)
        {
            //this code is not currently used.

            //retrieve tag ids
            int    RspCount = 0;
            string sTagID   = null;


            foreach (Tag tt in tRdr.Tags)
            {
                RspCount++;
                sTagID = tt.ToString();
                if (tt.TagFields.ItemCount > 0)
                {
                    foreach (TagField tf in tt.TagFields.FieldArray)
                    {
                        //get field data
                        sTagID += "," + tf.ToString();
                        break;
                    }
                }
                if (bDebug == true)
                {
                    System.Console.WriteLine("TagID -> " + sTagID + " " + DateTime.Now.ToString());
                }
            }
        }
예제 #2
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;
     }
 }
예제 #3
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;
 }
예제 #4
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;
     }
 }
예제 #5
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;
            }
        }
예제 #6
0
 public void Dispose()
 {
     if (_BRIReader != null)
     {
         _BRIReader.Dispose();
         _BRIReader = null;
     }
     if (_SSAPI != null)
     {
         _SSAPI.Dispose();
         _SSAPI = null;
     }
     base.Dispose();
 }
예제 #7
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);
        }
예제 #8
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;
            }
        }
예제 #9
0
 private void Button3_Click(object sender, EventArgs e)
 {
     if (db == null && dbAdonis == null)
     {
         try
         {
             db       = new Database();
             dbAdonis = new DatabaseAdonis();
             address  = ReadConfigFile();
             db.CreateDB();
         }
         catch (MySqlException ex)
         {
             MessageBox.Show("Exception: " + ex.Message);
         }
     }
     if (!isConnected)
     {
         try
         {
             reader          = new BRIReader(this, address);
             isConnected     = true;
             button3.Enabled = false;
             try
             {
                 reader.Attributes.RFIDTagType = BRIReader.RFIDTagTypes.EPCC1G2;
                 reader.Attributes.ReadTries   = 3;
             }
             catch (Exception ex)
             {
                 MessageBox.Show("Failed to set reader attribute, exception= " + ex.Message, "Error");
                 return;
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show("Impossível conectar ao host. Erro: " + ex.Message);
         }
     }
     else
     {
         MessageBox.Show("Leitor já está conectado!");
     }
 }
예제 #10
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);
            }
        }
예제 #11
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;
     }
 }
 public Huecos_Racks(string[] detalle, string[] usuario, string[] rack, string epc, BRIReader reader, int evento, int tipoRack, string newIdSQL)
 {
     InitializeComponent();
     newId = newIdSQL;
     txtHuecos.Focus();
     lblNiveles.Text  = lblNiveles.Text + rack[6];
     lblVentanas.Text = lblVentanas.Text + rack[7];
     if (evento == 0)
     {
         txtEstimado.Text = rack[3];
     }
     if (evento == 1)
     {
         txtEstimado.Text = rack[4];
     }
     lblOP.Text       = rack[2];
     lblArticulo.Text = rack[8];
     tag    = epc;
     racks  = rack;// VER QUE PASA RACK
     user   = usuario;
     folio  = detalle;
     reng   = detalle[11];
     lector = reader;
     evnt   = evento;
     if (evnt == 0)
     {
         txtHuecos.Enabled = false;
         label4.Text       = "Huecos";
     }
     else
     {
         txtHuecos.Enabled = true;
         label4.Text       = "Mermas";
     }
     tr  = tipoRack;
     epc = tag;
 }
        public Contar_Huecos(string[] usuario, string[] folio, bool c, BRIReader lector, int evento, string newid, string epcRFID)
        {
            InitializeComponent();
            epcMerma        = epcRFID;
            newId           = newid;
            op              = folio[1];
            id              = folio[0];
            pzasParcialidad = Convert.ToInt32(folio[14]);
            fol             = folio[1];
            user            = usuario;
            codprod         = folio[8];
            renglon         = folio[11];
            info            = folio;
            b = c;
            btnConectar.Enabled = false;
            reader = lector;
            evnt   = evento;
            switch (evento)
            {
            case 0: this.Text = "Contar Huecos"; break;

            case 1: this.Text = "Contar Mermas"; menuItem2.Text = "Siguiente"; break;

            default: break;
            }
            fillDataGrid();
            ActivaBoton = (dataGrid1.VisibleRowCount);
            if (ActivaBoton == 0)
            {
                menuItem2.Enabled = true;
            }
            else
            {
                menuItem2.Enabled = false;
            }
        }
예제 #14
0
        /// <summary>
        /// 初始化读取器
        /// </summary>
        /// <param name="strIP">strIP有两种情况:1.URL模式: "TCP://127.0.0.1";2.COM模式: "SERIAL://COM4";</param>
        /// <param name="strPort"></param>
        /// <param name="connTimeOut"></param>
        /// <param name="readerPowerList"></param>
        /// <param name="readerAntennasList"></param>
        /// <returns></returns>
        public ReturnMessage InitReader(string strIP, string strPort, string connTimeOut, List <string> readerPowerList, List <string> readerAntennasList)
        {
            ReturnMessage returnMsg = new ReturnMessage();

            if (string.IsNullOrEmpty(strPort))
            {
                strPort = "2189";
            }
            if (readerPowerList == null)
            {
                readerPowerList = new List <string>()
                {
                    "30", "30", "30", "30"
                };
            }
            if (readerAntennasList == null)
            {
                readerAntennasList = new List <string>()
                {
                    "1", "2", "3", "4"
                };
            }
            //strIP有两种情况:
            //URL模式: "TCP://127.0.0.1";
            //COM模式: "SERIAL://COM4";
            this.ReaderIP   = strIP;
            this.ReaderPort = strPort;
            //功率
            string strAntennasPower = string.Empty;

            foreach (var power in readerPowerList)
            {
                strAntennasPower += power + "dB,";
            }
            strAntennasPower       = strAntennasPower.Substring(0, strAntennasPower.Length - 1);
            this.ReaderPowerString = strAntennasPower;

            //开启的天线
            foreach (var antenna in readerAntennasList)
            {
                ReaderAntennasList.Add(Convert.ToInt32(antenna));
            }

            try
            {
                m_RFIDReader = new BRIReader(null, this.ReaderIP);
                if (m_RFIDReader.IsConnected)
                {
                    IsAllowConnect        = true;
                    returnMsg.CallMessage = "读取器连接成功.";
                    returnMsg.CallStatus  = true;
                }
                else
                {
                    IsAllowConnect        = false;
                    returnMsg.CallMessage = "读取器连接失败.";
                    returnMsg.CallStatus  = false;
                }
            }
            catch (BasicReaderException bre)
            {
                IsAllowConnect        = false;
                returnMsg.CallMessage = "读取器连接失败 :" + bre.Message;
                returnMsg.CallStatus  = false;
            }

            //创建日志记录对象
            DeclaimerCommon.DeclaimerReaderLog.InstanceLogger(LoggerClassType.DeclaimerWaitingGodotRollingFileAppender);
            return(returnMsg);
        }
예제 #15
0
        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);
        }
예제 #16
0
        /*
         * CENTER  The center trigger button on a portable reader.
         * LEFT    The left scan button on a mobile computer.
         * MIDDLE  The center scan button on a mobile computer.
         * RIGHT   The right scan button on a mobile computer.
         * UNKNOWN Unknown button ID.
         *
         * The registry changes
         * ie BriReaderButonEnable( RFIDButtonID.Left ) changes event2 from "ITC_RFID_TRIGGER_EVENT" to "RFIDDCE_LEFT_DELTA" (HKEY_LOCAL_MACHINE\Drivers\HID\ClientDrivers\ITCKeyboard\Layout\A-Numeric\0001\Events\Delta)
         * MIDDLE changes event1 between "RFIDDCE_MIDDLE_DELTA" and "DeltaLeftScan"
         *
         * ITC_RFID_TRIGGER_EVENT is for general RFID and used by IntermecSettings for RFID, that does not include Button Event Firing, which is only done for "Button Remapping" settings to "BRI" (which is RFIDDCE_ in registry).
         * RFIDDCE_... is for BRI
         * so, the ITC_RFID_TRIGGER_EVENT will trigger a RFID TAG read but this button press will not be reported to BRIReader
         */
        public Form1()
        {
            InitializeComponent();
            _SSAPI = new SSAPI();
            BRIReader.LoggerOptionsAdv logOpts = new BRIReader.LoggerOptionsAdv();
            logOpts.LogEnable             = true;
            logOpts.LogFilePath           = @"\RFIDLog1.txt";
            logOpts.IDEConsoleEnable      = false; //send to debugOut?
            logOpts.TimeStampEnable       = true;
            logOpts.TraceSeverity         = BasicBRIReader.LoggerOptions.TraceSeverityLevels.DEBUG;
            logOpts.ShowNonPrintableChars = true;

            _BRIReader = new BRIReader(this, "tcp://127.0.0.1:2189", logOpts);

            _BRIReader.EventHandlerRFIDButton += new DCE_BUTTON_EventHandlerAdv(_BRIReader_EventHandlerRFIDButton);

            //for reading TAGs
            _BRIReader.EventHandlerTag += new Tag_EventHandlerAdv(_BRIReader_EventHandlerTag);

            //will only be called for Trigger presses on RFID Handle (if any)
            _BRIReader.EventHandlerTriggerAction += new TriggerAction_EventHandler(_BRIReader_EventHandlerTriggerAction);

            textBox1.Text = getButtonSetting().ToString();

            //if (!this._BRIReader.IsRFIDButtonEnabled(BRIReader.RFIDButtonIDs.MIDDLE))
            //    this._BRIReader.RFIDButtonEnable(BRIReader.RFIDButtonIDs.MIDDLE);

            chkLeftLower.CheckStateChanged  += new EventHandler(CheckStateChanged);
            chkLeftUpper.CheckStateChanged  += new EventHandler(CheckStateChanged);
            chkLeftLower.CheckStateChanged  += new EventHandler(CheckStateChanged);
            chkRightLower.CheckStateChanged += new EventHandler(CheckStateChanged);

            chkBoxes.Add(BRIReader.RFIDButtonIDs.CENTER, chkCenterScan);
            chkBoxes.Add(BRIReader.RFIDButtonIDs.LEFT, chkLeftLower);
            chkBoxes.Add(BRIReader.RFIDButtonIDs.MIDDLE, chkButtonMiddle);
            chkBoxes.Add(BRIReader.RFIDButtonIDs.RIGHT, chkRightLower);

            chkRightUpper.Enabled = false;
            chkLeftUpper.Enabled  = false;

            CheckBox ChkBox = null;

            foreach (BRIReader.RFIDButtonIDs id in bIDs)
            {
                if (_BRIReader.IsRFIDButtonEnabled(id))
                {
                    if (chkBoxes.TryGetValue(id, out ChkBox))
                    {
                        ChkBox.Checked = true;
                    }
                }
                else
                {
                    if (chkBoxes.TryGetValue(id, out ChkBox))
                    {
                        ChkBox.Checked = false;
                    }
                }
            }
            updateCheckBoxes();
            doNotUpdate = false;
        }
예제 #17
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;
     }
 }
예제 #18
0
        public Paneles_Conteo(int tipoRack, int id, string pedido, string tag, string[] usuario, string[] datos, BRIReader reader, int pxt)
        {
            InitializeComponent();
            tr      = tipoRack;
            lector  = reader;
            fol     = pedido;
            epc     = tag;
            folio   = datos;
            cod     = datos[8];
            user    = usuario;
            pv      = pxt;
            this.id = id.ToString();
            if (pv > 0)
            {
                switch (tr)
                {
                case 1:
                    pbN1.Visible = true;
                    pbN2.Visible = true;
                    pbN3.Visible = true;
                    pbN4.Visible = true;
                    pbN5.Visible = true;
                    pbN6.Visible = true;
                    pbN7.Visible = true;
                    pbN8.Visible = false;
                    pbN9.Visible = false;
                    pbN1.Enabled = true;
                    pbN2.Enabled = true;
                    pbN3.Enabled = true;
                    pbN4.Enabled = true;
                    pbN5.Enabled = true;
                    pbN6.Enabled = true;
                    pbN7.Enabled = true;
                    pbN8.Enabled = false;
                    pbN9.Enabled = false;
                    pbV3.Enabled = false;
                    pbV3.Visible = false;
                    huecos       = null;
                    huecos       = new int[14];
                    break;

                case 2:
                    pbN1.Visible = true;
                    pbN2.Visible = true;
                    pbN3.Visible = true;
                    pbN4.Visible = true;
                    pbN5.Visible = true;
                    pbN6.Visible = true;
                    pbN7.Visible = true;
                    pbN8.Visible = true;
                    pbN9.Visible = true;
                    pbN1.Enabled = true;
                    pbN2.Enabled = true;
                    pbN3.Enabled = true;
                    pbN4.Enabled = true;
                    pbN5.Enabled = true;
                    pbN6.Enabled = true;
                    pbN7.Enabled = true;
                    pbN8.Enabled = true;
                    pbN9.Enabled = true;
                    pbV3.Enabled = false;
                    pbV3.Visible = false;
                    huecos       = null;
                    huecos       = new int[18];
                    break;

                case 3:
                    pbN1.Visible = true;
                    pbN2.Visible = true;
                    pbN3.Visible = true;
                    pbN4.Visible = true;
                    pbN5.Visible = true;
                    pbN6.Visible = true;
                    pbN7.Visible = true;
                    pbN8.Visible = false;
                    pbN9.Visible = false;
                    pbN1.Enabled = true;
                    pbN2.Enabled = true;
                    pbN3.Enabled = true;
                    pbN4.Enabled = true;
                    pbN5.Enabled = true;
                    pbN6.Enabled = true;
                    pbN7.Enabled = true;
                    pbN8.Enabled = false;
                    pbN9.Enabled = false;
                    huecos       = null;
                    huecos       = new int[21];
                    break;

                case 4:
                    pbN1.Visible = true;
                    pbN2.Visible = true;
                    pbN3.Visible = true;
                    pbN4.Visible = true;
                    pbN5.Visible = true;
                    pbN6.Visible = true;
                    pbN7.Visible = false;
                    pbN8.Visible = false;
                    pbN9.Visible = false;
                    pbN1.Enabled = true;
                    pbN2.Enabled = true;
                    pbN3.Enabled = true;
                    pbN4.Enabled = true;
                    pbN5.Enabled = true;
                    pbN6.Enabled = true;
                    pbN7.Enabled = false;
                    pbN8.Enabled = false;
                    pbN9.Enabled = false;
                    huecos       = null;
                    huecos       = new int[18];
                    break;

                default: break;
                }
            }
            else if (pv == 0)
            {
                pbN1.Visible      = false;
                pbN2.Visible      = false;
                pbN3.Visible      = false;
                pbN4.Visible      = false;
                pbN5.Visible      = false;
                pbN6.Visible      = false;
                pbN7.Visible      = false;
                pbN8.Visible      = false;
                pbN9.Visible      = false;
                pbN1.Enabled      = false;
                pbN2.Enabled      = false;
                pbN3.Enabled      = false;
                pbN4.Enabled      = false;
                pbN5.Enabled      = false;
                pbN6.Enabled      = false;
                pbN7.Enabled      = false;
                pbN8.Enabled      = false;
                pbN9.Enabled      = false;
                menuItem1.Enabled = true;
            }
        }