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

namespace FPER
{
    public partial class frmDriveTest : Form
    {
        public frmDriveTest()
        {
            InitializeComponent();

            // cyim 2016.03.25 : ������ ȭ�鿡 ǥ�ø��ϴ� ���� ���� (�ֱ������� ����)
            timer_Protect.Enabled = true;
        }
        LogFileCreate LFC = new LogFileCreate();
        MDIParent mdi = null;
        delegate void deleFormInit();

        bool sBatteryTestCommandStart = false;
        int sBatteryTestAction = 0;
        int sBatteryTestSecond = 20;

        int iStatusCount = 0;

        //   bool sKeypadTestCommandStart = false;
        //   int sKeypadTestAction = 0;

        delegate void SetVoltageCallback(float cnt);

        private void btnWinClose_Click(object sender, EventArgs e)
        {
            try
            {
                //DoBatteryTest(false);
                mdi.winDriveTestForm = null;//k.s.d 20101023, Driver Test form Handle set null ( init bug fix )
                this.Close();
            }
            catch (Exception ex)
            {
                Util.UErrorMessage(ex, 0, 0);
            }
        }

        public void Form_Init()
        {
            try
            {

            }
            catch (Exception ex)
            {
                Util.UErrorMessage(ex, 0, 0);

                //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.Source), Application.ProductName);
            }
        }

        private void frmDriveTest_Load(object sender, EventArgs e)
        {
            // cyim 2013.8.1 : �������۸� ����
            SetStyle(ControlStyles.UserPaint, true);
            //this.UpdateStyles();
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            //this.UpdateStyles();
            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            this.UpdateStyles();

            try
            {
                this.mdi = (MDIParent)this.MdiParent;
                txtThisReceiverID.Text = string.Format("{0:00}", mdi.myReceiverID);

                //foreach (Control currentControl in tabPage3.Controls)
                //{
                //    if (currentControl is TextBox)
                //    {
                //        TextBox txt = (TextBox)currentControl;
                //        txt.Text = "";
                //    }
                //}

                foreach (Control currentControl in panel_Bottom.Controls)
                {
                    if (currentControl is TextBox)
                    {
                        TextBox txt = (TextBox)currentControl;
                        txt.Text = "";
                    }
                }
                txtTestSecond.Text = string.Format("{0}��", sBatteryTestSecond);

                //�����б� ���� ����
                this.mdi.ui.Voltage_Read(null);
            }
            catch (Exception ex)
            {
                Util.UErrorMessage(ex, 0, 0);
            }
        }

        private void frmDriveTest_Activated(object sender, EventArgs e)
        {
            try
            {
                this.mdi.SelectMenuIndex = 5;
                // cyim 2015.3.31 �������� �׽�Ʈ�� �������� �ʱ�ȭ
                // ���Ŀ� ���󿡼� ���� Ȥ�� �������� �̻��� �Ǹ� �׽�Ʈ�� �����Ų��
                // ��, �������� �׽�Ʈ ���� Ȱ��ȭ�Ǿ� �ִٴ� �����Ͽ����� ���۵ȴ�
                this.mdi.Form_Active_frmDriveTest = true; // cyim 2015.8.4 ���Ź��� ���� static Ŭ���� ����
            }
            catch (Exception ex)
            {
                Util.UErrorMessage(ex, 0, 0);
            }
        }

        private void frmDriveTest_Disposed(object sender, EventArgs e)
        {
            try
            {
                this.mdi.SelectMenuIndex = 0;
                // cyim 2015.3.31 �������� �׽�Ʈ�� �������� �ʱ�ȭ            
                this.mdi.Form_Active_frmDriveTest = false; // cyim 2015.8.4 ���Ź��� ���� static Ŭ���� ����

                // cyim 2016.03.21 �׽�Ʈ ���߿� �ٸ� �޴��� �����Ҷ� �׽�Ʈ ���Ḧ ���� ����
                DoBatteryTest(false);
            }
            catch (Exception ex)
            {
                Util.UErrorMessage(ex, 0, 0);
            }
        }

