Ejemplo n.º 1
0
            /// <summary>
            ///
            /// </summary>
            public static bool CheckList(TagReadDataEventArgs e)
            {
                //Check dt if EPC already exist.
                if (BookListing.getBookList().Any(p => p.EPC == e.TagReadData.EpcString))
                {
                    return(false);
                }

                if (UnknownList.Any(p => p.EPC == e.TagReadData.EpcString))
                {
                    var list  = UnknownList.First(f => f.EPC == e.TagReadData.EpcString);
                    var index = UnknownList.IndexOf(list);
                    UnknownList[index].timeStamp = e.TagReadData.Time.ToString();
                    UnknownList[index].RSSI      = e.TagReadData.Rssi.ToString();

                    // double distance =  Math.Pow((-30 - Double.Parse(UnknownList[index].RSSI)) / (10 * 2), 10);
                    // UnknownList[index].RSSI = distance.ToString();

                    Console.WriteLine("[Update Unknown Tag] " + e.TagReadData.EpcString + e.TagReadData.Time.ToString() + " -  " + e.TagReadData.Rssi);
                    return(true);
                }
                else
                {
                    addUnknownRFIDItem(e.TagReadData.EpcString, e.TagReadData.Time.ToString(), e.TagReadData.Rssi.ToString());
                    return(false);
                }
            }
