/// <summary>
 /// Predicate for post-processing filters.
 /// </summary>
 /// <param name="t">tag data to screen</param>
 /// <returns>Return true to allow tag through the filter.
 /// Return false to reject tag.</returns>
 public bool Matches(ThingMagic.TagData t)
 {
     throw new NotSupportedException();
 }
Exemple #2
0
            /// <summary>
            /// Test if a tag Matches this filter. Only applies to selects based
            /// on the EPC.
            /// </summary>
            /// <param name="t">tag data to screen</param>
            /// <returns>Return true to allow tag through the filter.
            /// Return false to reject tag.</returns>
            public bool Matches(ThingMagic.TagData t)
            {
                bool match = true;
                int i, bitAddr;

                if (Bank != Bank.EPC)
                    throw new NotSupportedException("Can't match against non-EPC memory");

                i = 0;
                bitAddr = (int)BitPointer;
                // Matching against the CRC and PC does not have defined
                // behavior; see section 6.3.2.11.1.1 of Gen2 version 1.2.0.
                // We choose to let it match, because that's simple.
                bitAddr -= 32;
                if (bitAddr < 0)
                {
                    i -= bitAddr;
                    bitAddr = 0;
                }

                for (; i < BitLength; i++, bitAddr++)
                {
                    if (bitAddr > (t.EpcBytes.Length * 8))
                    {
                        match = false;
                        break;
                    }
                    // Extract the relevant bit from both the EPC and the mask.
                    if (((t.EpcBytes[bitAddr / 8] >> (7 - (bitAddr & 7))) & 1) !=
                        ((Mask[i / 8] >> (7 - (i & 7))) & 1))
                    {
                        match = false;
                        break;
                    }
                }

                if (Invert)
                    match = match ? false : true;

                return match;
            }