/// <summary> /// 扫描信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void rp_PaketReceived(object sender, StrArrEventArgs e) { s++; if (s > 50000) { s = 0; Sp.GetInstance().Send(Commands.BuildReadMultiFrame(60000)); } string[] packetRx = e.Data; string strPacket = string.Empty; for (int i = 0; i < packetRx.Length; i++) { strPacket += packetRx[i] + " "; } if (packetRx[1] == ConstCode.FRAME_TYPE_INFO && packetRx[2] == ConstCode.CMD_INVENTORY) { int PCEPCLength = ((Convert.ToInt32((packetRx[6]), 16)) / 8 + 1) * 2; string pc = packetRx[6] + " " + packetRx[7]; string epc = string.Empty; for (int i = 0; i < PCEPCLength - 2; i++) { epc = epc + packetRx[8 + i]; } epc = Commands.AutoAddSpace(epc); if (!epc.Contains("E2 00 68 0A 8A A8")) { TempData = epc; if (epc != null && ServerSetting.EPClist.Count == 0 && !ServerSetting.OldEPClist.Contains(epc)) { ServerSetting.EPClist.Enqueue(epc); } } } if (packetRx[2] == ConstCode.CMD_READ_DATA) { string strInvtReadData = ""; int dataLen = Convert.ToInt32(packetRx[3], 16) * 256 + Convert.ToInt32(packetRx[4], 16); int pcEpcLen = Convert.ToInt32(packetRx[5], 16); for (int i = 0; i < dataLen - pcEpcLen - 1; i++) { strInvtReadData = strInvtReadData + packetRx[i + pcEpcLen + 6]; } ReturnUser = Commands.AutoAddSpace(strInvtReadData); } if (packetRx[2] == ConstCode.CMD_GET_MODULE_INFO) { string hardwareVersion = String.Empty; if (packetRx[5] == ConstCode.MODULE_HARDWARE_VERSION_FIELD) { try { for (int i = 0; i < Convert.ToInt32(packetRx[4], 16) - 1; i++) { hardwareVersion += (char)Convert.ToInt32(packetRx[6 + i], 16); } result = false; Sp.GetInstance().Send(Commands.BuildReadMultiFrame(60000)); // Stop(); } catch { hardwareVersion = packetRx[6].Substring(1, 1) + "." + packetRx[7]; result = true; } } } }
/// <summary> /// 扫描信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void rp_PaketReceived(object sender, StrArrEventArgs e) { string[] packetRx = e.Data; string strPacket = string.Empty; for (int i = 0; i < packetRx.Length; i++) { strPacket += packetRx[i] + " "; } if (packetRx[1] == ConstCode.FRAME_TYPE_INFO && packetRx[2] == ConstCode.CMD_INVENTORY) { int PCEPCLength = ((Convert.ToInt32((packetRx[6]), 16)) / 8 + 1) * 2; string pc = packetRx[6] + " " + packetRx[7]; string epc = string.Empty; for (int i = 0; i < PCEPCLength - 2; i++) { epc = epc + packetRx[8 + i]; } epc = Commands.AutoAddSpace(epc); TempData = epc; book = new BookMessage() { EPC = TempData }; bool isSave = false; if (bookList != null && bookList.Count > 0) { foreach (BookMessage message in bookList) { if (message.EPC == book.EPC) { isSave = true; } } } if (!isSave) { bookList.Add(book); PublicData.PublicData.bookList.Add(book); } if (epc.Contains("E2 00 68 0A")) { foreach (BookMessage bookMessage in bookList) { if (bookMessage.EPC == epc && bookMessage.User == null) { parameter = epc; ChangeVistsRegion(); } } } else { // ChangeVistsRegion(); } } if (packetRx[2] == ConstCode.CMD_READ_DATA) { string strInvtReadData = ""; int dataLen = Convert.ToInt32(packetRx[3], 16) * 256 + Convert.ToInt32(packetRx[4], 16); int pcEpcLen = Convert.ToInt32(packetRx[5], 16); for (int i = 0; i < dataLen - pcEpcLen - 1; i++) { strInvtReadData = strInvtReadData + packetRx[i + pcEpcLen + 6]; } ReturnUser = Commands.AutoAddSpace(strInvtReadData); switch (region) { case VisitRegion.User: for (int i = 0; i < bookList.Count; i++) { if (bookList[i].EPC == parameter && bookList[i].User == null) { bookList[i].User = Commands.AutoAddSpace(strInvtReadData); } } break; case VisitRegion.TID: for (int i = 0; i < bookList.Count; i++) { if (bookList[i].EPC == parameter && bookList[i].TID == null) { bookList[i].TID = Commands.AutoAddSpace(strInvtReadData); } } region = VisitRegion.User; break; default: break; } } }