示例#1
0
 private void cmbPartition_SelectedIndexChanged(object sender, EventArgs e)
 {
     CurrentPartitionValue  = Convert.ToInt32(GetComboboxItem(cmbPartition));
     CurrentPartitionRecord = GetPartitionTableRecord(CurrentPartitionValue);
     overrideValues         = false;
     CreateNewEpcId();
 }
示例#2
0
        /// <summary>
        /// Extract EPC tag id's header, filter, partition and serial number.
        /// </summary>
        private void ExtractEpcData()
        {
            SetStatusIcon(CommandStatus.None);

            if (string.IsNullOrEmpty(currentEpcId))
            {
                MessageBox.Show("EPC Tag id should not be null or empty.", "Error", MessageBoxButtons.OK);
                return;
            }

            var binaryValue = string.Empty;

            foreach (var c in currentEpcId.ToCharArray())
            {
                binaryValue += Convert.ToString(Convert.ToInt64(c.ToString(), 16), 2).PadLeft(4, '0');
            }

            if (binaryValue.Length != SGTIN_LENGTH)
            {
                MessageBox.Show("EPC Tag id length is not valid.", "Error", MessageBoxButtons.OK);
                return;
            }

            if (overrideValues)
            {
                CurrentFilterValue    = Convert.ToInt32(binaryValue.Substring(EPC_HEADER_LENGTH, EPC_FILTER_LENGTH), 2);
                CurrentPartitionValue = Convert.ToInt32(binaryValue.Substring((EPC_HEADER_LENGTH + EPC_FILTER_LENGTH), EPC_PARTITION_LENGTH), 2);

                if (CurrentPartitionValue > 6 || CurrentPartitionValue < 0)
                {
                    SetTextboxText(txtEpcId, string.Empty);
                    MessageBox.Show("Invalid EPC Tag. Partition value should be between 0-6." + CurrentPartitionValue + ".", "Error", MessageBoxButtons.OK);
                    return;
                }
                CurrentPartitionRecord = GetPartitionTableRecord(CurrentPartitionValue);

                SetComboboxItem(cmbFilterValue, CurrentFilterValue.ToString());
                SetComboboxItem(cmbPartition, CurrentPartitionValue.ToString());
                overrideValues = true;
            }

            CurrentEPCsUPCPortionInBinary = binaryValue.Substring((EPC_HEADER_LENGTH + EPC_FILTER_LENGTH + EPC_PARTITION_LENGTH), EPC_PREFIX_REFERENCE_LENGTH);
            if (overrideSerial)
            {
                CurrentSerialNumber = Convert.ToInt64(binaryValue.Substring((binaryValue.Length - EPC_SERIAL_NUMBER_LENGTH), EPC_SERIAL_NUMBER_LENGTH), 2);
                SetTextboxText(txtSerialNumber, CurrentSerialNumber.ToString());
                overrideSerial = true;
            }
            else
            {
                SetTextboxText(txtSerialNumber, CurrentSerialNumber.ToString());
            }
        }