This commit is contained in:
GukSang.Jin
2026-01-05 11:26:01 +08:00
parent 365f6d63b9
commit 49b7e4b763

View File

@@ -1053,9 +1053,15 @@ namespace WindowsFormsApp6
/// <summary>
/// 读取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
/// 每次测试添加一个试样的一次测试数据,试样数量动态增长
/// </summary>
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行是吸芯高度