FocusZeroHilTests.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System.Linq;
  2. using System.Threading;
  3. using IvfTl.Hardware.HilTests.Infrastructure;
  4. using IvfTl.Hardware.Impl;
  5. using Xunit;
  6. using Xunit.Abstractions;
  7. namespace IvfTl.Hardware.HilTests
  8. {
  9. /// <summary>
  10. /// M-06 防回归:control SerialChannelImpl.ReadWellFocusZeroWait(well) 必须按 well 读各自 Z 焦点零点。
  11. /// 修前 ComBin.ReadEEPROMvertMtStartPulseWait 硬编码 well-1 → 各 well 全返回同值(去重=1)=回归。
  12. /// 修后各 well 分槽(去重>1)。纯 0x11 EEPROM 读,无任何电机动作,非破坏。
  13. /// </summary>
  14. [Collection("HIL")]
  15. public class FocusZeroHilTests
  16. {
  17. private readonly HardwareRigFixture _rig;
  18. private readonly ITestOutputHelper _out;
  19. public FocusZeroHilTests(HardwareRigFixture rig, ITestOutputHelper o) { _rig = rig; _out = o; }
  20. [SkippableFact]
  21. public void PerWellFocusZero_IsDistinctPerWell_AndWithinSafeZ()
  22. {
  23. var chamber = _rig.FirstChamberWithWells();
  24. Skip.If(chamber == null, "无响应真舱:无硬件 / control 正占用串口 / 未连接");
  25. var vals = new int[17];
  26. SerialChannelImpl ch = null;
  27. try
  28. {
  29. ch = new SerialChannelImpl(0, chamber.Port);
  30. Assert.True(ch.Open(), $"{chamber.Port} 打开失败");
  31. for (int well = 1; well <= 16; well++)
  32. {
  33. vals[well] = ch.ReadWellFocusZeroWait(well);
  34. Thread.Sleep(120);
  35. }
  36. }
  37. finally { try { ch?.Close(); } catch { } }
  38. var read = vals.Skip(1).ToArray();
  39. _out.WriteLine($"舱{chamber.HouseSn} 各 well 焦点零点: {string.Join(",", read)}");
  40. int distinct = read.Distinct().Count();
  41. Assert.True(distinct > 1,
  42. $"按 well 读应各 well 不同(去重>1),实得去重={distinct}(=1 说明退回恒读 well-1=M-06 回归)");
  43. Assert.All(read, v => Assert.InRange(v, 0, 125000)); // 安全 Z 区间
  44. }
  45. }
  46. }