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

using SmartX;
using INT_LKD_2.DataStore;
using INT_LKD_2.Controls;
using INT_LKD_2.Part11_UserManager;
using INT_LKD_2.DialogForms;
using INT_LKD_2.Controls.MainDisplay;

namespace INT_LKD_2.Forms
{
    public partial class FormMainDisplay : Form
    {
        #region Field
        public string ChangeID;
        private bool BeforeEthernetStatus;
        private int FlagIgnoreCNT;
        private string MessageBoxRange;
        private int testIndex;
        private Define.E_ProcessStatus CurrentProcessStatus;
        private bool IsTestMode;

        private Color ColorProgressOn;
        private Color ColorProgressOff;
        private Color ColorProgressTextOn;
        private Color ColorProgressTextOff;
        private Color ColorSensorNormal;
        private Color ColorSensorError;
        private Color ColorNumberSelected;
        private Color ColorNumberUnSelected;
        
        private Collection<SmartLabel> CollectionLabelPressureWorking;
        private Collection<SmartLabel> CollectionLabelLeakRatePerSec;
        private Collection<SmartLabel> CollectionLabelDisplacement;
        private Collection<SmartLabel> CollectionLabelSbAlarm;
        private Collection<SmartLabel> CollectionLabelNumber;
        private Collection<SmartLabel> CollectionLabelDispAlarm;
        private Collection<ControlMainResult> CollectionControlResult;

        private FormMain m_ParentForm;

        //private ControlMainDisplay ChildControl;
        public ControlMainModbus ChildModbus;
        private ControlMainDisplay12 ChildMainDisplay10;
        #endregion

        #region Constructor
        public FormMainDisplay(FormMain parent)
        {
            InitializeComponent();

            this.ParentForm = parent;

            this.DefaultSetting();
            this.InitializeData();
            this.InitializeLanguage();
            this.InitializeProcessStatus();
        }
        #endregion

        #region Property
        public FormMain ParentForm
        {
            get { return this.m_ParentForm; }
            private set { this.m_ParentForm = value; }
        }
        #endregion

        #region Method
        private void DefaultSetting()
        {
            int testIndex = 0;
            this.BeforeEthernetStatus = false;
            this.IsTestMode = false;

            this.FlagIgnoreCNT = 0;
            this.MessageBoxRange = "";
            this.CurrentProcessStatus = Define.E_ProcessStatus._0_None;

            this.ColorProgressOff = Color.FromArgb(231, 231, 231);
            this.ColorProgressOn = Color.FromArgb(95, 196, 188);
            this.ColorProgressTextOff = Color.Black;
            this.ColorProgressTextOn = Color.Black;
            this.ColorSensorNormal = Color.FromArgb(39, 200, 64);
            this.ColorSensorError = Color.FromArgb(254, 70, 70);
            this.ColorNumberSelected = Color.Teal;
            this.ColorNumberUnSelected = Color.FromArgb(80, 92, 118);

            this.CollectionLabelPressureWorking = new Collection<SmartLabel>();
            this.CollectionLabelPressureWorking.Clear();
            this.CollectionLabelPressureWorking.Add(this.labelPressureWorking1);
            this.CollectionLabelPressureWorking.Add(this.labelPressureWorking2);
            this.CollectionLabelPressureWorking.Add(this.labelPressureWorking3);
            this.CollectionLabelPressureWorking.Add(this.labelPressureWorking4);
            this.CollectionLabelPressureWorking.Add(this.labelPressureWorking5);
            this.CollectionLabelPressureWorking.Add(this.labelPressureWorking6);
            this.CollectionLabelPressureWorking.Add(this.labelPressureWorking7);
            this.CollectionLabelPressureWorking.Add(this.labelPressureWorking8);
            this.CollectionLabelPressureWorking.Add(this.labelPressureWorking9);
            this.CollectionLabelPressureWorking.Add(this.labelPressureWorking10);
            this.CollectionLabelPressureWorking.Add(this.labelPressureWorking11);
            this.CollectionLabelPressureWorking.Add(this.labelPressureWorking12);

            this.CollectionLabelDisplacement = new Collection<SmartLabel>();
            this.CollectionLabelDisplacement.Clear();
            this.CollectionLabelDisplacement.Add(this.labelDisplacement1);
            this.CollectionLabelDisplacement.Add(this.labelDisplacement2);
            this.CollectionLabelDisplacement.Add(this.labelDisplacement3);
            this.CollectionLabelDisplacement.Add(this.labelDisplacement4);
            this.CollectionLabelDisplacement.Add(this.labelDisplacement5);
            this.CollectionLabelDisplacement.Add(this.labelDisplacement6);
            this.CollectionLabelDisplacement.Add(this.labelDisplacement7);
            this.CollectionLabelDisplacement.Add(this.labelDisplacement8);
            this.CollectionLabelDisplacement.Add(this.labelDisplacement9);
            this.CollectionLabelDisplacement.Add(this.labelDisplacement10);
            this.CollectionLabelDisplacement.Add(this.labelDisplacement11);
            this.CollectionLabelDisplacement.Add(this.labelDisplacement12);

            this.CollectionLabelLeakRatePerSec = new Collection<SmartLabel>();
            this.CollectionLabelLeakRatePerSec.Clear();
            this.CollectionLabelLeakRatePerSec.Add(this.labelLrSec1);
            this.CollectionLabelLeakRatePerSec.Add(this.labelLrSec2);
            this.CollectionLabelLeakRatePerSec.Add(this.labelLrSec3);
            this.CollectionLabelLeakRatePerSec.Add(this.labelLrSec4);
            this.CollectionLabelLeakRatePerSec.Add(this.labelLrSec5);
            this.CollectionLabelLeakRatePerSec.Add(this.labelLrSec6);
            this.CollectionLabelLeakRatePerSec.Add(this.labelLrSec7);
            this.CollectionLabelLeakRatePerSec.Add(this.labelLrSec8);
            this.CollectionLabelLeakRatePerSec.Add(this.labelLrSec9);
            this.CollectionLabelLeakRatePerSec.Add(this.labelLrSec10);
            this.CollectionLabelLeakRatePerSec.Add(this.labelLrSec11);
            this.CollectionLabelLeakRatePerSec.Add(this.labelLrSec12);

            this.CollectionLabelSbAlarm = new Collection<SmartLabel>();
            this.CollectionLabelSbAlarm.Clear();
            this.CollectionLabelSbAlarm.Add(this.labelSbAlarm1);
            this.CollectionLabelSbAlarm.Add(this.labelSbAlarm2);
            this.CollectionLabelSbAlarm.Add(this.labelSbAlarm3);
            this.CollectionLabelSbAlarm.Add(this.labelSbAlarm4);
            this.CollectionLabelSbAlarm.Add(this.labelSbAlarm5);
            this.CollectionLabelSbAlarm.Add(this.labelSbAlarm6);
            this.CollectionLabelSbAlarm.Add(this.labelSbAlarm7);
            this.CollectionLabelSbAlarm.Add(this.labelSbAlarm8);
            this.CollectionLabelSbAlarm.Add(this.labelSbAlarm9);
            this.CollectionLabelSbAlarm.Add(this.labelSbAlarm10);
            this.CollectionLabelSbAlarm.Add(this.labelSbAlarm11);
            this.CollectionLabelSbAlarm.Add(this.labelSbAlarm12);

            this.CollectionLabelNumber = new Collection<SmartLabel>();
            this.CollectionLabelNumber.Clear();
            this.CollectionLabelNumber.Add(this.labelNumber1);
            this.CollectionLabelNumber.Add(this.labelNumber2);
            this.CollectionLabelNumber.Add(this.labelNumber3);
            this.CollectionLabelNumber.Add(this.labelNumber4);
            this.CollectionLabelNumber.Add(this.labelNumber5);
            this.CollectionLabelNumber.Add(this.labelNumber6);
            this.CollectionLabelNumber.Add(this.labelNumber7);
            this.CollectionLabelNumber.Add(this.labelNumber8);
            this.CollectionLabelNumber.Add(this.labelNumber9);
            this.CollectionLabelNumber.Add(this.labelNumber10);
            this.CollectionLabelNumber.Add(this.labelNumber11);
            this.CollectionLabelNumber.Add(this.labelNumber12);

            this.CollectionLabelDispAlarm = new Collection<SmartLabel>();
            this.CollectionLabelDispAlarm.Clear();
            this.CollectionLabelDispAlarm.Add(this.labeldispAlarm1);
            this.CollectionLabelDispAlarm.Add(this.labeldispAlarm2);
            this.CollectionLabelDispAlarm.Add(this.labeldispAlarm3);
            this.CollectionLabelDispAlarm.Add(this.labeldispAlarm4);
            this.CollectionLabelDispAlarm.Add(this.labeldispAlarm5);
            this.CollectionLabelDispAlarm.Add(this.labeldispAlarm6);
            this.CollectionLabelDispAlarm.Add(this.labeldispAlarm7);
            this.CollectionLabelDispAlarm.Add(this.labeldispAlarm8);
            this.CollectionLabelDispAlarm.Add(this.labeldispAlarm9);
            this.CollectionLabelDispAlarm.Add(this.labeldispAlarm10);
            this.CollectionLabelDispAlarm.Add(this.labeldispAlarm11);
            this.CollectionLabelDispAlarm.Add(this.labeldispAlarm12);

            this.CollectionControlResult = new Collection<ControlMainResult>();
            for (int i = 0; i < 12; i++)
                this.CollectionControlResult.Add(new ControlMainResult(this));
         
            for (int i = 0; i < 12; i++)
            {
                this.Controls.Add(this.CollectionControlResult[i]);
                this.CollectionControlResult[i].BringToFront();
                this.CollectionControlResult[i].Visible = false;
            }

            this.CollectionControlResult[0].Location = new Point(610, 205);
            this.CollectionControlResult[1].Location = new Point(755, 205);
            this.CollectionControlResult[2].Location = new Point(610, 299);
            this.CollectionControlResult[3].Location = new Point(755, 299);
            this.CollectionControlResult[4].Location = new Point(610, 393);
            this.CollectionControlResult[5].Location = new Point(755, 393);
            this.CollectionControlResult[6].Location = new Point(610, 487);
            this.CollectionControlResult[7].Location = new Point(755, 487);
            this.CollectionControlResult[8].Location = new Point(610, 581);
            this.CollectionControlResult[9].Location = new Point(755, 581);
            this.CollectionControlResult[10].Location = new Point(610, 675);
            this.CollectionControlResult[11].Location = new Point(755, 675);

            //this.ChildControl = new ControlMainDisplay(this.ParentForm);
            //this.Controls.Add(this.ChildControl);
            //this.ChildControl.Location = new Point(0, 118);
            //this.ChildControl.BringToFront();
            //this.ChildControl.Visible = false;

            this.ChildModbus = new ControlMainModbus(this);
            this.Controls.Add(this.ChildModbus);
            this.ChildModbus.Location = new Point(0, 155);
            this.ChildModbus.BringToFront();
            this.ChildModbus.Visible = false;

            this.ChildMainDisplay10 = new ControlMainDisplay12(this);
            this.Controls.Add(this.ChildMainDisplay10);
            this.ChildMainDisplay10.Location = new Point(0, 147);
            this.ChildMainDisplay10.BringToFront();
            this.ChildMainDisplay10.Visible = false;

            this.buttonRecipeNo.ButtonText = this.ParentForm.SystemConfig.RECIPE_NUMBER.ToString();
            this.UpdateDisplayUser(this.ParentForm.CurrentSystemStatus.CurrentUser);
        }
        private void InitializeData()
        {
            for (int i = 0; i < this.ParentForm.SystemConfig.EQUIPMENT_LANE; i++)
            {
                this.CollectionControlResult[i].Visible = false;
                this.SetLabelPressureWorking(this.CollectionLabelPressureWorking[i], "0.0");
                this.SetLabelLeakRatePerSec(this.CollectionLabelLeakRatePerSec[i], "0.0");
                this.SetLabelDisplacement(this.CollectionLabelDisplacement[i], "0.00/0.00");
                this.CollectionLabelSbAlarm[i].Visible = false;
                this.CollectionLabelDispAlarm[i].Visible = false;
                this.SetLabelNumberColor(i, this.ColorNumberUnSelected);
            }
        }
        private void InitializeLanguage()
        {
            switch (this.ParentForm.SystemConfig.LANGUAGE)
            {
                case Define.E_LanguageID.Korean:
                    this.labelProgress0_1.Text = "초기상태";
                    this.labelProgress1_1.Text = "제품이동";
                    this.labelProgress2_1.Text = "측정 중";
                    this.labelProgress3_1.Text = "배출";
                    break;
                case Define.E_LanguageID.English:
                    this.labelProgress0_1.Text = "Ready";
                    this.labelProgress1_1.Text = "Chamber shift";
                    this.labelProgress2_1.Text = "Measuring";
                    this.labelProgress3_1.Text = "Discharge";
                    break;
                default:
                    break;
            }
        }

