using System;
using System.IO.Ports;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using Modbus.Device;

namespace NDSD_Screwdriver.Tool
{
  	public class hfIIReader
	{
		// Token: 0x0600000F RID: 15 RVA: 0x000032BC File Offset: 0x000014BC
		public bool Connect(SerialPort serialPort, int timeout, int addr)
		{
			this.ReaderSetComType(0);
			this.master = ModbusSerialMaster.CreateRtu(serialPort);
			bool flag = this.master == null;
			bool result;
			if (flag)
			{
				result = false;
			}
			else
			{
				this.master.Transport.Retries = 1;
				this.master.Transport.ReadTimeout = timeout;
				this.deviceAddr = (byte)addr;
				this.modBusSerialPort = serialPort;
				result = true;
			}
			return result;
		}

		// Token: 0x06000010 RID: 16 RVA: 0x0000332C File Offset: 0x0000152C
		public void Disconnect()
		{
			bool flag = this.modBusSerialPort != null;
			if (flag)
			{
				try
				{
					this.modBusSerialPort.Close();
				}
				catch (Exception)
				{
				}
				this.modBusSerialPort = null;
			}
			bool flag2 = this.master != null;
			if (flag2)
			{
				this.master.Dispose();
				this.master = null;
			}
		}

		// Token: 0x06000011 RID: 17 RVA: 0x00003398 File Offset: 0x00001598
		private void ClearRxBuffer()
		{
			bool flag = this.comType == 0;
			if (flag)
			{
				string text = this.modBusSerialPort.ReadExisting();
			}
			else
			{
				bool flag2 = this.comType == 1;
				if (flag2)
				{
					NetworkStream stream = this.clientSocket.GetStream();
					stream.Flush();
				}
			}
		}

		// Token: 0x06000012 RID: 18 RVA: 0x000033E8 File Offset: 0x000015E8
		public int ReaderConnectTcpServer(string ipStr, string portStr, int device_Addr)
		{
			int result = -1;
			this.ReaderSetComType(1);
			try
			{
				int port = Convert.ToInt32(portStr);
				this.clientSocket = new TcpClient();
				IAsyncResult asyncResult = this.clientSocket.BeginConnect(ipStr, port, null, null);
				asyncResult.AsyncWaitHandle.WaitOne(1000);
				bool flag = !asyncResult.IsCompleted;
				if (flag)
				{
					this.clientSocket.Close();
					this.clientSocket = null;
					return -1;
				}
				this.masterIp = ModbusIpMaster.CreateIp(this.clientSocket);
				this.masterIp.Transport.Retries = 1;
				this.masterIp.Transport.ReadTimeout = 1000;
				this.deviceAddr = (byte)device_Addr;
				result = 0;
			}
			catch (Exception)
			{
				result = -1;
			}
			return result;
		}

		// Token: 0x06000013 RID: 19 RVA: 0x000034C0 File Offset: 0x000016C0
		public void ReaderCloseTcpServer()
		{
			try
			{
				bool flag = this.clientSocket != null;
				if (flag)
				{
					bool connected = this.clientSocket.Connected;
					if (connected)
					{
						try
						{
							this.clientSocket.Close();
						}
						catch (Exception)
						{
						}
					}
					this.clientSocket = null;
				}
				bool flag2 = this.masterIp != null;
				if (flag2)
				{
					this.masterIp.Dispose();
					this.masterIp = null;
				}
			}
			catch (Exception ex)
			{
			}
		}

		// Token: 0x06000014 RID: 20 RVA: 0x00003554 File Offset: 0x00001754
		private void ReaderSetComType(int mode)
		{
			bool flag = mode == 0;
			if (flag)
			{
				this.Disconnect();
				this.comType = 0;
			}
			else
			{
				bool flag2 = mode == 1;
				if (flag2)
				{
					this.ReaderCloseTcpServer();
					this.comType = 1;
				}
			}
		}

