完成S7变量启用和停用更新

This commit is contained in:
2025-09-16 14:42:23 +08:00
parent 3102938f92
commit 74fde6bd8b
59 changed files with 226 additions and 454 deletions

View File

@@ -1,6 +1,5 @@
using AutoMapper;
using DMS.Application.DTOs;
using DMS.Application.DTOs.Events;
using DMS.Core.Models;
using DMS.Application.Interfaces;
using DMS.Core.Interfaces;
@@ -11,6 +10,7 @@ using System.Collections.Generic;
using System.Threading.Tasks;
using System;
using System.Linq;
using DMS.Application.Events;
using DMS.Application.Interfaces.Management;
using DMS.Core.Events;

View File

@@ -3,7 +3,7 @@ using DMS.Application.DTOs;
using DMS.Application.Interfaces;
using DMS.Core.Interfaces;
using System.Collections.Concurrent;
using DMS.Application.DTOs.Events;
using DMS.Application.Events;
using DMS.Application.Interfaces.Database;
using DMS.Core.Models;

View File

@@ -1,5 +1,4 @@
using System;
using DMS.Application.DTOs.Events;
using DMS.Application.Events;
using DMS.Application.Interfaces;
using DMS.Core.Events;
@@ -77,6 +76,16 @@ public class EventService : IEventService
OnVariableChanged?.Invoke(sender, e);
}
/// <summary>
/// 变量启停改变事件
/// </summary>
public event EventHandler<VariablesActiveChangedEventArgs> OnVariableActiveChanged;
public void RaiseVariableActiveChanged(object sender, VariablesActiveChangedEventArgs e)
{
OnVariableActiveChanged?.Invoke(sender, e);
}
/// <summary>
/// 变量值改变事件

View File

@@ -1,5 +1,5 @@
using DMS.Application.DTOs;
using DMS.Application.DTOs.Events;
using DMS.Application.Events;
using DMS.Application.Interfaces;
using DMS.Application.Interfaces.Database;
using DMS.Application.Interfaces.Management;

View File

@@ -1,5 +1,5 @@
using DMS.Application.DTOs;
using DMS.Application.DTOs.Events;
using DMS.Application.Events;
using DMS.Application.Interfaces;
using DMS.Application.Interfaces.Database;
using DMS.Application.Interfaces.Management;

View File

@@ -1,5 +1,5 @@
using DMS.Application.DTOs;
using DMS.Application.DTOs.Events;
using DMS.Application.Events;
using DMS.Application.Interfaces;
using DMS.Application.Interfaces.Management;
using DMS.Core.Enums;

View File

@@ -1,5 +1,5 @@
using DMS.Application.DTOs;
using DMS.Application.DTOs.Events;
using DMS.Application.Events;
using DMS.Application.Interfaces;
using DMS.Application.Interfaces.Database;
using DMS.Application.Interfaces.Management;

View File

@@ -1,6 +1,6 @@
using System.Collections.Concurrent;
using DMS.Application.DTOs;
using DMS.Application.DTOs.Events;
using DMS.Application.Events;
using DMS.Application.Interfaces;
using DMS.Application.Interfaces.Database;
using DMS.Application.Interfaces.Management;

View File

@@ -1,6 +1,6 @@
using System.Collections.Concurrent;
using DMS.Application.DTOs;
using DMS.Application.DTOs.Events;
using DMS.Application.Events;
using DMS.Application.Interfaces;
using DMS.Application.Interfaces.Database;
using DMS.Application.Interfaces.Management;

View File

@@ -2,8 +2,8 @@ using System;
using System.Collections.Concurrent;
using System.Threading;
using System.Threading.Tasks;
using DMS.Application.Events;
using DMS.Application.Interfaces;
using DMS.Core.Events;
using DMS.Core.Models;
using Microsoft.Extensions.Logging;

View File

@@ -33,7 +33,7 @@ public class HistoryProcessor : IVariableProcessor, IDisposable
// 只有当数据需要保存时才记录历史
if (!context.Data.IsHistoryEnabled) // 如果数据已经被其他处理器处理过或者不需要保存,则跳过
{
_logger.LogDebug("变量 {VariableName} (ID: {VariableId}) 历史记录已禁用,跳过处理", context.Data.Name, context.Data.Id);
// _logger.LogDebug("变量 {VariableName} (ID: {VariableId}) 历史记录已禁用,跳过处理", context.Data.Name, context.Data.Id);
return;
}

View File

@@ -20,7 +20,7 @@ public class ValueConvertProcessor : IVariableProcessor
ConvertS7ValueToStringAndNumeric(context.Data, context.NewValue);
context.Data.UpdatedAt = DateTime.Now;
// 如何值没有变化则中断处理
if (context.Data.DataValue!=oldValue)
if (context.Data.DataValue==oldValue)
{
context.IsHandled = true;
}