        private void InitializeProcessStatus()
        {
            this.pictureBoxProgress0_1.Visible = false;
            this.pictureBoxProgress0_2.Visible = false;
            this.pictureBoxProgress1_34.Visible = false;
            this.pictureBoxProgress2_5.Visible = false;
            this.pictureBoxProgress2_6.Visible = false;
            this.pictureBoxProgress2_78.Visible = false;
            this.pictureBoxProgress2_910.Visible = false;
            this.pictureBoxProgress3_11.Visible = false;

            this.progressBar1.Value = this.progressBar1.Minimum;

            this.SetLabelRoundRectFillColor(this.labelProgress0, this.ColorProgressOff);
            this.SetLabelRoundRectFillColor(this.labelProgress1, this.ColorProgressOff);
            this.SetLabelRoundRectFillColor(this.labelProgress2, this.ColorProgressOff);
            this.SetLabelRoundRectFillColor(this.labelProgress3, this.ColorProgressOff);
            this.SetLabelBackGroundColor(this.labelProgress0_1, this.ColorProgressOff);
            this.SetLabelBackGroundColor(this.labelProgress1_1, this.ColorProgressOff);
            this.SetLabelBackGroundColor(this.labelProgress2_1, this.ColorProgressOff);
            this.SetLabelBackGroundColor(this.labelProgress3_1, this.ColorProgressOff);
            this.SetLabelTextColor(this.labelProgress0_1, this.ColorProgressTextOff);
            this.SetLabelTextColor(this.labelProgress1_1, this.ColorProgressTextOff);
            this.SetLabelTextColor(this.labelProgress2_1, this.ColorProgressTextOff);
            this.SetLabelTextColor(this.labelProgress3_1, this.ColorProgressTextOff);
        }
        private bool UI_Invoke(ThreadStart invoker)
        {
            try
            {
                if (this.InvokeRequired)
                {
                    if (this.IsDisposed)
                        return true;

                    this.Invoke(invoker);
                }
                else
                {
                    invoker();
                }

                return true;

            }
            catch (Exception e)
            {
                return false;
            }

        }
        private void SetLabelBackGroundColor(SmartLabel label, Color c)
        {
            if (label.BackGroundColor != c)
                label.BackGroundColor = c;
        }
        private void SetLabelRoundRectFillColor(SmartLabel label, Color c)
        {
            if (label.RoundRectFillColor != c)
                label.RoundRectFillColor = c;
        }
        private void SetLabelTextColor(SmartLabel label, Color c)
        {
            if (label.TextColor != c)
                label.TextColor = c;
        }
        private void SetLabelNumberColor(int index, Color c)
        {
            if (this.CollectionLabelNumber[index].BackGroundColor != c)
            {
                this.CollectionLabelNumber[index].BackGroundColor = c;
                this.CollectionLabelSbAlarm[index].BackGroundColor = c;
            }
        }
        private void SetLabelPressureWorking(SmartLabel label, string data)
        {
            label.Text = string.Format("W{0,15} kPa", data);
        }
        private void SetLabelLeakRatePerSec(SmartLabel label, string data)
        {
            label.Text = string.Format("{0,12}   Pa", data);
        }
        private void SetLabelDisplacement(SmartLabel label, string data)
        {
            label.Text = string.Format("{0,15}  mm", data);        
        }

        private void UpdateDisplayUser(UserItem user)
        {
            string id = "", group = "", expireDate = "";

            switch (user.Group)
            {
                case Define.E_UserGroup.None:
                    break;
                case Define.E_UserGroup.Level1:
                    id = user.ID;
                    group = user.Group.ToString();

                    if (this.labelUserLevel.TextColor != this.ParentForm.ColorLogOn)
                        this.labelUserLevel.TextColor = this.labelUserID.TextColor = this.ParentForm.ColorLogOn;

                    this.labelExpireOfPassword.Visible = true;

                    this.buttonUser.ButtonDown();
                    this.buttonRecipeNo.Enabled = this.ParentForm.CurrentUserGroup.Level1.IsMainDisplayProductChange;
                    this.buttonClear.Enabled = this.ParentForm.CurrentUserGroup.Level1.IsMainDisplayClear;
                    this.buttonInspection.Enabled = true;
                    this.buttonMenu.Enabled = true;
                    break;
                case Define.E_UserGroup.Level2:
                    id = user.ID;
                    group = user.Group.ToString();

                    if (this.labelUserLevel.TextColor != this.ParentForm.ColorLogOn)
                        this.labelUserLevel.TextColor = this.labelUserID.TextColor = this.ParentForm.ColorLogOn;

                    this.labelExpireOfPassword.Visible = true;

                    this.buttonUser.ButtonDown();
                    this.buttonRecipeNo.Enabled = this.ParentForm.CurrentUserGroup.Level2.IsMainDisplayProductChange;
                    this.buttonClear.Enabled = this.ParentForm.CurrentUserGroup.Level2.IsMainDisplayClear;
                    this.buttonInspection.Enabled = true;
                    this.buttonMenu.Enabled = true;
                    break;
                case Define.E_UserGroup.Level3:
                    id = user.ID;
                    group = user.Group.ToString();

                    this.labelExpireOfPassword.Visible = true;

                    if (this.labelUserLevel.TextColor != this.ParentForm.ColorLogOn)
                        this.labelUserLevel.TextColor = this.labelUserID.TextColor = this.ParentForm.ColorLogOn;

                    this.buttonUser.ButtonDown();
                    this.buttonRecipeNo.Enabled = this.ParentForm.CurrentUserGroup.Level3.IsMainDisplayProductChange;
                    this.buttonClear.Enabled = this.ParentForm.CurrentUserGroup.Level3.IsMainDisplayClear;
                    this.buttonInspection.Enabled = true;
                    this.buttonMenu.Enabled = true;
                    break;
                case Define.E_UserGroup.Admin:
                    id = user.ID;
                    group = user.Group.ToString();

                    this.labelExpireOfPassword.Visible = false;

                    if (this.labelUserLevel.TextColor != this.ParentForm.ColorLogOn)
                        this.labelUserLevel.TextColor = this.labelUserID.TextColor = this.ParentForm.ColorLogOn;

                    this.buttonUser.ButtonDown();
                    this.buttonRecipeNo.Enabled = true;
                    this.buttonClear.Enabled = true;
                    this.buttonInspection.Enabled = true;
                    this.buttonMenu.Enabled = true;
                    break;
                case Define.E_UserGroup.Developer:
                    id = user.ID;
                    group = user.Group.ToString();

                    this.labelExpireOfPassword.Visible = true;

                    if (this.labelUserLevel.TextColor != this.ParentForm.ColorLogOn)
                        this.labelUserLevel.TextColor = this.labelUserID.TextColor = this.ParentForm.ColorLogOn;

                    this.buttonUser.ButtonDown();
                    this.buttonRecipeNo.Enabled = true;
                    this.buttonClear.Enabled = true;
                    this.buttonInspection.Enabled = true;
                    this.buttonMenu.Enabled = true;
                    break;
                case Define.E_UserGroup.NotLogin:
                    id = "";
                    group = "";

                    this.labelExpireOfPassword.Visible = false;

                    this.buttonRecipeNo.Enabled = true;
                    this.buttonClear.Enabled = true;
                    this.buttonInspection.Enabled = true;
                    this.buttonMenu.Enabled = true;
                    break;
                case Define.E_UserGroup.LogOut:
                    id = "Log Off";
                    group = "-";

                    this.labelExpireOfPassword.Visible = false;

                    if (this.labelUserLevel.TextColor != this.ParentForm.ColorLogOff)
                        this.labelUserLevel.TextColor = this.labelUserID.TextColor = this.ParentForm.ColorLogOff;

                    this.buttonUser.ButtonUp();
                    this.buttonRecipeNo.Enabled = false;
                    this.buttonClear.Enabled = false;
                    this.buttonInspection.Enabled = false;
                    this.buttonMenu.Enabled = false;
                    break;
                default:
                    break;
            }

            // button Color
            this.buttonRecipeNo.ButtonColor = this.ParentForm.ButtonColorChange(this.buttonRecipeNo.Enabled);
            this.buttonClear.ButtonColor = this.ParentForm.ButtonColorChange(this.buttonClear.Enabled);
            this.buttonMenu.ButtonColor = this.ParentForm.ButtonColorChange(this.buttonMenu.Enabled);

            if (this.buttonInspection.Enabled == true)
                this.buttonInspection.ButtonColor = Color.DarkGreen;
            else
                this.buttonInspection.ButtonColor = this.ParentForm.ButtonColorChange(this.buttonInspection.Enabled);

            expireDate = this.DisplayExpireOfPassword(user.Group);
            if (expireDate != "-")
            {
                int intExpireDate = int.Parse(expireDate);

                if (intExpireDate == 0)
                {
                    this.labelExpireOfPassword.TextColor = this.ParentForm.ColorLogOff;
                    this.labelExpireOfPassword.Text = "D-0";
                }
                else if (intExpireDate < 0)
                {
                    if (intExpireDate * -1 > this.ParentForm.CurrentSystemStatus.CurrentUser.ExpirePassword)
                        expireDate = "-" + (this.ParentForm.CurrentSystemStatus.CurrentUser.ExpirePassword - 1).ToString();

                    this.labelExpireOfPassword.Text = "D" + expireDate;
                    if (intExpireDate >= -10)
                        this.labelExpireOfPassword.TextColor = this.ParentForm.ColorLogOff;
                    else
                        this.labelExpireOfPassword.TextColor = this.ParentForm.ColorLogOn;
                }
                else
                {
                    this.labelExpireOfPassword.TextColor = this.ParentForm.ColorLogOn;
                    this.labelExpireOfPassword.Text = "D+" + expireDate;
                }
            }
            else
            {
                this.labelExpireOfPassword.TextColor = this.ParentForm.ColorLogOn;
                this.labelExpireOfPassword.Text = "-";
            }

            if (this.labelUserLevel.Text != group)
                this.labelUserLevel.Text = group;
            if (this.labelUserID.Text != id)
                this.labelUserID.Text = id;
        }
        private void Login()
        {
            int extract = 0;
            DialogResult result;

            DialogFormLogOn logOn = new DialogFormLogOn(this.ParentForm, false, false);
            result = logOn.ShowDialog();
            if (result == DialogResult.OK)
            {
                if (this.ParentForm.CurrentSystemStatus.CurrentUser.Group == Define.E_UserGroup.Level1 ||
                    this.ParentForm.CurrentSystemStatus.CurrentUser.Group == Define.E_UserGroup.Level2 ||
                    this.ParentForm.CurrentSystemStatus.CurrentUser.Group == Define.E_UserGroup.Level3)
                {
                    // 비밀번호 만료일 10일 미만 체크 후 비밀번호 변경
                    this.PasswordExpirationCheck(this.ParentForm.CurrentSystemStatus.CurrentUser);
                }

                //this.ParentForm.ChildFormMenu.CenterEquipUserGroupEditor.UpdateAllMenu(this.ParentForm.CurrentSystemStatus);
                this.DisplayRefresh();

                this.buttonUser.ButtonDown();
                this.ParentForm.ChildFormMenu.UpdateDisplayUser(this.ParentForm.CurrentSystemStatus.CurrentUser);
            }
            else if (result == DialogResult.Abort)
            {
                // 비밀 번호 변경 띄우기
                DialogFormLogOn logOn1 = new DialogFormLogOn(this.ParentForm, false, true);
                if (logOn1.ShowDialog() == DialogResult.OK)
                {
                    //this.ParentForm.ChildFormMenu.CenterEquipUserGroupEditor.UpdateAllMenu(this.ParentForm.CurrentSystemStatus);
                    this.DisplayRefresh();

                    this.buttonUser.ButtonDown();
                    this.ParentForm.ChildFormMenu.UpdateDisplayUser(this.ParentForm.CurrentSystemStatus.CurrentUser);
                }
                else
                    this.buttonUser.ButtonUp();
            }
            else
            {
                this.buttonUser.ButtonUp();
            }
        }
        public void Logout()
        {
            this.ParentForm.CurrentSystemStatus.CurrentUser.Group = Define.E_UserGroup.LogOut;
            this.buttonUser.ButtonUp();
            this.buttonUser.ButtonText = "Login";
            this.ChangeID = "";

            // Part 11
            this.ParentForm.SetTrackingHistoryData(Define.E_TrackingOperation.Logout, "");

            this.DisplayRefresh();
        }
        private void PasswordExpirationCheck(UserItem user)
        {
            int expiryDay = 0;

            // 만료일 -10 일때 메시지 띄우기
            expiryDay = user.GetPasswordExpiryDday();
            if (expiryDay >= -10)
            {
                //Console.WriteLine("password : " + expiryDay.ToString());
                if (expiryDay < 0)
                    expiryDay *= -1;

                DialogFormYesNo myDlg = new DialogFormYesNo(this.ParentForm.SystemConfig.LANGUAGE, 2, expiryDay.ToString());
                if (myDlg.ShowDialog() == DialogResult.Yes)
                {
                    // 비밀 번호 변경 띄우기
                    DialogFormLogOn logOn = new DialogFormLogOn(this.ParentForm, true, true);
                    if (logOn.ShowDialog() == DialogResult.OK)
                    {

                    }
                }
            }
        }
        public void Part11AutomaticLogoutReset()
        {
            //UserManager.UserManager_AutoLogoutTimeoutReset();
        }
        public string DisplayExpireOfPassword(Define.E_UserGroup group)
        {
            string ret = "";

            if (group == Define.E_UserGroup.Admin || group == Define.E_UserGroup.Developer)
                ret = "-";
            else
            {
                //TimeSpan resultTime = DateTime.Now - this.ParentForm.CurrentSystemStatus.CurrentUser.DateExpireRegister;
                TimeSpan dayDiff = DateTime.Now.Date - this.ParentForm.CurrentSystemStatus.CurrentUser.DatePasswordExpire.Date;
                ret = dayDiff.Days.ToString();
            }

            return ret;
        }