		// Token: 0x06000015 RID: 21 RVA: 0x00003594 File Offset: 0x00001794
		public void JmpApp()
		{
			byte[] array = new byte[]
			{
				126,
				85,
				8,
				0,
				0,
				byte.MaxValue,
				byte.MaxValue,
				3,
				0,
				213,
				123
			};
			bool flag = this.comType == 0;
			if (flag)
			{
				this.modBusSerialPort.Write(array, 0, array.Length);
			}
			else
			{
				bool flag2 = this.comType == 1;
				if (flag2)
				{
					NetworkStream stream = this.clientSocket.GetStream();
					bool canWrite = stream.CanWrite;
					if (canWrite)
					{
						stream.Write(array, 0, array.Length);
					}
				}
			}
			Thread.Sleep(200);
		}

		// Token: 0x06000016 RID: 22 RVA: 0x00003618 File Offset: 0x00001818
		public bool GetParams(ref HFIIREADER_PARAMS devParams, uint deviceType, ushort devieVer, int protocolType)
		{
			bool result = true;
			this.ClearRxBuffer();
			bool flag = (deviceType & 16773120U) == 3358720U && devieVer < 12288;
			ushort num;
			if (flag)
			{
				num = 9;
			}
			else
			{
				num = 12;
			}
			try
			{
				ushort[] array = new ushort[12];
				bool flag2 = this.comType == 0;
				if (flag2)
				{
					array = this.master.ReadHoldingRegisters(this.deviceAddr, 0, num);
				}
				else
				{
					bool flag3 = this.comType == 1;
					if (flag3)
					{
						array = this.masterIp.ReadHoldingRegisters(this.deviceAddr, 0, num);
					}
				}
				bool flag4 = array == null;
				if (flag4)
				{
					result = false;
				}
				else
				{
					devParams.addr = array[0];
					devParams.br = array[1];
					bool flag5 = protocolType == 0;
					if (flag5)
					{
						devParams.afiMode = array[2];
					}
					else
					{
						devParams.tagType = array[2];
					}
					devParams.invtTo = array[3];
					devParams.trgMode = array[4];
					devParams.opTagMode = array[5];
					devParams.opBlockRegAddr = array[6];
					devParams.opBlockRegNum = array[7];
					devParams.trgTimerTick = array[8];
					bool flag6 = num == 12;
					if (flag6)
					{
						devParams.opFormat = array[9];
						devParams.frameHead = array[10];
						devParams.keppTimer = array[11];
					}
				}
			}
			catch (Exception ex)
			{
				string message = ex.Message;
				result = false;
			}
			return result;
		}

		// Token: 0x06000017 RID: 23 RVA: 0x00003794 File Offset: 0x00001994
		public bool GetBlockParams(ref int paramsInfo)
		{
			bool result = true;
			this.ClearRxBuffer();
			try
			{
				ushort[] array = null;
				bool flag = this.comType == 0;
				if (flag)
				{
					array = this.master.ReadHoldingRegisters(this.deviceAddr, 12, 1);
				}
				else
				{
					bool flag2 = this.comType == 1;
					if (flag2)
					{
						array = this.masterIp.ReadHoldingRegisters(this.deviceAddr, 12, 1);
					}
				}
				bool flag3 = array == null;
				if (flag3)
				{
					result = false;
				}
				else
				{
					paramsInfo = (int)array[0];
				}
			}
			catch (Exception ex)
			{
				string message = ex.Message;
				result = false;
			}
			return result;
		}

		// Token: 0x06000018 RID: 24 RVA: 0x0000383C File Offset: 0x00001A3C
		public bool GetRfPower(ref int level)
		{
			bool result = true;
			this.ClearRxBuffer();
			try
			{
				ushort[] array = null;
				bool flag = this.comType == 0;
				if (flag)
				{
					array = this.master.ReadHoldingRegisters(this.deviceAddr, 15, 1);
				}
				else
				{
					bool flag2 = this.comType == 1;
					if (flag2)
					{
						array = this.masterIp.ReadHoldingRegisters(this.deviceAddr, 15, 1);
					}
				}
				bool flag3 = array == null;
				if (flag3)
				{
					result = false;
				}
				else
				{
					level = (int)array[0];
				}
			}
			catch (Exception ex)
			{
				string message = ex.Message;
				result = false;
			}
			return result;
		}

