This commit is contained in:
YONGYE 2025-10-14 12:38:10 +08:00
parent 465d76d0db
commit 4b5ac96b7c
4 changed files with 240 additions and 247 deletions

View File

@ -93,7 +93,6 @@ public partial class MainWindow : Window
// 清空之前图表数据 // 清空之前图表数据
chartManager.ClearAllCharts(); chartManager.ClearAllCharts();
sensorManager.Start(); sensorManager.Start();
//chartManager.Start(); // 启动图表刷新
BtnSensorControl.Content = "检测确定"; BtnSensorControl.Content = "检测确定";
isDetecting = true; isDetecting = true;
} }
@ -101,7 +100,6 @@ public partial class MainWindow : Window
{ {
// 停止检测 // 停止检测
sensorManager.Stop(); sensorManager.Stop();
//chartManager.Stop(); // 停止图表刷新
BtnSensorControl.Content = "检测开始"; BtnSensorControl.Content = "检测开始";
isDetecting = false; isDetecting = false;
} }

View File

@ -1,15 +1,12 @@
using guoke; using guoke;
using LiveCharts; using LiveCharts;
using LiveCharts.Wpf; using LiveCharts.Wpf;
using System;
using System.Collections.Generic;
using System.Windows.Threading; using System.Windows.Threading;
using WpfApp.src.config;
namespace WpfApp.Services namespace WpfApp.Services;
public class ChartManager
{ {
public class ChartManager
{
private readonly Dispatcher dispatcher; private readonly Dispatcher dispatcher;
private readonly LogService log; private readonly LogService log;
private readonly DatabaseService db; private readonly DatabaseService db;
@ -195,5 +192,4 @@ namespace WpfApp.Services
{ {
even?.AddEventHandler(SENSOR_DATA_EVENT, OnSensorDataReceived); even?.AddEventHandler(SENSOR_DATA_EVENT, OnSensorDataReceived);
} }
}
} }

View File

@ -2,13 +2,13 @@
using System.Windows; using System.Windows;
using WpfApp.src.components; using WpfApp.src.components;
namespace WpfApp.Services namespace WpfApp.Services;
/// <summary>
/// SensorChart 管理器 - 负责传感器数据采集和更新
/// </summary>
public class SensorChartManager
{ {
/// <summary>
/// SensorChart 管理器 - 负责传感器数据采集和更新
/// </summary>
public class SensorChartManager
{
private readonly Window dispatcherOwner; private readonly Window dispatcherOwner;
private CancellationTokenSource cts; private CancellationTokenSource cts;
private readonly Random rand = new Random(); private readonly Random rand = new Random();
@ -92,5 +92,4 @@ namespace WpfApp.Services
even.TriggerEvent(SENSOR_DATA_EVENT, this, eventArgs); even.TriggerEvent(SENSOR_DATA_EVENT, this, eventArgs);
} }
} }
}
} }