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 INT63DC_2C.DialogForms;
using INT63DC_2C.SerialManger;
using INT63DC_2C.Part11_UserManager;
using INT63DC_2C.Part11_Encryption;
using INT63DC_2C.Int_Modbus;

namespace INT63DC_2C.Forms
{
    public partial class FormMain : Form
    {
        #region Field
        private SmartX.SmartSplash SmartSplashProgramLoad;
        private int CommunicationCheckCount;
        public bool IsCommunicationLogOpen;
        public bool IsCom1LogOpen;
        public bool IsCom3LogOpen;
        public bool IsBootingComplete;
        public bool IsAdcLogOpen;
        private bool FlagADCValueWrite;
        public int BufferSmartUart;         // Buffer size 정의
        public bool FlagThreadMessage1;     // 플레그 쓰레드 메시지 11
        private int ProductChangNumber;     // 변경할 품번
        private int FlagTimeoutCount;       // 품번 변경 실패 시 재시도 횟수
        public bool IsDeveloperMode;        // 장비테스트에서 설정 (관리자 모드) 
        public bool IsServoOrigin;          // 비상정지 시 false 처리
        public int FlagAutomaticLogoutWarningTime;  //Part11 Auto Logout 

        private string ComPortMainToLCD;

        // 파일 위치
        private string m_PathLaunchFolder;
        private string m_PathSystemFileFolder;
        private string m_PathDataBackupFolder;
        private string m_PathDataStatisticsFolder;
        private string m_PathDataFolder;
        private string m_PathDataHistoryFolder;
        private string m_PathDataInspectionFolder;
        private string m_PathDataOthersFolder;
        private string m_PathEncryptionFolder;
        private string m_PathHeaderFolder;
        private string m_PathDataLogFolder;
        private static string m_PathBinFolder;

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

        // Form 생성
        public FormMainDisplay ChildFormMainDisplay;
        public FormMenu ChildFormMenu;
        public FormSystemSetting ChildFormSystemSetting;
        public FormCalibration ChildFormCalibration;
        public FormIOTest ChildFormIOTest;
        public FormEquipmentSetting ChildFormEquipmentSetting;
        public FormDataBackup ChildFormDataBackup;
        public FormConfiguration ChildFormConfiguration;
        public FormTimeSetting ChildFormTimeSetting;
        public FormInformation ChildFormInformation;
        public FormFactoryInitialize ChildFormFactoryInitialize;
        public FormProgramUpdate ChildFormProgramUpdate;
        public FormEquipmentTest ChildFormEquipmentTest;
        public FormUserEditor ChildFormUserEditor;
        public FormDataStatistics ChildFormDataStatistics;
        public FormOptionSetting ChildFormOptionSetting;
        public FormMotorSetting ChildFormMotorSetting;
        public FormUserGroupEditor ChildFormUserGroupEditor;
        public FormDataBackup_Part11 ChildFormDataBackup_Part11;
        public FormDataViewer ChildFormDataViewer;
        public FormCommunication ChildFormCommunication;

        // System Configuration
        public SystemConfigurationItem SystemConfig;
        // 현재 선택 된 품목
        public ProductItem CurrentProductItem;
        // 현재 선택 된 판정 설정 값
        public JudgmentSetItem CurrentJudgmentSetItem;
        // 중량 조정 설정값
        public CalibrationItem CurrentCalibrationItem;
        // 제로 파라미터 설정값
        public ZeroParameterItem CurrentZeroParameterItem;
        // 옵션 파라미터 설정값
        public OptionParameterItem CurrentOptionParameterItem;
        // 통신 ABFood 
        public CommunicationStatusItem CommunicationABFood;
        // UserPasswordType
        public UserPasswordType CurrentUserPasswordType;
        // UserGroup
        public UserGroup CurrentUserGroup;
        // Communication Respone
        private CommunicationRespone CurrentComRespone;
        // Dll User_Name List
        public List<string> ListDllUserName;
        // Dataviewer Filter
        public DataViewerFilter CurrentDataViewerFilter;

        // 열별 중량 데이터
        public Collection<WeightData> CollectionWeightData;
        // 장비테스트모드 열별 중량 데이터
        public Collection<WeightData> CollectionWeightDataTest;

        // 장비 구동 상태
        private DataStore.EquipmentStatus m_EquipmentStatus;
        private DataStore.EquipmentStatus m_EquipmentStatus1;

        // 알람
        public AlarmList CurrentAlarmList;

        // Collection
        private Collection<int> CollectionGraphData;                    // 판정설정 그래프 데이터
        private Collection<string> CollectionIOTest_InputData;          // IO Test Input 데이터 취합
        private Collection<string> CollectionIOTest_InputData1;          // IO Test Input1 데이터 취합 확장보드
        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;                // 품목명 리스트

        // 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 PathSystemFileFolder
        {
            get { return this.m_PathSystemFileFolder; }
            set { this.m_PathSystemFileFolder = value; }
        }
        public string PathDataBackupFolder
        {
            get { return this.m_PathDataBackupFolder; }
            set { this.m_PathDataBackupFolder = value; }
        }
        public string PathDataStatisticsFolder
        {
            get { return this.m_PathDataStatisticsFolder; }
            private set { this.m_PathDataStatisticsFolder = value; }
        }
        public string PathDataFolder
        {
            get { return this.m_PathDataFolder; }
            private set { this.m_PathDataFolder = value; }
        }
        public string PathDataHistoryFolder
        {
            get { return this.m_PathDataHistoryFolder; }
            private set { this.m_PathDataHistoryFolder = value; }
        }
        public string PathDataInspectionFolder
        {
            get { return this.m_PathDataInspectionFolder; }
            private set { this.m_PathDataInspectionFolder = value; }
        }
        public string PathDataOthersFolder
        {
            get { return this.m_PathDataOthersFolder; }
            private set { this.m_PathDataOthersFolder = value; }
        }
        public string PathEncryptionFolder
        {
            get { return this.m_PathEncryptionFolder; }
            set { this.m_PathEncryptionFolder = value; }
        }
        public string PathHeaderFolder
        {
            get { return this.m_PathHeaderFolder; }
            private set { this.m_PathHeaderFolder = value; }
        }
        public string PathDataLogFolder
        {
            get { return this.m_PathDataLogFolder; }
            set { this.m_PathDataLogFolder = value; }
        }
        public static string PathBinFolder
        {
            get { return m_PathBinFolder; }
            private set { m_PathBinFolder = value; }
        }

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

        #region Method
        private void CreateForm()
        {
            this.ChildFormMainDisplay = new FormMainDisplay(this);
            this.ChildFormMenu = new FormMenu(this);
            this.ChildFormSystemSetting = new FormSystemSetting(this);
            this.ChildFormEquipmentSetting = new FormEquipmentSetting(this);
            this.ChildFormConfiguration = new FormConfiguration(this);
            this.ChildFormCalibration = new FormCalibration(this);
            this.ChildFormEquipmentTest = new FormEquipmentTest(this);
            this.ChildFormIOTest = new FormIOTest(this);
            this.ChildFormTimeSetting = new FormTimeSetting(this);
            this.ChildFormInformation = new FormInformation(this);
            this.ChildFormFactoryInitialize = new FormFactoryInitialize(this);
            this.ChildFormProgramUpdate = new FormProgramUpdate(this);
            this.ChildFormDataStatistics = new FormDataStatistics(this);
            this.ChildFormOptionSetting = new FormOptionSetting(this);
            this.ChildFormMotorSetting = new FormMotorSetting(this);
            this.ChildFormCommunication = new FormCommunication(this);
            this.ChildFormUserEditor = new FormUserEditor(this);
            this.ChildFormUserGroupEditor = new FormUserGroupEditor(this);
            this.ChildFormDataViewer = new FormDataViewer(this);
            if (this.SystemConfig.IsPart11 == true)
                this.ChildFormDataBackup_Part11 = new FormDataBackup_Part11(this);
            else
                this.ChildFormDataBackup = new FormDataBackup(this);

            this.smartForm.MainForm = this;

            this.smartForm.AddChildForm(this.ChildFormMainDisplay);
            this.smartForm.AddChildForm(this.ChildFormMenu);
            this.smartForm.AddChildForm(this.ChildFormSystemSetting);
            this.smartForm.AddChildForm(this.ChildFormEquipmentSetting);
            this.smartForm.AddChildForm(this.ChildFormConfiguration);
            this.smartForm.AddChildForm(this.ChildFormCalibration);
            this.smartForm.AddChildForm(this.ChildFormEquipmentTest);
            this.smartForm.AddChildForm(this.ChildFormIOTest);
            this.smartForm.AddChildForm(this.ChildFormTimeSetting);
            this.smartForm.AddChildForm(this.ChildFormInformation);
            this.smartForm.AddChildForm(this.ChildFormFactoryInitialize);
            this.smartForm.AddChildForm(this.ChildFormProgramUpdate);
            this.smartForm.AddChildForm(this.ChildFormDataStatistics);
            this.smartForm.AddChildForm(this.ChildFormOptionSetting);
            this.smartForm.AddChildForm(this.ChildFormMotorSetting);
            this.smartForm.AddChildForm(this.ChildFormCommunication);
            this.smartForm.AddChildForm(this.ChildFormUserEditor);
            this.smartForm.AddChildForm(this.ChildFormUserGroupEditor);
            this.smartForm.AddChildForm(this.ChildFormDataViewer);
            if (this.SystemConfig.IsPart11 == true)
                this.smartForm.AddChildForm(this.ChildFormDataBackup_Part11);
            else
                this.smartForm.AddChildForm(this.ChildFormDataBackup);
        }
        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.CollectionIOTest_InputData1 = 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.CollectionWeightData.Clear();
            this.CollectionWeightDataTest.Clear();
            this.CollectionGraphData.Clear();
            this.CollectionIOTest_InputData.Clear();
            this.CollectionIOTest_InputData1.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 < this.SystemConfig.EquipmentColumns; 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("");
            }

