using BPA.Message;
using BPA.Message.Enum;
using BPASmartClient.Device;
using BPASmartClient.Helper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.Business
{
    /// <summary>
    /// 主题定义
    /// </summary>
    public class TopicDefine : Singleton<TopicDefine>
    {
        /// <summary>
        /// 获取订阅主题
        /// </summary>
        public List<string> SubscribTopics { get; private set; }
        /// <summary>
        /// 获取心跳上报主题
        /// </summary>
        public Dictionary<DeviceClientType, string> PushHeartbeatTopics { get; set; }
        public void Initialize(List<IDevice> devices)
        {
            SubscribTopics = new List<string>();
            PushHeartbeatTopics = new Dictionary<DeviceClientType, string>();
            foreach (var device in devices)
            {
                //SubscribTopics.Add(TOPIC.GetInstance.GetOrderPushTopic(device.DeviceType, Plugin.GetInstance().GetPlugin<ConfigMgr>().ClientId));
                //SubscribTopics.Add(TOPIC.GetInstance.GetBusinessTopic(device.DeviceType, Plugin.GetInstance().GetPlugin<ConfigMgr>().ClientId));

                SubscribTopics.Add(TOPIC.GetInstance.GetOrderPushTopic(device.DeviceType, device.DeviceId));
                SubscribTopics.Add(TOPIC.GetInstance.GetBusinessTopic(device.DeviceType, device.DeviceId));

                PushHeartbeatTopics.Add(device.DeviceType, TOPIC.GetInstance.GetHeatbeatTopic(device.DeviceType));
            }
        }
    }
}