        public void CallBackUserListModifyInfoData(UserManager.UserMgr_user_info_t user)
        {
            this.ParentForm.CurrentSystemStatus.CurrentUser.DatePasswordExpire = DateTime.Now.AddDays(this.ParentForm.CurrentSystemStatus.CurrentUser.ExpirePassword - 1);
            this.DisplayExpireOfPassword(this.ParentForm.CurrentSystemStatus.CurrentUser.Group);
        }
        public void CallBackUserListLoginTimeoutDataEvent(UserManager.UserMgr_login_timeout_t user)
        {
            string code = "", message1 = "", message2 = "";
            int warningTime = 0;

            if (user.remainder_time != 0)
            {
                switch (this.ParentForm.SystemConfig.LANGUAGE)
                {
                    case Define.E_LanguageID.Korean:
                        code = "로그인";
                        message1 = "잠시 후에 로그아웃 됩니다";
                        message2 = "";
                        break;
                    case Define.E_LanguageID.English:
                        code = "Login";
                        message1 = "You will be logged out after a while";
                        message2 = "";
                        break;
                    default:
                        break;
                }

                warningTime = this.ParentForm.FlagAutomaticLogoutWarningTime - 2;

                this.UI_Invoke(delegate
                {
                    DialogFormMessage msg = new DialogFormMessage(Define.E_MessageBoxIcon.Asterisk, code, message1, message2, warningTime);
                    msg.ShowDialog();
                });
            }
            else
            {
                switch (this.ParentForm.SystemConfig.LANGUAGE)
                {
                    case Define.E_LanguageID.Korean:
                        code = "Login";
                        message1 = "자동 로그아웃 되었습니다";
                        message2 = "";
                        break;
                    case Define.E_LanguageID.English:
                        code = "Login";
                        message1 = "automatically logged out";
                        message2 = "";
                        break;
                    default:
                        break;
                }

                // User Logout
                UserManager.UserManager_UserLogout();

                this.UI_Invoke(delegate
                {
                    this.Logout();
                });

                this.UI_Invoke(delegate
                {
                    DialogFormMessage msg = new DialogFormMessage(Define.E_MessageBoxIcon.Asterisk, code, message1, message2, 0);
                    msg.ShowDialog();
                });
            }
        }

        private void ProgressBarSetting(Define.E_ProcessStatus status)
        {
            switch (status)
            {
                case Define.E_ProcessStatus._6_VacuumStart:
                    this.smartTimerProgressBar.Start();
                    break;
                case Define.E_ProcessStatus._7_VacuumHold:
                    this.progressBar1.Value = 30;
                    break;
                case Define.E_ProcessStatus._8_Judgment:
                    this.progressBar1.Value = 60;
                    break;
                case Define.E_ProcessStatus._9_VacuumBreak:
                    this.progressBar1.Value = this.progressBar1.Maximum;
                    this.smartTimerProgressBar.Stop();
                    break;
                default:
                    break;
            }
        }

        public void InitialEthernetIcon()
        {
            // 이더넷
            if (this.ParentForm.SystemConfig.IsEthernetEnable == true)
            {
                this.pictureBoxEthernetDisable.Visible = false;
                this.pictureBoxEthernetDisconnection.Visible = true;
                this.pictureBoxEthernetConnection.Visible = false;
            }
            else
            {
                this.pictureBoxEthernetDisable.Visible = true;
                this.pictureBoxEthernetDisconnection.Visible = false;
                this.pictureBoxEthernetConnection.Visible = false;
            }
        }
        public void UpdateEthernetStatusDisplay(bool status)
        {
            //Console.Write("\n" + string.Format("UpdateEthernetStatusDisplay {0:yyyy-MM-dd HH:mm:ss}: {1}", DateTime.Now, status.ToString()));

            if (this.BeforeEthernetStatus == status)
                return;
            else
                this.BeforeEthernetStatus = status;

            if (status == true)
            {
                this.pictureBoxEthernetConnection.Visible = true;
                this.pictureBoxEthernetDisconnection.Visible = false;
            }
            else
            {
                this.pictureBoxEthernetConnection.Visible = false;
                this.pictureBoxEthernetDisconnection.Visible = true;
            }
        }
        public void TimerServer(bool value)
        {
            if (value == false)
            {
                if (this.timerServer.IsStart == true)
                    this.timerServer.Stop();
            }
            else
            {
                if (this.timerServer.IsStart == false)
                    this.timerServer.Start();
            }
        }
        public void MainButtonModbusAdd(bool bValue)
        {
            this.buttonModbus.Visible = bValue;
        }

