Пример #1
0
        /// <summary>
        /// Cancel Epc Filter
        /// </summary>
        private void CancelEpcFilter()
        {
            Cursor.Current = Cursors.WaitCursor;
            Cursor.Show();
            try
            {
                string errInfo = "";
                byte[] bcode   = new byte[listBoxAddr.Items.Count];
                byte[] match   = new byte[this.listBoxAddr.Items.Count];
                for (int i = 0; i < match.Length; i++)
                {
                    match[i] = 0x00;
                }

                if (RfidConfig.SetEpcFilter(0x01, bcode, match, out errInfo))
                {
                    AddToStatusAsync("Cancel match EPC.");
                    FormatConvert.SoundSucceed();
                    Close();
                }
                else
                {
                    FormatConvert.SoundError();
                    AddToStatusAsync("Cancel Failed");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            Cursor.Current = Cursors.Default;
        }
Пример #2
0
        /// <summary>
        /// Set Epc Filter
        /// </summary>
        private void SetEpcFilter()
        {
            string errInfo = "";
            string strhex  = FormatConvert.HaxToStr(tvEpcData.Text.Trim());

            if (strhex == "" ||
                strhex.Length != 24)
            {
                AddToStatusAsync("Input tag EPC(12-byte)!");
                tvEpcData.Focus();
                return;
            }
            if (listBoxChooseAddr.Items.Count < 1)
            {
                AddToStatusAsync("Select matched data!");
                return;
            }

            Cursor.Current = Cursors.WaitCursor;
            Cursor.Show();
            try
            {
                byte[] match = new byte[this.listBoxAddr.Items.Count];
                for (int i = 0; i < match.Length; i++)
                {
                    match[i] = 0x00;
                }
                foreach (object o in this.listBoxChooseAddr.Items)
                {
                    ComboBindData item = (ComboBindData)o;
                    int           iadd = Convert.ToInt32(item.ValueMember);
                    match[iadd] = 0xFF;
                }
                byte[] bcode = Util.ConvertHexStringToByteArray(strhex);

                if (RfidConfig.SetEpcFilter(0x00, bcode, match, out errInfo))
                {
                    AddToStatusAsync("Configure EPC match completed.");
                    FormatConvert.SoundSucceed();
                    Close();
                }
                else
                {
                    FormatConvert.SoundError();
                    AddToStatusAsync("Configure EPC match failed!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            Cursor.Current = Cursors.Default;
        }