        //���� ǥ��
        public void Display_24Voltage(float vol)
        {
            try
            {
                if (this.txt24Voltage.InvokeRequired)
                {
                    Console.WriteLine("Display_24Voltage = {0}", vol);
                    SetVoltageCallback d = new SetVoltageCallback(Display_24Voltage);
                    this.txt24Voltage.Invoke(d, new object[] { vol });
                }
                else
                {
                    this.txt24Voltage.Text = String.Format("{0:0.00}V", vol);
                }
            }
            catch (Exception ex)
            {
                Util.UErrorMessage(ex, 0, 0);
            }
        }

        //���� ǥ��
        public void Display_5Voltage(float vol)
        {
            try
            {
                if (this.txt5Voltage.InvokeRequired)
                {
                    SetVoltageCallback d = new SetVoltageCallback(Display_5Voltage);
                    this.txt5Voltage.Invoke(d, new object[] { vol });
                }
                else
                {
                    this.txt5Voltage.Text = String.Format("{0:0.00}V", vol);
                }
            }
            catch (Exception ex)
            {
                Util.UErrorMessage(ex, 0, 0);
            }
        }

        //���� ǥ��
        public void Display_3Voltage(float vol)
        {
            try
            {
                if (this.txt3Voltage.InvokeRequired)
                {
                    SetVoltageCallback d = new SetVoltageCallback(Display_3Voltage);
                    this.txt3Voltage.Invoke(d, new object[] { vol });
                }
                else
                {
                    this.txt3Voltage.Text = String.Format("{0:0.00}V", vol);
                }
            }
            catch (Exception ex)
            {
                Util.UErrorMessage(ex, 0, 0);
            }
        }

        //���� ǥ��
        public void Display_BatteryVoltage(float vol)
        {
            try
            {
                if (this.txtBatteryVoltage.InvokeRequired)
                {
                    SetVoltageCallback d = new SetVoltageCallback(Display_BatteryVoltage);
                    this.txtBatteryVoltage.Invoke(d, new object[] { vol }); // cyim �� ��ü�� invoke ���� �ʵ��� �Ѵ�
                }
                else
                {
                    this.txtBatteryVoltage.Text = String.Format("{0:0.00}V", vol);
                }
            }
            catch (Exception ex)
            {
                Util.UErrorMessage(ex, 0, 0);
            }
        }

        // ���͸� �׽�Ʈ ��ư�� ��������..
        public void btnBatteryTest_Click(object sender, EventArgs e)
        {
            // ���� ���͸� �׽�Ʈ ��� �޽����� ����. (1�� �̻� ��ٷ��� �ϴϱ�..)
            //lblBatteryTestResult.Text = "BATTERY �׽�Ʈ ��� (�������� Ȯ��)";
            // cyim 2015.3.31 �������� �׽�Ʈ�� �������� �ʱ�ȭ
            if (mdi.AC_TestError == true && mdi.Battery_TestError == false) // cyim 2015.8.4 ���Ź��� ���� static Ŭ���� ����
                lblBatteryTestResult.Text = "BATTERY �׽�Ʈ ��� (�������� Ȯ��)";
            else if (mdi.Battery_TestError == true && mdi.AC_TestError == false) // cyim 2015.8.4 ���Ź��� ���� static Ŭ���� ����
                lblBatteryTestResult.Text = "BATTERY �׽�Ʈ ��� (�������� Ȯ��)";
            else
                lblBatteryTestResult.Text = "BATTERY �׽�Ʈ ��� (���� Ȯ��)";
            LFC.Log("Ÿ��: ���ű� ���� �α�, �޼���: BATTERY �׽�Ʈ");
            // ������� ���¸� �о������ �Ѵ�.
            mdi.ui.ReadIO15Input();

            // Ÿ�̸Ӹ� Ȱ��ȭ�Ѵ�. (1�� �Ŀ� Ÿ�̸� ��ƾ���� �����Ѵ�. ���� Ȯ���� ���� �ð��� Ȯ���Ѵ�.)
            iStatusCount = 0; // cyim 2015.3.31 ī���� �ʱ�ȭ
            StatusTimer.Enabled = true;
        }

