Esempio n. 1
0
        public Dictionary <String, String> readTags()
        {
            int status = 1;
            //List<string> tagList = new List<string>();
            Dictionary <String, String> tagList = new Dictionary <String, String>();

            //不管读到的是图书还是层架标签,都存储在这里,key为解码后的RFID号,value为类型,比如book或者shelf。
            tagstruct[] tagArray = new tagstruct[maxTagsAtOneRead];
            comsdk.clear_ID_Buff(defaultAddress);
            status = comsdk.gen2_Multi_Identify(defaultAddress, out tagArray);
            //status my return 1,mean read error of nothing to read ,can distrinct it ,i dont know

            /***
             * while (status == 1)
             * {
             *  Thread.Sleep(delayWhenReadNothing);
             *  status = comsdk.gen2_Multi_Identify(defaultAddress, out tagArray);
             * }***/
            //上面注释掉的部分是原来的程序,原有的程序只有当读到数据时才返回结果,现在改为不管有没有读到数据都返回
            int readCount = 1;

            while ((status == 1) && (readCount < 3)) //一定不能一直读,否则串口会无反应,流量太大了
            {
                //Thread.Sleep(5);//不能睡眠,以免导致冲突
                readCount = readCount + 1;
                status    = comsdk.gen2_Multi_Identify(defaultAddress, out tagArray);
            }
            if (status == 1)
            {
                return(tagList);
            }
            //现在的程序改为一直读3次,如果什么都没有读到就返回空的Directory

            for (int i = 0; i < tagArray.Length; i++)
            {
                //this code should examine
                //string tagDataString=rawDataToString(tagArray[i].TagData);
                byte[] userData   = new byte[16]; //解析后,不管是层架标签还是图书,最长为16位
                String decodeData = "";
                //读取的RFID标签为12个比特的数据,书的标签和层架标签解析的起始位不同
                //Array.Copy(tagArray[i].TagData, 4, userData, 0, 8);    //for book only
                //Array.Copy(tagArray[i].TagData, 2, userData, 0, 10);   //for shief only
                if (isBookRFID(tagArray[i].TagData))
                {
                    //Console.WriteLine("book");
                    Array.Copy(tagArray[i].TagData, 4, userData, 0, 8);
                    decodeData = DecodedOfBookRfid(userData, 8);
                    tagList.Add(decodeData, "book");
                }
                if (isShelfRFID(tagArray[i].TagData))
                {
                    //Console.WriteLine("shelf");
                    Array.Copy(tagArray[i].TagData, 2, userData, 0, 10);   //for shief only
                    decodeData = DecodedOfShelfRfid(userData, 10);
                    tagList.Add(decodeData, "shelf");
                }
            }
            return(tagList);
        }
Esempio n. 2
0
        public Dictionary<String, String> readTags()
        {
            int status = 1;
            //List<string> tagList = new List<string>();
            Dictionary<String, String> tagList = new Dictionary<String, String>();
            //不管读到的是图书还是层架标签,都存储在这里,key为解码后的RFID号,value为类型,比如book或者shelf。
            tagstruct[] tagArray = new tagstruct[maxTagsAtOneRead];
            comsdk.clear_ID_Buff(defaultAddress);
            status = comsdk.gen2_Multi_Identify(defaultAddress, out tagArray);
            //status my return 1,mean read error of nothing to read ,can distrinct it ,i dont know
            /***
            while (status == 1)
            {
                Thread.Sleep(delayWhenReadNothing);
                status = comsdk.gen2_Multi_Identify(defaultAddress, out tagArray);
            }***/
            //上面注释掉的部分是原来的程序,原有的程序只有当读到数据时才返回结果,现在改为不管有没有读到数据都返回
            int readCount=1;
            while ((status == 1)&&(readCount<3)) //一定不能一直读,否则串口会无反应,流量太大了
            {
                //Thread.Sleep(5);//不能睡眠,以免导致冲突
                readCount = readCount + 1; 
                status = comsdk.gen2_Multi_Identify(defaultAddress, out tagArray);
            }
            if (status == 1)
            {
                return tagList;
            }
            //现在的程序改为一直读3次,如果什么都没有读到就返回空的Directory

            for (int i = 0; i < tagArray.Length; i++)
            {
                //this code should examine
                //string tagDataString=rawDataToString(tagArray[i].TagData);
                byte[] userData = new byte[16];  //解析后,不管是层架标签还是图书,最长为16位
                String decodeData = "";
                //读取的RFID标签为12个比特的数据,书的标签和层架标签解析的起始位不同
                //Array.Copy(tagArray[i].TagData, 4, userData, 0, 8);    //for book only
                //Array.Copy(tagArray[i].TagData, 2, userData, 0, 10);   //for shief only 
                if (isBookRFID(tagArray[i].TagData))
                {
                    //Console.WriteLine("book");
                    Array.Copy(tagArray[i].TagData, 4, userData, 0, 8);
                    decodeData = DecodedOfBookRfid(userData, 8);
                    tagList.Add(decodeData, "book");
                }
                if (isShelfRFID(tagArray[i].TagData))
                {
                    //Console.WriteLine("shelf");
                    Array.Copy(tagArray[i].TagData, 2, userData, 0, 10);   //for shief only 
                    decodeData = DecodedOfShelfRfid(userData, 10);
                    tagList.Add(decodeData, "shelf");
                }
            }
            return tagList;

        }
