Browse Source

优化测试设备日志读取

callm 3 days ago
parent
commit
d18a3059c2

+ 24 - 0
UAS_MES_ZDXW/.workbuddy/memory/2026-10-13.md

@@ -0,0 +1,24 @@
+## 2026-10-13 工作日志
+
+### Make_GetTestData 重构为双串口并发采集
+- 参考客户提供的"正大信维 4G-5G天线测试系统/index.html"逻辑,把单串口 SCPI 采集改为双串口并发采集
+- HTML 核心逻辑:向两个已连接串口同时发送同一条命令(FETCh?+CRLF) → 分别接收返回 → 取逗号前数据 → 上下限开区间判定 PASS/FAIL
+- Designer.cs: 单组串口控件拆为两组(ComList1/2 + BaudRate1/2 + DataBits1/2 + Parity1/2 + StopBits1/2 + Handshake1/2),新增 CommandBox(默认FETCh?) + LowerLimit(默认99000) + UpperLimit(默认101000),OperateResult 高度从 516 压缩到 340 腾空间
+- .cs 关键改动:
+  - CreateSerialPort(int portIndex) 按 0/1 读取对应组控件
+  - CollectFromPort(portIndex, command) 打开→WriteLine(command+\r\n)→Sleep(500)→ReadLine→关闭,每个串口在独立 Task 线程
+  - 用 Task.Factory.StartNew(不用 Task.Run,.NET 4.0 兼容) + Task.WaitAll 实现并发
+  - ExtractResistance(text) 取第一行+逗号前部分(对应HTML extractResistance)
+  - JudgePass(v1,v2,lower,upper) 开区间判定,等于边界判 FAIL(对应HTML judgeResult)
+  - 两路数据分别插入 STEPTESTDETAIL,std_class='4G-1'/'4G-2'
+  - 判定结果决定 SetStepResult 的 OK/NG
+- C# 7 兼容性修正:内联 out string reason 改为传统先声明后传递
+
+### Make_GetTestData 排版优化
+- 修复水平遮挡:lower_label(440+114=554) 遮挡 LowerLimit(536),upper_label(700+114=814) 遮挡 UpperLimit(796)
+  - lower_label x=440→400, LowerLimit x=536→492,标签(400+82=482)<控件(492) 间距10
+  - upper_label x=700→642, UpperLimit x=796→734,标签(642+82=724)<控件(734) 间距10
+  - "下限"/"上限" Size 从 (114,41) 修正为 (82,41) — 2字标签实际宽 82px,原误写 114
+- 串口行 x 坐标统一对齐:每对"标签+控件"间距统一 10~16px,串口1/串口2两行列 x 完全对齐
+- ComList 宽 200→180, Handshake 宽 180→150,总宽 1470 < ClientSize 1482
+- 命令行 y=560,串口1 y=624,串口2 y=692,sncode y=760

+ 448 - 173
UAS_MES_ZDXW/FunctionCode/Make/Make_GetTestData.Designer.cs

@@ -32,22 +32,40 @@ namespace UAS_MES_NEW.Make
             this.sncode_label = new System.Windows.Forms.Label();
             this.pr_code_label = new System.Windows.Forms.Label();
             this.ms_makecode_label = new System.Windows.Forms.Label();
-            this.com_label = new System.Windows.Forms.Label();
-            this.baudrate_label = new System.Windows.Forms.Label();
-            this.databits_label = new System.Windows.Forms.Label();
-            this.parity_label = new System.Windows.Forms.Label();
-            this.stopbits_label = new System.Windows.Forms.Label();
-            this.handshake_label = new System.Windows.Forms.Label();
+            this.command_label = new System.Windows.Forms.Label();
+            this.lower_label = new System.Windows.Forms.Label();
+            this.upper_label = new System.Windows.Forms.Label();
+            this.port1_label = new System.Windows.Forms.Label();
+            this.port2_label = new System.Windows.Forms.Label();
+            this.baudrate1_label = new System.Windows.Forms.Label();
+            this.databits1_label = new System.Windows.Forms.Label();
+            this.parity1_label = new System.Windows.Forms.Label();
+            this.stopbits1_label = new System.Windows.Forms.Label();
+            this.handshake1_label = new System.Windows.Forms.Label();
+            this.baudrate2_label = new System.Windows.Forms.Label();
+            this.databits2_label = new System.Windows.Forms.Label();
+            this.parity2_label = new System.Windows.Forms.Label();
+            this.stopbits2_label = new System.Windows.Forms.Label();
+            this.handshake2_label = new System.Windows.Forms.Label();
             this.StepCount = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.SourceStepCount();
             this.ms_makecode = new UAS_MES_NEW.CustomControl.ValueLabel.ValueLabel();
             this.ms_prodcode = new UAS_MES_NEW.CustomControl.ValueLabel.ValueLabel();
             this.pr_detail = new UAS_MES_NEW.CustomControl.ValueLabel.ValueLabel();
-            this.ComList = new UAS_MES_NEW.CustomControl.ComBoxWithFocus.SerialPortCombox();
-            this.BaudRate = new System.Windows.Forms.ComboBox();
-            this.DataBits = new System.Windows.Forms.ComboBox();
-            this.Parity = new System.Windows.Forms.ComboBox();
-            this.StopBits = new System.Windows.Forms.ComboBox();
-            this.Handshake = new System.Windows.Forms.ComboBox();
+            this.CommandBox = new System.Windows.Forms.TextBox();
+            this.LowerLimit = new System.Windows.Forms.TextBox();
+            this.UpperLimit = new System.Windows.Forms.TextBox();
+            this.ComList1 = new UAS_MES_NEW.CustomControl.ComBoxWithFocus.SerialPortCombox();
+            this.ComList2 = new UAS_MES_NEW.CustomControl.ComBoxWithFocus.SerialPortCombox();
+            this.BaudRate1 = new System.Windows.Forms.ComboBox();
+            this.DataBits1 = new System.Windows.Forms.ComboBox();
+            this.Parity1 = new System.Windows.Forms.ComboBox();
+            this.StopBits1 = new System.Windows.Forms.ComboBox();
+            this.Handshake1 = new System.Windows.Forms.ComboBox();
+            this.BaudRate2 = new System.Windows.Forms.ComboBox();
+            this.DataBits2 = new System.Windows.Forms.ComboBox();
+            this.Parity2 = new System.Windows.Forms.ComboBox();
+            this.StopBits2 = new System.Windows.Forms.ComboBox();
+            this.Handshake2 = new System.Windows.Forms.ComboBox();
             this.sncode = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.SnCollectionBox();
             this.OperateResult = new UAS_MES_NEW.CustomControl.RichText.RichTextAutoBottom();
             this.SuspendLayout();