		// Token: 0x06000019 RID: 25 RVA: 0x000038E4 File Offset: 0x00001AE4
		public bool GetReadTagRspErrMode(ref int mode)
		{
			bool result = true;
			this.ClearRxBuffer();
			try
			{
				ushort[] array = null;
				bool flag = this.comType == 0;
				if (flag)
				{
					array = this.master.ReadHoldingRegisters(this.deviceAddr, 16, 1);
				}
				else
				{
					bool flag2 = this.comType == 1;
					if (flag2)
					{
						array = this.masterIp.ReadHoldingRegisters(this.deviceAddr, 16, 1);
					}
				}
				bool flag3 = array == null;
				if (flag3)
				{
					result = false;
				}
				else
				{
					mode = (int)array[0];
				}
			}
			catch (Exception ex)
			{
				string message = ex.Message;
				result = false;
			}
			return result;
		}

		// Token: 0x0600001A RID: 26 RVA: 0x0000398C File Offset: 0x00001B8C
		public bool SetBlockParams(int paramsInfo)
		{
			bool result = true;
			this.ClearRxBuffer();
			try
			{
				ushort[] data = new ushort[]
				{
					(ushort)paramsInfo
				};
				bool flag = this.comType == 0;
				if (flag)
				{
					this.master.WriteMultipleRegisters(this.deviceAddr, 12, data);
				}
				else
				{
					bool flag2 = this.comType == 1;
					if (flag2)
					{
						this.masterIp.WriteMultipleRegisters(this.deviceAddr, 12, data);
					}
				}
			}
			catch (Exception ex)
			{
				string message = ex.Message;
				result = false;
			}
			return result;
		}

		// Token: 0x0600001B RID: 27 RVA: 0x00003A28 File Offset: 0x00001C28
		public bool SetM1KeyParams(bool bSave, int type, byte[] key)
		{
			bool result = true;
			this.ClearRxBuffer();
			try
			{
				ushort[] array = new ushort[5];
				if (bSave)
				{
					array[0] = 1;
				}
				else
				{
					array[0] = 0;
				}
				array[1] = (ushort)(type & 1);
				array[2] = (ushort)((int)key[0] * 256 + (int)key[1] & 65535);
				array[3] = (ushort)((int)key[2] * 256 + (int)key[3] & 65535);
				array[4] = (ushort)((int)key[4] * 256 + (int)key[5] & 65535);
				bool flag = this.comType == 0;
				if (flag)
				{
					this.master.WriteMultipleRegisters(this.deviceAddr, 65280, array);
				}
				else
				{
					bool flag2 = this.comType == 1;
					if (flag2)
					{
						this.masterIp.WriteMultipleRegisters(this.deviceAddr, 65280, array);
					}
				}
			}
			catch (Exception ex)
			{
				string message = ex.Message;
				result = false;
			}
			return result;
		}

		// Token: 0x0600001C RID: 28 RVA: 0x00003B24 File Offset: 0x00001D24
		public bool GetM1KeyParams(ref bool bSave, ref int type, byte[] key)
		{
			bool result = true;
			this.ClearRxBuffer();
			try
			{
				ushort[] array = null;
				bool flag = this.comType == 0;
				if (flag)
				{
					array = this.master.ReadHoldingRegisters(this.deviceAddr, 65280, 5);
				}
				else
				{
					bool flag2 = this.comType == 1;
					if (flag2)
					{
						array = this.masterIp.ReadHoldingRegisters(this.deviceAddr, 65280, 5);
					}
				}
				bool flag3 = array != null;
				if (flag3)
				{
					bool flag4 = array[0] == 1;
					if (flag4)
					{
						bSave = true;
					}
					else
					{
						bSave = false;
					}
					type = (int)(array[1] & 1);
					key[0] = (byte)(array[2] >> 8 & 255);
					key[1] = (byte)(array[2] & 255);
					key[2] = (byte)(array[3] >> 8 & 255);
					key[3] = (byte)(array[3] & 255);
					key[4] = (byte)(array[4] >> 8 & 255);
					key[5] = (byte)(array[4] & 255);
				}
			}
			catch (Exception ex)
			{
				string message = ex.Message;
				result = false;
			}
			return result;
		}

