Exemplo n.º 1
0
        public void SetIgnoreStateTest()
        {
            TagPool.SetMinReadedCount(2);
            TagPool.ClearTagPool();

            List <TagInfo> tagList = TagPool.GetAllExistsTags();

            Assert.IsTrue(tagList.Count == 0);


            TagInfo ti1 = new TagInfo("111", "01");
            TagInfo ti2 = new TagInfo("111", "03");

            TagPool.AddTag(ti1);
            TagPool.AddTag(ti2);
            TagPool.ResetExistsState();
            tagList = TagPool.GetAllExistsTags();
            Assert.IsTrue(tagList.Count == 0);
            TagPool.AddTag(ti1);
            TagPool.AddTag(ti2);
            TagPool.SetIgnoreMisreading(true);
            TagPool.ResetExistsState();
            tagList = TagPool.GetAllExistsTags();
            Assert.IsTrue(tagList.Count == 1);
        }
Exemplo n.º 2
0
        public void TagPoolTest()
        {
            TagPool.ClearTagPool();
            TagPool.SetMinReadedCount(2);

            List <TagInfo> tagList = TagPool.GetAllExistsTags();

            TagPool.ResetExistsState();
            Assert.IsTrue(tagList.Count == 0);

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

            ti01.port = common_port_9601;
            TagPool.AddTag(ti01);
            TagPool.ResetExistsState();
            tagList = TagPool.GetAllExistsTags();
            Assert.IsTrue(tagList.Count == 0);
            tagList = TagPool.GetAllExistsTags(true);
            string str = JsonConvert.SerializeObject(tagList);

            Assert.IsTrue(tagList.Count == 1);
            //Assert.IsTrue(tagList[0].epc == "300833B2DDD906C001010101");

            TagInfo ti02 = new TagInfo("300833B2DDD906C001010102", "01");

            ti02.port = common_port_9602;
            TagPool.AddTag(ti01);
            TagPool.AddTag(ti02);
            TagPool.AddTag(ti02);
            TagPool.ResetExistsState();
            tagList = TagPool.GetAllExistsTags();
            Assert.IsTrue(tagList.Count == 1);
            Assert.IsTrue(tagList.Exists((_tag) => { return(_tag.epc == "300833B2DDD906C001010102" && _tag.port == common_port_9602); }));
        }
Exemplo n.º 3
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");
        }