Exemplo n.º 1
0
        public void ReceiveNewTag(string tagInfo)
        {
            TagInfo ti = TagInfo.Parse(tagInfo);

            if (null == ti)
            {
                return;
            }
            this.AddNewTag2Table(ti);
        }
Exemplo n.º 2
0
        public void ReceiveNewTag()
        {
            string temp1 = this.stringBuilder.ToString();
            //Debug.WriteLine(temp1);
            int start = temp1.IndexOf("Disc:");
            int end   = temp1.IndexOf("\r\n");

            if (start >= 0 && end > 110 && start < end)
            {
                string temp = this.stringBuilder.ToString(start, end + 2);
                this.stringBuilder.Remove(0, end + 2);
                //this.stringBuilder.Remove(start, end + 2);

                for (int i = 0; i < temp.Length; i++)
                {
                    string tagInfo    = string.Empty;
                    int    startIndex = temp.IndexOf("Disc", i);
                    if (startIndex == -1)
                    {
                        return;
                    }
                    if (temp.Length - startIndex > 110)
                    {
                        tagInfo = temp.Substring(startIndex, 110);
                    }
                    else
                    {
                        return;
                    }
                    TagInfo ti = TagInfo.Parse(tagInfo);
                    if (null == ti)
                    {
                        return;
                    }
                    this.AddNewTag2Table(ti);
                    i = startIndex + 110;
                }
            }
        }
Exemplo n.º 3
0
        //丢失或者拿走的标签列表
        //public List<TagInfo> lostTagList = new List<TagInfo>();


        //接收串口或者其它方式接收到的标签信息,
        public void ParseDataToTag()
        {
            int    tagLength = 110;//每条数据的标准长度为110
            string temp1     = this.stringBuilder.ToString();
            //Debug.WriteLine(temp1);
            int start = temp1.IndexOf("Disc:");

            if (start < 0)
            {
                return;
            }
            int tempStart     = start;
            int lastDiscIndex = start;

            while (true)//找到最后一个Disc,并且其后有满格式的数据,即长度为110
            {
                int DiscIndex = temp1.IndexOf("Disc:", lastDiscIndex + 1);
                if (DiscIndex == -1)
                {
                    break;
                }
                else
                {
                    if (temp1.Length < DiscIndex + tagLength)
                    {
                        break;
                    }
                }
                lastDiscIndex = DiscIndex;
            }
            int    tail = lastDiscIndex + 110;
            string temp = this.stringBuilder.ToString(start, tail + 2);

            this.stringBuilder.Remove(0, tail + 2);//正确数据之前的数据已经没用了
            //int end = temp1.IndexOf("\r\n");
            //if (start >= 0 && end >= 110 && start < end)
            //if (temp1.Length > start + 110)
            {
                for (int i = 0; i < temp.Length; i++)
                {
                    string tagInfo    = string.Empty;
                    int    startIndex = temp.IndexOf("Disc", i);
                    if (startIndex == -1)
                    {
                        return;
                    }
                    if (temp.Length - startIndex >= tagLength)
                    {
                        tagInfo = temp.Substring(startIndex, tagLength);
                    }
                    else
                    {
                        return;
                    }
                    TagInfo ti = TagInfo.Parse(tagInfo);
                    if (null == ti)
                    {
                        return;
                    }
                    //this.AddNewTag2Table(ti);
                    this.AddNewTag2TempTable(ti);
                    i = startIndex + tagLength;
                }
            }
        }
