Files
DMS/DMS.Infrastructure/Services/Mqtt/MqttDeviceContext.cs
David P.G a6fc543e4f 1 feat(mqtt): 实现MQTT服务器状态管理与事件系统
2
    3 1. 在MqttServer和MqttServerDto模型中添加IsConnect属性,用于跟踪连接状态
    4 2. 重构MqttManagementService服务,使用事件驱动方式管理服务器状态变化
    5 3. 实现MqttServerChangedEventArgs事件参数类,支持区分不同变更类型
    6 4. 在IEventService中添加OnMqttServerChanged事件,实现事件通知机制
    7 5. 优化数据存储结构,将MqttServers从ObservableCollection改为ObservableDictionary
    8 6. 更新MqttServiceManager以正确处理连接状态和事件触发
    9 7. 在WPF层更新UI以响应服务器状态变化
   10 8. 删除不再需要的Helper类(DataServicesHelper, MessageHelper, SiemensHelper)
   11 9. 在NLog配置中添加调试器输出目标以便调试
   12 10. 完善VariableHistoryViewModel防止空引用异常
2025-10-05 00:28:25 +08:00

42 lines
1.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Collections.Concurrent;
using DMS.Core.Models;
using DMS.Infrastructure.Interfaces.Services;
namespace DMS.Infrastructure.Services.Mqtt
{
/// <summary>
/// MQTT设备上下文用于存储单个MQTT服务器的连接信息和状态
/// </summary>
public class MqttDeviceContext
{
/// <summary>
/// MQTT服务器配置
/// </summary>
public MqttServer MqttServerConfig { get; set; }
/// <summary>
/// MQTT服务实例
/// </summary>
public IMqttService MqttService { get; set; }
/// <summary>
/// 重连尝试次数
/// </summary>
public int ReconnectAttempts { get; set; }
/// <summary>
/// 与该MQTT服务器关联的所有变量MQTT别名
/// </summary>
public ConcurrentDictionary<int, VariableMqttAlias> VariableMqttAliases { get; set; }
/// <summary>
/// 构造函数
/// </summary>
public MqttDeviceContext()
{
VariableMqttAliases = new ConcurrentDictionary<int, VariableMqttAlias>();
ReconnectAttempts = 0;
}
}
}