23 lines
705 B
C#
23 lines
705 B
C#
|
|
namespace SSPCTester.Devices.Interfaces;
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 所有设备的公共连接接口。
|
||
|
|
/// </summary>
|
||
|
|
public interface IDeviceConnection
|
||
|
|
{
|
||
|
|
/// <summary>当前是否处于已连接状态。</summary>
|
||
|
|
bool IsConnected { get; }
|
||
|
|
|
||
|
|
/// <summary>设备的人类可读名称(用于 UI 显示与日志)。</summary>
|
||
|
|
string DisplayName { get; }
|
||
|
|
|
||
|
|
/// <summary>建立连接,返回是否成功。</summary>
|
||
|
|
Task<bool> ConnectAsync(CancellationToken ct = default);
|
||
|
|
|
||
|
|
/// <summary>断开连接。</summary>
|
||
|
|
Task DisconnectAsync();
|
||
|
|
|
||
|
|
/// <summary>连接状态变化事件。bool 参数为新的 IsConnected。</summary>
|
||
|
|
event EventHandler<bool>? ConnectionChanged;
|
||
|
|
}
|