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