1. 创建了 DeviceStateType 枚举来区分状态类型(激活/连接) 2. 创建了 DeviceStateChangedEventArgs 统一事件类 3. 更新了 IEventService 接口,将两个事件合并为一个 4. 更新了 EventService 实现以支持新事件 5. 更新了所有相关服务(DeviceMonitoringService, OpcUaServiceManager, S7ServiceManager, DeviceDataService, DeviceItemViewModel) 关键优点: - 减少了事件类型的数量,简化了事件系统 - 为设备状态变化提供了一致的处理方式 - 保持了向后兼容性,将旧类标记为 [Obsolete]
37 lines
992 B
C#
37 lines
992 B
C#
namespace DMS.Core.Events;
|
|
|
|
/// <summary>
|
|
/// 已弃用:请使用 DeviceStateChangedEventArgs 替代
|
|
/// </summary>
|
|
[Obsolete("Use DeviceStateChangedEventArgs instead")]
|
|
public class DeviceConnectChangedEventArgs
|
|
{
|
|
/// <summary>
|
|
/// 设备ID
|
|
/// </summary>
|
|
public int DeviceId { get; }
|
|
|
|
/// <summary>
|
|
/// 设备名称
|
|
/// </summary>
|
|
public string DeviceName { get; }
|
|
|
|
/// <summary>
|
|
/// 新状态
|
|
/// </summary>
|
|
public bool NewStatus { get; }
|
|
|
|
/// <summary>
|
|
/// 初始化DeviceStatusChangedEventArgs类的新实例
|
|
/// </summary>
|
|
/// <param name="deviceId">设备ID</param>
|
|
/// <param name="deviceName">设备名称</param>
|
|
/// <param name="oldStatus">旧状态</param>
|
|
/// <param name="newStatus">新状态</param>
|
|
public DeviceConnectChangedEventArgs(int deviceId, string deviceName, bool newStatus)
|
|
{
|
|
DeviceId = deviceId;
|
|
DeviceName = deviceName;
|
|
NewStatus = newStatus;
|
|
}
|
|
} |