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

using SmartX;
using INT69DC_7C.Controls;
using INT69DC_7C.DialogForms;
using INT69DC_ImageDll;

namespace INT69DC_7C.Forms
{
    public partial class FormEquipmentTest : Form
    {
        #region Field
        private FormMain m_ParentForm;
        private ControlEquipmentTest m_ChildControl1;
        
        private Collection<SmartLabel> CollectionLabelWeightValue;
        private Collection<SmartLabel> CollectionLabelADC;
        private Collection<Label> CollectionLabelZero;
        private Collection<Label> CollectionLabelSensor;
        private Collection<SmartButton> CollectionButtonForward;
        private Collection<SmartButton> CollectionButtonReverse;
        private Collection<SmartButton> CollectionButtonConveyor;
        #endregion

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

            this.ParentForm = parent;
        }
        #endregion

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

        #region Method
        private void InitializeDesign()
        {
            ImageDll images = new ImageDll();

            if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Korean)
            {

            }
            else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.English)
            {
                this.labelTitle.Text = "Equipment Test";

                this.buttonAllContinue.Font = new Font("새굴림", 9, FontStyle.Bold);
                this.buttonAllContinue.Text = "Consecutively";

                this.buttonForwardDirectionAll.Text = "Forward";
                this.buttonForwardDirection1.Text = "Forward";
                this.buttonForwardDirection2.Text = "Forward";
                this.buttonForwardDirection3.Text = "Forward";
                this.buttonForwardDirection4.Text = "Forward";
                this.buttonForwardDirection5.Text = "Forward";
                this.buttonForwardDirection6.Text = "Forward";
                this.buttonForwardDirection7.Text = "Forward";
                this.buttonForwardDirection8.Text = "Forward";
                this.buttonForwardDirection9.Text = "Forward";
                this.buttonForwardDirection10.Text = "Forward";
                this.buttonForwardDirection11.Text = "Forward";
                this.buttonForwardDirection12.Text = "Forward";

                this.buttonReverseDirectionAll.Text = "Reverse";
                this.buttonReverseDirection1.Text = "Reverse";
                this.buttonReverseDirection2.Text = "Reverse";
                this.buttonReverseDirection3.Text = "Reverse";
                this.buttonReverseDirection4.Text = "Reverse";
                this.buttonReverseDirection5.Text = "Reverse";
                this.buttonReverseDirection6.Text = "Reverse";
                this.buttonReverseDirection7.Text = "Reverse";
                this.buttonReverseDirection8.Text = "Reverse";
                this.buttonReverseDirection9.Text = "Reverse";
                this.buttonReverseDirection10.Text = "Reverse";
                this.buttonReverseDirection11.Text = "Reverse";
                this.buttonReverseDirection12.Text = "Reverse";

                this.buttonBack.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engBackDisable));
                this.buttonBack.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engBackDown));
                this.buttonBack.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engBackUp));
                this.buttonDisplay.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engScreenDisable));
                this.buttonDisplay.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engScreenDown));
                this.buttonDisplay.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engScreenUp));
            }
            else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Chinese)
            {
                this.labelTitle.Text = "设备测试";

                this.smartGroupBox1.Text = "重量";
                this.groupBoxStick.Text = "球杆";

                this.labelStaticWeight.Text = "重量";
                this.labelStaticImpeller.Text = "叶轮";

                this.buttonLogAdcOpen.Text = this.buttonLogOpen.Text = this.buttonCOM1LogOpen.Text = this.buttonCOM3LogOpen.Text = "开";
                this.buttonLogAdcClose.Text = this.buttonLogClose.Text = this.buttonCOM1LogClose.Text = this.buttonCOM3LogClose.Text = "关闭";

                this.buttonAllContinue.Font = new Font("새굴림", 9, FontStyle.Bold);
                this.buttonAllContinue.Text = "连续旋转";

                this.buttonForwardDirectionAll.Text = "正向";
                this.buttonForwardDirection1.Text = "正向";
                this.buttonForwardDirection2.Text = "正向";
                this.buttonForwardDirection3.Text = "正向";
                this.buttonForwardDirection4.Text = "正向";
                this.buttonForwardDirection5.Text = "正向";
                this.buttonForwardDirection6.Text = "正向";
                this.buttonForwardDirection7.Text = "正向";
                this.buttonForwardDirection8.Text = "正向";
                this.buttonForwardDirection9.Text = "正向";
                this.buttonForwardDirection10.Text = "正向";
                this.buttonForwardDirection11.Text = "正向";
                this.buttonForwardDirection12.Text = "正向";

                this.buttonReverseDirectionAll.Text = "反向";
                this.buttonReverseDirection1.Text = "反向";
                this.buttonReverseDirection2.Text = "反向";
                this.buttonReverseDirection3.Text = "反向";
                this.buttonReverseDirection4.Text = "反向";
                this.buttonReverseDirection5.Text = "反向";
                this.buttonReverseDirection6.Text = "反向";
                this.buttonReverseDirection7.Text = "反向";
                this.buttonReverseDirection8.Text = "反向";
                this.buttonReverseDirection9.Text = "反向";
                this.buttonReverseDirection10.Text = "反向";
                this.buttonReverseDirection11.Text = "反向";
                this.buttonReverseDirection12.Text = "反向";

                this.buttonBack.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnBackDisable));
                this.buttonBack.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnBackDown));
                this.buttonBack.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnBackUp));
                this.buttonDisplay.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnScreenDisable));
                this.buttonDisplay.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnScreenDown));
                this.buttonDisplay.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnScreenUp));
            }
            else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Czech)
            {
                this.labelTitle.Text = "Test zařízení";

                this.buttonForwardDirectionAll.Text = "Vpřed";
                this.buttonForwardDirection1.Text = "Vpřed";
                this.buttonForwardDirection2.Text = "Vpřed";
                this.buttonForwardDirection3.Text = "Vpřed";
                this.buttonForwardDirection4.Text = "Vpřed";
                this.buttonForwardDirection5.Text = "Vpřed";
                this.buttonForwardDirection6.Text = "Vpřed";
                this.buttonForwardDirection7.Text = "Vpřed";
                this.buttonForwardDirection8.Text = "Vpřed";
                this.buttonForwardDirection9.Text = "Vpřed";
                this.buttonForwardDirection10.Text = "Vpřed";
                this.buttonForwardDirection11.Text = "Vpřed";
                this.buttonForwardDirection12.Text = "Vpřed";

                this.buttonReverseDirectionAll.Text = "Vzad";
                this.buttonReverseDirection1.Text = "Vzad";
                this.buttonReverseDirection2.Text = "Vzad";
                this.buttonReverseDirection3.Text = "Vzad";
                this.buttonReverseDirection4.Text = "Vzad";
                this.buttonReverseDirection5.Text = "Vzad";
                this.buttonReverseDirection6.Text = "Vzad";
                this.buttonReverseDirection7.Text = "Vzad";
                this.buttonReverseDirection8.Text = "Vzad";
                this.buttonReverseDirection9.Text = "Vzad";
                this.buttonReverseDirection10.Text = "Vzad";
                this.buttonReverseDirection11.Text = "Vzad";
                this.buttonReverseDirection12.Text = "Vzad";

                this.buttonAllContinue.Text = "Nepřetržitě";
                this.smartGroupBox1.Text = this.labelStaticWeight.Text = "Hmotnost";
                this.groupBoxStick.Text = "Hůl";
                this.labelStaticImpeller.Text = "Poháněč";
                this.labelStaticCutInput.Text = "Vstupní signál stříhání";
                this.buttonCut.Text = "Snížit";

                this.labelStaticFeedingCV.Text = "PodáváníCV";
                this.labelStaticRejectCVCW.Text = "VyřazeníCV CW";
                this.labelStaticRejectCVCCW.Text = "VyřazeníCW CCW";
                this.labelStaticCommLog.Text = "Záznam komunikace";
                this.labelStaticCOM3CommLog.Text = "COM3 Záznam komunikace";

                this.buttonLogAdcOpen.Text = this.buttonLogOpen.Text = this.buttonCOM3LogOpen.Text = "Otevřeno";
                this.buttonLogAdcClose.Text = this.buttonLogClose.Text = this.buttonCOM3LogClose.Text = "Zavřít";                

                this.buttonFeedingConveyor.DownImage = this.buttonRejectConveyorCW.DownImage = this.buttonRejectConveyorCCW.DownImage
                    = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeEnable));
                this.buttonFeedingConveyor.UpImage = this.buttonRejectConveyorCW.UpImage = this.buttonRejectConveyorCCW.UpImage
                    = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeDisable));

                this.buttonBack.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeBackDisable));
                this.buttonBack.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeBackDown));
                this.buttonBack.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeBackUp));
                this.buttonDisplay.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeScreenDisable));
                this.buttonDisplay.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeScreenDown));
                this.buttonDisplay.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeScreenUp));
            }
            else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.German)
            {
                this.labelTitle.Text = "Vorrichtungstest";

                this.buttonForwardDirectionAll.Text = "Vorwärts";
                this.buttonForwardDirection1.Text = "Vorwärts";
                this.buttonForwardDirection2.Text = "Vorwärts";
                this.buttonForwardDirection3.Text = "Vorwärts";
                this.buttonForwardDirection4.Text = "Vorwärts";
                this.buttonForwardDirection5.Text = "Vorwärts";
                this.buttonForwardDirection6.Text = "Vorwärts";
                this.buttonForwardDirection7.Text = "Vorwärts";
                this.buttonForwardDirection8.Text = "Vorwärts";
                this.buttonForwardDirection9.Text = "Vorwärts";
                this.buttonForwardDirection10.Text = "Vorwärts";
                this.buttonForwardDirection11.Text = "Vorwärts";
                this.buttonForwardDirection12.Text = "Vorwärts";

                this.buttonReverseDirectionAll.Text = "Rückwärts";
                this.buttonReverseDirection1.Text = "Rückwärts";
                this.buttonReverseDirection2.Text = "Rückwärts";
                this.buttonReverseDirection3.Text = "Rückwärts";
                this.buttonReverseDirection4.Text = "Rückwärts";
                this.buttonReverseDirection5.Text = "Rückwärts";
                this.buttonReverseDirection6.Text = "Rückwärts";
                this.buttonReverseDirection7.Text = "Rückwärts";
                this.buttonReverseDirection8.Text = "Rückwärts";
                this.buttonReverseDirection9.Text = "Rückwärts";
                this.buttonReverseDirection10.Text = "Rückwärts";
                this.buttonReverseDirection11.Text = "Rückwärts";
                this.buttonReverseDirection12.Text = "Rückwärts";

                this.buttonAllContinue.Text = "Dauerhafter";
                this.smartGroupBox1.Text = this.labelStaticWeight.Text = "Gewicht";
                this.groupBoxStick.Text = "Beutel";
                this.labelStaticImpeller.Text = "Laufrad";
                this.labelStaticCutInput.Text = "Schnitt - Eingang";
                this.buttonCut.Text = "Schnitt";

                this.labelStaticFeedingCV.Text = "Zuführförderer";
                this.labelStaticRejectCVCW.Text = "Aussortierförderer CW";
                this.labelStaticRejectCVCCW.Text = "Aussortierförderer CCW";
                this.labelStaticCommLog.Text = "Kommunikationsprotokoll";
                this.labelStaticLog.Text = "Protokoll(ADC)";
                this.labelStaticCOM3CommLog.Text = "COM3 Protokoll";
                this.labelStaticCOM1CommLog.Text = "COM1 Protokoll";
                this.checkBoxCutMainDisplayView.Text = "Anzeige der [CUT]";

                this.buttonLogAdcOpen.Text = this.buttonLogOpen.Text = this.buttonCOM3LogOpen.Text = "Öffnen";
                this.buttonLogAdcClose.Text = this.buttonLogClose.Text = this.buttonCOM3LogClose.Text = "Schließen";

                this.buttonFeedingConveyor.DownImage = this.buttonRejectConveyorCW.DownImage = this.buttonRejectConveyorCCW.DownImage
                    = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerEnable));
                this.buttonFeedingConveyor.UpImage = this.buttonRejectConveyorCW.UpImage = this.buttonRejectConveyorCCW.UpImage
                    = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerDisable));

                this.buttonBack.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerBackDisable));
                this.buttonBack.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerBackDown));
                this.buttonBack.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerBackUp));
                this.buttonDisplay.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerScreenDisable));
                this.buttonDisplay.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerScreenDown));
                this.buttonDisplay.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerScreenUp));
            }
            else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Japanese)
            {
                this.labelTitle.Text = "装置テスト";

                this.buttonAllContinue.Font = new Font("새굴림", 9, FontStyle.Bold);
                this.buttonAllContinue.Text = "連続";

                this.buttonForwardDirectionAll.Text = "正転";
                this.buttonForwardDirection1.Text = "正転";
                this.buttonForwardDirection2.Text = "正転";
                this.buttonForwardDirection3.Text = "正転";
                this.buttonForwardDirection4.Text = "正転";
                this.buttonForwardDirection5.Text = "正転";
                this.buttonForwardDirection6.Text = "正転";
                this.buttonForwardDirection7.Text = "正転";
                this.buttonForwardDirection8.Text = "正転";
                this.buttonForwardDirection9.Text = "正転";
                this.buttonForwardDirection10.Text = "正転";
                this.buttonForwardDirection11.Text = "正転";
                this.buttonForwardDirection12.Text = "正転";

                this.buttonReverseDirectionAll.Text = "逆回転";
                this.buttonReverseDirection1.Text = "逆回転";
                this.buttonReverseDirection2.Text = "逆回転";
                this.buttonReverseDirection3.Text = "逆回転";
                this.buttonReverseDirection4.Text = "逆回転";
                this.buttonReverseDirection5.Text = "逆回転";
                this.buttonReverseDirection6.Text = "逆回転";
                this.buttonReverseDirection7.Text = "逆回転";
                this.buttonReverseDirection8.Text = "逆回転";
                this.buttonReverseDirection9.Text = "逆回転";
                this.buttonReverseDirection10.Text = "逆回転";
                this.buttonReverseDirection11.Text = "逆回転";
                this.buttonReverseDirection12.Text = "逆回転";

                this.labelStaticCutInput.Text = "[カット] 入力";
                this.buttonCut.Text = "カット";
                this.checkBoxCutMainDisplayView.Text = "[CUT]メイン画面に表示";
                this.checkBoxSamplingMainDisplayView.Text = "[Sampling]メイン画面に表示";

                this.buttonBack.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnBackDisable));
                this.buttonBack.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnBackDown));
                this.buttonBack.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnBackUp));
                this.buttonDisplay.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnScreenDisable));
                this.buttonDisplay.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnScreenDown));
                this.buttonDisplay.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnScreenUp));
            }
            else
            {

            }
        }
        private void InitializeControl()
        {
            if (this.ParentForm.SystemConfig.EquipmentMode == 0)
                this.groupBoxConveyor.Location = new Point(this.groupBoxStick.Location.X, this.groupBoxStick.Location.Y);

            if (this.ParentForm.EquipmentStatus == DataStore.EquipmentStatus.Stop)
            {
                this.pictureBoxStop.Visible = true;
                this.pictureBoxStart.Visible = false;
            }
            else
            {
                this.pictureBoxStop.Visible = false;
                this.pictureBoxStart.Visible = true;
            }
        }
        private void DefaultSetting()
        {
            this.ChildControl1 = new ControlEquipmentTest(this);
            this.Controls.Add(this.ChildControl1);
            this.ChildControl1.Location = new Point(0, 70);
            this.ChildControl1.Visible = false;

            this.CollectionLabelWeightValue = new Collection<SmartLabel>();
            this.CollectionLabelWeightValue.Clear();
            this.CollectionLabelWeightValue.Add(this.labelWeight1);
            this.CollectionLabelWeightValue.Add(this.labelWeight2);
            this.CollectionLabelWeightValue.Add(this.labelWeight3);
            this.CollectionLabelWeightValue.Add(this.labelWeight4);
            this.CollectionLabelWeightValue.Add(this.labelWeight5);
            this.CollectionLabelWeightValue.Add(this.labelWeight6);
            this.CollectionLabelWeightValue.Add(this.labelWeight7);
            this.CollectionLabelWeightValue.Add(this.labelWeight8);
            this.CollectionLabelWeightValue.Add(this.labelWeight9);
            this.CollectionLabelWeightValue.Add(this.labelWeight10);
            this.CollectionLabelWeightValue.Add(this.labelWeight11);
            this.CollectionLabelWeightValue.Add(this.labelWeight12);

            this.CollectionLabelADC = new Collection<SmartLabel>();
            this.CollectionLabelADC.Clear();
            this.CollectionLabelADC.Add(this.labelADC1);
            this.CollectionLabelADC.Add(this.labelADC2);
            this.CollectionLabelADC.Add(this.labelADC3);
            this.CollectionLabelADC.Add(this.labelADC4);
            this.CollectionLabelADC.Add(this.labelADC5);
            this.CollectionLabelADC.Add(this.labelADC6);
            this.CollectionLabelADC.Add(this.labelADC7);
            this.CollectionLabelADC.Add(this.labelADC8);
            this.CollectionLabelADC.Add(this.labelADC9);
            this.CollectionLabelADC.Add(this.labelADC10);
            this.CollectionLabelADC.Add(this.labelADC11);
            this.CollectionLabelADC.Add(this.labelADC12);

            this.CollectionLabelZero = new Collection<Label>();
            this.CollectionLabelZero.Clear();
            this.CollectionLabelZero.Add(this.labelZero1);
            this.CollectionLabelZero.Add(this.labelZero2);
            this.CollectionLabelZero.Add(this.labelZero3);
            this.CollectionLabelZero.Add(this.labelZero4);
            this.CollectionLabelZero.Add(this.labelZero5);
            this.CollectionLabelZero.Add(this.labelZero6);
            this.CollectionLabelZero.Add(this.labelZero7);
            this.CollectionLabelZero.Add(this.labelZero8);
            this.CollectionLabelZero.Add(this.labelZero9);
            this.CollectionLabelZero.Add(this.labelZero10);
            this.CollectionLabelZero.Add(this.labelZero11);
            this.CollectionLabelZero.Add(this.labelZero12);

            this.CollectionLabelSensor = new Collection<Label>();
            this.CollectionLabelSensor.Clear();
            this.CollectionLabelSensor.Add(this.labelSensor1);
            this.CollectionLabelSensor.Add(this.labelSensor2);
            this.CollectionLabelSensor.Add(this.labelSensor3);
            this.CollectionLabelSensor.Add(this.labelSensor4);
            this.CollectionLabelSensor.Add(this.labelSensor5);
            this.CollectionLabelSensor.Add(this.labelSensor6);
            this.CollectionLabelSensor.Add(this.labelSensor7);
            this.CollectionLabelSensor.Add(this.labelSensor8);
            this.CollectionLabelSensor.Add(this.labelSensor9);
            this.CollectionLabelSensor.Add(this.labelSensor10);
            this.CollectionLabelSensor.Add(this.labelSensor11);
            this.CollectionLabelSensor.Add(this.labelSensor12);

            this.CollectionButtonConveyor = new Collection<SmartButton>();
            this.CollectionButtonConveyor.Clear();
            this.CollectionButtonConveyor.Add(this.buttonConveyor1);
            this.CollectionButtonConveyor.Add(this.buttonConveyor2);
            this.CollectionButtonConveyor.Add(this.buttonConveyor3);
            this.CollectionButtonConveyor.Add(this.buttonConveyor4);
            this.CollectionButtonConveyor.Add(this.buttonConveyor5);
            this.CollectionButtonConveyor.Add(this.buttonConveyor6);
            this.CollectionButtonConveyor.Add(this.buttonConveyor7);
            this.CollectionButtonConveyor.Add(this.buttonConveyor8);
            this.CollectionButtonConveyor.Add(this.buttonConveyor9);
            this.CollectionButtonConveyor.Add(this.buttonConveyor10);
            this.CollectionButtonConveyor.Add(this.buttonConveyor11);
            this.CollectionButtonConveyor.Add(this.buttonConveyor12);

            this.CollectionButtonForward = new Collection<SmartButton>();
            this.CollectionButtonForward.Clear();
            this.CollectionButtonForward.Add(this.buttonForwardDirection1);
            this.CollectionButtonForward.Add(this.buttonForwardDirection2);
            this.CollectionButtonForward.Add(this.buttonForwardDirection3);
            this.CollectionButtonForward.Add(this.buttonForwardDirection4);
            this.CollectionButtonForward.Add(this.buttonForwardDirection5);
            this.CollectionButtonForward.Add(this.buttonForwardDirection6);
            this.CollectionButtonForward.Add(this.buttonForwardDirection7);
            this.CollectionButtonForward.Add(this.buttonForwardDirection8);
            this.CollectionButtonForward.Add(this.buttonForwardDirection9);
            this.CollectionButtonForward.Add(this.buttonForwardDirection10);
            this.CollectionButtonForward.Add(this.buttonForwardDirection11);
            this.CollectionButtonForward.Add(this.buttonForwardDirection12);

            this.CollectionButtonReverse = new Collection<SmartButton>();
            this.CollectionButtonReverse.Clear();
            this.CollectionButtonReverse.Add(this.buttonReverseDirection1);
            this.CollectionButtonReverse.Add(this.buttonReverseDirection2);
            this.CollectionButtonReverse.Add(this.buttonReverseDirection3);
            this.CollectionButtonReverse.Add(this.buttonReverseDirection4);
            this.CollectionButtonReverse.Add(this.buttonReverseDirection5);
            this.CollectionButtonReverse.Add(this.buttonReverseDirection6);
            this.CollectionButtonReverse.Add(this.buttonReverseDirection7);
            this.CollectionButtonReverse.Add(this.buttonReverseDirection8);
            this.CollectionButtonReverse.Add(this.buttonReverseDirection9);
            this.CollectionButtonReverse.Add(this.buttonReverseDirection10);
            this.CollectionButtonReverse.Add(this.buttonReverseDirection11);
            this.CollectionButtonReverse.Add(this.buttonReverseDirection1);

            foreach (SmartLabel label in this.CollectionLabelWeightValue)
                label.Text = Helper.StringToDecimalPlaces("0", this.ParentForm.SystemConfig.DecimalPlaces);

            foreach (SmartLabel label in this.CollectionLabelADC)
                label.Text = "0";

            foreach (SmartButton button in this.CollectionButtonConveyor)
                button.ButtonUp();

            for (int i = 0; i < 12; i++)
            {
                this.CollectionLabelZero[i].Visible = false;
                this.CollectionLabelSensor[i].Visible = false;
            }
        }

        private void TransferDataStreamASetting(string value)
        {
            string length = "";

            length = Helper.StringZeroFillDigits4(value.Length.ToString());

            this.ParentForm.TransferDataStream(CommunicationCommand.BypassToMotor, CommunicationID.MainBoard, CommunicationAddress.None, length + "A" + value);
        }
        private void SetlabelOnOff(Label control, bool isOn)
        {
            if (isOn == true)
            {
                if (control.Visible != true)
                    control.Visible = true;
            }
            else
            {
                if (control.Visible != false)
                    control.Visible = false;
            }
        }

        public void UpdateEquipmentStatusDisplay(DataStore.EquipmentStatus status)
        {
            if (status == DataStore.EquipmentStatus.Start)
            {
                this.pictureBoxStart.Visible = true;
                this.pictureBoxStop.Visible = false;
                this.buttonBack.Enabled = false;
            }
            else
            {
                this.pictureBoxStart.Visible = false;
                this.pictureBoxStop.Visible = true;
                this.buttonBack.Enabled = true;
            }
        }
        public void UpdateStopWeightDisplay(DataStore.EquipmentStatus status, Collection<WeightData> weightDatas)
        {
            string value = "";

            if (status == DataStore.EquipmentStatus.Stop)
            {
                for (int i = 0; i < this.ParentForm.SystemConfig.EquipmentColumns; i++)
                {
                    // 중량
                    value = Helper.DoubleToString(weightDatas[i].Weight, this.ParentForm.SystemConfig.DecimalPlaces);
                    if (this.CollectionLabelWeightValue[i].Text != value)
                        this.CollectionLabelWeightValue[i].Text = value;

                    // ADC
                    value = weightDatas[i].ADCValue;
                    if (this.CollectionLabelADC[i].Text != value)
                        this.CollectionLabelADC[i].Text = value;

                    // 영점표시
                    if (weightDatas[i].Status == DataStore.WeightStatus.WeightZero)
                        this.CollectionLabelZero[i].Visible = true;
                    else
                        this.CollectionLabelZero[i].Visible = false;
                }
            }
            else
            {
                for (int i = 0; i < this.ParentForm.SystemConfig.EquipmentColumns; i++)
                {
                    // 영점표시
                    if (weightDatas[i].Status == DataStore.WeightStatus.WeightZero)
                        this.CollectionLabelZero[i].Visible = true;
                    else
                        this.CollectionLabelZero[i].Visible = false;
                }
            }
        }
        public void UpdateUpdateStartWeightDisplay(DataStore.EquipmentStatus status, Collection<WeightData> weightDatas)
        {
            this.UpdateUpdateStartWeightDisplay1(status, weightDatas[0]);
            this.UpdateUpdateStartWeightDisplay2(status, weightDatas[1]);
            this.UpdateUpdateStartWeightDisplay3(status, weightDatas[2]);
            this.UpdateUpdateStartWeightDisplay4(status, weightDatas[3]);
            this.UpdateUpdateStartWeightDisplay5(status, weightDatas[4]);
            this.UpdateUpdateStartWeightDisplay6(status, weightDatas[5]);
            this.UpdateUpdateStartWeightDisplay7(status, weightDatas[6]);
            this.UpdateUpdateStartWeightDisplay8(status, weightDatas[7]);
            this.UpdateUpdateStartWeightDisplay9(status, weightDatas[8]);
            this.UpdateUpdateStartWeightDisplay10(status, weightDatas[9]);
            this.UpdateUpdateStartWeightDisplay11(status, weightDatas[10]);
            this.UpdateUpdateStartWeightDisplay12(status, weightDatas[11]);
        }
        public void UpdateUpdateStartWeightDisplay1(DataStore.EquipmentStatus status, WeightData weightData)
        {
            string value = "";

            value = Helper.DoubleToString(weightData.Weight, this.ParentForm.SystemConfig.DecimalPlaces);
            if (this.labelWeight1.Text != value)
                this.labelWeight1.Text = value;

            value = weightData.ADCValue;
            if (this.labelADC1.Text != value)
                this.labelADC1.Text = value;
        }
        public void UpdateUpdateStartWeightDisplay2(DataStore.EquipmentStatus status, WeightData weightData)
        {
            string value = "";

            value = Helper.DoubleToString(weightData.Weight, this.ParentForm.SystemConfig.DecimalPlaces);
            if (this.labelWeight2.Text != value)
                this.labelWeight2.Text = value;

            value = weightData.ADCValue;
            if (this.labelADC2.Text != value)
                this.labelADC2.Text = value;
        }
        public void UpdateUpdateStartWeightDisplay3(DataStore.EquipmentStatus status, WeightData weightData)
        {
            string value = "";

            value = Helper.DoubleToString(weightData.Weight, this.ParentForm.SystemConfig.DecimalPlaces);
            if (this.labelWeight3.Text != value)
                this.labelWeight3.Text = value;

            value = weightData.ADCValue;
            if (this.labelADC3.Text != value)
                this.labelADC3.Text = value;
        }
        public void UpdateUpdateStartWeightDisplay4(DataStore.EquipmentStatus status, WeightData weightData)
        {
            string value = "";

            value = Helper.DoubleToString(weightData.Weight, this.ParentForm.SystemConfig.DecimalPlaces);
            if (this.labelWeight4.Text != value)
                this.labelWeight4.Text = value;

            value = weightData.ADCValue;
            if (this.labelADC4.Text != value)
                this.labelADC4.Text = value;
        }
        public void UpdateUpdateStartWeightDisplay5(DataStore.EquipmentStatus status, WeightData weightData)
        {
            string value = "";

            value = Helper.DoubleToString(weightData.Weight, this.ParentForm.SystemConfig.DecimalPlaces);
            if (this.labelWeight5.Text != value)
                this.labelWeight5.Text = value;

            value = weightData.ADCValue;
            if (this.labelADC5.Text != value)
                this.labelADC5.Text = value;
        }
        public void UpdateUpdateStartWeightDisplay6(DataStore.EquipmentStatus status, WeightData weightData)
        {
            string value = "";

            value = Helper.DoubleToString(weightData.Weight, this.ParentForm.SystemConfig.DecimalPlaces);
            if (this.labelWeight6.Text != value)
                this.labelWeight6.Text = value;

            value = weightData.ADCValue;
            if (this.labelADC6.Text != value)
                this.labelADC6.Text = value;
        }
        public void UpdateUpdateStartWeightDisplay7(DataStore.EquipmentStatus status, WeightData weightData)
        {
            string value = "";

            value = Helper.DoubleToString(weightData.Weight, this.ParentForm.SystemConfig.DecimalPlaces);
            if (this.labelWeight7.Text != value)
                this.labelWeight7.Text = value;

            value = weightData.ADCValue;
            if (this.labelADC7.Text != value)
                this.labelADC7.Text = value;
        }
        public void UpdateUpdateStartWeightDisplay8(DataStore.EquipmentStatus status, WeightData weightData)
        {
            string value = "";

            value = Helper.DoubleToString(weightData.Weight, this.ParentForm.SystemConfig.DecimalPlaces);
            if (this.labelWeight8.Text != value)
                this.labelWeight8.Text = value;

            value = weightData.ADCValue;
            if (this.labelADC8.Text != value)
                this.labelADC8.Text = value;
        }
        public void UpdateUpdateStartWeightDisplay9(DataStore.EquipmentStatus status, WeightData weightData)
        {
            string value = "";

            value = Helper.DoubleToString(weightData.Weight, this.ParentForm.SystemConfig.DecimalPlaces);
            if (this.labelWeight9.Text != value)
                this.labelWeight9.Text = value;

            value = weightData.ADCValue;
            if (this.labelADC9.Text != value)
                this.labelADC9.Text = value;
        }
        public void UpdateUpdateStartWeightDisplay10(DataStore.EquipmentStatus status, WeightData weightData)
        {
            string value = "";

            value = Helper.DoubleToString(weightData.Weight, this.ParentForm.SystemConfig.DecimalPlaces);
            if (this.labelWeight10.Text != value)
                this.labelWeight10.Text = value;

            value = weightData.ADCValue;
            if (this.labelADC10.Text != value)
                this.labelADC10.Text = value;
        }
        public void UpdateUpdateStartWeightDisplay11(DataStore.EquipmentStatus status, WeightData weightData)
        {
            string value = "";

            value = Helper.DoubleToString(weightData.Weight, this.ParentForm.SystemConfig.DecimalPlaces);
            if (this.labelWeight11.Text != value)
                this.labelWeight11.Text = value;

            value = weightData.ADCValue;
            if (this.labelADC11.Text != value)
                this.labelADC11.Text = value;
        }
        public void UpdateUpdateStartWeightDisplay12(DataStore.EquipmentStatus status, WeightData weightData)
        {
            string value = "";

            value = Helper.DoubleToString(weightData.Weight, this.ParentForm.SystemConfig.DecimalPlaces);
            if (this.labelWeight12.Text != value)
                this.labelWeight12.Text = value;

            value = weightData.ADCValue;
            if (this.labelADC12.Text != value)
                this.labelADC12.Text = value;
        }
        public void UpdateInputRead(Collection<string> values)
        {
            if (values.Count == 0 || values == null)
                return;

            for (int i = 0; i < this.CollectionLabelSensor.Count; i++)
                this.SetlabelOnOff(this.CollectionLabelSensor[i], values[i] == "1" ? true : false);
        }
        public void UpdateZeroParameterDisplay(DataStore.EquipmentStatus status, ZeroParameterItem item)
        {
            this.ChildControl1.UpdateZeroParameterDisplay(status, item);
        }
        public void UpdateOptionParameterDisplay(DataStore.EquipmentStatus status, OptionParameterItem item, SystemConfigurationItem systemItem)
        {
            this.ChildControl1.UpdateOptionParameterDisplay(status, item, systemItem);
        }
        public void UpdateCalibrationItemDisplay(DataStore.EquipmentStatus status, CalibrationItem item)
        {
            this.ChildControl1.UpdateCalibrationDisplay(item);
        }

        public void DisplayRefresh()
        {
            string value = "";
            this.ParentForm.SystemConfig.CurrentForm = DataStore.FormStore.FormEquipmentTest;

            this.ParentForm.TransferData(CommunicationCommand.ModeEquipmentTest, CommunicationID.MainBoard);

            value = this.ParentForm.CurrentJudgmentSetItem.Sorter1DelayTime.ToString();
            if (this.labelSorterDelayTime.Text != value)
                this.labelSorterDelayTime.Text = value;

            value = this.ParentForm.CurrentJudgmentSetItem.Sorter1RunTime.ToString();
            if (this.labelSorterOperatingTime.Text != value)
                this.labelSorterOperatingTime.Text = value;

            if (this.CollectionButtonConveyor != null && this.CollectionButtonConveyor.Count != 0)
            {
                foreach (SmartButton button in this.CollectionButtonConveyor)
                    button.ButtonUp();
            }

            if (this.ChildControl1 != null)
                this.ChildControl1.DisplayRefresh();
        }
        #endregion

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

            this.DefaultSetting();
            this.InitializeDesign();
            this.InitializeControl();
        }
        #endregion

        #region Event Handler
        private void buttonBack_Click(object sender, EventArgs e)
        {
            this.ParentForm.timerAdcLog.Enabled = false;
            this.ParentForm.IsAdcLogOpen = false;
            this.ParentForm.smartFileAdcLog.Close();
            this.labelAdcLogOpen.Visible = false;

            this.ParentForm.ChildFormMenu.DisplayRefresh();
            ((FormMain)(Owner)).smartForm.Show((int)DataStore.FormStore.FormMenu);
        }

        private void buttonZero_Click(object sender, EventArgs e)
        {
            SmartButton button = sender as SmartButton;

            if (button == null)
                return;

            if (button == this.buttonZero1)
                this.ParentForm.TransferData(CommunicationCommand.Zero, CommunicationID.SubBoard1);
            else if (button == this.buttonZero2)
                this.ParentForm.TransferData(CommunicationCommand.Zero, CommunicationID.SubBoard2);
            else if (button == this.buttonZero3)
                this.ParentForm.TransferData(CommunicationCommand.Zero, CommunicationID.SubBoard3);
            else if (button == this.buttonZero4)
                this.ParentForm.TransferData(CommunicationCommand.Zero, CommunicationID.SubBoard4);
            else if (button == this.buttonZero5)
                this.ParentForm.TransferData(CommunicationCommand.Zero, CommunicationID.SubBoard5);
            else if (button == this.buttonZero6)
                this.ParentForm.TransferData(CommunicationCommand.Zero, CommunicationID.SubBoard6);
            else if (button == this.buttonZero7)
                this.ParentForm.TransferData(CommunicationCommand.Zero, CommunicationID.SubBoard7);
            else if (button == this.buttonZero8)
                this.ParentForm.TransferData(CommunicationCommand.Zero, CommunicationID.SubBoard8);
            else if (button == this.buttonZero9)
                this.ParentForm.TransferData(CommunicationCommand.Zero, CommunicationID.SubBoard9);
            else if (button == this.buttonZero10)
                this.ParentForm.TransferData(CommunicationCommand.Zero, CommunicationID.SubBoard10);
            else if (button == this.buttonZero11)
                this.ParentForm.TransferData(CommunicationCommand.Zero, CommunicationID.SubBoard11);
            else
                this.ParentForm.TransferData(CommunicationCommand.Zero, CommunicationID.SubBoard12);
        }

        private void pictureBoxStart_Click(object sender, EventArgs e)
        {
            this.ParentForm.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);

            foreach (SmartButton button in this.CollectionButtonConveyor)
                button.ButtonUp();
        }
        private void pictureBoxStop_Click(object sender, EventArgs e)
        {
            this.ParentForm.TransferData(CommunicationCommand.Start, CommunicationID.MainBoard);

            foreach (SmartButton button in this.CollectionButtonConveyor)
                button.ButtonDown();
        }

        #region Conveyor
        private void buttonConveyor_Click(object sender, EventArgs e)
        {
            SmartButton button = sender as SmartButton;

            if (button == null)
                return;

            if (button.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
            {
                this.ParentForm.TransferDataStream(CommunicationCommand.IOTest, CommunicationID.MainBoard, Helper.StringZeroFillDigits4(button.Tag.ToString()),
                    Helper.StringZeroFillDigits4("1"));
            }
            else
            {
                this.ParentForm.TransferDataStream(CommunicationCommand.IOTest, CommunicationID.MainBoard, Helper.StringZeroFillDigits4(button.Tag.ToString()),
                    Helper.StringZeroFillDigits4("0"));
            }
        }

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

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelSorterDelayTime.Text, 4, 0, false, this.ParentForm.SystemConfig.Language);

            if (myKeyPad.ShowDialog() == DialogResult.OK)
            {
                if (myKeyPad.doubleValue < 0 || myKeyPad.doubleValue > 9999)
                {
                    // 입력범위를 확인하세요
                    DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.SystemConfig.Language);
                    myMsg.ShowDialog();
                }
                else
                {
                    this.labelSorterDelayTime.Text = myKeyPad.StringValue;
                    this.ParentForm.CurrentJudgmentSetItem.Sorter1DelayTime = myKeyPad.IntValue;

                    value = Helper.StringZeroFillDigits4(this.labelSorterDelayTime.Text);
                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.SubBoardAll, CommunicationAddress._5102_Sorter1DelayTime, value);

                    this.ParentForm.SaveJudgmentSetFile(this.ParentForm.CurrentJudgmentSetItem, this.ParentForm.SystemConfig.ProductNumber - 1);
                }
            }
        }
        private void labelSorterOperatingTime_Click(object sender, EventArgs e)
        {
            string value = "";

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelSorterOperatingTime.Text, 4, 0, false, this.ParentForm.SystemConfig.Language);

            if (myKeyPad.ShowDialog() == DialogResult.OK)
            {
                if (myKeyPad.doubleValue < 0 || myKeyPad.doubleValue > 9999)
                {
                    // 입력범위를 확인하세요
                    DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.SystemConfig.Language);
                    myMsg.ShowDialog();
                }
                else
                {
                    this.labelSorterOperatingTime.Text = myKeyPad.StringValue;
                    this.ParentForm.CurrentJudgmentSetItem.Sorter1RunTime = myKeyPad.IntValue;

                    value = Helper.StringZeroFillDigits4(this.labelSorterOperatingTime.Text);
                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.SubBoardAll, CommunicationAddress._5103_Sorter1RunTime, value);

                    this.ParentForm.SaveJudgmentSetFile(this.ParentForm.CurrentJudgmentSetItem, this.ParentForm.SystemConfig.ProductNumber - 1);
                }
            }
        }
        #endregion

        #region Stick
        private void buttonForwardDirection_Click(object sender, EventArgs e)
        {
            string deviceName = "";
            int deviceNo = 0;
            SmartX.SmartButton button = sender as SmartX.SmartButton;

            if (button == null)
                return;

            if (this.ParentForm.SystemConfig.StepMotorType == (int)DataStore.StepMotorType.MDrive)
            {
                if (button == this.buttonForwardDirection1)
                    deviceName = "A";
                else if (button == this.buttonForwardDirection2)
                    deviceName = "B";
                else if (button == this.buttonForwardDirection3)
                    deviceName = "C";
                else if (button == this.buttonForwardDirection4)
                    deviceName = "D";
                else if (button == this.buttonForwardDirection5)
                    deviceName = "E";
                else if (button == this.buttonForwardDirection6)
                    deviceName = "F";
                else if (button == this.buttonForwardDirection7)
                    deviceName = "G";
                else if (button == this.buttonForwardDirection8)
                    deviceName = "H";
                else if (button == this.buttonForwardDirection9)
                    deviceName = "I";
                else if (button == this.buttonForwardDirection10)
                    deviceName = "J";
                else if (button == this.buttonForwardDirection11)
                    deviceName = "K";
                else if (button == this.buttonForwardDirection12)
                    deviceName = "L";

                if (this.ParentForm.SystemConfig.IsImpellerMotorDirectionCW == true)
                    this.ParentForm.ChildFormMotorSetting.TransferDirectSTXETX0x0A(deviceName + "MR-" + this.labelRotationAngle1.Text + "00");
                else
                    this.ParentForm.ChildFormMotorSetting.TransferDirectSTXETX0x0A(deviceName + "MR " + this.labelRotationAngle1.Text + "00");
            }
            else if (this.ParentForm.SystemConfig.StepMotorType == (int)DataStore.StepMotorType.Moons)
            {
                if (button == this.buttonForwardDirection1)
                    deviceName = "1";
                else if (button == this.buttonForwardDirection2)
                    deviceName = "2";
                else if (button == this.buttonForwardDirection3)
                    deviceName = "3";
                else if (button == this.buttonForwardDirection4)
                    deviceName = "4";
                else if (button == this.buttonForwardDirection5)
                    deviceName = "5";
                else if (button == this.buttonForwardDirection6)
                    deviceName = "6";
                else if (button == this.buttonForwardDirection7)
                    deviceName = "7";
                else if (button == this.buttonForwardDirection8)
                    deviceName = "8";
                else if (button == this.buttonForwardDirection9)
                    deviceName = "9";
                else if (button == this.buttonForwardDirection10)
                    deviceName = ":";
                else if (button == this.buttonForwardDirection11)
                    deviceName = ";";
                else if (button == this.buttonForwardDirection12)
                    deviceName = "<";

                if (this.ParentForm.SystemConfig.IsImpellerMotorDirectionCW == true)
                    this.ParentForm.ChildFormMotorSetting.TransferDirectETX0x0D(deviceName + "FL" + this.labelRotationAngle1.Text + "00");
                else
                    this.ParentForm.ChildFormMotorSetting.TransferDirectETX0x0D(deviceName + "FL-" + this.labelRotationAngle1.Text + "00");
            }
            else if (this.ParentForm.SystemConfig.StepMotorType == (int)DataStore.StepMotorType.EDB_ALL_P)
            {
                if (button == this.buttonForwardDirection1)
                    deviceNo = 1;
                else if (button == this.buttonForwardDirection2)
                    deviceNo = 2;
                else if (button == this.buttonForwardDirection3)
                    deviceNo = 3;
                else if (button == this.buttonForwardDirection4)
                    deviceNo = 4;
                else if (button == this.buttonForwardDirection5)
                    deviceNo = 5;
                else if (button == this.buttonForwardDirection6)
                    deviceNo = 6;
                else if (button == this.buttonForwardDirection7)
                    deviceNo = 7;
                else if (button == this.buttonForwardDirection8)
                    deviceNo = 8;
                else if (button == this.buttonForwardDirection9)
                    deviceNo = 9;
                else if (button == this.buttonForwardDirection10)
                    deviceNo = 10;
                else if (button == this.buttonForwardDirection11)
                    deviceNo = 11;
                else if (button == this.buttonForwardDirection12)
                    deviceNo = 12;

                this.ParentForm.ChildFormMotorSetting.TransferDirectToEDBMotor
                    (this.ParentForm.ChildFormMotorSetting.SendCommand((byte)deviceNo, 5, 7, 0, 0));
            }
        }
        private void buttonReverseDirection_Click(object sender, EventArgs e)
        {
            string deviceName = "";
            SmartX.SmartButton button = sender as SmartX.SmartButton;

            if (button == null)
                return;

            if (this.ParentForm.SystemConfig.StepMotorType != (int)DataStore.StepMotorType.Moons)
            {
                if (button == this.buttonReverseDirection1)
                    deviceName = "A";
                else if (button == this.buttonReverseDirection2)
                    deviceName = "B";
                else if (button == this.buttonReverseDirection3)
                    deviceName = "C";
                else if (button == this.buttonReverseDirection4)
                    deviceName = "D";
                else if (button == this.buttonReverseDirection5)
                    deviceName = "E";
                else if (button == this.buttonReverseDirection6)
                    deviceName = "F";
                else if (button == this.buttonReverseDirection7)
                    deviceName = "G";
                else if (button == this.buttonReverseDirection8)
                    deviceName = "H";
                else if (button == this.buttonReverseDirection9)
                    deviceName = "I";
                else if (button == this.buttonReverseDirection10)
                    deviceName = "J";
                else if (button == this.buttonReverseDirection11)
                    deviceName = "K";
                else if (button == this.buttonReverseDirection12)
                    deviceName = "L";

                if (this.ParentForm.SystemConfig.IsImpellerMotorDirectionCW == true)
                    this.ParentForm.ChildFormMotorSetting.TransferDirectSTXETX0x0A(deviceName + "MR " + this.labelRotationAngle1.Text + "00");
                else
                    this.ParentForm.ChildFormMotorSetting.TransferDirectSTXETX0x0A(deviceName + "MR-" + this.labelRotationAngle1.Text + "00");

                //if (this.ParentForm.SystemConfig.IsImpellerMotorDirectionCW == true)
                //    this.ParentForm.TransferData(CommunicationCommand.ImpellerMotorForward, deviceName);
                //else
                //    this.ParentForm.TransferData(CommunicationCommand.ImpellerMotorReverse, deviceName);
            }
            else
            {
                if (button == this.buttonReverseDirection1)
                    deviceName = "1";
                else if (button == this.buttonReverseDirection2)
                    deviceName = "2";
                else if (button == this.buttonReverseDirection3)
                    deviceName = "3";
                else if (button == this.buttonReverseDirection4)
                    deviceName = "4";
                else if (button == this.buttonReverseDirection5)
                    deviceName = "5";
                else if (button == this.buttonReverseDirection6)
                    deviceName = "6";
                else if (button == this.buttonReverseDirection7)
                    deviceName = "7";
                else if (button == this.buttonReverseDirection8)
                    deviceName = "8";
                else if (button == this.buttonReverseDirection9)
                    deviceName = "9";
                else if (button == this.buttonReverseDirection10)
                    deviceName = ":";
                else if (button == this.buttonReverseDirection11)
                    deviceName = ";";
                else if (button == this.buttonReverseDirection12)
                    deviceName = "<";

                if (this.ParentForm.SystemConfig.IsImpellerMotorDirectionCW == true)
                    this.ParentForm.ChildFormMotorSetting.TransferDirectETX0x0D(deviceName + "FL-" + this.labelRotationAngle1.Text + "00");
                else
                    this.ParentForm.ChildFormMotorSetting.TransferDirectETX0x0D(deviceName + "FL" + this.labelRotationAngle1.Text + "00");
            }
        }

        private void buttonForwardDirectionAll_Click(object sender, EventArgs e)
        {
            if (this.ParentForm.SystemConfig.StepMotorType != (int)DataStore.StepMotorType.Moons)
            {
                if (this.ParentForm.SystemConfig.IsImpellerMotorDirectionCW == true)
                    this.ParentForm.ChildFormMotorSetting.TransferDirectSTXETX0x0A("*MR-" + this.labelRotationAngle1.Text + "00");
                else
                    this.ParentForm.ChildFormMotorSetting.TransferDirectSTXETX0x0A("*MR " + this.labelRotationAngle1.Text + "00");
            }
            else
            {
                if (this.ParentForm.SystemConfig.IsImpellerMotorDirectionCW == true)
                    this.ParentForm.ChildFormMotorSetting.TransferDirectETX0x0D("FL" + this.labelRotationAngle1.Text + "00");
                else
                    this.ParentForm.ChildFormMotorSetting.TransferDirectETX0x0D("FL-" + this.labelRotationAngle1.Text + "00");
            }
        }
        private void buttonReverseDirectionAll_Click(object sender, EventArgs e)
        {
            if (this.ParentForm.SystemConfig.StepMotorType != (int)DataStore.StepMotorType.Moons)
            {
                if (this.ParentForm.SystemConfig.IsImpellerMotorDirectionCW == true)
                    this.ParentForm.ChildFormMotorSetting.TransferDirectSTXETX0x0A("*MR " + this.labelRotationAngle1.Text + "00");
                else
                    this.ParentForm.ChildFormMotorSetting.TransferDirectSTXETX0x0A("*MR-" + this.labelRotationAngle1.Text + "00");
            }
            else
            {
                if (this.ParentForm.SystemConfig.IsImpellerMotorDirectionCW == true)
                    this.ParentForm.ChildFormMotorSetting.TransferDirectETX0x0D("FL-" + this.labelRotationAngle1.Text + "00");
                else
                    this.ParentForm.ChildFormMotorSetting.TransferDirectETX0x0D("FL" + this.labelRotationAngle1.Text + "00");
            }
        }

        private void buttonFeedingConveyor_Click(object sender, EventArgs e)
        {
            if (this.buttonFeedingConveyor.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
                this.ParentForm.TransferDataStream(CommunicationCommand.IOTest, CommunicationID.MainBoard, "7705", Helper.StringZeroFillDigits4("1"));
            else
                this.ParentForm.TransferDataStream(CommunicationCommand.IOTest, CommunicationID.MainBoard, "7705", Helper.StringZeroFillDigits4("0"));
        }

        private void buttonRejectConveyorCW_Click(object sender, EventArgs e)
        {
            if (this.buttonRejectConveyorCW.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
            {
                this.buttonRejectConveyorCCW.Enabled = false;

                this.ParentForm.TransferDataStream(CommunicationCommand.IOTest, CommunicationID.MainBoard, "7707", Helper.StringZeroFillDigits4("1"));
            }
            else
            {
                this.buttonRejectConveyorCCW.Enabled = true;

                this.ParentForm.TransferDataStream(CommunicationCommand.IOTest, CommunicationID.MainBoard, "7707", Helper.StringZeroFillDigits4("0"));
            }
        }
        private void buttonRejectConveyorCCW_Click(object sender, EventArgs e)
        {
            if (this.buttonRejectConveyorCCW.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
            {
                this.buttonRejectConveyorCW.Enabled = false;

                this.ParentForm.TransferDataStream(CommunicationCommand.IOTest, CommunicationID.MainBoard, "7708", Helper.StringZeroFillDigits4("1"));
            }
            else
            {
                this.buttonRejectConveyorCW.Enabled = true;

                this.ParentForm.TransferDataStream(CommunicationCommand.IOTest, CommunicationID.MainBoard, "7708", Helper.StringZeroFillDigits4("0"));
            }
        }

        private void buttonCut_Click(object sender, EventArgs e)
        {
            this.ParentForm.TransferData(CommunicationCommand.CutInput, CommunicationID.MainBoard);
        }

        private void timer_Tick(object sender, EventArgs e)
        {
            if (this.ParentForm.SystemConfig.StepMotorType != (int)DataStore.StepMotorType.Moons)
            {
                if (this.ParentForm.SystemConfig.IsImpellerMotorDirectionCW == true)
                    this.ParentForm.ChildFormMotorSetting.TransferDirectSTXETX0x0A("*MR-" + this.labelRotationAngle1.Text + "00");
                else
                    this.ParentForm.ChildFormMotorSetting.TransferDirectSTXETX0x0A("*MR " + this.labelRotationAngle1.Text + "00");
            }
            else
            {
                if (this.ParentForm.SystemConfig.IsImpellerMotorDirectionCW == true)
                    this.ParentForm.ChildFormMotorSetting.TransferDirectETX0x0D("FL" + this.labelRotationAngle1.Text + "00");
                else
                    this.ParentForm.ChildFormMotorSetting.TransferDirectETX0x0D("FL-" + this.labelRotationAngle1.Text + "00");
            }
        }
        private void labelIntervalAll_Click(object sender, EventArgs e)
        {
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelIntervalAll.Text, 4, 0, false, this.ParentForm.SystemConfig.Language);
            if (myKeyPad.ShowDialog() == DialogResult.OK)
            {
                if (myKeyPad.doubleValue < 1000 || myKeyPad.doubleValue > 9999)
                {
                    // 입력범위를 확인하세요
                    DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.SystemConfig.Language);
                    myMsg.ShowDialog();
                }
                else
                {
                    this.labelIntervalAll.Text = myKeyPad.doubleValue.ToString();
                }
            }
        }
        private void buttonAllContinue_Click(object sender, EventArgs e)
        {
            if (this.buttonAllContinue.ButtonStatus == SmartX.SmartButton.BUTSTATUS.DOWN)
            {
                this.timer.Interval = int.Parse(this.labelIntervalAll.Text);
                this.timer.Enabled = true;

                this.buttonBack.Enabled = false;
                this.buttonForwardDirectionAll.Enabled = false;
                this.buttonReverseDirectionAll.Enabled = false;

                foreach (SmartButton button in this.CollectionButtonForward)
                    button.Enabled = false;
                foreach (SmartButton button in this.CollectionButtonReverse)
                    button.Enabled = false;
            }
            else
            {
                this.timer.Enabled = false;

                this.buttonBack.Enabled = true;
                this.buttonForwardDirectionAll.Enabled = true;
                this.buttonReverseDirectionAll.Enabled = true;

                foreach (SmartButton button in this.CollectionButtonForward)
                    button.Enabled = true;
                foreach (SmartButton button in this.CollectionButtonReverse)
                    button.Enabled = true;
            }
        }
        private void labelRotationAngle1_Click(object sender, EventArgs e)
        {
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelRotationAngle1.Text, 3, 0, false, this.ParentForm.SystemConfig.Language);
            if (myKeyPad.ShowDialog() == DialogResult.OK)
            {
                if (myKeyPad.doubleValue < 0 || myKeyPad.doubleValue > 360)
                {
                    // 입력범위를 확인하세요
                    DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.SystemConfig.Language);
                    myMsg.ShowDialog();
                }
                else
                {
                    this.labelRotationAngle1.Text = myKeyPad.StringValue;
                    if (this.ParentForm.SystemConfig.StepMotorType == (int)DataStore.StepMotorType.Moons)
                        this.ParentForm.ChildFormMotorSetting.TransferDirectETX0x0D("FL" + this.labelRotationAngle1.Text + "00");
                    else if(this.ParentForm.SystemConfig.StepMotorType == (int)DataStore.StepMotorType.MDrive)
                        this.ParentForm.ChildFormMotorSetting.TransferDirectSTXETX0x0A("*MR" + this.labelRotationAngle1.Text + "00");
                    //else if (this.ParentForm.SystemConfig.StepMotorType == (int)DataStore.StepMotorType.EDB_ALL_P)
                    //    this.ParentForm.ChildFormMotorSetting.TransferDirectToEDBMotor
                    //        (this.ParentForm.ChildFormMotorSetting.SendCommand((byte)1, 9, 0, 2, 2));
                }
            }
        }
        #endregion

        private void buttonLogOpen_Click(object sender, EventArgs e)
        {
            this.ParentForm.smartFileCommunicationLog.Close();
            this.ParentForm.smartFileCommunicationLog.Open(this.ParentForm.BufferSmartUart);

            this.ParentForm.IsCommunicationLogOpen = true;
        }
        private void buttonLogClose_Click(object sender, EventArgs e)
        {
            this.ParentForm.IsCommunicationLogOpen = false;

            this.ParentForm.smartFileCommunicationLog.Close();
        }
        private void buttonCOM3LogOpen_Click(object sender, EventArgs e)
        {
            this.ParentForm.smartFileCom3Log.Close();
            this.ParentForm.smartFileCom3Log.Open(this.ParentForm.BufferSmartUart);

            this.ParentForm.IsCom3LogOpen = true;
        }
        private void buttonCOM3LogClose_Click(object sender, EventArgs e)
        {
            this.ParentForm.IsCom3LogOpen = false;

            this.ParentForm.smartFileCom3Log.Close();
        }
        private void buttonLogAdcOpen_Click(object sender, EventArgs e)
        {
            this.ParentForm.smartFileAdcLog.Close();
            this.ParentForm.smartFileAdcLog.Open(this.ParentForm.BufferSmartUart);

            this.ParentForm.IsAdcLogOpen = true;
            this.ParentForm.timerAdcLog.Enabled = true;

            this.labelAdcLogOpen.Visible = true;
        }
        private void buttonLogAdcClose_Click(object sender, EventArgs e)
        {
            this.ParentForm.IsAdcLogOpen = false;
            this.ParentForm.timerAdcLog.Enabled = false;

            this.ParentForm.smartFileAdcLog.Close();

            this.labelAdcLogOpen.Visible = false;
        }
        private void buttonCOM1LogOpen_Click(object sender, EventArgs e)
        {
            this.ParentForm.smartFileCom1Log.Close();
            this.ParentForm.smartFileCom1Log.Open(this.ParentForm.BufferSmartUart);

            this.ParentForm.IsCom1LogOpen = true;
        }
        private void buttonCOM1LogClose_Click(object sender, EventArgs e)
        {
            this.ParentForm.IsCom1LogOpen = false;

            this.ParentForm.smartFileCom1Log.Close();
        }
        private void buttonDisplay_Click(object sender, EventArgs e)
        {
            if (this.ChildControl1.Visible == false)
            {
                this.ChildControl1.BringToFront();
                this.ChildControl1.Visible = true;
            }
            else
                this.ChildControl1.Visible = false;
        }

        private void checkBoxCutMainDisplayView_Click(object sender, EventArgs e)
        {
            if (this.checkBoxCutMainDisplayView.Checked == true)
                this.ParentForm.SystemConfig.IsCutView = true;
            else
                this.ParentForm.SystemConfig.IsCutView = false;
        }
        private void checkBoxSamplingMainDisplayView_Click(object sender, EventArgs e)
        {
            if (this.checkBoxSamplingMainDisplayView.Checked == true)
                this.ParentForm.SystemConfig.IsSamplingView = true;
            else
                this.ParentForm.SystemConfig.IsSamplingView = false;
        }
        #endregion
    }
}