修复S7服务轮询问题

This commit is contained in:
2025-09-15 20:54:32 +08:00
parent 4773e87886
commit 5ab18f95f0
21 changed files with 351 additions and 260 deletions

View File

@@ -72,6 +72,8 @@ public partial class App : System.Windows.Application
DeviceItemViewModel.EventService = Host.Services.GetRequiredService<IEventService>();
// 初始化数据处理链
var dataProcessingService = Host.Services.GetRequiredService<IDataProcessingService>();
dataProcessingService.AddProcessor(Host.Services.GetRequiredService<ValueConvertProcessor>());
dataProcessingService.AddProcessor(Host.Services.GetRequiredService<UpdateViewProcessor>());
dataProcessingService.AddProcessor(Host.Services.GetRequiredService<CheckValueChangedProcessor>());
dataProcessingService.AddProcessor(Host.Services.GetRequiredService<LoggingProcessor>());
dataProcessingService.AddProcessor(Host.Services.GetRequiredService<HistoryProcessor>());
@@ -194,6 +196,8 @@ public partial class App : System.Windows.Application
services.AddSingleton<IDataProcessingService, DataProcessingService>();
services.AddHostedService(provider =>
(DataProcessingService)provider.GetRequiredService<IDataProcessingService>());
services.AddSingleton<ValueConvertProcessor>();
services.AddSingleton<UpdateViewProcessor>();
services.AddSingleton<CheckValueChangedProcessor>();
services.AddSingleton<LoggingProcessor>();
services.AddSingleton<UpdateDbVariableProcessor>();

View File

@@ -6,6 +6,7 @@ using DMS.Application.DTOs;
using DMS.Application.DTOs.Events;
using DMS.Application.Interfaces;
using DMS.Core.Enums;
using DMS.Core.Events;
using DMS.Core.Models;
using DMS.Message;
using DMS.WPF.Interfaces;
@@ -20,6 +21,7 @@ public class DataEventService : IDataEventService
{
private readonly IMapper _mapper;
private readonly IDataStorageService _dataStorageService;
private readonly IEventService _eventService;
private readonly IAppDataCenterService _appDataCenterService;
private readonly IWPFDataService _wpfDataService;
@@ -28,16 +30,18 @@ public class DataEventService : IDataEventService
/// </summary>
public DataEventService(IMapper mapper,
IDataStorageService dataStorageService,
IEventService eventService,
IAppDataCenterService appDataCenterService,
IWPFDataService wpfDataService)
{
_mapper = mapper;
_dataStorageService = dataStorageService;
_eventService = eventService;
_appDataCenterService = appDataCenterService;
_wpfDataService = wpfDataService;
// 监听变量值变更事件
_appDataCenterService.VariableManagementService.OnVariableValueChanged += OnVariableValueChanged;
_eventService.OnVariableValueChanged += OnVariableValueChanged;
_appDataCenterService.DataLoaderService.OnLoadDataCompleted += OnLoadDataCompleted;
// 监听日志变更事件
// _appDataCenterService.OnLogChanged += _logDataService.OnNlogChanged;