コード例 #1
0
 private void RecibeEventoTags(object sender, EventArgs e)
 {
     try
     {
         if (!reader.status)
         {
             return;
         }
         ReadTag tag = ParseEvent((string)sender);
         if (tag != null)
         {
             TagReceived(tag);
         }
     }
     catch (Exception ex)
     {
         log.Error(ex);
     }
 }
コード例 #2
0
        public ReadTag ParseEvent(string sData)
        {
            try
            {
                if (sData.Contains(prefixEventHeader))
                {
                    sData = sData.Substring(prefixLength);
                }
                else
                {
                    return(null);
                }
                sData = sData.Replace(" ", "");
                String[] splitDato = sData.Split(',');
                if (splitDato.Length != 3)
                {
                    return(null);
                }

                ReadTag tag = new ReadTag();
                splitDato[0] = splitDato[0].Replace("0x", "");
                tag.tagEPC   = splitDato[0].Substring(prefixData[0].Length, splitDato[0].Length - prefixData[0].Length - 1);
                tag.tagFolio = getEPCValue(tag.tagEPC.Substring(0, 16));

                if (splitDato[1].Length > prefixData[1].Length)
                {
                    splitDato[1] = splitDato[1].Replace("0x", "");
                    tag.tagUSER  = splitDato[1].Substring(prefixData[1].Length, splitDato[1].Length - prefixData[1].Length - 1);
                    tag.tagVIN   = getEPCValue(tag.tagUSER.Substring(16)).Substring(0, 17);
                }

                tag.anntena  = splitDato[2];
                tag.reader   = ip.ToString();
                tag.dateTime = DateTime.Now.ToString();
                readLogger.Info(tag.ToString());
                return(tag);
            }
            catch
            {
                return(null);
            }
        }