基于读取车载RFID标签自动开关车库门c#算法实现
2012-08-23 16:14
931 查看
最近做物联网自动识别技术,遇到一个算法难题,如下发给大家分享:
1 问题描述
1 问题描述
编码实现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 rule if (!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 Time return false; } } } #endregion #region Fiter by Time readerCfgTagGroup tagsArray = rs.ReaderCfg.tagGroups.Where(p => p.tag.Contains(epc)).FirstOrDefault(); //epc not in config or this tag's tagGroup is disanable ,Submit data if (tagsArray == null || tagsArray.Enabled == false || tagsArray.tag == null || tagsArray.tag.Length == 0) { re = true; } else { DateTime dtNow = DateTime.Now; if (!tagGroupTimeDic.ContainsKey(epc)) { //Submit data re = 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 time if (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 nothing re = false; } } // add/update the reading time. tagGroupTimeDic[epc] = dtNow; } if (!re) { log.InfoFormat("EPC Ignored: {0}", epc); } #endregion return re; } } }
相关文章推荐
- 基于读取车载RFID标签自动开关车库门c#算法实现
- 基于CuDNN如何实现自动选取最优卷积算法?
- 基于COM技术的ATM自动存款机实现(C#版)
- C# 实现自动ADSL拨号(基于bat)
- C#用Activex实现Web客户端读取RFID功能
- 基于灰度世界、完美反射、动态阈值等图像自动白平衡算法的原理、实现及效果
- 基于灰度世界、完美反射、动态阈值等图像自动白平衡算法的原理、实现及效果
- 基于灰度世界、完美反射、动态阈值等图像自动白平衡算法的原理、实现及效果
- 针对新闻标签提取的tf-idf优化算法1.0版本——基于jieba分词实现
- 基于c#实现网站的自动登陆
- C#用Activex实现Web客户端读取RFID功能的代码
- 使用struts2标签,从后台读取数据时实现横向循环然后在自动换行循环
- 基于ViewGroup实现自动换行标签控件
- Otsu最佳全局算法c#实现-基于EmguCV
- 基于折线生成平行线的C#算法实现
- 基于C#代码实现九宫格算法横竖都等于4
- C#通过Activex实现Web客户端读取RFID
- 基于C#实现的开源自动更新程序
- 基于白点检测的数码相机自动白平衡算法实现(Opencv+vs)
- 【VS开发】【图像处理】基于灰度世界、完美反射、动态阈值等图像自动白平衡算法的原理、实现及效果