using HslCommunication.Core; using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Net.Sockets; using System.Text; namespace HslCommunication.ModBus { /// /// ModBus的异步状态信息 /// internal class ModBusState { #region Constructor /// /// 实例化一个对象 /// public ModBusState( ) { hybirdLock = new SimpleHybirdLock( ); ConnectTime = DateTime.Now; HeadByte = new byte[6]; } #endregion /// /// 连接的时间 /// public DateTime ConnectTime { get; private set; } /// /// 远端的地址 /// public IPEndPoint IpEndPoint { get; internal set; } /// /// 远端的Ip地址 /// public string IpAddress { get; internal set; } /// /// 工作套接字 /// public Socket WorkSocket = null; /// /// 消息头的缓存 /// public byte[] HeadByte = new byte[6]; /// /// 消息头的接收长度 /// public int HeadByteReceivedLength = 0; /// /// 内容数据缓存 /// public byte[] Content = null; /// /// 内容数据接收长度 /// public int ContentReceivedLength = 0; /// /// 回发信息的同步锁 /// internal SimpleHybirdLock hybirdLock; /// /// 清除原先的接收状态 /// public void Clear( ) { Array.Clear( HeadByte, 0, 6 ); HeadByteReceivedLength = 0; Content = null; ContentReceivedLength = 0; } } }