Exemplo n.º 4
0
        //接收串口或者其它方式接收到的标签信息,
        public void ParseDataToTag()
        {
#if TRACE
            Debug.WriteLine("ParseDataToTag->");
#endif
            int    tagLength = 110;//每条数据的标准长度为110
            string temp1     = this.stringBuilder.ToString();
            //Debug.WriteLine(temp1);
            int start = temp1.IndexOf("Disc:");
            if (start < 0)
            {
                return;
            }
#if TRACE
            Debug.WriteLine("ParseDataToTag->  1");
#endif
            int tempStart     = start;
            int lastDiscIndex = start;
            while (true)//找到最后一个Disc,并且其后有满格式的数据,即长度为110
            {
                int DiscIndex = temp1.IndexOf("Disc:", lastDiscIndex + 1);
                if (DiscIndex == -1)
                {
                    break;
                }
                else
                {
                    if (temp1.Length < DiscIndex + tagLength)
                    {
                        break;
                    }
                }
                lastDiscIndex = DiscIndex;
            }
#if TRACE
            Debug.WriteLine("ParseDataToTag->  2");
#endif
            //int tail = lastDiscIndex + 110;
            int tail = lastDiscIndex - 1;
#if TRACE
            Debug.WriteLine(string.Format("ParseDataToTag->  start = {0}   tail = {1}  length = {2}", start, tail, stringBuilder.Length));
#endif
            string temp = this.stringBuilder.ToString(start, tail - start + 1);
            //string temp = this.stringBuilder.ToString(start, tail + 2 - start + 1);

            this.stringBuilder.Remove(0, tail + 1);//正确数据之前的数据已经没用了
            //this.stringBuilder.Remove(0, tail + 2);//正确数据之前的数据已经没用了
            //int end = temp1.IndexOf("\r\n");
            //if (start >= 0 && end >= 110 && start < end)
            //if (temp1.Length > start + 110)
            {
                for (int i = 0; i < temp.Length; i++)
                {
                    string tagInfo    = string.Empty;
                    int    startIndex = temp.IndexOf("Disc", i);
#if TRACE
                    Debug.WriteLine("ParseDataToTag->  3");
#endif
                    if (startIndex == -1)
                    {
                        return;
                    }
#if TRACE
                    Debug.WriteLine("ParseDataToTag->  4");
#endif
                    if (temp.Length - startIndex >= tagLength)
                    {
#if TRACE
                        Debug.WriteLine("ParseDataToTag->  5");
#endif
                        tagInfo = temp.Substring(startIndex, tagLength);
                    }
                    else
                    {
#if TRACE
                        Debug.WriteLine("ParseDataToTag->  6");
#endif
                        return;
                    }
#if TRACE
                    Debug.WriteLine("ParseDataToTag -> TagInfo.Parse");
#endif
                    TagInfo ti = TagInfo.Parse(tagInfo);
                    if (null == ti)
                    {
#if TRACE
                        Debug.WriteLine("ParseDataToTag <- null");
#endif
                        return;
                    }
                    this.AddNewTag2Table(ti);
                    //this.AddNewTag2TempTable(ti);
                    i = startIndex + tagLength;
                }
            }
#if TRACE
            Debug.WriteLine("ParseDataToTag <-");
#endif
        }
Exemplo n.º 5
0
        //接收串口或者其它方式接收到的标签信息,
        public void ParseDataToTag(string data)
        {
            this.tagDeleted(lostDelay);
            //this.bBusy = true;
            if (data == null || data.Length <= 0)
            {
                return;
            }
            Debug.WriteLine(
                string.Format("TDJ_RFIDHelper.ParseDataToTag input data ->  = {0}"
                              , data));
            this.stringBuilder.Append(data);
            int    tagLength = 110;//每条数据的标准长度为110
            string temp1     = this.stringBuilder.ToString();
            //Debug.WriteLine(temp1);
            int start = temp1.IndexOf("Disc:");

            if (start < 0)
            {
                return;
            }
            int tempStart     = start;
            int lastDiscIndex = start;

            while (true)//找到最后一个Disc,并且其后有满格式的数据,即长度为110
            {
                int DiscIndex = temp1.IndexOf("Disc:", lastDiscIndex + 1);
                if (DiscIndex == -1)
                {
                    break;
                }
                else
                {
                    if (temp1.Length < DiscIndex + tagLength)
                    {
                        break;
                    }
                }
                lastDiscIndex = DiscIndex;
            }
            //int tail = lastDiscIndex + 110;
            int tail = lastDiscIndex - 1;

            string temp = this.stringBuilder.ToString(start, tail - start + 1);

            //string temp = this.stringBuilder.ToString(start, tail + 2 - start + 1);
            Debug.WriteLine(
                string.Format("TDJ_RFIDHelper.ParseDataToTag disposed data ->  = {0}"
                              , data));
            this.stringBuilder.Remove(0, tail + 1);//正确数据之前的数据已经没用了

            for (int i = 0; i < temp.Length; i++)
            {
                string tagInfo    = string.Empty;
                int    startIndex = temp.IndexOf("Disc", i);
                string restStr    = "no rest";
                if (startIndex >= 0)
                {
                    restStr = temp.Substring(startIndex);
                }
                else
                {
                    restStr = "just print " + temp.Substring(i);
                }
                Debug.WriteLine(
                    string.Format("TDJ_RFIDHelper.ParseDataToTag  -> startIndex = {0} lastDiscIndex = {1}  rest temp = {2}"
                                  , startIndex, lastDiscIndex, restStr));
                if (startIndex == -1)
                {
                    this.bBusy = false;
                    return;
                }
                if (temp.Length - startIndex >= tagLength)
                {
                    tagInfo = temp.Substring(startIndex, tagLength);
                }
                else
                {
                    this.bBusy = false;
                    return;
                }
                Debug.WriteLine(
                    string.Format("TDJ_RFIDHelper.ParseDataToTag  -> parsed = {0}"
                                  , tagInfo));
                TagInfo ti = TagInfo.Parse(tagInfo);
                if (null != ti)
                {
                    this.AddNewTag2Table(ti);
                    //this.bBusy = false;
                    //return;
                }

                //this.tagDeleted(lostDelay);

                i = startIndex + tagLength - 1;
            }
            this.bBusy = false;
        }