using System.Collections.Generic; using System.Threading.Tasks; using System; namespace Team.Communicate.Modbus { public interface IModbusTcpMaster { public string Ip { get; } public int Port { get; } int ConnectTimeOut { get; set; } byte SlaveId { get; set; } bool IsConnect { get; } void Connect(); Task ConnectAsync(); /// /// 重连 /// /// /// /// Task ReConnect(); ushort[] ReadBytes(ushort start, ushort length); /// /// 获取单个位状态 /// /// 从PLC里读出第几个字节 /// 第几位 /// bool GetBool(ushort start, ushort index); List> GetBoolList(IEnumerable addresses); /// /// 获取单个位状态 /// /// 从PLC里读出第几个字节 /// 第几位 /// Task GetBoolAsync(ushort start, ushort index); /// /// 写modbus位 /// /// 字节位置 /// 位索引 /// 位value void WriteBool(ushort start, int index, bool flag); /// /// 异步写modbus位 /// /// 字节位置 /// 位索引 /// 位value Task WriteBoolAsync(ushort start, int index, bool flag); void WriteInt32(ushort start, int value); Task WriteInt32Async(ushort start, int value); /// /// 写modbus位 /// /// /// /// void WriteByte(ushort start, int index, byte value); /// /// 写modbus位 /// /// /// /// Task WriteByteAsync(ushort start, int index, byte value); /// /// 写入双精度浮点 /// /// /// void WriteDouble(ushort start, double value); /// /// 异步写入双精度浮点 /// /// /// /// Task WriteDoubleAsync(ushort start, double value); /// /// 写入单精度浮点 /// /// /// void WriteFloat(ushort start, float value); /// /// 异步写入单精度浮点 /// /// /// /// Task WriteFloatAsync(ushort start, float value); /// /// 获取浮点数值 /// /// 数据索引 /// float GetFloat(ushort index); /// /// 获取浮点数值 /// /// 数据索引 /// Task GetFloatAsync(ushort index); /// /// 获取字 /// /// 数据索引 /// ushort GetShort(ushort index); /// /// 获取字 /// /// 数据索引 /// Task GetShortAsync(ushort index); /// /// 获取整型数值 /// /// 4字节整数 /// 数据索引 /// int GetInteger(ushort index); /// /// 异步获取整型数值 /// /// 4字节整数 /// 数据索引 /// Task GetIntegerAsync(ushort index); /// /// 读字节 /// /// 开始字索引 /// 第几个字节 /// Task GetByteAsync(ushort start, int index); /// /// 读字节 /// /// 开始字索引 /// 第几个字节 /// byte GetByte(ushort start, int index); ushort[] GetBytes(ushort start, ushort length); Task GetBytesAsync(ushort start, ushort length); event EventHandler ConnectChanged; } }