Exemplo n.º 1
0
        private void ReceiveUiiProc()
        {
            TagRead ent = new TagRead();
            int[] uLenUii = new int[1];
            byte[] uUii = new byte[128]; //UII should be at least 66 bytes
            while (canReceive)
            {
                //int[] uLenUii = new int[1];
                //byte[] uUii = new byte[128];   //UII should be at least 66 bytes
                if (UHF.UHFGetReceived(uLenUii, uUii))
                {
                    if (uLenUii[0] > 0)
                    {
                        if (FlagSound)
                        {
                            //Win32.PlayScanSound();
                        }

                        string uii = BitConverter.ToString(uUii, 0, uLenUii[0]).Replace("-", "");

                        //show to the interface
                        //TagRead ent = new TagRead();
                        ent.Uii = uii;
                        ent.Epc = uii.Substring(4, uii.Length - 4);  //Epc
                        ent.Count = 1;
                        if (!datalist.ContainsKey(ent.Epc))
                        {

                            datalist.Add(ent.Epc, 1);
                            ListViewItem lv = new ListViewItem();
                            lv.Text = (datalist.Count).ToString();
                            lv.SubItems.Add(ent.Epc);
                            lv.SubItems.Add("1");
                            _lvReadID.Invoke(new EventHandler(delegate
                            {
                                _lvReadID.Items.Add(lv);
                            }));

                            _lbSumTagsReadID.Invoke(new EventHandler(delegate
                            {
                                _lbSumTagsReadID.Text = datalist.Count.ToString();
                            }));
                        }
                        else
                        {
                            datalist[ent.Epc] += 1;
                            DisplayTagID(ent);

                        }
                        //UpdateControl(ent);

                    }
                }

                System.Threading.Thread.Sleep(20);
            }
        }
Exemplo n.º 2
0
        private void UpdateControl(TagRead ent)
        {
            if (this.InvokeRequired)
            {
                UpdateControlDelegate d = new UpdateControlDelegate(UpdateControl);
                this.Invoke(d, ent);
            }
            else
            {
                bool exist = false;
                foreach (TagRead var in list)
                {
                    if (var.Epc == ent.Epc)
                    {
                        exist = true;
                        var.Count += ent.Count;
                    }
                }
                if (!exist)
                {
                    ent.Serial = list.Count + 1;
                    list.Add(ent);
                }
                this._lvReadID.Items.Clear();
                foreach (TagRead var in list)
                {
                    string[] strArr = new string[3];
                    strArr[0] = var.Serial.ToString();
                    strArr[1] = var.Epc;
                    strArr[2] = var.Count.ToString();

                    ListViewItem item = new ListViewItem(strArr);
                    this._lvReadID.Items.Add(item);
                }
                _lbSumTagsReadID.Invoke(new EventHandler(delegate
                {
                    _lbSumTagsReadID.Text = list.Count.ToString();
                }));

            }
        }
Exemplo n.º 3
0
 private void DisplayTagID(TagRead ent)
 {
     _lvReadID.Invoke(new EventHandler(delegate
                    {
                        for (int cpt = 0; cpt < _lvReadID.Items.Count; cpt++)
                        {
                            if (this._lvReadID.Items[cpt].SubItems[1].Text == ent.Epc)
                            {
                                this._lvReadID.Items[cpt].SubItems[2].Text = datalist[ent.Epc].ToString();
                                break;
                            }
                        }
                    }));
 }