@@ -69,7 +87,7 @@ namespace UAS_MES_NEW.Make
             | System.Windows.Forms.AnchorStyles.Left)));
             this.sncode_label.AutoSize = true;
             this.sncode_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.sncode_label.Location = new System.Drawing.Point(28, 900);
+            this.sncode_label.Location = new System.Drawing.Point(28, 760);
             this.sncode_label.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.sncode_label.Name = "sncode_label";
             this.sncode_label.Size = new System.Drawing.Size(114, 41);
@@ -98,71 +116,170 @@ namespace UAS_MES_NEW.Make
             this.ms_makecode_label.TabIndex = 204;
             this.ms_makecode_label.Text = "工单编号";
             // 
-            // com_label
-            // 
-            this.com_label.AutoSize = true;
-            this.com_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.com_label.Location = new System.Drawing.Point(28, 764);
-            this.com_label.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
-            this.com_label.Name = "com_label";
-            this.com_label.Size = new System.Drawing.Size(82, 41);
-            this.com_label.TabIndex = 220;
-            this.com_label.Text = "串口";
-            // 
-            // baudrate_label
-            // 
-            this.baudrate_label.AutoSize = true;
-            this.baudrate_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.baudrate_label.Location = new System.Drawing.Point(392, 764);
-            this.baudrate_label.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
-            this.baudrate_label.Name = "baudrate_label";
-            this.baudrate_label.Size = new System.Drawing.Size(114, 41);
-            this.baudrate_label.TabIndex = 222;
-            this.baudrate_label.Text = "波特率";
-            // 
-            // databits_label
-            // 
-            this.databits_label.AutoSize = true;
-            this.databits_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.databits_label.Location = new System.Drawing.Point(712, 764);
-            this.databits_label.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
-            this.databits_label.Name = "databits_label";
-            this.databits_label.Size = new System.Drawing.Size(114, 41);
-            this.databits_label.TabIndex = 224;
-            this.databits_label.Text = "数据位";
-            // 
-            // parity_label
-            // 
-            this.parity_label.AutoSize = true;
-            this.parity_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.parity_label.Location = new System.Drawing.Point(968, 764);
-            this.parity_label.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
-            this.parity_label.Name = "parity_label";
-            this.parity_label.Size = new System.Drawing.Size(114, 41);
-            this.parity_label.TabIndex = 226;
-            this.parity_label.Text = "校验位";
-            // 
-            // stopbits_label
-            // 
-            this.stopbits_label.AutoSize = true;
-            this.stopbits_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.stopbits_label.Location = new System.Drawing.Point(28, 832);
-            this.stopbits_label.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
-            this.stopbits_label.Name = "stopbits_label";
-            this.stopbits_label.Size = new System.Drawing.Size(114, 41);
-            this.stopbits_label.TabIndex = 228;
-            this.stopbits_label.Text = "停止位";
-            // 
-            // handshake_label
-            // 
-            this.handshake_label.AutoSize = true;
-            this.handshake_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.handshake_label.Location = new System.Drawing.Point(392, 832);
-            this.handshake_label.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
-            this.handshake_label.Name = "handshake_label";
-            this.handshake_label.Size = new System.Drawing.Size(82, 41);
-            this.handshake_label.TabIndex = 230;
-            this.handshake_label.Text = "流控";
+            // command_label
+            // 
+            this.command_label.AutoSize = true;
+            this.command_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.command_label.Location = new System.Drawing.Point(26, 567);
+            this.command_label.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.command_label.Name = "command_label";
+            this.command_label.Size = new System.Drawing.Size(82, 41);
+            this.command_label.TabIndex = 240;
+            this.command_label.Text = "命令";
+            // 
+            // lower_label
+            // 
+            this.lower_label.AutoSize = true;
+            this.lower_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.lower_label.Location = new System.Drawing.Point(398, 567);
+            this.lower_label.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.lower_label.Name = "lower_label";
+            this.lower_label.Size = new System.Drawing.Size(82, 41);
+            this.lower_label.TabIndex = 242;
+            this.lower_label.Text = "下限";
+            // 
+            // upper_label
+            // 
+            this.upper_label.AutoSize = true;
+            this.upper_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.upper_label.Location = new System.Drawing.Point(640, 567);
+            this.upper_label.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.upper_label.Name = "upper_label";
+            this.upper_label.Size = new System.Drawing.Size(82, 41);
+            this.upper_label.TabIndex = 244;
+            this.upper_label.Text = "上限";
+            // 
+            // port1_label
+            // 
+            this.port1_label.AutoSize = true;
+            this.port1_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.port1_label.Location = new System.Drawing.Point(28, 624);
+            this.port1_label.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.port1_label.Name = "port1_label";
+            this.port1_label.Size = new System.Drawing.Size(101, 41);
+            this.port1_label.TabIndex = 246;
+            this.port1_label.Text = "串口1";
+            // 
+            // port2_label
+            // 
+            this.port2_label.AutoSize = true;
+            this.port2_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.port2_label.Location = new System.Drawing.Point(28, 692);
+            this.port2_label.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.port2_label.Name = "port2_label";
+            this.port2_label.Size = new System.Drawing.Size(101, 41);
+            this.port2_label.TabIndex = 256;
+            this.port2_label.Text = "串口2";
+            // 
+            // baudrate1_label
+            // 
+            this.baudrate1_label.AutoSize = true;
+            this.baudrate1_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.baudrate1_label.Location = new System.Drawing.Point(310, 624);
+            this.baudrate1_label.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.baudrate1_label.Name = "baudrate1_label";
+            this.baudrate1_label.Size = new System.Drawing.Size(114, 41);
+            this.baudrate1_label.TabIndex = 248;
+            this.baudrate1_label.Text = "波特率";
+            // 
+            // databits1_label
+            // 
+            this.databits1_label.AutoSize = true;
+            this.databits1_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.databits1_label.Location = new System.Drawing.Point(550, 624);
+            this.databits1_label.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.databits1_label.Name = "databits1_label";
+            this.databits1_label.Size = new System.Drawing.Size(114, 41);
+            this.databits1_label.TabIndex = 250;
+            this.databits1_label.Text = "数据位";
+            // 
+            // parity1_label
+            // 
+            this.parity1_label.AutoSize = true;
+            this.parity1_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.parity1_label.Location = new System.Drawing.Point(770, 624);
+            this.parity1_label.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.parity1_label.Name = "parity1_label";
+            this.parity1_label.Size = new System.Drawing.Size(114, 41);
+            this.parity1_label.TabIndex = 252;
+            this.parity1_label.Text = "校验位";
+            // 
+            // stopbits1_label
+            // 
+            this.stopbits1_label.AutoSize = true;
+            this.stopbits1_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.stopbits1_label.Location = new System.Drawing.Point(1010, 624);
+            this.stopbits1_label.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.stopbits1_label.Name = "stopbits1_label";
+            this.stopbits1_label.Size = new System.Drawing.Size(114, 41);
+            this.stopbits1_label.TabIndex = 254;
+            this.stopbits1_label.Text = "停止位";
+            // 
+            // handshake1_label
+            // 
+            this.handshake1_label.AutoSize = true;
+            this.handshake1_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.handshake1_label.Location = new System.Drawing.Point(1230, 624);
+            this.handshake1_label.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.handshake1_label.Name = "handshake1_label";
+            this.handshake1_label.Size = new System.Drawing.Size(82, 41);
+            this.handshake1_label.TabIndex = 255;
+            this.handshake1_label.Text = "流控";
+            // 
+            // baudrate2_label
+            // 
+            this.baudrate2_label.AutoSize = true;
+            this.baudrate2_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.baudrate2_label.Location = new System.Drawing.Point(310, 692);
+            this.baudrate2_label.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.baudrate2_label.Name = "baudrate2_label";
+            this.baudrate2_label.Size = new System.Drawing.Size(114, 41);
+            this.baudrate2_label.TabIndex = 258;
+            this.baudrate2_label.Text = "波特率";
+            // 
+            // databits2_label
+            // 
+            this.databits2_label.AutoSize = true;
+            this.databits2_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.databits2_label.Location = new System.Drawing.Point(550, 692);
+            this.databits2_label.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.databits2_label.Name = "databits2_label";
+            this.databits2_label.Size = new System.Drawing.Size(114, 41);
+            this.databits2_label.TabIndex = 260;
+            this.databits2_label.Text = "数据位";
+            // 
+            // parity2_label
+            // 
+            this.parity2_label.AutoSize = true;
+            this.parity2_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.parity2_label.Location = new System.Drawing.Point(770, 692);
+            this.parity2_label.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.parity2_label.Name = "parity2_label";
+            this.parity2_label.Size = new System.Drawing.Size(114, 41);
+            this.parity2_label.TabIndex = 262;
+            this.parity2_label.Text = "校验位";
+            // 
+            // stopbits2_label
+            // 
+            this.stopbits2_label.AutoSize = true;
+            this.stopbits2_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.stopbits2_label.Location = new System.Drawing.Point(1010, 692);
+            this.stopbits2_label.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.stopbits2_label.Name = "stopbits2_label";
+            this.stopbits2_label.Size = new System.Drawing.Size(114, 41);
+            this.stopbits2_label.TabIndex = 264;
+            this.stopbits2_label.Text = "停止位";
+            // 
+            // handshake2_label
+            // 
+            this.handshake2_label.AutoSize = true;
+            this.handshake2_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.handshake2_label.Location = new System.Drawing.Point(1230, 692);
+            this.handshake2_label.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.handshake2_label.Name = "handshake2_label";
+            this.handshake2_label.Size = new System.Drawing.Size(82, 41);
+            this.handshake2_label.TabIndex = 265;
+            this.handshake2_label.Text = "流控";
             // 
             // StepCount
             // 
