示例#1
0
        private void IntervalCheckProducts(List <TagInfo> tiList)
        {
            foreach (TagInfo ti in tiList)
            {
                strEpc      = ti.epc;
                strAntenaID = ti.antennaID;
                //误读也加入检测中
                //if (ti.antennaID == "01" || ti.antennaID == "02" || ti.antennaID == "04" || ti.antennaID == "08")
                {
                    //如果该epc尚未添加,则只需添加到列表中即可
                    if (this.ProductList.FindIndex(FindEpcProduct) < 0)
                    {
                        EpcProduct new_ep = new EpcProduct(ti);
                        this.ProductList.Add(new_ep);
                    }
                }
            }

            foreach (EpcProduct ep in this.ProductList)
            {
                strEpc      = ep.tagInfo.epc;
                strAntenaID = ep.tagInfo.antennaID;

                if (tiList.FindIndex(IsThisEpc) >= 0)
                {
                    //如果该epc已经存在,更改其读取记录为读取到
                    int OnFloorstate = ep.SetRecordReaded();
                    if (OnFloorstate == 1)
                    {
                        ep.ShiftToBeOnFloor();
                        this.bHasNewMessage = true;
                    }
                }
                else
                {
                    ep.SetRecordUnreaded();
                }

                int state = ep.VoteDecrease(); //每次固定减一
                if (state < 0)                 //表明产品下架了
                {
                    ep.ShiftFromFloor();       //产品下架后才有可能在其它层上架
                    this.bHasNewMessage = true;
                }
            }
            //Debug.WriteLine(string.Format("new message -> port {0}    message  {1}", this.udp_port.ToString(), bHasNewMessage.ToString()));
            if (this.listener != null && this.bHasNewMessage)
            {
                listener.NewTagMessage();
                this.bHasNewMessage = false;
            }
        }
        private void IntervalCheckProducts(List <TagInfo> tiList)
        {
            foreach (TagInfo ti in tiList)
            {
                strEpc      = ti.epc;
                strAntenaID = ti.antennaID;
                //如果是误读的标签,则不加入到检测中
                if (ti.antennaID == "01" || ti.antennaID == "02" || ti.antennaID == "04" || ti.antennaID == "08")
                {
                    //如果该epc尚未添加,则只需添加到列表中即可
                    if (this.ProductList.FindIndex(FindEpcProduct) < 0)
                    {
                        EpcProduct new_ep = new EpcProduct(ti);
                        this.ProductList.Add(new_ep);
                    }
                }
            }

            foreach (EpcProduct ep in this.ProductList)
            {
                strEpc      = ep.tagInfo.epc;
                strAntenaID = ep.tagInfo.antennaID;

                if (tiList.FindIndex(IsThisEpcAndAntena) >= 0)
                {
                    //如果该epc已经存在,更改其读取记录为读取到
                    int OnFloorstate = ep.SetRecordReaded();
                    // 当本产品本身满足上架条件并且整个货架上没有相同Epc的产品在架时,才能上架
                    // 这是为了防止一个标签同时被两个天线读到导致同一产品在不同层上架的情况发生
                    if (OnFloorstate == 1 && this.ProductList.FindIndex(FindEpcProductOnFloorWithoutAntena) < 0)
                    {
                        ep.ShiftToBeOnFloor();
                        this.bHasNewMessage = true;
                    }
                }
                else
                {
                    ep.SetRecordUnreaded();
                }

                //关于误读得到的数据的处理
                //如果有标签在货架上,则认为这是该层读到的,否则放弃
                if (tiList.FindIndex(IsJustThisEpcAndWrongAntena) >= 0 && ep.IsOnFloor)
                {
                    ep.SetRecordReaded();
                }

                int state = ep.VoteDecrease(); //每次固定减一
                if (state < 0)                 //表明产品下架了
                {
                    ep.ShiftFromFloor();       //产品下架后才有可能在其它层上架
                    this.bHasNewMessage = true;
                }
            }
            //Debug.WriteLine(string.Format("new message -> port {0}    message  {1}", this.udp_port.ToString(), bHasNewMessage.ToString()));
            if (this.listener != null && this.bHasNewMessage)
            {
                listener.NewTagMessage();
                this.bHasNewMessage = false;
            }
        }