|
|
|
|
using GRreader;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace HighWayIot.Rfid
|
|
|
|
|
{
|
|
|
|
|
public delegate void RecvIdentifyData(ushort iLen, byte[] pData, byte Antenna, UInt16 iDeviceId, string strId);
|
|
|
|
|
|
|
|
|
|
public enum G2MemBank
|
|
|
|
|
{
|
|
|
|
|
RESERVED = 0, //保留区
|
|
|
|
|
EPC = 1,
|
|
|
|
|
TID = 2,
|
|
|
|
|
USER = 3,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public enum CommType
|
|
|
|
|
{
|
|
|
|
|
RJ45 = 1, //网口
|
|
|
|
|
RS232 = 2, //com口
|
|
|
|
|
RS485 = 3, //485接口
|
|
|
|
|
};
|
|
|
|
|
public enum DeviceType
|
|
|
|
|
{
|
|
|
|
|
Mesnac_PKRK = 1, //软控物联网读写器一体机_GRUI160
|
|
|
|
|
Alien_9650 = 2, //Alien9650
|
|
|
|
|
ThingMagic_Vega = 3, //ThingMagic车载读写器
|
|
|
|
|
Mesnac_LD = 4, //软控磊德
|
|
|
|
|
Mesnac_GRUV100 = 5, //软控物联网车载读写器_GRUV100
|
|
|
|
|
Mesnac_GRUR445 = 6, //软控物联网四端口读写器
|
|
|
|
|
GzgDevice = 7, //干燥柜
|
|
|
|
|
|
|
|
|
|
ZlanIO_101 = 101, //卓岚IO
|
|
|
|
|
Moxa_E1212 = 102, //摩砂E1212
|
|
|
|
|
HwIo8 = 103, //海威
|
|
|
|
|
RFU620 = 620, //SICK 读写器
|
|
|
|
|
RFly_I160 = 160,//金瑞铭RFly-I160读写器
|
|
|
|
|
HWKC_81600 = 81600,//海威IO设备
|
|
|
|
|
Fuchs = 104
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public enum WriteOrRead
|
|
|
|
|
{
|
|
|
|
|
Write = 1, //写
|
|
|
|
|
Read = 2, //读
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 设备适配层接口
|
|
|
|
|
/// </summary>
|
|
|
|
|
public interface IDeviceAdapter
|
|
|
|
|
{
|
|
|
|
|
event RecvIdentifyData RecvIdentifyDataEvent;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 设备初始化
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>true成功,false失败</returns>
|
|
|
|
|
/// <param name="iCommType">通讯类型 1,RJ45 2,串口。</param>
|
|
|
|
|
/// <param name="pUrl">连接字符串 当iCommType为1时,pUrl格式“192.168.1.100:23”,为2时,pUrl格式为:“Com1:9600“</param>
|
|
|
|
|
/// <param name="iDeviceType">详见DeviceType</param>
|
|
|
|
|
bool Device_Init(CommType iCommType, string pUrl, DeviceType iDeviceType);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 设备初始化
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>true成功,false失败</returns>
|
|
|
|
|
/// <param name="iCommType">通讯类型 1,RJ45 2,串口。</param>
|
|
|
|
|
/// <param name="pUrl">连接字符串 当iCommType为1时,pUrl格式“192.168.1.100:23”,为2时,pUrl格式为:“Com1:9600“</param>
|
|
|
|
|
/// <param name="iDeviceType">详见DeviceType</param>
|
|
|
|
|
bool Device_Init_Id(CommType iCommType, string pUrl, UInt16 iDeviceId);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 连接设备
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>true成功,false失败</returns>
|
|
|
|
|
bool Device_Connect();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 重新连接设备
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>true成功,false失败</returns>
|
|
|
|
|
bool Device_ReConnect();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 设备销毁
|
|
|
|
|
/// </summary>
|
|
|
|
|
void Device_Destroy();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 设备状态
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>true正常,false异常</returns>
|
|
|
|
|
bool Device_GetState();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据天线号读取单个标签数据,只返回一条
|
|
|
|
|
/// //只有在天线号为0的时候可以读写其他区的数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>实际读取到的长度,0为读取失败</returns>
|
|
|
|
|
/// <param name="filterMembank">过滤数据区域 1,保留区 2,TID区 3,EPC区 4,USER区</param>
|
|
|
|
|
/// <param name="filterWordPtr">过滤写入起始偏移地址,单位byte</param>
|
|
|
|
|
/// <param name="filterWordCnt">过滤长度,单位byte</param>
|
|
|
|
|
/// <param name="filterData">过滤数据</param>
|
|
|
|
|
/// <param name="Membank">数据区哉 1,保留区 2,TID区 3,EPC区 4,USER区</param>
|
|
|
|
|
/// <param name="WordPtr">读取起始偏移地址,单位byte,必须为偶数。</param>
|
|
|
|
|
/// <param name="WordCnt">读取长度,单位byte,必须为偶数。</param>
|
|
|
|
|
/// <param name="pReadData">读取数据存放区。</param>
|
|
|
|
|
/// <param name="Antenna">天线号,0为本机,255为所有天线</param>
|
|
|
|
|
UInt16 Device_Read(G2MemBank filterMembank, UInt16 filterWordPtr, UInt16 filterWordCnt, Byte[] filterData, G2MemBank Membank, UInt16 WordPtr, UInt16 WordCnt, ref Byte[] pReadData, byte Antenna);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据天线号写单个标签数据
|
|
|
|
|
/// //只有在天线号为0的时候可以写其他区的数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>0,写失败 1,写入成功 2,写入和读取的不一致</returns>
|
|
|
|
|
/// <param name="filterMembank">过滤数据区哉 1,保留区 2,TID区 3,EPC区 4,USER区</param>
|
|
|
|
|
/// <param name="filterWordPtr">过滤写入起始偏移地址,单位byte</param>
|
|
|
|
|
/// <param name="filterWordCnt">过滤写入长度,单位byte</param>
|
|
|
|
|
/// <param name="filterData">过滤数据</param>
|
|
|
|
|
/// <param name="Membank">数据区哉 1,保留区 2,TID区 3,EPC区 4,USER区</param>
|
|
|
|
|
/// <param name="WordPtr">写入起始偏移地址,单位byte,必须为偶数。</param>
|
|
|
|
|
/// <param name="WordCnt">写入长度,单位byte,必须为偶数。</param>
|
|
|
|
|
/// <param name="pWriteData">待写入的数据</param>
|
|
|
|
|
/// <param name="Antenna">天线号,0为本机,255为所有天线</param>
|
|
|
|
|
UInt16 Device_Write(G2MemBank filterMembank, UInt16 filterWordPtr, UInt16 filterWordCnt, Byte[] filterData,
|
|
|
|
|
G2MemBank Membank, UInt16 WordPtr, UInt16 WordCnt, Byte[] pWriteData, byte Antenna);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据天线号识别单个标签EPC数据,只返回一条
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>识别的标签EPC长度,0为识别失败</returns>
|
|
|
|
|
/// <param name="pReadData">识别到的数据缓存区</param>
|
|
|
|
|
/// <param name="Antenna">天线号,0为本机,255为所有天线</param>
|
|
|
|
|
/// <param name="Timedout">超时时间,单位毫秒,识别到立即返回,未识别到等待超时返回</param>
|
|
|
|
|
Byte Device_GetOneIdentifyData(ref Byte[] pReadData, Byte Antenna, UInt16 Timedout);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据天线号识别单个标签EPC数据,只返回一条
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>识别的标签EPC长度,0为识别失败</returns>
|
|
|
|
|
/// <param name="pReadData">识别到的数据缓存区</param>
|
|
|
|
|
/// <param name="Antenna">天线号,0为本机,255为所有天线</param>
|
|
|
|
|
/// <param name="Timedout">超时时间,单位毫秒,统计时间内读到的次数,返回次数最多的一条</param>
|
|
|
|
|
Byte Device_GetOneIdentifyData_Finish(ref Byte[] pReadData, Byte Antenna, UInt16 Timedout);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据天线号识别单个标签EPC数据,只返回一条
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>EPC数据,例"4A474730303130323332",为""时失败</returns>
|
|
|
|
|
/// <param name="Antenna">天线号,0为本机,255为所有天线</param>
|
|
|
|
|
/// <param name="Timedout">超时时间,单位毫秒,识别到立即返回,未识别到等待超时返回</param>
|
|
|
|
|
string Device_GetOneIdentifyData(Byte Antenna, UInt16 Timedout);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据天线号识别单个标签EPC数据,只返回一条
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>EPC数据,例"4A474730303130323332",为""时失败</returns>
|
|
|
|
|
/// <param name="Antenna">天线号,0为本机,255为所有天线</param>
|
|
|
|
|
/// <param name="Timedout">超时时间,单位毫秒,统计时间内读到的次数,返回次数最多的一条</param>
|
|
|
|
|
string Device_GetOneIdentifyData_Finish(Byte Antenna, UInt16 Timedout);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 开始工作,读写器为开始识别,其他设备待定义
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>true正常,false异常</returns>
|
|
|
|
|
/// <param name="AutoReport">是否自动上报,1自动,0不自动,默认0</param>
|
|
|
|
|
/// <param name="Filter">过滤规则,默认为0无规则, 后续待定</param>
|
|
|
|
|
bool Device_BeginIdentify();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 停止识别,读写器为停止识别,其他设备待定义
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>true正常,false异常</returns>
|
|
|
|
|
bool Device_StopIdentify();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取工作期间的所有数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>实际读取到数据的总长度包括每组数据所占的字节,0为读取失败</returns>
|
|
|
|
|
/// <param name="pReadData">数据存放区,多组数据时格式为:1字节长度+天线号+每组数据...</param>
|
|
|
|
|
/// <param name="Antenna">天线号,0为本机,255为读取所有天线</param>
|
|
|
|
|
UInt16 Device_GetIdentifyData(ref Byte[] pReadData, Byte Antenna);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 设置天线收发功率
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>true为设置成功,false为设置失败</returns>
|
|
|
|
|
/// <param name="iDbi">识别到的数据缓存区</param>
|
|
|
|
|
/// <param name="Antenna">天线号,0为本机,255为所有天线</param>
|
|
|
|
|
/// <param name="RorW">Write为写,Read为读</param>
|
|
|
|
|
bool Device_SetRf(int iDbi, Byte Antenna, WriteOrRead RorW);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 发送心跳报文
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>1成功,2为通讯成功,设备未返回,3为发送失败</returns>
|
|
|
|
|
byte Device_SendHeartPack();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取自报数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>总长度,0为失败</returns>
|
|
|
|
|
/// <param name="pReadData">获得的自报数据,格式为长度,数据,。。。。。。长度,数据,其中长度占一个字节</param>
|
|
|
|
|
UInt16 Device_GetReportData(ref byte[] pReadData, Byte Antenna, UInt32 Timedout);
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 四通道读写器按时间段读取数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="DeviceType"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
List<TagInfo> Device_GetTagInfoList(DeviceType DeviceType,int time);
|
|
|
|
|
}
|
|
|
|
|
}
|