        // ���͸� �׽�Ʈ ��ƾ. (Ű�е� ���͸� �׽�Ʈ �Է¿� ���� ó��)
        public void DoBatteryTest2(bool status)
        {
            //lblBatteryTestResult.Text = "BATTERY �׽�Ʈ ��� (�������� Ȯ��)";

            if (status == false)
            {
                DoBatteryTest(false);   // ���͸� �׽�Ʈ ����
            }

            //mdi.ui.ReadIO15Input();

            //// ���� Ȯ�ο����� ������Ų��.
            //StatusTimer.Enabled = true;

            //if (status == false)  // ����
            //{
            //    sBatteryTestAction = 0; // �����ϱ� ���ؼ�.. ���͸� �׽�Ʈ ���¸� ����� �����Ѵ�.
            //}

            // cyim 2015.3.31 �������� �׽�Ʈ ��ƾ ����
            btnBatteryTest_Click(null, null);
        }

        // ���͸� �׽�Ʈ ��ƾ.
        public void DoBatteryTest(bool status)
        {
            try
            {
                if (status == true)
                {
                    if ((mdi.ui.bPowerStatus == true) && (mdi.ui.bEmergencyPowerStatus == true))  // ���� ���� ���°� �ƴ϶��
                    {
                        sBatteryTestAction = 1;//���۸���

                        sBatteryTestCommandStart = true;

                        btnBatteryTest.Text = " ��������";
                        sBatteryTestCommandStart = true;
                        timer1.Interval = 1000;
                        timer1.Enabled = true;
                        timer1.Start();

                        lblBatteryTestResult.Text = "BATTERY �׽�Ʈ ����";
                        lblBatteryTestResult.ForeColor = System.Drawing.Color.Blue;
                        lblBatteryTestResult.Show();
                        lblBatteryTestMessage.Show();
                        lblBatteryTestMessage2.Show();
                    }
                }
                else
                {
                    sBatteryTestAction = 0; //�������

                    sBatteryTestCommandStart = false;
                    //sBatteryTestAction = 0;//���۸���
                    btnBatteryTest.Text = " �������";

                    sBatteryTestSecond = 20;
                    txtTestSecond.Text = string.Format("{0}��", sBatteryTestSecond);
                    timer1.Enabled = false;

                    lblBatteryTestResult.Text = "BATTERY �׽�Ʈ �Ϸ�";
                    lblBatteryTestResult.ForeColor = System.Drawing.Color.Blue;
                    lblBatteryTestResult.Show();
                    lblBatteryTestMessage.Hide();
                    lblBatteryTestMessage2.Hide();
                }

                //�Ϸ��̺�Ʈ
                dCommandResponse d = new dCommandResponse(BatteryTestComplete);

                //���ɻ��� �� ����
                CmdInfo cmd = new CmdInfo(prt_cmd_define.read_command_status, mdi.myReceiverID, 0, 0, 0, d);
                cmd.CommandType = "TB";
                cmd.ApplyRange = "A";   //���ܷ���(ȸ��Ÿ�����ܿ�) A-All,C-Comm,B-Board,L-Loop,R-�߰��,D-ȸ��,I-�Է�ȸ��,O-���ȸ��
                cmd.CommandData = null;
                cmd.Status = sBatteryTestAction; //1-����,0-����
                mdi.ui.runCommand(cmd);
            }
            catch (Exception ex)
            {
                Util.UErrorMessage(ex, 0, 0);

                btnBatteryTest.Enabled = true;
                this.Cursor = Cursors.Default;
            }
        }

        //ȭ�� ���콺 Ŀ�� �� ��ư �ٽ� Ŭ�� ���ϵ��� ���� �� ����
        private void button_end(Button btn, Boolean val)
        {
            if (val)
            {
                btn.Enabled = true;
                this.Cursor = Cursors.Default;
            }
            else
            {
                btn.Enabled = false;
                this.Cursor = Cursors.WaitCursor;
            }
        }