		// Token: 0x0600001D RID: 29 RVA: 0x00003C38 File Offset: 0x00001E38
		public bool SetRfPower(int lv)
		{
			bool result = true;
			this.ClearRxBuffer();
			try
			{
				ushort[] data = new ushort[]
				{
					(ushort)lv
				};
				bool flag = this.comType == 0;
				if (flag)
				{
					this.master.WriteMultipleRegisters(this.deviceAddr, 15, data);
				}
				else
				{
					bool flag2 = this.comType == 1;
					if (flag2)
					{
						this.masterIp.WriteMultipleRegisters(this.deviceAddr, 15, data);
					}
				}
			}
			catch (Exception ex)
			{
				string message = ex.Message;
				result = false;
			}
			return result;
		}

		// Token: 0x0600001E RID: 30 RVA: 0x00003CD4 File Offset: 0x00001ED4
		public bool SetReadTagErrMode(int mode)
		{
			bool result = true;
			this.ClearRxBuffer();
			try
			{
				ushort[] data = new ushort[]
				{
					(ushort)mode
				};
				bool flag = this.comType == 0;
				if (flag)
				{
					this.master.WriteMultipleRegisters(this.deviceAddr, 16, data);
				}
				else
				{
					bool flag2 = this.comType == 1;
					if (flag2)
					{
						this.masterIp.WriteMultipleRegisters(this.deviceAddr, 16, data);
					}
				}
			}
			catch (Exception ex)
			{
				string message = ex.Message;
				result = false;
			}
			return result;
		}

		// Token: 0x0600001F RID: 31 RVA: 0x00003D70 File Offset: 0x00001F70
		public bool SetParams(HFIIREADER_PARAMS devParams, uint deviceType, ushort devieVer, int protocolType)
		{
			bool result = true;
			this.ClearRxBuffer();
			bool flag = (deviceType & 16773120U) == 3358720U && devieVer < 12288;
			ushort num;
			if (flag)
			{
				num = 9;
			}
			else
			{
				num = 12;
			}
			ushort[] array = new ushort[(int)num];
			array[0] = devParams.addr;
			array[1] = devParams.br;
			bool flag2 = protocolType == 0;
			if (flag2)
			{
				array[2] = devParams.afiMode;
			}
			else
			{
				array[2] = devParams.tagType;
			}
			array[3] = devParams.invtTo;
			array[4] = devParams.trgMode;
			array[5] = devParams.opTagMode;
			array[6] = devParams.opBlockRegAddr;
			array[7] = devParams.opBlockRegNum;
			array[8] = devParams.trgTimerTick;
			bool flag3 = num == 12;
			if (flag3)
			{
				array[9] = devParams.opFormat;
				array[10] = devParams.frameHead;
				array[11] = devParams.keppTimer;
			}
			try
			{
				bool flag4 = this.comType == 0;
				if (flag4)
				{
					this.master.WriteMultipleRegisters(this.deviceAddr, 0, array);
				}
				else
				{
					bool flag5 = this.comType == 1;
					if (flag5)
					{
						this.masterIp.WriteMultipleRegisters(this.deviceAddr, 0, array);
					}
				}
			}
			catch (Exception ex)
			{
				result = false;
			}
			return result;
		}

