using RobotNet10.RobotApp.Client.Shared.Devices; namespace RobotNet10.RobotApp.Devices; /// /// Interface cung cấp các chức năng để quản lý và truy xuất devices /// public interface IDeviceProvider { /// /// Lấy device theo deviceId /// /// Định danh duy nhất của device /// Device nếu tìm thấy, null nếu không tìm thấy DeviceBase? GetDevice(string deviceId); /// /// Lấy device theo deviceId (async) /// /// Định danh duy nhất của device /// Cancellation token /// Device nếu tìm thấy, null nếu không tìm thấy Task GetDeviceAsync(string deviceId, CancellationToken cancellationToken = default); /// /// Lấy device theo deviceType (lấy device đầu tiên tìm thấy) /// /// Loại thiết bị /// Device nếu tìm thấy, null nếu không tìm thấy DeviceBase? GetDeviceByType(DeviceType deviceType); /// /// Lấy device theo deviceType (async) /// /// Loại thiết bị /// Cancellation token /// Device nếu tìm thấy, null nếu không tìm thấy Task GetDeviceByTypeAsync(DeviceType deviceType, CancellationToken cancellationToken = default); /// /// Lấy tất cả devices theo deviceType /// /// Loại thiết bị /// Danh sách devices của loại được chỉ định IReadOnlyList GetDevicesByType(DeviceType deviceType); /// /// Lấy tất cả devices theo deviceType (async) /// /// Loại thiết bị /// Cancellation token /// Danh sách devices của loại được chỉ định Task> GetDevicesByTypeAsync(DeviceType deviceType, CancellationToken cancellationToken = default); /// /// Lấy tất cả devices /// /// Danh sách tất cả devices IReadOnlyList GetAllDevices(); /// /// Lấy tất cả devices (async) /// /// Cancellation token /// Danh sách tất cả devices Task> GetAllDevicesAsync(CancellationToken cancellationToken = default); /// /// Kiểm tra device có tồn tại không /// /// Định danh của device /// True nếu device tồn tại, false nếu không bool ContainsDevice(string deviceId); /// /// Lấy số lượng devices /// /// Số lượng devices đã đăng ký int GetDeviceCount(); /// /// Lấy số lượng devices theo deviceType /// /// Loại thiết bị /// Số lượng devices của loại được chỉ định int GetDeviceCountByType(DeviceType deviceType); /// /// Kiểm tra xem tất cả devices đã được load chưa /// bool AreDevicesLoaded { get; } /// /// Kiểm tra xem tất cả devices đã kết nối chưa /// bool AreDevicesConnected { get; } /// /// Đợi cho đến khi tất cả devices đã được load /// /// Timeout để đợi /// Cancellation token /// True nếu devices đã load, false nếu timeout Task WaitForDevicesLoadedAsync(TimeSpan timeout, CancellationToken cancellationToken = default); /// /// Đợi cho đến khi tất cả devices đã kết nối /// /// Timeout để đợi /// Cancellation token /// True nếu devices đã connect, false nếu timeout Task WaitForDevicesConnectedAsync(TimeSpan timeout, CancellationToken cancellationToken = default); /// /// Event được kích hoạt khi tất cả devices đã được load /// event EventHandler? DevicesLoaded; /// /// Event được kích hoạt khi tất cả devices đã kết nối /// event EventHandler? DevicesConnected; }