예제 #1
0
        private void ProcessInventoryReal(Reader.MessageTran msgTran)
        {
            string strCmd = "";

            strCmd = "Inventario en tiempo real";
            string strErrorCode = string.Empty;

            if (msgTran.AryData.Length == 1) // Recibir paquete de mensaje de error
            {
                strErrorCode = CCommondMethod.FormatErrorCode(msgTran.AryData[0]);
                string strLog = strCmd + "Fracaso, razón del fracaso:" + strErrorCode;
                m_curSetting.btRealInventoryFlag = 100; //读写器返回盘存错误
            }
            else if (msgTran.AryData.Length == 7)       //收到命令结束数据包
            {
                m_curInventoryBuffer.nReadRate   = Convert.ToInt32(msgTran.AryData[1]) * 256 + Convert.ToInt32(msgTran.AryData[2]);
                m_curInventoryBuffer.nDataCount  = Convert.ToInt32(msgTran.AryData[3]) * 256 * 256 * 256 + Convert.ToInt32(msgTran.AryData[4]) * 256 * 256 + Convert.ToInt32(msgTran.AryData[5]) * 256 + Convert.ToInt32(msgTran.AryData[6]);
                m_curSetting.btRealInventoryFlag = 1; //成功收到盘存命令结束数据包
            }
            else //收到实时标签数据信息
            {
                m_nTotal++;
                int             nLength    = msgTran.AryData.Length;
                int             nEpcLength = nLength - 4;
                RealTimeTagData tagData    = new RealTimeTagData();

                string strEPC  = CCommondMethod.ByteArrayToString(msgTran.AryData, 3, nEpcLength);
                string strPC   = CCommondMethod.ByteArrayToString(msgTran.AryData, 1, 2);
                string strRSSI = (msgTran.AryData[nLength - 1] - 129).ToString() + " dBm";
                byte   btTemp  = msgTran.AryData[0];
                byte   btAntId = (byte)((btTemp & 0x03) + 1);
                byte   btFreq  = (byte)(btTemp >> 2);



                tagData.strEpc  = strEPC;
                tagData.strPc   = strPC;
                tagData.strRssi = strRSSI;

                tagData.btAntId = btAntId;

                RealTimeTagDataList.Add(tagData);
            }
        }
예제 #2
0
        private void ProcessReadTag(Reader.MessageTran msgTran)
        {
            string strCmd       = "Leer etiqueta";
            string strErrorCode = string.Empty;

            if (msgTran.AryData.Length == 1)
            {
                strErrorCode = CCommondMethod.FormatErrorCode(msgTran.AryData[0]);
                string strLog = strCmd + "Fracaso, razón del fracaso: " + strErrorCode;
                m_curSetting.btRealInventoryFlag = 100; // reader devuelve un mensaje de error
            }
            else
            {
                RealTimeTagData tagData  = new RealTimeTagData();
                int             nLen     = msgTran.AryData.Length;
                int             nDataLen = Convert.ToInt32(msgTran.AryData[nLen - 3]);
                int             nEpcLen  = Convert.ToInt32(msgTran.AryData[2]) - nDataLen - 4;

                string strPC   = CCommondMethod.ByteArrayToString(msgTran.AryData, 3, 2);
                string strEPC  = CCommondMethod.ByteArrayToString(msgTran.AryData, 5, nEpcLen);
                string strCRC  = CCommondMethod.ByteArrayToString(msgTran.AryData, 5 + nEpcLen, 2);
                string strData = CCommondMethod.ByteArrayToString(msgTran.AryData, 7 + nEpcLen, nDataLen);

                byte byTemp  = msgTran.AryData[nLen - 2];
                byte byAntId = (byte)((byTemp & 0x03) + 1);


                tagData.strEpc  = strEPC;
                tagData.strPc   = strPC;
                tagData.strTid  = strData;
                tagData.btAntId = byAntId;

                RealTimeTagDataList.Add(tagData);

                int nReaddataCount = msgTran.AryData[0] * 255 + msgTran.AryData[1]; // El número total de datos
                if (RealTimeTagDataList.Count == nReaddataCount)                    // Recibe todos los datos
                {
                    m_curSetting.btRealInventoryFlag = 1;                           // reader devuelve un mensaje de error
                }
            }
        }