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

using ITC81DB.DialogForms;
using ITC81DB.Forms;

namespace ITC81DB
{
    public partial class ControlCenterInforSystem3 : UserControl
    {
        #region Field
        private FormMenu m_ParentForm;
        #endregion

        #region Constructor
        public ControlCenterInforSystem3(FormMenu parent)
        {
            InitializeComponent();

            this.ParentForm = parent;
            this.InitializeDesign();
            this.DefaultSetting();
        }
        #endregion

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

        #region Method
        public void InitializeDesign()
        {
            if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Korean)
            {
                this.groupBoxEquipment.Text = "기능설정";
                this.groupBoxSerial.Text = "시리얼통신";
                this.groupBoxRandomMode.Text = "랜덤모드";
                this.groupBoxEthernet.Text = "이더넷통신";

                this.labelTitleEquipmentID.Text = "장비 ID";
                this.labelTitleBuzzerOn.Text = "부저 ON";
                this.labelTitleChattering.Text = "채터링";
                this.labelTitleRelay.Text = "릴레이동작";
                this.labelTitleLanguage.Text = "언어설정";
                this.labelTitleOptionBoard.Text = "옵션보드";
                this.labelTitleExtension.Text = "확장자";
                this.labelTitleFormat.Text = "포맷";
                this.labelTitleLogin.Text = "로그인";
                this.labelTitleEquipmentType.Text = "장비타입";
                this.labelTitleBarcode.Text = "바코드";

                this.labelTitleSampleNumber.Text = "샘플개수";
                this.labelTitleDelayNumber.Text = "지연개수";
                this.labelTitlePulseWidth.Text = "펄스폭";
                this.labelTitleUsingOPT1.Text = "사용여부";
                this.labelTitleFeedbackOver.Text = "피드백상한";
                this.labelTitleFeedbackUnder.Text = "피드백하한";

                this.labelTitlePort.Text = "출력포트";
                this.labelTitleDelayTime1.Text = "지연시간1";
                this.labelTitleDelayTime2.Text = "지연시간2";

                this.labelTitleModeSerial.Text = "모드";

                this.labelTitleUnder.Text = "하한";
                this.labelTitleOver.Text = "상한";
                this.labelTitleTare.Text = "용기";
                this.labelTitleUsingRandomMode.Text = "사용여부";

                this.labelTitleOperatingMode.Text = "동작모드";
                this.labelTitleCommunicationMode.Text = "통신모드";
            }
            else
            {
                this.groupBoxEquipment.Text = "Equipment";
                this.groupBoxSerial.Text = "Serial";
                this.groupBoxRandomMode.Text = "Random Mode";
                this.groupBoxEthernet.Text = "Ethernet";

                this.labelTitleEquipmentID.Text = "Equip ID";
                this.labelTitleBuzzerOn.Text = "Buzz ON";
                this.labelTitleChattering.Text = "Chattering";
                this.labelTitleRelay.Text = "Relay";
                this.labelTitleLanguage.Text = "Language";
                this.labelTitleOptionBoard.Text = "Op.Board";
                this.labelTitleExtension.Text = "Extension";
                this.labelTitleFormat.Text = "Format";
                this.labelTitleLogin.Text = "Login";
                this.labelTitleEquipmentType.Text = "E-Type";
                this.labelTitleBarcode.Text = "Barcode";

                this.labelTitleSampleNumber.Text = "Sample Num";
                this.labelTitleDelayNumber.Text = "Delay Num";
                this.labelTitlePulseWidth.Text = "Pulse Width";
                this.labelTitleUsingOPT1.Text = "Using";
                this.labelTitleFeedbackOver.Text = "Feedback Over";
                this.labelTitleFeedbackUnder.Text = "Feedback Under";

                this.labelTitlePort.Text = "Port";
                this.labelTitleDelayTime1.Text = "Delay Time 1";
                this.labelTitleDelayTime2.Text = "Delay Time 2";

                this.labelTitleModeSerial.Text = "Mode";

                this.labelTitleUnder.Text = "Under";
                this.labelTitleOver.Text = "Over";
                this.labelTitleTare.Text = "Tare";
                this.labelTitleUsingRandomMode.Text = "Using";

                this.labelTitleOperatingMode.Text = "Op-Mode";
                this.labelTitleCommunicationMode.Text = "Com-Mode";
            }
        }
        private void DefaultSetting()
        {

        }

