static void OnReportEvent(MSG_RO_ACCESS_REPORT msg) { // Loop through all the tags in the report for (int i = 0; i < msg.TagReportData.Length; i++) { if (msg.TagReportData[i].EPCParameter.Count > 0) { string epc; // Two possible types of EPC: 96-bit and 128-bit if (msg.TagReportData[i].EPCParameter[0].GetType() == typeof(PARAM_EPC_96)) { epc = ((PARAM_EPC_96) (msg.TagReportData[i].EPCParameter[0])) .EPC.ToHexString(); } else { epc = ((PARAM_EPCData) (msg.TagReportData[i].EPCParameter[0])) .EPC.ToHexString(); } Console.WriteLine("epc = " + epc); } } }
// Simple Handler for receiving the tag reports from the reader static void reader_OnRoAccessReportReceived(MSG_RO_ACCESS_REPORT msg) { // Report could be empty if (msg.TagReportData == null) { return; } // Loop through and print out each tag for (int i = 0; i < msg.TagReportData.Length; i++) { reportCount++; // just write out the EPC as a hex string for now. It is guaranteed to be // in all LLRP reports regardless of default configuration string epc; if (msg.TagReportData[i].EPCParameter[0].GetType() == typeof(PARAM_EPC_96)) { epc = ((PARAM_EPC_96)(msg.TagReportData[i].EPCParameter[0])).EPC.ToHexString(); } else { epc = ((PARAM_EPCData)(msg.TagReportData[i].EPCParameter[0])).EPC.ToHexString(); } Console.WriteLine(epc); } }
private void UpdateROReport(MSG_RO_ACCESS_REPORT msg) { if (msg.TagReportData == null) { return; } ulong ms = msg.TagReportData[0].FirstSeenTimestampUTC.Microseconds - old_time; old_time = msg.TagReportData[0].FirstSeenTimestampUTC.Microseconds; if (ms <= 0) { ms = 1; } label1.Text = (60000000 / ms).ToString() + "Tags/Min"; try { for (int i = 0; i < msg.TagReportData.Length; i++) { if (msg.TagReportData[i].EPCParameter.Count > 0) { string epc; // reports come in two flavors. Get the right flavor if (msg.TagReportData[i].EPCParameter[0].GetType() == typeof(PARAM_EPC_96)) { epc = ((PARAM_EPC_96)(msg.TagReportData[i].EPCParameter[0])).EPC.ToHexString(); } else { epc = ((PARAM_EPCData)(msg.TagReportData[i].EPCParameter[0])).EPC.ToHexString(); } if (!listBox1.Items.Contains(epc)) { try { listBox1.Items.Add(epc); label2.Text = "Tags : " + listBox1.Items.Count.ToString(); } catch { } } } } try { textBox2.Text = msg.ToString(); } catch (Exception e) { textBox2.Text = e.Message; } } catch (Exception ex) { textBox2.Text = ex.Message; } }
private void reader_OnRoAccessReportReceived(MSG_RO_ACCESS_REPORT msg) { if (msg.TagReportData == null || msg.TagReportData.Length < 1) { return; } try { for (int i = 0; i < msg.TagReportData.Length; i++) { if (msg.TagReportData[i].EPCParameter.Count > 0) { string epc; string an; // reports come in two flavors. Get the right flavor if (msg.TagReportData[i].EPCParameter[0].GetType() == typeof(PARAM_EPC_96)) { epc = ((PARAM_EPC_96)(msg.TagReportData[i].EPCParameter[0])).EPC.ToHexString(); } else { epc = ((PARAM_EPCData)(msg.TagReportData[i].EPCParameter[0])).EPC.ToHexString(); } an = ((ushort)(msg.TagReportData[i].AntennaID.AntennaID)).ToString(); //天线号码// if (!RecordTag.Contains(epc)) { AntennaID.Add(an); //AntennaID.Add(msg.TagReportData[i].AntennaID.AntennaID.ToString()); RecordTag.Add(epc); RecordRssi.Add(Convert.ToInt32(msg.TagReportData[i].PeakRSSI.PeakRSSI.ToString())); } } if (msg.TagReportData[i].AccessCommandOpSpecResult != null && msg.TagReportData[i].AccessCommandOpSpecResult.Length > 0) { PARAM_C1G2WriteOpSpecResult resultWrite = (PARAM_C1G2WriteOpSpecResult)msg.TagReportData[i].AccessCommandOpSpecResult[0]; if (resultWrite.NumWordsWritten == InitNumWord) { DELETE_ACCESSSPEC(); writeOp = true; } } } } catch (Exception ex) { log.Error(ex.Message); } }
// Simple Handler for receiving the tag reports from the reader static void reader_OnRoAccessReportReceived(MSG_RO_ACCESS_REPORT msg) { // Report could be empty if (msg.TagReportData != null) { // Loop through and print out each tag for (int i = 0; i < msg.TagReportData.Length; i++) { reportCount++; // just write out the EPC as a hex string for now. It is guaranteed to be // in all LLRP reports regardless of default configuration string data = "EPC: "; if (msg.TagReportData[i].EPCParameter[0].GetType() == typeof(PARAM_EPC_96)) { data += ((PARAM_EPC_96)(msg.TagReportData[i].EPCParameter[0])).EPC.ToHexString(); } else { data += ((PARAM_EPCData)(msg.TagReportData[i].EPCParameter[0])).EPC.ToHexString(); } #region CheckForAccessResults // check for read data results if ((msg.TagReportData[i].AccessCommandOpSpecResult != null)) { // there had better be one (since that what I asked for if (msg.TagReportData[i].AccessCommandOpSpecResult.Count == 1) { // it had better be the read result if (msg.TagReportData[i].AccessCommandOpSpecResult[0].GetType() == typeof(PARAM_C1G2ReadOpSpecResult)) { PARAM_C1G2ReadOpSpecResult read = (PARAM_C1G2ReadOpSpecResult)msg.TagReportData[i].AccessCommandOpSpecResult[0]; accessCount++; data += " AccessData: "; if (read.Result == ENUM_C1G2ReadResultType.Success) { data += read.ReadData.ToHexWordString(); } else { data += read.Result.ToString(); } } } } #endregion Console.WriteLine(data); } } }
private void Reader_OnRoAccessReportReceived(MSG_RO_ACCESS_REPORT message) { if (message.TagReportData == null) { return; } foreach (var tagReportData in message.TagReportData) { if (tagReportData.EPCParameter.Count > 0) { this.AddTagData(tagReportData); } } }
public static void OnReportEvent(MSG_RO_ACCESS_REPORT msg) { foreach (var tagReport in msg.TagReportData) { if (tagReport.EPCParameter.Count > 0) { string epc; var epcParam = tagReport.EPCParameter[0]; if (epcParam.GetType() == typeof(PARAM_EPC_96)) { epc = ((PARAM_EPC_96)epcParam).EPC.ToHexString(); } else { epc = ((PARAM_EPCData)epcParam).EPC.ToHexString(); } Console.WriteLine("epc = " + epc); } } }
public void UpdateROReport(MSG_RO_ACCESS_REPORT msg) { if (msg.TagReportData == null) { readerMgr.HandleTagReceived(null); return; } string result = null; try { for (int i = 0; i < msg.TagReportData.Length; i++) { result = ParseTag(msg, result, i); //MessageBox.Show(result); } } catch (Exception ex) { WriteString(ex.Message); } }
/// <summary></summary> private void OnLLRPClientRoAccessReportReceived(MSG_RO_ACCESS_REPORT msg) { if (msg.Custom.Length > 0) { for (int i = 0; i < msg.Custom.Length; ++i) { IParameter custom = msg.Custom[i]; if (custom is PARAM_ImpinjExtendedTagInformation) { PARAM_ImpinjExtendedTagInformation info = (PARAM_ImpinjExtendedTagInformation)custom; string epc = info.EPCData[0].EPC.ToHexString(); if (info.ImpinjDirectionReportData != null) { byte firstSeenSectorId = info.ImpinjDirectionReportData.FirstSeenSectorID; byte lastSeenSectorId = info.ImpinjDirectionReportData.LastSeenSectorID; ENUM_ImpinjDirectionTagPopulationStatus status = info.ImpinjDirectionReportData.TagPopulationStatus; ENUM_ImpinjDirectionReportType type = info.ImpinjDirectionReportData.Type; DateTime dtFirstSeen = UnixDateTime.Convert(info.ImpinjDirectionReportData.FirstSeenTimestampUTC); DateTime dtLastSeen = UnixDateTime.Convert(info.ImpinjDirectionReportData.LastSeenTimestampUTC); /* * Console.Error.WriteLine($"{epc} Type: {type}, Status: {status}"); * Console.Error.WriteLine($" Sector: {firstSeenSectorId} => {lastSeenSectorId}"); * Console.Error.WriteLine($"{dtFirstSeen.ToString("yyyy-MM-ddTHH:mm:ss")} => {dtLastSeen.ToString("yyyy-MM-ddTHH:mm:ss")}"); */ Console.Error.WriteLine($"{epc},{dtFirstSeen.ToString(DateTimeFormat)},{dtLastSeen.ToString(DateTimeFormat)},{type},{firstSeenSectorId},{lastSeenSectorId},{status}"); } } } } }
private void ParseTagOpResponse(MSG_RO_ACCESS_REPORT response) { TagReadData td = new TagReadData(); UNION_AccessCommandOpSpecResult opSpecResult = response.TagReportData[0].AccessCommandOpSpecResult; try { if (null != opSpecResult) { if (opSpecResult.Count > 0) { ParseTagOpSpecResultType(opSpecResult, ref td); TagQueueEmptyEvent.Set(); } } } catch (ReaderException ex) { rx = ex; TagQueueEmptyEvent.Set(); } finally { reportReceived = true; } llrp.OnRoAccessReportReceived -= new delegateRoAccessReport(TagOpOnRoAccessReportReceived); }
private void ParseNotifyTag(MSG_RO_ACCESS_REPORT msg) { if (null == tagReads) { tagReads = new List<TagReadData>(); } TagReadData tag = null; if (null != msg) { for (int i = 0; i < msg.TagReportData.Length; i++) { try { tag = new TagReadData(); if (msg.TagReportData[i].EPCParameter.Count > 0) { string epc; // reports come in two flavors. Get the right flavor if (msg.TagReportData[i].EPCParameter[0].GetType() == typeof(PARAM_EPC_96)) { epc = ((PARAM_EPC_96)(msg.TagReportData[i].EPCParameter[0])).EPC.ToHexString(); } else { epc = ((PARAM_EPCData)(msg.TagReportData[i].EPCParameter[0])).EPC.ToHexString(); } TagData td = new TagData(ByteFormat.FromHex(epc)); TagProtocol tagProtocol = 0; //Match the recieved rospec id with the rospec id stored in the hashtable at the time of setting readplan if (roSpecProtcolTable.ContainsKey(msg.TagReportData[i].ROSpecID.ROSpecID)) { tagProtocol = (TagProtocol)roSpecProtcolTable[msg.TagReportData[i].ROSpecID.ROSpecID]; } if (TagProtocol.GEN2.Equals(tagProtocol)) { //Get crc and pc bits UNION_AirProtocolTagData tagdata = msg.TagReportData[i].AirProtocolTagData; td = new Gen2.TagData(ByteFormat.FromHex(epc), ByteConv.EncodeU16(((PARAM_C1G2_CRC)tagdata[1]).CRC), ByteConv.EncodeU16(((PARAM_C1G2_PC)tagdata[0]).PC_Bits)); } else if (TagProtocol.ISO180006B.Equals(tagProtocol)) { td = new Iso180006b.TagData(ByteFormat.FromHex(epc)); } else { td = new TagData(ByteFormat.FromHex(epc)); } tag.Reader = this; tag._tagData = td; tag._antenna = (int)msg.TagReportData[i].AntennaID.AntennaID; UInt64 usSinceEpoch = msg.TagReportData[i].LastSeenTimestampUTC.Microseconds; tag._baseTime = epochTime.AddMilliseconds(usSinceEpoch / 1000); tag._readOffset = 0; // Since Spruce release firmware doesn't support phase, there won't be PARAM_ThingMagicTagReportContentSelector // custom paramter in ROReportSpec string[] ver = softwareVersion.Split('.'); if (((Convert.ToInt32(ver[0]) == 4) && (Convert.ToInt32(ver[1]) >= 17)) || (Convert.ToInt32(ver[0]) > 4)) { tag._phase = Convert.ToInt32(((PARAM_ThingMagicRFPhase)msg.TagReportData[i].Custom[0]).Phase); } tag.Rssi = Convert.ToInt32(msg.TagReportData[i].PeakRSSI.PeakRSSI.ToString()); tag.ReadCount = msg.TagReportData[i].TagSeenCount.TagCount; int chIndex = Convert.ToInt32(msg.TagReportData[i].ChannelIndex.ChannelIndex); List<uint> freq = frequencyHopTable[0].Frequency.data; tag._frequency = Convert.ToInt32(freq[chIndex - 1]); UNION_AccessCommandOpSpecResult opSpecResult = msg.TagReportData[i].AccessCommandOpSpecResult; tag._data = EMPTY_DATA; // Use try-finally to to keep failed tagops from preventing report of TagReadData try { if (null != opSpecResult) { if (opSpecResult.Count > 0) { ParseTagOpSpecResultType(opSpecResult, ref tag); } } } finally { if (continuousReading) { OnTagRead(tag); } else { tagReads.Add(tag); } } } } catch (Exception ex) { ReaderException rx; if (ex is ReaderException) { rx = (ReaderException)ex; } else { rx = new ReaderException(ex.ToString()); } //Release the TagQueueEmptyEvent when parsing exception raised TagQueueEmptyEvent.Set(); ReadExceptionPublisher expub = new ReadExceptionPublisher(this, rx); Thread trd = new Thread(expub.OnReadException); trd.Name = "OnReadException"; trd.Start(); } finally { tag = null; } } TagQueueEmptyEvent.Set(); } }
// Simple Handler for receiving the tag reports from the reader static void reader_OnRoAccessReportReceived(MSG_RO_ACCESS_REPORT msg) { // Report could be empty if (msg.TagReportData != null) { // Loop through and print out each tag for (int i = 0; i < msg.TagReportData.Length; i++) { reportCount++; // just write out the EPC as a hex string for now. It is guaranteed to be // in all LLRP reports regardless of default configuration string data = "EPC: "; string velData; if (msg.TagReportData[i].EPCParameter[0].GetType() == typeof(PARAM_EPC_96)) { currentEpcData = ((PARAM_EPC_96)(msg.TagReportData[i].EPCParameter[0])).EPC.ToHexString(); data += currentEpcData; } else { currentEpcData = ((PARAM_EPCData)(msg.TagReportData[i].EPCParameter[0])).EPC.ToHexString(); data += currentEpcData; } velData = data; // collect some data for velocity calcs // NOTE: these could be NULL, so we shoudl check if (msg.TagReportData[i].AntennaID != null) { currentAntennaID = msg.TagReportData[i].AntennaID.AntennaID; data += " ant: " + currentAntennaID.ToString(); } if (msg.TagReportData[i].ChannelIndex != null) { currentChannelIndex = msg.TagReportData[i].ChannelIndex.ChannelIndex; data += " ch: " + currentChannelIndex.ToString(); } if (msg.TagReportData[i].FirstSeenTimestampUTC != null) { currentReadTime = msg.TagReportData[i].FirstSeenTimestampUTC.Microseconds; data += " time: " + currentReadTime.ToString(); } if (msg.TagReportData[i].Custom != null) { for (int x = 0; x < msg.TagReportData[i].Custom.Length; x++) { // try to make a tag direction report out of it if (msg.TagReportData[i].Custom[x].GetType() == typeof(PARAM_ImpinjRFPhaseAngle)) { PARAM_ImpinjRFPhaseAngle rfPhase = (PARAM_ImpinjRFPhaseAngle)msg.TagReportData[i].Custom[x]; currentRfPhase = rfPhase.PhaseAngle; data += " Phase: " + currentRfPhase.ToString(); } } } // estimate the velocity and print a filtered version double velocity; if (calculateVelocity(out velocity)) { directionCount++; /* keep a filtered value. Use a 1 pole IIR here for simplicity */ filteredVelocity = (6 * filteredVelocity + 4 * velocity) / 10.0; if (filteredVelocity > 0.25) { velData += "---->"; } else if (filteredVelocity < -0.25) { velData += "<----"; } else { velData += " "; } velData += " Velocity: " + filteredVelocity.ToString("F2"); } //Console.WriteLine(data); Console.WriteLine(velData); } } }
// int count = 0; private void reader_OnRoAccessReportReceived(MSG_RO_ACCESS_REPORT msg) { Control.CheckForIllegalCrossThreadCalls = false; //读取卡内容 CarData data = GetObjectByMsg(msg); if (data == null) return; lock (carQueue) { carQueue.Enqueue(data); } //count++; //label15.Text = count.ToString(); }
private CarData GetObjectByMsg(MSG_RO_ACCESS_REPORT msg) { if (msg.TagReportData == null || msg.TagReportData.Length < 1) return null ; ulong ms = msg.TagReportData[0].FirstSeenTimestampUTC.Microseconds - old_time; old_time = msg.TagReportData[0].FirstSeenTimestampUTC.Microseconds; if (ms <= 0) ms = 1; //>normalize to 1 // lbltagspermin.Text = (60000000 / ms).ToString() + "Tags/Min"; try { try { //textBox2.Text = msg.ToString(); string a = ((PARAM_C1G2ReadOpSpecResult)(msg.TagReportData[0].AccessCommandOpSpecResult[0])).ReadData.ToHexWordString(); uint a1 = ((PARAM_C1G2ReadOpSpecResult)(msg.TagReportData[0].AccessCommandOpSpecResult[0])).ReadData.data[0]; uint a2 = ((PARAM_C1G2ReadOpSpecResult)(msg.TagReportData[0].AccessCommandOpSpecResult[0])).ReadData.data[1]; uint a3 = ((PARAM_C1G2ReadOpSpecResult)(msg.TagReportData[0].AccessCommandOpSpecResult[0])).ReadData.data[2]; uint a4 = ((PARAM_C1G2ReadOpSpecResult)(msg.TagReportData[0].AccessCommandOpSpecResult[0])).ReadData.data[3]; uint a5 = ((PARAM_C1G2ReadOpSpecResult)(msg.TagReportData[0].AccessCommandOpSpecResult[0])).ReadData.data[4]; uint a6 = ((PARAM_C1G2ReadOpSpecResult)(msg.TagReportData[0].AccessCommandOpSpecResult[0])).ReadData.data[5]; uint a7 = ((PARAM_C1G2ReadOpSpecResult)(msg.TagReportData[0].AccessCommandOpSpecResult[0])).ReadData.data[6]; uint a8 = ((PARAM_C1G2ReadOpSpecResult)(msg.TagReportData[0].AccessCommandOpSpecResult[0])).ReadData.data[7]; uint a9 = ((PARAM_C1G2ReadOpSpecResult)(msg.TagReportData[0].AccessCommandOpSpecResult[0])).ReadData.data[8]; uint a10 = ((PARAM_C1G2ReadOpSpecResult)(msg.TagReportData[0].AccessCommandOpSpecResult[0])).ReadData.data[9]; uint a11 = ((PARAM_C1G2ReadOpSpecResult)(msg.TagReportData[0].AccessCommandOpSpecResult[0])).ReadData.data[10]; string epc; if (msg.TagReportData[0].EPCParameter[0].GetType() == typeof(PARAM_EPC_96)) { epc = ((PARAM_EPC_96)(msg.TagReportData[0].EPCParameter[0])).EPC.ToHexString(); //MessageBox.Show("96"); } else { epc = ((PARAM_EPCData)(msg.TagReportData[0].EPCParameter[0])).EPC.ToHexString(); //MessageBox.Show("EPC"); } if (a1.ToString() == "12288" || a1.ToString()== "12544" || a1.ToString()== "12800" || a1.ToString() == "13056") ; else return null; //uint x = a1 / 256; //char type = (char)x; char type = (char)(a1 >> 8); //车牌号 char car1 = (char)(a3 / 256); char car2 = (char)(a3 % 256); char car3 = (char)(a4 / 256); char car4 = (char)(a4 % 256); char car5 = (char)(a5 / 256); char car6 = (char)(a5 % 256); string car = "京" + car1.ToString() + car2.ToString() + car3.ToString() + car4.ToString() + car5.ToString() + car6.ToString(); CarData data = new CarData(); data.truckNo = car; //时间 string time = ((PARAM_C1G2ReadOpSpecResult)(msg.TagReportData[0].AccessCommandOpSpecResult[0])).ReadData.ToHexString(); //time=time.Substring(35, 12); string time2 = time.Substring(30, 12); string year = "20" + time2.Substring(0, 2); string month = time2.Substring(2, 2); string day = time2.Substring(5, 2); string hour = time2.Substring(7, 2); string min = time2.Substring(10, 2); time = year + "-" + month + "-" + day + "," + hour + ":" + min; //出发站点 data.startTime = time; char station1 = (char)(a10 / 256); char station2 = (char)(a10 % 256); string station = station1.ToString() + station2.ToString(); data.stationID = int.Parse(station); data.endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); data.boxid = epc; // listBox2.Items.Add(msg.ToString()); try { data.type = int.Parse(type.ToString()); } catch { data.type = -1; } return data; } catch (Exception e) { //((PARAM_C1G2ReadOpSpecResult)(msg.TagReportData[0].AccessCommandOpSpecResult[0])).ReadData.ToHexWordString(); // MessageBox.Show(e.Message); } } catch (Exception ex) { ((PARAM_C1G2ReadOpSpecResult)(msg.TagReportData[0].AccessCommandOpSpecResult[0])).ReadData.ToHexWordString(); // textBox2.Text = ((PARAM_C1G2WriteOpSpecResult)(msg.TagReportData[0].AccessCommandOpSpecResult[0])).OpSpecID.ToString(); //MessageBox.Show(ex.Message); } return null; }
// Simple Handler for receiving the tag reports from the reader static void reader_OnRoAccessReportReceived(MSG_RO_ACCESS_REPORT msg) { // Report could be empty if (msg.TagReportData != null) { // Loop through and print out each tag for (int i = 0; i < msg.TagReportData.Length; i++) { reportCount++; // just write out the EPC as a hex string for now. It is guaranteed to be // in all LLRP reports regardless of default configuration string data = "\nEPC: "; if (msg.TagReportData[i].EPCParameter[0].GetType() == typeof(PARAM_EPC_96)) { data += ((PARAM_EPC_96)(msg.TagReportData[i].EPCParameter[0])).EPC.ToHexString(); } else { data += ((PARAM_EPCData)(msg.TagReportData[i].EPCParameter[0])).EPC.ToHexString(); } #region CheckForAccessResults // check for Standard and Impinj OpSpecResults and print them out if ((msg.TagReportData[i].AccessCommandOpSpecResult != null)) { for (int x = 0; x < msg.TagReportData[i].AccessCommandOpSpecResult.Count; x++) { // it had better be the read result if (msg.TagReportData[i].AccessCommandOpSpecResult[x].GetType() == typeof(PARAM_C1G2ReadOpSpecResult)) { PARAM_C1G2ReadOpSpecResult read = (PARAM_C1G2ReadOpSpecResult)msg.TagReportData[i].AccessCommandOpSpecResult[x]; data += "\n ReadResult(" + read.OpSpecID.ToString() + "): " + read.Result.ToString(); opSpecCount++; if (read.Result == ENUM_C1G2ReadResultType.Success) { data += "\n Data: " + read.ReadData.ToHexWordString(); } } // it had better be the read result if (msg.TagReportData[i].AccessCommandOpSpecResult[x].GetType() == typeof(PARAM_C1G2WriteOpSpecResult)) { PARAM_C1G2WriteOpSpecResult write = (PARAM_C1G2WriteOpSpecResult)msg.TagReportData[i].AccessCommandOpSpecResult[x]; data += "\n WriteResult(" + write.OpSpecID.ToString() + "): " + write.Result.ToString(); opSpecCount++; } if (msg.TagReportData[i].AccessCommandOpSpecResult[x].GetType() == typeof(PARAM_ImpinjGetQTConfigOpSpecResult)) { PARAM_ImpinjGetQTConfigOpSpecResult get = (PARAM_ImpinjGetQTConfigOpSpecResult)msg.TagReportData[i].AccessCommandOpSpecResult[x]; opSpecCount++; data += "\n getQTResult(" + get.OpSpecID.ToString() + "): " + get.Result.ToString(); if (get.Result == ENUM_ImpinjGetQTConfigResultType.Success) { data += "\n Range :" + get.AccessRange.ToString(); data += "\n Profile: " + get.DataProfile.ToString(); } } if (msg.TagReportData[i].AccessCommandOpSpecResult[x].GetType() == typeof(PARAM_ImpinjSetQTConfigOpSpecResult)) { PARAM_ImpinjSetQTConfigOpSpecResult set = (PARAM_ImpinjSetQTConfigOpSpecResult)msg.TagReportData[i].AccessCommandOpSpecResult[x]; opSpecCount++; data += "\n setQTResult(" + set.OpSpecID.ToString() + "): " + set.Result.ToString(); } } } #endregion #region CheckForImpinjCustomTagData // check for other Impinj Specific tag data and print it out if (msg.TagReportData[i].Custom != null) { opSpecCount++; for (int x = 0; x < msg.TagReportData[i].Custom.Count; x++) { if (msg.TagReportData[i].Custom[x].GetType() == typeof(PARAM_ImpinjSerializedTID)) { PARAM_ImpinjSerializedTID stid = (PARAM_ImpinjSerializedTID)msg.TagReportData[i].Custom[x]; opSpecCount++; data += "\n serialTID: " + stid.TID.ToHexWordString(); } } } #endregion Console.WriteLine(data); } } }
/// <summary> /// Parsing ro access report /// </summary> /// <param name="msg">Ro access report</param> private void UpdateROReport(MSG_RO_ACCESS_REPORT msg) { if (msg.TagReportData == null) { //If reader does not send any Ro access report, set the TagQueueEmptyEvent TagQueueEmptyEvent.Set(); return; } //Transport listener BuildTransport(false, msg); lock (tagReadQueue) { tagReadQueue.Enqueue(msg); TagQueueAddedEvent.Set(); } }
// Simple Handler for receiving the tag reports from the reader void reader_OnRoAccessReportReceived(MSG_RO_ACCESS_REPORT msg) { // Report could be empty if (msg.TagReportData == null) { return; } // Loop through and print out each tag for (int i = 0; i < msg.TagReportData.Length; i++) { reportCount++; // just write out the EPC as a hex string for now. It is guaranteed to be // in all LLRP reports regardless of default configuration string epc; if (msg.TagReportData[i].EPCParameter[0].GetType() == typeof(PARAM_EPC_96)) { epc = ((PARAM_EPC_96)(msg.TagReportData[i].EPCParameter[0])).EPC.ToHexString(); } else { epc = ((PARAM_EPCData)(msg.TagReportData[i].EPCParameter[0])).EPC.ToHexString(); } int antennaId = msg.TagReportData[i].AntennaID.AntennaID; int channelIndex = 0;//msg.TagReportData[i].ChannelIndex.ChannelIndex; int inventoryParameterSpecID = msg.TagReportData[i].InventoryParameterSpecID.InventoryParameterSpecID; long time = (long)msg.TagReportData[i].FirstSeenTimestampUTC.Microseconds; int phase = 0; int rssi = 0; int doppler = 0; // just write out the EPC as a hex string for now. It is guaranteed to be // in all LLRP reports regardless of default configuration if (msg.TagReportData[i].AccessCommandOpSpecResult.Count != 0) { PARAM_C1G2WriteOpSpecResult result = (PARAM_C1G2WriteOpSpecResult) msg.TagReportData[i].AccessCommandOpSpecResult[0]; Console.WriteLine(result.NumWordsWritten + " words written to tag with EPC = " + epc); } // check for other Impinj Specific tag data and print it out if (msg.TagReportData[i].Custom != null) { for (int x = 0; x < msg.TagReportData[i].Custom.Count; x++) { if (msg.TagReportData[i].Custom[x].GetType() == typeof(PARAM_ImpinjSerializedTID)) { PARAM_ImpinjSerializedTID stid = (PARAM_ImpinjSerializedTID)msg.TagReportData[i].Custom[x]; } if (msg.TagReportData[i].Custom[x].GetType() == typeof(PARAM_ImpinjPeakRSSI)) { PARAM_ImpinjPeakRSSI Prssi = (PARAM_ImpinjPeakRSSI)msg.TagReportData[i].Custom[x]; rssi = Prssi.RSSI; } if (msg.TagReportData[i].Custom[x].GetType() == typeof(PARAM_ImpinjRFDopplerFrequency)) { PARAM_ImpinjRFDopplerFrequency DopplerFrequency = (PARAM_ImpinjRFDopplerFrequency)msg.TagReportData[i].Custom[x]; doppler = DopplerFrequency.DopplerFrequency; } if (msg.TagReportData[i].Custom[x].GetType() == typeof(PARAM_ImpinjRFPhaseAngle)) { PARAM_ImpinjRFPhaseAngle RFPhaseAngle = (PARAM_ImpinjRFPhaseAngle)msg.TagReportData[i].Custom[x]; phase = RFPhaseAngle.PhaseAngle; } } } listener.tagReport(epc, antennaId, channelIndex, doppler, rssi, phase, time, inventoryParameterSpecID); tagMessageList.Add(epc + " " + time); // Console.WriteLine(epc); } }
private string ParseTag(MSG_RO_ACCESS_REPORT msg, string result, int i) { if (msg.TagReportData[i].EPCParameter.Count > 0) { string epcInfo = ""; Type t = msg.TagReportData[i].EPCParameter[0].GetType(); if (t.Name == "PARAM_EPC_96") { epcInfo = ((PARAM_EPC_96)(msg.TagReportData[i].EPCParameter[0])).EPC.ToHexString(); } else if (t.Name == "PARAM_EPCData") { epcInfo = ((PARAM_EPCData)(msg.TagReportData[i].EPCParameter[0])).EPC.ToHexString(); } else { throw new Exception("ParseTag method couldn't resolve EPC type"); } string time = (msg.TagReportData[i].LastSeenTimestampUTC).ToString(); string count = (msg.TagReportData[i].TagSeenCount).ToString(); string accessSpecID = (msg.TagReportData[i].AccessSpecID).ToString(); string firstSeen = (msg.TagReportData[i].FirstSeenTimestampUTC).ToString(); string lastSeen = (msg.TagReportData[i].LastSeenTimestampUTC).ToString(); string rssi = (msg.TagReportData[i].PeakRSSI).ToString(); string freq = (msg.TagReportData[i].ChannelIndex).ToString(); string mode = readerMgr.GetReaderConfigMode(); result = null; //Tag newTag = BuildTag(epcInfo); // extract information count = getRelevantInfoFromXML(count, 1); //accessSpecID = getRelevantInfoFromXML(accessSpecID, 1); time = getRelevantInfoFromXML(time, 1); rssi = getRelevantInfoFromXML(rssi, 1); freq = getRelevantInfoFromXML(freq, 1); string accessResultData = ""; if (accessSpecID != "0") { for (int j = 0; j < msg.TagReportData[i].AccessCommandOpSpecResult.Length; j++) { result = msg.TagReportData[i].AccessCommandOpSpecResult[0].ToString(); // MessageBox.Show(result); - evil - just keeps popping up! // extract access result if (result != null && result.Contains("Success")) { Type t2 = msg.TagReportData[i].AccessCommandOpSpecResult[0].GetType(); if (t2.Name == "PARAM_C1G2ReadOpSpecResult") { PARAM_C1G2ReadOpSpecResult accessResult; accessResult = ((PARAM_C1G2ReadOpSpecResult)(msg.TagReportData[i].AccessCommandOpSpecResult[0])); string marker = "<ReadData>"; int start = result.IndexOf(marker); int end = result.IndexOf("<", start + 1); accessResultData = result.Substring(start + marker.Length, end - marker.Length - start); } } } } // Pass all this information to the GUI in a MyTag object. MyTag newTag = new MyTag(epcInfo, time, count, firstSeen, lastSeen, accessResultData, rssi, freq, mode); readerMgr.HandleTagReceived(newTag); } return(result); }
//Thread myThread = new Thread(new ThreadStart(this.UpdateROReport)); public void reader_OnRoAccessReportReceived(MSG_RO_ACCESS_REPORT msg) { delegateRoAccessReport del = UpdateROReport; del.BeginInvoke(msg, OnAsyncCallBack, null); }
public static void ParseXMLToLLRPMessage(string xmlstr, out object msg, out ENUM_LLRP_MSG_TYPE type) { XmlDocument xdoc = new XmlDocument(); xdoc.LoadXml(xmlstr); XmlNode node = (XmlNode)xdoc.DocumentElement; switch (node.Name) { case "CUSTOM_MESSAGE": msg = (object)MSG_CUSTOM_MESSAGE.FromString(xmlstr); type = ENUM_LLRP_MSG_TYPE.CUSTOM_MESSAGE; return; case "GET_READER_CAPABILITIES": msg = (object)MSG_GET_READER_CAPABILITIES.FromString(xmlstr); type = ENUM_LLRP_MSG_TYPE.GET_READER_CAPABILITIES; return; case "GET_READER_CAPABILITIES_RESPONSE": msg = (object)MSG_GET_READER_CAPABILITIES_RESPONSE.FromString(xmlstr); type = ENUM_LLRP_MSG_TYPE.GET_READER_CAPABILITIES_RESPONSE; return; case "ADD_ROSPEC": msg = (object)MSG_ADD_ROSPEC.FromString(xmlstr); type = ENUM_LLRP_MSG_TYPE.ADD_ROSPEC; return; case "ADD_ROSPEC_RESPONSE": msg = (object)MSG_ADD_ROSPEC_RESPONSE.FromString(xmlstr); type = ENUM_LLRP_MSG_TYPE.ADD_ROSPEC_RESPONSE; return; case "DELETE_ROSPEC": msg = (object)MSG_DELETE_ROSPEC.FromString(xmlstr); type = ENUM_LLRP_MSG_TYPE.DELETE_ROSPEC; return; case "DELETE_ROSPEC_RESPONSE": msg = (object)MSG_DELETE_ROSPEC_RESPONSE.FromString(xmlstr); type = ENUM_LLRP_MSG_TYPE.DELETE_ROSPEC_RESPONSE; return; case "START_ROSPEC": msg = (object)MSG_START_ROSPEC.FromString(xmlstr); type = ENUM_LLRP_MSG_TYPE.START_ROSPEC; return; case "START_ROSPEC_RESPONSE": msg = (object)MSG_START_ROSPEC_RESPONSE.FromString(xmlstr); type = ENUM_LLRP_MSG_TYPE.START_ROSPEC_RESPONSE; return; case "STOP_ROSPEC": msg = (object)MSG_STOP_ROSPEC.FromString(xmlstr); type = ENUM_LLRP_MSG_TYPE.STOP_ROSPEC; return; case "STOP_ROSPEC_RESPONSE": msg = (object)MSG_STOP_ROSPEC_RESPONSE.FromString(xmlstr); type = ENUM_LLRP_MSG_TYPE.STOP_ROSPEC_RESPONSE; return; case "ENABLE_ROSPEC": msg = (object)MSG_ENABLE_ROSPEC.FromString(xmlstr); type = ENUM_LLRP_MSG_TYPE.ENABLE_ROSPEC; return; case "ENABLE_ROSPEC_RESPONSE": msg = (object)MSG_ENABLE_ROSPEC_RESPONSE.FromString(xmlstr); type = ENUM_LLRP_MSG_TYPE.ENABLE_ROSPEC_RESPONSE; return; case "DISABLE_ROSPEC": msg = (object)MSG_DISABLE_ROSPEC.FromString(xmlstr); type = ENUM_LLRP_MSG_TYPE.DISABLE_ROSPEC; return; case "DISABLE_ROSPEC_RESPONSE": msg = (object)MSG_DISABLE_ROSPEC_RESPONSE.FromString(xmlstr); type = ENUM_LLRP_MSG_TYPE.DISABLE_ROSPEC_RESPONSE; return; case "GET_ROSPECS": msg = (object)MSG_GET_ROSPECS.FromString(xmlstr); type = ENUM_LLRP_MSG_TYPE.GET_ROSPECS; return; case "GET_ROSPECS_RESPONSE": msg = (object)MSG_GET_ROSPECS_RESPONSE.FromString(xmlstr); type = ENUM_LLRP_MSG_TYPE.GET_ROSPECS_RESPONSE; return; case "ADD_ACCESSSPEC": msg = (object)MSG_ADD_ACCESSSPEC.FromString(xmlstr); type = ENUM_LLRP_MSG_TYPE.ADD_ACCESSSPEC; return; case "ADD_ACCESSSPEC_RESPONSE": msg = (object)MSG_ADD_ACCESSSPEC_RESPONSE.FromString(xmlstr); type = ENUM_LLRP_MSG_TYPE.ADD_ACCESSSPEC_RESPONSE; return; case "DELETE_ACCESSSPEC": msg = (object)MSG_DELETE_ACCESSSPEC.FromString(xmlstr); type = ENUM_LLRP_MSG_TYPE.DELETE_ACCESSSPEC; return; case "DELETE_ACCESSSPEC_RESPONSE": msg = (object)MSG_DELETE_ACCESSSPEC_RESPONSE.FromString(xmlstr); type = ENUM_LLRP_MSG_TYPE.DELETE_ACCESSSPEC_RESPONSE; return; case "ENABLE_ACCESSSPEC": msg = (object)MSG_ENABLE_ACCESSSPEC.FromString(xmlstr); type = ENUM_LLRP_MSG_TYPE.ENABLE_ACCESSSPEC; return; case "ENABLE_ACCESSSPEC_RESPONSE": msg = (object)MSG_ENABLE_ACCESSSPEC_RESPONSE.FromString(xmlstr); type = ENUM_LLRP_MSG_TYPE.ENABLE_ACCESSSPEC_RESPONSE; return; case "DISABLE_ACCESSSPEC": msg = (object)MSG_DISABLE_ACCESSSPEC.FromString(xmlstr); type = ENUM_LLRP_MSG_TYPE.DISABLE_ACCESSSPEC; return; case "DISABLE_ACCESSSPEC_RESPONSE": msg = (object)MSG_DISABLE_ACCESSSPEC_RESPONSE.FromString(xmlstr); type = ENUM_LLRP_MSG_TYPE.DISABLE_ACCESSSPEC_RESPONSE; return; case "GET_ACCESSSPECS": msg = (object)MSG_GET_ACCESSSPECS.FromString(xmlstr); type = ENUM_LLRP_MSG_TYPE.GET_ACCESSSPECS; return; case "GET_ACCESSSPECS_RESPONSE": msg = (object)MSG_GET_ACCESSSPECS_RESPONSE.FromString(xmlstr); type = ENUM_LLRP_MSG_TYPE.GET_ACCESSSPECS_RESPONSE; return; case "GET_READER_CONFIG": msg = (object)MSG_GET_READER_CONFIG.FromString(xmlstr); type = ENUM_LLRP_MSG_TYPE.GET_READER_CONFIG; return; case "GET_READER_CONFIG_RESPONSE": msg = (object)MSG_GET_READER_CONFIG_RESPONSE.FromString(xmlstr); type = ENUM_LLRP_MSG_TYPE.GET_READER_CONFIG_RESPONSE; return; case "SET_READER_CONFIG": msg = (object)MSG_SET_READER_CONFIG.FromString(xmlstr); type = ENUM_LLRP_MSG_TYPE.SET_READER_CONFIG; return; case "SET_READER_CONFIG_RESPONSE": msg = (object)MSG_SET_READER_CONFIG_RESPONSE.FromString(xmlstr); type = ENUM_LLRP_MSG_TYPE.SET_READER_CONFIG_RESPONSE; return; case "CLOSE_CONNECTION": msg = (object)MSG_CLOSE_CONNECTION.FromString(xmlstr); type = ENUM_LLRP_MSG_TYPE.CLOSE_CONNECTION; return; case "CLOSE_CONNECTION_RESPONSE": msg = (object)MSG_CLOSE_CONNECTION_RESPONSE.FromString(xmlstr); type = ENUM_LLRP_MSG_TYPE.CLOSE_CONNECTION_RESPONSE; return; case "GET_REPORT": msg = (object)MSG_GET_REPORT.FromString(xmlstr); type = ENUM_LLRP_MSG_TYPE.GET_REPORT; return; case "RO_ACCESS_REPORT": msg = (object)MSG_RO_ACCESS_REPORT.FromString(xmlstr); type = ENUM_LLRP_MSG_TYPE.RO_ACCESS_REPORT; return; case "KEEPALIVE": msg = (object)MSG_KEEPALIVE.FromString(xmlstr); type = ENUM_LLRP_MSG_TYPE.KEEPALIVE; return; case "KEEPALIVE_ACK": msg = (object)MSG_KEEPALIVE_ACK.FromString(xmlstr); type = ENUM_LLRP_MSG_TYPE.KEEPALIVE_ACK; return; case "READER_EVENT_NOTIFICATION": msg = (object)MSG_READER_EVENT_NOTIFICATION.FromString(xmlstr); type = ENUM_LLRP_MSG_TYPE.READER_EVENT_NOTIFICATION; return; case "ENABLE_EVENTS_AND_REPORTS": msg = (object)MSG_ENABLE_EVENTS_AND_REPORTS.FromString(xmlstr); type = ENUM_LLRP_MSG_TYPE.ENABLE_EVENTS_AND_REPORTS; return; case "ERROR_MESSAGE": msg = (object)MSG_ERROR_MESSAGE.FromString(xmlstr); type = ENUM_LLRP_MSG_TYPE.ERROR_MESSAGE; return; default: msg = null; type = 0; return; } }
void OnRoAccessReportReceived(MSG_RO_ACCESS_REPORT msg) { isRoAccessReportReceived = true; lock (isRoAccessReportsComingLock) { isRoAccessReportsComing = true; } delegateRoAccessReport del = new delegateRoAccessReport(UpdateROReport); del.Invoke(msg); }
void reader_OnRoAccessReportReceived(MSG_RO_ACCESS_REPORT msg) { delegateRoAccessReport del = new delegateRoAccessReport(UpdateROReport); this.Invoke(del, msg); }
void TagOpOnRoAccessReportReceived(MSG_RO_ACCESS_REPORT msg) { BuildTransport(false, msg); delegateRoAccessReport del = new delegateRoAccessReport(ParseTagOpResponse); del.Invoke(msg); }