修复IDE0017警告:简化DeviceManager.cs和TemperatureData.cs中的对象初始化

This commit is contained in:
zqm
2025-10-30 16:55:24 +08:00
parent e6619e32c9
commit c7a0681712
2 changed files with 26 additions and 18 deletions

View File

@@ -1035,9 +1035,11 @@ namespace JoyD.Windows.CS.Toprie
try try
{ {
// 创建TCP客户端并连接到设备的温度数据端口 // 创建TCP客户端并连接到设备的温度数据端口
_temperatureTcpClient = new TcpClient(); _temperatureTcpClient = new TcpClient
_temperatureTcpClient.ReceiveTimeout = 5000; {
_temperatureTcpClient.SendTimeout = 5000; ReceiveTimeout = 5000,
SendTimeout = 5000
};
IAsyncResult result = _temperatureTcpClient.BeginConnect(_deviceIp, TEMPERATURE_TCP_PORT, null, null); IAsyncResult result = _temperatureTcpClient.BeginConnect(_deviceIp, TEMPERATURE_TCP_PORT, null, null);
bool connected = result.AsyncWaitHandle.WaitOne(3000, true); bool connected = result.AsyncWaitHandle.WaitOne(3000, true);
@@ -5294,11 +5296,13 @@ namespace JoyD.Windows.CS.Toprie
} }
// 创建新的温度数据对象 // 创建新的温度数据对象
TemperatureData result = new TemperatureData(); TemperatureData result = new TemperatureData
result.Width = width; {
result.Height = height; Width = width,
result.CompensationValue = CompensationValue; Height = height,
result.Data = regionData; CompensationValue = CompensationValue,
Data = regionData
};
result.CalculateStatistics(); result.CalculateStatistics();
return result; return result;
@@ -5327,11 +5331,13 @@ namespace JoyD.Windows.CS.Toprie
public TemperatureData ConvertTo(TemperatureMode mode) public TemperatureData ConvertTo(TemperatureMode mode)
{ {
// 创建新的温度数据对象 // 创建新的温度数据对象
TemperatureData result = new TemperatureData(); TemperatureData result = new TemperatureData
result.Width = Width; {
result.Height = Height; Width = Width,
result.CompensationValue = CompensationValue; Height = Height,
result.Data = new float[Height, Width]; CompensationValue = CompensationValue,
Data = new float[Height, Width]
};
// 根据目标模式进行转换 // 根据目标模式进行转换
switch (mode) switch (mode)

View File

@@ -259,11 +259,13 @@ namespace Toprie
} }
// 创建TemperatureData实例 // 创建TemperatureData实例
TemperatureData tempData = new TemperatureData(); TemperatureData tempData = new TemperatureData
tempData.Width = width; {
tempData.Height = height; Width = width,
tempData.TemperatureMatrix = matrix; Height = height,
tempData.Timestamp = timestamp; TemperatureMatrix = matrix,
Timestamp = timestamp
};
tempData.CalculateStatistics(); tempData.CalculateStatistics();
return tempData; return tempData;