更新
This commit is contained in:
@@ -1053,9 +1053,15 @@ namespace WindowsFormsApp6
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 读取Form3数据(液体芯吸速率)
|
/// 读取Form3数据(液体芯吸速率)
|
||||||
/// PLC地址:D200 - 吸水时间(s),D454 - 吸芯高度(mm),每次测试读取1个试样(各2个字节)
|
/// 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
|
/// 信号量:M310
|
||||||
/// 每次测试添加一个试样的一次测试数据,试样数量动态增长
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void ReadForm3Data(byte slaveId)
|
private void ReadForm3Data(byte slaveId)
|
||||||
{
|
{
|
||||||
@@ -1097,12 +1103,20 @@ namespace WindowsFormsApp6
|
|||||||
double wickingTime = ConvertRegistersToDouble(timeRegisters); // 吸水时间(秒)
|
double wickingTime = ConvertRegistersToDouble(timeRegisters); // 吸水时间(秒)
|
||||||
double wickingHeight = ConvertRegistersToDouble(heightRegisters); // 吸芯高度(mm)
|
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);
|
var position = GetNextForm3Position(dataTable, currentSampleCount, isVerticalLayout);
|
||||||
int sampleIndex = position.Item1; // 试样索引(1-based)
|
int sampleIndex = position.Item1; // 试样索引(1-based)
|
||||||
int testIndex = position.Item2; // 测试次数(1-3)
|
int testIndex = position.Item2; // 测试次数(1-3)
|
||||||
|
|
||||||
// 如果需要扩展试样数量
|
// 如果需要扩展试样数量(动态增长)
|
||||||
if (sampleIndex > currentSampleCount)
|
if (sampleIndex > currentSampleCount)
|
||||||
{
|
{
|
||||||
currentSampleCount = sampleIndex;
|
currentSampleCount = sampleIndex;
|
||||||
@@ -1120,7 +1134,7 @@ namespace WindowsFormsApp6
|
|||||||
dataTable = sampleDataTableField.GetValue(form3Instance) as DataTable;
|
dataTable = sampleDataTableField.GetValue(form3Instance) as DataTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 根据布局方式填充数据(精确参考GenerateMockData的方式)
|
// 根据布局方式填充数据
|
||||||
if (isVerticalLayout)
|
if (isVerticalLayout)
|
||||||
{
|
{
|
||||||
// 纵向布局:第1行是吸水时间,第2行是吸芯高度
|
// 纵向布局:第1行是吸水时间,第2行是吸芯高度
|
||||||
|
|||||||
Reference in New Issue
Block a user