        //*********************************************************************//
        //        ���͸� �׽�Ʈ �Ϸ� ���䵥���� �̺�Ʈ                          //
        //*********************************************************************//
        public void BatteryTestComplete(CmdInfo cmd)
        {
            try
            {
                //button_end(btnBatteryTest, true);
                btnBatteryTest.Enabled = true;
                this.Cursor = Cursors.Default;

                //��������ó��
                if (!Util.ComInfoErrProcess(cmd, mdi.ui.Connected, "RCVData_ReadCommandStatus")) // cyim 2015.7.23 NACK ó�� �κ� ���� 
                {
                    //������ �߻��Ͽ����Ƿ� ����
                    sBatteryTestCommandStart = false;

                    timer1.Stop();
                    timer1.Enabled = false;

                    // cyim 2015.3.31 �������� �׽�Ʈ�� �������� �ʱ�ȭ
                    DoBatteryTest(false);
                    return;
                }

                sBatteryTestCommandStart = true;

                if (sBatteryTestAction == 1)
                {
                    btnBatteryTest.Text = " ��������";
                    sBatteryTestCommandStart = true;
                    timer1.Interval = 1000;
                    timer1.Enabled = true;
                    timer1.Start();
                    lblBatteryTestMessage.Show();	//k.s.d 20101023, Test End Message show, hide
                    lblBatteryTestMessage2.Show();
                }
                else
                {
                    sBatteryTestCommandStart = false;
                    sBatteryTestAction = 0;//���۸���
                    btnBatteryTest.Text = " �������";
                    sBatteryTestSecond = 20;
                    txtTestSecond.Text = string.Format("{0}��", sBatteryTestSecond);
                    timer1.Enabled = false;
                    lblBatteryTestMessage.Hide();	//k.s.d 20101023, Test End Message show, hide
                    lblBatteryTestMessage2.Hide();
                }

                this.mdi.ui.Voltage_Read(null);

                //RCVData_ReadCommandStatus resData2 = (RCVData_ReadCommandStatus)cmd.ResponseData;
                ////lblBatteryTestResult.Text = string.Format("���͸� �׽�Ʈ {0}������ �Ϸ�Ǿ����ϴ�.", sBatteryTestCommandStart ? "����" : "����");
                //string msg = string.Format("���͸� �׽�Ʈ {0}������ �Ϸ�Ǿ����ϴ�.", sBatteryTestCommandStart ? "����" : "����");
                //MessageBox.Show(msg, Application.ProductName);
                //button_end(btnBatteryTest,true);
            }
            catch (Exception ex)
            {
                Util.UErrorMessage(ex, 0, 0);
            }
        }

        // cyim 2016.03.21 : ������ ȭ�鿡 ǥ�ø��ϴ� ���� ����
        private int timer_Protect_Tick_Cnt = 0;
        private void timer_Protect_Tick(object sender, EventArgs e)
        {
            try
            {
                // cyim 2017.05.08 : ����ó�� �ڵ� �߰�
                if (this.mdi == null
                    || this.mdi.ui == null
                    || this.txt24Voltage == null
                    || this.timer1 == null
                    || this.StatusTimer == null)
                    return;

                // cyim 2016.03.25 : ������ ȭ�鿡 ǥ�ø��ϴ� ���� ���� (�ֱ��� ����)
                //�ٸ� Ÿ�̸Ӱ� �������̸� ������
                if (this.timer1.Enabled == true || this.StatusTimer.Enabled == true)
                    return;

                timer_Protect_Tick_Cnt++;
                if (timer_Protect_Tick_Cnt == 1)
                {
                    this.mdi.ui.Voltage_Read(null);
                    this.txt24Voltage.Text = mdi.Power_Main_vol24;
                    timer_Protect_Tick_Cnt = 0;
                }
            }
            catch (Exception ex)
            {
                Util.UErrorMessage(ex, 0, 0);
            }
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            try
            {
                //timer1.Stop();
                //timer1.Enabled = false;

                // cyim 2016.03.21 : ������ ȭ�鿡 ǥ�ø��ϴ� ���� ���� : ���󿡰� �׽�Ʈ ���� �� ������ ��û�� ���ÿ� ���� �ʴ´�
                if (sBatteryTestSecond > 1 && sBatteryTestSecond < 20)
                    this.mdi.ui.Voltage_Read(null);

                if (sBatteryTestCommandStart)
                {
                    sBatteryTestSecond--;

                    txtTestSecond.Text = string.Format("{0}��", sBatteryTestSecond);

                    if (sBatteryTestSecond < 1)
                    {
                        sBatteryTestSecond = 0;
                        sBatteryTestCommandStart = false;

                        lblBatteryTestResult.Text = "BATTERY �׽�Ʈ �Ϸ�";
                        lblBatteryTestResult.ForeColor = System.Drawing.Color.Blue;
                        lblBatteryTestResult.Show();	//k.s.d 20101023, Test End Message show, hide
                        btnBatteryTest_Click(btnBatteryTest, System.EventArgs.Empty);
                    }
                }

                // cyim 2015.3.31 �������� �׽�Ʈ�� �������� �ʱ�ȭ
                if ((mdi.ui.bPowerStatus == false) || (mdi.ui.bEmergencyPowerStatus == false))
                {
                    DoBatteryTest(false);
                }
            }
            catch (Exception ex)
            {
                Util.UErrorMessage(ex, 0, 0);
            }
        }

