You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lj_plc/Mesnac.PlcUtils/IPlc.cs

122 lines
3.6 KiB
C#

using HslCommunication;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Mesnac.PlcUtils
{
/// <summary>
/// PLC 工具类接口
/// </summary>
public interface IPlc
{
bool IsConnected { get; set; }
/// <summary>
/// 建立连接
/// </summary>
/// <param name="IP"></param>
/// <param name="port"></param>
/// <returns></returns>
bool Connect(string IP, int port);
/// <summary>
/// 断开连接
/// </summary>
/// <returns></returns>
bool DisConnect();
/// <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>
OperateResult<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);
}
}