This commit is contained in:
@@ -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">
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user