		// Token: 0x06000020 RID: 32 RVA: 0x00003EC0 File Offset: 0x000020C0
		public string GetVersion(ref uint deviceTypeInfo, ref ushort deviceVersionInfo)
		{
			string text = "";
			this.ClearRxBuffer();
			try
			{
				ushort[] array = new ushort[1];
				bool flag = this.comType == 0;
				if (flag)
				{
					array = this.master.ReadInputRegisters(this.deviceAddr, 0, 2);
				}
				else
				{
					bool flag2 = this.comType == 1;
					if (flag2)
					{
						array = this.masterIp.ReadInputRegisters(this.deviceAddr, 0, 2);
					}
				}
				bool flag3 = array != null;
				if (flag3)
				{
					deviceTypeInfo = (uint)array[0];
					deviceTypeInfo <<= 16;
					deviceTypeInfo |= (uint)array[1];
				}
				else
				{
					deviceTypeInfo = 0U;
				}
				ushort[] array2 = new ushort[1];
				bool flag4 = this.comType == 0;
				if (flag4)
				{
					array2 = this.master.ReadInputRegisters(this.deviceAddr, 2, 1);
				}
				else
				{
					bool flag5 = this.comType == 1;
					if (flag5)
					{
						array2 = this.masterIp.ReadInputRegisters(this.deviceAddr, 2, 1);
					}
				}
				bool flag6 = array2 == null;
				if (flag6)
				{
					text = "Null";
				}
				else
				{
					deviceVersionInfo = array2[0];
					text += "获取版本：";
					text = string.Concat(new string[]
					{
						text,
						"V",
						(array2[0] >> 12 & 15).ToString("X"),
						".",
						(array2[0] >> 8 & 15).ToString("X"),
						".",
						(array2[0] >> 4 & 15).ToString("X"),
						".",
						((int)(array2[0] & 15)).ToString("X")
					});
				}
			}
			catch (Exception ex)
			{
				text = "Error";
			}
			return text;
		}

		// Token: 0x06000021 RID: 33 RVA: 0x00004098 File Offset: 0x00002298
		public string GetSn()
		{
			string text = "";
			this.ClearRxBuffer();
			try
			{
				ushort[] array = new ushort[6];
				bool flag = this.comType == 0;
				if (flag)
				{
					array = this.master.ReadInputRegisters(this.deviceAddr, 13, 6);
				}
				else
				{
					bool flag2 = this.comType == 1;
					if (flag2)
					{
						array = this.masterIp.ReadInputRegisters(this.deviceAddr, 13, 6);
					}
				}
				int num;
				for (int i = 0; i < 6; i = num + 1)
				{
					text += array[i].ToString("X").PadLeft(4, '0');
					num = i;
				}
			}
			catch (Exception ex)
			{
				text = "";
			}
			return text;
		}

		// Token: 0x06000022 RID: 34 RVA: 0x00004168 File Offset: 0x00002368
		public ushort[] ReadRfInfo()
		{
			ushort[] result = null;
			this.ClearRxBuffer();
			try
			{
				bool flag = this.comType == 0;
				if (flag)
				{
					result = this.master.ReadInputRegisters(this.deviceAddr, 5, 3);
				}
				else
				{
					bool flag2 = this.comType == 1;
					if (flag2)
					{
						result = this.masterIp.ReadInputRegisters(this.deviceAddr, 5, 3);
					}
				}
			}
			catch (Exception ex)
			{
				result = null;
			}
			return result;
		}

		// Token: 0x06000023 RID: 35 RVA: 0x000041EC File Offset: 0x000023EC
		public ushort[] ReadTagMemory(ref string strErr, ushort regAddr, ushort regNum)
		{
			ushort[] result = null;
			this.ClearRxBuffer();
			try
			{
				bool flag = this.comType == 0;
				if (flag)
				{
					result = this.master.ReadHoldingRegisters(this.deviceAddr, regAddr, regNum);
				}
				else
				{
					bool flag2 = this.comType == 1;
					if (flag2)
					{
						result = this.masterIp.ReadHoldingRegisters(this.deviceAddr, regAddr, regNum);
					}
				}
			}
			catch (Exception ex)
			{
				string message = ex.Message;
				result = null;
			}
			return result;
		}

		// Token: 0x06000024 RID: 36 RVA: 0x00004278 File Offset: 0x00002478
		public bool WriteTagMemory(ushort regAddr, ushort[] reg, bool bWriteTagMulRes)
		{
			this.ClearRxBuffer();
			try
			{
				if (bWriteTagMulRes)
				{
					bool flag = this.comType == 0;
					if (flag)
					{
						this.master.WriteMultipleRegisters(this.deviceAddr, regAddr, reg);
					}
					else
					{
						bool flag2 = this.comType == 1;
						if (flag2)
						{
							this.masterIp.WriteMultipleRegisters(this.deviceAddr, regAddr, reg);
						}
					}
				}
				else
				{
					int num;
					for (int i = 0; i < reg.Length; i = num + 1)
					{
						bool flag3 = this.comType == 0;
						if (flag3)
						{
							this.master.WriteSingleRegister(this.deviceAddr, (ushort)((int)regAddr + i), reg[i]);
						}
						else
						{
							bool flag4 = this.comType == 1;
							if (flag4)
							{
								this.masterIp.WriteSingleRegister(this.deviceAddr, (ushort)((int)regAddr + i), reg[i]);
							}
						}
						num = i;
					}
				}
			}
			catch (Exception ex)
			{
				return false;
			}
			return true;
		}

