移除温度数据接收机制相关代码
This commit is contained in:
@@ -81,29 +81,6 @@ namespace JoyD.Windows.CS.Toprie
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 设备管理器温度数据接收事件处理
|
/// 设备管理器温度数据接收事件处理
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void DeviceManager_TemperatureReceived(object sender, DeviceManager.TemperatureReceivedEventArgs e)
|
|
||||||
{
|
|
||||||
if (DesignMode) return;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// 确保事件参数有效
|
|
||||||
if (e == null || e.TemperatureData == null)
|
|
||||||
{
|
|
||||||
Console.WriteLine("接收到无效的温度数据事件参数");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Console.WriteLine("温度数据已更新");
|
|
||||||
// 不再更新Info,根据新要求移除更新Info的逻辑
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Console.WriteLine($"[PauseDetection] 操作失败 - 异常: {ex.Message}, 堆栈: {ex.StackTrace}");
|
|
||||||
Console.WriteLine($"处理接收到的温度数据时出错: {ex.Message}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 显示错误的定时器
|
// 显示错误的定时器
|
||||||
|
|
||||||
|
|
||||||
@@ -548,22 +525,7 @@ namespace JoyD.Windows.CS.Toprie
|
|||||||
// 直接调用HTTP方式的图像接收
|
// 直接调用HTTP方式的图像接收
|
||||||
_deviceManager.StartImageReceiving();
|
_deviceManager.StartImageReceiving();
|
||||||
|
|
||||||
// 在调用StartTemperatureDataReceiving前先调用StopTemperatureDataReceiving,保持与ResumeDetection方法一致的模式
|
// 不再需要温度数据实时通知机制,移除相关代码
|
||||||
// 并添加时间间隔检查,避免短时间内频繁调用
|
|
||||||
lock (_temperatureCallLock)
|
|
||||||
{
|
|
||||||
TimeSpan elapsed = DateTime.Now - _lastTemperatureStartCall;
|
|
||||||
if (elapsed.TotalMilliseconds < 500) // 至少间隔500毫秒
|
|
||||||
{
|
|
||||||
Console.WriteLine("避免短时间内重复启动温度数据接收,跳过本次调用");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//_deviceManager.StopTemperatureDataReceiving();
|
|
||||||
_deviceManager.StartTemperatureDataReceiving();
|
|
||||||
_lastTemperatureStartCall = DateTime.Now;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_isReceivingImage = true;
|
_isReceivingImage = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -595,9 +557,7 @@ namespace JoyD.Windows.CS.Toprie
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 记录上次启动温度数据接收的时间,用于防止短时间内重复调用
|
// 温度数据相关变量已移除,不再需要温度数据实时通知机制
|
||||||
private DateTime _lastTemperatureStartCall = DateTime.MinValue;
|
|
||||||
private readonly object _temperatureCallLock = new object();
|
|
||||||
|
|
||||||
// Ping相关字段
|
// Ping相关字段
|
||||||
private System.Threading.Timer _pingTimer;
|
private System.Threading.Timer _pingTimer;
|
||||||
@@ -1818,8 +1778,9 @@ namespace JoyD.Windows.CS.Toprie
|
|||||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
// 现在直接从设备管理器获取温度数据,不再使用缓存的温度数据
|
// 现在直接从设备管理器获取温度数据,不再使用缓存的温度数据
|
||||||
// 调用设备管理器的方法获取最新的温度数据
|
// 调用设备管理器的方法获取最新的温度数据
|
||||||
if (!_deviceManager.GetTemperatureData())
|
TemperatureData temperatureData = _deviceManager.LastTemperature;
|
||||||
|
if (temperatureData == null)
|
||||||
{
|
{
|
||||||
MessageBox.Show("获取温度数据失败,请确保设备已连接且正在接收数据。", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show("获取温度数据失败,请确保设备已连接且正在接收数据。", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -175,7 +175,10 @@ namespace JoyD.Windows.CS.Toprie
|
|||||||
|
|
||||||
// 暂停检测标志,用于控制是否进行连接检测和重连操作
|
// 暂停检测标志,用于控制是否进行连接检测和重连操作
|
||||||
public bool IsDetectionPaused { get; set; } = false;
|
public bool IsDetectionPaused { get; set; } = false;
|
||||||
|
/// <summary>
|
||||||
|
/// 最近检查到的温度
|
||||||
|
/// </summary>
|
||||||
|
public TemperatureData LastTemperature = null;
|
||||||
// 项目路径,用于数据文件的存取
|
// 项目路径,用于数据文件的存取
|
||||||
private string _projectPath = "";
|
private string _projectPath = "";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user