        private void UpdateDisplayDotGraphDiff(SmartDraw draw, DiffData diff)
        {
            int iValue = 0;
            double dValue = 0.0;

            // 값 표시 범위
            // 15.000 ~ -2.000  (17.000 ~ 0)
            // 그래프 영역 높이 102
            // 17000 / 102 = 166.666666~
            //dValue = (int.Parse(data.CurrentValueSign + data.CurrentValue) + 2000) / 166.66666;

            if (dValue > 110)
                dValue = 110;
            if (dValue < 1)
                dValue = 1;

            iValue = int.Parse(string.Format("{0:f0}", dValue));

            draw.Chart.PutData(iValue);
        }
        private void UpdateDisplayDotGraphDisp(SmartDraw draw, DispData disp)
        {
            int iValue = 0;
            double dValue = 0.0;

            // 값 표시 범위
            // 15.000 ~ -2.000  (17.000 ~ 0)
            // 그래프 영역 높이 102
            // 17000 / 102 = 166.666666~
            //dValue = (int.Parse(data.CurrentValueSign + data.CurrentValue) + 2000) / 166.66666;

            if (dValue > 110)
                dValue = 110;
            if (dValue < 1)
                dValue = 1;

            iValue = int.Parse(string.Format("{0:f0}", dValue));

            draw.Chart.PutData(iValue);
        }
        public void UpdateEquipmentStatusDisplay(Define.E_EquipmentStatus status)
        {
            if (status == Define.E_EquipmentStatus.Start)
            {
                #region Start
                this.labelStart.Visible = true;
                this.labelStop.Visible = false;
                #endregion
            }
            else
            {
                #region Stop
                this.labelStart.Visible = false;
                this.labelStop.Visible = true;

                this.InitializeData();
                #endregion
            }
        }
        public void UpdateDisplayAlarmView(AlarmList alarm)
        {
            string value = "";

            // A1_ServoEmergencyStop
            if (alarm.A1_ServoEmergencyStop == true)
                value = "a1_Emergency stop     ";
            // A2_PressureError
            if (alarm.A2_PressureError == true)
                value += "a2_Pressure     ";
            // A3_MasterSlaveComm
            if (alarm.A3_BoardStatusCOM == true)
                value += "a3_M/S Board     ";

            // A5_ServoAlarm1
            if (alarm.A5_ServoAlarm1 == true)
                value += "a5_Servo1     ";
            // A6_ServoTorqueAlarm1
            if (alarm.A6_ServoTorqueAlarm1 == true)
                value += "a6_Servo Torque1     ";
            // A7_ServoAlarm2
            if (alarm.A7_ServoAlarm2 == true)
                value += "a7_Servo2     ";
            // A8_ServoTorqueAlarm2
            if (alarm.A8_ServoTorqueAlarm2 == true)
                value += "a8_Servo Torque2     ";
            // A9_PressureSensorError1
            if (alarm.A9_PressureSensorError1 == true)
                value += "a9_Pressure Sensor1     ";
            // A10_PressureSensorError2
            if (alarm.A10_PressureSensorError2 == true)
                value += "a10_Pressure Sensor2     ";

            // A13_차압센서에러1
            if (alarm.A13_DiffSensorError1 == true)
                value += "a13_Diff Sensor1     ";
            // A14_차압센서에러2
            if (alarm.A14_DiffSensorError2 == true)
                value += "a14_Diff Sensor2     ";
            // A17_변위센서에러1
            if (alarm.A17_DispSensorError1 == true)
                value += "a17_Disp Sensor1     ";
            // A18_변위센서에러2
            if (alarm.A18_DispSensorError2 == true)
                value += "a18_Disp Sensor2     ";

            value = value.Trim();
            this.labelAlarm.Size = new Size(value.Length * 9, 30);
            this.labelAlarm.Text = value;

            if (this.labelAlarm.Width > 400)
            {
                if (this.labelAlarm.Text != "")
                    this.smartTimerAlarm.Start();
            }
            else
            {
                this.smartTimerAlarm.Stop();
                this.labelAlarm.Location = new Point(3, 26);
            }
        }

