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

using SmartX;
using InModbus;
using INT89DB_26.DialogForms;
using INT89DB_26_ImageDll;
using INT89DB_26.Int_Modbus;

namespace INT89DB_26.Forms
{
    public partial class FormMain : Form
    {
        #region Field
        private SmartX.SmartSplash SmartSplashProgramLoad;
        private int CommunicationCheckCount;
        public bool IsCommunicationLogOpen;
        public bool IsAdcLogOpen;
        private bool FlagADCValueWrite;
        public bool IsBootingComplete;
        public int BufferSmartUart; // Buffer size 정의
        public bool IsCom3LogOpen;  //Serial3 Log

        // Motor Download 통신용 변수
        public int LineNum;
        // LineNum 현재값 저장
        public int CurrentLineNum;
        // Timeout 설정을 위한 변수
        public int TimeOut;

        // 파일 위치
        private string m_PathLaunchFolder;
        private string m_PathSystemFileFolder1;
        private string m_PathSystemFileFolder2;
        private string m_PathDataBackupFolder;
        private string m_PathProgramSaveFolder;

        // 로그온 색상
        public Color ColorLogOff;
        public Color ColorLogOn;

        // Form 생성
        public FormMainDisplay ChildFormMainDisplay;
        public FormMenu ChildFormMenu;
        public FormCalibration ChildFormCalibration;
        public FormSystemSetting ChildFormSystemSetting;
        public FormIOTest ChildFormIOTest;
        public FormEquipmentSetting ChildFormEquipmentSetting;
        public FormDataBackup ChildFormDataBackup;
        public FormConfiguration ChildFormConfiguration;
        public FormTimeSetting ChildFormTimeSetting;
        public FormInformation ChildFormInformation;
        public FormFactoryReset ChildFormFactoryInitialize;
        public FormProgramUpdate ChildFormProgramUpdate;
        public FormEquipmentTest ChildFormEquipmentTest;
        public FormUserSetting ChildFormUserSetting;
        public FormCommunication ChildFormCommunication;
        public FormOptionSetting ChildFormOptionSetting;

        // System Configuration
        public SystemConfigurationItem SystemConfig;
        // 현재 선택 된 품목
        public ProductItem CurrentProductItem;
        // 현재 선택 된 판정 설정 값
        public JudgmentSetItem CurrentJudgmentSetItem;
        // 중량 조정 설정값
        public CalibrationItem CurrentCalibrationItem;
        // 제로 파라미터 설정값
        public ZeroParameterItem CurrentZeroParameterItem;
        // 옵션 파라미터 설정값
        public OptionParameterItem CurrentOptionParameterItem;
        // User
        public CollectionUser CurrentCollectionUser;
        // 현재 선택 된 피드백 설정 값
        public FeedbackConfiguration CurrentFeedbackItem;
        // 열별 중량 데이터
        public Collection<WeightData> CollectionWeightData;
        // 장비테스트모드 열별 중량 데이터
        public Collection<WeightData> CollectionWeightDataTest;
        // 장비 구동 상태
        private DataStore.EquipmentStatus m_EquipmentStatus;
        // 알람
        private AlarmList CurrentAlarmList;

        // Collection
        private Collection<int> CollectionGraphData;                    // 판정설정 그래프 데이터
        private Collection<string> CollectionIOTest_InputData;          // IO Test Input 데이터 취합
        private Collection<string> CollectionZeroParameterRange;        // 자동영점 - 범위
        private Collection<string> CollectionZeroParameterTime;         // 자동영점 - 시간
        private Collection<string> CollectionZeroParameterVariates;     // 자동영점 - 변량
        private Collection<string> CollectionBalanceWeight;             // 분동중량값
        private Collection<string> CollectionMaxWeight;                 // 분동중량값
        private Collection<string> CollectionDigit;                     // 한눈의값
        private Collection<string> CollectionFilter;                    // 필터
        private Collection<string> CollectionVersion;                   // 프로그램 버전
        public Collection<string> CollectionProductName;                // 품목명 리스트
        public Collection<FeedBackSystem> CollectionFeedbackStatus;    // 피드백 시스템 - option 

        // Ethernet
        public bool IsEthernetThreadStop;
        private bool IsEthernetTransferData;

        public object EthernetTransferData;

        private TcpClient EthernetTcpClient;

        private NetworkStream EthernetNetStream;
        private StreamReader EthernetStmReader;
        private StreamWriter EthernetStmWriter;

        private delegate void TransferDataByteArrayCallback(byte[] byteArray);
        private delegate void TransferDataStringCallback(string strtext);
        private delegate void TextStatusCallback(string strtext);
        private delegate void UIControlCallback(bool bEnable);
        private delegate void UIServerStatusCallback(bool bEnable);

        // Modbus
        private bool IsModbusCommonDataSend; // Modbus 공통 데이터 Start 시 한번 전송용
        public Modbus_30000_Data Current30000ModbusData;
        public Modbus_40000_Data Current40000ModbusData;
        public Modbus Modbus;
        #endregion

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

            // 프로그램 로딩 이미지
            this.SmartSplashProgramLoad = new SmartX.SmartSplash();
            this.SmartSplashProgramLoad.CenterPosition = true;
            this.SmartSplashProgramLoad.AnimationInterval = 100;
            this.SmartSplashProgramLoad.LoadingImagePathname = "SmartLoading3";
            this.SmartSplashProgramLoad.Start();
        }
        #endregion

        #region Property
        public string PathLaunchFolder
        {
            get { return this.m_PathLaunchFolder; }
            set { this.m_PathLaunchFolder = value; }
        }
        public string PathSystemFileFolder1
        {
            get { return this.m_PathSystemFileFolder1; }
            set { this.m_PathSystemFileFolder1 = value; }
        }
        public string PathSystemFileFolder2
        {
            get { return this.m_PathSystemFileFolder2; }
            set { this.m_PathSystemFileFolder2 = value; }
        }
        public string PathDataBackupFolder
        {
            get { return this.m_PathDataBackupFolder; }
            set { this.m_PathDataBackupFolder = value; }
        }
        public string PathProgramSaveFolder
        {
            get { return this.m_PathProgramSaveFolder; }
            set { this.m_PathProgramSaveFolder = value; }
        }

        public DataStore.EquipmentStatus EquipmentStatus
        {
            get { return this.m_EquipmentStatus; }
            private set { this.m_EquipmentStatus = value; }
        }
        #endregion

        #region Method
        private void CreateForm()
        {
            this.ChildFormMainDisplay = new FormMainDisplay(this);
            this.ChildFormMenu = new FormMenu(this);
            this.ChildFormCommunication = new FormCommunication(this);
            this.ChildFormCalibration = new FormCalibration(this);
            this.ChildFormSystemSetting = new FormSystemSetting(this);
            this.ChildFormIOTest = new FormIOTest(this);
            this.ChildFormEquipmentSetting = new FormEquipmentSetting(this);
            this.ChildFormDataBackup = new FormDataBackup(this);
            this.ChildFormConfiguration = new FormConfiguration(this);
            this.ChildFormTimeSetting = new FormTimeSetting(this);
            this.ChildFormInformation = new FormInformation(this);
            this.ChildFormFactoryInitialize = new FormFactoryReset(this);
            this.ChildFormProgramUpdate = new FormProgramUpdate(this);
            this.ChildFormEquipmentTest = new FormEquipmentTest(this);
            this.ChildFormUserSetting = new FormUserSetting(this);
            this.ChildFormOptionSetting = new FormOptionSetting(this);

            this.smartForm.MainForm = this;

            this.smartForm.AddChildForm(this.ChildFormMainDisplay);
            this.smartForm.AddChildForm(this.ChildFormMenu);
            this.smartForm.AddChildForm(this.ChildFormCommunication);
            this.smartForm.AddChildForm(this.ChildFormCalibration);
            this.smartForm.AddChildForm(this.ChildFormSystemSetting);
            this.smartForm.AddChildForm(this.ChildFormIOTest);
            this.smartForm.AddChildForm(this.ChildFormEquipmentSetting);
            this.smartForm.AddChildForm(this.ChildFormDataBackup);
            this.smartForm.AddChildForm(this.ChildFormConfiguration);
            this.smartForm.AddChildForm(this.ChildFormTimeSetting);
            this.smartForm.AddChildForm(this.ChildFormInformation);
            this.smartForm.AddChildForm(this.ChildFormFactoryInitialize);
            this.smartForm.AddChildForm(this.ChildFormProgramUpdate);
            this.smartForm.AddChildForm(this.ChildFormEquipmentTest);
            this.smartForm.AddChildForm(this.ChildFormUserSetting);
            this.smartForm.AddChildForm(this.ChildFormOptionSetting);
        }
        private void CreateCollection()
        {
            this.CollectionWeightData = new Collection<WeightData>();
            this.CollectionWeightDataTest = new Collection<WeightData>();
            this.CollectionGraphData = new Collection<int>();
            this.CollectionIOTest_InputData = new Collection<string>();
            this.CollectionZeroParameterRange = new Collection<string>();
            this.CollectionZeroParameterTime = new Collection<string>();
            this.CollectionZeroParameterVariates = new Collection<string>();
            this.CollectionBalanceWeight = new Collection<string>();
            this.CollectionMaxWeight = new Collection<string>();
            this.CollectionDigit = new Collection<string>();
            this.CollectionFilter = new Collection<string>();
            this.CollectionVersion = new Collection<string>();
            this.CollectionProductName = new Collection<string>();
            this.CollectionFeedbackStatus = new Collection<FeedBackSystem>();

            this.CollectionWeightData.Clear();
            this.CollectionWeightDataTest.Clear();
            this.CollectionGraphData.Clear();
            this.CollectionIOTest_InputData.Clear();
            this.CollectionZeroParameterRange.Clear();
            this.CollectionZeroParameterTime.Clear();
            this.CollectionZeroParameterVariates.Clear();
            this.CollectionBalanceWeight.Clear();
            this.CollectionMaxWeight.Clear();
            this.CollectionDigit.Clear();
            this.CollectionFilter.Clear();
            this.CollectionVersion.Clear();
            this.CollectionProductName.Clear();

            for (int i = 0; i < 6; i++)
            {
                this.CollectionWeightData.Add(new WeightData());
                this.CollectionWeightDataTest.Add(new WeightData());
                this.CollectionZeroParameterRange.Add("");
                this.CollectionZeroParameterTime.Add("");
                this.CollectionZeroParameterVariates.Add("");
                this.CollectionBalanceWeight.Add("");
                this.CollectionMaxWeight.Add("");
                this.CollectionDigit.Add("");
                this.CollectionFilter.Add("");
                this.CollectionFeedbackStatus.Add(new FeedBackSystem());
            }

            for (int i = 0; i < 7; i++)
            {
                this.CollectionVersion.Add("");
            }

            for (int i = 0; i < 100; i++)
            {
                this.CollectionGraphData.Add(0);
            }

            for (int i = 0; i < 16; i++)
            {
                this.CollectionIOTest_InputData.Add("0");
            }
        }
        private void DefaultSetting1()
        {
            this.LineNum = 1;
            this.CurrentLineNum = 0;
            this.TimeOut = 0;
            this.CommunicationCheckCount = 0;
            this.IsCommunicationLogOpen = false;
            this.IsAdcLogOpen = false;
            this.FlagADCValueWrite = false;
            this.IsBootingComplete = false;
            this.PathLaunchFolder = "SD Card\\";
            this.PathSystemFileFolder1 = this.PathLaunchFolder + "SystemFile1\\";
            this.PathSystemFileFolder2 = this.PathLaunchFolder + "SystemFile2\\";
            this.PathDataBackupFolder = this.PathLaunchFolder + "DataBackup\\";
            this.PathProgramSaveFolder = this.PathLaunchFolder + "Program\\";
            this.EquipmentStatus = DataStore.EquipmentStatus.Stop;
            this.BufferSmartUart = 1000000; // 1MB
            this.ColorLogOff = Color.Red;
            this.ColorLogOn = Color.Yellow;
            this.IsModbusCommonDataSend = false;
            this.IsCom3LogOpen = false;

            this.SystemConfig = new SystemConfigurationItem();
            this.CurrentProductItem = new ProductItem();
            this.CurrentJudgmentSetItem = new JudgmentSetItem();
            this.CurrentCalibrationItem = new CalibrationItem();
            this.CurrentZeroParameterItem = new ZeroParameterItem();
            this.CurrentOptionParameterItem = new OptionParameterItem();
            this.CurrentCollectionUser = new CollectionUser();
            this.CurrentAlarmList = new AlarmList();
            this.CurrentFeedbackItem = new FeedbackConfiguration();
            this.Current30000ModbusData = new Modbus_30000_Data();
            this.Current40000ModbusData = new Modbus_40000_Data();
            this.Modbus = new Modbus();

            // SystemFile1 폴더 생성
            if (Directory.Exists(this.PathSystemFileFolder1) == false)
                Directory.CreateDirectory(this.PathSystemFileFolder1);

            // SystemFile2 폴더 생성
            if (Directory.Exists(this.PathSystemFileFolder2) == false)
                Directory.CreateDirectory(this.PathSystemFileFolder2);

            // DataBackup 폴더 생성
            if (Directory.Exists(this.PathDataBackupFolder) == false)
                Directory.CreateDirectory(this.PathDataBackupFolder);
        }
        private void DefaultSetting2()
        {
            // 이더넷
            if (this.SystemConfig.IsEthernetEnable == true)
            {
                // Ethernet Static setting
                if (this.smartConfigs.IPSettings.DHCPEnable == 1)
                {
                    this.smartConfigs.IPSettings.DHCPEnable = 0;

                    this.smartConfigs.IPSettings.DeviceIP = "192.168.11.205";
                    this.smartConfigs.IPSettings.SubNetMask = "255.255.255.0";
                    this.smartConfigs.IPSettings.GateWay = "192.168.11.1";

                    this.smartConfigs.IPSettings.Save();
                    this.smartConfigs.IPSettings.SetApply();
                }

                if (this.SystemConfig.EthernetOperationMode == 1)
                {
                    try
                    {
                        if (string.Compare(this.smartConfigs.IPSettings.DeviceIP, "0.0.0.0") != 0)
                            this.EthernetServerStart();

                        if (this.SystemConfig.EthernetOperationMode == 1 && this.smartTCPMultiServer.IsStart == true)
                            this.ChildFormMainDisplay.TimerServer(true);
                    }
                    catch
                    {
                    }
                }
                else if (this.SystemConfig.EthernetOperationMode == 2)
                    this.EthernetClientDisconnect();
            }

        }
        private void TrasferSystemParameter(SystemConfigurationItem item)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(Helper.StringZeroFillDigits4(item.EquipmentID.ToString()));
            sb.Append(Helper.StringZeroFillDigits4(item.EquipmentColumns.ToString()));
            sb.Append(Helper.StringZeroFillDigits4(item.InverterQTY.ToString()));

