예제 #1
0
        // 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);
                }
            }
        }
예제 #2
0
        // 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);
                }
            }
        }