using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; namespace AMWD.Protocols.Modbus.Common.Contracts { /// /// Represents a Modbus connection. /// public interface IModbusConnection : IDisposable { /// /// The connection type name. /// string Name { get; } /// /// Gets a value indicating whether the connection is open. /// bool IsConnected { get; } /// /// Opens the connection to the remote device. /// /// A cancellation token used to propagate notification that this operation should be canceled. /// An awaitable . Task ConnectAsync(CancellationToken cancellationToken = default); /// /// Closes the connection to the remote device. /// /// A cancellation token used to propagate notification that this operation should be canceled. /// An awaitable . Task DisconnectAsync(CancellationToken cancellationToken = default); /// /// Invokes a Modbus request. /// /// The Modbus request serialized in bytes. /// A function to validate whether the response is complete. /// A cancellation token used to propagate notification that this operation should be canceled. /// A list of s containing the response. Task> InvokeAsync(IReadOnlyList request, Func, bool> validateResponseComplete, CancellationToken cancellationToken = default); } }