// 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); } }
// 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); } } }