        private void ProcessStatusPicturBox(Define.E_ProcessStatus status)
        {
            switch (status)
            {
                case Define.E_ProcessStatus._0_None:
                    break;
                case Define.E_ProcessStatus._1_Ready:
                    this.pictureBoxProgress0_1.Visible = true;
                    this.pictureBoxProgress0_1.BringToFront();
                    this.pictureBoxProgress0_2.Visible = false;
                    this.pictureBoxProgress1_34.Visible = false;
                    this.pictureBoxProgress2_5.Visible = false;
                    this.pictureBoxProgress2_6.Visible = false;
                    this.pictureBoxProgress2_78.Visible = false;
                    this.pictureBoxProgress2_910.Visible = false;
                    this.pictureBoxProgress3_11.Visible = false;
                    break;
                case Define.E_ProcessStatus._2_ProductEntry:
                    this.pictureBoxProgress0_1.Visible = false;
                    this.pictureBoxProgress0_2.Visible = true;
                    this.pictureBoxProgress0_2.BringToFront();
                    this.pictureBoxProgress1_34.Visible = false;
                    this.pictureBoxProgress2_5.Visible = false;
                    this.pictureBoxProgress2_6.Visible = false;
                    this.pictureBoxProgress2_78.Visible = false;
                    this.pictureBoxProgress2_910.Visible = false;
                    this.pictureBoxProgress3_11.Visible = false;
                    break;
                case Define.E_ProcessStatus._3_MoveToLeak:
                case Define.E_ProcessStatus._4_MoveToCheck:
                    this.pictureBoxProgress0_1.Visible = false;
                    this.pictureBoxProgress0_2.Visible = false;
                    this.pictureBoxProgress1_34.Visible = true;
                    this.pictureBoxProgress1_34.BringToFront();
                    this.pictureBoxProgress2_5.Visible = false;
                    this.pictureBoxProgress2_6.Visible = false;
                    this.pictureBoxProgress2_78.Visible = false;
                    this.pictureBoxProgress2_910.Visible = false;
                    this.pictureBoxProgress3_11.Visible = false;
                    break;
                case Define.E_ProcessStatus._5_ChamberMerge:
                    this.pictureBoxProgress0_1.Visible = false;
                    this.pictureBoxProgress0_2.Visible = false;
                    this.pictureBoxProgress1_34.Visible = false;
                    this.pictureBoxProgress2_5.Visible = true;
                    this.pictureBoxProgress2_5.BringToFront();
                    this.pictureBoxProgress2_6.Visible = false;
                    this.pictureBoxProgress2_78.Visible = false;
                    this.pictureBoxProgress2_910.Visible = false;
                    this.pictureBoxProgress3_11.Visible = false;
                    break;
                case Define.E_ProcessStatus._6_VacuumStart:
                case Define.E_ProcessStatus._7_VacuumHold:
                    this.pictureBoxProgress0_1.Visible = false;
                    this.pictureBoxProgress0_2.Visible = false;
                    this.pictureBoxProgress1_34.Visible = false;
                    this.pictureBoxProgress2_5.Visible = false;
                    this.pictureBoxProgress2_6.Visible = true;
                    this.pictureBoxProgress2_6.BringToFront();
                    this.pictureBoxProgress2_78.Visible = false;
                    this.pictureBoxProgress2_910.Visible = false;
                    this.pictureBoxProgress3_11.Visible = false;
                    break;
                case Define.E_ProcessStatus._8_Judgment:
                    this.pictureBoxProgress0_1.Visible = false;
                    this.pictureBoxProgress0_2.Visible = false;
                    this.pictureBoxProgress1_34.Visible = false;
                    this.pictureBoxProgress2_5.Visible = false;
                    this.pictureBoxProgress2_6.Visible = false;
                    this.pictureBoxProgress2_78.Visible = true;
                    this.pictureBoxProgress2_78.BringToFront();
                    this.pictureBoxProgress2_910.Visible = false;
                    this.pictureBoxProgress3_11.Visible = false;
                    break;
                case Define.E_ProcessStatus._9_VacuumBreak:
                case Define.E_ProcessStatus._10_ChamberRelease:
                    this.pictureBoxProgress0_1.Visible = false;
                    this.pictureBoxProgress0_2.Visible = false;
                    this.pictureBoxProgress1_34.Visible = false;
                    this.pictureBoxProgress2_5.Visible = false;
                    this.pictureBoxProgress2_6.Visible = false;
                    this.pictureBoxProgress2_78.Visible = false;
                    this.pictureBoxProgress2_910.Visible = true;
                    this.pictureBoxProgress2_910.BringToFront();
                    this.pictureBoxProgress3_11.Visible = false;
                    break;
                case Define.E_ProcessStatus._11_MoveToReady:
                    this.pictureBoxProgress0_1.Visible = false;
                    this.pictureBoxProgress0_2.Visible = false;
                    this.pictureBoxProgress1_34.Visible = false;
                    this.pictureBoxProgress2_5.Visible = false;
                    this.pictureBoxProgress2_6.Visible = false;
                    this.pictureBoxProgress2_78.Visible = false;
                    this.pictureBoxProgress2_910.Visible = false;
                    this.pictureBoxProgress3_11.Visible = true;
                    this.pictureBoxProgress3_11.BringToFront();
                    break;
                default:
                    break;
            }
        }
        // 진행상태 데이터
        private void ProcessStatusStep1(Define.E_ProcessStatus status)
        {
            this.smartTimerProgressBar.Stop();
            this.progressBar1.Value = this.progressBar1.Minimum;
            
            this.SetLabelRoundRectFillColor(this.labelProgress0, this.ColorProgressOn);
            this.SetLabelRoundRectFillColor(this.labelProgress1, this.ColorProgressOff);
            this.SetLabelRoundRectFillColor(this.labelProgress2, this.ColorProgressOff);
            this.SetLabelRoundRectFillColor(this.labelProgress3, this.ColorProgressOff);

            this.SetLabelBackGroundColor(this.labelProgress0_1, this.ColorProgressOn);
            this.SetLabelBackGroundColor(this.labelProgress1_1, this.ColorProgressOff);
            this.SetLabelBackGroundColor(this.labelProgress2_1, this.ColorProgressOff);
            this.SetLabelBackGroundColor(this.labelProgress3_1, this.ColorProgressOff);

            this.SetLabelTextColor(this.labelProgress0_1, this.ColorProgressTextOn);
            this.SetLabelTextColor(this.labelProgress1_1, this.ColorProgressTextOff);
            this.SetLabelTextColor(this.labelProgress2_1, this.ColorProgressTextOff);
            this.SetLabelTextColor(this.labelProgress3_1, this.ColorProgressTextOff);
        }
        private void ProcessStatusStep2(Define.E_ProcessStatus status)
        {
            this.smartTimerProgressBar.Stop();
            this.progressBar1.Value = this.progressBar1.Minimum;

            this.SetLabelRoundRectFillColor(this.labelProgress0, this.ColorProgressOff);
            this.SetLabelRoundRectFillColor(this.labelProgress1, this.ColorProgressOn);
            this.SetLabelRoundRectFillColor(this.labelProgress2, this.ColorProgressOff);
            this.SetLabelRoundRectFillColor(this.labelProgress3, this.ColorProgressOff);

            this.SetLabelBackGroundColor(this.labelProgress0_1, this.ColorProgressOff);
            this.SetLabelBackGroundColor(this.labelProgress1_1, this.ColorProgressOn);
            this.SetLabelBackGroundColor(this.labelProgress2_1, this.ColorProgressOff);
            this.SetLabelBackGroundColor(this.labelProgress3_1, this.ColorProgressOff);

            this.SetLabelTextColor(this.labelProgress0_1, this.ColorProgressTextOff);
            this.SetLabelTextColor(this.labelProgress1_1, this.ColorProgressTextOn);
            this.SetLabelTextColor(this.labelProgress2_1, this.ColorProgressTextOff);
            this.SetLabelTextColor(this.labelProgress3_1, this.ColorProgressTextOff);
        }
        private void ProcessStatusStep3(Define.E_ProcessStatus status)
        {
            this.SetLabelRoundRectFillColor(this.labelProgress0, this.ColorProgressOff);
            this.SetLabelRoundRectFillColor(this.labelProgress1, this.ColorProgressOff);
            this.SetLabelRoundRectFillColor(this.labelProgress2, this.ColorProgressOn);
            this.SetLabelRoundRectFillColor(this.labelProgress3, this.ColorProgressOff);

            this.SetLabelBackGroundColor(this.labelProgress0_1, this.ColorProgressOff);
            this.SetLabelBackGroundColor(this.labelProgress1_1, this.ColorProgressOff);
            this.SetLabelBackGroundColor(this.labelProgress2_1, this.ColorProgressOn);
            this.SetLabelBackGroundColor(this.labelProgress3_1, this.ColorProgressOff);

            this.SetLabelTextColor(this.labelProgress0_1, this.ColorProgressTextOff);
            this.SetLabelTextColor(this.labelProgress1_1, this.ColorProgressTextOff);
            this.SetLabelTextColor(this.labelProgress2_1, this.ColorProgressTextOn);
            this.SetLabelTextColor(this.labelProgress3_1, this.ColorProgressTextOff);

            this.ProgressBarSetting(status);
        }
        private void ProcessStatusStep4(Define.E_ProcessStatus status)
        {
            this.smartTimerProgressBar.Stop();
            this.progressBar1.Value = this.progressBar1.Minimum;

            this.SetLabelRoundRectFillColor(this.labelProgress0, this.ColorProgressOff);
            this.SetLabelRoundRectFillColor(this.labelProgress1, this.ColorProgressOff);
            this.SetLabelRoundRectFillColor(this.labelProgress2, this.ColorProgressOff);
            this.SetLabelRoundRectFillColor(this.labelProgress3, this.ColorProgressOn);

            this.SetLabelBackGroundColor(this.labelProgress0_1, this.ColorProgressOff);
            this.SetLabelBackGroundColor(this.labelProgress1_1, this.ColorProgressOff);
            this.SetLabelBackGroundColor(this.labelProgress2_1, this.ColorProgressOff);
            this.SetLabelBackGroundColor(this.labelProgress3_1, this.ColorProgressOn);

            this.SetLabelTextColor(this.labelProgress0_1, this.ColorProgressTextOff);
            this.SetLabelTextColor(this.labelProgress1_1, this.ColorProgressTextOff);
            this.SetLabelTextColor(this.labelProgress2_1, this.ColorProgressTextOff);
            this.SetLabelTextColor(this.labelProgress3_1, this.ColorProgressTextOn);
        }
        public void UpdateDisplayProcessStatus(Define.E_ProcessStatus status)
        {
            this.CurrentProcessStatus = status;
            this.labelProcess.Text = status.ToString();

            switch (status)
            {
                case Define.E_ProcessStatus._0_None:
                    break;
                case Define.E_ProcessStatus._1_Ready:
                    this.ProcessStatusStep1(status);

                    for (int i = 0; i < this.ParentForm.SystemConfig.EQUIPMENT_LANE; i++)
                        this.ParentForm.CurrentLeakDatas[i].ProcessStatus = Define.E_ProcessStatus._1_Ready;

                    this.pictureBoxProgress0_1.Visible = true;
                    this.pictureBoxProgress0_1.BringToFront();
                    this.pictureBoxProgress0_2.Visible = false;
                    this.pictureBoxProgress1_34.Visible = false;
                    this.pictureBoxProgress2_5.Visible = false;
                    this.pictureBoxProgress2_6.Visible = false;
                    this.pictureBoxProgress2_78.Visible = false;
                    this.pictureBoxProgress2_910.Visible = false;
                    this.pictureBoxProgress3_11.Visible = false;
                    break;
                case Define.E_ProcessStatus._2_ProductEntry:
                    this.InitializeData();
                    this.ProcessStatusStep1(status);

                    // Modbus
                    if (this.ParentForm.SystemConfig.ETHERNET_COMM_MODE == 1)
                    {
                        this.ParentForm.Current30000ModbusData.Initialization();
                        for (int i = 0; i < this.ParentForm.SystemConfig.EQUIPMENT_LANE; i++)
                        {
                            this.ParentForm.Current30000ModbusData.CollectionIsProcessing[i] = 0;
                            this.ParentForm.Current30000ModbusData.CollectionIsLeak[i] = 0;
                            this.ParentForm.CurrentLeakDatas[i].Clear();
                        }
                    }

                    this.pictureBoxProgress0_1.Visible = false;
                    this.pictureBoxProgress0_2.Visible = true;
                    this.pictureBoxProgress0_2.BringToFront();
                    this.pictureBoxProgress1_34.Visible = false;
                    this.pictureBoxProgress2_5.Visible = false;
                    this.pictureBoxProgress2_6.Visible = false;
                    this.pictureBoxProgress2_78.Visible = false;
                    this.pictureBoxProgress2_910.Visible = false;
                    this.pictureBoxProgress3_11.Visible = false;
                    break;
                case Define.E_ProcessStatus._3_MoveToLeak:
                case Define.E_ProcessStatus._4_MoveToCheck:
                    this.ProcessStatusStep2(status);

                    this.pictureBoxProgress0_1.Visible = false;
                    this.pictureBoxProgress0_2.Visible = false;
                    this.pictureBoxProgress1_34.Visible = true;
                    this.pictureBoxProgress1_34.BringToFront();
                    this.pictureBoxProgress2_5.Visible = false;
                    this.pictureBoxProgress2_6.Visible = false;
                    this.pictureBoxProgress2_78.Visible = false;
                    this.pictureBoxProgress2_910.Visible = false;
                    this.pictureBoxProgress3_11.Visible = false;
                    break;
                case Define.E_ProcessStatus._5_ChamberMerge:
                    this.ProcessStatusStep3(status);

                    this.pictureBoxProgress0_1.Visible = false;
                    this.pictureBoxProgress0_2.Visible = false;
                    this.pictureBoxProgress1_34.Visible = false;
                    this.pictureBoxProgress2_5.Visible = true;
                    this.pictureBoxProgress2_5.BringToFront();
                    this.pictureBoxProgress2_6.Visible = false;
                    this.pictureBoxProgress2_78.Visible = false;
                    this.pictureBoxProgress2_910.Visible = false;
                    this.pictureBoxProgress3_11.Visible = false;
                    break;
                case Define.E_ProcessStatus._6_VacuumStart:
                    this.ProcessStatusStep3(status);

                    this.pictureBoxProgress0_1.Visible = false;
                    this.pictureBoxProgress0_2.Visible = false;
                    this.pictureBoxProgress1_34.Visible = false;
                    this.pictureBoxProgress2_5.Visible = false;
                    this.pictureBoxProgress2_6.Visible = true;
                    this.pictureBoxProgress2_6.BringToFront();
                    this.pictureBoxProgress2_78.Visible = false;
                    this.pictureBoxProgress2_910.Visible = false;
                    this.pictureBoxProgress3_11.Visible = false;
                    break;
                case Define.E_ProcessStatus._7_VacuumHold:
                case Define.E_ProcessStatus._8_Judgment:
                    this.ProcessStatusStep3(status);

                    this.pictureBoxProgress0_1.Visible = false;
                    this.pictureBoxProgress0_2.Visible = false;
                    this.pictureBoxProgress1_34.Visible = false;
                    this.pictureBoxProgress2_5.Visible = false;
                    this.pictureBoxProgress2_6.Visible = false;
                    this.pictureBoxProgress2_78.Visible = true;
                    this.pictureBoxProgress2_78.BringToFront();
                    this.pictureBoxProgress2_910.Visible = false;
                    this.pictureBoxProgress3_11.Visible = false;
                    break;
                case Define.E_ProcessStatus._9_VacuumBreak:
                case Define.E_ProcessStatus._10_ChamberRelease:
                    this.ProcessStatusStep3(status);

                    this.pictureBoxProgress0_1.Visible = false;
                    this.pictureBoxProgress0_2.Visible = false;
                    this.pictureBoxProgress1_34.Visible = false;
                    this.pictureBoxProgress2_5.Visible = false;
                    this.pictureBoxProgress2_6.Visible = false;
                    this.pictureBoxProgress2_78.Visible = false;
                    this.pictureBoxProgress2_910.Visible = true;
                    this.pictureBoxProgress2_910.BringToFront();
                    this.pictureBoxProgress3_11.Visible = false;
                    break;
                case Define.E_ProcessStatus._11_MoveToReady:
                    this.ProcessStatusStep4(status);

                    // Modbus
                    this.ParentForm.ChildFormMainDisplay.UpdateDisplayJudgmentTrackingData(this.ParentForm.CurrentLeakDatas);

                    this.pictureBoxProgress0_1.Visible = false;
                    this.pictureBoxProgress0_2.Visible = false;
                    this.pictureBoxProgress1_34.Visible = false;
                    this.pictureBoxProgress2_5.Visible = false;
                    this.pictureBoxProgress2_6.Visible = false;
                    this.pictureBoxProgress2_78.Visible = false;
                    this.pictureBoxProgress2_910.Visible = false;
                    this.pictureBoxProgress3_11.Visible = true;
                    this.pictureBoxProgress3_11.BringToFront();
                    break;
                default:
                    break;
            }

            this.ChildMainDisplay10.UpdateDisplayProcessStatus(status);

            // Modbus
            if (this.ParentForm.SystemConfig.ETHERNET_COMM_MODE == 1)
                this.ParentForm.Update30000ModbusItem();
        }
        public void UpdateDisplayProcessStatus1(Define.E_ProcessStatus status)
        {
            if (this.ParentForm.CurrentSystemStatus.EquipmentStatus == Define.E_EquipmentStatus.Start)
            {
                this.SetLabelNumberColor(5, this.ColorNumberUnSelected);
                this.SetLabelNumberColor(6, this.ColorNumberUnSelected);

                this.SetLabelNumberColor(0, this.ColorNumberSelected);
                this.SetLabelNumberColor(11, this.ColorNumberSelected);
            }
        }
        public void UpdateDisplayProcessStatus2(Define.E_ProcessStatus status)
        {
            if (this.ParentForm.CurrentSystemStatus.EquipmentStatus == Define.E_EquipmentStatus.Start)
            {
                this.SetLabelNumberColor(0, this.ColorNumberUnSelected);
                this.SetLabelNumberColor(11, this.ColorNumberUnSelected);

                this.SetLabelNumberColor(1, this.ColorNumberSelected);
                this.SetLabelNumberColor(10, this.ColorNumberSelected);
            }
        }
        public void UpdateDisplayProcessStatus3(Define.E_ProcessStatus status)
        {
            if (this.ParentForm.CurrentSystemStatus.EquipmentStatus == Define.E_EquipmentStatus.Start)
            {
                this.SetLabelNumberColor(1, this.ColorNumberUnSelected);
                this.SetLabelNumberColor(10, this.ColorNumberUnSelected);

                this.SetLabelNumberColor(2, this.ColorNumberSelected);
                this.SetLabelNumberColor(9, this.ColorNumberSelected);
            }
        }
        public void UpdateDisplayProcessStatus4(Define.E_ProcessStatus status)
        {
            if (this.ParentForm.CurrentSystemStatus.EquipmentStatus == Define.E_EquipmentStatus.Start)
            {
                this.SetLabelNumberColor(2, this.ColorNumberUnSelected);
                this.SetLabelNumberColor(9, this.ColorNumberUnSelected);

                this.SetLabelNumberColor(3, this.ColorNumberSelected);
                this.SetLabelNumberColor(8, this.ColorNumberSelected);
            }
        }
        public void UpdateDisplayProcessStatus5(Define.E_ProcessStatus status)
        {
            if (this.ParentForm.CurrentSystemStatus.EquipmentStatus == Define.E_EquipmentStatus.Start)
            {
                this.SetLabelNumberColor(3, this.ColorNumberUnSelected);
                this.SetLabelNumberColor(8, this.ColorNumberUnSelected);

                this.SetLabelNumberColor(4, this.ColorNumberSelected);
                this.SetLabelNumberColor(7, this.ColorNumberSelected);
            }
        }
        public void UpdateDisplayProcessStatus6(Define.E_ProcessStatus status)
        {
            if (this.ParentForm.CurrentSystemStatus.EquipmentStatus == Define.E_EquipmentStatus.Start)
            {
                if (status == Define.E_ProcessStatus._4_MoveToCheck || status == Define.E_ProcessStatus._5_ChamberMerge)
                {
                    this.SetLabelNumberColor(4, this.ColorNumberUnSelected);
                    this.SetLabelNumberColor(7, this.ColorNumberUnSelected);

                    this.SetLabelNumberColor(5, this.ColorNumberSelected);
                    this.SetLabelNumberColor(6, this.ColorNumberSelected);
                }
            }
        }
        public void UpdateDisplayProcessStatus7(Define.E_ProcessStatus status)
        {
           
        }
        public void UpdateDisplayProcessStatus8(Define.E_ProcessStatus status)
        {
        }
        public void UpdateDisplayProcessStatus9(Define.E_ProcessStatus status)
        {
        }
        public void UpdateDisplayProcessStatus10(Define.E_ProcessStatus status)
        {
        }
        public void UpdateDisplayProcessStatus11(Define.E_ProcessStatus status)
        {
        }
        public void UpdateDisplayProcessStatus12(Define.E_ProcessStatus status)
        {
        }

