using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DBFactory;
using ICommLayer;
using CommLayerFactory;
namespace ControlSystem
{
    public partial class FrmStartCheck : Form
    {
        private static FrmStartCheck _formInstance;
        public static FrmStartCheck FormInstance
        {
            get
            {
                if (_formInstance == null)
                {
                    _formInstance = new FrmStartCheck();

                }
                return _formInstance;
            }
            set { _formInstance = value; }
        }
        public FrmStartCheck()
        {
            InitializeComponent();

            
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void FrmStartCheck_Load(object sender, EventArgs e)
        {
            IGetDeviceState gds;
            int[] States;
            CCommonFunction ccf = new CCommonFunction();


            try
            {
                gds = CommModeCreate.CreateGetDeviceState(161);//机器手系统准备好
                States = gds.GetDeviceState(161, 64777);//1完成,2任务号,5设备号
                if (States[0] == 1)
                {
                    lblRobot.Text = "系统准备好!";
                    lblRobot.ForeColor = Color.Blue;
                    this.label3.Visible = false;
                }
                else
                {
                    lblRobot.Text = "未准备好!";
                    lblRobot.ForeColor = Color.Red;
                    this.label3.Visible = true;
                }

            }
            catch (Exception ex)
            {
                if (FrmControlMonitor.FormInstance.GetObjectText("tsStatus").IndexOf("获取状态时：" + ex.Message) < 0)
                {

                    FrmControlMonitor.FormInstance.FlashPanit("tsStatus", "获取状态时：" + ex.Message, true);
                }
                return;
            }
            try
            {
                gds = CommModeCreate.CreateGetDeviceState(179);//堆垛机输送系统准备好
                States = gds.GetDeviceState(179, 64777);//1完成,2任务号,5设备号
                if (States[0] == 1)
                {
                    lblConveyor.Text = "系统准备好!";
                    lblConveyor.ForeColor = Color.Blue;
                    this.label4.Visible = false;
                }
                else
                {
                    lblConveyor.Text = "未准备好!";
                    lblConveyor.ForeColor = Color.Red;
                    this.label4.Visible = true;
                }

            }
            catch (Exception ex)
            {
                if (FrmControlMonitor.FormInstance.GetObjectText("tsStatus").IndexOf("获取状态时：" + ex.Message) < 0)
                {

                    FrmControlMonitor.FormInstance.FlashPanit("tsStatus", "获取状态时：" + ex.Message, true);
                }
                return;
            }
        }
    }
}