Exemplo n.º 1
0
        public static new Sgtin96Tag FromBinary(string epcText)
        {
            Assert.LengthIs("EpcCode", epcText, 24);

            BitArray bits = EpcEncoder.BinaryStringToBitArray(epcText);

            return(FromBinary(bits));
        }
Exemplo n.º 2
0
        public new static Sscc96Tag FromBinary(string epcCode)
        {
            Assert.LengthIs("EpcCode", epcCode, 24);

            BitArray bits = EpcEncoder.BinaryStringToBitArray(epcCode);

            return(FromBinary(bits));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Parses the partition table.
        /// </summary>
        /// <param name="bits">The bit array.</param>
        /// <param name="partitions">The tag type specific partition table.</param>
        /// <param name="firstBit">The first bit where the partion starts.</param>
        /// <param name="partition">The resulting partition.</param>
        /// <param name="val1">The first value.</param>
        /// <param name="val2">The second value.</param>
        /// <exception cref="System.FormatException"></exception>
        public static void DecodePartition(this BitArray bits, Partition[] partitions, int firstBit, out byte partition, out string val1, out string val2)
        {
            partition = (byte)EpcEncoder.DecodeUInt32(bits, firstBit, 3);
            if (partitions.Length < partition || partitions[partition] == null)
            {
                throw new FormatException(string.Format("Partition {0} not defined", partition));
            }

            var partitionDef = partitions[partition];

            int   bits1 = partitionDef.Bits1;
            int   bits2 = partitionDef.Bits2;
            ulong num1  = EpcEncoder.ReadUInt64(bits, firstBit + 3, bits1);
            ulong num2  = EpcEncoder.ReadUInt64(bits, firstBit + 3 + bits1, bits2);

            val1 = num1.ToString().PadLeft(partitionDef.Digits1, '0');
            val2 = num2.ToString().PadLeft(partitionDef.Digits2, '0');
        }
Exemplo n.º 4
0
        public static Sgtin96Tag FromBinary(BitArray rawBits)
        {
            uint header = EpcEncoder.DecodeUInt32(rawBits, 0, 8);

            if (header != BinaryHeader)
            {
                throw new FormatException(string.Format("Invalid EPC Header: 0x{0:X2} (expected 0x{1:X2)", header, BinaryHeader));
            }

            string companyPrefix;
            string indicatorAnditemRef;
            ulong  serial;
            byte   partition;

            byte filter = (Byte)EpcEncoder.DecodeUInt32(rawBits, 8, 3);

            EpcEncoder.DecodePartition(rawBits, PartitionTable, 11, out partition, out companyPrefix, out indicatorAnditemRef);
            serial = EpcEncoder.ReadUInt64(rawBits, 58, 38);

            return(new Sgtin96Tag(filter, partition, companyPrefix, indicatorAnditemRef, serial.ToString()));
        }
Exemplo n.º 5
0
 /// <summary>
 /// Gets the <see cref="EpcTag"/>'s binary text representation
 /// </summary>
 /// <returns>System.String.</returns>
 public string ToBinary()
 {
     return(EpcEncoder.BitArrayToBinaryString(ToBitArray()));
 }