        // 차압센서 데이터
        public void UpdateDisplayDiffData1(LeakData1 data)
        {
            this.SetLabelLeakRatePerSec(this.CollectionLabelLeakRatePerSec[0], data.DiffData.SecBuf);
            this.ChildMainDisplay10.UpdateDisplayDiffData1(data);
        }
        public void UpdateDisplayDiffData2(LeakData1 data)
        {
            this.SetLabelLeakRatePerSec(this.CollectionLabelLeakRatePerSec[1], data.DiffData.SecBuf);
            this.ChildMainDisplay10.UpdateDisplayDiffData2(data);
        }
        public void UpdateDisplayDiffData3(LeakData1 data)
        {
            this.SetLabelLeakRatePerSec(this.CollectionLabelLeakRatePerSec[2], data.DiffData.SecBuf);
            this.ChildMainDisplay10.UpdateDisplayDiffData3(data);
        }
        public void UpdateDisplayDiffData4(LeakData1 data)
        {
            this.SetLabelLeakRatePerSec(this.CollectionLabelLeakRatePerSec[3], data.DiffData.SecBuf);
            this.ChildMainDisplay10.UpdateDisplayDiffData4(data);
        }
        public void UpdateDisplayDiffData5(LeakData1 data)
        {
            this.SetLabelLeakRatePerSec(this.CollectionLabelLeakRatePerSec[4], data.DiffData.SecBuf);
            this.ChildMainDisplay10.UpdateDisplayDiffData5(data);
        }
        public void UpdateDisplayDiffData6(LeakData1 data)
        {
            this.SetLabelLeakRatePerSec(this.CollectionLabelLeakRatePerSec[5], data.DiffData.SecBuf);
            this.ChildMainDisplay10.UpdateDisplayDiffData6(data);
        }
        public void UpdateDisplayDiffData7(LeakData1 data)
        {
            this.SetLabelLeakRatePerSec(this.CollectionLabelLeakRatePerSec[6], data.DiffData.SecBuf);
            this.ChildMainDisplay10.UpdateDisplayDiffData7(data);
        }
        public void UpdateDisplayDiffData8(LeakData1 data)
        {
            this.SetLabelLeakRatePerSec(this.CollectionLabelLeakRatePerSec[7], data.DiffData.SecBuf);
            this.ChildMainDisplay10.UpdateDisplayDiffData8(data);
        }
        public void UpdateDisplayDiffData9(LeakData1 data)
        {
            this.SetLabelLeakRatePerSec(this.CollectionLabelLeakRatePerSec[8], data.DiffData.SecBuf);
            this.ChildMainDisplay10.UpdateDisplayDiffData9(data);
        }
        public void UpdateDisplayDiffData10(LeakData1 data)
        {
            this.SetLabelLeakRatePerSec(this.CollectionLabelLeakRatePerSec[9], data.DiffData.SecBuf);
            this.ChildMainDisplay10.UpdateDisplayDiffData10(data);
        }
        public void UpdateDisplayDiffData11(LeakData1 data)
        {
            this.SetLabelLeakRatePerSec(this.CollectionLabelLeakRatePerSec[10], data.DiffData.SecBuf);
            this.ChildMainDisplay10.UpdateDisplayDiffData11(data);
        }
        public void UpdateDisplayDiffData12(LeakData1 data)
        {
            this.SetLabelLeakRatePerSec(this.CollectionLabelLeakRatePerSec[11], data.DiffData.SecBuf);
            this.ChildMainDisplay10.UpdateDisplayDiffData12(data);
        }

        // 변위센서 데이터
        public void UpdateDisplayDispData1(LeakData1 data)
        {
            string value = "";

            value = string.Format("{0}/{1}", data.DispData.MData, data.DispData.MDataMax);
            this.SetLabelDisplacement(this.CollectionLabelDisplacement[0], value);

            this.ChildMainDisplay10.UpdateDisplayDispData1(data);
        }
        public void UpdateDisplayDispData2(LeakData1 data)
        {
            string value = "";

            value = string.Format("{0}/{1}", data.DispData.MData, data.DispData.MDataMax);
            this.SetLabelDisplacement(this.CollectionLabelDisplacement[1], value);

            this.ChildMainDisplay10.UpdateDisplayDispData2(data);
        }
        public void UpdateDisplayDispData3(LeakData1 data)
        {
            string value = "";

            value = string.Format("{0}/{1}", data.DispData.MData, data.DispData.MDataMax);
            this.SetLabelDisplacement(this.CollectionLabelDisplacement[2], value);

            this.ChildMainDisplay10.UpdateDisplayDispData3(data);
        }
        public void UpdateDisplayDispData4(LeakData1 data)
        {
            string value = "";

            value = string.Format("{0}/{1}", data.DispData.MData, data.DispData.MDataMax);
            this.SetLabelDisplacement(this.CollectionLabelDisplacement[3], value);

            this.ChildMainDisplay10.UpdateDisplayDispData4(data);
        }
        public void UpdateDisplayDispData5(LeakData1 data)
        {
            string value = "";

            value = string.Format("{0}/{1}", data.DispData.MData, data.DispData.MDataMax);
            this.SetLabelDisplacement(this.CollectionLabelDisplacement[4], value);

            this.ChildMainDisplay10.UpdateDisplayDispData5(data);
        }
        public void UpdateDisplayDispData6(LeakData1 data)
        {
            string value = "";

            value = string.Format("{0}/{1}", data.DispData.MData, data.DispData.MDataMax);
            this.SetLabelDisplacement(this.CollectionLabelDisplacement[5], value);

            this.ChildMainDisplay10.UpdateDisplayDispData6(data);
        }
        public void UpdateDisplayDispData7(LeakData1 data)
        {
            string value = "";

            value = string.Format("{0}/{1}", data.DispData.MData, data.DispData.MDataMax);
            this.SetLabelDisplacement(this.CollectionLabelDisplacement[6], value);

            this.ChildMainDisplay10.UpdateDisplayDispData7(data);
        }
        public void UpdateDisplayDispData8(LeakData1 data)
        {
            string value = "";

            value = string.Format("{0}/{1}", data.DispData.MData, data.DispData.MDataMax);
            this.SetLabelDisplacement(this.CollectionLabelDisplacement[7], value);

            this.ChildMainDisplay10.UpdateDisplayDispData8(data);
        }
        public void UpdateDisplayDispData9(LeakData1 data)
        {
            string value = "";

            value = string.Format("{0}/{1}", data.DispData.MData, data.DispData.MDataMax);
            this.SetLabelDisplacement(this.CollectionLabelDisplacement[8], value);

            this.ChildMainDisplay10.UpdateDisplayDispData9(data);
        }
        public void UpdateDisplayDispData10(LeakData1 data)
        {
            string value = "";

            value = string.Format("{0}/{1}", data.DispData.MData, data.DispData.MDataMax);
            this.SetLabelDisplacement(this.CollectionLabelDisplacement[9], value);

            this.ChildMainDisplay10.UpdateDisplayDispData10(data);
        }
        public void UpdateDisplayDispData11(LeakData1 data)
        {
            string value = "";

            value = string.Format("{0}/{1}", data.DispData.MData, data.DispData.MDataMax);
            this.SetLabelDisplacement(this.CollectionLabelDisplacement[10], value);

            this.ChildMainDisplay10.UpdateDisplayDispData11(data);
        }
        public void UpdateDisplayDispData12(LeakData1 data)
        {
            string value = "";

            value = string.Format("{0}/{1}", data.DispData.MData, data.DispData.MDataMax);
            this.SetLabelDisplacement(this.CollectionLabelDisplacement[11], value);

            this.ChildMainDisplay10.UpdateDisplayDispData12(data);
        }

