using GRreader; using System; using System.Collections.Generic; 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, //读 }; /// /// 设备适配层接口 /// public interface IDeviceAdapter { event RecvIdentifyData RecvIdentifyDataEvent; /// /// 设备初始化 /// /// true成功,false失败 /// 通讯类型 1,RJ45 2,串口。 /// 连接字符串 当iCommType为1时,pUrl格式“192.168.1.100:23”,为2时,pUrl格式为:“Com1:9600“ /// 详见DeviceType bool Device_Init(CommType iCommType, string pUrl, DeviceType iDeviceType); /// /// 设备初始化 /// /// true成功,false失败 /// 通讯类型 1,RJ45 2,串口。 /// 连接字符串 当iCommType为1时,pUrl格式“192.168.1.100:23”,为2时,pUrl格式为:“Com1:9600“ /// 详见DeviceType bool Device_Init_Id(CommType iCommType, string pUrl, UInt16 iDeviceId); /// /// 连接设备 /// /// true成功,false失败 bool Device_Connect(); /// /// 重新连接设备 /// /// true成功,false失败 bool Device_ReConnect(); /// /// 设备销毁 /// void Device_Destroy(); /// /// 设备状态 /// /// true正常,false异常 bool Device_GetState(); /// /// 根据天线号读取单个标签数据,只返回一条 /// //只有在天线号为0的时候可以读写其他区的数据 /// /// 实际读取到的长度,0为读取失败 /// 过滤数据区域 1,保留区 2,TID区 3,EPC区 4,USER区 /// 过滤写入起始偏移地址,单位byte /// 过滤长度,单位byte /// 过滤数据 /// 数据区哉 1,保留区 2,TID区 3,EPC区 4,USER区 /// 读取起始偏移地址,单位byte,必须为偶数。 /// 读取长度,单位byte,必须为偶数。 /// 读取数据存放区。 /// 天线号,0为本机,255为所有天线 UInt16 Device_Read(G2MemBank filterMembank, UInt16 filterWordPtr, UInt16 filterWordCnt, Byte[] filterData, G2MemBank Membank, UInt16 WordPtr, UInt16 WordCnt, ref Byte[] pReadData, byte Antenna); /// /// 根据天线号写单个标签数据 /// //只有在天线号为0的时候可以写其他区的数据 /// /// 0,写失败 1,写入成功 2,写入和读取的不一致 /// 过滤数据区哉 1,保留区 2,TID区 3,EPC区 4,USER区 /// 过滤写入起始偏移地址,单位byte /// 过滤写入长度,单位byte /// 过滤数据 /// 数据区哉 1,保留区 2,TID区 3,EPC区 4,USER区 /// 写入起始偏移地址,单位byte,必须为偶数。 /// 写入长度,单位byte,必须为偶数。 /// 待写入的数据 /// 天线号,0为本机,255为所有天线 UInt16 Device_Write(G2MemBank filterMembank, UInt16 filterWordPtr, UInt16 filterWordCnt, Byte[] filterData, G2MemBank Membank, UInt16 WordPtr, UInt16 WordCnt, Byte[] pWriteData, byte Antenna); /// /// 根据天线号识别单个标签EPC数据,只返回一条 /// /// 识别的标签EPC长度,0为识别失败 /// 识别到的数据缓存区 /// 天线号,0为本机,255为所有天线 /// 超时时间,单位毫秒,识别到立即返回,未识别到等待超时返回 Byte Device_GetOneIdentifyData(ref Byte[] pReadData, Byte Antenna, UInt16 Timedout); /// /// 根据天线号识别单个标签EPC数据,只返回一条 /// /// 识别的标签EPC长度,0为识别失败 /// 识别到的数据缓存区 /// 天线号,0为本机,255为所有天线 /// 超时时间,单位毫秒,统计时间内读到的次数,返回次数最多的一条 Byte Device_GetOneIdentifyData_Finish(ref Byte[] pReadData, Byte Antenna, UInt16 Timedout); /// /// 根据天线号识别单个标签EPC数据,只返回一条 /// /// EPC数据,例"4A474730303130323332",为""时失败 /// 天线号,0为本机,255为所有天线 /// 超时时间,单位毫秒,识别到立即返回,未识别到等待超时返回 string Device_GetOneIdentifyData(Byte Antenna, UInt16 Timedout); /// /// 根据天线号识别单个标签EPC数据,只返回一条 /// /// EPC数据,例"4A474730303130323332",为""时失败 /// 天线号,0为本机,255为所有天线 /// 超时时间,单位毫秒,统计时间内读到的次数,返回次数最多的一条 string Device_GetOneIdentifyData_Finish(Byte Antenna, UInt16 Timedout); /// /// 开始工作,读写器为开始识别,其他设备待定义 /// /// true正常,false异常 /// 是否自动上报,1自动,0不自动,默认0 /// 过滤规则,默认为0无规则, 后续待定 bool Device_BeginIdentify(); /// /// 停止识别,读写器为停止识别,其他设备待定义 /// /// true正常,false异常 bool Device_StopIdentify(); /// /// 获取工作期间的所有数据 /// /// 实际读取到数据的总长度包括每组数据所占的字节,0为读取失败 /// 数据存放区,多组数据时格式为:1字节长度+天线号+每组数据... /// 天线号,0为本机,255为读取所有天线 UInt16 Device_GetIdentifyData(ref Byte[] pReadData, Byte Antenna); /// /// 设置天线收发功率 /// /// true为设置成功,false为设置失败 /// 识别到的数据缓存区 /// 天线号,0为本机,255为所有天线 /// Write为写,Read为读 bool Device_SetRf(int iDbi, Byte Antenna, WriteOrRead RorW); /// /// 发送心跳报文 /// /// 1成功,2为通讯成功,设备未返回,3为发送失败 byte Device_SendHeartPack(); /// /// 获取自报数据 /// /// 总长度,0为失败 /// 获得的自报数据,格式为长度,数据,。。。。。。长度,数据,其中长度占一个字节 UInt16 Device_GetReportData(ref byte[] pReadData, Byte Antenna, UInt32 Timedout); /// /// 四通道读写器按时间段读取数据 /// /// /// List Device_GetTagInfoList(DeviceType DeviceType, int time); } }