Example #1
0
        public static TagInfo Parse(string tagInfo)
        {
            TagInfo          ti     = new TagInfo();
            emuTagInfoFormat format = emuTagInfoFormat.standard;

            if (tagInfo.Substring(0, 4) == "Disc")
            {
                format = emuTagInfoFormat.standard;
            }
            else
            {
                format = emuTagInfoFormat.simple;
            }

            /*
             * Disc:2000/02/28 20:01:51, Last:2000/02/28 20:07:42, Count:00019, Ant:02, Type:04, Tag:300833B2DDD906C000000000
             *
             */
            if (format == emuTagInfoFormat.standard)
            {
                string[] arrays = tagInfo.Split(',');
                if (arrays.Length < 6)//信息不全
                {
                    return(null);
                }
                string temp     = arrays[2];
                string strCount = arrays[2].Substring(temp.IndexOf(':') + 1);
                try
                {
                    ti.readCount = int.Parse(strCount);
                }
                catch (System.Exception ex)
                {
                }
                temp         = arrays[3];
                ti.antennaID = temp.Substring(temp.IndexOf(':') + 1).Trim();
                if (ti.antennaID == "03" || ti.antennaID == "00" || ti.antennaID == "05" || ti.antennaID == "06" || ti.antennaID == "07")
                {
                    return(null);
                }
                temp       = arrays[4];
                ti.tagType = temp.Substring(temp.IndexOf(':') + 1).Trim();
                temp       = arrays[5];
                ti.epc     = temp.Substring(temp.IndexOf(':') + 1).Trim();
                DateTime dt = DateTime.Now;
                TimeSpan ts = dt - Program.timeBase;
                ti.getTime = dt.ToString("yyyy-MM-dd HH:mm:ss");
                //ti.milliSecond = dt.Millisecond;
                ti.milliSecond = (long)ts.TotalMilliseconds;

                //  Debug.WriteLine(ti.toString());
            }


            //过滤无效天线编号


            return(ti);
        }
Example #2
0
        public static TagInfo Parse(string tagInfo)
        {
            Debug.WriteLine("TagInfo -> Parse  " + tagInfo);
            TagInfo ti = new TagInfo();

            try
            {
                emuTagInfoFormat format = emuTagInfoFormat.标准;
                if (tagInfo.Substring(0, 4) == "Disc")
                {
                    format = emuTagInfoFormat.标准;
                }
                else
                {
                    format = emuTagInfoFormat.简化;
                }

                /*
                 * Disc:2000/02/28 20:01:51, Last:2000/02/28 20:07:42, Count:00019, Ant:02, Type:04, Tag:300833B2DDD906C000000000
                 *
                 */
                if (format == emuTagInfoFormat.标准)
                {
                    string[] arrays = tagInfo.Split(',');
                    if (arrays.Length < 6)//信息不全
                    {
                        return(null);
                    }

                    string temp = arrays[1];
                    ti.getTime = temp.Substring(temp.IndexOf(':') + 1).Trim();

                    temp = arrays[2];
                    string strCount = arrays[2].Substring(temp.IndexOf(':') + 1);
                    try
                    {
                        ti.readCount = int.Parse(strCount);
                    }
                    catch (System.Exception ex)
                    {
                    }
                    temp         = arrays[3];
                    ti.antennaID = temp.Substring(temp.IndexOf(':') + 1).Trim();

                    //这里不再做天线误读的判断,因为误读至少说明这个标签被读到了,这个信息还有用
                    //if (ti.antennaID != "01" && ti.antennaID != "02" && ti.antennaID != "04" && ti.antennaID != "08")
                    //{
                    //    return null;
                    //}

                    temp       = arrays[4];
                    ti.tagType = temp.Substring(temp.IndexOf(':') + 1).Trim();
                    temp       = arrays[5];
                    ti.epc     = temp.Substring(temp.IndexOf(':') + 1).Trim();
                    DateTime dt = DateTime.Now;
                    TimeSpan ts = dt - PublicConfig.staticClass.timeBase;
                    //ti.getTime = dt.ToString("yyyy-MM-dd HH:mm:ss");
                    //ti.milliSecond = dt.Millisecond;
                    ti.milliSecond = (long)ts.TotalMilliseconds;

                    //  Debug.WriteLine(ti.toString());
                }


#if TRACE
                Debug.WriteLine("TagInfo <- Parse  ");
#endif
            }
            catch (System.Exception ex)
            {
                Debug.WriteLine("TagInfo <- Parse error   " + ex.Message);
            }
            return(ti);
        }