        // 압력센서 데이터
        public void UpdateDisplayPresData1(LeakData1 data)
        {
            this.SetLabelPressureWorking(this.CollectionLabelPressureWorking[0], data.PresData.WorkingChamber.Trim());
            this.ChildMainDisplay10.UpdateDisplayPresData1(data);
        }
        public void UpdateDisplayPresData2(LeakData1 data)
        {
            this.SetLabelPressureWorking(this.CollectionLabelPressureWorking[1], data.PresData.WorkingChamber.Trim());
            this.ChildMainDisplay10.UpdateDisplayPresData2(data);
        }
        public void UpdateDisplayPresData3(LeakData1 data)
        {
            this.SetLabelPressureWorking(this.CollectionLabelPressureWorking[2], data.PresData.WorkingChamber.Trim());
            this.ChildMainDisplay10.UpdateDisplayPresData3(data);
        }
        public void UpdateDisplayPresData4(LeakData1 data)
        {
            this.SetLabelPressureWorking(this.CollectionLabelPressureWorking[3], data.PresData.WorkingChamber.Trim());
            this.ChildMainDisplay10.UpdateDisplayPresData4(data);
        }
        public void UpdateDisplayPresData5(LeakData1 data)
        {
            this.SetLabelPressureWorking(this.CollectionLabelPressureWorking[4], data.PresData.WorkingChamber.Trim());
            this.ChildMainDisplay10.UpdateDisplayPresData5(data);
        }
        public void UpdateDisplayPresData6(LeakData1 data)
        {
            this.SetLabelPressureWorking(this.CollectionLabelPressureWorking[5], data.PresData.WorkingChamber.Trim());
            this.ChildMainDisplay10.UpdateDisplayPresData6(data);
        }
        public void UpdateDisplayPresData7(LeakData1 data)
        {
            this.SetLabelPressureWorking(this.CollectionLabelPressureWorking[6], data.PresData.WorkingChamber.Trim());
            this.ChildMainDisplay10.UpdateDisplayPresData7(data);
        }
        public void UpdateDisplayPresData8(LeakData1 data)
        {
            this.SetLabelPressureWorking(this.CollectionLabelPressureWorking[7], data.PresData.WorkingChamber.Trim());
            this.ChildMainDisplay10.UpdateDisplayPresData8(data);
        }
        public void UpdateDisplayPresData9(LeakData1 data)
        {
            this.SetLabelPressureWorking(this.CollectionLabelPressureWorking[8], data.PresData.WorkingChamber.Trim());
            this.ChildMainDisplay10.UpdateDisplayPresData9(data);
        }
        public void UpdateDisplayPresData10(LeakData1 data)
        {
            this.SetLabelPressureWorking(this.CollectionLabelPressureWorking[9], data.PresData.WorkingChamber.Trim());
            this.ChildMainDisplay10.UpdateDisplayPresData10(data);
        }
        public void UpdateDisplayPresData11(LeakData1 data)
        {
            this.SetLabelPressureWorking(this.CollectionLabelPressureWorking[10], data.PresData.WorkingChamber.Trim());
            this.ChildMainDisplay10.UpdateDisplayPresData11(data);
        }
        public void UpdateDisplayPresData12(LeakData1 data)
        {
            this.SetLabelPressureWorking(this.CollectionLabelPressureWorking[11], data.PresData.WorkingChamber.Trim());
            this.ChildMainDisplay10.UpdateDisplayPresData12(data);
        }
        
        // 판정결과
        public void UpdateDisplayJudgmentData1(LeakData1 data)
        {
            if (this.IsTestMode == false)
            {
                this.CollectionControlResult[0].SetResult(data.Judgment);
                this.CollectionControlResult[0].Visible = true;

                //this.ChildControl.UpdateStartLeakDataDisplay1(data);
                this.ChildMainDisplay10.UpdateDisplayJudgmentData1(data);
            }
            else
            {
                this.CollectionControlResult[0].SetResultTestMode(Define.E_JudgmentStatus.Ng, Define.E_JudgmentStatus.Ng, Define.E_JudgmentStatus.Pass);
                this.CollectionControlResult[0].Visible = true;
            }
        }
        public void UpdateDisplayJudgmentData2(LeakData1 data)
        {
            if (this.IsTestMode == false)
            {
                this.CollectionControlResult[1].SetResult(data.Judgment);
                this.CollectionControlResult[1].Visible = true;

                //this.ChildControl.UpdateStartLeakDataDisplay2(data);
                this.ChildMainDisplay10.UpdateDisplayJudgmentData2(data);
            }
            else
            {
                this.CollectionControlResult[1].SetResultTestMode(Define.E_JudgmentStatus.Pass, Define.E_JudgmentStatus.Pass, Define.E_JudgmentStatus.Pass);
                this.CollectionControlResult[1].Visible = true;
            }
        }
        public void UpdateDisplayJudgmentData3(LeakData1 data)
        {
            if (this.IsTestMode == false)
            {
                this.CollectionControlResult[2].SetResult(data.Judgment);
                this.CollectionControlResult[2].Visible = true;

                //this.ChildControl.UpdateStartLeakDataDisplay3(data);
                this.ChildMainDisplay10.UpdateDisplayJudgmentData3(data);
            }
            else
            {
                this.CollectionControlResult[2].SetResultTestMode(Define.E_JudgmentStatus.Pass, Define.E_JudgmentStatus.Pass, Define.E_JudgmentStatus.Pass);
                this.CollectionControlResult[2].Visible = true;
            }
        }
        public void UpdateDisplayJudgmentData4(LeakData1 data)
        {
            if (this.IsTestMode == false)
            {
                this.CollectionControlResult[3].SetResult(data.Judgment);
                this.CollectionControlResult[3].Visible = true;

                //this.ChildControl.UpdateStartLeakDataDisplay4(data);
                this.ChildMainDisplay10.UpdateDisplayJudgmentData4(data);
            }
            else
            {
                this.CollectionControlResult[3].SetResultTestMode(Define.E_JudgmentStatus.Ng, Define.E_JudgmentStatus.Pass, Define.E_JudgmentStatus.Ng);
                this.CollectionControlResult[3].Visible = true;
            }
        }
        public void UpdateDisplayJudgmentData5(LeakData1 data)
        {
            if (this.IsTestMode == false)
            {
                this.CollectionControlResult[4].SetResult(data.Judgment);
                this.CollectionControlResult[4].Visible = true;

                //this.ChildControl.UpdateStartLeakDataDisplay5(data);
                this.ChildMainDisplay10.UpdateDisplayJudgmentData5(data);
            }
            else
            {
                this.CollectionControlResult[4].SetResultTestMode(Define.E_JudgmentStatus.Pass, Define.E_JudgmentStatus.Pass, Define.E_JudgmentStatus.Pass);
                this.CollectionControlResult[4].Visible = true;
            }
        }
        public void UpdateDisplayJudgmentData6(LeakData1 data)
        {
            if (this.IsTestMode == false)
            {
                this.CollectionControlResult[5].SetResult(data.Judgment);
                this.CollectionControlResult[5].Visible = true;

                //this.ChildControl.UpdateStartLeakDataDisplay6(data);
                this.ChildMainDisplay10.UpdateDisplayJudgmentData6(data);
            }
            else
            {
                this.CollectionControlResult[5].SetResultTestMode(Define.E_JudgmentStatus.Pass, Define.E_JudgmentStatus.Pass, Define.E_JudgmentStatus.Pass);
                this.CollectionControlResult[5].Visible = true;
            }
        }
        public void UpdateDisplayJudgmentData7(LeakData1 data)
        {
            if (this.IsTestMode == false)
            {
                this.CollectionControlResult[6].SetResult(data.Judgment);
                this.CollectionControlResult[6].Visible = true;

                //this.ChildControl.UpdateStartLeakDataDisplay7(data);
                this.ChildMainDisplay10.UpdateDisplayJudgmentData7(data);
            }
            else
            {
                this.CollectionControlResult[6].SetResultTestMode(Define.E_JudgmentStatus.Pass, Define.E_JudgmentStatus.Pass, Define.E_JudgmentStatus.Pass);
                this.CollectionControlResult[6].Visible = true;
            }
        }
        public void UpdateDisplayJudgmentData8(LeakData1 data)
        {
            if (this.IsTestMode == false)
            {
                this.CollectionControlResult[7].SetResult(data.Judgment);
                this.CollectionControlResult[7].Visible = true;

                //this.ChildControl.UpdateStartLeakDataDisplay8(data);
                this.ChildMainDisplay10.UpdateDisplayJudgmentData8(data);
            }
            else
            {
                this.CollectionControlResult[7].SetResultTestMode(Define.E_JudgmentStatus.Ng, Define.E_JudgmentStatus.Pass, Define.E_JudgmentStatus.Ng);
                this.CollectionControlResult[7].Visible = true;
            }
        }
        public void UpdateDisplayJudgmentData9(LeakData1 data)
        {
            if (this.IsTestMode == false)
            {
                this.CollectionControlResult[8].SetResult(data.Judgment);
                this.CollectionControlResult[8].Visible = true;

                //this.ChildControl.UpdateStartLeakDataDisplay9(data);
                this.SetLabelNumberColor(8, this.ColorNumberUnSelected);
                this.ChildMainDisplay10.UpdateDisplayJudgmentData9(data);
            }
            else
            {
                this.CollectionControlResult[8].SetResultTestMode(Define.E_JudgmentStatus.Pass, Define.E_JudgmentStatus.Pass, Define.E_JudgmentStatus.Pass);
                this.CollectionControlResult[8].Visible = true;
            }
        }
        public void UpdateDisplayJudgmentData10(LeakData1 data)
        {
            if (this.IsTestMode == false)
            {
                this.CollectionControlResult[9].SetResult(data.Judgment);
                this.CollectionControlResult[9].Visible = true;

                //this.ChildControl.UpdateStartLeakDataDisplay10(data);
                this.SetLabelNumberColor(9, this.ColorNumberUnSelected);
                this.ChildMainDisplay10.UpdateDisplayJudgmentData10(data);
            }
            else
            {
                this.CollectionControlResult[9].SetResultTestMode(Define.E_JudgmentStatus.Pass, Define.E_JudgmentStatus.Pass, Define.E_JudgmentStatus.Pass);
                this.CollectionControlResult[9].Visible = true;
            }
        }
        public void UpdateDisplayJudgmentData11(LeakData1 data)
        {
            if (this.IsTestMode == false)
            {
                this.CollectionControlResult[10].SetResult(data.Judgment);
                this.CollectionControlResult[10].Visible = true;

                //this.ChildControl.UpdateStartLeakDataDisplay10(data);
                this.SetLabelNumberColor(10, this.ColorNumberUnSelected);
                this.ChildMainDisplay10.UpdateDisplayJudgmentData11(data);
            }
            else
            {
                this.CollectionControlResult[10].SetResultTestMode(Define.E_JudgmentStatus.Pass, Define.E_JudgmentStatus.Pass, Define.E_JudgmentStatus.Pass);
                this.CollectionControlResult[10].Visible = true;
            }
        }
        public void UpdateDisplayJudgmentData12(LeakData1 data)
        {
            if (this.IsTestMode == false)
            {
                this.CollectionControlResult[11].SetResult(data.Judgment);
                this.CollectionControlResult[11].Visible = true;

                //this.ChildControl.UpdateStartLeakDataDisplay10(data);
                this.SetLabelNumberColor(11, this.ColorNumberUnSelected);
                this.ChildMainDisplay10.UpdateDisplayJudgmentData12(data);
            }
            else
            {
                this.CollectionControlResult[11].SetResultTestMode(Define.E_JudgmentStatus.Pass, Define.E_JudgmentStatus.Pass, Define.E_JudgmentStatus.Pass);
                this.CollectionControlResult[11].Visible = true;
            }
        }
        public void UpdateDisplayJudgmentTrackingData(Collection<LeakData1> items)
        {
            this.ParentForm.TrackingInspectionData(items);
        }