        private void frmDriverTestClose(object sender, FormClosedEventArgs e)
        {	//k.s.d 20101023, test end when form close.
            try
            {
                DoBatteryTest(false);
                mdi.winDriveTestForm = null;
            }
            catch (Exception ex)
            {
                Util.UErrorMessage(ex, 0, 0);
            }
        }

        // IO15�� �������� ���¸� Ȯ���ϱ� ���ؼ�.. Ÿ�̸Ӹ� �������.
        // �������� ������ �ʰ� �ö���� ������.. ������ �� �Ŀ� (bReceivePowerStatus == true)
        // ���͸� �׽�Ʈ ó���� ������.
        private void StatusTimer_Tick(object sender, EventArgs e)
        {
            iStatusCount++;
            if (iStatusCount > 20)
            {
                StatusTimer.Enabled = false;
                iStatusCount = 0; // cyim 2015.3.31 ī���� �ʱ�ȭ              
            }

            // cyim 2016.03.21 ���͸� �׽�Ʈ ��ư�� �������� �ʰ� ���������� ���� ��찡 �߻��Ѵ�. Ÿ�̸Ӹ� ���� �ʰ� ��������
            if (iStatusCount == 1) return;

            // cyim 2015.3.31 �������� �׽�Ʈ�� �������� �ʱ�ȭ
            if (mdi.AC_TestError == true && mdi.Battery_TestError == false) // cyim 2015.8.4 ���Ź��� ���� static Ŭ���� ����
                lblBatteryTestResult.Text = "BATTERY �׽�Ʈ ��� (�������� Ȯ��)";
            else if (mdi.Battery_TestError == true && mdi.AC_TestError == false) // cyim 2015.8.4 ���Ź��� ���� static Ŭ���� ����
                lblBatteryTestResult.Text = "BATTERY �׽�Ʈ ��� (�������� Ȯ��)";
            else
                lblBatteryTestResult.Text = "BATTERY �׽�Ʈ ��� (���� Ȯ��)";

            if (mdi.ui.bReceivePowerStatus == true)
            {
                // �������� ���� Ȯ�ο� Ÿ�̸Ӹ� ����.
                StatusTimer.Enabled = false;
                iStatusCount = 0; // cyim 2015.3.31 ī���� �ʱ�ȭ

                // ���͸� �׽�Ʈ ���̸�..
                if (sBatteryTestAction == 1)
                {
                    //sBatteryTestAction = 0; //�������
                    DoBatteryTest(false);

                    //this.mdi.ui.Voltage_Read(null);
                    Console.WriteLine("DoBatteryTest(false);");
                }
                else
                {
                    DoBatteryTest(true);
                    Console.WriteLine("DoBatteryTest(true);");
                }
            }
            else
            {
                // cyim 2015.7.23 MTB ���尡 ���� ��� ���������׽�Ʈ ȭ�鿡�� �׽�Ʈ ��ư ������ ���� �߻�
                if (mdi.AC_TestError == true && mdi.Battery_TestError == true) // cyim 2015.8.4 ���Ź��� ���� static Ŭ���� ����
                {
                    lblBatteryTestResult.Text = "��� ���� ���� ";
                    lblBatteryTestResult.ForeColor = System.Drawing.Color.Blue;
                    lblBatteryTestResult.Show();

                    // ��� ����
                    StatusTimer.Enabled = false;
                    iStatusCount = 0;
                }
            }
        }

        //private void btnKeypadIn_1_Click(object sender, EventArgs e)
        //{
        //    txtKeypadIn_Result_1.Text = "Pass";
        //}

        //private void btnKeypadIn_2_Click(object sender, EventArgs e)
        //{
        //    txtKeypadIn_Result_2.Text = "Pass";
        //}

