99 lines
3.3 KiB
C#
99 lines
3.3 KiB
C#
namespace RobotNet10.Script.IO;
|
|
|
|
/// <summary>
|
|
/// Interface for ModbusTCP connection operations.
|
|
/// </summary>
|
|
public interface IModbusTcpConnection : IDisposable
|
|
{
|
|
/// <summary>
|
|
/// Gets the IP address of the ModbusTCP server.
|
|
/// </summary>
|
|
string IpAddress { get; }
|
|
|
|
/// <summary>
|
|
/// Gets the port of the ModbusTCP server.
|
|
/// </summary>
|
|
int Port { get; }
|
|
|
|
/// <summary>
|
|
/// Gets the slave ID (unit identifier).
|
|
/// </summary>
|
|
byte SlaveId { get; }
|
|
|
|
/// <summary>
|
|
/// Gets whether the connection is currently connected.
|
|
/// </summary>
|
|
bool IsConnected { get; }
|
|
|
|
/// <summary>
|
|
/// Connects to the ModbusTCP server.
|
|
/// </summary>
|
|
Task ConnectAsync();
|
|
|
|
/// <summary>
|
|
/// Disconnects from the ModbusTCP server.
|
|
/// </summary>
|
|
Task DisconnectAsync();
|
|
|
|
/// <summary>
|
|
/// Reads holding registers.
|
|
/// </summary>
|
|
/// <param name="startAddress">The starting address.</param>
|
|
/// <param name="numberOfPoints">The number of registers to read.</param>
|
|
/// <returns>Array of register values.</returns>
|
|
Task<ushort[]> ReadHoldingRegistersAsync(ushort startAddress, ushort numberOfPoints);
|
|
|
|
/// <summary>
|
|
/// Reads input registers.
|
|
/// </summary>
|
|
/// <param name="startAddress">The starting address.</param>
|
|
/// <param name="numberOfPoints">The number of registers to read.</param>
|
|
/// <returns>Array of register values.</returns>
|
|
Task<ushort[]> ReadInputRegistersAsync(ushort startAddress, ushort numberOfPoints);
|
|
|
|
/// <summary>
|
|
/// Reads coils.
|
|
/// </summary>
|
|
/// <param name="startAddress">The starting address.</param>
|
|
/// <param name="numberOfPoints">The number of coils to read.</param>
|
|
/// <returns>Array of coil values.</returns>
|
|
Task<bool[]> ReadCoilsAsync(ushort startAddress, ushort numberOfPoints);
|
|
|
|
/// <summary>
|
|
/// Reads discrete inputs.
|
|
/// </summary>
|
|
/// <param name="startAddress">The starting address.</param>
|
|
/// <param name="numberOfPoints">The number of inputs to read.</param>
|
|
/// <returns>Array of input values.</returns>
|
|
Task<bool[]> ReadDiscreteInputsAsync(ushort startAddress, ushort numberOfPoints);
|
|
|
|
/// <summary>
|
|
/// Writes a single coil.
|
|
/// </summary>
|
|
/// <param name="coilAddress">The coil address.</param>
|
|
/// <param name="value">The value to write.</param>
|
|
Task WriteSingleCoilAsync(ushort coilAddress, bool value);
|
|
|
|
/// <summary>
|
|
/// Writes multiple coils.
|
|
/// </summary>
|
|
/// <param name="startAddress">The starting address.</param>
|
|
/// <param name="values">The values to write.</param>
|
|
Task WriteMultipleCoilsAsync(ushort startAddress, bool[] values);
|
|
|
|
/// <summary>
|
|
/// Writes a single holding register.
|
|
/// </summary>
|
|
/// <param name="registerAddress">The register address.</param>
|
|
/// <param name="value">The value to write.</param>
|
|
Task WriteSingleRegisterAsync(ushort registerAddress, ushort value);
|
|
|
|
/// <summary>
|
|
/// Writes multiple holding registers.
|
|
/// </summary>
|
|
/// <param name="startAddress">The starting address.</param>
|
|
/// <param name="values">The values to write.</param>
|
|
Task WriteMultipleRegistersAsync(ushort startAddress, ushort[] values);
|
|
}
|
|
|