FocusRangeResolver.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. namespace IvfTl.AutoFocus.Layout
  2. {
  3. /// <summary>对焦范围就近优先解析:well级半幅 &gt; 设备级默认 &gt; 引擎硬编码默认。纯逻辑,仿 PhotoLayerCalculator。</summary>
  4. public class FocusRangeRawConfig
  5. {
  6. public int? WellHRange, WellVRange, DeviceHRange, DeviceVRange;
  7. public int ExposureMin, ExposureMax;
  8. public int HorizontalCenter, VerticalCenter;
  9. }
  10. public class FocusRangeConfig
  11. {
  12. public int HHalf, VHalf, ExpLo, ExpHi, HCenter, VCenter;
  13. }
  14. public static class FocusRangeResolver
  15. {
  16. // 与 CalibrationEngine 现有硬编码默认对齐(HFineRange=2000、FineZHalf=6000)。
  17. public const int DefaultHHalf = 2000;
  18. public const int DefaultVHalf = 6000;
  19. public static FocusRangeConfig Resolve(FocusRangeRawConfig raw)
  20. {
  21. if (raw == null) throw new System.ArgumentNullException(nameof(raw));
  22. return new FocusRangeConfig
  23. {
  24. HHalf = raw.WellHRange ?? raw.DeviceHRange ?? DefaultHHalf,
  25. VHalf = raw.WellVRange ?? raw.DeviceVRange ?? DefaultVHalf,
  26. ExpLo = raw.ExposureMin,
  27. ExpHi = raw.ExposureMax,
  28. HCenter = raw.HorizontalCenter,
  29. VCenter = raw.VerticalCenter,
  30. };
  31. }
  32. }
  33. }