        //private void btnKeypadIn_3_Click(object sender, EventArgs e)
        //{
        //    txtKeypadIn_Result_3.Text = "Pass";
        //}

        //private void btnKeypadIn_4_Click(object sender, EventArgs e)
        //{
        //    txtKeypadIn_Result_4.Text = "Pass";
        //}

        //private void btnKeypadIn_5_Click(object sender, EventArgs e)
        //{
        //    txtKeypadIn_Result_5.Text = "Pass";
        //}

        //private void btnKeypadIn_6_Click(object sender, EventArgs e)
        //{
        //    txtKeypadIn_Result_6.Text = "Pass";
        //}

        //private void btnKeypadIn_7_Click(object sender, EventArgs e)
        //{
        //    txtKeypadIn_Result_7.Text = "Pass";
        //}

        //private void btnKeyPadTest_Click(object sender, EventArgs e)
        //{
        //    try
        //    {
        //        string msg = string.Format("Ű�е� �׽�Ʈ {0}������ �����ðڽ��ϱ�?", sKeypadTestAction == 1 ? "����" : "����");

        //        if (MessageBox.Show(msg, Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes)
        //        {

        //            if (sKeypadTestAction == 1)
        //            {
        //                sKeypadTestAction = 0; //�������
        //            }
        //            else
        //            {
        //                sKeypadTestAction = 1;//���۸���
        //            }

        //            //��ư ��Ȱ�� ����
        //            button_end(btnKeyPadTest, false);

        //            //�Ϸ��̺�Ʈ
        //            dCommandResponse d = new dCommandResponse(KeypadTestComplete);

        //            //���ɻ��� �� ����
        //            CmdInfo cmd = new CmdInfo(prt_cmd_define.read_command_status, mdi.myReceiverID, 0, 0, 0, d);
        //            cmd.CommandType = "TK";
        //            cmd.ApplyRange = "A";   //���ܷ���(ȸ��Ÿ�����ܿ�) A-All,C-Comm,B-Board,L-Loop,R-�߰��,D-ȸ��,I-�Է�ȸ��,O-���ȸ��
        //            cmd.CommandData = null;
        //            cmd.Status = sKeypadTestAction; //1-����,0-����
        //            mdi.ui.runCommand(cmd);

        //        }

        //    }
        //    catch (Exception ex)
        //    {
        //        MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
        //    }
        //}


        ////*********************************************************************//
        ////        Ű�е� �׽�Ʈ �Ϸ� ���䵥���� �̺�Ʈ                          //
        ////*********************************************************************//
        //public void KeypadTestComplete(CmdInfo cmd)
        //{

        //    button_end(btnKeyPadTest, true);

        //    //��������ó��
        //    if (!Util.ComInfoErrProcess(cmd, mdi.ui.Connected))
        //    {
        //        //������ �߻��Ͽ����Ƿ� ����
        //        sKeypadTestCommandStart = false;
        //        return;
        //    }

        //    sKeypadTestCommandStart = true;

        //    if (sKeypadTestAction == 1)
        //    {
        //        KeypadTestButtonEnabled(true);
        //        btnKeyPadTest.Text = "��������";
        //        sKeypadTestCommandStart = true;
        //    }
        //    else
        //    {
        //        KeypadTestButtonEnabled(false);
        //        sKeypadTestCommandStart = false;
        //        sKeypadTestAction = 0;              //���۸���
        //        btnKeyPadTest.Text = "�������";
        //    }


        //    //RCVData_ReadCommandStatus resData2 = (RCVData_ReadCommandStatus)cmd.ResponseData;
        //    ////lblBatteryTestResult.Text = string.Format("���͸� �׽�Ʈ {0}������ �Ϸ�Ǿ����ϴ�.", sBatteryTestCommandStart ? "����" : "����");
        //    //string msg = string.Format("���͸� �׽�Ʈ {0}������ �Ϸ�Ǿ����ϴ�.", sBatteryTestCommandStart ? "����" : "����");
        //    //MessageBox.Show(msg, Application.ProductName);
        //    //button_end(btnBatteryTest,true);

        //}

        //private void KeypadTestButtonEnabled(bool action)
        //{
        //    btnKeypadIn_1.Enabled = action;
        //    btnKeypadIn_2.Enabled = action;
        //    btnKeypadIn_3.Enabled = action;
        //    btnKeypadIn_4.Enabled = action;
        //    btnKeypadIn_5.Enabled = action;
        //    btnKeypadIn_6.Enabled = action;
        //    btnKeypadIn_7.Enabled = action;

