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); } }
private static void AnalyData(MessageTran msgTran) { Logger("AnalyData started. " + msgTran.Cmd.ToString()); m_nReceiveFlag = 0; if (msgTran.PacketType != 0xA0) { return; } switch (msgTran.Cmd) { //case 0x69: // ProcessSetProfile(msgTran); // break; //case 0x6A: // ProcessGetProfile(msgTran); // break; //case 0x71: // ProcessSetUartBaudrate(msgTran); // break; //case 0x72: // ProcessGetFirmwareVersion(msgTran); // break; //case 0x73: // ProcessSetReadAddress(msgTran); // break; case 0x74: ProcessSetWorkAntenna(msgTran); break; //case 0x75: // ProcessGetWorkAntenna(msgTran); // break; //case 0x76: // ProcessSetOutputPower(msgTran); // break; //case 0x77: // ProcessGetOutputPower(msgTran); // break; //case 0x78: // ProcessSetFrequencyRegion(msgTran); // break; //case 0x79: // ProcessGetFrequencyRegion(msgTran); // break; //case 0x7A: // ProcessSetBeeperMode(msgTran); // break; //case 0x7B: // ProcessGetReaderTemperature(msgTran); // break; //case 0x7C: // ProcessSetDrmMode(msgTran); // break; //case 0x7D: // ProcessGetDrmMode(msgTran); // break; //case 0x7E: // ProcessGetImpedanceMatch(msgTran); // break; //case 0x60: // ProcessReadGpioValue(msgTran); // break; //case 0x61: // ProcessWriteGpioValue(msgTran); // break; //case 0x62: // ProcessSetAntDetector(msgTran); // break; //case 0x63: // ProcessGetAntDetector(msgTran); // break; //case 0x67: // ProcessSetReaderIdentifier(msgTran); // break; //case 0x68: // ProcessGetReaderIdentifier(msgTran); // break; //case 0x80: // ProcessInventory(msgTran); // break; //case 0x81: // ProcessReadTag(msgTran); // break; //case 0x82: // ProcessWriteTag(msgTran); // break; //case 0x83: // ProcessLockTag(msgTran); // break; //case 0x84: // ProcessKillTag(msgTran); // break; //case 0x85: // ProcessSetAccessEpcMatch(msgTran); // break; //case 0x86: // ProcessGetAccessEpcMatch(msgTran); // break; case 0x89: case 0x8B: ProcessInventoryReal(msgTran); break; //case 0x8A: // ProcessFastSwitch(msgTran); // break; //case 0x8D: // ProcessSetMonzaStatus(msgTran); // break; //case 0x8E: // ProcessGetMonzaStatus(msgTran); // break; //case 0x90: // ProcessGetInventoryBuffer(msgTran); // break; //case 0x91: // ProcessGetAndResetInventoryBuffer(msgTran); // break; //case 0x92: // ProcessGetInventoryBufferTagCount(msgTran); // break; //case 0x93: // ProcessResetInventoryBuffer(msgTran); // break; //case 0xb0: // ProcessInventoryISO18000(msgTran); // break; //case 0xb1: // ProcessReadTagISO18000(msgTran); // break; //case 0xb2: // ProcessWriteTagISO18000(msgTran); // break; //case 0xb3: // ProcessLockTagISO18000(msgTran); // break; //case 0xb4: // ProcessQueryISO18000(msgTran); // break; default: break; } }