using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace ZB.MOM.WW.LmxProxy.Host.Domain
{
///
/// Interface for SCADA system clients.
///
public interface IScadaClient : IAsyncDisposable
{
///
/// Gets the connection status.
///
bool IsConnected { get; }
///
/// Gets the current connection state.
///
ConnectionState ConnectionState { get; }
///
/// Occurs when the connection state changes.
///
event EventHandler ConnectionStateChanged;
///
/// Connects to the SCADA system.
///
/// Cancellation token.
Task ConnectAsync(CancellationToken ct = default);
///
/// Disconnects from the SCADA system.
///
/// Cancellation token.
Task DisconnectAsync(CancellationToken ct = default);
///
/// Reads a single tag value from the SCADA system.
///
/// The tag address.
/// Cancellation token.
/// The value, timestamp, and quality.
Task ReadAsync(string address, CancellationToken ct = default);
///
/// Reads multiple tag values from the SCADA system.
///
/// The tag addresses.
/// Cancellation token.
/// Dictionary of address to VTQ values.
Task>
ReadBatchAsync(IEnumerable addresses, CancellationToken ct = default);
///
/// Writes a single tag value to the SCADA system.
///
/// The tag address.
/// The value to write.
/// Cancellation token.
Task WriteAsync(string address, object value, CancellationToken ct = default);
///
/// Writes multiple tag values to the SCADA system.
///
/// Dictionary of address to value.
/// Cancellation token.
Task WriteBatchAsync(IReadOnlyDictionary values, CancellationToken ct = default);
///
/// Writes a batch of tag values and a flag tag, then waits for a response tag to
/// equal the expected value.
///
/// The regular tag values to write.
/// The address of the flag tag to write.
/// The value to write to the flag tag.
/// The address of the response tag to monitor.
/// The expected value of the response tag.
/// Cancellation token controlling the wait.
///
/// true if the response value was observed before cancellation;
/// otherwise false.
///
Task WriteBatchAndWaitAsync(
IReadOnlyDictionary values,
string flagAddress,
object flagValue,
string responseAddress,
object responseValue,
CancellationToken ct = default);
///
/// Subscribes to value changes for specified addresses.
///
/// The tag addresses to monitor.
/// Callback for value changes.
/// Cancellation token.
/// Subscription handle for unsubscribing.
Task SubscribeAsync(IEnumerable addresses, Action callback,
CancellationToken ct = default);
}
}