        //    btnKeypadOut_1.Enabled = action;
        //    btnKeypadOut_2.Enabled = action;
        //    btnKeypadOut_3.Enabled = action;
        //    btnKeypadOut_4.Enabled = action;
        //    btnKeypadOut_5.Enabled = action;
        //    btnKeypadOut_6.Enabled = action;
        //    btnKeypadOut_7.Enabled = action;
        //    btnKeypadOut_8.Enabled = action;
        //    btnKeypadOut_9.Enabled = action;
        //    btnKeypadOut_10.Enabled = action;
        //    btnKeypadOut_11.Enabled = action;
        //    btnKeypadOut_12.Enabled = action;
        //    btnKeypadOut_13.Enabled = action;
        //    btnKeypadOut_14.Enabled = action;
        //    btnKeypadOut_15.Enabled = action;
        //    btnKeypadOut_16.Enabled = action;
        //    btnKeypadOut_17.Enabled = action;

        //}

        //private void btnKeypadOut_1_Click(object sender, EventArgs e)
        //{
        //    try
        //    {
        //        if (sKeypadTestAction != 1)
        //        {
        //            MessageBox.Show("Ű�е� �׽�Ʈ�� ���۵��� �ʾҽ��ϴ�.", Application.ProductName);
        //            return;
        //        }

        //        if (MessageBox.Show("Ű�е� ȭ�� �׽�Ʈ ��¸����� �����ðڽ��ϱ�?"
        //            , Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes)
        //        {


        //            //��ư ��Ȱ�� ����
        //            button_end(btnKeypadOut_1, false);

        //            ////�Ϸ��̺�Ʈ
        //            //dCommandResponse d = new dCommandResponse(KeypadOutButtonComplete);

        //            ////���ɻ��� �� ����
        //            //CmdInfo cmd = new CmdInfo(prt_cmd_define.read_command_status, mdi.myReceiverID, 0, 0, 0, d);
        //            //cmd.CommandType = "TK";
        //            //cmd.ApplyRange = "A";   //���ܷ���(ȸ��Ÿ�����ܿ�) A-All,C-Comm,B-Board,L-Loop,R-�߰��,D-ȸ��,I-�Է�ȸ��,O-���ȸ��
        //            //cmd.CommandData = null;
        //            //cmd.Status = sKeypadTestAction; //1-����,0-����
        //            //mdi.ui.runCommand(cmd);

        //        }

        //    }
        //    catch (Exception ex)
        //    {
        //        MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
        //    }
        //}

        //public void KeypadOutButtonComplete(CmdInfo cmd)
        //{

        //    button_end(btnKeypadOut_1, true);

        //    //��������ó��
        //    if (!Util.ComInfoErrProcess(cmd, mdi.ui.Connected))
        //    {
        //        //������ �߻��Ͽ����Ƿ� ����
        //        sKeypadTestCommandStart = false;
        //        return;
        //    }

        //    sKeypadTestCommandStart = true;

        //    if (sKeypadTestAction == 1)
        //    {
        //        KeypadTestButtonEnabled(true);
        //        btnKeyPadTest.Text = "��������";
        //        sKeypadTestCommandStart = true;
        //    }
        //    else
        //    {
        //        KeypadTestButtonEnabled(false);
        //        sKeypadTestCommandStart = false;
        //        sKeypadTestAction = 0;              //���۸���
        //        btnKeyPadTest.Text = "�������";
        //    }

        //    //RCVData_ReadCommandStatus resData2 = (RCVData_ReadCommandStatus)cmd.ResponseData;
        //    ////lblBatteryTestResult.Text = string.Format("���͸� �׽�Ʈ {0}������ �Ϸ�Ǿ����ϴ�.", sBatteryTestCommandStart ? "����" : "����");
        //    //string msg = string.Format("���͸� �׽�Ʈ {0}������ �Ϸ�Ǿ����ϴ�.", sBatteryTestCommandStart ? "����" : "����");
        //    //MessageBox.Show(msg, Application.ProductName);
        //    //button_end(btnBatteryTest,true);

        //}
    }
}