| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- using System.Linq;
- using System.Threading;
- using IvfTl.Hardware.HilTests.Infrastructure;
- using IvfTl.Hardware.Impl;
- using Xunit;
- using Xunit.Abstractions;
- namespace IvfTl.Hardware.HilTests
- {
- /// <summary>
- /// M-06 防回归:control SerialChannelImpl.ReadWellFocusZeroWait(well) 必须按 well 读各自 Z 焦点零点。
- /// 修前 ComBin.ReadEEPROMvertMtStartPulseWait 硬编码 well-1 → 各 well 全返回同值(去重=1)=回归。
- /// 修后各 well 分槽(去重>1)。纯 0x11 EEPROM 读,无任何电机动作,非破坏。
- /// </summary>
- [Collection("HIL")]
- public class FocusZeroHilTests
- {
- private readonly HardwareRigFixture _rig;
- private readonly ITestOutputHelper _out;
- public FocusZeroHilTests(HardwareRigFixture rig, ITestOutputHelper o) { _rig = rig; _out = o; }
- [SkippableFact]
- public void PerWellFocusZero_IsDistinctPerWell_AndWithinSafeZ()
- {
- var chamber = _rig.FirstChamberWithWells();
- Skip.If(chamber == null, "无响应真舱:无硬件 / control 正占用串口 / 未连接");
- var vals = new int[17];
- SerialChannelImpl ch = null;
- try
- {
- ch = new SerialChannelImpl(0, chamber.Port);
- Assert.True(ch.Open(), $"{chamber.Port} 打开失败");
- for (int well = 1; well <= 16; well++)
- {
- vals[well] = ch.ReadWellFocusZeroWait(well);
- Thread.Sleep(120);
- }
- }
- finally { try { ch?.Close(); } catch { } }
- var read = vals.Skip(1).ToArray();
- _out.WriteLine($"舱{chamber.HouseSn} 各 well 焦点零点: {string.Join(",", read)}");
- int distinct = read.Distinct().Count();
- Assert.True(distinct > 1,
- $"按 well 读应各 well 不同(去重>1),实得去重={distinct}(=1 说明退回恒读 well-1=M-06 回归)");
- Assert.All(read, v => Assert.InRange(v, 0, 125000)); // 安全 Z 区间
- }
- }
- }
|