feat(lmxproxy): phase 1 — v2 protocol types and domain model
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -6,99 +6,62 @@ using System.Threading.Tasks;
|
||||
namespace ZB.MOM.WW.LmxProxy.Host.Domain
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface for SCADA system clients.
|
||||
/// Interface for SCADA system clients (MxAccess wrapper).
|
||||
/// </summary>
|
||||
public interface IScadaClient : IAsyncDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the connection status.
|
||||
/// </summary>
|
||||
/// <summary>Gets whether the client is connected to MxAccess.</summary>
|
||||
bool IsConnected { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current connection state.
|
||||
/// </summary>
|
||||
/// <summary>Gets the current connection state.</summary>
|
||||
ConnectionState ConnectionState { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the connection state changes.
|
||||
/// </summary>
|
||||
/// <summary>Occurs when the connection state changes.</summary>
|
||||
event EventHandler<ConnectionStateChangedEventArgs> ConnectionStateChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Connects to the SCADA system.
|
||||
/// </summary>
|
||||
/// <param name="ct">Cancellation token.</param>
|
||||
/// <summary>Connects to MxAccess.</summary>
|
||||
Task ConnectAsync(CancellationToken ct = default);
|
||||
|
||||
/// <summary>
|
||||
/// Disconnects from the SCADA system.
|
||||
/// </summary>
|
||||
/// <param name="ct">Cancellation token.</param>
|
||||
/// <summary>Disconnects from MxAccess.</summary>
|
||||
Task DisconnectAsync(CancellationToken ct = default);
|
||||
|
||||
/// <summary>
|
||||
/// Reads a single tag value from the SCADA system.
|
||||
/// </summary>
|
||||
/// <param name="address">The tag address.</param>
|
||||
/// <param name="ct">Cancellation token.</param>
|
||||
/// <returns>The value, timestamp, and quality.</returns>
|
||||
/// <summary>Reads a single tag value.</summary>
|
||||
/// <returns>VTQ with typed value.</returns>
|
||||
Task<Vtq> ReadAsync(string address, CancellationToken ct = default);
|
||||
|
||||
/// <summary>
|
||||
/// Reads multiple tag values from the SCADA system.
|
||||
/// </summary>
|
||||
/// <param name="addresses">The tag addresses.</param>
|
||||
/// <param name="ct">Cancellation token.</param>
|
||||
/// <returns>Dictionary of address to VTQ values.</returns>
|
||||
Task<IReadOnlyDictionary<string, Vtq>>
|
||||
ReadBatchAsync(IEnumerable<string> addresses, CancellationToken ct = default);
|
||||
/// <summary>Reads multiple tag values with semaphore-controlled concurrency.</summary>
|
||||
/// <returns>Dictionary of address to VTQ.</returns>
|
||||
Task<IReadOnlyDictionary<string, Vtq>> ReadBatchAsync(IEnumerable<string> addresses, CancellationToken ct = default);
|
||||
|
||||
/// <summary>
|
||||
/// Writes a single tag value to the SCADA system.
|
||||
/// </summary>
|
||||
/// <param name="address">The tag address.</param>
|
||||
/// <param name="value">The value to write.</param>
|
||||
/// <param name="ct">Cancellation token.</param>
|
||||
/// <summary>Writes a single tag value. Value is a native .NET type (not string).</summary>
|
||||
Task WriteAsync(string address, object value, CancellationToken ct = default);
|
||||
|
||||
/// <summary>
|
||||
/// Writes multiple tag values to the SCADA system.
|
||||
/// </summary>
|
||||
/// <param name="values">Dictionary of address to value.</param>
|
||||
/// <param name="ct">Cancellation token.</param>
|
||||
/// <summary>Writes multiple tag values with semaphore-controlled concurrency.</summary>
|
||||
Task WriteBatchAsync(IReadOnlyDictionary<string, object> values, CancellationToken ct = default);
|
||||
|
||||
/// <summary>
|
||||
/// Writes a batch of tag values and a flag tag, then waits for a response tag to
|
||||
/// equal the expected value.
|
||||
/// Writes a batch of values, then polls flagTag until it equals flagValue or timeout expires.
|
||||
/// Returns (writeSuccess, flagReached, elapsedMs).
|
||||
/// </summary>
|
||||
/// <param name="values">The regular tag values to write.</param>
|
||||
/// <param name="flagAddress">The address of the flag tag to write.</param>
|
||||
/// <param name="flagValue">The value to write to the flag tag.</param>
|
||||
/// <param name="responseAddress">The address of the response tag to monitor.</param>
|
||||
/// <param name="responseValue">The expected value of the response tag.</param>
|
||||
/// <param name="ct">Cancellation token controlling the wait.</param>
|
||||
/// <returns>
|
||||
/// <c>true</c> if the response value was observed before cancellation;
|
||||
/// otherwise <c>false</c>.
|
||||
/// </returns>
|
||||
Task<bool> WriteBatchAndWaitAsync(
|
||||
/// <param name="values">Tag-value pairs to write.</param>
|
||||
/// <param name="flagTag">Tag to poll after writes.</param>
|
||||
/// <param name="flagValue">Expected value (type-aware comparison).</param>
|
||||
/// <param name="timeoutMs">Max wait time in milliseconds.</param>
|
||||
/// <param name="pollIntervalMs">Poll interval in milliseconds.</param>
|
||||
/// <param name="ct">Cancellation token.</param>
|
||||
Task<(bool flagReached, int elapsedMs)> WriteBatchAndWaitAsync(
|
||||
IReadOnlyDictionary<string, object> values,
|
||||
string flagAddress,
|
||||
string flagTag,
|
||||
object flagValue,
|
||||
string responseAddress,
|
||||
object responseValue,
|
||||
int timeoutMs,
|
||||
int pollIntervalMs,
|
||||
CancellationToken ct = default);
|
||||
|
||||
/// <summary>
|
||||
/// Subscribes to value changes for specified addresses.
|
||||
/// </summary>
|
||||
/// <param name="addresses">The tag addresses to monitor.</param>
|
||||
/// <param name="callback">Callback for value changes.</param>
|
||||
/// <param name="ct">Cancellation token.</param>
|
||||
/// <summary>Subscribes to value changes for specified addresses.</summary>
|
||||
/// <returns>Subscription handle for unsubscribing.</returns>
|
||||
Task<IAsyncDisposable> SubscribeAsync(IEnumerable<string> addresses, Action<string, Vtq> callback,
|
||||
Task<IAsyncDisposable> SubscribeAsync(
|
||||
IEnumerable<string> addresses,
|
||||
Action<string, Vtq> callback,
|
||||
CancellationToken ct = default);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user