using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Concurrent;
namespace monitor_main_windows
{
    class UIMessageData
    {
        public enum NodeStatu
        {
            Normal=0,
            Error
        }

        private TimedData<NodeStatu> m_lidar_statu_A1 = new TimedData<NodeStatu>(NodeStatu.Normal);
        private TimedData<NodeStatu> m_lidar_statu_A2 = new TimedData<NodeStatu>(NodeStatu.Normal);
        private TimedData<NodeStatu> m_lidar_statu_B1 = new TimedData<NodeStatu>(NodeStatu.Normal);
        private TimedData<NodeStatu> m_lidar_statu_B2 = new TimedData<NodeStatu>(NodeStatu.Normal);
        private TimedData<NodeStatu> m_lidar_statu_C1 = new TimedData<NodeStatu>(NodeStatu.Normal);
        private TimedData<NodeStatu> m_lidar_statu_C2 = new TimedData<NodeStatu>(NodeStatu.Normal);

        private TimedData<NodeStatu> m_terminal_statu_A1 = new TimedData<NodeStatu>(NodeStatu.Normal);
        private TimedData<NodeStatu> m_terminal_statu_A2 = new TimedData<NodeStatu>(NodeStatu.Normal);
        private TimedData<NodeStatu> m_terminal_statu_B1 = new TimedData<NodeStatu>(NodeStatu.Normal);
        private TimedData<NodeStatu> m_terminal_statu_B2 = new TimedData<NodeStatu>(NodeStatu.Normal);
        private TimedData<NodeStatu> m_terminal_statu_C1 = new TimedData<NodeStatu>(NodeStatu.Normal);
        private TimedData<NodeStatu> m_terminal_statu_C2 = new TimedData<NodeStatu>(NodeStatu.Normal);

        private TimedData<NodeStatu> m_PLC_statu_A = new TimedData<NodeStatu>(NodeStatu.Normal);
        private TimedData<NodeStatu> m_PLC_statu_B = new TimedData<NodeStatu>(NodeStatu.Normal);
        private TimedData<NodeStatu> m_PLC_statu_C = new TimedData<NodeStatu>(NodeStatu.Normal);

        private TimedData<NodeStatu> m_main_node_statu = new TimedData<NodeStatu>(NodeStatu.Normal);
        private TimedData<NodeStatu> m_database_node_statu = new TimedData<NodeStatu>(NodeStatu.Normal);
        private TimedData<NodeStatu> m_output_terminal_node1_statu = new TimedData<NodeStatu>(NodeStatu.Normal);
        private TimedData<NodeStatu> m_output_terminal_node2_statu = new TimedData<NodeStatu>(NodeStatu.Normal);
        private TimedData<NodeStatu> m_output_unnormilized_statu = new TimedData<NodeStatu>(NodeStatu.Normal);

        public class CommandInfo
        {
            public CommandInfo() { }
            public CommandInfo(string[] steps,string[] backsteps,int index)
            {
                Steps = steps;
                BackSteps = backsteps;
                StepIndex = index;
            }
            public string[] Steps;
            public string[] BackSteps;
            public int StepIndex = 0;
        }
        //控件label为string内容
        private ConcurrentDictionary<string, TimedData<CommandInfo>> m_command_map = 
            new ConcurrentDictionary<string, TimedData<CommandInfo>>();
        class Nested
        {
            // 创建模板类实例，参数2设为true表示支持私有构造函数
            internal static readonly UIMessageData instance = Activator.CreateInstance(typeof(UIMessageData), true) as UIMessageData;
        }
      
        private static UIMessageData instance = null;
       
        public static UIMessageData Instance
        {
            get
            {
                return Nested.instance;
            }
        }
        private UIMessageData()
        {
        }

        #region  雷达节点状态
        public TimedData<NodeStatu> LidarStatuA1
        {
            get { return m_lidar_statu_A1; }
            set { m_lidar_statu_A1 = value; }
        }
        public TimedData<NodeStatu> LidarStatuA2
        {
            get { return m_lidar_statu_A2; }
            set { m_lidar_statu_A2 = value; }
        }
        public TimedData<NodeStatu> LidarStatuB1
        {
            get { return m_lidar_statu_B1; }
            set { m_lidar_statu_B1 = value; }
        }
        public TimedData<NodeStatu> LidarStatuB2
        {
            get { return m_lidar_statu_B2; }
            set { m_lidar_statu_B2 = value; }
        }
        public TimedData<NodeStatu> LidarStatuC1
        {
            get { return m_lidar_statu_C1; }
            set { m_lidar_statu_C1 = value; }
        }
        public TimedData<NodeStatu> LidarStatuC2
        {
            get { return m_lidar_statu_C2; }
            set { m_lidar_statu_C2 = value; }
        }
        #endregion

        #region 终端节点状态

        public TimedData<NodeStatu> TerminalStatuA1
        {
            get { return m_terminal_statu_A1; }
            set { m_terminal_statu_A1 = value; }
        }
        public TimedData<NodeStatu> TerminalStatuA2
        {
            get { return m_terminal_statu_A2; }
            set { m_terminal_statu_A2 = value; }
        }
        public TimedData<NodeStatu> TerminalStatuB1
        {
            get { return m_terminal_statu_B1; }
            set { m_terminal_statu_B1 = value; }
        }
        public TimedData<NodeStatu> TerminalStatuB2
        {
            get { return m_terminal_statu_B2; }
            set { m_terminal_statu_B2 = value; }
        }
        public TimedData<NodeStatu> TerminalStatuC1
        {
            get { return m_terminal_statu_C1; }
            set { m_terminal_statu_C1 = value; }
        }
        public TimedData<NodeStatu> TerminalStatuC2
        {
            get { return m_terminal_statu_C2; }
            set { m_terminal_statu_C2 = value; }
        }
        #endregion

        #region  PLC状态
        public TimedData<NodeStatu> PLCStatuA
        {
            get { return m_PLC_statu_A; }
            set { m_PLC_statu_A = value; }
        }
        public TimedData<NodeStatu> PLCStatuB
        {
            get { return m_PLC_statu_B; }
            set { m_PLC_statu_B = value; }
        }
        public TimedData<NodeStatu> PLCStatuC
        {
            get { return m_PLC_statu_C; }
            set { m_PLC_statu_C = value; }
        }

        #endregion

        public TimedData<NodeStatu> MainNodeStatu
        {
            get { return m_main_node_statu; }
            set { m_main_node_statu = value; }
        }
        public TimedData<NodeStatu> DatabaseNodeStatu
        {
            get { return m_database_node_statu; }
            set { m_database_node_statu = value; }
        }
        public TimedData<NodeStatu> OutputTerminal1Statu
        {
            get { return m_output_terminal_node1_statu; }
            set { m_output_terminal_node1_statu = value; }
        }
        public TimedData<NodeStatu> OutputTerminal2Statu
        {
            get { return m_output_terminal_node2_statu; }
            set { m_output_terminal_node2_statu = value; }
        }
        public TimedData<NodeStatu> OutputUnnormalNodeStatu
        {
            get { return m_output_unnormilized_statu; }
            set { m_output_unnormilized_statu = value; }
        }

        public ConcurrentDictionary<string, TimedData<CommandInfo>>  CommandMap
        {
            get { return m_command_map; }
        }

    }
}
