using System.Threading; using System.Threading.Tasks; using XP.Hardware.Detector.Abstractions; using XP.Hardware.Detector.Abstractions.Enums; using XP.Hardware.Detector.Config; namespace XP.Hardware.Detector.Services { /// /// 探测器服务接口 | Detector service interface /// 提供无厂商耦合的通用服务方法 /// public interface IDetectorService { /// /// 当前探测器状态 | Current detector status /// DetectorStatus Status { get; } /// /// 当前探测器类型 | Current detector type /// DetectorType? Type { get; } /// /// 探测器是否已连接(已初始化)| Whether detector is connected (initialized) /// bool IsConnected { get; } /// /// 初始化探测器(连接)| Initialize detector (connect) /// /// 取消令牌 | Cancellation token /// 操作结果 | Operation result Task InitializeAsync(CancellationToken cancellationToken = default); /// /// 断开探测器连接 | Disconnect detector /// /// 操作结果 | Operation result Task DisconnectAsync(); /// /// 启动连续采集 | Start continuous acquisition /// /// 取消令牌 | Cancellation token /// 操作结果 | Operation result Task StartAcquisitionAsync(CancellationToken cancellationToken = default); /// /// 停止采集 | Stop acquisition /// /// 取消令牌 | Cancellation token /// 操作结果 | Operation result Task StopAcquisitionAsync(CancellationToken cancellationToken = default); /// /// 单帧采集 | Single frame acquisition /// /// 取消令牌 | Cancellation token /// 操作结果 | Operation result Task AcquireSingleFrameAsync(CancellationToken cancellationToken = default); /// /// 暗场校正 | Dark field correction /// /// 采集帧数 | Frame count /// 取消令牌 | Cancellation token /// 操作结果 | Operation result Task DarkCorrectionAsync(int frameCount = 10, CancellationToken cancellationToken = default); /// /// 增益校正(亮场校正)| Gain correction (bright field correction) /// /// 采集帧数 | Frame count /// 取消令牌 | Cancellation token /// 操作结果 | Operation result Task GainCorrectionAsync(int frameCount = 10, CancellationToken cancellationToken = default); /// /// 坏像素校正 | Bad pixel correction /// /// 取消令牌 | Cancellation token /// 操作结果 | Operation result Task BadPixelCorrectionAsync(CancellationToken cancellationToken = default); /// /// 执行自动校正(暗场+增益+坏像素)| Execute auto correction (dark + gain + bad pixel) /// /// 采集帧数 | Frame count /// 取消令牌 | Cancellation token /// 操作结果 | Operation result Task AutoCorrectionAsync(int frameCount = 10, CancellationToken cancellationToken = default); /// /// 应用探测器参数(Binning/PGA/帧率统一下发)| Apply detector parameters (Binning/PGA/FrameRate) /// /// Binning 索引 | Binning index /// PGA 灵敏度值 | PGA sensitivity value /// 帧率 | Frame rate /// 取消令牌 | Cancellation token /// 操作结果 | Operation result Task ApplyParametersAsync(int binningIndex, int pga, decimal frameRate, CancellationToken cancellationToken = default); /// /// 保存当前配置到文件 | Save current configuration to file /// /// Binning 索引 | Binning index /// PGA 灵敏度值 | PGA sensitivity value /// 帧率 | Frame rate /// 帧合并数 | Average frame count void SaveParameters(int binningIndex, int pga, decimal frameRate, int avgFrames); /// /// 获取探测器信息 | Get detector information /// /// 探测器信息 | Detector information DetectorInfo GetInfo(); /// /// 获取最后的错误信息 | Get last error information /// /// 错误结果 | Error result DetectorResult GetLastError(); /// /// 获取当前探测器配置 | Get current detector configuration /// 用于 UI 层获取探测器类型相关的参数选项 /// /// 探测器配置,未初始化时返回 null | Detector config, null if not initialized DetectorConfig GetCurrentConfig(); } }