		// Token: 0x06000025 RID: 37 RVA: 0x00004378 File Offset: 0x00002578
		public ushort[] RwTagMemory(ushort wRegAddr, ushort[] wReg, ushort rRegAddr, ushort rRegNum)
		{
			ushort[] result = null;
			this.ClearRxBuffer();
			try
			{
				bool flag = this.comType == 0;
				if (flag)
				{
					result = this.master.ReadWriteMultipleRegisters(this.deviceAddr, rRegAddr, rRegNum, wRegAddr, wReg);
				}
				else
				{
					bool flag2 = this.comType == 1;
					if (flag2)
					{
						result = this.masterIp.ReadWriteMultipleRegisters(this.deviceAddr, rRegAddr, rRegNum, wRegAddr, wReg);
					}
				}
			}
			catch (Exception ex)
			{
			}
			return result;
		}

		// Token: 0x06000026 RID: 38 RVA: 0x00004400 File Offset: 0x00002600
		public bool WriteCoilTrgOpTag()
		{
			this.ClearRxBuffer();
			try
			{
				this.master.WriteSingleCoil(this.deviceAddr, 1, true);
			}
			catch (Exception ex)
			{
				return false;
			}
			return true;
		}

		// Token: 0x06000027 RID: 39 RVA: 0x00004448 File Offset: 0x00002648
		public string ReadOpTagState()
		{
			string result = "IDLE";
			this.ClearRxBuffer();
			try
			{
				ushort[] array = new ushort[1];
				bool flag = this.comType == 0;
				if (flag)
				{
					array = this.master.ReadInputRegisters(this.deviceAddr, 3, 1);
				}
				else
				{
					bool flag2 = this.comType == 1;
					if (flag2)
					{
						array = this.masterIp.ReadInputRegisters(this.deviceAddr, 3, 1);
					}
				}
				bool flag3 = array[0] == 0;
				if (flag3)
				{
					result = "OK";
				}
				else
				{
					bool flag4 = array[0] == 1;
					if (flag4)
					{
						result = "FAIL";
					}
					else
					{
						bool flag5 = array[0] == 3;
						if (flag5)
						{
							result = "BUSY";
						}
						else
						{
							result = "ERROR";
						}
					}
				}
			}
			catch (Exception ex)
			{
				result = "";
			}
			return result;
		}

		// Token: 0x06000028 RID: 40 RVA: 0x00004524 File Offset: 0x00002724
		public string ReceiveAutoTagInfo()
		{
			string result = "";
			try
			{
				bool flag = this.comType == 0;
				if (flag)
				{
					result = this.modBusSerialPort.ReadExisting();
				}
				else
				{
					bool flag2 = this.comType == 1;
					if (flag2)
					{
						NetworkStream stream = this.clientSocket.GetStream();
						bool flag3 = stream.CanRead && stream.DataAvailable;
						if (flag3)
						{
							byte[] array = new byte[1024];
							int count = stream.Read(array, 0, array.Length);
							result = Encoding.ASCII.GetString(array, 0, count);
						}
					}
				}
			}
			catch (Exception ex)
			{
			}
			return result;
		}

		// Token: 0x04000032 RID: 50
		private ModbusSerialMaster master;

		// Token: 0x04000033 RID: 51
		private ModbusIpMaster masterIp = null;

		// Token: 0x04000034 RID: 52
		private SerialPort modBusSerialPort;

		// Token: 0x04000035 RID: 53
		private byte deviceAddr = 1;

		// Token: 0x04000036 RID: 54
		public const ushort HFIIREADER_TYPE_ADDR_VERSION = 0;

