forked from wenjy/HighWayIot
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
2.2 KiB
C#
80 lines
2.2 KiB
C#
using HighWayIot.Rfid.Entity;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace HighWayIot.Rfid
|
|
{
|
|
public class RfidDataAnalyse
|
|
{
|
|
/// <summary>
|
|
/// 02H时间段盘点发送
|
|
/// </summary>
|
|
/// <param name="millisecond">盘点时间毫秒数</param>
|
|
/// <returns></returns>
|
|
public byte[] Send02H(ushort millisecond)
|
|
{
|
|
byte[] bytes = BitConverter.GetBytes(millisecond);
|
|
|
|
BaseSendDataEntity entity = new BaseSendDataEntity()
|
|
{
|
|
Code = 0x02,
|
|
Data = bytes
|
|
};
|
|
|
|
return BaseRFIDDataAnalyse.BaseSendDataAnalyse(entity);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 接受02H盘点数据 (默认EPC 12位)
|
|
/// </summary>
|
|
/// <param name="bytes"></param>
|
|
/// <returns></returns>
|
|
public Receive02HEntity Receive02H(byte[] bytes)
|
|
{
|
|
BaseReciveDataEntity recive = BaseRFIDDataAnalyse.BaseReceiveAnalyse(bytes);
|
|
byte[] DataBytes = recive.Data;
|
|
|
|
Receive02HEntity entity = new Receive02HEntity();
|
|
|
|
//取读到多少个标签
|
|
int index = 0;
|
|
entity.TagCount = DataBytes[index];
|
|
index++;
|
|
|
|
//取每一个读到的标签
|
|
entity.Data = new List<Single02HReceive>();
|
|
for (int i = 0; i < entity.TagCount; i++)
|
|
{
|
|
Single02HReceive EPCData = new Single02HReceive();
|
|
|
|
//取单个标签读取的次数
|
|
EPCData.Count = DataBytes[index];
|
|
index++;
|
|
|
|
//取信号强度
|
|
EPCData.RSSI = DataBytes[index];
|
|
index++;
|
|
|
|
//取天线端口
|
|
EPCData.Ant = DataBytes[index];
|
|
index++;
|
|
|
|
//取EPC区域
|
|
Array.Copy(DataBytes, index, EPCData.PC, 0, 2);
|
|
index += 2;
|
|
|
|
//取读到标签的EPC
|
|
Array.Copy(DataBytes, index, EPCData.EPC, 0, 12);
|
|
index += 12;
|
|
|
|
entity.Data.Add(EPCData);
|
|
}
|
|
|
|
return entity;
|
|
}
|
|
}
|
|
}
|