This commit is contained in:
xyy
2026-02-09 19:43:44 +08:00
parent 0d7a539493
commit b4076cc1b0
2 changed files with 14 additions and 20 deletions

View File

@@ -8,7 +8,7 @@
Title="GB/T 32064-2015 导热系数测试系统"
Height="700" Width="1015"
WindowStartupLocation="CenterScreen"
Closing="Window_Closing">
Closing="Window_Closing" Loaded="Window_Loaded">
<Window.Resources>
<Style TargetType="GroupBox">

View File

@@ -470,6 +470,12 @@ namespace ConductivityApp
_testData.Clear();
_temperatureSeries.Points.Clear();
if (_plc != null && _plc.IsConnected)
{
_plc.Close();
Thread.Sleep(500);
}
// 2. 连接PLC
//if (_plc != null && !_plc.IsConnected)
//{
@@ -480,7 +486,7 @@ namespace ConductivityApp
Console.WriteLine("加热启动");
// 等待加热稳定1秒
Thread.Sleep(1000);
Thread.Sleep(500);
//}
@@ -826,23 +832,6 @@ namespace ConductivityApp
}
}
private double ReadPressureData()
{
try
{
if (_plc != null && _plc.IsConnected)
{
object pressureObj = _plc.Read(DataType.DataBlock, 1, 18, VarType.Real, 1);
return Convert.ToDouble(pressureObj);
}
return 0.0;
}
catch
{
return 0.0;
}
}
private double ReadTemperatureData()
{
@@ -851,7 +840,7 @@ namespace ConductivityApp
if (_plc != null && _plc.IsConnected)
{
object pressureObj = _plc.Read(DataType.DataBlock, 1, 120, VarType.Real, 1);
return Convert.ToDouble(pressureObj);
return Convert.ToDouble(pressureObj)*0.85;
}
return 0.0;
@@ -2821,5 +2810,10 @@ namespace ConductivityApp
MessageBox.Show($"夹紧关灯失败:{ex.Message}");
}
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
_plc.Open();
}
}
}