		// Token: 0x04000037 RID: 55
		public const ushort HFIIREADER_TYPE_NUM_VERSION = 2;

		// Token: 0x04000038 RID: 56
		public const ushort HFIIREADER_TYPE_ADDR_SN = 13;

		// Token: 0x04000039 RID: 57
		public const ushort HFIIREADER_TYPE_NUM_SN = 6;

		// Token: 0x0400003A RID: 58
		public const ushort HFIIREADER_REG_ADDR_VERSION = 2;

		// Token: 0x0400003B RID: 59
		public const ushort HFIIREADER_REG_NUM_VERSION = 1;

		// Token: 0x0400003C RID: 60
		public const ushort HFIIREADER_REG_ADDR_OPSTAT = 3;

		// Token: 0x0400003D RID: 61
		public const ushort HFIIREADER_REG_NUM_OPSTAT = 1;

		// Token: 0x0400003E RID: 62
		public const ushort HFIIREADER_BR_9600 = 0;

		// Token: 0x0400003F RID: 63
		public const ushort HFIIREADER_BR_38400 = 1;

		// Token: 0x04000040 RID: 64
		public const ushort HFIIREADER_BR_115200 = 2;

		// Token: 0x04000041 RID: 65
		public const ushort HFIIREADER_BR_19200 = 3;

		// Token: 0x04000042 RID: 66
		public const ushort HFIIREADER_OP_MODE_RBLOCK = 1;

		// Token: 0x04000043 RID: 67
		public const ushort HFIIREADER_OP_MODE_RAFI = 2;

		// Token: 0x04000044 RID: 68
		public const ushort HFIIREADER_OP_MODE_RDSFID = 4;

		// Token: 0x04000045 RID: 69
		public const ushort HFIIREADER_OP_MODE_UID = 0;

		// Token: 0x04000046 RID: 70
		public const ushort READER_RSPFORMAT_NONE = 0;

		// Token: 0x04000047 RID: 71
		public const ushort READER_RSPFORMAT_ASCII = 256;

		// Token: 0x04000048 RID: 72
		public const ushort READER_RSPFORMAT_PULSE = 512;

		// Token: 0x04000049 RID: 73
		public const ushort HFIIREADER_OP_FORMAT_HEADER = 1;

		// Token: 0x0400004A RID: 74
		public const ushort HFIIREADER_OP_FORMAT_ADDRESS = 2;

		// Token: 0x0400004B RID: 75
		public const ushort HFIIREADER_OP_FORMAT_BCC = 4;

		// Token: 0x0400004C RID: 76
		public const ushort HFIIREADER_OP_MODE_MASK = 15;

		// Token: 0x0400004D RID: 77
		public const ushort HFIIREADER_TRG_MODE_TIMER = 0;

		// Token: 0x0400004E RID: 78
		public const ushort HFIIREADER_TRG_MODE_RWREG = 1;

		// Token: 0x0400004F RID: 79
		public const ushort HFIIREADER_TRG_MODE_WCOIL = 2;

		// Token: 0x04000050 RID: 80
		public const ushort HFIIREADER_TRG_MODE_NUM = 3;

		// Token: 0x04000051 RID: 81
		public const ushort HFIIREADER_AFI_MODE_ENABLE = 256;

		// Token: 0x04000052 RID: 82
		public const ushort HFIIREADER_AFI_MODE_DISABLE = 0;

		// Token: 0x04000053 RID: 83
		public const ushort HFIIREADER_INREG_RFINFO_ADDR = 5;

		// Token: 0x04000054 RID: 84
		public const ushort HFIIREADER_INREG_RFINFO_NUM = 3;

		// Token: 0x04000055 RID: 85
		public const ushort READER_RESULT_CLR_AUTO = 0;

		// Token: 0x04000056 RID: 86
		public const ushort READER_RESULT_CLR_KEEP = 256;

		// Token: 0x04000057 RID: 87
		public const ushort HFIIREADER_HOLDREG_PARAMS_ADDR = 0;

		// Token: 0x04000058 RID: 88
		public const ushort HFIIREADER_HOLDREG_PARAMS_NUM = 12;