        private string ReturnBaudrateName(int num)
        {
            switch (num)
            {
                case 0:
                    return "9600";
                case 1:
                    return "19200";
                case 2:
                    return "38400";
                case 3:
                    return "57600";
                case 4:
                    return "115200";
                default:
                    return "9600";
            }
        }
        private string ReturnCommunicationModeName(int num)
        {
            if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.German)
            {
                #region 독일어
                switch (num)
                {
                    case 0:
                        return "Keiner";
                    case 1:
                        return "STD1";
                    case 2:
                        return "Fernzugriff";
                    case 3:
                        return "Drucker";
                    case 4:
                        return "imaje9410-1";
                    case 5:
                        return "imaje9028-1";
                    case 6:
                        return "OPT0";
                    case 7:
                        return "imaje9410-2";
                    case 8:
                        return "imaje9028-2";
                    case 9:
                        return "Hitachi";
                    case 10:
                        return "MACSA";
                    case 11:
                        return "Markoprint";
                    case 12:
                        return "alphaJET";
                    case 13:
                        return "VJ1510";
                    case 14:
                        return "OPT1";
                    case 15:
                        return "OPT2";
                    case 16:
                        return "OPC";
                    case 17:
                        return "OPT3";
                    case 18:
                        return "HP-200";
                    case 19:
                        return "Smart Jet";
                    case 20:
                        return "imaje 9410 OPT3";
                    case 21:
                        return "RFID R420";
                    case 22:
                        return "Modbus";
                    case 23:
                        return "STD2";
                    case 24:
                        return "MULTi-JET";
                    case 25:
                        return "DJ(VIDEOJET)";
                    case 26:
                        return "LINX8830";
                    case 27:
                        return "MYJET";
                    default:
                        return "Keiner";
                }
                #endregion
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Spanish)
            {
                #region 스페인어
                switch (num)
                {
                    case 0:
                        return "Ninguna";
                    case 1:
                        return "STD1";
                    case 2:
                        return "Remoto";
                    case 3:
                        return "Impresora industrial";
                    case 4:
                        return "imaje9410-1";
                    case 5:
                        return "imaje9028-1";
                    case 6:
                        return "OPT0";
                    case 7:
                        return "imaje9410-2";
                    case 8:
                        return "imaje9028-2";
                    case 9:
                        return "Hitachi";
                    case 10:
                        return "MACSA";
                    case 11:
                        return "Markoprint";
                    case 12:
                        return "alphaJET";
                    case 13:
                        return "VJ1510";
                    case 14:
                        return "OPT1";
                    case 15:
                        return "OPT2";
                    case 16:
                        return "OPC";
                    case 17:
                        return "OPT3";
                    case 18:
                        return "HP-200";
                    case 19:
                        return "Smart Jet";
                    case 20:
                        return "imaje 9410 OPT3";
                    case 21:
                        return "RFID R420";
                    case 22:
                        return "Modbus";
                    case 23:
                        return "STD2";
                    case 24:
                        return "MULTi-JET";
                    case 25:
                        return "DJ(VIDEOJET)";
                    case 26:
                        return "LINX8830";
                    case 27:
                        return "MYJET";
                    default:
                        return "Ninguna";
                }
                #endregion                
            }
            else
            {
                #region 한국어
                switch (num)
                {
                    case 0:
                        return "None";
                    case 1:
                        return "STD1";
                    case 2:
                        return "Remote";
                    case 3:
                        return "Printer";
                    case 4:
                        return "imaje9410-1";
                    case 5:
                        return "imaje9028-1";
                    case 6:
                        return "OPT0";
                    case 7:
                        return "imaje9410-2";
                    case 8:
                        return "imaje9028-2";
                    case 9:
                        return "Hitachi";
                    case 10:
                        return "MACSA";
                    case 11:
                        return "Markoprint";
                    case 12:
                        return "alphaJET";
                    case 13:
                        return "VJ1510";
                    case 14:
                        return "OPT1";
                    case 15:
                        return "OPT2";
                    case 16:
                        return "OPC";
                    case 17:
                        return "OPT3";
                    case 18:
                        return "HP-200";
                    case 19:
                        return "Smart Jet";
                    case 20:
                        return "imaje 9410 OPT3";
                    case 21:
                        return "RFID R420";
                    case 22:
                        return "Modbus";
                    case 23:
                        return "STD2";
                    case 24:
                        return "MULTi-JET";
                    case 25:
                        return "DJ(VIDEOJET)";
                    case 26:
                        return "LINX8830";
                    case 27:
                        return "MYJET";
                    default:
                        return "None";
                }
                #endregion                
            }
        }
        private void InitialLabel()
        {
            #region Initial Label
            this.label996Under.Text = "-";
            this.label996Over.Text = "-";
            this.label996Tare.Text = "-";
            this.label996Using.Text = "-";
            this.label997Under.Text = "-";
            this.label997Over.Text = "-";
            this.label997Tare.Text = "-";
            this.label997Using.Text = "-";
            this.label998Under.Text = "-";
            this.label998Over.Text = "-";
            this.label998Tare.Text = "-";
            this.label998Using.Text = "-";
            this.label999Under.Text = "-";
            this.label999Over.Text = "-";
            this.label999Tare.Text = "-";
            this.label999Using.Text = "-";
            this.label1000Under.Text = "-";
            this.label1000Over.Text = "-";
            this.label1000Tare.Text = "-";
            this.label1000Using.Text = "-";

            this.labelOPT1SampleNumber.Text = "-";
            this.labelOPT1DelayNumber.Text = "-";
            this.labelOPT1PulseWidth.Text = "-";
            this.labelOPT1Using.Text = "-";
            this.labelOPT1FeedbackOver.Text = "-";
            this.labelOPT1FeedbackUnder.Text = "-";

            this.labelOPT2Port.Text = "-";
            this.labelOPT2DelayTime1.Text = "-";
            this.labelOPT2DelayTime2.Text = "-";

            this.labelBuzzerOn.Text = "-";
            this.labelChattering.Text = "-";
            this.labelRelay.Text = "-";
            this.labelOptionBoard.Text = "-";
            this.labelEquipmentType.Text = "-";
            this.labelPIN8.Text = "-";
            this.labelPIN7.Text = "-";
            this.labelPIN6.Text = "-";
            this.labelPIN5.Text = "-";
            this.labelPIN4.Text = "-";
            this.labelPIN3.Text = "-";
            this.labelPhotoB.Text = "-";

            this.labelEquipmentID.Text = "-";
            this.labelLanguage.Text = "-";
            this.labelExtension.Text = "-";
            this.labelFormat.Text = "-";
            this.labelLogin.Text = "-";
            this.labelBarcode.Text = "-";

            this.labelCOM1Baudrate.Text = "-";
            this.labelCOM1Mode.Text = "-";
            this.labelCOM3Baudrate.Text = "-";
            this.labelCOM3Mode.Text = "-";
            this.labelCOM4Baudrate.Text = "-";
            this.labelCOM4Mode.Text = "-";
            this.labelOperatingMode.Text = "-";
            this.labelCommunicationMode.Text = "-";
            this.labelIPConfiguration.Text = "-";
            this.labelIPAddress.Text = "-";
            this.labelSubnetMask.Text = "-";
            this.labelGateWay.Text = "-";
            this.labelServerPort.Text = "-";
            this.labelClientServerIP.Text = "-";
            this.labelClientServerPort.Text = "-"; 
            #endregion

            #region ForeColor
            this.label996Under.ForeColor = Color.White;
            this.label996Over.ForeColor = Color.White;
            this.label996Tare.ForeColor = Color.White;
            this.label996Using.ForeColor = Color.White;
            this.label997Under.ForeColor = Color.White;
            this.label997Over.ForeColor = Color.White;
            this.label997Tare.ForeColor = Color.White;
            this.label997Using.ForeColor = Color.White;
            this.label998Under.ForeColor = Color.White;
            this.label998Over.ForeColor = Color.White;
            this.label998Tare.ForeColor = Color.White;
            this.label998Using.ForeColor = Color.White;
            this.label999Under.ForeColor = Color.White;
            this.label999Over.ForeColor = Color.White;
            this.label999Tare.ForeColor = Color.White;
            this.label999Using.ForeColor = Color.White;
            this.label1000Under.ForeColor = Color.White;
            this.label1000Over.ForeColor = Color.White;
            this.label1000Tare.ForeColor = Color.White;
            this.label1000Using.ForeColor = Color.White;

            this.labelOPT1SampleNumber.ForeColor = Color.White;
            this.labelOPT1DelayNumber.ForeColor = Color.White;
            this.labelOPT1PulseWidth.ForeColor = Color.White;
            this.labelOPT1Using.ForeColor = Color.White;
            this.labelOPT1FeedbackOver.ForeColor = Color.White;
            this.labelOPT1FeedbackUnder.ForeColor = Color.White;

            this.labelOPT2Port.ForeColor = Color.White;
            this.labelOPT2DelayTime1.ForeColor = Color.White;
            this.labelOPT2DelayTime2.ForeColor = Color.White;

            this.labelBuzzerOn.ForeColor = Color.White;
            this.labelChattering.ForeColor = Color.White;
            this.labelRelay.ForeColor = Color.White;
            this.labelOptionBoard.ForeColor = Color.White;
            this.labelEquipmentType.ForeColor = Color.White;
            this.labelPIN8.ForeColor = Color.White;
            this.labelPIN7.ForeColor = Color.White;
            this.labelPIN6.ForeColor = Color.White;
            this.labelPIN5.ForeColor = Color.White;
            this.labelPIN4.ForeColor = Color.White;
            this.labelPIN3.ForeColor = Color.White;
            this.labelPhotoB.ForeColor = Color.White;

            this.labelEquipmentID.ForeColor = Color.White;
            this.labelLanguage.ForeColor = Color.White;
            this.labelExtension.ForeColor = Color.White;
            this.labelFormat.ForeColor = Color.White;
            this.labelLogin.ForeColor = Color.White;
            this.labelBarcode.ForeColor = Color.White;

            this.labelCOM1Baudrate.ForeColor = Color.White;
            this.labelCOM1Mode.ForeColor = Color.White;
            this.labelCOM3Baudrate.ForeColor = Color.White;
            this.labelCOM3Mode.ForeColor = Color.White;
            this.labelCOM4Baudrate.ForeColor = Color.White;
            this.labelCOM4Mode.ForeColor = Color.White;
            this.labelOperatingMode.ForeColor = Color.White;
            this.labelCommunicationMode.ForeColor = Color.White;
            this.labelIPConfiguration.ForeColor = Color.White;
            this.labelIPAddress.ForeColor = Color.White;
            this.labelSubnetMask.ForeColor = Color.White;
            this.labelGateWay.ForeColor = Color.White;
            this.labelServerPort.ForeColor = Color.White;
            this.labelClientServerIP.ForeColor = Color.White;
            this.labelClientServerPort.ForeColor = Color.White;
            #endregion
        }
        private string ReturnExternalOutput(int mode)
        {
            string temp = "None";

            switch (mode)
            {
                case (int)DataStore.ExternalInputMode.IN0_None:
                    temp = "None";
                    break;
                case (int)DataStore.ExternalInputMode.IN1_Metal:
                    temp = "Metal";
                    break;
                case (int)DataStore.ExternalInputMode.IN2_START:
                    temp = "START";
                    break;
                case (int)DataStore.ExternalInputMode.IN3_STOP:
                    temp = "STOP";
                    break;
                case (int)DataStore.ExternalInputMode.IN4_DischargeSorterA:
                    temp = "DischargeA";
                    break;
                case (int)DataStore.ExternalInputMode.IN5_Air:
                    temp = "Air";
                    break;
                case (int)DataStore.ExternalInputMode.IN6_Door:
                    temp = "Door";
                    break;
                case (int)DataStore.ExternalInputMode.IN7_Stopper:
                    temp = "Stopper";
                    break;
                case (int)DataStore.ExternalInputMode.IN8_Windproof:
                    temp = "Windproof";
                    break;
                case (int)DataStore.ExternalInputMode.IN9_ExternalOperation:
                    temp = "Ex-Operation";
                    break;
                case (int)DataStore.ExternalInputMode.IN10_DispensorEntry1:
                    temp = "Dispensor1";
                    break;
                case (int)DataStore.ExternalInputMode.IN11_DispensorEntry2:
                    temp = "Dispensor2";
                    break;
                case (int)DataStore.ExternalInputMode.IN12_StackUp:
                    temp = "StackUp";
                    break;
                case (int)DataStore.ExternalInputMode.IN13_ExNG1:
                    temp = "ExNG1";
                    break;
                case (int)DataStore.ExternalInputMode.IN14_ExNG2:
                    temp = "ExNG2";
                    break;
                case (int)DataStore.ExternalInputMode.IN15_ExInputCheck:
                    temp = "Ex-Input";
                    break;
                case (int)DataStore.ExternalInputMode.IN16_DischargeSorterB:
                    temp = "DischargeB";
                    break;
                default:
                    temp = "None";
                    break;
            }

            return temp;
        }
        private void CheckCompareBoardLCDValue(SystemInformation3 item)
        {
            Collection<ProductItem> productItem = new Collection<ProductItem>(); 
            for (int i = 0; i < 5; i++)
                productItem.Add(new ProductItem());
            for (int i = 0; i < 5; i++)
                productItem[i] = this.ParentForm.ParentForm.ChildFormMenu.CenterBasicProduct.ControlRandomMode.CollectionRandomItem[i];

            if (productItem[0].UnderRange != item.Random1Under)
                this.label996Under.ForeColor = Color.Red;
            if (productItem[0].OverRange != item.Random1Over)
                this.label996Over.ForeColor = Color.Red;
            if (productItem[0].TareRange != item.Random1Tare)
                this.label996Tare.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.SystemConfig2.IsGroup1UsingRandomMode != Convert.ToBoolean(item.Random1Using))
                this.label996Using.ForeColor = Color.Red;

            if (productItem[1].UnderRange != item.Random2Under)
                this.label997Under.ForeColor = Color.Red;
            if (productItem[1].OverRange != item.Random2Over)
                this.label997Over.ForeColor = Color.Red;
            if (productItem[1].TareRange != item.Random2Tare)
                this.label997Tare.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.SystemConfig2.IsGroup2UsingRandomMode != Convert.ToBoolean(item.Random2Using))
                this.label997Using.ForeColor = Color.Red;

            if (productItem[2].UnderRange != item.Random3Under)
                this.label998Under.ForeColor = Color.Red;
            if (productItem[2].OverRange != item.Random3Over)
                this.label998Over.ForeColor = Color.Red;
            if (productItem[2].TareRange != item.Random3Tare)
                this.label998Tare.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.SystemConfig2.IsGroup3UsingRandomMode != Convert.ToBoolean(item.Random3Using))
                this.label998Using.ForeColor = Color.Red;

            if (productItem[3].UnderRange != item.Random4Under)
                this.label999Under.ForeColor = Color.Red;
            if (productItem[3].OverRange != item.Random4Over)
                this.label999Over.ForeColor = Color.Red;
            if (productItem[3].TareRange != item.Random4Tare)
                this.label999Tare.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.SystemConfig2.IsGroup4UsingRandomMode != Convert.ToBoolean(item.Random4Using))
                this.label999Using.ForeColor = Color.Red;

            if (productItem[4].UnderRange != item.Random5Under)
                this.label1000Under.ForeColor = Color.Red;
            if (productItem[4].OverRange != item.Random5Over)
                this.label1000Over.ForeColor = Color.Red;
            if (productItem[4].TareRange != item.Random5Tare)
                this.label1000Tare.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.SystemConfig2.IsGroup5UsingRandomMode != Convert.ToBoolean(item.Random5Using))
                this.label1000Using.ForeColor = Color.Red;

            if (this.ParentForm.ParentForm.CurrentSystemParameter2.OPT1SamplingCount != item.OPT1SampleNumber)
                this.labelOPT1SampleNumber.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentSystemParameter2.OPT1DelayCount != item.OPT1DelayNumber)
                this.labelOPT1DelayNumber.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentSystemParameter2.OPT1PulseWidth != item.OPT1PulseWidth)
                this.labelOPT1PulseWidth.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentSystemParameter2.OPT1IsWeightSetting != item.OPT1Using)
                this.labelOPT1Using.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentSystemParameter2.OPT1OverRange != item.OPT1OverRange)
                this.labelOPT1FeedbackOver.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentSystemParameter2.OPT1UnderRange != item.OPT1UnderRange)
                this.labelOPT1FeedbackUnder.ForeColor = Color.Red;

            if (this.ParentForm.ParentForm.CurrentSystemParameter2.OPT2Port != item.OPT2Port)
                this.labelOPT2Port.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentSystemParameter2.OPT2DelayTime1 != item.OPT2Delay1)
                this.labelOPT2DelayTime1.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentSystemParameter2.OPT2DelayTime2 != item.OPT2Delay2)
                this.labelOPT2DelayTime2.ForeColor = Color.Red;

            if (this.ParentForm.ParentForm.CurrentSystemParameter1.BuzzerOnTime != item.BuzzerONTime)
                this.labelBuzzerOn.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentSystemParameter1.Chattering != item.Chattering)
                this.labelChattering.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentSystemParameter1.RelayOnTime != item.Relay)
                this.labelRelay.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentSystemParameter1.OptionBoard != item.OptionBoard)
                this.labelOptionBoard.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentSystemParameter1.EquipmentType != item.EquipmentType)
                this.labelEquipmentType.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentSystemParameter1.PI8 != int.Parse(item.PI8))
                this.labelPIN8.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentSystemParameter1.PI7 != int.Parse(item.PI7))
                this.labelPIN7.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentSystemParameter1.PI6 != int.Parse(item.PI6))
                this.labelPIN6.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentSystemParameter1.PI5 != int.Parse(item.PI5))
                this.labelPIN5.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentSystemParameter1.PI4 != int.Parse(item.PI4))
                this.labelPIN4.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentSystemParameter1.PI3 != int.Parse(item.PI3))
                this.labelPIN3.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentSystemParameter1.PI2 != int.Parse(item.PhotoB))
                this.labelPhotoB.ForeColor = Color.Red;
        }
        public void UpdateParameter1Display(SystemInformation3 item)
        {
            int temp = 0;

            // Random Mode
            this.label996Under.Text = Helper.StringToDecimalPlaces(item.Random1Under, this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces);
            this.label996Over.Text = Helper.StringToDecimalPlaces(item.Random1Over, this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces);
            this.label996Tare.Text = Helper.StringToDecimalPlaces(item.Random1Tare, this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces);
            temp = int.Parse(item.Random1Using);
            if (temp == 1)
                this.label996Using.Text = "ON";
            else
                this.label996Using.Text = "OFF";

            this.label997Under.Text = Helper.StringToDecimalPlaces(item.Random2Under, this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces);
            this.label997Over.Text = Helper.StringToDecimalPlaces(item.Random2Over, this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces);
            this.label997Tare.Text = Helper.StringToDecimalPlaces(item.Random2Tare, this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces);
            temp = int.Parse(item.Random2Using);
            if (temp == 1)
                this.label997Using.Text = "ON";
            else
                this.label997Using.Text = "OFF";

            this.label998Under.Text = Helper.StringToDecimalPlaces(item.Random3Under, this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces);
            this.label998Over.Text = Helper.StringToDecimalPlaces(item.Random3Over, this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces);
            this.label998Tare.Text = Helper.StringToDecimalPlaces(item.Random3Tare, this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces);
            temp = int.Parse(item.Random3Using);
            if (temp == 1)
                this.label998Using.Text = "ON";
            else
                this.label998Using.Text = "OFF";

            this.label999Under.Text = Helper.StringToDecimalPlaces(item.Random4Under, this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces);
            this.label999Over.Text = Helper.StringToDecimalPlaces(item.Random4Over, this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces);
            this.label999Tare.Text = Helper.StringToDecimalPlaces(item.Random4Tare, this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces);
            temp = int.Parse(item.Random4Using);
            if (temp == 1)
                this.label999Using.Text = "ON";
            else
                this.label999Using.Text = "OFF";

            this.label1000Under.Text = Helper.StringToDecimalPlaces(item.Random5Under, this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces);
            this.label1000Over.Text = Helper.StringToDecimalPlaces(item.Random5Over, this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces);
            this.label1000Tare.Text = Helper.StringToDecimalPlaces(item.Random5Tare, this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces);
            temp = int.Parse(item.Random5Using);
            if (temp == 1)
                this.label1000Using.Text = "ON";
            else
                this.label1000Using.Text = "OFF";
        }
        public void UpdateParameter2Display(SystemInformation3 item)
        {
            int temp = 0;

            #region OPT1
            this.labelOPT1SampleNumber.Text = item.OPT1SampleNumber;
            this.labelOPT1DelayNumber.Text = item.OPT1DelayNumber;
            temp = int.Parse(item.OPT1PulseWidth);
            switch (temp)
            {
                case 0:
                    this.labelOPT1PulseWidth.Text = "2";
                    break;
                case 1:
                    this.labelOPT1PulseWidth.Text = "4";
                    break;
                case 2:
                    this.labelOPT1PulseWidth.Text = "6";
                    break;
                case 3:
                    this.labelOPT1PulseWidth.Text = "8";
                    break;
                case 4:
                    this.labelOPT1PulseWidth.Text = "10";
                    break;
                default:
                    this.labelOPT1PulseWidth.Text = "6";
                    break;
            }

            temp = int.Parse(item.OPT1Using);
            if(temp == 1)
                this.labelOPT1Using.Text = "ON";
            else
                this.labelOPT1Using.Text = "OFF";
            this.labelOPT1FeedbackOver.Text = Helper.StringToDecimalPlaces(item.OPT1OverRange, this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces);
            this.labelOPT1FeedbackUnder.Text = Helper.StringToDecimalPlaces(item.OPT1UnderRange, this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces);
            #endregion

            #region OPT2
            temp = int.Parse(item.OPT2Port);
            if(temp == 1)
                this.labelOPT2Port.Text = "5, 6";
            else if(temp == 2)
                this.labelOPT2Port.Text = "7, 8";
            else
                this.labelOPT2Port.Text = "None";
            this.labelOPT2DelayTime1.Text = item.OPT2Delay1;
            this.labelOPT2DelayTime2.Text = item.OPT2Delay2;
            #endregion

            #region Equipment setting
            this.labelBuzzerOn.Text = item.BuzzerONTime;
            this.labelChattering.Text = item.Chattering;
            this.labelRelay.Text = item.Relay;

            temp = int.Parse(item.OptionBoard);
            if(temp == 1)
                this.labelOptionBoard.Text = "OPT1";
            else if(temp == 2)
                this.labelOptionBoard.Text = "OPT2";
            else
                this.labelOptionBoard.Text = "None";

            temp = int.Parse(item.EquipmentType);
            switch (temp)
            {
                case 0:
                    this.labelEquipmentType.Text = "Conveyer";
                    break;
                case 4:
                    this.labelEquipmentType.Text = "Updown";
                    break;
                case 6:
                    this.labelEquipmentType.Text = "Stop-W";
                    break;
                default:
                    this.labelEquipmentType.Text = "Conveyer";
                    break;
            }

            this.labelPIN8.Text = this.ReturnExternalOutput(int.Parse(item.PI8));
            this.labelPIN7.Text = this.ReturnExternalOutput(int.Parse(item.PI7));
            this.labelPIN6.Text = this.ReturnExternalOutput(int.Parse(item.PI6));
            this.labelPIN5.Text = this.ReturnExternalOutput(int.Parse(item.PI5));
            this.labelPIN4.Text = this.ReturnExternalOutput(int.Parse(item.PI4));
            this.labelPIN3.Text = this.ReturnExternalOutput(int.Parse(item.PI3));
            this.labelPhotoB.Text = this.ReturnExternalOutput(int.Parse(item.PhotoB));
            #endregion

            this.CheckCompareBoardLCDValue(item);
        }

        public void DisplayRefresh(SystemStatus status)
        {
            this.ParentForm.ParentForm.CurrentSystemStatus.CurrentDisplay = DataStore.DisplayStore.InforSystem3;
            this.ParentForm.ParentForm.SetDisplayMode(DataStore.DisplayMode.Menu);

            this.InitialLabel();
        }
        #endregion

        #region Event Handler
        private void buttonPrevious_Click(object sender, EventArgs e)
        {
            this.ParentForm.CenterInforSystem2.DisplayRefresh(this.ParentForm.ParentForm.CurrentSystemStatus);
            this.ParentForm.CenterInforSystem2.BringToFront();
        }

        private void buttonCapture_Click(object sender, EventArgs e)
        {
            string filePath = "";
            Bitmap bitMap = new Bitmap(800, 480);

            bitMap = IntechGraphics.CopyFromScreen();
            filePath = string.Format("{0}{1}_SystemInfo2.jpg",
                this.ParentForm.ParentForm.PathDataBackupFolder, this.ParentForm.ParentForm.SystemConfig1.SerialNumber);
            bitMap.Save(filePath, ImageFormat.Jpeg);
        }

        private void buttonLoad_Click(object sender, EventArgs e)
        {
            this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Read, CommunicationID.MainBoard, CommunicationAddress.SystemInformationRead3, "");

            #region Equipment setting
            this.labelEquipmentID.Text = this.ParentForm.ParentForm.SystemConfig1.EquipmentID.ToString();
            this.labelLanguage.Text = this.ParentForm.ParentForm.SystemConfig1.Language.ToString();
            if(this.ParentForm.ParentForm.SystemConfig2.FileNameExtension == 1)
                this.labelExtension.Text = "TXT";
            else
                this.labelExtension.Text = "CSV";
            if (this.ParentForm.ParentForm.SystemConfig1.DatabackupFormat == 1)
                this.labelFormat.Text = "OPT1"; // 종근당 리젝데이터 있는 포맷
            else
                this.labelFormat.Text = "STD1";
            if (this.ParentForm.ParentForm.SystemConfig1.IsLogin == true)
                this.labelLogin.Text = "ON";
            else
                this.labelLogin.Text = "OFF";
            if (this.ParentForm.ParentForm.SystemConfig2.Barcode != 0)
                this.labelBarcode.Text = this.ParentForm.ParentForm.SystemConfig2.Barcode.ToString();
            else
                this.labelBarcode.Text = "OFF";

            #endregion

            #region Serial
            this.labelCOM1Baudrate.Text = this.ReturnBaudrateName(this.ParentForm.ParentForm.SystemConfig1.SerialCOM1BaudRate);
            this.labelCOM1Mode.Text = this.ReturnCommunicationModeName(this.ParentForm.ParentForm.SystemConfig1.SerialCOM1Mode);
            this.labelCOM3Baudrate.Text = this.ReturnBaudrateName(this.ParentForm.ParentForm.SystemConfig1.SerialCOM3BaudRate);
            this.labelCOM3Mode.Text = this.ReturnCommunicationModeName(this.ParentForm.ParentForm.SystemConfig1.SerialCOM3Mode);
            this.labelCOM4Baudrate.Text = this.ReturnBaudrateName(this.ParentForm.ParentForm.SystemConfig1.SerialCOM4BaudRate);
            this.labelCOM4Mode.Text = this.ReturnCommunicationModeName(this.ParentForm.ParentForm.SystemConfig1.SerialCOM4Mode);
            #endregion

            #region Ethernet
            if(this.ParentForm.ParentForm.SystemConfig2.EthernetOperationMode == 1)
                this.labelOperatingMode.Text = "Server";
            else if (this.ParentForm.ParentForm.SystemConfig2.EthernetOperationMode == 2)
                this.labelOperatingMode.Text = "Client";
            else
                this.labelOperatingMode.Text = "None";
            this.labelCommunicationMode.Text = this.ReturnCommunicationModeName(this.ParentForm.ParentForm.SystemConfig2.EthernetCommMode);
            if (this.ParentForm.ParentForm.smartConfigs.IPSettings.DHCPEnable == 0)
                this.labelIPConfiguration.Text = "Static";
            else
                this.labelIPConfiguration.Text = "DHCP";
            this.labelIPAddress.Text = this.ParentForm.ParentForm.smartConfigs.IPSettings.DeviceIP;
            this.labelSubnetMask.Text = this.ParentForm.ParentForm.smartConfigs.IPSettings.SubNetMask;
            this.labelGateWay.Text = this.ParentForm.ParentForm.smartConfigs.IPSettings.GateWay;
            this.labelServerPort.Text = this.ParentForm.ParentForm.SystemConfig2.EthernetLocalPort.ToString();
            this.labelClientServerIP.Text = this.ParentForm.ParentForm.SystemConfig2.EthernetAddress;
            this.labelClientServerPort.Text = this.ParentForm.ParentForm.SystemConfig2.EthernetHostPort.ToString();
            #endregion
        }
        #endregion
    }
}
