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

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

impinj固定式阅读器数据解析中Rfid筛选器实现

發(fā)布時(shí)間:2025/4/5 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 impinj固定式阅读器数据解析中Rfid筛选器实现 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

在做物聯(lián)網(wǎng)倉庫管理中用到RFID標(biāo)簽進(jìn)行盤點(diǎn)和出庫掃描檢查,其中在倉庫門口的impinj固定式閱讀器對進(jìn)出的貨物進(jìn)行檢測,在讀取rfid時(shí)候需要對epc標(biāo)簽進(jìn)行過濾,實(shí)現(xiàn)2個(gè)過濾器,第一個(gè)是正則過濾,第二個(gè)是時(shí)間,在60秒內(nèi)只讀取一次,默認(rèn)tag是一秒讀200次,下面是過濾器的實(shí)現(xiàn):輸入

dataSource--tag信息類

device---設(shè)備配置類(包含讀取時(shí)間和過濾條件的xml,在最后)

???????

???????

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 Data
{
??? public 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)
??????? {
??????????? ReaderSite rs = this.device as ReaderSite;
??????????? TagData tag = dataSource as TagData;
??????????? string epc = tag.Data["Epc"].ToString();
??????????? bool re = false;

??????????? #region Fiter by Regex rule
??????????? try
??????????? {
??????????????? if (!string.IsNullOrEmpty(rs.ReaderCfg.filter.rule.Value) && rs.ReaderCfg.filter.rule.operation != null)
??????????????? {
??????????????????? if (rs.ReaderCfg.filter.rule.operation == readerCfgFilterRuleOperation.Submit)
??????????????????? {
??????????????????????? if (!Regex.IsMatch(epc, rs.ReaderCfg.filter.rule.Value))
??????????????????????? {
??????????????????????????? return false;
??????????????????????? }
??????????????????????? else
??????????????????????? {
??????????????????????????? //do nothing
??????????????????????? }
??????????????????? }
??????????????????? else if (rs.ReaderCfg.filter.rule.operation == readerCfgFilterRuleOperation.None)
??????????????????? {
??????????????????????? if (Regex.IsMatch(epc, rs.ReaderCfg.filter.rule.Value))
??????????????????????? {
??????????????????????????? return false;
??????????????????????? }
??????????????????????? else
??????????????????????? {
??????????????????????????? //do nothing
??????????????????????? }
??????????????????? }
??????????????? }
??????????? }
??????????? catch(Exception ex)
??????????? {
??????????????? log.ErrorFormat("FilterEpcByConf: do fiter by rule error: {0}", ex.Message);
??????????? }
??????????? #endregion

??????????? #region Fiter by Time
??????????? try
??????????? {
??????????????? string[] epcGroup = null;
??????????????? int readingTimeout = 0;
??????????????? //epc not in config ,Submit datas
??????????????? foreach (readerCfgTagGroup rg in rs.ReaderCfg.tagGroups)
??????????????? {
??????????????????? if (rg.Enabled == true && rg.Value.Contains(epc))
??????????????????? {
??????????????????????? epcGroup = rg.Value.Split(';');
??????????????????????? readingTimeout = rg.readingTimeout;
??????????????????????? break;
??????????????????? }
??????????????? }
??????????????? //epc not in config or this tag's tagGroup is disanable ,Submit data
??????????????? if (epcGroup == null || epcGroup.Length == 0)
??????????????? {
??????????????????? return true;
??????????????? }

??????????????? if (!tagGroupTimeDic.ContainsKey(epc))
??????????????? {
??????????????????? //Submit data
??????????????????? re = true;
??????????????????? tagGroupTimeDic.Add(epc, DateTime.Now);

??????????????? }
??????????????? else
??????????????? {
??????????????????? DateTime dtNow = DateTime.Now;
??????????????????? DateTime epcTime = tagGroupTimeDic[epc];
??????????????????? //find max time
??????????????????? foreach (string epcItem in epcGroup)
??????????????????? {
??????????????????????? if (tagGroupTimeDic.ContainsKey(epcItem))
??????????????????????? {
??????????????????????????? epcTime = tagGroupTimeDic[epcItem] < epcTime ? tagGroupTimeDic[epcItem] : epcTime;
??????????????????????? }
??????????????????? }
??????????????????? //check time
??????????????????? if (dtNow.Subtract(epcTime).TotalMilliseconds > readingTimeout)
??????????????????? {
??????????????????????? re = true;
??????????????????????? foreach (string epcItem in epcGroup)
??????????????????????? {
??????????????????????????? if (tagGroupTimeDic.ContainsKey(epcItem))
??????????????????????????? {
??????????????????????????????? tagGroupTimeDic.Remove(epcItem);
??????????????????????????? }
??????????????????????? }
??????????????????????? tagGroupTimeDic[epc] = dtNow;
??????????????????? }
??????????????????? else
??????????????????? {
??????????????????????? //do nothing
??????????????????????? re = false;
??????????????????? }
??????????????? }
??????????? }
??????????? catch (Exception ex)
??????????? {
??????????????? log.ErrorFormat("FilterEpcByConf: do fiter by rule error: {0}", ex.Message);
??????????? }
??????????? #endregion

??????????? return re;
??????? }
??? }
}

轉(zhuǎn)載于:https://www.cnblogs.com/sung/archive/2012/08/22/2651086.html

總結(jié)

以上是生活随笔為你收集整理的impinj固定式阅读器数据解析中Rfid筛选器实现的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。