private static void ProcessSetWorkAntenna(MessageTran msgTran) { int intCurrentAnt = 0; intCurrentAnt = m_curSetting.btWorkAntenna + 1; string strCmd = "Set working antenna successfully, Current Ant: Ant" + intCurrentAnt.ToString(); string strErrorCode = string.Empty; if (msgTran.AryData.Length == 1) { if (msgTran.AryData[0] == 0x10) { m_curSetting.btReadId = msgTran.ReadId; Logger(strCmd); //Verify inventory operations if (m_bInventory) { RunLoopInventroy(); } return; } else { strErrorCode = CCommondMethod.FormatErrorCode(msgTran.AryData[0]); } } else { strErrorCode = "Unknown Error"; } string strLog = strCmd + "Failure, failure cause: " + strErrorCode; Logger(strLog); if (m_bInventory) { m_curInventoryBuffer.nCommond = 1; m_curInventoryBuffer.dtEndInventory = DateTime.Now; RunLoopInventroy(); } }
private static void ProcessInventoryReal(MessageTran msgTran) { string strCmd = ""; if (msgTran.Cmd == 0x89) { strCmd = "Real time inventory"; Logger(strCmd); } if (msgTran.Cmd == 0x8B) { strCmd = "User define Session and Inventoried Flag inventory"; Logger(strCmd); } string strErrorCode = string.Empty; Logger("Check This AryData.Length 1 OR 7 : " + msgTran.AryData.Length); if (msgTran.AryData.Length == 1) { strErrorCode = CCommondMethod.FormatErrorCode(msgTran.AryData[0]); string strLog = strCmd + "Failure, failure cause: " + strErrorCode; Logger(strLog); RefreshInventoryReal(0x00); RunLoopInventroy(); } 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]); Logger(strCmd); RefreshInventoryReal(0x01); RunLoopInventroy(); } else { int nLength = msgTran.AryData.Length; int nEpcLength = nLength - 4; //Add inventory list //if (msgTran.AryData[3] == 0x00) //{ // MessageBox.Show(""); //} string strEPC = CCommondMethod.ByteArrayToString(msgTran.AryData, 3, nEpcLength); string strPC = CCommondMethod.ByteArrayToString(msgTran.AryData, 1, 2); string strRSSI = (msgTran.AryData[nLength - 1] & 0x7F).ToString(); SetMaxMinRSSI(Convert.ToInt32(msgTran.AryData[nLength - 1] & 0x7F)); byte btTemp = msgTran.AryData[0]; byte btAntId = (byte)((btTemp & 0x03) + 1); if ((msgTran.AryData[nLength - 1] & 0x80) != 0) { btAntId += 4; } m_curInventoryBuffer.nCurrentAnt = btAntId; string strAntId = btAntId.ToString(); byte btFreq = (byte)(btTemp >> 2); string strFreq = GetFreqString(btFreq); //DataRow row = m_curInventoryBuffer.dtTagDetailTable.NewRow(); //row[0] = strEPC; //row[1] = strRSSI; //row[2] = strAntId; //row[3] = strFreq; //m_curInventoryBuffer.dtTagDetailTable.Rows.Add(row); //m_curInventoryBuffer.dtTagDetailTable.AcceptChanges(); ////Add tag list //DataRow[] drsDetail = m_curInventoryBuffer.dtTagDetailTable.Select(string.Format("COLEPC = '{0}'", strEPC)); //int nDetailCount = drsDetail.Length; DataRow[] drs = m_curInventoryBuffer.dtTagTable.Select(string.Format("COLEPC = '{0}'", strEPC)); if (drs.Length == 0) { DataRow row1 = m_curInventoryBuffer.dtTagTable.NewRow(); row1[0] = strPC; row1[2] = strEPC; row1[4] = strRSSI; row1[5] = "1"; row1[6] = strFreq; m_curInventoryBuffer.dtTagTable.Rows.Add(row1); m_curInventoryBuffer.dtTagTable.AcceptChanges(); } else { foreach (DataRow dr in drs) { dr.BeginEdit(); dr[4] = strRSSI; dr[5] = (Convert.ToInt32(dr[5]) + 1).ToString(); dr[6] = strFreq; dr.EndEdit(); } m_curInventoryBuffer.dtTagTable.AcceptChanges(); } m_curInventoryBuffer.dtEndInventory = DateTime.Now; RefreshInventoryReal(0x89); } }