using System.Collections.Generic;
using XP.Hardware.Detector.Abstractions.Enums;
namespace XP.Hardware.Detector.Config
{
///
/// 探测器通用配置基类 | Detector common configuration base class
/// 包含所有探测器的通用配置参数
///
public class DetectorConfig
{
///
/// 探测器类型 | Detector type
///
public DetectorType Type { get; set; }
///
/// IP 地址 | IP address
///
public string IP { get; set; }
///
/// 端口号 | Port number
///
public int Port { get; set; }
///
/// 图像存储路径 | Image save path
///
public string SavePath { get; set; }
///
/// 是否自动保存图像 | Whether to auto save images
///
public bool AutoSave { get; set; }
///
/// 获取支持的 Binning 选项(显示名称 → 索引)| Get supported binning options (display name → index)
/// 子类可重写以提供不同的选项列表
///
public virtual List GetSupportedBinnings()
{
return new List
{
new BinningOption("1×1", 0),
new BinningOption("2×2", 1),
};
}
///
/// 获取支持的 PGA(灵敏度)选项 | Get supported PGA (sensitivity) options
/// 子类可重写以提供不同的选项列表
///
public virtual List GetSupportedPgaValues()
{
return new List { 2, 3, 4, 5, 6, 7 };
}
///
/// 获取各 Binning 模式下的最大帧率 | Get max frame rate for each binning mode
/// 子类可重写以提供不同的限制
///
public virtual decimal GetMaxFrameRate(int binningIndex)
{
return 15m;
}
///
/// 获取指定 Binning 模式下的图像规格(像素尺寸、分辨率)| Get image spec for given binning mode
/// 子类可重写以提供不同的映射关系
///
/// Binning 索引 | Binning index
/// 图像规格 | Image specification
public virtual BinningImageSpec GetImageSpec(int binningIndex)
{
return new BinningImageSpec(0.139, 0.139, 3072, 3060);
}
}
///
/// Binning 模式下的图像规格 | Image specification for binning mode
/// 包含像素尺寸和图像分辨率,供重建 PC 使用
///
public class BinningImageSpec
{
///
/// X 方向像素尺寸(mm)| Pixel size in X direction (mm)
///
public double PixelX { get; }
///
/// Y 方向像素尺寸(mm)| Pixel size in Y direction (mm)
///
public double PixelY { get; }
///
/// 图像宽度(像素)| Image width (pixels)
///
public int ImageWidth { get; }
///
/// 图像高度(像素)| Image height (pixels)
///
public int ImageHeight { get; }
public BinningImageSpec(double pixelX, double pixelY, int imageWidth, int imageHeight)
{
PixelX = pixelX;
PixelY = pixelY;
ImageWidth = imageWidth;
ImageHeight = imageHeight;
}
}
///
/// Binning 选项模型 | Binning option model
///
public class BinningOption
{
///
/// 显示名称 | Display name
///
public string DisplayName { get; }
///
/// 索引值 | Index value
///
public int Index { get; }
public BinningOption(string displayName, int index)
{
DisplayName = displayName;
Index = index;
}
public override string ToString() => DisplayName;
}
}