日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > C# >内容正文

C#

基于读取车载RFID标签自动开关车库门c#算法实现

發布時間:2024/4/14 C# 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 基于读取车载RFID标签自动开关车库门c#算法实现 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

最近做物聯網自動識別技術,遇到一個算法難題,如下發給大家分享:

1 問題描述

2.流程圖稍后上,

3.編碼實現

編碼實現using System; using System.Collections.Generic; using System.Linq; using System.Text; using log4net; using Org.LLRP.LTK.LLRPV1; using Org.LLRP.LTK.LLRPV1.DataType; using Org.LLRP.LTK.LLRPV1.Impinj; using System.Collections.Concurrent; using System.Diagnostics; using System.Collections.ObjectModel; using com.dn.Edgenode.Plugins.Data; using com.dn.Edgenode.Plugins.Rfid.Impinj; using com.dn.Edgenode.Plugins.Rfid.Impinj.Config; using System.Text.RegularExpressions;namespace com.dn. {internal class TagFilter : Filter<NormalizedData>{private static ILog log = log4net.LogManager.GetLogger("com.dn.Edgenode.Log.Engine.Plugin");private Dictionary<string, DateTime> tagGroupTimeDic = new Dictionary<string, DateTime>();public object device { get; set; }public override Func<NormalizedData, bool> Condition{get{return FilterEpcByConf;}set{throw new NotImplementedException();}}private bool FilterEpcByConf(NormalizedData dataSource){bool re = false;ReaderSite rs = this.device as ReaderSite;string epc = dataSource.Data["Epc"].ToString();#region Fiter by Regex ruleif (!string.IsNullOrEmpty(rs.ReaderCfg.filter.rule.Value) && !rs.ReaderCfg.filter.rule.operation.Equals(null)){if (Regex.IsMatch(epc, rs.ReaderCfg.filter.rule.Value)){if (rs.ReaderCfg.filter.rule.operation == readerCfgFilterRuleOperation.Submit){//do nothing// continue Fiter by Time.}else if (rs.ReaderCfg.filter.rule.operation == readerCfgFilterRuleOperation.None){//Ignored Fiter by Timereturn false;}}}#endregion#region Fiter by TimereaderCfgTagGroup tagsArray = rs.ReaderCfg.tagGroups.Where(p => p.tag.Contains(epc)).FirstOrDefault();//epc not in config or this tag's tagGroup is disanable ,Submit dataif (tagsArray == null || tagsArray.Enabled == false || tagsArray.tag == null || tagsArray.tag.Length == 0){re = true;}else{DateTime dtNow = DateTime.Now;if (!tagGroupTimeDic.ContainsKey(epc)){//Submit datare = true;}else{DateTime epcTime = tagGroupTimeDic[epc];//find max time, it is the last time of reading the any of tags in the group.foreach (string epcItem in tagsArray.tag){if (tagGroupTimeDic.ContainsKey(epcItem)){epcTime = tagGroupTimeDic[epcItem] > epcTime ? tagGroupTimeDic[epcItem] : epcTime;}}//check timeif (dtNow.Subtract(epcTime).TotalMilliseconds > tagsArray.readingTimeout){re = true;// the timespan is greater than reading timeout, it means the group of tags has left the reader before already.// so, remove all.(so the act will be as the same as the firs seen of them for the reader.)foreach (string epcItem in tagsArray.tag){if (tagGroupTimeDic.ContainsKey(epcItem)){tagGroupTimeDic.Remove(epcItem);}}}else{//do nothingre = false;}}// add/update the reading time.tagGroupTimeDic[epc] = dtNow;}if (!re){log.InfoFormat("EPC Ignored: {0}", epc);}#endregionreturn re;}} }

?

轉載于:https://www.cnblogs.com/sung/archive/2012/08/23/2652647.html

總結

以上是生活随笔為你收集整理的基于读取车载RFID标签自动开关车库门c#算法实现的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。