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 ITC81DB_2H.DialogForms;
using ITC81DB_2H.Controls;
using InModbus;
using ITC81DB_2H.Datastore;
using ITC81DB_2H.Part11_UserManager;
using ITC81DB_2H.Part11_Encryption;
using ITC81DB_2H.SerialManager;

namespace ITC81DB_2H.Forms
{
    public partial class FormMain : Form
    {
        #region Field
        public static string DisplayVersion = "3.4.3";
        public static string ReleaseDate = "2026.03.10";

        private SmartSplash SmartSplashProgramLoad;
        public bool IsCommunicationLogOpen;
        public bool IsErrorLogOpen;
        private int CommunicationCheckCount;
        public bool IsBootingComplete;
        public int BufferSmartUart; // Buffer size 정의
        public int ContinuousNGCount;
        public int ProductCount;    // 품목 수량 카운트
        public bool IsBuzzerOnDataSend;
        public bool IsLampOnDataSend;
        public int CountingOutput1Count; // CountingOutput1 개수
        public int CountingOutput2Count; // CountingOutput2 개수
        public bool FlagThreadMessage1;     // 플레그 쓰레드 메시지 23
        public bool IsCurrentKeyKorean;
        public int SensorDetectingTime;
        public double OverloadWeight;
        private int BLDCMotorIndex;
        private static int BLDCMotorMaxNum = 10;
        public bool IsAlarmOccured;
        public int UpdateValue; // Modbus - Update 될 때마다 +1
        public bool IsOPCModbusUsing;
        public int FlagAutomaticLogoutWarningTime;
        public bool IsLogProcessing;
        public bool IsBypassOnce; // 바이패스
        public bool IsBypassDirectionPass; // 바이패스
        public bool IsBypassUse; // 바이패스
        public bool IsBypassStart;
        public bool IsManufacturerVisible;
        public string PreviousAlarm; // 이전 알람값

        // 재전송 기능
        public int MissingCommIDCount;
        public int CommID;
        public bool FlagSerialDll = false;
        private string ComPortMainToLCD;
        private Queue<string> QueueCommunicationRecive; // 큐 통신 데이터용
        private int FlagComRetry3th;        // 3회 재전송 횟수
        public Queue<string> QueueOverRun = new Queue<string>();
        private int IndexOverRun = 0;

        private byte[] ClientSendDatabyteArray;
        private string ClientSendDataString;

        #region 통신관련
        // OPT2
        private SerialOPT2 CurrentOPT2COM1;
        private SerialOPT2 CurrentOPT2COM3;
        private SerialOPT2 CurrentOPT2COM4;
        private SerialOPT2 CurrentOPT2Ethernet;
        private delegate void SerialOPT2COM1_Delegate();
        private delegate void SerialOPT2COM3_Delegate();
        private delegate void SerialOPT2COM4_Delegate();
        private delegate void SerialOPT2Ethernet_Delegate();
        // 현재 MACSA 통신 프로토콜 저장
        private byte[] CurrentMACSACOM1;
        private byte[] CurrentMACSACOM3;
        private byte[] CurrentMACSACOM4;
        private byte[] CurrentMACSAEthernet;
        // MACSA 통신 프로토콜 1회 재전송 여부
        private bool IsMACSARetransmissionCOM1;
        private bool IsMACSARetransmissionCOM3;
        private bool IsMACSARetransmissionCOM4;
        private bool IsMACSARetransmissionEthernet;

        // 통신설정 - 전송 지연시간
        public Queue<object> QueueCOM1;
        public Queue<object> QueueCOM3;
        public Queue<object> QueueCOM4;
        public Queue<object> QueueEthernet;

        // OPC
        private static int TotalBytes = 48; // 전체 bytes

        // OPC
        private static int ModbusTotalBytes = 80; // 전체 bytes
        #endregion

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

        // 파일 위치
        private string m_PathFlashDiskFolder;              // 프로그램 실행 폴더
        private string m_PathLaunchFolder;              // 프로그램 실행 폴더
        private string m_PathLaunchRunFolder;                                    // 프로그램 Run 폴더
        private string m_PathPreVersionFolder;                                    // 이전버전 시스템파일 백업 폴더
        private string m_PathPreVersionRunFolder;                                // 이전버전 시스템파일 Run 폴더
        private string m_PathDataBackupFolder;          // 데이터 백업 폴더
        private string m_PathFlashDiskSystemFile1Folder;          // 시스템 파일1 폴더
        private string m_PathFlashDiskSystemFile2Folder;          // 시스템 파일2 폴더
        private string m_PathSDCardSystemFileFolder;          // 시스템 파일 폴더
        private string m_PathSDCardSystemFile1Folder;          // 시스템 파일1 폴더
        private string m_PathSDCardSystemFile2Folder;          // 시스템 파일2 폴더
        private string m_PathSDCardSystemFileBackupFolder;        // 시스템 파일 백업 폴더
        private string m_PathSDCardRemoveFileFolder;        // RemoveFile 폴더
        private string m_PathDataFolder;                                             // Data 폴더
        private string m_PathDataHistoryFolder;                                    // History 폴더
        private string m_PathDataInspectionFolder;                               // Inspection 폴더
        private string m_PathDataOthersFolder;                                    // Others 폴더
        private string m_PathDataLogFolder;                                        // Log 폴더
        private string m_PathEncryptionFolder;
        private string m_PathHeaderFolder;
        private static string m_PathBinFolder;

        // 현재 선택 된 품목
        //public ProductItem CurrentProductItem;
        // JudgmentSet
        //public JudgmentSetItem CurrentJudgmentSetItem;
        // 중량 데이터
        //public WeightData CurrentWeightData;

        // 시스템 상태
        private SystemStatus m_CurrentSystemStatus;
        // System Configuration1
        public SystemConfigurationItem1 SystemConfig1;
        // System Configuration2
        public SystemConfigurationItem2 SystemConfig2;
        // System Configuration3
        public SystemConfigurationItem3 SystemConfig3;
        // 중량 조정 설정값
        public CalibrationItem CurrentCalibrationItem;
        // 현재 피드백 값
        public FeedbackItem CurrentFeedbackItem;
        // 시스템파라미터1
        public SystemParameter1 CurrentSystemParameter1;
        // 시스템파라미터2
        public SystemParameter2 CurrentSystemParameter2;
        // 시스템파라미터3
        public SystemParameter3 CurrentSystemParameter3;
        // 시스템파라미터4
        public SystemParameter4 CurrentSystemParameter4;

        // 시스템정보 파라미터
        public SystemInformation2 SystemInfo2;
        public SystemInformation3 SystemInfo3;

        // Form
        public FormMainDisplay ChildFormMainDisplay;
        public FormMenu ChildFormMenu;

        // 알람
        public static int CurrentAlarmCount = 32;
        private AlarmList CurrentAlarmList;
        public List<short> CurrentAlarm;

        // IO Test Input 데이터 취합
        private Collection<string> CollectionIOTest_InputData;
        // IO Test Input 그래프 데이터
        private Collection<string> CollectionIOTestGraphData;
        // 판정설정 그래프 데이터
        private Collection<int> CollectionGraphData;
        // 업데이트 메인보드
        public UpdateForMainBoard UpdateForMain;

        // UserGroup
        public UserGroup CurrentUserGroup;
        // Bacode
        public Barcode CurrentBarcode;
        public Modbus Modbus;
        // Modbus Data
        public _30000_ModbusData Current30000ModbusData;
        public _40000_ModbusData Current40000ModbusData;
        // 품목설정 데이터
        public Collection<ProductItem> CollectionProductItem;
        // 판정설정 데이터
        public Collection<JudgmentSetItem> CollectionJudgmentItem;
        // Count 데이터
        public Collection<WeightData> CollectionWeightData;
        // 종근당 중량 데이터 버퍼
        private Collection<DataBackupOPT1> CollectionBufferWeightData;
        // BLDC 파라미터
        public Collection<BLDCMotorParameter> CollectionBLDCParameter;
        // 리젝데이터
        private JudgmentResult CurrentJudgmentResult;
        // Dll User_Name List
        public List<string> ListDllUserName;
        // Communication Respone
        private CommunicationRespone CurrentComRespone;

        // HM Handshake를 위한 함수
        private int HMCOM1_Step;
        private int HMCOM3_Step;
        private int HMCOM4_Step;
        private int HMEthernet_Step;

        // Ethernet
        private bool IsEthernetThreadStop;
        private bool IsEthernetTransferData;

        public object EthernetTransferData;

        private TcpClient EthernetTcpClient;

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

        private delegate void TransferDataCollbaack(string strtext);
        private delegate void TextStatusCallback(string strtext);
        private delegate void UIControlCallback(bool bEnable);
        private delegate void UIServerStatusCallback(bool bEnable);
        private delegate void TimerTryConnectCallback(bool bEnable);
        #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 PathFlashDiskFolder
        {
            get { return this.m_PathFlashDiskFolder; }
            set { this.m_PathFlashDiskFolder = value; }
        }
        public string PathLaunchFolder
        {
            get { return this.m_PathLaunchFolder; }
            set { this.m_PathLaunchFolder = value; }
        }
        public string PathLaunchRunFolder
        {
            get { return this.m_PathLaunchRunFolder; }
            set { this.m_PathLaunchRunFolder = value; }
        }
        public string PathPreVersionFolder
        {
            get { return this.m_PathPreVersionFolder; }
            set { this.m_PathPreVersionFolder = value; }
        }
        public string PathPreVersionRunFolder
        {
            get { return this.m_PathPreVersionRunFolder; }
            set { this.m_PathPreVersionRunFolder = value; }
        }
        public string PathDataBackupFolder
        {
            get { return this.m_PathDataBackupFolder; }
            set { this.m_PathDataBackupFolder = value; }
        }
        public string PathFlashDiskSystemFile1Folder
        {
            get { return this.m_PathFlashDiskSystemFile1Folder; }
            set { this.m_PathFlashDiskSystemFile1Folder = value; }
        }
        public string PathFlashDiskSystemFile2Folder
        {
            get { return this.m_PathFlashDiskSystemFile2Folder; }
            set { this.m_PathFlashDiskSystemFile2Folder = value; }
        }
        public string PathSDCardSystemFileFolder
        {
            get { return this.m_PathSDCardSystemFileFolder; }
            set { this.m_PathSDCardSystemFileFolder = value; }
        }
        public string PathSDCardSystemFile1Folder
        {
            get { return this.m_PathSDCardSystemFile1Folder; }
            set { this.m_PathSDCardSystemFile1Folder = value; }
        }
        public string PathSDCardSystemFile2Folder
        {
            get { return this.m_PathSDCardSystemFile2Folder; }
            set { this.m_PathSDCardSystemFile2Folder = value; }
        }
        public string PathSDCardSystemFileBackupFolder
        {
            get { return m_PathSDCardSystemFileBackupFolder; }
            set { m_PathSDCardSystemFileBackupFolder = value; }
        }
        public string PathSDCardRemoveFileFolder
        {
            get { return m_PathSDCardRemoveFileFolder; }
            set { m_PathSDCardRemoveFileFolder = 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 PathDataLogFolder
        {
            get { return this.m_PathDataLogFolder; }
            private set { this.m_PathDataLogFolder = 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 static string PathBinFolder
        {
            get { return m_PathBinFolder; }
            private set { m_PathBinFolder = value; }
        }

        public SystemStatus CurrentSystemStatus
        {
            get { return this.m_CurrentSystemStatus; }
            private set { this.m_CurrentSystemStatus = value; }
        }

        public ProductItem CurrentProductItem
        {
            get { return this.CollectionProductItem[this.SystemConfig1.ProductNumber - 1]; }
            set { this.CollectionProductItem[this.SystemConfig1.ProductNumber - 1] = value; }
        }
        public JudgmentSetItem CurrentJudgmentSetItem
        {
            get { return this.CollectionJudgmentItem[this.SystemConfig1.ProductNumber - 1]; }
            set { this.CollectionJudgmentItem[this.SystemConfig1.ProductNumber - 1] = value; } 
        }
        public WeightData CurrentWeightData
        {
            get { return this.CollectionWeightData[this.SystemConfig1.ProductNumber - 1]; }
            set { this.CollectionWeightData[this.SystemConfig1.ProductNumber - 1] = value; }
        }
        #endregion

        #region Method
        private void DefaultSetting1()
        {
            this.IsCommunicationLogOpen = false;
            this.IsErrorLogOpen = false;
            this.CommunicationCheckCount = 0;
            this.IsBootingComplete = false;
            this.BufferSmartUart = 1000000; // 1MB
            this.ContinuousNGCount = 0;
            this.ProductCount = 1000;
            this.IsBuzzerOnDataSend = false;
            this.IsLampOnDataSend = false;
            this.HMCOM1_Step = 0;
            this.HMCOM3_Step = 0;
            this.HMCOM4_Step = 0;
            this.HMEthernet_Step = 0;
            this.CountingOutput1Count = 0;
            this.CountingOutput2Count = 0;
            this.FlagThreadMessage1 = false;
            this.IsCurrentKeyKorean = false;
            this.OverloadWeight = 700.00;
            this.BLDCMotorIndex = 0;
            this.IsAlarmOccured = false;
            this.UpdateValue = 0;
            this.IsOPCModbusUsing = false;
            this.IsLogProcessing = false;
            this.FlagComRetry3th = 0;
            this.MissingCommIDCount = 0;
            this.CommID = 0;
            this.IsBypassOnce = true;
            this.IsBypassDirectionPass = true;
            this.IsBypassUse = false;
            this.PreviousAlarm = "00000000";

            this.QueueCommunicationRecive = new Queue<string>();

            this.CurrentAlarmList = new AlarmList();
            this.CurrentAlarmList.EventAlarmStateChange += new Define.EventHandlerAlarmStateChange(this.CurrentAlarmList_Change);
            this.CurrentAlarm = new List<short>();
            this.CurrentAlarm.Clear();
            for (int i = 0; i < CurrentAlarmCount; i++)
                this.CurrentAlarm.Add(0);

            this.Modbus = new Modbus();
            this.Current30000ModbusData = new _30000_ModbusData();
            this.Current40000ModbusData = new _40000_ModbusData();

            #region 통신관련
            this.CurrentOPT2COM1 = new SerialOPT2();
            this.CurrentOPT2COM3 = new SerialOPT2();
            this.CurrentOPT2COM4 = new SerialOPT2();
            this.CurrentOPT2Ethernet = new SerialOPT2();

            this.IsMACSARetransmissionCOM1 = false;
            this.IsMACSARetransmissionCOM3 = false;
            this.IsMACSARetransmissionCOM4 = false;
            this.IsMACSARetransmissionEthernet = false;

            this.QueueCOM1 = new Queue<object>();
            this.QueueCOM3 = new Queue<object>();
            this.QueueCOM4 = new Queue<object>();
            this.QueueEthernet = new Queue<object>();
            #endregion

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

            this.PathFlashDiskFolder = "Flash Disk\\";
            this.PathLaunchFolder = "SD Card\\";
            this.PathLaunchRunFolder = this.PathLaunchFolder + "Run\\";
            this.PathPreVersionFolder = this.PathLaunchFolder + "PreVersionBackup\\";
            this.PathPreVersionRunFolder = this.PathPreVersionFolder + "Run\\";
            this.PathFlashDiskSystemFile1Folder = this.PathFlashDiskFolder + "SystemFile1\\";
            this.PathFlashDiskSystemFile2Folder = this.PathFlashDiskFolder + "SystemFile2\\";
            this.PathSDCardSystemFileFolder = this.PathLaunchFolder + "SystemFile\\";
            this.PathSDCardSystemFile1Folder = this.PathLaunchFolder + "SystemFile1\\";
            this.PathSDCardSystemFile2Folder = this.PathLaunchFolder + "SystemFile2\\";
            this.PathDataBackupFolder = this.PathLaunchFolder + "DataBackup\\";
            this.PathSDCardSystemFileBackupFolder = this.PathLaunchFolder + "SystemFileBackup\\";
            this.PathSDCardRemoveFileFolder = this.PathLaunchFolder + "RemoveFile\\";
            this.PathDataFolder = this.PathLaunchFolder + "Data\\";
            this.PathDataHistoryFolder = this.PathDataFolder + "History\\";
            this.PathDataInspectionFolder = this.PathDataFolder + "Inspection\\";
            this.PathDataOthersFolder = this.PathDataFolder + "Others\\";
            this.PathDataLogFolder = this.PathDataOthersFolder + "Log\\";
            this.PathEncryptionFolder = this.PathLaunchFolder + "Encryption\\";
            this.PathHeaderFolder = this.PathLaunchFolder + "Header\\";
            PathBinFolder = this.PathLaunchFolder + "Bin\\";

            this.CurrentComRespone = new CommunicationRespone();

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

            this.CollectionIOTest_InputData = new Collection<string>();
            this.CollectionIOTest_InputData.Clear();
            for (int i = 0; i < 8; i++)
                this.CollectionIOTest_InputData.Add("0");

            this.CollectionIOTestGraphData = new Collection<string>();
            this.CollectionIOTestGraphData.Clear();
            for (int i = 0; i < 500; i++)
                this.CollectionIOTestGraphData.Add("0");

            this.CollectionGraphData = new Collection<int>();
            this.CollectionGraphData.Clear();
            for (int i = 0; i < 100; i++)
                this.CollectionGraphData.Add(0);

            this.SystemConfig1 = new SystemConfigurationItem1();
            this.SystemConfig2 = new SystemConfigurationItem2();
            this.SystemConfig3 = new SystemConfigurationItem3();
            this.CurrentCalibrationItem = new CalibrationItem();
            this.CurrentFeedbackItem = new FeedbackItem();
            this.CurrentSystemStatus = new SystemStatus();
            this.CurrentSystemParameter1 = new SystemParameter1();
            this.CurrentSystemParameter2 = new SystemParameter2();
            this.CurrentSystemParameter3 = new SystemParameter3();
            this.CurrentSystemParameter4 = new SystemParameter4();
            //this.CurrentAutoZeroItem = new SystemParameter4();
            this.SystemInfo2 = new SystemInformation2();
            this.SystemInfo3 = new SystemInformation3();
            this.CurrentUserGroup = new UserGroup();
            this.CollectionBufferWeightData = new Collection<DataBackupOPT1>();
            this.UpdateForMain = new UpdateForMainBoard();

            this.CurrentJudgmentResult = new JudgmentResult();

            this.CollectionBLDCParameter = new Collection<BLDCMotorParameter>();
            for (int i = 0; i < BLDCMotorMaxNum; i++)
                this.CollectionBLDCParameter.Add(new BLDCMotorParameter());

            this.CollectionProductItem = new Collection<ProductItem>();
            this.CollectionJudgmentItem = new Collection<JudgmentSetItem>();
            this.CollectionWeightData = new Collection<WeightData>();
            for (int i = 0; i < this.ProductCount; i++)
            {
                this.CollectionProductItem.Add(new ProductItem());
                this.CollectionJudgmentItem.Add(new JudgmentSetItem());
                this.CollectionWeightData.Add(new WeightData());
            }

            //this.CurrentAutoZeroItem.Initialization();

            // SystemFile1, 2 폴더 생성 + 기존 SystemFile 폴더에서 파일 이동 후 삭제
            DirectoryInfo pathSDCardSystemFileFolder = new DirectoryInfo(this.PathSDCardSystemFileFolder);
            DirectoryInfo pathSDCardSystemFile1Folder = new DirectoryInfo(this.PathSDCardSystemFile1Folder);
            DirectoryInfo pathSDCardSystemFile2Folder = new DirectoryInfo(this.PathSDCardSystemFile2Folder);
            FileInfo[] files;
            if (pathSDCardSystemFile1Folder.Exists == false)
            {
                pathSDCardSystemFile1Folder.Create();
                if (pathSDCardSystemFileFolder.Exists == true)
                {
                    files = pathSDCardSystemFileFolder.GetFiles();
                    foreach (FileInfo subFile in files)
                    {
                        if (subFile.Name != "ProductItem.int" && subFile.Name != "JudgmentSetItem.int" && subFile.Name != "counterItem.int")
                            subFile.MoveTo(this.PathSDCardSystemFile1Folder + subFile.Name);
                    }
                }
            }
            if (pathSDCardSystemFile2Folder.Exists == false)
            {
                pathSDCardSystemFile2Folder.Create();
                if (pathSDCardSystemFileFolder.Exists == true)
                {
                    files = pathSDCardSystemFileFolder.GetFiles();
                    foreach (FileInfo subFile in files)
                    {
                        if (subFile.Name == "ProductItem.int" || subFile.Name == "JudgmentSetItem.int" || subFile.Name == "counterItem.int")
                            subFile.MoveTo(this.PathSDCardSystemFile2Folder + subFile.Name);
                    }
                }
            }
            if (pathSDCardSystemFileFolder.Exists == true)
            {
                files = pathSDCardSystemFileFolder.GetFiles();
                if (files.Length == 0)
                    pathSDCardSystemFileFolder.Delete();
            }

            // COM port 설정
            this.smartSerialPort2.PortNo = SmartSerialPort.COMPORTNO.COM2;
            this.ComPortMainToLCD = "COM2:";

            if (this.FlagSerialDll == true)
            {
                SerialMgrComm.IntializeSerialManager();
                SerialMgrComm.SerialPortMessageReceive += this.SerialPort_MessageReceive;
                SerialMgrComm.SerialPortErrMessageReceive += this.SerialPort_ErrMessageReceive;
            }

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

            // Log 폴더 생성
            if (Directory.Exists(this.PathDataLogFolder) == false)
                Directory.CreateDirectory(this.PathDataLogFolder);
        }
        private void DefaultSetting2()
        {
            // 바코드
            if (this.SystemConfig1.IsBarcodeEnable == true)
            {
                this.CurrentBarcode = new Barcode(this.CollectionProductItem, this.ProductCount);

                if (this.CollectionProductItem[0].Name != BarcodeStatus.NoRead.ToString() || this.CollectionProductItem[0].LotNo != BarcodeStatus.NoRead.ToString())
                {
                    this.CollectionProductItem[0].Name = BarcodeStatus.NoRead.ToString();
                    this.CollectionProductItem[0].LotNo = BarcodeStatus.NoRead.ToString();
                    this.SaveProductFile(this.CollectionProductItem[0], 0);
                }

                if (this.CollectionProductItem[1].Name != BarcodeStatus.NoMatch.ToString() || this.CollectionProductItem[1].LotNo != BarcodeStatus.NoMatch.ToString())
                {
                    this.CollectionProductItem[1].Name = BarcodeStatus.NoMatch.ToString();
                    this.CollectionProductItem[1].LotNo = BarcodeStatus.NoMatch.ToString();
                    this.SaveProductFile(this.CollectionProductItem[1], 1);
                }

                // 통신 포트 설정
                this.CloseSerialCOM3();

                // STXANDETX
                this.ChangeSerialCOM3FrameSeparateType(Define.E_SeparateType.STXANDETX);

                this.smartSerialPort3.Baud_Rate = SmartSerialPort.BAUDRATE._9600bps;
                this.smartSerialPort3.Open();
            }

            // 이더넷
            if (this.smartConfigs.IPSettings.DHCPEnable != 0)
            {
                this.smartConfigs.IPSettings.DHCPEnable = 0;
                this.smartConfigs.IPSettings.Save();
                this.smartConfigs.IPSettings.SetApply();
            }
            if (this.SystemConfig2.EthernetOperationMode == 1)
            {
                try
                {
                    if (string.Compare(this.smartConfigs.IPSettings.DeviceIP, "0.0.0.0") != 0)
                        this.EthernetServerStart();

                    if (this.smartTCPMultiServer.IsStart == true)
                        this.ChildFormMainDisplay.TimerServer(true);
                }
                catch
                {

                }
            }
            else if (this.SystemConfig2.EthernetOperationMode == 2)
                this.EthernetClientDisconnect();

            if (this.SystemConfig2.EthernetCommMode != (int)Define.E_CommMode.f0_None)
            {
                switch (this.SystemConfig2.EthernetCommMode)
                {
                    case (int)Define.E_CommMode.f16_OPC:
                    case (int)Define.E_CommMode.f22_Modbus:
                        this.ChildFormMainDisplay.MainBottomModbusIconAdd(true);
                        break;
                    default:
                        break;
                }
            }

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

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

                // Bin 폴더 생성
                if (Directory.Exists(PathBinFolder) == false)
                    Directory.CreateDirectory(PathBinFolder);
            }
        }
        private void CreateForm()
        {
            this.ChildFormMainDisplay = new FormMainDisplay(this);
            this.ChildFormMenu = new FormMenu(this);

            this.smartForm.MainForm = this;

            this.smartForm.AddChildForm(this.ChildFormMainDisplay);
            this.smartForm.AddChildForm(this.ChildFormMenu);
        }

        public void OnExternalInputBuzzerSignal(bool bValue)
        {
            if (bValue == true)
                this.TransferData(CommunicationCommand.BuzzerOnContinuousEnable, CommunicationID.MainBoard);
            else
                this.TransferData(CommunicationCommand.BuzzerOnContinuousDisable, CommunicationID.MainBoard);
        }
        public void OnExternalInputLampSignal(bool bValue)
        {
            if (bValue == true)
                this.TransferData(CommunicationCommand.LampOnContinuousEnable, CommunicationID.MainBoard);
            else
                this.TransferData(CommunicationCommand.LampOnContinuousDisable, CommunicationID.MainBoard);
        }

        public static void Exception(Exception ex)
        {
            try
            {
                string fileName = "SD Card\\Data\\Others\\Log\\" + string.Format("{0:yyyyMMdd_HHmmss}_Exception.txt", DateTime.Now);
                FileStream fs = new FileStream(fileName, FileMode.OpenOrCreate);
                StreamWriter sw = new StreamWriter(fs);

                sw.Write(ex.ToString());

                sw.Close();
                fs.Close();
            }
            catch
            {
                string fileName = "Flash Disk\\" + string.Format("{0:yyyyMMdd_HHmmss}_Exception.txt", DateTime.Now);
                FileStream fs = new FileStream(fileName, FileMode.OpenOrCreate);
                StreamWriter sw = new StreamWriter(fs);

                sw.Write(ex.ToString());

                sw.Close();
                fs.Close();
            }
        }
        public void OnExternalInputBuzzerSignal(bool bValue, bool flagValue)
        {
            if (bValue == true)
                this.TransferData(CommunicationCommand.BuzzerOnContinuousEnable, CommunicationID.MainBoard);
            else
                this.TransferData(CommunicationCommand.BuzzerOnContinuousDisable, CommunicationID.MainBoard);

            if(flagValue == true)
                this.IsBuzzerOnDataSend = true;
            else
                this.IsBuzzerOnDataSend = false;
        }
        public void OnExternalInputLampSignal(bool bValue, bool flagValue)
        {
            if (bValue == true)
                this.TransferData(CommunicationCommand.LampOnContinuousEnable, CommunicationID.MainBoard);
            else
                this.TransferData(CommunicationCommand.LampOnContinuousDisable, CommunicationID.MainBoard);

            if(flagValue == true)
                this.IsLampOnDataSend = true;
            else
                this.IsLampOnDataSend = false;
        }
        private void ConverterResult(string alarm)
        {
            string sValue1 = "", sValue2 = "", sValue3 = "", sValue4 = "";

            if (alarm.Length != 4)
                return;

            this.CurrentJudgmentResult.Initialize();

            sValue1 = Convert.ToString(Convert.ToInt16(alarm.Substring(0, 1), 16), 2).PadLeft((4 <= 1) ? 1 : 4, '0');
            sValue2 = Convert.ToString(Convert.ToInt16(alarm.Substring(1, 1), 16), 2).PadLeft((4 <= 1) ? 1 : 4, '0');
            sValue3 = Convert.ToString(Convert.ToInt16(alarm.Substring(2, 1), 16), 2).PadLeft((4 <= 1) ? 1 : 4, '0');
            sValue4 = Convert.ToString(Convert.ToInt16(alarm.Substring(3, 1), 16), 2).PadLeft((4 <= 1) ? 1 : 4, '0');

            // 판정 16-
            if (sValue4[0] == '0')
            { }
            else
            { }
            // 판정 15-
            if (sValue4[1] == '0')
            { }
            else
            { }
            // 판정 14-
            if (sValue4[2] == '0')
            { }
            else
            { }
            // 판정 13-리젝터 동작 상태
            if (this.CurrentSystemParameter1.PI8 == 1)
            {
                if (sValue4[3] == '0')
                    this.CurrentJudgmentResult.CurrentRejectData = Define.E_JudgmentResult.OK;
                else
                    this.CurrentJudgmentResult.CurrentRejectData = Define.E_JudgmentResult.NG;
            }

            // 판정 12-
            if (sValue3[0] == '0')
            { }
            else
            { }
            // 판정 11-
            if (sValue3[1] == '0')
            { }
            else
            { }
            // 판정 10-
            if (sValue3[2] == '0')
            { }
            else
            { }
            // 판정 9-
            if (this.CurrentSystemParameter1.PI8 == 1)
            {
                if (sValue3[3] == '0')
                    this.CurrentJudgmentResult.PreviousRejectData = Define.E_JudgmentResult.OK;
                else
                    this.CurrentJudgmentResult.PreviousRejectData = Define.E_JudgmentResult.NG;
            }

            // 판정 8-
            if (sValue2[0] == '0')
            { }
            else
            { }
            // 판정 7-
            if (sValue2[1] == '0')
            { }
            else
            { }
            // 판정 6-
            if (sValue2[2] == '0')
            { }
            else
            { }
            // 판정 5-
            if (sValue2[3] == '0')
            { }
            else
            { }

            // 판정 4-
            if (sValue1[0] == '0')
            { }
            else
            { }
            // 판정 3-
            if (sValue1[1] == '0')
            { }
            else
            { }
            // 판정 2-
            if (sValue1[2] == '0')
            { }
            else
            { }
            // 판정 1-
            if (sValue1[3] == '0')
            { }
            else
            { }
        }
        private void BarcodeProductChange(Barcode barcode)
        {
            int productNo = 0;
            BarcodeStatus status = BarcodeStatus.None;

            status = barcode.GetData(ref productNo);
            // 품목변환
            this.TransferProductParameter(productNo);

            if (status == BarcodeStatus.NoRead || status == BarcodeStatus.NoMatch)
            {
                // 기타NG  전송(메인에서 NG 처리할수있도록)
                this.TransferData(CommunicationCommand.JudgmentExternalNG, CommunicationID.MainBoard);
            }

            this.ChildFormMainDisplay.UpdateBarcodeDisplay(this.CurrentBarcode);
        }
        private void UpdateCountData(WeightData wData)
        {
            if (this.SystemConfig1.ProductNumber == wData.BoardProductNumber)
            {
                if (wData.ExNGCount < wData.BoardExNGCount)
                    this.CurrentWeightData.ETCExNGCount = wData.BoardExNGCount - wData.BoardMetalDetectionCount - wData.BoardDoubleEntryCount;

                if (wData.MetalDetectionCount < wData.BoardMetalDetectionCount)
                    this.CurrentWeightData.MetalDetectionCount = wData.BoardMetalDetectionCount;

                if (wData.DoubleEntryCount < wData.BoardDoubleEntryCount)
                    this.CurrentWeightData.DoubleEntryCount = wData.BoardDoubleEntryCount;

                if (wData.OverCount < wData.BoardOverCount)
                    this.CurrentWeightData.OverCount = wData.BoardOverCount;

                if (wData.PassCount < wData.BoardPassCount)
                    this.CurrentWeightData.PassCount = wData.BoardPassCount;

                if (wData.UnderCount < wData.BoardUnderCount)
                    this.CurrentWeightData.UnderCount = wData.BoardUnderCount;

                if (wData.StartTime.Year == 1111)
                {
                    wData.StartTime = DateTime.Now;
                    this.CurrentWeightData.StartTime = wData.StartTime;
                }
                if (wData.StopTime.Year == 1111)
                {
                    wData.StopTime = DateTime.Now;
                    this.CurrentWeightData.StopTime = wData.StopTime;
                }

                this.SaveCounterFile(this.CurrentWeightData, this.SystemConfig1.ProductNumber - 1);

                if (this.ChildFormMainDisplay != null)
                    this.ChildFormMainDisplay.UpdateCurrentProductDisplay(this.CurrentSystemStatus.Equipment, this.CurrentProductItem, this.CurrentWeightData);
            }
        }

        private void StartThreadMessage1()
        {
            if (this.smartThread.State != SmartThread.ThreadState.Running)
            {
                this.smartThread.Start();
                this.FlagThreadMessage1 = false;
            }
        }
        private bool UI_Invoke(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));
            });
        }

        /// <summary>
        /// Set Mode
        /// </summary>
        /// <param name="mode"></param>
        public void SetDisplayMode(Define.E_DisplayMode mode)
        {
            if (this.CurrentSystemStatus.CurrentMode == mode)
                return;
            else
                this.CurrentSystemStatus.CurrentMode = mode;

            switch (mode)
            {
                case Define.E_DisplayMode.Normal:
                    this.TransferData(CommunicationCommand.ModeNormal, CommunicationID.MainBoard);
                    break;
                case Define.E_DisplayMode.Menu:
                    this.TransferData(CommunicationCommand.ModeMenu, CommunicationID.MainBoard);
                    break;
                case Define.E_DisplayMode.Calibration:
                    this.TransferData(CommunicationCommand.ModeCalibration, CommunicationID.MainBoard);
                    break;
                case Define.E_DisplayMode.SystemSetting:
                    this.TransferData(CommunicationCommand.ModeJudgment, CommunicationID.MainBoard);
                    break;
                case Define.E_DisplayMode.IOTest:
                    this.TransferData(CommunicationCommand.ModeIOTest, CommunicationID.MainBoard);
                    break;
                case Define.E_DisplayMode.Bypass:
                    this.TransferData(CommunicationCommand.ModeBypass, CommunicationID.MainBoard);
                    break;
                case Define.E_DisplayMode.EquipmentTest:
                    this.TransferData(CommunicationCommand.ModeEquipmentTest, CommunicationID.MainBoard);
                    break;
                case Define.E_DisplayMode.SorterTest:
                    this.TransferData(CommunicationCommand.ModeRejectorTest, CommunicationID.MainBoard);
                    break;
                default:
                    break;
            }
        }
        
        private void RetryUpdateForMain(UpdateForMainBoard update)
        {
            this.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard,
               CommunicationAddress._1651_UpdateForMain, Helper.StringZeroFillDigits4(update.Index.ToString()), update.SendData);

            this.smartTimerUpdate.Start();
        }
        public void SendUpdateForMain(byte[] datas)
        {
            int count = 0;

            if (datas.Length == 0)
                return;

            count = datas.Length / 100;

            if (count != 0)
            {
                this.UpdateForMain.SendData = new byte[100];
                for (int i = 0; i < 100; i++)
                    this.UpdateForMain.SendData[i] = datas[i];
            }
            else
            {
                this.UpdateForMain.SendData = new byte[datas.Length];
                for (int i = 0; i < datas.Length; i++)
                    this.UpdateForMain.SendData[i] = datas[i];

                this.UpdateForMain.IsLastData = true;
            }

            this.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard,
                CommunicationAddress._1651_UpdateForMain, Helper.StringZeroFillDigits4(this.UpdateForMain.Index.ToString()), this.UpdateForMain.SendData);

            if (this.UpdateForMain.ProgressBar1 == count)
                this.ChildFormMenu.CenterEquipUpdate.SetProgressBarValue(10);
            else if (this.UpdateForMain.ProgressBar2 == count)
                this.ChildFormMenu.CenterEquipUpdate.SetProgressBarValue(10);
            else if (this.UpdateForMain.ProgressBar3 == count)
                this.ChildFormMenu.CenterEquipUpdate.SetProgressBarValue(10);
            else if (this.UpdateForMain.ProgressBar4 == count)
                this.ChildFormMenu.CenterEquipUpdate.SetProgressBarValue(10);
            else if (this.UpdateForMain.ProgressBar5 == count)
                this.ChildFormMenu.CenterEquipUpdate.SetProgressBarValue(10);
            else if (this.UpdateForMain.ProgressBar6 == count)
                this.ChildFormMenu.CenterEquipUpdate.SetProgressBarValue(10);
            else if (this.UpdateForMain.ProgressBar7 == count)
                this.ChildFormMenu.CenterEquipUpdate.SetProgressBarValue(10);
            else if (this.UpdateForMain.ProgressBar8 == count)
                this.ChildFormMenu.CenterEquipUpdate.SetProgressBarValue(10);

            this.smartTimerUpdate.Start();
        }

        public void PrintingHeadLine()
        {
            if (this.SystemConfig1.SerialCOM1Mode == (int)Define.E_CommMode.f3_Printer)
            {
                this.TransferSerialCOM1("\n--------------------------------");
                this.TransferSerialCOM1(" NO    GRADE  WEIGHT");
                this.TransferSerialCOM1("(" + this.SystemConfig1.Unit + ")");
                this.TransferSerialCOM1("  COUNT");
                this.TransferSerialCOM1("\n--------------------------------");
            }
            if (this.SystemConfig1.SerialCOM3Mode == (int)Define.E_CommMode.f3_Printer)
            {
                this.TransferSerialCOM3("\n--------------------------------");
                this.TransferSerialCOM3(" NO    GRADE  WEIGHT");
                this.TransferSerialCOM3("(" + this.SystemConfig1.Unit + ")");
                this.TransferSerialCOM3("  COUNT");
                this.TransferSerialCOM3("\n--------------------------------");
            }
            if (this.SystemConfig1.SerialCOM4Mode == (int)Define.E_CommMode.f3_Printer)
            {
                this.TransferSerialCOM4("\n--------------------------------");
                this.TransferSerialCOM4(" NO    GRADE  WEIGHT");
                this.TransferSerialCOM4("(" + this.SystemConfig1.Unit + ")");
                this.TransferSerialCOM4("  COUNT");
                this.TransferSerialCOM4("\n--------------------------------");
            }
        }
        public void PrintingWeight(WeightData data, ProductItem pItem)
        {
            string value = "";

            if (this.SystemConfig1.SerialCOM1Mode == 3)
            {
                #region CH1(COM1)
                this.TransferSerialCOM1("\n################################");
                this.TransferSerialCOM1("\n           TOTAL  PRINT         ");
                this.TransferSerialCOM1("\n################################");
                this.TransferSerialCOM1(string.Format("\nPART       = {0}", pItem.Number));
                this.TransferSerialCOM1(string.Format("\nSTART      = {0}", data.StartTime.ToString("yyyy-MM-dd HH:mm:ss")));
                this.TransferSerialCOM1(string.Format("\nEND        = {0}", data.StopTime.ToString("yyyy-MM-dd HH:mm:ss")));

                this.TransferSerialCOM1(string.Format("\n\nUNDER      = {0}{1}",
                    Helper.StringToDecimalPlaces(pItem.UnderRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
                this.TransferSerialCOM1(string.Format("\n COUNT     = {0}", data.UnderCount));
                this.TransferSerialCOM1(string.Format("\n TOTAL.W   = {0}kg", data.UnderSumWeightKG));
                this.TransferSerialCOM1(string.Format("\n AVG       = {0}{1}",
                    Helper.DoubleToString(data.UnderAverage, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
                this.TransferSerialCOM1(string.Format("\n RATIO     = {0}%", data.UnderRatio));

                this.TransferSerialCOM1(string.Format("\n\nPASS       = {0}{1}",
                  Helper.StringToDecimalPlaces(pItem.PassRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
                this.TransferSerialCOM1(string.Format("\n COUNT     = {0}", data.PassCount));
                this.TransferSerialCOM1(string.Format("\n TOTAL.W   = {0}kg", data.PassSumWeightKG));
                this.TransferSerialCOM1(string.Format("\n AVG       = {0}{1}",
                    Helper.DoubleToString(data.PassAverage, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
                this.TransferSerialCOM1(string.Format("\n RATIO     = {0}%", data.PassRatio));

                this.TransferSerialCOM1(string.Format("\n\nOVER       = {0}{1}",
                  Helper.StringToDecimalPlaces(pItem.OverRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
                this.TransferSerialCOM1(string.Format("\n COUNT     = {0}", data.OverCount));
                this.TransferSerialCOM1(string.Format("\n TOTAL.W   = {0}kg", data.OverSumWeightKG));
                this.TransferSerialCOM1(string.Format("\n AVG       = {0}{1}",
                    Helper.DoubleToString(data.OverAverage, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
                this.TransferSerialCOM1(string.Format("\n RATIO     = {0}%", data.OverRatio));

                this.TransferSerialCOM1(string.Format("\n\nTARE       = {0}{1}",
                    Helper.StringToDecimalPlaces(pItem.TareRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
                this.TransferSerialCOM1(string.Format("\n\nFaulty     = {0}", data.TotalUnderOverCount));
                this.TransferSerialCOM1(string.Format("\n\nOther.F     = {0}", data.ExNGCount));

                this.TransferSerialCOM1(string.Format("\n\nTOTAL.COUNT= {0}", data.TotalCount));

                this.TransferSerialCOM1("\n################################\n\n\n\n");
                #endregion
            }
            else if (this.SystemConfig1.SerialCOM3Mode == 3)
            {
                #region CH2(COM3)
                this.TransferSerialCOM3("\n################################");
                this.TransferSerialCOM3("\n           TOTAL  PRINT         ");
                this.TransferSerialCOM3("\n################################");
                this.TransferSerialCOM3(string.Format("\nPART       = {0}", pItem.Number));
                this.TransferSerialCOM3(string.Format("\nSTART      = {0}", data.StartTime.ToString("yyyy-MM-dd HH:mm:ss")));
                this.TransferSerialCOM3(string.Format("\nEND        = {0}", data.StopTime.ToString("yyyy-MM-dd HH:mm:ss")));

                this.TransferSerialCOM3(string.Format("\n\nUNDER      = {0}{1}",
                    Helper.StringToDecimalPlaces(pItem.UnderRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
                this.TransferSerialCOM3(string.Format("\n COUNT     = {0}", data.UnderCount));
                this.TransferSerialCOM3(string.Format("\n TOTAL.W   = {0}kg", data.UnderSumWeightKG));
                this.TransferSerialCOM3(string.Format("\n AVG       = {0}{1}",
                    Helper.DoubleToString(data.UnderAverage, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
                this.TransferSerialCOM3(string.Format("\n RATIO     = {0}%", data.UnderRatio));

                this.TransferSerialCOM3(string.Format("\n\nPASS       = {0}{1}",
                  Helper.StringToDecimalPlaces(pItem.PassRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
                this.TransferSerialCOM3(string.Format("\n COUNT     = {0}", data.PassCount));
                this.TransferSerialCOM3(string.Format("\n TOTAL.W   = {0}kg", data.PassSumWeightKG));
                this.TransferSerialCOM3(string.Format("\n AVG       = {0}{1}",
                    Helper.DoubleToString(data.PassAverage, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
                this.TransferSerialCOM3(string.Format("\n RATIO     = {0}%", data.PassRatio));

                this.TransferSerialCOM3(string.Format("\n\nOVER       = {0}{1}",
                  Helper.StringToDecimalPlaces(pItem.OverRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
                this.TransferSerialCOM3(string.Format("\n COUNT     = {0}", data.OverCount));
                this.TransferSerialCOM3(string.Format("\n TOTAL.W   = {0}kg", data.OverSumWeightKG));
                this.TransferSerialCOM3(string.Format("\n AVG       = {0}{1}",
                    Helper.DoubleToString(data.OverAverage, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
                this.TransferSerialCOM3(string.Format("\n RATIO     = {0}%", data.OverRatio));

                this.TransferSerialCOM3(string.Format("\n\nTARE       = {0}{1}",
                    Helper.StringToDecimalPlaces(pItem.TareRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
                this.TransferSerialCOM3(string.Format("\n\nFaulty     = {0}", data.TotalUnderOverCount));
                this.TransferSerialCOM3(string.Format("\n\nOther.F     = {0}", data.ExNGCount));

                this.TransferSerialCOM3(string.Format("\n\nTOTAL.COUNT= {0}", data.TotalCount));

                this.TransferSerialCOM3("\n################################\n\n\n\n");
                #endregion
            }
            else if (this.SystemConfig1.SerialCOM4Mode == 3)
            {
                #region CH3(COM4)
                this.TransferSerialCOM4("\n################################");
                this.TransferSerialCOM4("\n           TOTAL  PRINT         ");
                this.TransferSerialCOM4("\n################################");
                this.TransferSerialCOM4(string.Format("\nPART       = {0}", pItem.Number));
                this.TransferSerialCOM4(string.Format("\nSTART      = {0}", data.StartTime.ToString("yyyy-MM-dd HH:mm:ss")));
                this.TransferSerialCOM4(string.Format("\nEND        = {0}", data.StopTime.ToString("yyyy-MM-dd HH:mm:ss")));

                this.TransferSerialCOM4(string.Format("\n\nUNDER      = {0}{1}",
                    Helper.StringToDecimalPlaces(pItem.UnderRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
                this.TransferSerialCOM4(string.Format("\n COUNT     = {0}", data.UnderCount));
                this.TransferSerialCOM4(string.Format("\n TOTAL.W   = {0}kg", data.UnderSumWeightKG));
                this.TransferSerialCOM4(string.Format("\n AVG       = {0}{1}",
                    Helper.DoubleToString(data.UnderAverage, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
                this.TransferSerialCOM4(string.Format("\n RATIO     = {0}%", data.UnderRatio));

                this.TransferSerialCOM4(string.Format("\n\nPASS       = {0}{1}",
                  Helper.StringToDecimalPlaces(pItem.PassRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
                this.TransferSerialCOM4(string.Format("\n COUNT     = {0}", data.PassCount));
                this.TransferSerialCOM4(string.Format("\n TOTAL.W   = {0}kg", data.PassSumWeightKG));
                this.TransferSerialCOM4(string.Format("\n AVG       = {0}{1}",
                    Helper.DoubleToString(data.PassAverage, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
                this.TransferSerialCOM4(string.Format("\n RATIO     = {0}%", data.PassRatio));

                this.TransferSerialCOM4(string.Format("\n\nOVER       = {0}{1}",
                  Helper.StringToDecimalPlaces(pItem.OverRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
                this.TransferSerialCOM4(string.Format("\n COUNT     = {0}", data.OverCount));
                this.TransferSerialCOM4(string.Format("\n TOTAL.W   = {0}kg", data.OverSumWeightKG));
                this.TransferSerialCOM4(string.Format("\n AVG       = {0}{1}",
                    Helper.DoubleToString(data.OverAverage, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
                this.TransferSerialCOM4(string.Format("\n RATIO     = {0}%", data.OverRatio));

                this.TransferSerialCOM4(string.Format("\n\nTARE       = {0}{1}",
                    Helper.StringToDecimalPlaces(pItem.TareRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
                this.TransferSerialCOM4(string.Format("\n\nFaulty     = {0}", data.TotalUnderOverCount));
                this.TransferSerialCOM4(string.Format("\n\nOther.F     = {0}", data.ExNGCount));

                this.TransferSerialCOM4(string.Format("\n\nTOTAL.COUNT= {0}", data.TotalCount));

                this.TransferSerialCOM4("\n################################\n\n\n\n");
                #endregion
            }
        }
        public void PrintingWeight2(WeightData data, ProductItem pItem)
        {
            string value = "";

            if (this.SystemConfig1.SerialCOM1Mode == 3)
            {
                #region CH1(COM1)
                this.TransferSerialCOM1("\n################################");
                this.TransferSerialCOM1("\n           TOTAL  PRINT         ");
                this.TransferSerialCOM1("\n################################");
                this.TransferSerialCOM1(string.Format("\nPART NAME  = {0}", pItem.Name));
                this.TransferSerialCOM1(string.Format("\nPART No.   = {0}", pItem.Number));
                this.TransferSerialCOM1(string.Format("\nLOT No.    = {0}", pItem.LotNo));
                this.TransferSerialCOM1(string.Format("\nSTART      = {0}", data.StartTime.ToString("yyyy-MM-dd HH:mm")));
                this.TransferSerialCOM1(string.Format("\nEND        = {0}", data.StopTime.ToString("yyyy-MM-dd HH:mm")));

                this.TransferSerialCOM1(string.Format("\n\nUNDER      = {0}{1}",
                    Helper.StringToDecimalPlaces(pItem.UnderRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
                this.TransferSerialCOM1(string.Format("\n COUNT     = {0}", data.UnderCount));

                this.TransferSerialCOM1(string.Format("\n\nPASS       = {0}{1}",
                  Helper.StringToDecimalPlaces(pItem.PassRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
                this.TransferSerialCOM1(string.Format("\n COUNT     = {0}", data.PassCount));
                this.TransferSerialCOM1(string.Format("\n AVG       = {0}{1}",
                    Helper.DoubleToString(data.PassAverage, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
                
                this.TransferSerialCOM1(string.Format("\n\nOVER       = {0}{1}",
                  Helper.StringToDecimalPlaces(pItem.OverRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
                this.TransferSerialCOM1(string.Format("\n COUNT     = {0}", data.OverCount));

                this.TransferSerialCOM1(string.Format("\n\nTARE       = {0}{1}",
                    Helper.StringToDecimalPlaces(pItem.TareRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));

                this.TransferSerialCOM1(string.Format("\n\nTOTAL.COUNT= {0}", data.TotalCount));

                this.TransferSerialCOM1("\n################################\n\n\n\n");
                #endregion
            }
            else if (this.SystemConfig1.SerialCOM3Mode == 3)
            {
                #region CH2(COM3)
                this.TransferSerialCOM3("\n################################");
                this.TransferSerialCOM3("\n           TOTAL  PRINT         ");
                this.TransferSerialCOM3("\n################################");
                this.TransferSerialCOM3(string.Format("\nPART NAME  = {0}", pItem.Name));
                this.TransferSerialCOM3(string.Format("\nPART No.   = {0}", pItem.Number));
                this.TransferSerialCOM3(string.Format("\nLOT No.    = {0}", pItem.LotNo));
                this.TransferSerialCOM3(string.Format("\nSTART      = {0}", data.StartTime.ToString("yyyy-MM-dd HH:mm")));
                this.TransferSerialCOM3(string.Format("\nEND        = {0}", data.StopTime.ToString("yyyy-MM-dd HH:mm")));

                this.TransferSerialCOM3(string.Format("\n\nUNDER      = {0}{1}",
                    Helper.StringToDecimalPlaces(pItem.UnderRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
                this.TransferSerialCOM3(string.Format("\n COUNT     = {0}", data.UnderCount));

                this.TransferSerialCOM3(string.Format("\n\nPASS       = {0}{1}",
                  Helper.StringToDecimalPlaces(pItem.PassRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
                this.TransferSerialCOM3(string.Format("\n COUNT     = {0}", data.PassCount));
                this.TransferSerialCOM3(string.Format("\n AVG       = {0}{1}",
                    Helper.DoubleToString(data.PassAverage, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));

                this.TransferSerialCOM3(string.Format("\n\nOVER       = {0}{1}",
                  Helper.StringToDecimalPlaces(pItem.OverRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
                this.TransferSerialCOM3(string.Format("\n COUNT     = {0}", data.OverCount));

                this.TransferSerialCOM3(string.Format("\n\nTARE       = {0}{1}",
                    Helper.StringToDecimalPlaces(pItem.TareRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));

                this.TransferSerialCOM3(string.Format("\n\nTOTAL.COUNT= {0}", data.TotalCount));

                this.TransferSerialCOM3("\n################################\n\n\n\n");
                #endregion
            }
            else if (this.SystemConfig1.SerialCOM4Mode == 3)
            {
                #region CH3(COM4)
                this.TransferSerialCOM4("\n################################");
                this.TransferSerialCOM4("\n           TOTAL  PRINT         ");
                this.TransferSerialCOM4("\n################################");
                this.TransferSerialCOM4(string.Format("\nPART NAME  = {0}", pItem.Name));
                this.TransferSerialCOM4(string.Format("\nPART No.   = {0}", pItem.Number));
                this.TransferSerialCOM4(string.Format("\nLOT No.    = {0}", pItem.LotNo));
                this.TransferSerialCOM4(string.Format("\nSTART      = {0}", data.StartTime.ToString("yyyy-MM-dd HH:mm")));
                this.TransferSerialCOM4(string.Format("\nEND        = {0}", data.StopTime.ToString("yyyy-MM-dd HH:mm")));

                this.TransferSerialCOM4(string.Format("\n\nUNDER      = {0}{1}",
                    Helper.StringToDecimalPlaces(pItem.UnderRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
                this.TransferSerialCOM4(string.Format("\n COUNT     = {0}", data.UnderCount));

                this.TransferSerialCOM4(string.Format("\n\nPASS       = {0}{1}",
                  Helper.StringToDecimalPlaces(pItem.PassRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
                this.TransferSerialCOM4(string.Format("\n COUNT     = {0}", data.PassCount));
                this.TransferSerialCOM4(string.Format("\n AVG       = {0}{1}",
                    Helper.DoubleToString(data.PassAverage, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));

                this.TransferSerialCOM4(string.Format("\n\nOVER       = {0}{1}",
                  Helper.StringToDecimalPlaces(pItem.OverRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
                this.TransferSerialCOM4(string.Format("\n COUNT     = {0}", data.OverCount));

                this.TransferSerialCOM4(string.Format("\n\nTARE       = {0}{1}",
                    Helper.StringToDecimalPlaces(pItem.TareRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));

                this.TransferSerialCOM4(string.Format("\n\nTOTAL.COUNT= {0}", data.TotalCount));

                this.TransferSerialCOM4("\n################################\n\n\n\n");
                #endregion
            }
        }

        private void UpdateScreen()
        {
            if (this.ChildFormMainDisplay.MainFeedback.IsUsingFeedback() == true)
            {
                this.UpdateFeedbackData(this.CurrentProductItem, this.CurrentSystemParameter2);
                this.UpdateFeedbackDeviation(this.CurrentProductItem, this.CurrentSystemParameter2);
            }

            if (this.CurrentSystemStatus.CurrentDisplay == Define.E_DisplayStore.MainDisplay)
            {
                if (this.ChildFormMainDisplay != null)
                    this.ChildFormMainDisplay.UpdateCurrentProductDisplay(this.CurrentSystemStatus.Equipment, this.CurrentProductItem, this.CurrentWeightData);

                this.ChildFormMainDisplay.UpdateModbusScreen();
            }
            else if (this.CurrentSystemStatus.CurrentDisplay == Define.E_DisplayStore.SystemSorterSetting)
            {
                if (this.ChildFormMenu.CenterSystemSorterSetting != null)
                    this.ChildFormMenu.CenterSystemSorterSetting.UpdateCurrentProductDisplay(this.CurrentSystemStatus.Equipment, this.CurrentProductItem);
            }
            else
            {
                if (this.ChildFormMenu.CenterSystemJudgment != null)
                    this.ChildFormMenu.CenterSystemJudgment.UpdateCurrentProductDisplay(this.CurrentSystemStatus.Equipment, this.CurrentProductItem);
            }
        }

        private void InitializeAES()
        {
            Encryption.DllAesEncryption_Event += Aes_Encryption_Event;
            Encryption.DllAesEncryption_GetVersionDataEvent += AesEncryption_GetVersionDataEvent;

            Encryption.InitializeEncryption();
        }

        // 피드백 데이터(피드백 편차 변경 X)
        public void UpdateFeedbackData(ProductItem item, SystemParameter2 parameter)
        {
            if (this.ChildFormMainDisplay.MainFeedback.IsUsingFeedback() == true)
            {
                int temp = 0;
                string feedbackValue = "";

                if (parameter.OPT1IsWeightSetting == "1")
                {
                    temp = item.PassRangeInt + this.CurrentFeedbackItem.OverRangeDeviationInt;
                    if (temp <= 0)
                    {
                        parameter.OPT1OverRange = "0";
                        this.UpdateFeedbackDeviation(this.CurrentProductItem, this.CurrentSystemParameter2);
                    }
                    else
                        parameter.OPT1OverRange = (item.PassRangeInt + this.CurrentFeedbackItem.OverRangeDeviationInt).ToString();

                    temp = item.PassRangeInt + this.CurrentFeedbackItem.UnderRangeDeviationInt;
                    if (temp <= 0)
                    {
                        parameter.OPT1UnderRange = "0";
                        this.UpdateFeedbackDeviation(this.CurrentProductItem, this.CurrentSystemParameter2);
                    }
                    else
                        parameter.OPT1UnderRange = (item.PassRangeInt + this.CurrentFeedbackItem.UnderRangeDeviationInt).ToString();
                }
                else
                {
                    parameter.OPT1OverRange = item.OverRange;
                    parameter.OPT1UnderRange = item.UnderRange;
                }

                if (parameter.OPT1OverRangeInt < item.PassRangeInt)
                    parameter.OPT1OverRange = item.PassRange;

                this.SaveSystemParameter2File(parameter);
                feedbackValue = Helper.StringZeroFillDigits7(parameter.OPT1OverRange);
                this.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.OPT1OverRange, feedbackValue);
                feedbackValue = Helper.StringZeroFillDigits7(parameter.OPT1UnderRange);
                this.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.OPT1UnderRange, feedbackValue);
            }

            this.ChildFormMainDisplay.MainFeedback.DisplayRefresh(this.CurrentSystemStatus);
        }
        public void UpdateFeedbackDeviation(ProductItem item, SystemParameter2 parameter)
        {
            string sValue = "";

            sValue = this.ChildFormMainDisplay.MainFeedback.CaculateDeviation(parameter.OPT1OverRangeInt);
            this.CurrentFeedbackItem.OverRangeDeviation = sValue;

            sValue = this.ChildFormMainDisplay.MainFeedback.CaculateDeviation(parameter.OPT1UnderRangeInt);
            this.CurrentFeedbackItem.UnderRangeDeviation = sValue;

            this.ChildFormMainDisplay.MainFeedback.DisplayRefresh(this.CurrentSystemStatus);
        }

        // PreVersionBackup\\ 폴더 체크
        private bool CheckPreVersionFolder()
        {
            bool ret = false;

            DirectoryInfo dirPreVersionFolder = new DirectoryInfo(this.PathPreVersionFolder);
            if (dirPreVersionFolder.Exists == false)
                ret = false;
            else
                ret = true;

            return ret;
        }
        // Version.ini 파일 확인 후 갱신
        private void CheckCurrentVersionIniFile()
        {
            FileInfo fileCurrentVersionCfg = new FileInfo(this.PathLaunchFolder + "Version.ini");
            if (fileCurrentVersionCfg.Exists == false)
            {
                VersionIniFile.CreateVersionIni("ITC81D_2H", DisplayVersion, ReleaseDate);
            }
            else
            {
                if (VersionIniFile.GetIni("PROGRAMINFO", "VERSION", "", this.PathLaunchFolder + "Version.ini") != DisplayVersion) ;
                {
                    VersionIniFile.SetIni("PROGRAMINFO", "VERSION", DisplayVersion, this.PathLaunchFolder + "Version.ini");
                    VersionIniFile.SetIni("PROGRAMINFO", "RELEASE", ReleaseDate, this.PathLaunchFolder + "Version.ini");
                }
            }
        }
        // PreVersionBackup\\Run\\ 폴더 Version.ini 파일 체크
        private string CheckPreVersionIniFile()
        {
            string ret = "";

            try
            {
                FileInfo filePreVersionCfg = new FileInfo(this.PathPreVersionRunFolder + "Version.ini");
                if (filePreVersionCfg.Exists == true)
                {
                    ret = VersionIniFile.GetIni("PROGRAMINFO", "VERSION", "", this.PathPreVersionRunFolder + "Version.ini");
                }
            }
            catch
            {

            }

            return ret;
        }

        #region Uart Communication
        private void OpenSmartSerialPort2()
        {
            string fullPath = "";
            DateTime dt = DateTime.Now;

            try
            {
                if (this.FlagSerialDll == false)
                {
                    if (this.smartSerialPort2.IsOpen == false)
                        this.smartSerialPort2.Open();
                }
                else
                {
                    // Port : COM2
                    // Baudrate : 115200
                    SerialMgrComm.serialPortOpen(this.ComPortMainToLCD, 115200, 0, 0, 8);
                }
            }
            catch
            {
            }

            #region Test 용 통신 로그
            fullPath = this.PathDataLogFolder + string.Format("{0:yyMMdd}_ITC81DB_2H_", dt) + "Communicationlog.txt";
            this.smartFileCommunicationLog.FilePathName = fullPath;
            //this.smartFileCommunicationLog.Open();
            //this.IsCommunicationLogOpen = true;
            #endregion

            #region Error Check 용 통신 로그
            fullPath = this.PathDataBackupFolder + string.Format("{0:yyMMdd}_", dt) + this.SystemConfig1.UsbID + "_Checklog.txt";
            this.smartFileCheckLog.FilePathName = fullPath;
            // CheckLog
            //this.smartFileCheckLog.Open();
            //this.IsErrorLogOpen = true;
            #endregion
        }
        public void CloseSmartSerialPort2()
        {
            if (this.FlagSerialDll == false)
                this.smartSerialPort2.Close();
            else
                SerialMgrComm.serialPortClose("COM2:");
        }

        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;
        }
        private string Checksumcalculator(byte[] 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 = 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;
        }
        private void SetCollectionForStringToByte(ref Collection<byte> collection, string value)
        {
            byte[] byteData;

            if (collection == null)
                return;

            byteData = Encoding.UTF8.GetBytes(value);
            for (int i = 0; i < byteData.Length; i++)
                collection.Add(byteData[i]);
        }
        public byte Checksumcalculator1digit(byte[] byteArray)
        {
            byte step1 = 0, step2 = 0, step3 = 0;

            for (int i = 0; i < byteArray.Length; i++)
                step1 += byteArray[i];

            step2 = (byte)(step1 & 0x00ff);
            step3 = (byte)(0x0100 - step2);

            return step3;
        }

        private void ChecklogPrint(string receiveData, WeightData weight)
        {
            if (weight.JudgmentStatus == Define.E_JudgmentStatus.Pass
                || weight.JudgmentStatus == Define.E_JudgmentStatus.Over
                || weight.JudgmentStatus == Define.E_JudgmentStatus.Under)
            {
                int tempWeight = 0;
                bool sign = false;
                string removeMinus = "";
                if (weight.WeightString.StartsWith("-") == true)
                {
                    removeMinus = weight.WeightString.Replace("-", "");
                    sign = true;
                    tempWeight = int.Parse(removeMinus);
                }
                else
                    tempWeight = int.Parse(weight.WeightString);

                if (sign == true)
                    tempWeight *= -1;

                bool tempFlag = false;

                if (this.CurrentProductItem.OverRangeInt >= tempWeight && this.CurrentProductItem.UnderRangeInt <= tempWeight
                    && weight.JudgmentStatus != Define.E_JudgmentStatus.Pass)
                    tempFlag = true;

                if (this.CurrentProductItem.OverRangeInt < tempWeight && weight.JudgmentStatus != Define.E_JudgmentStatus.Over)
                    tempFlag = true;

                if (this.CurrentProductItem.UnderRangeInt > tempWeight && weight.JudgmentStatus != Define.E_JudgmentStatus.Under)
                    tempFlag = true;

                if (tempFlag == true)
                    this.smartFileCheckLog.WriteString(string.Format("Check ({0:yyyy-MM-dd HH:mm:ss}): {1},{2},{3}", DateTime.Now, receiveData, this.CurrentProductItem.UnderRange, this.CurrentProductItem.OverRange));
            }           
        }

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

            if (this.FlagSerialDll == false)
            {
                if (this.smartSerialPort2.IsOpen == true)
                    this.smartSerialPort2.WriteFrame(sb.ToString(), SmartSerialPort.CODETYPES.ASCIICODE);
            }
            else
                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()));

            // 에러체크
            if (this.IsErrorLogOpen == true && sb.ToString().StartsWith("Sr") == false)
                this.smartFileCheckLog.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);

            if (this.FlagSerialDll == false)
            {
                if (this.smartSerialPort2.IsOpen == true)
                    this.smartSerialPort2.WriteFrame(sb.ToString(), SmartSerialPort.CODETYPES.ASCIICODE);
            }
            else
                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()));

            // 에러체크
            if (this.IsErrorLogOpen == true && sb.ToString().StartsWith("Pr") == false)
                this.smartFileCheckLog.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 index, byte[] datas)
        {
            int ret = 0, count = 0;
            byte[] byteData;
            string chkSum = "cc";
            Collection<byte> byteCollection = new Collection<byte>();

            // command;
            this.SetCollectionForStringToByte(ref byteCollection, command);

            // id;
            this.SetCollectionForStringToByte(ref byteCollection, id);

            // data Length
            count = datas.Length + index.Length;
            this.SetCollectionForStringToByte(ref byteCollection, Helper.StringZeroFillDigits4(count.ToString()));

            // address
            this.SetCollectionForStringToByte(ref byteCollection, address);

            // index
            this.SetCollectionForStringToByte(ref byteCollection, index);

            // datas
            for (int i = 0; i < datas.Length; i++)
                byteCollection.Add(datas[i]);

            // chkSum
            byteData = new byte[byteCollection.Count];
            for (int i = 0; i < byteCollection.Count; i++)
                byteData[i] = byteCollection[i];
            chkSum = this.Checksumcalculator(byteData);
            this.SetCollectionForStringToByte(ref byteCollection, chkSum);

            // collection -> byte[]
            byteData = new byte[byteCollection.Count];
            for (int i = 0; i < byteCollection.Count; i++)
                byteData[i] = byteCollection[i];

            if (this.FlagSerialDll == false)
            {
                if (this.smartSerialPort2.IsOpen == true)
                    this.smartSerialPort2.WriteFrame(byteData);
            }
            else
                SerialMgrComm.serialPortMessageByte(this.ComPortMainToLCD, byteData, byteData.Length);


            // 통신 확인 로그
            if (this.IsCommunicationLogOpen == true)
            {
                string log = "";

                for (int i = 0; i < byteCollection.Count; i++)
                    log += byteCollection[i].ToString("X2");

                this.smartFileCommunicationLog.WriteString(string.Format("Send ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, log));
            }

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

            if (this.FlagSerialDll == false)
            {
                if (this.smartSerialPort2.IsOpen == true)
                    this.smartSerialPort2.WriteFrame(sb.ToString(), SmartX.SmartSerialPort.CODETYPES.ASCIICODE);
            }
            else
                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 ReceiveData(string strTemp)
        {
            int ret = 0;

            try
            {
                switch (strTemp[0])
                {
                    case 'C':
                        if ((ret = this.ReceiveCommandC(strTemp)) != 0)
                            return;
                        break;
                    case 'P':
                        if ((ret = this.ReceiveCommandP(strTemp)) != 0)
                            return;
                        break;
                    case 'S':
                        if ((ret = this.ReceiveCommandS(strTemp)) != 0)
                            return;
                        break;
                    case 'T':
                        if ((ret = this.ReceiveCommandT(strTemp)) != 0)
                            return;
                        break;
                    default:
                        break;
                }
            }
            catch
            {
                // 로그
                if (this.IsCommunicationLogOpen == true)
                    this.smartFileCommunicationLog.WriteString(string.Format("Receive ({0:yyyy-MM-dd HH:mm:ss}): {1} : ReceiveData() Catch", DateTime.Now, strTemp));
            }
        }

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

            // 에러체크
            if (this.IsErrorLogOpen == true)
                this.smartFileCheckLog.WriteString(string.Format("Receive ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, strTemp));

            cmd = strTemp.Substring(0, 3);

            switch (cmd)
            {
                case "CI0":
                    #region Main Board Booted
                    if (this.CurrentSystemStatus.Equipment == Define.E_EquipmentStatus.Start)
                    {
                        this.CurrentSystemStatus.Equipment = Define.E_EquipmentStatus.Stop;

                        if (this.SystemConfig1.IsBarcodeEnable == true)
                        {
                            for (int i = 0; i < 1000; i++)
                            {
                                // 생산속도 Clear
                                this.CollectionWeightData[i].ProductionSpeed = 0;
                                // 정지 시간 저장
                                this.CollectionWeightData[i].StopTime = DateTime.Now;
                                this.CollectionWeightData[i].IsStart = false;
                            }
                            this.SaveCounterFile(this.CollectionWeightData);
                        }
                        else
                        {
                            // 생산속도 Clear
                            this.CurrentWeightData.ProductionSpeed = 0;
                            this.CurrentWeightData.IsStart = false;

                            // 정지 시간 저장
                            this.CurrentWeightData.StopTime = DateTime.Now;
                            this.SaveCounterFile(this.CurrentWeightData, this.SystemConfig1.ProductNumber - 1);
                        }

                        if (this.ChildFormMainDisplay != null)
                            this.ChildFormMainDisplay.UpdateEquipmentStatusDisplay(this.CurrentSystemStatus.Equipment);
                    }
                    // Write SystemParameter1
                    this.TransferParameter1();
                    #endregion
                    break;
                case "CBI":
                    #region 공장초기화완료
                    if (this.ChildFormMenu != null)
                        this.ChildFormMenu.CenterEquipInitialize.UpdateDisplayMainBoardInitialization();
                    #endregion
                    break;
                case "CBS":
                    #region 운전
                    this.CurrentSystemStatus.Equipment = Define.E_EquipmentStatus.Start;
                    this.SetTrackingHistoryData(Define.E_TrackingOperation.Start, "");

                    this.Update30000ModbusItem();

                    // OPT1(액트라 - 안리쯔 금속검출기)
                    if (this.SystemConfig1.SerialCOM1Mode == 14)
                        this.TransferSerialCOM1(this.Transfer_14_OPT1("12"));
                    if (this.SystemConfig1.SerialCOM3Mode == 14)
                        this.TransferSerialCOM3(this.Transfer_14_OPT1("12"));
                    if (this.SystemConfig1.SerialCOM4Mode == 14)
                        this.TransferSerialCOM4(this.Transfer_14_OPT1("12"));

                    // 바코드
                    if (this.SystemConfig1.IsBarcodeEnable == true)
                    {
                        // STXANDETX
                        this.ChangeSerialCOM3FrameSeparateType(Define.E_SeparateType.STXANDETX);

                        #region 바코드 사용
                        for (int i = 0; i < 1000; i++)
                        {
                            // 운전시 중량 0 으로 Clear
                            this.CollectionWeightData[i].Weight = 0.0;

                            // 운전 시간 저장 
                            // 1번 품번 카운트가 0 이면 모든 품번 적용
                            if (this.CollectionWeightData[0].TotalCount == 0)
                                this.CollectionWeightData[i].StartTime = DateTime.Now;
                        }

                        this.SaveCounterFile(this.CollectionWeightData);
                        #endregion
                    }
                    else
                    {
                        #region 바코드 미사용
                        // 운전시 중량 0 으로 Clear
                        this.CurrentWeightData.Weight = 0.0;

                        // 운전 시간 저장
                        if (this.CurrentWeightData.TotalCount == 0)
                        {
                            this.CurrentWeightData.StartTime = DateTime.Now;
                            this.SaveCounterFile(this.CurrentWeightData, this.SystemConfig1.ProductNumber - 1);
                        }
                        #endregion
                    }

                    // 이더넷
                    if (this.SystemConfig2.EthernetOperationMode == 2)
                        this.EthernetClientConnect();

                    if (this.CurrentSystemStatus.CurrentDisplay == Define.E_DisplayStore.MainDisplay)
                    {
                        if (this.ChildFormMainDisplay != null)
                            this.ChildFormMainDisplay.UpdateEquipmentStatusDisplay(this.CurrentSystemStatus.Equipment);
                    }
                    else
                    {
                        if (this.ChildFormMenu != null)
                            this.ChildFormMenu.UpdateEquipmentStatusDisplay(this.CurrentSystemStatus.Equipment);
                    }

                    this.IsLampOnDataSend = false;
                    this.IsBuzzerOnDataSend = false;

                    if (this.ChildFormMainDisplay.MainFeedback.IsUsingFeedback() == true)
                        this.ChildFormMainDisplay.MainFeedback.ItemChangeEnable(false);
                    #endregion
                    break;
                case "CBT":
                    #region 정지
                    this.CurrentSystemStatus.Equipment = Define.E_EquipmentStatus.Stop;
                    this.SetTrackingHistoryData(Define.E_TrackingOperation.Stop, "");

                    this.CommID = 0;

                    this.Update30000ModbusItem();

                // OPT1(액트라 - 안리쯔 금속검출기)
                    if (this.SystemConfig1.SerialCOM1Mode == 14)
                        this.TransferSerialCOM1(this.Transfer_14_OPT1("13"));
                    if (this.SystemConfig1.SerialCOM3Mode == 14)
                        this.TransferSerialCOM3(this.Transfer_14_OPT1("13"));
                    if (this.SystemConfig1.SerialCOM4Mode == 14)
                        this.TransferSerialCOM4(this.Transfer_14_OPT1("13"));

                    // 바코드
                    if (this.SystemConfig1.IsBarcodeEnable == true)
                    {
                        for (int i = 0; i < 1000; i++)
                        {
                            // 생산속도 Clear
                            this.CollectionWeightData[i].ProductionSpeed = 0;
                            // 정지 시간 저장
                            this.CollectionWeightData[i].StopTime = DateTime.Now;
                        }

                        this.SaveCounterFile(this.CollectionWeightData);
                        this.SaveSystemConfigurationFile1(this.SystemConfig1);
                    }
                    else
                    {
                        // 생산속도 Clear
                        this.CurrentWeightData.ProductionSpeed = 0;

                        // 정지 시간 저장
                        this.CurrentWeightData.StopTime = DateTime.Now;
                        this.SaveCounterFile(this.CurrentWeightData, this.SystemConfig1.ProductNumber - 1);
                    }

                    // 통신 지연용 Queue Clear
                    this.ClearQueue();

                    // 이더넷
                    if (this.SystemConfig2.EthernetOperationMode == 2)
                    {
                        this.IsEthernetTransferData = false;
                        this.EthernetClientDisconnect();
                    }

                    if (this.CurrentSystemStatus.CurrentDisplay == Define.E_DisplayStore.MainDisplay)
                    {
                        if (this.ChildFormMainDisplay != null)
                            this.ChildFormMainDisplay.UpdateEquipmentStatusDisplay(this.CurrentSystemStatus.Equipment);
                    }
                    else
                    {
                        if (this.CurrentSystemStatus.CurrentDisplay == Define.E_DisplayStore.SystemIOTest)
                        {
                            if (this.ChildFormMenu.CenterSystemIOTest != null)
                                this.ChildFormMenu.CenterSystemIOTest.UpdateEquipmentStatusDisplay(this.CurrentSystemStatus.Equipment);
                        }

                        if (this.ChildFormMenu != null)
                            this.ChildFormMenu.UpdateEquipmentStatusDisplay(this.CurrentSystemStatus.Equipment);
                    }

                    if (this.SystemConfig1.DatabackupFormat == 1)
                    {
                        // 데이터백업 포맷 : OPT1 - 정지 시 리젝데이터 STOP 처리
                        for (int i = 0; i < this.CollectionBufferWeightData.Count; i++)
                        {
                            this.CollectionBufferWeightData[i].Status = Define.E_JudgmentResult.STOP.ToString();
                            this.TrackingInspectionData1(this.CollectionBufferWeightData[i]);
                        }
                        this.CollectionBufferWeightData.Clear();
                    }

                    if (this.ChildFormMainDisplay.MainFeedback.IsUsingFeedback() == true)
                        this.ChildFormMainDisplay.MainFeedback.ItemChangeEnable(true);
                    #endregion
                    break;
                case "CBE":
                    #region 소거

                    #endregion
                    break;
                case "CBZ":
                    #region 영점
                    if (this.CurrentSystemStatus.CurrentDisplay == Define.E_DisplayStore.SystemCalibration)
                    {
                        this.ChildFormMenu.CenterSystemCalibration.SplashStop();
                        this.ChildFormMenu.CenterSystemCalibration.CalibrationButtonEnable(true, false, false);
                    }
                    #endregion
                    break;
                case "Csm":
                    #region 메뉴모드
                    if(this.CurrentSystemStatus.Equipment == Define.E_EquipmentStatus.Start)
                        this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);                    
                    #endregion
                    break;
                case "Csc":
                    #region 중량조정모드
                    if (this.CurrentSystemStatus.Equipment == Define.E_EquipmentStatus.Start)
                        this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
                    #endregion
                    break;
                case "CBU":
                    this.ChildFormMenu.CenterEquipUpdate.UpdateMainBoardFinish();
                    break;
                //case "Cmd":
                //    #region 업다운 - 다운
                //    this.ChildFormMainDisplay.ConveryorUpDownButtonUp(true);            
                //    #endregion
                //    break;
                //case "Cmu":
                //    #region 업다운 - Up
                //    this.ChildFormMainDisplay.ConveryorUpDownButtonUp(false);
                //    #endregion
                //    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);

            // 에러체크
            if (this.IsErrorLogOpen == true)
                this.smartFileCheckLog.WriteString(string.Format("Receive ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, strTemp));

            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 = "", transferCount = "";

            // 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);
            transferCount = 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":
                case "SM0":
                    if ((ret = this.ReceiveCommand(cmd, lane, dataID, transferCount, receiveData)) != 0)
                        return ret;
                    break;
                case "SC0":
                    // 에러체크
                    if (this.IsErrorLogOpen == true)
                        this.smartFileCheckLog.WriteString(string.Format("Receive ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, strTemp));
                    if ((ret = this.ReceiveCommandSC0(lane, receiveData)) != 0)
                        return ret;
                    break;
                case "ST0":
                    if ((ret = this.ReceiveCommandST0(lane, receiveData)) != 0)
                        return ret;
                    break;
                case "SF0":
                    // 에러체크
                    if (this.IsErrorLogOpen == true)
                        this.smartFileCheckLog.WriteString(string.Format("Receive ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, strTemp));
                    if ((ret = this.ReceiveCommandSF0(lane, receiveData)) != 0)
                        return ret;
                    break;
                case "SG0":
                    if ((ret = this.ReceiveCommandSG0(lane, receiveData)) != 0)
                        return ret;
                    break;
                case "SD0":
                    // 에러체크
                    if (this.IsErrorLogOpen == true)
                        this.smartFileCheckLog.WriteString(string.Format("Receive ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, strTemp));

                    if ((ret = this.ReceiveCommandSD0(lane, dataID, transferCount, receiveData)) != 0)
                        return ret;
                    break;
                case "SB0":
                    if ((ret = this.ReceiveCommandSB0(lane, dataID, transferCount, receiveData)) != 0)
                        return ret;
                    break;
                default:
                    break;
            }

            // ex
            #region ex
            //if (cmd == "SG0")
            //{
            //    byte[] a = new UTF8Encoding().GetBytes(strTemp.Substring(0, strTemp.Length - 2));
            //    int j = 0, first, second;
            //    char char1, char2;
            //    string value1 = "";
            //    for (int i = 0; i < a.Length; i++)
            //    {
            //        j += a[i];
            //    }

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

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

            //    value1 = char1.ToString() + char2.ToString();
            //    this.ChildFormMenu.CenterSystemJudgmentSetting.UpdateChecksumDisplay(strTemp.Substring(strTemp.Length - 2, 2), value1);
            //}
            #endregion

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

            // SIZE 확인
            if (this.SizeCheck("T", 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);
            receiveData = strTemp.Substring(10, strTemp.Length - 12);

            switch (cmd)
            {
                case "TG0":
                    // IO테스트 그래프 데이터
                    //if ((ret = this.ReceiveCommandTG0(lane, receiveData)) != 0)
                        return ret;
                    break;
                default:
                    break;
            }

            return ret;
        }

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

            try
            {
                switch (address)
                {
                    case "1502":
                        #region Value Assign
                        this.SystemConfig1.MainBoardVersion = receiveData;
                        #endregion
                        if (this.ChildFormMenu.CenterInforSystem != null)
                            this.ChildFormMenu.CenterInforSystem.UpdateMainBoardVersionDisplay(this.SystemConfig1.MainBoardVersion);
                        break;
                    case "2001":
                        #region Value Assign
                        iValue = int.Parse(receiveData);
                        #endregion
                        if (iValue <= 0 || iValue > 1000)
                            return ret = -1;
                        this.SystemConfig1.ProductNumber = iValue;
                        this.TransferDataStream(CommunicationCommand.Read, CommunicationID.MainBoard, CommunicationAddress.ProgramVersion, "");

                        // 최초에 부팅이 완료 되었는지 확인
                        if (this.IsBootingComplete == false)
                        {
                            this.IsBootingComplete = true;
                            this.TransferDataStream(CommunicationCommand.Read, CommunicationID.MainBoard, CommunicationAddress.ParameterCount, "");
                            this.SetTrackingHistoryData(Define.E_TrackingOperation.Booting, "");

                            if (this.CurrentSystemStatus.CurrentDisplay != Define.E_DisplayStore.MainDisplay)
                            {
                                this.ChildFormMainDisplay.DisplayRefresh(this.CurrentSystemStatus);
                                this.smartForm.Show((int)Define.E_FormStore.FormMainDisplay);
                            }
                        }
                        else
                        {
                            this.SaveCounterFile(this.CollectionWeightData);
                            this.TransferCountData(this.SystemConfig1.ProductNumber);
                        }

                        if (this.SystemConfig1.IsBarcodeEnable == true && this.CurrentSystemStatus.Equipment == Define.E_EquipmentStatus.Start)
                            return ret;

                        // Save System File
                        this.SaveSystemConfigurationFile1(this.SystemConfig1);
                        // 생산속도 Clear
                        this.CurrentWeightData.ProductionSpeed = 0;

                        if (this.CurrentSystemStatus.CurrentDisplay == Define.E_DisplayStore.MainDisplay)
                        {
                            if (this.ChildFormMainDisplay != null)
                                this.ChildFormMainDisplay.UpdateCurrentProductDisplay(this.CurrentSystemStatus.Equipment, this.CurrentProductItem, this.CurrentWeightData);
                        }
                        else if (this.CurrentSystemStatus.CurrentDisplay == Define.E_DisplayStore.SystemSorterSetting)
                        {
                            if (this.ChildFormMenu.CenterSystemSorterSetting != null)
                                this.ChildFormMenu.CenterSystemSorterSetting.UpdateCurrentProductDisplay(this.CurrentSystemStatus.Equipment, this.CurrentProductItem);
                        }
                        else
                        {
                            if (this.ChildFormMenu.CenterSystemJudgment != null)
                                this.ChildFormMenu.CenterSystemJudgment.UpdateCurrentProductDisplay(this.CurrentSystemStatus.Equipment, this.CurrentProductItem);
                        }

                        if (this.SystemConfig2.EthernetOperationMode == 1 && this.smartTCPMultiServer.IsStart == true)
                            this.ChildFormMainDisplay.TimerServer(true);

                        if (this.ChildFormMainDisplay.MainFeedback.IsUsingFeedback() == true)
                        {
                            this.UpdateFeedbackData(this.CurrentProductItem, this.CurrentSystemParameter2);
                            this.UpdateFeedbackDeviation(this.CurrentProductItem, this.CurrentSystemParameter2);
                        }

                        this.Update30000ModbusItem();

                        // OverloadWeight 값 확인을 위한 MaxWeight 값 읽기
                        this.TransferDataStream(CommunicationCommand.Read, CommunicationID.MainBoard, CommunicationAddress.ParameterRead3901, "");
                        break;
                    case "2002":
                        this.TransferDataStream(CommunicationCommand.Read, CommunicationID.MainBoard, CommunicationAddress.OverRange, "");
                        break;
                    case "3002":
                        this.CurrentCalibrationItem.BalanceWeight = receiveData.Substring(0, 7).Trim();

                        if (this.CurrentSystemStatus.CurrentDisplay == Define.E_DisplayStore.SystemCalibration)
                        {
                            if (this.ChildFormMenu.CenterSystemCalibration != null)
                                this.ChildFormMenu.CenterSystemCalibration.UpdateCalibrationItemDisplay(this.CurrentSystemStatus.Equipment, this.CurrentCalibrationItem);
                        }
                        break;
                    case "3601":
                        break;
                    case "3901":
                        break;
                    case "4907":
                        #region Value Assign
                        this.CurrentSystemParameter4.MainAutoZeroIsAutoZeroUsing = Convert.ToBoolean(int.Parse(receiveData.Substring(0, 4)));
                        this.CurrentSystemParameter4.MainAutoZeroPlusRange = receiveData.Substring(4, 7).Trim();
                        this.CurrentSystemParameter4.MainAutoZeroMinusRange = receiveData.Substring(11, 7).Trim();
                        this.CurrentSystemParameter4.MainAutoZeroVariate = receiveData.Substring(18, 4).Trim();
                        #endregion
                        if (this.CurrentSystemStatus.CurrentDisplay == Define.E_DisplayStore.SystemAutoZero)
                        {
                            if (this.ChildFormMenu.CenterSystemAutoZero != null)
                                this.ChildFormMenu.CenterSystemAutoZero.UpdateZeroParameterDisplay(this.CurrentSystemParameter4);
                        }
                        break;
                    case "5057":
                        #region Value Assign
                        this.SensorDetectingTime = int.Parse(receiveData.Substring(0, 4).Trim());
                        #endregion
                        if (this.ChildFormMenu.CenterSystemJudgment != null)
                            this.ChildFormMenu.CenterSystemJudgment.CaculateJudgmentData(this.SensorDetectingTime);
                        break;
                    case "5302":
                        break;
                    case "6734": // BLDC - 구동중인 모터의 RPM
                        #region Value Assign
                        for (int i = 0; i < this.SystemConfig2.BLDCTotalMotorNum; i++)
                        {
                            if (this.CurrentMotorID(lane) == this.CollectionBLDCParameter[i].MotorID)
                            {
                                index = i;

                                this.CollectionBLDCParameter[index]._6734_MotorRPM = receiveData.Substring(0, 4);

                                if (this.ChildFormMenu.CenterSystemBLDCMotorSetting != null)
                                    this.ChildFormMenu.CenterSystemBLDCMotorSetting.DisplayRPM();

                                break;
                            }
                        }
                        #endregion
                        break;
                    case "6901":
                        break;
                    case "9031":
                        #region Value Assign
                        this.CurrentWeightData.BoardProductNumber = int.Parse(receiveData.Substring(0, 4).Trim());
                        this.CurrentWeightData.BoardExNGCount = int.Parse(receiveData.Substring(4, 7).Trim());
                        this.CurrentWeightData.BoardOverCount = int.Parse(receiveData.Substring(11, 7).Trim());
                        this.CurrentWeightData.BoardPassCount = int.Parse(receiveData.Substring(18, 7).Trim());
                        this.CurrentWeightData.BoardUnderCount = int.Parse(receiveData.Substring(25, 7).Trim());
                        this.CurrentWeightData.BoardMetalDetectionCount = int.Parse(receiveData.Substring(32, 7).Trim());
                        this.CurrentWeightData.BoardDoubleEntryCount = int.Parse(receiveData.Substring(39, 7).Trim());

                        this.UpdateCountData(this.CurrentWeightData);
                        #endregion
                        break;
                    case "9518":
                        #region Value Assign
                        this.SystemInfo2.UnderRange = receiveData.Substring(0, 7).Trim();
                        this.SystemInfo2.PassRange = receiveData.Substring(7, 7).Trim();
                        this.SystemInfo2.OverRange = receiveData.Substring(14, 7).Trim();
                        this.SystemInfo2.TareRange = receiveData.Substring(21, 7).Trim();
                        this.SystemInfo2.BalanceWeight = receiveData.Substring(28, 7).Trim();
                        this.SystemInfo2.Filter = receiveData.Substring(35, 4).Trim();
                        this.SystemInfo2.JudgmentDelay = receiveData.Substring(39, 4).Trim();
                        this.SystemInfo2.DoubleDelay = receiveData.Substring(43, 4).Trim();
                        this.SystemInfo2.JudgmentNumber = receiveData.Substring(47, 4).Trim();
                        this.SystemInfo2.Speed = receiveData.Substring(51, 4).Trim();
                        this.SystemInfo2.Dynamic = receiveData.Substring(55, 7).Trim();
                        this.SystemInfo2.SorterAMode = receiveData.Substring(62, 4).Trim();
                        this.SystemInfo2.SorterADelay = receiveData.Substring(66, 4).Trim();
                        this.SystemInfo2.SorterAOperation = receiveData.Substring(70, 4).Trim();
                        this.SystemInfo2.SorterBMode = receiveData.Substring(74, 4).Trim();
                        this.SystemInfo2.SorterBDelay = receiveData.Substring(78, 4).Trim();
                        this.SystemInfo2.SorterBOperation = receiveData.Substring(82, 4).Trim();
                        this.SystemInfo2.DoubleEntry = receiveData.Substring(86, 4).Trim();
                        this.SystemInfo2.ExternalInput = receiveData.Substring(90, 4).Trim();
                        this.SystemInfo2.ETCNG = receiveData.Substring(94, 4).Trim();
                        #endregion

                        if (this.ChildFormMenu.CenterInforSystem2 != null)
                            this.ChildFormMenu.CenterInforSystem2.UpdateParameter9518Display(this.SystemInfo2);

                        this.TransferDataStream(CommunicationCommand.Read, CommunicationID.MainBoard, CommunicationAddress.SystemInformationRead2, "");
                        break;
                    case "9519":
                        #region Value Assign
                        this.SystemInfo2.ExternalOutput1Mode = receiveData.Substring(0, 4).Trim();
                        this.SystemInfo2.ExternalOutput1Delay = receiveData.Substring(4, 4).Trim();
                        this.SystemInfo2.ExternalOutput1Operation = receiveData.Substring(8, 4).Trim();
                        this.SystemInfo2.ExternalOutput2Mode = receiveData.Substring(12, 4).Trim();
                        this.SystemInfo2.ExternalOutput2Delay = receiveData.Substring(16, 4).Trim();
                        this.SystemInfo2.ExternalOutput2Operation = receiveData.Substring(20, 4).Trim();
                        this.SystemInfo2.ExternalOutput3Mode = receiveData.Substring(24, 4).Trim();
                        this.SystemInfo2.ExternalOutput3Delay = receiveData.Substring(28, 4).Trim();
                        this.SystemInfo2.ExternalOutput3Operation = receiveData.Substring(32, 4).Trim();
                        this.SystemInfo2.ExternalOutput4Mode = receiveData.Substring(36, 4).Trim();
                        this.SystemInfo2.ExternalOutput4Delay = receiveData.Substring(40, 4).Trim();
                        this.SystemInfo2.ExternalOutput4Operation = receiveData.Substring(44, 4).Trim();
                        this.SystemInfo2.ExternalOutput5Mode = receiveData.Substring(48, 4).Trim();
                        this.SystemInfo2.ExternalOutput5Delay = receiveData.Substring(52, 4).Trim();
                        this.SystemInfo2.ExternalOutput5Operation = receiveData.Substring(56, 4).Trim();
                        this.SystemInfo2.ExternalOutput6Mode = receiveData.Substring(60, 4).Trim();
                        this.SystemInfo2.ExternalOutput6Delay = receiveData.Substring(64, 4).Trim();
                        this.SystemInfo2.ExternalOutput6Operation = receiveData.Substring(68, 4).Trim();
                        this.SystemInfo2.IsAutoZeroUsing = receiveData.Substring(72, 4).Trim();
                        this.SystemInfo2.AutoZeroPlusRange = receiveData.Substring(76, 7).Trim();
                        this.SystemInfo2.AutoZeroMinusRange = receiveData.Substring(83, 7).Trim();
                        this.SystemInfo2.AutoZeroVariate = receiveData.Substring(90, 4).Trim();
                        #endregion

                        if (this.ChildFormMenu.CenterInforSystem2 != null)
                            this.ChildFormMenu.CenterInforSystem2.UpdateParameter9519Display(this.SystemInfo2);

                        this.TransferDataStream(CommunicationCommand.Read, CommunicationID.MainBoard, CommunicationAddress.SystemInformationRead3, "");
                        break;
                    case "9520":
                        #region Value Assign
                        this.SystemInfo2.PhotoB = receiveData.Substring(0, 4).Trim();
                        this.SystemInfo2.PI3 = receiveData.Substring(4, 4).Trim();
                        this.SystemInfo2.PI4 = receiveData.Substring(8, 4).Trim();
                        this.SystemInfo2.PI5 = receiveData.Substring(12, 4).Trim();
                        this.SystemInfo2.PI6 = receiveData.Substring(16, 4).Trim();
                        this.SystemInfo3.BuzzerONTime = receiveData.Substring(20, 4).Trim();
                        this.SystemInfo3.Chattering = receiveData.Substring(24, 4).Trim();
                        this.SystemInfo3.Relay = receiveData.Substring(28, 4).Trim();
                        this.SystemInfo3.BLDCMotorSpeed1 = receiveData.Substring(32, 4).Trim();
                        this.SystemInfo3.BLDCMotorPole1 = receiveData.Substring(36, 4).Trim();
                        this.SystemInfo3.BLDCMotorReductionRatio1 = receiveData.Substring(40, 4).Trim();
                        this.SystemInfo3.BLDCMotorDirection1 = receiveData.Substring(44, 4).Trim();
                        this.SystemInfo3.BLDCMotorSpeed2 = receiveData.Substring(48, 4).Trim();
                        this.SystemInfo3.BLDCMotorPole2 = receiveData.Substring(52, 4).Trim();
                        this.SystemInfo3.BLDCMotorReductionRatio2 = receiveData.Substring(56, 4).Trim();
                        this.SystemInfo3.BLDCMotorDirection2 = receiveData.Substring(60, 4).Trim();
                        this.SystemInfo3.BLDCMotorSpeed3 = receiveData.Substring(64, 4).Trim();
                        this.SystemInfo3.BLDCMotorPole3 = receiveData.Substring(68, 4).Trim();
                        this.SystemInfo3.BLDCMotorReductionRatio3 = receiveData.Substring(72, 4).Trim();
                        this.SystemInfo3.BLDCMotorDirection3 = receiveData.Substring(76, 4).Trim();
                        this.SystemInfo3.BLDCMotorSpeed4 = receiveData.Substring(80, 4).Trim();
                        this.SystemInfo3.BLDCMotorPole4 = receiveData.Substring(84, 4).Trim();
                        this.SystemInfo3.BLDCMotorReductionRatio4 = receiveData.Substring(88, 4).Trim();
                        this.SystemInfo3.BLDCMotorDirection4 = receiveData.Substring(92, 4).Trim();
                        #endregion

                        if (this.ChildFormMenu.CenterInforSystem3 != null)
                        {
                            this.ChildFormMenu.CenterInforSystem2.UpdateParameter9520Display(this.SystemInfo2);
                            this.ChildFormMenu.CenterInforSystem3.UpdateParameter9520Display(this.SystemInfo3, this.SystemConfig1, this.SystemConfig2);
                        }
                        break;
                    case "9516": // BLDC 모터 파라미터 읽기
                        #region Value Assign
                        for (int i = 0; i < this.SystemConfig2.BLDCTotalMotorNum; i++)
                        {
                            if (this.CurrentMotorID(lane) == this.CollectionBLDCParameter[i].MotorID)
                            {
                                index = i;

                                this.CollectionBLDCParameter[index]._6730_VersionMajor = receiveData.Substring(0, 4);
                                this.CollectionBLDCParameter[index]._6731_VersionMinor = receiveData.Substring(4, 4);
                                this.CollectionBLDCParameter[index]._6732_VersionBuild = receiveData.Substring(8, 4);
                                this.CollectionBLDCParameter[index]._6733_Frequency = receiveData.Substring(12, 4);
                                this.CollectionBLDCParameter[index]._6734_MotorRPM = receiveData.Substring(16, 4);
                                this.CollectionBLDCParameter[index]._6735_MotorDirection = int.Parse(receiveData.Substring(20, 4));
                                this.CollectionBLDCParameter[index]._6736_AttenuatorRPM = receiveData.Substring(24, 4);
                                this.CollectionBLDCParameter[index]._6765_SelectOperMode = int.Parse(receiveData.Substring(28, 4));

                                if (this.ChildFormMenu.CenterSystemBLDCMotorSetting != null)
                                    this.ChildFormMenu.CenterSystemBLDCMotorSetting.UpdateParameter(index, this.CollectionBLDCParameter);

                                this.TransferDataStream(CommunicationCommand.Read, lane, CommunicationAddress.BLDCMotorAlarmRead, "");

                                break;
                            }
                        }
                        #endregion
                        break;
                    case "9517": // BLDC 모터 알람 읽기
                        #region Value Assign
                        for (int i = 0; i < this.SystemConfig2.BLDCTotalMotorNum; i++)
                        {
                            if (this.CurrentMotorID(lane) == this.CollectionBLDCParameter[i].MotorID)
                            {
                                index = i;

                                this.CollectionBLDCParameter[index]._6790_Alarm_FaultSignal = Convert.ToBoolean(int.Parse(receiveData.Substring(0, 4)));
                                this.CollectionBLDCParameter[index]._6791_Alarm_HallSensorError = Convert.ToBoolean(int.Parse(receiveData.Substring(4, 4)));
                                this.CollectionBLDCParameter[index]._6792_Alarm_MotorStop = Convert.ToBoolean(int.Parse(receiveData.Substring(8, 4)));

                                if (this.ChildFormMenu.CenterSystemBLDCMotorSetting != null)
                                    this.ChildFormMenu.CenterSystemBLDCMotorSetting.UpdateAlarm(index, this.CollectionBLDCParameter);

                                break;
                            }
                        }
                        #endregion
                        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 = "";
            Define.E_ResponseData response = Define.E_ResponseData.NAK;

            try
            {
                if (receiveData == "0")
                    response = Define.E_ResponseData.NAK;
                else
                    response = Define.E_ResponseData.ACK;

                switch (address)
                {
                    case "1651":
                        #region 업데이트
                        #region Value Assign
                        try
                        {
                            index = int.Parse(receiveData.Substring(0, 4));
                        }
                        catch
                        {
                            index = 0;
                        }
                        ack = receiveData.Substring(4, 4);
                        #endregion

                        if (ack == "0001")
                            response = Define.E_ResponseData.ACK;
                        else
                            response = Define.E_ResponseData.NAK;

                        if (this.UpdateForMain.Index == index)
                        {
                            this.smartTimerUpdate.Stop();
                            if (response == Define.E_ResponseData.ACK)
                            {
                                beforeData = new byte[this.UpdateForMain.ByteData.Length];
                                for (int i = 0; i < this.UpdateForMain.ByteData.Length; i++)
                                    beforeData[i] = this.UpdateForMain.ByteData[i];

                                if (this.UpdateForMain.IsLastData == false)
                                {
                                    this.UpdateForMain.ByteData = new byte[beforeData.Length - 100];
                                    for (int i = 0; i < beforeData.Length - 100; i++)
                                        this.UpdateForMain.ByteData[i] = beforeData[100 + i];
                                    this.UpdateForMain.Index++;

                                    this.SendUpdateForMain(this.UpdateForMain.ByteData);
                                }
                                else
                                {
                                    this.ChildFormMenu.CenterEquipUpdate.SetProgressBarValue(5);
                                }
                            }
                            else
                            {
                                this.RetryUpdateForMain(this.UpdateForMain);
                            }
                        }
                        else
                        {
                            this.smartTimerUpdate.Stop();
                            this.ChildFormMenu.CenterEquipUpdate.UpdateMainBoardFail(this.SystemConfig1.Language);
                        }
                        #endregion
                        break;
                    case "9006":
                        if (response == Define.E_ResponseData.ACK)
                            this.TransferProductParameter(this.SystemConfig1.ProductNumber);
                        break;
                    case "9007":
                        if (response == Define.E_ResponseData.ACK)
                            this.TransferDataStream(CommunicationCommand.Read, CommunicationID.MainBoard, CommunicationAddress.ProductNumber, "");
                        break;
                    case "9018":
                        if (response == Define.E_ResponseData.ACK && this.CurrentSystemStatus.CurrentDisplay != Define.E_DisplayStore.EquipFuctionSetting)
                            this.TransferParameter2();
                        break;
                    case "9019":
                        if (response == Define.E_ResponseData.ACK)
                            this.TransferParameter3();
                        break;
                    case "9020":
                        if (response == Define.E_ResponseData.ACK)
                            this.TransferParameter4();
                        break;
                    case "9044":
                        if (response == Define.E_ResponseData.ACK)
                            this.TransferRandomMode();
                        break;
                    case "9023":
                        if (response == Define.E_ResponseData.ACK)
                        {
                            this.TransferBLDCMotorData(this.CurrentCommunicationID(this.BLDCMotorIndex),
                                this.SystemConfig2, this.CollectionBLDCParameter[this.BLDCMotorIndex]);
                            this.BLDCMotorIndex++;
                        }
                        break;
                    case "9033":
                        if (response == Define.E_ResponseData.ACK)
                            this.TransferDataStream(CommunicationCommand.Read, CommunicationID.MainBoard, CommunicationAddress.ProductNumber, "");
                        break;
                    case "9031":
                        break;
                    case "9041":
                        if (response == Define.E_ResponseData.ACK)
                        {
                            if (this.BLDCMotorIndex < this.SystemConfig2.BLDCTotalMotorNum)
                            {
                                this.TransferBLDCMotorData(this.CurrentCommunicationID(this.BLDCMotorIndex),
                                    this.SystemConfig2, this.CollectionBLDCParameter[this.BLDCMotorIndex]);
                                this.BLDCMotorIndex++;
                            }
                            else
                            {
                                this.BLDCMotorIndex = 0;
                                // V3.3.1 왜 996이 전송되지?
                                //if (this.SystemConfig2.IsUsingRandomMode == true)
                                //    this.SystemConfig1.ProductNumber = 996;
                                this.TransferProductParameter(this.SystemConfig1.ProductNumber);
                            }
                        }
                        break;
                    default:
                        break;
                }
            }
            catch
            {
                ret = -1;
            }

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

            try
            {
                if (receiveData == "0000")
                    response = Define.E_ResponseData.NAK;
                else
                    response = Define.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 "A":
                        #region Value Assign
                        if (this.CurrentSystemStatus.Equipment == Define.E_EquipmentStatus.Stop)
                        {
                            this.CurrentWeightData.Status = Helper.StringToWeightStatus(receiveData.Substring(0, 2));
                            //this.ConverterAlarm(this.CurrentWeightData, receiveData.Substring(2, 3));
                            this.CurrentWeightData.Weight = Helper.StringToWeight(receiveData.Substring(5, 5), this.SystemConfig1.DecimalPlaces);
                            this.CurrentWeightData.WeightString = receiveData.Substring(5, 5);
                            this.CurrentWeightData.ADCValue = receiveData.Substring(10, 5);
                        }
                        else
                        {
                            this.CurrentWeightData.Status = Helper.StringToWeightStatus(receiveData.Substring(0, 2));
                            //this.ConverterAlarm(this.CurrentWeightData, receiveData.Substring(2, 3));
                        }
                        #endregion
                        if (this.CurrentWeightData.WeightString.Trim() == "-9999" || this.CurrentWeightData.WeightString.Trim() == "9999"
                            || this.CurrentWeightData.WeightString.Trim() == "99999")
                            if (this.IsErrorLogOpen == true)
                                this.smartFileCheckLog.WriteString(string.Format("Check ({0:yyyy-MM-dd HH:mm:ss}): {1},{2},{3}", DateTime.Now, receiveData, this.CurrentProductItem.UnderRange, this.CurrentProductItem.OverRange));

                        // V6.2.0
                        if (this.OverloadWeight <= this.CurrentWeightData.Weight)
                        {
                            this.CurrentWeightData.WeightString = this.CurrentCalibrationItem.OverloadWeightString;
                            this.CurrentWeightData.Weight = this.OverloadWeight;
                        }

                        if (this.CurrentSystemStatus.CurrentDisplay == Define.E_DisplayStore.MainDisplay)
                        {
                            if (this.ChildFormMainDisplay != null)
                                this.ChildFormMainDisplay.UpdateStopWeightDisplay(this.CurrentSystemStatus.Equipment, this.CurrentWeightData);
                        }
                        break;
                    default:
                        break;
                }
            }
            catch
            {
                ret = -1;
            }

            return ret;
        }
        // 운전시 중량
        private int ReceiveCommand(string cmd, string lane, string transactionID, string transferCount, string receiveData)
        {
            int ret = 0;
            int temp = 0;

            try
            {
                switch (lane)
                {
                    case "A":
                        switch (cmd)
                        {
                            case "SR0": // 운전 시 중량
                                #region Value Assign
                                this.CurrentWeightData.JudgmentStatus = Helper.StringToJudgmentStatus(receiveData.Substring(0, 2));
                                //this.ConverterAlarm(this.CurrentWeightData, receiveData.Substring(2, 3));
                                this.CurrentWeightData.Weight = Helper.StringToWeight(receiveData.Substring(5, 5), this.SystemConfig1.DecimalPlaces);
                                this.CurrentWeightData.WeightString = receiveData.Substring(5, 5);
                                this.CurrentWeightData.ADCValue = receiveData.Substring(10, 5);
                                //this.CurrentWeightData.ProductionSpeed = int.Parse(receiveData.Substring(15, 4).Trim());

                                this.CurrentWeightData.WeightSum(this.CurrentWeightData.JudgmentStatus);
                                this.CurrentWeightData.SetDataIDTransferCount(transactionID, transferCount);

                                this.CurrentWeightData.Status = Define.E_WeightStatus.WeightChange;
                                #endregion
                                break;
                            case "SM0": // 랜덤모드 사용 + 운전 시 중량
                                #region Value Assign
                                this.SystemConfig1.ProductNumber = int.Parse(receiveData.Substring(0, 4));

                                this.CurrentWeightData.JudgmentStatus = Helper.StringToJudgmentStatus(receiveData.Substring(4, 2));
                                //this.ConverterAlarm(this.CurrentWeightData, receiveData.Substring(6, 3));
                                this.CurrentWeightData.Weight = Helper.StringToWeight(receiveData.Substring(9, 5), this.SystemConfig1.DecimalPlaces);
                                this.CurrentWeightData.WeightString = receiveData.Substring(9, 5);
                                this.CurrentWeightData.ADCValue = receiveData.Substring(14, 5);
                                this.CurrentWeightData.ProductionSpeed = int.Parse(receiveData.Substring(19, 4).Trim());

                                this.CurrentWeightData.WeightSum(this.CurrentWeightData.JudgmentStatus);
                                this.CurrentWeightData.SetDataIDTransferCount(transactionID, transferCount);

                                this.CurrentWeightData.Status = Define.E_WeightStatus.WeightChange;
                                #endregion
                                break;
                            default:
                                break;
                        }

                        //// 통신 제대로 받으면 ACK
                        //this.TransferData(string.Format("{0}{1}{2}{3}", CommunicationCommand.RunWeightData, (int)Define.E_ResponseData.ACK, dataID, transferCount), CommunicationID.MainBoard);

                        // 속도계산
                        this.CurrentWeightData.ProductionSpeedCalculation();

                        if (this.FlagSerialDll == true)
                        {
                            if (this.CommID % 10 != int.Parse(transactionID))
                            {
                                this.MissingCommIDCount++;
                                this.ChildFormMainDisplay.labelMissingCount.Text = this.MissingCommIDCount.ToString();
                            }
                            else
                                this.CommID++;

                            if (this.CurrentComRespone.TransactionID != transactionID)
                            {
                                this.CurrentComRespone.TransactionID = transactionID;
                                this.CurrentComRespone.TransferCount = transferCount;
                            }
                            else
                                return -1;
                        }

                        if (this.CurrentWeightData.WeightString.Trim() == "-9999" || this.CurrentWeightData.WeightString.Trim() == "9999"
                             || this.CurrentWeightData.WeightString.Trim() == "99999")
                            if (this.IsErrorLogOpen == true)
                                this.smartFileCheckLog.WriteString(string.Format("Check ({0:yyyy-MM-dd HH:mm:ss}): {1},{2},{3}", DateTime.Now, receiveData, this.CurrentProductItem.UnderRange, this.CurrentProductItem.OverRange));

                        if (this.IsErrorLogOpen == true)
                            this.ChecklogPrint(receiveData, this.CurrentWeightData);

                        // V6.2.0
                        if (this.OverloadWeight <= this.CurrentWeightData.Weight)
                        {
                            this.CurrentWeightData.WeightString = this.CurrentCalibrationItem.OverloadWeightString;
                            this.CurrentWeightData.Weight = this.OverloadWeight;
                        }

                        // 바이패스 사용 시
                        if (this.IsBypassUse == true && this.IsBypassOnce == true)
                        {
                            this.IsBypassOnce = false;
                            this.IsBypassUse = false;
                            this.ChildFormMainDisplay.MainWeightBigScreen.UpdateSpotOrBypassImageVisibleStatus(false);
                            this.ChildFormMainDisplay.MainWeightSmall.UpdateSpotOrBypassImageVisibleStatus(false);
                        }

                        this.Update30000ModbusItem();

                        #region 통신
                        // 통신 COM1
                        if (this.SystemConfig1.SerialCOM1Mode != 0)
                        {
                            #region COM1
                            switch (this.SystemConfig1.SerialCOM1Mode)
                            {
                                case 1:
                                    this.TransferSerialCOM1(this.Transfer_1_STD1(this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem));
                                    break;
                                case 2:
                                    this.TransferSerialCOM1(this.Transfer_2_Remote(this.CurrentWeightData, this.CurrentProductItem));
                                    break;
                                case 3:
                                    if (this.SystemConfig1.IsPrintPerProductEnable == true)
                                        this.TransferSerialCOM1(this.Transfer_3_Print(this.CurrentWeightData, this.CurrentProductItem));
                                    break;
                                case 4:
                                    if (this.CurrentWeightData.JudgmentStatus == Define.E_JudgmentStatus.Pass)
                                    {
                                        this.TransferSerialCOM1(this.RoomChange9410(2)); // 2번방 변경
                                        Thread.Sleep(200);
                                        this.TransferSerialCOM1(this.SendChar(Define.E_CharValue.ACK)); // ACK
                                        Thread.Sleep(200);
                                        this.TransferSerialCOM1(this.WeightData9410_OPT1(this.CurrentWeightData)); // 중량값 전송
                                    }
                                    else
                                    {
                                        this.TransferSerialCOM1(this.RoomChange9410(1)); // 1번방 변경
                                        Thread.Sleep(200);
                                        this.TransferSerialCOM1(this.SendChar(Define.E_CharValue.ACK)); // ACK
                                    }
                                    break;
                                case 5:
                                    this.HMCOM1_Step = 1;
                                    this.TransferSerialCOM1(this.SendChar(Define.E_CharValue.ENQ));
                                    break;
                                case 6:
                                    this.TransferSerialCOM1(this.Transfer_6_OPT0(this.CurrentWeightData));
                                    break;
                                case 7:
                                    this.TransferSerialCOM1(this.Transfer_7_imaje9410OPT2(this.CurrentWeightData));
                                    break;
                                case 8:
                                    this.TransferSerialCOM1(this.Transfer_8_imaje9028OPT2(this.CurrentWeightData));
                                    break;
                                case 9:
                                    this.TransferSerialCOM1(this.Transfer_9_Hitachi(this.CurrentWeightData, Define.E_SerialCOM.COM1));
                                    break;
                                case 10:
                                    this.TransferSerialCOM1(this.Transfer_10_MACSA(this.CurrentWeightData, this.CurrentProductItem));
                                    break;
                                case 11:
                                    this.TransferSerialCOM1(this.Transfer_11_Markoprint(this.CurrentWeightData, this.CurrentProductItem));
                                    break;
                                case 12:
                                    this.TransferSerialCOM1(this.Transfer_12_alphaJET(this.CurrentWeightData, this.CurrentProductItem));
                                    break;
                                case 13:
                                    this.TransferSerialCOM1(this.Transfer_13_Marking_VJ1510(this.CurrentWeightData));
                                    break;
                                case 17:
                                    this.TransferSerialCOM1(this.Transfer_17_OPT3(this.CurrentWeightData, this.CurrentProductItem));
                                    break;
                                case 18:
                                    this.TransferSerialCOM1(this.Transfer_18_HP200(this.CurrentWeightData, 1));
                                    this.TransferSerialCOM1(this.Transfer_18_HP200(this.CurrentWeightData, 2));
                                    break;
                                case 19:
                                    if (this.CurrentWeightData.JudgmentStatus == Define.E_JudgmentStatus.Pass)
                                        this.TransferSerialCOM1(this.Transfer_19_SmartJet(this.CurrentWeightData));
                                    break;
                                case 20:
                                    if (this.CurrentWeightData.JudgmentStatus == Define.E_JudgmentStatus.Pass)
                                    {
                                        this.TransferSerialCOM1(this.RoomChange9410(2)); // 2번방 변경
                                        Thread.Sleep(200);
                                        this.TransferSerialCOM1(this.SendChar(Define.E_CharValue.ACK)); // ACK
                                        Thread.Sleep(200);
                                        this.TransferSerialCOM1(this.WeightData9410_OPT3(this.CurrentWeightData)); // 중량값 전송
                                    }
                                    else
                                    {
                                        this.TransferSerialCOM1(this.RoomChange9410(1)); // 1번방 변경
                                        Thread.Sleep(200);
                                        this.TransferSerialCOM1(this.SendChar(Define.E_CharValue.ACK)); // ACK
                                    }
                                    break;
                                case (int)Define.E_CommMode.f22_Modbus: // Modbus RTU(Master 사용 시 - Write multiple register)
                                    if (this.SystemConfig2.ModbusRTUSelectFunction == (int)Define.E_ModbusFunction._16_WriteMultipleRegister)
                                    {
                                        byte[] sendData = this.Modbus.MakeRTUSendAllData(this.Transfer_22_Modbus_Write(), this.SystemConfig2.ModbusSlaveIDCOM1, this.SystemConfig2.ModbusRTUStartAddressCOM1);

                                        this.TransferSerialCOM1(sendData);
                                    }
                                    break;
                                case (int)Define.E_CommMode.f23_STD2:
                                    this.TransferSerialCOM1(this.Transfer_23_STD2(this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem));
                                    break;
                                case (int)Define.E_CommMode.f24_MULTi_JET:
                                    this.TransferSerialCOM1(this.Transfer_24_MULTi_JET(false, this.CurrentWeightData));
                                    break;
                                case (int)Define.E_CommMode.f26_LINX8830:
                                    this.TransferSerialCOM1(this.Transfer_26_LINX8830(false, this.CurrentWeightData));
                                    break;
                                case (int)Define.E_CommMode.f27_MYJET:
                                    this.TransferSerialCOM1(this.Transfer_27_MYJET(false, this.CurrentWeightData));
                                    break;
                                case (int)Define.E_CommMode.f28_OPT4: // Tasco(타스코) PC 전송
                                    this.TransferSerialCOM1(this.Transfer_28_OPT4(false, this.CurrentWeightData));
                                    break;
                                default:
                                    break;
                            }
                            #endregion
                        }
                        // 통신 COM3
                        if (this.SystemConfig1.SerialCOM3Mode != 0)
                        {
                            #region COM3
                            switch (this.SystemConfig1.SerialCOM3Mode)
                            {
                                case 1:
                                    this.TransferSerialCOM3(this.Transfer_1_STD1(this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem));
                                    break;
                                case 2:
                                    this.TransferSerialCOM3(this.Transfer_2_Remote(this.CurrentWeightData, this.CurrentProductItem));
                                    break;
                                case 3:
                                    if (this.SystemConfig1.IsPrintPerProductEnable == true)
                                        this.TransferSerialCOM3(this.Transfer_3_Print(this.CurrentWeightData, this.CurrentProductItem));
                                    break;
                                case 4:
                                    if (this.CurrentWeightData.JudgmentStatus == Define.E_JudgmentStatus.Pass)
                                    {
                                        this.TransferSerialCOM3(this.RoomChange9410(2)); // 2번방 변경
                                        Thread.Sleep(200);
                                        this.TransferSerialCOM3(this.SendChar(Define.E_CharValue.ACK)); // ACK
                                        Thread.Sleep(200);
                                        this.TransferSerialCOM3(this.WeightData9410_OPT1(this.CurrentWeightData)); // 중량값 전송
                                    }
                                    else
                                    {
                                        this.TransferSerialCOM3(this.RoomChange9410(1)); // 1번방 변경
                                        Thread.Sleep(200);
                                        this.TransferSerialCOM3(this.SendChar(Define.E_CharValue.ACK)); // ACK
                                    }
                                    break;
                                case 5:
                                    this.HMCOM3_Step = 1;
                                    this.TransferSerialCOM3(this.SendChar(Define.E_CharValue.ENQ));
                                    break;
                                case 6:
                                    this.TransferSerialCOM3(this.Transfer_6_OPT0(this.CurrentWeightData));
                                    break;
                                case 7:
                                    this.TransferSerialCOM3(this.Transfer_7_imaje9410OPT2(this.CurrentWeightData));
                                    break;
                                case 8:
                                    this.TransferSerialCOM3(this.Transfer_8_imaje9028OPT2(this.CurrentWeightData));
                                    break;
                                case 9:
                                    this.TransferSerialCOM3(this.Transfer_9_Hitachi(this.CurrentWeightData, Define.E_SerialCOM.COM3));
                                    break;
                                case 10:
                                    this.TransferSerialCOM3(this.Transfer_10_MACSA(this.CurrentWeightData, this.CurrentProductItem));
                                    break;
                                case 11:
                                    this.TransferSerialCOM3(this.Transfer_11_Markoprint(this.CurrentWeightData, this.CurrentProductItem));
                                    break;
                                case 12:
                                    this.TransferSerialCOM3(this.Transfer_12_alphaJET(this.CurrentWeightData, this.CurrentProductItem));
                                    break;
                                case 13:
                                    this.TransferSerialCOM3(this.Transfer_13_Marking_VJ1510(this.CurrentWeightData));
                                    break;
                                case 17:
                                    this.TransferSerialCOM3(this.Transfer_17_OPT3(this.CurrentWeightData, this.CurrentProductItem));
                                    break;
                                case 18:
                                    this.TransferSerialCOM3(this.Transfer_18_HP200(this.CurrentWeightData, 1));
                                    this.TransferSerialCOM3(this.Transfer_18_HP200(this.CurrentWeightData, 2));
                                    break;
                                case 19:
                                    if (this.CurrentWeightData.JudgmentStatus == Define.E_JudgmentStatus.Pass)
                                        this.TransferSerialCOM3(this.Transfer_19_SmartJet(this.CurrentWeightData));
                                    break;
                                case 20:
                                    if (this.CurrentWeightData.JudgmentStatus == Define.E_JudgmentStatus.Pass)
                                    {
                                        this.TransferSerialCOM3(this.RoomChange9410(2)); // 2번방 변경
                                        Thread.Sleep(200);
                                        this.TransferSerialCOM3(this.SendChar(Define.E_CharValue.ACK)); // ACK
                                        Thread.Sleep(200);
                                        this.TransferSerialCOM3(this.WeightData9410_OPT3(this.CurrentWeightData)); // 중량값 전송
                                    }
                                    else
                                    {
                                        this.TransferSerialCOM3(this.RoomChange9410(1)); // 1번방 변경
                                        Thread.Sleep(200);
                                        this.TransferSerialCOM3(this.SendChar(Define.E_CharValue.ACK)); // ACK
                                    }
                                    break;
                                case (int)Define.E_CommMode.f22_Modbus: // Modbus RTU(Master 사용 시 - Write multiple register)
                                    if (this.SystemConfig2.ModbusRTUSelectFunction == (int)Define.E_ModbusFunction._16_WriteMultipleRegister)
                                    {
                                        byte[] sendData = this.Modbus.MakeRTUSendAllData(this.Transfer_22_Modbus_Write(), this.SystemConfig2.ModbusSlaveIDCOM3, this.SystemConfig2.ModbusRTUStartAddressCOM3);

                                        this.TransferSerialCOM3(sendData);
                                    }
                                    break;
                                case (int)Define.E_CommMode.f23_STD2:
                                    this.TransferSerialCOM3(this.Transfer_23_STD2(this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem));
                                    break;
                                case (int)Define.E_CommMode.f24_MULTi_JET:
                                    this.TransferSerialCOM3(this.Transfer_24_MULTi_JET(false, this.CurrentWeightData));
                                    break;
                                case (int)Define.E_CommMode.f26_LINX8830:
                                    this.TransferSerialCOM3(this.Transfer_26_LINX8830(false, this.CurrentWeightData));
                                    break;
                                case (int)Define.E_CommMode.f27_MYJET:
                                    this.TransferSerialCOM3(this.Transfer_27_MYJET(false, this.CurrentWeightData));
                                    break;
                                case (int)Define.E_CommMode.f28_OPT4: // Tasco(타스코) PC 전송
                                    this.TransferSerialCOM3(this.Transfer_28_OPT4(false, this.CurrentWeightData));
                                    break;
                                default:
                                    break;
                            }
                            #endregion
                        }
                        // 통신 COM4
                        if (this.SystemConfig1.SerialCOM4Mode != 0)
                        {
                            #region COM4
                            switch (this.SystemConfig1.SerialCOM4Mode)
                            {
                                case 1:
                                    this.TransferSerialCOM4(this.Transfer_1_STD1(this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem));
                                    break;
                                case 2:
                                    this.TransferSerialCOM4(this.Transfer_2_Remote(this.CurrentWeightData, this.CurrentProductItem));
                                    break;
                                case 3:
                                    if (this.SystemConfig1.IsPrintPerProductEnable == true)
                                        this.TransferSerialCOM4(this.Transfer_3_Print(this.CurrentWeightData, this.CurrentProductItem));
                                    break;
                                case 4:
                                    if (this.CurrentWeightData.JudgmentStatus == Define.E_JudgmentStatus.Pass)
                                    {
                                        this.TransferSerialCOM4(this.RoomChange9410(2)); // 2번방 변경
                                        Thread.Sleep(200);
                                        this.TransferSerialCOM4(this.SendChar(Define.E_CharValue.ACK)); // ACK
                                        Thread.Sleep(200);
                                        this.TransferSerialCOM4(this.WeightData9410_OPT1(this.CurrentWeightData)); // 중량값 전송
                                    }
                                    else
                                    {
                                        this.TransferSerialCOM4(this.RoomChange9410(1)); // 1번방 변경
                                        Thread.Sleep(200);
                                        this.TransferSerialCOM4(this.SendChar(Define.E_CharValue.ACK)); // ACK
                                    }
                                    break;
                                case 5:
                                    this.HMCOM4_Step = 1;
                                    this.TransferSerialCOM4(this.SendChar(Define.E_CharValue.ENQ));
                                    break;
                                case 6:
                                    this.TransferSerialCOM4(this.Transfer_6_OPT0(this.CurrentWeightData));
                                    break;
                                case 7:
                                    this.TransferSerialCOM4(this.Transfer_7_imaje9410OPT2(this.CurrentWeightData));
                                    break;
                                case 8:
                                    this.TransferSerialCOM4(this.Transfer_8_imaje9028OPT2(this.CurrentWeightData));
                                    break;
                                case 9:
                                    this.TransferSerialCOM4(this.Transfer_9_Hitachi(this.CurrentWeightData, Define.E_SerialCOM.COM4));
                                    break;
                                case 10:
                                    this.TransferSerialCOM4(this.Transfer_10_MACSA(this.CurrentWeightData, this.CurrentProductItem));
                                    break;
                                case 11:
                                    this.TransferSerialCOM4(this.Transfer_11_Markoprint(this.CurrentWeightData, this.CurrentProductItem));
                                    break;
                                case 12:
                                    this.TransferSerialCOM4(this.Transfer_12_alphaJET(this.CurrentWeightData, this.CurrentProductItem));
                                    break;
                                case 13:
                                    this.TransferSerialCOM4(this.Transfer_13_Marking_VJ1510(this.CurrentWeightData));
                                    break;
                                case 17:
                                    this.TransferSerialCOM4(this.Transfer_17_OPT3(this.CurrentWeightData, this.CurrentProductItem));
                                    break;
                                case 18:
                                    this.TransferSerialCOM4(this.Transfer_18_HP200(this.CurrentWeightData, 1));
                                    this.TransferSerialCOM4(this.Transfer_18_HP200(this.CurrentWeightData, 2));
                                    break;
                                case 19:
                                    if (this.CurrentWeightData.JudgmentStatus == Define.E_JudgmentStatus.Pass)
                                        this.TransferSerialCOM4(this.Transfer_19_SmartJet(this.CurrentWeightData));
                                    break;
                                case 20:
                                    if (this.CurrentWeightData.JudgmentStatus == Define.E_JudgmentStatus.Pass)
                                    {
                                        this.TransferSerialCOM4(this.RoomChange9410(2)); // 2번방 변경
                                        Thread.Sleep(200);
                                        this.TransferSerialCOM4(this.SendChar(Define.E_CharValue.ACK)); // ACK
                                        Thread.Sleep(200);
                                        this.TransferSerialCOM4(this.WeightData9410_OPT3(this.CurrentWeightData)); // 중량값 전송
                                    }
                                    else
                                    {
                                        this.TransferSerialCOM4(this.RoomChange9410(1)); // 1번방 변경
                                        Thread.Sleep(200);
                                        this.TransferSerialCOM4(this.SendChar(Define.E_CharValue.ACK)); // ACK
                                    }
                                    break;
                                case (int)Define.E_CommMode.f22_Modbus: // Modbus RTU(Master 사용 시 - Write multiple register)
                                    if (this.SystemConfig2.ModbusRTUSelectFunction == (int)Define.E_ModbusFunction._16_WriteMultipleRegister)
                                    {
                                        byte[] sendData = this.Modbus.MakeRTUSendAllData(this.Transfer_22_Modbus_Write(), this.SystemConfig2.ModbusSlaveIDCOM4, this.SystemConfig2.ModbusRTUStartAddressCOM4);

                                        this.TransferSerialCOM4(sendData);
                                    }
                                    break;
                                case (int)Define.E_CommMode.f23_STD2:
                                    this.TransferSerialCOM4(this.Transfer_23_STD2(this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem));
                                    break;
                                case (int)Define.E_CommMode.f24_MULTi_JET:
                                    this.TransferSerialCOM4(this.Transfer_24_MULTi_JET(false, this.CurrentWeightData));
                                    break;
                                case (int)Define.E_CommMode.f26_LINX8830:
                                    this.TransferSerialCOM4(this.Transfer_26_LINX8830(false, this.CurrentWeightData));
                                    break;
                                case (int)Define.E_CommMode.f27_MYJET:
                                    this.TransferSerialCOM4(this.Transfer_27_MYJET(false, this.CurrentWeightData));
                                    break;
                                case (int)Define.E_CommMode.f28_OPT4: // Tasco(타스코) PC 전송
                                    this.TransferSerialCOM4(this.Transfer_28_OPT4(false, this.CurrentWeightData));
                                    break;
                                default:
                                    break;
                            }
                            #endregion
                        }

                        // 이더넷
                        switch (this.SystemConfig2.EthernetOperationMode)
                        {
                            case 1:
                                if (this.smartTCPMultiServer.ClientInfoList != null)
                                {
                                    if (this.SystemConfig2.EthernetCommMode != 0)
                                    {
                                        foreach (SmartTCPMultiServer.CLIENTSINFOS client in this.smartTCPMultiServer.ClientInfoList)
                                        {
                                            #region Server
                                            switch (this.SystemConfig2.EthernetCommMode)
                                            {
                                                case 1:
                                                    this.EthernetServerSendMessage(client,
                                                        this.Transfer_1_STD1(this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem));
                                                    break;
                                                case 2:
                                                    this.EthernetServerSendMessage(client, this.Transfer_2_Remote(this.CurrentWeightData, this.CurrentProductItem));
                                                    break;
                                                case 3:
                                                    if (this.SystemConfig1.IsPrintPerProductEnable == true)
                                                        this.EthernetServerSendMessage(client, this.Transfer_3_Print(this.CurrentWeightData, this.CurrentProductItem));
                                                    break;
                                                case 4:
                                                    if (this.CurrentWeightData.JudgmentStatus == Define.E_JudgmentStatus.Pass)
                                                    {
                                                        this.EthernetServerSendMessage(client, this.RoomChange9410(2)); // 2번방 변경
                                                        Thread.Sleep(200);
                                                        this.EthernetServerSendMessage(client, this.SendChar(Define.E_CharValue.ACK)); // ACK
                                                        Thread.Sleep(200);
                                                        this.EthernetServerSendMessage(client, this.WeightData9410_OPT1(this.CurrentWeightData)); // 중량값 전송
                                                    }
                                                    else
                                                    {
                                                        this.EthernetServerSendMessage(client, this.RoomChange9410(1)); // 1번방 변경
                                                        Thread.Sleep(200);
                                                        this.EthernetServerSendMessage(client, this.SendChar(Define.E_CharValue.ACK)); // ACK
                                                    }
                                                    break;
                                                case 5:
                                                    this.HMCOM1_Step = 1;
                                                    this.EthernetServerSendMessage(client, this.SendChar(Define.E_CharValue.ENQ));
                                                    break;
                                                case 6:
                                                    this.EthernetServerSendMessage(client, this.Transfer_6_OPT0(this.CurrentWeightData));
                                                    break;
                                                case 7:
                                                    this.EthernetServerSendMessage(client, this.Transfer_7_imaje9410OPT2(this.CurrentWeightData));
                                                    break;
                                                case 8:
                                                    this.EthernetServerSendMessage(client, this.Transfer_8_imaje9028OPT2(this.CurrentWeightData));
                                                    break;
                                                case 9:
                                                    this.EthernetServerSendMessage(client, this.Transfer_9_Hitachi(this.CurrentWeightData, Define.E_SerialCOM.COM1));
                                                    break;
                                                case 10:
                                                    this.EthernetServerSendMessage(client, this.Transfer_10_MACSA(this.CurrentWeightData, this.CurrentProductItem));
                                                    break;
                                                case 11:
                                                    this.EthernetServerSendMessage(client, this.Transfer_11_Markoprint(this.CurrentWeightData, this.CurrentProductItem));
                                                    break;
                                                case 12:
                                                    this.EthernetServerSendMessage(client, this.Transfer_12_alphaJET(this.CurrentWeightData, this.CurrentProductItem));
                                                    break;
                                                case 13:
                                                    this.EthernetServerSendMessage(client, this.Transfer_13_Marking_VJ1510(this.CurrentWeightData));
                                                    break;
                                                case 17:
                                                    this.EthernetServerSendMessage(client, this.Transfer_17_OPT3(this.CurrentWeightData, this.CurrentProductItem));
                                                    break;
                                                case 18:
                                                    this.EthernetServerSendMessage(client, this.Transfer_18_HP200(this.CurrentWeightData, 1));
                                                    this.EthernetServerSendMessage(client, this.Transfer_18_HP200(this.CurrentWeightData, 2));
                                                    break;
                                                case 19:
                                                    if (this.CurrentWeightData.JudgmentStatus == Define.E_JudgmentStatus.Pass)
                                                        this.EthernetServerSendMessage(client, this.Transfer_19_SmartJet(this.CurrentWeightData));
                                                    break;
                                                case 20:
                                                    if (this.CurrentWeightData.JudgmentStatus == Define.E_JudgmentStatus.Pass)
                                                    {
                                                        this.EthernetServerSendMessage(client, this.RoomChange9410(2)); // 2번방 변경
                                                        Thread.Sleep(200);
                                                        this.EthernetServerSendMessage(client, this.SendChar(Define.E_CharValue.ACK)); // ACK
                                                        Thread.Sleep(200);
                                                        this.EthernetServerSendMessage(client, this.WeightData9410_OPT3(this.CurrentWeightData)); // 중량값 전송
                                                    }
                                                    else
                                                    {
                                                        this.EthernetServerSendMessage(client, this.RoomChange9410(1)); // 1번방 변경
                                                        Thread.Sleep(200);
                                                        this.EthernetServerSendMessage(client, this.SendChar(Define.E_CharValue.ACK)); // ACK
                                                    }
                                                    break;
                                                case (int)Define.E_CommMode.f22_Modbus: // 22, Modbus TCP
                                                    if (this.SystemConfig2.ModbusTCPSelectFunction == (int)Define.E_ModbusFunction._16_WriteMultipleRegister)
                                                    {
                                                        byte[] sendData = this.Modbus.MakeTCPSendAllData(this.Transfer_22_Modbus_Write(), this.SystemConfig2.ModbusTCPStartAddress);

                                                        this.EthernetServerSendMessage(client, sendData);
                                                    }
                                                    break;
                                                case (int)Define.E_CommMode.f23_STD2:
                                                    this.EthernetServerSendMessage(client,
                                                        this.Transfer_23_STD2(this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem));
                                                    break;
                                                case (int)Define.E_CommMode.f24_MULTi_JET:
                                                    this.EthernetServerSendMessage(client, this.Transfer_24_MULTi_JET(false, this.CurrentWeightData));
                                                    break;
                                                case (int)Define.E_CommMode.f26_LINX8830:
                                                    this.EthernetServerSendMessage(client, this.Transfer_26_LINX8830(false, this.CurrentWeightData));
                                                    break;
                                                case (int)Define.E_CommMode.f27_MYJET:
                                                    if (this.CurrentWeightData.JudgmentStatus == Define.E_JudgmentStatus.Pass)
                                                        this.EthernetServerSendMessage(client, this.Transfer_27_MYJET(false, this.CurrentWeightData));
                                                    break;
                                                case (int)Define.E_CommMode.f28_OPT4: // Tasco(타스코) PC 전송
                                                    this.EthernetServerSendMessage(client, this.Transfer_28_OPT4(false, this.CurrentWeightData));
                                                    break;
                                                default:
                                                    break;
                                            }
                                            #endregion
                                        }
                                    }
                                }
                                break;
                            case 2:
                                if (this.SystemConfig2.EthernetCommMode != 0)
                                {
                                    #region Client
                                    switch (this.SystemConfig2.EthernetCommMode)
                                    {
                                        case 1:
                                            this.ClientSendDataString = this.Transfer_1_STD1(this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem);
                                            this.EthernetWeightData(this.ClientSendDataString);
                                            break;
                                        case 2:
                                            this.ClientSendDataString = this.Transfer_2_Remote(this.CurrentWeightData, this.CurrentProductItem);
                                            this.EthernetWeightData(this.ClientSendDataString);
                                            break;
                                        case 3:
                                            if (this.SystemConfig1.IsPrintPerProductEnable == true)
                                            {
                                                this.ClientSendDataString = this.Transfer_3_Print(this.CurrentWeightData, this.CurrentProductItem);
                                                this.EthernetWeightData(this.ClientSendDataString);
                                            }
                                            break;
                                        case 4:
                                            if (this.CurrentWeightData.JudgmentStatus == Define.E_JudgmentStatus.Pass)
                                            {
                                                this.EthernetWeightData(this.RoomChange9410(2)); // 2번방 변경
                                                Thread.Sleep(200);
                                                this.EthernetWeightData(this.SendChar(Define.E_CharValue.ACK)); // ACK
                                                Thread.Sleep(200);
                                                this.EthernetWeightData(this.WeightData9410_OPT1(this.CurrentWeightData)); // 중량값 전송
                                            }
                                            else
                                            {
                                                this.EthernetWeightData(this.RoomChange9410(1)); // 1번방 변경
                                                Thread.Sleep(200);
                                                this.EthernetWeightData(this.SendChar(Define.E_CharValue.ACK)); // ACK
                                            }
                                            break;
                                        case 5:
                                            this.HMCOM1_Step = 1;
                                            this.ClientSendDataString = this.SendChar(Define.E_CharValue.ENQ);
                                            this.EthernetWeightData(this.ClientSendDataString);
                                            break;
                                        case 6:
                                            this.ClientSendDataString = this.Transfer_6_OPT0(this.CurrentWeightData);
                                            this.EthernetWeightData(this.ClientSendDataString);
                                            break;
                                        case 7:
                                            this.ClientSendDatabyteArray = this.Transfer_7_imaje9410OPT2(this.CurrentWeightData);
                                            this.EthernetWeightData(this.ClientSendDatabyteArray);
                                            break;
                                        case 8:
                                            this.ClientSendDatabyteArray = this.Transfer_8_imaje9028OPT2(this.CurrentWeightData);
                                            this.EthernetWeightData(this.ClientSendDatabyteArray);
                                            break;
                                        case 9:
                                            this.ClientSendDataString = this.Transfer_9_Hitachi(this.CurrentWeightData, Define.E_SerialCOM.COM1);
                                            this.EthernetWeightData(this.ClientSendDataString);
                                            break;
                                        case 10:
                                            this.ClientSendDatabyteArray = this.Transfer_10_MACSA(this.CurrentWeightData, this.CurrentProductItem);
                                            this.EthernetWeightData(this.ClientSendDatabyteArray);
                                            break;
                                        case 11:
                                            this.ClientSendDatabyteArray = this.Transfer_11_Markoprint(this.CurrentWeightData, this.CurrentProductItem);
                                            this.EthernetWeightData(this.ClientSendDatabyteArray);
                                            break;
                                        case 12:
                                            this.ClientSendDatabyteArray = this.Transfer_12_alphaJET(this.CurrentWeightData, this.CurrentProductItem);
                                            this.EthernetWeightData(this.ClientSendDatabyteArray);
                                            break;
                                        case 13:
                                            this.ClientSendDataString = this.Transfer_13_Marking_VJ1510(this.CurrentWeightData);
                                            this.EthernetWeightData(this.ClientSendDataString);
                                            break;
                                        case 17:
                                            this.ClientSendDataString = this.Transfer_17_OPT3(this.CurrentWeightData, this.CurrentProductItem);
                                            this.EthernetWeightData(this.ClientSendDataString);
                                            break;
                                        case 18:
                                            this.EthernetWeightData(this.Transfer_18_HP200(this.CurrentWeightData, 1));
                                            this.EthernetWeightData(this.Transfer_18_HP200(this.CurrentWeightData, 2));
                                            break;
                                        case 19:
                                            if (this.CurrentWeightData.JudgmentStatus == Define.E_JudgmentStatus.Pass)
                                            {
                                                this.ClientSendDataString = this.Transfer_19_SmartJet(this.CurrentWeightData);
                                                this.EthernetWeightData(this.ClientSendDataString);
                                            }
                                            break;
                                        case 20:
                                            if (this.CurrentWeightData.JudgmentStatus == Define.E_JudgmentStatus.Pass)
                                            {
                                                this.EthernetWeightData(this.RoomChange9410(2)); // 2번방 변경
                                                Thread.Sleep(200);
                                                this.EthernetWeightData(this.SendChar(Define.E_CharValue.ACK)); // ACK
                                                Thread.Sleep(200);
                                                this.EthernetWeightData(this.WeightData9410_OPT3(this.CurrentWeightData)); // 중량값 전송
                                            }
                                            else
                                            {
                                                this.EthernetWeightData(this.RoomChange9410(1)); // 1번방 변경
                                                Thread.Sleep(200);
                                                this.EthernetWeightData(this.SendChar(Define.E_CharValue.ACK)); // ACK
                                            }
                                            break;
                                        case (int)Define.E_CommMode.f22_Modbus: // 22, Modbus TCP
                                            if (this.SystemConfig2.ModbusTCPSelectFunction == (int)Define.E_ModbusFunction._16_WriteMultipleRegister)
                                            {
                                                this.ClientSendDatabyteArray = this.Modbus.MakeTCPSendAllData(this.Transfer_22_Modbus_Write(), this.SystemConfig2.ModbusTCPStartAddress);

                                                this.EthernetWeightDataForModbus(this.ClientSendDatabyteArray);
                                            }
                                            break;
                                        case (int)Define.E_CommMode.f23_STD2:
                                            this.ClientSendDataString = this.Transfer_23_STD2(this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem);
                                            this.EthernetWeightData(this.ClientSendDataString);
                                            break;
                                        case (int)Define.E_CommMode.f24_MULTi_JET:
                                            this.EthernetWeightData(this.Transfer_24_MULTi_JET(false, this.CurrentWeightData));
                                            break;
                                        case (int)Define.E_CommMode.f26_LINX8830:
                                            this.EthernetWeightData(this.Transfer_26_LINX8830(false, this.CurrentWeightData));
                                            break;
                                        case (int)Define.E_CommMode.f27_MYJET:
                                            this.EthernetWeightData(this.Transfer_27_MYJET(false, this.CurrentWeightData));
                                            break;
                                        case (int)Define.E_CommMode.f28_OPT4: // Tasco(타스코) PC 전송
                                            this.EthernetWeightData(this.Transfer_28_OPT4(false, this.CurrentWeightData));
                                            break;
                                        default:
                                            break;
                                    }
                                    #endregion
                                }
                                break;
                            default:
                                break;
                        }
                        #endregion

                        #region 카운터출력

                        #region Counting Output 1
                        temp = this.SystemConfig2.CountingOutput1Number;

                        if (this.SystemConfig2.CountingOutput1Mode != 0 && temp != 0)
                        {
                            switch (this.SystemConfig2.CountingOutput1Mode)
                            {
                                case 1: // Pass
                                    if (this.CurrentWeightData.JudgmentStatus == Define.E_JudgmentStatus.Pass)
                                    {
                                        this.CountingOutput1Count++;

                                        if (this.CountingOutput1Count >= temp)
                                        {
                                            this.CountingOutput1Count = 0;

                                            if (this.SystemConfig2.IsCountingOutput1BuzzerOn == true)
                                                this.TransferData(CommunicationCommand.BuzzerOn, CommunicationID.MainBoard);
                                            if (this.SystemConfig2.IsCountingOutput1ConveyorStop == true)
                                            {
                                                this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
                                                // 메시지 23
                                                this.StartThreadMessage1();
                                            }
                                            if (this.SystemConfig2.IsCountingOutput1ExternalOutput == true)
                                                this.TransferData(CommunicationCommand.CountingOutput1Pulse, CommunicationID.MainBoard);
                                        }
                                    }
                                    else
                                    {
                                        if (this.SystemConfig2.IsCountingOutput1Continuous == true)
                                            this.CountingOutput1Count = 0;
                                    }
                                    break;
                                case 2: // NG
                                    if (this.CurrentWeightData.JudgmentStatus == Define.E_JudgmentStatus.Over
                                        || this.CurrentWeightData.JudgmentStatus == Define.E_JudgmentStatus.Under)
                                    {
                                        this.CountingOutput1Count++;

                                        if (this.CountingOutput1Count >= temp)
                                        {
                                            this.CountingOutput1Count = 0;

                                            if (this.SystemConfig2.IsCountingOutput1BuzzerOn == true)
                                                this.TransferData(CommunicationCommand.BuzzerOn, CommunicationID.MainBoard);
                                            if (this.SystemConfig2.IsCountingOutput1ConveyorStop == true)
                                            {
                                                this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
                                                // 메시지 23
                                                this.StartThreadMessage1();
                                            }
                                            if (this.SystemConfig2.IsCountingOutput1ExternalOutput == true)
                                                this.TransferData(CommunicationCommand.CountingOutput1Pulse, CommunicationID.MainBoard);
                                        }
                                    }
                                    else
                                    {
                                        if (this.SystemConfig2.IsCountingOutput1Continuous == true)
                                            this.CountingOutput1Count = 0;
                                    }
                                    break;
                                case 3: // Over
                                    if (this.CurrentWeightData.JudgmentStatus == Define.E_JudgmentStatus.Over)
                                    {
                                        this.CountingOutput1Count++;

                                        if (this.CountingOutput1Count >= temp)
                                        {
                                            this.CountingOutput1Count = 0;

                                            if (this.SystemConfig2.IsCountingOutput1BuzzerOn == true)
                                                this.TransferData(CommunicationCommand.BuzzerOn, CommunicationID.MainBoard);
                                            if (this.SystemConfig2.IsCountingOutput1ConveyorStop == true)
                                            {
                                                this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
                                                // 메시지 23
                                                this.StartThreadMessage1();
                                            }
                                            if (this.SystemConfig2.IsCountingOutput1ExternalOutput == true)
                                                this.TransferData(CommunicationCommand.CountingOutput1Pulse, CommunicationID.MainBoard);
                                        }
                                    }
                                    else
                                    {
                                        if (this.SystemConfig2.IsCountingOutput1Continuous == true)
                                            this.CountingOutput1Count = 0;
                                    }
                                    break;
                                case 4: // Under
                                    if (this.CurrentWeightData.JudgmentStatus == Define.E_JudgmentStatus.Under)
                                    {
                                        this.CountingOutput1Count++;

                                        if (this.CountingOutput1Count >= temp)
                                        {
                                            this.CountingOutput1Count = 0;

                                            if (this.SystemConfig2.IsCountingOutput1BuzzerOn == true)
                                                this.TransferData(CommunicationCommand.BuzzerOn, CommunicationID.MainBoard);
                                            if (this.SystemConfig2.IsCountingOutput1ConveyorStop == true)
                                            {
                                                this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
                                                // 메시지 23. 알람 조건이 충족하여 장비가 정지되었습니다
                                                this.StartThreadMessage1();
                                            }
                                            if (this.SystemConfig2.IsCountingOutput1ExternalOutput == true)
                                                this.TransferData(CommunicationCommand.CountingOutput1Pulse, CommunicationID.MainBoard);
                                        }
                                    }
                                    else
                                    {
                                        if (this.SystemConfig2.IsCountingOutput1Continuous == true)
                                            this.CountingOutput1Count = 0;
                                    }
                                    break;
                                default:
                                    break;
                            }
                        }
                        #endregion

                        #region Counting Output 2
                        temp = this.SystemConfig2.CountingOutput2Number;

                        if (this.SystemConfig2.CountingOutput2Mode != 0 && temp != 0)
                        {
                            switch (this.SystemConfig2.CountingOutput2Mode)
                            {
                                case 1: // Pass
                                    if (this.CurrentWeightData.JudgmentStatus == Define.E_JudgmentStatus.Pass)
                                    {
                                        this.CountingOutput2Count++;

                                        if (this.CountingOutput2Count >= temp)
                                        {
                                            this.CountingOutput2Count = 0;

                                            if (this.SystemConfig2.IsCountingOutput2BuzzerOn == true)
                                                this.TransferData(CommunicationCommand.BuzzerOn, CommunicationID.MainBoard);
                                            if (this.SystemConfig2.IsCountingOutput2ConveyorStop == true)
                                            {
                                                this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
                                                // 메시지 23
                                                this.StartThreadMessage1();
                                            }
                                            if (this.SystemConfig2.IsCountingOutput2ExternalOutput == true)
                                                this.TransferData(CommunicationCommand.CountingOutput2Pulse, CommunicationID.MainBoard);
                                        }
                                    }
                                    else
                                    {
                                        if (this.SystemConfig2.IsCountingOutput2Continuous == true)
                                            this.CountingOutput2Count = 0;
                                    }
                                    break;
                                case 2: // NG
                                    if (this.CurrentWeightData.JudgmentStatus == Define.E_JudgmentStatus.Over
                                        || this.CurrentWeightData.JudgmentStatus == Define.E_JudgmentStatus.Under)
                                    {
                                        this.CountingOutput2Count++;

                                        if (this.CountingOutput2Count >= temp)
                                        {
                                            this.CountingOutput2Count = 0;

                                            if (this.SystemConfig2.IsCountingOutput2BuzzerOn == true)
                                                this.TransferData(CommunicationCommand.BuzzerOn, CommunicationID.MainBoard);
                                            if (this.SystemConfig2.IsCountingOutput2ConveyorStop == true)
                                            {
                                                this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
                                                // 메시지 23
                                                this.StartThreadMessage1();
                                            }
                                            if (this.SystemConfig2.IsCountingOutput2ExternalOutput == true)
                                                this.TransferData(CommunicationCommand.CountingOutput2Pulse, CommunicationID.MainBoard);
                                        }
                                    }
                                    else
                                    {
                                        if (this.SystemConfig2.IsCountingOutput2Continuous == true)
                                            this.CountingOutput2Count = 0;
                                    }
                                    break;
                                case 3: // Over
                                    if (this.CurrentWeightData.JudgmentStatus == Define.E_JudgmentStatus.Over)
                                    {
                                        this.CountingOutput2Count++;

                                        if (this.CountingOutput2Count >= temp)
                                        {
                                            this.CountingOutput2Count = 0;

                                            if (this.SystemConfig2.IsCountingOutput2BuzzerOn == true)
                                                this.TransferData(CommunicationCommand.BuzzerOn, CommunicationID.MainBoard);
                                            if (this.SystemConfig2.IsCountingOutput2ConveyorStop == true)
                                            {
                                                this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
                                                // 메시지 23
                                                this.StartThreadMessage1();
                                            }
                                            if (this.SystemConfig2.IsCountingOutput2ExternalOutput == true)
                                                this.TransferData(CommunicationCommand.CountingOutput2Pulse, CommunicationID.MainBoard);
                                        }
                                    }
                                    else
                                    {
                                        if (this.SystemConfig2.IsCountingOutput2Continuous == true)
                                            this.CountingOutput2Count = 0;
                                    }
                                    break;
                                case 4: // Under
                                    if (this.CurrentWeightData.JudgmentStatus == Define.E_JudgmentStatus.Under)
                                    {
                                        this.CountingOutput2Count++;

                                        if (this.CountingOutput2Count >= temp)
                                        {
                                            this.CountingOutput2Count = 0;

                                            if (this.SystemConfig2.IsCountingOutput2BuzzerOn == true)
                                                this.TransferData(CommunicationCommand.BuzzerOn, CommunicationID.MainBoard);
                                            if (this.SystemConfig2.IsCountingOutput2ConveyorStop == true)
                                            {
                                                this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
                                                // 메시지 23
                                                this.StartThreadMessage1();
                                            }
                                            if (this.SystemConfig2.IsCountingOutput2ExternalOutput == true)
                                                this.TransferData(CommunicationCommand.CountingOutput2Pulse, CommunicationID.MainBoard);
                                        }
                                    }
                                    else
                                    {
                                        if (this.SystemConfig2.IsCountingOutput2Continuous == true)
                                            this.CountingOutput2Count = 0;
                                    }
                                    break;
                                default:
                                    break;
                            }
                        }
                        #endregion

                        this.ChildFormMainDisplay.MainWeightBigScreen.UpdateAlarmLabelDisplay(this.CountingOutput1Count, this.CountingOutput2Count);
                        this.ChildFormMainDisplay.MainWeightSmall.UpdateAlarmLabelDisplay(this.CountingOutput1Count, this.CountingOutput2Count);
                        #endregion

                        // CurrentDisplay
                        switch (this.CurrentSystemStatus.CurrentDisplay)
                        {
                            case Define.E_DisplayStore.MainDisplay:
                                #region MainDisplay
                                if (this.SystemConfig1.IsBarcodeEnable == true)
                                {
                                    this.CurrentBarcode.BarcodeDequeue();

                                    if (this.ChildFormMainDisplay != null)
                                        this.ChildFormMainDisplay.UpdateBarcodeDisplay(this.CurrentBarcode);

                                    if (this.CurrentBarcode.GetQueueCount > 0)
                                        this.BarcodeProductChange(this.CurrentBarcode);

                                    if (this.ChildFormMainDisplay != null)
                                        this.ChildFormMainDisplay.UpdateCurrentProductDisplay(this.CurrentSystemStatus.Equipment, this.CurrentProductItem, this.CurrentWeightData);
                                }

                                if (this.ChildFormMainDisplay != null)
                                    this.ChildFormMainDisplay.UpdateStartWeightDisplay(this.CurrentSystemStatus.Equipment, this.CurrentProductItem, this.CurrentWeightData);


                                if (this.SystemConfig1.DatabackupFormat == 1)
                                {
                                    #region OPT1 - 종근당 옵션
                                    if (this.timeOut.Enabled == true)
                                        this.timeOut.Enabled = false;

                                    //if (this.CollectionBufferWeightData.Count != 0)
                                    //{
                                    //    if (this.CurrentJudgmentResult.PreviousRejectData != Define.E_JudgmentResult.None)
                                    //        this.CollectionBufferWeightData[0].Status = this.CurrentJudgmentResult.PreviousRejectData.ToString();
                                    //    else
                                    //        this.CollectionBufferWeightData[0].Status = Define.E_JudgmentResult.OM.ToString();
                                    //    this.DataBackup1(this.CollectionBufferWeightData[0]);
                                    //    this.CollectionBufferWeightData.Clear();
                                    //}

                                    this.CollectionBufferWeightData.Add(new DataBackupOPT1());
                                    this.CollectionBufferWeightData[this.CollectionBufferWeightData.Count - 1].SetData(
                                        this.CurrentProductItem, this.CurrentWeightData, this.SystemConfig1, DateTime.Now);

                                    if (this.CurrentJudgmentSetItem.Sorter2Mode == 3)
                                        this.timeOut.Interval = (this.CurrentJudgmentSetItem.Sorter2DelayTime * 2) + (this.CurrentJudgmentSetItem.Sorter2RunTime * 5) + 1000;
                                    else
                                        this.timeOut.Interval = (this.CurrentJudgmentSetItem.Sorter1DelayTime * 2) + (this.CurrentJudgmentSetItem.Sorter1RunTime * 5) + 1000;
                                    this.timeOut.Enabled = true;
                                    #endregion
                                }
                                else
                                {
                                    #region STD1
                                    if (this.CurrentWeightData.JudgmentStatus != Define.E_JudgmentStatus.Empty)
                                        this.TrackingInspectionData0(this.CurrentWeightData);
                                    #endregion
                                }

                                // 표준분포
                                this.CurrentWeightData.SetNormalDistribution(this.CurrentProductItem.CollectionNormalDistributionRange, this.CurrentWeightData.WeightString);
                                #endregion
                                break;
                            default:
                                break;
                        }
                        break;
                    default:
                        break;
                }
            }
            catch
            {
                ret = -1;
            }

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

            switch (lane)
            {
                case "A":
                    #region Value Assign
                    this.CurrentWeightData.Status = Helper.StringToWeightStatus(receiveData.Substring(0, 2));
                    //this.ConverterAlarm(this.CurrentWeightData, receiveData.Substring(2, 3));
                    this.CurrentWeightData.Weight = Helper.StringToWeight(receiveData.Substring(5, 5), this.SystemConfig1.DecimalPlaces);
                    this.CurrentWeightData.ADCValue = receiveData.Substring(10, 5);
                    #endregion
                    if (this.ChildFormMenu.CenterSystemCalibration != null)
                        this.ChildFormMenu.CenterSystemCalibration.UpdateWeightDisplay(this.CurrentSystemStatus.Equipment, this.CurrentWeightData);
                    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 < 8; i++)
                        this.CollectionIOTest_InputData[i] = receiveData.Substring(i, 1);
                    #endregion
                    if (this.CurrentSystemStatus.CurrentMode == Define.E_DisplayMode.IOTest)
                    {
                        if (this.ChildFormMenu.CenterSystemIOTest != null)
                            this.ChildFormMenu.CenterSystemIOTest.UpdateInputRead(this.CollectionIOTest_InputData);
                    }
                    break;
                default:
                    break;
            }

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

            switch (lane)
            {
                case "A":
                    #region Value Assign
                    this.CurrentWeightData.Status = Helper.StringToWeightStatus(receiveData.Substring(0, 2));
                    //this.ConverterAlarm(this.CurrentWeightData, receiveData.Substring(2, 3));
                    this.CurrentWeightData.Weight = Helper.StringToWeight(receiveData.Substring(5, 5), this.SystemConfig1.DecimalPlaces);
                    this.CurrentWeightData.ADCValue = receiveData.Substring(10, 5);
                    #endregion
                    if (this.ChildFormMenu.CenterSystemJudgment != null)
                        this.ChildFormMenu.CenterSystemJudgment.UpdateStopWeightDisplay(this.CurrentSystemStatus.Equipment, this.CurrentWeightData);
                    break;
                default:
                    break;
            }

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

            switch (lane)
            {
                case "A":
                    #region Value Assign
                    this.CurrentWeightData.Status = Helper.StringToWeightStatus(receiveData.Substring(0, 2));
                    //this.ConverterAlarm(this.CurrentWeightData, receiveData.Substring(2, 3));
                    this.CurrentWeightData.Weight = Helper.StringToWeight(receiveData.Substring(5, 5), this.SystemConfig1.DecimalPlaces);

                    for (int i = 0; i < this.CollectionGraphData.Count; i++)
                    {
                        this.CollectionGraphData[i] = int.Parse(receiveData.Substring(temp, 5));
                        temp += 5;
                    }
                    #endregion
                    if (this.ChildFormMenu.CenterSystemJudgment != null)
                        this.ChildFormMenu.CenterSystemJudgment.UpdateGraphDataDisplay(this.CurrentSystemStatus.Equipment, this.CurrentWeightData, this.CollectionGraphData);
                        break;
                default:
                    break;
            }

            return ret;
        }
        // 리젝데이터
        private int ReceiveCommandSD0(string lane, string dataID, string transferCount, string receiveData)
        {
            int ret = 0;

            if (this.timeOut.Enabled == true)
                this.timeOut.Enabled = false;

            this.ConverterResult(receiveData);

            if (this.CollectionBufferWeightData.Count > 0)
            {
                if (this.CollectionBufferWeightData[this.CollectionBufferWeightData.Count - 1].DataID == dataID)
                {
                    if (this.CollectionBufferWeightData.Count == 2)
                    {
                        this.CollectionBufferWeightData[0].Status = this.CurrentJudgmentResult.PreviousRejectData.ToString();
                        this.TrackingInspectionData1(this.CollectionBufferWeightData[0]);
                    }
                    else if (this.CollectionBufferWeightData.Count > 2)
                    {
                        for (int i = 0; i < this.CollectionBufferWeightData.Count - 2; i++)
                        {
                            this.CollectionBufferWeightData[i].Status = Define.E_JudgmentResult.Timeout.ToString();
                            this.TrackingInspectionData1(this.CollectionBufferWeightData[i]);
                        }

                        this.CollectionBufferWeightData[this.CollectionBufferWeightData.Count - 2].Status = this.CurrentJudgmentResult.PreviousRejectData.ToString();
                        this.TrackingInspectionData1(this.CollectionBufferWeightData[this.CollectionBufferWeightData.Count - 2]);
                    }

                    this.CollectionBufferWeightData[this.CollectionBufferWeightData.Count - 1].Status = this.CurrentJudgmentResult.CurrentRejectData.ToString();
                    this.TrackingInspectionData1(this.CollectionBufferWeightData[this.CollectionBufferWeightData.Count - 1]);

                    this.CollectionBufferWeightData.Clear();
                }
            }
            return ret;
        }
        // 피드백 데이터
        private int ReceiveCommandSB0(string lane, string dataID, string transferCount, string receiveData)
        {
            int ret = 0;
            int temp = 0;

            try
            {
                switch (lane)
                {
                    case "A":
                        #region Value Assign
                        this.CurrentFeedbackItem.SampleCount = receiveData.Substring(0, 4);
                        this.CurrentFeedbackItem.DelayCount = receiveData.Substring(4, 4);
                        this.CurrentFeedbackItem.Sign = receiveData.Substring(8, 1);
                        this.CurrentFeedbackItem.FeedbackWeight = receiveData.Substring(9, 7);
                        #endregion
                        this.ChildFormMainDisplay.MainFeedback.UpdateDisplayCurrentValue(this.CurrentFeedbackItem);
                        break;
                    default:
                        break;
                }
            }
            catch
            {
                ret = -1;
            }

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

            switch (lane)
            {
                case "0":
                    #region Value Assign
                    currentAlarm = receiveData.Substring(0, 8);
                    #endregion
                    if (this.PreviousAlarm != currentAlarm)
                    {
                        this.IsAlarmOccured = this.CurrentAlarmList.IsAlarmOccured(currentAlarm);
                        this.Update30000ModbusItem();
                        this.CurrentAlarmList.SetAlarm(currentAlarm);
                        this.ChildFormMainDisplay.UpdateDisplayAlarmView(this.CurrentAlarmList, currentAlarm);
                        this.ChildFormMenu.UpdateDisplayAlarmView(this.CurrentAlarmList, currentAlarm);

                        this.PreviousAlarm = currentAlarm;
                    }
                    break;
                default:
                    break;
            }
            return ret;
        }
        #endregion

        #region Communication protocol
        public string PadLeft(int length, string sValue)
        {
            string temp;

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

            return temp;
        }

        private string Transfer_1_STD1(SystemConfigurationItem1 system, WeightData weight, ProductItem product)
        {
            StringBuilder sb = new StringBuilder();

            if (weight.JudgmentStatus == Define.E_JudgmentStatus.Empty)
                return "";

            sb.Append((char)0x02);
            sb.Append(string.Format("IN{0:000}", system.EquipmentID));
            sb.Append(string.Format("{0:0000}", product.Number));

            sb.Append(Helper.StringZeroFillDigits6(Helper.StringToDecimalPlaces(product.UnderRange, this.SystemConfig1.DecimalPlaces)));
            sb.Append(Helper.StringZeroFillDigits6(Helper.StringToDecimalPlaces(product.PassRange, this.SystemConfig1.DecimalPlaces)));
            sb.Append(Helper.StringZeroFillDigits6(Helper.StringToDecimalPlaces(product.OverRange, this.SystemConfig1.DecimalPlaces)));

            switch (weight.JudgmentStatus)
            {
                case Define.E_JudgmentStatus.Empty:
                    break;
                case Define.E_JudgmentStatus.Under:
                    sb.Append("U");
                    break;
                case Define.E_JudgmentStatus.Pass:
                    sb.Append("P");
                    break;
                case Define.E_JudgmentStatus.Over:
                    sb.Append("O");
                    break;
                case Define.E_JudgmentStatus.Double:
                    sb.Append("D");
                    break;
                case Define.E_JudgmentStatus.Metal:
                    sb.Append("M");
                    break;
                case Define.E_JudgmentStatus.ExNg:
                    sb.Append("E");
                    break;
                default:
                    sb.Append("E");
                    break;
            }

            if (weight.Weight <= 0.0)
                sb.Append("-");
            else
                sb.Append(" ");

            string temp = Helper.DoubleToString(weight.Weight, this.SystemConfig1.DecimalPlaces);
            if(temp.StartsWith("-"))
                temp = temp.Substring(1, temp.Length - 1);
            sb.Append(temp.PadLeft(6, ' '));
            sb.Append((char)0x03);

            return sb.ToString();
        }
        private string Transfer_2_Remote(WeightData weight, ProductItem product)
        {
            StringBuilder sb = new StringBuilder();

            if (weight.JudgmentStatus == Define.E_JudgmentStatus.Empty)
                return "";

            sb.Append((char)0x02);
            sb.Append("01");

            switch (weight.JudgmentStatus)
            {
                case Define.E_JudgmentStatus.Empty:
                    break;
                case Define.E_JudgmentStatus.Under:
                    sb.Append("U");
                    break;
                case Define.E_JudgmentStatus.Pass:
                    sb.Append("P");
                    break;
                case Define.E_JudgmentStatus.Over:
                    sb.Append("O");
                    break;
                case Define.E_JudgmentStatus.Double:
                    sb.Append("D");
                    break;
                case Define.E_JudgmentStatus.Metal:
                    sb.Append("M");
                    break;
                case Define.E_JudgmentStatus.ExNg:
                    sb.Append("E");
                    break;
                default:
                    sb.Append(" ");
                    break;
            }

            sb.Append(Helper.StringZeroFillDigits6(Helper.DoubleToString(weight.Weight, this.SystemConfig1.DecimalPlaces)));
            sb.Append((char)0x03);

            return sb.ToString();
        }
        private string Transfer_3_Print(WeightData weight, ProductItem product)
        {
            string sValue = "";
            BarcodeStatus status = BarcodeStatus.None;
            StringBuilder sb = new StringBuilder();

            if (weight.JudgmentStatus == Define.E_JudgmentStatus.Empty)
                return "";

            sb.Append(Helper.StringZeroFillDigits4(product.Number.ToString()));
            if (this.SystemConfig1.IsBarcodeEnable == true)
            {
                if (product.Number == 1)
                {
                    status = BarcodeStatus.NoRead;
                    sb.Append(string.Format("{0,8}", status));
                }
                else if (product.Number == 2)
                {
                    status = BarcodeStatus.NoMatch;
                    sb.Append(string.Format("{0,8}", status));
                }
                else
                    sb.Append(string.Format("{0,8}", weight.JudgmentStatus));
            }
            else
                sb.Append(string.Format("{0,8}", weight.JudgmentStatus));
            
            sb.Append(this.PadLeft(9, Helper.DoubleToString(weight.Weight, this.SystemConfig1.DecimalPlaces)));
            sb.Append(" ");
            sValue = weight.TotalCount.ToString();
            sb.Append(sValue.PadLeft(10, ' '));

            return sb.ToString();
        }
        private string Transfer_6_OPT0(WeightData weight)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append((char)0x1B);
            sb.Append("EW----;1.00I");
            sb.Append((char)0x0D);
            sb.Append((char)0x1B);
            sb.Append("P1-0-000000000;A9mm;");
            sb.Append(string.Format("{0, 6}", weight.Weight));
            sb.Append((char)0x0D);
            sb.Append((char)0x1B);
            sb.Append("EX----;");
            sb.Append((char)0x0D);
            sb.Append((char)0x02);
            sb.Append("TZ1.00I;13");
            sb.Append((char)0x0D);
            sb.Append((char)0x03);

            return sb.ToString();
        }
        private byte[] Transfer_7_imaje9410OPT2(WeightData weight)
        {
            int tempStringLength = 0;
            string tempString = "";

            byte[] byteArray = new byte[12];
            byte[] weightBytes = new byte[5];

            // 외부변수사용 : 0xE8
            byteArray[0] = 0xE8;
            // Length : 0x00, 0x08 고정값
            byteArray[1] = 0x00;
            byteArray[2] = 0x08;

            byteArray[3] = 0x01; // 1번 외부변수 번호
            byteArray[4] = 0x00;
            byteArray[5] = 0x05; // 1번 외부변수 길이

            if (weight.JudgmentStatus == Define.E_JudgmentStatus.Pass)
            {
                tempStringLength = weight.Weight.ToString().Trim().Length;
                if (tempStringLength > 5)
                    tempString = weight.Weight.ToString().Trim().Substring(tempStringLength - 5, 5);
                else
                    tempString = string.Format("{0,5}", weight.Weight);

                weightBytes = new UTF8Encoding().GetBytes(tempString);
                for (int i = 0; i < weightBytes.Length; i++)
                {
                    byteArray[i + 6] = weightBytes[i];
                }
            }
            else
            {
                for (int i = 0; i < 5; i++)
                {
                    byteArray[i + 6] = 0x20;
                }
            }

            byteArray[11] = 0x00;
            byteArray[11] = Helper.ChecksumCalculator(byteArray);

            return byteArray;
        }
        private byte[] Transfer_8_imaje9028OPT2(WeightData weight)
        {
            int tempStringLength = 0;
            string tempString = "";

            byte[] byteArray = new byte[11];
            byte[] weightBytes = new byte[5];

            this.TransferSerialCOM1(this.SendChar(Define.E_CharValue.ENQ)); // ACK
            Thread.Sleep(30);

            // 중량발송 : 0x99
            byteArray[0] = 0x99;

            // Length : 0x00, 0x02 고정값
            byteArray[1] = 0x00;
            byteArray[2] = 0x07;
            byteArray[3] = 0x12;

            if (weight.JudgmentStatus == Define.E_JudgmentStatus.Pass)
            {
                tempStringLength = weight.Weight.ToString().Trim().Length;
                if (tempStringLength > 5)
                    tempString = weight.Weight.ToString().Trim().Substring(tempStringLength - 5, 5);
                else
                    tempString = string.Format("{0,5}", weight.Weight);

                weightBytes = new UTF8Encoding().GetBytes(tempString);
                for (int i = 0; i < weightBytes.Length; i++)
                {
                    byteArray[i + 4] = weightBytes[i];
                }
            }
            else
            {
                for (int i = 0; i < 5; i++)
                {
                    byteArray[i + 4] = 0x20;
                }
            }

            byteArray[9] = 0x12;
            byteArray[10] = 0x00;
            byteArray[10] = Helper.ChecksumCalculator(byteArray);

            return byteArray;
        }
        private string Transfer_9_Hitachi(WeightData weight, Define.E_SerialCOM com)
        {
            if (weight.JudgmentStatus == Define.E_JudgmentStatus.Pass)
            {
                StringBuilder sb = new StringBuilder();

                sb.Append((char)0x02);
                sb.Append((char)0x10);

                if (com == Define.E_SerialCOM.COM1)
                {
                    sb.Append(this.HitachiRoomNumberToChar(this.SystemConfig2.HitachiRoomNumberCOM1));
                    if(this.SystemConfig2.IsHitachiBlankToNoneCOM1 == true)
                        sb.Append(weight.Weight.ToString().Trim());
                    else
                        sb.Append(string.Format("{0,6}", weight.Weight));
                }
                else if (com == Define.E_SerialCOM.COM3)
                {
                    sb.Append(this.HitachiRoomNumberToChar(this.SystemConfig2.HitachiRoomNumberCOM3));
                    if (this.SystemConfig2.IsHitachiBlankToNoneCOM3 == true)
                        sb.Append(weight.Weight.ToString().Trim());
                    else
                        sb.Append(string.Format("{0,6}", weight.Weight));
                }
                else if (com == Define.E_SerialCOM.COM4)
                {
                    sb.Append(this.HitachiRoomNumberToChar(this.SystemConfig2.HitachiRoomNumberCOM4));
                    if (this.SystemConfig2.IsHitachiBlankToNoneCOM4 == true)
                        sb.Append(weight.Weight.ToString().Trim());
                    else
                        sb.Append(string.Format("{0,6}", weight.Weight));
                }
                
                sb.Append((char)0x03);

                return sb.ToString();
            }
            else
                return "";
        }
        private byte[] Transfer_10_MACSA(WeightData weight, ProductItem product)
        {
            byte[] byteArray = new byte[14];
            byte[] bytes = new byte[6];
            byte sum = 0x00;
            string str = "";

            byteArray[0] = 0x02;
            byteArray[1] = 0xFE;
            byteArray[2] = 0x41;
            byteArray[3] = 0x30;
            byteArray[4] = 0x06;

            if (weight.Weight >= 0.0)
                bytes = new UTF8Encoding().GetBytes(string.Format("{0, 6}", weight.Weight));
            else if (product.TareRangeInt > 0)
                bytes = new UTF8Encoding().GetBytes(string.Format("{0, 6}", Helper.StringToWeight(product.TareRange, this.SystemConfig1.DecimalPlaces)));
            else
                bytes = new UTF8Encoding().GetBytes(string.Format("{0, 6}", 0.0));

            for (int i = 0; i < bytes.Length; i++)
            {
                byteArray[i + 5] = bytes[i];
            }

            byteArray[11] = byteArray[12] = byteArray[13] = 0x00;
            byteArray[11] = Helper.ChecksumCalculator(byteArray);
            byteArray[12] = (byte)(byteArray[11] & 0x00ff);
            byteArray[13] = 0x03;

            return byteArray;
        }
        private byte[] Transfer_11_Markoprint(WeightData weight, ProductItem product)
        {
            byte[] byteArray = new byte[50];
            byte[] bytes = new byte[30];
            byte[] weightBytes = new byte[30];
            string strCosmax = "TZcosmax.00I;13";
            string strCosmax2 = "TZcosmax2.00I;13";
            string strDate = string.Format("{0:yyyy.MM.dd}", DateTime.Now);

            if (this.SystemConfig2.IsMarkoprintTodaytDatePrintEthernet == false)
                strDate = this.SystemConfig2.MarkoprintDateSettingEthernet;
            else
                this.SystemConfig2.MarkoprintDateSettingEthernet = strDate;

            string str2 = "";

            byteArray[0] = 0x02; // <STX>
            if (this.SystemConfig2.MarkoprintLineNumberEthernet == 1)
            {
                #region 2줄
                bytes = new UTF8Encoding().GetBytes(strCosmax2);
                for (int i = 0; i < bytes.Length; i++)
                {
                    byteArray[i + 1] = bytes[i];
                }

                byteArray[strCosmax2.Length + 1] = 0x0D; // <CR>

                if (this.SystemConfig2.IsMarkoprintDatePrintEthernet == true)
                {
                    #region 날짜표시 On
                    if (weight.Weight >= 0.0)
                        weightBytes = new UTF8Encoding().GetBytes(string.Format("{0, 6}{1}", weight.Weight, this.SystemConfig1.Unit));
                    else if (product.TareRangeInt > 0)
                        weightBytes = new UTF8Encoding().GetBytes(string.Format("{0, 6}{1}", Helper.StringToWeight(product.TareRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
                    else
                        weightBytes = new UTF8Encoding().GetBytes(string.Format("{0, 6}{1}", 0.0, this.SystemConfig1.Unit));

                    for (int i = 0; i < weightBytes.Length; i++)
                    {
                        byteArray[i + strCosmax2.Length + 2] = weightBytes[i];
                    }

                    byteArray[strCosmax2.Length + weightBytes.Length + 2] = 0x0D; // <CR>

                    bytes = new UTF8Encoding().GetBytes(strDate);
                    for (int i = 0; i < bytes.Length; i++)
                    {
                        byteArray[i + strCosmax2.Length + weightBytes.Length + 3] = bytes[i];
                    }

                    byteArray[strCosmax2.Length + strDate.Length + weightBytes.Length + 3] = 0x0D; // <CR>
                    byteArray[strCosmax2.Length + strDate.Length + weightBytes.Length + 4] = 0x03; // <ETX>

                    return byteArray;
                    #endregion
                }
                else
                {
                    #region 날짜표시 Off
                    if (weight.Weight >= 0.0)
                        weightBytes = new UTF8Encoding().GetBytes(string.Format("{0, 6}{1}", weight.Weight, this.SystemConfig1.Unit));
                    else if (product.TareRangeInt > 0)
                        weightBytes = new UTF8Encoding().GetBytes(string.Format("{0, 6}{1}", Helper.StringToWeight(product.TareRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
                    else
                        weightBytes = new UTF8Encoding().GetBytes(string.Format("{0, 6}{1}", 0.0, this.SystemConfig1.Unit));

                    for (int i = 0; i < weightBytes.Length; i++)
                    {
                        byteArray[i + strCosmax.Length + 2] = weightBytes[i];
                    }

                    byteArray[strCosmax.Length + weightBytes.Length + 2] = 0x0D;
                    byteArray[strCosmax.Length + weightBytes.Length + 3] = 0x03;

                    return byteArray;
                    #endregion
                }
                #endregion
            }
            else
            {
                #region 1줄
                bytes = new UTF8Encoding().GetBytes(strCosmax);
                for (int i = 0; i < bytes.Length; i++)
                {
                    byteArray[i + 1] = bytes[i];
                }

                byteArray[strCosmax.Length + 1] = 0x0D;


                if (this.SystemConfig2.IsMarkoprintDatePrintEthernet == true)
                {
                    #region 날짜표시 On
                    bytes = new UTF8Encoding().GetBytes(strDate);
                    for (int i = 0; i < bytes.Length; i++)
                    {
                        byteArray[i + strCosmax.Length + 2] = bytes[i];
                    }

                    if (weight.Weight >= 0.0)
                        weightBytes = new UTF8Encoding().GetBytes(string.Format("{0, 6}{1}", weight.Weight, this.SystemConfig1.Unit));
                    else if (product.TareRangeInt > 0)
                        weightBytes = new UTF8Encoding().GetBytes(string.Format("{0, 6}{1}", Helper.StringToWeight(product.TareRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
                    else
                        weightBytes = new UTF8Encoding().GetBytes(string.Format("{0, 6}{1}", 0.0, this.SystemConfig1.Unit));

                    for (int i = 0; i < weightBytes.Length; i++)
                    {
                        byteArray[i + strCosmax.Length + strDate.Length + 2] = weightBytes[i];
                    }

                    byteArray[strCosmax.Length + strDate.Length + weightBytes.Length + 2] = 0x0D;
                    byteArray[strCosmax.Length + strDate.Length + weightBytes.Length + 3] = 0x03;

                    return byteArray;
                    #endregion
                }
                else
                {
                    #region 날짜표시 Off
                    if (weight.Weight >= 0.0)
                        weightBytes = new UTF8Encoding().GetBytes(string.Format("{0, 6}{1}", weight.Weight, this.SystemConfig1.Unit));
                    else if (product.TareRangeInt > 0)
                        weightBytes = new UTF8Encoding().GetBytes(string.Format("{0, 6}{1}", Helper.StringToWeight(product.TareRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
                    else
                        weightBytes = new UTF8Encoding().GetBytes(string.Format("{0, 6}{1}", 0.0, this.SystemConfig1.Unit));

                    for (int i = 0; i < weightBytes.Length; i++)
                    {
                        byteArray[i + strCosmax.Length + 2] = weightBytes[i];
                    }

                    byteArray[strCosmax.Length + weightBytes.Length + 2] = 0x0D;
                    byteArray[strCosmax.Length + weightBytes.Length + 3] = 0x03;

                    return byteArray;
                    #endregion
                }
                #endregion
            }
        }
        private byte[] Transfer_12_alphaJET(WeightData weight, ProductItem product)
        {
            byte[] byteArray = new byte[150];
            byte[] bytes = new byte[100];
            byte[] weightBytes = new byte[20];
            int length = 0;
            string fileName = "label\\1234.txt";
            string str = "";

            if (weight.JudgmentStatus == Define.E_JudgmentStatus.Pass)
            {
                bytes = new UTF8Encoding().GetBytes("<GP><LOADLAB>" + fileName + "</LOADLAB><DSET>" + @"<DF aI=""1"">");
                for (int i = 0; i < bytes.Length; i++)
                {
                    byteArray[i] = bytes[i];
                }

                length = bytes.Length;

                ///////////////////////////////////////////

                if (weight.Weight >= 0.0)
                    weightBytes = new UTF8Encoding().GetBytes(string.Format("{0, 6}{1}", weight.Weight, this.SystemConfig1.Unit));
                else if (product.TareRangeInt > 0)
                    weightBytes = new UTF8Encoding().GetBytes(string.Format("{0, 6}{1}", Helper.StringToWeight(product.TareRange, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
                else
                    weightBytes = new UTF8Encoding().GetBytes(string.Format("{0, 6}{1}", 0.0, this.SystemConfig1.Unit));

                for (int i = 0; i < weightBytes.Length; i++)
                {
                    byteArray[i + length] = weightBytes[i];
                }

                length = length + weightBytes.Length;

                ////////////////////////////////////////////

                bytes = new UTF8Encoding().GetBytes("</DF>");
                for (int i = 0; i < bytes.Length; i++)
                {
                    byteArray[i + length] = bytes[i];
                }

                length = length + bytes.Length;
            }
            else
            {
                bytes = new UTF8Encoding().GetBytes("<GP><LOADLAB>" + fileName + "</LOADLAB><DSET><DFCLERAR/>");
                for (int i = 0; i < bytes.Length; i++)
                {
                    byteArray[i] = bytes[i];
                }

                length = bytes.Length;
            }

            bytes = new UTF8Encoding().GetBytes("</DSET></GP>");
            for (int i = 0; i < bytes.Length; i++)
            {
                byteArray[i + length] = bytes[i];
            }

            return byteArray;
        }
        private string Transfer_13_Marking_VJ1510(WeightData weight)
        {
            // 총 byte 길이 = 9
            byte[] byteArray = new byte[9];
            byte[] weightBytes = new byte[4];
            byte sum = 0x00;
            string str = "";

            if (weight.JudgmentStatus == Define.E_JudgmentStatus.Pass)
            {
                StringBuilder sb = new StringBuilder();

                sb.Append((char)0x02);
                sb.Append((char)0x55); // U(고정)
                sb.Append((char)0x4B); // K(고정)
                sb.Append((char)0x0A); // LF(고정)

                string temp = weight.WeightString.Trim().Substring(0, 4);
                if (temp.Trim() == "")
                    temp = "   0";

                sb.Append(temp);
                sb.Append((char)0x03);

                return sb.ToString();
            }
            else
                return "";
        }
        private string Transfer_14_OPT1(string sValue)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append((char)0x02);
            sb.Append(sValue);
            sb.Append((char)0x03);

            return sb.ToString();
        }
        private string Transfer_17_OPT3(WeightData weight, ProductItem pItem)
        {
            string tempValue = "";
            DateTime dt = DateTime.Now;
            StringBuilder sb = new StringBuilder();

            sb.Append((char)0x02);
            sb.Append(string.Format(" {0:yyyyMMdd}", dt));
            sb.Append(string.Format(" {0:HH:mm:ss}", dt));
            if (weight.TotalCount.ToString().Length > 9)
            {
                int tempInt = weight.TotalCount.ToString().Length;
                sb.Append(weight.TotalCount.ToString().Substring(tempInt - 9, 9));
            }
            else
                sb.Append(string.Format("{0, 9}", weight.TotalCount));

            switch (weight.JudgmentStatus)
            {
                case Define.E_JudgmentStatus.Empty:
                    sb.Append("         ");
                    break;
                case Define.E_JudgmentStatus.Under:
                    tempValue = "U";
                    sb.Append(tempValue.PadLeft(9, ' '));
                    break;
                case Define.E_JudgmentStatus.Pass:
                    tempValue = "P";
                    sb.Append(tempValue.PadLeft(9, ' '));
                    break;
                case Define.E_JudgmentStatus.Over:
                    tempValue = "O";
                    sb.Append(tempValue.PadLeft(9, ' '));
                    break;
                case Define.E_JudgmentStatus.Double:
                    tempValue = "D";
                    sb.Append(tempValue.PadLeft(9, ' '));
                    break;
                case Define.E_JudgmentStatus.Metal:
                    tempValue = "M";
                    sb.Append(tempValue.PadLeft(9, ' '));
                    break;
                case Define.E_JudgmentStatus.ExNg:
                    tempValue = "E";
                    sb.Append(tempValue.PadLeft(9, ' '));
                    break;
                default:
                    tempValue = "E";
                    sb.Append(tempValue.PadLeft(9, ' '));
                    break;
            }

            sb.Append(string.Format("{0,9}", weight.Weight));
            if (pItem.LotNo.Length > 9)
                sb.Append(pItem.LotNo.Substring(0, 9));
            else
                sb.Append(pItem.LotNo.PadLeft(9, ' '));
            sb.Append((Helper.StringToDecimalPlaces(pItem.OverRange, this.SystemConfig1.DecimalPlaces)).PadLeft(9));
            sb.Append((Helper.StringToDecimalPlaces(pItem.UnderRange, this.SystemConfig1.DecimalPlaces)).PadLeft(9));
            sb.Append((Helper.StringToDecimalPlaces(pItem.PassRange, this.SystemConfig1.DecimalPlaces)).PadLeft(9));
            sb.Append((char)0x03);

            return sb.ToString();
        }
        private string Transfer_18_HP200(WeightData weight, int step)
        {
            StringBuilder sb = new StringBuilder();

            switch (step)
            {
                case 1:
                    if (weight.JudgmentStatus != Define.E_JudgmentStatus.Pass)
                    {
                        // 정량이 아닐 경우 공백 6문자 전송
                        sb.Append((char)0x02);
                        sb.Append((char)0x4a);
                        sb.Append((char)0x30);
                        sb.Append((char)0x2c);
                        sb.Append((char)0x20);
                        sb.Append((char)0x20);
                        sb.Append((char)0x20);
                        sb.Append((char)0x20);
                        sb.Append((char)0x20);
                        sb.Append((char)0x20);
                        sb.Append((char)0x0d);
                        sb.Append((char)0x04);
                    }
                    else
                    {
                        sb.Append((char)0x02);
                        sb.Append((char)0x4a);
                        sb.Append((char)0x30);
                        sb.Append((char)0x2c);
                        sb.Append((Helper.StringToDecimalPlaces(weight.WeightString.Trim(), this.SystemConfig1.DecimalPlaces)).PadLeft(6));
                        sb.Append((char)0x0d);
                        sb.Append((char)0x04);
                    }

                    return sb.ToString();
                case 2:
                    // 화면 업데이트
                    sb.Append((char)0x02);
                    sb.Append((char)0x5a);
                    sb.Append((char)0x04);

                    return sb.ToString();
                default:
                    return sb.ToString();
            }
        }
        private string Transfer_19_SmartJet(WeightData weight)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append((char)0x02);
            sb.Append("A01");
            sb.Append(string.Format("{0,6}", weight.Weight));
            sb.Append((char)0x04);

            return sb.ToString();
        }
        public byte[] Transfer_22_Modbus_Write()
        {
            byte[] madeData = new byte[ModbusTotalBytes];
            byte[] Length4Value = new byte[4];
            byte[] productName = new UTF8Encoding().GetBytes(this.CurrentProductItem.Name);

            double underValue = Helper.StringToWeight(this.CurrentProductItem.UnderRange, this.SystemConfig1.DecimalPlaces);
            double passValue = Helper.StringToWeight(this.CurrentProductItem.PassRange, this.SystemConfig1.DecimalPlaces);
            double overValue = Helper.StringToWeight(this.CurrentProductItem.OverRange, this.SystemConfig1.DecimalPlaces);
            double tareValue = Helper.StringToWeight(this.CurrentProductItem.TareRange, this.SystemConfig1.DecimalPlaces);

            int equipmentStatus;
            if (this.CurrentSystemStatus.Equipment == Define.E_EquipmentStatus.Start)
                equipmentStatus = 1;
            else
                equipmentStatus = 0;

            int alarmStatus;
            if (this.IsAlarmOccured == true)
                alarmStatus = 1;
            else
                alarmStatus = 0;

            int judgmentStatus;
            switch (this.CurrentWeightData.JudgmentStatus)
            {
                case Define.E_JudgmentStatus.Over:
                    judgmentStatus = 0;
                    break;
                case Define.E_JudgmentStatus.Pass:
                    judgmentStatus = 1;
                    break;
                case Define.E_JudgmentStatus.Under:
                    judgmentStatus = 2;
                    break;
                case Define.E_JudgmentStatus.Metal:
                    judgmentStatus = 3;
                    break;
                case Define.E_JudgmentStatus.Double:
                    judgmentStatus = 4;
                    break;
                default:
                    judgmentStatus = 5;
                    break;
            }

            Length4Value = GetBytes(this.UpdateValue);
            for (int i = 0; i < 4; i++)
                madeData[i] = Length4Value[3 - i];

            Length4Value = GetBytes(this.SystemConfig1.EquipmentID);
            for (int i = 0; i < 4; i++)
                madeData[4 + i] = Length4Value[3 - i];

            Length4Value = GetBytes(this.SystemConfig1.ProductNumber);
            for (int i = 0; i < 4; i++)
                madeData[8 + i] = Length4Value[3 - i];

            Length4Value = GetBytes((Single)underValue);
            for (int i = 0; i < 4; i++)
                madeData[12 + i] = Length4Value[3 - i];

            Length4Value = GetBytes((Single)passValue);
            for (int i = 0; i < 4; i++)
                madeData[16 + i] = Length4Value[3 - i];

            Length4Value = GetBytes((Single)overValue);
            for (int i = 0; i < 4; i++)
                madeData[20 + i] = Length4Value[3 - i];

            Length4Value = GetBytes((Single)tareValue);
            for (int i = 0; i < 4; i++)
                madeData[24 + i] = Length4Value[3 - i];

            Length4Value = GetBytes(this.CurrentWeightData.UnderCount);
            for (int i = 0; i < 4; i++)
                madeData[28 + i] = Length4Value[3 - i];

            Length4Value = GetBytes(this.CurrentWeightData.PassCount);
            for (int i = 0; i < 4; i++)
                madeData[32 + i] = Length4Value[3 - i];

            Length4Value = GetBytes(this.CurrentWeightData.OverCount);
            for (int i = 0; i < 4; i++)
                madeData[36 + i] = Length4Value[3 - i];

            Length4Value = GetBytes(this.CurrentWeightData.OverCount + this.CurrentWeightData.UnderCount);
            for (int i = 0; i < 4; i++)
                madeData[40 + i] = Length4Value[3 - i];

            Length4Value = GetBytes(this.CurrentWeightData.ExNGCount);
            for (int i = 0; i < 4; i++)
                madeData[44 + i] = Length4Value[3 - i];

            Length4Value = GetBytes(this.CurrentWeightData.TotalCount);
            for (int i = 0; i < 4; i++)
                madeData[48 + i] = Length4Value[3 - i];

            Length4Value = GetBytes(judgmentStatus);
            for (int i = 0; i < 4; i++)
                madeData[52 + i] = Length4Value[3 - i];

            Length4Value = GetBytes((Single)this.CurrentWeightData.Weight);
            for (int i = 0; i < 4; i++)
                madeData[56 + i] = Length4Value[3 - i];

            Length4Value = GetBytes(equipmentStatus);
            for (int i = 0; i < 4; i++)
                madeData[60 + i] = Length4Value[3 - i];

            Length4Value = GetBytes(alarmStatus);
            for (int i = 0; i < 4; i++)
                madeData[64 + i] = Length4Value[3 - i];

            Length4Value = GetBytes(this.CurrentWeightData.ProductionSpeed);
            for (int i = 0; i < 4; i++)
                madeData[68 + i] = Length4Value[3 - i];

            Length4Value = GetBytes(this.CurrentWeightData.MetalDetectionCount);
            for (int i = 0; i < 4; i++)
                madeData[72 + i] = Length4Value[3 - i];

            Length4Value = GetBytes(this.CurrentWeightData.DoubleEntryCount);
            for (int i = 0; i < 4; i++)
                madeData[76 + i] = Length4Value[3 - i];

            //int nameLength = productName.Length;
            //for (int i = 0; i < nameLength; i++)
            //    madeData[80 + i] = productName[i];
            //for (int i = 0; i < 20 - nameLength; i++)
            //    madeData[80 + nameLength + i] = 0x00;

            return madeData;
        }
        private byte[] Transfer_22_Modbus_Read_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 _40000_ModbusAddress._01_Clear:
                            length2Value = GetBytes(this.Current40000ModbusData._40011_Clear);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case _40000_ModbusAddress._02_ClearResult:
                            length2Value = GetBytes(this.Current40000ModbusData._40012_ClearResult);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case _40000_ModbusAddress._03_Operation:
                            length2Value = GetBytes(this.Current40000ModbusData._40013_Operation);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case _40000_ModbusAddress._04_OperationResult:
                            length2Value = GetBytes(this.Current40000ModbusData._40014_OperationResult);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case _40000_ModbusAddress._05_ProductChange_High:
                            length4Value = GetBytes(this.Current40000ModbusData._40015_ProductChange);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _40000_ModbusAddress._06_ProductChange_Low:
                            length4Value = GetBytes(this.Current40000ModbusData._40015_ProductChange);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _40000_ModbusAddress._07_ProductChangeResult:
                            length2Value = GetBytes(this.Current40000ModbusData._40017_ProductChangeResult);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case _40000_ModbusAddress._08_UnderRange_High:
                            length4Value = GetBytes(this.Current40000ModbusData._40018_UnderRange);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _40000_ModbusAddress._09_UnderRange_Low:
                            length4Value = GetBytes(this.Current40000ModbusData._40018_UnderRange);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _40000_ModbusAddress._10_UnderRangeResult:
                            length2Value = GetBytes(this.Current40000ModbusData._40020_UnderRangeResult);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case _40000_ModbusAddress._11_PassRange_High:
                            length4Value = GetBytes(this.Current40000ModbusData._40021_PassRange);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _40000_ModbusAddress._12_PassRange_Low:
                            length4Value = GetBytes(this.Current40000ModbusData._40021_PassRange);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _40000_ModbusAddress._13_PassRangeResult:
                            length2Value = GetBytes(this.Current40000ModbusData._40023_PassRangeResult);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case _40000_ModbusAddress._14_OverRange_High:
                            length4Value = GetBytes(this.Current40000ModbusData._40024_OverRange);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _40000_ModbusAddress._15_OverRange_Low:
                            length4Value = GetBytes(this.Current40000ModbusData._40024_OverRange);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _40000_ModbusAddress._16_OverRangeResult:
                            length2Value = GetBytes(this.Current40000ModbusData._40026_OverRangeResult);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case _40000_ModbusAddress._17_TareWeight_High:
                            length4Value = GetBytes(this.Current40000ModbusData._40027_TareWeight);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _40000_ModbusAddress._18_TareWeight_Low:
                            length4Value = GetBytes(this.Current40000ModbusData._40027_TareWeight);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _40000_ModbusAddress._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)
                int tempWeight = 0;
                string removeMinus = "";
                if (this.CurrentWeightData.WeightString.StartsWith("-") == true)
                {
                    removeMinus = this.CurrentWeightData.WeightString.Replace("-", "");
                    tempWeight = int.Parse(removeMinus);
                    tempWeight *= -1;
                }
                else
                    tempWeight = int.Parse(this.CurrentWeightData.WeightString);

                double underValue = Helper.StringToWeight(this.CurrentProductItem.UnderRange, this.SystemConfig1.DecimalPlaces);
                double passValue = Helper.StringToWeight(this.CurrentProductItem.PassRange, this.SystemConfig1.DecimalPlaces);
                double overValue = Helper.StringToWeight(this.CurrentProductItem.OverRange, this.SystemConfig1.DecimalPlaces);
                double tareValue = Helper.StringToWeight(this.CurrentProductItem.TareRange, this.SystemConfig1.DecimalPlaces);

                int equipmentStatus;
                if (this.CurrentSystemStatus.Equipment == Define.E_EquipmentStatus.Start)
                    equipmentStatus = 1;
                else
                    equipmentStatus = 0;

                int alarmStatus;
                if (this.IsAlarmOccured == true)
                    alarmStatus = 1;
                else
                    alarmStatus = 0;

                int judgmentStatus;
                switch (this.CurrentWeightData.JudgmentStatus)
                {
                    case Define.E_JudgmentStatus.Over:
                        judgmentStatus = 0;
                        break;
                    case Define.E_JudgmentStatus.Pass:
                        judgmentStatus = 1;
                        break;
                    case Define.E_JudgmentStatus.Under:
                        judgmentStatus = 2;
                        break;
                    case Define.E_JudgmentStatus.Metal:
                        judgmentStatus = 3;
                        break;
                    case Define.E_JudgmentStatus.Double:
                        judgmentStatus = 4;
                        break;
                    default:
                        judgmentStatus = 5;
                        break;
                }

                byte[] productName = this.Current30000ModbusData.ProductName;

                for (int j = startAddressInt; j < startAddressInt + numberOfRegisterInt; j++)
                {
                    switch (j)
                    {
                        #region Make data

                        #region Data
                        case _30000_ModbusAddress._01_DecimalPoint:
                            length2Value = GetBytes(this.SystemConfig1.DecimalPlaces);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case _30000_ModbusAddress._01_IsUpdate_High:
                            length4Value = GetBytes(this.UpdateValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._02_IsUpdate_Low:
                            length4Value = GetBytes(this.UpdateValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._03_EquipmentID_High:
                            length4Value = GetBytes(this.SystemConfig1.EquipmentID);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._04_EquipmentID_Low:
                            length4Value = GetBytes(this.SystemConfig1.EquipmentID);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._05_ProductNo_High:
                            length4Value = GetBytes(this.SystemConfig1.ProductNumber);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._06_ProductNo_Low:
                            length4Value = GetBytes(this.SystemConfig1.ProductNumber);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._07_UnderValueFloat_High:
                            length4Value = GetBytes((Single)underValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._08_UnderValueFloat_Low:
                            length4Value = GetBytes((Single)underValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._09_PassValueFloat_High:
                            length4Value = GetBytes((Single)passValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._10_PassValueFloat_Low:
                            length4Value = GetBytes((Single)passValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._11_OverValueFloat_High:
                            length4Value = GetBytes((Single)overValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._12_OverValueFloat_Low:
                            length4Value = GetBytes((Single)overValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._13_TareValueFloat_High:
                            length4Value = GetBytes((Single)tareValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._14_TareValueFloat_Low:
                            length4Value = GetBytes((Single)tareValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._15_UnderCount_High:
                            length4Value = GetBytes(this.CurrentWeightData.UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._16_UnderCount_Low:
                            length4Value = GetBytes(this.CurrentWeightData.UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._17_PassCount_High:
                            length4Value = GetBytes(this.CurrentWeightData.PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._18_PassCount_Low:
                            length4Value = GetBytes(this.CurrentWeightData.PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._19_OverCount_High:
                            length4Value = GetBytes(this.CurrentWeightData.OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._20_OverCount_Low:
                            length4Value = GetBytes(this.CurrentWeightData.OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._21_NGCount_High:
                            length4Value = GetBytes(this.CurrentWeightData.OverCount + this.CurrentWeightData.UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._22_NGCount_Low:
                            length4Value = GetBytes(this.CurrentWeightData.OverCount + this.CurrentWeightData.UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._23_ExNGCount_High:
                            length4Value = GetBytes(this.CurrentWeightData.ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._24_ExNGCount_Low:
                            length4Value = GetBytes(this.CurrentWeightData.ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._25_TotalCount_High:
                            length4Value = GetBytes(this.CurrentWeightData.TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._26_TotalCount_Low:
                            length4Value = GetBytes(this.CurrentWeightData.TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._27_Grade_High:
                            length4Value = GetBytes(judgmentStatus);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._28_Grade_Low:
                            length4Value = GetBytes(judgmentStatus);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._29_WeightFloat_High:
                            if (this.CurrentSystemStatus.Equipment == Define.E_EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.CurrentWeightData.Weight);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._30_WeightFloat_Low:
                            if (this.CurrentSystemStatus.Equipment == Define.E_EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.CurrentWeightData.Weight);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._31_OperationStatus_High:
                            length4Value = GetBytes(equipmentStatus);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._32_OperationStatus_Low:
                            length4Value = GetBytes(equipmentStatus);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._33_AlarmStatus_High:
                            length4Value = GetBytes(alarmStatus);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._34_AlarmStatus_Low:
                            length4Value = GetBytes(alarmStatus);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._35_Speed_High:
                            length4Value = GetBytes(this.CurrentWeightData.ProductionSpeed);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._36_Speed_Low:
                            length4Value = GetBytes(this.CurrentWeightData.ProductionSpeed);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._37_MetalDetectionCount_High:
                            length4Value = GetBytes(this.CurrentWeightData.MetalDetectionCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._38_MetalDetectionCount_Low:
                            length4Value = GetBytes(this.CurrentWeightData.MetalDetectionCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._39_DoubleEntryCount_High:
                            length4Value = GetBytes(this.CurrentWeightData.DoubleEntryCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._40_DoubleEntryCount_Low:
                            length4Value = GetBytes(this.CurrentWeightData.DoubleEntryCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._41_ProductName:
                            for (int i = 0; i < productName.Length; i++)
                                madeData[madeDataIndex + i] = productName[i];
                            break;
                        case _30000_ModbusAddress._51_UnderValueInt_High:
                            length4Value = GetBytes(this.CurrentProductItem.UnderRangeInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._52_UnderValueInt_Low:
                            length4Value = GetBytes(this.CurrentProductItem.UnderRangeInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._53_PassValueInt_High:
                            length4Value = GetBytes(this.CurrentProductItem.PassRangeInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._54_PassValueInt_Low:
                            length4Value = GetBytes(this.CurrentProductItem.PassRangeInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._55_OverValueInt_High:
                            length4Value = GetBytes(this.CurrentProductItem.OverRangeInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._56_OverValueInt_Low:
                            length4Value = GetBytes(this.CurrentProductItem.OverRangeInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._57_TareValueInt_High:
                            length4Value = GetBytes(this.CurrentProductItem.TareRangeInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._58_TareValueInt_Low:
                            length4Value = GetBytes(this.CurrentProductItem.TareRangeInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._59_WeightInt_High:
                            if (this.CurrentSystemStatus.Equipment == Define.E_EquipmentStatus.Stop)
                                length4Value = GetBytes(0);
                            else
                                length4Value = GetBytes(tempWeight);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._60_WeightInt_Low:
                            if (this.CurrentSystemStatus.Equipment == Define.E_EquipmentStatus.Stop)
                                length4Value = GetBytes(0);
                            else
                                length4Value = GetBytes(tempWeight);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        #endregion

                        #region Alarm
                        case _39000_ModbusAddressAlarm._9001_Alarm1:
                        case _39000_ModbusAddressAlarm._9002_Alarm2:
                        case _39000_ModbusAddressAlarm._9003_Alarm3:
                        case _39000_ModbusAddressAlarm._9004_Alarm4:
                        case _39000_ModbusAddressAlarm._9005_Alarm5:
                        case _39000_ModbusAddressAlarm._9006_Alarm6:
                        case _39000_ModbusAddressAlarm._9007_Alarm7:
                        case _39000_ModbusAddressAlarm._9008_Alarm8:
                        case _39000_ModbusAddressAlarm._9009_Alarm9:
                        case _39000_ModbusAddressAlarm._9010_Alarm10:
                        case _39000_ModbusAddressAlarm._9011_Alarm11:
                        case _39000_ModbusAddressAlarm._9012_Alarm12:
                        case _39000_ModbusAddressAlarm._9013_Alarm13:
                        case _39000_ModbusAddressAlarm._9014_Alarm14:
                        case _39000_ModbusAddressAlarm._9015_Alarm15:
                        case _39000_ModbusAddressAlarm._9016_Alarm16:
                        case _39000_ModbusAddressAlarm._9017_Alarm17:
                        case _39000_ModbusAddressAlarm._9018_Alarm18:
                            length2Value = GetBytes(this.CurrentAlarm[j - 9000]);

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

                        default:
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = 0;
                            break;
                        #endregion
                    }
                    if (j == (int)_30000_ModbusAddress._41_ProductName)
                    {
                        j += 9;
                        madeDataIndex += 20;
                    }
                    madeDataIndex += 2;
                }
                #endregion
            }

            return madeData;
        }
        private byte[] Transfer_22_Modbus_Read_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 _40000_ModbusAddress._01_Clear:
                            length2Value = GetBytes(this.Current40000ModbusData._40011_Clear);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case _40000_ModbusAddress._02_ClearResult:
                            length2Value = GetBytes(this.Current40000ModbusData._40012_ClearResult);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case _40000_ModbusAddress._03_Operation:
                            length2Value = GetBytes(this.Current40000ModbusData._40013_Operation);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case _40000_ModbusAddress._04_OperationResult:
                            length2Value = GetBytes(this.Current40000ModbusData._40014_OperationResult);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case _40000_ModbusAddress._05_ProductChange_High:
                            length4Value = GetBytes(this.Current40000ModbusData._40015_ProductChange);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _40000_ModbusAddress._06_ProductChange_Low:
                            length4Value = GetBytes(this.Current40000ModbusData._40015_ProductChange);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _40000_ModbusAddress._07_ProductChangeResult:
                            length2Value = GetBytes(this.Current40000ModbusData._40017_ProductChangeResult);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case _40000_ModbusAddress._08_UnderRange_High:
                            length4Value = GetBytes(this.Current40000ModbusData._40018_UnderRange);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _40000_ModbusAddress._09_UnderRange_Low:
                            length4Value = GetBytes(this.Current40000ModbusData._40018_UnderRange);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _40000_ModbusAddress._10_UnderRangeResult:
                            length2Value = GetBytes(this.Current40000ModbusData._40020_UnderRangeResult);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case _40000_ModbusAddress._11_PassRange_High:
                            length4Value = GetBytes(this.Current40000ModbusData._40021_PassRange);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _40000_ModbusAddress._12_PassRange_Low:
                            length4Value = GetBytes(this.Current40000ModbusData._40021_PassRange);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _40000_ModbusAddress._13_PassRangeResult:
                            length2Value = GetBytes(this.Current40000ModbusData._40023_PassRangeResult);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case _40000_ModbusAddress._14_OverRange_High:
                            length4Value = GetBytes(this.Current40000ModbusData._40024_OverRange);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _40000_ModbusAddress._15_OverRange_Low:
                            length4Value = GetBytes(this.Current40000ModbusData._40024_OverRange);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _40000_ModbusAddress._16_OverRangeResult:
                            length2Value = GetBytes(this.Current40000ModbusData._40026_OverRangeResult);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case _40000_ModbusAddress._17_TareWeight_High:
                            length4Value = GetBytes(this.Current40000ModbusData._40027_TareWeight);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _40000_ModbusAddress._18_TareWeight_Low:
                            length4Value = GetBytes(this.Current40000ModbusData._40027_TareWeight);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _40000_ModbusAddress._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)
                int tempWeight = 0;
                string removeMinus = "";
                if (this.CurrentWeightData.WeightString.StartsWith("-") == true)
                {
                    removeMinus = this.CurrentWeightData.WeightString.Replace("-", "");
                    tempWeight = int.Parse(removeMinus);
                    tempWeight *= -1;
                }
                else
                    tempWeight = int.Parse(this.CurrentWeightData.WeightString);

                double underValue = Helper.StringToWeight(this.CurrentProductItem.UnderRange, this.SystemConfig1.DecimalPlaces);
                double passValue = Helper.StringToWeight(this.CurrentProductItem.PassRange, this.SystemConfig1.DecimalPlaces);
                double overValue = Helper.StringToWeight(this.CurrentProductItem.OverRange, this.SystemConfig1.DecimalPlaces);
                double tareValue = Helper.StringToWeight(this.CurrentProductItem.TareRange, this.SystemConfig1.DecimalPlaces);
                double weight = this.CurrentWeightData.Weight;

                int equipmentStatus;
                if (this.CurrentSystemStatus.Equipment == Define.E_EquipmentStatus.Start)
                    equipmentStatus = 1;
                else
                    equipmentStatus = 0;

                int alarmStatus;
                if (this.IsAlarmOccured == true)
                    alarmStatus = 1;
                else
                    alarmStatus = 0;

                int judgmentStatus;
                switch (this.CurrentWeightData.JudgmentStatus)
                {
                    case Define.E_JudgmentStatus.Over:
                        judgmentStatus = 0;
                        break;
                    case Define.E_JudgmentStatus.Pass:
                        judgmentStatus = 1;
                        break;
                    case Define.E_JudgmentStatus.Under:
                        judgmentStatus = 2;
                        break;
                    case Define.E_JudgmentStatus.Metal:
                        judgmentStatus = 3;
                        break;
                    case Define.E_JudgmentStatus.Double:
                        judgmentStatus = 4;
                        break;
                    default:
                        judgmentStatus = 5;
                        break;
                }

                byte[] productName = this.Current30000ModbusData.ProductName;

                for (int j = startAddressInt; j < startAddressInt + numberOfRegisterInt; j++)
                {
                    switch (j)
                    {
                        #region Make data

                        #region Data
                        case _30000_ModbusAddress._01_DecimalPoint:
                            length2Value = GetBytes(this.SystemConfig1.DecimalPlaces);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length2Value[1 - i];
                            break;
                        case _30000_ModbusAddress._01_IsUpdate_High:
                            length4Value = GetBytes(this.UpdateValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._02_IsUpdate_Low:
                            length4Value = GetBytes(this.UpdateValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._03_EquipmentID_High:
                            length4Value = GetBytes(this.SystemConfig1.EquipmentID);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._04_EquipmentID_Low:
                            length4Value = GetBytes(this.SystemConfig1.EquipmentID);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._05_ProductNo_High:
                            length4Value = GetBytes(this.SystemConfig1.ProductNumber);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._06_ProductNo_Low:
                            length4Value = GetBytes(this.SystemConfig1.ProductNumber);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._07_UnderValueFloat_High:
                            length4Value = GetBytes((Single)underValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._08_UnderValueFloat_Low:
                            length4Value = GetBytes((Single)underValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._09_PassValueFloat_High:
                            length4Value = GetBytes((Single)passValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._10_PassValueFloat_Low:
                            length4Value = GetBytes((Single)passValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._11_OverValueFloat_High:
                            length4Value = GetBytes((Single)overValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._12_OverValueFloat_Low:
                            length4Value = GetBytes((Single)overValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._13_TareValueFloat_High:
                            length4Value = GetBytes((Single)tareValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._14_TareValueFloat_Low:
                            length4Value = GetBytes((Single)tareValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._15_UnderCount_High:
                            length4Value = GetBytes(this.CurrentWeightData.UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._16_UnderCount_Low:
                            length4Value = GetBytes(this.CurrentWeightData.UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._17_PassCount_High:
                            length4Value = GetBytes(this.CurrentWeightData.PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._18_PassCount_Low:
                            length4Value = GetBytes(this.CurrentWeightData.PassCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._19_OverCount_High:
                            length4Value = GetBytes(this.CurrentWeightData.OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._20_OverCount_Low:
                            length4Value = GetBytes(this.CurrentWeightData.OverCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._21_NGCount_High:
                            length4Value = GetBytes(this.CurrentWeightData.OverCount + this.CurrentWeightData.UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._22_NGCount_Low:
                            length4Value = GetBytes(this.CurrentWeightData.OverCount + this.CurrentWeightData.UnderCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._23_ExNGCount_High:
                            length4Value = GetBytes(this.CurrentWeightData.ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._24_ExNGCount_Low:
                            length4Value = GetBytes(this.CurrentWeightData.ExNGCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._25_TotalCount_High:
                            length4Value = GetBytes(this.CurrentWeightData.TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._26_TotalCount_Low:
                            length4Value = GetBytes(this.CurrentWeightData.TotalCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._27_Grade_High:
                            length4Value = GetBytes(judgmentStatus);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._28_Grade_Low:
                            length4Value = GetBytes(judgmentStatus);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._29_WeightFloat_High:
                            if (this.CurrentSystemStatus.Equipment == Define.E_EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.CurrentWeightData.Weight);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._30_WeightFloat_Low:
                            if (this.CurrentSystemStatus.Equipment == Define.E_EquipmentStatus.Stop)
                                length4Value = GetBytes((Single)0.0);
                            else
                                length4Value = GetBytes((Single)this.CurrentWeightData.Weight);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._31_OperationStatus_High:
                            length4Value = GetBytes(equipmentStatus);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._32_OperationStatus_Low:
                            length4Value = GetBytes(equipmentStatus);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._33_AlarmStatus_High:
                            length4Value = GetBytes(alarmStatus);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._34_AlarmStatus_Low:
                            length4Value = GetBytes(alarmStatus);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._35_Speed_High:
                            length4Value = GetBytes(this.CurrentWeightData.ProductionSpeed);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._36_Speed_Low:
                            length4Value = GetBytes(this.CurrentWeightData.ProductionSpeed);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._37_MetalDetectionCount_High:
                            length4Value = GetBytes(this.CurrentWeightData.MetalDetectionCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._38_MetalDetectionCount_Low:
                            length4Value = GetBytes(this.CurrentWeightData.MetalDetectionCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._39_DoubleEntryCount_High:
                            length4Value = GetBytes(this.CurrentWeightData.DoubleEntryCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._40_DoubleEntryCount_Low:
                            length4Value = GetBytes(this.CurrentWeightData.DoubleEntryCount);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._41_ProductName:
                            for (int i = 0; i < productName.Length; i++)
                                madeData[madeDataIndex + i] = productName[i];
                            break;
                        case _30000_ModbusAddress._51_UnderValueInt_High:
                            length4Value = GetBytes(this.CurrentProductItem.UnderRangeInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._52_UnderValueInt_Low:
                            length4Value = GetBytes(this.CurrentProductItem.UnderRangeInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._53_PassValueInt_High:
                            length4Value = GetBytes(this.CurrentProductItem.PassRangeInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._54_PassValueInt_Low:
                            length4Value = GetBytes(this.CurrentProductItem.PassRangeInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._55_OverValueInt_High:
                            length4Value = GetBytes(this.CurrentProductItem.OverRangeInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._56_OverValueInt_Low:
                            length4Value = GetBytes(this.CurrentProductItem.OverRangeInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._57_TareValueInt_High:
                            length4Value = GetBytes(this.CurrentProductItem.TareRangeInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._58_TareValueInt_Low:
                            length4Value = GetBytes(this.CurrentProductItem.TareRangeInt);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._59_WeightInt_High:
                            if (this.CurrentSystemStatus.Equipment == Define.E_EquipmentStatus.Stop)
                                length4Value = GetBytes(0);
                            else
                                length4Value = GetBytes(tempWeight);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._60_WeightInt_Low:
                            if (this.CurrentSystemStatus.Equipment == Define.E_EquipmentStatus.Stop)
                                length4Value = GetBytes(0);
                            else
                                length4Value = GetBytes(tempWeight);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        #endregion

                        #region Alarm
                        case _39000_ModbusAddressAlarm._9001_Alarm1:
                        case _39000_ModbusAddressAlarm._9002_Alarm2:
                        case _39000_ModbusAddressAlarm._9003_Alarm3:
                        case _39000_ModbusAddressAlarm._9004_Alarm4:
                        case _39000_ModbusAddressAlarm._9005_Alarm5:
                        case _39000_ModbusAddressAlarm._9006_Alarm6:
                        case _39000_ModbusAddressAlarm._9007_Alarm7:
                        case _39000_ModbusAddressAlarm._9008_Alarm8:
                        case _39000_ModbusAddressAlarm._9009_Alarm9:
                        case _39000_ModbusAddressAlarm._9010_Alarm10:
                        case _39000_ModbusAddressAlarm._9011_Alarm11:
                        case _39000_ModbusAddressAlarm._9012_Alarm12:
                        case _39000_ModbusAddressAlarm._9013_Alarm13:
                        case _39000_ModbusAddressAlarm._9014_Alarm14:
                        case _39000_ModbusAddressAlarm._9015_Alarm15:
                        case _39000_ModbusAddressAlarm._9016_Alarm16:
                        case _39000_ModbusAddressAlarm._9017_Alarm17:
                        case _39000_ModbusAddressAlarm._9018_Alarm18:
                            length2Value = GetBytes(this.CurrentAlarm[j - 9000]);

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

                        default:
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = 0;
                            break;
                        #endregion
                    }
                    if (j == (int)_30000_ModbusAddress._41_ProductName)
                    {
                        j += 9;
                        madeDataIndex += 20;
                    }
                    else
                        madeDataIndex += 2;
                }
                #endregion
            }

            return madeData;
        }
        private string Transfer_23_STD2(SystemConfigurationItem1 system, WeightData weight, ProductItem product)
        {
            StringBuilder sb = new StringBuilder();

            if (weight.JudgmentStatus == Define.E_JudgmentStatus.Empty)
                return "";

            sb.Append((char)0x02);
            sb.Append(string.Format("IN{0:000}", system.EquipmentID));
            sb.Append(string.Format("{0:0000}", product.Number));

            sb.Append(Helper.StringZeroFillDigits6(Helper.StringToDecimalPlaces(product.UnderRange, this.SystemConfig1.DecimalPlaces)));
            sb.Append(Helper.StringZeroFillDigits6(Helper.StringToDecimalPlaces(product.PassRange, this.SystemConfig1.DecimalPlaces)));
            sb.Append(Helper.StringZeroFillDigits6(Helper.StringToDecimalPlaces(product.OverRange, this.SystemConfig1.DecimalPlaces)));

            sb.Append(string.Format("{0:0000000}", weight.UnderCount));
            sb.Append(string.Format("{0:0000000}", weight.PassCount));
            sb.Append(string.Format("{0:0000000}", weight.OverCount));
            sb.Append(string.Format("{0:0000000}", weight.ExNGCount));
            sb.Append(string.Format("{0:000000000}", weight.TotalCount));

            switch (weight.JudgmentStatus)
            {
                case Define.E_JudgmentStatus.Empty:
                    break;
                case Define.E_JudgmentStatus.Under:
                    sb.Append("U");
                    break;
                case Define.E_JudgmentStatus.Pass:
                    sb.Append("P");
                    break;
                case Define.E_JudgmentStatus.Over:
                    sb.Append("O");
                    break;
                case Define.E_JudgmentStatus.Double:
                    sb.Append("D");
                    break;
                case Define.E_JudgmentStatus.Metal:
                    sb.Append("M");
                    break;
                case Define.E_JudgmentStatus.ExNg:
                    sb.Append("E");
                    break;
                default:
                    sb.Append("E");
                    break;
            }

            if (weight.Weight <= 0.0)
                sb.Append("-");
            else
                sb.Append(" ");

            string temp = Helper.DoubleToString(weight.Weight, this.SystemConfig1.DecimalPlaces);
            if (temp.StartsWith("-"))
                temp = temp.Substring(1, temp.Length - 1);
            sb.Append(temp.PadLeft(6, ' '));
            sb.Append((char)0x03);

            return sb.ToString();
        }
        private byte[] Transfer_24_MULTi_JET(bool isFillZero, WeightData weight)
        {
            byte slaveAddress = 1;
            string tempString = "";
            byte[] byteArray = new byte[29];
            byte[] date = new UTF8Encoding().GetBytes(string.Format("{0:yyyy.MM.dd}", DateTime.Now));
            byte[] bytes = new byte[7];

            byteArray[0] = 0x1B;
            byteArray[1] = 0x02;
            if (this.SystemConfig2.EthernetOperationMode != 0)
            {
                if (this.smartTCPMultiServer.IsStart == true && this.smartTCPMultiServer.ClientInfoList.Length != 0)
                {
                    string temp = this.smartTCPMultiServer.ClientInfoList[0].strIPAddress.Trim();
                    string[] splitTemp = temp.Split('.');
                    slaveAddress = Convert.ToByte(splitTemp[3]);
                }
            }
            else
            {
                if (this.SystemConfig1.SerialCOM1Mode == (int)Define.E_CommMode.f24_MULTi_JET)
                    slaveAddress = Convert.ToByte(this.SystemConfig3.MULTiJETSlaveAddressCOM1);
                else if (this.SystemConfig1.SerialCOM3Mode == (int)Define.E_CommMode.f24_MULTi_JET)
                    slaveAddress = Convert.ToByte(this.SystemConfig3.MULTiJETSlaveAddressCOM3);
                else if (this.SystemConfig1.SerialCOM4Mode == (int)Define.E_CommMode.f24_MULTi_JET)
                    slaveAddress = Convert.ToByte(this.SystemConfig3.MULTiJETSlaveAddressCOM4);
            }
            byteArray[2] = slaveAddress;
            byteArray[3] = 0x1D; // 고정값, 원격 필드 데이터 다운로드(1D)
            byteArray[4] = 0x02; // 데이터 개수
            byteArray[5] = 0x01; // 필드ID(마킹기 화면에서 설정 가능)
            byteArray[6] = 0x0A; // 현재 필드ID 자리수
            for (int i = 0; i < date.Length; i++)
                byteArray[7 + i] = date[i];
            byteArray[17] = 0x02; // 필드ID(마킹기 화면에서 설정 가능)
            byteArray[18] = 0x07; // 현재 필드ID 자리수

            if (isFillZero == true)
                tempString = Helper.StringZeroFillDigits6(Helper.DoubleToString(weight.Weight, this.SystemConfig1.DecimalPlaces)) + 'g';
            else
                tempString = this.PadLeft(6, Helper.DoubleToString(weight.Weight, this.SystemConfig1.DecimalPlaces)) + 'g';

            for (int i = 0; i < tempString.Length; i++)
            {
                bytes[i] = Convert.ToByte(tempString[i]);
                byteArray[19 + i] = bytes[i];
            }
            byteArray[26] = 0x1B;
            byteArray[27] = 0x03;
            byteArray[28] = this.Checksumcalculator1digit(byteArray);

            return byteArray;
        }
        private byte[] Transfer_26_LINX8830(bool isFillZero, WeightData weight)
        {
            byte[] byteArray = new byte[13];
            byte[] bytes = new byte[6];

            // 0~4 고정값
            byteArray[0] = 0x1b;
            byteArray[1] = 0x02;
            byteArray[2] = 0x1D;
            byteArray[3] = 0x06;
            byteArray[4] = 0x00;

            if (weight.Weight >= 0.0)
            {
                if (isFillZero == true)
                    bytes = new UTF8Encoding().GetBytes(Helper.StringZeroFillDigits6(Helper.DoubleToString(weight.Weight, this.SystemConfig1.DecimalPlaces)));
                else
                    bytes = new UTF8Encoding().GetBytes(this.PadLeft(6, Helper.DoubleToString(weight.Weight, this.SystemConfig1.DecimalPlaces)));
            }
            else
            {
                if (isFillZero == true)
                    bytes = new UTF8Encoding().GetBytes(Helper.StringZeroFillDigits6(Helper.DoubleToString(0.0, this.SystemConfig1.DecimalPlaces)));
                else
                    bytes = new UTF8Encoding().GetBytes(this.PadLeft(6, Helper.DoubleToString(0.0, this.SystemConfig1.DecimalPlaces)));
            }

            for (int i = 0; i < bytes.Length; i++)
            {
                byteArray[i + 5] = bytes[i];
            }

            // 11~12 고정값
            byteArray[11] = 0x1b;
            byteArray[12] = 0x03;

            return byteArray;
        }
        private byte[] Transfer_27_MYJET(bool isFillZero, WeightData weight)
        {
            byte[] byteArray = new byte[16];
            byte[] bytes = new byte[6];

            // 0~6 고정값
            byteArray[0] = 0x1b;
            byteArray[1] = 0x02;
            string[] ethernetAddr = this.SystemConfig2.EthernetAddress.Split('.');
            byteArray[2] = Helper.StringToHex(ethernetAddr[ethernetAddr.Length - 1]); // Server IP 맨 마지막자리
            byteArray[3] = 0x1D;
            byteArray[4] = 0x01;
            byteArray[5] = 0x01;
            byteArray[6] = 0x06;

            if (weight.Weight >= 0.0)
            {
                if (isFillZero == true)
                    bytes = new UTF8Encoding().GetBytes(Helper.StringZeroFillDigits6(Helper.DoubleToString(weight.Weight, this.SystemConfig1.DecimalPlaces)));
                else
                    bytes = new UTF8Encoding().GetBytes(this.PadLeft(6, Helper.DoubleToString(weight.Weight, this.SystemConfig1.DecimalPlaces)));
            }
            else
            {
                if (isFillZero == true)
                    bytes = new UTF8Encoding().GetBytes(Helper.StringZeroFillDigits6(Helper.DoubleToString(0.0, this.SystemConfig1.DecimalPlaces)));
                else
                    bytes = new UTF8Encoding().GetBytes(this.PadLeft(6, Helper.DoubleToString(0.0, this.SystemConfig1.DecimalPlaces)));
            }

            for (int i = 0; i < bytes.Length; i++)
            {
                byteArray[i + 7] = bytes[i];
            }

            // 13~14 고정값
            byteArray[13] = 0x1b;
            byteArray[14] = 0x03;

            byteArray[15] = 0x00;
            byteArray[15] = this.Checksumcalculator1digit(byteArray);

            return byteArray;
        }
        private string Transfer_28_OPT4(bool isFillZero, WeightData weight)
        {
            if (this.SystemConfig2.Barcode == 0)
                return "";

            StringBuilder sb = new StringBuilder();
            DateTime nowTime = DateTime.Now;

            sb.Append((char)0x02);
            sb.Append(string.Format("{0:yyyy-MM-dd HH:mm:ss}", nowTime));
            sb.Append(";");
            switch (weight.JudgmentStatus)
            {
                case Define.E_JudgmentStatus.Empty:
                    break;
                case Define.E_JudgmentStatus.Under:
                    sb.Append("U");
                    break;
                case Define.E_JudgmentStatus.Pass:
                    sb.Append("P");
                    break;
                case Define.E_JudgmentStatus.Over:
                    sb.Append("O");
                    break;
                case Define.E_JudgmentStatus.Double:
                    sb.Append("D");
                    break;
                case Define.E_JudgmentStatus.Metal:
                    sb.Append("M");
                    break;
                case Define.E_JudgmentStatus.ExNg:
                    sb.Append("E");
                    break;
                case Define.E_JudgmentStatus.LengthError:
                    sb.Append("L");
                    break;
                default:
                    sb.Append("E");
                    break;
            }
            sb.Append(";");
            if (isFillZero == true)
                sb.Append(Helper.StringZeroFillDigits6(Helper.DoubleToString(weight.Weight, this.SystemConfig1.DecimalPlaces)));
            else
                sb.Append(this.PadLeft(6, Helper.DoubleToString(weight.Weight, this.SystemConfig1.DecimalPlaces)));
            sb.Append(";");
            sb.Append(this.CurrentBarcode.BarcodePeek());
            sb.Append((char)0x03);

            return sb.ToString();
        }
        #endregion

        #region SerialCommunication
        public string SendChar(Define.E_CharValue sendChar)
        {
            StringBuilder temp = new StringBuilder();

            switch (sendChar)
            {
                case Define.E_CharValue.ENQ:
                    temp.Append((char)0x05);
                    break;
                case Define.E_CharValue.ACK:
                    temp.Append((char)0x06);
                    break;
                case Define.E_CharValue.NAK:
                    temp.Append((char)0x15);
                    break;
                case Define.E_CharValue.Space:
                    temp.Append((char)0x20);
                    break;
            }

            return temp.ToString();
        }

        // Markem-imaje 9410 방 변경
        public byte[] RoomChange9410(int num)
        {
            byte[] byteArray = new byte[6];

            // Position 변경 : 0xA0
            byteArray[0] = 0xA0;

            // Length : 0x00, 0x02 고정값
            byteArray[1] = 0x00;
            byteArray[2] = 0x02;


            if (num == 1)
            {
                // 1번방으로 이동
                byteArray[3] = 0x30;
                byteArray[4] = 0x31;
            }
            else
            {
                // 2번방으로 이동
                byteArray[3] = 0x30;
                byteArray[4] = 0x32;
            }

            byteArray[5] = 0x00;
            byteArray[5] = Helper.ChecksumCalculator(byteArray);

            return byteArray;
        }
        // Markem-imaje 9410 중량
        public byte[] WeightData9410_OPT1(WeightData weight)
        {
            int tempStringLength = 0;
            string tempString = "";

            byte[] byteArray = new byte[12];
            byte[] weightBytes = new byte[5];
            // 외부변수사용 : 0xE8
            byteArray[0] = 0xE8;
            // Length : 0x00, 0x08 고정값
            byteArray[1] = 0x00;
            byteArray[2] = 0x08;

            byteArray[3] = 0x01; // 1번 외부변수 번호
            byteArray[4] = 0x00;
            byteArray[5] = 0x05; // 1번 외부변수 길이

            tempStringLength = weight.Weight.ToString().Trim().Length;
            if (tempStringLength > 5)
                tempString = weight.Weight.ToString().Trim().Substring(tempStringLength - 5, 5);
            else
                tempString = string.Format("{0,5}", weight.Weight);

            weightBytes = new UTF8Encoding().GetBytes(tempString);
            for (int i = 0; i < weightBytes.Length; i++)
            {
                byteArray[i + 6] = weightBytes[i];
            }

            byteArray[11] = 0x00;
            byteArray[11] = Helper.ChecksumCalculator(byteArray);

            return byteArray;
        }
        // Markem-imaje 9410 중량(OPT3)
        public byte[] WeightData9410_OPT3(WeightData weight)
        {
            int tempStringLength = 0;
            string tempString = "";

            byte[] byteArray = new byte[12];
            byte[] weightBytes = new byte[5];
            // 외부변수사용 : 0xE8
            byteArray[0] = 0xE8;
            // Length : 0x00, 0x08 고정값
            byteArray[1] = 0x00;
            byteArray[2] = 0x08;

            byteArray[3] = 0x01; // 1번 외부변수 번호
            byteArray[4] = 0x00;
            byteArray[5] = 0x05; // 1번 외부변수 길이

            string result = weight.Weight.ToString().Trim();
            string[] splitResult = result.Split('.');

            weightBytes = new UTF8Encoding().GetBytes(string.Format("{0, 5}", int.Parse(splitResult[0])));
            for (int i = 0; i < weightBytes.Length; i++)
            {
                byteArray[i + 6] = weightBytes[i];
            }

            byteArray[11] = 0x00;
            byteArray[11] = Helper.ChecksumCalculator(byteArray);

            //tempStringLength = weight.Weight.ToString().Trim().Length;
            //if (tempStringLength > 5)
            //    tempString = weight.Weight.ToString().Trim().Substring(tempStringLength - 5, 5);
            //else
            //    tempString = string.Format("{0,5}", weight.Weight);

            //weightBytes = new UTF8Encoding().GetBytes(tempString);
            //for (int i = 0; i < weightBytes.Length; i++)
            //{
            //    byteArray[i + 6] = weightBytes[i];
            //}

            //byteArray[11] = 0x00;
            //byteArray[11] = Helper.ChecksumCalculator(byteArray);

            return byteArray;
        }

        // Markem-imaje 9028 방 변경
        public byte[] RoomChange9028(int num)
        {
            byte[] byteArray = new byte[6];

            // Position 변경 : 0x98
            byteArray[0] = 0x98;

            // Length : 0x00, 0x02 고정값
            byteArray[1] = 0x00;
            byteArray[2] = 0x02;


            if (num == 1)
            {
                // 1번방으로 이동
                byteArray[3] = 0x00;
                byteArray[4] = 0x01;
            }
            else
            {
                // 2번방으로 이동
                byteArray[3] = 0x00;
                byteArray[4] = 0x02;
            }

            byteArray[5] = 0x00;
            byteArray[5] = Helper.ChecksumCalculator(byteArray);

            return byteArray;
        }
        // Markem-imaje 9028 중량
        public byte[] WeightData9028(WeightData weight)
        {
            int tempStringLength = 0;
            string tempString = "";

            byte[] byteArray = new byte[12];
            byte[] weightBytes = new byte[5];

            // byteArray[0] ~ byteArray[3]은 고정
            byteArray[0] = 0x99;
            byteArray[1] = 0x00;
            byteArray[2] = 0x07;
            byteArray[3] = 0x12;

            string result = weight.Weight.ToString().Trim();
            string[] splitResult = result.Split('.');

            weightBytes = new UTF8Encoding().GetBytes(string.Format("{0, 5}", int.Parse(splitResult[0])));
            for (int i = 0; i < weightBytes.Length; i++)
            {
                byteArray[i + 4] = weightBytes[i];
            }

            byteArray[9] = 0x12;
            byteArray[10] = 0x00;
            byteArray[10] = Helper.ChecksumCalculator(byteArray);

            return byteArray;
        }

        // 전송지연시간
        private void CreateTimer(Define.E_MenuBottomConfiguration port)
        {
            switch (port)
            {
                case Define.E_MenuBottomConfiguration.SerialCOM1:
                    System.Windows.Forms.Timer timerCOM1 = new System.Windows.Forms.Timer();
                    timerCOM1.Interval = this.SystemConfig1.TransmissionDelayTimeCOM1;
                    timerCOM1.Tick += new EventHandler(this.timerCOM1_Tick);
                    timerCOM1.Enabled = true;
                    break;
                case Define.E_MenuBottomConfiguration.SerialCOM3:
                    System.Windows.Forms.Timer timerCOM3 = new System.Windows.Forms.Timer();
                    timerCOM3.Interval = this.SystemConfig1.TransmissionDelayTimeCOM3;
                    timerCOM3.Tick += new EventHandler(this.timerCOM3_Tick);
                    timerCOM3.Enabled = true;
                    break;
                case Define.E_MenuBottomConfiguration.SerialCOM4:
                    System.Windows.Forms.Timer timerCOM4 = new System.Windows.Forms.Timer();
                    timerCOM4.Interval = this.SystemConfig1.TransmissionDelayTimeCOM4;
                    timerCOM4.Tick += new EventHandler(this.timerCOM4_Tick);
                    timerCOM4.Enabled = true;
                    break;
                default:
                    break;
            }
        }
        public void ClearQueue()
        {
            this.QueueCOM1.Clear();
            this.QueueCOM3.Clear();
            this.QueueCOM4.Clear();
        }

        private char HitachiRoomNumberToChar(int roomNumber)
        {
            switch (roomNumber)
            {
                case 1:
                    return (char)0x31;
                case 2:
                    return (char)0x32;
                case 3:
                    return (char)0x33;
                case 4:
                    return (char)0x34;
                case 5:
                    return (char)0x35;
                case 6:
                    return (char)0x36;
                case 7:
                    return (char)0x37;
                case 8:
                    return (char)0x38;
                case 9:
                    return (char)0x39;
                default:
                    return (char)0x31;
            }
        }
        private string ResponseFrameOPT2()
        {
            StringBuilder sb = new StringBuilder();

            if (this.CurrentOPT2COM1.IsReceivedData == true)
            {
                this.CurrentOPT2COM1.IsReceivedData = false;

                // STX
                sb.Append((char)0x02);

                //식별코드;
                if (this.CurrentOPT2COM1.IsErrorReceivedData == true)
                    sb.Append("1");
                else if (this.CurrentOPT2COM1.IsErrorSettingStatus == true)
                    sb.Append("2");
                else if (this.CurrentOPT2COM1.IsFailProductChange == true)
                    sb.Append("3");
                else
                    sb.Append("0");

                //동작
                if (this.CurrentSystemStatus.Equipment == Define.E_EquipmentStatus.Start)
                    sb.Append("0");
                else
                    sb.Append("1");

                //품종번호
                if (this.CurrentProductItem.Number <= 99)
                    sb.Append(string.Format("{0:d2}", this.CurrentProductItem.Number));
                else
                    sb.Append("00");

                //ETX
                sb.Append((char)0x03);

                return sb.ToString();
            }
            else
                return "";
        }
        private void SerialOPT2COM1Delegate()
        {
            System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
            timer.Interval = 500;
            timer.Tick += new EventHandler(this.timerOPT2COM1_Tick);
            timer.Enabled = true;
        }
        private void SerialOPT2COM3Delegate()
        {
            System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
            timer.Interval = 500;
            timer.Tick += new EventHandler(this.timerOPT2COM3_Tick);
            timer.Enabled = true;
        }
        private void SerialOPT2COM4Delegate()
        {
            System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
            timer.Interval = 500;
            timer.Tick += new EventHandler(this.timerOPT2COM4_Tick);
            timer.Enabled = true;
        }
        private void SerialOPT2EthernetDelegate()
        {
            System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
            timer.Interval = 500;
            timer.Tick += new EventHandler(this.timerOPT2Ethernet_Tick);
            timer.Enabled = true;
        }
        #endregion
        #region Serial COM1
        public void OpenSerialCOM1()
        {
            int baudrate = 9600;

            if (this.SystemConfig1.SerialCOM1Mode == 0 || this.SystemConfig1.SerialCOM1Mode == 16)
                return;

            this.CloseSerialCOM1();

            switch (this.SystemConfig1.SerialCOM1BaudRate)
            {
                case 0:
                    this.smartSerialPort1.Baud_Rate = SmartSerialPort.BAUDRATE._9600bps;
                    baudrate = 9600;
                    break;
                case 1:
                    this.smartSerialPort1.Baud_Rate = SmartSerialPort.BAUDRATE._19200bps;
                    baudrate = 19200;
                    break;
                case 2:
                    this.smartSerialPort1.Baud_Rate = SmartSerialPort.BAUDRATE._38400bps;
                    baudrate = 38400;
                    break;
                case 3:
                    this.smartSerialPort1.Baud_Rate = SmartSerialPort.BAUDRATE._57600bps;
                    baudrate = 57600;
                    break;
                case 4:
                    this.smartSerialPort1.Baud_Rate = SmartSerialPort.BAUDRATE._115200bps;
                    baudrate = 115200;
                    break;
                default:
                    this.smartSerialPort1.Baud_Rate = SmartSerialPort.BAUDRATE._9600bps;
                    baudrate = 9600;
                    break;
            }

            if (this.FlagSerialDll == false)
            {
                this.smartSerialPort1.Open();
            }
            else
            {
                // Port : COM1
                SerialMgrComm.serialPortOpen("COM1:", baudrate, 0, 0, 8);
            }
        }
        public void CloseSerialCOM1()
        {
            if (this.FlagSerialDll == false)
                this.smartSerialPort1.Close();
            else
                SerialMgrComm.serialPortClose("COM1:");
        }
        public bool CheckOpenCOM1()
        {
            if (this.FlagSerialDll == false)
            {
                if (this.smartSerialPort1.IsOpen == true)
                    return true;
                else
                    return false;
            }
            else
                return true;
        }
        public void TransferDirectSerialCOM1(string strTemp)
        {
            if (this.SystemConfig1.SerialCOM1Mode == 3 && this.SystemConfig1.StatisticsPrintFormat == 1)
            {
                byte[] strByte = Encoding.GetEncoding("ks_c_5601-1987").GetBytes(strTemp);

                if (this.FlagSerialDll == false)
                    this.smartSerialPort1.WriteNoneFrame(strByte);
                else
                    SerialMgrComm.serialPortMessageByte("COM1:", strByte, strByte.Length);
            }
            else
            {
                if (this.FlagSerialDll == false)
                    this.smartSerialPort1.WriteNoneFrame(strTemp, SmartSerialPort.CODETYPES.ASCIICODE);
                else
                    SerialMgrComm.serialPortMessageRaw("COM1:", strTemp);
            }
        }
        public void TransferDirectSerialCOM1(byte[] buffer)
        {
            if (this.FlagSerialDll == false)
                this.smartSerialPort1.WriteNoneFrame(buffer);
            else
                SerialMgrComm.serialPortMessageByte("COM1:", buffer, buffer.Length);
        }
        public void TransferSerialCOM1(string strTemp)
        {
            if (this.SystemConfig1.TransmissionDelayTimeCOM1 == 0)
            {
                if (this.SystemConfig1.SerialCOM1Mode == 3 && this.SystemConfig1.StatisticsPrintFormat == 1)
                {
                    byte[] strByte = Encoding.GetEncoding("ks_c_5601-1987").GetBytes(strTemp);

                    if (this.FlagSerialDll == false)
                        this.smartSerialPort1.WriteNoneFrame(strByte);
                    else
                        SerialMgrComm.serialPortMessageByte("COM1:", strByte, strByte.Length);
                }
                else
                {
                    if (this.FlagSerialDll == false)
                        this.smartSerialPort1.WriteNoneFrame(strTemp, SmartSerialPort.CODETYPES.ASCIICODE);
                    else
                        SerialMgrComm.serialPortMessageRaw("COM1:", strTemp);
                }
            }
            else
            {
                this.QueueCOM1.Enqueue(strTemp);
                this.CreateTimer(Define.E_MenuBottomConfiguration.SerialCOM1);
            }
        }
        public void TransferSerialCOM1(byte[] buffer)
        {
            if (this.SystemConfig1.TransmissionDelayTimeCOM1 == 0)
            {
                if (this.FlagSerialDll == false)
                    this.smartSerialPort1.WriteNoneFrame(buffer);
                else
                    SerialMgrComm.serialPortMessageByte("COM1:", buffer, buffer.Length);
            }
            else
            {
                this.QueueCOM1.Enqueue(buffer);
                this.CreateTimer(Define.E_MenuBottomConfiguration.SerialCOM1);
            }
        }
        public void ChangeSerialCOM1FrameSeparateType(Define.E_SeparateType type)
        {
            if (this.FlagSerialDll == true)
                return;

            // 통신 포트 설정
            this.CloseSerialCOM1();

            if (type == Define.E_SeparateType.ETXONLY)
            {
                this.smartSerialPort1.FrameSeparationType = SmartSerialPort.FRAMESEPARATIONTYPES.ETXONLY;

                byte[] etxCodes = new byte[2];
                etxCodes[0] = 13;
                etxCodes[1] = 10;
                this.smartSerialPort1.ETXCodes = etxCodes;
            }
            else if (type == Define.E_SeparateType.STXANDETX)
            {
                this.smartSerialPort1.FrameSeparationType = SmartSerialPort.FRAMESEPARATIONTYPES.STXANDETX;

                this.smartSerialPort1.STXCode = 2;
                this.smartSerialPort1.ETXCode = 3;
            }
            else if (type == Define.E_SeparateType.NONEFRAME_READTIMEOUT)
            {
                this.smartSerialPort1.FrameSeparationType = SmartSerialPort.FRAMESEPARATIONTYPES.NONEFRAME_READTIMEOUT;
                this.smartSerialPort1.ReadTimeout = 300;
            }
            else
            {
                this.smartSerialPort1.FrameSeparationType = SmartSerialPort.FRAMESEPARATIONTYPES.STXONLY;
                this.smartSerialPort1.STXCode = 2;
            }

            this.smartSerialPort1.Open();
        }
        #endregion
        #region Serial COM3
        public void OpenSerialCOM3()
        {
            int baudrate = 9600;

            if (this.SystemConfig1.SerialCOM3Mode == 0 || this.SystemConfig1.SerialCOM3Mode == 16)
                return;

            this.CloseSerialCOM3();

            switch (this.SystemConfig1.SerialCOM3BaudRate)
            {
                case 0:
                    this.smartSerialPort3.Baud_Rate = SmartSerialPort.BAUDRATE._9600bps;
                    baudrate = 9600;
                    break;
                case 1:
                    this.smartSerialPort3.Baud_Rate = SmartSerialPort.BAUDRATE._19200bps;
                    baudrate = 19200;
                    break;
                case 2:
                    this.smartSerialPort3.Baud_Rate = SmartSerialPort.BAUDRATE._38400bps;
                    baudrate = 38400;
                    break;
                case 3:
                    this.smartSerialPort3.Baud_Rate = SmartSerialPort.BAUDRATE._57600bps;
                    baudrate = 57600;
                    break;
                case 4:
                    this.smartSerialPort3.Baud_Rate = SmartSerialPort.BAUDRATE._115200bps;
                    baudrate = 115200;
                    break;
                default:
                    this.smartSerialPort3.Baud_Rate = SmartSerialPort.BAUDRATE._9600bps;
                    baudrate = 9600;
                    break;
            }

            if (this.FlagSerialDll == false)
            {
                this.smartSerialPort3.Open();
            }
            else
            {
                // Port : COM3
                SerialMgrComm.serialPortOpen("COM3:", baudrate, 0, 0, 8);
            }
        }
        public void CloseSerialCOM3()
        {
            if (this.FlagSerialDll == false)
                this.smartSerialPort3.Close();
            else
                SerialMgrComm.serialPortClose("COM3:");
        }
        public bool CheckOpenCOM3()
        {
            if (this.FlagSerialDll == false)
            {
                if (this.smartSerialPort3.IsOpen == true)
                    return true;
                else
                    return false;
            }
            else
                return true;
        }
        public void TransferDirectSerialCOM3(string strTemp)
        {
            if (this.SystemConfig1.SerialCOM3Mode == 3 && this.SystemConfig1.StatisticsPrintFormat == 1)
            {
                byte[] strByte = Encoding.GetEncoding("ks_c_5601-1987").GetBytes(strTemp);

                if (this.FlagSerialDll == false)
                    this.smartSerialPort3.WriteNoneFrame(strByte);
                else
                    SerialMgrComm.serialPortMessageByte("COM3:", strByte, strByte.Length);
            }
            else
            {
                if (this.FlagSerialDll == false)
                    this.smartSerialPort3.WriteNoneFrame(strTemp, SmartSerialPort.CODETYPES.ASCIICODE);
                else
                    SerialMgrComm.serialPortMessageRaw("COM3:", strTemp);
            }
        }
        public void TransferDirectSerialCOM3(byte[] buffer)
        {
            if (this.FlagSerialDll == false)
                this.smartSerialPort3.WriteNoneFrame(buffer);
            else
                SerialMgrComm.serialPortMessageByte("COM3:", buffer, buffer.Length);
        }
        public void TransferDirectSerialCOM3RawData(string strTemp)
        {
            if (this.FlagSerialDll == false)
                this.smartSerialPort3.RawSerialPort.Write(strTemp);
            else
                SerialMgrComm.serialPortMessageRaw("COM3:", strTemp);
        }
        public void TransferDirectSerialCOM3RawData(byte[] buffer)
        {
            if (this.FlagSerialDll == false)
                this.smartSerialPort3.RawSerialPort.Write(buffer, 0, buffer.Length);
            else
                SerialMgrComm.serialPortMessageByte("COM3:", buffer, buffer.Length);
        }
        public void TransferSerialCOM3(string strTemp)
        {
            if (strTemp == "" || strTemp == null)
                return;

            if (this.SystemConfig1.TransmissionDelayTimeCOM3 == 0)
            {
                if (this.SystemConfig1.SerialCOM3Mode == 3 && this.SystemConfig1.StatisticsPrintFormat == 1)
                {
                    byte[] strByte = Encoding.GetEncoding("ks_c_5601-1987").GetBytes(strTemp);

                    if (this.FlagSerialDll == false)
                        this.smartSerialPort3.WriteNoneFrame(strByte);
                    else
                        SerialMgrComm.serialPortMessageByte("COM3:", strByte, strByte.Length);
                }
                else
                {
                    if (this.FlagSerialDll == false)
                        this.smartSerialPort3.WriteNoneFrame(strTemp, SmartSerialPort.CODETYPES.ASCIICODE);
                    else
                        SerialMgrComm.serialPortMessageRaw("COM3:", strTemp);
                }
            }
            else
            {
                this.QueueCOM3.Enqueue(strTemp);
                this.CreateTimer(Define.E_MenuBottomConfiguration.SerialCOM3);
            }
        }
        public void TransferSerialCOM3(byte[] buffer)
        {
            if (this.SystemConfig1.TransmissionDelayTimeCOM3 == 0)
            {
                if (this.FlagSerialDll == false)
                    this.smartSerialPort3.WriteNoneFrame(buffer);
                else
                    SerialMgrComm.serialPortMessageByte("COM3:", buffer, buffer.Length);
            }
            else
            {
                this.QueueCOM3.Enqueue(buffer);
                this.CreateTimer(Define.E_MenuBottomConfiguration.SerialCOM3);
            }
        }
        public void TransferSerialCOM3RawData(byte[] buffer)
        {
            if (this.SystemConfig1.TransmissionDelayTimeCOM3 == 0)
            {
                if (this.FlagSerialDll == false)
                    //RawSerialPort 기능을 사용하여 데이터를 전송
                    this.smartSerialPort3.RawSerialPort.Write(buffer, 0, buffer.Length);
                else
                    SerialMgrComm.serialPortMessageByte("COM3:", buffer, buffer.Length);

            }
            else
            {
                this.QueueCOM3.Enqueue(buffer);
                this.CreateTimer(Define.E_MenuBottomConfiguration.SerialCOM3);
            }
        }
        public void ReceiveSerialCOM3()
        {
            int ret = 0;
            string strTemp = "";
            byte[] readByte;

            SmartSerialPort.FRAMEDATAREADSTATUS receiveDataState = SmartSerialPort.FRAMEDATAREADSTATUS.EMPTY;

            try
            {
                receiveDataState = this.smartSerialPort3.ReadQueue(out readByte);
                strTemp = Encoding.Default.GetString(readByte, 0, readByte.Length);
            }
            catch
            {
                return;
            }

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

            // Bacode
            if (this.SystemConfig1.IsBarcodeEnable == true)
            {

            }
        }

        public void ChangeSerialCOM3FrameSeparateType(Define.E_SeparateType type)
        {
            if (this.FlagSerialDll == true)
                return;

            // 통신 포트 설정
            this.CloseSerialCOM3();

            if (type == Define.E_SeparateType.ETXONLY)
            {
                this.smartSerialPort3.FrameSeparationType = SmartSerialPort.FRAMESEPARATIONTYPES.ETXONLY;

                byte[] etxCodes = new byte[2];
                etxCodes[0] = 13;
                etxCodes[1] = 10;
                this.smartSerialPort3.ETXCodes = etxCodes;
            }
            else if (type == Define.E_SeparateType.STXANDETX)
            {
                this.smartSerialPort3.FrameSeparationType = SmartSerialPort.FRAMESEPARATIONTYPES.STXANDETX;

                this.smartSerialPort3.STXCode = 2;
                this.smartSerialPort3.ETXCode = 3;
            }
            else if (type == Define.E_SeparateType.NONEFRAME_READTIMEOUT)
            {
                this.smartSerialPort3.FrameSeparationType = SmartSerialPort.FRAMESEPARATIONTYPES.NONEFRAME_READTIMEOUT;
                this.smartSerialPort3.ReadTimeout = 300;
            }
            else
            {
                this.smartSerialPort3.FrameSeparationType = SmartSerialPort.FRAMESEPARATIONTYPES.STXONLY;
                this.smartSerialPort3.STXCode = 2;
            }

            this.OpenSerialCOM3();
        }
        public void ChangeSerialCOM3ReceiveDetect(SmartSerialPort.RECEIVEDETECTTYPE detectType)
        {
            this.smartSerialPort3.ReceiveDetect = detectType;
        }
        public void ChangeSerialCOM3FrameBufferSize(uint size)
        {
            this.smartSerialPort3.FrameBufferSize = size;
        }
        #endregion
        #region Serial COM4
        public void OpenSerialCOM4()
        {
            int baudrate = 9600;

            if (this.SystemConfig1.SerialCOM4Mode == 0 || this.SystemConfig1.SerialCOM4Mode == 16)
                return;

            this.CloseSerialCOM4();

            switch (this.SystemConfig1.SerialCOM4BaudRate)
            {
                case 0:
                    this.smartSerialPort4.Baud_Rate = SmartSerialPort.BAUDRATE._9600bps;
                    baudrate = 9600;
                    break;
                case 1:
                    this.smartSerialPort4.Baud_Rate = SmartSerialPort.BAUDRATE._19200bps;
                    baudrate = 19200;
                    break;
                case 2:
                    this.smartSerialPort4.Baud_Rate = SmartSerialPort.BAUDRATE._38400bps;
                    baudrate = 38400;
                    break;
                case 3:
                    this.smartSerialPort4.Baud_Rate = SmartSerialPort.BAUDRATE._57600bps;
                    baudrate = 57600;
                    break;
                case 4:
                    this.smartSerialPort4.Baud_Rate = SmartSerialPort.BAUDRATE._115200bps;
                    baudrate = 115200;
                    break;
                default:
                    this.smartSerialPort4.Baud_Rate = SmartSerialPort.BAUDRATE._9600bps;
                    baudrate = 9600;
                    break;
            }

            if (this.FlagSerialDll == false)
            {
                this.smartSerialPort4.Open();
            }
            else
            {
                // Port : COM4
                SerialMgrComm.serialPortOpen("COM4:", baudrate, 0, 0, 8);
            }
        }
        public void CloseSerialCOM4()
        {
            if (this.FlagSerialDll == false)
                this.smartSerialPort4.Close();
            else
                SerialMgrComm.serialPortClose("COM4:");
        }
        public bool CheckOpenCOM4()
        {
            if (this.FlagSerialDll == false)
            {
                if (this.smartSerialPort4.IsOpen == true)
                    return true;
                else
                    return false;
            }
            else
                return true;
        }
        public void TransferDirectSerialCOM4(string strTemp)
        {
            if (this.SystemConfig1.SerialCOM4Mode == 3 && this.SystemConfig1.StatisticsPrintFormat == 1)
            {
                byte[] strByte = Encoding.GetEncoding("ks_c_5601-1987").GetBytes(strTemp);

                if (this.FlagSerialDll == false)
                    this.smartSerialPort4.WriteNoneFrame(strByte);
                else
                    SerialMgrComm.serialPortMessageByte("COM4:", strByte, strByte.Length);
            }
            else
            {
                if (this.FlagSerialDll == false)
                    this.smartSerialPort4.WriteNoneFrame(strTemp, SmartSerialPort.CODETYPES.ASCIICODE);
                else
                    SerialMgrComm.serialPortMessageRaw("COM4:", strTemp);
            }
        }
        public void TransferDirectSerialCOM4(byte[] buffer)
        {
            if (this.FlagSerialDll == false)
                this.smartSerialPort4.WriteNoneFrame(buffer);
            else
                SerialMgrComm.serialPortMessageByte("COM4:", buffer, buffer.Length);
        }
        public void TransferSerialCOM4(string strTemp)
        {
            if (this.SystemConfig1.TransmissionDelayTimeCOM4 == 0)
            {
                if (this.SystemConfig1.SerialCOM4Mode == 3 && this.SystemConfig1.StatisticsPrintFormat == 1)
                {
                    byte[] strByte = Encoding.GetEncoding("ks_c_5601-1987").GetBytes(strTemp);

                    if (this.FlagSerialDll == false)
                        this.smartSerialPort4.WriteNoneFrame(strByte);
                    else
                        SerialMgrComm.serialPortMessageByte("COM4:", strByte, strByte.Length);
                }
                else
                {
                    if (this.FlagSerialDll == false)
                        this.smartSerialPort4.WriteNoneFrame(strTemp, SmartSerialPort.CODETYPES.ASCIICODE);
                    else
                        SerialMgrComm.serialPortMessageRaw("COM4:", strTemp);
                }
            }
            else
            {
                this.QueueCOM4.Enqueue(strTemp);
                this.CreateTimer(Define.E_MenuBottomConfiguration.SerialCOM4);
            }
        }
        public void TransferSerialCOM4(byte[] buffer)
        {
            if (this.SystemConfig1.TransmissionDelayTimeCOM4 == 0)
            {
                if (this.FlagSerialDll == false)
                    this.smartSerialPort4.WriteNoneFrame(buffer);
                else
                    SerialMgrComm.serialPortMessageByte("COM4:", buffer, buffer.Length);
            }
            else
            {
                this.QueueCOM4.Enqueue(buffer);
                this.CreateTimer(Define.E_MenuBottomConfiguration.SerialCOM4);
            }
        }
        public void ChangeSerialCOM4FrameSeparateType(Define.E_SeparateType type)
        {
            if (this.FlagSerialDll == true)
                return;

            // 통신 포트 설정
            this.CloseSerialCOM4();

            if (type == Define.E_SeparateType.ETXONLY)
            {
                this.smartSerialPort4.FrameSeparationType = SmartSerialPort.FRAMESEPARATIONTYPES.ETXONLY;

                byte[] etxCodes = new byte[2];
                etxCodes[0] = 13;
                etxCodes[1] = 10;
                this.smartSerialPort4.ETXCodes = etxCodes;
            }
            else if (type == Define.E_SeparateType.STXANDETX)
            {
                this.smartSerialPort4.FrameSeparationType = SmartSerialPort.FRAMESEPARATIONTYPES.STXANDETX;

                this.smartSerialPort4.STXCode = 2;
                this.smartSerialPort4.ETXCode = 3;
            }
            else if (type == Define.E_SeparateType.NONEFRAME_READTIMEOUT)
            {
                this.smartSerialPort4.FrameSeparationType = SmartSerialPort.FRAMESEPARATIONTYPES.NONEFRAME_READTIMEOUT;
                this.smartSerialPort4.ReadTimeout = 300;
            }
            else
            {
                this.smartSerialPort4.FrameSeparationType = SmartSerialPort.FRAMESEPARATIONTYPES.STXONLY;
                this.smartSerialPort4.STXCode = 2;
            }

            this.smartSerialPort4.Open();
        }
        #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;
        }

        /// <summary>
        /// OPC, Modbus - 항목 업데이트 시마다 +1
        /// </summary>
        public void Update30000ModbusItem()
        {
            if (this.IsOPCModbusUsing == false)
                return;

            if (this.UpdateValue > 999999999)
                this.UpdateValue = 0;
            else
                this.UpdateValue++;

            this.Current30000ModbusData.IsUpdate = this.UpdateValue;
            this.Current30000ModbusData.EquipmentID = this.SystemConfig1.EquipmentID;
            this.Current30000ModbusData.ProductNo = this.SystemConfig1.ProductNumber;

            this.Current30000ModbusData.UnderValueFloat = Helper.StringToWeight(this.CurrentProductItem.UnderRange, this.SystemConfig1.DecimalPlaces);
            this.Current30000ModbusData.PassValueFloat = Helper.StringToWeight(this.CurrentProductItem.PassRange, this.SystemConfig1.DecimalPlaces);
            this.Current30000ModbusData.OverValueFloat = Helper.StringToWeight(this.CurrentProductItem.OverRange, this.SystemConfig1.DecimalPlaces);
            this.Current30000ModbusData.TareValueFloat = Helper.StringToWeight(this.CurrentProductItem.TareRange, this.SystemConfig1.DecimalPlaces);

            this.Current30000ModbusData.UnderCount = (UInt32)this.CurrentWeightData.UnderCount;
            this.Current30000ModbusData.PassCount = (UInt32)this.CurrentWeightData.PassCount;
            this.Current30000ModbusData.OverCount = (UInt32)this.CurrentWeightData.OverCount;
            this.Current30000ModbusData.NGCount = (UInt32)this.CurrentWeightData.UnderCount + (UInt32)this.CurrentWeightData.OverCount;
            this.Current30000ModbusData.ExNGCount = (UInt32)this.CurrentWeightData.ExNGCount;
            this.Current30000ModbusData.TotalCount = (UInt32)this.CurrentWeightData.TotalCount;

            switch (this.CurrentWeightData.JudgmentStatus)
            {
                case Define.E_JudgmentStatus.Over:
                    this.Current30000ModbusData.Grade = 0;
                    break;
                case Define.E_JudgmentStatus.Pass:
                    this.Current30000ModbusData.Grade = 1;
                    break;
                case Define.E_JudgmentStatus.Under:
                    this.Current30000ModbusData.Grade = 2;
                    break;
                case Define.E_JudgmentStatus.Metal:
                    this.Current30000ModbusData.Grade = 3;
                    break;
                case Define.E_JudgmentStatus.Double:
                    this.Current30000ModbusData.Grade = 4;
                    break;
                default:
                    this.Current30000ModbusData.Grade = 5;
                    break;
            }

            if (this.CurrentSystemStatus.Equipment == Define.E_EquipmentStatus.Start)
            {
                this.Current30000ModbusData.WeightFloat = this.CurrentWeightData.Weight;
                this.Current30000ModbusData.OperationStatus = 1;
            }
            else
            {
                this.Current30000ModbusData.WeightFloat = 0.0;
                this.Current30000ModbusData.OperationStatus = 0;
            }

            if (this.IsAlarmOccured == true)
                this.Current30000ModbusData.AlarmStatus = 1;
            else
                this.Current30000ModbusData.AlarmStatus = 0;

            if (this.CurrentWeightData.ProductionSpeed <= 500)
                this.Current30000ModbusData.Speed = this.CurrentWeightData.ProductionSpeed;
            this.Current30000ModbusData.MetalDetectionCount = (UInt32)this.CurrentWeightData.MetalDetectionCount;
            this.Current30000ModbusData.DoubleEntryCount = (UInt32)this.CurrentWeightData.DoubleEntryCount;

            try
            {
                byte[] productName = new UTF8Encoding().GetBytes(this.CurrentProductItem.Name);
                if (productName.Length > 20)
                {
                    for (int i = 0; i < 20; i++)
                        this.Current30000ModbusData.ProductName[i] = productName[i];
                }
                else
                {
                    for (int i = 0; i < productName.Length; i++)
                        this.Current30000ModbusData.ProductName[i] = productName[i];
                    for (int i = productName.Length; i < 20; i++)
                        this.Current30000ModbusData.ProductName[i] = 0x20;
                }

                // 로그
                //if (this.IsCommunicationLogOpen == true)
                //{
                //    this.smartFileCommunicationLog.WriteString(string.Format("Update30000ModbusItem ({0:yyyy-MM-dd HH:mm:ss}): {1}, {2}", DateTime.Now, BitConverter.ToString(productName), productName.Length));
                //}
            }
            catch
            {
                byte[] productName = new UTF8Encoding().GetBytes(this.SystemConfig1.ProductNumber.ToString() + "_Name");
                for (int i = 0; i < productName.Length; i++)
                    this.Current30000ModbusData.ProductName[i] = productName[i];
                for (int i = productName.Length; i < 20; i++)
                    this.Current30000ModbusData.ProductName[i] = 0x20;
            }

            this.Current30000ModbusData.UnderValueInt = this.CurrentProductItem.UnderRangeInt;
            this.Current30000ModbusData.PassValueInt = this.CurrentProductItem.PassRangeInt;
            this.Current30000ModbusData.OverValueInt = this.CurrentProductItem.OverRangeInt;
            this.Current30000ModbusData.TareValueInt = this.CurrentProductItem.TareRangeInt;

            int tempWeight = 0;
            string removeMinus = "";
            if (this.CurrentWeightData.WeightString.StartsWith("-") == true)
            {
                removeMinus = this.CurrentWeightData.WeightString.Replace("-", "");
                tempWeight = int.Parse(removeMinus);
                tempWeight *= -1;
            }
            else
                tempWeight = int.Parse(this.CurrentWeightData.WeightString);

            this.Current30000ModbusData.WeightInt = tempWeight;

            this.ChildFormMainDisplay.MainModbus.UpdateData(this.Current30000ModbusData);
        }
        public void Update39000ModbusAlarmItem()
        {

        }
        /// <summary>
        /// Modbus RTU - Write Multiple Register에 대한 Manage 메소드
        /// </summary>
        /// <param name="readByte">전송받은 Modbus Data</param>
        public void ReceiveModbusRTUWriteManager(byte[] readByte)
        {
            int startAddressInt;
            int numberOfRegisterInt;
            float floatNum;
            byte[] startAddressByte = new byte[2] { readByte[2], readByte[3] };
            byte[] numberOfRegisterByte = new byte[2] { readByte[4], readByte[5] };

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

            try
            {
                for (int j = startAddressInt; j < startAddressInt + numberOfRegisterInt; j++)
                {
                    switch (j)
                    {
                        #region Change data
                        case _40000_ModbusAddress._01_Clear:
                            #region 40011_소거 요청
                            for (int i = 0; i < 2; i++)
                                Length2Value[i] = readByte[7 + 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;
                                }
                                catch
                                {
                                    // 실패
                                    this.Current40000ModbusData._40012_ClearResult = 2;
                                }
                            }
                            #endregion
                            break;
                        case _40000_ModbusAddress._02_ClearResult:
                            #region 40012_소거 요청 결과
                            for (int i = 0; i < 2; i++)
                                Length2Value[i] = readByte[7 + madeDataIndex + i];
                            this.Current40000ModbusData._40012_ClearResult = Modbus.ToBigEndianAndInt(Length2Value);
                            #endregion
                            break;
                        case _40000_ModbusAddress._03_Operation:
                            #region 40013_운전/정지 요청, 1:운전/2:정지
                            for (int i = 0; i < 2; i++)
                                Length2Value[i] = readByte[7 + 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);
                                    }
                                    else
                                    {
                                        this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
                                    }

                                    this.Current40000ModbusData._40013_Operation = 0;

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

                            if (this.Current40000ModbusData._40015_ProductChange != 0)
                            {
                                try
                                {
                                    if (this.CurrentSystemStatus.Equipment == Define.E_EquipmentStatus.Stop)
                                    {
                                        if (this.Current40000ModbusData._40015_ProductChange >= 1
                                            && this.Current40000ModbusData._40015_ProductChange <= 1000)
                                            this.ChildFormMainDisplay.ChangeProductNumber(this.Current40000ModbusData._40015_ProductChange);

                                        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 _40000_ModbusAddress._07_ProductChangeResult:
                            #region 40017_품번 변경 요청 수행 결과
                            for (int i = 0; i < 2; i++)
                                Length2Value[i] = readByte[7 + madeDataIndex + i];
                            this.Current40000ModbusData._40017_ProductChangeResult = Modbus.ToBigEndianAndInt(Length2Value);
                            #endregion
                            break;
                        case _40000_ModbusAddress._08_UnderRange_High:
                            #region 40018_Under 중량설정 요청
                            for (int i = 0; i < 4; i++)
                                Length4Value[i] = readByte[7 + madeDataIndex + i];
                            floatNum = Modbus.ToBigEndianAndFloat(Length4Value);
                            this.Current40000ModbusData._40018_UnderRange =
                                int.Parse(Helper.DoubleToString((double)floatNum, this.SystemConfig1.DecimalPlaces).Replace(".", ""));

                            if (this.Current40000ModbusData._40018_UnderRange >= 0 && this.Current40000ModbusData._40018_UnderRange <= 99999)
                            {
                                try
                                {
                                    this.CurrentProductItem.UnderRange = this.Current40000ModbusData._40018_UnderRange.ToString();

                                    this.SaveProductFile(this.CurrentProductItem, this.SystemConfig1.ProductNumber - 1);
                                    this.TransferCurrentProductItem(this.CurrentProductItem);

                                    this.Update30000ModbusItem();
                                    this.UpdateScreen();

                                    // 초기값으로 설정해놓기
                                    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 _40000_ModbusAddress._10_UnderRangeResult:
                            #region 40020_Under 중량설정 요청 수행 결과
                            for (int i = 0; i < 2; i++)
                                Length2Value[i] = readByte[7 + madeDataIndex + i];
                            this.Current40000ModbusData._40020_UnderRangeResult = Modbus.ToBigEndianAndInt(Length2Value);
                            #endregion
                            break;
                        case _40000_ModbusAddress._11_PassRange_High:
                            #region 40021_Pass 중량설정 요청
                            for (int i = 0; i < 4; i++)
                                Length4Value[i] = readByte[7 + madeDataIndex + i];
                            floatNum = Modbus.ToBigEndianAndFloat(Length4Value);
                            this.Current40000ModbusData._40021_PassRange =
                                int.Parse(Helper.DoubleToString((double)floatNum, this.SystemConfig1.DecimalPlaces).Replace(".", ""));

                            if (this.Current40000ModbusData._40021_PassRange >= 0 && this.Current40000ModbusData._40021_PassRange <= 99999)
                            {
                                try
                                {
                                    string value = "";
                                    int digit = 0, temp = 0;
                                    int oldUnderRangeDeviation = this.CurrentProductItem.UnderRangeDeviation;
                                    int oldOverRangeDeviation = this.CurrentProductItem.OverRangeDeviation;

                                    this.CurrentProductItem.PassRange = this.Current40000ModbusData._40021_PassRange.ToString();

                                    #region UnderRange
                                    temp = this.CurrentProductItem.PassRangeInt + oldUnderRangeDeviation;
                                    if (temp < 0)
                                        value = "0";
                                    else
                                        value = temp.ToString();

                                    this.CurrentProductItem.UnderRange = value;
                                    #endregion

                                    #region OverRange
                                    temp = this.CurrentProductItem.PassRangeInt + oldOverRangeDeviation;
                                    if (temp > 99999)
                                        value = "99999";
                                    else
                                        value = temp.ToString();

                                    this.CurrentProductItem.OverRange = value;
                                    #endregion

                                    this.SaveProductFile(this.CurrentProductItem, this.SystemConfig1.ProductNumber - 1);
                                    this.TransferCurrentProductItem(this.CurrentProductItem);

                                    this.Update30000ModbusItem();
                                    this.UpdateScreen();

                                    // 초기값으로 설정해놓기
                                    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 _40000_ModbusAddress._13_PassRangeResult:
                            #region 40023_Pass 중량설정 요청 수행 결과
                            for (int i = 0; i < 2; i++)
                                Length2Value[i] = readByte[7 + madeDataIndex + i];
                            this.Current40000ModbusData._40023_PassRangeResult = Modbus.ToBigEndianAndInt(Length2Value);
                            #endregion
                            break;
                        case _40000_ModbusAddress._14_OverRange_High:
                            #region 40024_Over 중량설정 요청
                            for (int i = 0; i < 4; i++)
                                Length4Value[i] = readByte[7 + madeDataIndex + i];
                            floatNum = Modbus.ToBigEndianAndFloat(Length4Value);
                            this.Current40000ModbusData._40024_OverRange =
                                int.Parse(Helper.DoubleToString((double)floatNum, this.SystemConfig1.DecimalPlaces).Replace(".", ""));

                            if (this.Current40000ModbusData._40024_OverRange >= 0 && this.Current40000ModbusData._40024_OverRange <= 99999)
                            {
                                try
                                {
                                    this.CurrentProductItem.OverRange = this.Current40000ModbusData._40024_OverRange.ToString();

                                    this.SaveProductFile(this.CurrentProductItem, this.SystemConfig1.ProductNumber - 1);
                                    this.TransferCurrentProductItem(this.CurrentProductItem);

                                    this.Update30000ModbusItem();
                                    this.UpdateScreen();

                                    // 초기값으로 설정해놓기
                                    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 _40000_ModbusAddress._16_OverRangeResult:
                            #region 40026_Over 중량설정 요청 수행 결과
                            for (int i = 0; i < 2; i++)
                                Length2Value[i] = readByte[7 + madeDataIndex + i];
                            this.Current40000ModbusData._40026_OverRangeResult = Modbus.ToBigEndianAndInt(Length2Value);
                            #endregion
                            break;
                        case _40000_ModbusAddress._17_TareWeight_High:
                            #region 40027_Tare 중량설정 요청
                            for (int i = 0; i < 4; i++)
                                Length4Value[i] = readByte[7 + madeDataIndex + i];
                            floatNum = Modbus.ToBigEndianAndFloat(Length4Value);
                            this.Current40000ModbusData._40027_TareWeight =
                                int.Parse(Helper.DoubleToString((double)floatNum, this.SystemConfig1.DecimalPlaces).Replace(".", ""));

                            if (this.Current40000ModbusData._40027_TareWeight >= 0 && this.Current40000ModbusData._40027_TareWeight <= 99999)
                            {
                                try
                                {
                                    this.CurrentProductItem.TareRange = this.Current40000ModbusData._40027_TareWeight.ToString();

                                    this.SaveProductFile(this.CurrentProductItem, this.SystemConfig1.ProductNumber - 1);
                                    this.TransferCurrentProductItem(this.CurrentProductItem);

                                    this.Update30000ModbusItem();
                                    this.UpdateScreen();

                                    // 초기값으로 설정해놓기
                                    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 _40000_ModbusAddress._19_TareWeightResult:
                            #region 40029_Tare 중량설정 요청 수행 결과
                            for (int i = 0; i < 2; i++)
                                Length2Value[i] = readByte[7 + madeDataIndex + i];
                            this.Current40000ModbusData._40029_TareWeightResult = Modbus.ToBigEndianAndInt(Length2Value);
                            #endregion
                            break;
                        default:
                            break;
                        #endregion
                    }
                    madeDataIndex += 2;
                }
            }
            catch
            {

            }
        }
        /// <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 _40000_ModbusAddress._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;
                            }
                            catch
                            {
                                // 실패
                                this.Current40000ModbusData._40012_ClearResult = 2;
                            }
                        }
                        #endregion
                        break;
                    case _40000_ModbusAddress._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 _40000_ModbusAddress._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);
                                }
                                else
                                {
                                    this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
                                }

                                this.Current40000ModbusData._40013_Operation = 0;

                                // 성공
                                this.Current40000ModbusData._40014_OperationResult = 1;
                            }
                            catch
                            {
                                // 실패
                                this.Current40000ModbusData._40014_OperationResult = 2;
                            }
                        }
                        #endregion
                        break;
                    case _40000_ModbusAddress._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 _40000_ModbusAddress._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.CurrentSystemStatus.Equipment == Define.E_EquipmentStatus.Stop)
                                {
                                    if (this.Current40000ModbusData._40015_ProductChange >= 1
                                        && this.Current40000ModbusData._40015_ProductChange <= 1000)
                                        this.ChildFormMainDisplay.ChangeProductNumber(this.Current40000ModbusData._40015_ProductChange);

                                    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 _40000_ModbusAddress._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 _40000_ModbusAddress._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.SystemConfig1.DecimalPlaces).Replace(".", ""));

                        if (this.Current40000ModbusData._40018_UnderRange >= 0 && this.Current40000ModbusData._40018_UnderRange <= 99999)
                        {
                            try
                            {
                                this.CurrentProductItem.UnderRange = this.Current40000ModbusData._40018_UnderRange.ToString();

                                this.SaveProductFile(this.CurrentProductItem, this.SystemConfig1.ProductNumber - 1);
                                this.TransferCurrentProductItem(this.CurrentProductItem);

                                this.Update30000ModbusItem();
                                this.UpdateScreen();

                                // 초기값으로 설정해놓기
                                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 _40000_ModbusAddress._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 _40000_ModbusAddress._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.SystemConfig1.DecimalPlaces).Replace(".", ""));

                        if (this.Current40000ModbusData._40021_PassRange >= 0 && this.Current40000ModbusData._40021_PassRange <= 99999)
                        {
                            try
                            {
                                string value = "";
                                int digit = 0, temp = 0;
                                int oldUnderRangeDeviation = this.CurrentProductItem.UnderRangeDeviation;
                                int oldOverRangeDeviation = this.CurrentProductItem.OverRangeDeviation;

                                this.CurrentProductItem.PassRange = this.Current40000ModbusData._40021_PassRange.ToString();

                                #region UnderRange
                                temp = this.CurrentProductItem.PassRangeInt + oldUnderRangeDeviation;
                                if (temp < 0)
                                    value = "0";
                                else
                                    value = temp.ToString();

                                this.CurrentProductItem.UnderRange = value;
                                #endregion

                                #region OverRange
                                temp = this.CurrentProductItem.PassRangeInt + oldOverRangeDeviation;
                                if (temp > 99999)
                                    value = "99999";
                                else
                                    value = temp.ToString();

                                this.CurrentProductItem.OverRange = value;
                                #endregion

                                this.SaveProductFile(this.CurrentProductItem, this.SystemConfig1.ProductNumber - 1);
                                this.TransferCurrentProductItem(this.CurrentProductItem);

                                this.Update30000ModbusItem();
                                this.UpdateScreen();

                                // 초기값으로 설정해놓기
                                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 _40000_ModbusAddress._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 _40000_ModbusAddress._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.SystemConfig1.DecimalPlaces).Replace(".", ""));

                        if (this.Current40000ModbusData._40024_OverRange >= 0 && this.Current40000ModbusData._40024_OverRange <= 99999)
                        {
                            try
                            {
                                this.CurrentProductItem.OverRange = this.Current40000ModbusData._40024_OverRange.ToString();

                                this.SaveProductFile(this.CurrentProductItem, this.SystemConfig1.ProductNumber - 1);
                                this.TransferCurrentProductItem(this.CurrentProductItem);

                                this.Update30000ModbusItem();
                                this.UpdateScreen();

                                // 초기값으로 설정해놓기
                                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 _40000_ModbusAddress._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 _40000_ModbusAddress._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.SystemConfig1.DecimalPlaces).Replace(".", ""));

                        if (this.Current40000ModbusData._40027_TareWeight >= 0 && this.Current40000ModbusData._40027_TareWeight <= 99999)
                        {
                            try
                            {
                                this.CurrentProductItem.TareRange = this.Current40000ModbusData._40027_TareWeight.ToString();

                                this.SaveProductFile(this.CurrentProductItem, this.SystemConfig1.ProductNumber - 1);
                                this.TransferCurrentProductItem(this.CurrentProductItem);

                                this.Update30000ModbusItem();
                                this.UpdateScreen();

                                // 초기값으로 설정해놓기
                                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 _40000_ModbusAddress._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 Ethernet
        public void IsUsingTimerEthernetPing(bool bValue)
        {
            //if (this.SystemConfig2.IsDisconnectDetection == true)
            //{
            //    this.timerEthernetPing.Enabled = bValue;
            //}
            //else
            //    this.timerEthernetPing.Enabled = false;
        }

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

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

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

                cpClientThread.IsBackground = true;

                cpClientThread.Start();

                //this.IsUsingTimerEthernetPing(true);
            }
            catch
            {
                TextStatusOut(">Thread Error");
            }
        }
        public void EthernetClientDisconnect()
        {
            this.IsUsingTimerEthernetPing(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();

            this.IsEthernetThreadStop = true;
            this.DelegateTextStatusOut(">Disconnected");

            if (this.CurrentSystemStatus.Equipment == Define.E_EquipmentStatus.Start
                && this.CurrentSystemStatus.CurrentDisplay == Define.E_DisplayStore.MainDisplay)
                this.DelegateTimerTryConnect(true);
        }

        private void EthernetClientReceiveThread()
        {
            int nConnectPort = Convert.ToInt32(this.SystemConfig2.EthernetPort);
            try
            {
                this.DelegateTextStatusOut(">Now Connecting..");
                this.EthernetTcpClient = new TcpClient(this.SystemConfig2.EthernetAddress, nConnectPort);

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

                this.DelegateUISeverStatus(true);
                this.DelegateTextStatusOut(">Connected Server");
                this.SetTrackingHistoryData(Define.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.IsEthernetThreadStop = true;
                        break;
                    }

                    this.DelegateTextStatusOut(strRecvMsg);
                }
            }
            catch
            {
                this.DelegateTextStatusOut(">Connect Fail !");
            }
            finally
            {
                this.EthernetClientDisconnect();
            }

            return;
        }

        private void UIServerStatus(bool status)
        {
            this.ChildFormMainDisplay.UpdateEthernetStatusDisplay(status);
        }
        public void DelegateUISeverStatus(bool status)
        {
            this.Invoke(new UIServerStatusCallback(this.UIServerStatus), status);
        }

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

        private void TimerTryConnect(bool status)
        {
            this.timerClientTryConnect.Enabled = status;
        }
        private void DelegateTimerTryConnect(bool status)
        {
            this.Invoke(new TimerTryConnectCallback(this.TimerTryConnect), status);
        }

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

                if (this.IsCommunicationLogOpen == true)
                    this.smartFileCommunicationLog.WriteString(string.Format("EthernetSendMessage Send string ({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("EthernetSendMessage Send byte[] ({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.Write(msg);
                this.EthernetStmWriter.Flush();

                if (this.IsCommunicationLogOpen == true)
                    this.smartFileCommunicationLog.WriteString(string.Format("EthernetSendMessage Send byte ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, msg));
            }
            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[] bytes)
        {
            this.IsEthernetTransferData = true;
            this.EthernetTransferData = bytes;

            if (this.IsEthernetThreadStop == true)
                this.EthernetClientConnect();
            else
            {
                this.EthernetSendMessage((byte[])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

        #region Server
        public void EthernetServerStart()
        {
            if (this.smartTCPMultiServer.IsStart == false)
            {
                this.IsUsingTimerEthernetPing(true);
                this.ChildFormMenu.CenterConfiEthernet.DisplayLabelLocalPort(false);
                this.smartTCPMultiServer.Port = this.SystemConfig2.EthernetLocalPort;
                this.smartTCPMultiServer.Start();
            }
        }
        public void EthernetServerStop()
        {
            if (this.smartTCPMultiServer.IsStart == true)
            {
                this.IsUsingTimerEthernetPing(false);
                this.ChildFormMenu.CenterConfiEthernet.DisplayLabelLocalPort(true);
                this.smartTCPMultiServer.Stop();
            }
        }
        public void EthernetServerSendMessage(SmartTCPMultiServer.CLIENTSINFOS client, string msg)
        {
            if (this.smartTCPMultiServer.SendStringASCIIID(client.strID, msg) == true)
            {
                // 로그
                if (this.IsCommunicationLogOpen == true)
                    this.smartFileCommunicationLog.WriteString(string.Format("Ethernet Send ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, msg));
            }
        }
        public void EthernetServerSendMessage(SmartTCPMultiServer.CLIENTSINFOS client, byte[] bytes)
        {
            if (this.smartTCPMultiServer.SendByteByClientID(client.strID, bytes) == true)
            {
                // 로그
                if (this.IsCommunicationLogOpen == true)
                    this.smartFileCommunicationLog.WriteString(string.Format("Ethernet Send ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, Encoding.Default.GetString(bytes, 0, bytes.Length)));
            }
        }
        #endregion

        #endregion

        #region Alarm
        public void ClearAlarm(int clearAlarm)
        {
            // 0:모두 1:알람1 2:알람2
            if (clearAlarm == 1)
                this.CountingOutput1Count = 0;
            else if (clearAlarm == 2)
                this.CountingOutput2Count = 0;
            else
            {
                this.CountingOutput1Count = 0;
                this.CountingOutput2Count = 0;
            }

            this.ChildFormMainDisplay.MainWeightBigScreen.UpdateAlarmLabelDisplay(this.CountingOutput1Count, this.CountingOutput2Count);
            this.ChildFormMainDisplay.MainWeightSmall.UpdateAlarmLabelDisplay(this.CountingOutput1Count, this.CountingOutput2Count);
        }
        #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, Define.E_DataType type)
        {
            string dataFolderPath = "";

            switch (type)
            {
                case Define.E_DataType.None:
                    break;
                case Define.E_DataType.History:
                    dataFolderPath = this.PathDataHistoryFolder;
                    break;
                case Define.E_DataType.Inspection:
                    dataFolderPath = this.PathDataInspectionFolder;
                    break;
                case Define.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.SystemConfig3.StoragePeriod))
                    fi.Delete();
            }
        }
        #endregion
        #region Tracking Inspection data
        private void GetTrackingInspectionFolderPath(ref string folder, ref string fileName)
        {
            DateTime time = DateTime.Now;

            folder = string.Format("{0}{1}\\{2}\\", this.PathDataInspectionFolder, time.Year, time.Month);
            if (Directory.Exists(folder) == false)
                Directory.CreateDirectory(folder);
            fileName = string.Format("I{0:yyyyMMdd}-{1}.csv", time, this.CurrentProductItem.Number);
        }

        /// <summary>
        /// DataBackup Format - STD1
        /// </summary>
        /// <param name="item"></param>
        public void TrackingInspectionData0(WeightData item)
        {
            bool fileCheck = false, directoryCheck = false;
            string fullFilePath = "", folderPath = "", fileName = "";
            string filePathExtension = "";
            StreamWriter sw;
            DateTime time = DateTime.Now;

            if (this.SystemConfig2.FileNameExtension == 0)
                filePathExtension = ".csv";
            else
                filePathExtension = ".txt";

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

            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");
                sw.Write(",");
                sw.Write("Weight");
                sw.Write(",");
                sw.Write("Grade");
                sw.WriteLine();
            }

            sw.Write(string.Format("{0:yyyy-MM-dd}", time));
            sw.Write(",");
            sw.Write(string.Format("{0:HH:mm:ss}", time));
            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.SystemConfig1.DecimalPlaces));
            sw.Write(",");
            sw.Write(Helper.StringToDecimalPlaces(this.CurrentProductItem.PassRange, this.SystemConfig1.DecimalPlaces));
            sw.Write(",");
            sw.Write(Helper.StringToDecimalPlaces(this.CurrentProductItem.OverRange, this.SystemConfig1.DecimalPlaces));
            sw.Write(",");
            sw.Write(Helper.StringToDecimalPlaces(this.CurrentProductItem.TareRange, this.SystemConfig1.DecimalPlaces));
            sw.Write(",");
            if (item.Weight == this.OverloadWeight)
                sw.Write("O.L");
            else
                sw.Write(Helper.DoubleToString(item.Weight, this.SystemConfig1.DecimalPlaces));
            sw.Write(",");
            sw.Write(item.JudgmentStatus);
            sw.WriteLine();

            sw.Close();
        }
        /// <summary>
        /// DataBackup Format - OPT1(종근당)
        /// </summary>
        /// <param name="item"></param>
        public void TrackingInspectionData1(DataBackupOPT1 item)
        {
            bool fileCheck = false, directoryCheck = false;
            string fullFilePath = "", folderPath = "", fileName = "";
            string filePathExtension = "";
            StreamWriter sw;
            DateTime time = DateTime.Now;

            if (this.SystemConfig2.FileNameExtension == 0)
                filePathExtension = ".csv";
            else
                filePathExtension = ".txt";

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

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

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

            // 제품명, LOT번호, 상한설정값, 하한설정값, 중량, 날짜, 시간, Pass수량, Grade, Status
            if (fileCheck == false)
            {
                this.RemoveInspectionDataFile();

                sw.Write("Name");
                sw.Write(",");
                sw.Write("LOT");
                sw.Write(",");
                sw.Write("OverRange");
                sw.Write(",");
                sw.Write("UnderRange");
                sw.Write(",");
                sw.Write("Weight");
                sw.Write(",");
                sw.Write("Date");
                sw.Write(",");
                sw.Write("Time");
                sw.Write(",");
                sw.Write("Pass Count");
                sw.Write(",");
                sw.Write("Grade");
                sw.Write(",");
                sw.Write("Status");
                sw.WriteLine();
            }

            sw.Write(item.Name);
            sw.Write(",");
            sw.Write(item.Lot);
            sw.Write(",");
            sw.Write(item.OverRange);
            sw.Write(",");
            sw.Write(item.UnderRange);
            sw.Write(",");
            if (double.Parse(item.Weight) == this.OverloadWeight)
                sw.Write("O.L");
            else
                sw.Write(item.Weight);
            sw.Write(",");
            sw.Write(item.Date);
            sw.Write(",");
            sw.Write(item.Time);
            sw.Write(",");
            sw.Write(item.PassCount);
            sw.Write(",");
            sw.Write(item.Grade);
            sw.Write(",");
            sw.Write(item.Status);

            sw.WriteLine();
            sw.Close();
        }
        private void RemoveInspectionDataFile()
        {
            try
            {
                this.DeleteLogFile(this.PathDataInspectionFolder, Define.E_DataType.Inspection);
            }
            catch
            {

            }
        }
        #endregion
        #region Tracking History data
        private void GetTrackingHistoryFolderPath(ref string folder, ref string fileName)
        {
            DateTime time = DateTime.Now;

            folder = string.Format("{0}{1}\\{2}\\", this.PathDataHistoryFolder, time.Year, time.Month);
            if (Directory.Exists(folder) == false)
                Directory.CreateDirectory(folder);
            fileName = string.Format("H{0:yyyyMMdd}.csv", time);
        }

        public void SetTrackingHistoryData(Define.E_TrackingOperation eventType, string detail)
        {
            HistoryData data = new HistoryData();

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

            this.TrackingHistoryData(data);
        }
        public void SetTrackingHistoryData(Define.E_TrackingOperation eventType, string detail, string loginID)
        {
            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(Define.E_TrackingAlarm eventType, string detail)
        {
            HistoryData data = new HistoryData();

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

            this.TrackingHistoryData(data);
        }
        public void SetTrackingHistoryData(Define.E_TrackingParameter eventType, string detail, string before, string after)
        {
            HistoryData data = new HistoryData();

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

            this.TrackingHistoryData(data);
        }

        private void TrackingHistoryData(HistoryData data)
        {
            if (this.IsLogProcessing == true)
                return;

            bool fileCheck = false, directoryCheck = false;
            string fullFilePath = "", folderPath = "", fileName = "";
            StreamWriter sw;
            DateTime time = DateTime.Now;

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

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

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

            try
            {
                if (fileCheck == false)
                {
                    this.RemoveHistoryDataFile();
                    this.RemoveOthersDataFile();

                    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();
            }
            catch
            {

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

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

            }
        }
        #endregion

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

            this.SystemConfig1.Initialization();

            structItem.DummyBool1 = false;
            structItem.IsLogin = this.SystemConfig1.IsLogin;

            structItem.EquipmentID = this.SystemConfig1.EquipmentID;
            structItem.DecimalPlaces = this.SystemConfig1.DecimalPlaces;
            structItem.ProductNumber = this.SystemConfig1.ProductNumber;
            structItem.UsbID = this.SystemConfig1.UsbID;
            structItem.Serial1BaudRate = this.SystemConfig1.SerialCOM1BaudRate;
            structItem.Serial1Mode = this.SystemConfig1.SerialCOM1Mode;
            structItem.Serial2BaudRate = this.SystemConfig1.SerialCOM3BaudRate;
            structItem.Serial2Mode = this.SystemConfig1.SerialCOM3Mode;
            structItem.Serial3BaudRate = this.SystemConfig1.SerialCOM4BaudRate;
            structItem.Serial3Mode = this.SystemConfig1.SerialCOM4Mode;

            structItem.SerialNumber = this.SystemConfig1.SerialNumber;
            structItem.Language = this.SystemConfig1.Language;
            structItem.Unit = this.SystemConfig1.Unit;

            structItem.IsBLDCON = this.SystemConfig1.IsBLDCON;
            structItem.IsExternalInputLamp = this.SystemConfig1.IsExternalInputLamp;
            structItem.IsExternalInputBuzzer = this.SystemConfig1.IsExternalInputBuzzer;
            structItem.IsPrintPerProductEnable = this.SystemConfig1.IsPrintPerProductEnable;
            structItem.IsBarcodeEnable = this.SystemConfig1.IsBarcodeEnable;
            structItem.TransmissionDelayTimeCOM1 = this.SystemConfig1.TransmissionDelayTimeCOM1;
            structItem.TransmissionDelayTimeCOM3 = this.SystemConfig1.TransmissionDelayTimeCOM3;
            structItem.TransmissionDelayTimeCOM4 = this.SystemConfig1.TransmissionDelayTimeCOM4;
            structItem.StatisticsPrintFormat = this.SystemConfig1.StatisticsPrintFormat;
            structItem.DatabackupFormat = this.SystemConfig1.DatabackupFormat;
            structItem.DummyString1 = "0";
            structItem.UserDefineCOM1 = this.SystemConfig1.UserDefineCOM1;
            structItem.UserDefineCOM3 = this.SystemConfig1.UserDefineCOM3;
            structItem.UserDefineCOM4 = this.SystemConfig1.UserDefineCOM4;
            structItem.DummyString5 = "0";

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

            fullFilePath = this.PathSDCardSystemFile1Folder + "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.DummyBool1 = false;
            structItem.IsLogin = item.IsLogin;

            structItem.EquipmentID = item.EquipmentID;
            structItem.DecimalPlaces = item.DecimalPlaces;
            structItem.ProductNumber = item.ProductNumber;
            structItem.UsbID = item.UsbID;
            structItem.Serial1BaudRate = item.SerialCOM1BaudRate;
            structItem.Serial1Mode = item.SerialCOM1Mode;
            structItem.Serial2BaudRate = item.SerialCOM3BaudRate;
            structItem.Serial2Mode = item.SerialCOM3Mode;
            structItem.Serial3BaudRate = item.SerialCOM4BaudRate;
            structItem.Serial3Mode = item.SerialCOM4Mode;

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

            structItem.IsBLDCON = item.IsBLDCON;
            structItem.IsExternalInputLamp = item.IsExternalInputLamp;
            structItem.IsExternalInputBuzzer = item.IsExternalInputBuzzer;
            structItem.IsPrintPerProductEnable = item.IsPrintPerProductEnable;
            structItem.IsBarcodeEnable = item.IsBarcodeEnable;
            structItem.TransmissionDelayTimeCOM1 = item.TransmissionDelayTimeCOM1;
            structItem.TransmissionDelayTimeCOM3 = item.TransmissionDelayTimeCOM3;
            structItem.TransmissionDelayTimeCOM4 = item.TransmissionDelayTimeCOM4;
            structItem.StatisticsPrintFormat = item.StatisticsPrintFormat;
            structItem.DatabackupFormat = item.DatabackupFormat;
            structItem.DummyString1 = "0";
            structItem.UserDefineCOM1 = item.UserDefineCOM1;
            structItem.UserDefineCOM3 = item.UserDefineCOM3;
            structItem.UserDefineCOM4 = item.UserDefineCOM4;
            structItem.DummyString5 = "0";

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

            fullFilePath = this.PathSDCardSystemFile1Folder + "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.SystemConfig1.IsLogin = structItem.IsLogin;
                this.SystemConfig1.IsBarcodeEnable = structItem.IsBarcodeEnable;
                this.SystemConfig1.IsPrintPerProductEnable = structItem.IsPrintPerProductEnable;
                this.SystemConfig1.IsExternalInputBuzzer = structItem.IsExternalInputBuzzer;
                this.SystemConfig1.IsExternalInputLamp = structItem.IsExternalInputLamp;
                this.SystemConfig1.IsBLDCON = structItem.IsBLDCON;

                this.SystemConfig1.EquipmentID = structItem.EquipmentID;
                this.SystemConfig1.DecimalPlaces = structItem.DecimalPlaces;
                this.SystemConfig1.ProductNumber = structItem.ProductNumber;
                this.SystemConfig1.UsbID = structItem.UsbID;
                this.SystemConfig1.SerialCOM1BaudRate = structItem.Serial1BaudRate;
                this.SystemConfig1.SerialCOM1Mode = structItem.Serial1Mode;
                this.SystemConfig1.SerialCOM3BaudRate = structItem.Serial2BaudRate;
                this.SystemConfig1.SerialCOM3Mode = structItem.Serial2Mode;
                this.SystemConfig1.SerialCOM4BaudRate = structItem.Serial3BaudRate;
                this.SystemConfig1.SerialCOM4Mode = structItem.Serial3Mode;
                this.SystemConfig1.DatabackupFormat = structItem.DatabackupFormat;
                this.SystemConfig1.TransmissionDelayTimeCOM1 = structItem.TransmissionDelayTimeCOM1;
                this.SystemConfig1.TransmissionDelayTimeCOM3 = structItem.TransmissionDelayTimeCOM3;
                this.SystemConfig1.TransmissionDelayTimeCOM4 = structItem.TransmissionDelayTimeCOM4;
                this.SystemConfig1.StatisticsPrintFormat = structItem.StatisticsPrintFormat;

                this.SystemConfig1.SerialNumber = structItem.SerialNumber;
                this.SystemConfig1.Language = structItem.Language;
                this.SystemConfig1.Unit = structItem.Unit;
                this.SystemConfig1.UserDefineCOM1 = structItem.UserDefineCOM1;
                this.SystemConfig1.UserDefineCOM3 = structItem.UserDefineCOM3;
                this.SystemConfig1.UserDefineCOM4 = structItem.UserDefineCOM4;
            }
            catch
            {
                DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig1.Language);
                myMsg.ShowDialog();

                this.smartFileIO.Close();
            }

            this.smartFileIO.Close();
        }
        #endregion
        #region SystemConfiguration File2
        private void CreateSystemConfigurationFile2()
        {
            StructSystemConfigurationItem2 structItem;

            this.SystemConfig2.Initialization();

            structItem.Alarm1Mode = this.SystemConfig2.CountingOutput1Mode;
            structItem.Alarm1Number = this.SystemConfig2.CountingOutput1Number;
            structItem.IsAlarm1Continuous = this.SystemConfig2.IsCountingOutput1Continuous;
            structItem.IsAlarm1ConveyorStop = this.SystemConfig2.IsCountingOutput1ConveyorStop;
            structItem.IsAlarm1BuzzerOn = this.SystemConfig2.IsCountingOutput1BuzzerOn;
            structItem.IsAlarm1ExternalOutput = this.SystemConfig2.IsCountingOutput1ExternalOutput;

            structItem.Alarm2Mode = this.SystemConfig2.CountingOutput2Mode;
            structItem.Alarm2Number = this.SystemConfig2.CountingOutput2Number;
            structItem.IsAlarm2Continuous = this.SystemConfig2.IsCountingOutput2Continuous;
            structItem.IsAlarm2ConveyorStop = this.SystemConfig2.IsCountingOutput2ConveyorStop;
            structItem.IsAlarm2BuzzerOn = this.SystemConfig2.IsCountingOutput2BuzzerOn;
            structItem.IsAlarm2ExternalOutput = this.SystemConfig2.IsCountingOutput2ExternalOutput;

            structItem.IsDisconnectDetection = this.SystemConfig2.IsDisconnectDetection;
            structItem.IsCommunicationOption = this.SystemConfig2.IsCommunicationOption;
            structItem.IsBypassOnce = this.SystemConfig2.IsBypassOnce;
            structItem.IsBypassDirectionPass = this.SystemConfig2.IsBypassDirectionPass;
            structItem.IsHitachiBlankToNoneCOM4 = this.SystemConfig2.IsHitachiBlankToNoneCOM4;
            structItem.IsHitachiBlankToNoneCOM3 = this.SystemConfig2.IsHitachiBlankToNoneCOM3;
            structItem.IsHitachiBlankToNoneCOM1 = this.SystemConfig2.IsHitachiBlankToNoneCOM1;
            structItem.IsMarkoprintTodaytDatePrintEthernet = this.SystemConfig2.IsMarkoprintTodaytDatePrintEthernet;
            structItem.IsMarkoprintDatePrintEthernet = this.SystemConfig2.IsMarkoprintDatePrintEthernet;
            structItem.IsGroup1UsingRandomMode = this.SystemConfig2.IsGroup1UsingRandomMode;
            structItem.IsGroup2UsingRandomMode = this.SystemConfig2.IsGroup2UsingRandomMode;
            structItem.IsGroup3UsingRandomMode = this.SystemConfig2.IsGroup3UsingRandomMode;
            structItem.IsGroup4UsingRandomMode = this.SystemConfig2.IsGroup4UsingRandomMode;
            structItem.IsGroup5UsingRandomMode = this.SystemConfig2.IsGroup5UsingRandomMode;
            structItem.IsMarkoprintTodaytDatePrintCOM4 = this.SystemConfig2.IsMarkoprintTodaytDatePrintCOM4;
            structItem.IsMarkoprintDatePrintCOM4 = this.SystemConfig2.IsMarkoprintDatePrintCOM4;
            structItem.IsMarkoprintTodaytDatePrintCOM3 = this.SystemConfig2.IsMarkoprintTodaytDatePrintCOM3;
            structItem.IsMarkoprintDatePrintCOM3 = this.SystemConfig2.IsMarkoprintDatePrintCOM3;
            structItem.IsMarkoprintTodaytDatePrintCOM1 = this.SystemConfig2.IsMarkoprintTodaytDatePrintCOM1;
            structItem.IsMarkoprintDatePrintCOM1 = this.SystemConfig2.IsMarkoprintDatePrintCOM1;

            structItem.DummyInt1 = 0;
            structItem.DummyInt2 = 0;
            structItem.DummyInt3 = 0;
            structItem.UserAutomaticLogout = this.SystemConfig2.UserAutomaticLogout;
            structItem.ModbusTCPStartAddress = this.SystemConfig2.ModbusTCPStartAddress;
            structItem.ModbusRTUStartAddressCOM1 = this.SystemConfig2.ModbusRTUStartAddressCOM1;
            structItem.ModbusRTUStartAddressCOM3 = this.SystemConfig2.ModbusRTUStartAddressCOM3;
            structItem.ModbusRTUStartAddressCOM4 = this.SystemConfig2.ModbusRTUStartAddressCOM4;
            structItem.ModbusTCPSelectFunction = this.SystemConfig2.ModbusTCPSelectFunction;
            structItem.BLDCTotalMotorNum = this.SystemConfig2.BLDCTotalMotorNum;
            structItem.ModbusRTUSelectFunction = this.SystemConfig2.ModbusRTUSelectFunction;
            structItem.ModbusRTUSlaveIDCOM1 = this.SystemConfig2.ModbusSlaveIDCOM1;
            structItem.ModbusRTUSlaveIDCOM3 = this.SystemConfig2.ModbusSlaveIDCOM3;
            structItem.ModbusRTUSlaveIDCOM4 = this.SystemConfig2.ModbusSlaveIDCOM4;
            structItem.Barcode = this.SystemConfig2.Barcode;
            structItem.EthernetLocalPort = this.SystemConfig2.EthernetLocalPort;
            structItem.SortingPointLength = this.SystemConfig2.SortingPointLength;
            structItem.ConveyorLength = this.SystemConfig2.ConveyorLength;
            structItem.MarkoprintLineNumberEthernet = this.SystemConfig2.MarkoprintLineNumberEthernet;
            structItem.HitachiRoomNumberEthernet = this.SystemConfig2.HitachiRoomNumberEthernet;
            structItem.EthernetPort = this.SystemConfig2.EthernetPort;
            structItem.EthernetCommMode = this.SystemConfig2.EthernetCommMode;
            structItem.EthernetOperationMode = this.SystemConfig2.EthernetOperationMode;
            structItem.FileNameExtension = this.SystemConfig2.FileNameExtension;
            structItem.MarkoprintLineNumberCOM4 = this.SystemConfig2.MarkoprintLineNumberCOM4;
            structItem.HitachiRoomNumberCOM4 = this.SystemConfig2.HitachiRoomNumberCOM4;
            structItem.MarkoprintLineNumberCOM3 = this.SystemConfig2.MarkoprintLineNumberCOM3;
            structItem.HitachiRoomNumberCOM3 = this.SystemConfig2.HitachiRoomNumberCOM3;
            structItem.MarkoprintLineNumberCOM1 = this.SystemConfig2.MarkoprintLineNumberCOM1;
            structItem.HitachiRoomNumberCOM1 = this.SystemConfig2.HitachiRoomNumberCOM1;

            structItem.DummyString1 = "0";
            structItem.DummyString2 = "0";
            structItem.DummyString3 = "0";
            structItem.DummyString4 = "0";
            structItem.DummyString5 = "0";
            structItem.DummyString6 = "0";
            structItem.DummyString7 = "0";
            structItem.UserGroupLevel1Name = this.SystemConfig2.UserGroupLevel1Name;
            structItem.UserGroupLevel2Name = this.SystemConfig2.UserGroupLevel2Name;
            structItem.UserGroupLevel3Name = this.SystemConfig2.UserGroupLevel3Name;
            structItem.MarkoprintDateSettingEthernet = this.SystemConfig2.MarkoprintDateSettingEthernet;
            structItem.EthernetAddress = this.SystemConfig2.EthernetAddress;
            structItem.MarkoprintDateSettingCOM4 = this.SystemConfig2.MarkoprintDateSettingCOM4;
            structItem.MarkoprintDateSettingCOM3 = this.SystemConfig2.MarkoprintDateSettingCOM3;
            structItem.MarkoprintDateSettingCOM1 = this.SystemConfig2.MarkoprintDateSettingCOM1;

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

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

            structItem.Alarm1Mode = item.CountingOutput1Mode;
            structItem.Alarm1Number = item.CountingOutput1Number;
            structItem.IsAlarm1Continuous = item.IsCountingOutput1Continuous;
            structItem.IsAlarm1ConveyorStop = item.IsCountingOutput1ConveyorStop;
            structItem.IsAlarm1BuzzerOn = item.IsCountingOutput1BuzzerOn;
            structItem.IsAlarm1ExternalOutput = item.IsCountingOutput1ExternalOutput;

            structItem.Alarm2Mode = item.CountingOutput2Mode;
            structItem.Alarm2Number = item.CountingOutput2Number;
            structItem.IsAlarm2Continuous = item.IsCountingOutput2Continuous;
            structItem.IsAlarm2ConveyorStop = item.IsCountingOutput2ConveyorStop;
            structItem.IsAlarm2BuzzerOn = item.IsCountingOutput2BuzzerOn;
            structItem.IsAlarm2ExternalOutput = item.IsCountingOutput2ExternalOutput;

            structItem.IsDisconnectDetection = item.IsDisconnectDetection;
            structItem.IsCommunicationOption = item.IsCommunicationOption;
            structItem.IsBypassOnce = item.IsBypassOnce;
            structItem.IsBypassDirectionPass = item.IsBypassDirectionPass;
            structItem.IsHitachiBlankToNoneCOM4 = item.IsHitachiBlankToNoneCOM4;
            structItem.IsHitachiBlankToNoneCOM3 = item.IsHitachiBlankToNoneCOM3;
            structItem.IsHitachiBlankToNoneCOM1 = item.IsHitachiBlankToNoneCOM1;
            structItem.IsMarkoprintTodaytDatePrintEthernet = item.IsMarkoprintTodaytDatePrintEthernet;
            structItem.IsMarkoprintDatePrintEthernet = item.IsMarkoprintDatePrintEthernet;
            structItem.IsGroup1UsingRandomMode = item.IsGroup1UsingRandomMode;
            structItem.IsGroup2UsingRandomMode = item.IsGroup2UsingRandomMode;
            structItem.IsGroup3UsingRandomMode = item.IsGroup3UsingRandomMode;
            structItem.IsGroup4UsingRandomMode = item.IsGroup4UsingRandomMode;
            structItem.IsGroup5UsingRandomMode = item.IsGroup5UsingRandomMode;
            structItem.IsMarkoprintTodaytDatePrintCOM4 = item.IsMarkoprintTodaytDatePrintCOM4;
            structItem.IsMarkoprintDatePrintCOM4 = item.IsMarkoprintDatePrintCOM4;
            structItem.IsMarkoprintTodaytDatePrintCOM3 = item.IsMarkoprintTodaytDatePrintCOM3;
            structItem.IsMarkoprintDatePrintCOM3 = item.IsMarkoprintDatePrintCOM3;
            structItem.IsMarkoprintTodaytDatePrintCOM1 = item.IsMarkoprintTodaytDatePrintCOM1;
            structItem.IsMarkoprintDatePrintCOM1 = item.IsMarkoprintDatePrintCOM1;

            structItem.DummyInt1 = 0;
            structItem.DummyInt2 = 0;
            structItem.DummyInt3 = 0;
            structItem.UserAutomaticLogout = item.UserAutomaticLogout;
            structItem.ModbusTCPStartAddress = item.ModbusTCPStartAddress;
            structItem.ModbusRTUStartAddressCOM1 = item.ModbusRTUStartAddressCOM1;
            structItem.ModbusRTUStartAddressCOM3 = item.ModbusRTUStartAddressCOM3;
            structItem.ModbusRTUStartAddressCOM4 = item.ModbusRTUStartAddressCOM4;
            structItem.ModbusTCPSelectFunction = item.ModbusTCPSelectFunction;
            structItem.BLDCTotalMotorNum = item.BLDCTotalMotorNum;
            structItem.ModbusRTUSelectFunction = item.ModbusRTUSelectFunction;
            structItem.ModbusRTUSlaveIDCOM1 = item.ModbusSlaveIDCOM1;
            structItem.ModbusRTUSlaveIDCOM3 = item.ModbusSlaveIDCOM3;
            structItem.ModbusRTUSlaveIDCOM4 = item.ModbusSlaveIDCOM4;
            structItem.Barcode = item.Barcode;
            structItem.EthernetLocalPort = item.EthernetLocalPort;
            structItem.SortingPointLength = item.SortingPointLength;
            structItem.ConveyorLength = item.ConveyorLength;
            structItem.MarkoprintLineNumberEthernet = item.MarkoprintLineNumberEthernet;
            structItem.HitachiRoomNumberEthernet = item.HitachiRoomNumberEthernet;
            structItem.EthernetPort = item.EthernetPort;
            structItem.EthernetCommMode = item.EthernetCommMode;
            structItem.EthernetOperationMode = item.EthernetOperationMode;
            structItem.FileNameExtension = item.FileNameExtension;
            structItem.MarkoprintLineNumberCOM4 = item.MarkoprintLineNumberCOM4;
            structItem.HitachiRoomNumberCOM4 = item.HitachiRoomNumberCOM4;
            structItem.MarkoprintLineNumberCOM3 = item.MarkoprintLineNumberCOM3;
            structItem.HitachiRoomNumberCOM3 = item.HitachiRoomNumberCOM3;
            structItem.MarkoprintLineNumberCOM1 = item.MarkoprintLineNumberCOM1;
            structItem.HitachiRoomNumberCOM1 = item.HitachiRoomNumberCOM1;

            structItem.DummyString1 = "0";
            structItem.DummyString2 = "0";
            structItem.DummyString3 = "0";
            structItem.DummyString4 = "0";
            structItem.DummyString5 = "0";
            structItem.DummyString6 = "0";
            structItem.DummyString7 = "0";
            structItem.UserGroupLevel1Name = item.UserGroupLevel1Name;
            structItem.UserGroupLevel2Name = item.UserGroupLevel2Name;
            structItem.UserGroupLevel3Name = item.UserGroupLevel3Name;
            structItem.MarkoprintDateSettingEthernet = item.MarkoprintDateSettingEthernet;
            structItem.EthernetAddress = item.EthernetAddress;
            structItem.MarkoprintDateSettingCOM4 = item.MarkoprintDateSettingCOM4;
            structItem.MarkoprintDateSettingCOM3 = item.MarkoprintDateSettingCOM3;
            structItem.MarkoprintDateSettingCOM1 = item.MarkoprintDateSettingCOM1;

            this.smartFileIO.WriteStructure(structItem, 0);
            this.smartFileIO.Close();
        }
        public void LoadSystemConfigurationFile2()
        {
            string fullFilePath = "";
            bool fileCheck = false;
            string value;
            StructSystemConfigurationItem2 structItem;

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

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

                this.SystemConfig2.CountingOutput1Mode = structItem.Alarm1Mode;
                this.SystemConfig2.CountingOutput1Number = structItem.Alarm1Number;
                this.SystemConfig2.IsCountingOutput1Continuous = structItem.IsAlarm1Continuous;
                this.SystemConfig2.IsCountingOutput1ConveyorStop = structItem.IsAlarm1ConveyorStop;
                this.SystemConfig2.IsCountingOutput1BuzzerOn = structItem.IsAlarm1BuzzerOn;
                this.SystemConfig2.IsCountingOutput1ExternalOutput = structItem.IsAlarm1ExternalOutput;

                this.SystemConfig2.CountingOutput2Mode = structItem.Alarm2Mode;
                this.SystemConfig2.CountingOutput2Number = structItem.Alarm2Number;
                this.SystemConfig2.IsCountingOutput2Continuous = structItem.IsAlarm2Continuous;
                this.SystemConfig2.IsCountingOutput2ConveyorStop = structItem.IsAlarm2ConveyorStop;
                this.SystemConfig2.IsCountingOutput2BuzzerOn = structItem.IsAlarm2BuzzerOn;
                this.SystemConfig2.IsCountingOutput2ExternalOutput = structItem.IsAlarm2ExternalOutput;

                this.SystemConfig2.IsMarkoprintTodaytDatePrintCOM1 = structItem.IsMarkoprintTodaytDatePrintCOM1;
                this.SystemConfig2.IsMarkoprintTodaytDatePrintCOM3 = structItem.IsMarkoprintTodaytDatePrintCOM3;
                this.SystemConfig2.IsMarkoprintTodaytDatePrintCOM4 = structItem.IsMarkoprintTodaytDatePrintCOM4;
                this.SystemConfig2.IsMarkoprintDatePrintCOM1 = structItem.IsMarkoprintDatePrintCOM1;
                this.SystemConfig2.IsMarkoprintDatePrintCOM3 = structItem.IsMarkoprintDatePrintCOM3;
                this.SystemConfig2.IsMarkoprintDatePrintCOM4 = structItem.IsMarkoprintDatePrintCOM4;

                this.SystemConfig2.MarkoprintLineNumberCOM1 = structItem.MarkoprintLineNumberCOM1;
                this.SystemConfig2.MarkoprintLineNumberCOM3 = structItem.MarkoprintLineNumberCOM3;
                this.SystemConfig2.MarkoprintLineNumberCOM4 = structItem.MarkoprintLineNumberCOM4;
                this.SystemConfig2.HitachiRoomNumberCOM1 = structItem.HitachiRoomNumberCOM1;
                this.SystemConfig2.HitachiRoomNumberCOM3 = structItem.HitachiRoomNumberCOM3;
                this.SystemConfig2.HitachiRoomNumberCOM4 = structItem.HitachiRoomNumberCOM4;

                this.SystemConfig2.IsHitachiBlankToNoneCOM1 = structItem.IsHitachiBlankToNoneCOM1;
                this.SystemConfig2.IsHitachiBlankToNoneCOM3 = structItem.IsHitachiBlankToNoneCOM3;
                this.SystemConfig2.IsHitachiBlankToNoneCOM4 = structItem.IsHitachiBlankToNoneCOM4;

                this.SystemConfig2.MarkoprintDateSettingCOM1 = structItem.MarkoprintDateSettingCOM1;
                this.SystemConfig2.MarkoprintDateSettingCOM3 = structItem.MarkoprintDateSettingCOM3;
                this.SystemConfig2.MarkoprintDateSettingCOM4 = structItem.MarkoprintDateSettingCOM4;

                this.SystemConfig2.IsGroup1UsingRandomMode = structItem.IsGroup1UsingRandomMode;
                this.SystemConfig2.IsGroup2UsingRandomMode = structItem.IsGroup2UsingRandomMode;
                this.SystemConfig2.IsGroup3UsingRandomMode = structItem.IsGroup3UsingRandomMode;
                this.SystemConfig2.IsGroup4UsingRandomMode = structItem.IsGroup4UsingRandomMode;
                this.SystemConfig2.IsGroup5UsingRandomMode = structItem.IsGroup5UsingRandomMode;

                this.SystemConfig2.Barcode = structItem.Barcode;
                this.SystemConfig2.FileNameExtension = structItem.FileNameExtension;
                this.SystemConfig2.IsDisconnectDetection = structItem.IsDisconnectDetection;

                this.SystemConfig2.EthernetPort = structItem.EthernetPort;
                this.SystemConfig2.EthernetCommMode = structItem.EthernetCommMode;
                this.SystemConfig2.EthernetOperationMode = structItem.EthernetOperationMode;
                this.SystemConfig2.EthernetLocalPort = structItem.EthernetLocalPort;

                this.SystemConfig2.IsBypassOnce = structItem.IsBypassOnce;
                this.SystemConfig2.IsBypassDirectionPass = structItem.IsBypassDirectionPass;
                this.SystemConfig2.IsCommunicationOption = structItem.IsCommunicationOption;

                this.SystemConfig2.ModbusTCPSelectFunction = structItem.ModbusTCPSelectFunction;

                this.SystemConfig2.ModbusRTUSelectFunction = structItem.ModbusRTUSelectFunction;
                this.SystemConfig2.ModbusSlaveIDCOM1 = structItem.ModbusRTUSlaveIDCOM1;
                this.SystemConfig2.ModbusSlaveIDCOM3 = structItem.ModbusRTUSlaveIDCOM3;
                this.SystemConfig2.ModbusSlaveIDCOM4 = structItem.ModbusRTUSlaveIDCOM4;

                this.SystemConfig2.ModbusRTUStartAddressCOM1 = structItem.ModbusRTUStartAddressCOM1;
                this.SystemConfig2.ModbusRTUStartAddressCOM3 = structItem.ModbusRTUStartAddressCOM3;
                this.SystemConfig2.ModbusRTUStartAddressCOM4 = structItem.ModbusRTUStartAddressCOM4;
                this.SystemConfig2.ModbusTCPStartAddress = structItem.ModbusTCPStartAddress;

                this.SystemConfig2.ConveyorLength = structItem.ConveyorLength;
                this.SystemConfig2.SortingPointLength = structItem.SortingPointLength;
                this.SystemConfig2.BLDCTotalMotorNum = structItem.BLDCTotalMotorNum;

                value = structItem.EthernetAddress;
                if (value == "")
                    value = this.SystemConfig2.EthernetAddress;
                this.SystemConfig2.EthernetAddress = value;

                this.SystemConfig2.UserGroupLevel1Name = structItem.UserGroupLevel1Name;
                this.SystemConfig2.UserGroupLevel2Name = structItem.UserGroupLevel2Name;
                this.SystemConfig2.UserGroupLevel3Name = structItem.UserGroupLevel3Name;

                this.SystemConfig2.UserAutomaticLogout = structItem.UserAutomaticLogout;
            }
            catch
            {
                DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig1.Language);
                myMsg.ShowDialog();

                this.smartFileIO.Close();
            }

            this.smartFileIO.Close();
        }
        #endregion
        #region SystemConfiguration File3
        private void CreateSystemConfigurationFile3()
        {
            StructSystemConfigurationItem3 structItem;

            this.SystemConfig3.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.DummyBool20 = false;
            structItem.DummyBool21 = false;
            structItem.DummyBool22 = false;
            structItem.DummyBool23 = false;
            structItem.DummyBool24 = false;
            structItem.DummyBool25 = false;
            structItem.DummyBool26 = false;
            structItem.DummyBool27 = false;
            structItem.DummyBool28 = false;
            structItem.IsModbus = this.SystemConfig3.IsModbus;
            structItem.IsPart11 = this.SystemConfig3.IsPart11;

            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.NumberOfLoginFailures = this.SystemConfig3.NumberOfLoginFailures;
            structItem.MULTiJETSlaveAddressCOM1 = this.SystemConfig3.MULTiJETSlaveAddressCOM1;
            structItem.MULTiJETSlaveAddressCOM3 = this.SystemConfig3.MULTiJETSlaveAddressCOM3;
            structItem.MULTiJETSlaveAddressCOM4 = this.SystemConfig3.MULTiJETSlaveAddressCOM4;
            structItem.MULTiJETSlaveAddressEthernet = this.SystemConfig3.MULTiJETSlaveAddressEthernet;
            structItem.StoragePeriod = this.SystemConfig3.StoragePeriod;

            structItem.DummyString1 = "0";
            structItem.DummyString2 = "0";
            structItem.DummyString3 = "0";
            structItem.DummyString4 = "0";
            structItem.DummyString5 = "0";
            structItem.DummyString6 = "0";
            structItem.DummyString7 = "0";
            structItem.DummyString8 = "0";
            structItem.DummyString9 = "0";
            structItem.DummyString10 = "0";
            structItem.DummyString11 = "0";
            structItem.DummyString12 = "0";
            structItem.DummyString13 = "0";
            structItem.DummyString14 = "0";
            structItem.DummyString15 = "0";

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

            fullFilePath = this.PathSDCardSystemFile1Folder + "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();
                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.DummyBool20 = false;
            structItem.DummyBool21 = false;
            structItem.DummyBool22 = false;
            structItem.DummyBool23 = false;
            structItem.DummyBool24 = false;
            structItem.DummyBool25 = false;
            structItem.DummyBool26 = false;
            structItem.DummyBool27 = false;
            structItem.DummyBool28 = false;
            structItem.IsModbus = item.IsModbus;
            structItem.IsPart11 = item.IsPart11;

            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.NumberOfLoginFailures = item.NumberOfLoginFailures;
            structItem.MULTiJETSlaveAddressCOM1 = item.MULTiJETSlaveAddressCOM1;
            structItem.MULTiJETSlaveAddressCOM3 = item.MULTiJETSlaveAddressCOM3;
            structItem.MULTiJETSlaveAddressCOM4 = item.MULTiJETSlaveAddressCOM4;
            structItem.MULTiJETSlaveAddressEthernet = item.MULTiJETSlaveAddressEthernet;
            structItem.StoragePeriod = item.StoragePeriod;

            structItem.DummyString1 = "0";
            structItem.DummyString2 = "0";
            structItem.DummyString3 = "0";
            structItem.DummyString4 = "0";
            structItem.DummyString5 = "0";
            structItem.DummyString6 = "0";
            structItem.DummyString7 = "0";
            structItem.DummyString8 = "0";
            structItem.DummyString9 = "0";
            structItem.DummyString10 = "0";
            structItem.DummyString11 = "0";
            structItem.DummyString12 = "0";
            structItem.DummyString13 = "0";
            structItem.DummyString14 = "0";
            structItem.DummyString15 = "0";

            this.smartFileIO.WriteStructure(structItem, 1);
            this.smartFileIO.Close();
        }
        public void LoadSystemConfigurationFile3()
        {
            string fullFilePath = "";
            bool fileCheck = false;
            string value;
            StructSystemConfigurationItem3 structItem;

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

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

                this.SystemConfig3.IsModbus = structItem.IsModbus;
                this.SystemConfig3.IsPart11 = structItem.IsPart11;

                this.SystemConfig3.MULTiJETSlaveAddressCOM1 = structItem.MULTiJETSlaveAddressCOM1;
                this.SystemConfig3.MULTiJETSlaveAddressCOM3 = structItem.MULTiJETSlaveAddressCOM3;
                this.SystemConfig3.MULTiJETSlaveAddressCOM4 = structItem.MULTiJETSlaveAddressCOM4;
                this.SystemConfig3.MULTiJETSlaveAddressEthernet = structItem.MULTiJETSlaveAddressEthernet;

                this.SystemConfig3.StoragePeriod = structItem.StoragePeriod;
                this.SystemConfig3.NumberOfLoginFailures = structItem.NumberOfLoginFailures;
            }
            catch
            {
                this.smartFileIO.Open(this.BufferSmartUart);
                this.CreateSystemConfigurationFile3();
            }
            this.smartFileIO.Close();
        }
        #endregion

        #region BLDCMotorParameter
        public int CurrentMotorID(string lane)
        {
            int motorID = 0;

            switch (lane)
            {
                case "A":
                    motorID = 1;
                    break;
                case "B":
                    motorID = 2;
                    break;
                case "C":
                    motorID = 3;
                    break;
                case "D":
                    motorID = 4;
                    break;
                case "E":
                    motorID = 5;
                    break;
                case "F":
                    motorID = 6;
                    break;
                case "G":
                    motorID = 7;
                    break;
                case "H":
                    motorID = 8;
                    break;
                case "I":
                    motorID = 9;
                    break;
                case "J":
                    motorID = 10;
                    break;
                case "K":
                    motorID = 11;
                    break;
                case "L":
                    motorID = 12;
                    break;
                case "M":
                    motorID =13;
                    break;
                case "N":
                    motorID = 14;
                    break;
                case "O":
                    motorID = 15;
                    break;
                case "P":
                    motorID = 16;
                    break;
                default:
                    motorID = 1;
                    break;
            }

            return motorID;
        }
        public string CurrentCommunicationID(int num)
        {
            int motorID = this.CollectionBLDCParameter[num].MotorID;
            string ID = "A";

            switch (motorID)
            {
                case 1:
                    ID = "A";
                    break;
                case 2:
                    ID = "B";
                    break;
                case 3:
                    ID = "C";
                    break;
                case 4:
                    ID = "D";
                    break;
                case 5:
                    ID = "E";
                    break;
                case 6:
                    ID = "F";
                    break;
                case 7:
                    ID = "G";
                    break;
                case 8:
                    ID = "H";
                    break;
                case 9:
                    ID = "I";
                    break;
                case 10:
                    ID = "J";
                    break;
                case 11:
                    ID = "K";
                    break;
                case 12:
                    ID = "L";
                    break;
                case 13:
                    ID = "M";
                    break;
                case 14:
                    ID = "N";
                    break;
                case 15:
                    ID = "O";
                    break;
                case 16:
                    ID = "P";
                    break;
                default:
                    ID = "A";
                    break;
            }

            return ID;
        }

        private void CreateBLDCMotorParameter()
        {
            StructBLDCMotorParameter structItem;

            for (int i = 0; i < BLDCMotorMaxNum; i++)
            {
                this.CollectionBLDCParameter[i].Initialization();

                structItem.MotorID = i + 1;

                structItem.CommBaudrate = this.CollectionBLDCParameter[i]._6700_CommBaudrate;
                structItem.CommParityBit = this.CollectionBLDCParameter[i]._6701_CommParityBit;
                structItem.PWMDelay = this.CollectionBLDCParameter[i]._6702_PWMDelay;
                structItem.FeedbackDeviation = this.CollectionBLDCParameter[i]._6703_FeedbackDeviation;
                structItem.MotorSpeed = this.CollectionBLDCParameter[i]._6704_MotorSpeed;
                structItem.PoleNum = this.CollectionBLDCParameter[i]._6705_PoleNum;
                structItem.AttenuatorRatio = this.CollectionBLDCParameter[i]._6706_AttenuatorRatio;

                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.DummyString1 = "0";
                structItem.DummyString2 = "0";
                structItem.DummyString3 = "0";
                structItem.DummyString4 = "0";
                structItem.DummyString5 = "0";
                structItem.DummyString6 = "0";
                structItem.DummyString7 = "0";
                structItem.DummyString8 = "0";
                structItem.DummyString9 = "0";
                structItem.DummyString10 = "0";

                structItem.BootingStart = this.CollectionBLDCParameter[i]._6760_BootingStart;
                structItem.PortUse = this.CollectionBLDCParameter[i]._6761_PortUse;
                structItem.Feedback = this.CollectionBLDCParameter[i]._6762_Feedback;
                structItem.InitDirection = this.CollectionBLDCParameter[i]._6763_InitDirection;
                structItem.OperDirection = this.CollectionBLDCParameter[i]._6764_OperDirection;

                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.DummyString11 = "0";
                structItem.DummyString12 = "0";
                structItem.DummyString13 = "0";
                structItem.DummyString14 = "0";
                structItem.DummyString15 = "0";
                structItem.DummyString16 = "0";
                structItem.DummyString17 = "0";
                structItem.DummyString18 = "0";
                structItem.DummyString19 = "0";
                structItem.DummyString20 = "0";

                this.smartFileIO.WriteStructure(structItem, i);
            }
        }
        public void SaveBLDCMotorFile(BLDCMotorParameter item, int index)
        {
            string fullFilePath = "";
            bool fileCheck = false;
            StructBLDCMotorParameter structItem;

            fullFilePath = this.PathSDCardSystemFile1Folder + "BLDCMotorItem.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.CreateBLDCMotorParameter();
            }

            structItem.MotorID = item.MotorID;

            structItem.CommBaudrate = item._6700_CommBaudrate;
            structItem.CommParityBit = item._6701_CommParityBit;
            structItem.PWMDelay = item._6702_PWMDelay;
            structItem.FeedbackDeviation = item._6703_FeedbackDeviation;
            structItem.MotorSpeed = item._6704_MotorSpeed;
            structItem.PoleNum = item._6705_PoleNum;
            structItem.AttenuatorRatio = item._6706_AttenuatorRatio;

            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.DummyString1 = "0";
            structItem.DummyString2 = "0";
            structItem.DummyString3 = "0";
            structItem.DummyString4 = "0";
            structItem.DummyString5 = "0";
            structItem.DummyString6 = "0";
            structItem.DummyString7 = "0";
            structItem.DummyString8 = "0";
            structItem.DummyString9 = "0";
            structItem.DummyString10 = "0";

            structItem.BootingStart = item._6760_BootingStart;
            structItem.PortUse = item._6761_PortUse;
            structItem.Feedback = item._6762_Feedback;
            structItem.InitDirection = item._6763_InitDirection;
            structItem.OperDirection = item._6764_OperDirection;

            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.DummyString11 = "0";
            structItem.DummyString12 = "0";
            structItem.DummyString13 = "0";
            structItem.DummyString14 = "0";
            structItem.DummyString15 = "0";
            structItem.DummyString16 = "0";
            structItem.DummyString17 = "0";
            structItem.DummyString18 = "0";
            structItem.DummyString19 = "0";
            structItem.DummyString20 = "0";

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

            this.smartFileIO.Close();
        }
        public void SaveBLDCMotorFile(Collection<BLDCMotorParameter> items)
        {
            string fullFilePath = "";
            bool fileCheck = false;
            StructBLDCMotorParameter structItem;

            fullFilePath = this.PathSDCardSystemFile1Folder + "BLDCMotorItem.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.CreateBLDCMotorParameter();
            }

            for (int i = 0; i < this.SystemConfig2.BLDCTotalMotorNum; i++)
            {
                structItem.MotorID = items[i].MotorID;

                structItem.CommBaudrate = items[i]._6700_CommBaudrate;
                structItem.CommParityBit = items[i]._6701_CommParityBit;
                structItem.PWMDelay = items[i]._6702_PWMDelay;
                structItem.FeedbackDeviation = items[i]._6703_FeedbackDeviation;
                structItem.MotorSpeed = items[i]._6704_MotorSpeed;
                structItem.PoleNum = items[i]._6705_PoleNum;
                structItem.AttenuatorRatio = items[i]._6706_AttenuatorRatio;

                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.DummyString1 = "0";
                structItem.DummyString2 = "0";
                structItem.DummyString3 = "0";
                structItem.DummyString4 = "0";
                structItem.DummyString5 = "0";
                structItem.DummyString6 = "0";
                structItem.DummyString7 = "0";
                structItem.DummyString8 = "0";
                structItem.DummyString9 = "0";
                structItem.DummyString10 = "0";

                structItem.BootingStart = items[i]._6760_BootingStart;
                structItem.PortUse = items[i]._6761_PortUse;
                structItem.Feedback = items[i]._6762_Feedback;
                structItem.InitDirection = items[i]._6763_InitDirection;
                structItem.OperDirection = items[i]._6764_OperDirection;

                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.DummyString11 = "0";
                structItem.DummyString12 = "0";
                structItem.DummyString13 = "0";
                structItem.DummyString14 = "0";
                structItem.DummyString15 = "0";
                structItem.DummyString16 = "0";
                structItem.DummyString17 = "0";
                structItem.DummyString18 = "0";
                structItem.DummyString19 = "0";
                structItem.DummyString20 = "0";

                this.smartFileIO.WriteStructure_Begin(structItem, i);
            }
            this.smartFileIO.WriteStructure_End();

            this.smartFileIO.Close();
        }
        public void LoadBLDCMotorFile(ref Collection<BLDCMotorParameter> items)
        {
            string fullFilePath = "", value = "";
            bool fileCheck = false;
            StructBLDCMotorParameter structItem;

            fullFilePath = this.PathSDCardSystemFile1Folder + "BLDCMotorItem.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.CreateBLDCMotorParameter();
            }

            try
            {
                if (this.smartFileIO.ReadStructureAllBuffer() == true)
                {
                    for (int i = 0; i < this.SystemConfig2.BLDCTotalMotorNum; i++)
                    {
                        structItem = (StructBLDCMotorParameter)this.smartFileIO.ReadStructureBuffer(typeof(StructBLDCMotorParameter), i);

                        items[i].MotorID = structItem.MotorID;

                        items[i]._6700_CommBaudrate = structItem.CommBaudrate;
                        items[i]._6701_CommParityBit = structItem.CommParityBit;
                        items[i]._6702_PWMDelay = structItem.PWMDelay;
                        items[i]._6703_FeedbackDeviation = structItem.FeedbackDeviation;
                        items[i]._6704_MotorSpeed = structItem.MotorSpeed;
                        items[i]._6705_PoleNum = structItem.PoleNum;
                        items[i]._6706_AttenuatorRatio = structItem.AttenuatorRatio;

                        items[i]._6760_BootingStart = structItem.BootingStart;
                        items[i]._6761_PortUse = structItem.PortUse;
                        items[i]._6762_Feedback = structItem.Feedback;
                        items[i]._6763_InitDirection = structItem.InitDirection;
                        items[i]._6764_OperDirection = structItem.OperDirection;
                    }
                }
            }
            catch
            {
                DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig1.Language);
                myMsg.ShowDialog();

                this.smartFileIO.Close();
            }

            this.smartFileIO.Close();
        }
        #endregion

        #region TransferParameter
        public void TransferParameter1()
        {
            string value = "";

            StringBuilder sb = new StringBuilder();
            SystemParameter1 sItem = new SystemParameter1();

            this.LoadSystemParameter1File(ref sItem);

            sb.Append(Helper.StringZeroFillDigits4(sItem.BuzzerOnTime.ToString()));            // 부저ON시간(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.RelayOnTime.ToString()));             // 릴레이동작시간(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.SorterDoubleEntry.ToString()));      // 이중진입(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.Chattering.ToString()));                // 채터링감지4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.SorterExternalNgInput.ToString()));  // 외부NG입력(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.SorterEtcNg.ToString()));              // 기타NG사용유무(4)     
            sb.Append(Helper.StringZeroFillDigits4(sItem.StopWeighing.ToString()));            // 정지계량(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.OptionBoard.ToString()));               // 옵션보드(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.InitialDrive.ToString()));                 // 초기운전(4)

            sb.Append(Helper.StringZeroFillDigits4(sItem.PI2.ToString()));                            // PI2
            sb.Append(Helper.StringZeroFillDigits4(sItem.PI3.ToString()));                            // PI3
            sb.Append(Helper.StringZeroFillDigits4(sItem.PI4.ToString()));                            // PI4
            sb.Append(Helper.StringZeroFillDigits4(sItem.PI5.ToString()));                            // PI5
            sb.Append(Helper.StringZeroFillDigits4(sItem.PI6.ToString()));                            // PI6
            sb.Append(Helper.StringZeroFillDigits4(sItem.PI7.ToString()));                            // PI7
            sb.Append(Helper.StringZeroFillDigits4(sItem.PI8.ToString()));                            // PI8

            sb.Append(Helper.StringZeroFillDigits4(sItem.EquipmentType.ToString()));             // 장비타입
            sb.Append(Helper.StringZeroFillDigits4(sItem.SwitchChattering.ToString()));           // 스위치채터링4)
            sb.Append("0000");                                                                                // Dummy2(4)
            sb.Append("0000");                                                                                // Dummy3(4)

            this.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.SystemParameterWrite1, sb.ToString());
        }
        public void TransferParameter2()
        {
            string value = "";

            StringBuilder sb = new StringBuilder();
            SystemParameter2 sItem = new SystemParameter2();

            this.LoadSystemParameter2File(ref sItem);

            sb.Append(Helper.StringZeroFillDigits4(sItem.OPT1SamplingCount.ToString()));      // OPT1_샘플링개수(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.OPT1DelayCount.ToString()));          // OPT1_지연개수(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.OPT1PulseWidth.ToString()));             // OPT1_펄스폭(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.OPT1IsWeightSetting.ToString()));       // OPT1_범위설정사용여부(4)
            sb.Append(Helper.StringZeroFillDigits7(sItem.OPT1OverRange.ToString()));             // OPT1_상한범위(7)
            sb.Append(Helper.StringZeroFillDigits7(sItem.OPT1UnderRange.ToString()));           // OPT1_하한범위(7)
            sb.Append(Helper.StringZeroFillDigits4(sItem.OPT1Port.ToString()));                     // OPT1_포트(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.OPT2Port.ToString()));                     // OPT2_포트(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.OPT2DelayTime1.ToString()));            // OPT2_지연시간1(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.OPT2DelayTime2.ToString()));            // OPT2_지연시간2(4)
            sb.Append("0000000");                                                                            // Dummy1(7)                    
            sb.Append("0000000");                                                                            // Dummy2(7)
            sb.Append("0000");                                                                                // Dummy3(4)
            sb.Append("0000");                                                                                // Dummy4(4)
            sb.Append("0000");                                                                                // Dummy5(4)
            sb.Append("0000");                                                                                // Dummy6(4)
            sb.Append("0000");                                                                                // Dummy7(4)

            this.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.SystemParameterWrite2, sb.ToString());
        }
        public void TransferParameter3()
        {
            string value = "";

            StringBuilder sb = new StringBuilder();
            SystemParameter3 sItem = new SystemParameter3();

            this.LoadSystemParameter3File(ref sItem);

            sb.Append(Helper.StringZeroFillDigits4(sItem.ExternalOut1Mode.ToString()));               // 외부출력1모드4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.ExternalOut1DelayTime.ToString()));          // 외부출력1지연(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.ExternalOut1RunTime.ToString()));            // 외부출력1동작(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.ExternalOut2Mode.ToString()));               // 외부출력2모드(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.ExternalOut2DelayTime.ToString()));          // 외부출력2지연(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.ExternalOut2RunTime.ToString()));            // 외부출력2동작(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.ExternalOut3Mode.ToString()));               // 외부출력3모드(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.ExternalOut3DelayTime.ToString()));          // 외부출력3지연(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.ExternalOut3RunTime.ToString()));            // 외부출력3동작(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.ExternalOut4Mode.ToString()));               // 외부출력4모드(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.ExternalOut4DelayTime.ToString()));         // 외부출력4지연(4)    
            sb.Append(Helper.StringZeroFillDigits4(sItem.ExternalOut4RunTime.ToString()));           // 외부출력4동작(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.ExternalOut5Mode.ToString()));              // 외부출력9모드(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.ExternalOut5DelayTime.ToString()));         // 외부출력9지연(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.ExternalOut5RunTime.ToString()));          // 외부출력9동작(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.ExternalOut6Mode.ToString()));            // 외부출력10모드(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.ExternalOut6DelayTime.ToString()));       // 외부출력10지연(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.ExternalOut6RunTime.ToString()));         // 외부출력10동작(4)
            sb.Append("0000");                                                                                     // Dummy1(4)                    
            sb.Append("0000");                                                                                     // Dummy2(4)

            this.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.SystemParameterWrite3, sb.ToString());
        }
        public void TransferParameter4()
        {
            string value = "";

            StringBuilder sb = new StringBuilder();
            SystemParameter4 sItem = new SystemParameter4();

            this.LoadSystemParameter4File(ref sItem);

            sb.Append(Helper.StringZeroFillDigits4(Convert.ToInt16(sItem.LCDAutoZeroIsAutoZeroUsing).ToString()));          // 자동영점사용여부(4)
            sb.Append(Helper.StringZeroFillDigits7(sItem.LCDAutoZeroPlusRange));            // 자동영점+범위(7)
            sb.Append(Helper.StringZeroFillDigits7(sItem.LCDAutoZeroMinusRange));           // 자동영점-범위(7)
            sb.Append(Helper.StringZeroFillDigits4(sItem.LCDAutoZeroVariate));         // 자동영점변량(4)
            sb.Append("0000");                                                                               // Dummy1(4)                    
            sb.Append("0000");                                                                               // Dummy2(4)
            sb.Append("0000");                                                                               // Dummy3(4)
            sb.Append("0000");                                                                               // Dummy4(4)
            sb.Append("0000");                                                                               // Dummy5(4)
            sb.Append("0000");                                                                               // Dummy6(4)
            sb.Append("0000");                                                                               // Dummy7(4)
            sb.Append("0000");                                                                               // Dummy8(4)
            sb.Append("0000");                                                                               // Dummy9(4)
            sb.Append("0000");                                                                               // Dummy10(4)
            sb.Append("0000");                                                                               // Dummy11(4)                    
            sb.Append("0000");                                                                               // Dummy12(4)
            sb.Append("0000");                                                                               // Dummy13(4)
            sb.Append("0000");                                                                               // Dummy14(4)
            sb.Append("0000");                                                                               // Dummy15(4)
            sb.Append("0000");                                                                               // Dummy16(4)
            sb.Append("0000");                                                                               // Dummy17(4)
            sb.Append("0000");                                                                               // Dummy18(4)
            sb.Append("0000");                                                                               // Dummy19(4)
            sb.Append("0000");                                                                               // Dummy20(4)

            this.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.SystemParameterWrite4, sb.ToString());
        }
        public void TransferRandomMode()
        {
            string value = "";

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

            pItem = this.CollectionProductItem[995];
            sb.Append("0996");                                                                                                // 품번(4)                    
            sb.Append(Helper.StringZeroFillDigits4((Convert.ToInt32(false)).ToString()));         // 사용여부(4)
            sb.Append(Helper.StringZeroFillDigits7(pItem.UnderRange));                                             // 하한값(7)
            sb.Append(Helper.StringZeroFillDigits7(pItem.OverRange));                                               // 상한값(7)
            sb.Append(Helper.StringZeroFillDigits7(pItem.TareRange));                                               // 용기(7)

            pItem = this.CollectionProductItem[996];
            sb.Append("0997");                                                                                                // 품번(4)                    
            sb.Append(Helper.StringZeroFillDigits4((Convert.ToInt32(false)).ToString()));         // 사용여부(4)
            sb.Append(Helper.StringZeroFillDigits7(pItem.UnderRange));                                             // 하한값(7)
            sb.Append(Helper.StringZeroFillDigits7(pItem.OverRange));                                               // 상한값(7)
            sb.Append(Helper.StringZeroFillDigits7(pItem.TareRange));                                               // 용기(7)

            pItem = this.CollectionProductItem[997];
            sb.Append("0998");                                                                                                // 품번(4)                    
            sb.Append(Helper.StringZeroFillDigits4((Convert.ToInt32(false)).ToString()));         // 사용여부(4)
            sb.Append(Helper.StringZeroFillDigits7(pItem.UnderRange));                                             // 하한값(7)
            sb.Append(Helper.StringZeroFillDigits7(pItem.OverRange));                                               // 상한값(7)
            sb.Append(Helper.StringZeroFillDigits7(pItem.TareRange));                                               // 용기(7)

            pItem = this.CollectionProductItem[998];
            sb.Append("0999");                                                                                                // 품번(4)                    
            sb.Append(Helper.StringZeroFillDigits4((Convert.ToInt32(false)).ToString()));         // 사용여부(4)
            sb.Append(Helper.StringZeroFillDigits7(pItem.UnderRange));                                             // 하한값(7)
            sb.Append(Helper.StringZeroFillDigits7(pItem.OverRange));                                               // 상한값(7)
            sb.Append(Helper.StringZeroFillDigits7(pItem.TareRange));                                               // 용기(7)

            pItem = this.CollectionProductItem[999];
            sb.Append("1000");                                                                                                // 품번(4)                    
            sb.Append(Helper.StringZeroFillDigits4((Convert.ToInt32(false)).ToString()));         // 사용여부(4)
            //sb.Append(Helper.StringZeroFillDigits4((Convert.ToInt32(this.SystemConfig2.IsGroup5UsingRandomMode)).ToString()));         // 사용여부(4)
            sb.Append(Helper.StringZeroFillDigits7(pItem.UnderRange));                                             // 하한값(7)
            sb.Append(Helper.StringZeroFillDigits7(pItem.OverRange));                                               // 상한값(7)
            sb.Append(Helper.StringZeroFillDigits7(pItem.TareRange));                                               // 용기(7)

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

            StringBuilder sb = new StringBuilder();

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

            pItem = this.CollectionProductItem[productNumber - 1];
            jItem = this.CollectionJudgmentItem[productNumber - 1];

            sb.Append(Helper.StringZeroFillDigits7(pItem.UnderRange));                          // 하한값(7)
            sb.Append(Helper.StringZeroFillDigits7(pItem.PassRange));                            // 기준값(7)                   
            sb.Append(Helper.StringZeroFillDigits7(pItem.OverRange));                           // 상한값(7)
            sb.Append(Helper.StringZeroFillDigits7(pItem.TareRange));                           // 용기(7)
            value = Helper.DoubleToString(jItem.DynamicCorrection, 6);
            value = value.Replace(".", "");
            sb.Append(Helper.StringZeroFillDigits7(value));                                      // 동보정(7)
            sb.Append(Helper.StringZeroFillDigits4(jItem.Filter.ToString()));                       // 필터(4)
            sb.Append(Helper.StringZeroFillDigits4(jItem.JudgmentDelayTime.ToString()));       // 판정지연(4)
            sb.Append(Helper.StringZeroFillDigits4(jItem.DoubleDelayTime.ToString()));         // 이중지연(4)
            sb.Append(Helper.StringZeroFillDigits4(jItem.JudgmentCount.ToString()));           // 판정개수(4)
            sb.Append(Helper.StringZeroFillDigits4(jItem.AscendDelayTime.ToString()));       // 상승지연(4)
            sb.Append(Helper.StringZeroFillDigits4(jItem.DescendDelayTime.ToString()));         // 하강지연(4)
            sb.Append(Helper.StringZeroFillDigits4(jItem.FeedSpeed1.ToString()));              // 인버터1속도(4)
            sb.Append(Helper.StringZeroFillDigits4(jItem.FeedSpeed2.ToString()));              // 인버터2속도(4)
            sb.Append(Helper.StringZeroFillDigits4(jItem.FeedSpeed3.ToString()));              // 인버터3속도(4)
            sb.Append(Helper.StringZeroFillDigits4(jItem.ProductLength.ToString()));      // 자동판정-길이(4)
            sb.Append(Helper.StringZeroFillDigits4(jItem.AutoJudgment1.ToString()));           // 자동판정-1(4)
            sb.Append(Helper.StringZeroFillDigits4(jItem.AutoJudgment2.ToString()));           // 자동판정-2(4)
            sb.Append(Helper.StringZeroFillDigits4(jItem.AutoJudgment3.ToString()));           // 자동판정-3(4)
            sb.Append(Helper.StringZeroFillDigits4(jItem.Sorter1Mode.ToString()));             // 선별기1모드(4)    
            sb.Append(Helper.StringZeroFillDigits4(jItem.Sorter1DelayTime.ToString()));        // 선별기1지연시간(4)
            sb.Append(Helper.StringZeroFillDigits4(jItem.Sorter1RunTime.ToString()));          // 선별기1동작시간(4)
            sb.Append(Helper.StringZeroFillDigits4(jItem.Sorter2Mode.ToString()));             // 선별기2모드(4)
            sb.Append(Helper.StringZeroFillDigits4(jItem.Sorter2DelayTime.ToString()));        // 선별기2지연시간(4)
            sb.Append(Helper.StringZeroFillDigits4(jItem.Sorter2RunTime.ToString()));          // 선별기2동작시간(4)
            sb.Append(Helper.StringZeroFillDigits4(this.SystemConfig1.EquipmentID.ToString()));  // 장비ID(4)
            sb.Append("0000000");                                                                                   // Dummy1(7)
            sb.Append("0000000");                                                                                   // Dummy2(7)
            sb.Append("0000");                                                                                   // Dummy3(4)
            sb.Append(Helper.StringZeroFillDigits4(jItem.MovingAverage.ToString()));                // 이동평균(4)
            sb.Append(Helper.StringZeroFillDigits4(this.SystemConfig1.DecimalPlaces.ToString())); // 소수점(4)
            sb.Append(Helper.StringZeroFillDigits4(productNumber.ToString()));                      // 품번 

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

            string temp = "";
            if (productNumber > 100)
                temp = productNumber.ToString().Substring(productNumber.ToString().Length - 2, 2);
            else
                temp = string.Format("{0:00}", productNumber);

            // OPT1(액트라 - 안리쯔 금속검출기)
            if (this.SystemConfig1.SerialCOM1Mode == 14)
                this.TransferSerialCOM1(this.Transfer_14_OPT1("200" + temp));
            if (this.SystemConfig1.SerialCOM3Mode == 14)
                this.TransferSerialCOM3(this.Transfer_14_OPT1("200" + temp));
            if (this.SystemConfig1.SerialCOM4Mode == 14)
                this.TransferSerialCOM4(this.Transfer_14_OPT1("200" + temp));

            // OPT2(NOW - PPI)
            if (this.SystemConfig1.SerialCOM1Mode == 15)
                this.TransferSerialCOM1(this.ResponseFrameOPT2());
            if (this.SystemConfig1.SerialCOM3Mode == 15)
                this.TransferSerialCOM3(this.ResponseFrameOPT2());
            if (this.SystemConfig1.SerialCOM4Mode == 15)
                this.TransferSerialCOM4(this.ResponseFrameOPT2());
        }
        public void TransferCountData(int productNumber)
        {
            StringBuilder sb = new StringBuilder();

            WeightData wItem = new WeightData();
            wItem = this.CollectionWeightData[productNumber - 1];

            sb.Append(Helper.StringZeroFillDigits4(productNumber.ToString()));      // 품번(4)
            sb.Append(Helper.StringZeroFillDigits7(wItem.ExNGCount.ToString()));                           // ExNG카운트(7)
            sb.Append(Helper.StringZeroFillDigits7(wItem.OverCount.ToString()));                            // 상한카운트(7)
            sb.Append(Helper.StringZeroFillDigits7(wItem.PassCount.ToString()));                             // 기준카운트(7)
            sb.Append(Helper.StringZeroFillDigits7(wItem.UnderCount.ToString()));                           // 하한카운트(7)
            sb.Append(Helper.StringZeroFillDigits7(wItem.MetalDetectionCount.ToString()));               // 금속카운트(7)
            sb.Append(Helper.StringZeroFillDigits7(wItem.DoubleEntryCount.ToString()));                   // 이중카운트(7)
            sb.Append("0000000");                                                                                   // Dummy3(7)
            sb.Append("0000000");                                                                                   // Dummy4(7)
            sb.Append("0000");                                                                                   // Dummy1(4)

            this.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.ParameterCount, sb.ToString());
        }
        public void TransferBLDCMotorData(string ID, SystemConfigurationItem2 system2, BLDCMotorParameter item)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(Helper.StringZeroFillDigits4(system2.BLDCTotalMotorNum));       // BLDC 모터 개수(4)
            sb.Append(Helper.StringZeroFillDigits4(item._6700_CommBaudrate));          // 메인보드와의 통신 Baudrate(4)
            sb.Append(Helper.StringZeroFillDigits4(item._6701_CommParityBit));           // 메인보드와의 통신 Parity bit(4)
            sb.Append(Helper.StringZeroFillDigits4(item._6702_PWMDelay));                // PWM 변화 속도(4)
            sb.Append(Helper.StringZeroFillDigits4(item._6703_FeedbackDeviation));      // Feedback 구동을 위한 변화 편차(4)
            sb.Append(Helper.StringZeroFillDigits4(item._6704_MotorSpeed));              // Motor 속도(4)
            sb.Append(Helper.StringZeroFillDigits4(item._6705_PoleNum));                  // BLDC 모터 Pole 수(4)
            sb.Append(Helper.StringZeroFillDigits4(item._6706_AttenuatorRatio));          // 감속기 비율(4)
            sb.Append(Helper.StringZeroFillDigits4(item._6760_BootingStart));              // 부팅 시 자동 구동 여부(4)
            sb.Append(Helper.StringZeroFillDigits4(item._6761_PortUse));                    // 타 Port 모터 사용 여부(4)
            sb.Append(Helper.StringZeroFillDigits4(item._6762_Feedback));                  // 모터 구동 중 피드백 제어 여부(4)
            sb.Append(Helper.StringZeroFillDigits4(item._6763_InitDirection));               // 초기 모터 방향(4)
            sb.Append(Helper.StringZeroFillDigits4(item._6764_OperDirection));            // 구동 중 모터 방향(4)
            sb.Append("0000");                                                                                  // Dummy1(4)
            sb.Append("0000");                                                                                  // Dummy2(4)
            sb.Append("0000");                                                                                  // Dummy3(4)
            sb.Append("0000");                                                                                  // Dummy4(4)
            sb.Append("0000");                                                                                  // Dummy5(4)
            sb.Append("0000");                                                                                  // Dummy6(4)
            sb.Append("0000");                                                                                  // Dummy7(4)
            sb.Append("0000");                                                                                  // Dummy8(4)
            sb.Append("0000");                                                                                  // Dummy9(4)
            sb.Append("0000");                                                                                  // Dummy10(4)
            sb.Append("0000");                                                                                  // Dummy11(4)
            sb.Append("0000");                                                                                  // Dummy12(4)
            sb.Append("0000");                                                                                  // Dummy13(4)
            sb.Append("0000");                                                                                  // Dummy14(4)
            sb.Append("0000");                                                                                  // Dummy15(4)
            sb.Append("0000");                                                                                  // Dummy16(4)
            sb.Append("0000");                                                                                  // Dummy17(4)
            sb.Append("0000");                                                                                  // Dummy18(4)
            sb.Append("0000");                                                                                  // Dummy19(4)
            sb.Append("0000");                                                                                  // Dummy20(4)
            sb.Append("0000");                                                                                  // Dummy21(4)
            sb.Append("0000");                                                                                  // Dummy22(4)

            this.TransferDataStream(CommunicationCommand.Write, ID, CommunicationAddress.BLDCMotorSetting, sb.ToString());
        }
        public void TransferCurrentProductItem(ProductItem pItem)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(Helper.StringZeroFillDigits7(pItem.UnderRange));
            sb.Append(Helper.StringZeroFillDigits7(pItem.PassRange));
            sb.Append(Helper.StringZeroFillDigits7(pItem.OverRange));
            sb.Append(Helper.StringZeroFillDigits7(pItem.TareRange));
            sb.Append(Helper.StringZeroFillDigits4(this.SystemConfig1.ProductNumber.ToString()));

            this.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.ParameterWeightSetting, sb.ToString());
        }
        #endregion
        #region SystemParameter1
        private void CreateSystemParameter1File()
        {
            StructSystemParameter1 structItem;

            this.CurrentSystemParameter1.Initialization();

            structItem.BuzzerOnTime = this.CurrentSystemParameter1.BuzzerOnTime;
            structItem.RelayOnTime = this.CurrentSystemParameter1.RelayOnTime;
            structItem.Chattering = this.CurrentSystemParameter1.Chattering;
            structItem.SorterDoubleEntry = this.CurrentSystemParameter1.SorterDoubleEntry;
            structItem.SorterExternalNgInput = this.CurrentSystemParameter1.SorterExternalNgInput;
            structItem.SorterEtcNgInput = this.CurrentSystemParameter1.SorterEtcNg;
            structItem.StopWeighing = this.CurrentSystemParameter1.StopWeighing;
            structItem.InitialDrive = this.CurrentSystemParameter1.InitialDrive;
            structItem.OptionBoard = this.CurrentSystemParameter1.OptionBoard;

            structItem.PI2 = this.CurrentSystemParameter1.PI2;
            structItem.PI3 = this.CurrentSystemParameter1.PI3;
            structItem.PI4 = this.CurrentSystemParameter1.PI4;
            structItem.PI5 = this.CurrentSystemParameter1.PI5;
            structItem.PI6 = this.CurrentSystemParameter1.PI6;
            structItem.PI7 = this.CurrentSystemParameter1.PI7;
            structItem.PI8 = this.CurrentSystemParameter1.PI8;

            structItem.SwitchChattering = this.CurrentSystemParameter1.SwitchChattering;
            structItem.EquipmentType = this.CurrentSystemParameter1.EquipmentType;

            structItem.Dummy1 = "0";
            structItem.Dummy2 = "0";

            this.smartFileIO.WriteStructure(structItem, 0);
        }
        public void SaveSystemParameter1File(SystemParameter1 item)
        {
            string fullFilePath = "";
            bool fileCheck = false;
            StructSystemParameter1 structItem;

            fullFilePath = this.PathSDCardSystemFile1Folder + "SystemParameter1.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.CreateSystemParameter1File();
            }

            structItem.BuzzerOnTime = item.BuzzerOnTime;
            structItem.RelayOnTime = item.RelayOnTime;
            structItem.SorterDoubleEntry = item.SorterDoubleEntry;
            structItem.Chattering = item.Chattering;
            structItem.SorterExternalNgInput = item.SorterExternalNgInput;
            structItem.SorterEtcNgInput = item.SorterEtcNg;
            structItem.StopWeighing = item.StopWeighing;
            structItem.OptionBoard = item.OptionBoard;
            structItem.InitialDrive = item.InitialDrive;

            structItem.PI2 = item.PI2;
            structItem.PI3 = item.PI3;
            structItem.PI4 = item.PI4;
            structItem.PI5 = item.PI5;
            structItem.PI6 = item.PI6;
            structItem.PI7 = item.PI7;
            structItem.PI8 = item.PI8;

            structItem.SwitchChattering = item.SwitchChattering;
            structItem.EquipmentType = item.EquipmentType;

            structItem.Dummy1 = "0";
            structItem.Dummy2 = "0";

            this.smartFileIO.WriteStructure(structItem, 0);
            this.smartFileIO.Close();
        }
        public void LoadSystemParameter1File(ref SystemParameter1 pItem)
        {
            string fullFilePath = "";
            bool fileCheck = false;
            StructSystemParameter1 structItem;

            fullFilePath = this.PathSDCardSystemFile1Folder + "SystemParameter1.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.CreateSystemParameter1File();
            }

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

                pItem.BuzzerOnTime = structItem.BuzzerOnTime;
                pItem.RelayOnTime = structItem.RelayOnTime;
                pItem.Chattering = structItem.Chattering;
                pItem.SorterDoubleEntry = structItem.SorterDoubleEntry;
                pItem.SorterExternalNgInput = structItem.SorterExternalNgInput;
                pItem.SorterEtcNg = structItem.SorterEtcNgInput;
                pItem.StopWeighing = structItem.StopWeighing;
                pItem.InitialDrive = structItem.InitialDrive;
                pItem.OptionBoard = structItem.OptionBoard;

                // Version 4 -> Version 5 업데이트 시, 값이 ""라서 오류 발생하여 강제로 값 삽입
                if (structItem.EquipmentType == "")
                    structItem.EquipmentType = "0";
                pItem.EquipmentType = structItem.EquipmentType;
                pItem.SwitchChattering = structItem.SwitchChattering;

                pItem.PI2 = structItem.PI2;
                pItem.PI3 = structItem.PI3;
                pItem.PI4 = structItem.PI4;
                pItem.PI5 = structItem.PI5;
                pItem.PI6 = structItem.PI6;
                pItem.PI7 = structItem.PI7;
                pItem.PI8 = structItem.PI8;
            }
            catch
            {
                DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig1.Language);
                myMsg.ShowDialog();

                this.smartFileIO.Close();
            }

            this.smartFileIO.Close();
        }
        #endregion
        #region SystemParameter2
        private void CreateSystemParameter2File()
        {
            StructSystemParameter2 structItem;

            this.CurrentSystemParameter2.Initialization();

            structItem.OPT1SamplingCount = this.CurrentSystemParameter2.OPT1SamplingCount;
            structItem.OPT1DelayCount = this.CurrentSystemParameter2.OPT1DelayCount;
            structItem.OPT1PulseWidth = this.CurrentSystemParameter2.OPT1PulseWidth;
            structItem.OPT1IsWeightSetting = this.CurrentSystemParameter2.OPT1IsWeightSetting;
            structItem.OPT1OverRange = this.CurrentSystemParameter2.OPT1OverRange;
            structItem.OPT1UnderRange = this.CurrentSystemParameter2.OPT1UnderRange;
            structItem.OPT1Port = this.CurrentSystemParameter2.OPT1Port;

            structItem.OPT2Port = this.CurrentSystemParameter2.OPT2Port;
            structItem.OPT2DelayTime1 = this.CurrentSystemParameter2.OPT2DelayTime1;
            structItem.OPT2DelayTime2 = this.CurrentSystemParameter2.OPT2DelayTime2;

            structItem.Dummy1 = "0";
            structItem.Dummy2 = "0";
            structItem.Dummy3 = "0";
            structItem.Dummy4 = "0";
            structItem.Dummy5 = "0";
            structItem.OPT2ZeroZoneCycle = "0";
            structItem.OPT2ZeroZoneCount = "0";

            this.smartFileIO.WriteStructure(structItem, 0);
        }
        public void SaveSystemParameter2File(SystemParameter2 item)
        {
            string fullFilePath = "";
            bool fileCheck = false;
            StructSystemParameter2 structItem;

            fullFilePath = this.PathSDCardSystemFile1Folder + "SystemParameter2.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.CreateSystemParameter2File();
            }

            structItem.OPT1SamplingCount = item.OPT1SamplingCount;
            structItem.OPT1DelayCount = item.OPT1DelayCount;
            structItem.OPT1PulseWidth = item.OPT1PulseWidth;
            structItem.OPT1IsWeightSetting = item.OPT1IsWeightSetting;
            structItem.OPT1OverRange = item.OPT1OverRange;
            structItem.OPT1UnderRange = item.OPT1UnderRange;
            structItem.OPT1Port = item.OPT1Port;

            structItem.OPT2Port = item.OPT2Port;
            structItem.OPT2DelayTime1 = item.OPT2DelayTime1;
            structItem.OPT2DelayTime2 = item.OPT2DelayTime2;

            structItem.Dummy1 = "0";
            structItem.Dummy2 = "0";
            structItem.Dummy3 = "0";
            structItem.Dummy4 = "0";
            structItem.Dummy5 = "0";
            structItem.OPT2ZeroZoneCycle = "0";
            structItem.OPT2ZeroZoneCount = "0";

            this.smartFileIO.WriteStructure(structItem, 0);
            this.smartFileIO.Close();
        }
        public void LoadSystemParameter2File(ref SystemParameter2 pItem)
        {
            string fullFilePath = "";
            bool fileCheck = false;
            StructSystemParameter2 structItem;

            fullFilePath = this.PathSDCardSystemFile1Folder + "SystemParameter2.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.CreateSystemParameter2File();
            }

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

                pItem.OPT1SamplingCount = structItem.OPT1SamplingCount;
                pItem.OPT1DelayCount = structItem.OPT1DelayCount;
                pItem.OPT1PulseWidth = structItem.OPT1PulseWidth;
                pItem.OPT1IsWeightSetting = structItem.OPT1IsWeightSetting;
                pItem.OPT1OverRange = structItem.OPT1OverRange;
                pItem.OPT1UnderRange = structItem.OPT1UnderRange;
                pItem.OPT1Port = structItem.OPT1Port;

                pItem.OPT2Port = structItem.OPT2Port;
                pItem.OPT2DelayTime1 = structItem.OPT2DelayTime1;
                pItem.OPT2DelayTime2 = structItem.OPT2DelayTime2;
            }
            catch
            {
                DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig1.Language);
                myMsg.ShowDialog();

                this.smartFileIO.Close();
            }

            this.smartFileIO.Close();
        }
        #endregion
        #region SystemParameter3
        private void CreateSystemParameter3File()
        {
            StructSystemParameter3 structItem;

            this.CurrentSystemParameter3.Initialization();

            structItem.ExternalOut1Mode = this.CurrentSystemParameter3.ExternalOut1Mode;
            structItem.ExternalOut1DelayTime = this.CurrentSystemParameter3.ExternalOut1DelayTime;
            structItem.ExternalOut1RunTime = this.CurrentSystemParameter3.ExternalOut1RunTime;

            structItem.ExternalOut2Mode = this.CurrentSystemParameter3.ExternalOut2Mode;
            structItem.ExternalOut2DelayTime = this.CurrentSystemParameter3.ExternalOut2DelayTime;
            structItem.ExternalOut2RunTime = this.CurrentSystemParameter3.ExternalOut2RunTime;

            structItem.ExternalOut3Mode = this.CurrentSystemParameter3.ExternalOut3Mode;
            structItem.ExternalOut3DelayTime = this.CurrentSystemParameter3.ExternalOut3DelayTime;
            structItem.ExternalOut3RunTime = this.CurrentSystemParameter3.ExternalOut3RunTime;

            structItem.ExternalOut4Mode = this.CurrentSystemParameter3.ExternalOut4Mode;
            structItem.ExternalOut4DelayTime = this.CurrentSystemParameter3.ExternalOut4DelayTime;
            structItem.ExternalOut4RunTime = this.CurrentSystemParameter3.ExternalOut4RunTime;

            structItem.ExternalOut5Mode = this.CurrentSystemParameter3.ExternalOut5Mode;
            structItem.ExternalOut5DelayTime = this.CurrentSystemParameter3.ExternalOut5DelayTime;
            structItem.ExternalOut5RunTime = this.CurrentSystemParameter3.ExternalOut5RunTime;

            structItem.ExternalOut6Mode = this.CurrentSystemParameter3.ExternalOut6Mode;
            structItem.ExternalOut6DelayTime = this.CurrentSystemParameter3.ExternalOut6DelayTime;
            structItem.ExternalOut6RunTime = this.CurrentSystemParameter3.ExternalOut6RunTime;

            structItem.Dummy1 = "0";
            structItem.Dummy2 = "0";

            this.smartFileIO.WriteStructure(structItem, 0);
        }
        public void SaveSystemParameter3File(SystemParameter3 item)
        {
            string fullFilePath = "";
            bool fileCheck = false;
            StructSystemParameter3 structItem;

            fullFilePath = this.PathSDCardSystemFile1Folder + "SystemParameter3.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.CreateSystemParameter3File();
            }

            structItem.ExternalOut1Mode = item.ExternalOut1Mode;
            structItem.ExternalOut1DelayTime = item.ExternalOut1DelayTime;
            structItem.ExternalOut1RunTime = item.ExternalOut1RunTime;

            structItem.ExternalOut2Mode = item.ExternalOut2Mode;
            structItem.ExternalOut2DelayTime = item.ExternalOut2DelayTime;
            structItem.ExternalOut2RunTime = item.ExternalOut2RunTime;

            structItem.ExternalOut3Mode = item.ExternalOut3Mode;
            structItem.ExternalOut3DelayTime = item.ExternalOut3DelayTime;
            structItem.ExternalOut3RunTime = item.ExternalOut3RunTime;

            structItem.ExternalOut4Mode = item.ExternalOut4Mode;
            structItem.ExternalOut4DelayTime = item.ExternalOut4DelayTime;
            structItem.ExternalOut4RunTime = item.ExternalOut4RunTime;

            structItem.ExternalOut5Mode = item.ExternalOut5Mode;
            structItem.ExternalOut5DelayTime = item.ExternalOut5DelayTime;
            structItem.ExternalOut5RunTime = item.ExternalOut5RunTime;

            structItem.ExternalOut6Mode = item.ExternalOut6Mode;
            structItem.ExternalOut6DelayTime = item.ExternalOut6DelayTime;
            structItem.ExternalOut6RunTime = item.ExternalOut6RunTime;

            structItem.Dummy1 = "0";
            structItem.Dummy2 = "0";

            this.smartFileIO.WriteStructure(structItem, 0);
            this.smartFileIO.Close();
        }
        public void LoadSystemParameter3File(ref SystemParameter3 pItem)
        {
            string fullFilePath = "";
            bool fileCheck = false;
            StructSystemParameter3 structItem;

            fullFilePath = this.PathSDCardSystemFile1Folder + "SystemParameter3.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.CreateSystemParameter3File();
            }

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

                pItem.ExternalOut1Mode = structItem.ExternalOut1Mode;
                pItem.ExternalOut1DelayTime = structItem.ExternalOut1DelayTime;
                pItem.ExternalOut1RunTime = structItem.ExternalOut1RunTime;

                pItem.ExternalOut2Mode = structItem.ExternalOut2Mode;
                pItem.ExternalOut2DelayTime = structItem.ExternalOut2DelayTime;
                pItem.ExternalOut2RunTime = structItem.ExternalOut2RunTime;

                pItem.ExternalOut3Mode = structItem.ExternalOut3Mode;
                pItem.ExternalOut3DelayTime = structItem.ExternalOut3DelayTime;
                pItem.ExternalOut3RunTime = structItem.ExternalOut3RunTime;

                pItem.ExternalOut4Mode = structItem.ExternalOut4Mode;
                pItem.ExternalOut4DelayTime = structItem.ExternalOut4DelayTime;
                pItem.ExternalOut4RunTime = structItem.ExternalOut4RunTime;

                pItem.ExternalOut5Mode = structItem.ExternalOut5Mode;
                pItem.ExternalOut5DelayTime = structItem.ExternalOut5DelayTime;
                pItem.ExternalOut5RunTime = structItem.ExternalOut5RunTime;

                pItem.ExternalOut6Mode = structItem.ExternalOut6Mode;
                pItem.ExternalOut6DelayTime = structItem.ExternalOut6DelayTime;
                pItem.ExternalOut6RunTime = structItem.ExternalOut6RunTime;
            }
            catch
            {
                DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig1.Language);
                myMsg.ShowDialog();

                this.smartFileIO.Close();
            }

            this.smartFileIO.Close();
        }
        #endregion
        #region SystemParameter4
        private void CreateSystemParameter4File()
        {
            StructSystemParameter4 structItem;

            this.CurrentSystemParameter4.Initialization();

            structItem.AutoZeroIsAutoZeroUsing = this.CurrentSystemParameter4.LCDAutoZeroIsAutoZeroUsing;
            structItem.AutoZeroPlusRange = this.CurrentSystemParameter4.LCDAutoZeroPlusRange;
            structItem.AutoZeroMinusRange = this.CurrentSystemParameter4.LCDAutoZeroMinusRange;
            structItem.AutoZeroVariate = this.CurrentSystemParameter4.LCDAutoZeroVariate;

            structItem.Dummy1 = "0";
            structItem.Dummy2 = "0";
            structItem.Dummy3 = "0";
            structItem.Dummy4 = "0";
            structItem.Dummy5 = "0";
            structItem.Dummy6 = "0";
            structItem.Dummy7 = "0";
            structItem.Dummy8 = "0";
            structItem.Dummy9 = "0";
            structItem.Dummy10 = "0";

            this.smartFileIO.WriteStructure(structItem, 0);
        }
        public void SaveSystemParameter4File(SystemParameter4 item)
        {
            string fullFilePath = "";
            bool fileCheck = false;
            StructSystemParameter4 structItem;

            fullFilePath = this.PathSDCardSystemFile1Folder + "SystemParameter4.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.CreateSystemParameter4File();
            }

            structItem.AutoZeroIsAutoZeroUsing = item.LCDAutoZeroIsAutoZeroUsing;
            structItem.AutoZeroPlusRange = item.LCDAutoZeroPlusRange;
            structItem.AutoZeroMinusRange = item.LCDAutoZeroMinusRange;
            structItem.AutoZeroVariate = item.LCDAutoZeroVariate;

            structItem.Dummy1 = "0";
            structItem.Dummy2 = "0";
            structItem.Dummy3 = "0";
            structItem.Dummy4 = "0";
            structItem.Dummy5 = "0";
            structItem.Dummy6 = "0";
            structItem.Dummy7 = "0";
            structItem.Dummy8 = "0";
            structItem.Dummy9 = "0";
            structItem.Dummy10 = "0";

            this.smartFileIO.WriteStructure(structItem, 0);
            this.smartFileIO.Close();
        }
        public void LoadSystemParameter4File(ref SystemParameter4 pItem)
        {
            string fullFilePath = "";
            bool fileCheck = false;
            StructSystemParameter4 structItem;

            fullFilePath = this.PathSDCardSystemFile1Folder + "SystemParameter4.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.CreateSystemParameter4File();
            }

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

                pItem.LCDAutoZeroIsAutoZeroUsing = structItem.AutoZeroIsAutoZeroUsing;
                pItem.LCDAutoZeroPlusRange = structItem.AutoZeroPlusRange;
                pItem.LCDAutoZeroVariate = structItem.AutoZeroVariate;
                pItem.LCDAutoZeroMinusRange = structItem.AutoZeroMinusRange;
            }
            catch
            {
                DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig1.Language);
                myMsg.ShowDialog();

                this.smartFileIO.Close();
            }

            this.smartFileIO.Close();
        }
        #endregion

        #region Product 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.PassRange = this.CurrentProductItem.PassRange;
                structItem.OverRange = this.CurrentProductItem.OverRange;
                structItem.UnderRange = this.CurrentProductItem.UnderRange;
                structItem.TareRange = this.CurrentProductItem.TareRange;
                structItem.DispenserDelayTime1 = this.CurrentProductItem.DispenserDelayTime1;
                structItem.DispenserDelayTime2 = this.CurrentProductItem.DispenserDelayTime2;
                structItem.DummyString3 = "0";
                structItem.DummyString4 = "0";

                this.smartFileIO.WriteStructure_Begin(structItem, i);
            }
            this.smartFileIO.WriteStructure_End();
        }
        public void OpenSmartFileIO()
        {
            bool fileCheck = false;
            string fullFilePath = "";

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

            FileInfo fileInfo = new FileInfo(fullFilePath);
            fileCheck = fileInfo.Exists;
            if (fileCheck == true)
                this.smartFileIO.Open(this.BufferSmartUart);
        }
        public void CloseSmartFileIO()
        {
            this.smartFileIO.Close();
        }
        public void SaveProductFile(ProductItem item, int index)
        {
            bool fileCheck = false;
            string fullFilePath = "";
            StructProductItem structItem;

            fullFilePath = this.PathSDCardSystemFile2Folder + "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.DispenserDelayTime1 = item.DispenserDelayTime1;
            structItem.DispenserDelayTime2 = item.DispenserDelayTime2;
            structItem.DummyString3 = "0";
            structItem.DummyString4 = "0";

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

            this.smartFileIO.Close();
        }
        public void SaveProductFile(Collection<ProductItem> items)
        {
            bool fileCheck = false;
            string fullFilePath = "";
            StructProductItem structItem;

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

            for (int i = 0; i < this.ProductCount; i++)
            {
                structItem.Number = items[i].Number;
                structItem.Name = items[i].Name;
                structItem.LotNo = items[i].LotNo;
                structItem.OverRange = items[i].OverRange;
                structItem.PassRange = items[i].PassRange;
                structItem.UnderRange = items[i].UnderRange;
                structItem.TareRange = items[i].TareRange;
                structItem.DispenserDelayTime1 = items[i].DispenserDelayTime1;
                structItem.DispenserDelayTime2 = items[i].DispenserDelayTime2;
                structItem.DummyString3 = "0";
                structItem.DummyString4 = "0";

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

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

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

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

                this.CreateProductFile();
            }

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

                item.Number = structItem.Number;
                item.Name = structItem.Name;
                item.LotNo = structItem.LotNo;
                item.PassRange = structItem.PassRange;
                item.OverRange = structItem.OverRange;
                item.UnderRange = structItem.UnderRange;
                item.TareRange = structItem.TareRange;
                item.DispenserDelayTime1 = structItem.DispenserDelayTime1;
                item.DispenserDelayTime2 = structItem.DispenserDelayTime2;
            }
            catch
            {
                DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig1.Language);
                myMsg.ShowDialog();

                this.smartFileIO.Close();
            }

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

            values.Clear();

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

            this.smartFileIO.Open(this.BufferSmartUart);

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

                    values.Add(structItem.Name);
                }
            }

            this.smartFileIO.Close();
        }
        private void LoadProductFile(ref Collection<ProductItem> items)
        {
            bool fileCheck = false;
            string fullFilePath = "";
            StructProductItem structProduct;

            fullFilePath = this.PathSDCardSystemFile2Folder + "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)
                {
                    for (int i = 0; i < this.ProductCount; i++)
                    {
                        structProduct = (StructProductItem)this.smartFileIO.ReadStructureBuffer(typeof(StructProductItem), i);

                        items[i].Number = structProduct.Number;
                        items[i].Name = structProduct.Name;
                        items[i].LotNo = structProduct.LotNo;
                        items[i].OverRange = structProduct.OverRange;
                        items[i].PassRange = structProduct.PassRange;
                        items[i].UnderRange = structProduct.UnderRange;
                        items[i].TareRange = structProduct.TareRange;
                        items[i].DispenserDelayTime1 = structProduct.DispenserDelayTime1;
                        items[i].DispenserDelayTime2 = structProduct.DispenserDelayTime2;
                    }
                }
            }
            catch
            {
                DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig1.Language);
                myMsg.ShowDialog();

                this.smartFileIO.Close();
            }

            this.smartFileIO.Close();
        }
        public void ReLoadProductFile()
        {
            this.LoadProductFile(ref this.CollectionProductItem);
        }
        #endregion

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

            this.CurrentJudgmentSetItem.Initialization();

            for (int i = 0; i < 1000; i++)
            {
                structItem.Filter = this.CurrentJudgmentSetItem.Filter;
                structItem.JudgmentDelayTime = this.CurrentJudgmentSetItem.JudgmentDelayTime;
                structItem.DoubleDelayTime = this.CurrentJudgmentSetItem.DoubleDelayTime;
                structItem.JudgmentCount = this.CurrentJudgmentSetItem.JudgmentCount;
                structItem.FeedSpeed1 = this.CurrentJudgmentSetItem.FeedSpeed1;
                structItem.FeedSpeed2 = this.CurrentJudgmentSetItem.FeedSpeed2;
                structItem.FeedSpeed3 = this.CurrentJudgmentSetItem.FeedSpeed3;
                structItem.DynamicCorrection = this.CurrentJudgmentSetItem.DynamicCorrection;
                structItem.AscendDelayTime = this.CurrentJudgmentSetItem.AscendDelayTime;
                structItem.DescendDelayTime = this.CurrentJudgmentSetItem.DescendDelayTime;

                structItem.Sorter1Mode = this.CurrentJudgmentSetItem.Sorter1Mode;
                structItem.Sorter1DelayTime = this.CurrentJudgmentSetItem.Sorter1DelayTime;
                structItem.Sorter1RunTime = this.CurrentJudgmentSetItem.Sorter1RunTime;
                structItem.Sorter2Mode = this.CurrentJudgmentSetItem.Sorter2Mode;
                structItem.Sorter2DelayTime = this.CurrentJudgmentSetItem.Sorter2DelayTime;
                structItem.Sorter2RunTime = this.CurrentJudgmentSetItem.Sorter2RunTime;

                structItem.ProductLength = this.CurrentJudgmentSetItem.ProductLength;
                structItem.AutoJudgment1 = this.CurrentJudgmentSetItem.AutoJudgment1;
                structItem.AutoJudgment2 = this.CurrentJudgmentSetItem.AutoJudgment2;
                structItem.AutoJudgment3 = this.CurrentJudgmentSetItem.AutoJudgment3;

                structItem.MovingAverage = this.CurrentJudgmentSetItem.MovingAverage;
                structItem.DummyInt1 = 0;
                structItem.DummyInt2 = 0;

                structItem.DummyString1 = "0";
                structItem.DummyString2 = "0";
                structItem.DummyString3 = "0";
                structItem.DummyString4 = "0";
                structItem.DummyString5 = "0";

                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.PathSDCardSystemFile2Folder + "JudgmentSetItem.int";
            this.smartFileIO.FilePathName = fullFilePath;

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

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

            structItem.Filter = item.Filter;
            structItem.JudgmentDelayTime = item.JudgmentDelayTime;
            structItem.DoubleDelayTime = item.DoubleDelayTime;
            structItem.JudgmentCount = item.JudgmentCount;
            structItem.FeedSpeed1 = item.FeedSpeed1;
            structItem.FeedSpeed2 = item.FeedSpeed2;
            structItem.FeedSpeed3 = item.FeedSpeed3;
            structItem.DynamicCorrection = item.DynamicCorrection;

            structItem.Sorter1Mode = item.Sorter1Mode;
            structItem.Sorter1DelayTime = item.Sorter1DelayTime;
            structItem.Sorter1RunTime = item.Sorter1RunTime;
            structItem.Sorter2Mode = item.Sorter2Mode;
            structItem.Sorter2DelayTime = item.Sorter2DelayTime;
            structItem.Sorter2RunTime = item.Sorter2RunTime;

            structItem.ProductLength = item.ProductLength;
            structItem.AutoJudgment1 = item.AutoJudgment1;
            structItem.AutoJudgment2 = item.AutoJudgment2;
            structItem.AutoJudgment3 = item.AutoJudgment3;

            structItem.AscendDelayTime = item.AscendDelayTime;
            structItem.DescendDelayTime = item.DescendDelayTime;
            structItem.MovingAverage = item.MovingAverage;
            structItem.DummyInt1 = 0;
            structItem.DummyInt2 = 0;

            structItem.DummyString1 = "0";
            structItem.DummyString2 = "0";
            structItem.DummyString3 = "0";
            structItem.DummyString4 = "0";
            structItem.DummyString5 = "0";

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

            this.smartFileIO.Close();
        }
        public void SaveJudgmentSetFile(Collection<JudgmentSetItem> items)
        {
            bool fileCheck = false;
            string fullFilePath = "";
            StructJudgmentSetItem structItem;

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

            for (int i = 0; i < this.ProductCount; i++)
            {
                structItem.Filter = items[i].Filter;
                structItem.JudgmentDelayTime = items[i].JudgmentDelayTime;
                structItem.DoubleDelayTime = items[i].DoubleDelayTime;
                structItem.JudgmentCount = items[i].JudgmentCount;
                structItem.FeedSpeed1 = items[i].FeedSpeed1;
                structItem.FeedSpeed2 = items[i].FeedSpeed2;
                structItem.FeedSpeed3 = items[i].FeedSpeed3;
                structItem.DynamicCorrection = items[i].DynamicCorrection;

                structItem.Sorter1Mode = items[i].Sorter1Mode;
                structItem.Sorter1DelayTime = items[i].Sorter1DelayTime;
                structItem.Sorter1RunTime = items[i].Sorter1RunTime;
                structItem.Sorter2Mode = items[i].Sorter2Mode;
                structItem.Sorter2DelayTime = items[i].Sorter2DelayTime;
                structItem.Sorter2RunTime = items[i].Sorter2RunTime;

                structItem.ProductLength = items[i].ProductLength;
                structItem.AutoJudgment1 = items[i].AutoJudgment1;
                structItem.AutoJudgment2 = items[i].AutoJudgment2;
                structItem.AutoJudgment3 = items[i].AutoJudgment3;

                structItem.AscendDelayTime = items[i].AscendDelayTime;
                structItem.DescendDelayTime = items[i].DescendDelayTime;
                structItem.MovingAverage = items[i].MovingAverage;
                structItem.DummyInt1 = 0;
                structItem.DummyInt2 = 0;

                structItem.DummyString1 = "0";
                structItem.DummyString2 = "0";
                structItem.DummyString3 = "0";
                structItem.DummyString4 = "0";
                structItem.DummyString5 = "0";

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

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

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

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

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

                item.Filter = structItem.Filter;
                item.JudgmentDelayTime = structItem.JudgmentDelayTime;
                item.DoubleDelayTime = structItem.DoubleDelayTime;
                item.JudgmentCount = structItem.JudgmentCount;
                item.FeedSpeed1 = structItem.FeedSpeed1;
                item.FeedSpeed2 = structItem.FeedSpeed2;
                item.FeedSpeed3 = structItem.FeedSpeed3;
                item.DynamicCorrection = structItem.DynamicCorrection;
                item.MovingAverage = structItem.MovingAverage;

                item.Sorter1Mode = structItem.Sorter1Mode;
                item.Sorter1DelayTime = structItem.Sorter1DelayTime;
                item.Sorter1RunTime = structItem.Sorter1RunTime;
                item.Sorter2Mode = structItem.Sorter2Mode;
                item.Sorter2DelayTime = structItem.Sorter2DelayTime;
                item.Sorter2RunTime = structItem.Sorter2RunTime;

                item.ProductLength = structItem.ProductLength;
                item.AutoJudgment1 = structItem.AutoJudgment1;
                item.AutoJudgment2 = structItem.AutoJudgment2;
                item.AutoJudgment3 = structItem.AutoJudgment3;

                item.AscendDelayTime = structItem.AscendDelayTime;
                item.DescendDelayTime = structItem.DescendDelayTime;
            }
            catch
            {
                DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig1.Language);
                myMsg.ShowDialog();

                this.smartFileIO.Close();
            }
            this.smartFileIO.Close();
        }
        private void LoadJudgmentSetFile(ref Collection<JudgmentSetItem> items)
        {
            bool fileCheck = false;
            string fullFilePath = "";
            StructJudgmentSetItem structJudgment;

            fullFilePath = this.PathSDCardSystemFile2Folder + "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)
                {
                    for (int i = 0; i < this.ProductCount; i++)
                    {
                        structJudgment = (StructJudgmentSetItem)this.smartFileIO.ReadStructureBuffer(typeof(StructJudgmentSetItem), i);

                        items[i].Filter = structJudgment.Filter;
                        items[i].JudgmentDelayTime = structJudgment.JudgmentDelayTime;
                        items[i].DoubleDelayTime = structJudgment.DoubleDelayTime;
                        items[i].JudgmentCount = structJudgment.JudgmentCount;
                        items[i].FeedSpeed1 = structJudgment.FeedSpeed1;
                        items[i].FeedSpeed2 = structJudgment.FeedSpeed2;
                        items[i].FeedSpeed3 = structJudgment.FeedSpeed3;
                        items[i].DynamicCorrection = structJudgment.DynamicCorrection;

                        items[i].Sorter1Mode = structJudgment.Sorter1Mode;
                        items[i].Sorter1DelayTime = structJudgment.Sorter1DelayTime;
                        items[i].Sorter1RunTime = structJudgment.Sorter1RunTime;
                        items[i].Sorter2Mode = structJudgment.Sorter2Mode;
                        items[i].Sorter2DelayTime = structJudgment.Sorter2DelayTime;
                        items[i].Sorter2RunTime = structJudgment.Sorter2RunTime;

                        items[i].ProductLength = structJudgment.ProductLength;
                        items[i].AutoJudgment1 = structJudgment.AutoJudgment1;
                        items[i].AutoJudgment2 = structJudgment.AutoJudgment2;
                        items[i].AutoJudgment3 = structJudgment.AutoJudgment3;

                        items[i].AscendDelayTime = structJudgment.AscendDelayTime;
                        items[i].DescendDelayTime = structJudgment.DescendDelayTime;
                        items[i].MovingAverage = structJudgment.MovingAverage;
                    }
                }
            }
            catch
            {
                DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig1.Language);
                myMsg.ShowDialog();

                this.smartFileIO.Close();
            }
            this.smartFileIO.Close();
        }
        public void ReLoadJudgmentSetFile()
        {
            this.LoadJudgmentSetFile(ref this.CollectionJudgmentItem);
        }
        #endregion

        #region Counter File
        private void CreateCounterFile()
        {
            StructCounterItem structItem;
            WeightData item = new WeightData();
            item.ClearCount();

            for (int i = 0; i < 1000; i++)
            {
                structItem.OverCount = item.OverCount;
                structItem.OverSumWeight = item.OverSumWeight;
                structItem.PassCount = item.PassCount;
                structItem.PassSumWeight = item.PassSumWeight;
                structItem.UnderCount = item.UnderCount;
                structItem.UnderSumWeight = item.UnderSumWeight;
                structItem.ExNGCount = item.ExNGCount;

                structItem.NormalDistribution1 = item.CollectionNormalDistributionCount[0];
                structItem.NormalDistribution2 = item.CollectionNormalDistributionCount[1];
                structItem.NormalDistribution3 = item.CollectionNormalDistributionCount[2];
                structItem.NormalDistribution4 = item.CollectionNormalDistributionCount[3];
                structItem.NormalDistribution5 = item.CollectionNormalDistributionCount[4];
                structItem.NormalDistribution6 = item.CollectionNormalDistributionCount[5];
                structItem.NormalDistribution7 = item.CollectionNormalDistributionCount[6];
                structItem.NormalDistribution8 = item.CollectionNormalDistributionCount[7];
                structItem.NormalDistribution9 = item.CollectionNormalDistributionCount[8];
                structItem.NormalDistribution10 = item.CollectionNormalDistributionCount[9];

                structItem.StartTime = item.StartTime;
                structItem.StopTime = item.StopTime;

                structItem.DoubleEntryCount = item.DoubleEntryCount;
                structItem.MetalDetectionCount = item.MetalDetectionCount;
                structItem.ETCExNGCount = item.ETCExNGCount;
                structItem.DummyInt1 = 0;
                structItem.DummyInt2 = 0;

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

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

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

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

                this.CreateCounterFile();
            }

            structItem.OverCount = item.OverCount;
            structItem.OverSumWeight = item.OverSumWeight;
            structItem.PassCount = item.PassCount;
            structItem.PassSumWeight = item.PassSumWeight;
            structItem.UnderCount = item.UnderCount;
            structItem.UnderSumWeight = item.UnderSumWeight;
            structItem.ExNGCount = item.ExNGCount;

            structItem.NormalDistribution1 = item.CollectionNormalDistributionCount[0];
            structItem.NormalDistribution2 = item.CollectionNormalDistributionCount[1];
            structItem.NormalDistribution3 = item.CollectionNormalDistributionCount[2];
            structItem.NormalDistribution4 = item.CollectionNormalDistributionCount[3];
            structItem.NormalDistribution5 = item.CollectionNormalDistributionCount[4];
            structItem.NormalDistribution6 = item.CollectionNormalDistributionCount[5];
            structItem.NormalDistribution7 = item.CollectionNormalDistributionCount[6];
            structItem.NormalDistribution8 = item.CollectionNormalDistributionCount[7];
            structItem.NormalDistribution9 = item.CollectionNormalDistributionCount[8];
            structItem.NormalDistribution10 = item.CollectionNormalDistributionCount[9];

            structItem.StartTime = item.StartTime;
            structItem.StopTime = item.StopTime;

            structItem.DoubleEntryCount = item.DoubleEntryCount;
            structItem.MetalDetectionCount = item.MetalDetectionCount;
            structItem.ETCExNGCount = item.ETCExNGCount;
            structItem.DummyInt1 = 0;
            structItem.DummyInt2 = 0;

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

            this.smartFileIO.Close();
        }
        public void SaveCounterFile(Collection<WeightData> items)
        {
            string fullFilePath = "";
            bool fileCheck = false;
            StructCounterItem structItem;

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

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

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

                this.CreateCounterFile();
            }

            for (int i = 0; i < this.ProductCount; i++)
            {
                structItem.OverCount = items[i].OverCount;
                structItem.OverSumWeight = items[i].OverSumWeight;
                structItem.PassCount = items[i].PassCount;
                structItem.PassSumWeight = items[i].PassSumWeight;
                structItem.UnderCount = items[i].UnderCount;
                structItem.UnderSumWeight = items[i].UnderSumWeight;
                structItem.ExNGCount = items[i].ExNGCount;

                structItem.NormalDistribution1 = items[i].CollectionNormalDistributionCount[0];
                structItem.NormalDistribution2 = items[i].CollectionNormalDistributionCount[1];
                structItem.NormalDistribution3 = items[i].CollectionNormalDistributionCount[2];
                structItem.NormalDistribution4 = items[i].CollectionNormalDistributionCount[3];
                structItem.NormalDistribution5 = items[i].CollectionNormalDistributionCount[4];
                structItem.NormalDistribution6 = items[i].CollectionNormalDistributionCount[5];
                structItem.NormalDistribution7 = items[i].CollectionNormalDistributionCount[6];
                structItem.NormalDistribution8 = items[i].CollectionNormalDistributionCount[7];
                structItem.NormalDistribution9 = items[i].CollectionNormalDistributionCount[8];
                structItem.NormalDistribution10 = items[i].CollectionNormalDistributionCount[9];

                structItem.StartTime = items[i].StartTime;
                structItem.StopTime = items[i].StopTime;

                structItem.DoubleEntryCount = items[i].DoubleEntryCount;
                structItem.MetalDetectionCount = items[i].MetalDetectionCount;
                structItem.ETCExNGCount = items[i].ETCExNGCount;
                structItem.DummyInt1 = 0;
                structItem.DummyInt2 = 0;

                this.smartFileIO.WriteStructure_Begin(structItem, i);
            }
            this.smartFileIO.WriteStructure_End();
            this.smartFileIO.Close();
        }
        public void LoadCounterFile(ref WeightData item, int index)
        {
            string fullFilePath = "";
            bool fileCheck = false;
            StructCounterItem structItem;

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

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

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

                this.CreateCounterFile();
            }

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

                item.UnderCount = structItem.UnderCount;
                item.UnderSumWeight = structItem.UnderSumWeight;
                item.PassCount = structItem.PassCount;
                item.PassSumWeight = structItem.PassSumWeight;
                item.OverCount = structItem.OverCount;
                item.OverSumWeight = structItem.OverSumWeight;

                item.CollectionNormalDistributionCount[0] = structItem.NormalDistribution1;
                item.CollectionNormalDistributionCount[1] = structItem.NormalDistribution2;
                item.CollectionNormalDistributionCount[2] = structItem.NormalDistribution3;
                item.CollectionNormalDistributionCount[3] = structItem.NormalDistribution4;
                item.CollectionNormalDistributionCount[4] = structItem.NormalDistribution5;
                item.CollectionNormalDistributionCount[5] = structItem.NormalDistribution6;
                item.CollectionNormalDistributionCount[6] = structItem.NormalDistribution7;
                item.CollectionNormalDistributionCount[7] = structItem.NormalDistribution8;
                item.CollectionNormalDistributionCount[8] = structItem.NormalDistribution9;
                item.CollectionNormalDistributionCount[9] = structItem.NormalDistribution10;

                item.StartTime = structItem.StartTime;
                item.StopTime = structItem.StopTime;

                item.DoubleEntryCount = structItem.DoubleEntryCount;
                item.MetalDetectionCount = structItem.MetalDetectionCount;
                item.ETCExNGCount = structItem.ETCExNGCount;
            }
            catch
            {
                DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig1.Language);
                myMsg.ShowDialog();

                this.smartFileIO.Close();
            }
            this.smartFileIO.Close();
        }
        private void LoadCounterFile(ref Collection<WeightData> items)
        {
            bool fileCheck = false;
            string fullFilePath = "";
            StructCounterItem structItem;

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

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

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

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

                        items[i].UnderCount = structItem.UnderCount;
                        items[i].UnderSumWeight = structItem.UnderSumWeight;
                        items[i].PassCount = structItem.PassCount;
                        items[i].PassSumWeight = structItem.PassSumWeight;
                        items[i].OverCount = structItem.OverCount;
                        items[i].OverSumWeight = structItem.OverSumWeight;

                        items[i].CollectionNormalDistributionCount[0] = structItem.NormalDistribution1;
                        items[i].CollectionNormalDistributionCount[1] = structItem.NormalDistribution2;
                        items[i].CollectionNormalDistributionCount[2] = structItem.NormalDistribution3;
                        items[i].CollectionNormalDistributionCount[3] = structItem.NormalDistribution4;
                        items[i].CollectionNormalDistributionCount[4] = structItem.NormalDistribution5;
                        items[i].CollectionNormalDistributionCount[5] = structItem.NormalDistribution6;
                        items[i].CollectionNormalDistributionCount[6] = structItem.NormalDistribution7;
                        items[i].CollectionNormalDistributionCount[7] = structItem.NormalDistribution8;
                        items[i].CollectionNormalDistributionCount[8] = structItem.NormalDistribution9;
                        items[i].CollectionNormalDistributionCount[9] = structItem.NormalDistribution10;

                        items[i].StartTime = structItem.StartTime;
                        items[i].StopTime = structItem.StopTime;

                        items[i].DoubleEntryCount = structItem.DoubleEntryCount;
                        items[i].MetalDetectionCount = structItem.MetalDetectionCount;
                        items[i].ETCExNGCount = structItem.ETCExNGCount;
                    }
                }
            }
            catch
            {
                DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig1.Language);
                myMsg.ShowDialog();

                this.smartFileIO.Close();
            }
            this.smartFileIO.Close();
        }
        public void ReLoadCounterFile()
        {
            this.LoadCounterFile(ref this.CollectionWeightData);
        }
        #endregion

        #region User
        // User Manager 초기화
        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.PathSDCardSystemFile1Folder);

            if (this.SystemConfig2.UserAutomaticLogout == 1)
                this.FlagAutomaticLogoutWarningTime = 30;
            else
                this.FlagAutomaticLogoutWarningTime = 60;

            UserManager.UserManager_AutoLogoutSetTimeout(this.SystemConfig2.UserAutomaticLogout, this.FlagAutomaticLogoutWarningTime);
        }
        /// <summary>
        /// Set User
        /// </summary>
        /// <param name="user"></param>
        public void SetUser(Define.E_UserGroup user)
        {
            if (this.CurrentSystemStatus.CurrentUserPasswordType.Group != user)
                this.CurrentSystemStatus.CurrentUserPasswordType.Group = user;
        }
        public void TimerLogoutEnabled(bool bValue)
        {
            if (bValue == true)
                this.smartTimerLogout.Start();
            else
                this.smartTimerLogout.Stop();
        }

        #region UserGroupPassword File
        private void CreateUserGroupPasswordFile()
        {
            this.CurrentSystemStatus.CurrentUserPasswordType.Initialization();

            this.smartFileIO.WriteString(this.CurrentSystemStatus.CurrentUserPasswordType.Level1Password, (int)Define.E_FileUserPassword.f0_Level1);
            this.smartFileIO.WriteString(this.CurrentSystemStatus.CurrentUserPasswordType.Level2Password, (int)Define.E_FileUserPassword.f1_Level2);
            this.smartFileIO.WriteString(this.CurrentSystemStatus.CurrentUserPasswordType.Level3Password, (int)Define.E_FileUserPassword.f2_Level3);
        }
        public void SaveUserGroupPasswordFile(UserPasswordType item)
        {
            string fullFilePath = "";
            bool fileCheck = false;

            fullFilePath = this.PathSDCardSystemFile1Folder + "UserGroupPassword.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.CreateUserGroupPasswordFile();
            }

            this.smartFileIO.WriteString(item.Level1Password, (int)Define.E_FileUserPassword.f0_Level1);
            this.smartFileIO.WriteString(item.Level2Password, (int)Define.E_FileUserPassword.f1_Level2);
            this.smartFileIO.WriteString(item.Level3Password, (int)Define.E_FileUserPassword.f2_Level3);

            this.smartFileIO.Close();
        }
        private void LoadUserGroupPasswordFile()
        {
            string fullFilePath = "";
            bool fileCheck = false;

            fullFilePath = this.PathSDCardSystemFile1Folder + "UserGroupPassword.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.CreateUserGroupPasswordFile();
            }

            try
            {
                this.CurrentSystemStatus.CurrentUserPasswordType.Level1Password = this.smartFileIO.ReadString((int)Define.E_FileUserPassword.f0_Level1);
                this.CurrentSystemStatus.CurrentUserPasswordType.Level2Password = this.smartFileIO.ReadString((int)Define.E_FileUserPassword.f1_Level2);
                this.CurrentSystemStatus.CurrentUserPasswordType.Level3Password = this.smartFileIO.ReadString((int)Define.E_FileUserPassword.f2_Level3);
            }
            catch
            {
                DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig1.Language);
                myMsg.ShowDialog();

                this.smartFileIO.Close();
            }

            this.smartFileIO.Close();
        }
        #endregion

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

            for (int i = 0; i < 4; i++)
            {
                switch (i)
                {
                    case 0:
                        #region Level1
                        structItem.IsMainDisplayWeightSetting = false;
                        structItem.IsMainDisplaySubMenu = false;
                        structItem.IsMainDisplayClear = false;
                        structItem.IsMainDisplayProductNo = true;

                        structItem.IsBasicDataStatistics = false;
                        structItem.IsBasicProduct = false;
                        structItem.IsBasicTime = false;

                        structItem.IsConfiSerial = false;
                        structItem.IsConfiEthernet = false;
                        structItem.IsConfiOption = false;

                        structItem.IsEquipFunctionSetting = false;
                        structItem.IsEquipInitialize = false;
                        structItem.IsEquipUpdate = false;
                        structItem.IsEquipEngineerSetting = false;
                        structItem.IsEquipUser = false;

                        structItem.IsInforAS = true;
                        structItem.IsInforSystem = true;

                        structItem.IsSystemAutoZero = false;
                        structItem.IsSystemCalibration = true;
                        structItem.IsSystemExternalOutput = false;
                        structItem.IsSystemIOTest = false;
                        structItem.IsSystemJudgmentSetting = true;
                        structItem.IsSystemSorterSetting = true;

                        structItem.IsLogJudge = true;
                        structItem.IsLogHistory = true;
                        structItem.IsLogOthers = true;

                        structItem.Dummy0 = true;
                        structItem.IsEquipManufacturerSetting = 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;
                        #endregion
                        break;
                    case 1:
                        #region Level2
                        structItem.IsMainDisplayWeightSetting = true;
                        structItem.IsMainDisplaySubMenu = true;
                        structItem.IsMainDisplayClear = true;
                        structItem.IsMainDisplayProductNo = true;

                        structItem.IsBasicDataStatistics = true;
                        structItem.IsBasicProduct = true;
                        structItem.IsBasicTime = true;

                        structItem.IsConfiSerial = false;
                        structItem.IsConfiEthernet = false;
                        structItem.IsConfiOption = false;

                        structItem.IsEquipFunctionSetting = true;
                        structItem.IsEquipInitialize = false;
                        structItem.IsEquipUpdate = false;
                        structItem.IsEquipEngineerSetting = false;
                        structItem.IsEquipUser = false;

                        structItem.IsInforAS = true;
                        structItem.IsInforSystem = true;

                        structItem.IsSystemAutoZero = true;
                        structItem.IsSystemCalibration = true;
                        structItem.IsSystemExternalOutput = true;
                        structItem.IsSystemIOTest = true;
                        structItem.IsSystemJudgmentSetting = true;
                        structItem.IsSystemSorterSetting = true;

                        structItem.IsLogJudge = true;
                        structItem.IsLogHistory = true;
                        structItem.IsLogOthers = true;

                        structItem.Dummy0 = true;
                        structItem.IsEquipManufacturerSetting = 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;
                        #endregion
                        break;
                    case 2:
                        #region Level3
                        structItem.IsMainDisplayWeightSetting = true;
                        structItem.IsMainDisplayClear = true;
                        structItem.IsMainDisplaySubMenu = true;
                        structItem.IsMainDisplayProductNo = true;

                        structItem.IsBasicDataStatistics = true;
                        structItem.IsBasicProduct = true;
                        structItem.IsBasicTime = true;

                        structItem.IsConfiSerial = true;
                        structItem.IsConfiOption = true;
                        structItem.IsConfiEthernet = true;

                        structItem.IsEquipFunctionSetting = true;
                        structItem.IsEquipInitialize = true;
                        structItem.IsEquipUpdate = true;
                        structItem.IsEquipUser = true;
                        structItem.IsEquipEngineerSetting = true;

                        structItem.IsInforAS = true;
                        structItem.IsInforSystem = true;

                        structItem.IsSystemAutoZero = true;
                        structItem.IsSystemCalibration = true;
                        structItem.IsSystemExternalOutput = true;
                        structItem.IsSystemIOTest = true;
                        structItem.IsSystemJudgmentSetting = true;
                        structItem.IsSystemSorterSetting = true;

                        structItem.IsLogJudge = true;
                        structItem.IsLogHistory = true;
                        structItem.IsLogOthers = true;

                        structItem.Dummy0 = true;
                        structItem.IsEquipManufacturerSetting = true;
                        structItem.Dummy2 = true;
                        structItem.Dummy3 = true;
                        structItem.Dummy4 = true;
                        structItem.Dummy5 = true;
                        structItem.Dummy6 = true;
                        structItem.Dummy7 = true;
                        structItem.Dummy8 = true;
                        structItem.Dummy9 = true;
                        structItem.Dummy10 = true;
                        structItem.Dummy11 = true;
                        structItem.Dummy12 = true;
                        structItem.Dummy13 = true;
                        structItem.Dummy14 = true;
                        structItem.Dummy15 = true;
                        structItem.Dummy16 = true;
                        #endregion
                        break;
                    case 3:
                        #region Not Login
                        structItem.IsMainDisplayWeightSetting = true;
                        structItem.IsMainDisplayClear = true;
                        structItem.IsMainDisplayProductNo = true;
                        structItem.IsMainDisplaySubMenu = true;

                        structItem.IsBasicDataStatistics = true;
                        structItem.IsBasicProduct = true;
                        structItem.IsBasicTime = true;

                        structItem.IsConfiSerial = true;
                        structItem.IsConfiOption = true;
                        structItem.IsConfiEthernet = true;

                        structItem.IsEquipFunctionSetting = true;
                        structItem.IsEquipInitialize = true;
                        structItem.IsEquipUpdate = true;
                        structItem.IsEquipUser = false;
                        structItem.IsEquipEngineerSetting = true;

                        structItem.IsInforAS = true;
                        structItem.IsInforSystem = true;

                        structItem.IsSystemAutoZero = true;
                        structItem.IsSystemCalibration = true;
                        structItem.IsSystemExternalOutput = true;
                        structItem.IsSystemIOTest = true;
                        structItem.IsSystemJudgmentSetting = true;
                        structItem.IsSystemSorterSetting = true;

                        structItem.IsLogJudge = true;
                        structItem.IsLogHistory = true;
                        structItem.IsLogOthers = true;

                        structItem.Dummy0 = true;
                        structItem.IsEquipManufacturerSetting = true;
                        structItem.Dummy2 = true;
                        structItem.Dummy3 = true;
                        structItem.Dummy4 = true;
                        structItem.Dummy5 = true;
                        structItem.Dummy6 = true;
                        structItem.Dummy7 = true;
                        structItem.Dummy8 = true;
                        structItem.Dummy9 = true;
                        structItem.Dummy10 = true;
                        structItem.Dummy11 = true;
                        structItem.Dummy12 = true;
                        structItem.Dummy13 = true;
                        structItem.Dummy14 = true;
                        structItem.Dummy15 = true;
                        structItem.Dummy16 = true;
                        #endregion
                        break;
                    default:
                        #region default
                        structItem.IsMainDisplayProductNo = item.IsMainDisplayProductNo;
                        structItem.IsMainDisplayWeightSetting = item.IsMainDisplayWeightSetting;
                        structItem.IsMainDisplayClear = item.IsMainDisplayClear;
                        structItem.IsMainDisplaySubMenu = item.IsMainDisplaySubMenu;

                        structItem.IsBasicDataStatistics = item.IsBasicDataStatistics;
                        structItem.IsBasicProduct = item.IsBasicProduct;
                        structItem.IsBasicTime = item.IsBasicTime;

                        structItem.IsConfiSerial = item.IsConfiSerial;
                        structItem.IsConfiOption = item.IsConfiOption;
                        structItem.IsConfiEthernet = item.IsConfiEthernet;

                        structItem.IsEquipFunctionSetting = item.IsEquipFunctionSetting;
                        structItem.IsEquipInitialize = item.IsEquipInitialize;
                        structItem.IsEquipUpdate = item.IsEquipUpdate;
                        structItem.IsEquipUser = item.IsEquipUserSetting;
                        structItem.IsEquipEngineerSetting = item.IsEquipEngineerSetting;

                        structItem.IsInforAS = item.IsInforAS;
                        structItem.IsInforSystem = item.IsInforSystem;

                        structItem.IsSystemAutoZero = item.IsSystemAutoZero;
                        structItem.IsSystemCalibration = item.IsSystemCalibration;
                        structItem.IsSystemExternalOutput = item.IsSystemExternalOutput;
                        structItem.IsSystemIOTest = item.IsSystemIOTest;
                        structItem.IsSystemJudgmentSetting = item.IsSystemJudgmentSetting;
                        structItem.IsSystemSorterSetting = item.IsSystemSorterSetting;

                        structItem.IsLogJudge = item.IsLogJudge;
                        structItem.IsLogHistory = item.IsLogHistory;
                        structItem.IsLogOthers = item.IsLogOthers;

                        structItem.Dummy0 = true;
                        structItem.IsEquipManufacturerSetting = item.IsEquipManufacturerSetting;
                        structItem.Dummy2 = true;
                        structItem.Dummy3 = true;
                        structItem.Dummy4 = true;
                        structItem.Dummy5 = true;
                        structItem.Dummy6 = true;
                        structItem.Dummy7 = true;
                        structItem.Dummy8 = true;
                        structItem.Dummy9 = true;
                        structItem.Dummy10 = true;
                        structItem.Dummy11 = true;
                        structItem.Dummy12 = true;
                        structItem.Dummy13 = true;
                        structItem.Dummy14 = true;
                        structItem.Dummy15 = true;
                        structItem.Dummy16 = true;
                        #endregion
                        break;
                }
                this.smartFileIO.WriteStructure_Begin(structItem, i);
            }
            this.smartFileIO.WriteStructure_End();
        }
        public void SaveUserGroupFile(UserGroup item)
        {
            string fullFilePath = "";
            bool fileCheck = false;
            StructUserGroupItem structItem;

            fullFilePath = this.PathSDCardSystemFile1Folder + "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.IsMainDisplaySubMenu = item.Level1.IsMainDisplaySubMenu;
            structItem.IsMainDisplayClear = item.Level1.IsMainDisplayClear;

            structItem.IsBasicDataStatistics = item.Level1.IsBasicDataStatistics;
            structItem.IsBasicProduct = item.Level1.IsBasicProduct;
            structItem.IsBasicTime = item.Level1.IsBasicTime;

            structItem.IsConfiEthernet = item.Level1.IsConfiEthernet;
            structItem.IsConfiSerial = item.Level1.IsConfiSerial;
            structItem.IsConfiOption = item.Level1.IsConfiOption;

            structItem.IsEquipFunctionSetting = item.Level1.IsEquipFunctionSetting;
            structItem.IsEquipInitialize = item.Level1.IsEquipInitialize;
            structItem.IsEquipUpdate = item.Level1.IsEquipUpdate;
            structItem.IsEquipUser = item.Level1.IsEquipUserSetting;
            structItem.IsEquipEngineerSetting = item.Level1.IsEquipEngineerSetting;

            structItem.IsInforAS = item.Level1.IsInforAS;
            structItem.IsInforSystem = item.Level1.IsInforSystem;

            structItem.IsSystemAutoZero = item.Level1.IsSystemAutoZero;
            structItem.IsSystemCalibration = item.Level1.IsSystemCalibration;
            structItem.IsSystemExternalOutput = item.Level1.IsSystemExternalOutput;
            structItem.IsSystemIOTest = item.Level1.IsSystemIOTest;
            structItem.IsSystemJudgmentSetting = item.Level1.IsSystemJudgmentSetting;
            structItem.IsSystemSorterSetting = item.Level1.IsSystemSorterSetting;

            structItem.IsLogJudge = item.Level1.IsLogJudge;
            structItem.IsLogHistory = item.Level1.IsLogHistory;
            structItem.IsLogOthers = item.Level1.IsLogOthers;

            structItem.Dummy0 = false;
            structItem.IsEquipManufacturerSetting = item.Level1.IsEquipManufacturerSetting;
            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;

            this.smartFileIO.WriteStructure_Begin(structItem, (int)Define.E_FileUserGroup.f0_Level1);
            #endregion

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

            structItem.IsBasicDataStatistics = item.Level2.IsBasicDataStatistics;
            structItem.IsBasicProduct = item.Level2.IsBasicProduct;
            structItem.IsBasicTime = item.Level2.IsBasicTime;

            structItem.IsConfiEthernet = item.Level2.IsConfiEthernet;
            structItem.IsConfiSerial = item.Level2.IsConfiSerial;
            structItem.IsConfiOption = item.Level2.IsConfiOption;

            structItem.IsEquipFunctionSetting = item.Level2.IsEquipFunctionSetting;
            structItem.IsEquipInitialize = item.Level2.IsEquipInitialize;
            structItem.IsEquipUpdate = item.Level2.IsEquipUpdate;
            structItem.IsEquipUser = item.Level2.IsEquipUserSetting;
            structItem.IsEquipEngineerSetting = item.Level2.IsEquipEngineerSetting;

            structItem.IsInforAS = item.Level2.IsInforAS;
            structItem.IsInforSystem = item.Level2.IsInforSystem;

            structItem.IsSystemAutoZero = item.Level2.IsSystemAutoZero;
            structItem.IsSystemCalibration = item.Level2.IsSystemCalibration;
            structItem.IsSystemExternalOutput = item.Level2.IsSystemExternalOutput;
            structItem.IsSystemIOTest = item.Level2.IsSystemIOTest;
            structItem.IsSystemJudgmentSetting = item.Level2.IsSystemJudgmentSetting;
            structItem.IsSystemSorterSetting = item.Level2.IsSystemSorterSetting;

            structItem.IsLogJudge = item.Level2.IsLogJudge;
            structItem.IsLogHistory = item.Level2.IsLogHistory;
            structItem.IsLogOthers = item.Level2.IsLogOthers;

            structItem.Dummy0 = false;
            structItem.IsEquipManufacturerSetting = item.Level2.IsEquipManufacturerSetting;
            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;

            this.smartFileIO.WriteStructure_Begin(structItem, (int)Define.E_FileUserGroup.f1_Level2);
            #endregion

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

            structItem.IsBasicDataStatistics = item.Level3.IsBasicDataStatistics;
            structItem.IsBasicProduct = item.Level3.IsBasicProduct;
            structItem.IsBasicTime = item.Level3.IsBasicTime;

            structItem.IsConfiEthernet = item.Level3.IsConfiEthernet;
            structItem.IsConfiSerial = item.Level3.IsConfiSerial;
            structItem.IsConfiOption = item.Level3.IsConfiOption;

            structItem.IsEquipFunctionSetting = item.Level3.IsEquipFunctionSetting;
            structItem.IsEquipInitialize = item.Level3.IsEquipInitialize;
            structItem.IsEquipUpdate = item.Level3.IsEquipUpdate;
            structItem.IsEquipUser = item.Level3.IsEquipUserSetting;
            structItem.IsEquipEngineerSetting = item.Level3.IsEquipEngineerSetting;

            structItem.IsInforAS = item.Level3.IsInforAS;
            structItem.IsInforSystem = item.Level3.IsInforSystem;

            structItem.IsSystemAutoZero = item.Level3.IsSystemAutoZero;
            structItem.IsSystemCalibration = item.Level3.IsSystemCalibration;
            structItem.IsSystemExternalOutput = item.Level3.IsSystemExternalOutput;
            structItem.IsSystemIOTest = item.Level3.IsSystemIOTest;
            structItem.IsSystemJudgmentSetting = item.Level3.IsSystemJudgmentSetting;
            structItem.IsSystemSorterSetting = item.Level3.IsSystemSorterSetting;

            structItem.IsLogJudge = item.Level3.IsLogJudge;
            structItem.IsLogHistory = item.Level3.IsLogHistory;
            structItem.IsLogOthers = item.Level3.IsLogOthers;

            structItem.Dummy0 = false;
            structItem.IsEquipManufacturerSetting = item.Level3.IsEquipManufacturerSetting;
            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;

            this.smartFileIO.WriteStructure_Begin(structItem, (int)Define.E_FileUserGroup.f2_Level3);
            #endregion

            #region Not Login
            structItem.IsBasicDataStatistics = item.NotLogin.IsBasicDataStatistics;
            structItem.IsBasicProduct = item.NotLogin.IsBasicProduct;
            structItem.IsBasicTime = item.NotLogin.IsBasicTime;

            structItem.IsConfiEthernet = item.NotLogin.IsConfiEthernet;
            structItem.IsConfiSerial = item.NotLogin.IsConfiSerial;
            structItem.IsConfiOption = item.NotLogin.IsConfiOption;

            structItem.IsEquipFunctionSetting = item.NotLogin.IsEquipFunctionSetting;
            structItem.IsEquipInitialize = item.NotLogin.IsEquipInitialize;
            structItem.IsEquipUpdate = item.NotLogin.IsEquipUpdate;
            structItem.IsEquipUser = false;
            structItem.IsEquipEngineerSetting = false;

            structItem.IsInforAS = item.NotLogin.IsInforAS;
            structItem.IsInforSystem = item.NotLogin.IsInforSystem;

            structItem.IsSystemAutoZero = item.NotLogin.IsSystemAutoZero;
            structItem.IsSystemCalibration = item.NotLogin.IsSystemCalibration;
            structItem.IsSystemExternalOutput = item.NotLogin.IsSystemExternalOutput;
            structItem.IsSystemIOTest = item.NotLogin.IsSystemIOTest;
            structItem.IsSystemJudgmentSetting = item.NotLogin.IsSystemJudgmentSetting;
            structItem.IsSystemSorterSetting = item.NotLogin.IsSystemSorterSetting;

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

            structItem.IsLogJudge = item.NotLogin.IsLogJudge;
            structItem.IsLogHistory = item.NotLogin.IsLogHistory;
            structItem.IsLogOthers = item.NotLogin.IsLogOthers;

            structItem.Dummy0 = false;
            structItem.IsEquipManufacturerSetting = item.NotLogin.IsEquipManufacturerSetting;
            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;

            this.smartFileIO.WriteStructure_Begin(structItem, (int)Define.E_FileUserGroup.f3_NotLogin);
            #endregion

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

            fullFilePath = this.PathSDCardSystemFile1Folder + "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.IsMainDisplayProductNo;
            structItem.IsMainDisplayWeightSetting = item.IsMainDisplayWeightSetting;
            structItem.IsMainDisplaySubMenu = item.IsMainDisplaySubMenu;
            structItem.IsMainDisplayClear = item.IsMainDisplayClear;

            structItem.IsBasicDataStatistics = item.IsBasicDataStatistics;
            structItem.IsBasicProduct = item.IsBasicProduct;
            structItem.IsBasicTime = item.IsBasicTime;

            structItem.IsConfiEthernet = item.IsConfiEthernet;
            structItem.IsConfiSerial = item.IsConfiSerial;
            structItem.IsConfiOption = item.IsConfiOption;

            structItem.IsEquipFunctionSetting = item.IsEquipFunctionSetting;
            structItem.IsEquipInitialize = item.IsEquipInitialize;
            structItem.IsEquipUpdate = item.IsEquipUpdate;
            structItem.IsEquipUser = item.IsEquipUserSetting;
            structItem.IsEquipEngineerSetting = item.IsEquipEngineerSetting;

            structItem.IsInforAS = item.IsInforAS;
            structItem.IsInforSystem = item.IsInforSystem;

            structItem.IsSystemAutoZero = item.IsSystemAutoZero;
            structItem.IsSystemCalibration = item.IsSystemCalibration;
            structItem.IsSystemExternalOutput = item.IsSystemExternalOutput;
            structItem.IsSystemIOTest = item.IsSystemIOTest;
            structItem.IsSystemJudgmentSetting = item.IsSystemJudgmentSetting;
            structItem.IsSystemSorterSetting = item.IsSystemSorterSetting;

            structItem.IsLogJudge = item.IsLogJudge;
            structItem.IsLogHistory = item.IsLogHistory;
            structItem.IsLogOthers = item.IsLogOthers;

            structItem.Dummy0 = false;
            structItem.IsEquipManufacturerSetting = item.IsEquipManufacturerSetting;
            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;

            this.smartFileIO.WriteStructure_Begin(structItem, (int)Define.E_FileUserGroup.f0_Level1);
            #endregion

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

            fullFilePath = this.PathSDCardSystemFile1Folder + "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 Level2
            structItem.IsMainDisplayProductNo = item.IsMainDisplayProductNo;
            structItem.IsMainDisplayWeightSetting = item.IsMainDisplayWeightSetting;
            structItem.IsMainDisplaySubMenu = item.IsMainDisplaySubMenu;
            structItem.IsMainDisplayClear = item.IsMainDisplayClear;

            structItem.IsBasicDataStatistics = item.IsBasicDataStatistics;
            structItem.IsBasicProduct = item.IsBasicProduct;
            structItem.IsBasicTime = item.IsBasicTime;

            structItem.IsConfiEthernet = item.IsConfiEthernet;
            structItem.IsConfiSerial = item.IsConfiSerial;
            structItem.IsConfiOption = item.IsConfiOption;

            structItem.IsEquipFunctionSetting = item.IsEquipFunctionSetting;
            structItem.IsEquipInitialize = item.IsEquipInitialize;
            structItem.IsEquipUpdate = item.IsEquipUpdate;
            structItem.IsEquipUser = item.IsEquipUserSetting;
            structItem.IsEquipEngineerSetting = item.IsEquipEngineerSetting;

            structItem.IsInforAS = item.IsInforAS;
            structItem.IsInforSystem = item.IsInforSystem;

            structItem.IsSystemAutoZero = item.IsSystemAutoZero;
            structItem.IsSystemCalibration = item.IsSystemCalibration;
            structItem.IsSystemExternalOutput = item.IsSystemExternalOutput;
            structItem.IsSystemIOTest = item.IsSystemIOTest;
            structItem.IsSystemJudgmentSetting = item.IsSystemJudgmentSetting;
            structItem.IsSystemSorterSetting = item.IsSystemSorterSetting;

            structItem.IsLogJudge = item.IsLogJudge;
            structItem.IsLogHistory = item.IsLogHistory;
            structItem.IsLogOthers = item.IsLogOthers;

            structItem.Dummy0 = false;
            structItem.IsEquipManufacturerSetting = item.IsEquipManufacturerSetting;
            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;

            this.smartFileIO.WriteStructure_Begin(structItem, (int)Define.E_FileUserGroup.f1_Level2);
            #endregion

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

            fullFilePath = this.PathSDCardSystemFile1Folder + "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 Level3
            structItem.IsMainDisplayProductNo = item.IsMainDisplayProductNo;
            structItem.IsMainDisplayWeightSetting = item.IsMainDisplayWeightSetting;
            structItem.IsMainDisplaySubMenu = item.IsMainDisplaySubMenu;
            structItem.IsMainDisplayClear = item.IsMainDisplayClear;

            structItem.IsBasicDataStatistics = item.IsBasicDataStatistics;
            structItem.IsBasicProduct = item.IsBasicProduct;
            structItem.IsBasicTime = item.IsBasicTime;

            structItem.IsConfiEthernet = item.IsConfiEthernet;
            structItem.IsConfiSerial = item.IsConfiSerial;
            structItem.IsConfiOption = item.IsConfiOption;

            structItem.IsEquipFunctionSetting = item.IsEquipFunctionSetting;
            structItem.IsEquipInitialize = item.IsEquipInitialize;
            structItem.IsEquipUpdate = item.IsEquipUpdate;
            structItem.IsEquipUser = true;
            structItem.IsEquipEngineerSetting = item.IsEquipEngineerSetting;

            structItem.IsInforAS = item.IsInforAS;
            structItem.IsInforSystem = item.IsInforSystem;

            structItem.IsSystemAutoZero = item.IsSystemAutoZero;
            structItem.IsSystemCalibration = item.IsSystemCalibration;
            structItem.IsSystemExternalOutput = item.IsSystemExternalOutput;
            structItem.IsSystemIOTest = item.IsSystemIOTest;
            structItem.IsSystemJudgmentSetting = item.IsSystemJudgmentSetting;
            structItem.IsSystemSorterSetting = item.IsSystemSorterSetting;

            structItem.IsLogJudge = item.IsLogJudge;
            structItem.IsLogHistory = item.IsLogHistory;
            structItem.IsLogOthers = item.IsLogOthers;

            structItem.Dummy0 = false;
            structItem.IsEquipManufacturerSetting = item.IsEquipManufacturerSetting;
            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;

            this.smartFileIO.WriteStructure_Begin(structItem, (int)Define.E_FileUserGroup.f2_Level3);
            #endregion

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

            fullFilePath = this.PathSDCardSystemFile1Folder + "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 NotLogin
            structItem.IsMainDisplayProductNo = item.IsMainDisplayProductNo;
            structItem.IsMainDisplayWeightSetting = item.IsMainDisplayWeightSetting;
            structItem.IsMainDisplaySubMenu = item.IsMainDisplaySubMenu;
            structItem.IsMainDisplayClear = item.IsMainDisplayClear;

            structItem.IsBasicDataStatistics = item.IsBasicDataStatistics;
            structItem.IsBasicProduct = item.IsBasicProduct;
            structItem.IsBasicTime = item.IsBasicTime;

            structItem.IsConfiEthernet = item.IsConfiEthernet;
            structItem.IsConfiSerial = item.IsConfiSerial;
            structItem.IsConfiOption = item.IsConfiOption;

            structItem.IsEquipFunctionSetting = item.IsEquipFunctionSetting;
            structItem.IsEquipInitialize = item.IsEquipInitialize;
            structItem.IsEquipUpdate = item.IsEquipUpdate;
            structItem.IsEquipUser = item.IsEquipUserSetting;
            structItem.IsEquipEngineerSetting = item.IsEquipEngineerSetting;

            structItem.IsInforAS = item.IsInforAS;
            structItem.IsInforSystem = item.IsInforSystem;

            structItem.IsSystemAutoZero = item.IsSystemAutoZero;
            structItem.IsSystemCalibration = item.IsSystemCalibration;
            structItem.IsSystemExternalOutput = item.IsSystemExternalOutput;
            structItem.IsSystemIOTest = item.IsSystemIOTest;
            structItem.IsSystemJudgmentSetting = item.IsSystemJudgmentSetting;
            structItem.IsSystemSorterSetting = item.IsSystemSorterSetting;

            structItem.IsLogJudge = item.IsLogJudge;
            structItem.IsLogHistory = item.IsLogHistory;
            structItem.IsLogOthers = item.IsLogOthers;

            structItem.Dummy0 = false;
            structItem.IsEquipManufacturerSetting = item.IsEquipManufacturerSetting;
            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;

            this.smartFileIO.WriteStructure_Begin(structItem, (int)Define.E_FileUserGroup.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.PathSDCardSystemFile1Folder + "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)Define.E_FileUserGroup.f0_Level1);

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

                    item.Level1.IsBasicDataStatistics = structItem.IsBasicDataStatistics;
                    item.Level1.IsBasicProduct = structItem.IsBasicProduct;
                    item.Level1.IsBasicTime = structItem.IsBasicTime;

                    item.Level1.IsConfiEthernet = structItem.IsConfiEthernet;
                    item.Level1.IsConfiSerial = structItem.IsConfiSerial;
                    item.Level1.IsConfiOption = structItem.IsConfiOption;

                    item.Level1.IsEquipFunctionSetting = structItem.IsEquipFunctionSetting;
                    item.Level1.IsEquipInitialize = structItem.IsEquipInitialize;
                    item.Level1.IsEquipUpdate = structItem.IsEquipUpdate;
                    item.Level1.IsEquipUserSetting = structItem.IsEquipUser;
                    item.Level1.IsEquipEngineerSetting = structItem.IsEquipEngineerSetting;

                    item.Level1.IsInforAS = structItem.IsInforAS;
                    item.Level1.IsInforSystem = structItem.IsInforSystem;

                    item.Level1.IsSystemAutoZero = structItem.IsSystemAutoZero;
                    item.Level1.IsSystemCalibration = structItem.IsSystemCalibration;
                    item.Level1.IsSystemExternalOutput = structItem.IsSystemExternalOutput;
                    item.Level1.IsSystemIOTest = structItem.IsSystemIOTest;
                    item.Level1.IsSystemJudgmentSetting = structItem.IsSystemJudgmentSetting;
                    item.Level1.IsSystemSorterSetting = structItem.IsSystemSorterSetting;

                    item.Level1.IsLogJudge = structItem.IsLogJudge;
                    item.Level1.IsLogHistory = structItem.IsLogHistory;
                    item.Level1.IsLogOthers = structItem.IsLogOthers;

                    item.Level1.IsEquipManufacturerSetting = structItem.IsEquipManufacturerSetting;
                    #endregion

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

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

                    item.Level2.IsBasicDataStatistics = structItem.IsBasicDataStatistics;
                    item.Level2.IsBasicProduct = structItem.IsBasicProduct;
                    item.Level2.IsBasicTime = structItem.IsBasicTime;

                    item.Level2.IsConfiEthernet = structItem.IsConfiEthernet;
                    item.Level2.IsConfiSerial = structItem.IsConfiSerial;
                    item.Level2.IsConfiOption = structItem.IsConfiOption;

                    item.Level2.IsEquipFunctionSetting = structItem.IsEquipFunctionSetting;
                    item.Level2.IsEquipInitialize = structItem.IsEquipInitialize;
                    item.Level2.IsEquipUpdate = structItem.IsEquipUpdate;
                    item.Level2.IsEquipUserSetting = structItem.IsEquipUser;
                    item.Level2.IsEquipEngineerSetting = structItem.IsEquipEngineerSetting;

                    item.Level2.IsInforAS = structItem.IsInforAS;
                    item.Level2.IsInforSystem = structItem.IsInforSystem;

                    item.Level2.IsSystemAutoZero = structItem.IsSystemAutoZero;
                    item.Level2.IsSystemCalibration = structItem.IsSystemCalibration;
                    item.Level2.IsSystemExternalOutput = structItem.IsSystemExternalOutput;
                    item.Level2.IsSystemIOTest = structItem.IsSystemIOTest;
                    item.Level2.IsSystemJudgmentSetting = structItem.IsSystemJudgmentSetting;
                    item.Level2.IsSystemSorterSetting = structItem.IsSystemSorterSetting;

                    item.Level2.IsLogJudge = structItem.IsLogJudge;
                    item.Level2.IsLogHistory = structItem.IsLogHistory;
                    item.Level2.IsLogOthers = structItem.IsLogOthers;

                    item.Level2.IsEquipManufacturerSetting = structItem.IsEquipManufacturerSetting;
                    #endregion

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

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

                    item.Level3.IsBasicDataStatistics = structItem.IsBasicDataStatistics;
                    item.Level3.IsBasicProduct = structItem.IsBasicProduct;
                    item.Level3.IsBasicTime = structItem.IsBasicTime;

                    item.Level3.IsConfiEthernet = structItem.IsConfiEthernet;
                    item.Level3.IsConfiSerial = structItem.IsConfiSerial;
                    item.Level3.IsConfiOption = structItem.IsConfiOption;

                    item.Level3.IsEquipFunctionSetting = structItem.IsEquipFunctionSetting;
                    item.Level3.IsEquipInitialize = structItem.IsEquipInitialize;
                    item.Level3.IsEquipUpdate = structItem.IsEquipUpdate;
                    item.Level3.IsEquipUserSetting = structItem.IsEquipUser;
                    item.Level3.IsEquipEngineerSetting = structItem.IsEquipEngineerSetting;

                    item.Level3.IsInforAS = structItem.IsInforAS;
                    item.Level3.IsInforSystem = structItem.IsInforSystem;

                    item.Level3.IsSystemAutoZero = structItem.IsSystemAutoZero;
                    item.Level3.IsSystemCalibration = structItem.IsSystemCalibration;
                    item.Level3.IsSystemExternalOutput = structItem.IsSystemExternalOutput;
                    item.Level3.IsSystemIOTest = structItem.IsSystemIOTest;
                    item.Level3.IsSystemJudgmentSetting = structItem.IsSystemJudgmentSetting;
                    item.Level3.IsSystemSorterSetting = structItem.IsSystemSorterSetting;

                    item.Level3.IsLogJudge = structItem.IsLogJudge;
                    item.Level3.IsLogHistory = structItem.IsLogHistory;
                    item.Level3.IsLogOthers = structItem.IsLogOthers;

                    item.Level3.IsEquipManufacturerSetting = structItem.IsEquipManufacturerSetting;
                    #endregion

                    #region Not Login
                    try
                    {
                        structItem = (StructUserGroupItem)this.smartFileIO.ReadStructureBuffer(typeof(StructUserGroupItem), (int)Define.E_FileUserGroup.f3_NotLogin);

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

                        item.NotLogin.IsBasicDataStatistics = structItem.IsBasicDataStatistics;
                        item.NotLogin.IsBasicProduct = structItem.IsBasicProduct;
                        item.NotLogin.IsBasicTime = structItem.IsBasicTime;

                        item.NotLogin.IsConfiSerial = structItem.IsConfiSerial;
                        item.NotLogin.IsConfiOption = structItem.IsConfiOption;
                        item.NotLogin.IsConfiEthernet = structItem.IsConfiEthernet;

                        item.NotLogin.IsEquipFunctionSetting = structItem.IsEquipFunctionSetting;
                        item.NotLogin.IsEquipInitialize = structItem.IsEquipInitialize;
                        item.NotLogin.IsEquipUpdate = structItem.IsEquipUpdate;
                        item.NotLogin.IsEquipUserSetting = structItem.IsEquipUser;
                        item.NotLogin.IsEquipEngineerSetting = structItem.IsEquipEngineerSetting;

                        item.NotLogin.IsInforAS = structItem.IsInforAS;
                        item.NotLogin.IsInforSystem = structItem.IsInforSystem;

                        item.NotLogin.IsSystemAutoZero = structItem.IsSystemAutoZero;
                        item.NotLogin.IsSystemCalibration = structItem.IsSystemCalibration;
                        item.NotLogin.IsSystemExternalOutput = structItem.IsSystemExternalOutput;
                        item.NotLogin.IsSystemIOTest = structItem.IsSystemIOTest;
                        item.NotLogin.IsSystemJudgmentSetting = structItem.IsSystemJudgmentSetting;
                        item.NotLogin.IsSystemSorterSetting = structItem.IsSystemSorterSetting;

                        item.NotLogin.IsLogJudge = structItem.IsLogJudge;
                        item.NotLogin.IsLogHistory = structItem.IsLogHistory;
                        item.NotLogin.IsLogOthers = structItem.IsLogOthers;

                        item.NotLogin.IsEquipManufacturerSetting = structItem.IsEquipManufacturerSetting;
                    }
                    catch
                    {
                        #region Not Login
                        item.NotLogin.IsBasicDataStatistics = structItem.IsBasicDataStatistics = true;
                        item.NotLogin.IsBasicProduct = structItem.IsBasicProduct = true;
                        item.NotLogin.IsBasicTime = structItem.IsBasicTime = true;

                        item.NotLogin.IsConfiSerial = structItem.IsConfiSerial = true;
                        item.NotLogin.IsConfiOption = structItem.IsConfiOption = true;
                        item.NotLogin.IsConfiEthernet = structItem.IsConfiEthernet = true;

                        item.NotLogin.IsEquipFunctionSetting = structItem.IsEquipFunctionSetting = true;
                        item.NotLogin.IsEquipInitialize = structItem.IsEquipInitialize = true;
                        item.NotLogin.IsEquipUpdate = structItem.IsEquipUpdate = true;
                        item.NotLogin.IsEquipUserSetting = structItem.IsEquipUser = false;
                        item.NotLogin.IsEquipEngineerSetting = structItem.IsEquipEngineerSetting = false;

                        item.NotLogin.IsInforAS = structItem.IsInforAS = true;
                        item.NotLogin.IsInforSystem = structItem.IsInforSystem = true;

                        item.NotLogin.IsSystemAutoZero = structItem.IsSystemAutoZero = true;
                        item.NotLogin.IsSystemCalibration = structItem.IsSystemCalibration = true;
                        item.NotLogin.IsSystemExternalOutput = structItem.IsSystemExternalOutput = true;
                        item.NotLogin.IsSystemIOTest = structItem.IsSystemIOTest = true;
                        item.NotLogin.IsSystemJudgmentSetting = structItem.IsSystemJudgmentSetting = true;
                        item.NotLogin.IsSystemSorterSetting = structItem.IsSystemSorterSetting = true;

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

                        item.NotLogin.IsLogJudge = structItem.IsLogJudge = true;
                        item.NotLogin.IsLogHistory = structItem.IsLogHistory = true;
                        item.NotLogin.IsLogOthers = structItem.IsLogOthers = true;

                        structItem.Dummy0 = true;
                        structItem.IsEquipManufacturerSetting = structItem.IsEquipManufacturerSetting = true;
                        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;
                        #endregion

                        this.smartFileIO.WriteStructure_Begin(structItem, 3);
                        this.smartFileIO.WriteStructure_End();
                    }
                    #endregion
                }
            }
            catch
            {
                DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig1.Language);
                myMsg.ShowDialog();
            }
            this.smartFileIO.Close();
        }
        #endregion

        #endregion
        #endregion

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

            // 변수 초기 셋팅1
            this.DefaultSetting1();

            // SystemConfiguration 파일 읽기
            this.LoadSystemConfigurationFile1();
            this.LoadSystemConfigurationFile2();
            this.LoadSystemConfigurationFile3();

            // SystemParameter1
            this.LoadSystemParameter1File(ref this.CurrentSystemParameter1);

            // SystemParameter2
            this.LoadSystemParameter2File(ref this.CurrentSystemParameter2);

            // SystemParameter3
            this.LoadSystemParameter3File(ref this.CurrentSystemParameter3);

            // SystemParameter4
            this.LoadSystemParameter4File(ref this.CurrentSystemParameter4);

            // Product File Load
            this.LoadProductFile(ref this.CollectionProductItem);

            // Judgment File Load
            this.LoadJudgmentSetFile(ref this.CollectionJudgmentItem);

            // Counter File Load
            this.LoadCounterFile(ref this.CollectionWeightData);

            // BLDC Motor Settings 파일 읽기
            this.LoadBLDCMotorFile(ref this.CollectionBLDCParameter);

            // UserGroup 파일 읽기
            this.LoadUserGroupFile(ref this.CurrentUserGroup);
            
            this.SetTrackingHistoryData(Define.E_TrackingOperation.PowerOn, "");

            // 폼 생성
            this.CreateForm();

            // 메인 통신 OPEN
            this.OpenSmartSerialPort2();

            // 통신 버퍼용
            if (this.FlagSerialDll == true)
            {
                this.smartThreadSerialPort2Read.Priority = ThreadPriority.Normal;
                this.smartThreadSerialPort2Read.Start();
                //this.smartThreadSerialPort2OverRun.Start();
            }

            #region Communication
            if (this.SystemConfig1.SerialCOM1Mode != (int)Define.E_CommMode.f0_None)
            {
                switch (this.SystemConfig1.SerialCOM1Mode)
                {
                    case (int)Define.E_CommMode.f16_OPC:
                    case (int)Define.E_CommMode.f22_Modbus:
                        this.ChildFormMainDisplay.MainBottomModbusIconAdd(true);
                        break;
                    default:
                        break;
                }

                // COM1 OPEN
                this.OpenSerialCOM1();
            }

            if (this.SystemConfig1.SerialCOM3Mode != (int)Define.E_CommMode.f0_None)
            {
                switch (this.SystemConfig1.SerialCOM3Mode)
                {
                    case (int)Define.E_CommMode.f16_OPC:
                    case (int)Define.E_CommMode.f22_Modbus:
                        this.ChildFormMainDisplay.MainBottomModbusIconAdd(true);
                        break;
                    default:
                        break;
                }

                // COM3 OPEN
                this.OpenSerialCOM3();
            }

            if (this.SystemConfig1.SerialCOM4Mode != (int)Define.E_CommMode.f0_None)
            {
                switch (this.SystemConfig1.SerialCOM4Mode)
                {
                    case (int)Define.E_CommMode.f16_OPC:
                    case (int)Define.E_CommMode.f22_Modbus:
                        this.ChildFormMainDisplay.MainBottomModbusIconAdd(true);
                        break;
                    default:
                        break;
                }

                // COM4 OPEN
                this.OpenSerialCOM4();
            }
            #endregion

            // Write SystemParameter1
            this.TransferParameter1();

            // 변수 초기 셋팅2(바코드 셋팅, 이더넷)
            this.DefaultSetting2();

            if (this.SystemConfig1.IsLogin == true)
            {
                // UserManager 초기화
                this.InitializeUserManager();

                if (this.SystemConfig3.IsPart11 == false)
                    UserManager.UserManager_AutoLogoutTimeoutPause();
            }
            else
            {
                this.ChildFormMenu.CenterEquipUserGroupEditor.UpdateAllMenu(this.CurrentSystemStatus);
            }

            if (this.SystemConfig3.IsPart11 == true)
                // Encryption 초기화
                this.InitializeAES();

            // 현재 Version.ini 파일 생성 혹은 갱신
            this.CheckCurrentVersionIniFile();

            this.SmartSplashProgramLoad.Finish();

            this.smartForm.Show((int)Define.E_FormStore.FormMainDisplay);
            this.ChildFormMainDisplay.CurrentBottomMenuControlEnable();

            this.timerUserList.Enabled = true;

            // Mouse On
            //this.smartForm.Mode = SmartForm.RUNMODE.DEVELOPER;
            //this.smartForm.MouseCursor = SmartForm.OnOff.ON;
        }
        #endregion

        #region Event Handler
        private void SerialReceiveData(string data)
        {
            string cmd = "", dataID = "", transferCNT = "", lane = "";

            try
            {
                if (this.FlagSerialDll == false)
                {
                    cmd = data.Substring(0, 3);
                    if (cmd == "SR0")
                    {
                        if (this.SizeCheck("S", data) == true && this.ChksumCheck(data) == true)
                        {
                            dataID = data.Substring(3, 1);
                            transferCNT = data.Substring(4, 1);
                            lane = data.Substring(5, 1);

                            this.TransferDataRespone(CommunicationCommand.StartDataCMD, lane, dataID, transferCNT, ((int)Define.E_ResponseData.ACK).ToString());
                            Application.DoEvents();
                        }
                    }
                }

                // 수신 버퍼 삭제 하고 테스트
                this.QueueCommunicationRecive.Enqueue(data);
                //this.ReceiveData1(data);

                this.ChildFormMainDisplay.labelBufferCNT.BeginInvoke(new Action(() =>
                {
                    this.ChildFormMainDisplay.labelBufferCNT.Text = this.QueueCommunicationRecive.Count.ToString();
                }));

                // 통신 확인
                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 smartSerialPort1_OnReadQueueEvent()
        {
            int ret = 0;
            string strTemp = "";
            byte[] readByte;

            SmartSerialPort.FRAMEDATAREADSTATUS receiveDataState = SmartSerialPort.FRAMEDATAREADSTATUS.EMPTY;

            try
            {
                receiveDataState = this.smartSerialPort1.ReadQueue(out readByte);
                if (this.SystemConfig1.SerialCOM1Mode != 4 && this.SystemConfig1.SerialCOM1Mode != 5)
                    strTemp = Encoding.Default.GetString(readByte, 0, readByte.Length);

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

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

            switch (this.SystemConfig1.SerialCOM1Mode)
            {
                case 5:
                    #region imaje 9028 OPT1 - 한맥프린터(네추럴 F&P)
                    if (readByte[0] != 0x06) // ACK가 아니면 재발송
                    {
                        switch (this.HMCOM1_Step)
                        {
                            case 1:
                                this.TransferSerialCOM1(this.SendChar(Define.E_CharValue.ENQ));
                                break;
                            case 2:
                                this.TransferSerialCOM1(this.RoomChange9028(2));
                                break;
                            case 3:
                                this.TransferSerialCOM1(this.RoomChange9028(1));
                                break;
                            case 4:
                                this.TransferSerialCOM1(this.WeightData9028(this.CurrentWeightData)); // 중량값 전송
                                break;
                            default:
                                break;
                        }
                    }
                    else
                    {
                        switch (this.HMCOM1_Step)
                        {
                            case 1:
                                if (this.CurrentWeightData.JudgmentStatus == Define.E_JudgmentStatus.Pass)
                                {
                                    this.HMCOM1_Step = 2;
                                    this.TransferSerialCOM1(this.RoomChange9028(2));
                                }
                                else
                                {
                                    this.HMCOM1_Step = 3;
                                    this.TransferSerialCOM1(this.RoomChange9028(1));
                                }
                                break;
                            case 2:
                                this.HMCOM1_Step = 4;
                                this.TransferSerialCOM1(this.WeightData9028(this.CurrentWeightData)); // 중량값 전송
                                break;
                            case 3:
                                break;
                            case 4:
                                break;
                            default:
                                break;
                        }
                    }
                    #endregion
                    break;
                case 10:
                    #region MACSA Laser
                    if (strTemp[0] == 0x02)
                    {
                        if (strTemp[3] == 0x15)
                        {
                            if (strTemp[6] == 0x54)
                            {
                                if (this.IsMACSARetransmissionCOM1 == true)
                                {
                                    // MACSA 통신전송이 실패하였습니다.
                                    DialogFormMessage msg = new DialogFormMessage(24, this.SystemConfig1.Language);
                                    msg.ShowDialog();

                                    this.IsMACSARetransmissionCOM1 = false;
                                }
                                else
                                {
                                    this.TransferSerialCOM1(this.CurrentMACSACOM1);

                                    this.IsMACSARetransmissionCOM1 = true;
                                }
                            }
                        }
                    }
                    #endregion
                    break;
                case 15:
                    #region OPT2
                    int iValue = 0;

                    if (strTemp[0] == 0x02)
                    {
                        this.CurrentOPT2COM1.IsReceivedData = true;

                        if ((strTemp.Length != 7) || (strTemp.Length < 7) || (strTemp[6] != 0x03))
                        {
                            // Response 현재품번으로 해서 응답
                            this.CurrentOPT2COM1.IsErrorReceivedData = true;
                            this.TransferSerialCOM1(this.ResponseFrameOPT2());
                            return;
                        }

                        try
                        {
                            iValue = int.Parse(strTemp.Substring(4, 2));
                        }
                        catch
                        {
                            // Response 현재품번으로 해서 응답
                            this.CurrentOPT2COM1.IsErrorReceivedData = true;
                            this.TransferSerialCOM1(this.ResponseFrameOPT2());
                            return;
                        }

                        if ((iValue < 0) || (iValue > 50))
                        {
                            // Response 현재품번으로 해서 응답
                            this.CurrentOPT2COM1.IsErrorSettingStatus = true;
                            this.TransferSerialCOM1(this.ResponseFrameOPT2());
                            return;
                        }
                        this.CurrentOPT2COM1.IsErrorReceivedData = false;
                        this.CurrentOPT2COM1.IsErrorSettingStatus = false;

                        this.TransferProductParameter(iValue);

                        this.Invoke(new SerialOPT2COM1_Delegate(this.SerialOPT2COM1Delegate));
                    }
                    #endregion
                    break;
                case (int)Define.E_CommMode.f16_OPC:
                    #region OPC
                    try
                    {
                        byte[] responseData;
                        byte errorCheck = this.Modbus.CheckRequestDataErrorRTU(readByte, ModbusFunctionCode.FunctionCode_04);

                        if (errorCheck == 0x00)
                            responseData = this.Modbus.MakeRTU04ResponseData(this.Transfer_22_Modbus_Read_RTU(readByte), this.SystemConfig2.ModbusSlaveIDCOM1);
                        else
                            responseData = this.Modbus.MakeRTU04ErrorResponseData(errorCheck, this.SystemConfig2.ModbusSlaveIDCOM1);

                        this.TransferSerialCOM1(responseData);

                        // 로그
                        if (this.IsCommunicationLogOpen == true)
                            this.smartFileCommunicationLog.WriteString(string.Format("Send COM1 ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, BitConverter.ToString(responseData)));
                    }
                    catch
                    {
                    }
                    #endregion
                    break;
                case (int)Define.E_CommMode.f22_Modbus:
                    #region Modbus RTU
                    this.ChildFormMainDisplay.MainModbus.UpdateReceiveCount();

                    if (this.SystemConfig2.ModbusSlaveIDCOM1 != Convert.ToInt32(readByte[0]))
                        return;

                    if (readByte[1] == 0x03) // Read Holding Register
                    {
                        #region Read Holding Register
                        try
                        {
                            byte[] responseData;
                            byte errorCheck = this.Modbus.CheckRequestDataErrorRTU(readByte, ModbusFunctionCode.FunctionCode_03);

                            if (errorCheck == 0x00)
                                responseData = this.Modbus.MakeRTUResponseData(this.Transfer_22_Modbus_Read_RTU(readByte), this.SystemConfig2.ModbusSlaveIDCOM1, ModbusFunctionCode.FunctionCode_03);
                            else
                                responseData = this.Modbus.MakeRTUErrorResponseData(errorCheck, this.SystemConfig2.ModbusSlaveIDCOM1, ModbusFunctionCode.FunctionCode_03);

                            this.TransferSerialCOM1(responseData);

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

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

                                crc = this.Modbus.MakeRTUCRC(responseData, responseData.Length - 2);
                                for (int i = 0; i < 2; i++)
                                    responseData[6 + i] = crc[i];

                                this.TransferSerialCOM1(responseData);

                                this.ReceiveModbusRTUWriteManager(readByte);
                            }
                            else
                            {
                                errorResponseData[0] = readByte[0];
                                errorResponseData[1] = 0x90;
                                errorResponseData[2] = errorCheck;

                                crc = this.Modbus.MakeRTUCRC(errorResponseData, errorResponseData.Length - 2);
                                for (int i = 0; i < 2; i++)
                                    errorResponseData[3 + i] = crc[i];

                                this.TransferSerialCOM1(errorResponseData);
                            }

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

                                if (errorCheck == 0x00)
                                    responseData = this.Modbus.MakeRTU04ResponseData(this.Transfer_22_Modbus_Read_RTU(readByte), this.SystemConfig2.ModbusSlaveIDCOM1);
                                else
                                    responseData = this.Modbus.MakeRTU04ErrorResponseData(errorCheck, this.SystemConfig2.ModbusSlaveIDCOM1);

                                this.TransferSerialCOM1(responseData);

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

        }
        private void smartSerialPort2_OnReadQueueEvent()
        {
            string strTemp = "";
            byte[] readByte;

            SmartSerialPort.FRAMEDATAREADSTATUS receiveDataState = SmartSerialPort.FRAMEDATAREADSTATUS.EMPTY;

            try
            {
                receiveDataState = this.smartSerialPort2.ReadQueue(out readByte);
                strTemp = Encoding.Default.GetString(readByte, 0, readByte.Length);
            }
            catch
            {
                return;
            }

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

            if (this.FlagSerialDll == true)
                this.SerialReceiveData(strTemp);
            else
            {
                this.ReceiveData(strTemp);

                // 통신 확인
                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;
                }
            }
        }
        private void smartSerialPort3_OnReadQueueEvent()
        {
            int productNo = 0;
            string strTemp = "", value = "";
            byte[] readByte;
            BarcodeStatus status = BarcodeStatus.None;
            SmartSerialPort.FRAMEDATAREADSTATUS receiveDataState = SmartSerialPort.FRAMEDATAREADSTATUS.EMPTY;

            try
            {
                receiveDataState = this.smartSerialPort3.ReadQueue(out readByte);
                if (this.SystemConfig1.SerialCOM3Mode != 4 && this.SystemConfig1.SerialCOM3Mode != 5)
                    strTemp = Encoding.Default.GetString(readByte, 0, readByte.Length);

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

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

            switch (this.SystemConfig1.SerialCOM3Mode)
            {
                case 5:
                    #region imaje 9028 OPT1 - 한맥프린터(네추럴 F&P)
                    if (readByte[0] != 0x06) // ACK가 아니면 재발송
                    {
                        switch (this.HMCOM3_Step)
                        {
                            case 1:
                                this.TransferSerialCOM3(this.SendChar(Define.E_CharValue.ENQ));
                                break;
                            case 2:
                                this.TransferSerialCOM3(this.RoomChange9028(2));
                                break;
                            case 3:
                                this.TransferSerialCOM3(this.RoomChange9028(1));
                                break;
                            case 4:
                                this.TransferSerialCOM3(this.WeightData9028(this.CurrentWeightData)); // 중량값 전송
                                break;
                            default:
                                break;
                        }
                    }
                    else
                    {
                        switch (this.HMCOM3_Step)
                        {
                            case 1:
                                if (this.CurrentWeightData.JudgmentStatus == Define.E_JudgmentStatus.Pass)
                                {
                                    this.HMCOM3_Step = 2;
                                    this.TransferSerialCOM3(this.RoomChange9028(2));
                                }
                                else
                                {
                                    this.HMCOM3_Step = 3;
                                    this.TransferSerialCOM3(this.RoomChange9028(1));
                                }
                                break;
                            case 2:
                                this.HMCOM3_Step = 4;
                                this.TransferSerialCOM3(this.WeightData9028(this.CurrentWeightData)); // 중량값 전송
                                break;
                            case 3:
                                break;
                            case 4:
                                break;
                            default:
                                break;
                        }
                    }
                    #endregion
                    break;
                case 10:
                    #region MACSA Laser
                    if (strTemp[0] == 0x02)
                    {
                        if (strTemp[3] == 0x15)
                        {
                            if (strTemp[6] == 0x54)
                            {
                                if (this.IsMACSARetransmissionCOM3 == true)
                                {
                                    // MACSA 통신전송이 실패하였습니다.
                                    DialogFormMessage msg = new DialogFormMessage(24, this.SystemConfig1.Language);
                                    msg.ShowDialog();

                                    this.IsMACSARetransmissionCOM3 = false;
                                }
                                else
                                {
                                    this.TransferSerialCOM3(this.CurrentMACSACOM3);

                                    this.IsMACSARetransmissionCOM3 = true;
                                }
                            }
                        }
                    }
                    #endregion
                    break;
                case 15:
                    #region OPT2
                    int iValue = 0;

                    if (strTemp[0] == 0x02)
                    {
                        this.CurrentOPT2COM3.IsReceivedData = true;

                        if ((strTemp.Length != 7) || (strTemp.Length < 7) || (strTemp[6] != 0x03))
                        {
                            // Response 현재품번으로 해서 응답
                            this.CurrentOPT2COM3.IsErrorReceivedData = true;
                            this.TransferSerialCOM3(this.ResponseFrameOPT2());
                            return;
                        }

                        try
                        {
                            iValue = int.Parse(strTemp.Substring(4, 2));
                        }
                        catch
                        {
                            // Response 현재품번으로 해서 응답
                            this.CurrentOPT2COM3.IsErrorReceivedData = true;
                            this.TransferSerialCOM3(this.ResponseFrameOPT2());
                            return;
                        }

                        if ((iValue < 0) || (iValue > 50))
                        {
                            // Response 현재품번으로 해서 응답
                            this.CurrentOPT2COM3.IsErrorSettingStatus = true;
                            this.TransferSerialCOM3(this.ResponseFrameOPT2());
                            return;
                        }
                        this.CurrentOPT2COM3.IsErrorReceivedData = false;
                        this.CurrentOPT2COM3.IsErrorSettingStatus = false;

                        this.TransferProductParameter(iValue);

                        this.Invoke(new SerialOPT2COM3_Delegate(this.SerialOPT2COM3Delegate));
                    }
                    #endregion
                    break;
                case (int)Define.E_CommMode.f16_OPC:
                    #region OPC
                    try
                    {
                        byte[] responseData;
                        byte errorCheck = this.Modbus.CheckRequestDataErrorRTU(readByte, ModbusFunctionCode.FunctionCode_04);

                        if (errorCheck == 0x00)
                            responseData = this.Modbus.MakeRTU04ResponseData(this.Transfer_22_Modbus_Read_RTU(readByte), this.SystemConfig2.ModbusSlaveIDCOM3);
                        else
                            responseData = this.Modbus.MakeRTU04ErrorResponseData(errorCheck, this.SystemConfig2.ModbusSlaveIDCOM3);

                        this.TransferSerialCOM3(responseData);

                        // 로그
                        if (this.IsCommunicationLogOpen == true)
                            this.smartFileCommunicationLog.WriteString(string.Format("Send COM3 ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, BitConverter.ToString(responseData)));
                    }
                    catch
                    {
                    }
                    #endregion
                    break;
                case (int)Define.E_CommMode.f22_Modbus:
                    #region Modbus RTU
                    this.ChildFormMainDisplay.MainModbus.UpdateReceiveCount();

                    if (this.SystemConfig2.ModbusSlaveIDCOM3 != Convert.ToInt32(readByte[0]))
                        return;

                    if (readByte[1] == 0x03) // Read Holding Register
                    {
                        #region Read Holding Register
                        try
                        {
                            byte[] responseData;
                            byte errorCheck = this.Modbus.CheckRequestDataErrorRTU(readByte, ModbusFunctionCode.FunctionCode_03);

                            if (errorCheck == 0x00)
                                responseData = this.Modbus.MakeRTUResponseData(this.Transfer_22_Modbus_Read_RTU(readByte), this.SystemConfig2.ModbusSlaveIDCOM3, ModbusFunctionCode.FunctionCode_03);
                            else
                                responseData = this.Modbus.MakeRTUErrorResponseData(errorCheck, this.SystemConfig2.ModbusSlaveIDCOM3, ModbusFunctionCode.FunctionCode_03);

                            this.TransferSerialCOM3(responseData);

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

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

                                crc = this.Modbus.MakeRTUCRC(responseData, responseData.Length - 2);
                                for (int i = 0; i < 2; i++)
                                    responseData[6 + i] = crc[i];

                                this.TransferSerialCOM3(responseData);

                                this.ReceiveModbusRTUWriteManager(readByte);
                            }
                            else
                            {
                                errorResponseData[0] = readByte[0];
                                errorResponseData[1] = 0x90;
                                errorResponseData[2] = errorCheck;

                                crc = this.Modbus.MakeRTUCRC(errorResponseData, errorResponseData.Length - 2);
                                for (int i = 0; i < 2; i++)
                                    errorResponseData[3 + i] = crc[i];

                                this.TransferSerialCOM3(errorResponseData);
                            }

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

                                if (errorCheck == 0x00)
                                    responseData = this.Modbus.MakeRTU04ResponseData(this.Transfer_22_Modbus_Read_RTU(readByte), this.SystemConfig2.ModbusSlaveIDCOM3);
                                else
                                    responseData = this.Modbus.MakeRTU04ErrorResponseData(errorCheck, this.SystemConfig2.ModbusSlaveIDCOM3);

                                this.TransferSerialCOM3(responseData);

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

            #region 바코드
            if (this.SystemConfig1.IsBarcodeEnable == true)
            {
                if (this.CurrentSystemStatus.Equipment == Define.E_EquipmentStatus.Start)
                {
                    this.CurrentBarcode.SetData(strTemp);
                    this.ChildFormMainDisplay.UpdateBarcodeDisplay(this.CurrentBarcode);

                    if (this.CurrentBarcode.GetQueueCount > 0)
                        this.BarcodeProductChange(this.CurrentBarcode);
                }
                else if (this.CurrentSystemStatus.CurrentDisplay == Define.E_DisplayStore.ConfiSerial)
                {
                    switch (readByte[0])
                    {
                        case 0x4E: // 78, N : 설정 실패
                            value = strTemp.Substring(2, strTemp.Length - 2);
                            this.ChildFormMenu.CenterConfiSerial.ControlBarcode.DisplayStatus("> Fail : ErrorNo " + value);
                            break;
                        case 0x59: // 89, Y : 설정 성공
                            if (readByte[strTemp.Length - 1] == 0x41) // Barcode 설정 저장 시, 'Y<space>P<CR><LF><ESC>[A' 수신, A = 0x41
                            {
                                // Self Disconnection
                                this.ChildFormMenu.CenterConfiSerial.ControlBarcode.EnterOrExitCommandMode(0x5B);
                            }
                            else
                            {
                                value = strTemp.Substring(2, strTemp.Length - 2);
                                this.ChildFormMenu.CenterConfiSerial.ControlBarcode.DisplayLoadingValue(this.CurrentBarcode.SaveGettingShortCut, this.CurrentBarcode.SaveSettingShortCut, value);
                            }
                            break;
                        case 0x1B: // 27, <ESC>:응답
                            this.ChildFormMenu.CenterConfiSerial.ControlBarcode.EnterOrExitCommandMode(readByte[1]);
                            break;
                        case 0x02: //2
                            strTemp = strTemp.Substring(1, strTemp.Length - 2);
                            break;
                        default:
                            break;
                    }
                    this.ChildFormMenu.CenterConfiSerial.DisplayReceive(strTemp);
                }

                // 나중에 지울것
                this.ChildFormMainDisplay.labelBarcode.Text = strTemp;
            } 
            #endregion
        }
        private void smartSerialPort4_OnReadQueueEvent()
        {
            int ret = 0;
            string strTemp = "";
            byte[] readByte;

            SmartSerialPort.FRAMEDATAREADSTATUS receiveDataState = SmartSerialPort.FRAMEDATAREADSTATUS.EMPTY;

            try
            {
                receiveDataState = this.smartSerialPort4.ReadQueue(out readByte);
                if (this.SystemConfig1.SerialCOM4Mode != 4 && this.SystemConfig1.SerialCOM4Mode != 5)
                    strTemp = Encoding.Default.GetString(readByte, 0, readByte.Length);

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

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

            switch (this.SystemConfig1.SerialCOM4Mode)
            {
                case 5:
                    #region imaje 9028 OPT1 - 한맥프린터(네추럴 F&P)
                    if (readByte[0] != 0x06) // ACK가 아니면 재발송
                    {
                        switch (this.HMCOM4_Step)
                        {
                            case 1:
                                this.TransferSerialCOM4(this.SendChar(Define.E_CharValue.ENQ));
                                break;
                            case 2:
                                this.TransferSerialCOM4(this.RoomChange9028(2));
                                break;
                            case 3:
                                this.TransferSerialCOM4(this.RoomChange9028(1));
                                break;
                            case 4:
                                this.TransferSerialCOM4(this.WeightData9028(this.CurrentWeightData)); // 중량값 전송
                                break;
                            default:
                                break;
                        }
                    }
                    else
                    {
                        switch (this.HMCOM4_Step)
                        {
                            case 1:
                                if (this.CurrentWeightData.JudgmentStatus == Define.E_JudgmentStatus.Pass)
                                {
                                    this.HMCOM4_Step = 2;
                                    this.TransferSerialCOM4(this.RoomChange9028(2));
                                }
                                else
                                {
                                    this.HMCOM4_Step = 3;
                                    this.TransferSerialCOM4(this.RoomChange9028(1));
                                }
                                break;
                            case 2:
                                this.HMCOM4_Step = 4;
                                this.TransferSerialCOM4(this.WeightData9028(this.CurrentWeightData)); // 중량값 전송
                                break;
                            case 3:
                                break;
                            case 4:
                                break;
                            default:
                                break;
                        }
                    }
                    #endregion
                    break;
                case 10:
                    #region MACSA Laser
                    if (strTemp[0] == 0x02)
                    {
                        if (strTemp[3] == 0x15)
                        {
                            if (strTemp[6] == 0x54)
                            {
                                if (this.IsMACSARetransmissionCOM4 == true)
                                {
                                    // MACSA 통신전송이 실패하였습니다.
                                    DialogFormMessage msg = new DialogFormMessage(24, this.SystemConfig1.Language);
                                    msg.ShowDialog();

                                    this.IsMACSARetransmissionCOM4 = false;
                                }
                                else
                                {
                                    this.TransferSerialCOM4(this.CurrentMACSACOM4);

                                    this.IsMACSARetransmissionCOM4 = true;
                                }
                            }
                        }
                    }
                    #endregion
                    break;
                case 15:
                    #region OPT2
                    int iValue = 0;

                    if (strTemp[0] == 0x02)
                    {
                        this.CurrentOPT2COM4.IsReceivedData = true;

                        if ((strTemp.Length != 7) || (strTemp.Length < 7) || (strTemp[6] != 0x03))
                        {
                            // Response 현재품번으로 해서 응답
                            this.CurrentOPT2COM4.IsErrorReceivedData = true;
                            this.TransferSerialCOM4(this.ResponseFrameOPT2());
                            return;
                        }

                        try
                        {
                            iValue = int.Parse(strTemp.Substring(4, 2));
                        }
                        catch
                        {
                            // Response 현재품번으로 해서 응답
                            this.CurrentOPT2COM4.IsErrorReceivedData = true;
                            this.TransferSerialCOM4(this.ResponseFrameOPT2());
                            return;
                        }

                        if ((iValue < 0) || (iValue > 50))
                        {
                            // Response 현재품번으로 해서 응답
                            this.CurrentOPT2COM4.IsErrorSettingStatus = true;
                            this.TransferSerialCOM4(this.ResponseFrameOPT2());
                            return;
                        }
                        this.CurrentOPT2COM4.IsErrorReceivedData = false;
                        this.CurrentOPT2COM4.IsErrorSettingStatus = false;

                        this.TransferProductParameter(iValue);

                        this.Invoke(new SerialOPT2COM4_Delegate(this.SerialOPT2COM4Delegate));
                    }
                    #endregion
                    break;
                case (int)Define.E_CommMode.f16_OPC:
                    #region OPC
                    try
                    {
                        byte[] responseData;
                        byte errorCheck = this.Modbus.CheckRequestDataErrorRTU(readByte, ModbusFunctionCode.FunctionCode_04);

                        if (errorCheck == 0x00)
                            responseData = this.Modbus.MakeRTU04ResponseData(this.Transfer_22_Modbus_Read_RTU(readByte), this.SystemConfig2.ModbusSlaveIDCOM4);
                        else
                            responseData = this.Modbus.MakeRTU04ErrorResponseData(errorCheck, this.SystemConfig2.ModbusSlaveIDCOM4);

                        this.TransferSerialCOM4(responseData);

                        // 로그
                        if (this.IsCommunicationLogOpen == true)
                            this.smartFileCommunicationLog.WriteString(string.Format("Send COM4 ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, BitConverter.ToString(responseData)));
                    }
                    catch
                    {
                    }
                    #endregion
                    break;
                case (int)Define.E_CommMode.f22_Modbus:
                    #region Modbus RTU
                    this.ChildFormMainDisplay.MainModbus.UpdateReceiveCount();

                    if (this.SystemConfig2.ModbusSlaveIDCOM4 != Convert.ToInt32(readByte[0]))
                        return;

                    if (readByte[1] == 0x03) // Read Holding Register
                    {
                        #region Read Holding Register
                        try
                        {
                            byte[] responseData;
                            byte errorCheck = this.Modbus.CheckRequestDataErrorRTU(readByte, ModbusFunctionCode.FunctionCode_03);

                            if (errorCheck == 0x00)
                                responseData = this.Modbus.MakeRTUResponseData(this.Transfer_22_Modbus_Read_RTU(readByte), this.SystemConfig2.ModbusSlaveIDCOM4, ModbusFunctionCode.FunctionCode_03);
                            else
                                responseData = this.Modbus.MakeRTUErrorResponseData(errorCheck, this.SystemConfig2.ModbusSlaveIDCOM4, ModbusFunctionCode.FunctionCode_03);

                            this.TransferSerialCOM4(responseData);

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

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

                                crc = this.Modbus.MakeRTUCRC(responseData, responseData.Length - 2);
                                for (int i = 0; i < 2; i++)
                                    responseData[6 + i] = crc[i];

                                this.TransferSerialCOM4(responseData);

                                this.ReceiveModbusRTUWriteManager(readByte);
                            }
                            else
                            {
                                errorResponseData[0] = readByte[0];
                                errorResponseData[1] = 0x90;
                                errorResponseData[2] = errorCheck;

                                crc = this.Modbus.MakeRTUCRC(errorResponseData, errorResponseData.Length - 2);
                                for (int i = 0; i < 2; i++)
                                    errorResponseData[3 + i] = crc[i];

                                this.TransferSerialCOM4(errorResponseData);
                            }

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

                                if (errorCheck == 0x00)
                                    responseData = this.Modbus.MakeRTU04ResponseData(this.Transfer_22_Modbus_Read_RTU(readByte), this.SystemConfig2.ModbusSlaveIDCOM4);
                                else
                                    responseData = this.Modbus.MakeRTU04ErrorResponseData(errorCheck, this.SystemConfig2.ModbusSlaveIDCOM4);

                                this.TransferSerialCOM4(responseData);

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

        private void smartTCPMultiServer_OnReceiveHandler(SmartTCPMultiServer.CHandleClinet.READINFO datas)
        {
            int ret = 0;
            byte[] readByte;
            string strRecData = "";
            byte[] sendDatas = new byte[57];

            try
            {
                readByte = datas.receiveDatas;
                strRecData = SmartTCPMultiServer.ConvertAsciiByteToString(readByte);
                //Console.Write("\n" + string.Format("{0:yyyy-MM-dd HH:mm:ss}: Receive : {1}", DateTime.Now, BitConverter.ToString(readByte)));
            }
            catch
            {
                return;
            }

            switch (this.SystemConfig2.EthernetCommMode)
            {
                case 5:
                    #region imaje 9028 OPT1 - 한맥프린터(네추럴 F&P)
                    if (readByte[0] != 0x06) // ACK가 아니면 재발송
                    {
                        switch (this.HMEthernet_Step)
                        {
                            case 1:
                                this.EthernetWeightData(this.SendChar(Define.E_CharValue.ENQ));
                                break;
                            case 2:
                                this.EthernetWeightData(this.RoomChange9028(2));
                                break;
                            case 3:
                                this.EthernetWeightData(this.RoomChange9028(1));
                                break;
                            case 4:
                                this.EthernetWeightData(this.WeightData9028(this.CurrentWeightData)); // 중량값 전송
                                break;
                            default:
                                break;
                        }
                    }
                    else
                    {
                        switch (this.HMEthernet_Step)
                        {
                            case 1:
                                if (this.CurrentWeightData.JudgmentStatus == Define.E_JudgmentStatus.Pass)
                                {
                                    this.HMEthernet_Step = 2;
                                    this.EthernetWeightData(this.RoomChange9028(2));
                                }
                                else
                                {
                                    this.HMEthernet_Step = 3;
                                    this.EthernetWeightData(this.RoomChange9028(1));
                                }
                                break;
                            case 2:
                                this.HMEthernet_Step = 4;
                                this.EthernetWeightData(this.WeightData9028(this.CurrentWeightData)); // 중량값 전송
                                break;
                            case 3:
                                break;
                            case 4:
                                break;
                            default:
                                break;
                        }
                    }
                    #endregion
                    break;
                case 10:
                    #region MACSA Laser
                    if (readByte[0] == 0x02)
                    {
                        if (readByte[3] == 0x15)
                        {
                            if (readByte[6] == 0x54)
                            {
                                if (this.IsMACSARetransmissionEthernet == true)
                                {
                                    // MACSA 통신전송이 실패하였습니다.
                                    DialogFormMessage msg = new DialogFormMessage(24, this.SystemConfig1.Language);
                                    msg.ShowDialog();

                                    this.IsMACSARetransmissionEthernet = false;
                                }
                                else
                                {
                                    this.EthernetWeightData(this.CurrentMACSAEthernet);

                                    this.IsMACSARetransmissionEthernet = true;
                                }
                            }
                        }
                    }
                    #endregion
                    break;
                case 15:
                    #region OPT2
                    int iValue = 0;

                    if (readByte[0] == 0x02)
                    {
                        this.CurrentOPT2Ethernet.IsReceivedData = true;

                        if ((readByte.Length != 7) || (readByte.Length < 7) || (readByte[6] != 0x03))
                        {
                            // Response 현재품번으로 해서 응답
                            this.CurrentOPT2Ethernet.IsErrorReceivedData = true;
                            this.EthernetWeightData(this.ResponseFrameOPT2());
                            return;
                        }

                        try
                        {
                            iValue = int.Parse(strRecData.Substring(4, 2));
                        }
                        catch
                        {
                            // Response 현재품번으로 해서 응답
                            this.CurrentOPT2Ethernet.IsErrorReceivedData = true;
                            this.EthernetWeightData(this.ResponseFrameOPT2());
                            return;
                        }

                        if ((iValue < 0) || (iValue > 50))
                        {
                            // Response 현재품번으로 해서 응답
                            this.CurrentOPT2Ethernet.IsErrorSettingStatus = true;
                            this.EthernetWeightData(this.ResponseFrameOPT2());
                            return;
                        }
                        this.CurrentOPT2Ethernet.IsErrorReceivedData = false;
                        this.CurrentOPT2Ethernet.IsErrorSettingStatus = false;

                        this.TransferProductParameter(iValue);

                        this.Invoke(new SerialOPT2Ethernet_Delegate(this.SerialOPT2EthernetDelegate));
                    }
                    #endregion
                    break;
                case (int)Define.E_CommMode.f16_OPC:
                    #region OPC
                    if (this.smartTCPMultiServer.ClientInfoList != null)
                    {
                        byte[] responseData;
                        byte errorCheck = this.Modbus.CheckRequestDataErrorTCP(readByte, ModbusFunctionCode.FunctionCode_04);

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

                        foreach (SmartTCPMultiServer.CLIENTSINFOS client in this.smartTCPMultiServer.ClientInfoList)
                        {
                            this.smartTCPMultiServer.SendByteByClientID(client.strID, responseData);
                        }
                    }
                    #endregion
                    break;
                case (int)Define.E_CommMode.f22_Modbus:
                    #region Modbus TCP
                    if (this.smartTCPMultiServer.ClientInfoList != null)
                    {
                        this.ChildFormMainDisplay.MainModbus.UpdateReceiveCount();

                        if (readByte[7] == 0x03) // Read Holding Register
                        {
                            #region Read Holding Register
                            try
                            {
                                byte[] responseData;
                                byte errorCheck = this.Modbus.CheckRequestDataErrorTCP(readByte, ModbusFunctionCode.FunctionCode_03);

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

                                foreach (SmartTCPMultiServer.CLIENTSINFOS client in this.smartTCPMultiServer.ClientInfoList)
                                {
                                    this.smartTCPMultiServer.SendByteByClientID(client.strID, responseData);
                                    //Console.Write("\n" + string.Format("{0:yyyy-MM-dd HH:mm:ss}: Send3 : {1}", DateTime.Now, BitConverter.ToString(responseData)));
                                }

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

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

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

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

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

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

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

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

                                    foreach (SmartTCPMultiServer.CLIENTSINFOS client in this.smartTCPMultiServer.ClientInfoList)
                                    {
                                        this.smartTCPMultiServer.SendByteByClientID(client.strID, responseData);
                                        //Console.Write("\n" + string.Format("{0:yyyy-MM-dd HH:mm:ss}: Send4 : {1}", DateTime.Now, BitConverter.ToString(responseData)));
                                    }

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

        private void smartThread_UIThreadFunction(ThreadArgs args)
        {
            // 메시지 23. 알람 조건이 충족하여 장비가 정지되었습니다
            if (this.FlagThreadMessage1 == false)
            {
                DialogFormMessage myMsg = new DialogFormMessage(23, this.SystemConfig1.Language, this);
                myMsg.ShowDialog();

                this.FlagThreadMessage1 = true;
            }
        }

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

            // 데이터백업 포맷 : OPT1 - 리젝데이터 Timeout 처리
            if (this.CollectionBufferWeightData.Count > 0)
            {
                for (int i = 0; i < this.CollectionBufferWeightData.Count; i++)
                {
                    this.CollectionBufferWeightData[i].Status = Define.E_JudgmentResult.Timeout.ToString();
                    this.TrackingInspectionData1(this.CollectionBufferWeightData[i]);
                }
                this.CollectionBufferWeightData.Clear();
            }
        }
        private void timerEthernetPing_Tick(object sender, EventArgs e)
        {
            try
            {
                CIPSetting.PINGRESULTINFO pingResultInfo = new CIPSetting.PINGRESULTINFO();
                if (this.SystemConfig2.EthernetOperationMode == 1) // 중량선별기 : Server
                {
                    try
                    {
                        bool bValue = this.smartConfigs.IPSettings.PingIP(this.smartTCPMultiServer.ClientInfoList[0].strIPAddress, ref pingResultInfo);
                        if (bValue == false)
                        {
                            this.ChildFormMainDisplay.UpdateEthernetStatusDisplay(false);
                            this.ChildFormMenu.CenterConfiEthernet.DelegateConnectedIPStatusOut("-");
                            bool disconnect = this.smartTCPMultiServer.CloseClientIP(this.smartTCPMultiServer.ClientInfoList[0].strIPAddress);

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

                            this.EthernetServerStart();
                        }

                        // 로그
                        if (this.IsCommunicationLogOpen == true)
                            this.smartFileCommunicationLog.WriteString(string.Format("Connection ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, bValue.ToString()));
                    }
                    catch
                    {
                        this.ChildFormMainDisplay.UpdateEthernetStatusDisplay(false);
                        this.ChildFormMenu.CenterConfiEthernet.DelegateConnectedIPStatusOut("-");

                        // 로그
                        if (this.IsCommunicationLogOpen == true)
                            this.smartFileCommunicationLog.WriteString(string.Format("Error ({0:yyyy-MM-dd HH:mm:ss}): Catch", DateTime.Now));
                    }
                }
                else // 중량선별기 : Client
                {
                    try
                    {
                        if (this.smartConfigs.IPSettings.PingIP(this.SystemConfig2.EthernetAddress, ref pingResultInfo) == false)
                        {
                            this.EthernetClientDisconnect();
                            this.EthernetClientConnect();
                        }
                    }
                    catch
                    {
                        this.DelegateUISeverStatus(false);
                        this.ChildFormMenu.CenterConfiEthernet.DelegateConnectedIPStatusOut("-");
                    }
                }
            }
            catch
            {
                if (this.SystemConfig2.EthernetOperationMode == 1) // 중량선별기 : Server
                {
                    this.ChildFormMainDisplay.UpdateEthernetStatusDisplay(false);
                }
                else // 중량선별기 : Client
                {
                    this.DelegateUISeverStatus(false);
                    this.EthernetClientDisconnect();
                }
            }
        }

        // 전송지연시간 관련
        private void timerCOM1_Tick(object sender, EventArgs e)
        {
            System.Windows.Forms.Timer timer = sender as System.Windows.Forms.Timer;
            timer.Enabled = false;

            if (this.QueueCOM1.Count > 0)
            {
                Type type = this.QueueCOM1.Peek().GetType();

                if (type == typeof(string))
                    this.TransferDirectSerialCOM1((string)this.QueueCOM1.Dequeue());
                else if (type == typeof(byte[]))
                    this.TransferDirectSerialCOM1((byte[])this.QueueCOM1.Dequeue());
            }

            timer.Dispose();
            timer = null;
        }
        private void timerCOM3_Tick(object sender, EventArgs e)
        {
            System.Windows.Forms.Timer timer = sender as System.Windows.Forms.Timer;
            timer.Enabled = false;

            if (this.QueueCOM3.Count > 0)
            {
                Type type = this.QueueCOM3.Peek().GetType();

                if (this.smartSerialPort3.FrameSeparationType == SmartSerialPort.FRAMESEPARATIONTYPES.ETXONLY)
                {
                    if (type == typeof(string))
                        this.TransferDirectSerialCOM3RawData((string)this.QueueCOM3.Dequeue());
                    else if (type == typeof(byte[]))
                        this.TransferDirectSerialCOM3RawData((byte[])this.QueueCOM3.Dequeue());
                }
                else
                {
                    if (type == typeof(string))
                        this.TransferDirectSerialCOM3((string)this.QueueCOM3.Dequeue());
                    else if (type == typeof(byte[]))
                        this.TransferDirectSerialCOM3((byte[])this.QueueCOM3.Dequeue());
                }
            }

            timer.Dispose();
            timer = null;
        }
        private void timerCOM4_Tick(object sender, EventArgs e)
        {
            System.Windows.Forms.Timer timer = sender as System.Windows.Forms.Timer;
            timer.Enabled = false;

            if (this.QueueCOM4.Count > 0)
            {
                Type type = this.QueueCOM4.Peek().GetType();

                if (type == typeof(string))
                    this.TransferDirectSerialCOM4((string)this.QueueCOM4.Dequeue());
                else if (type == typeof(byte[]))
                    this.TransferDirectSerialCOM4((byte[])this.QueueCOM4.Dequeue());
            }

            timer.Dispose();
            timer = null;
        }
        private void timerOPT2COM1_Tick(object sender, EventArgs e)
        {
            System.Windows.Forms.Timer timer = sender as System.Windows.Forms.Timer;
            timer.Enabled = false;

            this.CurrentOPT2COM1.IsReceivedData = false;

            timer.Dispose();
            timer = null;

        }
        private void timerOPT2COM3_Tick(object sender, EventArgs e)
        {
            System.Windows.Forms.Timer timer = sender as System.Windows.Forms.Timer;
            timer.Enabled = false;

            this.CurrentOPT2COM3.IsReceivedData = false;

            timer.Dispose();
            timer = null;
        }
        private void timerOPT2COM4_Tick(object sender, EventArgs e)
        {
            System.Windows.Forms.Timer timer = sender as System.Windows.Forms.Timer;
            timer.Enabled = false;

            this.CurrentOPT2COM4.IsReceivedData = false;

            timer.Dispose();
            timer = null;
        }
        private void timerOPT2Ethernet_Tick(object sender, EventArgs e)
        {
            System.Windows.Forms.Timer timer = sender as System.Windows.Forms.Timer;
            timer.Enabled = false;

            this.CurrentOPT2Ethernet.IsReceivedData = false;

            timer.Dispose();
            timer = null;
        }
        //private void timerImaje9410OPT1_Tick(object sender, EventArgs e)
        //{
        //    System.Windows.Forms.Timer timer = sender as System.Windows.Forms.Timer;
        //    timer.Enabled = false;

        //    this.TransferSerial_imaje9410OPT1(Define.E_MenuBottomConfiguration.SerialCOM4, this.CurrentWeightData);
        //    if (this.QueueCOM4.Count > 0)
        //        this.TransferSerialCOM4((byte[])this.QueueCOM4.Dequeue());

        //    timer.Dispose();
        //    timer = null;
        //}
        //private void timerImaje9028OPT1_Tick(object sender, EventArgs e)
        //{
        //    System.Windows.Forms.Timer timer = sender as System.Windows.Forms.Timer;
        //    timer.Enabled = false;

        //    if (this.QueueCOM4.Count > 0)
        //        this.TransferSerialCOM4((byte[])this.QueueCOM4.Dequeue());

        //    timer.Dispose();
        //    timer = null;
        //}
        //private void timerImaje9410OPT2_Tick(object sender, EventArgs e)
        //{
        //    System.Windows.Forms.Timer timer = sender as System.Windows.Forms.Timer;
        //    timer.Enabled = false;

        //    if (this.QueueCOM4.Count > 0)
        //        this.TransferSerialCOM4((byte[])this.QueueCOM4.Dequeue());

        //    timer.Dispose();
        //    timer = null;
        //}
        //private void timerImaje9028OPT2_Tick(object sender, EventArgs e)
        //{
        //    System.Windows.Forms.Timer timer = sender as System.Windows.Forms.Timer;
        //    timer.Enabled = false;

        //    if (this.QueueCOM4.Count > 0)
        //        this.TransferSerialCOM4((byte[])this.QueueCOM4.Dequeue());

        //    timer.Dispose();
        //    timer = null;
        //}
        private void smartTimerUpdate_Tick(object sender, EventArgs e)
        {
            this.smartTimerUpdate.Stop();
            this.UpdateForMain.RetryCount++;

            if (this.UpdateForMain.RetryCount < 5)
                this.RetryUpdateForMain(this.UpdateForMain);
            else
                this.ChildFormMenu.CenterEquipUpdate.UpdateMainBoardFail(this.SystemConfig1.Language);
        }
        private void timerClientTryConnect_Tick(object sender, EventArgs e)
        {
            this.DelegateTimerTryConnect(false);
            this.EthernetClientConnect();
        }

        private void smartTCPMultiServer_OnClientAdd(SmartTCPMultiServer.CLIENTSINFOS addClientInfo)
        {

        }

        private void timerUserList_Tick(object sender, EventArgs e)
        {
            this.timerUserList.Enabled = false;
            UserManager.UserManager_GetUserListName();
        }

        private void smartTimerLogout_Tick(object sender, EventArgs e)
        {
            this.smartTimerLogout.Stop();

            DialogFormMessage msg = new DialogFormMessage(43, this.SystemConfig1.Language);
            msg.ShowDialog();

            if (this.CurrentSystemStatus.CurrentDisplay != Define.E_DisplayStore.MainDisplay)
                this.ChildFormMenu.ChangeToMainScreen();

            this.ChildFormMainDisplay.Logout();
        }

        private void CurrentAlarmList_Change(Define.E_TrackingAlarm alarm, string status)
        {
            if (status == "ON")
                this.CurrentAlarm[(short)alarm - 1] = 1;
            else
                this.CurrentAlarm[(short)alarm - 1] = 0;
            
            this.SetTrackingHistoryData(alarm, status);
        }

        private void smartThreadSerialPort2Read_UIThreadFunction(ThreadArgs args)
        {
            if (this.QueueCommunicationRecive.Count != 0)
            {
                this.ReceiveData(this.QueueCommunicationRecive.Dequeue());

                this.ChildFormMainDisplay.labelBufferCNT.BeginInvoke(new Action(() =>
                {
                    this.ChildFormMainDisplay.labelBufferCNT.Text = this.QueueCommunicationRecive.Count.ToString();
                }));
            }
        }
        private void smartSerialSerialPort2_OnPortError(System.IO.Ports.SerialError eErrorState)
        {
            this.IndexOverRun++;
            this.QueueOverRun.Enqueue(string.Format("{0}", this.IndexOverRun));
        }
        private void smartThreadSerialPort2OverRun_UIThreadFunction(ThreadArgs args)
        {
            if (this.QueueOverRun.Count != 0)
                this.ChildFormMainDisplay.UpdateDisplayOverRun(this.QueueOverRun.Dequeue());
        }

        #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.CurrentSystemStatus.CurrentDisplay == Define.E_DisplayStore.EquipUser)
                    this.ChildFormMenu.CallBackGetUserData(userList);
            }
            catch
            {
            }
        }
        private void UserManager_UserListLoginTimeoutDataEvent(object data)
        {
            try
            {
                UserManager.UserMgr_login_timeout_t loginTimeout = (UserManager.UserMgr_login_timeout_t)data;

                if (this.CurrentSystemStatus.CurrentDisplay == Define.E_DisplayStore.MainDisplay)
                    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.CurrentSystemStatus.CurrentDisplay == Define.E_DisplayStore.EquipUser)
                    this.ChildFormMenu.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.ChildFormMenu.CallBackUserListDeleteDataEvent(user);
            }
            catch
            {
            }
        }
        private void UserManager_UserListModifyUserDataEvent(object data)
        {
            try
            {
                UserManager.UserMgr_user_modify_t user = (UserManager.UserMgr_user_modify_t)data;

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

                if (this.CurrentSystemStatus.CurrentDisplay == Define.E_DisplayStore.MainDisplay)
                    this.ChildFormMainDisplay.CallBackUserListModifyInfoData(user);
                else
                    this.ChildFormMenu.CallBackUserListModifyInfoData(user);
            }
            catch (Exception ex)
            {
                FormMain.Exception(ex);
            }
        }
        private void UserManager_UserListNewDataEvent(object data)
        {
            try
            {
                UserManager.UserMgr_user_info_t user = (UserManager.UserMgr_user_info_t)data;

                this.ChildFormMenu.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.ChildFormMenu.CenterInforSystem != null)
                    this.ChildFormMenu.CenterInforSystem.UpdatePart11UserManagerVersionDisplay(data.ToString());
            }
            catch
            {
            }
        }
        #endregion

        #region EncryptionEvent
        private void Aes_Encryption_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.ChildFormMenu.CallBackEncryptionEvent(status);
            }
            catch
            {

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

        #endregion
    }
}