Ejemplo n.º 2
0
            /// <summary>
            ///
            /// </summary>
            public static bool CheckList(TagReadDataEventArgs e)
            {
                DataTable dt = DBHelper.GetDT();

                foreach (DataRow row in dt.Rows)
                {
                    if (row["Book_RFID_EPC"].ToString() == e.TagReadData.EpcString)
                    {
                        DBHelper.updateBook(e);
                        Console.WriteLine("Update Book call from checklist");
                    }
                }
                if (BookList.Any(p => p.EPC == e.TagReadData.EpcString))
                {
                    var list  = BookList.First(f => f.EPC == e.TagReadData.EpcString);
                    var index = BookList.IndexOf(list);
                    BookList[index].timeStamp = e.TagReadData.Time.ToString();
                    BookList[index].RSSI      = e.TagReadData.Rssi.ToString();
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
Ejemplo n.º 3
0
        public void tagsReportedTM(Object sender, TagReadDataEventArgs taginfo)
        {
            if (!isInventory)
            {
                return;
            }

            if (taginfo == null || taginfo.TagReadData == null || string.IsNullOrEmpty(taginfo.TagReadData.EpcString))
            {
                return;
            }

            string epc = taginfo.TagReadData.EpcString;

            if (!string.IsNullOrEmpty(epc))
            {
                epc = epc.ToUpper();
            }

            if (!epcList.Contains(epc))
            {
                lastReadTime = DateTime.Now;
                epcList.Add(epc);
            }
        }
Ejemplo n.º 4
0
        public void Reader_OnTagReported(Object sender, TagReadDataEventArgs taginfo)
        {
            if (!isInventory)
            {
                return;
            }
            if (taginfo == null || taginfo.TagReadData == null || string.IsNullOrEmpty(taginfo.TagReadData.EpcString))
            {
                return;
            }
            if (!epcList.Contains(taginfo.TagReadData.EpcString))
            {
                lastReadTime = DateTime.Now;
                epcList.Add(taginfo.TagReadData.EpcString);

                /*
                 * TagDetailInfo tag = GetTagDetailInfoByEpc(taginfo.Epc);
                 * if (tag != null)   //合法EPC
                 * {
                 *  tagDetailList.Add(tag);
                 *  if (!tag.IsAddEpc)   //主条码
                 *      mainEpcNumber++;
                 *  else
                 *      addEpcNumber++;
                 * }
                 * else
                 * {
                 *  //累加非法EPC数量
                 *  errorEpcNumber++;
                 * }
                 * UpdateView();
                 */
            }
        }
        private void OnTagRead(object sender, TagReadDataEventArgs e)
        {
            bool newEpc = false;
            int  epccount;

            myEpc   = e.TagReadData.ToString().Substring(4, 24).ToUpper();
            myEpcID = myEpc.Substring(0, 2).ToUpper();
            myRssi  = e.TagReadData.Rssi;
            //int temp;


            if (myEPClist.Contains(myEpcID))
            {
                index = myEPClist.IndexOf(myEpcID);
                myEPClistcount[index] = myEPClistcount[index] + 1;
            }
            else
            {
                myEPClist.Add(myEpcID);
                myEPClistcount.Add(0);
                index  = myEPClist.IndexOf(myEpcID);
                newEpc = true;
            }


            try
            {
                epccount = myEPClistcount[index];
                updateFirebase(epccount, newEpc);
                //exportFirebase(epccount);
            }
            catch { }
            //Thread.Sleep(1000);
        }
Ejemplo n.º 6
0
 private void Asnyc_Handler(object sender, TagReadDataEventArgs e)
 {
     if (code != int.Parse(e.TagReadData.EpcString.ToString()))
     {
         code = int.Parse(e.TagReadData.EpcString.ToString());
         WhenValueChange();
     }
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Function that save the Tag Data inDB;
        /// </summary>
        /// <param name="read"></param>
        void PrintTagRead(Object sender, TagReadDataEventArgs e)
        {
            tagdb.Add();
            BLL bll = new BLL();

            countEPC = tagdb.TagList.Count.ToString();
            bll.WriteListEPCToDB(tagdb, ((int)dtReaders.Rows[row][0]));
        }
Ejemplo n.º 8
0
 private void OnTagRead(object sender, TagReadDataEventArgs e)
 {
     //this.sw.WriteLine(e.TagReadData.ToString().Substring(5,28) + "\\n");
     myEpc  = e.TagReadData.ToString().Substring(5, 23);
     myRssi = e.TagReadData.Rssi;
     updateFirebase();
     //sw.Dispose();
 }
Ejemplo n.º 9
0
 public void TagRead(Object sender, TagReadDataEventArgs e)
 {
     // Test first byte of tag EPC
     byte[] epcBytes = e.TagReadData.Tag.EpcBytes;
     if ((0 < epcBytes.Length) &&
         (e.TagReadData.Tag.EpcBytes[0] == ToMatch))
     {
         Matched++;
     }
     else
     {
         NonMatched++;
     }
 }
Ejemplo n.º 10
0
        public void tagsReportedTM(Object sender, TagReadDataEventArgs taginfo)
        {
            if (taginfo == null || taginfo.TagReadData == null || string.IsNullOrEmpty(taginfo.TagReadData.EpcString))
            {
                return;
            }

            string epc = taginfo.TagReadData.EpcString;

            if (!string.IsNullOrEmpty(epc))
            {
                epc = epc.ToUpper();
            }
            this.OnTagReported?.Invoke(epc);
        }
Ejemplo n.º 11
0
        private void Rt_TagRead(object sender, TagReadDataEventArgs e)
        {
            Dispatcher.BeginInvoke(new ThreadStart(delegate()
            {
                tagdb.Add(e.TagReadData);
                //Console.WriteLine("--> {0}", e.TagReadData);
                TagResults.dgTagResults.ItemsSource = null;
                TagResults.dgTagResults.ItemsSource = tagdb.TagList;
            }));

            Dispatcher.BeginInvoke(new ThreadStart(delegate()
            {
                uniqueReadCount_label.Content = tagdb.UniqueTagCount;
                totalReadCount_label.Content  = tagdb.TotalTagCount;
            }));
        }
Ejemplo n.º 12
0
        void _ObjReader_TagRead(object sender, TagReadDataEventArgs e)
        {
            try
            {
                if (_form.InvokeRequired)
                {
                    _form.Invoke(new InsertItemDelegate(_ObjReader_TagRead), sender, e);
                }
                else
                {
                    if (taginputbox != null)
                    {
                        //playBeepSound();
                        if (e.TagReadData != null)
                        {
                            try
                            {
                                taginputbox.Text = EPCID;
                                //taginputbox.Text = e.TagReadData.EpcString;
                                logger.Info(string.Format("EPC={0}", EPCID));
                            }
                            catch (Exception ex)
                            {
                                logger.Error(ex.Message, ex);
                                taginputbox.Text = "";
                            }

                            taginputbox.Enabled = false;
                            taginputbox.Visible = true;
                        }


                        if (OnAfterTagRead != null)
                        {
                            OnAfterTagRead(sender, e);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                writeErrorLog(ex.Message, ex);
                //_ObjReader_ReadException(sender, new ReaderExceptionEventArgs(new ReaderException(ex.Message, ex)));
                this.DisableReader();
                //throw ex;
            }
        }
Ejemplo n.º 13
0
        public void Reader_OnTagReported(Object sender, TagReadDataEventArgs taginfo)
        {
            if (!isInventory)
            {
                return;
            }
            if (taginfo == null || taginfo.TagReadData == null || string.IsNullOrEmpty(taginfo.TagReadData.EpcString))
            {
                return;
            }
            if (!epcList.Contains(taginfo.TagReadData.EpcString))
            {
                lastReadTime = DateTime.Now;
                epcList.Add(taginfo.TagReadData.EpcString);

                UpdateView();
            }
        }
Ejemplo n.º 14
0
 /// <summary>
 /// Function that processes the Tag Data produced by StartReading();
 /// </summary>
 /// <param name="read"></param>
 void PrintTagRead(Object sender, TagReadDataEventArgs e)
 {
     BeginInvoke((Action) delegate
     {
         if (properties["audiblealert"].ToLower() == "yes")
         {
             if (readTriggeredByTap)
             {
                 playBeepSound();
             }
         }
         TagReadData read = e.TagReadData;
         UpdateReadTagIDBox(new TagReadData[] { read });
         if (overTempFlag)
         {
             this.BeginInvoke(new OverTemperatureChange(ShowOverTemperature));
         }
     });
 }
Ejemplo n.º 15
0
 public void TagRead(Object sender, TagReadDataEventArgs e)
 {
     lock (SeenTags.SyncRoot)
     {
         try
         {
             TagData t   = e.TagReadData.Tag;
             string  epc = t.EpcString;
             if (!SeenTags.ContainsKey(epc))
             {
                 Console.WriteLine("New tag: " + t.ToString());
                 SeenTags.Add(epc, null);
             }
         }
         catch (ArgumentException ex)
         {
             Console.WriteLine("EPC already added");
         }
     }
 }
Ejemplo n.º 16
0
        //北京加密 天津加密 不加密 湖南加密

        public void TagsReadHandler(object sender, TagReadDataEventArgs e)
        {
            //去掉每个单位空一格
            if (e.TagReadData.EpcString.Length != 24)
            {
                return;
            }

            //SSEncryptor.SSEncrypt enc2 = new SSEncryptor.SSEncrypt(22, 24, "");
            //string epc = enc2.Decryptor(e.TagReadData.EpcString);
            string epc = e.TagReadData.EpcString;

            if (!string.IsNullOrWhiteSpace(epc))
            {
                if (TagsReportedEvent != null)
                {
                    TagsReportedEvent(epc);
                }
            }
        }
Ejemplo n.º 17
0
 private static void r_tagRead(object sender, TagReadDataEventArgs e)
 {
     Console.WriteLine("Background read: " + e.TagReadData);
     if (0 < e.TagReadData.Data.Length)
     {
         if (e.TagReadData.isErrorData)
         {
             // In case of error, show the error to user. Extract error code.
             byte[] errorCodeBytes = e.TagReadData.Data;
             int    offset         = 0;
             //converts byte array to int value
             int errorCode = (((errorCodeBytes[offset] & 0xFF) << 8) | ((errorCodeBytes[offset + 1] & 0xFF) << 0));
             Console.WriteLine("Embedded Tag operation failed. Error: " + ReaderCodeException.faultCodeToMessage(errorCode));
         }
         else
         {
             Console.WriteLine("Data[" + e.TagReadData.dataLength + "]: " + ByteFormat.ToHex(e.TagReadData.Data, "", " "));
         }
     }
 }
Ejemplo n.º 18
0
        /// <summary>
        ///
        /// </summary>
        private void OnTagRead(Object sender, TagReadDataEventArgs e)
        {
            bool check_Unknown = false;
            bool check_Book    = false;

            try
            {
                Application.Current.Dispatcher.BeginInvoke(
                    DispatcherPriority.Background,
                    new Action(() =>
                {
                    if (toggelReader == false)
                    {
                        Console.WriteLine("Read Booklisting End");
                        reader.StopReading();
                        return;
                    }
                    check_Unknown = UnknownRFIDList.CheckList(e);
                    UpdateUnkownRFID_DG(check_Unknown);
                }));

                Application.Current.Dispatcher.BeginInvoke(
                    DispatcherPriority.Background,
                    new Action(() =>
                {
                    if (toggelReader == false)
                    {
                        Console.WriteLine("Read Booklisting End");
                        reader.StopReading();
                        return;
                    }

                    check_Book = BookListing.CheckList(e);
                    UpdateBook_DG(check_Book);
                }));
            }
            catch (Exception ex) {
                Console.WriteLine(ex);
            }
        }
Ejemplo n.º 19
0
        public void Reader_OnTagReported(Object sender, TagReadDataEventArgs taginfo)
        {
            if (!isInventory)
            {
                return;
            }
            if (taginfo == null || taginfo.TagReadData == null || string.IsNullOrEmpty(taginfo.TagReadData.EpcString) || ignore(taginfo.TagReadData.EpcString))
            {
                return;
            }
            if (!epcList.Contains(taginfo.TagReadData.EpcString))
            {
                lastReadTime = DateTime.Now;
                epcList.Add(taginfo.TagReadData.EpcString);

                TagDetailInfo tag = GetTagDetailInfoByEpc(taginfo.TagReadData.EpcString);
                if (tag != null)   //合法EPC
                {
                    tagDetailList.Add(tag);
                    if (!tag.IsAddEpc)   //主条码
                    {
                        mainEpcNumber++;
                    }
                    else
                    {
                        addEpcNumber++;
                    }
                }
                else
                {
                    //累加非法EPC数量
                    errorEpcNumber++;
                }
                UpdateView();
            }
        }
Ejemplo n.º 20
0
        public static void updateBook(TagReadDataEventArgs e)
        {
            String query = "Update Book SET Book_RFID_TimeStamp = @Book_RFID_TimeStamp, Book_RFID_RSSI = @Book_RFID_RSSI where Book_RFID_EPC = '" + e.TagReadData.EpcString + "'";

            try
            {
                if (connection != null && connection.State == ConnectionState.Closed)
                {
                    Console.WriteLine("[Update Book] " + e.TagReadData.EpcString + e.TagReadData.Time.ToString() + " -  " + e.TagReadData.Rssi);
                    connection.Open();
                    cmd = new MySqlCommand(query, connection);

                    cmd.Parameters.AddWithValue("@Book_RFID_TimeStamp", e.TagReadData.Time.ToString());
                    cmd.Parameters.AddWithValue("@Book_RFID_RSSI", e.TagReadData.Rssi);
                    cmd.ExecuteNonQuery();

                    connection.Close();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Ejemplo n.º 21
0
 private static void Reader_TagRead(object sender, TagReadDataEventArgs e)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 22
0
        static void PrintTagreads(Object sender, TagReadDataEventArgs e)
        {
            Reader r = (Reader)sender;

            Console.WriteLine("Background read:" + (string)r.ParamGet("/reader/uri") + e.TagReadData);
        }