@@ -211,94 +328,213 @@ namespace UAS_MES_NEW.Make
             this.pr_detail.Size = new System.Drawing.Size(0, 41);
             this.pr_detail.TabIndex = 212;
             // 
-            // ComList
-            // 
-            this.ComList.Location = new System.Drawing.Point(124, 756);
-            this.ComList.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
-            this.ComList.Name = "ComList";
-            this.ComList.Size = new System.Drawing.Size(240, 56);
-            this.ComList.TabIndex = 221;
-            // 
-            // BaudRate
-            // 
-            this.BaudRate.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
-            this.BaudRate.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.BaudRate.FormattingEnabled = true;
-            this.BaudRate.Items.AddRange(new object[] {
+            // CommandBox
+            // 
+            this.CommandBox.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.CommandBox.Location = new System.Drawing.Point(120, 564);
+            this.CommandBox.Margin = new System.Windows.Forms.Padding(6);
+            this.CommandBox.Name = "CommandBox";
+            this.CommandBox.Size = new System.Drawing.Size(260, 50);
+            this.CommandBox.TabIndex = 241;
+            this.CommandBox.Text = "FETCh?";
+            // 
+            // LowerLimit
+            // 
+            this.LowerLimit.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.LowerLimit.Location = new System.Drawing.Point(492, 564);
+            this.LowerLimit.Margin = new System.Windows.Forms.Padding(6);
+            this.LowerLimit.Name = "LowerLimit";
+            this.LowerLimit.Size = new System.Drawing.Size(130, 50);
+            this.LowerLimit.TabIndex = 243;
+            this.LowerLimit.Text = "99000";
+            // 
+            // UpperLimit
+            // 
+            this.UpperLimit.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.UpperLimit.Location = new System.Drawing.Point(734, 564);
+            this.UpperLimit.Margin = new System.Windows.Forms.Padding(6);
+            this.UpperLimit.Name = "UpperLimit";
+            this.UpperLimit.Size = new System.Drawing.Size(130, 50);
+            this.UpperLimit.TabIndex = 245;
+            this.UpperLimit.Text = "101000";
+            // 
+            // ComList1
+            // 
+            this.ComList1.Location = new System.Drawing.Point(120, 624);
+            this.ComList1.Margin = new System.Windows.Forms.Padding(4);
+            this.ComList1.Name = "ComList1";
+            this.ComList1.Size = new System.Drawing.Size(180, 56);
+            this.ComList1.TabIndex = 247;
+            // 
+            // ComList2
+            // 
+            this.ComList2.Location = new System.Drawing.Point(120, 692);
+            this.ComList2.Margin = new System.Windows.Forms.Padding(4);
+            this.ComList2.Name = "ComList2";
+            this.ComList2.Size = new System.Drawing.Size(180, 56);
+            this.ComList2.TabIndex = 257;
+            // 
+            // BaudRate1
+            // 
+            this.BaudRate1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+            this.BaudRate1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.BaudRate1.FormattingEnabled = true;
+            this.BaudRate1.Items.AddRange(new object[] {
+            "9600",
+            "19200",
+            "38400",
+            "57600",
+            "115200"});
+            this.BaudRate1.Location = new System.Drawing.Point(440, 624);
+            this.BaudRate1.Margin = new System.Windows.Forms.Padding(6);
+            this.BaudRate1.Name = "BaudRate1";
+            this.BaudRate1.Size = new System.Drawing.Size(100, 49);
+            this.BaudRate1.TabIndex = 249;
+            // 
+            // DataBits1
+            // 
+            this.DataBits1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+            this.DataBits1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.DataBits1.FormattingEnabled = true;
+            this.DataBits1.Items.AddRange(new object[] {
+            "8",
+            "7",
+            "6",
+            "5"});
+            this.DataBits1.Location = new System.Drawing.Point(680, 624);
+            this.DataBits1.Margin = new System.Windows.Forms.Padding(6);
+            this.DataBits1.Name = "DataBits1";
+            this.DataBits1.Size = new System.Drawing.Size(80, 49);
+            this.DataBits1.TabIndex = 251;
+            // 
+            // Parity1
+            // 
+            this.Parity1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+            this.Parity1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.Parity1.FormattingEnabled = true;
+            this.Parity1.Items.AddRange(new object[] {
+            "None",
+            "Odd",
+            "Even",
+            "Mark",
+            "Space"});
+            this.Parity1.Location = new System.Drawing.Point(900, 624);
+            this.Parity1.Margin = new System.Windows.Forms.Padding(6);
+            this.Parity1.Name = "Parity1";
+            this.Parity1.Size = new System.Drawing.Size(100, 49);
+            this.Parity1.TabIndex = 253;
+            // 
+            // StopBits1
+            // 
+            this.StopBits1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+            this.StopBits1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.StopBits1.FormattingEnabled = true;
+            this.StopBits1.Items.AddRange(new object[] {
+            "1",
+            "1.5",
+            "2"});
+            this.StopBits1.Location = new System.Drawing.Point(1140, 624);
+            this.StopBits1.Margin = new System.Windows.Forms.Padding(6);
+            this.StopBits1.Name = "StopBits1";
+            this.StopBits1.Size = new System.Drawing.Size(80, 49);
+            this.StopBits1.TabIndex = 255;
+            // 
+            // Handshake1
+            // 
+            this.Handshake1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+            this.Handshake1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.Handshake1.FormattingEnabled = true;
+            this.Handshake1.Items.AddRange(new object[] {
+            "None",
+            "Hardware",
+            "XOnXOff",
+            "Both"});
+            this.Handshake1.Location = new System.Drawing.Point(1320, 624);
+            this.Handshake1.Margin = new System.Windows.Forms.Padding(6);
+            this.Handshake1.Name = "Handshake1";
+            this.Handshake1.Size = new System.Drawing.Size(150, 49);
+            this.Handshake1.TabIndex = 256;
+            // 
+            // BaudRate2
+            // 
+            this.BaudRate2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+            this.BaudRate2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.BaudRate2.FormattingEnabled = true;
+            this.BaudRate2.Items.AddRange(new object[] {
             "9600",
             "19200",
             "38400",
             "57600",
             "115200"});
-            this.BaudRate.Location = new System.Drawing.Point(520, 756);
-            this.BaudRate.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
-            this.BaudRate.Name = "BaudRate";
-            this.BaudRate.Size = new System.Drawing.Size(156, 49);
-            this.BaudRate.TabIndex = 223;
-            // 
-            // DataBits
-            // 
-            this.DataBits.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
-            this.DataBits.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.DataBits.FormattingEnabled = true;
-            this.DataBits.Items.AddRange(new object[] {
+            this.BaudRate2.Location = new System.Drawing.Point(440, 692);
+            this.BaudRate2.Margin = new System.Windows.Forms.Padding(6);
+            this.BaudRate2.Name = "BaudRate2";
+            this.BaudRate2.Size = new System.Drawing.Size(100, 49);
+            this.BaudRate2.TabIndex = 259;
+            // 
+            // DataBits2
+            // 
+            this.DataBits2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+            this.DataBits2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.DataBits2.FormattingEnabled = true;
+            this.DataBits2.Items.AddRange(new object[] {
             "8",
             "7",
             "6",
             "5"});
-            this.DataBits.Location = new System.Drawing.Point(840, 756);
-            this.DataBits.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
-            this.DataBits.Name = "DataBits";
-            this.DataBits.Size = new System.Drawing.Size(96, 49);
-            this.DataBits.TabIndex = 225;
-            // 
-            // Parity
-            // 
-            this.Parity.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
-            this.Parity.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.Parity.FormattingEnabled = true;
-            this.Parity.Items.AddRange(new object[] {
+            this.DataBits2.Location = new System.Drawing.Point(680, 692);
+            this.DataBits2.Margin = new System.Windows.Forms.Padding(6);
+            this.DataBits2.Name = "DataBits2";
+            this.DataBits2.Size = new System.Drawing.Size(80, 49);
+            this.DataBits2.TabIndex = 261;
+            // 
+            // Parity2
+            // 
+            this.Parity2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+            this.Parity2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.Parity2.FormattingEnabled = true;
+            this.Parity2.Items.AddRange(new object[] {
             "None",
             "Odd",
             "Even",
             "Mark",
             "Space"});
-            this.Parity.Location = new System.Drawing.Point(1096, 756);
-            this.Parity.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
-            this.Parity.Name = "Parity";
-            this.Parity.Size = new System.Drawing.Size(176, 49);
-            this.Parity.TabIndex = 227;
-            // 
-            // StopBits
-            // 
-            this.StopBits.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
-            this.StopBits.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.StopBits.FormattingEnabled = true;
-            this.StopBits.Items.AddRange(new object[] {
+            this.Parity2.Location = new System.Drawing.Point(900, 692);
+            this.Parity2.Margin = new System.Windows.Forms.Padding(6);
+            this.Parity2.Name = "Parity2";
+            this.Parity2.Size = new System.Drawing.Size(100, 49);
+            this.Parity2.TabIndex = 263;
+            // 
+            // StopBits2
+            // 
+            this.StopBits2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+            this.StopBits2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.StopBits2.FormattingEnabled = true;
+            this.StopBits2.Items.AddRange(new object[] {
             "1",
             "1.5",
             "2"});
-            this.StopBits.Location = new System.Drawing.Point(160, 824);
-            this.StopBits.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
-            this.StopBits.Name = "StopBits";
-            this.StopBits.Size = new System.Drawing.Size(96, 49);
-            this.StopBits.TabIndex = 229;
-            // 
-            // Handshake
-            // 
-            this.Handshake.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
-            this.Handshake.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.Handshake.FormattingEnabled = true;
-            this.Handshake.Items.AddRange(new object[] {
+            this.StopBits2.Location = new System.Drawing.Point(1140, 692);
+            this.StopBits2.Margin = new System.Windows.Forms.Padding(6);
+            this.StopBits2.Name = "StopBits2";
+            this.StopBits2.Size = new System.Drawing.Size(80, 49);
+            this.StopBits2.TabIndex = 265;
+            // 
+            // Handshake2
+            // 
+            this.Handshake2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+            this.Handshake2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.Handshake2.FormattingEnabled = true;
+            this.Handshake2.Items.AddRange(new object[] {
             "None",
             "Hardware",
             "XOnXOff",
             "Both"});
-            this.Handshake.Location = new System.Drawing.Point(480, 824);
-            this.Handshake.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
-            this.Handshake.Name = "Handshake";
-            this.Handshake.Size = new System.Drawing.Size(216, 49);
-            this.Handshake.TabIndex = 231;
+            this.Handshake2.Location = new System.Drawing.Point(1320, 692);
+            this.Handshake2.Margin = new System.Windows.Forms.Padding(6);
+            this.Handshake2.Name = "Handshake2";
+            this.Handshake2.Size = new System.Drawing.Size(150, 49);
+            this.Handshake2.TabIndex = 266;
             // 
             // sncode
             // 
@@ -307,7 +543,7 @@ namespace UAS_MES_NEW.Make
             | System.Windows.Forms.AnchorStyles.Left)));
             this.sncode.BackColor = System.Drawing.Color.White;
             this.sncode.ID = null;
-            this.sncode.Location = new System.Drawing.Point(154, 906);
+            this.sncode.Location = new System.Drawing.Point(154, 760);
             this.sncode.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
             this.sncode.Name = "sncode";
             this.sncode.Power = null;
@@ -322,10 +558,10 @@ namespace UAS_MES_NEW.Make
             // OperateResult
             // 
             this.OperateResult.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.OperateResult.Location = new System.Drawing.Point(20, 212);
+            this.OperateResult.Location = new System.Drawing.Point(20, 200);
             this.OperateResult.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
             this.OperateResult.Name = "OperateResult";
-            this.OperateResult.Size = new System.Drawing.Size(1438, 516);
+            this.OperateResult.Size = new System.Drawing.Size(1438, 340);
             this.OperateResult.TabIndex = 208;
             this.OperateResult.Text = "";
             // 
@@ -335,18 +571,36 @@ namespace UAS_MES_NEW.Make
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(1482, 980);
             this.Controls.Add(this.StepCount);
-            this.Controls.Add(this.Handshake);
-            this.Controls.Add(this.handshake_label);
-            this.Controls.Add(this.StopBits);
-            this.Controls.Add(this.stopbits_label);
-            this.Controls.Add(this.Parity);
-            this.Controls.Add(this.parity_label);
-            this.Controls.Add(this.DataBits);
-            this.Controls.Add(this.databits_label);
-            this.Controls.Add(this.BaudRate);
-            this.Controls.Add(this.baudrate_label);
-            this.Controls.Add(this.ComList);
-            this.Controls.Add(this.com_label);
+            this.Controls.Add(this.Handshake2);
+            this.Controls.Add(this.handshake2_label);
+            this.Controls.Add(this.StopBits2);
+            this.Controls.Add(this.stopbits2_label);
+            this.Controls.Add(this.Parity2);
+            this.Controls.Add(this.parity2_label);
+            this.Controls.Add(this.DataBits2);
+            this.Controls.Add(this.databits2_label);
+            this.Controls.Add(this.BaudRate2);
+            this.Controls.Add(this.baudrate2_label);
+            this.Controls.Add(this.ComList2);
+            this.Controls.Add(this.port2_label);
+            this.Controls.Add(this.Handshake1);
+            this.Controls.Add(this.handshake1_label);
+            this.Controls.Add(this.StopBits1);
+            this.Controls.Add(this.stopbits1_label);
+            this.Controls.Add(this.Parity1);
+            this.Controls.Add(this.parity1_label);
+            this.Controls.Add(this.DataBits1);
+            this.Controls.Add(this.databits1_label);
+            this.Controls.Add(this.BaudRate1);
+            this.Controls.Add(this.baudrate1_label);
+            this.Controls.Add(this.ComList1);
+            this.Controls.Add(this.port1_label);
+            this.Controls.Add(this.UpperLimit);
+            this.Controls.Add(this.upper_label);
+            this.Controls.Add(this.LowerLimit);
+            this.Controls.Add(this.lower_label);
+            this.Controls.Add(this.CommandBox);
+            this.Controls.Add(this.command_label);
             this.Controls.Add(this.ms_makecode);
             this.Controls.Add(this.ms_prodcode);
             this.Controls.Add(this.pr_detail);
@@ -357,7 +611,7 @@ namespace UAS_MES_NEW.Make
             this.Controls.Add(this.pr_code_label);
             this.Controls.Add(this.ms_makecode_label);
             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
-            this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+            this.Margin = new System.Windows.Forms.Padding(4);
             this.Name = "Make_GetTestData";
             this.Tag = "Make!GetTestData";
             this.Text = "测试数据获取";
@@ -380,17 +634,38 @@ namespace UAS_MES_NEW.Make
         private CustomControl.ValueLabel.ValueLabel ms_prodcode;
         private CustomControl.ValueLabel.ValueLabel pr_detail;
         private CustomControl.TextBoxWithIcon.SourceStepCount StepCount;
-        private System.Windows.Forms.Label com_label;
-        private CustomControl.ComBoxWithFocus.SerialPortCombox ComList;
-        private System.Windows.Forms.Label baudrate_label;
-        private System.Windows.Forms.ComboBox BaudRate;
-        private System.Windows.Forms.Label databits_label;
-        private System.Windows.Forms.ComboBox DataBits;
-        private System.Windows.Forms.Label parity_label;
-        private System.Windows.Forms.ComboBox Parity;
-        private System.Windows.Forms.Label stopbits_label;
-        private System.Windows.Forms.ComboBox StopBits;
-        private System.Windows.Forms.Label handshake_label;
-        private System.Windows.Forms.ComboBox Handshake;
+        // 命令 + 上下限
+        private System.Windows.Forms.Label command_label;
+        private System.Windows.Forms.TextBox CommandBox;
+        private System.Windows.Forms.Label lower_label;
+        private System.Windows.Forms.TextBox LowerLimit;
+        private System.Windows.Forms.Label upper_label;
+        private System.Windows.Forms.TextBox UpperLimit;
+        // 串口1
+        private System.Windows.Forms.Label port1_label;
+        private CustomControl.ComBoxWithFocus.SerialPortCombox ComList1;
+        private System.Windows.Forms.Label baudrate1_label;
+        private System.Windows.Forms.ComboBox BaudRate1;
+        private System.Windows.Forms.Label databits1_label;
+        private System.Windows.Forms.ComboBox DataBits1;
+        private System.Windows.Forms.Label parity1_label;
+        private System.Windows.Forms.ComboBox Parity1;
+        private System.Windows.Forms.Label stopbits1_label;
+        private System.Windows.Forms.ComboBox StopBits1;
+        private System.Windows.Forms.Label handshake1_label;
+        private System.Windows.Forms.ComboBox Handshake1;
+        // 串口2
+        private System.Windows.Forms.Label port2_label;
+        private CustomControl.ComBoxWithFocus.SerialPortCombox ComList2;
+        private System.Windows.Forms.Label baudrate2_label;
+        private System.Windows.Forms.ComboBox BaudRate2;
+        private System.Windows.Forms.Label databits2_label;
+        private System.Windows.Forms.ComboBox DataBits2;
+        private System.Windows.Forms.Label parity2_label;
+        private System.Windows.Forms.ComboBox Parity2;
+        private System.Windows.Forms.Label stopbits2_label;
+        private System.Windows.Forms.ComboBox StopBits2;
+        private System.Windows.Forms.Label handshake2_label;
+        private System.Windows.Forms.ComboBox Handshake2;
     }
 }

+ 159 - 68
UAS_MES_ZDXW/FunctionCode/Make/Make_GetTestData.cs

@@ -3,7 +3,9 @@ using System.ComponentModel;
 using System.Data;
 using System.Drawing;
 using System.IO.Ports;
+using System.Text;
 using System.Threading;
+using System.Threading.Tasks;
 using System.Windows.Forms;
 using UAS_MES_NEW.DataOperate;
 using UAS_MES_NEW.Entity;
@@ -30,12 +32,17 @@ namespace UAS_MES_NEW.Make
         {
             asc.controllInitializeSize(this);
             dh = SystemInf.dh;
-            //默认选中串口参数(SCPI协议: 9600/8/N/1/None)
-            BaudRate.SelectedIndex = 0;
-            DataBits.SelectedIndex = 0;
-            Parity.SelectedIndex = 0;
-            StopBits.SelectedIndex = 0;
-            Handshake.SelectedIndex = 0;
+            //默认选中两组串口参数(SCPI协议: 9600/8/N/1/None)
+            BaudRate1.SelectedIndex = 0;
+            DataBits1.SelectedIndex = 0;
+            Parity1.SelectedIndex = 0;
+            StopBits1.SelectedIndex = 0;
+            Handshake1.SelectedIndex = 0;
+            BaudRate2.SelectedIndex = 0;
+            DataBits2.SelectedIndex = 0;
+            Parity2.SelectedIndex = 0;
+            StopBits2.SelectedIndex = 0;
+            Handshake2.SelectedIndex = 0;
             //聚焦SN输入框
             sncode.Focus();
             OperateResult.AppendText(">>请输入SN\n", Color.Black);
@@ -53,17 +60,40 @@ namespace UAS_MES_NEW.Make
         }
 
         /// <summary>
-        /// 根据界面设置创建并配置SerialPort
+        /// 根据界面第 portIndex 组串口设置创建并配置SerialPort
+        /// portIndex: 0=串口1, 1=串口2
         /// </summary>
-        private SerialPort CreateSerialPort(int readTimeout = 3000)
+        private SerialPort CreateSerialPort(int portIndex, int readTimeout = 3000)
         {
+            //读取对应组的控件值
+            string portName;
+            string baudText, dataBitsText, parityText, stopBitsText, handshakeText;
+            if (portIndex == 0)
+            {
+                portName = ComList1.Text;
+                baudText = BaudRate1.Text;
+                dataBitsText = DataBits1.Text;
+                parityText = Parity1.Text;
+                stopBitsText = StopBits1.Text;
+                handshakeText = Handshake1.Text;
+            }
+            else
+            {
+                portName = ComList2.Text;
+                baudText = BaudRate2.Text;
+                dataBitsText = DataBits2.Text;
+                parityText = Parity2.Text;
+                stopBitsText = StopBits2.Text;
+                handshakeText = Handshake2.Text;
+            }
+
             int baud = 9600;
-            int.TryParse(BaudRate.Text, out baud);
+            int.TryParse(baudText, out baud);
             int dataBits = 8;
-            int.TryParse(DataBits.Text, out dataBits);
+            int.TryParse(dataBitsText, out dataBits);
 
             System.IO.Ports.Parity parity = System.IO.Ports.Parity.None;
-            switch (Parity.Text)
+            switch (parityText)
             {
                 case "Odd": parity = System.IO.Ports.Parity.Odd; break;
                 case "Even": parity = System.IO.Ports.Parity.Even; break;
@@ -72,14 +102,14 @@ namespace UAS_MES_NEW.Make
             }
 
             System.IO.Ports.StopBits stopBits = System.IO.Ports.StopBits.One;
-            switch (StopBits.Text)
+            switch (stopBitsText)
             {
                 case "1.5": stopBits = System.IO.Ports.StopBits.OnePointFive; break;
                 case "2": stopBits = System.IO.Ports.StopBits.Two; break;
             }
 
             System.IO.Ports.Handshake handshake = System.IO.Ports.Handshake.None;
-            switch (Handshake.Text)
+            switch (handshakeText)
             {
                 case "Hardware": handshake = System.IO.Ports.Handshake.RequestToSend; break;
                 case "XOnXOff": handshake = System.IO.Ports.Handshake.XOnXOff; break;
@@ -87,80 +117,105 @@ namespace UAS_MES_NEW.Make
             }
 
             SerialPort sp = new SerialPort();
-            sp.PortName = ComList.Text;
+            sp.PortName = portName;
             sp.BaudRate = baud;
             sp.DataBits = dataBits;
             sp.Parity = parity;
             sp.StopBits = stopBits;
             sp.Handshake = handshake;
-            sp.NewLine = "\n";
+            sp.NewLine = "\r\n";
             sp.ReadTimeout = readTimeout;
             sp.WriteTimeout = 1000;
             return sp;
         }
 
         /// <summary>
-        /// 从台式电桥获取测试数据
-        /// 通讯协议: SCPI, 参数由界面设置
-        /// 发送格式: 指令 + 0x0A(换行)
-        /// 返回格式: 以回车换行结尾
+        /// 从指定串口采集数据:打开串口 -> 发送命令(回车结尾) -> 读取返回
+        /// 每个串口在独立线程中调用,互不干扰。
         /// </summary>
-        /// <returns>测量数据字符串, 多个值以逗号分隔; 失败返回空字符串</returns>
-        private string GetTestDataFromBridge()
+        /// <param name="portIndex">0=串口1, 1=串口2</param>
+        /// <param name="command">要发送的命令文本(不带换行)</param>
+        /// <returns>原始返回文本; 失败或无返回返回空字符串</returns>
+        private string CollectFromPort(int portIndex, string command)
         {
-            if (ComList.Text == "")
-            {
-                OperateResult.AppendText("<<请先选择串口\n", Color.Red);
+            string portName = portIndex == 0 ? ComList1.Text : ComList2.Text;
+            if (portName == "")
                 return "";
-            }
 
-            SerialPort sp = CreateSerialPort();
+            SerialPort sp = CreateSerialPort(portIndex);
             string result = "";
             try
             {
                 sp.Open();
-                //发送触发命令 *TRG
-                sp.WriteLine("*TRG");
-                //等待测量完成
+                //发送命令(WriteLine 自动追加 NewLine = \r\n)
+                sp.WriteLine(command);
+                //等待设备响应
                 Thread.Sleep(500);
-                //发送查询命令 FETCh? 获取测量数据
-                sp.WriteLine("FETCh?");
                 //读取返回数据(以回车换行结尾)
                 result = sp.ReadLine().Trim();
                 sp.Close();
             }
             catch (Exception ex)
             {
-                OperateResult.AppendText("<<串口通讯异常:" + ex.Message + "\n", Color.Red);
                 if (sp.IsOpen)
                     sp.Close();
-                return "";
+                //把异常信息带回主线程记录
+                result = "ERROR:" + ex.Message;
             }
             return result;
         }
 
         /// <summary>
-        /// 查询当前测量功能名称
+        /// 从串口返回文本中提取"逗号之前"的数据(对应HTML中的 extractResistance)
+        /// 仪器返回形如 "100500,0.25,OK" 时只取 "100500"
         /// </summary>
-        private string GetFunctionName()
+        private string ExtractResistance(string text)
         {
-            if (ComList.Text == "")
+            if (string.IsNullOrEmpty(text))
                 return "";
-            SerialPort sp = CreateSerialPort(2000);
-            string funcName = "";
-            try
+            string s = text;
+            //只取第一行有效内容
+            int nl = s.IndexOfAny(new char[] { '\r', '\n' });
+            if (nl >= 0)
+                s = s.Substring(0, nl);
+            //取第一个半角逗号之前的内容(兼容全角逗号)
+            int idx = s.IndexOf(',');
+            if (idx < 0) idx = s.IndexOf(',');
+            if (idx >= 0)
+                s = s.Substring(0, idx);
+            //清理不可见控制字符与首尾空白
+            StringBuilder sb = new StringBuilder();
+            foreach (char c in s)
             {
-                sp.Open();
-                sp.WriteLine("FUNCtion?");
-                funcName = sp.ReadLine().Trim();
-                sp.Close();
+                if (c >= 0x20 && c != 0x7F)
+                    sb.Append(c);
             }
-            catch
+            return sb.ToString().Trim();
+        }
+
+        /// <summary>
+        /// 判定两个电阻值是否都严格落在开区间 (lower, upper) 内(对应HTML中的 judgeResult)
+        /// 等于边界值判FAIL
+        /// </summary>
+        private bool JudgePass(string v1, string v2, double lower, double upper, out string reason)
+        {
+            reason = "";
+            double n1, n2;
+            if (!double.TryParse(v1, out n1))
             {
-                if (sp.IsOpen)
-                    sp.Close();
+                reason = "4G-1非数值(" + v1 + ")";
+                return false;
+            }
+            if (!double.TryParse(v2, out n2))
+            {
+                reason = "4G-2非数值(" + v2 + ")";
+                return false;
             }
-            return funcName;
+            if (n1 <= lower) { reason = "4G-1低于下限(" + v1 + "<=" + lower + ")"; return false; }
+            if (n1 >= upper) { reason = "4G-1高于上限(" + v1 + ">=" + upper + ")"; return false; }
+            if (n2 <= lower) { reason = "4G-2低于下限(" + v2 + "<=" + lower + ")"; return false; }
+            if (n2 >= upper) { reason = "4G-2高于上限(" + v2 + ">=" + upper + ")"; return false; }
+            return true;
         }
 
         private void LoadCollectedNum()
@@ -214,34 +269,68 @@ namespace UAS_MES_NEW.Make
                 BaseUtil.SetFormValue(this.Controls, dt);
                 LoadCollectedNum();
 
-                OperateResult.AppendText(">>" + sncode.Text + " SN校验通过, 开始读取台式电桥数据\n", Color.Black);
+                OperateResult.AppendText(">>" + sncode.Text + " SN校验通过, 开始双串口并发采集\n", Color.Black);
+
+                //5) 双串口并发采集(对应HTML doScan: 向两个已连接串口同时发送同一条命令)
+                string command = CommandBox.Text.Trim();
+                if (command == "")
+                {
+                    OperateResult.AppendText(">>发送命令不能为空\n", Color.Red, sncode);
+                    return;
+                }
 
-                //5) 从台式电桥获取测试数据
-                string testData = GetTestDataFromBridge();
-                if (testData == "")
+                //检查至少配置了一个串口
+                if (ComList1.Text == "" && ComList2.Text == "")
                 {
-                    OperateResult.AppendText(">>未获取到测试数据, 请检查串口连接\n", Color.Red, sncode);
+                    OperateResult.AppendText(">>请至少选择一个串口\n", Color.Red, sncode);
                     return;
                 }
 
-                OperateResult.AppendText(">>电桥返回数据:" + testData + "\n", Color.Black);
+                //并发: 两个串口各自在独立线程中打开、发送、读取(.NET 4.0 用 Task.Factory.StartNew)
+                var t1 = Task.Factory.StartNew(() => CollectFromPort(0, command));
+                var t2 = Task.Factory.StartNew(() => CollectFromPort(1, command));
+                Task.WaitAll(t1, t2);
 
-                //6) 解析数据并插入STEPTESTDETAIL
-                //电桥返回数据以逗号分隔多个测量值
-                string[] values = testData.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
-                //尝试获取当前测量功能
-                string funcName = GetFunctionName();
+                string raw1 = t1.Result;
+                string raw2 = t2.Result;
 
-                for (int i = 0; i < values.Length; i++)
+                //记录原始返回
+                if (raw1 != "")
+                    OperateResult.AppendText(">>[串口1]原始返回:" + raw1 + "\n", Color.Black);
+                else
+                    OperateResult.AppendText(">>[串口1]未返回数据(未配置或通讯失败)\n", Color.Red);
+                if (raw2 != "")
+                    OperateResult.AppendText(">>[串口2]原始返回:" + raw2 + "\n", Color.Black);
+                else
+                    OperateResult.AppendText(">>[串口2]未返回数据(未配置或通讯失败)\n", Color.Red);
+
+                //6) 提取逗号前的数据(对应HTML extractResistance)
+                string val1 = ExtractResistance(raw1);
+                string val2 = ExtractResistance(raw2);
+                OperateResult.AppendText(">>4G-1提取值:" + (val1 == "" ? "无" : val1) + "  4G-2提取值:" + (val2 == "" ? "无" : val2) + "\n", Color.Black);
+
+                //7) 插入STEPTESTDETAIL(两路数据分别入库)
+                if (val1 != "")
                 {
-                    string className = funcName != "" ? funcName + (i + 1) : "测量值" + (i + 1);
-                    string testResult = values[i].Trim();
-                    dh.ExecuteSql("insert into STEPTESTDETAIL(std_id,std_sn,std_indate,std_class,std_testtimes,std_testresult,std_badcode) values(STEPTESTDETAIL_seq.nextval,'" + sncode.Text + "',sysdate,'" + className + "','','" + testResult + "','')", "insert");
-                    OperateResult.AppendText(">>" + className + ":" + testResult + "\n", Color.Black);
+                    dh.ExecuteSql("insert into STEPTESTDETAIL(std_id,std_sn,std_indate,std_class,std_testtimes,std_testresult,std_badcode) values(STEPTESTDETAIL_seq.nextval,'" + sncode.Text + "',sysdate,'4G-1','','" + val1 + "','')", "insert");
                 }
+                if (val2 != "")
+                {
+                    dh.ExecuteSql("insert into STEPTESTDETAIL(std_id,std_sn,std_indate,std_class,std_testtimes,std_testresult,std_badcode) values(STEPTESTDETAIL_seq.nextval,'" + sncode.Text + "',sysdate,'4G-2','','" + val2 + "','')", "insert");
+                }
+
+                //8) 上下限判定(对应HTML judgeResult: 开区间, 不含边界)
+                double lower = 99000, upper = 101000;
+                double.TryParse(LowerLimit.Text, out lower);
+                double.TryParse(UpperLimit.Text, out upper);
+                string reason;
+                bool pass = JudgePass(val1, val2, lower, upper, out reason);
+
+                //9) 过站 SetStepResult(判定结果决定过站OK/NG)
+                string stepResult = pass ? "OK" : "NG";
+                string stepRemark = pass ? "双串口测试通过" : ("测试失败:" + reason);
 
-                //7) 过站 SetStepResult
-                if (LogicHandler.SetStepResult(oMakeCode, User.UserSourceCode, sncode.Text, "电桥测试", "OK", User.UserCode, out oErrorMessage))
+                if (LogicHandler.SetStepResult(oMakeCode, User.UserSourceCode, sncode.Text, "电桥测试", stepResult, User.UserCode, out oErrorMessage))
                 {
                     //提示正确返回时传递的信息
                     if (oErrorMessage.Contains("AFTERSUCCESS"))
@@ -249,9 +338,11 @@ namespace UAS_MES_NEW.Make
                     //刷新工单计数
                     LoadCollectedNum();
                     //记录日志
-                    LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, oMakeCode, User.UserLineCode, User.UserSourceCode, "电桥测试", "测试数据采集成功", sncode.Text, "");
-                    //SN核对成功
-                    OperateResult.AppendText("<<" + sncode.Text + "测试数据采集完成, 过站成功\n", Color.Green, sncode);
+                    LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, oMakeCode, User.UserLineCode, User.UserSourceCode, "电桥测试", stepRemark, sncode.Text, "");
+                    if (pass)
+                        OperateResult.AppendText("<<" + sncode.Text + "测试PASS(4G-1=" + val1 + " 4G-2=" + val2 + ") 过站成功\n", Color.Green, sncode);
+                    else
+                        OperateResult.AppendText("<<" + sncode.Text + "测试FAIL " + reason + " 过站记录NG\n", Color.Red, sncode);
                     OperateResult.AppendText(">>请输入SN\n", Color.Black);
                 }
                 else