        public void UpdateDisplayRecipeData(Recipe data)
        {
            this.buttonRecipeNo.ButtonText = data.NUMBER.ToString();

            if (data.DISP_JUDG_ENABLE == false)
            {
                for (int i = 0; i < this.CollectionLabelDisplacement.Count; i++)
                    this.CollectionLabelDisplacement[i].TextColor = Color.Gray;
            }
            else
            {
                for (int i = 0; i < this.CollectionLabelDisplacement.Count; i++)
                    this.CollectionLabelDisplacement[i].TextColor = Color.White;
            }
        }
        public void UpdateDisplayTime(DateTime time)
        {
            this.labelTime.Text = time.ToString("yyyy-MM-dd HH:mm:ss");
        }

        public void DisplayRefresh()
        {
            this.ParentForm.CurrentSystemStatus.CurrentForm = Define.E_FormStore.FormMainDisplay;
            this.ParentForm.CurrentSystemStatus.CurrentDisplayMode = Define.E_DisplayModeStore.MainDisplay;
            this.ParentForm.SetDisplayMode(Define.E_EquipmentMode.Normal);

            this.ChildModbus.Visible = false;

            this.InitializeProcessStatus();
            this.UpdateDisplayUser(this.ParentForm.CurrentSystemStatus.CurrentUser);
            this.UpdateDisplayRecipeData(this.ParentForm.CurrentRecipe);
        }
        #endregion

        #region Override Member
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            this.smartTimerLogin.Start();
        }
        #endregion

        #region Event Handler
        private void labelStop_Click(object sender, EventArgs e)
        {
            this.ParentForm.TransferData_Master(CommunicationCommand.Start, CommunicationID.MainBoardMaster);

            this.ParentForm.SetTrackingHistoryData(Define.E_TrackingOperation.EquipmentStart, "");
        }
        private void labelStart_Click(object sender, EventArgs e)
        {
            this.ParentForm.TransferData_Master(CommunicationCommand.Stop, CommunicationID.MainBoardMaster);

            this.ParentForm.SetTrackingHistoryData(Define.E_TrackingOperation.EquipmentStop, "");
        }

        private void buttonProductNo_Click(object sender, EventArgs e)
        {
            string before = "", after = "";

            this.Part11AutomaticLogoutReset();

            before = this.buttonRecipeNo.ButtonText;
            DialogFormNumKeyPad myKeypad = new DialogFormNumKeyPad("NUMBER", this.buttonRecipeNo.ButtonText, 4, 0, false);

            if (myKeypad.ShowDialog() == DialogResult.OK)
            {
                if (myKeypad.IntValue < 1 || myKeypad.IntValue > 1000)
                {
                    this.MessageBoxRange = "1 ~ 1000";
                    this.buttonRecipeNo.ButtonText = before;
                    this.smartTimerMessageShow.Start();
                    return;
                }

                this.buttonRecipeNo.ButtonText = "**";
                this.ParentForm.TransferRecipeParameter9043(myKeypad.IntValue, Define.E_BoardMode.Master);
                this.ParentForm.TransferRecipeParameter9043(myKeypad.IntValue, Define.E_BoardMode.Slave);
                after = myKeypad.StringValue;

                this.ParentForm.SetTrackingHistoryData(Define.E_TrackingParameter.RecipeNumber, "", before, after);
            }
        }
        private void buttonInspection_Click(object sender, EventArgs e)
        {
            this.Part11AutomaticLogoutReset();

            this.ParentForm.TransferData_Master(CommunicationCommand.CutInpupt, CommunicationID.MainBoardMaster);
            this.ParentForm.TransferData_Slave(CommunicationCommand.CutInpupt, CommunicationID.MainBoardMaster);

            this.InitializeData();
            //this.ChildControl.ClearAllData();
            this.ChildMainDisplay10.InitializeData();
        }
        private void buttonDischarge_Click(object sender, EventArgs e)
        {
            this.ParentForm.TransferData_Master(CommunicationCommand.Clear, CommunicationID.MainBoardMaster);
            this.ParentForm.TransferData_Slave(CommunicationCommand.Clear, CommunicationID.MainBoardMaster);
        }
        private void buttonUser_Click(object sender, EventArgs e)
        {
            this.Part11AutomaticLogoutReset();

            if (this.ParentForm.CurrentSystemStatus.CurrentUser.Group == Define.E_UserGroup.LogOut)
            {
                this.Login();
            }
            else
            {
                DialogFormYesNo msg = new DialogFormYesNo(this.ParentForm.SystemConfig.LANGUAGE, 12);
                if (msg.ShowDialog() == DialogResult.Yes)
                {
                    this.Logout();
                }
            }
            this.InitializeProcessStatus();
        }
        private void buttonMenu_Click(object sender, EventArgs e)
        {
            this.Part11AutomaticLogoutReset();

            if (this.ParentForm.CurrentSystemStatus.EquipmentStatus == Define.E_EquipmentStatus.Stop)
            {
                UserManager.UserManager_AutoLogoutTimeoutPause();

                this.ParentForm.ChildFormMenu.DisplayRefresh(this.ParentForm.CurrentSystemStatus);
                this.ParentForm.FormChange((int)Define.E_FormStore.FormMenu);
            }
        }
        private void buttonModbus_Click(object sender, EventArgs e)
        {
            this.Part11AutomaticLogoutReset();

            if (this.ChildModbus.Visible == true)
            {
                this.ChildModbus.Visible = false;
            }
            else
            {
                this.ChildModbus.DisplayRefresh();
                this.ChildModbus.Visible = true;
            }
        }
        private void buttonDisplay_Click(object sender, EventArgs e)
        {
            if (this.ChildMainDisplay10.Visible == false)
                this.ChildMainDisplay10.Visible = true;
            else
                this.ChildMainDisplay10.Visible = false;
        }
        private void buttonClear_Click(object sender, EventArgs e)
        {
            this.InitializeData();
            //this.ChildControl.ClearAllData();
            this.ChildMainDisplay10.InitializeData();
            this.ChildModbus.ClearData();
        }

        private void buttonExit_Click(object sender, EventArgs e)
        {
            this.ParentForm.CloseSmartUartLink();
            this.ParentForm.Dispose();
            this.ParentForm.Close();
        }

        private void smartTimerAlarm_Tick(object sender, EventArgs e)
        {
            this.labelAlarm.Left = this.labelAlarm.Left - 5;
            if (this.labelAlarm.Left < 0 - this.labelAlarm.Width - 20)
                this.labelAlarm.Left = this.smartGroupBox1.Width - 10;
        }
        private void smartTimerMessageShow_Tick(object sender, EventArgs e)
        {
            this.smartTimerMessageShow.Stop();

            DialogFormMessage msg = new DialogFormMessage(1, this.ParentForm.SystemConfig.LANGUAGE, this.MessageBoxRange);
            msg.ShowDialog();
        }
        private void smartTimerLogin_Tick(object sender, EventArgs e)
        {
            this.smartTimerLogin.Stop();

            //this.Login();
        }
        private void smartTimerProgressBar_Tick(object sender, EventArgs e)
        {
            if (this.CurrentProcessStatus == Define.E_ProcessStatus._6_VacuumStart)
            {
                if (this.progressBar1.Value < 30)
                    this.progressBar1.Value++;
            }
            else if (this.CurrentProcessStatus == Define.E_ProcessStatus._7_VacuumHold)
            {
                if (this.progressBar1.Value < 60)
                    this.progressBar1.Value++;
            }
            else if (this.CurrentProcessStatus == Define.E_ProcessStatus._8_Judgment)
            {
                if (this.progressBar1.Value == this.progressBar1.Maximum)
                    this.smartTimerProgressBar.Stop();
                else
                    this.progressBar1.Value++;
            }
        }
        private void timerServer_Tick(object sender, EventArgs e)
        {
            if (this.ParentForm.smartTCPMultiServer.IsStart == true)
            {
                if (this.ParentForm.smartTCPMultiServer.ClientInfoList == null)
                    this.UpdateEthernetStatusDisplay(false);
                else
                    this.UpdateEthernetStatusDisplay(true);
            }
        }

        private void buttonTest_Click(object sender, EventArgs e)
        {
            if (this.buttonTest.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
            {
                //this.InitializeData();
                this.ParentForm.TransferData_Master(CommunicationCommand.CutInpupt, CommunicationID.MainBoardMaster);
                this.smartTimerTest.Start();
                this.IsTestMode = true;
            }
            else
            {
                this.smartTimerTest.Stop();
                this.IsTestMode = false;
            }
        }
        private void smartTimerTest_Tick(object sender, EventArgs e)
        {
            //this.InitializeData();
            this.ParentForm.TransferData_Master(CommunicationCommand.CutInpupt, CommunicationID.MainBoardMaster);
        }
        #endregion

        private void smartButton4_Click(object sender, EventArgs e)
        {
            string value = "";

            this.smartTimerAlarm.Stop();

            value = "a1_Servo emergency stop     ";
            value += "a2_Pressure     ";
            value += "a3_M/S Board     ";
            value += "a5_Servo1     ";
            value += "a6_Servo Torque1     ";

            value = value.Trim();
            this.labelAlarm.Size = new Size(value.Length * 8, 20);
            this.labelAlarm.Text = value;

            if (this.labelAlarm.Width > 400)
            {
                if (this.labelAlarm.Text != "")
                    this.smartTimerAlarm.Start();
            }
            else
            {
                this.smartTimerAlarm.Stop();
                this.labelAlarm.Location = new Point(3, 26);
            }
        }
        private void smartButton5_Click(object sender, EventArgs e)
        {
            switch (this.testIndex)
            {
                case 0:
                    this.UpdateDisplayProcessStatus(Define.E_ProcessStatus._1_Ready);
                    break;
                case 1:
                    this.UpdateDisplayProcessStatus(Define.E_ProcessStatus._2_ProductEntry);
                    break;
                case 2:
                    this.UpdateDisplayProcessStatus(Define.E_ProcessStatus._3_MoveToLeak);
                    break;
                case 3:
                    this.UpdateDisplayProcessStatus(Define.E_ProcessStatus._4_MoveToCheck);
                    break;
                case 4:
                    this.UpdateDisplayProcessStatus(Define.E_ProcessStatus._5_ChamberMerge);
                    break;
                case 5:
                    this.UpdateDisplayProcessStatus(Define.E_ProcessStatus._6_VacuumStart);
                    break;
                case 6:
                    this.UpdateDisplayProcessStatus(Define.E_ProcessStatus._7_VacuumHold);
                    break;
                case 7:
                    this.UpdateDisplayProcessStatus(Define.E_ProcessStatus._8_Judgment);
                    break;
                case 8:
                    this.UpdateDisplayProcessStatus(Define.E_ProcessStatus._9_VacuumBreak);
                    break;
                case 9:
                    this.UpdateDisplayProcessStatus(Define.E_ProcessStatus._10_ChamberRelease);
                    break;
                case 10:
                    this.UpdateDisplayProcessStatus(Define.E_ProcessStatus._11_MoveToReady);
                    break;
                default:
                    break;
            }

            if (this.testIndex >= 10)
                this.testIndex = 0;
            else
                this.testIndex++;
        }

       
    }
}