|
|
@@ -0,0 +1,66 @@
|
|
|
+using IvfTl.Control.Entity;
|
|
|
+using ivf_tl_SerialHelper.Util;
|
|
|
+using Xunit;
|
|
|
+
|
|
|
+namespace ivf_tl_SerialHelper.Tests
|
|
|
+{
|
|
|
+ /// <summary>
|
|
|
+ /// M-06 回归护栏:CreateReadEEPROMvertMtStartPulse(well) 按 well 产出该 well 的 Z 焦点零点读命令地址。
|
|
|
+ /// builder 早已支持 case 1-16(地址 0x08+4*(well-1),与 autofocustool 权威表一致),
|
|
|
+ /// 此前 ComBin.ReadEEPROMvertMtStartPulseWait 硬编码 (1) 致 HAL.ReadWellFocusZeroWait 忽略 well 恒读 well-1(M-06)。
|
|
|
+ /// 修复=ComBin 加 well 参 + HAL 传 well(集成层 red→green 真机验证:修前各 well 全同→修后各异)。
|
|
|
+ /// 本类锁住 builder 的 per-well 地址表,防回归;字节为纯逻辑。
|
|
|
+ /// </summary>
|
|
|
+ public class FocusZeroBuilderTests
|
|
|
+ {
|
|
|
+ // 帧 5E 11 00 09 00 04 [addr] 04 00 + ORC;地址字节在 index[6]。
|
|
|
+ private static byte AddrOf(int well)
|
|
|
+ {
|
|
|
+ var custom = new CustomProtocol();
|
|
|
+ custom.CreateReadEEPROMvertMtStartPulse(well);
|
|
|
+ return custom.sendBuffer[6];
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>16 个 well 的焦点零点 EEPROM 地址低字节 = 0x08 + 4*(well-1)(autofocustool 权威表)。</summary>
|
|
|
+ [Theory]
|
|
|
+ [InlineData(1, 0x08)]
|
|
|
+ [InlineData(2, 0x0C)]
|
|
|
+ [InlineData(3, 0x10)]
|
|
|
+ [InlineData(4, 0x14)]
|
|
|
+ [InlineData(5, 0x18)]
|
|
|
+ [InlineData(6, 0x1C)]
|
|
|
+ [InlineData(7, 0x20)]
|
|
|
+ [InlineData(8, 0x24)]
|
|
|
+ [InlineData(9, 0x28)]
|
|
|
+ [InlineData(10, 0x2C)]
|
|
|
+ [InlineData(11, 0x30)]
|
|
|
+ [InlineData(12, 0x34)]
|
|
|
+ [InlineData(13, 0x38)]
|
|
|
+ [InlineData(14, 0x3C)]
|
|
|
+ [InlineData(15, 0x40)]
|
|
|
+ [InlineData(16, 0x44)]
|
|
|
+ public void 各well焦点零点地址按well分槽(int well, byte expectedAddr)
|
|
|
+ {
|
|
|
+ Assert.Equal(expectedAddr, AddrOf(well));
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>护栏:不同 well 必产不同地址(防回退到"忽略 well 恒读 well-1")。</summary>
|
|
|
+ [Fact]
|
|
|
+ public void 不同well产不同地址_非全well1()
|
|
|
+ {
|
|
|
+ Assert.NotEqual(AddrOf(1), AddrOf(2));
|
|
|
+ Assert.NotEqual(AddrOf(1), AddrOf(16));
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>well-1 完整帧字节(含 ORC)锁定。</summary>
|
|
|
+ [Fact]
|
|
|
+ public void well1完整帧字节()
|
|
|
+ {
|
|
|
+ var custom = new CustomProtocol();
|
|
|
+ custom.CreateReadEEPROMvertMtStartPulse(1);
|
|
|
+ // 5E 11 00 09 00 04 08 04 → ORC 覆写末位占位=前8字节和=0x88(帧 9 字节,CreateORC 不追加)
|
|
|
+ var expected = new byte[] { 0x5E, 0x11, 0x00, 0x09, 0x00, 0x04, 0x08, 0x04, 0x88 };
|
|
|
+ Assert.Equal(expected, custom.sendBuffer);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|