优化DeviceManager.cs代码,移除未使用的变量lastHeartbeatTime和lastReceiveTime,清理冗余注释
This commit is contained in:
@@ -1222,7 +1222,7 @@ namespace JoyD.Windows.CS.Toprie
|
||||
localStream = localTcpClient.GetStream();
|
||||
localStream.ReadTimeout = RECEIVE_TIMEOUT;
|
||||
|
||||
// 温度数据接收状态更新代码已移除,因为未被使用
|
||||
|
||||
|
||||
// 根据SDK文档,建立TCP连接后不需要发送任何开始命令
|
||||
Log("TCP连接已建立,等待接收温度数据...");
|
||||
@@ -1231,8 +1231,6 @@ namespace JoyD.Windows.CS.Toprie
|
||||
{
|
||||
Log($"TCP连接或初始化失败: {ex.Message}");
|
||||
|
||||
// 温度数据接收状态更新代码已移除,因为未被使用
|
||||
|
||||
// 连接失败后等待一段时间再重试
|
||||
Thread.Sleep(LONG_SLEEP_MS);
|
||||
continue;
|
||||
@@ -1244,11 +1242,7 @@ namespace JoyD.Windows.CS.Toprie
|
||||
{
|
||||
try
|
||||
{
|
||||
// 温度数据接收状态更新代码已移除,因为未被使用
|
||||
|
||||
// 记录上次心跳时间和上次接收数据时间
|
||||
DateTime lastHeartbeatTime = DateTime.Now;
|
||||
DateTime lastReceiveTime = DateTime.Now;
|
||||
// 记录连接检查时间
|
||||
DateTime lastConnectionCheckTime = DateTime.Now;
|
||||
DateTime lastPausedLogTime = DateTime.MinValue;
|
||||
const int PAUSED_LOG_INTERVAL_MS = 30000; // 暂停状态日志间隔30秒
|
||||
@@ -1361,7 +1355,7 @@ namespace JoyD.Windows.CS.Toprie
|
||||
int bytesRead = localStream.Read(buffer, 0, buffer.Length);
|
||||
if (bytesRead > 0)
|
||||
{
|
||||
lastReceiveTime = DateTime.Now; // 更新最后接收数据时间
|
||||
|
||||
Log($"==========================================接收到温度数据字节数: {bytesRead}");
|
||||
|
||||
// 根据暂停状态决定是否处理数据
|
||||
@@ -1393,7 +1387,7 @@ namespace JoyD.Windows.CS.Toprie
|
||||
// 连接已关闭
|
||||
Log("远程主机关闭了连接");
|
||||
|
||||
// 温度数据接收状态更新代码已移除,因为未被使用
|
||||
|
||||
|
||||
// 清理连接资源
|
||||
CleanupConnectionResources(localStream, localTcpClient, out localStream, out localTcpClient);
|
||||
|
||||
Reference in New Issue
Block a user