|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace HighWayIot.Plc
|
|
|
|
|
{
|
|
|
|
|
public interface IPlc
|
|
|
|
|
{
|
|
|
|
|
bool IsConnected { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool DisConnect();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 建立连接
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="IP"></param>
|
|
|
|
|
/// <param name="port"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
bool Connect(string IP, int port);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 读取心跳
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
Task<bool> ReadHeart(string address);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 通过地址和长度读取PLC数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="len"></param>
|
|
|
|
|
/// <param name="address"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
byte[] readValueByAddress(int len, string address);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 通过PLC地址写入int类型数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="value"></param>
|
|
|
|
|
/// <param name="address"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
bool writeValueByAddress(int value, string address);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 通过PLC地址清零数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="address"></param>
|
|
|
|
|
/// <param name="len"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
bool resetByAddress(string address, int len);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 通过PLC地址读取EA值
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="address"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
string readEaByAddress(string address);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 通过PLC地址读取交互信号
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="address"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
int readInteractiveSignal(string address);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 通过PLC地址读取int32类型数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="address"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
int readInt32ByAddress(string address);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 通过PLC地址写入int32类型数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="address"></param>
|
|
|
|
|
/// <param name="value"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
bool writeInt32ByAddress(string address, int value);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 通过PLC地址读取string类型数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="address"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
string readStringByAddress(string address, ushort length);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 通过PLC地址写入String类型数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="address"></param>
|
|
|
|
|
/// <param name="SFC"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
bool writeStringByAddress(string address, string value);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 通过PLC地址读取Bool类型数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="address"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
bool readBoolByAddress(string address);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 通过PLC地址写入Bool类型数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="address"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
bool writeBoolByAddress(string address, bool value);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 通过PLC地址写入Double类型数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="address"></param>
|
|
|
|
|
/// <param name="value"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
bool writeDoubleByAddress(string address, int value);
|
|
|
|
|
}
|
|
|
|
|
}
|