            for (int i = 0; i < 17; 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");
                this.CollectionIOTest_InputData1.Add("0");
            }
        }
        private void DefaultSetting1()
        {
            this.IsDeveloperMode = false;

            this.timerAdcLog.Interval = 300000;
            this.timerAdcLog.Enabled = false;

            this.ColorLogOff = Color.Red;
            this.ColorLogOn = Color.Green;

            this.CommunicationCheckCount = 0;
            this.IsCommunicationLogOpen = false;
            this.IsCom1LogOpen = false;
            this.IsCom3LogOpen = false;
            this.IsBootingComplete = false;
            this.IsAdcLogOpen = false;
            this.FlagADCValueWrite = false;

            this.PathLaunchFolder = "SD Card\\";
            this.PathSystemFileFolder = this.PathLaunchFolder + "SystemFile\\";
            this.PathDataBackupFolder = this.PathLaunchFolder + "DataBackup\\";
            this.PathDataStatisticsFolder = this.PathLaunchFolder + "DataStatistics\\";
            this.PathDataFolder = this.PathLaunchFolder + "Data\\";
            this.PathDataHistoryFolder = this.PathDataFolder + "History\\";
            this.PathDataInspectionFolder = this.PathDataFolder + "Inspection\\";
            this.PathDataOthersFolder = this.PathDataFolder + "Others\\";
            this.PathEncryptionFolder = this.PathLaunchFolder + "Encryption\\";
            this.PathHeaderFolder = this.PathLaunchFolder + "Header\\";
            this.PathDataLogFolder = this.PathLaunchFolder + "Log\\";
            PathBinFolder = this.PathLaunchFolder + "Bin\\";

            this.EquipmentStatus = DataStore.EquipmentStatus.Stop;
            this.BufferSmartUart = 1000000; // 1MB
            this.FlagThreadMessage1 = false;
            this.ProductChangNumber = 1;
            this.FlagTimeoutCount = 0;
            this.IsServoOrigin = false;

            this.ListDllUserName = new List<string>();
            this.ListDllUserName.Clear();

            this.CurrentAlarmList = new AlarmList();
            this.CurrentAlarmList.EventAlarmStateChange += new DataStore.EventHandlerAlarmStateChange(this.CurrentAlarmList_Change);

            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.CommunicationABFood = new CommunicationStatusItem();
            this.CurrentUserPasswordType = new UserPasswordType();
            this.CurrentUserGroup = new UserGroup();
            this.CurrentComRespone = new CommunicationRespone();
            this.CurrentDataViewerFilter = new DataViewerFilter();

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

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

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

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

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

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

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

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

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

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

            // Bin 폴더 생성
            if (Directory.Exists(PathBinFolder) == false)
                Directory.CreateDirectory(PathBinFolder);
        }
        private void DefaultSetting2()
        {
            this.timerSampling.Interval = this.SystemConfig.SamplingTime * 60000;
            this.timerLeakSampling.Interval = this.SystemConfig.LeakSamplingTime * 60000;

            // COM port 설정
            if (this.SystemConfig.ComPort == "COM2")
            {
                this.smartServoModbus.PortNo = SmartModbus.COMPORTNO.COM1;
                this.ComPortMainToLCD = "COM2:";
            }
            else
            {
                this.smartServoModbus.PortNo = SmartModbus.COMPORTNO.COM2;
                this.ComPortMainToLCD = "COM1:";
            }

            // Ethernet Static setting
            if (this.smartConfigs.IPSettings.DHCPEnable == 1)
            {
                this.smartConfigs.IPSettings.DHCPEnable = 0;

                this.smartConfigs.IPSettings.DeviceIP = "192.168.3.10";
                this.smartConfigs.IPSettings.SubNetMask = "255.255.255.0";
                this.smartConfigs.IPSettings.GateWay = "192.168.3.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();

            // SerialDll Initialize
            SerialMgrComm.IntializeSerialManager();
            SerialMgrComm.SerialPortMessageReceive += this.SerialPort_MessageReceive;
            SerialMgrComm.SerialPortErrMessageReceive += this.SerialPort_ErrMessageReceive;
        }

        private bool UI_Invoke(System.Threading.ThreadStart invoker)
        {
            try
            {
                if (this.InvokeRequired)
                {
                    if (this.IsDisposed)
                        return true;

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

                return true;
            }
            catch (Exception e)
            {
                return false;
            }
        }
        private void SerialPort_MessageReceive(object data)
        {
            this.UI_Invoke(delegate
            {
                this.SerialReceiveData(data.ToString());
            });
        }
        private void SerialPort_ErrMessageReceive(object data)
        {
            this.UI_Invoke(delegate
            {
                if (this.IsCommunicationLogOpen == true)
                    this.smartFileCommunicationLog.WriteString(string.Format("Receive ({0:yyyy-MM-dd HH:mm:ss}): {1} : Dll(Err MSG)", DateTime.Now, data));
            });
        }
        private void InitializeUserManager()
        {
            UserManager.UserListNewDataEvent += this.UserManager_UserListNewDataEvent;
            UserManager.UserListAddDataEvent += this.UserManager_UserListAddDataEvent;
            UserManager.UserListModifyUserDataEvent += this.UserManager_UserListModifyUserDataEvent;
            UserManager.UserListModifyInfoDataEvent += this.UserManager_UserListModifyInfoDataEvent;
            UserManager.UserListDeleteDataEvent += this.UserManager_UserListDeleteDataEvent;
            UserManager.UserListLockDataEvent += this.UserManager_UserListLockDataEvent;
            UserManager.UserListDefautSettingDataEvent += this.UserManager_UserListDefaultSettingDataEvent;
            UserManager.UserListLoginTimeoutDataEvent += this.UserManager_UserListLoginTimeoutDataEvent;
            UserManager.UserListGetListDataEvent += this.UserManager_UserListGetListDataEvent;
            UserManager.UserListLoginDataEvent += this.UserManager_UserListLoginDataEvent;
            UserManager.UserListLogoutDataEvent += this.UserManager_UserListLogoutDataEvent;
            UserManager.UserListGetListNameDataEvent += this.UserManager_UserListGetListNameDataEvent;
            UserManager.UserListGetVersionDataEvent += this.UserManager_UserListGetVersionDataEvent;

            UserManager.IntializeUserManager(this.PathSystemFileFolder);

            if (this.SystemConfig.AutomaticLogout == 1)
                this.FlagAutomaticLogoutWarningTime = 30;
            else
                this.FlagAutomaticLogoutWarningTime = 60;

            UserManager.UserManager_AutoLogoutSetTimeout(this.SystemConfig.AutomaticLogout, this.FlagAutomaticLogoutWarningTime);
        }
        private void InitializeAES()
        {
            Encryption.DllAesEncryption_Event += AesEncryption_Event;
            Encryption.DllAesEncryption_GetVersionDataEvent += AesEncryption_GetVersionDataEvent;

            Encryption.InitializeEncryption();
        }

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

            // 장비열개수
            sb.Append(Helper.StringZeroFillDigits4(item.EquipmentColumns.ToString()));
            // 개별NG사용유무
            if (item.IsEachNG == false)
                sb.Append(Helper.StringZeroFillDigits4("0"));
            else
                sb.Append(Helper.StringZeroFillDigits4("1"));
            // 선별기3위치
            sb.Append(Helper.StringZeroFillDigits4(item.Sorter3Location.ToString()));
            // Empty중량설정
            if (item.EmptyWeight == "")
                sb.Append(Helper.StringZeroFillDigits4("0"));
            else
                sb.Append(Helper.StringZeroFillDigits4(item.EmptyWeight));
            // 모터
            sb.Append(Helper.StringZeroFillDigits4(item.MotorSelect.ToString()));
            // 선별부 동작감지 사용 여부
            if (item.IsSorterCheckEnable == false)
                sb.Append(Helper.StringZeroFillDigits4("0"));
            else
                sb.Append(Helper.StringZeroFillDigits4("1"));
            // Dummy
            sb.Append(Helper.StringZeroFillDigits4("0"));
            // 인버터 토크
            sb.Append(Helper.StringZeroFillDigits4(item.InverterTorque.ToString()));
            // 외부출력1 지연시간
            sb.Append(Helper.StringZeroFillDigits4(item.EXT1_DelayTime.ToString()));
            // 외부출력1 동작시간
            sb.Append(Helper.StringZeroFillDigits4(item.EXT1_RunTime.ToString()));
            // 선별기1 위치
            sb.Append(Helper.StringZeroFillDigits4(item.Sorter1Location.ToString()));
            // 선별기2 위치
            sb.Append(Helper.StringZeroFillDigits4(item.Sorter2Location.ToString()));
            // 선별기4 위치
            sb.Append(Helper.StringZeroFillDigits4(item.Sorter4Location.ToString()));
            // Dummy
            sb.Append(Helper.StringZeroFillDigits4("0"));
            sb.Append(Helper.StringZeroFillDigits4("0"));
            sb.Append(Helper.StringZeroFillDigits4("0"));

            this.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._9029_ParameterSystem, sb.ToString());
        }
        private void TransferDynamicParameter(int productNumber)
        {
            string value = "";
            StringBuilder sb = new StringBuilder();
            JudgmentSetItem item = new JudgmentSetItem();

            //this.LoadJudgmentSetFile(ref item, productNumber - 1);
            this.LoadDynamicCorrectionFile(ref item, productNumber - 1);

            if (this.SystemConfig.EquipmentColumns >= 2)
            {
                value = Helper.DoubleToString(item.DynamicCorrection1, 6);
                value = value.Replace(".", "");
                sb.Append(Helper.StringZeroFillDigits7(value));

                value = Helper.DoubleToString(item.DynamicCorrection2, 6);
                value = value.Replace(".", "");
                sb.Append(Helper.StringZeroFillDigits7(value));
            }
            if (this.SystemConfig.EquipmentColumns >= 3)
            {
                value = Helper.DoubleToString(item.DynamicCorrection3, 6);
                value = value.Replace(".", "");
                sb.Append(Helper.StringZeroFillDigits7(value));
            }
            if (this.SystemConfig.EquipmentColumns >= 4)
            {
                value = Helper.DoubleToString(item.DynamicCorrection4, 6);
                value = value.Replace(".", "");
                sb.Append(Helper.StringZeroFillDigits7(value));
            }
            if (this.SystemConfig.EquipmentColumns >= 5)
            {
                value = Helper.DoubleToString(item.DynamicCorrection5, 6);
                value = value.Replace(".", "");
                sb.Append(Helper.StringZeroFillDigits7(value));
            }
            if (this.SystemConfig.EquipmentColumns >= 6)
            {
                value = Helper.DoubleToString(item.DynamicCorrection6, 6);
                value = value.Replace(".", "");
                sb.Append(Helper.StringZeroFillDigits7(value));
            }
            if (this.SystemConfig.EquipmentColumns >= 7)
            {
                value = Helper.DoubleToString(item.DynamicCorrection7, 6);
                value = value.Replace(".", "");
                sb.Append(Helper.StringZeroFillDigits7(value));
            }
            if (this.SystemConfig.EquipmentColumns >= 8)
            {
                value = Helper.DoubleToString(item.DynamicCorrection8, 6);
                value = value.Replace(".", "");
                sb.Append(Helper.StringZeroFillDigits7(value));
            }
            if (this.SystemConfig.EquipmentColumns >= 9)
            {
                value = Helper.DoubleToString(item.DynamicCorrection9, 6);
                value = value.Replace(".", "");
                sb.Append(Helper.StringZeroFillDigits7(value));
            }
            if (this.SystemConfig.EquipmentColumns >= 10)
            {
                value = Helper.DoubleToString(item.DynamicCorrection10, 6);
                value = value.Replace(".", "");
                sb.Append(Helper.StringZeroFillDigits7(value));
            }
            if (this.SystemConfig.EquipmentColumns >= 11)
            {
                value = Helper.DoubleToString(item.DynamicCorrection11, 6);
                value = value.Replace(".", "");
                sb.Append(Helper.StringZeroFillDigits7(value));
            }
            if (this.SystemConfig.EquipmentColumns >= 12)
            {
                value = Helper.DoubleToString(item.DynamicCorrection12, 6);
                value = value.Replace(".", "");
                sb.Append(Helper.StringZeroFillDigits7(value));
            }
            if (this.SystemConfig.EquipmentColumns >= 13)
            {
                value = Helper.DoubleToString(item.DynamicCorrection13, 6);
                value = value.Replace(".", "");
                sb.Append(Helper.StringZeroFillDigits7(value));
            }
            if (this.SystemConfig.EquipmentColumns >= 14)
            {
                value = Helper.DoubleToString(item.DynamicCorrection14, 6);
                value = value.Replace(".", "");
                sb.Append(Helper.StringZeroFillDigits7(value));
            }
            if (this.SystemConfig.EquipmentColumns >= 15)
            {
                value = Helper.DoubleToString(item.DynamicCorrection15, 6);
                value = value.Replace(".", "");
                sb.Append(Helper.StringZeroFillDigits7(value));
            }
            if (this.SystemConfig.EquipmentColumns >= 16)
            {
                value = Helper.DoubleToString(item.DynamicCorrection16, 6);
                value = value.Replace(".", "");
                sb.Append(Helper.StringZeroFillDigits7(value));
            }

            this.TransferDataStream(CommunicationCommand.Write, CommunicationID.SubBoardAll, CommunicationAddress._9034_ParameterDynamicCorrection, sb.ToString());
        }
        private void TransferProductParameter1(int productNumber)
        {
            StringBuilder sb = new StringBuilder();
            ProductItem pItem = new ProductItem();
            JudgmentSetItem jItem = new JudgmentSetItem();

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

            sb.Append(Helper.StringZeroFillDigits7(pItem.UnderRange));
            sb.Append(Helper.StringZeroFillDigits7(pItem.OverRange));
            sb.Append(Helper.StringZeroFillDigits7(pItem.TareRange));
            sb.Append(Helper.StringZeroFillDigits7(jItem.OriginOffset.ToString()));
            sb.Append(Helper.StringZeroFillDigits4(jItem.Filter.ToString()));
            sb.Append(Helper.StringZeroFillDigits4(jItem.JudgmentCount.ToString()));
            sb.Append(Helper.StringZeroFillDigits4(jItem.FeedSpeed.ToString()));
            sb.Append(Helper.StringZeroFillDigits4(jItem.TurnDelayTime.ToString()));
            sb.Append(Helper.StringZeroFillDigits4(jItem.Sorter1RunTime.ToString()));
            sb.Append(Helper.StringZeroFillDigits4(jItem.JudgmentDelayTime.ToString()));
            sb.Append(Helper.StringZeroFillDigits4(jItem.Sorter1DelayTime.ToString()));
            sb.Append(Helper.StringZeroFillDigits4(jItem.Sorter2DelayTime.ToString()));
            sb.Append(Helper.StringZeroFillDigits4(jItem.Sorter2RunTime.ToString()));
            sb.Append(Helper.StringZeroFillDigits4(jItem.ForcedZeroDelayTime.ToString()));
            sb.Append(Helper.StringZeroFillDigits4(jItem.Sorter3DelayTime));
            sb.Append(Helper.StringZeroFillDigits4(jItem.Sorter3RunTime));
            sb.Append(Helper.StringZeroFillDigits4(productNumber.ToString()));
            sb.Append(Helper.StringZeroFillDigits4(jItem.EntryGateDelayTime.ToString()));
            sb.Append(Helper.StringZeroFillDigits4(jItem.EntryGateRunTime.ToString()));
            sb.Append(Helper.StringZeroFillDigits4(jItem.DischargeStopperDelayTime.ToString()));
            sb.Append(Helper.StringZeroFillDigits4(jItem.DischargeStopperRunTime.ToString()));
            sb.Append(Helper.StringZeroFillDigits4(jItem.Sorter4DelayTime));
            sb.Append(Helper.StringZeroFillDigits4(jItem.Sorter4RunTime));

            this.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._9030_ParameterProduct1, sb.ToString());
        }
        private void TransferProductParameter2(int productNumber)
        {
            StringBuilder sb = new StringBuilder();
            ProductItem pItem = new ProductItem();
            JudgmentSetItem jItem = new JudgmentSetItem();

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

            sb.Append(Helper.StringZeroFillDigits7(pItem.UnderRangeLimit));
            sb.Append(Helper.StringZeroFillDigits7(pItem.OverRangeLimit));
            sb.Append(Helper.StringZeroFillDigits7("0"));
            sb.Append(Helper.StringZeroFillDigits7("0"));
            sb.Append(Helper.StringZeroFillDigits7("0"));
            sb.Append(Helper.StringZeroFillDigits7("0"));
            
            if (this.SystemConfig.IsWeightLimitEnable == false)
                sb.Append(Helper.StringZeroFillDigits4("0"));
            else
                sb.Append(Helper.StringZeroFillDigits4("1"));
            sb.Append(Helper.StringZeroFillDigits4(this.SystemConfig.WeightLimitIgnoreCount.ToString()));
            sb.Append(Helper.StringZeroFillDigits4(jItem.Stopper2DelayTime.ToString()));
            sb.Append(Helper.StringZeroFillDigits4(jItem.Stopper2RunTime.ToString()));
            sb.Append(Helper.StringZeroFillDigits4("0"));
            sb.Append(Helper.StringZeroFillDigits4("0"));
            sb.Append(Helper.StringZeroFillDigits4("0"));
            sb.Append(Helper.StringZeroFillDigits4("0"));
            sb.Append(Helper.StringZeroFillDigits4("0"));
            sb.Append(Helper.StringZeroFillDigits4("0"));

            this.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._9040_ParameterProduct2, sb.ToString());
        }
        public void ProductChange(int productNumber)
        {
            this.ProductChangNumber = productNumber;
            this.TransferDynamicParameter(productNumber);

            this.FlagTimeoutCount = 0;
            this.timerTimeout.Enabled = true;
        }

        private void StartThreadMessage1()
        {
            if (this.smartThread.State != SmartThread.ThreadState.Running)
            {
                this.smartThread.Start();
                this.FlagThreadMessage1 = false;
            }
        }

        // Interlock 중량 체크 후 정지
        private void InterlockCheckWeightStop(Collection<WeightData> datas)
        {
            if (this.SystemConfig.IsWeightLimitEnable == true)
            {
                for (int i = 0; i < datas.Count; i++)
                {
                    if (int.Parse(datas[i].WeightString) > int.Parse(this.CurrentProductItem.OverRangeLimit))
                    {
                        this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
                        //this.ChildFormMainDisplay.UpdateDisplayPinchPointAlarm(i + 1);
                        this.timerEmergencyStop.Enabled = true;
                        return;
                    }

                    if (int.Parse(datas[i].WeightString) < int.Parse(this.CurrentProductItem.UnderRangeLimit))
                    {
                        this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
                        //this.ChildFormMainDisplay.UpdateDisplayPinchPointAlarm(i + 1);
                        this.timerEmergencyStop.Enabled = true;
                        return;
                    }
                }
            }
        }

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

            try
            {
                // Port : COM1 or COM2
                // Baudrate : 115200
                SerialMgrComm.serialPortOpen(this.ComPortMainToLCD, 115200, 0, 0, 8);
            }
            catch
            {
            }

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

            #region ADC 통신 로그
            fullPath = this.PathDataLogFolder + 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 ChksumCheck(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 = this.Checksumcalculator(strTemp.Substring(0, strTemp.Length - 2));

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

            return ret;
        }
        private string Checksumcalculator(string strTemp)
        {
            string chkSum = "";
            byte[] temp;
            int value = 0, first = 0, second = 0;
            char char1, char2;

            if (strTemp == null || strTemp.Length == 0)
                chkSum = "cc";
            else
            {
                temp = new UTF8Encoding().GetBytes(strTemp);

                for (int i = 0; i < temp.Length; i++)
                    value += temp[i];

                first = (value & 0x00f0) >> 4;
                if (first > 9)
                    char1 = (char)(first + 0x37);
                else
                    char1 = (char)(first + 0x30);

                second = value & 0x000f;
                if (second > 9)
                    char2 = (char)(second + 0x37);
                else
                    char2 = (char)(second + 0x30);

                chkSum = char1.ToString() + char2.ToString();
            }

            return chkSum;
        }

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

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

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

            sb.Append(chkSum);

            SerialMgrComm.serialPortMessage(this.ComPortMainToLCD, sb.ToString());

            // 통신 확인 로그
            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 = this.Checksumcalculator(sb.ToString());

            sb.Append(chkSum);

            SerialMgrComm.serialPortMessage(this.ComPortMainToLCD, sb.ToString());

            // 통신 확인 로그
            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 int TransferDataRespone(string command, string id, string transactionID, string TransferCount, string respone)
        {
            int ret = 0;
            string chkSum = "cc";
            StringBuilder sb = new StringBuilder();

            sb.Append(command);
            sb.Append(transactionID);
            sb.Append(TransferCount);
            sb.Append(respone);

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

            sb.Append(chkSum);

            SerialMgrComm.serialPortMessage(this.ComPortMainToLCD, sb.ToString());

            // 통신 확인 로그
            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 ReceiveData1(string strTemp)
        {
            int ret = 0;

            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;
            }
        }

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

            if (this.ChksumCheck(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.IsBootingComplete = false;
                    this.TransferDataStream(CommunicationCommand.Read, CommunicationID.MainBoard, CommunicationAddress._6901_ParameterRead6901, "");

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

                    if (this.ChildFormMainDisplay != null)
                        this.ChildFormMainDisplay.UpdateEquipmentStatusDisplay(this.EquipmentStatus);
                    if (this.ChildFormEquipmentTest != null)
                        this.ChildFormEquipmentTest.UpdateEquipmentStatusDisplay(this.EquipmentStatus);
                    if (this.ChildFormSystemSetting != null)
                        this.ChildFormSystemSetting.UpdateEquipmentStatusDisplay(this.EquipmentStatus);
                    break;
                case "CBS":
                    this.EquipmentStatus = DataStore.EquipmentStatus.Start;
                    this.timerEquipmentStatus.Enabled = true;

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

                    // 재전송 관련 카운트 표시
                    // 관리자모드 설정 시 메인화면 표시됨 (장비 테스트화면에서 설정)
                    this.SystemConfig.ComRetryCNT = 0;

                    if (this.ChildFormMainDisplay != null)
                        this.ChildFormMainDisplay.UpdateEquipmentStatusDisplay(this.EquipmentStatus);
                    if (this.ChildFormEquipmentTest != null)
                        this.ChildFormEquipmentTest.UpdateEquipmentStatusDisplay(this.EquipmentStatus);
                    if (this.ChildFormSystemSetting != null)
                        this.ChildFormSystemSetting.UpdateEquipmentStatusDisplay(this.EquipmentStatus);

                    // Part 11
                    if (this.SystemConfig.IsPart11 == true)
                        this.SetTrackingHistoryData(DataStore.E_TrackingOperation.EquipmentStart, "");

                    // 비상정지시 장비 정지상태로 변환
                    if (this.IsServoOrigin == true)
                    {
                        this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
                        this.ChildFormMainDisplay.UpdateDisplayAlarmMessageServoOrigin();
                    }

                    // Ethernet Connection
                    if (this.SystemConfig.IsEthernetEnable == true)
                    {
                        if (this.SystemConfig.EthernetOperationMode == 1)
                            this.EthernetServerStart();
                        else
                            this.EthernetClientConnect();
                    }
                    break;
                case "CBT":
                    this.EquipmentStatus = DataStore.EquipmentStatus.Stop;
                    this.timerEquipmentStatus.Enabled = true;

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

                    // Part 11
                    if (this.SystemConfig.IsPart11 == true)
                        this.SetTrackingHistoryData(DataStore.E_TrackingOperation.EquipmentStop, "");

                    // Respone
                    this.CurrentComRespone.Initialization();

                    if (this.ChildFormMainDisplay != null)
                        this.ChildFormMainDisplay.UpdateEquipmentStatusDisplay(this.EquipmentStatus);
                    if (this.ChildFormEquipmentTest != null)
                        this.ChildFormEquipmentTest.UpdateEquipmentStatusDisplay(this.EquipmentStatus);
                    if (this.ChildFormSystemSetting != null)
                        this.ChildFormSystemSetting.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.ChksumCheck(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 = "", dataID = "", transferCNT = "";

            // 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.ChksumCheck(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);
            dataID = strTemp.Substring(3, 1);
            transferCNT = strTemp.Substring(4, 1);
            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, dataID, transferCNT)) != 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;
                case "ST1":
                    if ((ret = this.ReceiveCommandST1(lane, receiveData)) != 0)
                        return ret;
                    break;
                default:
                    break;
            }

            return ret;
        }

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

            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);
                        }

                        if (this.ChildFormInformation != null)
                            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;
                            // 부팅 후 영점이안맞아 강제로 영점 잡는 명령 보냄..(V1.0.3)
                            this.TransferData(CommunicationCommand.Zero, CommunicationID.SubBoardAll);
                        }

                        // Retry Timer stop
                        this.timerTimeout.Enabled = false;

                        this.SaveSystemConfigurationFile1(this.SystemConfig);

                        this.LoadProductFile(ref this.CurrentProductItem, this.SystemConfig.ProductNumber - 1);
                        this.LoadCounterFile1(ref this.CollectionWeightData, this.SystemConfig.ProductNumber - 1);
                        if(this.SystemConfig.EquipmentColumns == 16)
                            this.LoadCounterFile2(ref this.CollectionWeightData, this.SystemConfig.ProductNumber - 1);
                        this.LoadJudgmentSetFile(ref this.CurrentJudgmentSetItem, this.SystemConfig.ProductNumber - 1);
                        this.LoadDynamicCorrectionFile(ref this.CurrentJudgmentSetItem, this.SystemConfig.ProductNumber - 1);

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

                        if (this.SystemConfig.CurrentForm == DataStore.FormStore.FormMainDisplay)
                        {
                            if (this.ChildFormMainDisplay != null)
                                this.ChildFormMainDisplay.UpdateCurrentProductDisplay(this.EquipmentStatus, this.CurrentProductItem, this.CurrentJudgmentSetItem, this.CollectionWeightData);
                        }
                        else if (this.SystemConfig.CurrentForm == DataStore.FormStore.FormSystemSetting)
                        {
                            if (this.ChildFormSystemSetting != null)
                                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

                        if (this.ChildFormConfiguration != null)
                            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

                        if (this.ChildFormConfiguration != null)
                            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

                        if (this.ChildFormConfiguration != null)
                            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;
                            case 7:
                                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();
                                this.CurrentCalibrationItem.Constant7 = receiveData.Substring(63, 7).Trim();
                                break;
                            case 8:
                                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();
                                this.CurrentCalibrationItem.Constant7 = receiveData.Substring(63, 7).Trim();
                                this.CurrentCalibrationItem.Constant8 = receiveData.Substring(70, 7).Trim();
                                break;
                            case 10:
                                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();
                                this.CurrentCalibrationItem.Constant7 = receiveData.Substring(63, 7).Trim();
                                this.CurrentCalibrationItem.Constant8 = receiveData.Substring(70, 7).Trim();
                                this.CurrentCalibrationItem.Constant9 = receiveData.Substring(77, 7).Trim();
                                this.CurrentCalibrationItem.Constant10 = receiveData.Substring(84, 7).Trim();
                                break;
                            case 12:
                                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();
                                this.CurrentCalibrationItem.Constant7 = receiveData.Substring(63, 7).Trim();
                                this.CurrentCalibrationItem.Constant8 = receiveData.Substring(70, 7).Trim();
                                this.CurrentCalibrationItem.Constant9 = receiveData.Substring(77, 7).Trim();
                                this.CurrentCalibrationItem.Constant10 = receiveData.Substring(84, 7).Trim();
                                this.CurrentCalibrationItem.Constant11 = receiveData.Substring(91, 7).Trim();
                                this.CurrentCalibrationItem.Constant12 = receiveData.Substring(98, 7).Trim();
                                break;
                            case 15:
                                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();
                                this.CurrentCalibrationItem.Constant7 = receiveData.Substring(63, 7).Trim();
                                this.CurrentCalibrationItem.Constant8 = receiveData.Substring(70, 7).Trim();
                                this.CurrentCalibrationItem.Constant9 = receiveData.Substring(77, 7).Trim();
                                this.CurrentCalibrationItem.Constant10 = receiveData.Substring(84, 7).Trim();
                                this.CurrentCalibrationItem.Constant11 = receiveData.Substring(91, 7).Trim();
                                this.CurrentCalibrationItem.Constant12 = receiveData.Substring(98, 7).Trim();
                                this.CurrentCalibrationItem.Constant13 = receiveData.Substring(105, 7).Trim();
                                this.CurrentCalibrationItem.Constant14 = receiveData.Substring(112, 7).Trim();
                                this.CurrentCalibrationItem.Constant15 = receiveData.Substring(119, 7).Trim();
                                break;
                            case 16:
                                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();
                                this.CurrentCalibrationItem.Constant7 = receiveData.Substring(63, 7).Trim();
                                this.CurrentCalibrationItem.Constant8 = receiveData.Substring(70, 7).Trim();
                                this.CurrentCalibrationItem.Constant9 = receiveData.Substring(77, 7).Trim();
                                this.CurrentCalibrationItem.Constant10 = receiveData.Substring(84, 7).Trim();
                                this.CurrentCalibrationItem.Constant11 = receiveData.Substring(91, 7).Trim();
                                this.CurrentCalibrationItem.Constant12 = receiveData.Substring(98, 7).Trim();
                                this.CurrentCalibrationItem.Constant13 = receiveData.Substring(105, 7).Trim();
                                this.CurrentCalibrationItem.Constant14 = receiveData.Substring(112, 7).Trim();
                                this.CurrentCalibrationItem.Constant15 = receiveData.Substring(119, 7).Trim();
                                this.CurrentCalibrationItem.Constant16 = receiveData.Substring(126, 7).Trim();
                                break;
                            default:
                                break;
                        }
                        #endregion

                        if (this.SystemConfig.CurrentForm == DataStore.FormStore.FormCalibration)
                        {
                            if (this.ChildFormCalibration != null)
                                this.ChildFormCalibration.UpdateCalibrationItemDisplay(this.EquipmentStatus, this.CurrentCalibrationItem);
                        }
                        else
                        {
                            if (this.ChildFormEquipmentTest != null)
                                this.ChildFormEquipmentTest.UpdateCalibrationItemDisplay(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

                        if (this.ChildFormConfiguration != null)
                            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

                        if (this.ChildFormConfiguration != null)
                            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

                        if (this.ChildFormConfiguration != null)
                            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
                        if (this.SystemConfig.CurrentForm == DataStore.FormStore.FormConfiguration)
                        {
                            if (this.ChildFormConfiguration != null)
                                this.ChildFormConfiguration.UpdateZeroParameterDisplay(this.EquipmentStatus, this.CurrentZeroParameterItem);
                        }
                        else
                        {
                            if (this.ChildFormEquipmentTest != null)
                                this.ChildFormEquipmentTest.UpdateZeroParameterDisplay(this.EquipmentStatus, this.CurrentZeroParameterItem);

                            this.TransferDataStream(CommunicationCommand.Read, CommunicationID.MainBoard, CommunicationAddress._6901_ParameterRead6901, "");
                        }
                        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

                        if (this.ChildFormConfiguration != null)
                            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
                        if (this.IsBootingComplete == false)
                        {
                            this.TrasferSystemParameter(this.SystemConfig);
                        }
                        else
                        {
                            if (this.SystemConfig.CurrentForm == DataStore.FormStore.FormConfiguration)
                            {
                                if (this.ChildFormConfiguration != null)
                                    this.ChildFormConfiguration.UpdateOptionParameterDisplay(this.EquipmentStatus, this.CurrentOptionParameterItem);
                            }
                            else
                            {
                                if (this.ChildFormEquipmentTest != null)
                                    this.ChildFormEquipmentTest.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, index = 0;
            byte[] beforeData;
            string ack = "", data = "";
            DataStore.E_ResponseData response = DataStore.E_ResponseData.NAK;

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

                switch (address)
                {
                    case "9029":
                        if (response == DataStore.E_ResponseData.ACK)
                            this.ProductChange(this.SystemConfig.ProductNumber);
                        break;
                    case "9030":
                        if (response == DataStore.E_ResponseData.ACK)
                            this.TransferProductParameter2(this.ProductChangNumber);
                        break;
                    case "9034":
                        if (response == DataStore.E_ResponseData.ACK)
                            this.TransferProductParameter1(this.ProductChangNumber);
                        break;
                    case "9040":
                        if(response == DataStore.E_ResponseData.ACK)
                            this.TransferDataStream(CommunicationCommand.Read, CommunicationID.MainBoard, CommunicationAddress._2001_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.E_ResponseData response = DataStore.E_ResponseData.NAK;

            try
            {
                if (receiveData == "0000")
                    response = DataStore.E_ResponseData.NAK;
                else
                    response = DataStore.E_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.FormStore.FormMainDisplay)
                        {
                            if (this.SystemConfig.IsWeightViewForward == true)
                            {
                                for (int i = 0; i < this.SystemConfig.EquipmentColumns; i++)
                                {
                                    if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                    {
                                        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
                                    {
                                        this.CollectionWeightData[i].Status = Helper.StringToWeightStatus(receiveData.Substring(i * 12, 2));
                                    }
                                }
                            }
                            else
                            {
                                for (int i = 1; i <= this.SystemConfig.EquipmentColumns; i++)
                                {
                                    if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                    {
                                        this.CollectionWeightData[this.SystemConfig.EquipmentColumns - i].Status = Helper.StringToWeightStatus(receiveData.Substring((i-1) * 12, 2));
                                        this.CollectionWeightData[this.SystemConfig.EquipmentColumns - i].Weight = Helper.StringToWeight(receiveData.Substring((i - 1) * 12 + 2, 5), this.SystemConfig.DecimalPlaces);
                                        this.CollectionWeightData[this.SystemConfig.EquipmentColumns - i].ADCValue = receiveData.Substring((i - 1) * 12 + 7, 5);
                                    }
                                    else
                                    {
                                        this.CollectionWeightData[this.SystemConfig.EquipmentColumns - i].Status = Helper.StringToWeightStatus(receiveData.Substring((i - 1) * 12, 2));
                                    }
                                }
                            }
                        }
                        else if (this.SystemConfig.CurrentForm == DataStore.FormStore.FormEquipmentTest)
                        {
                            if (this.SystemConfig.IsWeightViewForward == true)
                            {
                                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);
                                }
                            }
                            else
                            {
                                for (int i = 1; i <= this.SystemConfig.EquipmentColumns; i++)
                                {
                                    this.CollectionWeightDataTest[this.SystemConfig.EquipmentColumns - i].Status = Helper.StringToWeightStatus(receiveData.Substring((i - 1) * 12, 2));
                                    this.CollectionWeightDataTest[this.SystemConfig.EquipmentColumns - i].Weight = Helper.StringToWeight(receiveData.Substring((i - 1) * 12 + 2, 5), this.SystemConfig.DecimalPlaces);
                                    this.CollectionWeightDataTest[this.SystemConfig.EquipmentColumns - i].ADCValue = receiveData.Substring((i - 1) * 12 + 7, 5);
                                }
                            }
                        }
                        #endregion
                        if (this.SystemConfig.CurrentForm == DataStore.FormStore.FormMainDisplay)
                        {
                            if (this.ChildFormMainDisplay != null)
                                this.ChildFormMainDisplay.UpdateStopWeightDisplay(this.EquipmentStatus, this.CollectionWeightData);
                        }
                        else if (this.SystemConfig.CurrentForm == DataStore.FormStore.FormEquipmentTest)
                        {
                            if (this.ChildFormEquipmentTest != null)
                                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, string transactionID, string transferCNT)
        {
            int ret = 0;
            string data;
            string etherStringData = "";
            StringBuilder weightLimit = new StringBuilder();
            StringBuilder sb = new StringBuilder();

            try
            {
                switch (lane)
                {
                    case "Z":
                        #region Value Assign
                        // Respone
                        //this.TransferDataRespone(CommunicationCommand.StartDataCMD, lane, transactionID, transferCNT, CommunicationAddress.ACK);
                        //Application.DoEvents();

                        if (this.CurrentComRespone.TransactionID != transactionID)
                        {
                            this.CurrentComRespone.TransactionID = transactionID;
                            this.CurrentComRespone.TransferCount = transferCNT;

                            if (this.SystemConfig.CurrentForm == DataStore.FormStore.FormEquipmentTest)
                            {
                                #region FormEquipmentTest
                                if (this.SystemConfig.IsWeightViewForward == true)
                                {
                                    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].ADCValue = receiveData.Substring(i * 12 + 7, 5);

                                        // SamplingData Check
                                        data = receiveData.Substring(i * 12, 2);
                                        if (data == "sU" || data == "sO" || data == "sP" || data == "sT")
                                            this.CollectionWeightDataTest[i].IsSamplingData = true;
                                        else
                                            this.CollectionWeightDataTest[i].IsSamplingData = false;
                                    }
                                }
                                else
                                {
                                    for (int i = 1; i <= this.SystemConfig.EquipmentColumns; i++)
                                    {
                                        this.CollectionWeightDataTest[this.CollectionWeightDataTest.Count - i].JudgmentStatus =
                                            Helper.StringToJudgmentStatus(receiveData.Substring((i - 1) * 12, 2));
                                        this.CollectionWeightDataTest[this.CollectionWeightDataTest.Count - i].Weight =
                                            Helper.StringToWeight(receiveData.Substring((i - 1) * 12 + 2, 5), this.SystemConfig.DecimalPlaces);
                                        this.CollectionWeightDataTest[this.CollectionWeightDataTest.Count - i].ADCValue = receiveData.Substring((i - 1) * 12 + 7, 5);

                                        // SamplingData Check
                                        data = receiveData.Substring((i - 1) * 12, 2);
                                        if (data == "sU" || data == "sO" || data == "sP" || data == "sT")
                                            this.CollectionWeightDataTest[this.CollectionWeightDataTest.Count - i].IsSamplingData = true;
                                        else
                                            this.CollectionWeightDataTest[this.CollectionWeightDataTest.Count - i].IsSamplingData = false;
                                    }
                                }
                                #endregion
                            }
                            else
                            {
                                #region FormMainDisplay
                                if (this.SystemConfig.IsWeightViewForward == true)
                                {
                                    for (int i = 0; i < this.SystemConfig.EquipmentColumns; i++)
                                    {
                                        this.CollectionWeightData[i].JudgmentStatus = Helper.StringToJudgmentStatus(receiveData.Substring(i * 7, 2));
                                        this.CollectionWeightData[i].Weight = Helper.StringToWeight(receiveData.Substring(i * 7 + 2, 5), this.SystemConfig.DecimalPlaces);
                                        this.CollectionWeightData[i].WeightString = receiveData.Substring(i * 7 + 2, 5).Trim();
                                        //this.CollectionWeightData[i].ADCValue = receiveData.Substring(i * 12 + 7, 5);

                                        // SamplingData Check
                                        data = receiveData.Substring(i * 7, 2);
                                        if (data == "sU" || data == "sO" || data == "sP" || data == "sT")
                                            this.CollectionWeightData[i].IsSamplingData = true;
                                        else
                                            this.CollectionWeightData[i].IsSamplingData = false;

                                        // Weight Limit Check
                                        if (data == "sa" || data == "sj")
                                        {
                                            if (weightLimit.ToString().Length == 0)
                                                weightLimit.Append(string.Format("#{0}", i + 1));
                                            else
                                            {
                                                weightLimit.Append(", ");
                                                weightLimit.Append(string.Format("#{0}", i + 1));
                                            }
                                        }
                                        if (weightLimit.ToString().Length != 0)
                                            this.ChildFormMainDisplay.UpdateDisplayProductJamAlarm(weightLimit.ToString());
                                    }
                                }
                                else
                                {
                                    for (int i = 1; i <= this.SystemConfig.EquipmentColumns; i++)
                                    {
                                        this.CollectionWeightData[this.CollectionWeightData.Count - i].JudgmentStatus =
                                            Helper.StringToJudgmentStatus(receiveData.Substring((i - 1) * 7, 2));
                                        this.CollectionWeightData[this.CollectionWeightData.Count - i].Weight =
                                            Helper.StringToWeight(receiveData.Substring((i - 1) * 7 + 2, 5), this.SystemConfig.DecimalPlaces);
                                        this.CollectionWeightData[this.CollectionWeightData.Count - i].WeightString = receiveData.Substring((i - 1) * 7 + 2, 5).Trim();
                                        //this.CollectionWeightData[this.CollectionWeightData.Count - i].ADCValue = receiveData.Substring((i - 1) * 7 + 7, 5);

                                        // SamplingData Check
                                        data = receiveData.Substring((i - 1) * 7, 2);
                                        if (data == "sU" || data == "sO" || data == "sP" || data == "sT")
                                            this.CollectionWeightData[this.CollectionWeightData.Count - i].IsSamplingData = true;
                                        else
                                            this.CollectionWeightData[this.CollectionWeightData.Count - i].IsSamplingData = false;

                                        // Weight Limit Check
                                        if (data == "sa" || data == "sj")
                                        {
                                            if (weightLimit.ToString().Length == 0)
                                                weightLimit.Append(string.Format("#{0}", (this.CollectionWeightData.Count - i) + 1));
                                            else
                                            {
                                                weightLimit.Append(", ");
                                                weightLimit.Append(string.Format("#{0}", (this.CollectionWeightData.Count - i) + 1));
                                            }
                                        }
                                        if (weightLimit.ToString().Length != 0)
                                            this.ChildFormMainDisplay.UpdateDisplayProductJamAlarm(weightLimit.ToString());
                                    }
                                }

                                // 생산속도
                                try
                                {
                                    this.CollectionWeightData[0].ProductionSpeed = int.Parse(receiveData.Substring(receiveData.Length - 4, 4).Trim());
                                }
                                catch
                                {
                                    this.CollectionWeightData[0].ProductionSpeed = 0;
                                }
                                #endregion
                            }
                        #endregion

                            if (this.SystemConfig.CurrentForm == DataStore.FormStore.FormMainDisplay)
                            {
                                #region 이더넷
                                if (this.SystemConfig.IsEthernetEnable == true)
                                {
                                    if (this.SystemConfig.EthernetMode == 1)
                                    {
                                        etherStringData = this.Protocol_STD1(this.SystemConfig, this.CollectionWeightData);
                                        this.SendEthernetData(etherStringData);
                                    }
                                    else if (this.SystemConfig.EthernetMode == 2)
                                    {
                                        etherStringData = this.Protocol_STD2(this.SystemConfig, this.CollectionWeightData, this.CurrentProductItem);
                                        this.SendEthernetData(etherStringData);
                                    }
                                    else if (this.SystemConfig.EthernetMode == 3)
                                    {
                                        etherStringData = this.Protocol_STD3(this.SystemConfig, this.CollectionWeightData, this.CurrentProductItem);
                                        this.SendEthernetData(etherStringData);
                                    }
                                }
                                #endregion

                                #region Serial 3
                                if (this.SystemConfig.Serial3Mode == 1)         // OPT1 - 중량 데이터 피드백
                                {
                                    // V1.10.0 아남자동기 수정
                                    // FeedbackEmptyTransfer - 제품 안들어 올때 데이터 전송 여부
                                    // 중량이 0.3g 이하이면 전송 안함 (제품이 안들어 올때) <- 전체열이 0.3g이하일때 전송안함
                                    // V3.1.0 HRG 수정 (V1.10.0 기능 삭제)
                                    // Empty중량설정 추가 - 판정이 Empty이면 데이터 전송 안함
                                    // V3.3.2
                                    // Empty판정이 1개라도 있으면 데이터 전송 안함
                                    // V8.0.0
                                    // Empty 중량설정 이하면 전송 안하도록 수정(바이패스 시 GRD 'P'로 전송되어, 0g 이여도 전송됨
                                    int cnt = 0;
                                    foreach (WeightData weight in this.CollectionWeightData)
                                    {
                                        //if (weight.JudgmentStatus == DataStore.JudgmentStatus.Empty)
                                        //    cnt++;

                                        if (int.Parse(weight.WeightString) < int.Parse(this.SystemConfig.EmptyWeight))
                                            cnt++;
                                    }

                                    if (cnt == 0)
                                        this.SerialCH3STD1(this.CollectionWeightData);
                                }
                                else if (this.SystemConfig.Serial3Mode == 2)
                                    this.SerialCH3STD2(this.CollectionWeightData);
                                else if (this.SystemConfig.Serial3Mode == 3)
                                    this.SerialCH3STD3(this.CollectionWeightData);
                                #endregion

                                #region FormMainDisplay
                                this.TrackingInspectionData(this.CollectionWeightData);

                                if (this.ChildFormMainDisplay != null)
                                {
                                    this.ChildFormMainDisplay.UpdateStartWeightDisplay(this.EquipmentStatus, this.CollectionWeightData);
                                }
                                #endregion
                            }
                            else if (this.SystemConfig.CurrentForm == DataStore.FormStore.FormEquipmentTest)
                            {
                                #region FormEquipmentTest
                                if (this.ChildFormEquipmentTest != null)
                                    this.ChildFormEquipmentTest.UpdateStartWeightDisplay(this.EquipmentStatus, this.CollectionWeightDataTest);
                                #endregion
                            }
                            else if (this.SystemConfig.CurrentForm == DataStore.FormStore.FormSystemSetting)
                            {
                                #region FormSystemSetting
                                if (this.ChildFormSystemSetting != null)
                                    this.ChildFormSystemSetting.UpdateStartWeightDisplay(this.EquipmentStatus, this.CollectionWeightData);
                                #endregion
                            }

                            // SamplingData 화면 표시 후 초기화
                            //for (int i = 0; i < this.CollectionWeightData.Count; i++)
                            //{
                            //    this.CollectionWeightData[i].IsSamplingData = false;
                            //    this.CollectionWeightDataTest[i].IsSamplingData = false;
                            //}
                            // 샘플링 연속 기능 V4.2.0
                            if (this.SystemConfig.IsSamplingOnce == false)
                            {
                                if (this.SystemConfig.IsSamplingRun == true && this.timerSampling.Enabled == false)
                                {
                                    if (this.SystemConfig.SamplingCurrentCount >= this.SystemConfig.SamplingCount)
                                    {
                                        this.SystemConfig.SamplingCurrentCount = 0;
                                        this.timerSampling.Enabled = true;
                                    }
                                    else
                                    {
                                        this.TransferData(CommunicationCommand.SamplingSignal, CommunicationID.MainBoard);
                                        this.SystemConfig.SamplingCurrentCount++;
                                    }
                                }
                            }

                            // Leak Sampling 연속 기능 V8.4.0
                            if (this.SystemConfig.IsLeakSamplingOnce == false)
                            {
                                if (this.SystemConfig.IsLeakSamplingRun == true && this.timerLeakSampling.Enabled == false)
                                {
                                    this.TransferData(CommunicationCommand.LeakSamplingSignal, CommunicationID.MainBoard);
                                    this.timerLeakSampling.Enabled = true;
                                }
                            }
                        }
                        else
                        { 
                            // 같은 데이터를 전송받으면 재전송 카운트 증가
                            this.SystemConfig.ComRetryCNT++;
                            this.SaveSystemConfigurationFile2(this.SystemConfig);
                        }

                        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

                    if (this.ChildFormCalibration != null)
                        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

                    if (this.ChildFormSystemSetting != null)
                        this.ChildFormSystemSetting.UpdateStopWeightDisplay(this.EquipmentStatus, this.CollectionWeightData);
                    break;
                default:
                    break;
            }

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

            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);
                    time1 = receiveData.Substring(12, 4);

                    for (int i = 0; i < this.CollectionGraphData.Count; i++)
                    {
                        this.CollectionGraphData[i] = int.Parse(receiveData.Substring(temp, 5));
                        temp += 5;
                    }
                    #endregion

                    if (this.ChildFormSystemSetting != null)
                        this.ChildFormSystemSetting.UpdateGraphDataDisplay(this.EquipmentStatus, this.CollectionWeightData[0], this.CollectionGraphData, time1);
                    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);
                    time1 = receiveData.Substring(12, 4);

                    for (int i = 0; i < this.CollectionGraphData.Count; i++)
                    {
                        this.CollectionGraphData[i] = int.Parse(receiveData.Substring(temp, 5));
                        temp += 5;
                    }
                    #endregion

                    if (this.ChildFormSystemSetting != null)
                        this.ChildFormSystemSetting.UpdateGraphDataDisplay(this.EquipmentStatus, this.CollectionWeightData[1], this.CollectionGraphData, time1);
                    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);
                    time1 = receiveData.Substring(12, 4);

                    for (int i = 0; i < this.CollectionGraphData.Count; i++)
                    {
                        this.CollectionGraphData[i] = int.Parse(receiveData.Substring(temp, 5));
                        temp += 5;
                    }
                    #endregion

                    if (this.ChildFormSystemSetting != null)
                        this.ChildFormSystemSetting.UpdateGraphDataDisplay(this.EquipmentStatus, this.CollectionWeightData[2], this.CollectionGraphData, time1);
                    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);
                    time1 = receiveData.Substring(12, 4);

                    for (int i = 0; i < this.CollectionGraphData.Count; i++)
                    {
                        this.CollectionGraphData[i] = int.Parse(receiveData.Substring(temp, 5));
                        temp += 5;
                    }
                    #endregion

                    if (this.ChildFormSystemSetting != null)
                        this.ChildFormSystemSetting.UpdateGraphDataDisplay(this.EquipmentStatus, this.CollectionWeightData[3], this.CollectionGraphData, time1);
                    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);
                    time1 = receiveData.Substring(12, 4);

                    for (int i = 0; i < this.CollectionGraphData.Count; i++)
                    {
                        this.CollectionGraphData[i] = int.Parse(receiveData.Substring(temp, 5));
                        temp += 5;
                    }
                    #endregion

                    if (this.ChildFormSystemSetting != null)
                        this.ChildFormSystemSetting.UpdateGraphDataDisplay(this.EquipmentStatus, this.CollectionWeightData[4], this.CollectionGraphData, time1);
                    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);
                    time1 = receiveData.Substring(12, 4);

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

                    for (int i = 0; i < this.CollectionGraphData.Count; i++)
                    {
                        this.CollectionGraphData[i] = int.Parse(receiveData.Substring(temp, 5));
                        temp += 5;
                    }
                    #endregion

                    if (this.ChildFormSystemSetting != null)
                        this.ChildFormSystemSetting.UpdateGraphDataDisplay(this.EquipmentStatus, this.CollectionWeightData[6], this.CollectionGraphData, time1);
                    break;
                case "H":
                    #region Value Assign
                    this.CollectionWeightData[7].Weight = Helper.StringToWeight(receiveData.Substring(2, 5), this.SystemConfig.DecimalPlaces);
                    this.CollectionWeightData[7].ADCValue = receiveData.Substring(7, 5);
                    time1 = receiveData.Substring(12, 4);

                    for (int i = 0; i < this.CollectionGraphData.Count; i++)
                    {
                        this.CollectionGraphData[i] = int.Parse(receiveData.Substring(temp, 5));
                        temp += 5;
                    }
                    #endregion

                    if (this.ChildFormSystemSetting != null)
                        this.ChildFormSystemSetting.UpdateGraphDataDisplay(this.EquipmentStatus, this.CollectionWeightData[7], this.CollectionGraphData, time1);
                    break;
                case "I":
                    #region Value Assign
                    this.CollectionWeightData[8].Weight = Helper.StringToWeight(receiveData.Substring(2, 5), this.SystemConfig.DecimalPlaces);
                    this.CollectionWeightData[8].ADCValue = receiveData.Substring(7, 5);
                    time1 = receiveData.Substring(12, 4);

                    for (int i = 0; i < this.CollectionGraphData.Count; i++)
                    {
                        this.CollectionGraphData[i] = int.Parse(receiveData.Substring(temp, 5));
                        temp += 5;
                    }
                    #endregion

                    if (this.ChildFormSystemSetting != null)
                        this.ChildFormSystemSetting.UpdateGraphDataDisplay(this.EquipmentStatus, this.CollectionWeightData[8], this.CollectionGraphData, time1);
                    break;
                case "J":
                    #region Value Assign
                    this.CollectionWeightData[9].Weight = Helper.StringToWeight(receiveData.Substring(2, 5), this.SystemConfig.DecimalPlaces);
                    this.CollectionWeightData[9].ADCValue = receiveData.Substring(7, 5);
                    time1 = receiveData.Substring(12, 4);

                    for (int i = 0; i < this.CollectionGraphData.Count; i++)
                    {
                        this.CollectionGraphData[i] = int.Parse(receiveData.Substring(temp, 5));
                        temp += 5;
                    }
                    #endregion

                    if (this.ChildFormSystemSetting != null)
                        this.ChildFormSystemSetting.UpdateGraphDataDisplay(this.EquipmentStatus, this.CollectionWeightData[9], this.CollectionGraphData, time1);
                    break;
                case "K":
                    #region Value Assign
                    this.CollectionWeightData[10].Weight = Helper.StringToWeight(receiveData.Substring(2, 5), this.SystemConfig.DecimalPlaces);
                    this.CollectionWeightData[10].ADCValue = receiveData.Substring(7, 5);
                    time1 = receiveData.Substring(12, 4);

                    for (int i = 0; i < this.CollectionGraphData.Count; i++)
                    {
                        this.CollectionGraphData[i] = int.Parse(receiveData.Substring(temp, 5));
                        temp += 5;
                    }
                    #endregion

                    if (this.ChildFormSystemSetting != null)
                        this.ChildFormSystemSetting.UpdateGraphDataDisplay(this.EquipmentStatus, this.CollectionWeightData[10], this.CollectionGraphData, time1);
                    break;
                case "L":
                    #region Value Assign
                    this.CollectionWeightData[11].Weight = Helper.StringToWeight(receiveData.Substring(2, 5), this.SystemConfig.DecimalPlaces);
                    this.CollectionWeightData[11].ADCValue = receiveData.Substring(7, 5);
                    time1 = receiveData.Substring(12, 4);

                    for (int i = 0; i < this.CollectionGraphData.Count; i++)
                    {
                        this.CollectionGraphData[i] = int.Parse(receiveData.Substring(temp, 5));
                        temp += 5;
                    }
                    #endregion

                    if (this.ChildFormSystemSetting != null)
                        this.ChildFormSystemSetting.UpdateGraphDataDisplay(this.EquipmentStatus, this.CollectionWeightData[11], this.CollectionGraphData, time1);
                    break;
                case "M":
                    #region Value Assign
                    this.CollectionWeightData[12].Weight = Helper.StringToWeight(receiveData.Substring(2, 5), this.SystemConfig.DecimalPlaces);
                    this.CollectionWeightData[12].ADCValue = receiveData.Substring(7, 5);
                    time1 = receiveData.Substring(12, 4);

                    for (int i = 0; i < this.CollectionGraphData.Count; i++)
                    {
                        this.CollectionGraphData[i] = int.Parse(receiveData.Substring(temp, 5));
                        temp += 5;
                    }
                    #endregion

                    if (this.ChildFormSystemSetting != null)
                        this.ChildFormSystemSetting.UpdateGraphDataDisplay(this.EquipmentStatus, this.CollectionWeightData[12], this.CollectionGraphData, time1);
                    break;
                case "N":
                    #region Value Assign
                    this.CollectionWeightData[13].Weight = Helper.StringToWeight(receiveData.Substring(2, 5), this.SystemConfig.DecimalPlaces);
                    this.CollectionWeightData[13].ADCValue = receiveData.Substring(7, 5);
                    time1 = receiveData.Substring(12, 4);

                    for (int i = 0; i < this.CollectionGraphData.Count; i++)
                    {
                        this.CollectionGraphData[i] = int.Parse(receiveData.Substring(temp, 5));
                        temp += 5;
                    }
                    #endregion

                    if (this.ChildFormSystemSetting != null)
                        this.ChildFormSystemSetting.UpdateGraphDataDisplay(this.EquipmentStatus, this.CollectionWeightData[13], this.CollectionGraphData, time1);
                    break;
                case "O":
                    #region Value Assign
                    this.CollectionWeightData[14].Weight = Helper.StringToWeight(receiveData.Substring(2, 5), this.SystemConfig.DecimalPlaces);
                    this.CollectionWeightData[14].ADCValue = receiveData.Substring(7, 5);
                    time1 = receiveData.Substring(12, 4);

                    for (int i = 0; i < this.CollectionGraphData.Count; i++)
                    {
                        this.CollectionGraphData[i] = int.Parse(receiveData.Substring(temp, 5));
                        temp += 5;
                    }
                    #endregion

                    if (this.ChildFormSystemSetting != null)
                        this.ChildFormSystemSetting.UpdateGraphDataDisplay(this.EquipmentStatus, this.CollectionWeightData[14], this.CollectionGraphData, time1);
                    break;
                case "P":
                    #region Value Assign
                    this.CollectionWeightData[15].Weight = Helper.StringToWeight(receiveData.Substring(2, 5), this.SystemConfig.DecimalPlaces);
                    this.CollectionWeightData[15].ADCValue = receiveData.Substring(7, 5);
                    time1 = receiveData.Substring(12, 4);

                    for (int i = 0; i < this.CollectionGraphData.Count; i++)
                    {
                        this.CollectionGraphData[i] = int.Parse(receiveData.Substring(temp, 5));
                        temp += 5;
                    }
                    #endregion

                    if (this.ChildFormSystemSetting != null)
                        this.ChildFormSystemSetting.UpdateGraphDataDisplay(this.EquipmentStatus, this.CollectionWeightData[15], this.CollectionGraphData, time1);
                    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.FormStore.FormIOTest)
                    {
                        if (this.ChildFormIOTest != null)
                            this.ChildFormIOTest.UpdateInputRead(this.CollectionIOTest_InputData);
                    }
                    else if (this.SystemConfig.CurrentForm == DataStore.FormStore.FormEquipmentTest)
                    {
                        if (this.ChildFormEquipmentTest != null)
                            this.ChildFormEquipmentTest.UpdateInputRead(this.CollectionIOTest_InputData);
                    }
                    break;
                default:
                    break;
            }

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

            switch (lane)
            {
                case "0":
                    #region Value Assign
                    for (int i = 0; i < 16; i++)
                        this.CollectionIOTest_InputData1[i] = receiveData.Substring(i, 1);
                    #endregion
                    if (this.SystemConfig.CurrentForm == DataStore.FormStore.FormIOTest)
                    {
                        if (this.ChildFormIOTest != null)
                            this.ChildFormIOTest.UpdateInputRead1(this.CollectionIOTest_InputData1);
                    }
                    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
                    // Servo Origin (Emergency Stop)
                    if (this.CurrentAlarmList.IsEmergencyStop == true)
                    {
                        if (this.EquipmentStatus1 == DataStore.EquipmentStatus.Start)
                        {
                            if (this.IsServoOrigin == false)
                                this.IsServoOrigin = true;
                        }
                    }

                    // Display
                    if (this.ChildFormMainDisplay != null)
                    {
                        this.ChildFormMainDisplay.UpdateDisplayAlarmView(this.CurrentAlarmList);
                        this.ChildFormMainDisplay.UpdateDisplayAlarmMessageServoOrigin();
                    }

                    if (this.ChildFormMotorSetting != null)
                        this.ChildFormMotorSetting.UpdateDisplayAlarmView(this.CurrentAlarmList);
                    break;
                default:
                    break;
            }

            return ret;
        }
        #endregion

        #region SystemConfiguration File1
        private void CreateSystemConfigurationFile1()
        {
            StructSystemConfigurationItem1 structItem;

            this.SystemConfig.Initialization();

            structItem.IsDataBackup = this.SystemConfig.IsDataBackup;
            structItem.IsEachNG = this.SystemConfig.IsEachNG;
            structItem.IsLogin = this.SystemConfig.IsLogin;
            structItem.IsWeightViewForward = this.SystemConfig.IsWeightViewForward;
            structItem.IsOptDataStatistics = this.SystemConfig.IsOptDataStatistics;
            structItem.IsSorterCheckEnable = this.SystemConfig.IsSorterCheckEnable;
            structItem.IsDeleteAfterBackup = this.SystemConfig.IsDeleteAfterBackup;
            structItem.DummyBool7 = false;

            structItem.DecimalPlaces = this.SystemConfig.DecimalPlaces;
            structItem.EquipmentColumns = this.SystemConfig.EquipmentColumns;
            structItem.ProductNumber = this.SystemConfig.ProductNumber;
            structItem.Serial3BaudRate = this.SystemConfig.Serial3BaudRate;
            structItem.Serial3Mode = this.SystemConfig.Serial3Mode;
            structItem.UsbID = this.SystemConfig.UsbID;
            structItem.WeightLimitIgnoreCount = this.SystemConfig.WeightLimitIgnoreCount;
            structItem.MotorSelect = this.SystemConfig.MotorSelect;

            structItem.Unit = this.SystemConfig.Unit;
            structItem.SerialNumber = this.SystemConfig.SerialNumber;

            structItem.Language = this.SystemConfig.Language;

            structItem.DummyBool1 = false;
            structItem.DummyBool2 = false;
            structItem.DummyBool3 = false;
            structItem.DummyBool4 = false;
            structItem.DummyBool8 = false;
            structItem.Sorter1Location = this.SystemConfig.Sorter1Location;
            structItem.Sorter2Location = this.SystemConfig.Sorter2Location;
            structItem.EXT1_DelayTime = this.SystemConfig.EXT1_DelayTime;
            structItem.EXT1_RunTime = this.SystemConfig.EXT1_RunTime;
            structItem.InverterTorque = this.SystemConfig.InverterTorque;
            structItem.EmptyWeight = this.SystemConfig.EmptyWeight;
            structItem.ComPort = this.SystemConfig.ComPort;
            structItem.DummyString3 = "";
            structItem.DummyString4 = "";
            structItem.DummyString5 = "";

            this.smartFileIO.WriteStructure(structItem, 0);
        }
        public void SaveSystemConfigurationFile1(SystemConfigurationItem item)
        {
            string fullFilePath = "";
            bool fileCheck = false;
            StructSystemConfigurationItem1 structItem;

            fullFilePath = this.PathSystemFileFolder + "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.CreateSystemConfigurationFile1();
            }

            structItem.IsDataBackup = item.IsDataBackup;
            structItem.IsEachNG = item.IsEachNG;
            structItem.IsLogin = item.IsLogin;
            structItem.IsWeightViewForward = item.IsWeightViewForward;
            structItem.IsOptDataStatistics = item.IsOptDataStatistics;
            structItem.IsSorterCheckEnable = item.IsSorterCheckEnable;
            structItem.IsDeleteAfterBackup = item.IsDeleteAfterBackup;
            structItem.DummyBool7 = false;

            structItem.DecimalPlaces = item.DecimalPlaces;
            structItem.EquipmentColumns = item.EquipmentColumns;
            structItem.ProductNumber = item.ProductNumber;
            structItem.Serial3BaudRate = item.Serial3BaudRate;
            structItem.Serial3Mode = item.Serial3Mode;
            structItem.UsbID = item.UsbID;
            structItem.WeightLimitIgnoreCount = item.WeightLimitIgnoreCount;
            structItem.MotorSelect = item.MotorSelect;

            structItem.Unit = item.Unit;
            structItem.SerialNumber = item.SerialNumber;

            structItem.Language = item.Language;

            structItem.DummyBool1 = false;
            structItem.DummyBool2 = false;
            structItem.DummyBool3 = false;
            structItem.DummyBool4 = false;
            structItem.DummyBool8 = false;
            structItem.Sorter1Location = item.Sorter1Location;
            structItem.Sorter2Location = item.Sorter2Location;
            structItem.EXT1_DelayTime = item.EXT1_DelayTime;
            structItem.EXT1_RunTime = item.EXT1_RunTime;
            structItem.InverterTorque = item.InverterTorque;
            structItem.EmptyWeight = item.EmptyWeight;
            structItem.ComPort = item.ComPort;
            structItem.DummyString3 = "";
            structItem.DummyString4 = "";
            structItem.DummyString5 = "";

            this.smartFileIO.WriteStructure(structItem, 0);
            this.smartFileIO.Close();
        }
        private void LoadSystemConfigurationFile1()
        {
            string fullFilePath = "";
            bool fileCheck = false, save = false;
            StructSystemConfigurationItem1 structItem;

            fullFilePath = this.PathSystemFileFolder + "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.CreateSystemConfigurationFile1();
            }

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

                this.SystemConfig.IsDataBackup = structItem.IsDataBackup;
                this.SystemConfig.IsEachNG = structItem.IsEachNG;
                this.SystemConfig.IsLogin = structItem.IsLogin;
                this.SystemConfig.IsWeightViewForward = structItem.IsWeightViewForward;
                this.SystemConfig.IsOptDataStatistics = structItem.IsOptDataStatistics;
                this.SystemConfig.IsSorterCheckEnable = structItem.IsSorterCheckEnable;
                this.SystemConfig.IsDeleteAfterBackup = structItem.IsDeleteAfterBackup;

                this.SystemConfig.DecimalPlaces = structItem.DecimalPlaces;
                this.SystemConfig.EquipmentColumns = structItem.EquipmentColumns;
                this.SystemConfig.ProductNumber = structItem.ProductNumber;
                this.SystemConfig.Serial3BaudRate = structItem.Serial3BaudRate;
                this.SystemConfig.Serial3Mode = structItem.Serial3Mode;
                this.SystemConfig.UsbID = structItem.UsbID;
                this.SystemConfig.InverterTorque = structItem.InverterTorque;
                this.SystemConfig.EXT1_DelayTime = structItem.EXT1_DelayTime;
                this.SystemConfig.EXT1_RunTime = structItem.EXT1_RunTime;
                this.SystemConfig.Sorter1Location = structItem.Sorter1Location;
                this.SystemConfig.Sorter2Location = structItem.Sorter2Location;
                this.SystemConfig.MotorSelect = structItem.MotorSelect;
                this.SystemConfig.WeightLimitIgnoreCount = structItem.WeightLimitIgnoreCount;

                this.SystemConfig.Unit = structItem.Unit;
                this.SystemConfig.SerialNumber = structItem.SerialNumber;
                this.SystemConfig.EmptyWeight = structItem.EmptyWeight;

                this.SystemConfig.Language = structItem.Language;

                // Com Port
                if (structItem.ComPort == "")
                {
                    save = true;
                    this.SystemConfig.ComPort = "COM2";
                }
                else
                    this.SystemConfig.ComPort = structItem.ComPort;
            }
            catch
            {
                DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig.Language);
                myMsg.ShowDialog();

                this.smartFileIO.Close();
            }

            this.smartFileIO.Close();

            if (save == true)
                this.SaveSystemConfigurationFile1(this.SystemConfig);
        }
        #endregion
        #region SystemConfiguration File2
        private void CreateSystemConfigurationFile2()
        {
            StructSystemConfigurationItem2 structItem;

            this.SystemConfig.Initialization();

            structItem.DummyDouble11 = 0.0;
            structItem.DummyDouble12 = 0.0;
            structItem.DummyDouble13 = 0.0;
            structItem.DummyDouble14 = 0.0;
            structItem.DummyDouble15 = 0.0;
            structItem.DummyDouble16 = 0.0;
            structItem.DummyDouble17 = 0.0;
            structItem.DummyDouble18 = 0.0;
            structItem.DummyDouble19 = 0.0;
            structItem.DummyDouble20 = 0.0;
            structItem.DummyDouble21 = 0.0;
            structItem.DummyDouble22 = 0.0;

            structItem.DummyBool1 = false;
            structItem.DummyBool2 = false;
            structItem.DummyBool3 = false;
            structItem.DummyBool4 = false;
            structItem.DummyBool5 = false;
            structItem.DummyBool6 = false;
            structItem.DummyBool7 = false;
            structItem.IsPart11 = this.SystemConfig.IsPart11;
            structItem.IsLeakSamplingOnce = this.SystemConfig.IsLeakSamplingOnce;
            structItem.IsSamplingOnce = this.SystemConfig.IsSamplingOnce;

            structItem.DummyInt1 = 0;
            structItem.NumberOfLoginFailures = 0;
            structItem.AutomaticLogout = this.SystemConfig.AutomaticLogout;
            structItem.StoragePeriod = this.SystemConfig.StoragePeriod;
            structItem.LeakSamplingTime = this.SystemConfig.LeakSamplingTime;
            structItem.Sorter4Location = this.SystemConfig.Sorter4Location;
            structItem.ComRetryCNT = this.SystemConfig.ComRetryCNT;
            structItem.SamplingCount = this.SystemConfig.SamplingCount;
            structItem.SamplingTime = this.SystemConfig.SamplingTime;
            structItem.Sorter3Location = this.SystemConfig.Sorter3Location;

            structItem.DummyDouble1 = 0.0;
            structItem.DummyDouble2 = 0.0;
            structItem.DummyDouble3 = 0.0;
            structItem.DummyDouble4 = 0.0;
            structItem.DummyDouble5 = 0.0;
            structItem.DummyDouble6 = 0.0;
            structItem.DummyDouble7 = 0.0;
            structItem.DummyDouble8 = 0.0;
            structItem.DummyDouble9 = 0.0;
            structItem.DummyDouble10 = 0.0;

            structItem.DummyString1 = "";
            structItem.DummyString2 = "";
            structItem.DummyString3 = "";
            structItem.DummyString4 = "";
            structItem.DummyString5 = "";
            structItem.DummyString6 = "";
            structItem.DummyString7 = "";
            structItem.User_Level1_Name = this.SystemConfig.User_Level1_Name;
            structItem.User_Level2_Name = this.SystemConfig.User_Level2_Name;
            structItem.User_Level3_Name = this.SystemConfig.User_Level3_Name;

            structItem.DummyString11 = "";
            structItem.DummyString12 = "";
            structItem.DummyString13 = "";
            structItem.DummyString14 = "";
            structItem.DummyString15 = "";

            this.smartFileIO.WriteStructure(structItem, 0);
        }
        public void SaveSystemConfigurationFile2(SystemConfigurationItem item)
        {
            string fullFilePath = "";
            bool fileCheck = false;
            StructSystemConfigurationItem2 structItem;

            fullFilePath = this.PathSystemFileFolder + "system2.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.CreateSystemConfigurationFile2();
            }

            structItem.DummyDouble11 = 0.0;
            structItem.DummyDouble12 = 0.0;
            structItem.DummyDouble13 = 0.0;
            structItem.DummyDouble14 = 0.0;
            structItem.DummyDouble15 = 0.0;
            structItem.DummyDouble16 = 0.0;
            structItem.DummyDouble17 = 0.0;
            structItem.DummyDouble18 = 0.0;
            structItem.DummyDouble19 = 0.0;
            structItem.DummyDouble20 = 0.0;
            structItem.DummyDouble21 = 0.0;
            structItem.DummyDouble22 = 0.0; 

            structItem.DummyBool1 = false;
            structItem.DummyBool2 = false;
            structItem.DummyBool3 = false;
            structItem.DummyBool4 = false;
            structItem.DummyBool5 = false;
            structItem.DummyBool6 = false;
            structItem.DummyBool7 = false;
            structItem.IsPart11 = item.IsPart11;
            structItem.IsLeakSamplingOnce = item.IsLeakSamplingOnce;
            structItem.IsSamplingOnce = item.IsSamplingOnce;

            structItem.DummyInt1 = 0;
            structItem.NumberOfLoginFailures = 0;
            structItem.AutomaticLogout = item.AutomaticLogout;
            structItem.StoragePeriod = item.StoragePeriod;
            structItem.LeakSamplingTime = item.LeakSamplingTime;
            structItem.Sorter4Location = item.Sorter4Location;
            structItem.ComRetryCNT = item.ComRetryCNT;
            structItem.SamplingCount = item.SamplingCount;
            structItem.SamplingTime = item.SamplingTime;
            structItem.Sorter3Location = item.Sorter3Location;

            structItem.DummyDouble1 = 0.0;
            structItem.DummyDouble2 = 0.0;
            structItem.DummyDouble3 = 0.0;
            structItem.DummyDouble4 = 0.0;
            structItem.DummyDouble5 = 0.0;
            structItem.DummyDouble6 = 0.0;
            structItem.DummyDouble7 = 0.0;
            structItem.DummyDouble8 = 0.0;
            structItem.DummyDouble9 = 0.0;
            structItem.DummyDouble10 = 0.0;

            structItem.DummyString1 = "";
            structItem.DummyString2 = "";
            structItem.DummyString3 = "";
            structItem.DummyString4 = "";
            structItem.DummyString5 = "";
            structItem.DummyString6 = "";
            structItem.DummyString7 = "";
            structItem.User_Level1_Name = item.User_Level1_Name;
            structItem.User_Level2_Name = item.User_Level2_Name;
            structItem.User_Level3_Name = item.User_Level3_Name;

            structItem.DummyString11 = "";
            structItem.DummyString12 = "";
            structItem.DummyString13 = "";
            structItem.DummyString14 = "";
            structItem.DummyString15 = "";

            this.smartFileIO.WriteStructure(structItem, 0);
            this.smartFileIO.Close();
        }
        private void LoadSystemConfigurationFile2()
        {
            string fullFilePath = "";
            bool fileCheck = false, save = false;
            StructSystemConfigurationItem2 structItem;
            SystemConfigurationItem sysCfg = new SystemConfigurationItem();

            fullFilePath = this.PathSystemFileFolder + "system2.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.CreateSystemConfigurationFile2();
            }

            try
            {
                structItem = (StructSystemConfigurationItem2)this.smartFileIO.ReadStructure(0, typeof(StructSystemConfigurationItem2));

                // Sorter3Location
                this.SystemConfig.Sorter3Location = structItem.Sorter3Location;
                // IsSamplingOnce
                this.SystemConfig.IsSamplingOnce = structItem.IsSamplingOnce;
                // SamplingCount
                if (structItem.SamplingCount == 0)
                {
                    save = true;
                    this.SystemConfig.SamplingCount = sysCfg.SamplingCount;
                }
                else
                    this.SystemConfig.SamplingCount = structItem.SamplingCount;
                // SamplingTime
                if (structItem.SamplingTime == 0)
                {
                    save = true;
                    this.SystemConfig.SamplingTime = sysCfg.SamplingTime;
                }
                else
                    this.SystemConfig.SamplingTime = structItem.SamplingTime;
                // ComRetryCNT
                this.SystemConfig.ComRetryCNT = structItem.ComRetryCNT;
                // Sorter4Location
                this.SystemConfig.Sorter4Location = structItem.Sorter4Location;
                // IsLeakSamplingOnce
                this.SystemConfig.IsLeakSamplingOnce = structItem.IsLeakSamplingOnce;
                // LeakSamplingTime
                if (structItem.LeakSamplingTime == 0)
                {
                    save = true;
                    this.SystemConfig.LeakSamplingTime = sysCfg.LeakSamplingTime;
                }
                else
                    this.SystemConfig.LeakSamplingTime = structItem.LeakSamplingTime;
                // IsOptPart11
                this.SystemConfig.IsPart11 = structItem.IsPart11;
                // AutomaticLogout
                if (structItem.AutomaticLogout == 0)
                {
                    save = true;
                    this.SystemConfig.AutomaticLogout = sysCfg.AutomaticLogout;
                }
                else
                    this.SystemConfig.AutomaticLogout = structItem.AutomaticLogout;
                // DataStoragePeriod
                if (structItem.StoragePeriod == 0)
                {
                    save = true;
                    this.SystemConfig.StoragePeriod = sysCfg.StoragePeriod;
                }
                else
                    this.SystemConfig.StoragePeriod = structItem.StoragePeriod;
                // User_Level1_Name
                if (structItem.User_Level1_Name == "")
                {
                    save = true;
                    this.SystemConfig.User_Level1_Name = sysCfg.User_Level1_Name;
                }
                else
                    this.SystemConfig.User_Level1_Name = structItem.User_Level1_Name;
                // User_Level2_Name
                if (structItem.User_Level2_Name == "")
                {
                    save = true;
                    this.SystemConfig.User_Level2_Name = sysCfg.User_Level2_Name;
                }
                else
                    this.SystemConfig.User_Level2_Name = structItem.User_Level2_Name;
                // User_Level3_Name
                if (structItem.User_Level3_Name == "")
                {
                    save = true;
                    this.SystemConfig.User_Level3_Name = sysCfg.User_Level3_Name;
                }
                else
                    this.SystemConfig.User_Level3_Name = structItem.User_Level3_Name;
            }
            catch
            {
                DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig.Language);
                myMsg.ShowDialog();

                this.smartFileIO.Close();
            }

            this.smartFileIO.Close();

            if (save == true)
                this.SaveSystemConfigurationFile2(this.SystemConfig);
        }
        #endregion
        #region SystemConfiguration File3
        private void CreateSystemConfigurationFile3()
        {
            StructSystemConfigurationItem3 structItem;

            this.SystemConfig.Initialization();

            structItem.DummyBool1 = false;
            structItem.DummyBool2 = false;
            structItem.DummyBool3 = false;
            structItem.DummyBool4 = false;
            structItem.DummyBool5 = false;
            structItem.DummyBool6 = false;
            structItem.DummyBool7 = false;
            structItem.DummyBool8 = false;
            structItem.DummyBool9 = false;
            structItem.DummyBool10 = false;
            structItem.DummyBool11 = false;
            structItem.DummyBool12 = false;
            structItem.DummyBool13 = false;
            structItem.DummyBool14 = false;
            structItem.DummyBool15 = false;
            structItem.DummyBool16 = false;
            structItem.DummyBool17 = false;
            structItem.DummyBool18 = false;
            structItem.DummyBool19 = false;
            structItem.IsModbus = this.SystemConfig.IsModbus;


            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;
            structItem.DummyInt11 = 0;
            structItem.DummyInt12 = 0;
            structItem.DummyInt13 = 0;
            structItem.EthernetServerPort = this.SystemConfig.EthernetServerPort;
            structItem.EthernetMode = this.SystemConfig.EthernetMode;
            structItem.EthernetOperationMode = this.SystemConfig.EthernetOperationMode;
            structItem.EthernetLocalPort = this.SystemConfig.EthernetLocalPort;
            structItem.ModbusTcpAddress1 = this.SystemConfig.ModbusTcpAddress1;
            structItem.ModbusTcpAddress2 = this.SystemConfig.ModbusTcpAddress2;
            structItem.ModbusTcpStartAddress = this.SystemConfig.ModbusTcpStartAddress;

            structItem.DummyString1 = "";
            structItem.DummyString2 = "";
            structItem.DummyString3 = "";
            structItem.DummyString4 = "";
            structItem.DummyString5 = "";
            structItem.DummyString6 = "";
            structItem.DummyString7 = "";
            structItem.DummyString8 = "";
            structItem.DummyString9 = "";
            structItem.EthernetServerAddress = this.SystemConfig.EthernetServerAddress;

            this.smartFileIO.WriteStructure(structItem, 0);
        }
        public void SaveSystemConfigurationFile3(SystemConfigurationItem item)
        {
            string fullFilePath = "";
            bool fileCheck = false;
            StructSystemConfigurationItem3 structItem;

            fullFilePath = this.PathSystemFileFolder + "system3.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.CreateSystemConfigurationFile3();
            }

            structItem.DummyBool1 = false;
            structItem.DummyBool2 = false;
            structItem.DummyBool3 = false;
            structItem.DummyBool4 = false;
            structItem.DummyBool5 = false;
            structItem.DummyBool6 = false;
            structItem.DummyBool7 = false;
            structItem.DummyBool8 = false;
            structItem.DummyBool9 = false;
            structItem.DummyBool10 = false;
            structItem.DummyBool11 = false;
            structItem.DummyBool12 = false;
            structItem.DummyBool13 = false;
            structItem.DummyBool14 = false;
            structItem.DummyBool15 = false;
            structItem.DummyBool16 = false;
            structItem.DummyBool17 = false;
            structItem.DummyBool18 = false;
            structItem.DummyBool19 = false;
            structItem.IsModbus = item.IsModbus;

            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;
            structItem.DummyInt11 = 0;
            structItem.DummyInt12 = 0;
            structItem.DummyInt13 = 0;
            structItem.EthernetServerPort = item.EthernetServerPort;
            structItem.EthernetMode = item.EthernetMode;
            structItem.EthernetOperationMode = item.EthernetOperationMode;
            structItem.EthernetLocalPort = item.EthernetLocalPort;
            structItem.ModbusTcpAddress1 = item.ModbusTcpAddress1;
            structItem.ModbusTcpAddress2 = item.ModbusTcpAddress2;
            structItem.ModbusTcpStartAddress = item.ModbusTcpStartAddress;

            structItem.DummyString1 = "";
            structItem.DummyString2 = "";
            structItem.DummyString3 = "";
            structItem.DummyString4 = "";
            structItem.DummyString5 = "";
            structItem.DummyString6 = "";
            structItem.DummyString7 = "";
            structItem.DummyString8 = "";
            structItem.DummyString9 = "";
            structItem.EthernetServerAddress = item.EthernetServerAddress;

            this.smartFileIO.WriteStructure(structItem, 0);
            this.smartFileIO.Close();
        }
        private void LoadSystemConfigurationFile3()
        {
            string fullFilePath = "";
            bool fileCheck = false, save = false;
            StructSystemConfigurationItem3 structItem;
            SystemConfigurationItem sysCfg = new SystemConfigurationItem();

            fullFilePath = this.PathSystemFileFolder + "system3.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.CreateSystemConfigurationFile3();
            }

            try
            {
                structItem = (StructSystemConfigurationItem3)this.smartFileIO.ReadStructure(0, typeof(StructSystemConfigurationItem3));

                this.SystemConfig.IsModbus = structItem.IsModbus;
                this.SystemConfig.EthernetServerPort = structItem.EthernetServerPort;
                this.SystemConfig.EthernetMode = structItem.EthernetMode;
                this.SystemConfig.EthernetOperationMode = structItem.EthernetOperationMode;
                this.SystemConfig.EthernetLocalPort = structItem.EthernetLocalPort;
                this.SystemConfig.ModbusTcpAddress1 = structItem.ModbusTcpAddress1;
                this.SystemConfig.ModbusTcpAddress2 = structItem.ModbusTcpAddress2;
                this.SystemConfig.ModbusTcpStartAddress = structItem.ModbusTcpStartAddress;
                this.SystemConfig.EthernetServerAddress = structItem.EthernetServerAddress;
            }
            catch
            {
                DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig.Language);
                myMsg.ShowDialog();

                this.smartFileIO.Close();
            }

            this.smartFileIO.Close();

            if (save == true)
                this.SaveSystemConfigurationFile3(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.OverRangeLimit = this.CurrentProductItem.OverRangeLimit;
                structItem.UnderRangeLimit = this.CurrentProductItem.UnderRangeLimit;
                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.PathSystemFileFolder + "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.OverRangeLimit = item.OverRangeLimit;
            structItem.UnderRangeLimit = item.UnderRangeLimit;
            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, save = false;
            string fullFilePath = "";
            StructProductItem structItem;

            fullFilePath = this.PathSystemFileFolder + "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
            {
                if (this.smartFileIO.ReadStructureAllBuffer() == true)
                {
                    structItem = (StructProductItem)this.smartFileIO.ReadStructureBuffer(typeof(StructProductItem), index);

                    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;

                    // OverRangeLimit
                    if (structItem.OverRangeLimit == "")
                    {
                        item.OverRangeLimit = "99999";
                        save = true;
                    }
                    else
                        item.OverRangeLimit = structItem.OverRangeLimit;
                    // UnderRangeLimit
                    if (structItem.UnderRangeLimit == "")
                        item.UnderRangeLimit = "0";
                    else
                        item.UnderRangeLimit = structItem.UnderRangeLimit;
                }
            }
            catch
            {
                DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig.Language);
                myMsg.ShowDialog();

                this.smartFileIO.Close();
            }

            this.smartFileIO.Close();

            this.SaveProductFile(item, index);
        }
        public void LoadProductName(ref Collection<string> values)
        {
            string fullFilePath = "";
            StructProductItem structItem;

            values.Clear();

            fullFilePath = this.PathSystemFileFolder + "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();
        }
        #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.JudgmentCount = this.CurrentJudgmentSetItem.JudgmentCount;
                structItem.FeedSpeed = this.CurrentJudgmentSetItem.FeedSpeed;
                structItem.TurnDelayTime = this.CurrentJudgmentSetItem.TurnDelayTime;
                structItem.Sorter1RunTime = this.CurrentJudgmentSetItem.Sorter1RunTime;
                structItem.DynamicCorrection = this.CurrentJudgmentSetItem.DynamicCorrection;
                structItem.OriginOffset = this.CurrentJudgmentSetItem.OriginOffset;
                structItem.ForcedZeroDelayTime = this.CurrentJudgmentSetItem.ForcedZeroDelayTime;
                structItem.Sorter1DelayTime = this.CurrentJudgmentSetItem.Sorter1DelayTime;
                structItem.Sorter2DelayTime = this.CurrentJudgmentSetItem.Sorter2DelayTime;
                structItem.Sorter2RunTime = this.CurrentJudgmentSetItem.Sorter2RunTime;
                structItem.DummyString1 = "";
                structItem.Sorter4DelayTime = this.CurrentJudgmentSetItem.Sorter4DelayTime;
                structItem.Sorter4RunTime = this.CurrentJudgmentSetItem.Sorter4RunTime;
                structItem.Sorter3DelayTime = this.CurrentJudgmentSetItem.Sorter3DelayTime;
                structItem.Sorter3RunTime = this.CurrentJudgmentSetItem.Sorter3RunTime;

                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.PathSystemFileFolder + "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.JudgmentCount = item.JudgmentCount;
            structItem.FeedSpeed = item.FeedSpeed;
            structItem.TurnDelayTime = item.TurnDelayTime;
            structItem.Sorter1RunTime = item.Sorter1RunTime;
            structItem.DynamicCorrection = item.DynamicCorrection;
            structItem.OriginOffset = item.OriginOffset;
            structItem.ForcedZeroDelayTime = item.ForcedZeroDelayTime;
            structItem.Sorter1DelayTime = item.Sorter1DelayTime;
            structItem.Sorter2DelayTime = item.Sorter2DelayTime;
            structItem.Sorter2RunTime = item.Sorter2RunTime;
            structItem.DummyString1 = "";
            structItem.Sorter4DelayTime = item.Sorter4DelayTime;
            structItem.Sorter4RunTime = item.Sorter4RunTime;
            structItem.Sorter3DelayTime = item.Sorter3DelayTime;
            structItem.Sorter3RunTime = item.Sorter3RunTime;

            this.smartFileIO.WriteStructure(structItem, index);

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

            fullFilePath = this.PathSystemFileFolder + "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
            {
                if (this.smartFileIO.ReadStructureAllBuffer() == true)
                {
                    structItem = (StructJudgmentSetItem)this.smartFileIO.ReadStructureBuffer(typeof(StructJudgmentSetItem), index);

                    item.Filter = structItem.Filter;
                    item.JudgmentDelayTime = structItem.JudgmentDelayTime;
                    item.JudgmentCount = structItem.JudgmentCount;
                    item.FeedSpeed = structItem.FeedSpeed;
                    item.TurnDelayTime = structItem.TurnDelayTime;
                    item.DynamicCorrection = structItem.DynamicCorrection;
                    item.Sorter1DelayTime = structItem.Sorter1DelayTime;
                    item.Sorter1RunTime = structItem.Sorter1RunTime;
                    item.Sorter2DelayTime = structItem.Sorter2DelayTime;
                    item.Sorter2RunTime = structItem.Sorter2RunTime;
                    item.ForcedZeroDelayTime = structItem.ForcedZeroDelayTime;
                    item.OriginOffset = structItem.OriginOffset;

                    // Sorter3 Delaytime
                    if (structItem.Sorter3DelayTime == "")
                        item.Sorter3DelayTime = "500";
                    else
                        item.Sorter3DelayTime = structItem.Sorter3DelayTime;
                    // Sorter3 Runtime
                    if (structItem.Sorter3RunTime == "")
                        item.Sorter3RunTime = "1000";
                    else
                        item.Sorter3RunTime = structItem.Sorter3RunTime;

                    // Sorter4 Delaytime
                    if (structItem.Sorter4DelayTime == "")
                        item.Sorter4DelayTime = "1";
                    else
                        item.Sorter4DelayTime = structItem.Sorter4DelayTime;
                    // Sorter4 Runtime
                    if (structItem.Sorter4RunTime == "")
                        item.Sorter4RunTime = "600";
                    else
                        item.Sorter4RunTime = structItem.Sorter4RunTime;
                }
            }
            catch
            {
                DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig.Language);
                myMsg.ShowDialog();

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

        #region DynamicCorrectionItem File
        private void CreateDynamicCorrectionFile()
        {
            StructDynamicCorrectionItem structItem;

            this.CurrentJudgmentSetItem.Initialization();

            for (int i = 0; i < 1000; i++)
            {
                structItem.DynamicCorrection1 = this.CurrentJudgmentSetItem.DynamicCorrection1;
                structItem.DynamicCorrection2 = this.CurrentJudgmentSetItem.DynamicCorrection2;
                structItem.DynamicCorrection3 = this.CurrentJudgmentSetItem.DynamicCorrection3;
                structItem.DynamicCorrection4 = this.CurrentJudgmentSetItem.DynamicCorrection4;
                structItem.DynamicCorrection5 = this.CurrentJudgmentSetItem.DynamicCorrection5;
                structItem.DynamicCorrection6 = this.CurrentJudgmentSetItem.DynamicCorrection6;
                structItem.DynamicCorrection7 = this.CurrentJudgmentSetItem.DynamicCorrection7;
                structItem.DynamicCorrection8 = this.CurrentJudgmentSetItem.DynamicCorrection8;
                structItem.DynamicCorrection9 = this.CurrentJudgmentSetItem.DynamicCorrection9;
                structItem.DynamicCorrection10 = this.CurrentJudgmentSetItem.DynamicCorrection10;
                structItem.DynamicCorrection11 = this.CurrentJudgmentSetItem.DynamicCorrection11;
                structItem.DynamicCorrection12 = this.CurrentJudgmentSetItem.DynamicCorrection12;

                structItem.DummyDouble1 = 0.0;
                structItem.DummyDouble2 = 0.0;
                structItem.DummyDouble3 = 0.0;
                structItem.DummyDouble4 = 0.0;
                structItem.DummyDouble5 = 0.0;
                structItem.DummyDouble6 = 0.0;
                structItem.DynamicCorrection13 = this.CurrentJudgmentSetItem.DynamicCorrection13;
                structItem.DynamicCorrection14 = this.CurrentJudgmentSetItem.DynamicCorrection14;
                structItem.DynamicCorrection15 = this.CurrentJudgmentSetItem.DynamicCorrection15;
                structItem.DynamicCorrection16 = this.CurrentJudgmentSetItem.DynamicCorrection16;

                structItem.DummyInt1 = 0;
                structItem.DummyInt2 = 0;
                structItem.DummyInt3 = 0;
                structItem.DummyInt4 = 0;
                structItem.Stopper2DelayTime = this.CurrentJudgmentSetItem.Stopper2DelayTime;
                structItem.Stopper2RunTime = this.CurrentJudgmentSetItem.Stopper2RunTime;
                structItem.EntryGateDelayTime = this.CurrentJudgmentSetItem.EntryGateDelayTime;
                structItem.EntryGateRunTime = this.CurrentJudgmentSetItem.EntryGateRunTime;
                structItem.DischargeStopperDelayTime = this.CurrentJudgmentSetItem.DischargeStopperDelayTime;
                structItem.DischargeStopperRunTime = this.CurrentJudgmentSetItem.DischargeStopperRunTime;

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

            fullFilePath = this.PathSystemFileFolder + "DynamicCorrectionItem.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.CreateDynamicCorrectionFile();
            }

            structItem.DynamicCorrection1 = item.DynamicCorrection1;
            structItem.DynamicCorrection2 = item.DynamicCorrection2;
            structItem.DynamicCorrection3 = item.DynamicCorrection3;
            structItem.DynamicCorrection4 = item.DynamicCorrection4;
            structItem.DynamicCorrection5 = item.DynamicCorrection5;
            structItem.DynamicCorrection6 = item.DynamicCorrection6;
            structItem.DynamicCorrection7 = item.DynamicCorrection7;
            structItem.DynamicCorrection8 = item.DynamicCorrection8;
            structItem.DynamicCorrection9 = item.DynamicCorrection9;
            structItem.DynamicCorrection10 = item.DynamicCorrection10;
            structItem.DynamicCorrection11 = item.DynamicCorrection11;
            structItem.DynamicCorrection12 = item.DynamicCorrection12;

            structItem.DummyDouble1 = 0.0;
            structItem.DummyDouble2 = 0.0;
            structItem.DummyDouble3 = 0.0;
            structItem.DummyDouble4 = 0.0;
            structItem.DummyDouble5 = 0.0;
            structItem.DummyDouble6 = 0.0;
            structItem.DynamicCorrection13 = item.DynamicCorrection13;
            structItem.DynamicCorrection14 = item.DynamicCorrection14;
            structItem.DynamicCorrection15 = item.DynamicCorrection15;
            structItem.DynamicCorrection16 = item.DynamicCorrection16;

            structItem.DummyInt1 = 0;
            structItem.DummyInt2 = 0;
            structItem.DummyInt3 = 0;
            structItem.DummyInt4 = 0;
            structItem.Stopper2DelayTime = item.Stopper2DelayTime;
            structItem.Stopper2RunTime = item.Stopper2RunTime;
            structItem.EntryGateDelayTime = item.EntryGateDelayTime;
            structItem.EntryGateRunTime = item.EntryGateRunTime;
            structItem.DischargeStopperDelayTime = item.DischargeStopperDelayTime;
            structItem.DischargeStopperRunTime = item.DischargeStopperRunTime;

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

            fullFilePath = this.PathSystemFileFolder + "DynamicCorrectionItem.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.CreateDynamicCorrectionFile();
            }

            try
            {
                if (this.smartFileIO.ReadStructureAllBuffer() == true)
                {
                    structItem = (StructDynamicCorrectionItem)this.smartFileIO.ReadStructureBuffer(typeof(StructDynamicCorrectionItem), index);

                    item.DynamicCorrection1 = structItem.DynamicCorrection1;
                    item.DynamicCorrection2 = structItem.DynamicCorrection2;
                    item.DynamicCorrection3 = structItem.DynamicCorrection3;
                    item.DynamicCorrection4 = structItem.DynamicCorrection4;
                    item.DynamicCorrection5 = structItem.DynamicCorrection5;
                    item.DynamicCorrection6 = structItem.DynamicCorrection6;
                    item.DynamicCorrection7 = structItem.DynamicCorrection7;
                    item.DynamicCorrection8 = structItem.DynamicCorrection8;
                    item.DynamicCorrection9 = structItem.DynamicCorrection9;
                    item.DynamicCorrection10 = structItem.DynamicCorrection10;
                    item.DynamicCorrection11 = structItem.DynamicCorrection11;
                    item.DynamicCorrection12 = structItem.DynamicCorrection12;
                    item.DynamicCorrection13 = structItem.DynamicCorrection13;
                    item.DynamicCorrection14 = structItem.DynamicCorrection14;
                    item.DynamicCorrection15 = structItem.DynamicCorrection15;
                    item.DynamicCorrection16 = structItem.DynamicCorrection16;

                    item.EntryGateDelayTime = structItem.EntryGateDelayTime;
                    item.EntryGateRunTime = structItem.EntryGateRunTime;
                    item.DischargeStopperDelayTime = structItem.DischargeStopperDelayTime;
                    item.DischargeStopperRunTime = structItem.DischargeStopperRunTime;
                    item.Stopper2DelayTime = structItem.Stopper2DelayTime;
                    item.Stopper2RunTime = structItem.Stopper2RunTime;
                }
            }
            catch
            {
                DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig.Language);
                myMsg.ShowDialog();

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

        #region Counter File1
        private void CreateCounterFile1()
        {
            StructCounter1 structItem1;

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

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

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

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

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

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

                structItem1.OverCount7 = 0;
                structItem1.PassCount7 = 0;
                structItem1.UnderCount7 = 0;
                structItem1.ExNGCount7 = 0;

                structItem1.OverCount8 = 0;
                structItem1.PassCount8 = 0;
                structItem1.UnderCount8 = 0;
                structItem1.ExNGCount8 = 0;

                structItem1.OverCount9 = 0;
                structItem1.PassCount9 = 0;
                structItem1.UnderCount9 = 0;
                structItem1.ExNGCount9 = 0;

                structItem1.OverCount10 = 0;
                structItem1.PassCount10 = 0;
                structItem1.UnderCount10 = 0;
                structItem1.ExNGCount10 = 0;

                structItem1.OverCount11 = 0;
                structItem1.PassCount11 = 0;
                structItem1.UnderCount11 = 0;
                structItem1.ExNGCount11 = 0;

                structItem1.OverCount12 = 0;
                structItem1.PassCount12 = 0;
                structItem1.UnderCount12 = 0;
                structItem1.ExNGCount12 = 0;

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

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

            fullFilePath = this.PathSystemFileFolder + "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.CreateCounterFile1();
            }

            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;

            switch (this.SystemConfig.EquipmentColumns)
            {
                case 2:
                    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.OverCount7 = 0;
                    structItem.PassCount7 = 0;
                    structItem.UnderCount7 = 0;
                    structItem.ExNGCount7 = 0;

                    structItem.OverCount8 = 0;
                    structItem.PassCount8 = 0;
                    structItem.UnderCount8 = 0;
                    structItem.ExNGCount8 = 0;

                    structItem.OverCount9 = 0;
                    structItem.PassCount9 = 0;
                    structItem.UnderCount9 = 0;
                    structItem.ExNGCount9 = 0;

                    structItem.OverCount10 = 0;
                    structItem.PassCount10 = 0;
                    structItem.UnderCount10 = 0;
                    structItem.ExNGCount10 = 0;

                    structItem.OverCount11 = 0;
                    structItem.PassCount11 = 0;
                    structItem.UnderCount11 = 0;
                    structItem.ExNGCount11 = 0;

                    structItem.OverCount12 = 0;
                    structItem.PassCount12 = 0;
                    structItem.UnderCount12 = 0;
                    structItem.ExNGCount12 = 0;
                    break;
                case 3:
                    structItem.OverCount3 = items[2].OverCount;
                    structItem.PassCount3 = items[2].PassCount;
                    structItem.UnderCount3 = items[2].UnderCount;
                    structItem.ExNGCount3 = items[2].ExNGCount;

                    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.OverCount7 = 0;
                    structItem.PassCount7 = 0;
                    structItem.UnderCount7 = 0;
                    structItem.ExNGCount7 = 0;

                    structItem.OverCount8 = 0;
                    structItem.PassCount8 = 0;
                    structItem.UnderCount8 = 0;
                    structItem.ExNGCount8 = 0;

                    structItem.OverCount9 = 0;
                    structItem.PassCount9 = 0;
                    structItem.UnderCount9 = 0;
                    structItem.ExNGCount9 = 0;

                    structItem.OverCount10 = 0;
                    structItem.PassCount10 = 0;
                    structItem.UnderCount10 = 0;
                    structItem.ExNGCount10 = 0;

                    structItem.OverCount11 = 0;
                    structItem.PassCount11 = 0;
                    structItem.UnderCount11 = 0;
                    structItem.ExNGCount11 = 0;

                    structItem.OverCount12 = 0;
                    structItem.PassCount12 = 0;
                    structItem.UnderCount12 = 0;
                    structItem.ExNGCount12 = 0;
                    break;
                case 4:
                    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 = 0;
                    structItem.PassCount5 = 0;
                    structItem.UnderCount5 = 0;
                    structItem.ExNGCount5 = 0;

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

                    structItem.OverCount7 = 0;
                    structItem.PassCount7 = 0;
                    structItem.UnderCount7 = 0;
                    structItem.ExNGCount7 = 0;

                    structItem.OverCount8 = 0;
                    structItem.PassCount8 = 0;
                    structItem.UnderCount8 = 0;
                    structItem.ExNGCount8 = 0;

                    structItem.OverCount9 = 0;
                    structItem.PassCount9 = 0;
                    structItem.UnderCount9 = 0;
                    structItem.ExNGCount9 = 0;

                    structItem.OverCount10 = 0;
                    structItem.PassCount10 = 0;
                    structItem.UnderCount10 = 0;
                    structItem.ExNGCount10 = 0;

                    structItem.OverCount11 = 0;
                    structItem.PassCount11 = 0;
                    structItem.UnderCount11 = 0;
                    structItem.ExNGCount11 = 0;

                    structItem.OverCount12 = 0;
                    structItem.PassCount12 = 0;
                    structItem.UnderCount12 = 0;
                    structItem.ExNGCount12 = 0;
                    break;
                case 5:
                    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 = 0;
                    structItem.PassCount6 = 0;
                    structItem.UnderCount6 = 0;
                    structItem.ExNGCount6 = 0;

                    structItem.OverCount7 = 0;
                    structItem.PassCount7 = 0;
                    structItem.UnderCount7 = 0;
                    structItem.ExNGCount7 = 0;

                    structItem.OverCount8 = 0;
                    structItem.PassCount8 = 0;
                    structItem.UnderCount8 = 0;
                    structItem.ExNGCount8 = 0;

                    structItem.OverCount9 = 0;
                    structItem.PassCount9 = 0;
                    structItem.UnderCount9 = 0;
                    structItem.ExNGCount9 = 0;

                    structItem.OverCount10 = 0;
                    structItem.PassCount10 = 0;
                    structItem.UnderCount10 = 0;
                    structItem.ExNGCount10 = 0;

                    structItem.OverCount11 = 0;
                    structItem.PassCount11 = 0;
                    structItem.UnderCount11 = 0;
                    structItem.ExNGCount11 = 0;

                    structItem.OverCount12 = 0;
                    structItem.PassCount12 = 0;
                    structItem.UnderCount12 = 0;
                    structItem.ExNGCount12 = 0;
                    break;
                case 6:
                    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.OverCount7 = 0;
                    structItem.PassCount7 = 0;
                    structItem.UnderCount7 = 0;
                    structItem.ExNGCount7 = 0;

                    structItem.OverCount8 = 0;
                    structItem.PassCount8 = 0;
                    structItem.UnderCount8 = 0;
                    structItem.ExNGCount8 = 0;

                    structItem.OverCount9 = 0;
                    structItem.PassCount9 = 0;
                    structItem.UnderCount9 = 0;
                    structItem.ExNGCount9 = 0;

                    structItem.OverCount10 = 0;
                    structItem.PassCount10 = 0;
                    structItem.UnderCount10 = 0;
                    structItem.ExNGCount10 = 0;

                    structItem.OverCount11 = 0;
                    structItem.PassCount11 = 0;
                    structItem.UnderCount11 = 0;
                    structItem.ExNGCount11 = 0;

                    structItem.OverCount12 = 0;
                    structItem.PassCount12 = 0;
                    structItem.UnderCount12 = 0;
                    structItem.ExNGCount12 = 0;
                    break;
                case 7:
                    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.OverCount7 = items[6].OverCount;
                    structItem.PassCount7 = items[6].PassCount;
                    structItem.UnderCount7 = items[6].UnderCount;
                    structItem.ExNGCount7 = items[6].ExNGCount;

                    structItem.OverCount8 = 0;
                    structItem.PassCount8 = 0;
                    structItem.UnderCount8 = 0;
                    structItem.ExNGCount8 = 0;

                    structItem.OverCount9 = 0;
                    structItem.PassCount9 = 0;
                    structItem.UnderCount9 = 0;
                    structItem.ExNGCount9 = 0;

                    structItem.OverCount10 = 0;
                    structItem.PassCount10 = 0;
                    structItem.UnderCount10 = 0;
                    structItem.ExNGCount10 = 0;

                    structItem.OverCount11 = 0;
                    structItem.PassCount11 = 0;
                    structItem.UnderCount11 = 0;
                    structItem.ExNGCount11 = 0;

                    structItem.OverCount12 = 0;
                    structItem.PassCount12 = 0;
                    structItem.UnderCount12 = 0;
                    structItem.ExNGCount12 = 0;
                    break;
                case 8:
                    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.OverCount7 = items[6].OverCount;
                    structItem.PassCount7 = items[6].PassCount;
                    structItem.UnderCount7 = items[6].UnderCount;
                    structItem.ExNGCount7 = items[6].ExNGCount;

                    structItem.OverCount8 = items[7].OverCount;
                    structItem.PassCount8 = items[7].PassCount;
                    structItem.UnderCount8 = items[7].UnderCount;
                    structItem.ExNGCount8 = items[7].ExNGCount;

                    structItem.OverCount9 = 0;
                    structItem.PassCount9 = 0;
                    structItem.UnderCount9 = 0;
                    structItem.ExNGCount9 = 0;

                    structItem.OverCount10 = 0;
                    structItem.PassCount10 = 0;
                    structItem.UnderCount10 = 0;
                    structItem.ExNGCount10 = 0;

                    structItem.OverCount11 = 0;
                    structItem.PassCount11 = 0;
                    structItem.UnderCount11 = 0;
                    structItem.ExNGCount11 = 0;

                    structItem.OverCount12 = 0;
                    structItem.PassCount12 = 0;
                    structItem.UnderCount12 = 0;
                    structItem.ExNGCount12 = 0;
                    break;
                case 10:
                    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.OverCount7 = items[6].OverCount;
                    structItem.PassCount7 = items[6].PassCount;
                    structItem.UnderCount7 = items[6].UnderCount;
                    structItem.ExNGCount7 = items[6].ExNGCount;

                    structItem.OverCount8 = items[7].OverCount;
                    structItem.PassCount8 = items[7].PassCount;
                    structItem.UnderCount8 = items[7].UnderCount;
                    structItem.ExNGCount8 = items[7].ExNGCount;

                    structItem.OverCount9 = items[8].OverCount;
                    structItem.PassCount9 = items[8].PassCount;
                    structItem.UnderCount9 = items[8].UnderCount;
                    structItem.ExNGCount9 = items[8].ExNGCount;

                    structItem.OverCount10 = items[9].OverCount;
                    structItem.PassCount10 = items[9].PassCount;
                    structItem.UnderCount10 = items[9].UnderCount;
                    structItem.ExNGCount10 = items[9].ExNGCount;

                    structItem.OverCount11 = 0;
                    structItem.PassCount11 = 0;
                    structItem.UnderCount11 = 0;
                    structItem.ExNGCount11 = 0;

                    structItem.OverCount12 = 0;
                    structItem.PassCount12 = 0;
                    structItem.UnderCount12 = 0;
                    structItem.ExNGCount12 = 0;
                    break;
                case 12:
                case 15:
                case 16:
                    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.OverCount7 = items[6].OverCount;
                    structItem.PassCount7 = items[6].PassCount;
                    structItem.UnderCount7 = items[6].UnderCount;
                    structItem.ExNGCount7 = items[6].ExNGCount;

                    structItem.OverCount8 = items[7].OverCount;
                    structItem.PassCount8 = items[7].PassCount;
                    structItem.UnderCount8 = items[7].UnderCount;
                    structItem.ExNGCount8 = items[7].ExNGCount;

                    structItem.OverCount9 = items[8].OverCount;
                    structItem.PassCount9 = items[8].PassCount;
                    structItem.UnderCount9 = items[8].UnderCount;
                    structItem.ExNGCount9 = items[8].ExNGCount;

                    structItem.OverCount10 = items[9].OverCount;
                    structItem.PassCount10 = items[9].PassCount;
                    structItem.UnderCount10 = items[9].UnderCount;
                    structItem.ExNGCount10 = items[9].ExNGCount;

                    structItem.OverCount11 = items[10].OverCount;
                    structItem.PassCount11 = items[10].PassCount;
                    structItem.UnderCount11 = items[10].UnderCount;
                    structItem.ExNGCount11 = items[10].ExNGCount;

                    structItem.OverCount12 = items[11].OverCount;
                    structItem.PassCount12 = items[11].PassCount;
                    structItem.UnderCount12 = items[11].UnderCount;
                    structItem.ExNGCount12 = items[11].ExNGCount;
                    break;
                default:
                    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.OverCount7 = 0;
                    structItem.PassCount7 = 0;
                    structItem.UnderCount7 = 0;
                    structItem.ExNGCount7 = 0;

                    structItem.OverCount8 = 0;
                    structItem.PassCount8 = 0;
                    structItem.UnderCount8 = 0;
                    structItem.ExNGCount8 = 0;

                    structItem.OverCount9 = 0;
                    structItem.PassCount9 = 0;
                    structItem.UnderCount9 = 0;
                    structItem.ExNGCount9 = 0;

                    structItem.OverCount10 = 0;
                    structItem.PassCount10 = 0;
                    structItem.UnderCount10 = 0;
                    structItem.ExNGCount10 = 0;

                    structItem.OverCount11 = 0;
                    structItem.PassCount11 = 0;
                    structItem.UnderCount11 = 0;
                    structItem.ExNGCount11 = 0;

                    structItem.OverCount12 = 0;
                    structItem.PassCount12 = 0;
                    structItem.UnderCount12 = 0;
                    structItem.ExNGCount12 = 0;
                    break;
            }

            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 LoadCounterFile1(ref Collection<WeightData> items, int index)
        {
            string fullFilePath = "";
            bool fileCheck = false;
            StructCounter1 structItem;

            fullFilePath = this.PathSystemFileFolder + "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.CreateCounterFile1();
            }

            try
            {
                if (this.smartFileIO.ReadStructureAllBuffer() == true)
                {
                    structItem = (StructCounter1)this.smartFileIO.ReadStructureBuffer(typeof(StructCounter1), index);

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

                    switch (this.SystemConfig.EquipmentColumns)
                    {
                        case 2:
                            items[1].UnderCount = structItem.UnderCount2;
                            items[1].PassCount = structItem.PassCount2;
                            items[1].OverCount = structItem.OverCount2;
                            items[1].ExNGCount = structItem.ExNGCount2;
                            break;
                        case 3:
                            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;
                            break;
                        case 4:
                            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;
                            break;
                        case 5:
                            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;
                            break;
                        case 6:
                            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;
                            break;
                        case 7:
                            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;

                            items[6].UnderCount = structItem.UnderCount7;
                            items[6].PassCount = structItem.PassCount7;
                            items[6].OverCount = structItem.OverCount7;
                            items[6].ExNGCount = structItem.ExNGCount7;
                            break;
                        case 8:
                            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;

                            items[6].UnderCount = structItem.UnderCount7;
                            items[6].PassCount = structItem.PassCount7;
                            items[6].OverCount = structItem.OverCount7;
                            items[6].ExNGCount = structItem.ExNGCount7;

                            items[7].UnderCount = structItem.UnderCount8;
                            items[7].PassCount = structItem.PassCount8;
                            items[7].OverCount = structItem.OverCount8;
                            items[7].ExNGCount = structItem.ExNGCount8;
                            break;
                        case 10:
                            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;

                            items[6].UnderCount = structItem.UnderCount7;
                            items[6].PassCount = structItem.PassCount7;
                            items[6].OverCount = structItem.OverCount7;
                            items[6].ExNGCount = structItem.ExNGCount7;

                            items[7].UnderCount = structItem.UnderCount8;
                            items[7].PassCount = structItem.PassCount8;
                            items[7].OverCount = structItem.OverCount8;
                            items[7].ExNGCount = structItem.ExNGCount8;

                            items[8].UnderCount = structItem.UnderCount9;
                            items[8].PassCount = structItem.PassCount9;
                            items[8].OverCount = structItem.OverCount9;
                            items[8].ExNGCount = structItem.ExNGCount9;

                            items[9].UnderCount = structItem.UnderCount10;
                            items[9].PassCount = structItem.PassCount10;
                            items[9].OverCount = structItem.OverCount10;
                            items[9].ExNGCount = structItem.ExNGCount10;
                            break;
                        case 12:
                        case 15:
                        case 16:
                            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;

                            items[6].UnderCount = structItem.UnderCount7;
                            items[6].PassCount = structItem.PassCount7;
                            items[6].OverCount = structItem.OverCount7;
                            items[6].ExNGCount = structItem.ExNGCount7;

                            items[7].UnderCount = structItem.UnderCount8;
                            items[7].PassCount = structItem.PassCount8;
                            items[7].OverCount = structItem.OverCount8;
                            items[7].ExNGCount = structItem.ExNGCount8;

                            items[8].UnderCount = structItem.UnderCount9;
                            items[8].PassCount = structItem.PassCount9;
                            items[8].OverCount = structItem.OverCount9;
                            items[8].ExNGCount = structItem.ExNGCount9;

                            items[9].UnderCount = structItem.UnderCount10;
                            items[9].PassCount = structItem.PassCount10;
                            items[9].OverCount = structItem.OverCount10;
                            items[9].ExNGCount = structItem.ExNGCount10;

                            items[10].UnderCount = structItem.UnderCount11;
                            items[10].PassCount = structItem.PassCount11;
                            items[10].OverCount = structItem.OverCount11;
                            items[10].ExNGCount = structItem.ExNGCount11;

                            items[11].UnderCount = structItem.UnderCount12;
                            items[11].PassCount = structItem.PassCount12;
                            items[11].OverCount = structItem.OverCount12;
                            items[11].ExNGCount = structItem.ExNGCount12;
                            break;
                        default:
                            break;
                    }
                }
            }
            catch
            {
                DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig.Language);
                myMsg.ShowDialog();

                this.smartFileIO.Close();
            }
            this.smartFileIO.Close();
        }
        #endregion
        #region Counter File2
        private void CreateCounterFile2()
        {
            StructCounter2 structItem;

            for (int i = 0; i < 1000; i++)
            {
                structItem.OverCount13 = 0;
                structItem.PassCount13 = 0;
                structItem.UnderCount13 = 0;
                structItem.ExNGCount13 = 0;

                structItem.OverCount14 = 0;
                structItem.PassCount14 = 0;
                structItem.UnderCount14 = 0;
                structItem.ExNGCount14 = 0;

                structItem.OverCount15 = 0;
                structItem.PassCount15 = 0;
                structItem.UnderCount15 = 0;
                structItem.ExNGCount15 = 0;

                structItem.OverCount16 = 0;
                structItem.PassCount16 = 0;
                structItem.UnderCount16 = 0;
                structItem.ExNGCount16 = 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;

                structItem.DummyInt11 = 0;
                structItem.DummyInt12 = 0;
                structItem.DummyInt13 = 0;
                structItem.DummyInt14 = 0;
                structItem.DummyInt15 = 0;
                structItem.DummyInt16 = 0;
                structItem.DummyInt17 = 0;
                structItem.DummyInt18 = 0;
                structItem.DummyInt19 = 0;
                structItem.DummyInt20 = 0;

                structItem.DummyInt21 = 0;
                structItem.DummyInt22 = 0;
                structItem.DummyInt23 = 0;
                structItem.DummyInt24 = 0;
                structItem.DummyInt25 = 0;
                structItem.DummyInt26 = 0;
                structItem.DummyInt27 = 0;
                structItem.DummyInt28 = 0;
                structItem.DummyInt29 = 0;
                structItem.DummyInt30 = 0;

                structItem.DummyInt31 = 0;
                structItem.DummyInt32 = 0;
                structItem.DummyInt33 = 0;
                structItem.DummyInt34 = 0;
                structItem.DummyInt35 = 0;
                structItem.DummyInt36 = 0;
                structItem.DummyInt37 = 0;
                structItem.DummyInt38 = 0;
                structItem.DummyInt39 = 0;
                structItem.DummyInt40 = 0;

                structItem.DummyInt41 = 0;
                structItem.DummyInt42 = 0;

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

            if (items.Count < 12)
                return;

            fullFilePath = this.PathSystemFileFolder + "counterItem2.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.CreateCounterFile2();
            }

            switch (this.SystemConfig.EquipmentColumns)
            {
                case 15:
                    structItem.OverCount13 = items[12].OverCount;
                    structItem.PassCount13 = items[12].PassCount;
                    structItem.UnderCount13 = items[12].UnderCount;
                    structItem.ExNGCount13 = items[12].ExNGCount;

                    structItem.OverCount14 = items[13].OverCount;
                    structItem.PassCount14 = items[13].PassCount;
                    structItem.UnderCount14 = items[13].UnderCount;
                    structItem.ExNGCount14 = items[13].ExNGCount;

                    structItem.OverCount15 = items[14].OverCount;
                    structItem.PassCount15 = items[14].PassCount;
                    structItem.UnderCount15 = items[14].UnderCount;
                    structItem.ExNGCount15 = items[14].ExNGCount;

                    structItem.OverCount16 = 0;
                    structItem.PassCount16 = 0;
                    structItem.UnderCount16 = 0;
                    structItem.ExNGCount16 = 0;
                    break;
                case 16:
                    structItem.OverCount13 = items[12].OverCount;
                    structItem.PassCount13 = items[12].PassCount;
                    structItem.UnderCount13 = items[12].UnderCount;
                    structItem.ExNGCount13 = items[12].ExNGCount;

                    structItem.OverCount14 = items[13].OverCount;
                    structItem.PassCount14 = items[13].PassCount;
                    structItem.UnderCount14 = items[13].UnderCount;
                    structItem.ExNGCount14 = items[13].ExNGCount;

                    structItem.OverCount15 = items[14].OverCount;
                    structItem.PassCount15 = items[14].PassCount;
                    structItem.UnderCount15 = items[14].UnderCount;
                    structItem.ExNGCount15 = items[14].ExNGCount;

                    structItem.OverCount16 = items[15].OverCount;
                    structItem.PassCount16 = items[15].PassCount;
                    structItem.UnderCount16 = items[15].UnderCount;
                    structItem.ExNGCount16 = items[15].ExNGCount;
                    break;
                default:
                    structItem.OverCount13 = 0;
                    structItem.PassCount13 = 0;
                    structItem.UnderCount13 = 0;
                    structItem.ExNGCount13 = 0;

                    structItem.OverCount14 = 0;
                    structItem.PassCount14 = 0;
                    structItem.UnderCount14 = 0;
                    structItem.ExNGCount14 = 0;

                    structItem.OverCount15 = 0;
                    structItem.PassCount15 = 0;
                    structItem.UnderCount15 = 0;
                    structItem.ExNGCount15 = 0;

                    structItem.OverCount16 = 0;
                    structItem.PassCount16 = 0;
                    structItem.UnderCount16 = 0;
                    structItem.ExNGCount16 = 0;
                    break;
            }

            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;

            structItem.DummyInt11 = 0;
            structItem.DummyInt12 = 0;
            structItem.DummyInt13 = 0;
            structItem.DummyInt14 = 0;
            structItem.DummyInt15 = 0;
            structItem.DummyInt16 = 0;
            structItem.DummyInt17 = 0;
            structItem.DummyInt18 = 0;
            structItem.DummyInt19 = 0;
            structItem.DummyInt20 = 0;

            structItem.DummyInt21 = 0;
            structItem.DummyInt22 = 0;
            structItem.DummyInt23 = 0;
            structItem.DummyInt24 = 0;
            structItem.DummyInt25 = 0;
            structItem.DummyInt26 = 0;
            structItem.DummyInt27 = 0;
            structItem.DummyInt28 = 0;
            structItem.DummyInt29 = 0;
            structItem.DummyInt30 = 0;

            structItem.DummyInt31 = 0;
            structItem.DummyInt32 = 0;
            structItem.DummyInt33 = 0;
            structItem.DummyInt34 = 0;
            structItem.DummyInt35 = 0;
            structItem.DummyInt36 = 0;
            structItem.DummyInt37 = 0;
            structItem.DummyInt38 = 0;
            structItem.DummyInt39 = 0;
            structItem.DummyInt40 = 0;

            structItem.DummyInt41 = 0;
            structItem.DummyInt42 = 0;

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

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

            if (items.Count < 12)
                return;

            fullFilePath = this.PathSystemFileFolder + "counterItem2.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.CreateCounterFile2();
            }

            try
            {
                if (this.smartFileIO.ReadStructureAllBuffer() == true)
                {
                    structItem = (StructCounter2)this.smartFileIO.ReadStructureBuffer(typeof(StructCounter2), index);

                    switch (this.SystemConfig.EquipmentColumns)
                    {
                        case 15:
                            items[12].UnderCount = structItem.UnderCount13;
                            items[12].PassCount = structItem.PassCount13;
                            items[12].OverCount = structItem.OverCount13;
                            items[12].ExNGCount = structItem.ExNGCount13;

                            items[13].UnderCount = structItem.UnderCount14;
                            items[13].PassCount = structItem.PassCount14;
                            items[13].OverCount = structItem.OverCount14;
                            items[13].ExNGCount = structItem.ExNGCount14;

                            items[14].UnderCount = structItem.UnderCount15;
                            items[14].PassCount = structItem.PassCount15;
                            items[14].OverCount = structItem.OverCount15;
                            items[14].ExNGCount = structItem.ExNGCount15;
                            break;
                        case 16:
                            items[12].UnderCount = structItem.UnderCount13;
                            items[12].PassCount = structItem.PassCount13;
                            items[12].OverCount = structItem.OverCount13;
                            items[12].ExNGCount = structItem.ExNGCount13;

                            items[13].UnderCount = structItem.UnderCount14;
                            items[13].PassCount = structItem.PassCount14;
                            items[13].OverCount = structItem.OverCount14;
                            items[13].ExNGCount = structItem.ExNGCount14;

                            items[14].UnderCount = structItem.UnderCount15;
                            items[14].PassCount = structItem.PassCount15;
                            items[14].OverCount = structItem.OverCount15;
                            items[14].ExNGCount = structItem.ExNGCount15;

                            items[15].UnderCount = structItem.UnderCount16;
                            items[15].PassCount = structItem.PassCount16;
                            items[15].OverCount = structItem.OverCount16;
                            items[15].ExNGCount = structItem.ExNGCount16;
                            break;
                        default:
                            break;
                    }
                }
            }
            catch
            {
                DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig.Language);
                myMsg.ShowDialog();

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

        #region UserGroupFile
        private void CreateUserGroupFile()
        {
            StructUserGroupItem structItem;
            UserGroupItem item = new UserGroupItem();

            #region Level1
            structItem.IsMainDisplayProductNo = true;
            structItem.IsMainDisplayWeightSetting = false;
            structItem.IsMainDisplayClear = true;
            structItem.IsMainDispalySubMenu = false;

            structItem.IsMenuTimeSetting = false;
            structItem.IsMenuInformation = true;
            structItem.IsMenuDataBackup = true;
            structItem.IsMenuCalibration = false;
            structItem.IsMenuCommunication = false;
            structItem.IsMenuConfiguration = false;
            structItem.IsMenuSystemSetting = false;
            structItem.IsMenuMotorSetting = false;
            structItem.IsMenuUpdate = false;
            structItem.IsMenuFactoryReset = false;
            structItem.IsMenuEquipmentSetting = false;
            structItem.IsMenuIOTest = false;
            structItem.IsMenuDataStatistics = true;
            structItem.IsMenuUserSetting = true;
            structItem.IsMenuUserGroupSetting = false;
            structItem.IsMenuDataViewer = false;

            structItem.Dummy1 = false;
            structItem.Dummy2 = false;
            structItem.Dummy3 = false;
            structItem.Dummy4 = false;
            structItem.Dummy5 = false;
            structItem.Dummy6 = false;
            structItem.Dummy7 = false;
            structItem.Dummy8 = false;
            structItem.Dummy9 = false;
            structItem.Dummy10 = false;
            structItem.Dummy11 = false;
            structItem.Dummy12 = false;
            structItem.Dummy13 = false;
            structItem.Dummy14 = false;
            structItem.Dummy15 = false;
            structItem.Dummy16 = false;
            structItem.Dummy17 = false;
            structItem.Dummy18 = false;
            structItem.Dummy19 = false;
            structItem.Dummy20 = false;

            this.smartFileIO.WriteStructure_Begin(structItem, 0);
            #endregion

            #region Level2
            structItem.IsMainDisplayProductNo = true;
            structItem.IsMainDisplayWeightSetting = true;
            structItem.IsMainDisplayClear = true;
            structItem.IsMainDispalySubMenu = true;

            structItem.IsMenuTimeSetting = false;
            structItem.IsMenuInformation = true;
            structItem.IsMenuDataBackup = true;
            structItem.IsMenuCalibration = true;
            structItem.IsMenuCommunication = false;
            structItem.IsMenuConfiguration = false;
            structItem.IsMenuSystemSetting = true;
            structItem.IsMenuMotorSetting = false;
            structItem.IsMenuUpdate = false;
            structItem.IsMenuFactoryReset = false;
            structItem.IsMenuEquipmentSetting = false;
            structItem.IsMenuIOTest = false;
            structItem.IsMenuDataStatistics = true;
            structItem.IsMenuUserSetting = true;
            structItem.IsMenuUserGroupSetting = false;
            structItem.IsMenuDataViewer = true;

            structItem.Dummy1 = false;
            structItem.Dummy2 = false;
            structItem.Dummy3 = false;
            structItem.Dummy4 = false;
            structItem.Dummy5 = false;
            structItem.Dummy6 = false;
            structItem.Dummy7 = false;
            structItem.Dummy8 = false;
            structItem.Dummy9 = false;
            structItem.Dummy10 = false;
            structItem.Dummy11 = false;
            structItem.Dummy12 = false;
            structItem.Dummy13 = false;
            structItem.Dummy14 = false;
            structItem.Dummy15 = false;
            structItem.Dummy16 = false;
            structItem.Dummy17 = false;
            structItem.Dummy18 = false;
            structItem.Dummy19 = false;
            structItem.Dummy20 = false;

            this.smartFileIO.WriteStructure_Begin(structItem, 1);
            #endregion

            #region Level3
            structItem.IsMainDisplayProductNo = true;
            structItem.IsMainDisplayWeightSetting = true;
            structItem.IsMainDisplayClear = true;
            structItem.IsMainDispalySubMenu = true;

            structItem.IsMenuTimeSetting = true;
            structItem.IsMenuInformation = true;
            structItem.IsMenuDataBackup = true;
            structItem.IsMenuCalibration = true;
            structItem.IsMenuCommunication = true;
            structItem.IsMenuConfiguration = true;
            structItem.IsMenuSystemSetting = true;
            structItem.IsMenuMotorSetting = true;
            structItem.IsMenuUpdate = true;
            structItem.IsMenuFactoryReset = true;
            structItem.IsMenuEquipmentSetting = true;
            structItem.IsMenuIOTest = true;
            structItem.IsMenuDataStatistics = true;
            structItem.IsMenuUserSetting = true;
            structItem.IsMenuUserGroupSetting = true;
            structItem.IsMenuDataViewer = true;

            structItem.Dummy1 = false;
            structItem.Dummy2 = false;
            structItem.Dummy3 = false;
            structItem.Dummy4 = false;
            structItem.Dummy5 = false;
            structItem.Dummy6 = false;
            structItem.Dummy7 = false;
            structItem.Dummy8 = false;
            structItem.Dummy9 = false;
            structItem.Dummy10 = false;
            structItem.Dummy11 = false;
            structItem.Dummy12 = false;
            structItem.Dummy13 = false;
            structItem.Dummy14 = false;
            structItem.Dummy15 = false;
            structItem.Dummy16 = false;
            structItem.Dummy17 = false;
            structItem.Dummy18 = false;
            structItem.Dummy19 = false;
            structItem.Dummy20 = false;

            this.smartFileIO.WriteStructure_Begin(structItem, 2);
            #endregion

            #region NotLogin
            structItem.IsMainDisplayProductNo = true;
            structItem.IsMainDisplayWeightSetting = true;
            structItem.IsMainDisplayClear = true;
            structItem.IsMainDispalySubMenu = true;

            structItem.IsMenuTimeSetting = true;
            structItem.IsMenuInformation = true;
            structItem.IsMenuDataBackup = true;
            structItem.IsMenuCalibration = true;
            structItem.IsMenuCommunication = true;
            structItem.IsMenuConfiguration = true;
            structItem.IsMenuSystemSetting = true;
            structItem.IsMenuMotorSetting = true;
            structItem.IsMenuUpdate = true;
            structItem.IsMenuFactoryReset = true;
            structItem.IsMenuEquipmentSetting = true;
            structItem.IsMenuIOTest = true;
            structItem.IsMenuDataStatistics = false;
            structItem.IsMenuUserSetting = false;
            structItem.IsMenuUserGroupSetting = false;
            structItem.IsMenuDataViewer = false;

            structItem.Dummy1 = false;
            structItem.Dummy2 = false;
            structItem.Dummy3 = false;
            structItem.Dummy4 = false;
            structItem.Dummy5 = false;
            structItem.Dummy6 = false;
            structItem.Dummy7 = false;
            structItem.Dummy8 = false;
            structItem.Dummy9 = false;
            structItem.Dummy10 = false;
            structItem.Dummy11 = false;
            structItem.Dummy12 = false;
            structItem.Dummy13 = false;
            structItem.Dummy14 = false;
            structItem.Dummy15 = false;
            structItem.Dummy16 = false;
            structItem.Dummy17 = false;
            structItem.Dummy18 = false;
            structItem.Dummy19 = false;
            structItem.Dummy20 = false;

            this.smartFileIO.WriteStructure_Begin(structItem, 3);
            #endregion

            this.smartFileIO.WriteStructure_End();
        }
        public void SaveUserGroupFile(UserGroup item)
        {
            string fullFilePath = "";
            bool fileCheck = false;
            StructUserGroupItem structItem;

            fullFilePath = this.PathSystemFileFolder + "UserGroup.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.CreateUserGroupFile();
            }

            #region Level1
            structItem.IsMainDisplayProductNo = item.Level1.IsMainDisplayProductNo;
            structItem.IsMainDisplayWeightSetting = item.Level1.IsMainDisplayWeightSetting;
            structItem.IsMainDisplayClear = item.Level1.IsMainDisplayClear;
            structItem.IsMainDispalySubMenu = item.Level1.IsMainDisplaySubMenu;

            structItem.IsMenuTimeSetting = item.Level1.IsMenuTime;
            structItem.IsMenuInformation = item.Level1.IsMenuInformation;
            structItem.IsMenuDataBackup = item.Level1.IsMenuDataBackup;
            structItem.IsMenuCalibration = item.Level1.IsMenuCalibration;
            structItem.IsMenuCommunication = item.Level1.IsMenuCommunication;
            structItem.IsMenuConfiguration = item.Level1.IsMenuConfiguration;
            structItem.IsMenuSystemSetting = item.Level1.IsMenuSystem;
            structItem.IsMenuMotorSetting = item.Level1.IsMenuMotor;
            structItem.IsMenuUpdate = item.Level1.IsMenuUpdate;
            structItem.IsMenuFactoryReset = item.Level1.IsMenuInitialization;
            structItem.IsMenuEquipmentSetting = item.Level1.IsMenuEquipment;
            structItem.IsMenuIOTest = item.Level1.IsMenuIOTest;
            structItem.IsMenuDataStatistics = item.Level1.IsMenuStatistics;
            structItem.IsMenuUserSetting = item.Level1.IsMenuUser;
            structItem.IsMenuUserGroupSetting = item.Level1.IsMenuUserGroupEditor;
            structItem.IsMenuDataViewer = item.Level1.IsMenuViewer;

            structItem.Dummy1 = false;
            structItem.Dummy2 = false;
            structItem.Dummy3 = false;
            structItem.Dummy4 = false;
            structItem.Dummy5 = false;
            structItem.Dummy6 = false;
            structItem.Dummy7 = false;
            structItem.Dummy8 = false;
            structItem.Dummy9 = false;
            structItem.Dummy10 = false;
            structItem.Dummy11 = false;
            structItem.Dummy12 = false;
            structItem.Dummy13 = false;
            structItem.Dummy14 = false;
            structItem.Dummy15 = false;
            structItem.Dummy16 = false;
            structItem.Dummy17 = false;
            structItem.Dummy18 = false;
            structItem.Dummy19 = false;
            structItem.Dummy20 = false;

            this.smartFileIO.WriteStructure_Begin(structItem, (int)DataStore.E_UserGroup_FileIndex.f0_Level1);
            #endregion

            #region Level2
            structItem.IsMainDisplayProductNo = item.Level2.IsMainDisplayProductNo;
            structItem.IsMainDisplayWeightSetting = item.Level2.IsMainDisplayWeightSetting;
            structItem.IsMainDisplayClear = item.Level2.IsMainDisplayClear;
            structItem.IsMainDispalySubMenu = item.Level2.IsMainDisplaySubMenu;

            structItem.IsMenuTimeSetting = item.Level2.IsMenuTime;
            structItem.IsMenuInformation = item.Level2.IsMenuInformation;
            structItem.IsMenuDataBackup = item.Level2.IsMenuDataBackup;
            structItem.IsMenuCalibration = item.Level2.IsMenuCalibration;
            structItem.IsMenuCommunication = item.Level2.IsMenuCommunication;
            structItem.IsMenuConfiguration = item.Level2.IsMenuConfiguration;
            structItem.IsMenuSystemSetting = item.Level2.IsMenuSystem;
            structItem.IsMenuMotorSetting = item.Level2.IsMenuMotor;
            structItem.IsMenuUpdate = item.Level2.IsMenuUpdate;
            structItem.IsMenuFactoryReset = item.Level2.IsMenuInitialization;
            structItem.IsMenuEquipmentSetting = item.Level2.IsMenuEquipment;
            structItem.IsMenuIOTest = item.Level2.IsMenuIOTest;
            structItem.IsMenuDataStatistics = item.Level2.IsMenuStatistics;
            structItem.IsMenuUserSetting = item.Level2.IsMenuUser;
            structItem.IsMenuUserGroupSetting = item.Level2.IsMenuUserGroupEditor;
            structItem.IsMenuDataViewer = item.Level2.IsMenuViewer;

            structItem.Dummy1 = false;
            structItem.Dummy2 = false;
            structItem.Dummy3 = false;
            structItem.Dummy4 = false;
            structItem.Dummy5 = false;
            structItem.Dummy6 = false;
            structItem.Dummy7 = false;
            structItem.Dummy8 = false;
            structItem.Dummy9 = false;
            structItem.Dummy10 = false;
            structItem.Dummy11 = false;
            structItem.Dummy12 = false;
            structItem.Dummy13 = false;
            structItem.Dummy14 = false;
            structItem.Dummy15 = false;
            structItem.Dummy16 = false;
            structItem.Dummy17 = false;
            structItem.Dummy18 = false;
            structItem.Dummy19 = false;
            structItem.Dummy20 = false;

            this.smartFileIO.WriteStructure_Begin(structItem, (int)DataStore.E_UserGroup_FileIndex.f1_Level2);
            #endregion

            #region Level3
            structItem.IsMainDisplayProductNo = item.Level3.IsMainDisplayProductNo;
            structItem.IsMainDisplayWeightSetting = item.Level3.IsMainDisplayWeightSetting;
            structItem.IsMainDisplayClear = item.Level3.IsMainDisplayClear;
            structItem.IsMainDispalySubMenu = item.Level3.IsMainDisplaySubMenu;

            structItem.IsMenuTimeSetting = item.Level3.IsMenuTime;
            structItem.IsMenuInformation = item.Level3.IsMenuInformation;
            structItem.IsMenuDataBackup = item.Level3.IsMenuDataBackup;
            structItem.IsMenuCalibration = item.Level3.IsMenuCalibration;
            structItem.IsMenuCommunication = item.Level3.IsMenuCommunication;
            structItem.IsMenuConfiguration = item.Level3.IsMenuConfiguration;
            structItem.IsMenuSystemSetting = item.Level3.IsMenuSystem;
            structItem.IsMenuMotorSetting = item.Level3.IsMenuMotor;
            structItem.IsMenuUpdate = item.Level3.IsMenuUpdate;
            structItem.IsMenuFactoryReset = item.Level3.IsMenuInitialization;
            structItem.IsMenuEquipmentSetting = item.Level3.IsMenuEquipment;
            structItem.IsMenuIOTest = item.Level3.IsMenuIOTest;
            structItem.IsMenuDataStatistics = item.Level3.IsMenuStatistics;
            structItem.IsMenuUserSetting = item.Level3.IsMenuUser;
            structItem.IsMenuUserGroupSetting = item.Level3.IsMenuUserGroupEditor;
            structItem.IsMenuDataViewer = item.Level3.IsMenuViewer;

            structItem.Dummy1 = false;
            structItem.Dummy2 = false;
            structItem.Dummy3 = false;
            structItem.Dummy4 = false;
            structItem.Dummy5 = false;
            structItem.Dummy6 = false;
            structItem.Dummy7 = false;
            structItem.Dummy8 = false;
            structItem.Dummy9 = false;
            structItem.Dummy10 = false;
            structItem.Dummy11 = false;
            structItem.Dummy12 = false;
            structItem.Dummy13 = false;
            structItem.Dummy14 = false;
            structItem.Dummy15 = false;
            structItem.Dummy16 = false;
            structItem.Dummy17 = false;
            structItem.Dummy18 = false;
            structItem.Dummy19 = false;
            structItem.Dummy20 = false;

            this.smartFileIO.WriteStructure_Begin(structItem, (int)DataStore.E_UserGroup_FileIndex.f2_Level3);
            #endregion

            #region NotLogin
            structItem.IsMainDisplayProductNo = item.NotLogin.IsMainDisplayProductNo;
            structItem.IsMainDisplayWeightSetting = item.NotLogin.IsMainDisplayWeightSetting;
            structItem.IsMainDisplayClear = item.NotLogin.IsMainDisplayClear;
            structItem.IsMainDispalySubMenu = item.NotLogin.IsMainDisplaySubMenu;

            structItem.IsMenuTimeSetting = item.NotLogin.IsMenuTime;
            structItem.IsMenuInformation = item.NotLogin.IsMenuInformation;
            structItem.IsMenuDataBackup = item.NotLogin.IsMenuDataBackup;
            structItem.IsMenuCalibration = item.NotLogin.IsMenuCalibration;
            structItem.IsMenuCommunication = item.NotLogin.IsMenuCommunication;
            structItem.IsMenuConfiguration = item.NotLogin.IsMenuConfiguration;
            structItem.IsMenuSystemSetting = item.NotLogin.IsMenuSystem;
            structItem.IsMenuMotorSetting = item.NotLogin.IsMenuMotor;
            structItem.IsMenuUpdate = item.NotLogin.IsMenuUpdate;
            structItem.IsMenuFactoryReset = item.NotLogin.IsMenuInitialization;
            structItem.IsMenuEquipmentSetting = item.NotLogin.IsMenuEquipment;
            structItem.IsMenuIOTest = item.NotLogin.IsMenuIOTest;
            structItem.IsMenuDataStatistics = item.NotLogin.IsMenuStatistics;
            structItem.IsMenuUserSetting = item.NotLogin.IsMenuUser;
            structItem.IsMenuUserGroupSetting = item.NotLogin.IsMenuUserGroupEditor;
            structItem.IsMenuDataViewer = item.NotLogin.IsMenuViewer;

            structItem.Dummy1 = false;
            structItem.Dummy2 = false;
            structItem.Dummy3 = false;
            structItem.Dummy4 = false;
            structItem.Dummy5 = false;
            structItem.Dummy6 = false;
            structItem.Dummy7 = false;
            structItem.Dummy8 = false;
            structItem.Dummy9 = false;
            structItem.Dummy10 = false;
            structItem.Dummy11 = false;
            structItem.Dummy12 = false;
            structItem.Dummy13 = false;
            structItem.Dummy14 = false;
            structItem.Dummy15 = false;
            structItem.Dummy16 = false;
            structItem.Dummy17 = false;
            structItem.Dummy18 = false;
            structItem.Dummy19 = false;
            structItem.Dummy20 = false;

            this.smartFileIO.WriteStructure_Begin(structItem, (int)DataStore.E_UserGroup_FileIndex.f3_NotLogin);
            #endregion

            this.smartFileIO.WriteStructure_End();
            this.smartFileIO.Close();
        }
        private void LoadUserGroupFile(ref UserGroup item)
        {
            string fullFilePath = "";
            bool fileCheck = false;
            StructUserGroupItem structItem;

            fullFilePath = this.PathSystemFileFolder + "UserGroup.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.CreateUserGroupFile();
            }

            try
            {
                if (this.smartFileIO.ReadStructureAllBuffer() == true)
                {
                    #region Level1
                    structItem = (StructUserGroupItem)this.smartFileIO.ReadStructureBuffer(typeof(StructUserGroupItem), (int)DataStore.E_UserGroup_FileIndex.f0_Level1);

                    item.Level1.IsMainDisplayProductNo = structItem.IsMainDisplayProductNo;
                    item.Level1.IsMainDisplayWeightSetting = structItem.IsMainDisplayWeightSetting;
                    item.Level1.IsMainDisplayClear = structItem.IsMainDisplayClear;
                    item.Level1.IsMainDisplaySubMenu = structItem.IsMainDispalySubMenu;

                    item.Level1.IsMenuTime = structItem.IsMenuTimeSetting;
                    item.Level1.IsMenuInformation = structItem.IsMenuInformation;
                    item.Level1.IsMenuDataBackup = structItem.IsMenuDataBackup;
                    item.Level1.IsMenuCalibration = structItem.IsMenuCalibration;
                    item.Level1.IsMenuCommunication = structItem.IsMenuCommunication;
                    item.Level1.IsMenuConfiguration = structItem.IsMenuConfiguration;
                    item.Level1.IsMenuSystem = structItem.IsMenuSystemSetting;
                    item.Level1.IsMenuMotor = structItem.IsMenuMotorSetting;
                    item.Level1.IsMenuUpdate = structItem.IsMenuUpdate;
                    item.Level1.IsMenuInitialization = structItem.IsMenuFactoryReset;
                    item.Level1.IsMenuEquipment = structItem.IsMenuEquipmentSetting;
                    item.Level1.IsMenuIOTest = structItem.IsMenuIOTest;
                    item.Level1.IsMenuStatistics = structItem.IsMenuDataStatistics;
                    item.Level1.IsMenuUser = true;
                    item.Level1.IsMenuUserGroupEditor = structItem.IsMenuUserGroupSetting;
                    item.Level1.IsMenuViewer = structItem.IsMenuDataViewer;
                    #endregion

                    #region Level2
                    structItem = (StructUserGroupItem)this.smartFileIO.ReadStructureBuffer(typeof(StructUserGroupItem), (int)DataStore.E_UserGroup_FileIndex.f1_Level2);

                    item.Level2.IsMainDisplayProductNo = structItem.IsMainDisplayProductNo;
                    item.Level2.IsMainDisplayWeightSetting = structItem.IsMainDisplayWeightSetting;
                    item.Level2.IsMainDisplayClear = structItem.IsMainDisplayClear;
                    item.Level2.IsMainDisplaySubMenu = structItem.IsMainDispalySubMenu;

                    item.Level2.IsMenuTime = structItem.IsMenuTimeSetting;
                    item.Level2.IsMenuInformation = structItem.IsMenuInformation;
                    item.Level2.IsMenuDataBackup = structItem.IsMenuDataBackup;
                    item.Level2.IsMenuCalibration = structItem.IsMenuCalibration;
                    item.Level2.IsMenuCommunication = structItem.IsMenuCommunication;
                    item.Level2.IsMenuConfiguration = structItem.IsMenuConfiguration;
                    item.Level2.IsMenuSystem = structItem.IsMenuSystemSetting;
                    item.Level2.IsMenuMotor = structItem.IsMenuMotorSetting;
                    item.Level2.IsMenuUpdate = structItem.IsMenuUpdate;
                    item.Level2.IsMenuInitialization = structItem.IsMenuFactoryReset;
                    item.Level2.IsMenuEquipment = structItem.IsMenuEquipmentSetting;
                    item.Level2.IsMenuIOTest = structItem.IsMenuIOTest;
                    item.Level2.IsMenuStatistics = structItem.IsMenuDataStatistics;
                    item.Level2.IsMenuUser = true;
                    item.Level2.IsMenuUserGroupEditor = structItem.IsMenuUserGroupSetting;
                    item.Level2.IsMenuViewer = structItem.IsMenuDataViewer;
                    #endregion

                    #region Level3
                    structItem = (StructUserGroupItem)this.smartFileIO.ReadStructureBuffer(typeof(StructUserGroupItem), (int)DataStore.E_UserGroup_FileIndex.f2_Level3);

                    item.Level3.IsMainDisplayProductNo = structItem.IsMainDisplayProductNo;
                    item.Level3.IsMainDisplayWeightSetting = structItem.IsMainDisplayWeightSetting;
                    item.Level3.IsMainDisplayClear = structItem.IsMainDisplayClear;
                    item.Level3.IsMainDisplaySubMenu = structItem.IsMainDispalySubMenu;

                    item.Level3.IsMenuTime = structItem.IsMenuTimeSetting;
                    item.Level3.IsMenuInformation = structItem.IsMenuInformation;
                    item.Level3.IsMenuDataBackup = structItem.IsMenuDataBackup;
                    item.Level3.IsMenuCalibration = structItem.IsMenuCalibration;
                    item.Level3.IsMenuCommunication = structItem.IsMenuCommunication;
                    item.Level3.IsMenuConfiguration = structItem.IsMenuConfiguration;
                    item.Level3.IsMenuSystem = structItem.IsMenuSystemSetting;
                    item.Level3.IsMenuMotor = structItem.IsMenuMotorSetting;
                    item.Level3.IsMenuUpdate = structItem.IsMenuUpdate;
                    item.Level3.IsMenuInitialization = structItem.IsMenuFactoryReset;
                    item.Level3.IsMenuEquipment = structItem.IsMenuEquipmentSetting;
                    item.Level3.IsMenuIOTest = structItem.IsMenuIOTest;
                    item.Level3.IsMenuStatistics = structItem.IsMenuDataStatistics;
                    item.Level3.IsMenuUser = true;
                    item.Level3.IsMenuUserGroupEditor = structItem.IsMenuUserGroupSetting;
                    item.Level3.IsMenuViewer = structItem.IsMenuDataViewer;
                    #endregion

                    #region NotLogin
                    structItem = (StructUserGroupItem)this.smartFileIO.ReadStructureBuffer(typeof(StructUserGroupItem), (int)DataStore.E_UserGroup_FileIndex.f3_NotLogin);

                    item.NotLogin.IsMainDisplayProductNo = structItem.IsMainDisplayProductNo;
                    item.NotLogin.IsMainDisplayWeightSetting = structItem.IsMainDisplayWeightSetting;
                    item.NotLogin.IsMainDisplayClear = structItem.IsMainDisplayClear;
                    item.NotLogin.IsMainDisplaySubMenu = structItem.IsMainDispalySubMenu;

                    item.NotLogin.IsMenuTime = structItem.IsMenuTimeSetting;
                    item.NotLogin.IsMenuInformation = structItem.IsMenuInformation;
                    item.NotLogin.IsMenuDataBackup = structItem.IsMenuDataBackup;
                    item.NotLogin.IsMenuCalibration = structItem.IsMenuCalibration;
                    item.NotLogin.IsMenuCommunication = structItem.IsMenuCommunication;
                    item.NotLogin.IsMenuConfiguration = structItem.IsMenuConfiguration;
                    item.NotLogin.IsMenuSystem = structItem.IsMenuSystemSetting;
                    item.NotLogin.IsMenuMotor = structItem.IsMenuMotorSetting;
                    item.NotLogin.IsMenuUpdate = structItem.IsMenuUpdate;
                    item.NotLogin.IsMenuInitialization = structItem.IsMenuFactoryReset;
                    item.NotLogin.IsMenuEquipment = structItem.IsMenuEquipmentSetting;
                    item.NotLogin.IsMenuIOTest = structItem.IsMenuIOTest;
                    item.NotLogin.IsMenuStatistics = structItem.IsMenuDataStatistics;
                    item.NotLogin.IsMenuUser = false;
                    item.NotLogin.IsMenuUserGroupEditor = structItem.IsMenuUserGroupSetting;
                    item.NotLogin.IsMenuViewer = structItem.IsMenuDataViewer;
                    #endregion
                }
            }
            catch
            {
                DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig.Language);
                myMsg.ShowDialog();

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

        #region Communication Protocol
        private string Protocol_STD1_NotStxEtx(SystemConfigurationItem system, Collection<WeightData> datas)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(string.Format("IN{0:D3}", system.UsbID));
            sb.Append(string.Format("{0:D4}", system.ProductNumber));

            for (int i = 0; i < system.EquipmentColumns; i++)
            {
                if (datas[i].JudgmentStatus == DataStore.JudgmentStatus.Under)
                    sb.Append("U");
                else if (datas[i].JudgmentStatus == DataStore.JudgmentStatus.Over)
                    sb.Append("O");
                else if (datas[i].JudgmentStatus == DataStore.JudgmentStatus.Double)
                    sb.Append("D");
                else if (datas[i].JudgmentStatus == DataStore.JudgmentStatus.Pass)
                    sb.Append("P");
                else if (datas[i].JudgmentStatus == DataStore.JudgmentStatus.Empty)
                    sb.Append("T");
                else
                    sb.Append("E");

                if (this.SystemConfig.EquipmentColumns == 16)
                    sb.Append(" ");

                sb.Append(Helper.StringBlankFillDigits6(Helper.DoubleToString(datas[i].Weight, system.DecimalPlaces)));
            }

            return sb.ToString();
        }
        public string Protocol_STD1(SystemConfigurationItem system, Collection<WeightData> datas)
        {
            StringBuilder sb = new StringBuilder();

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

            return sb.ToString();
        }

        private string Protocol_STD2_NotStxEtx(SystemConfigurationItem system, Collection<WeightData> datas, ProductItem pItem)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(string.Format("IN{0:D3}", system.UsbID));
            sb.Append(string.Format("{0:D4}", system.ProductNumber));
            sb.Append(Helper.StringBlankFillDigits6(Helper.StringToDecimalPlaces(pItem.UnderRange, system.DecimalPlaces)));
            sb.Append(Helper.StringBlankFillDigits6(Helper.StringToDecimalPlaces(pItem.PassRange, system.DecimalPlaces)));
            sb.Append(Helper.StringBlankFillDigits6(Helper.StringToDecimalPlaces(pItem.OverRange, system.DecimalPlaces)));
            sb.Append(Helper.StringBlankFillDigits6(Helper.StringToDecimalPlaces(pItem.TareRange, system.DecimalPlaces)));

            for (int i = 0; i < system.EquipmentColumns; i++)
            {
                if (datas[i].JudgmentStatus == DataStore.JudgmentStatus.Under)
                    sb.Append("U");
                else if (datas[i].JudgmentStatus == DataStore.JudgmentStatus.Over)
                    sb.Append("O");
                else if (datas[i].JudgmentStatus == DataStore.JudgmentStatus.Double)
                    sb.Append("D");
                else if (datas[i].JudgmentStatus == DataStore.JudgmentStatus.Pass)
                    sb.Append("P");
                else if (datas[i].JudgmentStatus == DataStore.JudgmentStatus.Empty)
                    sb.Append("T");
                else
                    sb.Append("E");

                if (this.SystemConfig.EquipmentColumns == 16)
                    sb.Append(" ");

                sb.Append(Helper.StringBlankFillDigits6(Helper.DoubleToString(datas[i].Weight, system.DecimalPlaces)));
            }

            return sb.ToString();
        }
        public string Protocol_STD2(SystemConfigurationItem system, Collection<WeightData> datas, ProductItem pItem)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append((char)0x02);
            sb.Append(this.Protocol_STD2_NotStxEtx(system, datas, pItem));
            sb.Append((char)0x03);

            return sb.ToString();
        }

        private string Protocol_STD3_NotStxEtx(SystemConfigurationItem system, Collection<WeightData> datas, ProductItem pItem)
        {
            string value = "";
            int toTalPass = 0, toTalNG = 0;
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < this.SystemConfig.EquipmentColumns; i++)
            {
                toTalPass += datas[i].PassCount;
                toTalNG += datas[i].TotalNGCount;
            }

            sb.Append(string.Format("IN{0:D3}", this.SystemConfig.UsbID));
            sb.Append(string.Format("{0:D4}", this.SystemConfig.ProductNumber));
            sb.Append(this.PadLeft(6, Helper.StringToDecimalPlaces(this.CurrentProductItem.UnderRange, this.SystemConfig.DecimalPlaces)));
            sb.Append(this.PadLeft(6, Helper.StringToDecimalPlaces(this.CurrentProductItem.PassRange, this.SystemConfig.DecimalPlaces)));
            sb.Append(this.PadLeft(6, Helper.StringToDecimalPlaces(this.CurrentProductItem.OverRange, this.SystemConfig.DecimalPlaces)));
            sb.Append(this.PadLeft(6, Helper.StringToDecimalPlaces(this.CurrentProductItem.TareRange, this.SystemConfig.DecimalPlaces)));
            sb.Append(this.PadLeft(7, toTalPass.ToString()));
            sb.Append(this.PadLeft(7, toTalNG.ToString()));

            for (int i = 0; i < this.SystemConfig.EquipmentColumns; i++)
            {
                if (datas[i].JudgmentStatus == DataStore.JudgmentStatus.Under)
                    sb.Append("U");
                else if (datas[i].JudgmentStatus == DataStore.JudgmentStatus.Over)
                    sb.Append("O");
                else if (datas[i].JudgmentStatus == DataStore.JudgmentStatus.Double)
                    sb.Append("D");
                else if (datas[i].JudgmentStatus == DataStore.JudgmentStatus.Pass)
                    sb.Append("P");
                else if (datas[i].JudgmentStatus == DataStore.JudgmentStatus.Empty)
                    sb.Append("T");
                else
                    sb.Append("E");

                if (this.SystemConfig.EquipmentColumns == 16)
                    sb.Append(" ");

                value = Helper.DoubleToString(datas[i].Weight, this.SystemConfig.DecimalPlaces);
                sb.Append(value.PadLeft(6, ' '));
            }

            return sb.ToString();
        }
        public string Protocol_STD3(SystemConfigurationItem system, Collection<WeightData> datas, ProductItem pItem)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append((char)0x02);
            sb.Append(this.Protocol_STD3_NotStxEtx(system, datas, pItem));
            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].Weight);
            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];

            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];

            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;

                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.UnderRange_High:
                            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:
                            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:
                            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:
                            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:
                            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:
                            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:
                            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:
                            length4Value = GetBytes((Single)tareValue);
                            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:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[0].Weight);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_Weight_Low:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[0].Weight);
                            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;
                        #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].Weight);
                            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].Weight);
                            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;
                        #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].Weight);
                            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].Weight);
                            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;
                        #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].Weight);
                            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].Weight);
                            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;
                        #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].Weight);
                            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].Weight);
                            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;
                        #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].Weight);
                            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].Weight);
                            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;
                        #endregion

                        #region #7
                        case (int)ModbusDefine._30000_Modbus._7_Update:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[6].Update);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._7_Grade:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[6].Grade);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._7_Weight_High:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[6].Weight);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._7_Weight_Low:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[6].Weight);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._7_UnderCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[6].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._7_UnderCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[6].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._7_PassCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[6].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._7_PassCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[6].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._7_OverCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[6].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._7_OverCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[6].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._7_NGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[6].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._7_NgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[6].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._7_ExNGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[6].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._7_ExNgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[6].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._7_TotalCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[6].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._7_TotalCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[6].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        #endregion

                        #region #8
                        case (int)ModbusDefine._30000_Modbus._8_Update:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[7].Update);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._8_Grade:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[7].Grade);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._8_Weight_High:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[7].Weight);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._8_Weight_Low:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[7].Weight);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._8_UnderCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[7].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._8_UnderCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[7].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._8_PassCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[7].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._8_PassCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[7].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._8_OverCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[7].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._8_OverCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[7].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._8_NGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[7].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._8_NgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[7].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._8_ExNGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[7].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._8_ExNgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[7].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._8_TotalCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[7].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._8_TotalCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[7].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        #endregion

                        #region #9
                        case (int)ModbusDefine._30000_Modbus._9_Update:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[8].Update);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._9_Grade:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[8].Grade);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._9_Weight_High:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[8].Weight);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._9_Weight_Low:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[8].Weight);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._9_UnderCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[8].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._9_UnderCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[8].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._9_PassCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[8].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._9_PassCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[8].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._9_OverCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[8].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._9_OverCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[8].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._9_NGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[8].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._9_NgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[8].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._9_ExNGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[8].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._9_ExNgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[8].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._9_TotalCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[8].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._9_TotalCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[8].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        #endregion

                        #region #10
                        case (int)ModbusDefine._30000_Modbus._10_Update:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[9].Update);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._10_Grade:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[9].Grade);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._10_Weight_High:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[9].Weight);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._10_Weight_Low:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[9].Weight);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._10_UnderCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[9].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._10_UnderCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[9].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._10_PassCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[9].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._10_PassCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[9].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._10_OverCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[9].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._10_OverCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[9].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._10_NGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[9].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._10_NgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[9].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._10_ExNGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[9].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._10_ExNgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[9].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._10_TotalCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[9].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._10_TotalCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[9].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        #endregion

                        #region #11
                        case (int)ModbusDefine._30000_Modbus._11_Update:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[10].Update);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._11_Grade:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[10].Grade);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._11_Weight_High:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[10].Weight);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._11_Weight_Low:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[10].Weight);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._11_UnderCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[10].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._11_UnderCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[10].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._11_PassCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[10].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._11_PassCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[10].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._11_OverCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[10].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._11_OverCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[10].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._11_NGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[10].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._11_NgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[10].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._11_ExNGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[10].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._11_ExNgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[10].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._11_TotalCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[10].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._11_TotalCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[10].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        #endregion

                        #region #12
                        case (int)ModbusDefine._30000_Modbus._12_Update:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[11].Update);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._12_Grade:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[11].Grade);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._12_Weight_High:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[11].Weight);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._12_Weight_Low:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[11].Weight);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._12_UnderCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[11].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._12_UnderCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[11].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._12_PassCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[11].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._12_PassCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[11].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._12_OverCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[11].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._12_OverCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[11].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._12_NGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[11].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._12_NgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[11].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._12_ExNGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[11].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._12_ExNgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[11].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._12_TotalCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[11].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._12_TotalCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[11].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[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;

                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.UnderRange_High:
                            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:
                            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:
                            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:
                            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:
                            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:
                            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:
                            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:
                            length4Value = GetBytes((Single)tareValue);
                            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:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[0].Weight);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._1_Weight_Low:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[0].Weight);
                            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;
                        #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].Weight);
                            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].Weight);
                            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;
                        #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].Weight);
                            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].Weight);
                            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;
                        #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].Weight);
                            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].Weight);
                            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;
                        #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].Weight);
                            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].Weight);
                            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;
                        #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].Weight);
                            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].Weight);
                            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;
                        #endregion

                        #region #7
                        case (int)ModbusDefine._30000_Modbus._7_Update:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[6].Update);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._7_Grade:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[6].Grade);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._7_Weight_High:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[6].Weight);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._7_Weight_Low:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[6].Weight);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._7_UnderCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[6].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._7_UnderCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[6].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._7_PassCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[6].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._7_PassCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[6].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._7_OverCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[6].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._7_OverCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[6].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._7_NGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[6].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._7_NgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[6].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._7_ExNGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[6].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._7_ExNgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[6].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._7_TotalCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[6].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._7_TotalCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[6].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        #endregion

                        #region #8
                        case (int)ModbusDefine._30000_Modbus._8_Update:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[7].Update);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._8_Grade:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[7].Grade);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._8_Weight_High:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[7].Weight);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._8_Weight_Low:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[7].Weight);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._8_UnderCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[7].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._8_UnderCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[7].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._8_PassCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[7].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._8_PassCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[7].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._8_OverCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[7].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._8_OverCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[7].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._8_NGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[7].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._8_NgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[7].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._8_ExNGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[7].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._8_ExNgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[7].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._8_TotalCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[7].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._8_TotalCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[7].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        #endregion

                        #region #9
                        case (int)ModbusDefine._30000_Modbus._9_Update:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[8].Update);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._9_Grade:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[8].Grade);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._9_Weight_High:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[8].Weight);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._9_Weight_Low:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[8].Weight);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._9_UnderCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[8].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._9_UnderCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[8].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._9_PassCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[8].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._9_PassCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[8].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._9_OverCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[8].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._9_OverCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[8].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._9_NGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[8].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._9_NgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[8].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._9_ExNGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[8].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._9_ExNgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[8].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._9_TotalCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[8].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._9_TotalCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[8].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        #endregion

                        #region #10
                        case (int)ModbusDefine._30000_Modbus._10_Update:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[9].Update);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._10_Grade:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[9].Grade);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._10_Weight_High:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[9].Weight);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._10_Weight_Low:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[9].Weight);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._10_UnderCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[9].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._10_UnderCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[9].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._10_PassCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[9].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._10_PassCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[9].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._10_OverCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[9].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._10_OverCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[9].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._10_NGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[9].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._10_NgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[9].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._10_ExNGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[9].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._10_ExNgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[9].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._10_TotalCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[9].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._10_TotalCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[9].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        #endregion

                        #region #11
                        case (int)ModbusDefine._30000_Modbus._11_Update:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[10].Update);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._11_Grade:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[10].Grade);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._11_Weight_High:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[10].Weight);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._11_Weight_Low:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[10].Weight);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._11_UnderCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[10].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._11_UnderCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[10].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._11_PassCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[10].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._11_PassCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[10].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._11_OverCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[10].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._11_OverCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[10].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._11_NGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[10].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._11_NgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[10].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._11_ExNGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[10].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._11_ExNgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[10].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._11_TotalCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[10].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._11_TotalCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[10].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        #endregion

                        #region #12
                        case (int)ModbusDefine._30000_Modbus._12_Update:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[11].Update);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._12_Grade:
                            length2Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[11].Grade);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._12_Weight_High:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[11].Weight);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._12_Weight_Low:
                            if (this.EquipmentStatus == DataStore.EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.Current30000ModbusData.ModbusLaneData[11].Weight);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._12_UnderCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[11].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._12_UnderCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[11].UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._12_PassCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[11].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._12_PassCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[11].PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._12_OverCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[11].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._12_OverCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[11].OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._12_NGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[11].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._12_NgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[11].NGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._12_ExNGCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[11].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._12_ExNgCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[11].ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._12_TotalCount_High:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[11].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case (int)ModbusDefine._30000_Modbus._12_TotalCount_Low:
                            length4Value = GetBytes(this.Current30000ModbusData.ModbusLaneData[11].TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[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 Uart Com3
        public void UartCom3Open()
        {
            string fullPath = "";
            int baudrate = 9600;

            if (this.SystemConfig.Serial3Mode != 0)
            {
                try
                {
                    switch (this.SystemConfig.Serial3BaudRate)
                    {
                        case 0:
                            baudrate = 9600;
                            break;
                        case 1:
                            baudrate = 19200;
                            break;
                        case 2:
                            baudrate = 38400;
                            break;
                        case 3:
                            baudrate = 115200;
                            break;
                        default:
                            baudrate = 9600;
                            break;
                    }

                    // Port : COM3
                    SerialMgrComm.serialPortOpen("COM3:", baudrate, 0, 0, 8);
                }
                catch
                {
                }
            }

            #region Test 용 통신 로그
            fullPath = this.PathDataLogFolder + "COM3log.txt";
            this.smartFileCom3Log.FilePathName = fullPath;
            //this.smartUARTCom3.Open();
            //this.IsCom3LogOpen = true;
            #endregion
        }

        public string PadLeft(int length, string sValue)
        {
            string temp;

            temp = sValue.PadLeft(length, ' ');

            return temp;
        }

        public void SerialCH3STD1(Collection<WeightData> datas)
        {
            string value = "";

            value = this.Protocol_STD1_NotStxEtx(this.SystemConfig, datas);

            SerialMgrComm.serialPortMessage("COM3:", value);

            if (this.IsCom3LogOpen == true)
                this.smartFileCom3Log.WriteString(string.Format("Send ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, value));
        }
        public void SerialCH3STD2(Collection<WeightData> datas)
        {
            string value = "";

            value = this.Protocol_STD2_NotStxEtx(this.SystemConfig, datas, this.CurrentProductItem);

            SerialMgrComm.serialPortMessage("COM3:", value);

            if (this.IsCom3LogOpen == true)
                this.smartFileCom3Log.WriteString(string.Format("Send ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, value));
        }
        public void SerialCH3STD3(Collection<WeightData> datas)
        {
            string value = "";

            value = this.Protocol_STD3_NotStxEtx(this.SystemConfig, datas, this.CurrentProductItem);

            SerialMgrComm.serialPortMessage("COM3:", value);

            if (this.IsCom3LogOpen == true)
                this.smartFileCom3Log.WriteString(string.Format("Send ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, value));
        }
        #endregion
        #region Ethernet
        private void SendEthernetData(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.EthernetWeightData(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();
        }

        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");
                this.SetTrackingHistoryData(DataStore.E_TrackingOperation.EthernetConnect, "Client");

                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 = this.EthernetStmReader.ReadLine();

                    if (null == strRecvMsg)
                    {
                        this.DelegateTextStatusOut(">Server Out");
                        this.SetTrackingHistoryData(DataStore.E_TrackingOperation.EthernetDisconnect, "Client");
                        this.IsEthernetThreadStop = true;
                        break;
                    }

                    this.DelegateTextStatusOut(strRecvMsg);
                }
            }
            catch
            {
                this.DelegateTextStatusOut(">Connect Fail !");
            }
            finally
            {
                this.IsEthernetThreadStop = true;
                this.DelegateUISeverStatus(false);
                this.DelegateTextStatusOut(">Disconnected Server");
                this.SetTrackingHistoryData(DataStore.E_TrackingOperation.EthernetDisconnect, "Client");
                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();
            }

            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.EthernetSendMessage), data);
        }
        private void DelegateTransferData(byte[] data)
        {
            this.Invoke(new TransferDataByteArrayCallback(this.EthernetSendMessage), data);
        }
        private void DelegateTransferData(byte data)
        {
            this.Invoke(new TransferDataStringCallback(this.EthernetSendMessage), data);
        }
        public void EthernetSendMessage(string msg)
        {
            try
            {
                this.IsEthernetTransferData = false;

                this.EthernetStmWriter.Write(msg);
                this.EthernetStmWriter.Flush();

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

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

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

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

            if (this.IsEthernetThreadStop == true)
                this.EthernetClientConnect();
            else
                this.EthernetSendMessage(bytes);
        }
        #endregion
        #endregion
        #region OPC, 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;
        }

        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);
        }
        public void Update30000ModbusData(int index)
        {
            this.Update30000UpdateData(index);

            this.Current30000ModbusData.ModbusLaneData[index].Grade = this.Grade(this.CollectionWeightData[index].JudgmentStatus);
            this.Current30000ModbusData.ModbusLaneData[index].Weight = 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;
        }

        // 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.EthernetWeightDataForModbus(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.EthernetWeightDataForModbus(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.IsPart11 == 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.IsPart11 == true)
                                        this.SetTrackingHistoryData(DataStore.E_TrackingOperation.MB_EquipmentStart, "");
                                }
                                else
                                {
                                    this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);

                                    // Part 11 Log
                                    if (this.SystemConfig.IsPart11 == 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.IsPart11 == 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.ChildFormMainDisplay.UpdateUnderRangeLimitCheck(true);
                                
                                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.ChildFormMainDisplay.UpdateOverRangeLimitCheck(true);

                                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.UpdateTareRnageChange(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 Servo Modbus
        public void ServoModbusOpen()
        {
            if (this.smartServoModbus.IsOpen == true)
                this.smartServoModbus.PortClose();

            this.smartServoModbus.PortOpen();
        }
        public void ServoModbusClose()
        {
            this.smartServoModbus.PortClose();
        }

        public string ServoMotorRead1(int slaveAddress, int parameterAddress)
        {
            int value = 0;
            byte[] readData = new byte[2];

            this.smartServoModbus.SlaveAddress = slaveAddress;
            this.smartServoModbus.ReadHoldingRegister(parameterAddress, 1, ref readData);

            Array.Reverse(readData);
            value = BitConverter.ToInt16(readData, 0);

            return string.Format("{0}", value);
        }
        public string ServoMotorRead2(int slaveAddress, int parameterAddress)
        {
            int value = 0;
            byte[] readData = new byte[4];

            this.smartServoModbus.SlaveAddress = slaveAddress;
            this.smartServoModbus.ReadHoldingRegister(parameterAddress, 2, ref readData);

            byte[] readData1 = new byte[4];
            readData1[0] = readData[1];
            readData1[1] = readData[0];
            readData1[2] = readData[3];
            readData1[3] = readData[2];

            value = BitConverter.ToInt32(readData1, 0);

            return string.Format("{0}", value);
        }
        public void ServoMotorWrite1(int slaveAddress, int parameterAddress, int value, SmartLabel label)
        {
            this.smartServoModbus.SlaveAddress = slaveAddress;
            if (this.smartServoModbus.WriteSingleRegister(parameterAddress, value) == SmartX.SmartModbus.EXCEPTIONCODE.SUCCESS)
            {
                //MessageBox.Show("쓰기완료");
            }
            label.Text = this.ServoMotorRead1(slaveAddress, parameterAddress);
        }
        public void ServoMotorWrite1(int slaveAddress, int parameterAddress, int value)
        {
            this.smartServoModbus.SlaveAddress = slaveAddress;
            if (this.smartServoModbus.WriteSingleRegister(parameterAddress, value) == SmartX.SmartModbus.EXCEPTIONCODE.SUCCESS)
            {
                //MessageBox.Show("쓰기완료");
            }
        }
        public void ServoMotorWrite2(int slaveAddress, int parameterAddress, int value, SmartLabel label)
        {
            byte[] data = BitConverter.GetBytes(value);

            byte[] readData1 = new byte[4];
            readData1[0] = data[1];
            readData1[1] = data[0];
            readData1[2] = data[3];
            readData1[3] = data[2];

            this.smartServoModbus.SlaveAddress = slaveAddress;
            if (this.smartServoModbus.WriteMultipleRegister(parameterAddress, 4, readData1) == SmartX.SmartModbus.EXCEPTIONCODE.SUCCESS)
            {
                //MessageBox.Show("쓰기완료");
            }
            label.Text = this.ServoMotorRead2(slaveAddress, parameterAddress);
        }
        public void ServoMotorWrite(int slaveAddress, int parameterAddress, int value)
        {
            this.smartServoModbus.SlaveAddress = slaveAddress;
            if (this.smartServoModbus.WriteSingleRegister(parameterAddress, value) == SmartX.SmartModbus.EXCEPTIONCODE.SUCCESS)
            {
                //MessageBox.Show("쓰기완료");
            }
        }
        #endregion

        #region Backup
        public List<string> GetSeletedNodeList(TreeView tree)
        {
            int yearCNT, monthCNT, dayCNT;
            List<string> listSelectedFile = new List<string>();

            yearCNT = tree.Nodes.Count;
            if (yearCNT != 0)
            {
                for (int i = 0; i < yearCNT; i++)
                {
                    monthCNT = tree.Nodes[i].Nodes.Count;
                    if (monthCNT != 0)
                    {
                        for (int j = 0; j < monthCNT; j++)
                        {
                            dayCNT = tree.Nodes[i].Nodes[j].Nodes.Count;
                            if (dayCNT != 0)
                            {
                                for (int k = 0; k < dayCNT; k++)
                                {
                                    //if (tree.Nodes[i].Nodes[j].Nodes[k].Checked == true)
                                    //{
                                    //listSelectedFile.Add(tree.Nodes[i].Nodes[j].Nodes[k].Text);
                                    listSelectedFile.Add(string.Format("{0}\\{1}\\{2}", tree.Nodes[i].Text, tree.Nodes[i].Nodes[j].Text, tree.Nodes[i].Nodes[j].Nodes[k].Text));
                                    //}
                                }
                            }
                        }
                    }
                }
            }

            return listSelectedFile;
        }

        private void DeleteLogFile(string path, DataStore.E_DataType type)
        {
            string dataFolderPath = "";

            switch (type)
            {
                case DataStore.E_DataType.None:
                    break;
                case DataStore.E_DataType.History:
                    dataFolderPath = this.PathDataHistoryFolder;
                    break;
                case DataStore.E_DataType.Inspection:
                    dataFolderPath = this.PathDataInspectionFolder;
                    break;
                case DataStore.E_DataType.Others:
                    dataFolderPath = this.PathDataOthersFolder;
                    break;
                default:
                    break;
            }

            foreach (string Folder in Directory.GetDirectories(path))
            {
                this.DeleteLogFile(Folder, type); //재귀함수 호출
                if (Directory.GetDirectories(Folder).Count() == 0 && Directory.GetFiles(Folder).Count() == 0 && Folder != dataFolderPath)
                    Directory.Delete(Folder, true);
            }

            foreach (string file in Directory.GetFiles(path))
            {
                FileInfo fi = new FileInfo(file);
                if (DateTime.ParseExact(fi.Name.Substring(1, 8), "yyyyMMdd", null) < DateTime.Now.AddMonths(-1 * this.SystemConfig.StoragePeriod))
                    fi.Delete();
            }
        }
        #endregion
        #region Tracking Inspection data
        private void GetTrackingInspectionFolderPath(ref string folder, ref string fileName)
        {
            DateTime time = DateTime.Now;

            if (this.SystemConfig.IsPart11 == false)
            {
                folder = this.PathDataBackupFolder;
                fileName = string.Format("{0:yyyyMMdd}-{1}.csv", time, this.SystemConfig.ProductNumber);
            }
            else
            {
                folder = string.Format("{0}{1}\\{2}\\", this.PathDataInspectionFolder, time.Year, time.Month);
                fileName = string.Format("I{0:yyyyMMdd}-{1}.csv", time, this.SystemConfig.ProductNumber);
            }
        }
        private void TrackingInspectionData(Collection<WeightData> items)
        {
            bool fileCheck = false, directoryCheck = false;
            string fullFilePath = "", folderPath = "", fileName = "";
            StreamWriter sw;

            if (this.SystemConfig.IsDataBackup == true)
            {
                this.GetTrackingInspectionFolderPath(ref folderPath, ref fileName);
                fullFilePath = string.Format("{0}{1}", folderPath, fileName);

                DirectoryInfo di = new DirectoryInfo(folderPath);
                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)
                {
                    this.RemoveInspectionDataFile();

                    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("UnderRange");
                    sw.Write(",");
                    sw.Write("PassRange");
                    sw.Write(",");
                    sw.Write("OverRange");
                    sw.Write(",");
                    sw.Write("TareRange");

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

                    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.StringToDecimalPlaces(this.CurrentProductItem.UnderRange, this.SystemConfig.DecimalPlaces));
                sw.Write(",");
                sw.Write(Helper.StringToDecimalPlaces(this.CurrentProductItem.PassRange, this.SystemConfig.DecimalPlaces));
                sw.Write(",");
                sw.Write(Helper.StringToDecimalPlaces(this.CurrentProductItem.OverRange, this.SystemConfig.DecimalPlaces));
                sw.Write(",");
                sw.Write(Helper.StringToDecimalPlaces(this.CurrentProductItem.TareRange, this.SystemConfig.DecimalPlaces));

                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 RemoveInspectionDataFile()
        {
            bool directoryCheck = false;

            try
            {
                if (this.SystemConfig.IsPart11 == true)
                    this.DeleteLogFile(this.PathDataInspectionFolder, DataStore.E_DataType.Inspection);
                else
                {
                    string dday = string.Format("{0:yyyyMMdd}", DateTime.Now.AddDays(-180)) + ".csv";

                    DirectoryInfo dir = new DirectoryInfo(this.PathDataInspectionFolder);

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

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

            }
        }
        #endregion
        #region Tracking History data
        public void SetTrackingHistoryData(DataStore.E_TrackingOperation type, string detail)
        {
            HistoryData data = new HistoryData();

            data.Type = "Operation";
            data.Time = DateTime.Now;
            data.LoginID = this.SystemConfig.CurrentUser.ID;
            data.Event = type.ToString();
            data.Detail = detail;
            data.BeforeData = "";
            data.AfterData = "";

            this.TrackingHistoryData(data);
        }
        public void SetTrackingHistoryData(DataStore.E_TrackingOperation eventType, string detail, string loginID)
        {
            if (this.SystemConfig.IsPart11 == false)
                return;

            HistoryData data = new HistoryData();

            data.Type = "Operation";
            data.Time = DateTime.Now;
            data.LoginID = loginID;
            data.Event = eventType.ToString();
            data.Detail = detail;
            data.BeforeData = "";
            data.AfterData = "";

            this.TrackingHistoryData(data);
        }
        public void SetTrackingHistoryData(DataStore.TrackingAlarm type, string detail)
        {
            HistoryData data = new HistoryData();

            data.Type = "Alarm";
            data.Time = DateTime.Now;
            data.LoginID = this.SystemConfig.CurrentUser.ID;
            data.Event = type.ToString();
            data.Detail = detail;
            data.BeforeData = "";
            data.AfterData = "";

            this.TrackingHistoryData(data);
        }
        public void SetTrackingHistoryData(DataStore.TrackingParameter type, string detail, string before, string after)
        {
            if (before == after)
                return;

            HistoryData data = new HistoryData();

            data.Type = "Parameter";
            data.Time = DateTime.Now;
            data.LoginID = this.SystemConfig.CurrentUser.ID;
            data.Event = type.ToString();
            data.Detail = detail;
            data.BeforeData = before;
            data.AfterData = after;

            this.TrackingHistoryData(data);
        }

        private void TrackingHistoryData(HistoryData data)
        {
            bool fileCheck = false, directoryCheck = false;
            string fullFilePath = "", folderPath = "", fileName = "";
            StreamWriter sw;
            DateTime time = DateTime.Now;

            if (this.SystemConfig.IsPart11 == true)
            {
                folderPath = string.Format("{0}{1}\\{2}\\", this.PathDataHistoryFolder, time.Year, time.Month);
                fileName = string.Format("H{0:yyyyMMdd}.csv", time);

                fullFilePath = string.Format("{0}{1}", folderPath, fileName);

                DirectoryInfo di = new DirectoryInfo(folderPath);
                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)
                {
                    this.RemoveHistoryDataFile();

                    sw.Write("Date");
                    sw.Write(",");
                    sw.Write("Time");
                    sw.Write(",");
                    sw.Write("LoginID");
                    sw.Write(",");
                    sw.Write("Event");
                    sw.Write(",");
                    sw.Write("Detail");
                    sw.Write(",");
                    sw.Write("Before");
                    sw.Write(",");
                    sw.Write("After");
                    sw.Write(",");
                    sw.Write("Type");

                    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(data.LoginID);
                sw.Write(",");
                sw.Write(data.Event.ToString());
                sw.Write(",");
                sw.Write(data.Detail);
                sw.Write(",");
                sw.Write(data.BeforeData);
                sw.Write(",");
                sw.Write(data.AfterData);
                sw.Write(",");
                sw.Write(data.Type);
                sw.WriteLine();

                sw.Close();
            }
        }
        private void RemoveHistoryDataFile()
        {
            try
            {
                this.DeleteLogFile(this.PathDataHistoryFolder, DataStore.E_DataType.History);
            }
            catch
            {

            }
        }
        #endregion
        #region Tracking Others data
        private void RemoveOthersDataFile()
        {
            try
            {
                this.DeleteLogFile(this.PathDataOthersFolder, DataStore.E_DataType.Others);
            }
            catch
            {

            }
        }
        #endregion
        #endregion

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

            // 변수 초기 셋팅1
            this.DefaultSetting1();
            // SystemConfiguration 1 읽기
            this.LoadSystemConfigurationFile1();
            // SystemConfiguration 2 읽기
            this.LoadSystemConfigurationFile2();
            // SystemConfiguration 3 읽기
            this.LoadSystemConfigurationFile3();
            // Collection 생성
            this.CreateCollection();
            // Count 읽기
            this.LoadCounterFile1(ref this.CollectionWeightData, this.SystemConfig.ProductNumber - 1);
            if(this.SystemConfig.EquipmentColumns > 12)
                this.LoadCounterFile2(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);
            // 동보정 파일 읽기
            this.LoadDynamicCorrectionFile(ref this.CurrentJudgmentSetItem, this.SystemConfig.ProductNumber - 1);
            // 품목명 읽기
            this.LoadProductName(ref this.CollectionProductName);
            // UserGroup File Load
            this.LoadUserGroupFile(ref this.CurrentUserGroup);

            // 변수 초기 셋팅2
            // 시스템설정 값 로딩 후 셋팅
            this.DefaultSetting2();

            // 폼생성
            this.CreateForm();

            // UserManager 초기화
            if (this.SystemConfig.IsLogin == true)
            {
                this.InitializeUserManager();
                this.SystemConfig.CurrentUser.Group = DataStore.UserGroup.LogOut;

                if (this.SystemConfig.IsPart11 == false)
                    UserManager.UserManager_AutoLogoutTimeoutPause();

                // UserManager_GetUserListName
                this.timerUserList.Enabled = true;
            }
            else
                this.SystemConfig.CurrentUser.Group = DataStore.UserGroup.NotLogin;
            // Encryption 초기화
            if (this.SystemConfig.IsPart11 == true)
            {
                this.InitializeAES();
                this.SetTrackingHistoryData(DataStore.E_TrackingOperation.PowerOn, "");
            }
           
            this.SmartSplashProgramLoad.Finish();

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

            // 통신 OPEN
            this.OpenSmartUartLink();

            // Serial3 통신 Open
            this.UartCom3Open();

            // Modbus Open
            if (this.SystemConfig.MotorSelect == 1)
                this.ServoModbusOpen();

            // 초기 파라미터 전송
            this.TransferDataStream(CommunicationCommand.Read, CommunicationID.MainBoard, CommunicationAddress._6901_ParameterRead6901, "");
        }
        #endregion

        #region Event Handler
        private void SerialReceiveData(string data)
        {
            try
            {
                this.ReceiveData1(data);

                // 통신 확인
                if (this.CommunicationCheckCount / 3 == 1)
                {
                    if (this.ChildFormMainDisplay != null)
                        this.ChildFormMainDisplay.pictureBoxCommunicationStatus.Visible = true;

                    this.CommunicationCheckCount = 0;
                }
                else
                {
                    if (this.ChildFormMainDisplay != null)
                        this.ChildFormMainDisplay.pictureBoxCommunicationStatus.Visible = false;

                    this.CommunicationCheckCount += 1;
                }
            }
            catch
            {

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

        private void smartThread_UIThreadFunction(ThreadArgs args)
        {
            // 메시지 11. 입력센서 에러에 의해 정지하였습니다.
            if (this.FlagThreadMessage1 == false)
            {
                DialogFormMessage msg = new DialogFormMessage(11, this.SystemConfig.Language, this);
                msg.ShowDialog();

                this.FlagThreadMessage1 = true;
            }
        }
        private void smartTimerSampling_Tick(object sender, EventArgs e)
        {
            this.timerSampling.Enabled = false;
            this.TransferData(CommunicationCommand.SamplingSignal, CommunicationID.MainBoard);
            this.SystemConfig.SamplingCurrentCount++;
        }
        private void timerSampling_Tick(object sender, EventArgs e)
        {
            this.timerSampling.Enabled = false;
            this.TransferData(CommunicationCommand.SamplingSignal, CommunicationID.MainBoard);
            this.SystemConfig.SamplingCurrentCount++;
        }
        private void timerTimeout_Tick(object sender, EventArgs e)
        {
            if (this.SystemConfig.CurrentForm == DataStore.FormStore.FormMainDisplay)
            {
                if (this.ChildFormMainDisplay != null)
                    this.ChildFormMainDisplay.UpdateDisplayProductChangeInfo(this.FlagTimeoutCount);
            }
            else if (this.SystemConfig.CurrentForm == DataStore.FormStore.FormSystemSetting)
            {
                if (this.ChildFormSystemSetting != null)
                    this.ChildFormSystemSetting.UpdateDisplayProductChangeInfo(this.FlagTimeoutCount);
            }

            this.TransferDynamicParameter(this.ProductChangNumber);

            this.FlagTimeoutCount++;
        }
        private void timerEmergencyStop_Tick(object sender, EventArgs e)
        {
            this.timerEmergencyStop.Enabled = false;

            if (this.EquipmentStatus == DataStore.EquipmentStatus.Start)
            {
                this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
                this.timerEmergencyStop.Enabled = true;
            } 
        }
        private void timerLeakSampling_Tick(object sender, EventArgs e)
        {
            this.timerLeakSampling.Enabled = false;
            this.TransferData(CommunicationCommand.LeakSamplingSignal, CommunicationID.MainBoard);
        }
        private void timerUserList_Tick(object sender, EventArgs e)
        {
            this.timerUserList.Enabled = false;
            UserManager.UserManager_GetUserListName();
        }

        private void CurrentAlarmList_Change(DataStore.TrackingAlarm alarm, string status)
        {
            if (this.SystemConfig.IsPart11 == false)
                return;

            this.SetTrackingHistoryData(alarm, status);
        }

        #region UserManagerEvent
        private void UserManager_UserListLogoutDataEvent(int status)
        {
            try
            {
                if (status == (int)UserManager.USERMGR_LOGOUT_STATUS_OK)
                {
                    // logout
                }
                else
                {
                    // logout fail !!!
                    //MessageBox.Show("Logout Failed !!!!");
                }
            }
            catch
            {
            }
        }
        private void UserManager_UserListLoginDataEvent(int status, object data)
        {
            try
            {
                if (status == (int)UserManager.E_user_mgr_status.USER_MGR_STATUS_OK)
                {
                    UserManager.UserMgr_user_info_t userInfo = (UserManager.UserMgr_user_info_t)data;

                    //this.ChildFormMainDisplay.updatedisplayuser

                    //String Message;
                }
                else
                {
                    this.UI_Invoke(delegate
                    {
                        // login fail !!!
                        //textBox_id.Enabled = true;
                        //textBox_pw.Enabled = true;
                        //comboBox_logout_timeout.Enabled = true;

                        //button_login.Text = "LOGIN";
                        //Activation.IsLogin = false;
                    });
                }
            }
            catch
            {
            }
        }
        private void UserManager_UserListGetListDataEvent(object data)
        {
            try
            {
                UserManager.UserMgr_user_list_t userList = (UserManager.UserMgr_user_list_t)data;

                if (this.SystemConfig.CurrentForm == DataStore.FormStore.FormUserEditor)
                    this.ChildFormUserEditor.CallBackGetUserData(userList);
            }
            catch
            {
            }
        }
        private void UserManager_UserListLoginTimeoutDataEvent(object data)
        {
            try
            {
                UserManager.UserMgr_login_timeout_t loginTimeout = (UserManager.UserMgr_login_timeout_t)data;

                if (this.SystemConfig.CurrentForm == DataStore.FormStore.FormMainDisplay)
                    this.ChildFormMainDisplay.CallBackUserListLoginTimeoutDataEvent(loginTimeout);
            }
            catch (Exception e)
            {
            }
        }
        private void UserManager_UserListLockDataEvent(object data)
        {
            try
            {
                UserManager.UserMgr_user_lock_t user = (UserManager.UserMgr_user_lock_t)data;

                if (this.SystemConfig.CurrentForm == DataStore.FormStore.FormUserEditor)
                    this.ChildFormUserEditor.CallBackUserListLockDataEvent(user);
            }
            catch
            {
            }
        }
        private void UserManager_UserListDefaultSettingDataEvent(object data)
        {
            try
            {

            }
            catch
            {
            }
        }
        private void UserManager_UserListDeleteDataEvent(object data)
        {
            try
            {
                UserManager.UserMgr_user_del_t user = (UserManager.UserMgr_user_del_t)data;
                this.ChildFormUserEditor.CallBackUserListDeleteDataEvent(user);
            }
            catch
            {
            }
        }
        private void UserManager_UserListModifyUserDataEvent(object data)
        {
            try
            {
                UserManager.UserMgr_user_modify_t user = (UserManager.UserMgr_user_modify_t)data;

                this.ChildFormUserEditor.CallBackUserModifyUserData(user);
            }
            catch
            {
            }
        }
        private void UserManager_UserListModifyInfoDataEvent(object data)
        {
            try
            {
                UserManager.UserMgr_user_info_t user = (UserManager.UserMgr_user_info_t)data;

                if (this.SystemConfig.CurrentForm == DataStore.FormStore.FormUserEditor)
                    this.ChildFormUserEditor.CallBackUserListModifyInfoDataEvent(user);
                //else if (this.SystemConfig.CurrentForm == DataStore.FormStore.FormMainDisplay)
                //this.ChildFormMainDisplay.CallBackUserListModifyInfoDataEvent(user);
            }
            catch
            {
            }
        }
        private void UserManager_UserListNewDataEvent(object data)
        {
            try
            {
                UserManager.UserMgr_user_info_t user = (UserManager.UserMgr_user_info_t)data;

                this.ChildFormUserEditor.CallBackUserListNewData(user);
            }
            catch (Exception e)
            {
            }
        }
        private void UserManager_UserListAddDataEvent(object data)
        {
            try
            {
                UserManager.UserMgr_user_add_t userAdd = (UserManager.UserMgr_user_add_t)data;

                if (userAdd.status == (int)UserManager.E_user_mgr_status.USER_MGR_STATUS_OK)
                {
                    //for (int i = 0; i < this.CollectionUser.Count; i++)
                    //{
                    //    if (this.CollectionUser[i].ID == userAdd.user_id)
                    //    {
                    //        this.FlagUserListCNT++;
                    //        this.CollectionUser[i].IsUpdate = true;
                    //        this.CollectionUser[i].IsLockAccount = userAdd.flock_status_account == 0 ? false : true;
                    //        this.CollectionUser[i].IsLockPassword = userAdd.flock_status_password == 0 ? false : true;
                    //        break;
                    //    }
                    //}
                }
                else
                {
                    //for (int i = 0; i < this.CollectionUser.Count; i++)
                    //{
                    //    if (this.CollectionUser[i].ID == userAdd.user_id)
                    //    {
                    //        this.CollectionUser.RemoveAt(i);
                    //        break;
                    //    }
                    //}

                    //this.SaveUserFile(this.CollectionUser);
                }
            }
            catch
            {
            }
        }
        private void UserManager_UserListGetListNameDataEvent(object data)
        {
            try
            {
                UserManager.UserMgr_user_list_name_t name = (UserManager.UserMgr_user_list_name_t)data;

                if (name.total_count == 0)
                    return;

                this.ListDllUserName.Add(name.user_id);
            }
            catch
            {
            }
        }
        private void UserManager_UserListGetVersionDataEvent(object data)
        {
            try
            {
                if (this.ChildFormInformation != null)
                    this.ChildFormInformation.UpdatePart11UserManagerVersionDisplay(data.ToString());
            }
            catch
            {
            }
        }
        #endregion

        #region EncryptionEvent
        private void AesEncryption_Event(object data)
        {
            try
            {
                Encryption.auth_encryption_status_t status = (Encryption.auth_encryption_status_t)data;

                //this.labelStatus.Text = status.percentage.ToString();
                //this.StatusPercentage = status.percentage;

                this.ChildFormDataBackup_Part11.CallBackEncryptionEvent(status);
            }
            catch
            {

            }
        }
        private void AesEncryption_GetVersionDataEvent(object data)
        {
            if (this.ChildFormInformation != null)
                this.ChildFormInformation.UpdatePart11AesEncryptionVersionDisplay(data.ToString());
        }
        #endregion
        #endregion

        private void timerEquipmentStatus_Tick(object sender, EventArgs e)
        {
            this.timerEquipmentStatus.Enabled = false;

            this.EquipmentStatus1 = this.EquipmentStatus;
        }
    }
}