From 49b7e4b76338a9812701089efa9388ab1b734ec5 Mon Sep 17 00:00:00 2001 From: "GukSang.Jin" Date: Mon, 5 Jan 2026 11:26:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WindowsFormsApp6/MainForm.cs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/WindowsFormsApp6/MainForm.cs b/WindowsFormsApp6/MainForm.cs index b7342f7..90a9eed 100644 --- a/WindowsFormsApp6/MainForm.cs +++ b/WindowsFormsApp6/MainForm.cs @@ -1053,9 +1053,15 @@ namespace WindowsFormsApp6 /// /// 读取Form3数据(液体芯吸速率) /// PLC地址:D200 - 吸水时间(s),D454 - 吸芯高度(mm),每次测试读取1个试样(各2个字节) - /// 一组数据包含次试样1,包含 3次测试,二组数据包含次试样2,包含 3次测试, 依次类推 + /// + /// 数据结构说明: + /// - 每组试样包含3次测试数据(试样1_1, 试样1_2, 试样1_3) + /// - 每5个试样为一组,显示5列 + /// - 平均芯吸速率:计算每个试样3次测试的平均值,合并显示在该试样的第3列 + /// - 标准偏差:计算每组5个试样的标准偏差,合并显示在第1列 + /// - 试样数量动态增长 + /// /// 信号量:M310 - /// 每次测试添加一个试样的一次测试数据,试样数量动态增长 /// private void ReadForm3Data(byte slaveId) { @@ -1097,12 +1103,20 @@ namespace WindowsFormsApp6 double wickingTime = ConvertRegistersToDouble(timeRegisters); // 吸水时间(秒) double wickingHeight = ConvertRegistersToDouble(heightRegisters); // 吸芯高度(mm) + // 检查数据有效性 + if (double.IsNaN(wickingTime) || double.IsInfinity(wickingTime) || + double.IsNaN(wickingHeight) || double.IsInfinity(wickingHeight)) + { + System.Diagnostics.Debug.WriteLine("读取的数据无效,跳过本次读取"); + return; + } + // 确定当前要填充的位置(试样索引和测试次数) var position = GetNextForm3Position(dataTable, currentSampleCount, isVerticalLayout); int sampleIndex = position.Item1; // 试样索引(1-based) int testIndex = position.Item2; // 测试次数(1-3) - // 如果需要扩展试样数量 + // 如果需要扩展试样数量(动态增长) if (sampleIndex > currentSampleCount) { currentSampleCount = sampleIndex; @@ -1120,7 +1134,7 @@ namespace WindowsFormsApp6 dataTable = sampleDataTableField.GetValue(form3Instance) as DataTable; } - // 根据布局方式填充数据(精确参考GenerateMockData的方式) + // 根据布局方式填充数据 if (isVerticalLayout) { // 纵向布局:第1行是吸水时间,第2行是吸芯高度