using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace monitor_main_windows
{
    public partial class FormMonitor : Form
    {
        Timer timer = new Timer();
        public FormMonitor()
        {
            InitializeComponent();
            
        }

        private void Timer_Tick(object sender, EventArgs e)
        {
            led_A_plc.Statu = UIMeaasgeData.Instance.PLCStatuA.IsTimeout() ? monitor_main_windows.LED.LED_Statu.Disconnected :
                (monitor_main_windows.LED.LED_Statu)UIMeaasgeData.Instance.PLCStatuA.Value;
            led_B_plc.Statu = UIMeaasgeData.Instance.PLCStatuB.IsTimeout() ? monitor_main_windows.LED.LED_Statu.Disconnected :
                (monitor_main_windows.LED.LED_Statu)UIMeaasgeData.Instance.PLCStatuB.Value;
            led_C_plc.Statu = UIMeaasgeData.Instance.PLCStatuC.IsTimeout() ? monitor_main_windows.LED.LED_Statu.Disconnected :
                (monitor_main_windows.LED.LED_Statu)UIMeaasgeData.Instance.PLCStatuC.Value;

            led_A1_terminal.Statu = UIMeaasgeData.Instance.TerminalStatuA1.IsTimeout() ? monitor_main_windows.LED.LED_Statu.Disconnected :
                (monitor_main_windows.LED.LED_Statu)UIMeaasgeData.Instance.TerminalStatuA1.Value;
            led_A2_terminal.Statu = UIMeaasgeData.Instance.TerminalStatuA2.IsTimeout() ? monitor_main_windows.LED.LED_Statu.Disconnected :
                (monitor_main_windows.LED.LED_Statu)UIMeaasgeData.Instance.TerminalStatuA2.Value;
            led_B1_terminal.Statu = UIMeaasgeData.Instance.TerminalStatuB1.IsTimeout() ? monitor_main_windows.LED.LED_Statu.Disconnected :
                (monitor_main_windows.LED.LED_Statu)UIMeaasgeData.Instance.TerminalStatuB1.Value;
            led_B2_terminal.Statu = UIMeaasgeData.Instance.TerminalStatuB2.IsTimeout() ? monitor_main_windows.LED.LED_Statu.Disconnected :
                (monitor_main_windows.LED.LED_Statu)UIMeaasgeData.Instance.TerminalStatuB2.Value;
            led_C1_terminal.Statu = UIMeaasgeData.Instance.TerminalStatuC1.IsTimeout() ? monitor_main_windows.LED.LED_Statu.Disconnected :
                (monitor_main_windows.LED.LED_Statu)UIMeaasgeData.Instance.TerminalStatuC1.Value;
            led_C2_terminal.Statu = UIMeaasgeData.Instance.TerminalStatuC2.IsTimeout() ? monitor_main_windows.LED.LED_Statu.Disconnected :
                (monitor_main_windows.LED.LED_Statu)UIMeaasgeData.Instance.TerminalStatuC2.Value;

            led_A1_lidar.Statu = UIMeaasgeData.Instance.LidarStatuA1.IsTimeout() ? monitor_main_windows.LED.LED_Statu.Disconnected :
                (monitor_main_windows.LED.LED_Statu)UIMeaasgeData.Instance.LidarStatuA1.Value;
            led_A2_lidar.Statu = UIMeaasgeData.Instance.LidarStatuA2.IsTimeout() ? monitor_main_windows.LED.LED_Statu.Disconnected :
                (monitor_main_windows.LED.LED_Statu)UIMeaasgeData.Instance.LidarStatuA2.Value;
            led_B1_lidar.Statu = UIMeaasgeData.Instance.LidarStatuB1.IsTimeout() ? monitor_main_windows.LED.LED_Statu.Disconnected :
                (monitor_main_windows.LED.LED_Statu)UIMeaasgeData.Instance.LidarStatuB1.Value;
            led_B2_lidar.Statu = UIMeaasgeData.Instance.LidarStatuB2.IsTimeout() ? monitor_main_windows.LED.LED_Statu.Disconnected :
                (monitor_main_windows.LED.LED_Statu)UIMeaasgeData.Instance.LidarStatuB2.Value;
            led_C1_lidar.Statu = UIMeaasgeData.Instance.LidarStatuC1.IsTimeout() ? monitor_main_windows.LED.LED_Statu.Disconnected :
                (monitor_main_windows.LED.LED_Statu)UIMeaasgeData.Instance.LidarStatuC1.Value;
            led_C2_lidar.Statu = UIMeaasgeData.Instance.LidarStatuC2.IsTimeout() ? monitor_main_windows.LED.LED_Statu.Disconnected :
                (monitor_main_windows.LED.LED_Statu)UIMeaasgeData.Instance.LidarStatuC2.Value;

            led_main.Statu = UIMeaasgeData.Instance.MainNodeStatu.IsTimeout() ? monitor_main_windows.LED.LED_Statu.Disconnected :
                (monitor_main_windows.LED.LED_Statu)UIMeaasgeData.Instance.MainNodeStatu.Value;
            led_database.Statu = UIMeaasgeData.Instance.DatabaseNodeStatu.IsTimeout() ? monitor_main_windows.LED.LED_Statu.Disconnected :
                (monitor_main_windows.LED.LED_Statu)UIMeaasgeData.Instance.DatabaseNodeStatu.Value;
            led_out_terminal1.Statu = UIMeaasgeData.Instance.OutputTerminal1Statu.IsTimeout() ? monitor_main_windows.LED.LED_Statu.Disconnected :
                (monitor_main_windows.LED.LED_Statu)UIMeaasgeData.Instance.OutputTerminal1Statu.Value;
            led_out_terminal2.Statu = UIMeaasgeData.Instance.OutputTerminal2Statu.IsTimeout() ? monitor_main_windows.LED.LED_Statu.Disconnected :
                (monitor_main_windows.LED.LED_Statu)UIMeaasgeData.Instance.OutputTerminal2Statu.Value;
            led_out_unnormal.Statu = UIMeaasgeData.Instance.OutputUnnormalNodeStatu.IsTimeout() ? monitor_main_windows.LED.LED_Statu.Disconnected :
                (monitor_main_windows.LED.LED_Statu)UIMeaasgeData.Instance.OutputUnnormalNodeStatu.Value;


        }
        private void FormMonitor_Load(object sender, EventArgs e)
        {
            timer.Enabled = true;
            timer.Interval = 500;
            timer.Tick += Timer_Tick;
        }

        public void UpdataCommand()
        {
            monitor_main_windows.StepControl step = new StepControl();
            step.Label = System.DateTime.Now.ToString();
            step.Steps = new string[] { "开始", "分配车位" };
            step.BackSteps = new string[] { "清除车位", "异常结束" };
            step.StepIndex = 3;
            step.Dock = DockStyle.Top;
            panel_input_B1.Controls.Add(step);

            monitor_main_windows.StepControl step1 = new StepControl();
            
            step1.Steps = new string[] { "开始", "分配车位","搬运中","确认车位","完成" };
           
            step1.StepIndex = 3;
            step1.Dock = DockStyle.Top;
            step1.Label = System.DateTime.Now.ToString();
            panel_input_B2.Controls.Add(step1);
        }
    }
}
