Ejemplo n.º 1
0
        public void TagPoolResetTagStateTest()
        {
            TagPool.ClearTagPool();

            string  epc  = "300833B2DDD906C001010101";
            TagInfo ti01 = new TagInfo(epc, "01");

            ti01.port = common_port_9601;
            TagPool.AddTag(ti01);
            TagPool.AddTag(ti01);
            TagInfo tiTemp = TagPool.GetSpecifiedTag(epc);

            Assert.IsTrue(TagPool.GetMaxReadCountTag(tiTemp) == 2);
            TagPool.UpdateTagInfo(tiTemp, ti01);
            Assert.IsTrue(TagPool.GetMaxReadCountTag(tiTemp) == 3);
            TagPool.ResetReadCountDefault(tiTemp);
            TagPool.UpdateTagInfo(tiTemp, null);
            Assert.IsTrue(TagPool.GetMaxReadCountTag(tiTemp) == 0);
        }
Ejemplo n.º 2
0
        public void TagEventTest()
        {
            TagPool.ClearTagPool();
            TagPool.SetMinReadedCount(2);


            //新读取标签测试,由不存在到存在,事件变为  TagEvent_TagNew
            string  epc  = "300833B2DDD906C001010101";
            TagInfo ti01 = new TagInfo(epc, "01");

            TagPool.AddTag(ti01);
            TagPool.AddTag(ti01);
            TagPool.ResetExistsState();
            TagInfo tiTemp = TagPool.GetSpecifiedTag(epc);

            Assert.IsTrue(tiTemp.bThisTagExists == true);
            Assert.IsTrue(tiTemp.Event == TagEvent.TagEvent_TagNew);
            Assert.IsTrue(tiTemp.antennaID == "01");

            //标签消失测试,由存在变为不存在,事件变为 TagEvent_TagDeleted
            TagPool.ResetExistsState();
            TagPool.UpdateTagInfo(tiTemp, null);
            tiTemp = TagPool.GetSpecifiedTag(epc);
            Assert.IsTrue(tiTemp.bThisTagExists == false);
            Assert.IsTrue(tiTemp.Event == TagEvent.TagEvent_TagDeleted);
            Assert.IsTrue(tiTemp.antennaID == "01");

            //标签由消失变化默认状态,不存在状态延续,事件变为 TagEvent_Normal
            TagPool.ResetExistsState();
            tiTemp = TagPool.GetSpecifiedTag(epc);
            Assert.IsTrue(tiTemp.Event == TagEvent.TagEvent_Normal);
            Assert.IsTrue(tiTemp.antennaID == "01");

            //标签切换天线
            TagPool.AddTag(ti01);
            TagPool.AddTag(ti01);
            TagPool.ResetExistsState();
            tiTemp = TagPool.GetSpecifiedTag(epc);
            Assert.IsTrue(tiTemp.bThisTagExists == true);
            Assert.IsTrue(tiTemp.Event == TagEvent.TagEvent_TagNew);
            Assert.IsTrue(tiTemp.antennaID == "01");
            TagInfo ti02 = new TagInfo(epc, "02");

            TagPool.AddTag(ti02);
            TagPool.AddTag(ti02);
            TagPool.AddTag(ti02);
            TagPool.ResetExistsState();
            Assert.IsTrue(tiTemp.bThisTagExists == true);
            Assert.IsTrue(tiTemp.Event == TagEvent.TagEvent_SwitchAnt);
            Assert.IsTrue(tiTemp.antennaID == "02");

            //存在状态延续,事件由 TagEvent_SwitchAnt 变为 TagEvent_Normal
            TagPool.AddTag(ti02);
            TagPool.AddTag(ti02);
            TagPool.AddTag(ti02);
            TagPool.ResetExistsState();
            Assert.IsTrue(tiTemp.bThisTagExists == true);
            Assert.IsTrue(tiTemp.Event == TagEvent.TagEvent_Normal);
            Assert.IsTrue(tiTemp.antennaID == "02");

            //由消失变存在,事件由
            //TagPool.AddTag(ti01);
            //TagPool.AddTag(ti01);
            //TagPool.ResetExistsState();
            //Assert.IsTrue(tiTemp.bThisTagExists == true);
            //Assert.IsTrue(tiTemp.Event == TagEvent.TagEvent_SwitchAnt);
            //Assert.IsTrue(tiTemp.antennaID == "01");
        }