            this.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._9047_ParameterSystem, sb.ToString());
        }
        public void TransferProductParameter(int productNumber)
        {
            string value = "";

            StringBuilder sb = new StringBuilder();
            ProductItem pItem = new ProductItem();
            JudgmentSetItem jItem = new JudgmentSetItem();

            this.LoadProductFile(ref pItem, productNumber - 1);
            this.LoadJudgmentSetFile(ref jItem, productNumber - 1);

            sb.Append(Helper.StringZeroFillDigits4(productNumber.ToString()));
            sb.Append(Helper.StringZeroFillDigits7(pItem.UnderRange));
            sb.Append(Helper.StringZeroFillDigits7(pItem.OverRange));
            sb.Append(Helper.StringZeroFillDigits7(pItem.TareRange));
            value = Helper.DoubleToString(jItem.DynamicCorrection, 7);
            value = value.Replace(".", "");
            sb.Append(Helper.StringZeroFillDigits7(value));
            sb.Append(Helper.StringZeroFillDigits4(jItem.Filter.ToString()));
            sb.Append(Helper.StringZeroFillDigits4(jItem.JudgmentDelayTime.ToString()));
            sb.Append(Helper.StringZeroFillDigits4(jItem.DoubleDelayTime.ToString()));
            sb.Append(Helper.StringZeroFillDigits4(jItem.JudgmentCount.ToString()));
            sb.Append(Helper.StringZeroFillDigits4(jItem.Sorter1Mode.ToString()));
            sb.Append(Helper.StringZeroFillDigits4(jItem.Sorter1DelayTime.ToString()));
            sb.Append(Helper.StringZeroFillDigits4(jItem.Sorter1RunTime.ToString()));
            sb.Append(Helper.StringZeroFillDigits4(jItem.ConveyorSpeed1.ToString()));
            sb.Append(Helper.StringZeroFillDigits4(jItem.ConveyorSpeed2.ToString()));
            sb.Append(Helper.StringZeroFillDigits4(jItem.ConveyorSpeed3.ToString()));
            sb.Append(Helper.StringZeroFillDigits4(jItem.ConveyorSpeed4.ToString()));         

            this.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._9048_ParameterProduct, sb.ToString());
        }

        #region Uart Communication
        private void OpenSmartUartLink()
        {
            string fullPath = "";

            try
            {
                if (this.smartSerialPortLink.IsReadStart == false)
                    this.smartSerialPortLink.Open();
            }
            catch
            {
            }

            #region Test 용 통신 로그
            fullPath = this.PathDataBackupFolder + "Communicationlog.txt";
            this.smartFileCommunicationLog.FilePathName = fullPath;
            //this.smartFileCommunicationLog.Open();
            //this.IsCommunicationLogOpen = true;
            #endregion

            #region ADC 통신 로그
            fullPath = this.PathDataBackupFolder + this.SystemConfig.UsbID.ToString() + "ADC_log.txt";
            this.smartFileAdcLog.FilePathName = fullPath;
            #endregion
        }
        public void CloseSmartUartLink()
        {
            this.smartSerialPortLink.Close();
        }

        private bool SizeCheck(string cmd, string strTemp)
        {
            bool ret = false;
            string dataSize = "";
            int size = 0;

            if (strTemp == null || strTemp.Length == 0)
            {
                ret = false;
                return ret;
            }

            try
            {
                if (cmd == "P")
                    dataSize = strTemp.Substring(14, strTemp.Length - 16);
                else // "S"
                    dataSize = strTemp.Substring(10, strTemp.Length - 12);

                size = int.Parse(strTemp.Substring(6, 4).Trim());
            }
            catch
            {
                ret = false;
                return ret;
            }

            if (dataSize.Length == size)
                ret = true;
            else
                ret = false;

            return ret;
        }
        private bool Checksumcalculator(string strTemp)
        {
            bool ret = false;
            string chkSum = "", dataChksum = "";

            if (strTemp == null || strTemp.Length == 0)
                ret = false;
            else
            {
                chkSum = strTemp.Substring(strTemp.Length - 2, 2);
                dataChksum = Helper.Checksumcalculator(strTemp.Substring(0, strTemp.Length - 2));

                if (chkSum == dataChksum)
                    ret = true;
                else
                    ret = false;
            }

            return ret;
        }

        public int TransferData(string command, string id)
        {
            int ret = 0;
            string chkSum = "cc";
            StringBuilder sb = new StringBuilder();

            sb.Append(command);
            sb.Append(id);

            chkSum = Helper.Checksumcalculator(sb.ToString());

            sb.Append(chkSum);

            if (this.smartSerialPortLink.IsReadStart == true)
                this.smartSerialPortLink.WriteFrame(sb.ToString(), SmartX.SmartSerialPort.CODETYPES.ASCIICODE);

            // 통신 확인 로그
            if (this.IsCommunicationLogOpen == true)
                this.smartFileCommunicationLog.WriteString(string.Format("Send ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, sb.ToString()));

            return ret;
        }
        public int TransferDataStream(string command, string id, string address, string data)
        {
            int ret = 0;
            string chkSum = "cc";
            StringBuilder sb = new StringBuilder();

            sb.Append(command);
            sb.Append(id);
            sb.Append(Helper.StringZeroFillDigits4(data.Length.ToString()));
            sb.Append(address);
            sb.Append(data);

            chkSum = Helper.Checksumcalculator(sb.ToString());

            sb.Append(chkSum);

            if (this.smartSerialPortLink.IsReadStart == true)
                this.smartSerialPortLink.WriteFrame(sb.ToString(), SmartSerialPort.CODETYPES.ASCIICODE);

            // 통신 확인 로그
            if (this.IsCommunicationLogOpen == true)
                this.smartFileCommunicationLog.WriteString(string.Format("Send ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, sb.ToString()));

            return ret;
        }
        private void ReceiveData()
        {
            int ret = 0;
            string strTemp = "";
            byte[] readByte;

            SmartSerialPort.FRAMEDATAREADSTATUS receiveDataState = SmartSerialPort.FRAMEDATAREADSTATUS.EMPTY;

            receiveDataState = this.smartSerialPortLink.ReadQueue(out readByte);
            strTemp = Encoding.Default.GetString(readByte, 0, readByte.Length);

            if ((receiveDataState == SmartSerialPort.FRAMEDATAREADSTATUS.EMPTY) || (receiveDataState == SmartSerialPort.FRAMEDATAREADSTATUS.FAILDATA))
            {
                return;
            }

            try
            {
                switch (strTemp[0])
                {
                    case 'C':
                        if ((ret = this.ReceiveCommandC(strTemp)) != 0)
                            return;
                        break;
                    case 'P':
                        if ((ret = this.ReceiveCommandP(strTemp)) != 0)
                            return;
                        break;
                    case 'S':
                        if ((ret = this.ReceiveCommandS(strTemp)) != 0)
                            return;
                        break;
                    default:
                        break;
                }
            }
            catch
            {
            }
        }

        private int ReceiveCommandC(string strTemp)
        {
            int ret = 0;
            string cmd = "";

            if (this.Checksumcalculator(strTemp) == false)
            {
                // 로그
                if (this.IsCommunicationLogOpen == true)
                    this.smartFileCommunicationLog.WriteString(string.Format("Receive ({0:yyyy-MM-dd HH:mm:ss}): {1} : Receive Command Data CHKSUM Error", DateTime.Now, strTemp));
                return ret = -1;
            }

            // 로그
            if (this.IsCommunicationLogOpen == true)
                this.smartFileCommunicationLog.WriteString(string.Format("Receive ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, strTemp));

            cmd = strTemp.Substring(0, 3);

            switch (cmd)
            {
                case "CI0":
                    this.TrasferSystemParameter(this.SystemConfig);
                    break;
                case "CBS":
                    this.EquipmentStatus = DataStore.EquipmentStatus.Start;

                    // 운전시 중량 0 으로 Clear
                    foreach (WeightData data in this.CollectionWeightData)
                    {
                        data.Weight = 0.0;
                    }

                    // Ethernet Client 연결 시도
                    if (this.SystemConfig.IsEthernetEnable == true)
                    {
                        if (this.SystemConfig.EthernetOperationMode == 2)
                        {
                            this.EthernetClientDisconnect();
                            this.EthernetClientConnect();
                        }
                    }

                    this.Update30000Operation();

                    this.ChildFormMainDisplay.UpdateEquipmentStatusDisplay(this.EquipmentStatus);
                    this.ChildFormSystemSetting.UpdateEquipmentStatusDisplay(this.EquipmentStatus);
                    this.ChildFormEquipmentTest.UpdateEquipmentStatusDisplay(this.EquipmentStatus);
                    break;
                case "CBT":
                    this.EquipmentStatus = DataStore.EquipmentStatus.Stop;

                    // 생산속도 Clear
                    foreach (WeightData data in this.CollectionWeightData)
                    {
                        data.ProductionSpeed = 0;
                        data.IsStart = false;
                    }

                    this.Update30000Operation();

                    this.ChildFormMainDisplay.UpdateEquipmentStatusDisplay(this.EquipmentStatus);
                    this.ChildFormSystemSetting.UpdateEquipmentStatusDisplay(this.EquipmentStatus);
                    this.ChildFormEquipmentTest.UpdateEquipmentStatusDisplay(this.EquipmentStatus);
                    break;
                case "CBE":
                    break;
                case "CBZ":
                    break;
                default:
                    break;
            }

            return ret;
        }
        private int ReceiveCommandP(string strTemp)
        {
            int ret = 0;
            string cmd = "", address = "", lane = "", receiveData = "";

            // SIZE 확인
            if (this.SizeCheck("P", strTemp) == false)
            {
                // 로그
                if (this.IsCommunicationLogOpen == true)
                    this.smartFileCommunicationLog.WriteString(string.Format("Receive ({0:yyyy-MM-dd HH:mm:ss}): {1} : Receive Stream Data SIZE Error", DateTime.Now, strTemp));
                return ret = -1;
            }
            // CHKSUM 확인
            if (this.Checksumcalculator(strTemp) == false)
            {
                // 로그
                if (this.IsCommunicationLogOpen == true)
                    this.smartFileCommunicationLog.WriteString(string.Format("Receive ({0:yyyy-MM-dd HH:mm:ss}): {1} : Receive Stream Data CHKSUM Error", DateTime.Now, strTemp));
                return ret = -1;
            }

            // 로그
            if (this.IsCommunicationLogOpen == true)
                this.smartFileCommunicationLog.WriteString(string.Format("Receive ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, strTemp));

            cmd = strTemp.Substring(0, 3);
            lane = strTemp.Substring(5, 1);
            address = strTemp.Substring(10, 4);
            receiveData = strTemp.Substring(14, strTemp.Length - 16);

            switch (cmd)
            {
                case "PR0":
                    if ((ret = this.ReceiveCommandPR0(lane, address, receiveData)) != 0)
                        return ret = -1;
                    break;
                case "PW0":
                    if ((ret = this.ReceiveCommandPW0(lane, address, receiveData)) != 0)
                        return ret = -1;
                    break;
                case "PB0":
                    if ((ret = this.ReceiveCommandPB0(lane, address, receiveData)) != 0)
                        return ret = -1;
                    break;
                default:
                    break;
            }

            return ret;
        }
        private int ReceiveCommandS(string strTemp)
        {
            int ret = 0;
            string cmd = "", lane = "", receiveData = "";

            // SIZE 확인
            if (this.SizeCheck("S", strTemp) == false)
            {
                // 로그
                if (this.IsCommunicationLogOpen == true)
                    this.smartFileCommunicationLog.WriteString(string.Format("Receive ({0:yyyy-MM-dd HH:mm:ss}): {1} : Receive Stream Data SIZE Error", DateTime.Now, strTemp));
                return ret = -1;
            }
            // CHKSUM 확인
            if (this.Checksumcalculator(strTemp) == false)
            {
                // 로그
                if (this.IsCommunicationLogOpen == true)
                    this.smartFileCommunicationLog.WriteString(string.Format("Receive ({0:yyyy-MM-dd HH:mm:ss}): {1} : Receive Stream Data CHKSUM Error", DateTime.Now, strTemp));
                return ret = -1;
            }

            // 로그
            if (this.IsCommunicationLogOpen == true)
                this.smartFileCommunicationLog.WriteString(string.Format("Receive ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, strTemp));

            cmd = strTemp.Substring(0, 3);
            lane = strTemp.Substring(5, 1);
            receiveData = strTemp.Substring(10, strTemp.Length - 12);

            switch (cmd)
            {
                case "SA0":
                    if ((ret = this.ReceiveCommandSA0(lane, receiveData)) != 0)
                        return ret;
                    break;
                case "SN0":
                    if ((ret = this.ReceiveCommandSN0(lane, receiveData)) != 0)
                        return ret;
                    break;
                case "SR0":
                    if ((ret = this.ReceiveCommandSR0(lane, receiveData)) != 0)
                        return ret;
                    break;
                case "SC0":
                    if ((ret = this.ReceiveCommandSC0(lane, receiveData)) != 0)
                        return ret;
                    break;
                case "SF0":
                    if ((ret = this.ReceiveCommandSF0(lane, receiveData)) != 0)
                        return ret;
                    break;
                case "SG0":
                    if ((ret = this.ReceiveCommandSG0(lane, receiveData)) != 0)
                        return ret;
                    break;
                case "ST0":
                    if ((ret = this.ReceiveCommandST0(lane, receiveData)) != 0)
                        return ret;
                    break;
                default:
                    break;
            }

            return ret;
        }

        // 파라미터 읽기 응답
        private int ReceiveCommandPR0(string lane, string address, string receiveData)
        {
            int ret = 0, iValue = 0;

            try
            {
                switch (address)
                {
                    case "1500":
                        #region Value Assign
                        for (int i = 0; i < this.SystemConfig.EquipmentColumns + 1; i++)
                        {
                            this.CollectionVersion[i] = receiveData.Substring(i * 4, 4);
                        }
                        this.ChildFormInformation.UpdateProgreamVersionDisplay(this.EquipmentStatus, this.CollectionVersion);
                        #endregion
                        break;
                    case "2001":
                        #region Value Assign
                        iValue = int.Parse(receiveData);
                        if (iValue <= 0 || iValue > 1000)
                            return ret = -1;

                        this.SystemConfig.ProductNumber = iValue;

                        #endregion

                        // 최초에 부팅이 완료 되었는지 확인
                        if (this.IsBootingComplete == false)
                            this.IsBootingComplete = true;

                        this.SaveSystemConfigurationFile(this.SystemConfig);

                        this.LoadProductFile(ref this.CurrentProductItem, this.SystemConfig.ProductNumber - 1);
                        this.LoadCounterFile(ref this.CollectionWeightData, this.SystemConfig.ProductNumber - 1);
                        this.LoadJudgmentSetFile(ref this.CurrentJudgmentSetItem, this.SystemConfig.ProductNumber - 1);
                        this.LoadFeedbackItemFile(ref this.CurrentFeedbackItem, this.SystemConfig.ProductNumber - 1);

                        // 생산속도 Clear
                        foreach (WeightData data in this.CollectionWeightData)
                        {
                            data.ProductionSpeed = 0;
                            data.IsStart = false;
                        }

                        if (this.SystemConfig.CurrentForm == DataStore.E_FormStore.FormMainDisplay)
                        {
                            this.ChildFormMainDisplay.UpdateCurrentProductDisplay(this.EquipmentStatus, this.CurrentProductItem, this.CurrentJudgmentSetItem, this.CollectionWeightData);

                            this.ChildFormMainDisplay.ClearRefreshFeedbackDisplay();
                        }
                        else if (this.SystemConfig.CurrentForm == DataStore.E_FormStore.FormSystemSetting)
                            this.ChildFormSystemSetting.UpdateItemNoDisplay(this.EquipmentStatus, this.CurrentProductItem, this.CurrentJudgmentSetItem);
                        break;
                    case "3001":
                        #region Value Assign
                        for (int i = 0; i < this.SystemConfig.EquipmentColumns; i++)
                            this.CollectionMaxWeight[i] = receiveData.Substring(i * 7, 7).Trim();
                        #endregion
                        this.ChildFormConfiguration.UpdateMaxWeightDisplay(this.EquipmentStatus, this.CollectionMaxWeight);
                        break;
                    case "3002":
                        #region Value Assign
                        for (int i = 0; i < this.SystemConfig.EquipmentColumns; i++)
                            this.CollectionBalanceWeight[i] = receiveData.Substring(i * 7, 7).Trim();
                        #endregion
                        this.ChildFormConfiguration.UpdateBalanceWeightDisplay(this.EquipmentStatus, this.CollectionBalanceWeight);
                        break;
                    case "3003":
                        #region Value Assign
                        for (int i = 0; i < this.SystemConfig.EquipmentColumns; i++)
                            this.CollectionDigit[i] = receiveData.Substring(i * 7, 7).Trim();
                        #endregion
                        this.ChildFormConfiguration.UpdateDigitDisplay(this.EquipmentStatus, this.CollectionDigit);
                        break;
                    case "3901":
                        #region Value Assign
                        this.CurrentCalibrationItem.MaxWeight = receiveData.Substring(0, 7).Trim();
                        this.CurrentCalibrationItem.BalanceWeight = receiveData.Substring(7, 7).Trim();
                        this.CurrentCalibrationItem.Digit = receiveData.Substring(14, 7).Trim();

                        switch (this.SystemConfig.EquipmentColumns)
                        {
                            case 2:
                                this.CurrentCalibrationItem.Constant1 = receiveData.Substring(21, 7).Trim();
                                this.CurrentCalibrationItem.Constant2 = receiveData.Substring(28, 7).Trim();
                                break;
                            case 3:
                                this.CurrentCalibrationItem.Constant1 = receiveData.Substring(21, 7).Trim();
                                this.CurrentCalibrationItem.Constant2 = receiveData.Substring(28, 7).Trim();
                                this.CurrentCalibrationItem.Constant3 = receiveData.Substring(35, 7).Trim();
                                break;
                            case 4:
                                this.CurrentCalibrationItem.Constant1 = receiveData.Substring(21, 7).Trim();
                                this.CurrentCalibrationItem.Constant2 = receiveData.Substring(28, 7).Trim();
                                this.CurrentCalibrationItem.Constant3 = receiveData.Substring(35, 7).Trim();
                                this.CurrentCalibrationItem.Constant4 = receiveData.Substring(42, 7).Trim();
                                break;
                            case 5:
                                this.CurrentCalibrationItem.Constant1 = receiveData.Substring(21, 7).Trim();
                                this.CurrentCalibrationItem.Constant2 = receiveData.Substring(28, 7).Trim();
                                this.CurrentCalibrationItem.Constant3 = receiveData.Substring(35, 7).Trim();
                                this.CurrentCalibrationItem.Constant4 = receiveData.Substring(42, 7).Trim();
                                this.CurrentCalibrationItem.Constant5 = receiveData.Substring(49, 7).Trim();
                                break;
                            case 6:
                                this.CurrentCalibrationItem.Constant1 = receiveData.Substring(21, 7).Trim();
                                this.CurrentCalibrationItem.Constant2 = receiveData.Substring(28, 7).Trim();
                                this.CurrentCalibrationItem.Constant3 = receiveData.Substring(35, 7).Trim();
                                this.CurrentCalibrationItem.Constant4 = receiveData.Substring(42, 7).Trim();
                                this.CurrentCalibrationItem.Constant5 = receiveData.Substring(49, 7).Trim();
                                this.CurrentCalibrationItem.Constant6 = receiveData.Substring(56, 7).Trim();
                                break;
                            default:
                                break;
                        }
                        #endregion
                        this.ChildFormCalibration.UpdateConfiguration(this.EquipmentStatus, this.CurrentCalibrationItem);
                        break;
                    case "4001":
                        #region Value Assign
                        for (int i = 0; i < this.SystemConfig.EquipmentColumns; i++)
                            this.CollectionZeroParameterTime[i] = receiveData.Substring(i * 4, 4).Trim();
                        #endregion
                        this.ChildFormConfiguration.UpdateZeroParameterTimeDisplay(this.EquipmentStatus, this.CollectionZeroParameterTime);
                        break;
                    case "4002":
                        #region Value Assign
                        for (int i = 0; i < this.SystemConfig.EquipmentColumns; i++)
                            this.CollectionZeroParameterRange[i] = receiveData.Substring(i * 4, 4).Trim();
                        #endregion
                        this.ChildFormConfiguration.UpdateZeroParameterRangeDisplay(this.EquipmentStatus, this.CollectionZeroParameterRange);
                        break;
                    case "4003":
                        #region Value Assign
                        for (int i = 0; i < this.SystemConfig.EquipmentColumns; i++)
                            this.CollectionZeroParameterVariates[i] = receiveData.Substring(i * 4, 4).Trim();
                        #endregion
                        this.ChildFormConfiguration.UpdateZeroParameterVariateDisplay(this.EquipmentStatus, this.CollectionZeroParameterVariates);
                        break;
                    case "4901":
                        #region Value Assign
                        this.CurrentZeroParameterItem.Time = receiveData.Substring(0, 4).Trim();
                        this.CurrentZeroParameterItem.Range = receiveData.Substring(4, 4).Trim();
                        this.CurrentZeroParameterItem.Variate = receiveData.Substring(8, 4).Trim();
                        this.CurrentZeroParameterItem.Mode = receiveData.Substring(12, 4).Trim();
                        #endregion
                        this.ChildFormConfiguration.UpdateZeroParameterDisplay(this.EquipmentStatus, this.CurrentZeroParameterItem);
                        break;
                    case "5001":
                        #region Value Assign
                        for (int i = 0; i < this.SystemConfig.EquipmentColumns; i++)
                            this.CollectionFilter[i] = receiveData.Substring(i * 4, 4).Trim();
                        #endregion
                        this.ChildFormConfiguration.UpdateFilterDisplay(this.EquipmentStatus, this.CollectionFilter);
                        break;
                    case "6901":
                        #region Value Assign
                        this.CurrentOptionParameterItem.BuzzerOnTime = receiveData.Substring(0, 4).Trim();
                        this.CurrentOptionParameterItem.RelayOnTime = receiveData.Substring(4, 4).Trim();
                        this.CurrentOptionParameterItem.PassAlarm = receiveData.Substring(8, 4).Trim();
                        this.CurrentOptionParameterItem.PassAlarmCount = receiveData.Substring(12, 4).Trim();
                        this.CurrentOptionParameterItem.DoubleEnter = receiveData.Substring(16, 4).Trim();
                        this.CurrentOptionParameterItem.Chattering = receiveData.Substring(20, 4).Trim();
                        #endregion
                        this.ChildFormConfiguration.UpdateOptionParameterDisplay(this.EquipmentStatus, this.CurrentOptionParameterItem);
                        break;
                    default:
                        break;
                }
            }
            catch
            {
                ret = -1;
            }

            return ret;
        }
        // 파라미터 쓰기 응답
        private int ReceiveCommandPW0(string lane, string address, string receiveData)
        {
            int ret = 0;
            DataStore.ResponseData response = DataStore.ResponseData.NAK;

            try
            {
                if (receiveData == "0000")
                    response = DataStore.ResponseData.NAK;
                else
                    response = DataStore.ResponseData.ACK;

                switch (address)
                {
                    case "9047":
                        if (response == DataStore.ResponseData.ACK)
                            this.TransferProductParameter(this.SystemConfig.ProductNumber);
                        break;
                    case "9048":
                        if (response == DataStore.ResponseData.ACK)
                            this.TransferDataStream(CommunicationCommand.Read, CommunicationID.MainBoard, CommunicationAddress.ProductNumber, "");
                        break;
                    default:
                        break;
                }
            }
            catch
            {
                ret = -1;
            }

            return ret;
        }
        // Bypass to motor
        private int ReceiveCommandPB0(string lane, string address, string receiveData)
        {
            int ret = 0;
            DataStore.ResponseData response = DataStore.ResponseData.NAK;

            try
            {
                if (receiveData == "0000")
                    response = DataStore.ResponseData.NAK;
                else
                    response = DataStore.ResponseData.ACK;

                switch (address)
                {
                    case "1101":
                        break;
                    case "1102":
                        break;
                    case "1103":
                        break;
                    default:
                        break;
                }
            }
            catch
            {
                ret = -1;
            }

            return ret;
        }

        // 정지시 중량
        private int ReceiveCommandSN0(string lane, string receiveData)
        {
            int ret = 0;

            try
            {
                switch (lane)
                {
                    case "Z":
                        #region Value Assign
                        if (this.SystemConfig.CurrentForm == DataStore.E_FormStore.FormMainDisplay)
                        {
                            for (int i = 0; i < this.SystemConfig.EquipmentColumns; i++)
                            {
                                this.CollectionWeightData[i].Status = Helper.StringToWeightStatus(receiveData.Substring(i * 12, 2));
                                this.CollectionWeightData[i].Weight = Helper.StringToWeight(receiveData.Substring(i * 12 + 2, 5), this.SystemConfig.DecimalPlaces);
                                this.CollectionWeightData[i].ADCValue = receiveData.Substring(i * 12 + 7, 5);
                            }
                        }
                        else if (this.SystemConfig.CurrentForm == DataStore.E_FormStore.FormEquipmentTest)
                        {
                            for (int i = 0; i < this.SystemConfig.EquipmentColumns; i++)
                            {
                                this.CollectionWeightDataTest[i].Status = Helper.StringToWeightStatus(receiveData.Substring(i * 12, 2));
                                this.CollectionWeightDataTest[i].Weight = Helper.StringToWeight(receiveData.Substring(i * 12 + 2, 5), this.SystemConfig.DecimalPlaces);
                                this.CollectionWeightDataTest[i].ADCValue = receiveData.Substring(i * 12 + 7, 5);
                            }
                        }
                        #endregion
                        if (this.SystemConfig.CurrentForm == DataStore.E_FormStore.FormMainDisplay)
                        {
                            this.ChildFormMainDisplay.UpdateStopWeightDisplay(this.EquipmentStatus, this.CollectionWeightData);
                        }
                        else if (this.SystemConfig.CurrentForm == DataStore.E_FormStore.FormEquipmentTest)
                        {
                            this.ChildFormEquipmentTest.UpdateStopWeightDisplay(this.EquipmentStatus, this.CollectionWeightDataTest);

                            if (this.IsAdcLogOpen == true)
                            {
                                if (this.FlagADCValueWrite == true)
                                {
                                    StringBuilder sb = new StringBuilder();

                                    for (int i = 0; i < this.SystemConfig.EquipmentColumns; i++)
                                    {
                                        sb.Append(this.CollectionWeightDataTest[i].ADCValue);
                                        sb.Append(",");
                                    }

                                    this.smartFileAdcLog.WriteString(string.Format("Receive,{0:yyyy-MM-dd HH:mm:ss},{1}", DateTime.Now, sb.ToString()));
                                    this.FlagADCValueWrite = false;
                                }
                            }
                        }
                        break;
                    default:
                        break;
                }
            }
            catch
            {
                ret = -1;
            }

            return ret;
        }
        // 운전시 중량
        private int ReceiveCommandSR0(string lane, string receiveData)
        {
            int ret = 0;

            try
            {
                switch (lane)
                {
                    case "A":
                        #region Value Assign
                        if (this.SystemConfig.CurrentForm == DataStore.E_FormStore.FormMainDisplay)
                        {
                            this.CollectionWeightData[0].JudgmentStatus = Helper.StringToJudgmentStatus(receiveData.Substring(0, 2));
                            this.CollectionWeightData[0].Weight = Helper.StringToWeight(receiveData.Substring(2, 5), this.SystemConfig.DecimalPlaces);
                            this.CollectionWeightData[0].WeightString = receiveData.Substring(2, 5);
                            this.CollectionWeightData[0].ADCValue = receiveData.Substring(7, 5);
                        }
                        else if (this.SystemConfig.CurrentForm == DataStore.E_FormStore.FormEquipmentTest)
                        {
                            this.CollectionWeightDataTest[0].JudgmentStatus = Helper.StringToJudgmentStatus(receiveData.Substring(0, 2));
                            this.CollectionWeightDataTest[0].Weight = Helper.StringToWeight(receiveData.Substring(2, 5), this.SystemConfig.DecimalPlaces);
                            this.CollectionWeightDataTest[0].WeightString = receiveData.Substring(2, 5);
                            this.CollectionWeightDataTest[0].ADCValue = receiveData.Substring(7, 5);
                        }
                        #endregion
                        if (this.SystemConfig.CurrentForm == DataStore.E_FormStore.FormMainDisplay)
                        {
                            this.DataBackup(this.CollectionWeightData[0], 1);
                            this.ChildFormMainDisplay.UpdateUpdateStartWeightDisplay1(this.EquipmentStatus, this.CollectionWeightData[0]);

                            #region Feedback
                            if (this.SystemConfig.IsFeedback == true)
                            {
                                this.FeedbackCalculation(1, this.CollectionWeightData[0]);
                                this.ChildFormMainDisplay.UpdateFeedbackDataDisplay1(this.EquipmentStatus, this.CollectionFeedbackStatus[0], this.CollectionWeightData[0]);
                            }
                            #endregion

                            // CH3 
                            if (this.SystemConfig.Serial3Mode == (int)DataStore.CommunicationMode.f1_STD1)         // OPT1
                                this.SerialPort3_Write(this.Protocol_STD1_NotStxEtx(this.SystemConfig, this.CollectionWeightData[0], 1));
                            else if (this.SystemConfig.Serial3Mode == (int)DataStore.CommunicationMode.f2_STD2)    // OPT2
                                this.SerialPort3_Write(this.Protocol_STD2_NotStxEtx(this.SystemConfig, this.CollectionWeightData[0], 1));

                            // Ethernet
                            if (this.SystemConfig.IsEthernetEnable == true)
                            {
                                if (this.SystemConfig.EthernetMode == (int)DataStore.CommunicationMode.f1_STD1)         // OPT1
                                    this.EthernetWrite(this.Protocol_STD1(this.SystemConfig, this.CollectionWeightData[0], 1));
                                else if (this.SystemConfig.EthernetMode == (int)DataStore.CommunicationMode.f2_STD2)    // OPT2
                                    this.EthernetWrite(this.Protocol_STD2(this.SystemConfig, this.CollectionWeightData[0], 1));
                                else if (this.SystemConfig.EthernetMode == (int)DataStore.CommunicationMode.f99_Modbus)    // Modbus
                                {
                                    this.Update30000ModbusData(0);
                                    if (this.SystemConfig.EthernetOperationMode == 2) // Client
                                    {
                                        byte[] etherByteData = this.Modbus.WriteMultipleRegisterTCP(
                                                                  this.Protocol_Modbus_Client_Write_Lane_Data_TCP(0), this.SystemConfig.ModbusTcpStartAddress + (1 * 50) + 140);
                                        this.EthernetClientWeightDataForModbus(etherByteData);
                                    }
                                }
                            }
                        }
                        else if (this.SystemConfig.CurrentForm == DataStore.E_FormStore.FormEquipmentTest)
                        {
                            this.ChildFormEquipmentTest.UpdateUpdateStartWeightDisplay1(this.EquipmentStatus, this.CollectionWeightDataTest[0]);
                        }
                        break;
                    case "B":
                        #region Value Assign
                        if (this.SystemConfig.CurrentForm == DataStore.E_FormStore.FormMainDisplay)
                        {
                            this.CollectionWeightData[1].JudgmentStatus = Helper.StringToJudgmentStatus(receiveData.Substring(0, 2));
                            this.CollectionWeightData[1].Weight = Helper.StringToWeight(receiveData.Substring(2, 5), this.SystemConfig.DecimalPlaces);
                            this.CollectionWeightData[1].WeightString = receiveData.Substring(2, 5);
                            this.CollectionWeightData[1].ADCValue = receiveData.Substring(7, 5);
                        }
                        else if (this.SystemConfig.CurrentForm == DataStore.E_FormStore.FormEquipmentTest)
                        {
                            this.CollectionWeightDataTest[1].JudgmentStatus = Helper.StringToJudgmentStatus(receiveData.Substring(0, 2));
                            this.CollectionWeightDataTest[1].Weight = Helper.StringToWeight(receiveData.Substring(2, 5), this.SystemConfig.DecimalPlaces);
                            this.CollectionWeightDataTest[1].WeightString = receiveData.Substring(2, 5);
                            this.CollectionWeightDataTest[1].ADCValue = receiveData.Substring(7, 5);
                        }
                        #endregion
                        if (this.SystemConfig.CurrentForm == DataStore.E_FormStore.FormMainDisplay)
                        {
                            this.DataBackup(this.CollectionWeightData[1], 2);
                            this.ChildFormMainDisplay.UpdateUpdateStartWeightDisplay2(this.EquipmentStatus, this.CollectionWeightData[1]);

                            #region Feedback
                            if (this.SystemConfig.IsFeedback == true)
                            {
                                this.FeedbackCalculation(2, this.CollectionWeightData[1]);
                                this.ChildFormMainDisplay.UpdateFeedbackDataDisplay2(this.EquipmentStatus, this.CollectionFeedbackStatus[1], this.CollectionWeightData[1]);
                            }
                            #endregion

                            // CH3 
                            if (this.SystemConfig.Serial3Mode == (int)DataStore.CommunicationMode.f1_STD1)         // OPT1
                                this.SerialPort3_Write(this.Protocol_STD1_NotStxEtx(this.SystemConfig, this.CollectionWeightData[1], 2));
                            else if (this.SystemConfig.Serial3Mode == (int)DataStore.CommunicationMode.f2_STD2)    // OPT2
                                this.SerialPort3_Write(this.Protocol_STD2_NotStxEtx(this.SystemConfig, this.CollectionWeightData[1], 2));

                            // Ethernet
                            if (this.SystemConfig.IsEthernetEnable == true)
                            {
                                if (this.SystemConfig.EthernetMode == (int)DataStore.CommunicationMode.f1_STD1)         // OPT1
                                    this.EthernetWrite(this.Protocol_STD1(this.SystemConfig, this.CollectionWeightData[1], 2));
                                else if (this.SystemConfig.EthernetMode == (int)DataStore.CommunicationMode.f2_STD2)    // OPT2
                                    this.EthernetWrite(this.Protocol_STD2(this.SystemConfig, this.CollectionWeightData[1], 2));
                                else if (this.SystemConfig.EthernetMode == (int)DataStore.CommunicationMode.f99_Modbus)    // Modbus
                                {
                                    this.Update30000ModbusData(1);
                                    if (this.SystemConfig.EthernetOperationMode == 2) // Client
                                    {
                                        byte[] etherByteData = this.Modbus.WriteMultipleRegisterTCP(
                                                                  this.Protocol_Modbus_Client_Write_Lane_Data_TCP(1), this.SystemConfig.ModbusTcpStartAddress + (2 * 50) + 140);
                                        this.EthernetClientWeightDataForModbus(etherByteData);
                                    }
                                }
                            }
                        }
                        else if (this.SystemConfig.CurrentForm == DataStore.E_FormStore.FormEquipmentTest)
                        {
                            this.ChildFormEquipmentTest.UpdateUpdateStartWeightDisplay2(this.EquipmentStatus, this.CollectionWeightDataTest[1]);
                        }
                        break;
                    case "C":
                        #region Value Assign
                        if (this.SystemConfig.CurrentForm == DataStore.E_FormStore.FormMainDisplay)
                        {
                            this.CollectionWeightData[2].JudgmentStatus = Helper.StringToJudgmentStatus(receiveData.Substring(0, 2));
                            this.CollectionWeightData[2].Weight = Helper.StringToWeight(receiveData.Substring(2, 5), this.SystemConfig.DecimalPlaces);
                            this.CollectionWeightData[2].WeightString = receiveData.Substring(2, 5);
                            this.CollectionWeightData[2].ADCValue = receiveData.Substring(7, 5);
                        }
                        else if (this.SystemConfig.CurrentForm == DataStore.E_FormStore.FormEquipmentTest)
                        {
                            this.CollectionWeightDataTest[2].JudgmentStatus = Helper.StringToJudgmentStatus(receiveData.Substring(0, 2));
                            this.CollectionWeightDataTest[2].Weight = Helper.StringToWeight(receiveData.Substring(2, 5), this.SystemConfig.DecimalPlaces);
                            this.CollectionWeightDataTest[2].WeightString = receiveData.Substring(2, 5);
                            this.CollectionWeightDataTest[2].ADCValue = receiveData.Substring(7, 5);
                        }
                        #endregion
                        if (this.SystemConfig.CurrentForm == DataStore.E_FormStore.FormMainDisplay)
                        {
                            this.DataBackup(this.CollectionWeightData[2], 3);
                            this.ChildFormMainDisplay.UpdateUpdateStartWeightDisplay3(this.EquipmentStatus, this.CollectionWeightData[2]);

                            #region Feedback
                            if (this.SystemConfig.IsFeedback == true)
                            {
                                this.FeedbackCalculation(3, this.CollectionWeightData[2]);
                                this.ChildFormMainDisplay.UpdateFeedbackDataDisplay3(this.EquipmentStatus, this.CollectionFeedbackStatus[2], this.CollectionWeightData[2]);
                            }
                            #endregion

                            // CH3 
                            if (this.SystemConfig.Serial3Mode == (int)DataStore.CommunicationMode.f1_STD1)         // OPT1
                                this.SerialPort3_Write(this.Protocol_STD1_NotStxEtx(this.SystemConfig, this.CollectionWeightData[2], 3));
                            else if (this.SystemConfig.Serial3Mode == (int)DataStore.CommunicationMode.f2_STD2)    // OPT2
                                this.SerialPort3_Write(this.Protocol_STD2_NotStxEtx(this.SystemConfig, this.CollectionWeightData[2], 3));

                            // Ethernet
                            if (this.SystemConfig.IsEthernetEnable == true)
                            {
                                if (this.SystemConfig.EthernetMode == (int)DataStore.CommunicationMode.f1_STD1)         // OPT1
                                    this.EthernetWrite(this.Protocol_STD1(this.SystemConfig, this.CollectionWeightData[2], 3));
                                else if (this.SystemConfig.EthernetMode == (int)DataStore.CommunicationMode.f2_STD2)    // OPT2
                                    this.EthernetWrite(this.Protocol_STD2(this.SystemConfig, this.CollectionWeightData[2], 3));
                                else if (this.SystemConfig.EthernetMode == (int)DataStore.CommunicationMode.f99_Modbus)    // Modbus
                                {
                                    this.Update30000ModbusData(2);
                                    if (this.SystemConfig.EthernetOperationMode == 2) // Client
                                    {
                                        byte[] etherByteData = this.Modbus.WriteMultipleRegisterTCP(
                                                                  this.Protocol_Modbus_Client_Write_Lane_Data_TCP(2), this.SystemConfig.ModbusTcpStartAddress + (3 * 50) + 140);
                                        this.EthernetClientWeightDataForModbus(etherByteData);
                                    }
                                }
                            }
                        }
                        else if (this.SystemConfig.CurrentForm == DataStore.E_FormStore.FormEquipmentTest)
                        {
                            this.ChildFormEquipmentTest.UpdateUpdateStartWeightDisplay3(this.EquipmentStatus, this.CollectionWeightDataTest[2]);
                        }
                        break;
                    case "D":
                        #region Value Assign
                        if (this.SystemConfig.CurrentForm == DataStore.E_FormStore.FormMainDisplay)
                        {
                            this.CollectionWeightData[3].JudgmentStatus = Helper.StringToJudgmentStatus(receiveData.Substring(0, 2));
                            this.CollectionWeightData[3].Weight = Helper.StringToWeight(receiveData.Substring(2, 5), this.SystemConfig.DecimalPlaces);
                            this.CollectionWeightData[3].WeightString = receiveData.Substring(2, 5);
                            this.CollectionWeightData[3].ADCValue = receiveData.Substring(7, 5);
                        }
                        else if (this.SystemConfig.CurrentForm == DataStore.E_FormStore.FormEquipmentTest)
                        {
                            this.CollectionWeightDataTest[3].JudgmentStatus = Helper.StringToJudgmentStatus(receiveData.Substring(0, 2));
                            this.CollectionWeightDataTest[3].Weight = Helper.StringToWeight(receiveData.Substring(2, 5), this.SystemConfig.DecimalPlaces);
                            this.CollectionWeightDataTest[3].ADCValue = receiveData.Substring(7, 5);
                            this.CollectionWeightDataTest[3].ADCValue = receiveData.Substring(7, 5);
                        }
                        #endregion
                        if (this.SystemConfig.CurrentForm == DataStore.E_FormStore.FormMainDisplay)
                        {
                            this.DataBackup(this.CollectionWeightData[3], 4);
                            this.ChildFormMainDisplay.UpdateUpdateStartWeightDisplay4(this.EquipmentStatus, this.CollectionWeightData[3]);

                            #region Feedback
                            if (this.SystemConfig.IsFeedback == true)
                            {
                                this.FeedbackCalculation(4, this.CollectionWeightData[3]);
                                this.ChildFormMainDisplay.UpdateFeedbackDataDisplay4(this.EquipmentStatus, this.CollectionFeedbackStatus[3], this.CollectionWeightData[3]);
                            }
                            #endregion

                            // CH3 
                            if (this.SystemConfig.Serial3Mode == (int)DataStore.CommunicationMode.f1_STD1)         // OPT1
                                this.SerialPort3_Write(this.Protocol_STD1_NotStxEtx(this.SystemConfig, this.CollectionWeightData[3], 4));
                            else if (this.SystemConfig.Serial3Mode == (int)DataStore.CommunicationMode.f2_STD2)    // OPT2
                                this.SerialPort3_Write(this.Protocol_STD2_NotStxEtx(this.SystemConfig, this.CollectionWeightData[3], 4));

                            // Ethernet
                            if (this.SystemConfig.IsEthernetEnable == true)
                            {
                                if (this.SystemConfig.EthernetMode == (int)DataStore.CommunicationMode.f1_STD1)         // OPT1
                                    this.EthernetWrite(this.Protocol_STD1(this.SystemConfig, this.CollectionWeightData[3], 4));
                                else if (this.SystemConfig.EthernetMode == (int)DataStore.CommunicationMode.f2_STD2)    // OPT2
                                    this.EthernetWrite(this.Protocol_STD2(this.SystemConfig, this.CollectionWeightData[3], 4));
                                else if (this.SystemConfig.EthernetMode == (int)DataStore.CommunicationMode.f99_Modbus)    // Modbus
                                {
                                    this.Update30000ModbusData(3);
                                    if (this.SystemConfig.EthernetOperationMode == 2) // Client
                                    {
                                        byte[] etherByteData = this.Modbus.WriteMultipleRegisterTCP(
                                                                  this.Protocol_Modbus_Client_Write_Lane_Data_TCP(3), this.SystemConfig.ModbusTcpStartAddress + (4 * 50) + 140);
                                        this.EthernetClientWeightDataForModbus(etherByteData);
                                    }
                                }
                            }                            
                        }
                        else if (this.SystemConfig.CurrentForm == DataStore.E_FormStore.FormEquipmentTest)
                        {
                            this.ChildFormEquipmentTest.UpdateUpdateStartWeightDisplay4(this.EquipmentStatus, this.CollectionWeightDataTest[3]);
                        }
                        break;
                    case "E":
                        #region Value Assign
                        if (this.SystemConfig.CurrentForm == DataStore.E_FormStore.FormMainDisplay)
                        {
                            this.CollectionWeightData[4].JudgmentStatus = Helper.StringToJudgmentStatus(receiveData.Substring(0, 2));
                            this.CollectionWeightData[4].Weight = Helper.StringToWeight(receiveData.Substring(2, 5), this.SystemConfig.DecimalPlaces);
                            this.CollectionWeightData[4].WeightString = receiveData.Substring(2, 5);
                            this.CollectionWeightData[4].ADCValue = receiveData.Substring(7, 5);
                        }
                        else if (this.SystemConfig.CurrentForm == DataStore.E_FormStore.FormEquipmentTest)
                        {
                            this.CollectionWeightDataTest[4].JudgmentStatus = Helper.StringToJudgmentStatus(receiveData.Substring(0, 2));
                            this.CollectionWeightDataTest[4].Weight = Helper.StringToWeight(receiveData.Substring(2, 5), this.SystemConfig.DecimalPlaces);
                            this.CollectionWeightDataTest[4].WeightString = receiveData.Substring(2, 5);
                            this.CollectionWeightDataTest[4].ADCValue = receiveData.Substring(7, 5);
                        }
                        #endregion
                        if (this.SystemConfig.CurrentForm == DataStore.E_FormStore.FormMainDisplay)
                        {
                            this.DataBackup(this.CollectionWeightData[4], 5);
                            this.ChildFormMainDisplay.UpdateUpdateStartWeightDisplay5(this.EquipmentStatus, this.CollectionWeightData[4]);

                            #region Feedback
                            if (this.SystemConfig.IsFeedback == true)
                            {
                                this.FeedbackCalculation(5, this.CollectionWeightData[4]);
                                this.ChildFormMainDisplay.UpdateFeedbackDataDisplay5(this.EquipmentStatus, this.CollectionFeedbackStatus[4], this.CollectionWeightData[4]);
                            }
                            #endregion

                            // CH3 
                            if (this.SystemConfig.Serial3Mode == (int)DataStore.CommunicationMode.f1_STD1)         // OPT1
                                this.SerialPort3_Write(this.Protocol_STD1_NotStxEtx(this.SystemConfig, this.CollectionWeightData[4], 5));
                            else if (this.SystemConfig.Serial3Mode == (int)DataStore.CommunicationMode.f2_STD2)    // OPT2
                                this.SerialPort3_Write(this.Protocol_STD2_NotStxEtx(this.SystemConfig, this.CollectionWeightData[4], 5));

                            // Ethernet
                            if (this.SystemConfig.IsEthernetEnable == true)
                            {
                                if (this.SystemConfig.EthernetMode == (int)DataStore.CommunicationMode.f1_STD1)         // OPT1
                                    this.EthernetWrite(this.Protocol_STD1(this.SystemConfig, this.CollectionWeightData[4], 5));
                                else if (this.SystemConfig.EthernetMode == (int)DataStore.CommunicationMode.f2_STD2)    // OPT2
                                    this.EthernetWrite(this.Protocol_STD2(this.SystemConfig, this.CollectionWeightData[4], 5));
                                else if (this.SystemConfig.EthernetMode == (int)DataStore.CommunicationMode.f99_Modbus)    // Modbus
                                {
                                    this.Update30000ModbusData(4);
                                    if (this.SystemConfig.EthernetOperationMode == 2) // Client
                                    {
                                        byte[] etherByteData = this.Modbus.WriteMultipleRegisterTCP(
                                                                  this.Protocol_Modbus_Client_Write_Lane_Data_TCP(4), this.SystemConfig.ModbusTcpStartAddress + (5 * 50) + 140);
                                        this.EthernetClientWeightDataForModbus(etherByteData);
                                    }
                                }
                            }                            
                        }
                        else if (this.SystemConfig.CurrentForm == DataStore.E_FormStore.FormEquipmentTest)
                        {
                            this.ChildFormEquipmentTest.UpdateUpdateStartWeightDisplay5(this.EquipmentStatus, this.CollectionWeightDataTest[4]);
                        }
                        break;
                    case "F":
                        #region Value Assign
                        if (this.SystemConfig.CurrentForm == DataStore.E_FormStore.FormMainDisplay)
                        {
                            this.CollectionWeightData[5].JudgmentStatus = Helper.StringToJudgmentStatus(receiveData.Substring(0, 2));
                            this.CollectionWeightData[5].Weight = Helper.StringToWeight(receiveData.Substring(2, 5), this.SystemConfig.DecimalPlaces);
                            this.CollectionWeightData[5].WeightString = receiveData.Substring(2, 5);
                            this.CollectionWeightData[5].ADCValue = receiveData.Substring(7, 5);
                        }
                        else if (this.SystemConfig.CurrentForm == DataStore.E_FormStore.FormEquipmentTest)
                        {
                            this.CollectionWeightDataTest[5].JudgmentStatus = Helper.StringToJudgmentStatus(receiveData.Substring(0, 2));
                            this.CollectionWeightDataTest[5].Weight = Helper.StringToWeight(receiveData.Substring(2, 5), this.SystemConfig.DecimalPlaces);
                            this.CollectionWeightDataTest[5].WeightString = receiveData.Substring(2, 5);
                            this.CollectionWeightDataTest[5].ADCValue = receiveData.Substring(7, 5);
                        }
                        #endregion
                        if (this.SystemConfig.CurrentForm == DataStore.E_FormStore.FormMainDisplay)
                        {
                            this.DataBackup(this.CollectionWeightData[5], 6);
                            this.ChildFormMainDisplay.UpdateUpdateStartWeightDisplay6(this.EquipmentStatus, this.CollectionWeightData[5]);

                            #region Feedback
                            if (this.SystemConfig.IsFeedback == true)
                            {
                                this.FeedbackCalculation(6, this.CollectionWeightData[5]);
                                this.ChildFormMainDisplay.UpdateFeedbackDataDisplay6(this.EquipmentStatus, this.CollectionFeedbackStatus[5], this.CollectionWeightData[5]);
                            }
                            #endregion

                            // CH3 
                            if (this.SystemConfig.Serial3Mode == (int)DataStore.CommunicationMode.f1_STD1)         // OPT1
                                this.SerialPort3_Write(this.Protocol_STD1_NotStxEtx(this.SystemConfig, this.CollectionWeightData[4], 5));
                            else if (this.SystemConfig.Serial3Mode == (int)DataStore.CommunicationMode.f2_STD2)    // OPT2
                                this.SerialPort3_Write(this.Protocol_STD2_NotStxEtx(this.SystemConfig, this.CollectionWeightData[4], 5));

                            // Ethernet
                            if (this.SystemConfig.IsEthernetEnable == true)
                            {
                                if (this.SystemConfig.EthernetMode == (int)DataStore.CommunicationMode.f1_STD1)         // OPT1
                                    this.EthernetWrite(this.Protocol_STD1(this.SystemConfig, this.CollectionWeightData[4], 5));
                                else if (this.SystemConfig.EthernetMode == (int)DataStore.CommunicationMode.f2_STD2)    // OPT2
                                    this.EthernetWrite(this.Protocol_STD2(this.SystemConfig, this.CollectionWeightData[4], 5));
                                else if (this.SystemConfig.EthernetMode == (int)DataStore.CommunicationMode.f99_Modbus)    // Modbus
                                {
                                    this.Update30000ModbusData(5);
                                    if (this.SystemConfig.EthernetOperationMode == 2) // Client
                                    {
                                        byte[] etherByteData = this.Modbus.WriteMultipleRegisterTCP(
                                                                  this.Protocol_Modbus_Client_Write_Lane_Data_TCP(5), this.SystemConfig.ModbusTcpStartAddress + (6 * 50) + 140);
                                        this.EthernetClientWeightDataForModbus(etherByteData);
                                    }
                                }
                            }                            
                        }
                        else if (this.SystemConfig.CurrentForm == DataStore.E_FormStore.FormEquipmentTest)
                        {
                            this.ChildFormEquipmentTest.UpdateUpdateStartWeightDisplay6(this.EquipmentStatus, this.CollectionWeightDataTest[5]);
                        }
                        break;
                    case "Z":
                        #region Value Assign
                        if (this.SystemConfig.CurrentForm == DataStore.E_FormStore.FormMainDisplay)
                        {
                            for (int i = 0; i < this.SystemConfig.EquipmentColumns; i++)
                            {
                                this.CollectionWeightData[i].JudgmentStatus = Helper.StringToJudgmentStatus(receiveData.Substring(i * 12, 2));
                                this.CollectionWeightData[i].Weight = Helper.StringToWeight(receiveData.Substring(i * 12 + 2, 5), this.SystemConfig.DecimalPlaces);
                                this.CollectionWeightData[i].WeightString = receiveData.Substring(i * 12 + 2, 5);
                                this.CollectionWeightData[i].ADCValue = receiveData.Substring(i * 12 + 7, 5);
                            }
                        }
                        else if (this.SystemConfig.CurrentForm == DataStore.E_FormStore.FormEquipmentTest)
                        {
                            for (int i = 0; i < this.SystemConfig.EquipmentColumns; i++)
                            {
                                this.CollectionWeightDataTest[i].JudgmentStatus = Helper.StringToJudgmentStatus(receiveData.Substring(i * 12, 2));
                                this.CollectionWeightDataTest[i].Weight = Helper.StringToWeight(receiveData.Substring(i * 12 + 2, 5), this.SystemConfig.DecimalPlaces);
                                this.CollectionWeightDataTest[i].WeightString = receiveData.Substring(i * 12 + 2, 5);
                                this.CollectionWeightDataTest[i].ADCValue = receiveData.Substring(i * 12 + 7, 5);
                            }
                        }
                        #endregion
                        if (this.SystemConfig.CurrentForm == DataStore.E_FormStore.FormMainDisplay)
                        {
                            this.DataBackup(this.CollectionWeightData);
                            this.ChildFormMainDisplay.UpdateUpdateStartWeightDisplay(this.EquipmentStatus, this.CollectionWeightData);

                            #region Feedback
                            if (this.SystemConfig.IsFeedback == true)
                            {
                                for (int i = 0; i < this.SystemConfig.EquipmentColumns; i++)
                                    this.FeedbackCalculation(i + 1, this.CollectionWeightData[i]);

                                this.ChildFormMainDisplay.UpdateFeedbackDataDisplay(this.EquipmentStatus, this.CollectionFeedbackStatus, this.CollectionWeightData);
                            }
                            #endregion

                            if (this.SystemConfig.EthernetMode == (int)DataStore.CommunicationMode.f99_Modbus)    // Modbus
                            {
                                for (int i = 0; i < this.SystemConfig.EquipmentColumns; i++)
                                    this.Update30000ModbusData(i);

                                if (this.SystemConfig.EthernetOperationMode == 2) // Client
                                {
                                    for (int i = 0; i < this.SystemConfig.EquipmentColumns; i++)
                                    {
                                        byte[] etherByteData = this.Modbus.WriteMultipleRegisterTCP(
                                            this.Protocol_Modbus_Client_Write_Lane_Data_TCP(i), this.SystemConfig.ModbusTcpStartAddress + ((i + 1) * 50) + 140);
                                        this.EthernetClientWeightDataForModbus(etherByteData);
                                    }
                                }
                            }                            
                        }
                        else if (this.SystemConfig.CurrentForm == DataStore.E_FormStore.FormEquipmentTest)
                        {
                            this.ChildFormEquipmentTest.UpdateUpdateStartWeightDisplay(this.EquipmentStatus, this.CollectionWeightDataTest);
                        }
                        break;
                    default:
                        break;
                }
            }
            catch
            {
                ret = -1;
            }

            return ret;
        }
        // 중량조정시 중량
        private int ReceiveCommandSC0(string lane, string receiveData)
        {
            int ret = 0;

            switch (lane)
            {
                case "Z":
                    #region Value Assign
                    for (int i = 0; i < this.SystemConfig.EquipmentColumns; i++)
                    {
                        this.CollectionWeightData[i].Status = Helper.StringToWeightStatus(receiveData.Substring(i * 12, 2));
                        this.CollectionWeightData[i].Weight = Helper.StringToWeight(receiveData.Substring(i * 12 + 2, 5), this.SystemConfig.DecimalPlaces);
                        this.CollectionWeightData[i].ADCValue = receiveData.Substring(i * 12 + 7, 5);
                    }
                    #endregion
                    this.ChildFormCalibration.UpdateWeightDisplay(this.EquipmentStatus, this.CollectionWeightData);
                    break;
                default:
                    break;
            }

            return ret;
        }
        // 판정설정시 중량 - 정지
        private int ReceiveCommandSF0(string lane, string receiveData)
        {
            int ret = 0;

            switch (lane)
            {
                case "Z":
                    #region Value Assign
                    for (int i = 0; i < this.SystemConfig.EquipmentColumns; i++)
                    {
                        this.CollectionWeightData[i].Status = Helper.StringToWeightStatus(receiveData.Substring(i * 12, 2));
                        this.CollectionWeightData[i].Weight = Helper.StringToWeight(receiveData.Substring(i * 12 + 2, 5), this.SystemConfig.DecimalPlaces);
                        this.CollectionWeightData[i].ADCValue = receiveData.Substring(i * 12 + 7, 5);
                    }
                    #endregion
                    this.ChildFormSystemSetting.UpdateStopWeightDisplay(this.EquipmentStatus, this.CollectionWeightData);
                    break;
                default:
                    break;
            }

            return ret;
        }
        // 판정설정 그래프
        private int ReceiveCommandSG0(string lane, string receiveData)
        {
            int ret = 0, temp = 12;

            switch (lane)
            {
                case "A":
                    #region Value Assign
                    this.CollectionWeightData[0].Weight = Helper.StringToWeight(receiveData.Substring(2, 5), this.SystemConfig.DecimalPlaces);
                    this.CollectionWeightData[0].ADCValue = receiveData.Substring(7, 5);

                    for (int i = 0; i < this.CollectionGraphData.Count; i++)
                    {
                        this.CollectionGraphData[i] = int.Parse(receiveData.Substring(temp, 5));
                        temp += 5;
                    }
                    #endregion
                    this.ChildFormSystemSetting.UpdateGraphDataDisplay(this.EquipmentStatus, this.CollectionWeightData[0], this.CollectionGraphData);
                    break;
                case "B":
                    #region Value Assign
                    this.CollectionWeightData[1].Weight = Helper.StringToWeight(receiveData.Substring(2, 5), this.SystemConfig.DecimalPlaces);
                    this.CollectionWeightData[1].ADCValue = receiveData.Substring(7, 5);

                    for (int i = 0; i < this.CollectionGraphData.Count; i++)
                    {
                        this.CollectionGraphData[i] = int.Parse(receiveData.Substring(temp, 5));
                        temp += 5;
                    }
                    #endregion
                    this.ChildFormSystemSetting.UpdateGraphDataDisplay(this.EquipmentStatus, this.CollectionWeightData[1], this.CollectionGraphData);
                    break;
                case "C":
                    #region Value Assign
                    this.CollectionWeightData[2].Weight = Helper.StringToWeight(receiveData.Substring(2, 5), this.SystemConfig.DecimalPlaces);
                    this.CollectionWeightData[2].ADCValue = receiveData.Substring(7, 5);

                    for (int i = 0; i < this.CollectionGraphData.Count; i++)
                    {
                        this.CollectionGraphData[i] = int.Parse(receiveData.Substring(temp, 5));
                        temp += 5;
                    }
                    #endregion
                    this.ChildFormSystemSetting.UpdateGraphDataDisplay(this.EquipmentStatus, this.CollectionWeightData[2], this.CollectionGraphData);
                    break;
                case "D":
                    #region Value Assign
                    this.CollectionWeightData[3].Weight = Helper.StringToWeight(receiveData.Substring(2, 5), this.SystemConfig.DecimalPlaces);
                    this.CollectionWeightData[3].ADCValue = receiveData.Substring(7, 5);

                    for (int i = 0; i < this.CollectionGraphData.Count; i++)
                    {
                        this.CollectionGraphData[i] = int.Parse(receiveData.Substring(temp, 5));
                        temp += 5;
                    }
                    #endregion
                    this.ChildFormSystemSetting.UpdateGraphDataDisplay(this.EquipmentStatus, this.CollectionWeightData[3], this.CollectionGraphData);
                    break;
                case "E":
                    #region Value Assign
                    this.CollectionWeightData[4].Weight = Helper.StringToWeight(receiveData.Substring(2, 5), this.SystemConfig.DecimalPlaces);
                    this.CollectionWeightData[4].ADCValue = receiveData.Substring(7, 5);

                    for (int i = 0; i < this.CollectionGraphData.Count; i++)
                    {
                        this.CollectionGraphData[i] = int.Parse(receiveData.Substring(temp, 5));
                        temp += 5;
                    }
                    #endregion
                    this.ChildFormSystemSetting.UpdateGraphDataDisplay(this.EquipmentStatus, this.CollectionWeightData[4], this.CollectionGraphData);
                    break;
                case "F":
                    #region Value Assign
                    this.CollectionWeightData[5].Weight = Helper.StringToWeight(receiveData.Substring(2, 5), this.SystemConfig.DecimalPlaces);
                    this.CollectionWeightData[5].ADCValue = receiveData.Substring(7, 5);

                    for (int i = 0; i < this.CollectionGraphData.Count; i++)
                    {
                        this.CollectionGraphData[i] = int.Parse(receiveData.Substring(temp, 5));
                        temp += 5;
                    }
                    #endregion
                    this.ChildFormSystemSetting.UpdateGraphDataDisplay(this.EquipmentStatus, this.CollectionWeightData[5], this.CollectionGraphData);
                    break;
                default:
                    break;
            }

            return ret;
        }
        // IO테스트-IN
        private int ReceiveCommandST0(string lane, string receiveData)
        {
            int ret = 0;

            switch (lane)
            {
                case "0":
                    #region Value Assign
                    for (int i = 0; i < 16; i++)
                        this.CollectionIOTest_InputData[i] = receiveData.Substring(i, 1);
                    #endregion
                    if (this.SystemConfig.CurrentForm == DataStore.E_FormStore.FormIOTest)
                        this.ChildFormIOTest.UpdateInputRead(this.CollectionIOTest_InputData);
                    else if (this.SystemConfig.CurrentForm == DataStore.E_FormStore.FormEquipmentTest)
                        this.ChildFormEquipmentTest.UpdateInputRead(this.CollectionIOTest_InputData);
                    break;
                default:
                    break;
            }

            return ret;
        }
        // 알람
        private int ReceiveCommandSA0(string lane, string receiveData)
        {
            int ret = 0;

            switch (lane)
            {
                case "0":
                    #region Value Assign
                    this.CurrentAlarmList.SetAlarm(receiveData.Substring(0, 8));
                    #endregion

                    this.ChildFormMainDisplay.UpdateDisplayAlarmView(this.CurrentAlarmList);
                    break;
                default:
                    break;
            }

            return ret;
        }
        #endregion

        #region Communication Protocol
        public string Protocol_STD1_NotStxEtx(SystemConfigurationItem system, WeightData data, int lane)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(string.Format("IN{0:D3}", this.SystemConfig.EquipmentID));
            sb.Append(string.Format("{0:D4}", this.SystemConfig.ProductNumber));
            sb.Append(string.Format("{0:D2}", lane));

            if (data.JudgmentStatus == DataStore.JudgmentStatus.Under)
                sb.Append("U");
            else if (data.JudgmentStatus == DataStore.JudgmentStatus.Over)
                sb.Append("O");
            else if (data.JudgmentStatus == DataStore.JudgmentStatus.Double)
                sb.Append("D");
            else
                sb.Append("P");

            sb.Append(Helper.StringBlankFillDigits6(Helper.DoubleToString(data.Weight, system.DecimalPlaces)));

            return sb.ToString();
        }
        public string Protocol_STD1(SystemConfigurationItem system, WeightData data, int lane)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append((char)0x02);
            sb.Append(this.Protocol_STD1_NotStxEtx(system, data, lane));
            sb.Append((char)0x03);

            return sb.ToString();
        }
        public string Protocol_STD2_NotStxEtx(SystemConfigurationItem system, WeightData data, int lane)
        {
            int value = 0, passWeight = 0, weight = 0;
            StringBuilder sb = new StringBuilder();

            sb.Append(string.Format("IN{0:D3}", this.SystemConfig.EquipmentID));
            sb.Append(string.Format("{0:D4}", this.SystemConfig.ProductNumber));
            sb.Append(string.Format("{0:D2}", lane));

            passWeight = int.Parse(this.CurrentProductItem.PassRange.Trim());
            weight = int.Parse(data.WeightString.Trim());
            value = weight - passWeight;

            // SIGN
            if (value < 0)
                sb.Append("-");
            else
                sb.Append("+");

            // WEIGHT
            value = Math.Abs(value);
            sb.Append(Helper.StringBlankFillDigits6(Helper.StringToDecimalPlaces(value.ToString(), system.DecimalPlaces)));

            return sb.ToString();
        }
        public string Protocol_STD2(SystemConfigurationItem system, WeightData data, int lane)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append((char)0x02);
            sb.Append(this.Protocol_STD2_NotStxEtx(system, data, lane));
            sb.Append((char)0x03);

            return sb.ToString();
        }
        public string Protocol_STD3_NotStxEtx(SystemConfigurationItem system, FeedBackSystem data, int lane)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(string.Format("IN{0:D3}", this.SystemConfig.EquipmentID));
            sb.Append(string.Format("{0:D4}", this.SystemConfig.ProductNumber));
            sb.Append(string.Format("{0:D2}", lane));

            // SIGN
            if (data.FeedbackWeight < 0)
                sb.Append("-");
            else
                sb.Append("+");

            // WEIGHT
            sb.Append(Helper.StringBlankFillDigits6(Helper.DoubleToString(Math.Abs(data.FeedbackWeight), system.DecimalPlaces)));

            return sb.ToString();
        }
        public string Protocol_STD3(SystemConfigurationItem system, FeedBackSystem data, int lane)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append((char)0x02);
            sb.Append(this.Protocol_STD3_NotStxEtx(system, data, lane));
            sb.Append((char)0x03);

            return sb.ToString();
        }

        public byte[] Protocol_Modbus_Client_Write_Common_Data_TCP()
        {
            int index = 0;
            byte[] madeData = new byte[40];
            byte[] length4Value = new byte[4];
            byte[] length2Value = new byte[2];

            double underValue = this.Current30000ModbusData.UnderValue;
            double passValue = this.Current30000ModbusData.PassValue;
            double overValue = this.Current30000ModbusData.OverValue;
            double tareValue = this.Current30000ModbusData.TareValue;

            #region 고정 Data(10개, 40 bytes)
            // 하한값
            length4Value = GetBytes((Single)underValue);
            for (int i = 0; i < 4; i++)
                madeData[i] = length4Value[3 - i];

            // 기준값
            length4Value = GetBytes((Single)passValue);
            for (int i = 0; i < 4; i++)
                madeData[4 + i] = length4Value[3 - i];

            // 상한값
            length4Value = GetBytes((Single)overValue);
            for (int i = 0; i < 4; i++)
                madeData[8 + i] = length4Value[3 - i];

            // 용기값
            length4Value = GetBytes((Single)tareValue);
            for (int i = 0; i < 4; i++)
                madeData[12 + i] = length4Value[3 - i];
            #endregion

            return madeData;
        }
        public byte[] Protocol_Modbus_Client_Write_Lane_Data_TCP(int laneIndex)
        {
            int index = 0;
            byte[] madeData = new byte[32];
            byte[] length4Value = new byte[4];
            byte[] length2Value = new byte[2];

            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[laneIndex].Update);
            for (int i = 0; i < 2; i++)
                madeData[i] = length2Value[1 - i];

            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[laneIndex].Grade);
            for (int i = 0; i < 2; i++)
                madeData[2 + i] = length2Value[1 - i];

            length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[laneIndex].WeightDouble);
            for (int i = 0; i < 4; i++)
                madeData[4 + i] = length4Value[3 - i];

            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[laneIndex].UnderCount);
            for (int i = 0; i < 4; i++)
                madeData[8 + i] = length4Value[3 - i];

            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[laneIndex].PassCount);
            for (int i = 0; i < 4; i++)
                madeData[12 + i] = length4Value[3 - i];

            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[laneIndex].OverCount);
            for (int i = 0; i < 4; i++)
                madeData[16 + i] = length4Value[3 - i];

            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[laneIndex].NGCount);
            for (int i = 0; i < 4; i++)
                madeData[20 + i] = length4Value[3 - i];

            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[laneIndex].ExNGCount);
            for (int i = 0; i < 4; i++)
                madeData[24 + i] = length4Value[3 - i];

            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[laneIndex].TotalCount);
            for (int i = 0; i < 4; i++)
                madeData[28 + i] = length4Value[3 - i];

            length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[laneIndex].FeedbackWeightDouble);
            for (int i = 0; i < 4; i++)
                madeData[32 + i] = length4Value[3 - i];

            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[laneIndex].FeedbackWeightInt);
            for (int i = 0; i < 4; i++)
                madeData[36 + i] = length4Value[3 - i];

            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[laneIndex].WeightInt);
            for (int i = 0; i < 4; i++)
                madeData[40 + i] = length4Value[3 - i];

            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[laneIndex].UpdateFeedbackData);
            for (int i = 0; i < 2; i++)
                madeData[44 + i] = length2Value[1 - i];

            return madeData;
        }
        private byte[] Protocol_Modbus_Server_Read_Lane_Data_TCP(byte[] readByte)
        {
            byte[] startAddressByte = new byte[2] { readByte[8], readByte[9] };
            byte[] numberOfRegisterByte = new byte[2] { readByte[10], readByte[11] };
            int startAddressInt;
            int numberOfRegisterInt;
            int madeDataIndex = 0;
            byte[] length2Value = new byte[2];
            byte[] length4Value = new byte[4];

            int equipmentStatus;
            if (this.EquipmentStatus == DataStore.EquipmentStatus.Start)
                equipmentStatus = 1;
            else
                equipmentStatus = 0;

            startAddressInt = Modbus.ToBigEndianAndInt(startAddressByte);
            numberOfRegisterInt = Modbus.ToBigEndianAndInt(numberOfRegisterByte);

            byte[] madeData = new byte[numberOfRegisterInt * 2];

            if (readByte[7] == ModbusFunctionCode.FunctionCode_03)
            {
                #region Read Holding Register(0x03)
                for (int j = startAddressInt; j < startAddressInt + numberOfRegisterInt; j++)
                {
                    switch (j)
                    {
                        #region Make data
                        case Modbus_40000_Address._01_Clear:
                            length2Value = GetBytes(this.Current40000ModbusData._40011_Clear);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case Modbus_40000_Address._02_ClearResult:
                            length2Value = GetBytes(this.Current40000ModbusData._40012_ClearResult);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case Modbus_40000_Address._03_Operation:
                            length2Value = GetBytes(this.Current40000ModbusData._40013_Operation);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case Modbus_40000_Address._04_OperationResult:
                            length2Value = GetBytes(this.Current40000ModbusData._40014_OperationResult);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case Modbus_40000_Address._05_ProductChange_High:
                            length4Value = GetBytes(this.Current40000ModbusData._40015_ProductChange);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case Modbus_40000_Address._06_ProductChange_Low:
                            length4Value = GetBytes(this.Current40000ModbusData._40015_ProductChange);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case Modbus_40000_Address._07_ProductChangeResult:
                            length2Value = GetBytes(this.Current40000ModbusData._40017_ProductChangeResult);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case Modbus_40000_Address._08_UnderRange_High:
                            length4Value = GetBytes(this.Current40000ModbusData._40018_UnderRange);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case Modbus_40000_Address._09_UnderRange_Low:
                            length4Value = GetBytes(this.Current40000ModbusData._40018_UnderRange);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case Modbus_40000_Address._10_UnderRangeResult:
                            length2Value = GetBytes(this.Current40000ModbusData._40020_UnderRangeResult);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case Modbus_40000_Address._11_PassRange_High:
                            length4Value = GetBytes(this.Current40000ModbusData._40021_PassRange);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case Modbus_40000_Address._12_PassRange_Low:
                            length4Value = GetBytes(this.Current40000ModbusData._40021_PassRange);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case Modbus_40000_Address._13_PassRangeResult:
                            length2Value = GetBytes(this.Current40000ModbusData._40023_PassRangeResult);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case Modbus_40000_Address._14_OverRange_High:
                            length4Value = GetBytes(this.Current40000ModbusData._40024_OverRange);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case Modbus_40000_Address._15_OverRange_Low:
                            length4Value = GetBytes(this.Current40000ModbusData._40024_OverRange);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case Modbus_40000_Address._16_OverRangeResult:
                            length2Value = GetBytes(this.Current40000ModbusData._40026_OverRangeResult);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case Modbus_40000_Address._17_TareWeight_High:
                            length4Value = GetBytes(this.Current40000ModbusData._40027_TareWeight);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case Modbus_40000_Address._18_TareWeight_Low:
                            length4Value = GetBytes(this.Current40000ModbusData._40027_TareWeight);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case Modbus_40000_Address._19_TareWeightResult:
                            length2Value = GetBytes(this.Current40000ModbusData._40029_TareWeightResult);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        default:
                            break;
                        #endregion
                    }
                    madeDataIndex += 2;
                }
                #endregion
            }
            else if (readByte[7] == ModbusFunctionCode.FunctionCode_04)
            {
                #region Read Input Register(0x04)
                double underValue = this.Current30000ModbusData.UnderValue;
                double passValue = this.Current30000ModbusData.PassValue;
                double overValue = this.Current30000ModbusData.OverValue;
                double tareValue = this.Current30000ModbusData.TareValue;
                double lowLimit = this.Current30000ModbusData.LowLimit;
                double highLimit = this.Current30000ModbusData.HighLimit;
                double deadZoneLow = this.Current30000ModbusData.DeadZoneLowLimit;
                double deadZoneHigh = this.Current30000ModbusData.DeadZoneHighLimit;

                for (int j = startAddressInt; j < startAddressInt + numberOfRegisterInt; j++)
                {
                    switch (j)
                    {
                        #region Common data
                        case (int)ModbusDefine._30000_Modbus.DecimalPoint:
                            length2Value = GetBytes(this.Current30000ModbusData.DecimalPoint);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.Operation_High:
                            length4Value = GetBytes(this.Current30000ModbusData.OperationStatus);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.Operation_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.OperationStatus);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.UnderRange_High_Float:
                            length4Value = GetBytes((Single)underValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.UnderRange_Low_Float:
                            length4Value = GetBytes((Single)underValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.PassRange_High_Float:
                            length4Value = GetBytes((Single)passValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.PassRange_Low_Float:
                            length4Value = GetBytes((Single)passValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.OverRange_High_Float:
                            length4Value = GetBytes((Single)overValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.OverRange_Low_Float:
                            length4Value = GetBytes((Single)overValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.TareRange_High_Float:
                            length4Value = GetBytes((Single)tareValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.TareRange_Low_Float:
                            length4Value = GetBytes((Single)tareValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.HighLimit_High_Float:
                            length4Value = GetBytes((Single)highLimit);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.HighLimit_Low_Float:
                            length4Value = GetBytes((Single)highLimit);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.DeadZoneHighLimit_High_Float:
                            length4Value = GetBytes((Single)deadZoneHigh);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.DeadZoneHighLimit_Low_Float:
                            length4Value = GetBytes((Single)deadZoneHigh);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.DeadZoneLowLimit_High_Float:
                            length4Value = GetBytes((Single)deadZoneLow);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.DeadZoneLowLimit_Low_Float:
                            length4Value = GetBytes((Single)deadZoneLow);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.LowLimit_High_Float:
                            length4Value = GetBytes((Single)lowLimit);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.LowLimit_Low_Float:
                            length4Value = GetBytes((Single)lowLimit);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.SampleCount_High:
                            length4Value = GetBytes(this.SystemConfig.FeedbackSampleCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.SampleCount_Low:
                            length4Value = GetBytes(this.SystemConfig.FeedbackSampleCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.IgnoreCount_High:
                            length4Value = GetBytes(this.SystemConfig.FeedbackIgnorePackages);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.IgnoreCount_Low:
                            length4Value = GetBytes(this.SystemConfig.FeedbackIgnorePackages);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.UnderRange_High_Int:
                            length4Value = GetBytes(int.Parse(this.CurrentProductItem.UnderRange));
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.UnderRange_Low_Int:
                            length4Value = GetBytes(int.Parse(this.CurrentProductItem.UnderRange));
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.PassRange_High_Int:
                            length4Value = GetBytes(int.Parse(this.CurrentProductItem.PassRange));
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.PassRange_Low_Int:
                            length4Value = GetBytes(int.Parse(this.CurrentProductItem.PassRange));
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.OverRange_High_Int:
                            length4Value = GetBytes(int.Parse(this.CurrentProductItem.OverRange));
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.OverRange_Low_Int:
                            length4Value = GetBytes(int.Parse(this.CurrentProductItem.OverRange));
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.TareRange_High_Int:
                            length4Value = GetBytes(int.Parse(this.CurrentProductItem.TareRange));
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.TareRange_Low_Int:
                            length4Value = GetBytes(int.Parse(this.CurrentProductItem.TareRange));
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.HighLimit_High_Int:
                            length4Value = GetBytes(int.Parse(this.CurrentFeedbackItem.HighLimit));
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.HighLimit_Low_Int:
                            length4Value = GetBytes(int.Parse(this.CurrentFeedbackItem.HighLimit));
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.DeadZoneHighLimit_High_Int:
                            length4Value = GetBytes(int.Parse(this.CurrentProductItem.PassRange) + int.Parse(this.CurrentFeedbackItem.DeadZone));
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.DeadZoneHighLimit_Low_Int:
                            length4Value = GetBytes(int.Parse(this.CurrentProductItem.PassRange) + int.Parse(this.CurrentFeedbackItem.DeadZone));
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.DeadZoneLowLimit_High_Int:
                            length4Value = GetBytes(int.Parse(this.CurrentProductItem.PassRange) - int.Parse(this.CurrentFeedbackItem.DeadZone));
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.DeadZoneLowLimit_Low_Int:
                            length4Value = GetBytes(int.Parse(this.CurrentProductItem.PassRange) - int.Parse(this.CurrentFeedbackItem.DeadZone));
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.LowLimit_High_Int:
                            length4Value = GetBytes(int.Parse(this.CurrentFeedbackItem.LowLimit));
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.LowLimit_Low_Int:
                            length4Value = GetBytes(int.Parse(this.CurrentFeedbackItem.LowLimit));
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        #endregion

                        #region #1
                        case (int)ModbusDefine._30000_Modbus._1_Update:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[0].Update);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_Grade:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[0].Grade);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_Weight_High_Float:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[0].WeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_Weight_Low_Float:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[0].WeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_UnderCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[0].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_UnderCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[0].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_PassCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[0].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_PassCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[0].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_OverCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[0].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_OverCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[0].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_NGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[0].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_NgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[0].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_ExNGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[0].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_ExNgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[0].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_TotalCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[0].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_TotalCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[0].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_FeedbackWeight_High_Float:
                            length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[0].FeedbackWeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_FeedbackWeight_Low_Float:
                            length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[0].FeedbackWeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_FeedbackWeight_High_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[0].FeedbackWeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_FeedbackWeight_Low_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[0].FeedbackWeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_Weight_High_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[0].WeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_Weight_Low_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[0].WeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_UpdateFeedbackData:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[0].UpdateFeedbackData);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        #endregion

                        #region #2
                        case (int)ModbusDefine._30000_Modbus._2_Update:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[1].Update);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._2_Grade:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[1].Grade);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._2_Weight_High:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[1].WeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._2_Weight_Low:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[1].WeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._2_UnderCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[1].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._2_UnderCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[1].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._2_PassCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[1].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._2_PassCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[1].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._2_OverCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[1].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._2_OverCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[1].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._2_NGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[1].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._2_NgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[1].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._2_ExNGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[1].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._2_ExNgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[1].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._2_TotalCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[1].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._2_TotalCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[1].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._2_FeedbackWeight_High_Float:
                            length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[1].FeedbackWeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._2_FeedbackWeight_Low_Float:
                            length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[1].FeedbackWeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._2_FeedbackWeight_High_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[1].FeedbackWeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._2_FeedbackWeight_Low_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[1].FeedbackWeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._2_Weight_High_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[1].WeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._2_Weight_Low_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[1].WeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._2_UpdateFeedbackData:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[1].UpdateFeedbackData);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        #endregion

                        #region #3
                        case (int)ModbusDefine._30000_Modbus._3_Update:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[2].Update);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._3_Grade:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[2].Grade);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._3_Weight_High:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[2].WeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._3_Weight_Low:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[2].WeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._3_UnderCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[2].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._3_UnderCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[2].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._3_PassCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[2].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._3_PassCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[2].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._3_OverCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[2].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._3_OverCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[2].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._3_NGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[2].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._3_NgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[2].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._3_ExNGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[2].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._3_ExNgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[2].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._3_TotalCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[2].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._3_TotalCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[2].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._3_FeedbackWeight_High_Float:
                            length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[2].FeedbackWeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._3_FeedbackWeight_Low_Float:
                            length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[2].FeedbackWeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._3_FeedbackWeight_High_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[2].FeedbackWeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._3_FeedbackWeight_Low_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[2].FeedbackWeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._3_Weight_High_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[2].WeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._3_Weight_Low_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[2].WeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._3_UpdateFeedbackData:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[2].UpdateFeedbackData);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        #endregion

                        #region #4
                        case (int)ModbusDefine._30000_Modbus._4_Update:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[3].Update);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._4_Grade:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[3].Grade);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._4_Weight_High:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[3].WeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._4_Weight_Low:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[3].WeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._4_UnderCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[3].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._4_UnderCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[3].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._4_PassCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[3].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._4_PassCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[3].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._4_OverCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[3].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._4_OverCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[3].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._4_NGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[3].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._4_NgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[3].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._4_ExNGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[3].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._4_ExNgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[3].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._4_TotalCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[3].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._4_TotalCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[3].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._4_FeedbackWeight_High_Float:
                            length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[3].FeedbackWeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._4_FeedbackWeight_Low_Float:
                            length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[3].FeedbackWeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._4_FeedbackWeight_High_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[3].FeedbackWeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._4_FeedbackWeight_Low_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[3].FeedbackWeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._4_Weight_High_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[3].WeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._4_Weight_Low_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[3].WeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._4_UpdateFeedbackData:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[3].UpdateFeedbackData);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        #endregion

                        #region #5
                        case (int)ModbusDefine._30000_Modbus._5_Update:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[4].Update);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._5_Grade:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[4].Grade);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._5_Weight_High:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[4].WeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._5_Weight_Low:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[4].WeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._5_UnderCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[4].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._5_UnderCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[4].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._5_PassCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[4].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._5_PassCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[4].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._5_OverCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[4].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._5_OverCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[4].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._5_NGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[4].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._5_NgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[4].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._5_ExNGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[4].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._5_ExNgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[4].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._5_TotalCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[4].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._5_TotalCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[4].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._5_FeedbackWeight_High_Float:
                            length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[4].FeedbackWeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._5_FeedbackWeight_Low_Float:
                            length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[4].FeedbackWeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._5_FeedbackWeight_High_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[4].FeedbackWeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._5_FeedbackWeight_Low_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[4].FeedbackWeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._5_Weight_High_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[4].WeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._5_Weight_Low_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[4].WeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._5_UpdateFeedbackData:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[4].UpdateFeedbackData);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        #endregion

                        #region #6
                        case (int)ModbusDefine._30000_Modbus._6_Update:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[5].Update);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._6_Grade:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[5].Grade);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._6_Weight_High:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[5].WeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._6_Weight_Low:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[5].WeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._6_UnderCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[5].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._6_UnderCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[5].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._6_PassCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[5].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._6_PassCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[5].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._6_OverCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[5].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._6_OverCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[5].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._6_NGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[5].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._6_NgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[5].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._6_ExNGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[5].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._6_ExNgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[5].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._6_TotalCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[5].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._6_TotalCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[5].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._6_FeedbackWeight_High_Float:
                            length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[5].FeedbackWeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._6_FeedbackWeight_Low_Float:
                            length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[5].FeedbackWeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._6_FeedbackWeight_High_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[5].FeedbackWeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._6_FeedbackWeight_Low_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[5].FeedbackWeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._6_Weight_High_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[5].WeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._6_Weight_Low_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[5].WeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._6_UpdateFeedbackData:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[5].UpdateFeedbackData);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        #endregion

                        default:
                            length2Value = GetBytes(0);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                    }
                    madeDataIndex += 2;
                }
                #endregion
            }

            return madeData;
        }
        private byte[] Protocol_Modbus_Read_Lane_Data_RTU(byte[] readByte)
        {
            byte[] startAddressByte = new byte[2] { readByte[2], readByte[3] };
            byte[] numberOfRegisterByte = new byte[2] { readByte[4], readByte[5] };
            int startAddressInt;
            int numberOfRegisterInt;
            int madeDataIndex = 0;
            byte[] length2Value = new byte[2];
            byte[] length4Value = new byte[4];

            startAddressInt = Modbus.ToBigEndianAndInt(startAddressByte);
            numberOfRegisterInt = Modbus.ToBigEndianAndInt(numberOfRegisterByte);

            byte[] madeData = new byte[numberOfRegisterInt * 2];

            if (readByte[1] == ModbusFunctionCode.FunctionCode_03)
            {
                #region Read Holding Register(0x03)
                for (int j = startAddressInt; j < startAddressInt + numberOfRegisterInt; j++)
                {
                    switch (j)
                    {
                        #region Make data
                        case Modbus_40000_Address._01_Clear:
                            length2Value = GetBytes(this.Current40000ModbusData._40011_Clear);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case Modbus_40000_Address._02_ClearResult:
                            length2Value = GetBytes(this.Current40000ModbusData._40012_ClearResult);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case Modbus_40000_Address._03_Operation:
                            length2Value = GetBytes(this.Current40000ModbusData._40013_Operation);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case Modbus_40000_Address._04_OperationResult:
                            length2Value = GetBytes(this.Current40000ModbusData._40014_OperationResult);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case Modbus_40000_Address._05_ProductChange_High:
                            length4Value = GetBytes(this.Current40000ModbusData._40015_ProductChange);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case Modbus_40000_Address._06_ProductChange_Low:
                            length4Value = GetBytes(this.Current40000ModbusData._40015_ProductChange);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case Modbus_40000_Address._07_ProductChangeResult:
                            length2Value = GetBytes(this.Current40000ModbusData._40017_ProductChangeResult);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case Modbus_40000_Address._08_UnderRange_High:
                            length4Value = GetBytes(this.Current40000ModbusData._40018_UnderRange);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case Modbus_40000_Address._09_UnderRange_Low:
                            length4Value = GetBytes(this.Current40000ModbusData._40018_UnderRange);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case Modbus_40000_Address._10_UnderRangeResult:
                            length2Value = GetBytes(this.Current40000ModbusData._40020_UnderRangeResult);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case Modbus_40000_Address._11_PassRange_High:
                            length4Value = GetBytes(this.Current40000ModbusData._40021_PassRange);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case Modbus_40000_Address._12_PassRange_Low:
                            length4Value = GetBytes(this.Current40000ModbusData._40021_PassRange);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case Modbus_40000_Address._13_PassRangeResult:
                            length2Value = GetBytes(this.Current40000ModbusData._40023_PassRangeResult);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case Modbus_40000_Address._14_OverRange_High:
                            length4Value = GetBytes(this.Current40000ModbusData._40024_OverRange);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case Modbus_40000_Address._15_OverRange_Low:
                            length4Value = GetBytes(this.Current40000ModbusData._40024_OverRange);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case Modbus_40000_Address._16_OverRangeResult:
                            length2Value = GetBytes(this.Current40000ModbusData._40026_OverRangeResult);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case Modbus_40000_Address._17_TareWeight_High:
                            length4Value = GetBytes(this.Current40000ModbusData._40027_TareWeight);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case Modbus_40000_Address._18_TareWeight_Low:
                            length4Value = GetBytes(this.Current40000ModbusData._40027_TareWeight);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case Modbus_40000_Address._19_TareWeightResult:
                            length2Value = GetBytes(this.Current40000ModbusData._40029_TareWeightResult);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        default:
                            break;
                        #endregion
                    }
                    madeDataIndex += 2;
                }
                #endregion
            }
            else if (readByte[1] == ModbusFunctionCode.FunctionCode_04)
            {
                #region Read Input Register(0x04)
                double underValue = this.Current30000ModbusData.UnderValue;
                double passValue = this.Current30000ModbusData.PassValue;
                double overValue = this.Current30000ModbusData.OverValue;
                double tareValue = this.Current30000ModbusData.TareValue;
                double lowLimit = this.Current30000ModbusData.LowLimit;
                double highLimit = this.Current30000ModbusData.HighLimit;
                double deadZoneLow = this.Current30000ModbusData.DeadZoneLowLimit;
                double deadZoneHigh = this.Current30000ModbusData.DeadZoneHighLimit;

                int equipmentStatus;
                if (this.EquipmentStatus == DataStore.EquipmentStatus.Start)
                    equipmentStatus = 1;
                else
                    equipmentStatus = 0;

                for (int j = startAddressInt; j < startAddressInt + numberOfRegisterInt; j++)
                {
                    switch (j)
                    {
                        #region Common data
                        case (int)ModbusDefine._30000_Modbus.DecimalPoint:
                            length2Value = GetBytes(this.Current30000ModbusData.DecimalPoint);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.Operation_High:
                            length4Value = GetBytes(this.Current30000ModbusData.OperationStatus);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.Operation_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.OperationStatus);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.UnderRange_High_Float:
                            length4Value = GetBytes((Single)underValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.UnderRange_Low_Float:
                            length4Value = GetBytes((Single)underValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.PassRange_High_Float:
                            length4Value = GetBytes((Single)passValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.PassRange_Low_Float:
                            length4Value = GetBytes((Single)passValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.OverRange_High_Float:
                            length4Value = GetBytes((Single)overValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.OverRange_Low_Float:
                            length4Value = GetBytes((Single)overValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.TareRange_High_Float:
                            length4Value = GetBytes((Single)tareValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.TareRange_Low_Float:
                            length4Value = GetBytes((Single)tareValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.HighLimit_High_Float:
                            length4Value = GetBytes((Single)highLimit);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.HighLimit_Low_Float:
                            length4Value = GetBytes((Single)highLimit);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.DeadZoneHighLimit_High_Float:
                            length4Value = GetBytes((Single)deadZoneHigh);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.DeadZoneHighLimit_Low_Float:
                            length4Value = GetBytes((Single)deadZoneHigh);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.DeadZoneLowLimit_High_Float:
                            length4Value = GetBytes((Single)deadZoneLow);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.DeadZoneLowLimit_Low_Float:
                            length4Value = GetBytes((Single)deadZoneLow);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.LowLimit_High_Float:
                            length4Value = GetBytes((Single)lowLimit);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.LowLimit_Low_Float:
                            length4Value = GetBytes((Single)lowLimit);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.SampleCount_High:
                            length4Value = GetBytes(this.SystemConfig.FeedbackSampleCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.SampleCount_Low:
                            length4Value = GetBytes(this.SystemConfig.FeedbackSampleCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.IgnoreCount_High:
                            length4Value = GetBytes(this.SystemConfig.FeedbackIgnorePackages);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.IgnoreCount_Low:
                            length4Value = GetBytes(this.SystemConfig.FeedbackIgnorePackages);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.UnderRange_High_Int:
                            length4Value = GetBytes(int.Parse(this.CurrentProductItem.UnderRange));
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.UnderRange_Low_Int:
                            length4Value = GetBytes(int.Parse(this.CurrentProductItem.UnderRange));
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.PassRange_High_Int:
                            length4Value = GetBytes(int.Parse(this.CurrentProductItem.PassRange));
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.PassRange_Low_Int:
                            length4Value = GetBytes(int.Parse(this.CurrentProductItem.PassRange));
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.OverRange_High_Int:
                            length4Value = GetBytes(int.Parse(this.CurrentProductItem.OverRange));
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.OverRange_Low_Int:
                            length4Value = GetBytes(int.Parse(this.CurrentProductItem.OverRange));
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.TareRange_High_Int:
                            length4Value = GetBytes(int.Parse(this.CurrentProductItem.TareRange));
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.TareRange_Low_Int:
                            length4Value = GetBytes(int.Parse(this.CurrentProductItem.TareRange));
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.HighLimit_High_Int:
                            length4Value = GetBytes(int.Parse(this.CurrentFeedbackItem.HighLimit));
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.HighLimit_Low_Int:
                            length4Value = GetBytes(int.Parse(this.CurrentFeedbackItem.HighLimit));
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.DeadZoneHighLimit_High_Int:
                            length4Value = GetBytes(int.Parse(this.CurrentProductItem.PassRange) + int.Parse(this.CurrentFeedbackItem.DeadZone));
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.DeadZoneHighLimit_Low_Int:
                            length4Value = GetBytes(int.Parse(this.CurrentProductItem.PassRange) + int.Parse(this.CurrentFeedbackItem.DeadZone));
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.DeadZoneLowLimit_High_Int:
                            length4Value = GetBytes(int.Parse(this.CurrentProductItem.PassRange) - int.Parse(this.CurrentFeedbackItem.DeadZone));
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.DeadZoneLowLimit_Low_Int:
                            length4Value = GetBytes(int.Parse(this.CurrentProductItem.PassRange) - int.Parse(this.CurrentFeedbackItem.DeadZone));
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.LowLimit_High_Int:
                            length4Value = GetBytes(int.Parse(this.CurrentFeedbackItem.LowLimit));
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus.LowLimit_Low_Int:
                            length4Value = GetBytes(int.Parse(this.CurrentFeedbackItem.LowLimit));
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        #endregion

                        #region #1
                        case (int)ModbusDefine._30000_Modbus._1_Update:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[0].Update);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_Grade:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[0].Grade);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_Weight_High_Float:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[0].WeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_Weight_Low_Float:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[0].WeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_UnderCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[0].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_UnderCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[0].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_PassCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[0].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_PassCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[0].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_OverCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[0].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_OverCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[0].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_NGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[0].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_NgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[0].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_ExNGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[0].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_ExNgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[0].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_TotalCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[0].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_TotalCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[0].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_FeedbackWeight_High_Float:
                            length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[0].FeedbackWeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_FeedbackWeight_Low_Float:
                            length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[0].FeedbackWeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_FeedbackWeight_High_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[0].FeedbackWeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_FeedbackWeight_Low_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[0].FeedbackWeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_Weight_High_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[0].WeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_Weight_Low_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[0].WeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_UpdateFeedbackData:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[0].UpdateFeedbackData);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        #endregion

                        #region #2
                        case (int)ModbusDefine._30000_Modbus._2_Update:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[1].Update);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._2_Grade:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[1].Grade);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._2_Weight_High:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[1].WeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._2_Weight_Low:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[1].WeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._2_UnderCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[1].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._2_UnderCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[1].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._2_PassCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[1].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._2_PassCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[1].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._2_OverCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[1].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._2_OverCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[1].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._2_NGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[1].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._2_NgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[1].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._2_ExNGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[1].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._2_ExNgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[1].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._2_TotalCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[1].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._2_TotalCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[1].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._2_FeedbackWeight_High_Float:
                            length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[1].FeedbackWeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._2_FeedbackWeight_Low_Float:
                            length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[1].FeedbackWeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._2_FeedbackWeight_High_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[1].FeedbackWeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._2_FeedbackWeight_Low_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[1].FeedbackWeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._2_Weight_High_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[1].WeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._2_Weight_Low_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[1].WeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._2_UpdateFeedbackData:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[1].UpdateFeedbackData);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        #endregion

                        #region #3
                        case (int)ModbusDefine._30000_Modbus._3_Update:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[2].Update);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._3_Grade:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[2].Grade);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._3_Weight_High:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[2].WeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._3_Weight_Low:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[2].WeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._3_UnderCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[2].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._3_UnderCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[2].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._3_PassCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[2].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._3_PassCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[2].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._3_OverCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[2].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._3_OverCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[2].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._3_NGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[2].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._3_NgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[2].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._3_ExNGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[2].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._3_ExNgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[2].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._3_TotalCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[2].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._3_TotalCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[2].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._3_FeedbackWeight_High_Float:
                            length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[2].FeedbackWeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._3_FeedbackWeight_Low_Float:
                            length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[2].FeedbackWeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._3_FeedbackWeight_High_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[2].FeedbackWeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._3_FeedbackWeight_Low_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[2].FeedbackWeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._3_Weight_High_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[2].WeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._3_Weight_Low_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[2].WeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._3_UpdateFeedbackData:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[2].UpdateFeedbackData);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        #endregion

                        #region #4
                        case (int)ModbusDefine._30000_Modbus._4_Update:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[3].Update);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._4_Grade:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[3].Grade);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._4_Weight_High:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[3].WeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._4_Weight_Low:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[3].WeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._4_UnderCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[3].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._4_UnderCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[3].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._4_PassCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[3].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._4_PassCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[3].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._4_OverCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[3].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._4_OverCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[3].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._4_NGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[3].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._4_NgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[3].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._4_ExNGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[3].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._4_ExNgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[3].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._4_TotalCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[3].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._4_TotalCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[3].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._4_FeedbackWeight_High_Float:
                            length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[3].FeedbackWeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._4_FeedbackWeight_Low_Float:
                            length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[3].FeedbackWeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._4_FeedbackWeight_High_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[3].FeedbackWeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._4_FeedbackWeight_Low_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[3].FeedbackWeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._4_Weight_High_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[3].WeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._4_Weight_Low_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[3].WeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._4_UpdateFeedbackData:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[3].UpdateFeedbackData);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        #endregion

                        #region #5
                        case (int)ModbusDefine._30000_Modbus._5_Update:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[4].Update);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._5_Grade:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[4].Grade);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._5_Weight_High:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[4].WeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._5_Weight_Low:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[4].WeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._5_UnderCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[4].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._5_UnderCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[4].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._5_PassCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[4].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._5_PassCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[4].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._5_OverCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[4].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._5_OverCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[4].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._5_NGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[4].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._5_NgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[4].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._5_ExNGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[4].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._5_ExNgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[4].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._5_TotalCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[4].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._5_TotalCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[4].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._5_FeedbackWeight_High_Float:
                            length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[4].FeedbackWeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._5_FeedbackWeight_Low_Float:
                            length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[4].FeedbackWeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._5_FeedbackWeight_High_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[4].FeedbackWeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._5_FeedbackWeight_Low_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[4].FeedbackWeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._5_Weight_High_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[4].WeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._5_Weight_Low_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[4].WeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._5_UpdateFeedbackData:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[4].UpdateFeedbackData);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        #endregion

                        #region #6
                        case (int)ModbusDefine._30000_Modbus._6_Update:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[5].Update);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._6_Grade:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[5].Grade);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._6_Weight_High:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[5].WeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._6_Weight_Low:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[5].WeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._6_UnderCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[5].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._6_UnderCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[5].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._6_PassCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[5].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._6_PassCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[5].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._6_OverCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[5].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._6_OverCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[5].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._6_NGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[5].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._6_NgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[5].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._6_ExNGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[5].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._6_ExNgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[5].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._6_TotalCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[5].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._6_TotalCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[5].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._6_FeedbackWeight_High_Float:
                            length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[5].FeedbackWeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._6_FeedbackWeight_Low_Float:
                            length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[5].FeedbackWeightDouble);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._6_FeedbackWeight_High_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[5].FeedbackWeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._6_FeedbackWeight_Low_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[5].FeedbackWeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._6_Weight_High_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[5].WeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._6_Weight_Low_Int:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[5].WeightInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._6_UpdateFeedbackData:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[5].UpdateFeedbackData);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        #endregion

                        default:
                            length2Value = GetBytes(0);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                    }
                    madeDataIndex += 2;
                }
                #endregion
            }

            return madeData;
        }
        #endregion
        #region Serial CH3
        public void SerialPort3_Open()
        {
            string fullPath = "";

            if (this.smartSerialPort3.IsOpen == true)
                this.smartSerialPort3.Close();

            if (this.SystemConfig.Serial3Mode != 0)
            {
                switch (this.SystemConfig.Serial3BaudRate)
                {
                    case 9600:
                        this.smartSerialPort3.Baud_Rate = SmartSerialPort.BAUDRATE._9600bps;
                        break;
                    case 19200:
                        this.smartSerialPort3.Baud_Rate = SmartSerialPort.BAUDRATE._19200bps;
                        break;
                    case 38400:
                        this.smartSerialPort3.Baud_Rate = SmartSerialPort.BAUDRATE._38400bps;
                        break;
                    case 115200:
                        this.smartSerialPort3.Baud_Rate = SmartSerialPort.BAUDRATE._115200bps;
                        break;
                    default:
                        this.smartSerialPort3.Baud_Rate = SmartSerialPort.BAUDRATE._9600bps;
                        break;
                }

                this.smartSerialPort3.Open();
            }

            #region Test 용 통신 로그
            fullPath = this.PathDataBackupFolder + "COM3log.txt";
            this.smartFileSerialPort3Log.FilePathName = fullPath;
            //this.IsCom3LogOpen = true;
            //this.smartFileSerialPort3Log.Open();
            #endregion
        }
        public void SerialPort3_Close()
        {
            this.smartFileSerialPort3Log.Close();
            this.smartSerialPort3.Close();
        }

        public void SerialPort3_Write(string data)
        {
            this.smartSerialPort3.WriteFrame(data, SmartSerialPort.CODETYPES.ASCIICODE);

            // 통신 확인 로그
            if (this.IsCom3LogOpen == true)
                this.smartFileSerialPort3Log.WriteString(string.Format("Send ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, data));
        }
        private int SerialPort3_Write(string command, string id, string address, string data)
        {
            int ret = 0;
            string chkSum = "cc";
            StringBuilder sb = new StringBuilder();

            sb.Append(command);
            sb.Append(id);
            sb.Append(Helper.StringZeroFillDigits4(data.Length.ToString()));
            sb.Append(address);
            sb.Append(data);

            chkSum = Helper.Checksumcalculator(sb.ToString());

            sb.Append(chkSum);

            if (this.smartSerialPort3.IsOpen == true)
                this.smartSerialPort3.WriteFrame(sb.ToString(), SmartSerialPort.CODETYPES.ASCIICODE);

            // 통신 확인 로그
            if (this.IsCom3LogOpen == true)
                this.smartFileSerialPort3Log.WriteString(string.Format("Send ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, sb.ToString()));

            return ret;
        }
        #region Feedback Board
        private void SerialPort3_ReceiveDataFbBoard()
        {
            int ret = 0;
            string strTemp = "";
            byte[] readByte;
            StringBuilder sb = new StringBuilder();

            SmartSerialPort.FRAMEDATAREADSTATUS receiveDataState = SmartSerialPort.FRAMEDATAREADSTATUS.EMPTY;

            receiveDataState = this.smartSerialPort3.ReadQueue(out readByte);
            strTemp = Encoding.Default.GetString(readByte, 0, readByte.Length);

            if ((receiveDataState == SmartSerialPort.FRAMEDATAREADSTATUS.EMPTY) || (receiveDataState == SmartSerialPort.FRAMEDATAREADSTATUS.FAILDATA))
            {
                return;
            }

            try
            {
                switch (strTemp[0])
                {
                    case 'C':
                        if ((ret = this.SerialPort3_ReceiveFbBoardCommamdC(strTemp)) != 0)
                            return;
                        break;
                    case 'P':
                        if ((ret = this.SerialPort3_ReceiveFbBoardCommamdP(strTemp)) != 0)
                            return;
                        break;
                    default:
                        break;
                }
            }
            catch
            {
            }
        }
        private int SerialPort3_ReceiveFbBoardCommamdC(string strTemp)
        {
            int ret = 0;
            string cmd = "";

            if (this.Checksumcalculator(strTemp) == false)
            {
                // 로그
                if (this.IsCom3LogOpen == true)
                    this.smartFileSerialPort3Log.WriteString(string.Format("Receive ({0:yyyy-MM-dd HH:mm:ss}): {1} : Receive Command Data CHKSUM Error", DateTime.Now, strTemp));
                return ret = -1;
            }

            // 로그
            if (this.IsCom3LogOpen == true)
                this.smartFileSerialPort3Log.WriteString(string.Format("Receive ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, strTemp));

            cmd = strTemp.Substring(0, 3);

            switch (cmd)
            {
                case "CI0":
                    this.timerTimeoutOPT4_OnlineCheck.Enabled = false;
                    this.SerialPort3_FbBoardBooting();
                    break;
                case "CT0":
                    this.timerTimeoutOPT4_OnlineCheck.Enabled = false;
                    this.ChildFormMainDisplay.UpdateFeedbackBoardStatusDisplay(true);
                    this.timerTimeoutOPT4_OnlineCheck.Enabled = true;
                    break;
                default:
                    break;
            }

            return ret;
        }
        private int SerialPort3_ReceiveFbBoardCommamdP(string strTemp)
        {
            int ret = 0;
            string cmd = "", address = "", lane = "", receiveData = "";

            // SIZE 확인
            if (this.SizeCheck("P", strTemp) == false)
            {
                // 로그
                if (this.IsCom3LogOpen == true)
                    this.smartFileSerialPort3Log.WriteString(string.Format("Receive ({0:yyyy-MM-dd HH:mm:ss}): {1} : Receive Stream Data SIZE Error", DateTime.Now, strTemp));
                return ret = -1;
            }
            // CHKSUM 확인
            if (this.Checksumcalculator(strTemp) == false)
            {
                // 로그
                if (this.IsCom3LogOpen == true)
                    this.smartFileSerialPort3Log.WriteString(string.Format("Receive ({0:yyyy-MM-dd HH:mm:ss}): {1} : Receive Stream Data CHKSUM Error", DateTime.Now, strTemp));
                return ret = -1;
            }

            // 로그
            if (this.IsCom3LogOpen == true)
                this.smartFileSerialPort3Log.WriteString(string.Format("Receive ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, strTemp));

            cmd = strTemp.Substring(0, 3);
            lane = strTemp.Substring(5, 1);
            address = strTemp.Substring(10, 4);
            receiveData = strTemp.Substring(14, strTemp.Length - 16);

            switch (cmd)
            {
                case "PW0":
                    if ((ret = this.SerialPort3_ReceiveFbBoardCommamdPW0(lane, address, receiveData)) != 0)
                        return ret = -1;
                    break;
                default:
                    break;
            }

            return ret;
        }
        private int SerialPort3_ReceiveFbBoardCommamdPW0(string lane, string address, string receiveData)
        {
            int ret = 0;
            string value = "";

            DataStore.ResponseData response = DataStore.ResponseData.NAK;

            try
            {
                if (receiveData == "0000")
                    response = DataStore.ResponseData.NAK;
                else
                    response = DataStore.ResponseData.ACK;

                switch (address)
                {
                    case "6203":
                        if (response == DataStore.ResponseData.ACK)
                        {
                            this.timerTimeoutOPT4.Enabled = false;
                            this.CurrentFeedbackItem.RetryCount = 0;
                            this.CurrentFeedbackItem.DataTransfer = DataStore.FeedbackBoardDataTransfer.None;

                            if (this.CurrentFeedbackItem.IsBootingComplete == false)
                            {
                                this.CurrentFeedbackItem.DataTransfer = DataStore.FeedbackBoardDataTransfer.Step2_6208;

                                value = Helper.StringZeroFillDigits4(this.SystemConfig.FeedbackCorrectionRate.ToString());
                                this.SerialPort3_FbBoardTransfer(CommunicationAddress._6208_FeedbackCollectionRate, value);
                            }

                            this.ChildFormMainDisplay.UpdateFeedbackBoardStatusDisplay(true);
                        }
                        else
                        {
                            value = Helper.StringZeroFillDigits4(this.SystemConfig.FeedbackPulseWidth.ToString());
                            this.SerialPort3_FbBoardTransfer(CommunicationAddress._6203_FeedbackPulseWidth, value);

                            this.ChildFormMainDisplay.UpdateFeedbackBoardStatusDisplay(false);
                        }
                        break;
                    case "6208":
                        if (response == DataStore.ResponseData.ACK)
                        {
                            this.timerTimeoutOPT4.Enabled = false;
                            this.CurrentFeedbackItem.RetryCount = 0;
                            this.CurrentFeedbackItem.DataTransfer = DataStore.FeedbackBoardDataTransfer.None;

                            if (this.CurrentFeedbackItem.IsBootingComplete == false)
                            {
                                this.CurrentFeedbackItem.IsBootingComplete = true;
                                this.timerTimeoutOPT4_OnlineCheck.Enabled = true;
                                this.CurrentFeedbackItem.DataTransfer = DataStore.FeedbackBoardDataTransfer.None;
                            }

                            this.ChildFormMainDisplay.UpdateFeedbackBoardStatusDisplay(true);
                        }
                        else
                        {
                            value = Helper.StringZeroFillDigits4(this.SystemConfig.FeedbackCorrectionRate.ToString());
                            this.SerialPort3_FbBoardTransfer(CommunicationAddress._6208_FeedbackCollectionRate, value);

                            this.ChildFormMainDisplay.UpdateFeedbackBoardStatusDisplay(false);
                        }
                        break;
                    default:
                        break;
                }
            }
            catch
            {
                ret = -1;
            }

            return ret;
        }

        private void SerialPort3_FbBoardBooting()
        {
            string value = "";

            this.timerTimeoutOPT4.Enabled = false;
            this.CurrentFeedbackItem.IsBootingComplete = false;
            this.CurrentFeedbackItem.RetryCount = 0;
            this.CurrentFeedbackItem.DataTransfer = DataStore.FeedbackBoardDataTransfer.Step1_6203;

            value = Helper.StringZeroFillDigits4(this.SystemConfig.FeedbackPulseWidth.ToString());
            this.SerialPort3_FbBoardTransfer(CommunicationAddress._6203_FeedbackPulseWidth, value);
        }
        public void SerialPort3_FbBoardTransfer(string address, string data)
        {
            this.SerialPort3_Write(CommunicationCommand.Write, CommunicationID.MainBoard, address, data);
            this.timerTimeoutOPT4.Enabled = true;
        }

        public void SerialPort3_FbBoardTestSend(int lane)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(string.Format("IN{0:D3}", this.SystemConfig.EquipmentID));
            sb.Append(string.Format("{0:D4}", this.SystemConfig.ProductNumber));
            sb.Append(string.Format("{0:D2}", lane));
            sb.Append("+");
            sb.Append(Helper.StringBlankFillDigits6(Helper.DoubleToString(0.5, this.SystemConfig.DecimalPlaces)));

            this.SerialPort3_Write(sb.ToString());

            if (this.IsCom3LogOpen == true)
                this.smartFileSerialPort3Log.WriteString(string.Format("Send ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, sb.ToString()));
        }
        #endregion
        #endregion
        #region Ethernet
        private void EthernetWrite(string etherData)
        {
            if (this.SystemConfig.EthernetOperationMode == 1)
            {
                if (this.smartTCPMultiServer.ClientInfoList != null)
                {
                    foreach (SmartTCPMultiServer.CLIENTSINFOS client in this.smartTCPMultiServer.ClientInfoList)
                        this.EthernetServerSendMessage(client, etherData);
                }
            }
            else
                this.EthernetClientWeightData(etherData);
        }

        #region Server
        public void EthernetServerStart()
        {
            if (this.smartTCPMultiServer.IsStart == false)
            {
                this.ChildFormCommunication.DisplayLabelLocalPort(false);
                this.smartTCPMultiServer.Port = this.SystemConfig.EthernetLocalPort;
                this.smartTCPMultiServer.Start();
            }
        }
        public void EthernetServerStop()
        {
            if (this.smartTCPMultiServer.IsStart == true)
            {
                this.ChildFormCommunication.DisplayLabelLocalPort(true);
                this.smartTCPMultiServer.Stop();
            }
        }
        public void EthernetServerSendMessage(SmartTCPMultiServer.CLIENTSINFOS client, string msg)
        {
            this.smartTCPMultiServer.SendStringASCIIID(client.strID, msg);
        }
        public void EthernetServerSendMessage(SmartTCPMultiServer.CLIENTSINFOS client, byte[] bytes)
        {
            this.smartTCPMultiServer.SendByteByClientID(client.strID, bytes);
        }
        #endregion

        #region Client
        Thread cpClientThread;

        public void EthernetClientConnect()
        {
            if (this.IsEthernetThreadStop == false)
                return;  // Online 경우 
            if (this.SystemConfig.IsEthernetEnable == false)
            {
                this.TextStatusOut("<Disable");
                return;
            }

            if (string.Compare(this.SystemConfig.EthernetServerAddress, "0.0.0.0") == 0)
            {
                this.TextStatusOut("<Addr Err");
                return;
            }

            try
            {
                this.cpClientThread = new Thread(new ThreadStart(EthernetClientReceiveThread));

                this.cpClientThread.IsBackground = true;

                this.cpClientThread.Start();
            }
            catch
            {
                TextStatusOut(">Thread Error");
            }
        }
        public void EthernetClientDisconnect()
        {
            this.IsEthernetThreadStop = true;
            this.IsModbusCommonDataSend = false;
            this.DelegateUISeverStatus(false);
            if (null != this.EthernetStmReader)
                this.EthernetStmReader.Close();

            if (null != this.EthernetStmWriter)
                this.EthernetStmWriter.Close();

            if (null != this.EthernetNetStream)
                this.EthernetNetStream.Close();

            if (null != this.EthernetTcpClient)
                this.EthernetTcpClient.Close();

            if (this.IsCommunicationLogOpen == true)
                this.smartFileCommunicationLog.WriteString(string.Format("Client ({0:yyyy-MM-dd HH:mm:ss}): Disconnect", DateTime.Now));
        }

        private void EthernetClientReceiveThread()
        {
            //this.cpClientThread.Abort();

            int nConnectPort = Convert.ToInt32(this.SystemConfig.EthernetServerPort);
            try
            {
                this.DelegateTextStatusOut(">Now Connecting..");
                this.EthernetTcpClient = new TcpClient(this.SystemConfig.EthernetServerAddress, nConnectPort);

                this.EthernetNetStream = EthernetTcpClient.GetStream();
                this.EthernetStmReader = new StreamReader(EthernetNetStream);
                this.EthernetStmWriter = new StreamWriter(EthernetNetStream);

                this.DelegateUISeverStatus(true);
                this.DelegateTextStatusOut(">Connected Server");

                if (this.IsCommunicationLogOpen == true)
                    this.smartFileCommunicationLog.WriteString(string.Format("Client ({0:yyyy-MM-dd HH:mm:ss}): Connect", DateTime.Now));

                this.IsEthernetThreadStop = false;

                // 판정 데이터 전송
                if (this.IsEthernetTransferData == true)
                {
                    this.IsEthernetTransferData = false;
                    Type type = this.EthernetTransferData.GetType();
                    if (type == typeof(string))
                        this.DelegateTransferData((string)this.EthernetTransferData);
                    else if (type == typeof(byte[]))
                        this.DelegateTransferData((byte[])this.EthernetTransferData);
                    else if (type == typeof(byte))
                        this.DelegateTransferData((byte)this.EthernetTransferData);
                }

                while (this.IsEthernetThreadStop == false)
                {
                    string strRecvMsg = "";
                    char[] datas = new char[12];
                    int sum = 0;

                    try
                    {
                        //strRecvMsg = this.EthernetStmReader.ReadLine();
                        this.EthernetStmReader.Read(datas, 0, datas.Length);
                        for (int i = 0; i < datas.Length; i++)
                            sum += datas[i];
                        if (sum == 0)
                            return;

                        strRecvMsg = BitConverter.ToString(Encoding.UTF8.GetBytes(datas));

                        if (this.IsCommunicationLogOpen == true)
                            this.smartFileCommunicationLog.WriteString(string.Format("Client Receive ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, strRecvMsg));

                        if (null == strRecvMsg)
                        {
                            this.DelegateTextStatusOut(">Server Out");
                            this.IsEthernetThreadStop = true;
                            break;
                        }

                        this.DelegateTextStatusOut(strRecvMsg);
                    }
                    catch
                    {
                        this.DelegateTextStatusOut(">Server Out");
                        this.IsEthernetThreadStop = true;
                    }
                }
            }
            catch
            {
                this.DelegateTextStatusOut(">Connect Fail !");
            }
            finally
            {
                this.IsEthernetThreadStop = true;
                this.DelegateUISeverStatus(false);
                this.DelegateTextStatusOut(">Disconnected Server");
                if (null != this.EthernetStmReader)
                    this.EthernetStmReader.Close();

                if (null != this.EthernetStmWriter)
                    this.EthernetStmWriter.Close();

                if (null != this.EthernetNetStream)
                    this.EthernetNetStream.Close();

                if (null != this.EthernetTcpClient)
                    this.EthernetTcpClient.Close();

                if (this.IsCommunicationLogOpen == true)
                    this.smartFileCommunicationLog.WriteString(string.Format("Client ({0:yyyy-MM-dd HH:mm:ss}): Disconnect", DateTime.Now));
            }

            return;
        }

        private void UIServerStatus(bool status)
        {
            if (this.ChildFormMainDisplay != null)
                this.ChildFormMainDisplay.UpdateEthernetStatusDisplay(status);
        }
        private void DelegateUISeverStatus(bool status)
        {
            this.Invoke(new UIServerStatusCallback(this.UIServerStatus), status);
        }

        private void TextStatusOut(string value)
        {
            if (this.ChildFormCommunication != null)
                this.ChildFormCommunication.UpdateEthernetStatusDisplay(value);
        }
        private void DelegateTextStatusOut(string value)
        {
            this.Invoke(new TextStatusCallback(this.TextStatusOut), value);
        }

        private void DelegateTransferData(string data)
        {
            this.Invoke(new TransferDataStringCallback(this.EthernetClientSendMessage), data);
        }
        private void DelegateTransferData(byte[] data)
        {
            this.Invoke(new TransferDataByteArrayCallback(this.EthernetClientSendMessage), data);
        }
        private void DelegateTransferData(byte data)
        {
            this.Invoke(new TransferDataStringCallback(this.EthernetClientSendMessage), data);
        }
        public void EthernetClientSendMessage(string msg)
        {
            try
            {
                this.EthernetStmWriter.Write(msg);
                this.EthernetStmWriter.Flush();

                // 로그
                if (this.IsCommunicationLogOpen == true)
                    this.smartFileCommunicationLog.WriteString(string.Format("Client Send ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, msg));
            }
            catch
            {
                this.DelegateUISeverStatus(false);
                this.DelegateTextStatusOut("> Disconnect");
            }
        }
        public void EthernetClientSendMessage(byte[] msg)
        {
            try
            {
                this.EthernetStmWriter.BaseStream.Write(msg, 0, msg.Length);
                this.EthernetStmWriter.Flush();

                // 로그
                if (this.IsCommunicationLogOpen == true)
                    this.smartFileCommunicationLog.WriteString(string.Format("Client Send ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, BitConverter.ToString(msg)));
            }
            catch
            {
                this.DelegateUISeverStatus(false);
                this.DelegateTextStatusOut("> Disconnect");
            }
        }
        public void EthernetClientSendMessage(byte msg)
        {
            try
            {
                this.EthernetStmWriter.WriteLine(msg);
                this.EthernetStmWriter.Flush();

                // 로그
                if (this.IsCommunicationLogOpen == true)
                    this.smartFileCommunicationLog.WriteString(string.Format("Client Send ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, msg));
            }
            catch
            {
                this.DelegateUISeverStatus(false);
                this.DelegateTextStatusOut("> Disconnect");
            }
        }
        public void EthernetClientWeightData(string strTemp)
        {
            this.IsEthernetTransferData = true;
            this.EthernetTransferData = strTemp;

            if (this.IsEthernetThreadStop == true)
                this.EthernetClientConnect();
            else
                this.EthernetClientSendMessage((string)this.EthernetTransferData);
        }
        public void EthernetClientWeightData(byte temp)
        {
            this.IsEthernetTransferData = true;
            this.EthernetTransferData = temp;

            if (this.IsEthernetThreadStop == true)
                this.EthernetClientConnect();
            else
                this.EthernetClientSendMessage((byte)this.EthernetTransferData);
        }
        public void EthernetClientWeightDataForModbus(byte[] bytes)
        {
            this.IsEthernetTransferData = true;
            this.EthernetTransferData = bytes;

            if (this.IsEthernetThreadStop == true)
                this.EthernetClientConnect();
            else
                this.EthernetClientSendMessage(bytes);
        }
        #endregion
        #endregion
        #region Modbus
        public static byte[] GetBytes(int argument)
        {
            byte[] byteArray = BitConverter.GetBytes(argument);
            return byteArray;
        }
        public static byte[] GetBytes(Single argument)
        {
            byte[] byteArray = BitConverter.GetBytes(argument);
            return byteArray;
        }
        public static byte[] GetBytes(uint argument)
        {
            byte[] byteArray = BitConverter.GetBytes(argument);
            return byteArray;
        }

        public ushort Grade(DataStore.JudgmentStatus status)
        {
            ushort judgmentStatus = 0;

            switch (status)
            {
                case DataStore.JudgmentStatus.Over:
                    judgmentStatus = 0;
                    break;
                case DataStore.JudgmentStatus.Pass:
                    judgmentStatus = 1;
                    break;
                case DataStore.JudgmentStatus.Under:
                    judgmentStatus = 2;
                    break;
                case DataStore.JudgmentStatus.Double:
                    judgmentStatus = 3;
                    break;
                case DataStore.JudgmentStatus.EXNg:
                    judgmentStatus = 4;
                    break;
                case DataStore.JudgmentStatus.SensorError:
                    judgmentStatus = 5;
                    break;
                default:
                    judgmentStatus = 0;
                    break;
            }

            return judgmentStatus;
        }

        public void Update30000Operation()
        {
            if (this.EquipmentStatus == DataStore.EquipmentStatus.Start)
                this.Current30000ModbusData.OperationStatus = 1;
            else
                this.Current30000ModbusData.OperationStatus = 0;
        }
        public void Update30000DecimalPoint()
        {
            this.Current30000ModbusData.DecimalPoint = short.Parse(this.SystemConfig.DecimalPlaces.ToString());
        }
        private void Update30000UpdateData(int index)
        {
            if (this.CollectionWeightData[index].UpdateCount > 65535)
                this.CollectionWeightData[index].UpdateCount = 0;
            else
                this.CollectionWeightData[index].UpdateCount++;

            this.Current30000ModbusData.ModbusLaneData[index].Update = this.CollectionWeightData[index].UpdateCount;
        }
        public void Update30000ModbusData()
        {
            for (int i = 0; i < this.SystemConfig.EquipmentColumns; i++)
                this.Update30000UpdateData(i);

            this.Current30000ModbusData.UnderValue = Helper.StringToWeight(this.CurrentProductItem.UnderRange, this.SystemConfig.DecimalPlaces);
            this.Current30000ModbusData.PassValue = Helper.StringToWeight(this.CurrentProductItem.PassRange, this.SystemConfig.DecimalPlaces);
            this.Current30000ModbusData.OverValue = Helper.StringToWeight(this.CurrentProductItem.OverRange, this.SystemConfig.DecimalPlaces);
            this.Current30000ModbusData.TareValue = Helper.StringToWeight(this.CurrentProductItem.TareRange, this.SystemConfig.DecimalPlaces);
            this.Current30000ModbusData.HighLimit = Helper.StringToWeight(this.CurrentFeedbackItem.HighLimit, this.SystemConfig.DecimalPlaces);
            this.Current30000ModbusData.DeadZoneHighLimit =
                Helper.StringToWeight((int.Parse(this.CurrentProductItem.PassRange) + int.Parse(this.CurrentFeedbackItem.DeadZone)).ToString(), this.SystemConfig.DecimalPlaces);
            this.Current30000ModbusData.DeadZoneLowLimit =
                Helper.StringToWeight((int.Parse(this.CurrentProductItem.PassRange) - int.Parse(this.CurrentFeedbackItem.DeadZone)).ToString(), this.SystemConfig.DecimalPlaces);
            this.Current30000ModbusData.LowLimit = Helper.StringToWeight(this.CurrentFeedbackItem.LowLimit, this.SystemConfig.DecimalPlaces);
            this.Current30000ModbusData.SampleCount = (UInt32)this.SystemConfig.FeedbackSampleCount;
            this.Current30000ModbusData.IgnoreCount = (UInt32)this.SystemConfig.FeedbackIgnorePackages;
        }
        public void Update30000ModbusData(int index)
        {
            this.Update30000UpdateData(index);

            this.Current30000ModbusData.ModbusLaneData[index].Grade = this.Grade(this.CollectionWeightData[index].JudgmentStatus);
            this.Current30000ModbusData.ModbusLaneData[index].WeightDouble = this.CollectionWeightData[index].Weight;
            this.Current30000ModbusData.ModbusLaneData[index].UnderCount = (UInt32)this.CollectionWeightData[index].UnderCount;
            this.Current30000ModbusData.ModbusLaneData[index].PassCount = (UInt32)this.CollectionWeightData[index].PassCount;
            this.Current30000ModbusData.ModbusLaneData[index].OverCount = (UInt32)this.CollectionWeightData[index].OverCount;
            this.Current30000ModbusData.ModbusLaneData[index].ExNGCount = (UInt32)this.CollectionWeightData[index].ExNGCount;

            if (this.SystemConfig.IsFeedback == true)
            {
                this.Current30000ModbusData.ModbusLaneData[index].FeedbackWeightDouble = this.CollectionFeedbackStatus[index].FeedbackWeight;
                this.Current30000ModbusData.ModbusLaneData[index].UpdateFeedbackData = ushort.Parse(this.CollectionFeedbackStatus[index].UpdateFeedbackData.ToString());
            }
        }

        // Common 값 변경 시 통신전송 (Client 일때 전송)
        public void ModbusCommonDataSend()
        {
            if (this.SystemConfig.EthernetOperationMode == 2)
            {
                byte[] etherByteData = this.Modbus.WriteMultipleRegisterTCP(
                    this.Protocol_Modbus_Client_Write_Common_Data_TCP(), this.SystemConfig.ModbusTcpStartAddress);
                this.EthernetClientWeightDataForModbus(etherByteData);
            }
        }
        // Lane Test 통신전송
        public void ModbusLaneTestDataSend(int lane)
        {
            // 이더넷
            if (this.SystemConfig.EthernetOperationMode == 1)
            {
                byte[] etherByteData = this.Modbus.WriteMultipleRegisterTCP(this.Protocol_Modbus_Client_Write_Common_Data_TCP(), 1010 + 140 + (lane * 50));

                if (this.smartTCPMultiServer.ClientInfoList != null)
                {
                    foreach (SmartTCPMultiServer.CLIENTSINFOS info in this.smartTCPMultiServer.ClientInfoList)
                        this.EthernetServerSendMessage(info, etherByteData);
                }
            }
            else if (this.SystemConfig.EthernetOperationMode == 2)
            {
                byte[] etherByteData = this.Modbus.WriteMultipleRegisterTCP(
                    this.Protocol_Modbus_Client_Write_Lane_Test_Data(lane), this.SystemConfig.ModbusTcpStartAddress + 140 + (lane * 50));
                this.EthernetClientWeightDataForModbus(etherByteData);
            }
        }
        public byte[] Protocol_Modbus_Client_Write_Lane_Test_Data(int laneIndex)
        {
            int index = 0;
            byte[] madeData = new byte[32];
            byte[] length4Value = new byte[4];
            byte[] length2Value = new byte[2];

            var random = new Random();
            Single ranDouble = Single.Parse(string.Format("{0:F2}", random.NextDouble()));

            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[laneIndex].Update);
            for (int i = 0; i < 2; i++)
                madeData[i] = length2Value[1 - i];

            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[laneIndex].Grade);
            for (int i = 0; i < 2; i++)
                madeData[2 + i] = length2Value[1 - i];

            length4Value = GetBytes(ranDouble + random.Next(999));
            for (int i = 0; i < 4; i++)
                madeData[4 + i] = length4Value[3 - i];

            length4Value = GetBytes(random.Next(9999999));
            for (int i = 0; i < 4; i++)
                madeData[8 + i] = length4Value[3 - i];

            length4Value = GetBytes(random.Next(9999999));
            for (int i = 0; i < 4; i++)
                madeData[12 + i] = length4Value[3 - i];

            length4Value = GetBytes(random.Next(9999999));
            for (int i = 0; i < 4; i++)
                madeData[16 + i] = length4Value[3 - i];

            length4Value = GetBytes(random.Next(9999999));
            for (int i = 0; i < 4; i++)
                madeData[20 + i] = length4Value[3 - i];

            length4Value = GetBytes(random.Next(9999999));
            for (int i = 0; i < 4; i++)
                madeData[24 + i] = length4Value[3 - i];

            length4Value = GetBytes(random.Next(9999999));
            for (int i = 0; i < 4; i++)
                madeData[28 + i] = length4Value[3 - i];

            return madeData;
        }
        /// <summary>
        /// Modbus TCP - Write Multiple Register에 대한 Manage 메소드
        /// </summary>
        /// <param name="readByte">전송받은 Modbus Data</param>
        public void ReceiveModbusTCPWriteManager(byte[] readByte)
        {
            int startAddressInt;
            int numberOfRegisterInt;
            float floatNum;
            byte[] startAddressByte = new byte[2] { readByte[8], readByte[9] };
            byte[] numberOfRegisterByte = new byte[2] { readByte[10], readByte[11] };

            int madeDataIndex = 0;
            byte[] Length2Value = new byte[2];
            byte[] Length4Value = new byte[4];
            byte[] Length12Value = new byte[12];
            byte[] Length14Value = new byte[14];

            startAddressInt = Modbus.ToBigEndianAndInt(startAddressByte);
            numberOfRegisterInt = Modbus.ToBigEndianAndInt(numberOfRegisterByte);

            for (int j = startAddressInt; j < startAddressInt + numberOfRegisterInt; j++)
            {
                switch (j)
                {
                    #region Change data
                    case Modbus_40000_Address._01_Clear:
                        #region 40011_소거 요청
                        for (int i = 0; i < 2; i++)
                            Length2Value[i] = readByte[13 + madeDataIndex + i];
                        this.Current40000ModbusData._40011_Clear = Modbus.ToBigEndianAndInt(Length2Value);

                        if (this.Current40000ModbusData._40011_Clear == 1)
                        {
                            try
                            {
                                this.ChildFormMainDisplay.Clear();

                                // 변수 초기화
                                this.Current40000ModbusData._40011_Clear = 0;

                                // 성공
                                this.Current40000ModbusData._40012_ClearResult = 1;

                                //// Part 11 Log
                                //if (this.SystemConfig.IsOptPart11 == true)
                                //    this.SetTrackingHistoryData(DataStore.E_TrackingOperation.MB_Clear, "");
                            }
                            catch
                            {
                                // 실패
                                this.Current40000ModbusData._40012_ClearResult = 2;
                            }
                        }
                        #endregion
                        break;
                    case Modbus_40000_Address._02_ClearResult:
                        #region 40012_소거 요청 결과
                        for (int i = 0; i < 2; i++)
                            Length2Value[i] = readByte[13 + madeDataIndex + i];
                        this.Current40000ModbusData._40012_ClearResult = Modbus.ToBigEndianAndInt(Length2Value);
                        #endregion
                        break;
                    case Modbus_40000_Address._03_Operation:
                        #region 40013_운전/정지 요청, 1:운전/2:정지
                        for (int i = 0; i < 2; i++)
                            Length2Value[i] = readByte[13 + madeDataIndex + i];
                        this.Current40000ModbusData._40013_Operation = Modbus.ToBigEndianAndInt(Length2Value);

                        if (this.Current40000ModbusData._40013_Operation != 0)
                        {
                            try
                            {
                                if (this.Current40000ModbusData._40013_Operation == 1)
                                {
                                    this.TransferData(CommunicationCommand.Start, CommunicationID.MainBoard);

                                    //// Part 11 Log
                                    //if (this.SystemConfig.IsOptPart11 == true)
                                    //    this.SetTrackingHistoryData(DataStore.E_TrackingOperation.MB_EquipmentStart, "");
                                }
                                else
                                {
                                    this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);

                                    //// Part 11 Log
                                    //if (this.SystemConfig.IsOptPart11 == true)
                                    //    this.SetTrackingHistoryData(DataStore.E_TrackingOperation.MB_EquipmentStop, "");
                                }

                                // 변수 초기화
                                this.Current40000ModbusData._40013_Operation = 0;

                                // 성공
                                this.Current40000ModbusData._40014_OperationResult = 1;
                            }
                            catch
                            {
                                // 실패
                                this.Current40000ModbusData._40014_OperationResult = 2;
                            }
                        }
                        #endregion
                        break;
                    case Modbus_40000_Address._04_OperationResult:
                        #region 40014_운전/정지 요청 수행 결과
                        for (int i = 0; i < 2; i++)
                            Length2Value[i] = readByte[13 + madeDataIndex + i];
                        this.Current40000ModbusData._40014_OperationResult = Modbus.ToBigEndianAndInt(Length2Value);
                        #endregion
                        break;
                    case Modbus_40000_Address._05_ProductChange_High:
                        #region 40015_품번 변경 요청
                        for (int i = 0; i < 4; i++)
                            Length4Value[i] = readByte[13 + madeDataIndex + i];
                        this.Current40000ModbusData._40015_ProductChange = Modbus.ToBigEndianAndInt(Length4Value);

                        if (this.Current40000ModbusData._40015_ProductChange != 0)
                        {
                            try
                            {
                                if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                {
                                    if (this.Current40000ModbusData._40015_ProductChange >= 1 && this.Current40000ModbusData._40015_ProductChange <= 1000)
                                        this.ChildFormMainDisplay.ProductChange(this.Current40000ModbusData._40015_ProductChange);

                                    //// Part 11 Log
                                    //if (this.SystemConfig.IsOptPart11 == true)
                                    //{
                                    //    string before = "", after = "";
                                    //    before = this.SystemConfig.ProductNumber.ToString();
                                    //    after = this.Current40000ModbusData._40015_ProductChange.ToString();

                                    //    this.SetTrackingHistoryData(DataStore.TrackingParameter.MB_ProductNumber, "", before, after);
                                    //}

                                    // 변수 초기화
                                    this.Current40000ModbusData._40015_ProductChange = 0;

                                    // 성공
                                    this.Current40000ModbusData._40017_ProductChangeResult = 1;
                                }
                                else
                                {
                                    this.Current40000ModbusData._40015_ProductChange = 0;
                                    this.Current40000ModbusData._40017_ProductChangeResult = 2;
                                }
                            }
                            catch
                            {
                                // 실패
                                this.Current40000ModbusData._40017_ProductChangeResult = 2;
                            }
                        }
                        #endregion
                        break;
                    case Modbus_40000_Address._07_ProductChangeResult:
                        #region 40017_품번 변경 요청 수행 결과
                        for (int i = 0; i < 2; i++)
                            Length2Value[i] = readByte[13 + madeDataIndex + i];
                        this.Current40000ModbusData._40017_ProductChangeResult = Modbus.ToBigEndianAndInt(Length2Value);
                        #endregion
                        break;
                    case Modbus_40000_Address._08_UnderRange_High:
                        #region 40018_Under 중량설정 요청
                        for (int i = 0; i < 4; i++)
                            Length4Value[i] = readByte[13 + madeDataIndex + i];
                        floatNum = Modbus.ToBigEndianAndFloat(Length4Value);
                        this.Current40000ModbusData._40018_UnderRange =
                            int.Parse(Helper.DoubleToString((double)floatNum, this.SystemConfig.DecimalPlaces).Replace(".", ""));

                        if (this.Current40000ModbusData._40018_UnderRange >= 0 && this.Current40000ModbusData._40018_UnderRange <= int.Parse(this.CurrentProductItem.PassRange))
                        {
                            try
                            {
                                string weight = Helper.StringToDecimalPlaces(this.Current40000ModbusData._40018_UnderRange.ToString(), this.SystemConfig.DecimalPlaces);
                                this.ChildFormMainDisplay.UpdateUnderRangeChange(weight);

                                this.Update30000ModbusData();
                                this.ModbusCommonDataSend();

                                // 변수 초기화
                                this.Current40000ModbusData._40018_UnderRange = 0;
                                // 성공
                                this.Current40000ModbusData._40020_UnderRangeResult = 1;
                            }
                            catch
                            {
                                // 실패
                                this.Current40000ModbusData._40020_UnderRangeResult = 2;
                            }
                        }
                        else
                        {
                            // 실패
                            this.Current40000ModbusData._40020_UnderRangeResult = 2;
                        }
                        #endregion
                        break;
                    case Modbus_40000_Address._10_UnderRangeResult:
                        #region 40020_Under 중량설정 요청 수행 결과
                        for (int i = 0; i < 2; i++)
                            Length2Value[i] = readByte[13 + madeDataIndex + i];
                        this.Current40000ModbusData._40020_UnderRangeResult = Modbus.ToBigEndianAndInt(Length2Value);
                        #endregion
                        break;
                    case Modbus_40000_Address._11_PassRange_High:
                        #region 40021_Pass 중량설정 요청
                        for (int i = 0; i < 4; i++)
                            Length4Value[i] = readByte[13 + madeDataIndex + i];
                        floatNum = Modbus.ToBigEndianAndFloat(Length4Value);
                        this.Current40000ModbusData._40021_PassRange =
                            int.Parse(Helper.DoubleToString((double)floatNum, this.SystemConfig.DecimalPlaces).Replace(".", ""));

                        if (this.Current40000ModbusData._40021_PassRange >= int.Parse(this.CurrentProductItem.UnderRange)
                            && this.Current40000ModbusData._40021_PassRange <= int.Parse(this.CurrentProductItem.OverRange))
                        {
                            try
                            {
                                string weight = Helper.StringToDecimalPlaces(this.Current40000ModbusData._40021_PassRange.ToString(), this.SystemConfig.DecimalPlaces);
                                this.ChildFormMainDisplay.UpdatePassRangeChange(weight);

                                this.Update30000ModbusData();
                                this.ModbusCommonDataSend();

                                // 변수 초기화
                                this.Current40000ModbusData._40021_PassRange = 0;
                                // 성공
                                this.Current40000ModbusData._40023_PassRangeResult = 1;
                            }
                            catch
                            {
                                // 실패
                                this.Current40000ModbusData._40023_PassRangeResult = 2;
                            }
                        }
                        else
                        {
                            // 실패
                            this.Current40000ModbusData._40023_PassRangeResult = 2;
                        }
                        #endregion
                        break;
                    case Modbus_40000_Address._13_PassRangeResult:
                        #region 40023_Pass 중량설정 요청 수행 결과
                        for (int i = 0; i < 2; i++)
                            Length2Value[i] = readByte[13 + madeDataIndex + i];
                        this.Current40000ModbusData._40023_PassRangeResult = Modbus.ToBigEndianAndInt(Length2Value);
                        #endregion
                        break;
                    case Modbus_40000_Address._14_OverRange_High:
                        #region 40024_Over 중량설정 요청
                        for (int i = 0; i < 4; i++)
                            Length4Value[i] = readByte[13 + madeDataIndex + i];
                        floatNum = Modbus.ToBigEndianAndFloat(Length4Value);
                        this.Current40000ModbusData._40024_OverRange =
                            int.Parse(Helper.DoubleToString((double)floatNum, this.SystemConfig.DecimalPlaces).Replace(".", ""));

                        if (this.Current40000ModbusData._40024_OverRange >= int.Parse(this.CurrentProductItem.PassRange)
                            && this.Current40000ModbusData._40024_OverRange <= 99999)
                        {
                            try
                            {
                                string weight = Helper.StringToDecimalPlaces(this.Current40000ModbusData._40024_OverRange.ToString(), this.SystemConfig.DecimalPlaces);
                                this.ChildFormMainDisplay.UpdateOverRangeChange(weight);

                                this.Update30000ModbusData();
                                this.ModbusCommonDataSend();

                                // 변수 초기화
                                this.Current40000ModbusData._40024_OverRange = 0;
                                // 성공
                                this.Current40000ModbusData._40026_OverRangeResult = 1;
                            }
                            catch
                            {
                                // 실패
                                this.Current40000ModbusData._40026_OverRangeResult = 2;
                            }
                        }
                        else
                        {
                            // 실패
                            this.Current40000ModbusData._40026_OverRangeResult = 2;
                        }
                        #endregion
                        break;
                    case Modbus_40000_Address._16_OverRangeResult:
                        #region 40026_Over 중량설정 요청 수행 결과
                        for (int i = 0; i < 2; i++)
                            Length2Value[i] = readByte[13 + madeDataIndex + i];
                        this.Current40000ModbusData._40026_OverRangeResult = Modbus.ToBigEndianAndInt(Length2Value);
                        #endregion
                        break;
                    case Modbus_40000_Address._17_TareWeight_High:
                        #region 40027_Tare 중량설정 요청
                        for (int i = 0; i < 4; i++)
                            Length4Value[i] = readByte[13 + madeDataIndex + i];
                        floatNum = Modbus.ToBigEndianAndFloat(Length4Value);
                        this.Current40000ModbusData._40027_TareWeight =
                            int.Parse(Helper.DoubleToString((double)floatNum, this.SystemConfig.DecimalPlaces).Replace(".", ""));

                        if (this.Current40000ModbusData._40027_TareWeight >= 0 && this.Current40000ModbusData._40027_TareWeight <= 99999)
                        {
                            try
                            {
                                string weight = Helper.StringToDecimalPlaces(this.Current40000ModbusData._40027_TareWeight.ToString(), this.SystemConfig.DecimalPlaces);
                                this.ChildFormMainDisplay.UpdateTareRangeChange(weight);

                                this.Update30000ModbusData();
                                this.ModbusCommonDataSend();

                                // 변수 초기화
                                this.Current40000ModbusData._40027_TareWeight = 0;
                                // 성공
                                this.Current40000ModbusData._40029_TareWeightResult = 1;
                            }
                            catch
                            {
                                // 실패
                                this.Current40000ModbusData._40029_TareWeightResult = 2;
                            }
                        }
                        else
                        {
                            // 실패
                            this.Current40000ModbusData._40029_TareWeightResult = 2;
                        }
                        #endregion
                        break;
                    case Modbus_40000_Address._19_TareWeightResult:
                        #region 40029_Tare 중량설정 요청 수행 결과
                        for (int i = 0; i < 2; i++)
                            Length2Value[i] = readByte[13 + madeDataIndex + i];
                        this.Current40000ModbusData._40029_TareWeightResult = Modbus.ToBigEndianAndInt(Length2Value);
                        #endregion
                        break;
                    default:
                        break;
                    #endregion
                }
                madeDataIndex += 2;
            }
        }
        #endregion

        #region SystemConfiguration File
        private void CreateSystemConfigurationFile()
        {
            StructSystemConfigurationItem1 structItem1;
            StructSystemConfigurationItem2 structItem2;

            this.SystemConfig.Initialization();

            #region StructItem1
            structItem1.IsDataBackup = this.SystemConfig.IsDataBackup;
            structItem1.DummyBool5 = false;
            structItem1.DummyBool6 = false;
            structItem1.DummyBool7 = false;
            structItem1.IsFeedbackBoard = this.SystemConfig.IsFeedbackBoard;
            structItem1.IsFeedback = this.SystemConfig.IsFeedback;
            structItem1.IsLogin = this.SystemConfig.IsLogin;
            structItem1.IsWeightViewForward = this.SystemConfig.IsWeightViewForward;
            structItem1.DecimalPlaces = this.SystemConfig.DecimalPlaces;
            structItem1.InverterQTY = this.SystemConfig.InverterQTY;
            structItem1.EquipmentColumns = this.SystemConfig.EquipmentColumns;
            structItem1.EquipmentID = this.SystemConfig.EquipmentID;
            structItem1.EquipmentMode = this.SystemConfig.EquipmentMode;
            structItem1.ProductNumber = this.SystemConfig.ProductNumber;
            structItem1.EthernetLocalPort = this.SystemConfig.EthernetLocalPort;
            structItem1.EthernetServerPort = this.SystemConfig.EthernetServerPort;
            structItem1.UsbID = this.SystemConfig.UsbID;
            structItem1.DummyString6 = "";
            structItem1.Unit = this.SystemConfig.Unit;
            structItem1.Language = this.SystemConfig.Language;
            structItem1.EthernetMode = this.SystemConfig.EthernetMode;
            structItem1.EthernetOperationMode = this.SystemConfig.EthernetOperationMode;
            structItem1.SerialNumber = this.SystemConfig.SerialNumber;
            structItem1.Serial3BaudRate = this.SystemConfig.Serial3BaudRate;
            structItem1.Serial3Mode = this.SystemConfig.Serial3Mode;

            structItem1.DummyBool1 = false;
            structItem1.DummyBool2 = false;
            structItem1.DummyBool3 = false;
            structItem1.DummyBool4 = false;
            structItem1.FeedbackSampleCount = this.SystemConfig.FeedbackSampleCount;
            structItem1.FeedbackIgnorePackages = this.SystemConfig.FeedbackIgnorePackages;
            structItem1.ModbusTcpStartAddress = this.SystemConfig.ModbusTcpStartAddress;

            structItem1.EthernetServerAddress = this.SystemConfig.EthernetServerAddress;
            structItem1.DummyString2 = "";
            structItem1.DummyString3 = "";
            structItem1.DummyString4 = "";
            structItem1.DummyString5 = ""; 
            #endregion

            this.smartFileIO.WriteStructure(structItem1, 0);

            #region StructItem2
            structItem2.DummyBool1 = false;
            structItem2.DummyBool2 = false;
            structItem2.DummyBool3 = false;
            structItem2.DummyBool4 = false;
            structItem2.DummyBool5 = false;
            structItem2.DummyBool6 = false;
            structItem2.DummyBool7 = false;
            structItem2.DummyBool8 = false;
            structItem2.DummyBool9 = false;
            structItem2.DummyBool10 = false;
            structItem2.DummyBool11 = false;
            structItem2.DummyBool12 = false;
            structItem2.DummyBool13 = false;
            structItem2.DummyBool14 = false;
            structItem2.DummyBool15 = false;
            structItem2.DummyBool16 = false;
            structItem2.DummyBool17 = false;
            structItem2.DummyBool18 = false;
            structItem2.DummyBool19 = false;
            structItem2.DummyBool20 = false;

            structItem2.FeedbackCorrectionRate = this.SystemConfig.FeedbackCorrectionRate;
            structItem2.FeedbackPulseWidth = this.SystemConfig.FeedbackPulseWidth;
            structItem2.DummyInt3 = 0;
            structItem2.DummyInt4 = 0;
            structItem2.DummyInt5 = 0;
            structItem2.DummyInt6 = 0;
            structItem2.DummyInt7 = 0;
            structItem2.DummyInt8 = 0;
            structItem2.DummyInt9 = 0;
            structItem2.DummyInt10 = 0;
            structItem2.DummyInt11 = 0;
            structItem2.DummyInt12 = 0;
            structItem2.DummyInt13 = 0;
            structItem2.DummyInt14 = 0;
            structItem2.DummyInt15 = 0;
            structItem2.DummyInt16 = 0;
            structItem2.DummyInt17 = 0;
            structItem2.DummyInt18 = 0;
            structItem2.DummyInt19 = 0;
            structItem2.DummyInt20 = 0;

            structItem2.DummyString1 = "";
            structItem2.DummyString2 = "";
            structItem2.DummyString3 = "";
            structItem2.DummyString4 = "";
            structItem2.DummyString5 = "";
            structItem2.DummyString6 = "";
            structItem2.DummyString7 = "";
            structItem2.DummyString8 = "";
            structItem2.DummyString9 = "";
            structItem2.DummyString10 = ""; 
            #endregion

            this.smartFileIO.WriteStructure(structItem2, 1);
        }
        public void SaveSystemConfigurationFile(SystemConfigurationItem item)
        {
            string fullFilePath = "";
            bool fileCheck = false;
            StructSystemConfigurationItem1 structItem1;
            StructSystemConfigurationItem2 structItem2;

            fullFilePath = this.PathSystemFileFolder1 + "system.cfg";
            this.smartFileIO.FilePathName = fullFilePath;

            FileInfo fileInfo = new FileInfo(fullFilePath);
            fileCheck = fileInfo.Exists;

            if (fileCheck == true)
                this.smartFileIO.Open(this.BufferSmartUart);
            else
            {
                this.smartFileIO.Open(this.BufferSmartUart);

                this.CreateSystemConfigurationFile();
            }

            #region StructItem1
            structItem1.IsDataBackup = item.IsDataBackup;
            structItem1.DummyBool5 = false;
            structItem1.DummyBool6 = false;
            structItem1.DummyBool7 = false;
            structItem1.IsFeedbackBoard = item.IsFeedbackBoard;
            structItem1.IsFeedback = item.IsFeedback;
            structItem1.IsLogin = item.IsLogin;
            structItem1.IsWeightViewForward = item.IsWeightViewForward;
            structItem1.DecimalPlaces = item.DecimalPlaces;
            structItem1.InverterQTY = item.InverterQTY;
            structItem1.EquipmentColumns = item.EquipmentColumns;
            structItem1.EquipmentID = item.EquipmentID;
            structItem1.EquipmentMode = item.EquipmentMode;
            structItem1.ProductNumber = item.ProductNumber;
            structItem1.EthernetLocalPort = item.EthernetLocalPort;
            structItem1.EthernetServerPort = item.EthernetServerPort;
            structItem1.UsbID = item.UsbID;
            structItem1.DummyString6 = "";
            structItem1.Unit = item.Unit;
            structItem1.Language = item.Language;
            structItem1.EthernetMode = item.EthernetMode;
            structItem1.EthernetOperationMode = item.EthernetOperationMode;
            structItem1.SerialNumber = item.SerialNumber;
            structItem1.Serial3BaudRate = item.Serial3BaudRate;
            structItem1.Serial3Mode = item.Serial3Mode;

            structItem1.DummyBool1 = false;
            structItem1.DummyBool2 = false;
            structItem1.DummyBool3 = false;
            structItem1.DummyBool4 = false;
            structItem1.FeedbackSampleCount = item.FeedbackSampleCount;
            structItem1.FeedbackIgnorePackages = item.FeedbackIgnorePackages;
            structItem1.ModbusTcpStartAddress = item.ModbusTcpStartAddress;

            structItem1.EthernetServerAddress = item.EthernetServerAddress;
            structItem1.DummyString2 = "";
            structItem1.DummyString3 = "";
            structItem1.DummyString4 = "";
            structItem1.DummyString5 = ""; 
            #endregion

            this.smartFileIO.WriteStructure(structItem1, 0);

            #region StructItem2
            structItem2.DummyBool1 = false;
            structItem2.DummyBool2 = false;
            structItem2.DummyBool3 = false;
            structItem2.DummyBool4 = false;
            structItem2.DummyBool5 = false;
            structItem2.DummyBool6 = false;
            structItem2.DummyBool7 = false;
            structItem2.DummyBool8 = false;
            structItem2.DummyBool9 = false;
            structItem2.DummyBool10 = false;
            structItem2.DummyBool11 = false;
            structItem2.DummyBool12 = false;
            structItem2.DummyBool13 = false;
            structItem2.DummyBool14 = false;
            structItem2.DummyBool15 = false;
            structItem2.DummyBool16 = false;
            structItem2.DummyBool17 = false;
            structItem2.DummyBool18 = false;
            structItem2.DummyBool19 = false;
            structItem2.DummyBool20 = false;

            structItem2.FeedbackCorrectionRate = item.FeedbackCorrectionRate;
            structItem2.FeedbackPulseWidth = item.FeedbackPulseWidth;
            structItem2.DummyInt3 = 0;
            structItem2.DummyInt4 = 0;
            structItem2.DummyInt5 = 0;
            structItem2.DummyInt6 = 0;
            structItem2.DummyInt7 = 0;
            structItem2.DummyInt8 = 0;
            structItem2.DummyInt9 = 0;
            structItem2.DummyInt10 = 0;
            structItem2.DummyInt11 = 0;
            structItem2.DummyInt12 = 0;
            structItem2.DummyInt13 = 0;
            structItem2.DummyInt14 = 0;
            structItem2.DummyInt15 = 0;
            structItem2.DummyInt16 = 0;
            structItem2.DummyInt17 = 0;
            structItem2.DummyInt18 = 0;
            structItem2.DummyInt19 = 0;
            structItem2.DummyInt20 = 0;

            structItem2.DummyString1 = "";
            structItem2.DummyString2 = "";
            structItem2.DummyString3 = "";
            structItem2.DummyString4 = "";
            structItem2.DummyString5 = "";
            structItem2.DummyString6 = "";
            structItem2.DummyString7 = "";
            structItem2.DummyString8 = "";
            structItem2.DummyString9 = "";
            structItem2.DummyString10 = "";
            #endregion

            this.smartFileIO.WriteStructure(structItem2, 1);

            this.smartFileIO.Close();
        }
        private void LoadSystemConfigurationFile()
        {
            string fullFilePath = "";
            bool fileCheck = false, save = false;
            StructSystemConfigurationItem1 structItem1;
            StructSystemConfigurationItem2 structItem2;

            fullFilePath = this.PathSystemFileFolder1 + "system.cfg";
            this.smartFileIO.FilePathName = fullFilePath;

            FileInfo fileInfo = new FileInfo(fullFilePath);
            fileCheck = fileInfo.Exists;

            if (fileCheck == true)
                this.smartFileIO.Open(this.BufferSmartUart);
            else
            {
                this.smartFileIO.Open(this.BufferSmartUart);

                this.CreateSystemConfigurationFile();
            }

            try
            {
                structItem1 = (StructSystemConfigurationItem1)this.smartFileIO.ReadStructure(0, typeof(StructSystemConfigurationItem1));

                #region StructItem1
                this.SystemConfig.IsFeedback = structItem1.IsFeedback;
                this.SystemConfig.IsDataBackup = structItem1.IsDataBackup;
                this.SystemConfig.IsWeightViewForward = structItem1.IsWeightViewForward;
                this.SystemConfig.DecimalPlaces = structItem1.DecimalPlaces;
                this.SystemConfig.EquipmentColumns = structItem1.EquipmentColumns;
                this.SystemConfig.EquipmentID = structItem1.EquipmentID;
                this.SystemConfig.EquipmentMode = structItem1.EquipmentMode;
                this.SystemConfig.ProductNumber = structItem1.ProductNumber;
                this.SystemConfig.UsbID = structItem1.UsbID;
                this.SystemConfig.Unit = structItem1.Unit;
                this.SystemConfig.Language = structItem1.Language;
                this.SystemConfig.SerialNumber = structItem1.SerialNumber;
                this.SystemConfig.Serial3BaudRate = structItem1.Serial3BaudRate;
                this.SystemConfig.Serial3Mode = structItem1.Serial3Mode;
                this.SystemConfig.IsLogin = structItem1.IsLogin;
                this.SystemConfig.FeedbackSampleCount = structItem1.FeedbackSampleCount;
                this.SystemConfig.FeedbackIgnorePackages = structItem1.FeedbackIgnorePackages;

                if (structItem1.InverterQTY < 1 || structItem1.InverterQTY > 4)
                {
                    save = true;
                    this.SystemConfig.InverterQTY = 2;
                }
                else
                    this.SystemConfig.InverterQTY = structItem1.InverterQTY;

                if (structItem1.EthernetLocalPort == 0)
                {
                    save = true;
                    this.SystemConfig.EthernetLocalPort = 5001;
                    this.SystemConfig.EthernetServerPort = 5002;
                    this.SystemConfig.EthernetMode = 0;
                    this.SystemConfig.EthernetOperationMode = 0;
                    this.SystemConfig.EthernetServerAddress = "0.0.0.0";
                }
                else
                {
                    this.SystemConfig.EthernetLocalPort = structItem1.EthernetLocalPort;
                    this.SystemConfig.EthernetServerPort = structItem1.EthernetServerPort;
                    this.SystemConfig.EthernetMode = structItem1.EthernetMode;
                    this.SystemConfig.EthernetOperationMode = structItem1.EthernetOperationMode;
                    this.SystemConfig.EthernetServerAddress = structItem1.EthernetServerAddress;
                }

                if (structItem1.ModbusTcpStartAddress == 0)
                {
                    save = true;
                    this.SystemConfig.ModbusTcpStartAddress = 1010;
                }
                else
                    this.SystemConfig.ModbusTcpStartAddress = structItem1.ModbusTcpStartAddress;

                this.SystemConfig.IsFeedbackBoard = structItem1.IsFeedbackBoard;
                #endregion

                structItem2 = (StructSystemConfigurationItem2)this.smartFileIO.ReadStructure(1, typeof(StructSystemConfigurationItem2));

                #region StructItem2
                this.SystemConfig.FeedbackCorrectionRate = structItem2.FeedbackCorrectionRate;
                this.SystemConfig.FeedbackPulseWidth = structItem2.FeedbackPulseWidth;
                #endregion
            }
            catch
            {
                DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig.Language, "");
                myMsg.Location = new Point(167, 207);
                myMsg.ShowDialog();

                this.smartFileIO.Close();
            }

            this.smartFileIO.Close();

            if (save == true)
                this.SaveSystemConfigurationFile(this.SystemConfig);
        }
        #endregion

        #region ProductItem File
        private void CreateProductFile()
        {
            StructProductItem structItem;

            this.CurrentProductItem.Initialization();

            for (int i = 0; i < 1000; i++)
            {
                structItem.Number = i + 1;
                structItem.Name = string.Format("Product {0}", i + 1);
                structItem.LotNo = string.Format("Lot {0}", i + 1);
                structItem.OverRange = this.CurrentProductItem.OverRange;
                structItem.PassRange = this.CurrentProductItem.PassRange;
                structItem.UnderRange = this.CurrentProductItem.UnderRange;
                structItem.TareRange = this.CurrentProductItem.TareRange;
                structItem.DummyString1 = "";
                structItem.DummyString2 = "";
                structItem.DummyString3 = "";
                structItem.DummyString4 = "";
                structItem.DummyString5 = "";
                structItem.DummyString6 = "";
                structItem.DummyString7 = "";
                structItem.DummyString8 = "";

                this.smartFileIO.WriteStructure_Begin(structItem, i);
            }
            this.smartFileIO.WriteStructure_End();
        }
        public void SaveProductFile(ProductItem item, int index)
        {
            bool fileCheck = false;
            string fullFilePath = "";
            StructProductItem structItem;

            fullFilePath = this.PathSystemFileFolder2 + "ProductItem.int";
            this.smartFileIO.FilePathName = fullFilePath;

            FileInfo fileInfo = new FileInfo(fullFilePath);
            fileCheck = fileInfo.Exists;

            if (fileCheck == true)
                this.smartFileIO.Open(this.BufferSmartUart);
            else
            {
                this.smartFileIO.Open(this.BufferSmartUart);
                this.CreateProductFile();
            }

            structItem.Number = item.Number;
            structItem.Name = item.Name;
            structItem.LotNo = item.LotNo;
            structItem.OverRange = item.OverRange;
            structItem.PassRange = item.PassRange;
            structItem.UnderRange = item.UnderRange;
            structItem.TareRange = item.TareRange;
            structItem.DummyString1 = "";
            structItem.DummyString2 = "";
            structItem.DummyString3 = "";
            structItem.DummyString4 = "";
            structItem.DummyString5 = "";
            structItem.DummyString6 = "";
            structItem.DummyString7 = "";
            structItem.DummyString8 = "";

            this.smartFileIO.WriteStructure_Begin(structItem, index);
            this.smartFileIO.WriteStructure_End();

            this.smartFileIO.Close();
        }
        public void LoadProductFile(ref ProductItem item, int index)
        {
            bool fileCheck = false;
            string fullFilePath = "";
            StructProductItem structItem;

            fullFilePath = this.PathSystemFileFolder2 + "ProductItem.int";
            this.smartFileIO.FilePathName = fullFilePath;

            FileInfo fileInfo = new FileInfo(fullFilePath);
            fileCheck = fileInfo.Exists;

            if (fileCheck == true)
                this.smartFileIO.Open(this.BufferSmartUart);
            else
            {
                this.smartFileIO.Open(this.BufferSmartUart);

                this.CreateProductFile();
            }

            try
            {
                structItem = (StructProductItem)this.smartFileIO.ReadStructure(index, typeof(StructProductItem));

                item.Number = structItem.Number;
                item.Name = structItem.Name;
                item.LotNo = structItem.LotNo;
                item.OverRange = structItem.OverRange;
                item.PassRange = structItem.PassRange;
                item.UnderRange = structItem.UnderRange;
                item.TareRange = structItem.TareRange;
            }
            catch
            {
                DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig.Language, "");
                myMsg.Location = new Point(167, 207);
                myMsg.ShowDialog();

                this.smartFileIO.Close();
            }

            this.smartFileIO.Close();
        }
        public void LoadProductName(ref Collection<string> values)
        {
            string fullFilePath = "";
            StructProductItem structItem;

            values.Clear();

            fullFilePath = this.PathSystemFileFolder2 + "ProductItem.int";
            this.smartFileIO.FilePathName = fullFilePath;

            this.smartFileIO.Open(this.BufferSmartUart);

            if (this.smartFileIO.ReadStructureAllBuffer() == true)
            {
                for (int i = 0; i < 1000; i++)
                {
                    structItem = (StructProductItem)this.smartFileIO.ReadStructureBuffer(typeof(StructProductItem), i);

                    values.Add(structItem.Name);
                }
            }

            this.smartFileIO.Close();
        }
        public void LoadProductFile(ref Collection<ProductItem> values)
        {
            string fullFilePath = "";
            StructProductItem structItem;

            this.smartFileIO.Close();
            fullFilePath = this.PathSystemFileFolder2 + "ProductItem.int";
            this.smartFileIO.FilePathName = fullFilePath;

            this.smartFileIO.Open(this.BufferSmartUart);

            if (this.smartFileIO.ReadStructureAllBuffer() == true)
            {
                for (int i = 0; i < 1000; i++)
                {
                    structItem = (StructProductItem)this.smartFileIO.ReadStructureBuffer(typeof(StructProductItem), i);

                    values[i].Number = structItem.Number;
                    values[i].Name = structItem.Name;
                    values[i].LotNo = structItem.LotNo;
                    values[i].OverRange = structItem.OverRange;
                    values[i].PassRange = structItem.PassRange;
                    values[i].UnderRange = structItem.UnderRange;
                    values[i].TareRange = structItem.TareRange;
                }
            }

            this.smartFileIO.Close();
        }
        #endregion

        #region JudgmentSetItem File
        private void CreateJudgmentSetFile()
        {
            StructJudgmentSetItem structItem;

            this.CurrentJudgmentSetItem.Initialization();

            for (int i = 0; i < 1000; i++)
            {
                structItem.Filter = this.CurrentJudgmentSetItem.Filter;
                structItem.JudgmentDelayTime = this.CurrentJudgmentSetItem.JudgmentDelayTime;
                structItem.DoubleDelayTime = this.CurrentJudgmentSetItem.DoubleDelayTime;
                structItem.JudgmentCount = this.CurrentJudgmentSetItem.JudgmentCount;
                structItem.ConveyorSpeed1 = this.CurrentJudgmentSetItem.ConveyorSpeed1;
                structItem.DynamicCorrection = this.CurrentJudgmentSetItem.DynamicCorrection;
                structItem.DummyInt1 = 0;
                structItem.DummyInt2 = 0;
                structItem.DummyInt3 = 0;
                structItem.DummyInt4 = 0;
                structItem.Sorter1Mode = this.CurrentJudgmentSetItem.Sorter1Mode;
                structItem.Sorter1DelayTime = this.CurrentJudgmentSetItem.Sorter1DelayTime;
                structItem.Sorter1OperatingTime = this.CurrentJudgmentSetItem.Sorter1RunTime;
                structItem.DummyInt5 = 0;
                structItem.DummyInt6 = 0;
                structItem.DummyInt7 = 0;
                structItem.DummyInt8 = 0;
                structItem.DummyInt9 = 0;
                structItem.DummyInt10 = 0;
                structItem.DummyInt11 = 0;
                structItem.DummyInt12 = 0;
                structItem.DummyInt13 = 0;
                structItem.ConveyorSpeed4 = this.CurrentJudgmentSetItem.ConveyorSpeed4;
                structItem.ConveyorSpeed3 = this.CurrentJudgmentSetItem.ConveyorSpeed3;
                structItem.ConveyorSpeed2 = this.CurrentJudgmentSetItem.ConveyorSpeed2;
                structItem.DummyInt14 = 0;
                structItem.DummyInt15 = 0;
                structItem.DummyString1 = "";
                structItem.DummyString2 = "";
                structItem.DummyString3 = "";
                structItem.DummyString4 = "";
                structItem.DummyString5 = "";

                this.smartFileIO.WriteStructure_Begin(structItem, i);
            }
            this.smartFileIO.WriteStructure_End();
        }
        public void SaveJudgmentSetFile(JudgmentSetItem item, int index)
        {
            bool fileCheck = false;
            string fullFilePath = "";
            StructJudgmentSetItem structItem;

            fullFilePath = this.PathSystemFileFolder2 + "JudgmentSetItem.int";
            this.smartFileIO.FilePathName = fullFilePath;

            FileInfo fileInfo = new FileInfo(fullFilePath);
            fileCheck = fileInfo.Exists;

            if (fileCheck == true)
                this.smartFileIO.Open(this.BufferSmartUart);
            else
            {
                this.smartFileIO.Open(this.BufferSmartUart);
                this.CreateJudgmentSetFile();
            }

            structItem.Filter = item.Filter;
            structItem.JudgmentDelayTime = item.JudgmentDelayTime;
            structItem.DoubleDelayTime = item.DoubleDelayTime;
            structItem.JudgmentCount = item.JudgmentCount;
            structItem.ConveyorSpeed1 = item.ConveyorSpeed1;
            structItem.DynamicCorrection = item.DynamicCorrection;
            structItem.DummyInt1 = 0;
            structItem.DummyInt2 = 0;
            structItem.DummyInt3 = 0;
            structItem.DummyInt4 = 0;
            structItem.Sorter1Mode = item.Sorter1Mode;
            structItem.Sorter1DelayTime = item.Sorter1DelayTime;
            structItem.Sorter1OperatingTime = item.Sorter1RunTime;
            structItem.DummyInt5 = 0;
            structItem.DummyInt6 = 0;
            structItem.DummyInt7 = 0;
            structItem.DummyInt8 = 0;
            structItem.DummyInt9 = 0;
            structItem.DummyInt10 = 0;
            structItem.DummyInt11 = 0;
            structItem.DummyInt12 = 0;
            structItem.DummyInt13 = 0;
            structItem.ConveyorSpeed4 = item.ConveyorSpeed4;
            structItem.ConveyorSpeed3 = item.ConveyorSpeed3;
            structItem.ConveyorSpeed2 = item.ConveyorSpeed2;
            structItem.DummyInt14 = 0;
            structItem.DummyInt15 = 0;
            structItem.DummyString1 = "";
            structItem.DummyString2 = "";
            structItem.DummyString3 = "";
            structItem.DummyString4 = "";
            structItem.DummyString5 = "";

            this.smartFileIO.WriteStructure_Begin(structItem, index);
            this.smartFileIO.WriteStructure_End();

            this.smartFileIO.Close();
        }
        public void LoadJudgmentSetFile(ref JudgmentSetItem item, int index)
        {
            bool fileCheck = false, save = false;
            string fullFilePath = "";
            StructJudgmentSetItem structItem;

            fullFilePath = this.PathSystemFileFolder2 + "JudgmentSetItem.int";
            this.smartFileIO.FilePathName = fullFilePath;

            FileInfo fileInfo = new FileInfo(fullFilePath);
            fileCheck = fileInfo.Exists;

            if (fileCheck == true)
                this.smartFileIO.Open(this.BufferSmartUart);
            else
            {
                this.smartFileIO.Open(this.BufferSmartUart);
                this.CreateJudgmentSetFile();
            }

            try
            {
                structItem = (StructJudgmentSetItem)this.smartFileIO.ReadStructure(index, typeof(StructJudgmentSetItem));

                item.Filter = structItem.Filter;
                item.JudgmentDelayTime = structItem.JudgmentDelayTime;
                item.DoubleDelayTime = structItem.DoubleDelayTime;
                item.JudgmentCount = structItem.JudgmentCount;
                item.ConveyorSpeed1 = structItem.ConveyorSpeed1;
                item.DynamicCorrection = structItem.DynamicCorrection;
                item.Sorter1Mode = structItem.Sorter1Mode;
                item.Sorter1DelayTime = structItem.Sorter1DelayTime;
                item.Sorter1RunTime = structItem.Sorter1OperatingTime;

                if (structItem.ConveyorSpeed2 == 0)
                {
                    save = true;
                    item.ConveyorSpeed2 = 60;
                    item.ConveyorSpeed3 = 60;
                    item.ConveyorSpeed4 = 60;
                }
                else
                {
                    item.ConveyorSpeed2 = structItem.ConveyorSpeed2;
                    item.ConveyorSpeed3 = structItem.ConveyorSpeed3;
                    item.ConveyorSpeed4 = structItem.ConveyorSpeed4;
                }
            }
            catch
            {
                DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig.Language, "");
                myMsg.Location = new Point(167, 207);
                myMsg.ShowDialog();

                this.smartFileIO.Close();
            }
            this.smartFileIO.Close();

            if (save == true)
                this.SaveJudgmentSetFile(item, index);
        }
        #endregion

        #region Counter File
        private void CreateCounterFile()
        {
            StructCounter structItem;

            for (int i = 0; i < 1000; i++)
            {
                structItem.OverCount1 = 0;
                structItem.PassCount1 = 0;
                structItem.UnderCount1 = 0;
                structItem.ExNGCount1 = 0;

                structItem.OverCount2 = 0;
                structItem.PassCount2 = 0;
                structItem.UnderCount2 = 0;
                structItem.ExNGCount2 = 0;

                structItem.OverCount3 = 0;
                structItem.PassCount3 = 0;
                structItem.UnderCount3 = 0;
                structItem.ExNGCount3 = 0;

                structItem.OverCount4 = 0;
                structItem.PassCount4 = 0;
                structItem.UnderCount4 = 0;
                structItem.ExNGCount4 = 0;

                structItem.OverCount5 = 0;
                structItem.PassCount5 = 0;
                structItem.UnderCount5 = 0;
                structItem.ExNGCount5 = 0;

                structItem.OverCount6 = 0;
                structItem.PassCount6 = 0;
                structItem.UnderCount6 = 0;
                structItem.ExNGCount6 = 0;

                structItem.DummyInt1 = 0;
                structItem.DummyInt2 = 0;
                structItem.DummyInt3 = 0;
                structItem.DummyInt4 = 0;
                structItem.DummyInt5 = 0;
                structItem.DummyInt6 = 0;
                structItem.DummyInt7 = 0;
                structItem.DummyInt8 = 0;
                structItem.DummyInt9 = 0;
                structItem.DummyInt10 = 0;

                this.smartFileIO.WriteStructure_Begin(structItem, i);
            }
            this.smartFileIO.WriteStructure_End();
        }
        public void SaveCounterFile(Collection<WeightData> items, int index)
        {
            string fullFilePath = "";
            bool fileCheck = false;
            StructCounter structItem;

            fullFilePath = this.PathSystemFileFolder2 + "counterItem.int";
            this.smartFileIO.FilePathName = fullFilePath;

            FileInfo fileInfo = new FileInfo(fullFilePath);
            fileCheck = fileInfo.Exists;

            if (fileCheck == true)
                this.smartFileIO.Open(this.BufferSmartUart);
            else
            {
                this.smartFileIO.Open(this.BufferSmartUart);

                this.CreateCounterFile();
            }

            structItem.OverCount1 = items[0].OverCount;
            structItem.PassCount1 = items[0].PassCount;
            structItem.UnderCount1 = items[0].UnderCount;
            structItem.ExNGCount1 = items[0].ExNGCount;

            structItem.OverCount2 = items[1].OverCount;
            structItem.PassCount2 = items[1].PassCount;
            structItem.UnderCount2 = items[1].UnderCount;
            structItem.ExNGCount2 = items[1].ExNGCount;

            structItem.OverCount3 = items[2].OverCount;
            structItem.PassCount3 = items[2].PassCount;
            structItem.UnderCount3 = items[2].UnderCount;
            structItem.ExNGCount3 = items[2].ExNGCount;

            structItem.OverCount4 = items[3].OverCount;
            structItem.PassCount4 = items[3].PassCount;
            structItem.UnderCount4 = items[3].UnderCount;
            structItem.ExNGCount4 = items[3].ExNGCount;

            structItem.OverCount5 = items[4].OverCount;
            structItem.PassCount5 = items[4].PassCount;
            structItem.UnderCount5 = items[4].UnderCount;
            structItem.ExNGCount5 = items[4].ExNGCount;

            structItem.OverCount6 = items[5].OverCount;
            structItem.PassCount6 = items[5].PassCount;
            structItem.UnderCount6 = items[5].UnderCount;
            structItem.ExNGCount6 = items[5].ExNGCount;

            structItem.DummyInt1 = 0;
            structItem.DummyInt2 = 0;
            structItem.DummyInt3 = 0;
            structItem.DummyInt4 = 0;
            structItem.DummyInt5 = 0;
            structItem.DummyInt6 = 0;
            structItem.DummyInt7 = 0;
            structItem.DummyInt8 = 0;
            structItem.DummyInt9 = 0;
            structItem.DummyInt10 = 0;

            this.smartFileIO.WriteStructure_Begin(structItem, index);
            this.smartFileIO.WriteStructure_End();

            this.smartFileIO.Close();
        }
        public void LoadCounterFile(ref Collection<WeightData> items, int index)
        {
            string fullFilePath = "";
            bool fileCheck = false;
            StructCounter structItem;

            fullFilePath = this.PathSystemFileFolder2 + "counterItem.int";
            this.smartFileIO.FilePathName = fullFilePath;

            FileInfo fileInfo = new FileInfo(fullFilePath);
            fileCheck = fileInfo.Exists;

            if (fileCheck == true)
                this.smartFileIO.Open(this.BufferSmartUart);
            else
            {
                this.smartFileIO.Open(this.BufferSmartUart);

                this.CreateCounterFile();
            }

            try
            {
                structItem = (StructCounter)this.smartFileIO.ReadStructure(index, typeof(StructCounter));

                items[0].UnderCount = structItem.UnderCount1;
                items[0].PassCount = structItem.PassCount1;
                items[0].OverCount = structItem.OverCount1;
                items[0].ExNGCount = structItem.ExNGCount1;

                items[1].UnderCount = structItem.UnderCount2;
                items[1].PassCount = structItem.PassCount2;
                items[1].OverCount = structItem.OverCount2;
                items[1].ExNGCount = structItem.ExNGCount2;

                items[2].UnderCount = structItem.UnderCount3;
                items[2].PassCount = structItem.PassCount3;
                items[2].OverCount = structItem.OverCount3;
                items[2].ExNGCount = structItem.ExNGCount3;

                items[3].UnderCount = structItem.UnderCount4;
                items[3].PassCount = structItem.PassCount4;
                items[3].OverCount = structItem.OverCount4;
                items[3].ExNGCount = structItem.ExNGCount4;

                items[4].UnderCount = structItem.UnderCount5;
                items[4].PassCount = structItem.PassCount5;
                items[4].OverCount = structItem.OverCount5;
                items[4].ExNGCount = structItem.ExNGCount5;

                items[5].UnderCount = structItem.UnderCount6;
                items[5].PassCount = structItem.PassCount6;
                items[5].OverCount = structItem.OverCount6;
                items[5].ExNGCount = structItem.ExNGCount6;
            }
            catch
            {
                DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig.Language, "");
                myMsg.Location = new Point(167, 207);
                myMsg.ShowDialog();

                this.smartFileIO.Close();
            }
            this.smartFileIO.Close();
        }
        #endregion

        #region FeedbackItem File
        private void CreateFeedbackItemFile()
        {
            string fullFilePath = "";
            StructFeedbackConfiguration structItem;
            Collection<ProductItem> collectionProductItem;

            collectionProductItem = new Collection<ProductItem>();
            for (int i = 0; i < 1000; i++)
                collectionProductItem.Add(new ProductItem());

            this.LoadProductFile(ref collectionProductItem);

            this.smartFileIO.Close();
            fullFilePath = this.PathSystemFileFolder2 + "FeedbackItem.int";
            this.smartFileIO.FilePathName = fullFilePath;
            this.smartFileIO.Open(this.BufferSmartUart);

            this.CurrentFeedbackItem.Initialization();

            for (int i = 0; i < 1000; i++)
            {
                structItem.HightLimit = collectionProductItem[i].OverRange;
                structItem.LowLimit = collectionProductItem[i].UnderRange;
                structItem.DeadZone = this.CurrentFeedbackItem.DeadZone;

                structItem.DummyBool1 = false;
                structItem.DummyBool2 = false;
                structItem.DummyBool3 = false;

                structItem.DummyInt1 = 1;
                structItem.DummyInt2 = 1;
                structItem.DummyInt3 = 1;

                structItem.DummyString1 = "";
                structItem.DummyString2 = "";
                structItem.DummyString3 = "";

                this.smartFileIO.WriteStructure_Begin(structItem, i);
            }
            this.smartFileIO.WriteStructure_End();
        }
        public void SaveFeedbackItemFile(FeedbackConfiguration item, int index)
        {
            bool fileCheck = false;
            string fullFilePath = "";
            StructFeedbackConfiguration structItem;

            this.smartFileIO.Close();
            fullFilePath = this.PathSystemFileFolder2 + "FeedbackItem.int";
            this.smartFileIO.FilePathName = fullFilePath;

            FileInfo fileInfo = new FileInfo(fullFilePath);
            fileCheck = fileInfo.Exists;

            if (fileCheck == false)
                this.CreateFeedbackItemFile();
            else
                this.smartFileIO.Open(this.BufferSmartUart);

            structItem.HightLimit = item.HighLimit;
            structItem.LowLimit = item.LowLimit;
            structItem.DeadZone = item.DeadZone;

            structItem.DummyBool1 = false;
            structItem.DummyBool2 = false;
            structItem.DummyBool3 = false;

            structItem.DummyInt1 = 1;
            structItem.DummyInt2 = 1;
            structItem.DummyInt3 = 1;

            structItem.DummyString1 = "";
            structItem.DummyString2 = "";
            structItem.DummyString3 = "";

            this.smartFileIO.WriteStructure_Begin(structItem, index);
            this.smartFileIO.WriteStructure_End();

            this.smartFileIO.Close();
        }
        public void LoadFeedbackItemFile(ref FeedbackConfiguration item, int index)
        {
            bool fileCheck = false;
            string fullFilePath = "";
            StructFeedbackConfiguration structItem;

            this.smartFileIO.Close();
            fullFilePath = this.PathSystemFileFolder2 + "FeedbackItem.int";
            this.smartFileIO.FilePathName = fullFilePath;

            FileInfo fileInfo = new FileInfo(fullFilePath);
            fileCheck = fileInfo.Exists;

            if (fileCheck == false)
                this.CreateFeedbackItemFile();
            else
                this.smartFileIO.Open(this.BufferSmartUart);

            try
            {
                structItem = (StructFeedbackConfiguration)this.smartFileIO.ReadStructure(index, typeof(StructFeedbackConfiguration));

                item.HighLimit = structItem.HightLimit;
                item.LowLimit = structItem.LowLimit;
                item.DeadZone = structItem.DeadZone;
            }
            catch
            {
                DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig.Language);
                myMsg.ShowDialog();

                this.smartFileIO.Close();
            }

            this.smartFileIO.Close();
        }
        #endregion
        #region FeedbackSystem
        private void FeedbackCalculation(int lane, WeightData data)
        {
            double passRange = 0.0, sumWeight = 0.0, averageWeight = 0.0, feedbackWeight = 0.0;

            if (this.CollectionFeedbackStatus[lane - 1].IsFbCalComplete == true)
            {
                this.CollectionFeedbackStatus[lane - 1].IgnoreCount++;

                if (this.CollectionFeedbackStatus[lane - 1].IgnoreCount >= this.SystemConfig.FeedbackIgnorePackages)
                {
                    this.CollectionFeedbackStatus[lane - 1].IgnoreCount = 0;
                    this.CollectionFeedbackStatus[lane - 1].IsFbCalComplete = false;
                }
            }
            else
            {
                this.SetFeedbackSystem(lane, data);

                if (this.CollectionFeedbackStatus[lane - 1].WeightList.Count >= this.SystemConfig.FeedbackSampleCount)
                {
                    passRange = Helper.StringToWeight(this.CurrentProductItem.PassRange, this.SystemConfig.DecimalPlaces);
                    sumWeight = Helper.StringToWeight(this.CollectionFeedbackStatus[lane - 1].SumWeight.ToString(), this.SystemConfig.DecimalPlaces);
                    averageWeight = Math.Round((sumWeight / this.SystemConfig.FeedbackSampleCount), this.SystemConfig.DecimalPlaces);
                    feedbackWeight = averageWeight - passRange;

                    this.CollectionFeedbackStatus[lane - 1].FeedbackWeight = feedbackWeight;
                    this.CollectionFeedbackStatus[lane - 1].ClearData();
                    this.CollectionFeedbackStatus[lane - 1].IsFbCalComplete = true;

                    if (this.CollectionFeedbackStatus[lane - 1].UpdateFeedbackData > 65535)
                        this.CollectionFeedbackStatus[lane - 1].UpdateFeedbackData = 0;
                    else
                        this.CollectionFeedbackStatus[lane - 1].UpdateFeedbackData++;

                    if (this.SystemConfig.IsFeedbackBoard == true)
                        this.SerialPort3_Write(this.Protocol_STD3_NotStxEtx(this.SystemConfig, this.CollectionFeedbackStatus[lane - 1], lane));
                }
            }
        }
        private void SetFeedbackSystem(int lane, WeightData data)
        {
            int checkWeight = 0;
            int passRange = 0, lowLimit = 0, highLimit = 0, deadZone = 0, deadZoneLow = 0, deadZoneHigh = 0;
            DataStore.FeedbackStatus status = DataStore.FeedbackStatus.None;

            checkWeight = int.Parse(data.WeightString);
            passRange = int.Parse(this.CurrentProductItem.PassRange);
            lowLimit = int.Parse(this.CurrentFeedbackItem.LowLimit);
            highLimit = int.Parse(this.CurrentFeedbackItem.HighLimit);
            deadZone = int.Parse(this.CurrentFeedbackItem.DeadZone);
            deadZoneLow = passRange - deadZone;
            deadZoneHigh = passRange + deadZone;

            if (((checkWeight < deadZoneLow) && (checkWeight > lowLimit)) || ((checkWeight > deadZoneHigh) && (checkWeight < highLimit)))
            {
                if ((checkWeight < deadZoneLow) && (checkWeight > lowLimit))
                    status = DataStore.FeedbackStatus.Negative;
                else
                    status = DataStore.FeedbackStatus.Positive;

                this.CollectionFeedbackStatus[lane - 1].SetWeight(checkWeight, status);
            }
            else
                this.CollectionFeedbackStatus[lane - 1].ClearDataList();
        }
        #endregion

        #region UserLevel1File
        private void CreateUserLevel1File()
        {
            StructUserItem structItem;
            User item = new User();

            structItem.ID = "L1";
            structItem.Password = "1111";
            structItem.Group = DataStore.UserGroup.Level1Operator;

            structItem.Dummy1 = "";
            structItem.Dummy2 = "";
            structItem.Dummy3 = "";
            structItem.Dummy4 = "";
            structItem.Dummy5 = "";

            this.smartFileIO.WriteStructure_Begin(structItem, 0);

            for (int i = 1; i < 5; i++)
            {
                structItem.ID = item.ID;
                structItem.Password = item.Password;
                structItem.Group = item.Group;

                structItem.Dummy1 = "";
                structItem.Dummy2 = "";
                structItem.Dummy3 = "";
                structItem.Dummy4 = "";
                structItem.Dummy5 = "";

                this.smartFileIO.WriteStructure_Begin(structItem, i);
            }
            this.smartFileIO.WriteStructure_End();
        }
        public void SaveUserLevel1File(Collection<User> item)
        {
            string fullFilePath = "";
            bool fileCheck = false;
            StructUserItem structItem;

            fullFilePath = this.PathSystemFileFolder1 + "UserLevel1.int";
            this.smartFileIO.FilePathName = fullFilePath;

            FileInfo fileInfo = new FileInfo(fullFilePath);
            fileCheck = fileInfo.Exists;

            if (fileCheck == true)
                this.smartFileIO.Open(this.BufferSmartUart);
            else
            {
                this.smartFileIO.Open(this.BufferSmartUart);

                this.CreateUserLevel1File();
            }

            if (item.Count == 0)
                return;

            for (int i = 0; i < item.Count; i++)
            {
                structItem.ID = item[i].ID;
                structItem.Password = item[i].Password;
                structItem.Group = item[i].Group;

                structItem.Dummy1 = "";
                structItem.Dummy2 = "";
                structItem.Dummy3 = "";
                structItem.Dummy4 = "";
                structItem.Dummy5 = "";

                this.smartFileIO.WriteStructure_Begin(structItem, i);
            }
            this.smartFileIO.WriteString_End();
            this.smartFileIO.Close();
        }
        public void LoadUserLevel1File(Collection<User> item)
        {
            string fullFilePath = "";
            bool fileCheck = false;
            StructUserItem structItem;

            fullFilePath = this.PathSystemFileFolder1 + "UserLevel1.int";
            this.smartFileIO.FilePathName = fullFilePath;

            FileInfo fileInfo = new FileInfo(fullFilePath);
            fileCheck = fileInfo.Exists;

            if (fileCheck == true)
                this.smartFileIO.Open(this.BufferSmartUart);
            else
            {
                this.smartFileIO.Open(this.BufferSmartUart);

                this.CreateUserLevel1File();
            }

            try
            {
                for (int i = 0; i < item.Count; i++)
                {
                    structItem = (StructUserItem)this.smartFileIO.ReadStructure(i, typeof(StructUserItem));

                    item[i].ID = structItem.ID;
                    item[i].Password = structItem.Password;
                    item[i].Group = structItem.Group;
                }
            }
            catch
            {
                DialogFormMessage myMsg = new DialogFormMessage(31, this.SystemConfig.Language, "");
                myMsg.ShowDialog();

                this.smartFileIO.Close();
            }
            this.smartFileIO.Close();
        }
        #endregion
        #region UserLevel2File
        private void CreateUserLevel2File()
        {
            StructUserItem structItem;
            User item = new User();

            structItem.ID = "L2";
            structItem.Password = "2222";
            structItem.Group = DataStore.UserGroup.Level2Engineer;

            structItem.Dummy1 = "";
            structItem.Dummy2 = "";
            structItem.Dummy3 = "";
            structItem.Dummy4 = "";
            structItem.Dummy5 = "";

            this.smartFileIO.WriteStructure_Begin(structItem, 0);

            for (int i = 1; i < 5; i++)
            {
                structItem.ID = item.ID;
                structItem.Password = item.Password;
                structItem.Group = item.Group;

                structItem.Dummy1 = "";
                structItem.Dummy2 = "";
                structItem.Dummy3 = "";
                structItem.Dummy4 = "";
                structItem.Dummy5 = "";

                this.smartFileIO.WriteStructure_Begin(structItem, i);
            }
            this.smartFileIO.WriteStructure_End();
        }
        public void SaveUserLevel2File(Collection<User> item)
        {
            string fullFilePath = "";
            bool fileCheck = false;
            StructUserItem structItem;

            fullFilePath = this.PathSystemFileFolder1 + "UserLevel2.int";
            this.smartFileIO.FilePathName = fullFilePath;

            FileInfo fileInfo = new FileInfo(fullFilePath);
            fileCheck = fileInfo.Exists;

            if (fileCheck == true)
                this.smartFileIO.Open(this.BufferSmartUart);
            else
            {
                this.smartFileIO.Open(this.BufferSmartUart);

                this.CreateUserLevel2File();
            }

            if (item.Count == 0)
                return;

            for (int i = 0; i < item.Count; i++)
            {
                structItem.ID = item[i].ID;
                structItem.Password = item[i].Password;
                structItem.Group = item[i].Group;

                structItem.Dummy1 = "";
                structItem.Dummy2 = "";
                structItem.Dummy3 = "";
                structItem.Dummy4 = "";
                structItem.Dummy5 = "";

                this.smartFileIO.WriteStructure_Begin(structItem, i);
            }
            this.smartFileIO.WriteString_End();
            this.smartFileIO.Close();
        }
        public void LoadUserLevel2File(Collection<User> item)
        {
            string fullFilePath = "";
            bool fileCheck = false;
            StructUserItem structItem;

            fullFilePath = this.PathSystemFileFolder1 + "UserLevel2.int";
            this.smartFileIO.FilePathName = fullFilePath;

            FileInfo fileInfo = new FileInfo(fullFilePath);
            fileCheck = fileInfo.Exists;

            if (fileCheck == true)
                this.smartFileIO.Open(this.BufferSmartUart);
            else
            {
                this.smartFileIO.Open(this.BufferSmartUart);

                this.CreateUserLevel2File();
            }

            try
            {
                for (int i = 0; i < item.Count; i++)
                {
                    structItem = (StructUserItem)this.smartFileIO.ReadStructure(i, typeof(StructUserItem));

                    item[i].ID = structItem.ID;
                    item[i].Password = structItem.Password;
                    item[i].Group = structItem.Group;
                }
            }
            catch
            {
                DialogFormMessage myMsg = new DialogFormMessage(31, this.SystemConfig.Language, "");
                myMsg.ShowDialog();

                this.smartFileIO.Close();
            }
            this.smartFileIO.Close();
        }
        #endregion
        #region UserLevel3File
        private void CreateUserLevel3File()
        {
            StructUserItem structItem;
            User item = new User();

            structItem.ID = "L3";
            structItem.Password = "3333";
            structItem.Group = DataStore.UserGroup.Level3Manager;

            structItem.Dummy1 = "";
            structItem.Dummy2 = "";
            structItem.Dummy3 = "";
            structItem.Dummy4 = "";
            structItem.Dummy5 = "";

            this.smartFileIO.WriteStructure_Begin(structItem, 0);

            for (int i = 1; i < 5; i++)
            {
                structItem.ID = item.ID;
                structItem.Password = item.Password;
                structItem.Group = item.Group;

                structItem.Dummy1 = "";
                structItem.Dummy2 = "";
                structItem.Dummy3 = "";
                structItem.Dummy4 = "";
                structItem.Dummy5 = "";

                this.smartFileIO.WriteStructure_Begin(structItem, i);
            }
            this.smartFileIO.WriteStructure_End();
        }
        public void SaveUserLevel3File(Collection<User> item)
        {
            string fullFilePath = "";
            bool fileCheck = false;
            StructUserItem structItem;

            fullFilePath = this.PathSystemFileFolder1 + "UserLevel3.int";
            this.smartFileIO.FilePathName = fullFilePath;

            FileInfo fileInfo = new FileInfo(fullFilePath);
            fileCheck = fileInfo.Exists;

            if (fileCheck == true)
                this.smartFileIO.Open(this.BufferSmartUart);
            else
            {
                this.smartFileIO.Open(this.BufferSmartUart);

                this.CreateUserLevel3File();
            }

            if (item.Count == 0)
                return;

            for (int i = 0; i < item.Count; i++)
            {
                structItem.ID = item[i].ID;
                structItem.Password = item[i].Password;
                structItem.Group = item[i].Group;

                structItem.Dummy1 = "";
                structItem.Dummy2 = "";
                structItem.Dummy3 = "";
                structItem.Dummy4 = "";
                structItem.Dummy5 = "";

                this.smartFileIO.WriteStructure_Begin(structItem, i);
            }
            this.smartFileIO.WriteString_End();
            this.smartFileIO.Close();
        }
        public void LoadUserLevel3File(Collection<User> item)
        {
            string fullFilePath = "";
            bool fileCheck = false;
            StructUserItem structItem;

            fullFilePath = this.PathSystemFileFolder1 + "UserLevel3.int";
            this.smartFileIO.FilePathName = fullFilePath;

            FileInfo fileInfo = new FileInfo(fullFilePath);
            fileCheck = fileInfo.Exists;

            if (fileCheck == true)
                this.smartFileIO.Open(this.BufferSmartUart);
            else
            {
                this.smartFileIO.Open(this.BufferSmartUart);

                this.CreateUserLevel3File();
            }

            try
            {
                for (int i = 0; i < item.Count; i++)
                {
                    structItem = (StructUserItem)this.smartFileIO.ReadStructure(i, typeof(StructUserItem));

                    item[i].ID = structItem.ID;
                    item[i].Password = structItem.Password;
                    item[i].Group = structItem.Group;
                }
            }
            catch
            {
                DialogFormMessage myMsg = new DialogFormMessage(31, this.SystemConfig.Language, "");
                myMsg.ShowDialog();

                this.smartFileIO.Close();
            }
            this.smartFileIO.Close();
        }
        #endregion

        #region Data Backup
        private void WriteUsingStreamWriter(WeightData item, string fullFilePath)
        {
            StreamWriter sw;

            sw = new StreamWriter(fullFilePath, true, Encoding.Default);

            sw.Write(string.Format("{0:yyyy-MM-dd}", DateTime.Now));
            sw.Write(",");
            sw.Write(string.Format("{0:HH:mm:ss}", DateTime.Now));
            sw.Write(",");
            sw.Write(this.CurrentProductItem.Number);
            sw.Write(",");
            sw.Write(this.CurrentProductItem.Name);
            sw.Write(",");
            sw.Write(this.CurrentProductItem.LotNo);
            sw.Write(",");
            sw.Write(Helper.DoubleToString(item.Weight, this.SystemConfig.DecimalPlaces));
            sw.Write(",");
            sw.Write(item.JudgmentStatus);
            sw.WriteLine();

            sw.Close();
        }

        private void DataBackup(Collection<WeightData> items)
        {
            bool fileCheck = false, directoryCheck = false;
            string fullFilePath = "";
            StreamWriter sw;

            this.RemoveUsbBackupFile();

            if (this.SystemConfig.IsDataBackup == true)
            {
                fullFilePath = string.Format("{0}{1:yyyyMMdd}_{2}.csv", this.PathDataBackupFolder, DateTime.Now, this.SystemConfig.UsbID);

                DirectoryInfo di = new DirectoryInfo(this.PathDataBackupFolder);
                directoryCheck = di.Exists;
                // 폴더 체크
                if (directoryCheck == false)
                    di.Create();

                FileInfo fileInfo = new FileInfo(fullFilePath);
                fileCheck = fileInfo.Exists;

                sw = new StreamWriter(fullFilePath, true, Encoding.UTF8);

                if (fileCheck == false)
                {
                    sw.Write("Date");
                    sw.Write(",");
                    sw.Write("Time");
                    sw.Write(",");
                    sw.Write("P_No");
                    sw.Write(",");
                    sw.Write("Name");
                    sw.Write(",");
                    sw.Write("Lot");

                    for (int i = 0; i < this.SystemConfig.EquipmentColumns; i++)
                    {
                        sw.Write(",");
                        sw.Write(string.Format("#{0}_Weight", i + 1));
                        sw.Write(",");
                        sw.Write("Grade");
                    }

                    sw.WriteLine();
                }

                sw.Write(string.Format("{0:yyyy-MM-dd}", DateTime.Now));
                sw.Write(",");
                sw.Write(string.Format("{0:HH:mm:ss}", DateTime.Now));
                sw.Write(",");
                sw.Write(this.CurrentProductItem.Number);
                sw.Write(",");
                sw.Write(this.CurrentProductItem.Name);
                sw.Write(",");
                sw.Write(this.CurrentProductItem.LotNo);

                for (int i = 0; i < this.SystemConfig.EquipmentColumns; i++)
                {
                    sw.Write(",");
                    sw.Write(Helper.DoubleToString(items[i].Weight, this.SystemConfig.DecimalPlaces));
                    sw.Write(",");
                    sw.Write(items[i].JudgmentStatus);
                }
                sw.WriteLine();
                sw.Close();
            }
        }
        private void DataBackup(WeightData item, int line)
        {
            bool fileCheck = false, directoryCheck = false;
            string fullFilePath = "";
            StreamWriter sw;

            this.RemoveUsbBackupFile();

            if (this.SystemConfig.IsDataBackup == true)
            {
                fullFilePath = string.Format("{0}{1:yyyyMMdd}_{2}_{3}Lane.csv", this.PathDataBackupFolder, DateTime.Now, this.SystemConfig.UsbID, line);

                DirectoryInfo di = new DirectoryInfo(this.PathDataBackupFolder);
                directoryCheck = di.Exists;
                // 폴더 체크
                if (directoryCheck == false)
                    di.Create();

                FileInfo fileInfo = new FileInfo(fullFilePath);
                fileCheck = fileInfo.Exists;

                sw = new StreamWriter(fullFilePath, true, Encoding.UTF8);

                if (fileCheck == false)
                {
                    sw.Write("Date");
                    sw.Write(",");
                    sw.Write("Time");
                    sw.Write(",");
                    sw.Write("P_No");
                    sw.Write(",");
                    sw.Write("Name");
                    sw.Write(",");
                    sw.Write("Lot");
                    sw.Write(",");
                    sw.Write("Weight");
                    sw.Write(",");
                    sw.Write("Grade");

                    sw.WriteLine();
                }

                sw.Write(string.Format("{0:yyyy-MM-dd}", DateTime.Now));
                sw.Write(",");
                sw.Write(string.Format("{0:HH:mm:ss}", DateTime.Now));
                sw.Write(",");
                sw.Write(this.CurrentProductItem.Number);
                sw.Write(",");
                sw.Write(this.CurrentProductItem.Name);
                sw.Write(",");
                sw.Write(this.CurrentProductItem.LotNo);
                sw.Write(",");
                sw.Write(Helper.DoubleToString(item.Weight, this.SystemConfig.DecimalPlaces));
                sw.Write(",");
                sw.Write(item.JudgmentStatus);
                sw.WriteLine();

                sw.Close();
            }
        }

        private void RemoveUsbBackupFile()
        {
            bool directoryCheck = false;

            try
            {
                string dday = string.Format("{0:yyyyMMdd}", DateTime.Now.AddDays(-180)) + ".csv";

                DirectoryInfo dir = new DirectoryInfo(this.PathDataBackupFolder);

                directoryCheck = dir.Exists;
                // 폴더 체크
                if (directoryCheck == false)
                    dir.Create();

                FileInfo[] files = dir.GetFiles();
                foreach (FileInfo subfile in files)
                {
                    if (subfile.Name.StartsWith("20"))  // 날짜 비교하여 10일 지난화일은 삭제함 
                    {
                        if (subfile.Name.CompareTo(dday) < 0)
                        {
                            subfile.Delete();
                        }
                    }
                }
            }
            catch
            {

            }

        }
        #endregion
        #endregion

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

            // 변수 초기 셋팅1
            this.DefaultSetting1();
            // SystemConfiguration 읽기
            this.LoadSystemConfigurationFile();
            // Collection 생성
            this.CreateCollection();
            // Count 읽기
            this.LoadCounterFile(ref this.CollectionWeightData, this.SystemConfig.ProductNumber - 1);
            // 품목 파일 읽기
            this.LoadProductFile(ref this.CurrentProductItem, this.SystemConfig.ProductNumber - 1);
            // 판정설정 파일 읽기
            this.LoadJudgmentSetFile(ref this.CurrentJudgmentSetItem, this.SystemConfig.ProductNumber - 1);
            // Feedback 파일 읽기
            this.LoadFeedbackItemFile(ref this.CurrentFeedbackItem, this.SystemConfig.ProductNumber - 1);
            // 품목명 읽기
            this.LoadProductName(ref this.CollectionProductName);
            // User 파일 읽기
            this.LoadUserLevel1File(this.CurrentCollectionUser.Level1Users);
            this.LoadUserLevel2File(this.CurrentCollectionUser.Level2Users);
            this.LoadUserLevel3File(this.CurrentCollectionUser.Level3Users);

            // 폼생성
            this.CreateForm();

            // 변수 초기 셋팅2
            this.DefaultSetting2();

            // 통신 OPEN
            this.OpenSmartUartLink();

            this.Update30000DecimalPoint();
            this.Update30000ModbusData();
            for (int i = 0; i < this.SystemConfig.EquipmentColumns; i++)
                this.Update30000ModbusData(i);

            // Serial3 Open
            this.SerialPort3_Open();

            // 초기 파라미터 전송
            this.TrasferSystemParameter(this.SystemConfig);

            this.SmartSplashProgramLoad.Finish();

            this.smartForm.Show((int)DataStore.E_FormStore.FormMainDisplay);

            // Feedback Board
            if (this.SystemConfig.IsFeedbackBoard == true)
                this.SerialPort3_FbBoardBooting();
        }
        #endregion

        #region Event Handler
        private void timerForTimeOutSetting_Tick(object sender, EventArgs e)
        {
            this.TimeOut++;

            if (TimeOut == 2)
            {
                // 에러 발생! 다시 시도해주세요
                DialogFormMessage myMsg = new DialogFormMessage(16, this.SystemConfig.Language, "");
                myMsg.ShowDialog();

                this.TimeOut = 0;

                this.LineNum = 1;
                this.CurrentLineNum = 0;
            }
        }

        private void smartSerialPortLink_OnReadQueueEvent()
        {
            this.ReceiveData();

            // 통신 확인
            if (this.CommunicationCheckCount / 3 == 1)
            {
                this.ChildFormMainDisplay.pictureBoxCommunicationStatus.Visible = true;
                this.CommunicationCheckCount = 0;
            }
            else
            {
                this.ChildFormMainDisplay.pictureBoxCommunicationStatus.Visible = false;
                this.CommunicationCheckCount += 1;
            }
        }
        private void smartTCPMultiServer_OnReceiveHandler(SmartTCPMultiServer.CHandleClinet.READINFO datas)
        {
            int ret = 0;
            byte[] readByte;
            string strRecData = "";
            byte[] sendOPCDatas = new byte[57];
            byte[] sendModbusDatas;
            byte[] madeDatas;

            try
            {
                readByte = datas.receiveDatas;
                strRecData = SmartTCPMultiServer.ConvertAsciiByteToString(readByte);
            }
            catch
            {
                return;
            }

            switch (this.SystemConfig.EthernetMode)
            {
                case (int)DataStore.CommunicationMode.f99_Modbus:
                    #region Modbus TCP
                    if (this.smartTCPMultiServer.ClientInfoList != null)
                    {
                        if (readByte[7] == 0x03) // Read Holding Register
                        {
                            #region Read Holding Register
                            try
                            {
                                byte[] responseData;
                                byte errorCheck = this.Modbus.CheckRequestSpecialDataErrorTCP(readByte, ModbusFunctionCode.FunctionCode_03);

                                if (errorCheck == 0x00)
                                    responseData = this.Modbus.MakeTCPResponseData(readByte, this.Protocol_Modbus_Server_Read_Lane_Data_TCP(readByte), ModbusFunctionCode.FunctionCode_03);
                                else
                                    responseData = this.Modbus.MakeTCPErrorResponseData(readByte, errorCheck, ModbusFunctionCode.FunctionCode_03);

                                foreach (SmartTCPMultiServer.CLIENTSINFOS client in this.smartTCPMultiServer.ClientInfoList)
                                {
                                    this.smartTCPMultiServer.SendByteByClientID(client.strID, responseData);
                                }

                                // 로그
                                if (this.IsCommunicationLogOpen == true)
                                {
                                    this.smartFileCommunicationLog.WriteString(string.Format("Receive TCP ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, BitConverter.ToString(readByte)));
                                    this.smartFileCommunicationLog.WriteString(string.Format("Send TCP ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, BitConverter.ToString(responseData)));
                                }
                            }
                            catch
                            {
                            }
                            #endregion
                        }
                        else if (readByte[7] == 0x10) // Write Multiple Register
                        {
                            #region Write Multiple Register
                            try
                            {
                                byte[] errorResponseData = new byte[9];
                                byte[] responseData = new byte[12];
                                byte errorCheck = this.Modbus.CheckRequestSpecialDataErrorTCP(readByte, ModbusFunctionCode.FunctionCode_16);

                                if (errorCheck == 0x00)
                                {
                                    for (int i = 0; i < 12; i++)
                                        responseData[i] = readByte[i];
                                    responseData[5] = 0x06;

                                    foreach (SmartTCPMultiServer.CLIENTSINFOS client in this.smartTCPMultiServer.ClientInfoList)
                                    {
                                        this.smartTCPMultiServer.SendByteByClientID(client.strID, responseData);
                                    }

                                    this.ReceiveModbusTCPWriteManager(readByte);
                                }
                                else
                                {
                                    for (int i = 0; i < 5; i++)
                                        errorResponseData[i] = readByte[i];

                                    // Length
                                    errorResponseData[5] = 0x03;
                                    // Unit ID
                                    errorResponseData[6] = 0x01;
                                    // Function Code
                                    errorResponseData[7] = 0x90;
                                    // Error Code
                                    errorResponseData[8] = errorCheck;

                                    foreach (SmartTCPMultiServer.CLIENTSINFOS client in this.smartTCPMultiServer.ClientInfoList)
                                    {
                                        this.smartTCPMultiServer.SendByteByClientID(client.strID, responseData);
                                    }
                                }

                                // 로그
                                if (this.IsCommunicationLogOpen == true)
                                {
                                    this.smartFileCommunicationLog.WriteString(string.Format("Receive TCP ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, BitConverter.ToString(readByte)));
                                    this.smartFileCommunicationLog.WriteString(string.Format("Send TCP ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, BitConverter.ToString(responseData)));
                                }
                            }
                            catch
                            {
                            }
                            #endregion
                        }
                        else // Read Input Register(0x04)
                        {
                            #region Read Input Register
                            try
                            {
                                byte[] responseData;
                                byte errorCheck = this.Modbus.CheckRequestSpecialDataErrorTCP(readByte, ModbusFunctionCode.FunctionCode_04);

                                if (errorCheck == 0x00)
                                    responseData = this.Modbus.MakeTCP04ResponseData(readByte, this.Protocol_Modbus_Server_Read_Lane_Data_TCP(readByte));
                                else
                                    responseData = this.Modbus.MakeTCP04ErrorResponseData(readByte, errorCheck);

                                foreach (SmartTCPMultiServer.CLIENTSINFOS client in this.smartTCPMultiServer.ClientInfoList)
                                {
                                    this.smartTCPMultiServer.SendByteByClientID(client.strID, responseData);
                                }

                                // 로그
                                //if (this.IsCommunicationLogOpen == true)
                                //{
                                //this.smartFileCommunicationLog.WriteString(string.Format("Receive TCP ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, BitConverter.ToString(readByte)));
                                //this.smartFileCommunicationLog.WriteString(string.Format("Send TCP ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, BitConverter.ToString(responseData)));
                                //}
                            }
                            catch
                            {
                            }
                            #endregion
                        }
                    }
                    #endregion
                    break;
                default:
                    break;
            }
        }

        private void timerAdcLog_Tick(object sender, EventArgs e)
        {
            this.FlagADCValueWrite = true;
        }

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

            this.timerTimeoutOPT4.Enabled = false;

            if (this.CurrentFeedbackItem.DataTransfer == DataStore.FeedbackBoardDataTransfer.Step1_6203)
            {
                if (this.CurrentFeedbackItem.RetryCount < 5)
                {
                    value = Helper.StringZeroFillDigits4(this.SystemConfig.FeedbackPulseWidth.ToString());
                    this.SerialPort3_Write(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._6203_FeedbackPulseWidth, value);
                    this.timerTimeoutOPT4.Enabled = true;
                    this.CurrentFeedbackItem.RetryCount++;
                }
                else
                {
                    this.CurrentFeedbackItem.RetryCount = 0;
                    this.ChildFormMainDisplay.UpdateFeedbackBoardStatusDisplay(false);
                }
            }
            else if (this.CurrentFeedbackItem.DataTransfer == DataStore.FeedbackBoardDataTransfer.Step2_6208)
            {
                if (this.CurrentFeedbackItem.RetryCount < 5)
                {
                    value = Helper.StringZeroFillDigits4(this.SystemConfig.FeedbackCorrectionRate.ToString());
                    this.SerialPort3_Write(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._6208_FeedbackCollectionRate, value);
                    this.timerTimeoutOPT4.Enabled = true;
                    this.CurrentFeedbackItem.RetryCount++;
                }
                else
                {
                    this.CurrentFeedbackItem.RetryCount = 0;
                    this.ChildFormMainDisplay.UpdateFeedbackBoardStatusDisplay(false);
                }
            }
        }
        private void timerTimeoutOPT4_OnlineCheck_Tick(object sender, EventArgs e)
        {
            this.timerTimeoutOPT4_OnlineCheck.Enabled = false;
            this.ChildFormMainDisplay.UpdateFeedbackBoardStatusDisplay(false);
        }
        private void smartSerialPort3_OnReadQueueEvent()
        {
            switch (this.SystemConfig.Serial3Mode)
            {
                case 98:
                    #region Feedback Board
                    if (this.SystemConfig.IsFeedbackBoard == true)
                        this.SerialPort3_ReceiveDataFbBoard();
                    #endregion
                    break;
                default:
                    break;
            }
        }
        #endregion
    }
}