Example #1
0
        // Encodes the label information to the required specifications of Lowes and returns the encoded string
        public string EncodeLowesManufacturingInformation()
        {
            int   modelEncodingNumber = 0;
            ulong encodedLabelNumber  = 0;

            // Check to see if this is a test label
            if (!this.Product.SKU.Equals(TestSku))
            {
                modelEncodingNumber = (int)Product.ModelEncodingNumber;

                if (modelEncodingNumber == InvalidModelEncodingNumber)
                {
                    return(string.Empty);
                }
            }

            // Takes the information of the label and encodes it into the required Lowes format
            encodedLabelNumber |= ((ulong)this.Tester);
            encodedLabelNumber |= ((ulong)this.Station << StationOffset);
            encodedLabelNumber |= ((ulong)this.Site << SiteOffset);
            // Get the last two digits of the year (2015 = 15)
            encodedLabelNumber |= ((ulong)(this.Date.Year % 100) << DateYearOffset);
            encodedLabelNumber |= ((ulong)this.Date.Day << DateDayOffset);
            // Month encoding starts at 0 (Jan)
            encodedLabelNumber |= ((ulong)(this.Date.Month - 1) << DateMonthOffset);
            // Board Revision is being passed in as a character, and therefore needs to be converted back to an int
            encodedLabelNumber |= ((ulong)(BoardRevision.CharToRevision((char)this.HardwareVersion)) << HWRevisionOffset);
            encodedLabelNumber |= ((ulong)modelEncodingNumber << ModelEncodingNumberOffset);


            byte[] encodedLabelNumberBytesArray = BitConverter.GetBytes(encodedLabelNumber);

            // Put the encodedLabelNumberBytesArray into a big endian format
            Array.Reverse(encodedLabelNumberBytesArray);

            // Array for final encoded information
            byte[] euiEncodedLabelNumber = new byte[encodedLabelNumberBytesArray.Length + EUI.Length];

            // Concatenate the two arrays together
            EUI.CopyTo(euiEncodedLabelNumber, 0);
            encodedLabelNumberBytesArray.CopyTo(euiEncodedLabelNumber, EUI.Length);

            // Convert the Byte array into a string of hex digits
            return(BitConverter.ToString(euiEncodedLabelNumber).Replace("-", ""));
        }