Esempio n. 3
0
 public List<string> readTags()
 {
     int status=1;
     List<string> tagList=new List<string>();
     tagstruct[] tagArray=new tagstruct[maxTagsAtOneRead];
     status=comsdk.gen2_Multi_Identify(defaultAddress, out tagArray);
     //status my return 1,mean read error of nothing to read ,can distrinct it ,i dont know
     for (int i = 0; i < tagArray.Length; i++)
     {
         string tagDataString=rawDataToString(tagArray[i].TagData);
         tagList.Add(tagDataString);
     }
     return tagList;
 }
Esempio n. 4
0
        public Dictionary <string, string> readTags()
        {
            int status = 1;
            //List<string> tagList = new List<string>();
            Dictionary <string, string> tagList = new Dictionary <string, string>();

            //不管读到的是图书还是层架标签,都存储在这里,key为解码后的RFID号,value为类型,比如book或者shelf。
            tagstruct[] tagArray = new tagstruct[maxTagsAtOneRead];
            comsdk.clear_ID_Buff(defaultAddress);
            status = comsdk.gen2_Multi_Identify(defaultAddress, out tagArray);
            //status my return 1,mean read error of nothing to read ,can distrinct it ,i dont know
            while (status == 1)
            {
                Thread.Sleep(delayWhenReadNothing);
                status = comsdk.gen2_Multi_Identify(defaultAddress, out tagArray);
            }

            for (int i = 0; i < tagArray.Length; i++)
            {
                //this code should examine
                //string tagDataString=rawDataToString(tagArray[i].TagData);
                byte[] userData   = new byte[16]; //解析后,不管是层架标签还是图书,最长为16位
                string decodeData = "";
                //读取的RFID标签为12个比特的数据,书的标签和层架标签解析的起始位不同
                //Array.Copy(tagArray[i].TagData, 4, userData, 0, 8);    //for book only
                //Array.Copy(tagArray[i].TagData, 2, userData, 0, 10);   //for shief only
                if (isRFIDBook(tagArray[i].TagData))
                {
                    //Console.WriteLine("book");
                    Array.Copy(tagArray[i].TagData, 4, userData, 0, 8);
                    decodeData = DecodedOfBookRfid(userData, 8);
                    tagList.Add(decodeData, "book");
                }
                if (isShelfRFID(tagArray[i].TagData))
                {
                    //Console.WriteLine("shelf");
                    Array.Copy(tagArray[i].TagData, 2, userData, 0, 10);   //for shief only
                    decodeData = DecodedOfShelfRfid(userData, 10);
                    tagList.Add(decodeData, "shelf");
                }
            }
            return(tagList);
        }
Esempio n. 5
0
        public Dictionary<string,string> readTags()
        {
            int status = 1;
            //List<string> tagList = new List<string>();
            Dictionary<string, string> tagList = new Dictionary<string, string>(); 
            //不管读到的是图书还是层架标签,都存储在这里,key为解码后的RFID号,value为类型,比如book或者shelf。
            tagstruct[] tagArray = new tagstruct[maxTagsAtOneRead];
            comsdk.clear_ID_Buff(defaultAddress);
            status = comsdk.gen2_Multi_Identify(defaultAddress, out tagArray);
            //status my return 1,mean read error of nothing to read ,can distrinct it ,i dont know
            while (status == 1)
            {
                Thread.Sleep(delayWhenReadNothing);
                status = comsdk.gen2_Multi_Identify(defaultAddress, out tagArray);
            }

            for (int i = 0; i < tagArray.Length; i++)
            {
                //this code should examine
                //string tagDataString=rawDataToString(tagArray[i].TagData);
                byte[] userData = new byte[16];  //解析后,不管是层架标签还是图书,最长为16位
                string decodeData = "";
                //读取的RFID标签为12个比特的数据,书的标签和层架标签解析的起始位不同
                //Array.Copy(tagArray[i].TagData, 4, userData, 0, 8);    //for book only
                //Array.Copy(tagArray[i].TagData, 2, userData, 0, 10);   //for shief only 
                if (isRFIDBook(tagArray[i].TagData))
                {
                    //Console.WriteLine("book");
                    Array.Copy(tagArray[i].TagData, 4, userData, 0, 8);
                    decodeData = DecodedOfBookRfid(userData, 8);
                    tagList.Add(decodeData,"book");
                }
                if(isShelfRFID(tagArray[i].TagData))
                {
                    //Console.WriteLine("shelf");
                    Array.Copy(tagArray[i].TagData, 2, userData, 0, 10);   //for shief only 
                    decodeData = DecodedOfShelfRfid(userData, 10);
                    tagList.Add(decodeData,"shelf");
                }     
            }
            return tagList;

        }