This commit is contained in:
@@ -352,395 +352,100 @@ namespace 外科辅料和患者防护罩激光抗性测试仪
|
||||
private bool isfire;
|
||||
private double costtime;
|
||||
private float penetime;
|
||||
|
||||
private async Task InsertReportAsync()
|
||||
{
|
||||
if (uiLabel10.Text != null && uiLabel10.Text.Trim() == "1")
|
||||
{
|
||||
bool[] value1 = await ReadModbusCoilAsync(160, 1);
|
||||
bool[] value2 = await ReadModbusCoilAsync(170, 1);
|
||||
bool[] value3 = await ReadModbusCoilAsync(180, 1);
|
||||
bool[] value4 = await ReadModbusCoilAsync(190, 1);
|
||||
if (uiLabel10.Text == null) return;
|
||||
|
||||
if (value1 != null && value1.Length > 0 && value1[0])
|
||||
var sampleId = uiLabel10.Text.Trim();
|
||||
if (string.IsNullOrEmpty(sampleId)) return;
|
||||
|
||||
// 解析样品ID
|
||||
if (!int.TryParse(sampleId, out int sampleIndex) || sampleIndex < 1 || sampleIndex > 5)
|
||||
{
|
||||
Debug.WriteLine($"无效的样品ID: {sampleId}");
|
||||
return;
|
||||
}
|
||||
|
||||
int coilBaseAddress = 159 + sampleIndex; // 160,161,162,163,164
|
||||
int fireCoilAddress = 200 + sampleIndex; // 201,202,203,204,205
|
||||
int timeRegAddress = 168 + sampleIndex * 2; // 170,172,174,176,178
|
||||
int tempRegAddress = 108 + sampleIndex * 2; // 110,112,114,116,118
|
||||
|
||||
// 读取分类线圈
|
||||
bool[] classificationResults = new bool[4];
|
||||
classificationResults[0] = await ReadCoilWithCheckAsync(coilBaseAddress); // P4
|
||||
classificationResults[1] = await ReadCoilWithCheckAsync(coilBaseAddress + 10); // P3
|
||||
classificationResults[2] = await ReadCoilWithCheckAsync(coilBaseAddress + 20); // P2
|
||||
classificationResults[3] = await ReadCoilWithCheckAsync(coilBaseAddress + 30); // P1
|
||||
|
||||
// 确定分类
|
||||
string classify = null;
|
||||
int classificationIndex = -1;
|
||||
|
||||
for (int i = 0; i < classificationResults.Length; i++)
|
||||
{
|
||||
if (classificationResults[i])
|
||||
{
|
||||
classify = "P4";//分类
|
||||
ushort[] yhlocation = _modbusMaster?.ReadHoldingRegisters(1, 320, 4);
|
||||
if (yhlocation != null && yhlocation.Length >= 3)
|
||||
{
|
||||
yh = c.UshortToFloat(yhlocation[1], yhlocation[0]);//余焰
|
||||
yy = c.UshortToFloat(yhlocation[3], yhlocation[2]);//余辉
|
||||
}
|
||||
bool[] fire = await ReadModbusCoilAsync(201, 1);
|
||||
isfire = (fire != null && fire.Length > 0 && fire[0]) ? true : false;//是否起火
|
||||
ushort[] time = _modbusMaster?.ReadHoldingRegisters(1, 170, 2);
|
||||
costtime = time[0];//总测试
|
||||
ushort[] petime = _modbusMaster?.ReadHoldingRegisters(1, 72, 2);
|
||||
penetime = c.UshortToFloat(petime[1], petime[0]);//穿透
|
||||
}
|
||||
else if (value2 != null && value2.Length > 0 && value2[0])
|
||||
{
|
||||
classify = "P3";
|
||||
ushort[] yhlocation = _modbusMaster?.ReadHoldingRegisters(1, 320, 4);
|
||||
if (yhlocation != null && yhlocation.Length >= 3)
|
||||
{
|
||||
yh = c.UshortToFloat(yhlocation[1], yhlocation[0]);//余焰
|
||||
yy = c.UshortToFloat(yhlocation[3], yhlocation[2]);//余辉
|
||||
}
|
||||
bool[] fire = await ReadModbusCoilAsync(201, 1);
|
||||
isfire = (fire != null && fire.Length > 0 && fire[0]) ? true : false;//是否起火
|
||||
ushort[] time = _modbusMaster?.ReadHoldingRegisters(1, 170, 2);
|
||||
costtime = time[0];//总测试
|
||||
ushort[] petime = _modbusMaster?.ReadHoldingRegisters(1, 72, 2);
|
||||
penetime = c.UshortToFloat(petime[1], petime[0]);//穿透
|
||||
}
|
||||
else if (value3 != null && value3.Length > 0 && value3[0])
|
||||
{
|
||||
classify = "P2";
|
||||
ushort[] yhlocation = _modbusMaster?.ReadHoldingRegisters(1, 320, 4);
|
||||
if (yhlocation != null && yhlocation.Length >= 3)
|
||||
{
|
||||
yh = c.UshortToFloat(yhlocation[1], yhlocation[0]);//余焰
|
||||
yy = c.UshortToFloat(yhlocation[3], yhlocation[2]);//余辉
|
||||
}
|
||||
bool[] fire = await ReadModbusCoilAsync(201, 1);
|
||||
isfire = (fire != null && fire.Length > 0 && fire[0]) ? true : false;//是否起火
|
||||
ushort[] time = _modbusMaster?.ReadHoldingRegisters(1, 170, 2);
|
||||
costtime = time[0];//总测试
|
||||
ushort[] petime = _modbusMaster?.ReadHoldingRegisters(1, 72, 2);
|
||||
penetime = c.UshortToFloat(petime[1], petime[0]);//穿透
|
||||
}
|
||||
else if (value4 != null && value4.Length > 0 && value4[0])
|
||||
{
|
||||
classify = "P1";
|
||||
ushort[] tem = _modbusMaster?.ReadHoldingRegisters(1, 110, 2);
|
||||
temperature = c.UshortToFloat(tem[1], tem[0]);//背部温度
|
||||
ushort[] yhlocation = _modbusMaster?.ReadHoldingRegisters(1, 320, 4);
|
||||
if (yhlocation != null && yhlocation.Length >= 3)
|
||||
{
|
||||
yh = c.UshortToFloat(yhlocation[1], yhlocation[0]);//余焰
|
||||
yy = c.UshortToFloat(yhlocation[3], yhlocation[2]);//余辉
|
||||
}
|
||||
bool[] fire = await ReadModbusCoilAsync(201, 1);
|
||||
isfire = (fire != null && fire.Length > 0 && fire[0]) ? true : false;//是否起火
|
||||
ushort[] time = _modbusMaster?.ReadHoldingRegisters(1, 170, 2);
|
||||
costtime = time[0];//总测试
|
||||
ushort[] petime = _modbusMaster?.ReadHoldingRegisters(1, 72, 2);
|
||||
penetime = c.UshortToFloat(petime[1], petime[0]);//穿透
|
||||
classify = $"P{4 - i}"; // P4, P3, P2, P1
|
||||
classificationIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (uiLabel10.Text != null && uiLabel10.Text.Trim() == "2")
|
||||
if (classify == null)
|
||||
{
|
||||
|
||||
bool[] value5 = await ReadModbusCoilAsync(161, 1);
|
||||
bool[] value6 = await ReadModbusCoilAsync(171, 1);
|
||||
bool[] value7 = await ReadModbusCoilAsync(181, 1);
|
||||
bool[] value8 = await ReadModbusCoilAsync(191, 1);
|
||||
|
||||
if (value5 != null && value5.Length > 0 && value5[0])
|
||||
{
|
||||
classify = "P4";//分类
|
||||
ushort[] yhlocation = _modbusMaster?.ReadHoldingRegisters(1, 320, 4);
|
||||
if (yhlocation != null && yhlocation.Length >= 3)
|
||||
{
|
||||
yh = c.UshortToFloat(yhlocation[1], yhlocation[0]);//余焰
|
||||
yy = c.UshortToFloat(yhlocation[3], yhlocation[2]);//余辉
|
||||
}
|
||||
bool[] fire = await ReadModbusCoilAsync(202, 1);
|
||||
isfire = (fire != null && fire.Length > 0 && fire[0]) ? true : false;//是否起火
|
||||
ushort[] time = _modbusMaster?.ReadHoldingRegisters(1, 172, 2);
|
||||
costtime = time[0];//总测试
|
||||
ushort[] petime = _modbusMaster?.ReadHoldingRegisters(1, 72, 2);
|
||||
penetime = c.UshortToFloat(petime[1], petime[0]);//穿透
|
||||
}
|
||||
else if (value6 != null && value6.Length > 0 && value6[0])
|
||||
{
|
||||
classify = "P3";//分类
|
||||
ushort[] yhlocation = _modbusMaster?.ReadHoldingRegisters(1, 320, 4);
|
||||
if (yhlocation != null && yhlocation.Length >= 3)
|
||||
{
|
||||
yh = c.UshortToFloat(yhlocation[1], yhlocation[0]);//余焰
|
||||
yy = c.UshortToFloat(yhlocation[3], yhlocation[2]);//余辉
|
||||
}
|
||||
bool[] fire = await ReadModbusCoilAsync(202, 1);
|
||||
isfire = (fire != null && fire.Length > 0 && fire[0]) ? true : false;//是否起火
|
||||
ushort[] time = _modbusMaster?.ReadHoldingRegisters(1, 172, 2);
|
||||
costtime = time[0];//总测试
|
||||
ushort[] petime = _modbusMaster?.ReadHoldingRegisters(1, 72, 2);
|
||||
penetime = c.UshortToFloat(petime[1], petime[0]);//穿透
|
||||
}
|
||||
else if (value7 != null && value7.Length > 0 && value7[0])
|
||||
{
|
||||
classify = "P2";//分类
|
||||
ushort[] yhlocation = _modbusMaster?.ReadHoldingRegisters(1, 320, 4);
|
||||
if (yhlocation != null && yhlocation.Length >= 3)
|
||||
{
|
||||
yh = c.UshortToFloat(yhlocation[1], yhlocation[0]);//余焰
|
||||
yy = c.UshortToFloat(yhlocation[3], yhlocation[2]);//余辉
|
||||
}
|
||||
bool[] fire = await ReadModbusCoilAsync(202, 1);
|
||||
isfire = (fire != null && fire.Length > 0 && fire[0]) ? true : false;//是否起火
|
||||
ushort[] time = _modbusMaster?.ReadHoldingRegisters(1, 172, 2);
|
||||
costtime = time[0];//总测试
|
||||
ushort[] petime = _modbusMaster?.ReadHoldingRegisters(1, 72, 2);
|
||||
penetime = c.UshortToFloat(petime[1], petime[0]);//穿透
|
||||
}
|
||||
else if (value8 != null && value8.Length > 0 && value8[0])
|
||||
{
|
||||
classify = "P1";
|
||||
ushort[] tem = _modbusMaster?.ReadHoldingRegisters(1, 112, 2);
|
||||
temperature = c.UshortToFloat(tem[1], tem[0]);//背部温度
|
||||
ushort[] yhlocation = _modbusMaster?.ReadHoldingRegisters(1, 320, 4);
|
||||
if (yhlocation != null && yhlocation.Length >= 3)
|
||||
{
|
||||
yh = c.UshortToFloat(yhlocation[1], yhlocation[0]);//余焰
|
||||
yy = c.UshortToFloat(yhlocation[3], yhlocation[2]);//余辉
|
||||
}
|
||||
bool[] fire = await ReadModbusCoilAsync(202, 1);
|
||||
isfire = (fire != null && fire.Length > 0 && fire[0]) ? true : false;//是否起火
|
||||
ushort[] time = _modbusMaster?.ReadHoldingRegisters(1, 172, 2);
|
||||
costtime = time[0];//总测试
|
||||
ushort[] petime = _modbusMaster?.ReadHoldingRegisters(1, 72, 2);
|
||||
penetime = c.UshortToFloat(petime[1], petime[0]);//穿透
|
||||
}
|
||||
Debug.WriteLine("未检测到有效分类");
|
||||
return;
|
||||
}
|
||||
|
||||
if (uiLabel10.Text != null && uiLabel10.Text.Trim() == "3")
|
||||
|
||||
float yh = 0, yy = 0, penetime = 0, temperature = 0;
|
||||
ushort costtime = 0;
|
||||
bool isfire = false;
|
||||
|
||||
|
||||
ushort[] yhlocation = _modbusMaster?.ReadHoldingRegisters(1, 320, 4);
|
||||
if (yhlocation != null && yhlocation.Length >= 4)
|
||||
{
|
||||
|
||||
bool[] value9 = await ReadModbusCoilAsync(162, 1);
|
||||
bool[] value10 = await ReadModbusCoilAsync(172, 1);
|
||||
bool[] value11 = await ReadModbusCoilAsync(182, 1);
|
||||
bool[] value12 = await ReadModbusCoilAsync(192, 1);
|
||||
|
||||
if (value9 != null && value9.Length > 0 && value9[0])
|
||||
{
|
||||
classify = "P4";//分类
|
||||
ushort[] yhlocation = _modbusMaster?.ReadHoldingRegisters(1, 320, 4);
|
||||
if (yhlocation != null && yhlocation.Length >= 3)
|
||||
{
|
||||
yh = c.UshortToFloat(yhlocation[1], yhlocation[0]);//余焰
|
||||
yy = c.UshortToFloat(yhlocation[3], yhlocation[2]);//余辉
|
||||
}
|
||||
bool[] fire = await ReadModbusCoilAsync(203, 1);
|
||||
isfire = (fire != null && fire.Length > 0 && fire[0]) ? true : false;//是否起火
|
||||
ushort[] time = _modbusMaster?.ReadHoldingRegisters(1, 174, 2);
|
||||
costtime = time[0];//总测试
|
||||
ushort[] petime = _modbusMaster?.ReadHoldingRegisters(1, 72, 2);
|
||||
penetime = c.UshortToFloat(petime[1], petime[0]);//穿透
|
||||
}
|
||||
else if (value10 != null && value10.Length > 0 && value10[0])
|
||||
{
|
||||
classify = "P3";//分类
|
||||
ushort[] yhlocation = _modbusMaster?.ReadHoldingRegisters(1, 320, 4);
|
||||
if (yhlocation != null && yhlocation.Length >= 3)
|
||||
{
|
||||
yh = c.UshortToFloat(yhlocation[1], yhlocation[0]);//余焰
|
||||
yy = c.UshortToFloat(yhlocation[3], yhlocation[2]);//余辉
|
||||
}
|
||||
bool[] fire = await ReadModbusCoilAsync(203, 1);
|
||||
isfire = (fire != null && fire.Length > 0 && fire[0]) ? true : false;//是否起火
|
||||
ushort[] time = _modbusMaster?.ReadHoldingRegisters(1, 174, 2);
|
||||
costtime = time[0];//总测试
|
||||
ushort[] petime = _modbusMaster?.ReadHoldingRegisters(1, 72, 2);
|
||||
penetime = c.UshortToFloat(petime[1], petime[0]);//穿透
|
||||
}
|
||||
else if (value11 != null && value11.Length > 0 && value11[0])
|
||||
{
|
||||
classify = "P2";//分类
|
||||
ushort[] yhlocation = _modbusMaster?.ReadHoldingRegisters(1, 320, 4);
|
||||
if (yhlocation != null && yhlocation.Length >= 3)
|
||||
{
|
||||
yh = c.UshortToFloat(yhlocation[1], yhlocation[0]);//余焰
|
||||
yy = c.UshortToFloat(yhlocation[3], yhlocation[2]);//余辉
|
||||
}
|
||||
bool[] fire = await ReadModbusCoilAsync(203, 1);
|
||||
isfire = (fire != null && fire.Length > 0 && fire[0]) ? true : false;//是否起火
|
||||
ushort[] time = _modbusMaster?.ReadHoldingRegisters(1, 174, 2);
|
||||
costtime = time[0];//总测试
|
||||
ushort[] petime = _modbusMaster?.ReadHoldingRegisters(1, 72, 2);
|
||||
penetime = c.UshortToFloat(petime[1], petime[0]);//穿透
|
||||
}
|
||||
else if (value12 != null && value12.Length > 0 && value12[0])
|
||||
{
|
||||
classify = "P1";
|
||||
ushort[] tem = _modbusMaster?.ReadHoldingRegisters(1, 114, 2);
|
||||
temperature = c.UshortToFloat(tem[1], tem[0]);//背部温度
|
||||
ushort[] yhlocation = _modbusMaster?.ReadHoldingRegisters(1, 320, 4);
|
||||
if (yhlocation != null && yhlocation.Length >= 3)
|
||||
{
|
||||
yh = c.UshortToFloat(yhlocation[1], yhlocation[0]);//余焰
|
||||
yy = c.UshortToFloat(yhlocation[3], yhlocation[2]);//余辉
|
||||
}
|
||||
bool[] fire = await ReadModbusCoilAsync(203, 1);
|
||||
isfire = (fire != null && fire.Length > 0 && fire[0]) ? true : false;//是否起火
|
||||
ushort[] time = _modbusMaster?.ReadHoldingRegisters(1, 174, 2);
|
||||
costtime = time[0];//总测试
|
||||
ushort[] petime = _modbusMaster?.ReadHoldingRegisters(1, 72, 2);
|
||||
penetime = c.UshortToFloat(petime[1], petime[0]);//穿透
|
||||
}
|
||||
}
|
||||
if (uiLabel10.Text != null && uiLabel10.Text.Trim() == "4")
|
||||
{
|
||||
bool[] value13 = await ReadModbusCoilAsync(163, 1);
|
||||
bool[] value14 = await ReadModbusCoilAsync(173, 1);
|
||||
bool[] value15 = await ReadModbusCoilAsync(183, 1);
|
||||
bool[] value16 = await ReadModbusCoilAsync(193, 1);
|
||||
|
||||
if (value13 != null && value13.Length > 0 && value13[0])
|
||||
{
|
||||
classify = "P4";//分类
|
||||
ushort[] yhlocation = _modbusMaster?.ReadHoldingRegisters(1, 320, 4);
|
||||
if (yhlocation != null && yhlocation.Length >= 3)
|
||||
{
|
||||
yh = c.UshortToFloat(yhlocation[1], yhlocation[0]);//余焰
|
||||
yy = c.UshortToFloat(yhlocation[3], yhlocation[2]);//余辉
|
||||
}
|
||||
bool[] fire = await ReadModbusCoilAsync(204, 1);
|
||||
isfire = (fire != null && fire.Length > 0 && fire[0]) ? true : false;//是否起火
|
||||
ushort[] time = _modbusMaster?.ReadHoldingRegisters(1, 176, 2);
|
||||
costtime = time[0];//总测试
|
||||
ushort[] petime = _modbusMaster?.ReadHoldingRegisters(1, 72, 2);
|
||||
penetime = c.UshortToFloat(petime[1], petime[0]);//穿透
|
||||
}
|
||||
else if (value14 != null && value14.Length > 0 && value14[0])
|
||||
{
|
||||
classify = "P3";//分类
|
||||
ushort[] yhlocation = _modbusMaster?.ReadHoldingRegisters(1, 320, 4);
|
||||
if (yhlocation != null && yhlocation.Length >= 3)
|
||||
{
|
||||
yh = c.UshortToFloat(yhlocation[1], yhlocation[0]);//余焰
|
||||
yy = c.UshortToFloat(yhlocation[3], yhlocation[2]);//余辉
|
||||
}
|
||||
bool[] fire = await ReadModbusCoilAsync(204, 1);
|
||||
isfire = (fire != null && fire.Length > 0 && fire[0]) ? true : false;//是否起火
|
||||
ushort[] time = _modbusMaster?.ReadHoldingRegisters(1, 176, 2);
|
||||
costtime = time[0];//总测试
|
||||
ushort[] petime = _modbusMaster?.ReadHoldingRegisters(1, 72, 2);
|
||||
penetime = c.UshortToFloat(petime[1], petime[0]);//穿透
|
||||
}
|
||||
else if (value15 != null && value15.Length > 0 && value15[0])
|
||||
{
|
||||
classify = "P2";//分类
|
||||
ushort[] yhlocation = _modbusMaster?.ReadHoldingRegisters(1, 320, 4);
|
||||
if (yhlocation != null && yhlocation.Length >= 3)
|
||||
{
|
||||
yh = c.UshortToFloat(yhlocation[1], yhlocation[0]);//余焰
|
||||
yy = c.UshortToFloat(yhlocation[3], yhlocation[2]);//余辉
|
||||
}
|
||||
bool[] fire = await ReadModbusCoilAsync(204, 1);
|
||||
isfire = (fire != null && fire.Length > 0 && fire[0]) ? true : false;//是否起火
|
||||
ushort[] time = _modbusMaster?.ReadHoldingRegisters(1, 176, 2);
|
||||
costtime = time[0];//总测试
|
||||
ushort[] petime = _modbusMaster?.ReadHoldingRegisters(1, 72, 2);
|
||||
penetime = c.UshortToFloat(petime[1], petime[0]);//穿透
|
||||
}
|
||||
else if (value16 != null && value16.Length > 0 && value16[0])
|
||||
{
|
||||
classify = "P1";
|
||||
ushort[] tem = _modbusMaster?.ReadHoldingRegisters(1, 116, 2);
|
||||
temperature = c.UshortToFloat(tem[1], tem[0]);//背部温度
|
||||
ushort[] yhlocation = _modbusMaster?.ReadHoldingRegisters(1, 320, 4);
|
||||
if (yhlocation != null && yhlocation.Length >= 3)
|
||||
{
|
||||
yh = c.UshortToFloat(yhlocation[1], yhlocation[0]);//余焰
|
||||
yy = c.UshortToFloat(yhlocation[3], yhlocation[2]);//余辉
|
||||
}
|
||||
bool[] fire = await ReadModbusCoilAsync(204, 1);
|
||||
isfire = (fire != null && fire.Length > 0 && fire[0]) ? true : false;//是否起火
|
||||
ushort[] time = _modbusMaster?.ReadHoldingRegisters(1, 176, 2);
|
||||
costtime = time[0];//总测试
|
||||
ushort[] petime = _modbusMaster?.ReadHoldingRegisters(1, 72, 2);
|
||||
penetime = c.UshortToFloat(petime[1], petime[0]);//穿透
|
||||
}
|
||||
yh = c.UshortToFloat(yhlocation[1], yhlocation[0]);
|
||||
yy = c.UshortToFloat(yhlocation[3], yhlocation[2]);
|
||||
}
|
||||
|
||||
if (uiLabel10.Text != null && uiLabel10.Text.Trim() == "5")
|
||||
{
|
||||
bool[] value17 = await ReadModbusCoilAsync(164, 1);
|
||||
bool[] value18 = await ReadModbusCoilAsync(174, 1);
|
||||
bool[] value19 = await ReadModbusCoilAsync(184, 1);
|
||||
bool[] value20 = await ReadModbusCoilAsync(194, 1);
|
||||
|
||||
if (value17 != null && value17.Length > 0 && value17[0])
|
||||
{
|
||||
classify = "P4";//分类
|
||||
ushort[] yhlocation = _modbusMaster?.ReadHoldingRegisters(1, 320, 4);
|
||||
if (yhlocation != null && yhlocation.Length >= 3)
|
||||
{
|
||||
yh = c.UshortToFloat(yhlocation[1], yhlocation[0]);//余焰
|
||||
yy = c.UshortToFloat(yhlocation[3], yhlocation[2]);//余辉
|
||||
}
|
||||
bool[] fire = await ReadModbusCoilAsync(205, 1);
|
||||
isfire = (fire != null && fire.Length > 0 && fire[0]) ? true : false;//是否起火
|
||||
ushort[] time = _modbusMaster?.ReadHoldingRegisters(1, 178, 2);
|
||||
costtime = time[0];//总测试
|
||||
ushort[] petime = _modbusMaster?.ReadHoldingRegisters(1, 72, 2);
|
||||
penetime = c.UshortToFloat(petime[1], petime[0]);//穿透
|
||||
}
|
||||
else if (value18 != null && value18.Length > 0 && value18[0])
|
||||
{
|
||||
classify = "P3";//分类
|
||||
ushort[] yhlocation = _modbusMaster?.ReadHoldingRegisters(1, 320, 4);
|
||||
if (yhlocation != null && yhlocation.Length >= 3)
|
||||
{
|
||||
yh = c.UshortToFloat(yhlocation[1], yhlocation[0]);//余焰
|
||||
yy = c.UshortToFloat(yhlocation[3], yhlocation[2]);//余辉
|
||||
}
|
||||
bool[] fire = await ReadModbusCoilAsync(205, 1);
|
||||
isfire = (fire != null && fire.Length > 0 && fire[0]) ? true : false;//是否起火
|
||||
ushort[] time = _modbusMaster?.ReadHoldingRegisters(1, 178, 2);
|
||||
costtime = time[0];//总测试
|
||||
ushort[] petime = _modbusMaster?.ReadHoldingRegisters(1, 72, 2);
|
||||
penetime = c.UshortToFloat(petime[1], petime[0]);//穿透
|
||||
}
|
||||
else if (value19 != null && value19.Length > 0 && value19[0])
|
||||
{
|
||||
classify = "P2";//分类
|
||||
ushort[] yhlocation = _modbusMaster?.ReadHoldingRegisters(1, 320, 4);
|
||||
if (yhlocation != null && yhlocation.Length >= 3)
|
||||
{
|
||||
yh = c.UshortToFloat(yhlocation[1], yhlocation[0]);//余焰
|
||||
yy = c.UshortToFloat(yhlocation[3], yhlocation[2]);//余辉
|
||||
}
|
||||
bool[] fire = await ReadModbusCoilAsync(205, 1);
|
||||
isfire = (fire != null && fire.Length > 0 && fire[0]) ? true : false;//是否起火
|
||||
ushort[] time = _modbusMaster?.ReadHoldingRegisters(1, 178, 2);
|
||||
costtime = time[0];//总测试
|
||||
ushort[] petime = _modbusMaster?.ReadHoldingRegisters(1, 72, 2);
|
||||
penetime = c.UshortToFloat(petime[1], petime[0]);//穿透
|
||||
}
|
||||
else if (value20 != null && value20.Length > 0 && value20[0])
|
||||
{
|
||||
classify = "P1";
|
||||
ushort[] tem = _modbusMaster?.ReadHoldingRegisters(1, 118, 2);
|
||||
temperature = c.UshortToFloat(tem[1], tem[0]);//背部温度
|
||||
ushort[] yhlocation = _modbusMaster?.ReadHoldingRegisters(1, 320, 4);
|
||||
if (yhlocation != null && yhlocation.Length >= 3)
|
||||
{
|
||||
yh = c.UshortToFloat(yhlocation[1], yhlocation[0]);//余焰
|
||||
yy = c.UshortToFloat(yhlocation[3], yhlocation[2]);//余辉
|
||||
}
|
||||
bool[] fire = await ReadModbusCoilAsync(205, 1);
|
||||
isfire = (fire != null && fire.Length > 0 && fire[0]) ? true : false;//是否起火
|
||||
ushort[] time = _modbusMaster?.ReadHoldingRegisters(1, 178, 2);
|
||||
costtime = time[0];//总测试
|
||||
ushort[] petime = _modbusMaster?.ReadHoldingRegisters(1, 72, 2);
|
||||
penetime = c.UshortToFloat(petime[1], petime[0]);//穿透
|
||||
}
|
||||
bool[] fire = await ReadModbusCoilAsync((ushort)fireCoilAddress, 1);
|
||||
isfire = fire != null && fire.Length > 0 && fire[0];
|
||||
|
||||
|
||||
ushort[] time = _modbusMaster?.ReadHoldingRegisters(1, (ushort)timeRegAddress, 2);
|
||||
if (time != null && time.Length > 0)
|
||||
{
|
||||
costtime = time[0];
|
||||
}
|
||||
|
||||
|
||||
ushort[] petime = _modbusMaster?.ReadHoldingRegisters(1, 72, 2);
|
||||
if (petime != null && petime.Length >= 2)
|
||||
{
|
||||
penetime = c.UshortToFloat(petime[1], petime[0]);
|
||||
}
|
||||
|
||||
// 如果是P1分类,读取温度
|
||||
if (classificationIndex == 3) // P1是数组的第3个元素
|
||||
{
|
||||
ushort[] tem = _modbusMaster?.ReadHoldingRegisters(1, (ushort)tempRegAddress, 2);
|
||||
if (tem != null && tem.Length >= 2)
|
||||
{
|
||||
temperature = c.UshortToFloat(tem[1], tem[0]);
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
string selectedO2Text = uiComboBox1.Text;
|
||||
reportList.Add(new PenetrationModel
|
||||
{
|
||||
sampleType2 = uiLabel10.Text.Contains("1") ? 1
|
||||
: uiLabel10.Text.Contains("2") ? 2
|
||||
: uiLabel10.Text.Contains("3") ? 3
|
||||
: uiLabel10.Text.Contains("4") ? 4
|
||||
: uiLabel10.Text.Contains("5") ? 5 : 0,
|
||||
sampleType2 = sampleIndex,
|
||||
O22 = selectedO2Text,
|
||||
result2 = classify,
|
||||
temperature2 = temperature,
|
||||
@@ -751,7 +456,6 @@ namespace 外科辅料和患者防护罩激光抗性测试仪
|
||||
penetime2 = penetime
|
||||
});
|
||||
await Task.Delay(100);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -759,6 +463,12 @@ namespace 外科辅料和患者防护罩激光抗性测试仪
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<bool> ReadCoilWithCheckAsync(int address)
|
||||
{
|
||||
var result = await ReadModbusCoilAsync((ushort)address, 1);
|
||||
return result != null && result.Length > 0 && result[0];
|
||||
}
|
||||
|
||||
private async Task ReadtimeAsync()
|
||||
{
|
||||
try
|
||||
@@ -1157,7 +867,7 @@ namespace 外科辅料和患者防护罩激光抗性测试仪
|
||||
uiLabel23.Text = $"{powerValue:F3} ";
|
||||
}
|
||||
|
||||
_waitingResponse = false;
|
||||
_waitingResponse = false;
|
||||
}
|
||||
else if (trimmedLine.Contains(".") && trimmedLine.Length > 0)
|
||||
{
|
||||
@@ -1175,7 +885,7 @@ namespace 外科辅料和患者防护罩激光抗性测试仪
|
||||
{
|
||||
uiLabel23.Text = $"{power:F3} W";
|
||||
}
|
||||
_waitingResponse = false;
|
||||
_waitingResponse = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1189,7 +899,7 @@ namespace 外科辅料和患者防护罩激光抗性测试仪
|
||||
catch (Exception ex)
|
||||
{
|
||||
WriteToLog($"处理功率计数据错误: {ex.Message}");
|
||||
_waitingResponse = false;
|
||||
_waitingResponse = false;
|
||||
}
|
||||
}
|
||||
private bool ShouldFilterPowerValue(double powerValue)
|
||||
@@ -1207,7 +917,7 @@ namespace 外科辅料和患者防护罩激光抗性测试仪
|
||||
{
|
||||
if (Math.Abs(powerValue - suspicious) < 0.1) // 允许0.1的误差
|
||||
{
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1217,7 +927,7 @@ namespace 外科辅料和患者防护罩激光抗性测试仪
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool IsPowerOfTwo(double value)
|
||||
|
||||
Reference in New Issue
Block a user