		// Token: 0x04000059 RID: 89
		public const ushort HFIIREADER_HOLDREG_PARAMS_NUM2 = 9;

		// Token: 0x0400005A RID: 90
		public const ushort HFIIREADER_HOLDREG_BLKPAR_ADDR = 12;

		// Token: 0x0400005B RID: 91
		public const ushort HFIIREADER_HOLDREG_BLKPAR_NUM = 1;

		// Token: 0x0400005C RID: 92
		public const ushort HFIIREADER_HOLDREG_BLKSIZE_MSK = 3;

		// Token: 0x0400005D RID: 93
		public const ushort HFIIREADER_HOLDREG_BLKNUM_MSK = 12;

		// Token: 0x0400005E RID: 94
		public const ushort HFIIREADER_HOLDREG_RFPWR_ADDR = 15;

		// Token: 0x0400005F RID: 95
		public const ushort HFIIREADER_HOLDREG_RFPWR_NUM = 1;

		// Token: 0x04000060 RID: 96
		public const ushort HFIIREADER_HOLDREG_ERRMOD_ADDR = 16;

		// Token: 0x04000061 RID: 97
		public const ushort HFIIREADER_HOLDREG_ERRMOD_NUM = 1;

		// Token: 0x04000062 RID: 98
		public const ushort HFIIREADER_HOLDREG_TAG_START = 26;

		// Token: 0x04000063 RID: 99
		public const ushort HFIIREADER_HOLDREG_DSFID_ADDR = 26;

		// Token: 0x04000064 RID: 100
		public const ushort HFIIREADER_HOLDREG_DSFID_NUM = 1;

		// Token: 0x04000065 RID: 101
		public const ushort HFIIREADER_HOLDREG_AFI_ADDR = 27;

		// Token: 0x04000066 RID: 102
		public const ushort HFIIREADER_HOLDREG_AFI_NUM = 1;

		// Token: 0x04000067 RID: 103
		public const ushort HFIIREADER_HOLDREG_UID_ADDR = 28;

		// Token: 0x04000068 RID: 104
		public const ushort HFIIREADER_HOLDREG_UID_NUM = 4;

		// Token: 0x04000069 RID: 105
		public const ushort HFIIREADER_HOLDREG_BLK_ADDR = 32;

		// Token: 0x0400006A RID: 106
		public const ushort HFIIREADER_HOLDREG_BLK_NUM = 1024;

		// Token: 0x0400006B RID: 107
		public const ushort HFIIREADER_HOLDREG_M1KEY_ADDR = 65280;

		// Token: 0x0400006C RID: 108
		public const ushort HFIIREADER_HOLDREG_M1KEY_NUM = 5;

		// Token: 0x0400006D RID: 109
		public const ushort HFIIREADER_COLIL_REG_NUM = 4;

		// Token: 0x0400006E RID: 110
		public const ushort HFIIREADER_COIL_ADDR_RSTSYS = 0;

		// Token: 0x0400006F RID: 111
		public const ushort HFIIREADER_COIL_ADDR_STARTOP = 1;

		// Token: 0x04000070 RID: 112
		public const ushort HFIIREADER_COIL_ADDR_RSTERR = 2;

		// Token: 0x04000071 RID: 113
		public const ushort HFIIREADER_COIL_ADDR_CFGMODE = 3;

		// Token: 0x04000072 RID: 114
		public const ushort HFIIREADER_COIL_VALUE_SET = 65280;

		// Token: 0x04000073 RID: 115
		public const ushort HFIIREADER_COIL_VALUE_RESET = 0;

		// Token: 0x04000074 RID: 116
		private byte[] txFrame = new byte[1024];

		// Token: 0x04000075 RID: 117
		private byte[] rxFrame = new byte[1024];

		// Token: 0x04000076 RID: 118
		private TcpClient clientSocket = null;

		// Token: 0x04000077 RID: 119
		public const int READER_COM_TYPE_UART = 0;

		// Token: 0x04000078 RID: 120
		public const int READER_COM_TYPE_NET = 1;

		// Token: 0x04000079 RID: 121
		public int comType = 0;
	}
}