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 System.Diagnostics;
using System.Net;

using SmartX;
using ITC81DB.DialogForms;
using ITC81DB.Controls;
using InModbus;
using ITC81DB.SerialManager;

namespace ITC81DB.Forms
{
    public partial class FormMain : Form
    {
        #region Field
        public static string DisplayVersion = "8.19.1";
        public static string ReleaseDate = "2023.12.18";

        public SmartSplash SmartSplashProgramLoad;
        public bool IsCommunicationLogOpen;
        public bool IsBarcodeLogOpen;
        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 CurrentSensorDetectingTime;
        public double OverloadWeight;
        public bool IsBypassOnce; // 1회 바이패스
        public string PreviousAlarm; // RFID - 이전 알람값
        public string PreviousTag; // RFID - 이전 태그값
        public string ReferenceTag; // RFID - 태그값 저장
        public SmartTimer TimerRFIDRead; // RFID Timout
        public int UpdateValue; // Modbus - Update 될 때마다 +1
        public bool IsOPCModbusUsing;
        public bool IsAlarmOccured;
        public bool IsCountingOutputCrossStatus;
        private bool IsSatisfyCounting;
        public bool IsBypassStart;

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

        // Form
        public FormMainDisplay ChildFormMainDisplay;
        public FormMenu ChildFormMenu;
        public ControlConversionItem ControlConversion;

        // 알람
        private AlarmList CurrentAlarmList;

        private Stopwatch StopWatchForBuzzer; // 부저울림 관련

        #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 ModbusTotalBytes = 68; // 전체 bytes

        // RFID
        private delegate void RFIDNGSendTime_Delegate();
        #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_PathPreVersionSystemFile1Folder;                      // 이전버전 시스템파일1 백업 폴더
        private string m_PathPreVersionSystemFile2Folder;                      // 이전버전 시스템파일2 백업 폴더
        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 폴더

        // 현재 선택 된 품목
        //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;
        // 시스템파라미터5
        public SystemParameter5 CurrentSystemParameter5;

        // 기준치 갱신 원래 품번 데이터 저장용
        private ProductItem m_CurrentProductItemForSave;

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

        // IO Test Input 데이터 취합
        private Collection<string> CollectionIOTest_InputData;
        // IO Test Input 그래프 데이터
        private Collection<string> CollectionIOTestGraphData;
        // 판정설정 그래프 데이터
        private Collection<int> CollectionGraphData;
        // 외부입력 모드
        private Collection<int> CollectionInput;

        // User
        public User CurrentUser;
        // UserGroup
        public UserGroup CurrentUserGroup;
        // Bacode
        public Barcode CurrentBarcode;
        // Modbus
        public Modbus Modbus;
        // Modbus Data
        public _30000_ModbusData Current30000ModbusData;
        public _40000_ModbusData Current40000ModbusData;
        // RFID Speedway R420
        public RFID_Impinj_Speedway_R420 CurrentRFID;
        // 품목설정 데이터
        public Collection<ProductItem> CollectionProductItem;
        // 판정설정 데이터
        public Collection<JudgmentSetItem> CollectionJudgmentItem;
        // Count 데이터
        public Collection<WeightData> CollectionWeightData;
        // 종근당 중량 데이터 버퍼
        private Collection<DataBackupOPT1> CollectionBufferWeightData;
        // 기준치 갱신 데이터 버퍼
        private Collection<AverageTrackingItem> CollectionAverageTrackingItem;
        // 리젝데이터
        private JudgmentResult CurrentJudgmentResult;
        // Communication Respone
        private CommunicationRespone CurrentComRespone;

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

        // Ethernet
        public bool IsEthernetClientConnect = false;
        public bool IsEthernetClientThreadStart = false;
        public bool IsEthernetTransferData;
        public object EthernetTransferData;
        public bool IsClientConnectTryTimerStart;

        private TcpClient EthernetTcpClient;

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

        private delegate void TransferByteArrayDataCallback(byte[] byteArray);
        private delegate void TransferStringDataCallback(string strText);
        private delegate void TransferByteDataCallback(byte byteText);
        private delegate void TextStatusCallback(string strText);
        private delegate void UIControlCallback(bool bEnable);
        private delegate void UIServerStatusCallback(bool bEnable);
        private delegate void UITimerWorkCallback(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 PathPreVersionSystemFile1Folder
        {
            get { return this.m_PathPreVersionSystemFile1Folder; }
            set { this.m_PathPreVersionSystemFile1Folder = value; }
        }
        public string PathPreVersionSystemFile2Folder
        {
            get { return this.m_PathPreVersionSystemFile2Folder; }
            set { this.m_PathPreVersionSystemFile2Folder = 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 SystemStatus CurrentSystemStatus
        {
            get { return this.m_CurrentSystemStatus; }
            private set { this.m_CurrentSystemStatus = value; }
        }

        public AverageTrackingItem CurrentAverageTrackingItem
        {
            get { return this.CollectionAverageTrackingItem[this.SystemConfig1.ProductNumber - 1]; }
            set { this.CollectionAverageTrackingItem[this.SystemConfig1.ProductNumber - 1] = 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; }
        }
        public ProductItem CurrentProductItemTemp
        {
            get { return this.m_CurrentProductItemForSave; }
            set { this.m_CurrentProductItemForSave = value; }
        }
        #endregion

        #region Method
        private void DefaultSetting1()
        {
            this.IsCommunicationLogOpen = false;
            this.IsBarcodeLogOpen = 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.IsBypassOnce = false;
            this.PreviousAlarm = "00000000";
            this.PreviousTag = "000000000000000000000000";
            this.ReferenceTag = "000000000000000000000000";
            this.UpdateValue = 0;
            this.IsOPCModbusUsing = false;
            this.IsAlarmOccured = false;
            this.IsCountingOutputCrossStatus = false;
            this.IsSatisfyCounting = false;
            this.FlagComRetry3th = 0;
            this.MissingCommIDCount = 0;
            this.CommID = 0;
            this.IsClientConnectTryTimerStart = false;

            this.QueueCommunicationRecive = new Queue<string>();
            this.CurrentAlarmList = new AlarmList();
            this.StopWatchForBuzzer = new Stopwatch();
            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 = "SD Card\\Run\\";
            this.PathPreVersionFolder = this.PathLaunchFolder + "PreVersionBackup\\";
            this.PathPreVersionRunFolder = this.PathPreVersionFolder + "Run\\";
            this.PathPreVersionSystemFile1Folder = this.PathPreVersionFolder + "SystemFile1\\";
            this.PathPreVersionSystemFile2Folder = this.PathPreVersionFolder + "SystemFile2\\";
            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.CurrentComRespone = new CommunicationRespone();

            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 < 300; i++)
                this.CollectionGraphData.Add(0);

            this.CollectionInput = new Collection<int>();

            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.CurrentSystemParameter5 = new SystemParameter5();
            //this.CurrentAutoZeroItem = new SystemParameter4();
            this.SystemInfo2 = new SystemInformation2();
            this.SystemInfo3 = new SystemInformation3();
            this.CurrentUser = new User();
            this.CurrentUserGroup = new UserGroup();
            this.CollectionBufferWeightData = new Collection<DataBackupOPT1>();

            this.CollectionProductItem = new Collection<ProductItem>();
            this.CollectionJudgmentItem = new Collection<JudgmentSetItem>();
            this.CollectionWeightData = new Collection<WeightData>();

            this.CurrentJudgmentResult = new JudgmentResult();

            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.Name != "counterItem2.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.Name == "counterItem2.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;
            }

            // DataBackup 폴더 생성
            if (Directory.Exists(this.PathDataBackupFolder) == false)
                Directory.CreateDirectory(this.PathDataBackupFolder);
        }
        private void DefaultSetting2()
        {
            // 바코드
            if (this.SystemConfig2.Barcode != 0)
            {
                this.CurrentBarcode = new Barcode(this.CollectionProductItem, this.ProductCount);

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

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

                this.BarcodeSerialSetting();
            }

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

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

            if (this.SystemConfig2.EthernetCommMode != (int)DataStore.EthernetMode.f0_None)
            {
                switch (this.SystemConfig2.EthernetCommMode)
                {
                    case (int)DataStore.EthernetMode.f16_OPC:
                    case (int)DataStore.EthernetMode.f22_Modbus_TCP:
                        this.ChildFormMainDisplay.MainBottomModbusIconAdd(true);
                        break;
                    default:
                        break;
                }
            }

            // RFID
            if (this.SystemConfig2.IsRFIDSpeedwayR420 == true)
            {
                if (this.SystemConfig2.Barcode > 0)
                {
                    this.SystemConfig2.IsRFIDSpeedwayR420 = false;
                    return;
                }
                else
                    this.SetRFIDInit();
            }

            // Average Tracking
            if (this.SystemConfig1.IsAverageTracking == true)
                this.SetAverageTrackingInit();

            this.RemoveAlarmFile();
            this.RemoveBackupDataFile();
        }
        public void BarcodeSerialSetting()
        {
            int baudrate = 9600;

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

            // STXANDETX
            this.ChangeSerialCOM3FrameSeparateType(DataStore.SeparateType.STXANDETX);

            switch (this.SystemConfig2.Barcode)
            {
                case 1:
                    break;
                case 2:
                    this.smartSerialPort3.Baud_Rate = SmartSerialPort.BAUDRATE._115200bps;
                    this.SystemConfig1.SerialCOM3BaudRate = 4;
                    this.SaveSystemConfigurationFile1(this.SystemConfig1);
                    baudrate = 115200;
                    break;
                case 3:
                    this.smartSerialPort3.Baud_Rate = SmartSerialPort.BAUDRATE._115200bps;
                    this.SystemConfig1.SerialCOM3BaudRate = 4;
                    this.SaveSystemConfigurationFile1(this.SystemConfig1);
                    baudrate = 115200;
                    break;
                default:
                    break;
            }

            if (this.FlagSerialDll == false)
            {
                this.smartSerialPort3.Open();
            }
            else
            {
                // Port : COM3
                SerialMgrComm.serialPortOpen("COM3:", baudrate, 0, 0, 8);
            }
        }
        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 static void Exception(Exception ex)
        {
            try
            {
                string fileName = "SD Card\\DataBackup\\" + 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;
        }

        public void SendAlarmToPC(string sValue)
        {
            StringBuilder sb = new StringBuilder();
            DateTime nowTime = DateTime.Now;

            sb.Append("ALARM");
            sb.Append(";");
            sb.Append(sValue);
            sb.Append(";");
            sb.Append(string.Format("{0:yyyy-MM-dd-HH:mm:ss}", nowTime));

            if (this.smartTCPMultiServer.ClientInfoList != null)
            {
                foreach (SmartTCPMultiServer.CLIENTSINFOS client in this.smartTCPMultiServer.ClientInfoList)
                {
                    if (this.smartTCPMultiServer.ClientInfoList != null)
                        this.EthernetServerSendMessage(client, sb.ToString());
                }
            }
        }
        public void SendMainAlarmForRFID(int index, char previous, char current)
        {
            string prevValue = "", currValue = "";
            StringBuilder sb = new StringBuilder();
            DateTime nowTime = DateTime.Now;

            prevValue = Convert.ToString(Convert.ToInt16(previous.ToString(), 16), 2).PadLeft((4 <= 1) ? 1 : 4, '0');
            currValue = Convert.ToString(Convert.ToInt16(current.ToString(), 16), 2).PadLeft((4 <= 1) ? 1 : 4, '0');

            switch (index)
            {
                case 0:
                    if (prevValue[0] == '0' && currValue[0] == '1')
                    {
                    }
                    if (prevValue[1] == '0' && currValue[1] == '1') // 압력에러
                        this.SendAlarmToPC("J1");
                    if (prevValue[2] == '0' && currValue[2] == '1')
                    {
                    }
                    if (prevValue[3] == '0' && currValue[3] == '1') // 입력센서 에러
                        this.SendAlarmToPC("S1");
                    break;
                case 1:
                    if (prevValue[0] == '0' && currValue[0] == '1') // 비상정지
                        this.SendAlarmToPC("H1");
                    if (prevValue[1] == '0' && currValue[1] == '1') // 배출센서 A
                        this.SendAlarmToPC("S2");
                    if (prevValue[2] == '0' && currValue[2] == '1') // 적체센서
                    {
                    }
                    if (prevValue[3] == '0' && currValue[3] == '1')
                    {
                    }
                    break;
                case 3:
                    if (prevValue[0] == '0' && currValue[0] == '1')
                    {
                    }
                    if (prevValue[1] == '0' && currValue[1] == '1')
                    {
                    }
                    if (prevValue[2] == '0' && currValue[2] == '1') // 배출센서 B
                        this.SendAlarmToPC("S3");
                    if (prevValue[3] == '0' && currValue[3] == '1') // 방풍커버
                    {
                    }
                    break;
                default:
                    break;
            }
        }
        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 = DataStore.JudgmentResult.OK;
                else
                    this.CurrentJudgmentResult.CurrentRejectData = DataStore.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 = DataStore.JudgmentResult.OK;
                else
                    this.CurrentJudgmentResult.PreviousRejectData = DataStore.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;

            if (this.SystemConfig2.Barcode == 3) // Cognex DM150Q
                status = barcode.GetData(ref productNo, this.SystemConfig3.LOTExtractDataFromIndex, this.SystemConfig3.LOTExtractDataToIndex);
            else
                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.ExNGCount = wData.BoardExNGCount;

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

        public void SetRFIDInit()
        {
            this.CurrentRFID = new RFID_Impinj_Speedway_R420(this.SystemConfig2.RFID_R420_BARCD, this.SystemConfig2.RFID_R420_EPC_Filter);

            //this.TimerRFIDRead = new SmartTimer();
            //this.TimerRFIDRead.Interval = 400;
            //this.TimerRFIDRead.Tick += new EventHandler(this.timerRFIDRead_Tick);
        }
        public void DeleteAverageTrackingFile()
        {
            DirectoryInfo dir = new DirectoryInfo(this.PathSDCardSystemFile2Folder);
            FileInfo[] files = dir.GetFiles();

            if (files.Length > 0)
            {
                foreach (FileInfo subFile in files)
                {
                    if (subFile.Name.StartsWith("AverageTracking") == true)
                        subFile.Delete();
                }
            }
        }
        public void SetAverageTrackingInit()
        {
            this.CollectionAverageTrackingItem = new Collection<AverageTrackingItem>();
            this.CurrentProductItemTemp = new ProductItem();

            this.CollectionAverageTrackingItem.Clear();
            for (int i = 0; i < this.ProductCount; i++)
                this.CollectionAverageTrackingItem.Add(new AverageTrackingItem());

            this.LoadAverageTrackingFile(ref this.CollectionAverageTrackingItem);
        }

        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(DataStore.DisplayMode mode)
        {
            if (this.CurrentSystemStatus.CurrentMode == mode)
                return;
            else
                this.CurrentSystemStatus.CurrentMode = mode;

            switch (mode)
            {
                case DataStore.DisplayMode.Normal:
                    this.TransferData(CommunicationCommand.ModeNormal, CommunicationID.MainBoard);
                    break;
                case DataStore.DisplayMode.Menu:
                    this.TransferData(CommunicationCommand.ModeMenu, CommunicationID.MainBoard);
                    break;
                case DataStore.DisplayMode.Calibration:
                    this.TransferData(CommunicationCommand.ModeCalibration, CommunicationID.MainBoard);
                    break;
                case DataStore.DisplayMode.SystemSetting:
                    this.TransferData(CommunicationCommand.ModeJudgment, CommunicationID.MainBoard);
                    break;
                case DataStore.DisplayMode.IOTest:
                    this.TransferData(CommunicationCommand.ModeIOTest, CommunicationID.MainBoard);
                    break;
                case DataStore.DisplayMode.Bypass:
                    this.TransferData(CommunicationCommand.ModeBypass, CommunicationID.MainBoard);
                    break;
                case DataStore.DisplayMode.EquipmentTest:
                    this.TransferData(CommunicationCommand.ModeEquipmentTest, CommunicationID.MainBoard);
                    break;
                case DataStore.DisplayMode.SorterTest:
                    this.TransferData(CommunicationCommand.ModeRejectorTest, CommunicationID.MainBoard);
                    break;
                default:
                    break;
            }
        }
        /// <summary>
        /// Set User
        /// </summary>
        /// <param name="user"></param>
        public void SetUser(DataStore.UserGroup user)
        {
            if (this.CurrentSystemStatus.CurrentUserPasswordType.Group != user)
                this.CurrentSystemStatus.CurrentUserPasswordType.Group = user;
        }

        public void PrintingHeadLine()
        {
            if (this.SystemConfig1.SerialCOM1Mode == 3)
            {
                this.TransferSerialCOM1("\n--------------------------------");
                this.TransferSerialCOM1(" NO    GRADE  WEIGHT");
                this.TransferSerialCOM1("(" + this.SystemConfig1.Unit + ")");
                this.TransferSerialCOM1("  COUNT");
                this.TransferSerialCOM1("\n--------------------------------");
            }
            if (this.SystemConfig1.SerialCOM3Mode == 3)
            {
                this.TransferSerialCOM3("\n--------------------------------");
                this.TransferSerialCOM3(" NO    GRADE  WEIGHT");
                this.TransferSerialCOM3("(" + this.SystemConfig1.Unit + ")");
                this.TransferSerialCOM3("  COUNT");
                this.TransferSerialCOM3("\n--------------------------------");
            }
            if (this.SystemConfig1.SerialCOM4Mode == 3)
            {
                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));
                if (this.SystemConfig1.Unit != "oz")
                    this.TransferSerialCOM1(string.Format("\n TOTAL.WT  = {0}kg", data.UnderSumWeightKG));
                else
                    this.TransferSerialCOM1(string.Format("\n TOTAL.WT  = {0}oz", data.UnderSumWeight));
                this.TransferSerialCOM1(string.Format("\n MEAN      = {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));
                if (this.SystemConfig1.Unit != "oz")
                    this.TransferSerialCOM1(string.Format("\n TOTAL.WT  = {0}kg", data.PassSumWeightKG));
                else
                    this.TransferSerialCOM1(string.Format("\n TOTAL.WT  = {0}oz", data.PassSumWeight));
                this.TransferSerialCOM1(string.Format("\n MEAN      = {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 MAX.WT    = {0}{1}",
                    Helper.DoubleToString(data.PassMaxWeight, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
                this.TransferSerialCOM1(string.Format("\n MIN.WT    = {0}{1}",
                    Helper.DoubleToString(data.PassMinWeight, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
                this.TransferSerialCOM1(string.Format("\n RANGE     = {0}{1}",
                    Helper.DoubleToString(data.MaxMinusMinWeight, 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));
                if (this.SystemConfig1.Unit != "oz")
                    this.TransferSerialCOM1(string.Format("\n TOTAL.WT  = {0}kg", data.OverSumWeightKG));
                else
                    this.TransferSerialCOM1(string.Format("\n TOTAL.WT  = {0}oz", data.OverSumWeight));
                this.TransferSerialCOM1(string.Format("\n MEAN      = {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(WEIGHT NG : Over+Under)"));
                this.TransferSerialCOM1(string.Format("\n COUNT     = {0}", data.TotalUnderOverCount));
                this.TransferSerialCOM1(string.Format("\n MEAN      = {0}{1}",
                    Helper.DoubleToString(data.NGAverage, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));

                string temp = string.Format("\n\nSD(O+P+U)  = {0:0.0000}", data.StandardDeviation);
                if (temp == "NaN")
                    this.TransferSerialCOM1("0.0000");
                else
                    this.TransferSerialCOM1(temp);

                this.TransferSerialCOM1(string.Format("\n\nOTHER FAULTY(ExNG)"));
                this.TransferSerialCOM1(string.Format("\n COUNT     = {0}", data.ExNGCount));

                this.TransferSerialCOM1(string.Format("\n\nTOTAL.COUNT = {0}", data.TotalCount));
                if (this.SystemConfig1.Unit != "oz")
                    this.TransferSerialCOM1(string.Format("\nTOTAL.WT    = {0}kg", data.TotalWeightKG));
                else
                    this.TransferSerialCOM1(string.Format("\nTOTAL.WT    = {0}oz", data.TotalWeight));

                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));
                if (this.SystemConfig1.Unit != "oz")
                    this.TransferSerialCOM3(string.Format("\n TOTAL.WT  = {0}kg", data.UnderSumWeightKG));
                else
                    this.TransferSerialCOM3(string.Format("\n TOTAL.WT  = {0}oz", data.UnderSumWeight));
                this.TransferSerialCOM3(string.Format("\n MEAN      = {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));
                if (this.SystemConfig1.Unit != "oz")
                    this.TransferSerialCOM3(string.Format("\n TOTAL.WT  = {0}kg", data.PassSumWeightKG));
                else
                    this.TransferSerialCOM3(string.Format("\n TOTAL.WT  = {0}oz", data.PassSumWeight));
                this.TransferSerialCOM3(string.Format("\n MEAN      = {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 MAX.WT    = {0}{1}",
                    Helper.DoubleToString(data.PassMaxWeight, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
                this.TransferSerialCOM3(string.Format("\n MIN.WT    = {0}{1}",
                    Helper.DoubleToString(data.PassMinWeight, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
                this.TransferSerialCOM3(string.Format("\n RANGE     = {0}{1}",
                    Helper.DoubleToString(data.MaxMinusMinWeight, 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));
                if (this.SystemConfig1.Unit != "oz")
                    this.TransferSerialCOM3(string.Format("\n TOTAL.WT  = {0}kg", data.OverSumWeightKG));
                else
                    this.TransferSerialCOM3(string.Format("\n TOTAL.WT  = {0}oz", data.OverSumWeight));
                this.TransferSerialCOM3(string.Format("\n MEAN      = {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(WEIGHT NG : Over+Under)"));
                this.TransferSerialCOM3(string.Format("\n COUNT     = {0}", data.TotalUnderOverCount));
                this.TransferSerialCOM3(string.Format("\n MEAN      = {0}{1}",
                    Helper.DoubleToString(data.NGAverage, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));

                string temp = string.Format("\n\nSD(O+P+U)  = {0:0.0000}", data.StandardDeviation);
                if (temp == "NaN")
                    this.TransferSerialCOM3("0.0000");
                else
                    this.TransferSerialCOM3(temp);

                this.TransferSerialCOM3(string.Format("\n\nOTHER FAULTY(ExNG)"));
                this.TransferSerialCOM3(string.Format("\n COUNT     = {0}", data.ExNGCount));

                this.TransferSerialCOM3(string.Format("\n\nTOTAL.COUNT = {0}", data.TotalCount));
                if (this.SystemConfig1.Unit != "oz")
                    this.TransferSerialCOM3(string.Format("\nTOTAL.WT    = {0}kg", data.TotalWeightKG));
                else
                    this.TransferSerialCOM3(string.Format("\nTOTAL.WT    = {0}oz", data.TotalWeight));

                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));
                if (this.SystemConfig1.Unit != "oz")
                    this.TransferSerialCOM4(string.Format("\n TOTAL.WT  = {0}kg", data.UnderSumWeightKG));
                else
                    this.TransferSerialCOM4(string.Format("\n TOTAL.WT  = {0}oz", data.UnderSumWeight));
                this.TransferSerialCOM4(string.Format("\n MEAN      = {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));
                if (this.SystemConfig1.Unit != "oz")
                    this.TransferSerialCOM4(string.Format("\n TOTAL.WT  = {0}kg", data.PassSumWeightKG));
                else
                    this.TransferSerialCOM4(string.Format("\n TOTAL.WT  = {0}oz", data.PassSumWeight));
                this.TransferSerialCOM4(string.Format("\n MEAN      = {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 MAX.WT    = {0}{1}",
                    Helper.DoubleToString(data.PassMaxWeight, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
                this.TransferSerialCOM4(string.Format("\n MIN.WT    = {0}{1}",
                    Helper.DoubleToString(data.PassMinWeight, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));
                this.TransferSerialCOM4(string.Format("\n RANGE     = {0}{1}",
                    Helper.DoubleToString(data.MaxMinusMinWeight, 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));
                if (this.SystemConfig1.Unit != "oz")
                    this.TransferSerialCOM4(string.Format("\n TOTAL.WT  = {0}kg", data.OverSumWeightKG));
                else
                    this.TransferSerialCOM4(string.Format("\n TOTAL.WT  = {0}oz", data.OverSumWeight));
                this.TransferSerialCOM4(string.Format("\n MEAN      = {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(WEIGHT NG : Over+Under)"));
                this.TransferSerialCOM4(string.Format("\n COUNT     = {0}", data.TotalUnderOverCount));
                this.TransferSerialCOM4(string.Format("\n MEAN      = {0}{1}",
                    Helper.DoubleToString(data.NGAverage, this.SystemConfig1.DecimalPlaces), this.SystemConfig1.Unit));

                string temp = string.Format("\n\nSD(O+P+U)  = {0:0.0000}", data.StandardDeviation);
                if (temp == "NaN")
                    this.TransferSerialCOM4("0.0000");
                else
                    this.TransferSerialCOM4(temp);

                this.TransferSerialCOM4(string.Format("\n\nOTHER FAULTY(ExNG)"));
                this.TransferSerialCOM4(string.Format("\n COUNT     = {0}", data.ExNGCount));

                this.TransferSerialCOM4(string.Format("\n\nTOTAL.COUNT = {0}", data.TotalCount));
                if (this.SystemConfig1.Unit != "oz")
                    this.TransferSerialCOM4(string.Format("\nTOTAL.WT    = {0}kg", data.TotalWeightKG));
                else
                    this.TransferSerialCOM4(string.Format("\nTOTAL.WT    = {0}oz", data.TotalWeight));

                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: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\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: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\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: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\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
            }
        }

        // 피드백 데이터(피드백 편차 변경 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);
        }

        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 == DataStore.DisplayStore.MainDisplay)
            {
                if (this.ChildFormMainDisplay != null)
                    this.ChildFormMainDisplay.UpdateCurrentProductDisplay(this.CurrentSystemStatus.Equipment, this.CurrentProductItem, this.CurrentWeightData);

                this.ChildFormMainDisplay.UpdateModbusScreen();
            }
            else if (this.CurrentSystemStatus.CurrentDisplay == DataStore.DisplayStore.SystemSorterSetting)
            {
                if (this.ChildFormMenu.CenterSystemSorterSetting != null)
                    this.ChildFormMenu.CenterSystemSorterSetting.UpdateCurrentProductDisplay(this.CurrentSystemStatus.Equipment, this.CurrentProductItem);
            }
            else if (this.CurrentSystemStatus.CurrentDisplay == DataStore.DisplayStore.ConfiOptionBoard2)
            {
                if (this.ChildFormMenu.CenterConfiOptionBoard.ControlOPT2 != null)
                    this.ChildFormMenu.CenterConfiOptionBoard.ControlOPT2.UpdateCurrentProductDisplay(this.CurrentProductItem, this.CurrentSystemParameter1, this.CurrentSystemParameter2);
            }
            else if (this.CurrentSystemStatus.CurrentDisplay == DataStore.DisplayStore.SystemJudgmentAuto)
            {
                this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
                if (this.SystemConfig3.IsStartStopLog == true)
                    this.smartFileStartStopLog.WriteString(string.Format("Send Stop ({0:yyyy-MM-dd HH:mm:ss}): FormMain-UpdateFeedbackDeviation", DateTime.Now));

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

                this.ChildFormMenu.CenterSystemJudgmentManual.DisplayRefresh(this.CurrentSystemStatus);
                this.ChildFormMenu.CenterSystemJudgmentManual.BringToFront();
            }
            else
            {
                if (this.ChildFormMenu.CenterSystemJudgmentSelect != null)
                    this.ChildFormMenu.CenterSystemJudgmentSelect.UpdateCurrentProductDisplay(this.CurrentSystemStatus.Equipment, this.CurrentProductItem);

                if (this.ChildFormMenu.CenterSystemJudgmentManual != null)
                    this.ChildFormMenu.CenterSystemJudgmentManual.UpdateCurrentProductDisplay(this.CurrentSystemStatus.Equipment, this.CurrentProductItem);

                if (this.ChildFormMenu.CenterSystemJudgmentUpdown != null)
                    this.ChildFormMenu.CenterSystemJudgmentUpdown.UpdateCurrentProductDisplay(this.CurrentSystemStatus.Equipment, this.CurrentProductItem);
            }
        }

        // 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.PathLaunchRunFolder + "Version.ini");
            if (fileCurrentVersionCfg.Exists == false)
            {
                IniFile.CreateVersionIni("ITC81D", DisplayVersion, ReleaseDate);
            }
            else
            {
                if (IniFile.GetIni("PROGRAMINFO", "VERSION", "", this.PathLaunchRunFolder + "Version.ini") != DisplayVersion) ;
                {
                    IniFile.SetIni("PROGRAMINFO", "VERSION", DisplayVersion, this.PathLaunchRunFolder + "Version.ini");
                    IniFile.SetIni("PROGRAMINFO", "RELEASE", ReleaseDate, this.PathLaunchRunFolder + "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 = IniFile.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.PathDataBackupFolder + string.Format("{0:yyMMdd}_", 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.EquipmentID + "_Checklog.txt";
            this.smartFileCheckLog.FilePathName = fullPath;
            // CheckLog
            //this.smartFileCheckLog.Open();
            //this.IsErrorLogOpen = true;
            #endregion

            #region StartStop 통신 로그 - 엔지니어설정 - Log ON 시 Open
            fullPath = this.PathDataBackupFolder + string.Format("{0:yyyyMM}_", dt) + this.SystemConfig1.EquipmentID + "_StartStopLog.txt";
            this.smartFileStartStopLog.FilePathName = fullPath;
            if (this.SystemConfig3.IsStartStopLog == true)
                this.smartFileStartStopLog.Open(this.BufferSmartUart);
            #endregion

            #region 바코드 통신 로그
            fullPath = this.PathDataBackupFolder + string.Format("{0:yyMMdd}_", dt) + "Barcode.txt";
            this.smartFileBarcodeLog.FilePathName = fullPath;
            //this.smartFileBarcodeLog.Open();
            //this.IsBarcodeLogOpen = true;
            #endregion

            #region Client 용 통신 로그
            fullPath = this.PathDataBackupFolder + string.Format("{0:yyMMdd}_", dt) + this.SystemConfig1.EquipmentID + "_ClientConnection.txt";
            this.smartFile1.FilePathName = fullPath;
            //this.timer1.Enabled = true;
            //this.smartFile1.Open();
            #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;
        }
        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 == DataStore.JudgmentStatus.Pass
                || weight.JudgmentStatus == DataStore.JudgmentStatus.Over
                || weight.JudgmentStatus == DataStore.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 != DataStore.JudgmentStatus.Pass)
                    tempFlag = true;

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

                if (this.CurrentProductItem.UnderRangeInt > tempWeight && weight.JudgmentStatus != DataStore.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;
        }
        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} : Receive Command Data CHKSUM Error", 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 'C' 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 == DataStore.EquipmentStatus.Start)
                    {
                        this.CurrentSystemStatus.Equipment = DataStore.EquipmentStatus.Stop;

                        if (this.SystemConfig2.Barcode != 0)
                        {
                            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 "CC0":
                    #region 외부입력 확인
                    // RFID
                    if (this.SystemConfig2.IsRFIDSpeedwayR420 == true)
                    {
                        if (this.CurrentSystemStatus.CurrentDisplay == DataStore.DisplayStore.MainDisplay
                           && this.CurrentSystemStatus.Equipment == DataStore.EquipmentStatus.Start)
                        {
                            this.CurrentRFID.Add("");
                            this.ChildFormMainDisplay.UpdateRFIDDisplay(this.CurrentRFID);

                            this.Invoke(new RFIDNGSendTime_Delegate(this.RFIDNGSendTimeDelegate));

                            //if (this.TimerRFIDRead.IsStart == true)
                            //    this.TimerRFIDRead.Stop();
                            //this.TimerRFIDRead.Start();
                        }
                    }
                    #endregion
                    break;
                case "CBI":
                    #region 공장초기화완료
                    if (this.ChildFormMenu != null)
                        this.ChildFormMenu.CenterEquipInitialize.UpdateDisplayMainBoardInitialization();
                    #endregion
                    break;
                case "CBS":
                    #region 운전
                    if (this.SystemConfig3.IsStartStopLog == true)
                        this.smartFileStartStopLog.WriteString(string.Format("Receive Start ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, strTemp));

                    this.CurrentSystemStatus.Equipment = DataStore.EquipmentStatus.Start;
                    this.Update30000ModbusItem();

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

                    // 운전 시, 진입센서 미감지 Pop up 창 자동 Close
                    this.ChildFormMainDisplay.PopUpWarning2CloseWhenEntryNotDetected();

                    // 바코드
                    if (this.SystemConfig2.Barcode != 0)
                    {
                        // STXANDETX
                        this.ChangeSerialCOM3FrameSeparateType(DataStore.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.SystemConfig1.IsAverageTracking == true)
                    {
                        this.CurrentProductItemTemp.OverRange = this.CurrentProductItem.OverRange;
                        this.CurrentProductItemTemp.PassRange = this.CurrentProductItem.PassRange;
                        this.CurrentProductItemTemp.UnderRange = this.CurrentProductItem.UnderRange;
                    }

                    // 재전송 관련 카운트 표시
                    // Hidden 버튼 누르면 메인화면에 표시됨
                    this.IndexOverRun = 0;
                    this.ChildFormMainDisplay.labelOverrun.Text = "0";

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

                        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 정지
                    if (this.SystemConfig3.IsStartStopLog == true)
                        this.smartFileStartStopLog.WriteString(string.Format("Receive Stop ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, strTemp));

                    this.CommID = 0;
                    
                    this.CurrentSystemStatus.Equipment = DataStore.EquipmentStatus.Stop;
                    this.Update30000ModbusItem();

                    // Respone
                    this.CurrentComRespone.Initialization();

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

                    // RFID
                    if (this.SystemConfig2.IsRFIDSpeedwayR420 == true)
                    {
                        this.PreviousTag = "000000000000000000000000";
                        this.ReferenceTag = "";
                        this.CurrentRFID.Clear();
                        this.ChildFormMainDisplay.UpdateRFIDDisplay(this.CurrentRFID);
                    }

                    // 기준치 갱신
                    if (this.SystemConfig1.IsAverageTracking == true)
                    {
                        this.CurrentAverageTrackingItem.DataClear();

                        this.CurrentProductItem.OverRange = this.CurrentProductItemTemp.OverRange;
                        this.CurrentProductItem.PassRange = this.CurrentProductItemTemp.PassRange;
                        this.CurrentProductItem.UnderRange = this.CurrentProductItemTemp.UnderRange;

                        this.ChildFormMainDisplay.MainAverageTracking.UpdateParameter(this.CurrentAverageTrackingItem, this.CurrentProductItem, this.SystemConfig1);
                        this.ChildFormMainDisplay.RescaleControl(this.CurrentProductItem);
                        this.TransferCurrentProductItem(this.CurrentProductItem);
                        this.SaveProductFile(this.CurrentProductItem, this.SystemConfig1.ProductNumber - 1);
                        this.ChildFormMainDisplay.UpdateCurrentProductDisplay(this.CurrentSystemStatus.Equipment, this.CurrentProductItem, this.CurrentWeightData);
                    }

                    // 바코드
                    if (this.SystemConfig2.Barcode != 0)
                    {
                        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.CurrentSystemStatus.CurrentDisplay == DataStore.DisplayStore.MainDisplay)
                    {
                        if (this.ChildFormMainDisplay != null)
                            this.ChildFormMainDisplay.UpdateEquipmentStatusDisplay(this.CurrentSystemStatus.Equipment);
                    }
                    else
                    {
                        if (this.CurrentSystemStatus.CurrentDisplay == DataStore.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.IsDataBackup == true)
                    {
                        if (this.SystemConfig1.DatabackupFormat == 1)
                        {
                            // 데이터백업 포맷 : OPT1 - 정지 시 리젝데이터 STOP 처리
                            for (int i = 0; i < this.CollectionBufferWeightData.Count; i++)
                            {
                                this.CollectionBufferWeightData[i].Status = DataStore.JudgmentResult.STOP.ToString();
                                this.DataBackup1(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 영점

                    #endregion
                    break;
                case "Csm":
                    #region 메뉴모드
                    if (this.CurrentSystemStatus.Equipment == DataStore.EquipmentStatus.Start)
                    {
                        this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
                        if (this.SystemConfig3.IsStartStopLog == true)
                            this.smartFileStartStopLog.WriteString(string.Format("Send Stop ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, strTemp));
                    }
                    #endregion
                    break;
                case "Csc":
                    #region 중량조정모드
                    if (this.CurrentSystemStatus.Equipment == DataStore.EquipmentStatus.Start)
                    {
                        this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
                        if (this.SystemConfig3.IsStartStopLog == true)
                            this.smartFileStartStopLog.WriteString(string.Format("Send Stop ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, strTemp));
                    }
                    #endregion
                    break;
                case "CSa":
                    #region 진입센서 감지 시
                    // 센서에러 감지시간 설정 시
                    if (this.SystemConfig3.SensorErrorDetectingTime > 0)
                    {
                        if (this.timerSensorError.Enabled == true)
                            this.timerSensorError.Enabled = false;
                        this.timerSensorError.Interval = this.SystemConfig3.SensorErrorDetectingTime + this.CurrentJudgmentSetItem.JudgmentDelayTime;
                        this.timerSensorError.Enabled = true;
                    }

                    if (this.SystemConfig2.Barcode > 0)
                    {
                        try
                        {
                            // V7.8.0
                            if (this.CurrentBarcode.GetQueueCount == 0)
                            {
                                // V8.6.5
                                // 2D 바코드 사용 시 NoRead 처리 안함
                                if (this.SystemConfig2.Barcode != 3)
                                    this.CurrentBarcode.SetData("NoRead");

                                if (this.CurrentBarcode.GetQueueCount > 0)
                                    this.BarcodeProductChange(this.CurrentBarcode);
                            }
                        }
                        catch
                        {
                        }
                    }
                    #endregion
                    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 = "";

            // 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 'P' Stream Data CHKSUM Error", DateTime.Now, strTemp));
                return ret = -1;
            }
            // 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 'P' Stream Data SIZE 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 = "";

            // 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 'S' Stream Data CHKSUM Error", DateTime.Now, strTemp));

                // 바코드 로그
                if (this.IsBarcodeLogOpen == true)
                    if(strTemp.StartsWith("SR0") == true)
                        this.smartFileBarcodeLog.WriteString(string.Format("Receive SR0 ({0:yyyy-MM-dd HH:mm:ss}): {1} : Receive 'S' Stream Data CHKSUM Error", DateTime.Now, strTemp));

                return ret = -1;
            }
            // 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 'S' Stream Data SIZE Error", DateTime.Now, strTemp));

                // 바코드 로그
                if (this.IsBarcodeLogOpen == true)
                    if (strTemp.StartsWith("SR0") == true)
                        this.smartFileBarcodeLog.WriteString(string.Format("Receive SR0 ({0:yyyy-MM-dd HH:mm:ss}): {1} : Receive 'S' Stream Data SIZE 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 (this.IsBarcodeLogOpen == true)
                        this.smartFileBarcodeLog.WriteString(string.Format("Receive SR0 ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, strTemp));

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

            // 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 'T' Stream Data CHKSUM Error", DateTime.Now, strTemp));
                return ret = -1;
            }
            // 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 'T' Stream Data SIZE 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":
                    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;
            string sValue = "";

            try
            {
                switch (address)
                {
                    case "1501":
                        #region Value Assign
                        this.SystemConfig1.MainBoardVersion = receiveData.Substring(0, 4);
                        #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;

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

                            //if (this.SystemConfig2.EthernetOperationMode == 2)
                            //{
                            //    this.TimerEnabled(true);
                            //}
                        }
                        else
                        {
                            this.SaveCounterFile(this.CollectionWeightData);
                            this.TransferCountData(this.SystemConfig1.ProductNumber);
                        }

                        if (this.SystemConfig2.Barcode != 0 && this.CurrentSystemStatus.Equipment == DataStore.EquipmentStatus.Start)
                            return ret;

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

                        this.UpdateScreen();

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

                        // OverloadWeight 값 확인을 위한 MaxWeight 값 읽기
                        this.TransferDataStream(CommunicationCommand.Read, CommunicationID.MainBoard, CommunicationAddress.ParameterRead3901, "");
                        break;
                    case "2002":
                        this.TransferDataStream(CommunicationCommand.Read, CommunicationID.MainBoard, CommunicationAddress.OverRange, "");
                        break;
                    case "3601":
                        #region Value Assign
                        this.CurrentCalibrationItem.Constant = receiveData.Substring(0, 7).Trim();
                        #endregion
                        if (this.CurrentSystemStatus.CurrentDisplay == DataStore.DisplayStore.SystemCalibration)
                        {
                            if (this.ChildFormMenu.CenterSystemCalibration != null)
                                this.ChildFormMenu.CenterSystemCalibration.UpdateCalibrationItemDisplay(this.CurrentSystemStatus.Equipment, this.CurrentCalibrationItem);
                        }
                        else if (this.CurrentSystemStatus.CurrentDisplay == DataStore.DisplayStore.SystemJudgmentManual)
                        {
                            if (this.ChildFormMenu.CenterSystemJudgmentManual != null)
                                this.ChildFormMenu.CenterSystemJudgmentManual.UpdateConstantDisplay(this.CurrentSystemStatus.Equipment, this.CurrentCalibrationItem);
                        }
                        else if (this.CurrentSystemStatus.CurrentDisplay == DataStore.DisplayStore.SystemJudgmentUpdown)
                        {
                            if (this.ChildFormMenu.CenterSystemJudgmentUpdown != null)
                                this.ChildFormMenu.CenterSystemJudgmentUpdown.UpdateConstantDisplay(this.CurrentSystemStatus.Equipment, this.CurrentCalibrationItem);
                        }
                        break;
                    case "3901":
                        #region Value Assign
                        this.CurrentCalibrationItem.MaxWeight = receiveData.Substring(0, 7).Trim();
                        this.CurrentCalibrationItem.BalanceWeight = receiveData.Substring(7, 7).Trim();
                        this.CurrentCalibrationItem.Digit = receiveData.Substring(14, 7).Trim();
                        this.CurrentCalibrationItem.Constant = receiveData.Substring(21, 7).Trim();
                        #endregion
                        this.OverloadWeight = Helper.StringToWeight(this.CurrentCalibrationItem.OverloadWeightString, this.SystemConfig1.DecimalPlaces);

                        if (this.CurrentSystemStatus.CurrentDisplay == DataStore.DisplayStore.SystemCalibration)
                        {
                            if (this.ChildFormMenu.CenterSystemCalibration != null)
                                this.ChildFormMenu.CenterSystemCalibration.UpdateCalibrationItemDisplay(this.CurrentSystemStatus.Equipment, this.CurrentCalibrationItem);
                        }
                        break;
                    case "4901":
                        #region Value Assign
                        this.CurrentSystemParameter4.MainAutoZero1Time = receiveData.Substring(0, 4).Trim();
                        this.CurrentSystemParameter4.MainAutoZero1Range = receiveData.Substring(4, 4).Trim();
                        this.CurrentSystemParameter4.MainAutoZero1Variate = receiveData.Substring(8, 4).Trim();
                        this.CurrentSystemParameter4.MainAutoZero1Mode = receiveData.Substring(12, 4).Trim();
                        #endregion
                        if (this.CurrentSystemStatus.CurrentDisplay == DataStore.DisplayStore.SystemAutoZero)
                        {
                            if (this.ChildFormMenu.CenterSystemAutoZero != null)
                                this.ChildFormMenu.CenterSystemAutoZero.UpdateZero1ParameterDisplay(this.CurrentSystemParameter4);
                        }
                        else if (this.CurrentSystemStatus.CurrentDisplay == DataStore.DisplayStore.MainDisplay)
                        {
                            if (this.ChildFormMainDisplay.MainSubMenu != null)
                                this.ChildFormMainDisplay.MainSubMenu.UpdateZero1ParameterDisplay(this.CurrentSystemParameter4);
                        }
                        break;
                    case "4902":
                        #region Value Assign
                        this.CurrentSystemParameter4.MainAutoZero2Mode = receiveData.Substring(0, 4).Trim();
                        this.CurrentSystemParameter4.MainAutoZero2Time = receiveData.Substring(4, 4).Trim();
                        this.CurrentSystemParameter4.MainAutoZero2Range = receiveData.Substring(8, 4).Trim();
                        this.CurrentSystemParameter4.MainAutoZero2Variate = receiveData.Substring(12, 4).Trim();
                        #endregion
                        if (this.ChildFormMenu.CenterSystemAutoZero != null)
                            this.ChildFormMenu.CenterSystemAutoZero.UpdateZero2ParameterDisplay(this.CurrentSystemParameter4);
                        break;
                    case "5057":
                        #region Value Assign
                        this.CurrentSensorDetectingTime = int.Parse(receiveData.Substring(0, 4).Trim());
                        #endregion
                        if (this.CurrentSystemStatus.CurrentDisplay == DataStore.DisplayStore.SystemJudgmentAuto)
                        {
                            if (this.ChildFormMenu.CenterSystemJudgmentAuto != null)
                                this.ChildFormMenu.CenterSystemJudgmentAuto.CaculateJudgmentData(this.CurrentSensorDetectingTime);
                        }
                        else
                        {
                            if (this.ChildFormMenu.CenterSystemJudgmentManual != null)
                                this.ChildFormMenu.CenterSystemJudgmentManual.CaculateJudgmentData(this.CurrentSensorDetectingTime);
                        }
                        break;
                    case "5302":
                        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.UpdateCountData(this.CurrentWeightData);
                        #endregion
                        break;
                    case "9512":
                        #region Value Assign
                        this.SystemInfo2.MaxWeight = receiveData.Substring(0, 7).Trim();
                        this.SystemInfo2.BalanceWeight = receiveData.Substring(7, 7).Trim();
                        this.SystemInfo2.Digit = receiveData.Substring(14, 7).Trim();
                        this.SystemInfo2.Calc = receiveData.Substring(21, 7).Trim();
                        this.SystemInfo2.Filter = receiveData.Substring(28, 4).Trim();
                        this.SystemInfo2.JudgmentDelay = receiveData.Substring(32, 4).Trim();
                        this.SystemInfo2.DoubleDelay = receiveData.Substring(36, 4).Trim();
                        this.SystemInfo2.JudgmentNumber = receiveData.Substring(40, 4).Trim();
                        this.SystemInfo2.Speed = receiveData.Substring(44, 4).Trim();
                        this.SystemInfo2.Dynamic = receiveData.Substring(48, 7).Trim();
                        this.SystemInfo2.SorterAMode = receiveData.Substring(55, 4).Trim();
                        this.SystemInfo2.SorterADelay = receiveData.Substring(59, 4).Trim();
                        this.SystemInfo2.SorterAOperation = receiveData.Substring(63, 4).Trim();
                        this.SystemInfo2.SorterBMode = receiveData.Substring(67, 4).Trim();
                        this.SystemInfo2.SorterBDelay = receiveData.Substring(71, 4).Trim();
                        this.SystemInfo2.SorterBOperation = receiveData.Substring(75, 4).Trim();
                        this.SystemInfo2.DoubleEntry = receiveData.Substring(79, 4).Trim();
                        this.SystemInfo2.ExternalInput = receiveData.Substring(83, 4).Trim();
                        this.SystemInfo2.ETCNG = receiveData.Substring(87, 4).Trim();
                        this.SystemInfo2.AutoZero1Time = receiveData.Substring(91, 4).Trim();
                        this.SystemInfo2.AutoZero1Range = receiveData.Substring(95, 4).Trim();
                        this.SystemInfo2.AutoZero1Variate = receiveData.Substring(99, 4).Trim();
                        this.SystemInfo2.AutoZero1Mode = receiveData.Substring(103, 4).Trim();
                        this.SystemInfo2.AutoZero2Mode = receiveData.Substring(107, 4).Trim();
                        this.SystemInfo2.AutoZero2Time = receiveData.Substring(111, 4).Trim();
                        this.SystemInfo2.AutoZero2Range = receiveData.Substring(115, 4).Trim();
                        this.SystemInfo2.AutoZero2Variate = receiveData.Substring(119, 4).Trim();
                        this.SystemInfo2.UnderRange = receiveData.Substring(123, 7).Trim();
                        this.SystemInfo2.PassRange = receiveData.Substring(130, 7).Trim();
                        this.SystemInfo2.OverRange = receiveData.Substring(137, 7).Trim();
                        this.SystemInfo2.TareRange = receiveData.Substring(144, 7).Trim();
                        #endregion

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

                        this.TransferDataStream(CommunicationCommand.Read, CommunicationID.MainBoard, CommunicationAddress.SystemInformationRead2, "");
                        break;
                    case "9513":
                        #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.ExternalOutput9Mode = receiveData.Substring(48, 4).Trim();
                        this.SystemInfo2.ExternalOutput9Delay = receiveData.Substring(52, 4).Trim();
                        this.SystemInfo2.ExternalOutput9Operation = receiveData.Substring(56, 4).Trim();
                        this.SystemInfo2.ExternalOutput10Mode = receiveData.Substring(60, 4).Trim();
                        this.SystemInfo2.ExternalOutput10Delay = receiveData.Substring(64, 4).Trim();
                        this.SystemInfo2.ExternalOutput10Operation = receiveData.Substring(68, 4).Trim();
                        this.SystemInfo2.AscendDelay = receiveData.Substring(72, 4).Trim();
                        this.SystemInfo2.DescendDelay = receiveData.Substring(76, 4).Trim();
                        this.SystemInfo2.dummy1 = receiveData.Substring(80, 4).Trim();
                        this.SystemInfo2.dummy2 = receiveData.Substring(84, 4).Trim();
                        this.SystemInfo2.dummy3 = receiveData.Substring(88, 4).Trim();
                        this.SystemInfo2.dummy4 = receiveData.Substring(92, 4).Trim();
                        this.SystemInfo2.dummy5 = receiveData.Substring(96, 4).Trim();
                        this.SystemInfo2.dummy6 = receiveData.Substring(100, 4).Trim();
                        this.SystemInfo2.dummy7 = receiveData.Substring(104, 4).Trim();
                        this.SystemInfo2.dummy8 = receiveData.Substring(108, 4).Trim();
                        #endregion

                        if (this.ChildFormMenu.CenterInforSystem2 != null)
                            this.ChildFormMenu.CenterInforSystem2.UpdateParameter2Display(this.SystemInfo2);
                        break;
                    case "9514":
                        #region Value Assign
                        this.SystemInfo3.Random1Number = receiveData.Substring(0, 4).Trim();
                        this.SystemInfo3.Random1Using = receiveData.Substring(4, 4).Trim();
                        this.SystemInfo3.Random1Under = receiveData.Substring(8, 7).Trim();
                        this.SystemInfo3.Random1Over = receiveData.Substring(15, 7).Trim();
                        this.SystemInfo3.Random1Tare = receiveData.Substring(22, 7).Trim();
                        this.SystemInfo3.Random2Number = receiveData.Substring(29, 4).Trim();
                        this.SystemInfo3.Random2Using = receiveData.Substring(33, 4).Trim();
                        this.SystemInfo3.Random2Under = receiveData.Substring(37, 7).Trim();
                        this.SystemInfo3.Random2Over = receiveData.Substring(44, 7).Trim();
                        this.SystemInfo3.Random2Tare = receiveData.Substring(51, 7).Trim();
                        this.SystemInfo3.Random3Number = receiveData.Substring(58, 4).Trim();
                        this.SystemInfo3.Random3Using = receiveData.Substring(62, 4).Trim();
                        this.SystemInfo3.Random3Under = receiveData.Substring(66, 7).Trim();
                        this.SystemInfo3.Random3Over = receiveData.Substring(73, 7).Trim();
                        this.SystemInfo3.Random3Tare = receiveData.Substring(80, 7).Trim();
                        this.SystemInfo3.Random4Number = receiveData.Substring(87, 4).Trim();
                        this.SystemInfo3.Random4Using = receiveData.Substring(91, 4).Trim();
                        this.SystemInfo3.Random4Under = receiveData.Substring(95, 7).Trim();
                        this.SystemInfo3.Random4Over = receiveData.Substring(102, 7).Trim();
                        this.SystemInfo3.Random4Tare = receiveData.Substring(109, 7).Trim();
                        this.SystemInfo3.Random5Number = receiveData.Substring(116, 4).Trim();
                        this.SystemInfo3.Random5Using = receiveData.Substring(120, 4).Trim();
                        this.SystemInfo3.Random5Under = receiveData.Substring(124, 7).Trim();
                        this.SystemInfo3.Random5Over = receiveData.Substring(131, 7).Trim();
                        this.SystemInfo3.Random5Tare = receiveData.Substring(138, 7).Trim();
                        #endregion

                        if (this.ChildFormMenu.CenterInforSystem3 != null)
                            this.ChildFormMenu.CenterInforSystem3.UpdateParameter1Display(this.SystemInfo3);

                        this.TransferDataStream(CommunicationCommand.Read, CommunicationID.MainBoard, CommunicationAddress.SystemInformationRead4, "");
                        break;
                    case "9515":
                        #region Value Assign
                        this.SystemInfo3.OPT1SampleNumber = receiveData.Substring(0, 4).Trim();
                        this.SystemInfo3.OPT1DelayNumber = receiveData.Substring(4, 4).Trim();
                        this.SystemInfo3.OPT1PulseWidth = receiveData.Substring(8, 4).Trim();
                        this.SystemInfo3.OPT1Using = receiveData.Substring(12, 4).Trim();
                        this.SystemInfo3.OPT1OverRange = receiveData.Substring(16, 7).Trim();
                        this.SystemInfo3.OPT1UnderRange = receiveData.Substring(23, 7).Trim();
                        this.SystemInfo3.OPT2Port = receiveData.Substring(30, 4).Trim();
                        this.SystemInfo3.OPT2Delay1 = receiveData.Substring(34, 4).Trim();
                        this.SystemInfo3.OPT2Delay2 = receiveData.Substring(38, 4).Trim();
                        this.SystemInfo3.BuzzerONTime = receiveData.Substring(42, 4).Trim();
                        this.SystemInfo3.Chattering = receiveData.Substring(46, 4).Trim();
                        this.SystemInfo3.Relay = receiveData.Substring(50, 4).Trim();
                        this.SystemInfo3.OptionBoard = receiveData.Substring(54, 4).Trim();
                        this.SystemInfo3.EquipmentType = receiveData.Substring(58, 4).Trim();
                        this.SystemInfo3.PhotoB = receiveData.Substring(62, 4).Trim();
                        this.SystemInfo3.PI3 = receiveData.Substring(66, 4).Trim();
                        this.SystemInfo3.PI4 = receiveData.Substring(70, 4).Trim();
                        this.SystemInfo3.PI5 = receiveData.Substring(74, 4).Trim();
                        this.SystemInfo3.PI6 = receiveData.Substring(78, 4).Trim();
                        this.SystemInfo3.PI7 = receiveData.Substring(82, 4).Trim();
                        this.SystemInfo3.PI8 = receiveData.Substring(86, 4).Trim();
                        this.SystemInfo3.dummy1 = receiveData.Substring(90, 4).Trim();
                        this.SystemInfo3.dummy2 = receiveData.Substring(94, 4).Trim();
                        this.SystemInfo3.dummy3 = receiveData.Substring(98, 4).Trim();
                        this.SystemInfo3.dummy4 = receiveData.Substring(102, 4).Trim();
                        this.SystemInfo3.dummy5 = receiveData.Substring(106, 4).Trim();
                        this.SystemInfo3.dummy6 = receiveData.Substring(110, 4).Trim();
                        this.SystemInfo3.dummy7 = receiveData.Substring(114, 4).Trim();
                        this.SystemInfo3.dummy8 = receiveData.Substring(118, 4).Trim();
                        this.SystemInfo3.dummy9 = receiveData.Substring(122, 4).Trim();
                        this.SystemInfo3.dummy10 = receiveData.Substring(126, 4).Trim();
                        #endregion

                        if (this.ChildFormMenu.CenterInforSystem3 != null)
                            this.ChildFormMenu.CenterInforSystem3.UpdateParameter2Display(this.SystemInfo3);
                        break;
                    default:
                        break;
                }
            }
            catch
            {
                ret = -1;
            }

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

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

                switch (address)
                {
                    case "4004":
                        if (response == DataStore.ResponseData.ACK)
                            this.TransferDataStream(CommunicationCommand.Read, CommunicationID.MainBoard, CommunicationAddress.ParameterRead4901, "");
                        break;
                    case "4005":
                        if (response == DataStore.ResponseData.ACK)
                            this.TransferDataStream(CommunicationCommand.Read, CommunicationID.MainBoard, CommunicationAddress.ParameterRead4902, "");
                        break;
                    case "9006":
                        if (response == DataStore.ResponseData.ACK)
                            this.TransferProductParameter(this.SystemConfig1.ProductNumber);
                        break;
                    case "9007":
                        if (response == DataStore.ResponseData.ACK)
                            this.TransferDataStream(CommunicationCommand.Read, CommunicationID.MainBoard, CommunicationAddress.ProductNumber, "");
                        break;
                    case "9018":
                        if (response == DataStore.ResponseData.ACK && this.CurrentSystemStatus.CurrentDisplay != DataStore.DisplayStore.EquipFuctionSetting)
                            this.TransferParameter2();
                        break;
                    case "9019":
                        if (response == DataStore.ResponseData.ACK)
                            this.TransferParameter3();
                        break;
                    case "9020":
                        if (response == DataStore.ResponseData.ACK)
                            this.TransferParameter4();
                        break;
                    case "9021":
                        if (response == DataStore.ResponseData.ACK)
                            this.TransferRandomMode();
                        break;
                    case "9023":
                        if (response == DataStore.ResponseData.ACK)
                        {
                            if (this.SystemConfig2.IsUsingRandomMode == true)
                                this.SystemConfig1.ProductNumber = 996;
                            this.TransferProductParameter(this.SystemConfig1.ProductNumber);
                        }
                        break;
                    case "9025":
                        if (response == DataStore.ResponseData.ACK)
                            this.TransferDataStream(CommunicationCommand.Read, CommunicationID.MainBoard, CommunicationAddress.ProductNumber, "");
                        break;
                    case "9031":
                        break;
                    default:
                        break;
                }
            }
            catch
            {
                ret = -1;
            }

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

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

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

            return ret;
        }

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

            try
            {
                switch (lane)
                {
                    case "A":
                        #region Value Assign
                        if (this.CurrentSystemStatus.Equipment == DataStore.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 == DataStore.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;

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

            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 = DataStore.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 = DataStore.WeightStatus.WeightChange;

                                if (this.ChildFormMainDisplay != null)
                                    this.ChildFormMainDisplay.UpdateCurrentProductDisplay(this.CurrentSystemStatus.Equipment,
                                        this.CurrentProductItem, this.CurrentWeightData);
                                #endregion
                                break;
                            default:
                                break;
                        }
                        // 통신 제대로 받으면 ACK
                        //this.TransferData(string.Format("{0}{1}{2}{3}", CommunicationCommand.RunWeightData, (int)DataStore.ResponseData.ACK, dataID, transferCount), CommunicationID.MainBoard);

                        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;

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

                            // 바이패스 1회 사용 시
                            if (this.IsBypassOnce == true)
                            {
                                this.IsBypassOnce = false;
                                this.ChildFormMainDisplay.MainWeightBigScreen.UpdateSpotOrBypassImageVisibleStatus(false);
                                this.ChildFormMainDisplay.MainWeightSmallScreen.UpdateSpotOrBypassImageVisibleStatus(false);
                                this.ChildFormMainDisplay.MainSpotCheck.ChangeEnableButtonSpotCheckRun(true);
                            }

                            // RFID
                            if (this.SystemConfig2.IsRFIDSpeedwayR420 == true)
                            {
                                if (this.CurrentRFID.Count() > 0)
                                    this.ReferenceTag = this.CurrentRFID.ReturnTag(0);
                            }

                            this.Update30000ModbusItem();

                            #region 통신
                            // 통신 COM1
                            if (this.SystemConfig1.SerialCOM1Mode != 0)
                            {
                                #region COM1
                                switch (this.SystemConfig1.SerialCOM1Mode)
                                {
                                    case 1:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM1 == false)
                                            this.TransferSerialCOM1(this.Transfer_1_STD1(this.SystemConfig3.IsCharToFillZeroCOM1, this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM1(this.Transfer_1_STD1(this.SystemConfig3.IsCharToFillZeroCOM1, this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem));
                                        }
                                        break;
                                    case 2:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM1 == false)
                                            this.TransferSerialCOM1(this.Transfer_2_Remote(this.SystemConfig3.IsCharToFillZeroCOM1, this.CurrentWeightData, this.CurrentProductItem));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM1(this.Transfer_2_Remote(this.SystemConfig3.IsCharToFillZeroCOM1, this.CurrentWeightData, this.CurrentProductItem));
                                        }
                                        break;
                                    case 3:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM1 == false)
                                        {
                                            if (this.SystemConfig1.IsPrintPerProductEnable == true)
                                                this.TransferSerialCOM1(this.Transfer_3_Print(this.SystemConfig3.IsCharToFillZeroCOM1, this.CurrentWeightData, this.CurrentProductItem));
                                        }
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM1(this.Transfer_3_Print(this.SystemConfig3.IsCharToFillZeroCOM1, this.CurrentWeightData, this.CurrentProductItem));
                                        }
                                        break;
                                    case 4:
                                        if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                        {
                                            this.TransferSerialCOM1(this.RoomChange9410(2)); // 2번방 변경
                                            Thread.Sleep(200);
                                            this.TransferSerialCOM1(this.SendChar(DataStore.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(DataStore.CharValue.ACK)); // ACK
                                        }
                                        break;
                                    case 5:
                                        this.HMCOM1_Step = 1;

                                        if (this.SystemConfig3.IsTransmitWhenPassCOM1 == false)
                                            this.TransferSerialCOM1(this.SendChar(DataStore.CharValue.ENQ));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM1(this.SendChar(DataStore.CharValue.ENQ));
                                        }
                                        break;
                                    case 6:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM1 == false)
                                            this.TransferSerialCOM1(this.Transfer_6_OPT0(this.SystemConfig3.IsCharToFillZeroCOM1, this.CurrentWeightData));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM1(this.Transfer_6_OPT0(this.SystemConfig3.IsCharToFillZeroCOM1, this.CurrentWeightData));
                                        }
                                        break;
                                    case 7:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM1 == false)
                                            this.TransferSerialCOM1(this.Transfer_7_imaje9410OPT2(this.SystemConfig3.IsCharToFillZeroCOM1, this.CurrentWeightData));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM1(this.Transfer_7_imaje9410OPT2(this.SystemConfig3.IsCharToFillZeroCOM1, this.CurrentWeightData));
                                        }
                                        break;
                                    case 8:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM1 == false)
                                            this.TransferSerialCOM1(this.Transfer_8_imaje9028OPT2(this.SystemConfig3.IsCharToFillZeroCOM1, this.CurrentWeightData));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM1(this.Transfer_8_imaje9028OPT2(this.SystemConfig3.IsCharToFillZeroCOM1, this.CurrentWeightData));
                                        }
                                        break;
                                    case (int)DataStore.SerialMode.f9_Hitachi:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM1 == false)
                                            this.TransferSerialCOM1(this.Transfer_9_Hitachi(this.SystemConfig3.IsCharToFillZeroCOM1, this.CurrentWeightData, DataStore.SerialCOM.COM1));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM1(this.Transfer_9_Hitachi(this.SystemConfig3.IsCharToFillZeroCOM1, this.CurrentWeightData, DataStore.SerialCOM.COM1));
                                        }
                                        break;
                                    case 10:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM1 == false)
                                            this.TransferSerialCOM1(this.Transfer_10_MACSA(this.SystemConfig3.IsCharToFillZeroCOM1, this.CurrentWeightData, this.CurrentProductItem));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM1(this.Transfer_10_MACSA(this.SystemConfig3.IsCharToFillZeroCOM1, this.CurrentWeightData, this.CurrentProductItem));
                                        }
                                        break;
                                    case 11:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM1 == false)
                                            this.TransferSerialCOM1(this.Transfer_11_Markoprint(this.SystemConfig3.IsCharToFillZeroCOM1, this.CurrentWeightData, this.CurrentProductItem));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM1(this.Transfer_11_Markoprint(this.SystemConfig3.IsCharToFillZeroCOM1, this.CurrentWeightData, this.CurrentProductItem));
                                        }
                                        break;
                                    case 12:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM1 == false)
                                            this.TransferSerialCOM1(this.Transfer_12_alphaJET(this.SystemConfig3.IsCharToFillZeroCOM1, this.CurrentWeightData, this.CurrentProductItem));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM1(this.Transfer_12_alphaJET(this.SystemConfig3.IsCharToFillZeroCOM1, this.CurrentWeightData, this.CurrentProductItem));
                                        }
                                        break;
                                    case (int)DataStore.SerialMode.f13_Marking_VJ1510:
                                    case (int)DataStore.SerialMode.f25_DJ_VIDEOJET:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM1 == false)
                                            this.TransferSerialCOM1(this.Transfer_13_Marking_VJ1510(this.SystemConfig3.IsCharToFillZeroCOM1, this.CurrentWeightData));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM1(this.Transfer_13_Marking_VJ1510(this.SystemConfig3.IsCharToFillZeroCOM1, this.CurrentWeightData));
                                        }
                                        break;
                                    case 17:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM1 == false)
                                            this.TransferSerialCOM1(this.Transfer_17_OPT3(this.SystemConfig3.IsCharToFillZeroCOM1, this.CurrentWeightData, this.CurrentProductItem));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM1(this.Transfer_17_OPT3(this.SystemConfig3.IsCharToFillZeroCOM1, this.CurrentWeightData, this.CurrentProductItem));
                                        }
                                        break;
                                    case 18:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM1 == false)
                                        {
                                            this.TransferSerialCOM1(this.Transfer_18_HP200(this.SystemConfig3.IsCharToFillZeroCOM1, this.CurrentWeightData, 1));
                                            this.TransferSerialCOM1(this.Transfer_18_HP200(this.SystemConfig3.IsCharToFillZeroCOM1, this.CurrentWeightData, 2));
                                        }
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                            {
                                                this.TransferSerialCOM1(this.Transfer_18_HP200(this.SystemConfig3.IsCharToFillZeroCOM1, this.CurrentWeightData, 1));
                                                this.TransferSerialCOM1(this.Transfer_18_HP200(this.SystemConfig3.IsCharToFillZeroCOM1, this.CurrentWeightData, 2));
                                            }
                                        }
                                        break;
                                    case 19:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM1 == false)
                                            this.TransferSerialCOM1(this.Transfer_19_SmartJet(this.SystemConfig3.IsCharToFillZeroCOM1, this.CurrentWeightData));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM1(this.Transfer_19_SmartJet(this.SystemConfig3.IsCharToFillZeroCOM1, this.CurrentWeightData));
                                        }
                                        break;
                                    case 20:
                                        if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                        {
                                            this.TransferSerialCOM1(this.RoomChange9410(2)); // 2번방 변경
                                            Thread.Sleep(200);
                                            this.TransferSerialCOM1(this.SendChar(DataStore.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(DataStore.CharValue.ACK)); // ACK
                                        }
                                        break;
                                    case (int)DataStore.SerialMode.f22_Modbus_RTU: // 22, Modbus RTU(Master 사용 시 - Write multiple register)
                                        if (this.SystemConfig2.ModbusRTUSelectFunction == (int)DataStore.ModbusFunction._16_WriteMultipleRegister)
                                        {
                                            byte[] sendData = this.Modbus.MakeRTUSendAllData(this.Transfer_22_Modbus_Write(), this.SystemConfig2.ModbusSlaveIDCOM1, this.SystemConfig3.ModbusRTUStartAddressCOM1);

                                            this.TransferSerialCOM1(sendData);
                                        }
                                        break;
                                    case (int)DataStore.SerialMode.f23_STD2:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM1 == false)
                                            this.TransferSerialCOM1(this.Transfer_23_STD2
                                                (this.SystemConfig3.IsCharToFillZeroCOM1, this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM1(this.Transfer_23_STD2
                                                    (this.SystemConfig3.IsCharToFillZeroCOM1, this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem));
                                        }
                                        break;
                                    case (int)DataStore.SerialMode.f24_MULTi_JET:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM1 == false)
                                            this.TransferSerialCOM1(this.Transfer_24_MULTi_JET(this.SystemConfig3.IsCharToFillZeroCOM1, this.CurrentWeightData));
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM1(this.Transfer_24_MULTi_JET(this.SystemConfig3.IsCharToFillZeroCOM1, this.CurrentWeightData));
                                        }
                                        break;
                                    case (int)DataStore.SerialMode.f26_LINX8830:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM1 == false)
                                            this.TransferSerialCOM1(this.Transfer_26_LINX8830(this.SystemConfig3.IsCharToFillZeroCOM1, this.CurrentWeightData));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM1(this.Transfer_26_LINX8830(this.SystemConfig3.IsCharToFillZeroCOM1, this.CurrentWeightData));
                                        }
                                        break;
                                    case (int)DataStore.SerialMode.f27_MYJET:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM1 == false)
                                            this.TransferSerialCOM1(this.Transfer_27_MYJET(this.SystemConfig3.IsCharToFillZeroCOM1, this.CurrentWeightData));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM1(this.Transfer_27_MYJET(this.SystemConfig3.IsCharToFillZeroCOM1, this.CurrentWeightData));
                                        }
                                        break;
                                    case (int)DataStore.SerialMode.f28_OPT4: // Tasco(타스코) PC 전송
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM1 == false)
                                            this.TransferSerialCOM1(this.Transfer_28_OPT4(this.SystemConfig3.IsCharToFillZeroCOM1, this.CurrentWeightData));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM1(this.Transfer_28_OPT4(this.SystemConfig3.IsCharToFillZeroCOM1, this.CurrentWeightData));
                                        }
                                        break;
                                    default:
                                        break;
                                }
                                #endregion
                            }
                            // 통신 COM3
                            if (this.SystemConfig1.SerialCOM3Mode != 0)
                            {
                                #region COM3
                                switch (this.SystemConfig1.SerialCOM3Mode)
                                {
                                    case 1:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM3 == false)
                                            this.TransferSerialCOM3(this.Transfer_1_STD1
                                                (this.SystemConfig3.IsCharToFillZeroCOM3, this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM3(this.Transfer_1_STD1
                                                    (this.SystemConfig3.IsCharToFillZeroCOM3, this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem));
                                        }
                                        break;
                                    case 2:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM3 == false)
                                            this.TransferSerialCOM3(this.Transfer_2_Remote
                                                (this.SystemConfig3.IsCharToFillZeroCOM3, this.CurrentWeightData, this.CurrentProductItem));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM3(this.Transfer_2_Remote
                                                    (this.SystemConfig3.IsCharToFillZeroCOM3, this.CurrentWeightData, this.CurrentProductItem));
                                        }
                                        break;
                                    case 3:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM3 == false)
                                        {
                                            if (this.SystemConfig1.IsPrintPerProductEnable == true)
                                                this.TransferSerialCOM3(this.Transfer_3_Print
                                                    (this.SystemConfig3.IsCharToFillZeroCOM3, this.CurrentWeightData, this.CurrentProductItem));
                                        }
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                            {
                                                if (this.SystemConfig1.IsPrintPerProductEnable == true)
                                                    this.TransferSerialCOM3(this.Transfer_3_Print
                                                        (this.SystemConfig3.IsCharToFillZeroCOM3, this.CurrentWeightData, this.CurrentProductItem));
                                            }
                                        }
                                        break;
                                    case 4:
                                        if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                        {
                                            this.TransferSerialCOM3(this.RoomChange9410(2)); // 2번방 변경
                                            Thread.Sleep(200);
                                            this.TransferSerialCOM3(this.SendChar(DataStore.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(DataStore.CharValue.ACK)); // ACK
                                        }
                                        break;
                                    case 5:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM3 == false)
                                        {
                                            this.HMCOM3_Step = 1;
                                            this.TransferSerialCOM3(this.SendChar(DataStore.CharValue.ENQ));
                                        }
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                            {
                                                this.HMCOM3_Step = 1;
                                                this.TransferSerialCOM3(this.SendChar(DataStore.CharValue.ENQ));
                                            }
                                        }
                                        break;
                                    case 6:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM3 == false)
                                            this.TransferSerialCOM3(this.Transfer_6_OPT0
                                                (this.SystemConfig3.IsCharToFillZeroCOM3, this.CurrentWeightData));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM3(this.Transfer_6_OPT0
                                                    (this.SystemConfig3.IsCharToFillZeroCOM3, this.CurrentWeightData));
                                        }
                                        break;
                                    case 7:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM3 == false)
                                            this.TransferSerialCOM3(this.Transfer_7_imaje9410OPT2
                                                (this.SystemConfig3.IsCharToFillZeroCOM3, this.CurrentWeightData));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM3(this.Transfer_7_imaje9410OPT2
                                                    (this.SystemConfig3.IsCharToFillZeroCOM3, this.CurrentWeightData));
                                        }
                                        break;
                                    case 8:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM3 == false)
                                            this.TransferSerialCOM3(this.Transfer_8_imaje9028OPT2
                                                (this.SystemConfig3.IsCharToFillZeroCOM3, this.CurrentWeightData));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM3(this.Transfer_8_imaje9028OPT2
                                                    (this.SystemConfig3.IsCharToFillZeroCOM3, this.CurrentWeightData));
                                        }
                                        break;
                                    case (int)DataStore.SerialMode.f9_Hitachi:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM3 == false)
                                            this.TransferSerialCOM3(this.Transfer_9_Hitachi
                                                (this.SystemConfig3.IsCharToFillZeroCOM3, this.CurrentWeightData, DataStore.SerialCOM.COM3));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM3(this.Transfer_9_Hitachi
                                                    (this.SystemConfig3.IsCharToFillZeroCOM3, this.CurrentWeightData, DataStore.SerialCOM.COM3));
                                        }
                                        break;
                                    case 10:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM3 == false)
                                            this.TransferSerialCOM3(this.Transfer_10_MACSA
                                                (this.SystemConfig3.IsCharToFillZeroCOM3, this.CurrentWeightData, this.CurrentProductItem));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM3(this.Transfer_10_MACSA
                                                    (this.SystemConfig3.IsCharToFillZeroCOM3, this.CurrentWeightData, this.CurrentProductItem));
                                        }
                                        break;
                                    case 11:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM3 == false)
                                            this.TransferSerialCOM3(this.Transfer_11_Markoprint
                                                (this.SystemConfig3.IsCharToFillZeroCOM3, this.CurrentWeightData, this.CurrentProductItem));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM3(this.Transfer_11_Markoprint
                                                    (this.SystemConfig3.IsCharToFillZeroCOM3, this.CurrentWeightData, this.CurrentProductItem));
                                        }
                                        break;
                                    case 12:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM3 == false)
                                            this.TransferSerialCOM3(this.Transfer_12_alphaJET
                                                (this.SystemConfig3.IsCharToFillZeroCOM3, this.CurrentWeightData, this.CurrentProductItem));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM3(this.Transfer_12_alphaJET
                                                    (this.SystemConfig3.IsCharToFillZeroCOM3, this.CurrentWeightData, this.CurrentProductItem));
                                        }
                                        break;
                                    case (int)DataStore.SerialMode.f13_Marking_VJ1510:
                                    case (int)DataStore.SerialMode.f25_DJ_VIDEOJET:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM3 == false)
                                            this.TransferSerialCOM3(this.Transfer_13_Marking_VJ1510
                                                (this.SystemConfig3.IsCharToFillZeroCOM3, this.CurrentWeightData));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM3(this.Transfer_13_Marking_VJ1510
                                                    (this.SystemConfig3.IsCharToFillZeroCOM3, this.CurrentWeightData));
                                        }
                                        break;
                                    case 17:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM3 == false)
                                            this.TransferSerialCOM3(this.Transfer_17_OPT3
                                                (this.SystemConfig3.IsCharToFillZeroCOM3, this.CurrentWeightData, this.CurrentProductItem));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM3(this.Transfer_17_OPT3
                                                    (this.SystemConfig3.IsCharToFillZeroCOM3, this.CurrentWeightData, this.CurrentProductItem));
                                        }
                                        break;
                                    case 18:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM3 == false)
                                        {
                                            this.TransferSerialCOM3(this.Transfer_18_HP200
                                                (this.SystemConfig3.IsCharToFillZeroCOM3, this.CurrentWeightData, 1));
                                            this.TransferSerialCOM3(this.Transfer_18_HP200
                                                (this.SystemConfig3.IsCharToFillZeroCOM3, this.CurrentWeightData, 2));
                                        }
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                            {
                                                this.TransferSerialCOM3(this.Transfer_18_HP200
                                                    (this.SystemConfig3.IsCharToFillZeroCOM3, this.CurrentWeightData, 1));
                                                this.TransferSerialCOM3(this.Transfer_18_HP200
                                                    (this.SystemConfig3.IsCharToFillZeroCOM3, this.CurrentWeightData, 2));
                                            }
                                        }
                                        break;
                                    case 19:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM3 == false)
                                            this.TransferSerialCOM3(this.Transfer_19_SmartJet
                                                (this.SystemConfig3.IsCharToFillZeroCOM3, this.CurrentWeightData));
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM3(this.Transfer_19_SmartJet
                                                    (this.SystemConfig3.IsCharToFillZeroCOM3, this.CurrentWeightData));
                                        }
                                        break;
                                    case (int)DataStore.SerialMode.f20_imaje_9410_OPT3:
                                        if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                        {
                                            this.TransferSerialCOM3(this.RoomChange9410(2)); // 2번방 변경
                                            Thread.Sleep(200);
                                            this.TransferSerialCOM3(this.SendChar(DataStore.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(DataStore.CharValue.ACK)); // ACK
                                        }
                                        break;
                                    case (int)DataStore.SerialMode.f22_Modbus_RTU: // Modbus RTU(Master 사용 시 - Write multiple register)
                                        if (this.SystemConfig2.ModbusRTUSelectFunction == (int)DataStore.ModbusFunction._16_WriteMultipleRegister)
                                        {
                                            byte[] sendData = this.Modbus.MakeRTUSendAllData(this.Transfer_22_Modbus_Write(), this.SystemConfig2.ModbusSlaveIDCOM3, this.SystemConfig3.ModbusRTUStartAddressCOM3);

                                            this.TransferSerialCOM3(sendData);
                                        }
                                        break;
                                    case (int)DataStore.SerialMode.f23_STD2:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM3 == false)
                                            this.TransferSerialCOM3(this.Transfer_23_STD2
                                                (this.SystemConfig3.IsCharToFillZeroCOM3, this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM3(this.Transfer_23_STD2
                                                    (this.SystemConfig3.IsCharToFillZeroCOM3, this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem));
                                        }
                                        break;
                                    case (int)DataStore.SerialMode.f24_MULTi_JET:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM3 == false)
                                            this.TransferSerialCOM3(this.Transfer_24_MULTi_JET(this.SystemConfig3.IsCharToFillZeroCOM3, this.CurrentWeightData));
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM3(this.Transfer_24_MULTi_JET(this.SystemConfig3.IsCharToFillZeroCOM3, this.CurrentWeightData));
                                        }
                                        break;
                                    case (int)DataStore.SerialMode.f26_LINX8830:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM3 == false)
                                            this.TransferSerialCOM3(this.Transfer_26_LINX8830(this.SystemConfig3.IsCharToFillZeroCOM3, this.CurrentWeightData));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM3(this.Transfer_26_LINX8830(this.SystemConfig3.IsCharToFillZeroCOM3, this.CurrentWeightData));
                                        }
                                        break;
                                    case (int)DataStore.SerialMode.f27_MYJET:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM3 == false)
                                            this.TransferSerialCOM3(this.Transfer_27_MYJET(this.SystemConfig3.IsCharToFillZeroCOM3, this.CurrentWeightData));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM3(this.Transfer_27_MYJET(this.SystemConfig3.IsCharToFillZeroCOM3, this.CurrentWeightData));
                                        }
                                        break;
                                    case (int)DataStore.SerialMode.f28_OPT4: // Tasco(타스코) PC 전송
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM3 == false)
                                            this.TransferSerialCOM3(this.Transfer_28_OPT4(this.SystemConfig3.IsCharToFillZeroCOM3, this.CurrentWeightData));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM3(this.Transfer_28_OPT4(this.SystemConfig3.IsCharToFillZeroCOM3, this.CurrentWeightData));
                                        }
                                        break;
                                    default:
                                        break;
                                }
                                #endregion
                            }
                            // 통신 COM4
                            if (this.SystemConfig1.SerialCOM4Mode != 0)
                            {
                                #region COM4
                                switch (this.SystemConfig1.SerialCOM4Mode)
                                {
                                    case 1:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM4 == false)
                                            this.TransferSerialCOM4(this.Transfer_1_STD1
                                                (this.SystemConfig3.IsCharToFillZeroCOM4, this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM4(this.Transfer_1_STD1
                                                    (this.SystemConfig3.IsCharToFillZeroCOM4, this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem));
                                        }
                                        break;
                                    case 2:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM4 == false)
                                            this.TransferSerialCOM4(this.Transfer_2_Remote
                                                (this.SystemConfig3.IsCharToFillZeroCOM4, this.CurrentWeightData, this.CurrentProductItem));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM4(this.Transfer_2_Remote
                                                    (this.SystemConfig3.IsCharToFillZeroCOM4, this.CurrentWeightData, this.CurrentProductItem));
                                        }
                                        break;
                                    case 3:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM4 == false)
                                        {
                                            if (this.SystemConfig1.IsPrintPerProductEnable == true)
                                                this.TransferSerialCOM4(this.Transfer_3_Print
                                                    (this.SystemConfig3.IsCharToFillZeroCOM4, this.CurrentWeightData, this.CurrentProductItem));
                                        }
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM4(this.Transfer_3_Print
                                                    (this.SystemConfig3.IsCharToFillZeroCOM4, this.CurrentWeightData, this.CurrentProductItem));
                                        }
                                        break;
                                    case 4:
                                        if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                        {
                                            this.TransferSerialCOM4(this.RoomChange9410(2)); // 2번방 변경
                                            Thread.Sleep(200);
                                            this.TransferSerialCOM4(this.SendChar(DataStore.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(DataStore.CharValue.ACK)); // ACK
                                        }
                                        break;
                                    case 5:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM4 == false)
                                        {
                                            this.HMCOM4_Step = 1;
                                            this.TransferSerialCOM4(this.SendChar(DataStore.CharValue.ENQ));
                                        }
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                            {
                                                this.HMCOM4_Step = 1;
                                                this.TransferSerialCOM4(this.SendChar(DataStore.CharValue.ENQ));
                                            }
                                        }
                                        break;
                                    case 6:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM4 == false)
                                            this.TransferSerialCOM4(this.Transfer_6_OPT0
                                                (this.SystemConfig3.IsCharToFillZeroCOM4, this.CurrentWeightData));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM4(this.Transfer_6_OPT0
                                                    (this.SystemConfig3.IsCharToFillZeroCOM4, this.CurrentWeightData));
                                        }
                                        break;
                                    case 7:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM4 == false)
                                            this.TransferSerialCOM4(this.Transfer_7_imaje9410OPT2
                                                (this.SystemConfig3.IsCharToFillZeroCOM4, this.CurrentWeightData));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM4(this.Transfer_7_imaje9410OPT2
                                                    (this.SystemConfig3.IsCharToFillZeroCOM4, this.CurrentWeightData));
                                        }
                                        break;
                                    case 8:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM4 == false)
                                            this.TransferSerialCOM4(this.Transfer_8_imaje9028OPT2
                                                (this.SystemConfig3.IsCharToFillZeroCOM4, this.CurrentWeightData));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM4(this.Transfer_8_imaje9028OPT2
                                                    (this.SystemConfig3.IsCharToFillZeroCOM4, this.CurrentWeightData));
                                        }
                                        break;
                                    case (int)DataStore.SerialMode.f9_Hitachi:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM4 == false)
                                            this.TransferSerialCOM4(this.Transfer_9_Hitachi
                                                (this.SystemConfig3.IsCharToFillZeroCOM4, this.CurrentWeightData, DataStore.SerialCOM.COM4));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM4(this.Transfer_9_Hitachi
                                                    (this.SystemConfig3.IsCharToFillZeroCOM4, this.CurrentWeightData, DataStore.SerialCOM.COM4));
                                        }
                                        break;
                                    case 10:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM4 == false)
                                            this.TransferSerialCOM4(this.Transfer_10_MACSA
                                                (this.SystemConfig3.IsCharToFillZeroCOM4, this.CurrentWeightData, this.CurrentProductItem));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM4(this.Transfer_10_MACSA
                                                    (this.SystemConfig3.IsCharToFillZeroCOM4, this.CurrentWeightData, this.CurrentProductItem));
                                        }
                                        break;
                                    case 11:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM4 == false)
                                            this.TransferSerialCOM4(this.Transfer_11_Markoprint
                                                (this.SystemConfig3.IsCharToFillZeroCOM4, this.CurrentWeightData, this.CurrentProductItem));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM4(this.Transfer_11_Markoprint
                                                    (this.SystemConfig3.IsCharToFillZeroCOM4, this.CurrentWeightData, this.CurrentProductItem));
                                        }
                                        break;
                                    case 12:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM4 == false)
                                            this.TransferSerialCOM4(this.Transfer_12_alphaJET
                                                (this.SystemConfig3.IsCharToFillZeroCOM4, this.CurrentWeightData, this.CurrentProductItem));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM4(this.Transfer_12_alphaJET
                                                    (this.SystemConfig3.IsCharToFillZeroCOM4, this.CurrentWeightData, this.CurrentProductItem));
                                        }
                                        break;
                                    case (int)DataStore.SerialMode.f13_Marking_VJ1510:
                                    case (int)DataStore.SerialMode.f25_DJ_VIDEOJET:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM4 == false)
                                            this.TransferSerialCOM4(this.Transfer_13_Marking_VJ1510
                                                (this.SystemConfig3.IsCharToFillZeroCOM4, this.CurrentWeightData));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM4(this.Transfer_13_Marking_VJ1510
                                                    (this.SystemConfig3.IsCharToFillZeroCOM4, this.CurrentWeightData));
                                        }
                                        break;
                                    case 17:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM4 == false)
                                            this.TransferSerialCOM4(this.Transfer_17_OPT3
                                                (this.SystemConfig3.IsCharToFillZeroCOM4, this.CurrentWeightData, this.CurrentProductItem));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM4(this.Transfer_17_OPT3
                                                    (this.SystemConfig3.IsCharToFillZeroCOM4, this.CurrentWeightData, this.CurrentProductItem));
                                        }
                                        break;
                                    case 18:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM4 == false)
                                        {
                                            this.TransferSerialCOM4(this.Transfer_18_HP200
                                                (this.SystemConfig3.IsCharToFillZeroCOM4, this.CurrentWeightData, 1));
                                            this.TransferSerialCOM4(this.Transfer_18_HP200
                                                (this.SystemConfig3.IsCharToFillZeroCOM4, this.CurrentWeightData, 2));
                                        }
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                            {
                                                this.TransferSerialCOM4(this.Transfer_18_HP200
                                                    (this.SystemConfig3.IsCharToFillZeroCOM4, this.CurrentWeightData, 1));
                                                this.TransferSerialCOM4(this.Transfer_18_HP200
                                                    (this.SystemConfig3.IsCharToFillZeroCOM4, this.CurrentWeightData, 2));
                                            }
                                        }
                                        break;
                                    case 19:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM4 == false)
                                            this.TransferSerialCOM4(this.Transfer_19_SmartJet
                                                (this.SystemConfig3.IsCharToFillZeroCOM4, this.CurrentWeightData));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM4(this.Transfer_19_SmartJet
                                                    (this.SystemConfig3.IsCharToFillZeroCOM4, this.CurrentWeightData));
                                        }
                                        break;
                                    case 20:
                                        if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                        {
                                            this.TransferSerialCOM4(this.RoomChange9410(2)); // 2번방 변경
                                            Thread.Sleep(200);
                                            this.TransferSerialCOM4(this.SendChar(DataStore.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(DataStore.CharValue.ACK)); // ACK
                                        }
                                        break;
                                    case (int)DataStore.SerialMode.f22_Modbus_RTU: // Modbus RTU(Master 사용 시 - Write multiple register)
                                        if (this.SystemConfig2.ModbusRTUSelectFunction == (int)DataStore.ModbusFunction._16_WriteMultipleRegister)
                                        {
                                            byte[] sendData = this.Modbus.MakeRTUSendAllData(this.Transfer_22_Modbus_Write(), this.SystemConfig2.ModbusSlaveIDCOM4, this.SystemConfig3.ModbusRTUStartAddressCOM4);

                                            this.TransferSerialCOM4(sendData);
                                        }
                                        break;
                                    case (int)DataStore.SerialMode.f23_STD2:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM4 == false)
                                            this.TransferSerialCOM4(this.Transfer_23_STD2
                                                (this.SystemConfig3.IsCharToFillZeroCOM4, this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM4(this.Transfer_23_STD2
                                                    (this.SystemConfig3.IsCharToFillZeroCOM4, this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem));
                                        }
                                        break;
                                    case (int)DataStore.SerialMode.f24_MULTi_JET:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM4 == false)
                                            this.TransferSerialCOM4(this.Transfer_24_MULTi_JET
                                                (this.SystemConfig3.IsCharToFillZeroCOM4, this.CurrentWeightData));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM4(this.Transfer_24_MULTi_JET
                                                    (this.SystemConfig3.IsCharToFillZeroCOM4, this.CurrentWeightData));
                                        }
                                        break;
                                    case (int)DataStore.SerialMode.f26_LINX8830:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM4 == false)
                                            this.TransferSerialCOM4(this.Transfer_26_LINX8830(this.SystemConfig3.IsCharToFillZeroCOM4, this.CurrentWeightData));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM4(this.Transfer_26_LINX8830(this.SystemConfig3.IsCharToFillZeroCOM4, this.CurrentWeightData));
                                        }
                                        break;
                                    case (int)DataStore.SerialMode.f27_MYJET:
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM4 == false)
                                            this.TransferSerialCOM4(this.Transfer_27_MYJET(this.SystemConfig3.IsCharToFillZeroCOM4, this.CurrentWeightData));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM4(this.Transfer_27_MYJET(this.SystemConfig3.IsCharToFillZeroCOM4, this.CurrentWeightData));
                                        }
                                        break;
                                    case (int)DataStore.SerialMode.f28_OPT4: // Tasco(타스코) PC 전송
                                        if (this.SystemConfig3.IsTransmitWhenPassCOM4 == false)
                                            this.TransferSerialCOM4(this.Transfer_28_OPT4(this.SystemConfig3.IsCharToFillZeroCOM4, this.CurrentWeightData));
                                        else
                                        {
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.TransferSerialCOM4(this.Transfer_28_OPT4(this.SystemConfig3.IsCharToFillZeroCOM4, this.CurrentWeightData));
                                        }
                                        break;
                                    default:
                                        break;
                                }
                                #endregion
                            }

                            // 이더넷
                            switch (this.SystemConfig2.EthernetOperationMode)
                            {
                                case 1: // Server
                                    if (this.smartTCPMultiServer.ClientInfoList != null)
                                    {
                                        #region Server
                                        foreach (SmartTCPMultiServer.CLIENTSINFOS client in this.smartTCPMultiServer.ClientInfoList)
                                        {
                                            switch (this.SystemConfig2.EthernetCommMode)
                                            {
                                                case 1:
                                                    this.EthernetServerSendMessage(client,
                                                        this.Transfer_1_STD1
                                                        (this.SystemConfig3.IsCharToFillZeroEthernet, this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem));
                                                    break;
                                                case 2:
                                                    this.EthernetServerSendMessage(client, this.Transfer_2_Remote
                                                        (this.SystemConfig3.IsCharToFillZeroEthernet, this.CurrentWeightData, this.CurrentProductItem));
                                                    break;
                                                case 3:
                                                    if (this.SystemConfig1.IsPrintPerProductEnable == true)
                                                        this.EthernetServerSendMessage(client, this.Transfer_3_Print
                                                            (this.SystemConfig3.IsCharToFillZeroEthernet, this.CurrentWeightData, this.CurrentProductItem));
                                                    break;
                                                case 4:
                                                    if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                    {
                                                        this.EthernetServerSendMessage(client, this.RoomChange9410(2)); // 2번방 변경
                                                        Thread.Sleep(200);
                                                        this.EthernetServerSendMessage(client, this.SendChar(DataStore.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(DataStore.CharValue.ACK)); // ACK
                                                    }
                                                    break;
                                                case 5:
                                                    this.HMCOM1_Step = 1;
                                                    this.EthernetServerSendMessage(client, this.SendChar(DataStore.CharValue.ENQ));
                                                    break;
                                                case 6:
                                                    this.EthernetServerSendMessage(client, this.Transfer_6_OPT0
                                                        (this.SystemConfig3.IsCharToFillZeroEthernet, this.CurrentWeightData));
                                                    break;
                                                case 7:
                                                    this.EthernetServerSendMessage(client, this.Transfer_7_imaje9410OPT2
                                                        (this.SystemConfig3.IsCharToFillZeroEthernet, this.CurrentWeightData));
                                                    break;
                                                case 8:
                                                    this.EthernetServerSendMessage(client, this.Transfer_8_imaje9028OPT2
                                                        (this.SystemConfig3.IsCharToFillZeroEthernet, this.CurrentWeightData));
                                                    break;
                                                case 9:
                                                    this.EthernetServerSendMessage(client, this.Transfer_9_Hitachi
                                                        (this.SystemConfig3.IsCharToFillZeroEthernet, this.CurrentWeightData, DataStore.SerialCOM.COM1));
                                                    break;
                                                case 10:
                                                    this.EthernetServerSendMessage(client, this.Transfer_10_MACSA
                                                        (this.SystemConfig3.IsCharToFillZeroEthernet, this.CurrentWeightData, this.CurrentProductItem));
                                                    break;
                                                case 11:
                                                    this.EthernetServerSendMessage(client, this.Transfer_11_Markoprint
                                                        (this.SystemConfig3.IsCharToFillZeroEthernet, this.CurrentWeightData, this.CurrentProductItem));
                                                    break;
                                                case 12:
                                                    this.EthernetServerSendMessage(client, this.Transfer_12_alphaJET
                                                        (this.SystemConfig3.IsCharToFillZeroEthernet, this.CurrentWeightData, this.CurrentProductItem));
                                                    break;
                                                case (int)DataStore.EthernetMode.f13_Marking_VJ1510:
                                                case (int)DataStore.EthernetMode.f25_DJ_VIDEOJET:
                                                    this.EthernetServerSendMessage(client, this.Transfer_13_Marking_VJ1510
                                                        (this.SystemConfig3.IsCharToFillZeroEthernet, this.CurrentWeightData));
                                                    break;
                                                case 17:
                                                    this.EthernetServerSendMessage(client, this.Transfer_17_OPT3
                                                        (this.SystemConfig3.IsCharToFillZeroEthernet, this.CurrentWeightData, this.CurrentProductItem));
                                                    break;
                                                case 18:
                                                    this.EthernetServerSendMessage(client, this.Transfer_18_HP200(this.SystemConfig3.IsCharToFillZeroEthernet, this.CurrentWeightData, 1));
                                                    this.EthernetServerSendMessage(client, this.Transfer_18_HP200(this.SystemConfig3.IsCharToFillZeroEthernet, this.CurrentWeightData, 2));
                                                    break;
                                                case 19:
                                                    if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                        this.EthernetServerSendMessage(client, this.Transfer_19_SmartJet(this.SystemConfig3.IsCharToFillZeroEthernet, this.CurrentWeightData));
                                                    break;
                                                case 20:
                                                    if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                    {
                                                        this.EthernetServerSendMessage(client, this.RoomChange9410(2)); // 2번방 변경
                                                        Thread.Sleep(200);
                                                        this.EthernetServerSendMessage(client, this.SendChar(DataStore.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(DataStore.CharValue.ACK)); // ACK
                                                    }
                                                    break;
                                                case (int)DataStore.EthernetMode.f21_Impinj_Speedway_R420: // ImpinjSpeedwayR420
                                                    this.EthernetServerSendMessage(client, this.Transfer_21_ImpinjSpeedwayR420ToPC
                                                        (this.SystemConfig3.IsCharToFillZeroEthernet, this.CurrentWeightData));
                                                    break;
                                                case (int)DataStore.EthernetMode.f22_Modbus_TCP: // 22, Modbus TCP
                                                    if (this.SystemConfig2.ModbusTCPSelectFunction == (int)DataStore.ModbusFunction._16_WriteMultipleRegister)
                                                    {
                                                        byte[] sendData = this.Modbus.MakeTCPSendAllData(this.Transfer_22_Modbus_Write(), this.SystemConfig3.ModbusTCPStartAddress);

                                                        this.EthernetServerSendMessage(client, sendData);
                                                    }
                                                    break;
                                                case (int)DataStore.EthernetMode.f23_STD2:
                                                    this.EthernetServerSendMessage(client,
                                                        this.Transfer_23_STD2(this.SystemConfig3.IsCharToFillZeroEthernet, this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem));
                                                    break;
                                                case (int)DataStore.EthernetMode.f24_MULTi_JET:
                                                    if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                        this.EthernetServerSendMessage(client, this.Transfer_24_MULTi_JET(this.SystemConfig3.IsCharToFillZeroEthernet, this.CurrentWeightData));
                                                    break;
                                                case (int)DataStore.EthernetMode.f26_LINX8830:
                                                    //if (this.SystemConfig3.IsTransmitWhenPassEthernet == false)
                                                    //    this.EthernetServerSendMessage(client, this.Transfer_26_LINX8830(this.SystemConfig3.IsCharToFillZeroEthernet, this.CurrentWeightData));
                                                    //else
                                                    //{
                                                    if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                        this.EthernetServerSendMessage(client, this.Transfer_26_LINX8830(this.SystemConfig3.IsCharToFillZeroEthernet, this.CurrentWeightData));
                                                    //}
                                                    break;
                                                case (int)DataStore.EthernetMode.f27_MYJET:
                                                    //if (this.SystemConfig3.IsTransmitWhenPassEthernet == false)
                                                    //    this.EthernetServerSendMessage(client, this.Transfer_27_MYJET(this.SystemConfig3.IsCharToFillZeroEthernet, this.CurrentWeightData));
                                                    //else
                                                    //{
                                                    if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                        this.EthernetServerSendMessage(client, this.Transfer_27_MYJET(this.SystemConfig3.IsCharToFillZeroEthernet, this.CurrentWeightData));
                                                    //}
                                                    break;
                                                case (int)DataStore.SerialMode.f28_OPT4: // Tasco(타스코) PC 전송
                                                    this.EthernetServerSendMessage(client, this.Transfer_28_OPT4(this.SystemConfig3.IsCharToFillZeroEthernet, this.CurrentWeightData));
                                                    break;
                                                default:
                                                    break;
                                            }
                                        }
                                        #endregion
                                    }
                                    break;
                                case 2: // Client
                                    switch (this.SystemConfig2.EthernetCommMode)
                                    {
                                        #region Client
                                        case 1:
                                            this.EthernetWeightData(this.Transfer_1_STD1
                                                (this.SystemConfig3.IsCharToFillZeroEthernet, this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem));
                                            break;
                                        case 2:
                                            this.EthernetWeightData(this.Transfer_2_Remote
                                                (this.SystemConfig3.IsCharToFillZeroEthernet, this.CurrentWeightData, this.CurrentProductItem));
                                            break;
                                        case 3:
                                            if (this.SystemConfig1.IsPrintPerProductEnable == true)
                                                this.EthernetWeightData(this.Transfer_3_Print
                                                    (this.SystemConfig3.IsCharToFillZeroEthernet, this.CurrentWeightData, this.CurrentProductItem));
                                            break;
                                        case 4:
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                            {
                                                this.EthernetWeightData(this.RoomChange9410(2)); // 2번방 변경
                                                Thread.Sleep(200);
                                                this.EthernetWeightData(this.SendChar(DataStore.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(DataStore.CharValue.ACK)); // ACK
                                            }
                                            break;
                                        case 5:
                                            this.HMCOM1_Step = 1;
                                            this.EthernetWeightData(this.SendChar(DataStore.CharValue.ENQ));
                                            break;
                                        case 6:
                                            this.EthernetWeightData(this.Transfer_6_OPT0
                                                (this.SystemConfig3.IsCharToFillZeroEthernet, this.CurrentWeightData));
                                            break;
                                        case 7:
                                            this.EthernetWeightData(this.Transfer_7_imaje9410OPT2
                                                (this.SystemConfig3.IsCharToFillZeroEthernet, this.CurrentWeightData));
                                            break;
                                        case 8:
                                            this.EthernetWeightData(this.Transfer_8_imaje9028OPT2
                                                (this.SystemConfig3.IsCharToFillZeroEthernet, this.CurrentWeightData));
                                            break;
                                        case 9:
                                            this.EthernetWeightData(this.Transfer_9_Hitachi
                                                (this.SystemConfig3.IsCharToFillZeroEthernet, this.CurrentWeightData, DataStore.SerialCOM.COM1));
                                            break;
                                        case 10:
                                            this.EthernetWeightData(this.Transfer_10_MACSA
                                                (this.SystemConfig3.IsCharToFillZeroEthernet, this.CurrentWeightData, this.CurrentProductItem));
                                            break;
                                        case 11:
                                            this.EthernetWeightData(this.Transfer_11_Markoprint
                                                (this.SystemConfig3.IsCharToFillZeroEthernet, this.CurrentWeightData, this.CurrentProductItem));
                                            break;
                                        case 12:
                                            this.EthernetWeightData(this.Transfer_12_alphaJET
                                                (this.SystemConfig3.IsCharToFillZeroEthernet, this.CurrentWeightData, this.CurrentProductItem));
                                            break;
                                        case (int)DataStore.EthernetMode.f13_Marking_VJ1510:
                                        case (int)DataStore.EthernetMode.f25_DJ_VIDEOJET:
                                            this.EthernetWeightData(this.Transfer_13_Marking_VJ1510
                                                (this.SystemConfig3.IsCharToFillZeroEthernet, this.CurrentWeightData));
                                            break;
                                        case 17:
                                            this.EthernetWeightData(this.Transfer_17_OPT3
                                                (this.SystemConfig3.IsCharToFillZeroEthernet, this.CurrentWeightData, this.CurrentProductItem));
                                            break;
                                        case 18:
                                            this.EthernetWeightData(this.Transfer_18_HP200
                                                (this.SystemConfig3.IsCharToFillZeroEthernet, this.CurrentWeightData, 1));
                                            this.EthernetWeightData(this.Transfer_18_HP200
                                                (this.SystemConfig3.IsCharToFillZeroEthernet, this.CurrentWeightData, 2));
                                            break;
                                        case 19:
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.EthernetWeightData(this.Transfer_19_SmartJet
                                                    (this.SystemConfig3.IsCharToFillZeroEthernet, this.CurrentWeightData));
                                            break;
                                        case 20:
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                            {
                                                this.EthernetWeightData(this.RoomChange9410(2)); // 2번방 변경
                                                Thread.Sleep(200);
                                                this.EthernetWeightData(this.SendChar(DataStore.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(DataStore.CharValue.ACK)); // ACK
                                            }
                                            break;
                                        case (int)DataStore.EthernetMode.f21_Impinj_Speedway_R420: // 21, ImpinjSpeedwayR420
                                            if (this.CurrentRFID.Count() > 0)
                                                this.CurrentRFID.RemoveIndex(0);
                                            break;
                                        case (int)DataStore.EthernetMode.f22_Modbus_TCP: // 22, Modbus TCP
                                            if (this.SystemConfig2.ModbusTCPSelectFunction == (int)DataStore.ModbusFunction._16_WriteMultipleRegister)
                                            {
                                                byte[] sendData = this.Modbus.MakeTCPSendAllData(this.Transfer_22_Modbus_Write(), this.SystemConfig3.ModbusTCPStartAddress);

                                                this.EthernetWeightDataForModbus(sendData);
                                            }
                                            break;
                                        case (int)DataStore.EthernetMode.f23_STD2:
                                            this.EthernetWeightData(this.Transfer_23_STD2
                                                (this.SystemConfig3.IsCharToFillZeroEthernet, this.SystemConfig1, this.CurrentWeightData, this.CurrentProductItem));
                                            break;
                                        case (int)DataStore.EthernetMode.f24_MULTi_JET:
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.EthernetWeightData(this.Transfer_24_MULTi_JET
                                                    (this.SystemConfig3.IsCharToFillZeroEthernet, this.CurrentWeightData));
                                            break;
                                        case (int)DataStore.EthernetMode.f26_LINX8830:
                                            //if (this.SystemConfig3.IsTransmitWhenPassEthernet == false)
                                            //    this.EthernetWeightData(this.Transfer_26_LINX8830(this.SystemConfig3.IsCharToFillZeroEthernet, this.CurrentWeightData));
                                            //else
                                            //{
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.EthernetWeightData(this.Transfer_26_LINX8830(this.SystemConfig3.IsCharToFillZeroEthernet, this.CurrentWeightData));
                                            //}
                                            break;
                                        case (int)DataStore.EthernetMode.f27_MYJET:
                                            //if (this.SystemConfig3.IsTransmitWhenPassEthernet == false)
                                            //    this.EthernetWeightData(this.Transfer_27_MYJET(this.SystemConfig3.IsCharToFillZeroEthernet, this.CurrentWeightData));
                                            //else
                                            //{
                                            if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                                this.EthernetWeightData(this.Transfer_27_MYJET(this.SystemConfig3.IsCharToFillZeroEthernet, this.CurrentWeightData));
                                            //}
                                            break;
                                        case (int)DataStore.SerialMode.f28_OPT4: // Tasco(타스코) PC 전송
                                            this.EthernetWeightData(this.Transfer_28_OPT4(this.SystemConfig3.IsCharToFillZeroEthernet, this.CurrentWeightData));
                                            break;
                                        default:
                                            break;
                                        #endregion
                                    }
                                    break;
                                default:
                                    break;
                            }
                            #endregion

                            #region 카운터출력
                            #region Counting Output 1
                            if (this.SystemConfig2.IsCountingOutput1Activated() == true)
                            {
                                if (this.SystemConfig3.IsCountingOutputCrossMode == true)
                                {
                                    if (this.SystemConfig2.IsCountingOutput2Activated() == true)
                                    {
                                        if (this.IsCountingOutputCrossStatus == false)
                                        {
                                            this.IsSatisfyCounting = false;
                                            this.UpdateCountingOutput1();
                                        }
                                    }
                                    else
                                        this.UpdateCountingOutput1();
                                }
                                else
                                {
                                    this.UpdateCountingOutput1();
                                }
                            }
                            #endregion

                            #region Counting Output 2
                            if (this.SystemConfig2.IsCountingOutput2Activated() == true)
                            {
                                if (this.SystemConfig3.IsCountingOutputCrossMode == true)
                                {
                                    if (this.SystemConfig2.IsCountingOutput1Activated() == true)
                                    {
                                        if (this.IsCountingOutputCrossStatus == true && this.IsSatisfyCounting == false)
                                            this.UpdateCountingOutput2();
                                        else
                                            this.IsSatisfyCounting = false;
                                    }
                                    else
                                        this.UpdateCountingOutput2();
                                }
                                else
                                {
                                    this.UpdateCountingOutput2();
                                }
                            }
                            #endregion

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

                            // CurrentDisplay
                            switch (this.CurrentSystemStatus.CurrentDisplay)
                            {
                                case DataStore.DisplayStore.MainDisplay:
                                    #region MainDisplay
                                    if (this.SystemConfig2.Barcode != 0)
                                    {
                                        this.CurrentBarcode.BarcodeDequeue();

                                        // 바코드 로그
                                        if (this.IsBarcodeLogOpen == true)
                                            this.smartFileBarcodeLog.WriteString(string.Format("Barcode Count ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, this.CurrentBarcode.GetQueueCount));

                                        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.SystemConfig1.IsAverageTracking == true)
                                    {
                                        if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                                        {
                                            this.ChildFormMainDisplay.MainAverageTracking.UpdateDisplayAverageTracking(this.CurrentWeightData);
                                            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.IsDataBackup == true)
                                    {
                                        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 != DataStore.JudgmentResult.None)
                                            //        this.CollectionBufferWeightData[0].Status = this.CurrentJudgmentResult.PreviousRejectData.ToString();
                                            //    else
                                            //        this.CollectionBufferWeightData[0].Status = DataStore.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 != DataStore.JudgmentStatus.Empty)
                                                this.DataBackup0(this.CurrentWeightData);
                                            #endregion
                                        }
                                    }

                                    if (this.SystemConfig2.IsRFIDSpeedwayR420 == true)
                                    {
                                        if (this.CurrentRFID.Count() > 0)
                                        {
                                            this.CurrentRFID.RemoveIndex(0);

                                            // 로그
                                            if (this.IsCommunicationLogOpen == true)
                                                this.smartFileCommunicationLog.WriteString(string.Format("RemoveTag ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, this.CurrentRFID.Count()));
                                            for (int i = 0; i < this.CurrentRFID.Count(); i++)
                                                this.smartFileCommunicationLog.WriteString(string.Format("ListTag ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, this.CurrentRFID.ReturnTag(i)));
                                        }

                                        if (this.ChildFormMainDisplay != null)
                                            this.ChildFormMainDisplay.UpdateRFIDDisplay(this.CurrentRFID);
                                    }

                                    // 표준분포
                                    this.CurrentWeightData.SetNormalDistribution(this.CurrentProductItem.CollectionNormalDistributionRange, this.CurrentWeightData.WeightString);
                                    #endregion
                                    break;
                                default:
                                    break;
                            }
                        }
                        else
                        {
                        }
                        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 == DataStore.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.CurrentSystemParameter1.EquipmentType == "4")
                    {
                        if (this.ChildFormMenu.CenterSystemJudgmentUpdown != null)
                            this.ChildFormMenu.CenterSystemJudgmentUpdown.UpdateStopWeightDisplay(this.CurrentSystemStatus.Equipment, this.CurrentWeightData);
                    }
                    else
                    {
                        if (this.ChildFormMenu.CenterSystemJudgmentManual != null)
                            this.ChildFormMenu.CenterSystemJudgmentManual.UpdateStopWeightDisplay(this.CurrentSystemStatus.Equipment, this.CurrentWeightData);
                    }
                    break;
                default:
                    break;
            }

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

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

                    for (int i = 0; i < this.CollectionGraphData.Count; i++)
                    {
                        this.CollectionGraphData[i] = int.Parse(receiveData.Substring(temp, 5));
                        temp += 5;
                    }
                    #endregion
                    if (this.CurrentSystemParameter1.EquipmentType == "4")
                    {
                        if (this.ChildFormMenu.CenterSystemJudgmentUpdown != null)
                            this.ChildFormMenu.CenterSystemJudgmentUpdown.UpdateGraphDataDisplay(this.CurrentSystemStatus.Equipment, this.CurrentWeightData, this.CollectionGraphData);
                    }
                    else
                    {
                        if (this.ChildFormMenu.CenterSystemJudgmentManual != null)
                            this.ChildFormMenu.CenterSystemJudgmentManual.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.DataBackup1(this.CollectionBufferWeightData[0]);
                    }
                    else if (this.CollectionBufferWeightData.Count > 2)
                    {
                        for (int i = 0; i < this.CollectionBufferWeightData.Count - 2; i++)
                        {
                            this.CollectionBufferWeightData[i].Status = DataStore.JudgmentResult.Timeout.ToString();
                            this.DataBackup1(this.CollectionBufferWeightData[i]);
                        }

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

                    this.CollectionBufferWeightData[this.CollectionBufferWeightData.Count - 1].Status = this.CurrentJudgmentResult.CurrentRejectData.ToString();
                    this.DataBackup1(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.CurrentSystemStatus.CurrentDisplay == DataStore.DisplayStore.MainDisplay)
                    {
                        if (this.PreviousAlarm != currentAlarm)
                        {
                            this.IsAlarmOccured = this.CurrentAlarmList.IsAlarmOccured(currentAlarm);
                            this.Update30000ModbusItem();
                            this.CurrentAlarmList.SetAlarm(currentAlarm);
                            this.ChildFormMainDisplay.UpdateDisplayAlarmView(this.CurrentAlarmList, currentAlarm);

                            try
                            {
                                if (this.SystemConfig2.IsRFIDSpeedwayR420 == true)
                                {
                                    for (int i = 0; i < 8; i++)
                                    {
                                        if (this.PreviousAlarm[i] != currentAlarm[i])
                                            this.SendMainAlarmForRFID(i, this.PreviousAlarm[i], currentAlarm[i]);
                                    }
                                }
                            }
                            catch
                            {

                            }

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

        // IO테스트-그래프
        private int ReceiveCommandTG0(string lane, string receiveData)
        {
            int ret = 0, temp = 0, flag = 0;

            switch (lane)
            {
                case "A":
                    #region Value Assign
                    for (int i = 0; i < this.CollectionIOTestGraphData.Count; i++)
                    {
                        this.CollectionIOTestGraphData[i] = Convert.ToString(Convert.ToInt32(receiveData.Substring(temp, 2), 16), 2).PadLeft(8, '0');
                        temp += 2;

                        // 그래프 갱신 여부를 위한 flag
                        //if (this.CollectionIOTestGraphData[i] != "11111111")
                        //    flag = 1;
                    }
                    if (this.CurrentSystemStatus.CurrentMode == DataStore.DisplayMode.IOTest) // && flag == 1)
                    {
                        if (this.ChildFormMenu.CenterSystemIOTest != null)
                            this.ChildFormMenu.CenterSystemIOTest.UpdateGraphDataDisplay(this.CollectionIOTestGraphData);
                    }
                    #endregion
                    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(bool isFillZero, SystemConfigurationItem1 system, WeightData weight, ProductItem product)
        {
            StringBuilder sb = new StringBuilder();

            if (weight.JudgmentStatus == DataStore.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 DataStore.JudgmentStatus.Empty:
                    break;
                case DataStore.JudgmentStatus.Under:
                    sb.Append("U");
                    break;
                case DataStore.JudgmentStatus.Pass:
                    sb.Append("P");
                    break;
                case DataStore.JudgmentStatus.Over:
                    sb.Append("O");
                    break;
                case DataStore.JudgmentStatus.Double:
                    sb.Append("D");
                    break;
                case DataStore.JudgmentStatus.Metal:
                    sb.Append("M");
                    break;
                case DataStore.JudgmentStatus.ExNg:
                    sb.Append("E");
                    break;
                case DataStore.JudgmentStatus.LengthError:
                    sb.Append("L");
                    break;
                default:
                    sb.Append("E");
                    break;
            }

            double weightWithoutSign = weight.Weight;
            if (weight.Weight <= 0.0)
            {
                sb.Append("-");
                weightWithoutSign = weightWithoutSign * -1.0;
            }
            else
            {
                sb.Append(" ");
            }

            if (isFillZero == true)
                sb.Append(Helper.StringZeroFillDigits6(Helper.DoubleToString(weightWithoutSign, this.SystemConfig1.DecimalPlaces)));
            else
                sb.Append(this.PadLeft(6, Helper.DoubleToString(weightWithoutSign, this.SystemConfig1.DecimalPlaces)));
            sb.Append((char)0x03);

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

            if (weight.JudgmentStatus == DataStore.JudgmentStatus.Empty)
                return "";

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

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

            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((char)0x03);

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

            if (weight.JudgmentStatus == DataStore.JudgmentStatus.Empty)
                return "";

            sb.Append(Helper.StringZeroFillDigits4(product.Number.ToString()));
            if (this.SystemConfig2.Barcode != 0)
            {
                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));

            if (isFillZero == true)
                sb.Append(Helper.StringZeroFillDigits9(Helper.DoubleToString(weight.Weight, this.SystemConfig1.DecimalPlaces)));
            else
                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(bool isFillZero, 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;");
            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((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(bool isFillZero, 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 == DataStore.JudgmentStatus.Pass)
            {
                tempStringLength = weight.Weight.ToString().Trim().Length;
                if (tempStringLength > 5)
                {
                    tempString = weight.Weight.ToString().Trim().Substring(tempStringLength - 5, 5).Replace(".", "");

                    if (isFillZero == true)
                        tempString = Helper.StringZeroFillDigits5(Helper.StringToDecimalPlaces(tempString, this.SystemConfig1.DecimalPlaces));
                    else
                        tempString = this.PadLeft(5, Helper.StringToDecimalPlaces(tempString, this.SystemConfig1.DecimalPlaces));
                }
                else
                {
                    if (isFillZero == true)
                        tempString = Helper.StringZeroFillDigits5(Helper.DoubleToString(weight.Weight, this.SystemConfig1.DecimalPlaces));
                    else
                        tempString = this.PadLeft(5, Helper.DoubleToString(weight.Weight, this.SystemConfig1.DecimalPlaces));
                }

                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(bool isFillZero, WeightData weight)
        {
            int tempStringLength = 0;
            string tempString = "";

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

            this.TransferSerialCOM1(this.SendChar(DataStore.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 == DataStore.JudgmentStatus.Pass)
            {
                tempStringLength = weight.Weight.ToString().Trim().Length;
                if (tempStringLength > 5)
                {
                    tempString = weight.Weight.ToString().Trim().Substring(tempStringLength - 5, 5).Replace(".", "");
                    if (isFillZero == true)
                        tempString = Helper.StringZeroFillDigits5(Helper.StringToDecimalPlaces(tempString, this.SystemConfig1.DecimalPlaces));
                    else
                        tempString = this.PadLeft(5, Helper.StringToDecimalPlaces(tempString, this.SystemConfig1.DecimalPlaces));
                }
                else
                {
                    if (isFillZero == true)
                        tempString = Helper.StringZeroFillDigits5(Helper.DoubleToString(weight.Weight, this.SystemConfig1.DecimalPlaces));
                    else
                        tempString = this.PadLeft(5, Helper.DoubleToString(weight.Weight, this.SystemConfig1.DecimalPlaces));
                }

                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(bool isFillZero, WeightData weight, DataStore.SerialCOM com)
        {
            if (weight.JudgmentStatus == DataStore.JudgmentStatus.Pass)
            {
                StringBuilder sb = new StringBuilder();

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

                if (com == DataStore.SerialCOM.COM1)
                {
                    sb.Append(this.HitachiRoomNumberToChar(this.SystemConfig2.HitachiRoomNumberCOM1));
                    if (this.SystemConfig2.IsHitachiBlankToNoneCOM1 == true)
                        sb.Append(Helper.DoubleToString(weight.Weight, this.SystemConfig1.DecimalPlaces));
                    else
                        sb.Append(this.PadLeft(6, Helper.DoubleToString(weight.Weight, this.SystemConfig1.DecimalPlaces)));
                }
                else if (com == DataStore.SerialCOM.COM3)
                {
                    sb.Append(this.HitachiRoomNumberToChar(this.SystemConfig2.HitachiRoomNumberCOM3));
                    if (this.SystemConfig2.IsHitachiBlankToNoneCOM3 == true)
                        sb.Append(Helper.DoubleToString(weight.Weight, this.SystemConfig1.DecimalPlaces));
                    else
                        sb.Append(this.PadLeft(6, Helper.DoubleToString(weight.Weight, this.SystemConfig1.DecimalPlaces)));
                }
                else if (com == DataStore.SerialCOM.COM4)
                {
                    sb.Append(this.HitachiRoomNumberToChar(this.SystemConfig2.HitachiRoomNumberCOM4));
                    if (this.SystemConfig2.IsHitachiBlankToNoneCOM4 == true)
                        sb.Append(Helper.DoubleToString(weight.Weight, this.SystemConfig1.DecimalPlaces));
                    else
                        sb.Append(this.PadLeft(6, Helper.DoubleToString(weight.Weight, this.SystemConfig1.DecimalPlaces)));
                }

                sb.Append((char)0x03);

                return sb.ToString();
            }
            else
                return "";
        }
        private byte[] Transfer_10_MACSA(bool isFillZero, 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)
            {
                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 (product.TareRangeInt > 0)
            {
                if (isFillZero == true)
                    bytes = new UTF8Encoding().GetBytes(Helper.StringZeroFillDigits6(Helper.StringToDecimalPlaces(product.TareRange, this.SystemConfig1.DecimalPlaces)));
                else
                    bytes = new UTF8Encoding().GetBytes(this.PadLeft(6, Helper.StringToDecimalPlaces(product.TareRange, 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];
            }

            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(bool isFillZero, 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 (weight.Weight >= 0.0)
                {
                    if (isFillZero == true)
                        weightBytes = new UTF8Encoding().GetBytes(Helper.StringZeroFillDigits6
                            (Helper.DoubleToString(weight.Weight, this.SystemConfig1.DecimalPlaces)) + this.SystemConfig1.Unit);
                    else
                        weightBytes = new UTF8Encoding().GetBytes(this.PadLeft
                            (6, Helper.DoubleToString(weight.Weight, this.SystemConfig1.DecimalPlaces)) + this.SystemConfig1.Unit);
                }
                else if (product.TareRangeInt > 0)
                {
                    if (isFillZero == true)
                        weightBytes = new UTF8Encoding().GetBytes(Helper.StringZeroFillDigits6
                            (Helper.StringToDecimalPlaces(product.TareRange, this.SystemConfig1.DecimalPlaces)) + this.SystemConfig1.Unit);
                    else
                        weightBytes = new UTF8Encoding().GetBytes(this.PadLeft
                            (6, Helper.StringToDecimalPlaces(product.TareRange, this.SystemConfig1.DecimalPlaces)) + this.SystemConfig1.Unit);
                }
                else
                {
                    if (isFillZero == true)
                        weightBytes = new UTF8Encoding().GetBytes(Helper.StringZeroFillDigits6
                            (Helper.DoubleToString(0.0, this.SystemConfig1.DecimalPlaces)) + this.SystemConfig1.Unit);
                    else
                        weightBytes = new UTF8Encoding().GetBytes(this.PadLeft
                            (6, Helper.DoubleToString(0.0, this.SystemConfig1.DecimalPlaces)) + this.SystemConfig1.Unit);
                }

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

                if (this.SystemConfig2.IsMarkoprintDatePrintEthernet == true)
                {
                    #region 날짜표시 On
                    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
                    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 (weight.Weight >= 0.0)
                {
                    if (isFillZero == true)
                        weightBytes = new UTF8Encoding().GetBytes(Helper.StringZeroFillDigits6
                            (Helper.DoubleToString(weight.Weight, this.SystemConfig1.DecimalPlaces)) + this.SystemConfig1.Unit);
                    else
                        weightBytes = new UTF8Encoding().GetBytes(this.PadLeft
                            (6, Helper.DoubleToString(weight.Weight, this.SystemConfig1.DecimalPlaces)) + this.SystemConfig1.Unit);
                }
                else if (product.TareRangeInt > 0)
                {
                    if (isFillZero == true)
                        weightBytes = new UTF8Encoding().GetBytes(Helper.StringZeroFillDigits6
                            (Helper.StringToDecimalPlaces(product.TareRange, this.SystemConfig1.DecimalPlaces)) + this.SystemConfig1.Unit);
                    else
                        weightBytes = new UTF8Encoding().GetBytes(this.PadLeft
                            (6, Helper.StringToDecimalPlaces(product.TareRange, this.SystemConfig1.DecimalPlaces)) + this.SystemConfig1.Unit);
                }
                else
                {
                    if (isFillZero == true)
                        weightBytes = new UTF8Encoding().GetBytes(Helper.StringZeroFillDigits6
                            (Helper.DoubleToString(0.0, this.SystemConfig1.DecimalPlaces)) + this.SystemConfig1.Unit);
                    else
                        weightBytes = new UTF8Encoding().GetBytes(this.PadLeft
                            (6, Helper.DoubleToString(0.0, this.SystemConfig1.DecimalPlaces)) + this.SystemConfig1.Unit);
                }

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

                    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
                    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(bool isFillZero, 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 == DataStore.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)
                {
                    if (isFillZero == true)
                        weightBytes = new UTF8Encoding().GetBytes(Helper.StringZeroFillDigits6
                            (Helper.DoubleToString(weight.Weight, this.SystemConfig1.DecimalPlaces)) + this.SystemConfig1.Unit);
                    else
                        weightBytes = new UTF8Encoding().GetBytes(this.PadLeft
                            (6, Helper.DoubleToString(weight.Weight, this.SystemConfig1.DecimalPlaces)) + this.SystemConfig1.Unit);
                }
                else if (product.TareRangeInt > 0)
                {
                    if (isFillZero == true)
                        weightBytes = new UTF8Encoding().GetBytes(Helper.StringZeroFillDigits6
                            (Helper.StringToDecimalPlaces(product.TareRange, this.SystemConfig1.DecimalPlaces)) + this.SystemConfig1.Unit);
                    else
                        weightBytes = new UTF8Encoding().GetBytes(this.PadLeft
                            (6, Helper.StringToDecimalPlaces(product.TareRange, this.SystemConfig1.DecimalPlaces)) + this.SystemConfig1.Unit);
                }
                else
                {
                    if (isFillZero == true)
                        weightBytes = new UTF8Encoding().GetBytes(Helper.StringZeroFillDigits6
                            (Helper.DoubleToString(0.0, this.SystemConfig1.DecimalPlaces)) + this.SystemConfig1.Unit);
                    else
                        weightBytes = new UTF8Encoding().GetBytes(this.PadLeft
                            (6, Helper.DoubleToString(0.0, this.SystemConfig1.DecimalPlaces)) + 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(bool isFillZero, WeightData weight)
        {
            try
            {
                if (weight.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                {
                    string temp;
                    StringBuilder sb = new StringBuilder();

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

                    temp = weight.WeightString.Substring(1, 4);
                    if (temp.Trim() == "")
                    {
                        if (isFillZero == true)
                            temp = "0000";
                        else
                            temp = "   0";
                    }
                    else
                    {
                        if (isFillZero == true)
                            temp = Helper.StringZeroFillDigits4(Helper.StringToDecimalPlaces(temp.Trim(), this.SystemConfig1.DecimalPlaces));
                        else
                            temp = this.PadLeft(4, Helper.StringToDecimalPlaces(temp.Trim(), this.SystemConfig1.DecimalPlaces));
                    }

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

                    return sb.ToString();
                }
                else
                    return "";
            }
            catch
            {
                return "";
            }
        }
        private string Transfer_14_OPT1(bool isFillZero, 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(bool isFillZero, 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
            {
                if (isFillZero == true)
                    sb.Append(Helper.StringZeroFillDigits9(weight.TotalCount.ToString()));
                else
                    sb.Append(this.PadLeft(9, weight.TotalCount.ToString()));
            }

            switch (weight.JudgmentStatus)
            {
                case DataStore.JudgmentStatus.Empty:
                    if (isFillZero == true)
                        sb.Append("000000000");
                    else
                        sb.Append("         ");
                    break;
                case DataStore.JudgmentStatus.Under:
                    tempValue = "U";
                    if (isFillZero == true)
                        sb.Append(Helper.StringZeroFillDigits9(tempValue.Trim()));
                    else
                        sb.Append(tempValue.PadLeft(9, ' '));
                    break;
                case DataStore.JudgmentStatus.Pass:
                    tempValue = "P";
                    if (isFillZero == true)
                        sb.Append(Helper.StringZeroFillDigits9(tempValue.Trim()));
                    else
                        sb.Append(tempValue.PadLeft(9, ' '));
                    break;
                case DataStore.JudgmentStatus.Over:
                    tempValue = "O";
                    if (isFillZero == true)
                        sb.Append(Helper.StringZeroFillDigits9(tempValue.Trim()));
                    else
                        sb.Append(tempValue.PadLeft(9, ' '));
                    break;
                case DataStore.JudgmentStatus.Double:
                    tempValue = "D";
                    if (isFillZero == true)
                        sb.Append(Helper.StringZeroFillDigits9(tempValue.Trim()));
                    else
                        sb.Append(tempValue.PadLeft(9, ' '));
                    break;
                case DataStore.JudgmentStatus.Metal:
                    tempValue = "M";
                    if (isFillZero == true)
                        sb.Append(Helper.StringZeroFillDigits9(tempValue.Trim()));
                    else
                        sb.Append(tempValue.PadLeft(9, ' '));
                    break;
                case DataStore.JudgmentStatus.ExNg:
                    tempValue = "E";
                    if (isFillZero == true)
                        sb.Append(Helper.StringZeroFillDigits9(tempValue.Trim()));
                    else
                        sb.Append(tempValue.PadLeft(9, ' '));
                    break;
                case DataStore.JudgmentStatus.LengthError:
                    tempValue = "L";
                    if (isFillZero == true)
                        sb.Append(Helper.StringZeroFillDigits9(tempValue.Trim()));
                    else
                        sb.Append(tempValue.PadLeft(9, ' '));
                    break;
                default:
                    tempValue = "E";
                    if (isFillZero == true)
                        sb.Append(Helper.StringZeroFillDigits9(tempValue.Trim()));
                    else
                        sb.Append(tempValue.PadLeft(9, ' '));
                    break;
            }
            if (isFillZero == true)
                sb.Append(Helper.StringZeroFillDigits9(Helper.DoubleToString(weight.Weight, this.SystemConfig1.DecimalPlaces)));
            else
                sb.Append(this.PadLeft(9, Helper.DoubleToString(weight.Weight, this.SystemConfig1.DecimalPlaces)));

            if (pItem.LotNo.Length > 9)
                sb.Append(pItem.LotNo.Substring(0, 9));
            else
            {
                if (isFillZero == true)
                    sb.Append(Helper.StringZeroFillDigits9(pItem.LotNo.Trim()));
                else
                    sb.Append(this.PadLeft(9, pItem.LotNo.Trim()));
            }
            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(bool isFillZero, WeightData weight, int step)
        {
            StringBuilder sb = new StringBuilder();

            switch (step)
            {
                case 1:
                    if (weight.JudgmentStatus != DataStore.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);
                        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((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(bool isFillZero, WeightData weight)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append((char)0x02);
            sb.Append("A01");
            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((char)0x04);

            return sb.ToString();
        }
        private string Transfer_21_ImpinjSpeedwayR420ToPC(bool isFillZero, WeightData weight)
        {
            double underValue = 0.0, overValue = 0.0;
            RFIDDataStore.VerifyCode verifyTag = RFIDDataStore.VerifyCode.Empty;
            StringBuilder sb = new StringBuilder();
            DateTime nowTime = DateTime.Now;

            sb.Append(weight.Weight.ToString().Trim());
            sb.Append(";");
            switch (weight.JudgmentStatus)
            {
                case DataStore.JudgmentStatus.Over:
                    sb.Append("HIG");
                    break;
                case DataStore.JudgmentStatus.Pass:
                    sb.Append("OK");
                    break;
                case DataStore.JudgmentStatus.Under:
                    sb.Append("LOW");
                    break;
                case DataStore.JudgmentStatus.Double:
                    sb.Append("DBL");
                    break;
                case DataStore.JudgmentStatus.Metal:
                    sb.Append("MTL");
                    break;
                default:
                    underValue = Helper.StringToWeight(this.CurrentProductItem.UnderRange, this.SystemConfig1.DecimalPlaces);
                    overValue = Helper.StringToWeight(this.CurrentProductItem.OverRange, this.SystemConfig1.DecimalPlaces);

                    if (underValue <= weight.Weight && overValue >= weight.Weight)
                        sb.Append("OK");
                    else if (underValue > weight.Weight)
                        sb.Append("LOW");
                    else
                        sb.Append("HIG");
                    break;
            }
            sb.Append(";");
            // 3)	PASS/ FAIL (RFID 미수집 및 표준코드 검증 오류) : P/F
            verifyTag = this.CurrentRFID.DefineCode(this.ReferenceTag, weight.JudgmentStatus);
            switch (verifyTag)
            {
                case RFIDDataStore.VerifyCode.Pass:
                    sb.Append("P");
                    break;
                default:
                    sb.Append("F");
                    break;
            }
            sb.Append(";");
            // 4)	TAG EPC 값
            sb.Append(this.ReferenceTag);
            sb.Append(";");
            sb.Append(string.Format("{0:yyyy-MM-dd-HH:mm:ss}", nowTime));

            return sb.ToString();
        }
        public byte[] Transfer_22_Modbus_Write()
        {
            byte[] madeData = new byte[ModbusTotalBytes];
            byte[] Length4Value = new byte[4];

            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 == DataStore.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 DataStore.JudgmentStatus.Over:
                    judgmentStatus = 0;
                    break;
                case DataStore.JudgmentStatus.Pass:
                    judgmentStatus = 1;
                    break;
                case DataStore.JudgmentStatus.Under:
                    judgmentStatus = 2;
                    break;
                case DataStore.JudgmentStatus.Metal:
                    judgmentStatus = 3;
                    break;
                case DataStore.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];

            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)
                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 == DataStore.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 DataStore.JudgmentStatus.Over:
                        judgmentStatus = 0;
                        break;
                    case DataStore.JudgmentStatus.Pass:
                        judgmentStatus = 1;
                        break;
                    case DataStore.JudgmentStatus.Under:
                        judgmentStatus = 2;
                        break;
                    case DataStore.JudgmentStatus.Metal:
                        judgmentStatus = 3;
                        break;
                    case DataStore.JudgmentStatus.Double:
                        judgmentStatus = 4;
                        break;
                    default:
                        judgmentStatus = 5;
                        break;
                }

                for (int j = startAddressInt; j < startAddressInt + numberOfRegisterInt; j++)
                {
                    switch (j)
                    {
                        #region Make data
                        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_UnderValue_High:
                            length4Value = GetBytes((Single)underValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._08_UnderValue_Low:
                            length4Value = GetBytes((Single)underValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._09_PassValue_High:
                            length4Value = GetBytes((Single)passValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._10_PassValue_Low:
                            length4Value = GetBytes((Single)passValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._11_OverValue_High:
                            length4Value = GetBytes((Single)overValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._12_OverValue_Low:
                            length4Value = GetBytes((Single)overValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._13_TareValue_High:
                            length4Value = GetBytes((Single)tareValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._14_TareValue_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_Weight_High:
                            if (this.CurrentSystemStatus.Equipment == DataStore.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_Weight_Low:
                            if (this.CurrentSystemStatus.Equipment == DataStore.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;
                        default:
                            break;
                        #endregion
                    }
                    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)
                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 == DataStore.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 DataStore.JudgmentStatus.Over:
                        judgmentStatus = 0;
                        break;
                    case DataStore.JudgmentStatus.Pass:
                        judgmentStatus = 1;
                        break;
                    case DataStore.JudgmentStatus.Under:
                        judgmentStatus = 2;
                        break;
                    case DataStore.JudgmentStatus.Metal:
                        judgmentStatus = 3;
                        break;
                    case DataStore.JudgmentStatus.Double:
                        judgmentStatus = 4;
                        break;
                    default:
                        judgmentStatus = 5;
                        break;
                }

                for (int j = startAddressInt; j < startAddressInt + numberOfRegisterInt; j++)
                {
                    switch (j)
                    {
                        #region Make data
                        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_UnderValue_High:
                            length4Value = GetBytes((Single)underValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._08_UnderValue_Low:
                            length4Value = GetBytes((Single)underValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._09_PassValue_High:
                            length4Value = GetBytes((Single)passValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._10_PassValue_Low:
                            length4Value = GetBytes((Single)passValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._11_OverValue_High:
                            length4Value = GetBytes((Single)overValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._12_OverValue_Low:
                            length4Value = GetBytes((Single)overValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[1 - i];
                            break;
                        case _30000_ModbusAddress._13_TareValue_High:
                            length4Value = GetBytes((Single)tareValue);
                            for (int i = 0; i < 2; i++)
                                madeData[madeDataIndex + i] = length4Value[3 - i];
                            break;
                        case _30000_ModbusAddress._14_TareValue_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_Weight_High:
                            if (this.CurrentSystemStatus.Equipment == DataStore.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_Weight_Low:
                            if (this.CurrentSystemStatus.Equipment == DataStore.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;
                        default:
                            break;
                        #endregion
                    }
                    madeDataIndex += 2;
                }
                #endregion
            }

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

            if (weight.JudgmentStatus == DataStore.JudgmentStatus.Empty)
                return "";

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

            if (isFillZero == true)
                sb.Append(Helper.StringZeroFillDigits6(Helper.StringToDecimalPlaces(product.UnderRange, this.SystemConfig1.DecimalPlaces)));
            else
                sb.Append(this.PadLeft(6, Helper.StringToDecimalPlaces(product.UnderRange, this.SystemConfig1.DecimalPlaces)));
            if (isFillZero == true)
                sb.Append(Helper.StringZeroFillDigits6(Helper.StringToDecimalPlaces(product.PassRange, this.SystemConfig1.DecimalPlaces)));
            else
                sb.Append(this.PadLeft(6, Helper.StringToDecimalPlaces(product.PassRange, this.SystemConfig1.DecimalPlaces)));
            if (isFillZero == true)
                sb.Append(Helper.StringZeroFillDigits6(Helper.StringToDecimalPlaces(product.OverRange, this.SystemConfig1.DecimalPlaces)));
            else
                sb.Append(this.PadLeft(6, Helper.StringToDecimalPlaces(product.OverRange, this.SystemConfig1.DecimalPlaces)));


            if (isFillZero == true)
                sb.Append(Helper.StringZeroFillDigits7(weight.UnderCount.ToString()));
            else
                sb.Append(this.PadLeft(7, weight.UnderCount.ToString()));

            if (isFillZero == true)
                sb.Append(Helper.StringZeroFillDigits7(weight.PassCount.ToString()));
            else
                sb.Append(this.PadLeft(7, weight.PassCount.ToString()));

            if (isFillZero == true)
                sb.Append(Helper.StringZeroFillDigits7(weight.OverCount.ToString()));
            else
                sb.Append(this.PadLeft(7, weight.OverCount.ToString()));

            if (isFillZero == true)
                sb.Append(Helper.StringZeroFillDigits7(weight.ExNGCount.ToString()));
            else
                sb.Append(this.PadLeft(7, weight.ExNGCount.ToString()));

            if (isFillZero == true)
                sb.Append(Helper.StringZeroFillDigits7(weight.TotalCount.ToString()));
            else
                sb.Append(this.PadLeft(7, weight.TotalCount.ToString()));

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

            double weightWithoutSign = weight.Weight;
            if (weight.Weight <= 0.0)
            {
                sb.Append("-");
                weightWithoutSign = weightWithoutSign * -1.0;
            }
            else
            {
                sb.Append(" ");
            }

            if (isFillZero == true)
                sb.Append(Helper.StringZeroFillDigits6(Helper.DoubleToString(weightWithoutSign, this.SystemConfig1.DecimalPlaces)));
            else
                sb.Append(this.PadLeft(6, Helper.DoubleToString(weightWithoutSign, this.SystemConfig1.DecimalPlaces)));

            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)DataStore.SerialMode.f24_MULTi_JET)
                    slaveAddress = Convert.ToByte(this.SystemConfig2.MULTiJETSlaveAddressCOM1);
                else if (this.SystemConfig1.SerialCOM3Mode == (int)DataStore.SerialMode.f24_MULTi_JET)
                    slaveAddress = Convert.ToByte(this.SystemConfig2.MULTiJETSlaveAddressCOM3);
                else if (this.SystemConfig1.SerialCOM4Mode == (int)DataStore.SerialMode.f24_MULTi_JET)
                    slaveAddress = Convert.ToByte(this.SystemConfig2.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)
        {
            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 DataStore.JudgmentStatus.Empty:
                    break;
                case DataStore.JudgmentStatus.Under:
                    sb.Append("U");
                    break;
                case DataStore.JudgmentStatus.Pass:
                    sb.Append("P");
                    break;
                case DataStore.JudgmentStatus.Over:
                    sb.Append("O");
                    break;
                case DataStore.JudgmentStatus.Double:
                    sb.Append("D");
                    break;
                case DataStore.JudgmentStatus.Metal:
                    sb.Append("M");
                    break;
                case DataStore.JudgmentStatus.ExNg:
                    sb.Append("E");
                    break;
                case DataStore.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(DataStore.CharValue sendChar)
        {
            StringBuilder temp = new StringBuilder();

            switch (sendChar)
            {
                case DataStore.CharValue.ENQ:
                    temp.Append((char)0x05);
                    break;
                case DataStore.CharValue.ACK:
                    temp.Append((char)0x06);
                    break;
                case DataStore.CharValue.NAK:
                    temp.Append((char)0x15);
                    break;
                case DataStore.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 중량(OPT1)
        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 = Helper.DoubleToString(weight.Weight, this.SystemConfig1.DecimalPlaces).Length;
            if (tempStringLength > 5)
                tempString = Helper.DoubleToString(weight.Weight, this.SystemConfig1.DecimalPlaces).Substring(tempStringLength - 5, 5);
            else
                tempString = Helper.DoubleToString(weight.Weight, this.SystemConfig1.DecimalPlaces);

            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 = Helper.DoubleToString(weight.Weight, this.SystemConfig1.DecimalPlaces);
            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[11];
            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(DataStore.MenuBottomConfiguration port)
        {
            switch (port)
            {
                case DataStore.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 DataStore.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 DataStore.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 == DataStore.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;
        }
        private void RFIDNGSendTimeDelegate()
        {
            System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();

            if (int.Parse(this.CurrentSystemParameter3.ExternalOut1Mode) == 12)
                timer.Interval = int.Parse(this.CurrentSystemParameter3.ExternalOut1RunTime);
            else if (int.Parse(this.CurrentSystemParameter3.ExternalOut2Mode) == 12)
                timer.Interval = int.Parse(this.CurrentSystemParameter3.ExternalOut2RunTime);
            else if (int.Parse(this.CurrentSystemParameter3.ExternalOut3Mode) == 12)
                timer.Interval = int.Parse(this.CurrentSystemParameter3.ExternalOut3RunTime);
            else if (int.Parse(this.CurrentSystemParameter3.ExternalOut4Mode) == 12)
                timer.Interval = int.Parse(this.CurrentSystemParameter3.ExternalOut4RunTime);
            else if (int.Parse(this.CurrentSystemParameter3.ExternalOut9Mode) == 12)
                timer.Interval = int.Parse(this.CurrentSystemParameter3.ExternalOut9RunTime);
            else if (int.Parse(this.CurrentSystemParameter3.ExternalOut10Mode) == 12)
                timer.Interval = int.Parse(this.CurrentSystemParameter3.ExternalOut10RunTime);
            else
                timer.Interval = this.CurrentJudgmentSetItem.JudgmentDelayTime;

            timer.Tick += new EventHandler(this.timerRFIDNGSend_Tick);
            timer.Enabled = true;
        }
        #endregion
        #region Serial COM1
        public void OpenSerialCOM1()
        {
            int baudrate = 9600;

            if (this.SystemConfig1.SerialCOM1Mode == 0)
                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(DataStore.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(DataStore.MenuBottomConfiguration.SerialCOM1);
            }
        }
        public void ChangeSerialCOM1FrameSeparateType(DataStore.SeparateType type)
        {
            if (this.FlagSerialDll == true)
                return;

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

            if (type == DataStore.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 == DataStore.SeparateType.STXANDETX)
            {
                this.smartSerialPort1.FrameSeparationType = SmartSerialPort.FRAMESEPARATIONTYPES.STXANDETX;

                this.smartSerialPort1.STXCode = 2;
                this.smartSerialPort1.ETXCode = 3;
            }
            else if (type == DataStore.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)
                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(DataStore.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(DataStore.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(DataStore.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.SystemConfig2.Barcode != 0)
            {

            }
        }

        public void ChangeSerialCOM3FrameSeparateType(DataStore.SeparateType type)
        {
            if (this.FlagSerialDll == true)
                return;

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

            if (type == DataStore.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 == DataStore.SeparateType.STXANDETX)
            {
                this.smartSerialPort3.FrameSeparationType = SmartSerialPort.FRAMESEPARATIONTYPES.STXANDETX;

                this.smartSerialPort3.STXCode = 2;
                this.smartSerialPort3.ETXCode = 3;
            }
            else if (type == DataStore.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.smartSerialPort3.Open();
        }
        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)
                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(DataStore.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(DataStore.MenuBottomConfiguration.SerialCOM4);
            }
        }
        public void ChangeSerialCOM4FrameSeparateType(DataStore.SeparateType type)
        {
            if (this.FlagSerialDll == true)
                return;

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

            if (type == DataStore.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 == DataStore.SeparateType.STXANDETX)
            {
                this.smartSerialPort4.FrameSeparationType = SmartSerialPort.FRAMESEPARATIONTYPES.STXANDETX;

                this.smartSerialPort4.STXCode = 2;
                this.smartSerialPort4.ETXCode = 3;
            }
            else if (type == DataStore.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.UnderValue = Helper.StringToWeight(this.CurrentProductItem.UnderRange, this.SystemConfig1.DecimalPlaces);
            this.Current30000ModbusData.PassValue = Helper.StringToWeight(this.CurrentProductItem.PassRange, this.SystemConfig1.DecimalPlaces);
            this.Current30000ModbusData.OverValue = Helper.StringToWeight(this.CurrentProductItem.OverRange, this.SystemConfig1.DecimalPlaces);
            this.Current30000ModbusData.TareValue = 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 DataStore.JudgmentStatus.Over:
                    this.Current30000ModbusData.Grade = 0;
                    break;
                case DataStore.JudgmentStatus.Pass:
                    this.Current30000ModbusData.Grade = 1;
                    break;
                case DataStore.JudgmentStatus.Under:
                    this.Current30000ModbusData.Grade = 2;
                    break;
                case DataStore.JudgmentStatus.Metal:
                    this.Current30000ModbusData.Grade = 3;
                    break;
                case DataStore.JudgmentStatus.Double:
                    this.Current30000ModbusData.Grade = 4;
                    break;
                default:
                    this.Current30000ModbusData.Grade = 5;
                    break;
            }

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

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

            this.ChildFormMainDisplay.MainModbus.UpdateData(this.Current30000ModbusData);
        }
        /// <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);
                                        if (this.SystemConfig3.IsStartStopLog == true)
                                            this.smartFileStartStopLog.WriteString(string.Format("Send Start ({0:yyyy-MM-dd HH:mm:ss}): Modbus Command", DateTime.Now));
                                    }
                                    else
                                    {
                                        this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
                                        if (this.SystemConfig3.IsStartStopLog == true)
                                            this.smartFileStartStopLog.WriteString(string.Format("Send Stop ({0:yyyy-MM-dd HH:mm:ss}): Modbus Command", DateTime.Now));
                                    }

                                    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 == DataStore.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);
                                    if (this.SystemConfig3.IsStartStopLog == true)
                                        this.smartFileStartStopLog.WriteString(string.Format("Send Start ({0:yyyy-MM-dd HH:mm:ss}): Modbus Command", DateTime.Now));
                                }
                                else
                                {
                                    this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
                                    if (this.SystemConfig3.IsStartStopLog == true)
                                        this.smartFileStartStopLog.WriteString(string.Format("Send Stop ({0:yyyy-MM-dd HH:mm:ss}): Modbus Command", DateTime.Now));
                                }

                                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 == DataStore.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.SystemConfig3.IsEthernetPingTimer == true)
            {
                this.timerEthernetPing.Enabled = bValue;
            }
            else
                this.timerEthernetPing.Enabled = false;
        }

        #region Client
        public void EthernetClientConnect()
        {
            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;
            }
            if (this.IsEthernetClientConnect == true || this.IsEthernetClientThreadStart == true)
                return;  // Online 경우

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

                cpClientThread.IsBackground = true;

                cpClientThread.Start();

                //this.IsUsingTimerEthernetPing(true);
            }
            catch
            {
                this.DelegateUISeverStatus(false);
                this.DelegateTextStatusOut(">Thread Error");

                this.EthernetClientDisconnect();
            }
        }
        public void EthernetClientDisconnect()
        {
            //this.IsUsingTimerEthernetPing(false);
            this.DelegateUISeverStatus(false);
            this.DelegateTextStatusOut(">Disconnected");

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

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

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

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

        private void EthernetClientReceiveThread()
        {
            int nConnectPort = Convert.ToInt32(this.SystemConfig2.EthernetHostPort);
            try
            {
                this.IsEthernetClientThreadStart = true;

                this.DelegateTextStatusOut(">Now Connecting..");
                this.EthernetTcpClient = new TcpClient(this.SystemConfig2.EthernetAddress, nConnectPort);

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

                this.DelegateUISeverStatus(true);
                this.DelegateTextStatusOut(">Connected Server");
                this.DelegateUITimerWork(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.IsEthernetClientConnect == true)
                {
                    string strRecvMsg = this.EthernetStmReader.ReadLine();

                    if (null == strRecvMsg)
                        break;

                    this.DelegateTextStatusOut(strRecvMsg);
                }

                this.DelegateTextStatusOut(">Server Out");

                this.EthernetClientDisconnect();
                this.DelegateUITimerWork(true);
            }
            catch
            {
                this.DelegateUISeverStatus(false);

                this.DelegateTextStatusOut(">Connect Fail !");

                this.EthernetClientDisconnect();
                this.DelegateUITimerWork(true);
            }

            this.IsEthernetClientThreadStart = false;

            return;
        }

        public void UITimerWork(bool status)
        {
            if (this.CurrentSystemStatus.CurrentDisplay == DataStore.DisplayStore.MainDisplay
                && this.ChildFormMainDisplay.CurrentDisplay != DataStore.MainDisplayStore.StartMenu)
            {
                if (this.IsClientConnectTryTimerStart != status)
                {
                    this.timerClientConnect.Enabled = status;
                    this.IsClientConnectTryTimerStart = status;

                    //Console.Write("\n" + string.Format("{0:yyyy-MM-dd HH:mm:ss}: {1}", DateTime.Now, status.ToString()));
                }
            }
        }
        private void DelegateUITimerWork(bool status)
        {
            this.Invoke(new UITimerWorkCallback(this.UITimerWork), status);
        }

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

        private void TextStatusOut(string value)
        {
            if (value.Contains(">Connected Server") == true)
                this.IsEthernetClientConnect = true;
            else
                this.IsEthernetClientConnect = false;

            if (this.ChildFormMenu.CenterConfiEthernet != null)
                this.ChildFormMenu.CenterConfiEthernet.UpdateEthernetStatusDisplay(value);

            //Console.Write("\n" + string.Format("{0:yyyy-MM-dd HH:mm:ss}: {1}", DateTime.Now, value));
        }
        private void DelegateTextStatusOut(string value)
        {
            this.Invoke(new TextStatusCallback(this.TextStatusOut), value);
        }

        private void DelegateTransferData(string data)
        {
            this.Invoke(new TransferStringDataCallback(this.EthernetSendMessage), data);
        }
        private void DelegateTransferData(byte[] data)
        {
            this.Invoke(new TransferByteArrayDataCallback(this.EthernetSendMessage), data);
        }
        private void DelegateTransferData(byte data)
        {
            this.Invoke(new TransferByteDataCallback(this.EthernetSendMessage), data);
        }
        public void EthernetSendMessage(string msg)
        {
            try
            {
                this.EthernetStmWriter.Write(msg);
                this.EthernetStmWriter.Flush();
            }
            catch
            {
                this.DelegateUISeverStatus(false);
            }
        }
        public void EthernetSendMessage(byte[] msg)
        {
            try
            {
                this.EthernetStmWriter.BaseStream.Write(msg, 0, msg.Length);
                this.EthernetStmWriter.Flush();
            }
            catch
            {
                this.DelegateUISeverStatus(false);
            }
        }
        public void EthernetSendMessage(byte msg)
        {
            try
            {
                this.EthernetStmWriter.Write(msg);
                this.EthernetStmWriter.Flush();
            }
            catch
            {
                this.DelegateUISeverStatus(false);
            }
        }
        public void EthernetWeightData(string strTemp)
        {
            this.IsEthernetTransferData = true;
            this.EthernetTransferData = strTemp;

            try
            {
                if (this.IsEthernetClientConnect == false)
                    this.EthernetClientConnect();

                this.EthernetSendMessage((string)this.EthernetTransferData);
            }
            catch
            {

            }
        }
        public void EthernetWeightData(byte[] bytes)
        {
            this.IsEthernetTransferData = true;
            this.EthernetTransferData = bytes;

            try
            {
                if (this.IsEthernetClientConnect == false)
                    this.EthernetClientConnect();

                this.EthernetSendMessage(bytes);
            }
            catch
            {

            }
        }
        public void EthernetWeightDataForModbus(byte[] bytes)
        {
            this.IsEthernetTransferData = true;
            this.EthernetTransferData = bytes;

            try
            {
                if (this.IsEthernetClientConnect == false)
                    this.EthernetClientConnect();

                this.EthernetSendMessage(bytes);
            }
            catch
            {

            }
        }
        #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
        private void RemoveAlarmFile()
        {
            bool directoryCheck = false;

            try
            {
                string dMonth = string.Format("{0:yyyyMM}", DateTime.Now.AddMonths(-3)) + ".csv";

                DirectoryInfo dir = new DirectoryInfo(this.PathDataBackupFolder);

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

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

            }

        }
        public void PrintAlarm(string alarmRawData, string alarmString)
        {
            bool fileCheck = false, directoryCheck = false;
            string fullFilePath = "";
            DateTime time = DateTime.Now;
            StreamWriter sw;

            fullFilePath = this.PathDataBackupFolder + string.Format("{0:yyyyMM}_", time) + this.SystemConfig1.EquipmentID + "_Alarm.csv";

            DirectoryInfo di = new DirectoryInfo(this.PathDataBackupFolder);
            directoryCheck = di.Exists;
            // 폴더 체크
            if (directoryCheck == false)
                di.Create();
            // 파일 체크
            FileInfo fileInfo = new FileInfo(fullFilePath);
            fileCheck = fileInfo.Exists;

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

            if (fileCheck == false)
            {
                sw.Write("Date");
                sw.Write(",");
                sw.Write("Time");
                sw.Write(",");
                sw.Write("Raw Data");
                sw.Write(",");
                sw.Write("Alarm Name");
                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(alarmRawData);
            sw.Write(",");
            sw.Write(alarmString);
            sw.WriteLine();

            sw.Close();
        }
        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.MainWeightSmallScreen.UpdateAlarmLabelDisplay(this.CountingOutput1Count, this.CountingOutput2Count);
        }
        #endregion

        #region CountingOutput
        private void CountingOutput1Operation(bool condition)
        {
            if (condition == true)
            {
                this.CountingOutput1Count++;

                if (this.CountingOutput1Count >= this.SystemConfig2.CountingOutput1Number)
                {
                    #region 설정된 CountingOutput 개수보다 Count값이 크거나 같을 때
                    this.IsCountingOutputCrossStatus = true;
                    this.IsSatisfyCounting = true;
                    this.CountingOutput1Count = 0;

                    if (this.SystemConfig2.IsRFIDSpeedwayR420 == true)
                    {
                        switch (this.SystemConfig2.CountingOutput1Mode)
                        {
                            case 3:
                                this.SendAlarmToPC("W1");
                                break;
                            case 4:
                                this.SendAlarmToPC("W2");
                                break;
                            case 5:
                                this.SendAlarmToPC("R2");
                                break;
                            default:
                                break;
                        }
                    }
                    if (this.SystemConfig2.IsCountingOutput1BuzzerOn == true)
                    {
                        if (this.StopWatchForBuzzer.IsRunning == true)
                        {
                            if ((this.timerBuzzer.Interval - (int)this.StopWatchForBuzzer.ElapsedMilliseconds)
                                < this.SystemConfig2.CountingOutput1BuzzerTime)
                            {
                                this.timerBuzzer.Enabled = false;
                                this.timerBuzzer.Interval = this.SystemConfig2.CountingOutput1BuzzerTime;
                                this.StopWatchForBuzzer.Stop();
                                this.StopWatchForBuzzer.Reset();
                                this.StopWatchForBuzzer.Start();
                                this.timerBuzzer.Enabled = true;
                            }
                        }
                        else
                        {
                            this.StopWatchForBuzzer.Reset();
                            this.StopWatchForBuzzer.Start();
                            this.timerBuzzer.Interval = this.SystemConfig2.CountingOutput1BuzzerTime;
                            this.timerBuzzer.Enabled = true;
                            this.TransferData(CommunicationCommand.BuzzerOnContinuousEnable, CommunicationID.MainBoard);
                        }
                    }
                    if (this.SystemConfig2.IsCountingOutput1ConveyorStop == true)
                    {
                        this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
                        if (this.SystemConfig3.IsStartStopLog == true)
                            this.smartFileStartStopLog.WriteString(string.Format("Send Stop ({0:yyyy-MM-dd HH:mm:ss}): FormMain-CountingOutput1Operation", DateTime.Now));
                        // 메시지 23
                        this.StartThreadMessage1();
                    }
                    if (this.SystemConfig2.IsCountingOutput1ExternalOutput == true)
                        this.TransferData(CommunicationCommand.CountingOutput1Pulse, CommunicationID.MainBoard);
                    #endregion
                }
            }
            else
            {
                if (this.SystemConfig2.IsCountingOutput1Continuous == true)
                    this.CountingOutput1Count = 0;
            }

        }
        private void CountingOutput2Operation(bool condition)
        {
            if (condition == true)
            {
                this.CountingOutput2Count++;

                if (this.CountingOutput2Count >= this.SystemConfig2.CountingOutput2Number)
                {
                    #region 설정된 CountingOutput 개수보다 Count값이 크거나 같을 때
                    this.IsCountingOutputCrossStatus = false;
                    this.IsSatisfyCounting = true;
                    this.CountingOutput2Count = 0;

                    if (this.SystemConfig2.IsRFIDSpeedwayR420 == true)
                    {
                        switch (this.SystemConfig2.CountingOutput2Mode)
                        {
                            case 3:
                                this.SendAlarmToPC("W1");
                                break;
                            case 4:
                                this.SendAlarmToPC("W2");
                                break;
                            case 5:
                                this.SendAlarmToPC("R2");
                                break;
                            default:
                                break;
                        }
                    }
                    if (this.SystemConfig2.IsCountingOutput2BuzzerOn == true)
                    {
                        if (this.StopWatchForBuzzer.IsRunning == true)
                        {
                            if ((this.timerBuzzer.Interval - (int)this.StopWatchForBuzzer.ElapsedMilliseconds)
                                < this.SystemConfig2.CountingOutput2BuzzerTime)
                            {
                                this.timerBuzzer.Enabled = false;
                                this.timerBuzzer.Interval = this.SystemConfig2.CountingOutput2BuzzerTime;
                                this.StopWatchForBuzzer.Stop();
                                this.StopWatchForBuzzer.Reset();
                                this.StopWatchForBuzzer.Start();
                                this.timerBuzzer.Enabled = true;
                            }
                        }
                        else
                        {
                            this.StopWatchForBuzzer.Reset();
                            this.StopWatchForBuzzer.Start();
                            this.timerBuzzer.Interval = this.SystemConfig2.CountingOutput2BuzzerTime;
                            this.timerBuzzer.Enabled = true;
                            this.TransferData(CommunicationCommand.BuzzerOnContinuousEnable, CommunicationID.MainBoard);
                        }
                    }
                    if (this.SystemConfig2.IsCountingOutput2ConveyorStop == true)
                    {
                        this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
                        if (this.SystemConfig3.IsStartStopLog == true)
                            this.smartFileStartStopLog.WriteString(string.Format("Send Stop ({0:yyyy-MM-dd HH:mm:ss}): FormMain-CountingOutput2Operation", DateTime.Now));
                        // 메시지 23
                        this.StartThreadMessage1();
                    }
                    if (this.SystemConfig2.IsCountingOutput2ExternalOutput == true)
                        this.TransferData(CommunicationCommand.CountingOutput2Pulse, CommunicationID.MainBoard);
                    #endregion
                }
            }
            else
            {
                if (this.SystemConfig2.IsCountingOutput2Continuous == true)
                    this.CountingOutput2Count = 0;
            }
        }

        private void UpdateCountingOutput1()
        {
            switch (this.SystemConfig2.CountingOutput1Mode)
            {
                case 1: // Pass
                    if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                        this.CountingOutput1Operation(true);
                    else
                        this.CountingOutput1Operation(false);
                    break;
                case 2: // NG
                    if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Over
                        || this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Under)
                        this.CountingOutput1Operation(true);
                    else
                        this.CountingOutput1Operation(false);
                    break;
                case 3: // Over
                    if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Over)
                        this.CountingOutput1Operation(true);
                    else
                        this.CountingOutput1Operation(false);
                    break;
                case 4: // Under
                    if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Under)
                        this.CountingOutput1Operation(true);
                    else
                        this.CountingOutput1Operation(false);
                    break;
                case 5: // ExNG
                    if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.ExNg
                        || this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.LengthError)
                        this.CountingOutput1Operation(true);
                    else
                        this.CountingOutput1Operation(false);
                    break;
                case 6: // Metal
                    if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Metal)
                        this.CountingOutput1Operation(true);
                    else
                        this.CountingOutput1Operation(false);
                    break;
                case 7: // Double
                    if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Double)
                        this.CountingOutput1Operation(true);
                    else
                        this.CountingOutput1Operation(false);
                    break;
                case 8: // ExNG1
                    if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.ExNg1)
                        this.CountingOutput1Operation(true);
                    else
                        this.CountingOutput1Operation(false);
                    break;
                case 9: // ExNG2
                    if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.ExNg2)
                        this.CountingOutput1Operation(true);
                    else
                        this.CountingOutput1Operation(false);
                    break;
                default:
                    break;
            }
        }
        private void UpdateCountingOutput2()
        {
            switch (this.SystemConfig2.CountingOutput2Mode)
            {
                case 1: // Pass
                    if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Pass)
                        this.CountingOutput2Operation(true);
                    else
                        this.CountingOutput2Operation(false);
                    break;
                case 2: // NG
                    if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Over
                        || this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Under)
                        this.CountingOutput2Operation(true);
                    else
                        this.CountingOutput2Operation(false);
                    break;
                case 3: // Over
                    if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Over)
                        this.CountingOutput2Operation(true);
                    else
                        this.CountingOutput2Operation(false);
                    break;
                case 4: // Under
                    if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Under)
                        this.CountingOutput2Operation(true);
                    else
                        this.CountingOutput2Operation(false);
                    break;
                case 5: // ExNG
                    if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.ExNg
                        || this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.LengthError)
                        this.CountingOutput2Operation(true);
                    else
                        this.CountingOutput2Operation(false);
                    break;
                case 6: // Metal
                    if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Metal)
                        this.CountingOutput2Operation(true);
                    else
                        this.CountingOutput2Operation(false);
                    break;
                case 7: // Double
                    if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.Double)
                        this.CountingOutput2Operation(true);
                    else
                        this.CountingOutput2Operation(false);
                    break;
                case 8: // ExNG1
                    if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.ExNg1)
                        this.CountingOutput2Operation(true);
                    else
                        this.CountingOutput2Operation(false);
                    break;
                case 9: // ExNG2
                    if (this.CurrentWeightData.JudgmentStatus == DataStore.JudgmentStatus.ExNg2)
                        this.CountingOutput2Operation(true);
                    else
                        this.CountingOutput2Operation(false);
                    break;
                default:
                    break;
            }
        }
        #endregion

        #region Data Backup
        private void RemoveBackupDataFile()
        {
            bool directoryCheck = false;

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

                DirectoryInfo dir = new DirectoryInfo(this.PathDataBackupFolder);

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

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

            }

        }
        /// <summary>
        /// DataBackup Format - STD1
        /// </summary>
        /// <param name="item"></param>
        private void DataBackup0(WeightData item)
        {
            bool fileCheck = false, directoryCheck = false;
            RFIDDataStore.VerifyCode verifyTag = RFIDDataStore.VerifyCode.Empty;
            string fullFilePath = "";
            string filePathExtension = "";
            StreamWriter sw;
            DateTime time = DateTime.Now;

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

            fullFilePath = string.Format("{0}{1:yyyyMMdd}_{2}_{3}_Data{4}", this.PathDataBackupFolder, DateTime.Now, this.SystemConfig1.EquipmentID, this.CurrentProductItem.Name, filePathExtension);

            DirectoryInfo di = new DirectoryInfo(this.PathDataBackupFolder);
            directoryCheck = di.Exists;
            // 폴더 체크
            if (directoryCheck == false)
                di.Create();
            // 파일 체크
            FileInfo fileInfo = new FileInfo(fullFilePath);
            fileCheck = fileInfo.Exists;

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

            if (fileCheck == false)
            {
                sw.Write("Date");
                sw.Write(",");
                sw.Write("Time");
                sw.Write(",");
                sw.Write("P_No");
                sw.Write(",");
                sw.Write("Name");
                sw.Write(",");
                sw.Write("Lot");
                sw.Write(",");
                sw.Write("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");
                if (this.SystemConfig2.IsRFIDSpeedwayR420 == true)
                {
                    sw.Write(",");
                    sw.Write("VerifyCode");
                    sw.Write(",");
                    sw.Write("TAG");
                }
                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);
            if (this.SystemConfig2.IsRFIDSpeedwayR420 == true)
            {
                sw.Write(",");
                verifyTag = this.CurrentRFID.DefineCode(this.ReferenceTag, item.JudgmentStatus);
                switch (verifyTag)
                {
                    case RFIDDataStore.VerifyCode.Pass:
                        sw.Write("P");
                        break;
                    default:
                        sw.Write("F");
                        break;
                }
                sw.Write(",");
                sw.Write(this.ReferenceTag);
            }

            sw.WriteLine();

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

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

            fullFilePath = string.Format("{0}{1:yyyyMMdd}_{2}_{3}_Data{4}", this.PathDataBackupFolder, DateTime.Now, this.SystemConfig1.EquipmentID, this.CurrentProductItem.Name, filePathExtension);

            DirectoryInfo di = new DirectoryInfo(this.PathDataBackupFolder);
            directoryCheck = di.Exists;
            // 폴더 체크
            if (directoryCheck == false)
                di.Create();
            // 파일 체크
            FileInfo fileInfo = new FileInfo(fullFilePath);
            fileCheck = fileInfo.Exists;

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

            #region OPT1 - 종근당
            // 제품명, LOT번호, 상한설정값, 하한설정값, 중량, 날짜, 시간, Pass수량, Grade, Status
            if (fileCheck == false)
            {
                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();
            #endregion
        }
        ///// <summary>
        ///// DataBackup Format - OPT1(종근당)
        ///// </summary>
        ///// <param name="item"></param>
        //private void DataBackup1(WeightData item)
        //{
        //    bool fileCheck = false, directoryCheck = false;
        //    string fullFilePath = "";
        //    StreamWriter sw;
        //    DateTime time = DateTime.Now;

        //    this.RemoveUsbBackupFile();

        //    fullFilePath = string.Format("{0}{1:yyyyMMdd}_{2}_{3}.csv", this.PathDataBackupFolder, DateTime.Now, this.SystemConfig.UsbID, this.CurrentProductItem.Name);

        //    DirectoryInfo di = new DirectoryInfo(this.PathDataBackupFolder);
        //    directoryCheck = di.Exists;
        //    // 폴더 체크
        //    if (directoryCheck == false)
        //        di.Create();
        //    // 파일 체크
        //    FileInfo fileInfo = new FileInfo(fullFilePath);
        //    fileCheck = fileInfo.Exists;

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

        //    #region OPT1 - 종근당
        //    // 제품명, LOT번호, 상한설정값, 하한설정값, 중량, 날짜, 시간, Pass수량, Grade, Status
        //    if (fileCheck == false)
        //    {
        //        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(this.CurrentProductItem.Name);
        //    sw.Write(",");
        //    sw.Write(this.CurrentProductItem.LotNo);
        //    sw.Write(",");
        //    sw.Write(Helper.StringToDecimalPlaces(this.CurrentProductItem.OverRange, this.SystemConfig.DecimalPlaces));
        //    sw.Write(",");
        //    sw.Write(Helper.StringToDecimalPlaces(this.CurrentProductItem.UnderRange, this.SystemConfig.DecimalPlaces));
        //    sw.Write(",");
        //    sw.Write(Helper.DoubleToString(item.Weight, this.SystemConfig.DecimalPlaces));
        //    sw.Write(",");
        //    sw.Write(string.Format("{0:yyyy-MM-dd}", time));
        //    sw.Write(",");
        //    sw.Write(string.Format("{0:HH:mm:ss}", time));
        //    sw.Write(",");
        //    sw.Write(item.PassCount);
        //    sw.Write(",");
        //    sw.Write(item.JudgmentStatus);
        //    sw.Write(",");
        //    sw.Write("리젝데이터");

        //    sw.WriteLine();
        //    sw.Close();
        //    #endregion
        //}
        #endregion

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

            this.SystemConfig1.Initialization();

            structItem.IsDataBackup = this.SystemConfig1.IsDataBackup;
            structItem.IsLogin = this.SystemConfig1.IsLogin;

            structItem.EquipmentID = this.SystemConfig1.EquipmentID;
            structItem.DecimalPlaces = this.SystemConfig1.DecimalPlaces;
            structItem.ProductNumber = this.SystemConfig1.ProductNumber;
            structItem.Dummy1Int = 0;
            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.IsAverageTracking = this.SystemConfig1.IsAverageTracking;
            structItem.IsExternalInputLamp = this.SystemConfig1.IsExternalInputLamp;
            structItem.IsExternalInputBuzzer = this.SystemConfig1.IsExternalInputBuzzer;
            structItem.IsPrintPerProductEnable = this.SystemConfig1.IsPrintPerProductEnable;
            structItem.DummyBool1 = false;
            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.IsDataBackup = item.IsDataBackup;
            structItem.IsLogin = item.IsLogin;

            structItem.EquipmentID = item.EquipmentID;
            structItem.DecimalPlaces = item.DecimalPlaces;
            structItem.ProductNumber = item.ProductNumber;
            structItem.Dummy1Int = 0;
            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.IsAverageTracking = item.IsAverageTracking;
            structItem.IsExternalInputLamp = item.IsExternalInputLamp;
            structItem.IsExternalInputBuzzer = item.IsExternalInputBuzzer;
            structItem.IsPrintPerProductEnable = item.IsPrintPerProductEnable;
            structItem.DummyBool1 = false;
            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.IsDataBackup = structItem.IsDataBackup;
                this.SystemConfig1.IsLogin = structItem.IsLogin;
                this.SystemConfig1.IsPrintPerProductEnable = structItem.IsPrintPerProductEnable;
                this.SystemConfig1.IsExternalInputBuzzer = structItem.IsExternalInputBuzzer;
                this.SystemConfig1.IsExternalInputLamp = structItem.IsExternalInputLamp;
                this.SystemConfig1.IsAverageTracking = structItem.IsAverageTracking;

                this.SystemConfig1.EquipmentID = structItem.EquipmentID;
                this.SystemConfig1.DecimalPlaces = structItem.DecimalPlaces;
                this.SystemConfig1.ProductNumber = structItem.ProductNumber;
                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.CountingOutput1Mode = this.SystemConfig2.CountingOutput1Mode;
            structItem.CountingOutput1Number = this.SystemConfig2.CountingOutput1Number;
            structItem.IsCountingOutput1Continuous = this.SystemConfig2.IsCountingOutput1Continuous;
            structItem.IsCountingOutput1ConveyorStop = this.SystemConfig2.IsCountingOutput1ConveyorStop;
            structItem.IsCountingOutput1BuzzerOn = this.SystemConfig2.IsCountingOutput1BuzzerOn;
            structItem.IsCountingOutput1ExternalOutput = this.SystemConfig2.IsCountingOutput1ExternalOutput;

            structItem.CountingOutput2Mode = this.SystemConfig2.CountingOutput2Mode;
            structItem.CountingOutput2Number = this.SystemConfig2.CountingOutput2Number;
            structItem.IsCountingOutput2Continuous = this.SystemConfig2.IsCountingOutput2Continuous;
            structItem.IsCountingOutput2ConveyorStop = this.SystemConfig2.IsCountingOutput2ConveyorStop;
            structItem.IsCountingOutput2BuzzerOn = this.SystemConfig2.IsCountingOutput2BuzzerOn;
            structItem.IsCountingOutput2ExternalOutput = this.SystemConfig2.IsCountingOutput2ExternalOutput;

            structItem.IsRFIDSpeedwayR420 = this.SystemConfig2.IsRFIDSpeedwayR420;
            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.MULTiJETSlaveAddressEthernet = this.SystemConfig2.MULTiJETSlaveAddressEthernet;
            structItem.MULTiJETSlaveAddressCOM1 = this.SystemConfig2.MULTiJETSlaveAddressCOM1;
            structItem.MULTiJETSlaveAddressCOM3 = this.SystemConfig2.MULTiJETSlaveAddressCOM3;
            structItem.MULTiJETSlaveAddressCOM4 = this.SystemConfig2.MULTiJETSlaveAddressCOM4;
            structItem.ModbusTCPSelectFunction = this.SystemConfig2.ModbusTCPSelectFunction;
            structItem.EthernetLocalPort = this.SystemConfig2.EthernetLocalPort;
            structItem.CommunicationControlCharacter = this.SystemConfig2.CommunicationControlCharacter;
            structItem.Barcode = this.SystemConfig2.Barcode;
            structItem.AverageTracking = this.SystemConfig2.AverageTrackingCount;
            structItem.ModbusRTUSelectFunction = this.SystemConfig2.ModbusRTUSelectFunction;
            structItem.ModbusRTUSlaveIDCOM1 = this.SystemConfig2.ModbusSlaveIDCOM1;
            structItem.ModbusRTUSlaveIDCOM3 = this.SystemConfig2.ModbusSlaveIDCOM3;
            structItem.ModbusRTUSlaveIDCOM4 = this.SystemConfig2.ModbusSlaveIDCOM4;
            structItem.Alarm1BuzzerTime = this.SystemConfig2.CountingOutput1BuzzerTime;
            structItem.Alarm2BuzzerTime = this.SystemConfig2.CountingOutput2BuzzerTime;
            structItem.SortingPointLength = this.SystemConfig2.SortingPointLength;
            structItem.ConveyorLength = this.SystemConfig2.ConveyorLength;
            structItem.MarkoprintLineNumberEthernet = this.SystemConfig2.MarkoprintLineNumberEthernet;
            structItem.HitachiRoomNumberEthernet = this.SystemConfig2.HitachiRoomNumberEthernet;
            structItem.EthernetHostPort = this.SystemConfig2.EthernetHostPort;
            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.EntryNotDetectedWeight = this.SystemConfig2.EntryNotDetectedWeight;
            structItem.RFID_R420_EPC_Filter = this.SystemConfig2.RFID_R420_EPC_Filter;
            structItem.RFID_R420_BARCD = this.SystemConfig2.RFID_R420_BARCD;
            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.CountingOutput1Mode = item.CountingOutput1Mode;
            structItem.CountingOutput1Number = item.CountingOutput1Number;
            structItem.IsCountingOutput1Continuous = item.IsCountingOutput1Continuous;
            structItem.IsCountingOutput1ConveyorStop = item.IsCountingOutput1ConveyorStop;
            structItem.IsCountingOutput1BuzzerOn = item.IsCountingOutput1BuzzerOn;
            structItem.IsCountingOutput1ExternalOutput = item.IsCountingOutput1ExternalOutput;

            structItem.CountingOutput2Mode = item.CountingOutput2Mode;
            structItem.CountingOutput2Number = item.CountingOutput2Number;
            structItem.IsCountingOutput2Continuous = item.IsCountingOutput2Continuous;
            structItem.IsCountingOutput2ConveyorStop = item.IsCountingOutput2ConveyorStop;
            structItem.IsCountingOutput2BuzzerOn = item.IsCountingOutput2BuzzerOn;
            structItem.IsCountingOutput2ExternalOutput = item.IsCountingOutput2ExternalOutput;

            structItem.IsRFIDSpeedwayR420 = item.IsRFIDSpeedwayR420;
            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.MULTiJETSlaveAddressEthernet = item.MULTiJETSlaveAddressEthernet;
            structItem.MULTiJETSlaveAddressCOM1 = item.MULTiJETSlaveAddressCOM1;
            structItem.MULTiJETSlaveAddressCOM3 = item.MULTiJETSlaveAddressCOM3;
            structItem.MULTiJETSlaveAddressCOM4 = item.MULTiJETSlaveAddressCOM4;
            structItem.ModbusTCPSelectFunction = item.ModbusTCPSelectFunction;
            structItem.EthernetLocalPort = item.EthernetLocalPort;
            structItem.CommunicationControlCharacter = item.CommunicationControlCharacter;
            structItem.Barcode = item.Barcode;
            structItem.AverageTracking = item.AverageTrackingCount;
            structItem.ModbusRTUSelectFunction = item.ModbusRTUSelectFunction;
            structItem.ModbusRTUSlaveIDCOM1 = item.ModbusSlaveIDCOM1;
            structItem.ModbusRTUSlaveIDCOM3 = item.ModbusSlaveIDCOM3;
            structItem.ModbusRTUSlaveIDCOM4 = item.ModbusSlaveIDCOM4;
            structItem.Alarm1BuzzerTime = item.CountingOutput1BuzzerTime;
            structItem.Alarm2BuzzerTime = item.CountingOutput2BuzzerTime;
            structItem.SortingPointLength = item.SortingPointLength;
            structItem.ConveyorLength = item.ConveyorLength;
            structItem.MarkoprintLineNumberEthernet = item.MarkoprintLineNumberEthernet;
            structItem.HitachiRoomNumberEthernet = item.HitachiRoomNumberEthernet;
            structItem.EthernetHostPort = item.EthernetHostPort;
            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.EntryNotDetectedWeight = item.EntryNotDetectedWeight;
            structItem.RFID_R420_EPC_Filter = item.RFID_R420_EPC_Filter;
            structItem.RFID_R420_BARCD = item.RFID_R420_BARCD;
            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.CountingOutput1Mode;
                this.SystemConfig2.CountingOutput1Number = structItem.CountingOutput1Number;
                this.SystemConfig2.CountingOutput1BuzzerTime = structItem.Alarm1BuzzerTime;
                this.SystemConfig2.IsCountingOutput1Continuous = structItem.IsCountingOutput1Continuous;
                this.SystemConfig2.IsCountingOutput1ConveyorStop = structItem.IsCountingOutput1ConveyorStop;
                this.SystemConfig2.IsCountingOutput1BuzzerOn = structItem.IsCountingOutput1BuzzerOn;
                this.SystemConfig2.IsCountingOutput1ExternalOutput = structItem.IsCountingOutput1ExternalOutput;

                this.SystemConfig2.CountingOutput2Mode = structItem.CountingOutput2Mode;
                this.SystemConfig2.CountingOutput2Number = structItem.CountingOutput2Number;
                this.SystemConfig2.CountingOutput2BuzzerTime = structItem.Alarm2BuzzerTime;
                this.SystemConfig2.IsCountingOutput2Continuous = structItem.IsCountingOutput2Continuous;
                this.SystemConfig2.IsCountingOutput2ConveyorStop = structItem.IsCountingOutput2ConveyorStop;
                this.SystemConfig2.IsCountingOutput2BuzzerOn = structItem.IsCountingOutput2BuzzerOn;
                this.SystemConfig2.IsCountingOutput2ExternalOutput = structItem.IsCountingOutput2ExternalOutput;

                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.FileNameExtension = structItem.FileNameExtension;

                this.SystemConfig2.EthernetHostPort = structItem.EthernetHostPort;
                this.SystemConfig2.EthernetCommMode = structItem.EthernetCommMode;
                this.SystemConfig2.EthernetOperationMode = structItem.EthernetOperationMode;

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

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

                this.SystemConfig2.Barcode = structItem.Barcode;
                this.SystemConfig2.CommunicationControlCharacter = structItem.CommunicationControlCharacter;

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

                this.SystemConfig2.IsRFIDSpeedwayR420 = structItem.IsRFIDSpeedwayR420;

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

                this.SystemConfig2.ModbusTCPSelectFunction = structItem.ModbusTCPSelectFunction;

                this.SystemConfig2.EntryNotDetectedWeight = structItem.EntryNotDetectedWeight;

                this.SystemConfig2.RFID_R420_BARCD = structItem.RFID_R420_BARCD;
                this.SystemConfig2.RFID_R420_EPC_Filter = structItem.RFID_R420_EPC_Filter;
                this.SystemConfig2.AverageTrackingCount = structItem.AverageTracking;

                this.SystemConfig2.MULTiJETSlaveAddressCOM1 = structItem.MULTiJETSlaveAddressCOM1;
                this.SystemConfig2.MULTiJETSlaveAddressCOM3 = structItem.MULTiJETSlaveAddressCOM3;
                this.SystemConfig2.MULTiJETSlaveAddressCOM4 = structItem.MULTiJETSlaveAddressCOM4;
                this.SystemConfig2.MULTiJETSlaveAddressEthernet = structItem.MULTiJETSlaveAddressEthernet;
            }
            catch
            {
                this.smartFileIO.Open(this.BufferSmartUart);

                this.CreateSystemConfigurationFile2();
                this.CreateSystemConfigurationFile3();
            }
            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.IsCountingOutputCrossMode = this.SystemConfig3.IsCountingOutputCrossMode;
            structItem.DummyBool20 = false;
            structItem.IsStartStopLog = this.SystemConfig3.IsStartStopLog;
            structItem.IsEthernetPingTimer = this.SystemConfig3.IsEthernetPingTimer;
            structItem.IsCharToFillZeroEthernet = this.SystemConfig3.IsCharToFillZeroEthernet;
            structItem.IsTransmitWhenPassEthernet = this.SystemConfig3.IsTransmitWhenPassEthernet;
            structItem.IsCharToFillZeroCOM1 = this.SystemConfig3.IsTransmitWhenPassCOM1;
            structItem.IsTransmitWhenPassCOM1 = this.SystemConfig3.IsTransmitWhenPassCOM1;
            structItem.IsCharToFillZeroCOM3 = this.SystemConfig3.IsCharToFillZeroCOM3;
            structItem.IsTransmitWhenPassCOM3 = this.SystemConfig3.IsTransmitWhenPassCOM3;
            structItem.IsCharToFillZeroCOM4 = this.SystemConfig3.IsCharToFillZeroCOM4;
            structItem.IsTransmitWhenPassCOM4 = this.SystemConfig3.IsTransmitWhenPassCOM4;

            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.SensorErrorDetectingTime = this.SystemConfig3.SensorErrorDetectingTime;
            structItem.LOTExtractDataFromIndex = this.SystemConfig3.LOTExtractDataFromIndex;
            structItem.LOTExtractDataToIndex = this.SystemConfig3.LOTExtractDataToIndex;
            structItem.ModbusTCPStartAddress = this.SystemConfig3.ModbusTCPStartAddress;
            structItem.ModbusRTUStartAddressCOM1 = this.SystemConfig3.ModbusRTUStartAddressCOM1;
            structItem.ModbusRTUStartAddressCOM3 = this.SystemConfig3.ModbusRTUStartAddressCOM3;
            structItem.ModbusRTUStartAddressCOM4 = this.SystemConfig3.ModbusRTUStartAddressCOM4;

            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.IsCountingOutputCrossMode = item.IsCountingOutputCrossMode;
            structItem.DummyBool20 = false;
            structItem.IsStartStopLog = item.IsStartStopLog;
            structItem.IsEthernetPingTimer = item.IsEthernetPingTimer;
            structItem.IsCharToFillZeroEthernet = item.IsCharToFillZeroEthernet;
            structItem.IsTransmitWhenPassEthernet = item.IsTransmitWhenPassEthernet;
            structItem.IsCharToFillZeroCOM1 = item.IsCharToFillZeroCOM1;
            structItem.IsTransmitWhenPassCOM1 = item.IsTransmitWhenPassCOM1;
            structItem.IsCharToFillZeroCOM3 = item.IsCharToFillZeroCOM3;
            structItem.IsTransmitWhenPassCOM3 = item.IsTransmitWhenPassCOM3;
            structItem.IsCharToFillZeroCOM4 = item.IsCharToFillZeroCOM4;
            structItem.IsTransmitWhenPassCOM4 = item.IsTransmitWhenPassCOM4;

            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.SensorErrorDetectingTime = item.SensorErrorDetectingTime;
            structItem.LOTExtractDataFromIndex = item.LOTExtractDataFromIndex;
            structItem.LOTExtractDataToIndex = item.LOTExtractDataToIndex;
            structItem.ModbusTCPStartAddress = item.ModbusTCPStartAddress;
            structItem.ModbusRTUStartAddressCOM1 = item.ModbusRTUStartAddressCOM1;
            structItem.ModbusRTUStartAddressCOM3 = item.ModbusRTUStartAddressCOM3;
            structItem.ModbusRTUStartAddressCOM4 = item.ModbusRTUStartAddressCOM4;

            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.IsCountingOutputCrossMode = structItem.IsCountingOutputCrossMode;
                this.SystemConfig3.IsStartStopLog = structItem.IsStartStopLog;
                this.SystemConfig3.IsEthernetPingTimer = structItem.IsEthernetPingTimer;
                this.SystemConfig3.IsCharToFillZeroEthernet = structItem.IsCharToFillZeroEthernet;
                this.SystemConfig3.IsTransmitWhenPassEthernet = structItem.IsTransmitWhenPassEthernet;
                this.SystemConfig3.IsCharToFillZeroCOM1 = structItem.IsCharToFillZeroCOM1;
                this.SystemConfig3.IsTransmitWhenPassCOM1 = structItem.IsTransmitWhenPassCOM1;
                this.SystemConfig3.IsCharToFillZeroCOM3 = structItem.IsCharToFillZeroCOM3;
                this.SystemConfig3.IsTransmitWhenPassCOM3 = structItem.IsTransmitWhenPassCOM3;
                this.SystemConfig3.IsCharToFillZeroCOM4 = structItem.IsCharToFillZeroCOM4;
                this.SystemConfig3.IsTransmitWhenPassCOM4 = structItem.IsTransmitWhenPassCOM4;

                this.SystemConfig3.SensorErrorDetectingTime = structItem.SensorErrorDetectingTime;
                this.SystemConfig3.LOTExtractDataFromIndex = structItem.LOTExtractDataFromIndex;
                this.SystemConfig3.LOTExtractDataToIndex = structItem.LOTExtractDataToIndex;
                this.SystemConfig3.ModbusTCPStartAddress = structItem.ModbusTCPStartAddress;
                this.SystemConfig3.ModbusRTUStartAddressCOM1 = structItem.ModbusRTUStartAddressCOM1;
                this.SystemConfig3.ModbusRTUStartAddressCOM3 = structItem.ModbusRTUStartAddressCOM3;
                this.SystemConfig3.ModbusRTUStartAddressCOM4 = structItem.ModbusRTUStartAddressCOM4;
            }
            catch
            {
                this.smartFileIO.Open(this.BufferSmartUart);
                this.CreateSystemConfigurationFile3();
            }
            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.SortingWhenNGLength.ToString()));  // 제품길이 이상 시 선별(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.SortingByProductNo));                    // 품번선별 여부(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.Inverter.ToString()));                       // 인버터 선택(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));      // OPT1_샘플링개수(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.OPT1DelayCount));          // OPT1_지연개수(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.OPT1PulseWidth));             // OPT1_펄스폭(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.OPT1IsWeightSetting));       // OPT1_범위설정사용여부(4)
            sb.Append(Helper.StringZeroFillDigits7(sItem.OPT1OverRange));             // OPT1_상한범위(7)
            sb.Append(Helper.StringZeroFillDigits7(sItem.OPT1UnderRange));           // OPT1_하한범위(7)
            sb.Append(Helper.StringZeroFillDigits4(sItem.OPT1Port));                     // OPT1_포트(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.OPT2Port));                     // OPT2_포트(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.OPT2DelayTime1));            // OPT2_지연시간1(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.OPT2DelayTime2));            // OPT2_지연시간2(4)
            sb.Append("0000000");                                                                     // Dummy1(7)                    
            sb.Append("0000000");                                                                    // Dummy2(7)
            sb.Append(Helper.StringZeroFillDigits4(sItem.OPT2ZeroZoneCycle));       // OPT2_영점실행주기(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.OPT2ZeroZoneCount));      // OPT2_영점실행개수(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.ExternalOut9Mode.ToString()));              // 외부출력9모드(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.ExternalOut9DelayTime.ToString()));         // 외부출력9지연(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.ExternalOut9RunTime.ToString()));          // 외부출력9동작(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.ExternalOut10Mode.ToString()));            // 외부출력10모드(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.ExternalOut10DelayTime.ToString()));       // 외부출력10지연(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.ExternalOut10RunTime.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(sItem.LCDAutoZero1Time));            // 자동영점1시간(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.LCDAutoZero1Range));          // 자동영점1범위(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.LCDAutoZero1Variate));         // 자동영점1변량(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.LCDAutoZero1Mode));           // 자동영점1모드(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.LCDAutoZero2Mode));           // 자동영점2모드(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.LCDAutoZero2Time));            // 자동영점2시간(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.LCDAutoZero2Range));          // 자동영점2범위(4)
            sb.Append(Helper.StringZeroFillDigits4(sItem.LCDAutoZero2Variate));         // 자동영점2변량(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)

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

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

            pItem = this.CollectionProductItem[995];
            jItem = this.CollectionJudgmentItem[995];
            sb.Append(Helper.StringZeroFillDigits4(jItem.Sorter1DelayTime.ToString()));                          // 선별부A 지연시간(4)                    
            sb.Append(Helper.StringZeroFillDigits4((Convert.ToInt32(this.SystemConfig2.IsGroup1UsingRandomMode)).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];
            jItem = this.CollectionJudgmentItem[996];
            sb.Append(Helper.StringZeroFillDigits4(jItem.Sorter1DelayTime.ToString()));                          // 선별부A 지연시간(4)                    
            sb.Append(Helper.StringZeroFillDigits4((Convert.ToInt32(this.SystemConfig2.IsGroup2UsingRandomMode)).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];
            jItem = this.CollectionJudgmentItem[997];
            sb.Append(Helper.StringZeroFillDigits4(jItem.Sorter1DelayTime.ToString()));                          // 선별부A 지연시간(4)                    
            sb.Append(Helper.StringZeroFillDigits4((Convert.ToInt32(this.SystemConfig2.IsGroup3UsingRandomMode)).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];
            jItem = this.CollectionJudgmentItem[998];
            sb.Append(Helper.StringZeroFillDigits4(jItem.Sorter1DelayTime.ToString()));                          // 선별부A 지연시간(4)                    
            sb.Append(Helper.StringZeroFillDigits4((Convert.ToInt32(this.SystemConfig2.IsGroup4UsingRandomMode)).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];
            jItem = this.CollectionJudgmentItem[999];
            sb.Append(Helper.StringZeroFillDigits4(jItem.Sorter1DelayTime.ToString()));                          // 선별부A 지연시간(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(Helper.StringZeroFillDigits7(this.SystemConfig2.EntryNotDetectedWeight)); // 제품진입미감지(7)
            sb.Append("0000000");                                                                                   // Dummy2(7)
            sb.Append(Helper.StringZeroFillDigits4(pItem.SensingTime));                                 // 센서검출시간(4)
            sb.Append(Helper.StringZeroFillDigits4(pItem.Sorting));                                      // 품번선별여부(4)
            sb.Append("0000");                                                                                      // Dummy5(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(this.SystemConfig3.IsCharToFillZeroCOM1, "200" + temp));
            if (this.SystemConfig1.SerialCOM3Mode == 14)
                this.TransferSerialCOM3(this.Transfer_14_OPT1(this.SystemConfig3.IsCharToFillZeroCOM1, "200" + temp));
            if (this.SystemConfig1.SerialCOM4Mode == 14)
                this.TransferSerialCOM4(this.Transfer_14_OPT1(this.SystemConfig3.IsCharToFillZeroCOM1, "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());

            // V8.0.0부터 Dispenser 지연시간 품목별 관리
            if (int.Parse(this.CurrentSystemParameter1.OptionBoard) == 2)
            {
                this.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.OPT2DelayTime1,
                    Helper.StringZeroFillDigits4(pItem.DispenserDelayTime1));
                this.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.OPT2DelayTime2,
                    Helper.StringZeroFillDigits4(pItem.DispenserDelayTime2));
            }
        }
        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("0000");                                                                                   // Dummy1(4)
            sb.Append("0000000");                                                                                   // Dummy1(7)
            sb.Append("0000000");                                                                                   // Dummy2(7)
            sb.Append("0000000");                                                                                   // Dummy3(7)
            sb.Append("0000000");                                                                                   // Dummy4(7)

            this.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.ParameterCount, 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.EquipmentType = this.CurrentSystemParameter1.EquipmentType;

            structItem.SortingWhenNGLength = this.CurrentSystemParameter1.SortingWhenNGLength;
            structItem.SortingByProductNo = this.CurrentSystemParameter1.SortingByProductNo;
            structItem.Inverter = this.CurrentSystemParameter1.Inverter;

            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.EquipmentType = item.EquipmentType;

            structItem.SortingWhenNGLength = item.SortingWhenNGLength;
            structItem.SortingByProductNo = item.SortingByProductNo;
            structItem.Inverter = item.Inverter;

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

                pItem.SortingWhenNGLength = structItem.SortingWhenNGLength;
                pItem.SortingByProductNo = structItem.SortingByProductNo;
                pItem.Inverter = structItem.Inverter;
            }
            catch
            {
                DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig1.Language);
                myMsg.ShowDialog();

                this.smartFileIO.Close();
            }

            this.smartFileIO.Close();
        }
        public bool CheckSystemParameter1(int num)
        {
            bool check = false;

            this.CollectionInput.Clear();
            this.CollectionInput.Add(this.CurrentSystemParameter1.PI2);
            this.CollectionInput.Add(this.CurrentSystemParameter1.PI3);
            this.CollectionInput.Add(this.CurrentSystemParameter1.PI4);
            this.CollectionInput.Add(this.CurrentSystemParameter1.PI5);
            this.CollectionInput.Add(this.CurrentSystemParameter1.PI6);
            this.CollectionInput.Add(this.CurrentSystemParameter1.PI7);
            this.CollectionInput.Add(this.CurrentSystemParameter1.PI8);

            switch (num)
            {
                case (int)DataStore.ExternalInputMode.IN1_Metal:
                    for (int i = 0; i < this.CollectionInput.Count; i++)
                        if (this.CollectionInput[i] == (int)DataStore.ExternalInputMode.IN1_Metal)
                            check = true;
                    break;
                case (int)DataStore.ExternalInputMode.IN2_START:
                    for (int i = 0; i < this.CollectionInput.Count; i++)
                        if (this.CollectionInput[i] == (int)DataStore.ExternalInputMode.IN2_START)
                            check = true;
                    break;
                case (int)DataStore.ExternalInputMode.IN3_STOP:
                    for (int i = 0; i < this.CollectionInput.Count; i++)
                        if (this.CollectionInput[i] == (int)DataStore.ExternalInputMode.IN3_STOP)
                            check = true;
                    break;
                case (int)DataStore.ExternalInputMode.IN4_DischargeSorterA:
                    for (int i = 0; i < this.CollectionInput.Count; i++)
                        if (this.CollectionInput[i] == (int)DataStore.ExternalInputMode.IN4_DischargeSorterA)
                            check = true;
                    break;
                case (int)DataStore.ExternalInputMode.IN5_Air:
                    for (int i = 0; i < this.CollectionInput.Count; i++)
                        if (this.CollectionInput[i] == (int)DataStore.ExternalInputMode.IN5_Air)
                            check = true;
                    break;
                case (int)DataStore.ExternalInputMode.IN6_Door:
                    for (int i = 0; i < this.CollectionInput.Count; i++)
                        if (this.CollectionInput[i] == (int)DataStore.ExternalInputMode.IN6_Door)
                            check = true;
                    break;
                case (int)DataStore.ExternalInputMode.IN7_Stopper:
                    for (int i = 0; i < this.CollectionInput.Count; i++)
                        if (this.CollectionInput[i] == (int)DataStore.ExternalInputMode.IN7_Stopper)
                            check = true;
                    break;
                case (int)DataStore.ExternalInputMode.IN8_Windproof:
                    for (int i = 0; i < this.CollectionInput.Count; i++)
                        if (this.CollectionInput[i] == (int)DataStore.ExternalInputMode.IN8_Windproof)
                            check = true;
                    break;
                case (int)DataStore.ExternalInputMode.IN9_ExternalOperation:
                    for (int i = 0; i < this.CollectionInput.Count; i++)
                        if (this.CollectionInput[i] == (int)DataStore.ExternalInputMode.IN9_ExternalOperation)
                            check = true;
                    break;
                case (int)DataStore.ExternalInputMode.IN10_DispensorEntry1:
                    for (int i = 0; i < this.CollectionInput.Count; i++)
                        if (this.CollectionInput[i] == (int)DataStore.ExternalInputMode.IN10_DispensorEntry1)
                            check = true;
                    break;
                case (int)DataStore.ExternalInputMode.IN11_DispensorEntry2:
                    for (int i = 0; i < this.CollectionInput.Count; i++)
                        if (this.CollectionInput[i] == (int)DataStore.ExternalInputMode.IN11_DispensorEntry2)
                            check = true;
                    break;
                case (int)DataStore.ExternalInputMode.IN12_StackUp:
                    for (int i = 0; i < this.CollectionInput.Count; i++)
                        if (this.CollectionInput[i] == (int)DataStore.ExternalInputMode.IN12_StackUp)
                            check = true;
                    break;
                case (int)DataStore.ExternalInputMode.IN13_ExNG1:
                    for (int i = 0; i < this.CollectionInput.Count; i++)
                        if (this.CollectionInput[i] == (int)DataStore.ExternalInputMode.IN13_ExNG1)
                            check = true;
                    break;
                case (int)DataStore.ExternalInputMode.IN14_ExNG2:
                    for (int i = 0; i < this.CollectionInput.Count; i++)
                        if (this.CollectionInput[i] == (int)DataStore.ExternalInputMode.IN14_ExNG2)
                            check = true;
                    break;
                case (int)DataStore.ExternalInputMode.IN15_ExInputCheck:
                    for (int i = 0; i < this.CollectionInput.Count; i++)
                        if (this.CollectionInput[i] == (int)DataStore.ExternalInputMode.IN15_ExInputCheck)
                            check = true;
                    break;
                case (int)DataStore.ExternalInputMode.IN16_DischargeSorterB:
                    for (int i = 0; i < this.CollectionInput.Count; i++)
                        if (this.CollectionInput[i] == (int)DataStore.ExternalInputMode.IN16_DischargeSorterB)
                            check = true;
                    break;
                default:
                    check = false;
                    break;
            }

            return check;
        }
        #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.OPT2ZeroZoneCycle = this.CurrentSystemParameter2.OPT2ZeroZoneCycle;
            structItem.OPT2ZeroZoneCount = this.CurrentSystemParameter2.OPT2ZeroZoneCount;
            structItem.Dummy1 = "0";
            structItem.Dummy2 = "0";
            structItem.Dummy3 = "0";
            structItem.Dummy4 = "0";
            structItem.Dummy5 = "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.OPT2ZeroZoneCycle = item.OPT2ZeroZoneCycle;
            structItem.OPT2ZeroZoneCount = item.OPT2ZeroZoneCount;
            structItem.Dummy1 = "0";
            structItem.Dummy2 = "0";
            structItem.Dummy3 = "0";
            structItem.Dummy4 = "0";
            structItem.Dummy5 = "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;
                pItem.OPT2ZeroZoneCycle = structItem.OPT2ZeroZoneCycle;
                pItem.OPT2ZeroZoneCount = structItem.OPT2ZeroZoneCount;
            }
            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.ExternalOut9Mode = this.CurrentSystemParameter3.ExternalOut9Mode;
            structItem.ExternalOut9DelayTime = this.CurrentSystemParameter3.ExternalOut9DelayTime;
            structItem.ExternalOut9RunTime = this.CurrentSystemParameter3.ExternalOut9RunTime;

            structItem.ExternalOut10Mode = this.CurrentSystemParameter3.ExternalOut10Mode;
            structItem.ExternalOut10DelayTime = this.CurrentSystemParameter3.ExternalOut10DelayTime;
            structItem.ExternalOut10RunTime = this.CurrentSystemParameter3.ExternalOut10RunTime;

            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.ExternalOut9Mode = item.ExternalOut9Mode;
            structItem.ExternalOut9DelayTime = item.ExternalOut9DelayTime;
            structItem.ExternalOut9RunTime = item.ExternalOut9RunTime;

            structItem.ExternalOut10Mode = item.ExternalOut10Mode;
            structItem.ExternalOut10DelayTime = item.ExternalOut10DelayTime;
            structItem.ExternalOut10RunTime = item.ExternalOut10RunTime;

            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.ExternalOut9Mode = structItem.ExternalOut9Mode;
                pItem.ExternalOut9DelayTime = structItem.ExternalOut9DelayTime;
                pItem.ExternalOut9RunTime = structItem.ExternalOut9RunTime;

                pItem.ExternalOut10Mode = structItem.ExternalOut10Mode;
                pItem.ExternalOut10DelayTime = structItem.ExternalOut10DelayTime;
                pItem.ExternalOut10RunTime = structItem.ExternalOut10RunTime;
            }
            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.AutoZero1UserSettingRange = this.CurrentSystemParameter4.LCDAutoZero1Range;
            structItem.AutoZero1UserSettingTime = this.CurrentSystemParameter4.LCDAutoZero1Time;
            structItem.AutoZero1UserSettingVariate = this.CurrentSystemParameter4.LCDAutoZero1Variate;
            structItem.AutoZero1Mode = this.CurrentSystemParameter4.LCDAutoZero1Mode;

            structItem.AutoZero2UserSettingRange = this.CurrentSystemParameter4.LCDAutoZero2Range;
            structItem.AutoZero2UserSettingTime = this.CurrentSystemParameter4.LCDAutoZero2Time;
            structItem.AutoZero2UserSettingVariate = this.CurrentSystemParameter4.LCDAutoZero2Variate;
            structItem.AutoZero2Mode = this.CurrentSystemParameter4.LCDAutoZero2Mode;

            structItem.Dummy1 = "0";
            structItem.Dummy2 = "0";
            structItem.Dummy3 = "0";
            structItem.Dummy4 = "0";
            structItem.Dummy5 = "0";
            structItem.Dummy6 = "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.AutoZero1UserSettingRange = item.LCDAutoZero1Range;
            structItem.AutoZero1UserSettingTime = item.LCDAutoZero1Time;
            structItem.AutoZero1UserSettingVariate = item.LCDAutoZero1Variate;
            structItem.AutoZero1Mode = item.LCDAutoZero1Mode;

            structItem.AutoZero2UserSettingRange = item.LCDAutoZero2Range;
            structItem.AutoZero2UserSettingTime = item.LCDAutoZero2Time;
            structItem.AutoZero2UserSettingVariate = item.LCDAutoZero2Variate;
            structItem.AutoZero2Mode = item.LCDAutoZero2Mode;

            structItem.Dummy1 = "0";
            structItem.Dummy2 = "0";
            structItem.Dummy3 = "0";
            structItem.Dummy4 = "0";
            structItem.Dummy5 = "0";
            structItem.Dummy6 = "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.LCDAutoZero1Range = structItem.AutoZero1UserSettingRange;
                pItem.LCDAutoZero1Time = structItem.AutoZero1UserSettingTime;
                pItem.LCDAutoZero1Variate = structItem.AutoZero1UserSettingVariate;
                pItem.LCDAutoZero1Mode = structItem.AutoZero1Mode;

                pItem.LCDAutoZero2Range = structItem.AutoZero2UserSettingRange;
                pItem.LCDAutoZero2Time = structItem.AutoZero2UserSettingTime;
                pItem.LCDAutoZero2Variate = structItem.AutoZero2UserSettingVariate;
                pItem.LCDAutoZero2Mode = structItem.AutoZero2Mode;
            }
            catch
            {
                DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig1.Language);
                myMsg.ShowDialog();

                this.smartFileIO.Close();
            }

            this.smartFileIO.Close();
        }
        #endregion
        #region SystemParameter5
        private void CreateSystemParameter5File()
        {
            StructSystemParameter5 structItem;

            this.CurrentSystemParameter5.Initialization();

            structItem.PhotoBBuzzer = this.CurrentSystemParameter5.PhotoBBuzzer;
            structItem.PIN3Buzzer = this.CurrentSystemParameter5.PIN3Buzzer;
            structItem.PIN4Buzzer = this.CurrentSystemParameter5.PIN4Buzzer;
            structItem.PIN5Buzzer = this.CurrentSystemParameter5.PIN5Buzzer;
            structItem.PIN6Buzzer = this.CurrentSystemParameter5.PIN6Buzzer;
            structItem.PIN7Buzzer = this.CurrentSystemParameter5.PIN7Buzzer;
            structItem.PIN8Buzzer = this.CurrentSystemParameter5.PIN8Buzzer;

            structItem.PhotoBLamp = this.CurrentSystemParameter5.PhotoBLamp;
            structItem.PIN3Lamp = this.CurrentSystemParameter5.PIN3Lamp;
            structItem.PIN4Lamp = this.CurrentSystemParameter5.PIN4Lamp;
            structItem.PIN5Lamp = this.CurrentSystemParameter5.PIN5Lamp;
            structItem.PIN6Lamp = this.CurrentSystemParameter5.PIN6Lamp;
            structItem.PIN7Lamp = this.CurrentSystemParameter5.PIN7Lamp;
            structItem.PIN8Lamp = this.CurrentSystemParameter5.PIN8Lamp;

            structItem.PhotoBConveyorStop = this.CurrentSystemParameter5.PhotoBConveyorStop;
            structItem.PIN3ConveyorStop = this.CurrentSystemParameter5.PIN3ConveyorStop;
            structItem.PIN4ConveyorStop = this.CurrentSystemParameter5.PIN4ConveyorStop;
            structItem.PIN5ConveyorStop = this.CurrentSystemParameter5.PIN5ConveyorStop;
            structItem.PIN6ConveyorStop = this.CurrentSystemParameter5.PIN6ConveyorStop;
            structItem.PIN7ConveyorStop = this.CurrentSystemParameter5.PIN7ConveyorStop;
            structItem.PIN8ConveyorStop = this.CurrentSystemParameter5.PIN8ConveyorStop;

            structItem.DummyBool1 = this.CurrentSystemParameter5.DummyBool1;
            structItem.DummyBool2 = this.CurrentSystemParameter5.DummyBool2;
            structItem.DummyBool3 = this.CurrentSystemParameter5.DummyBool3;
            structItem.DummyBool4 = this.CurrentSystemParameter5.DummyBool4;
            structItem.DummyBool5 = this.CurrentSystemParameter5.DummyBool5;
            structItem.DummyBool6 = this.CurrentSystemParameter5.DummyBool6;
            structItem.DummyBool7 = this.CurrentSystemParameter5.DummyBool7;
            structItem.DummyBool8 = this.CurrentSystemParameter5.DummyBool8;
            structItem.DummyBool9 = this.CurrentSystemParameter5.DummyBool9;
            structItem.DummyBool10 = this.CurrentSystemParameter5.DummyBool10;
            structItem.DummyBool11 = this.CurrentSystemParameter5.DummyBool11;
            structItem.DummyBool12 = this.CurrentSystemParameter5.DummyBool12;
            structItem.DummyBool13 = this.CurrentSystemParameter5.DummyBool13;
            structItem.DummyBool14 = this.CurrentSystemParameter5.DummyBool14;

            structItem.DummyInt1 = this.CurrentSystemParameter5.DummyInt1;
            structItem.DummyInt2 = this.CurrentSystemParameter5.DummyInt2;
            structItem.DummyInt3 = this.CurrentSystemParameter5.DummyInt3;
            structItem.DummyInt4 = this.CurrentSystemParameter5.DummyInt4;
            structItem.DummyInt5 = this.CurrentSystemParameter5.DummyInt5;
            structItem.DummyInt6 = this.CurrentSystemParameter5.DummyInt6;
            structItem.DummyInt7 = this.CurrentSystemParameter5.DummyInt7;
            structItem.DummyInt8 = this.CurrentSystemParameter5.DummyInt8;
            structItem.DummyInt9 = this.CurrentSystemParameter5.DummyInt9;
            structItem.DummyInt10 = this.CurrentSystemParameter5.DummyInt10;
            structItem.DummyInt11 = this.CurrentSystemParameter5.DummyInt11;
            structItem.DummyInt12 = this.CurrentSystemParameter5.DummyInt12;
            structItem.DummyInt13 = this.CurrentSystemParameter5.DummyInt13;
            structItem.DummyInt14 = this.CurrentSystemParameter5.DummyInt14;

            structItem.Dummy1 = this.CurrentSystemParameter5.Dummy1;
            structItem.Dummy2 = this.CurrentSystemParameter5.Dummy2;
            structItem.Dummy3 = this.CurrentSystemParameter5.Dummy3;
            structItem.Dummy4 = this.CurrentSystemParameter5.Dummy4;
            structItem.Dummy5 = this.CurrentSystemParameter5.Dummy5;
            structItem.Dummy6 = this.CurrentSystemParameter5.Dummy6;
            structItem.Dummy7 = this.CurrentSystemParameter5.Dummy7;

            this.smartFileIO.WriteStructure(structItem, 0);
        }
        public void SaveSystemParameter5File(SystemParameter5 item)
        {
            string fullFilePath = "";
            bool fileCheck = false;
            StructSystemParameter5 structItem;

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

            structItem.PhotoBBuzzer = item.PhotoBBuzzer;
            structItem.PIN3Buzzer = item.PIN3Buzzer;
            structItem.PIN4Buzzer = item.PIN4Buzzer;
            structItem.PIN5Buzzer = item.PIN5Buzzer;
            structItem.PIN6Buzzer = item.PIN6Buzzer;
            structItem.PIN7Buzzer = item.PIN7Buzzer;
            structItem.PIN8Buzzer = item.PIN8Buzzer;

            structItem.PhotoBLamp = item.PhotoBLamp;
            structItem.PIN3Lamp = item.PIN3Lamp;
            structItem.PIN4Lamp = item.PIN4Lamp;
            structItem.PIN5Lamp = item.PIN5Lamp;
            structItem.PIN6Lamp = item.PIN6Lamp;
            structItem.PIN7Lamp = item.PIN7Lamp;
            structItem.PIN8Lamp = item.PIN8Lamp;

            structItem.PhotoBConveyorStop = item.PhotoBConveyorStop;
            structItem.PIN3ConveyorStop = item.PIN3ConveyorStop;
            structItem.PIN4ConveyorStop = item.PIN4ConveyorStop;
            structItem.PIN5ConveyorStop = item.PIN5ConveyorStop;
            structItem.PIN6ConveyorStop = item.PIN6ConveyorStop;
            structItem.PIN7ConveyorStop = item.PIN7ConveyorStop;
            structItem.PIN8ConveyorStop = item.PIN8ConveyorStop;

            structItem.DummyBool1 = item.DummyBool1;
            structItem.DummyBool2 = item.DummyBool2;
            structItem.DummyBool3 = item.DummyBool3;
            structItem.DummyBool4 = item.DummyBool4;
            structItem.DummyBool5 = item.DummyBool5;
            structItem.DummyBool6 = item.DummyBool6;
            structItem.DummyBool7 = item.DummyBool7;
            structItem.DummyBool8 = item.DummyBool8;
            structItem.DummyBool9 = item.DummyBool9;
            structItem.DummyBool10 = item.DummyBool10;
            structItem.DummyBool11 = item.DummyBool11;
            structItem.DummyBool12 = item.DummyBool12;
            structItem.DummyBool13 = item.DummyBool13;
            structItem.DummyBool14 = item.DummyBool14;

            structItem.DummyInt1 = item.DummyInt1;
            structItem.DummyInt2 = item.DummyInt2;
            structItem.DummyInt3 = item.DummyInt3;
            structItem.DummyInt4 = item.DummyInt4;
            structItem.DummyInt5 = item.DummyInt5;
            structItem.DummyInt6 = item.DummyInt6;
            structItem.DummyInt7 = item.DummyInt7;
            structItem.DummyInt8 = item.DummyInt8;
            structItem.DummyInt9 = item.DummyInt9;
            structItem.DummyInt10 = item.DummyInt10;
            structItem.DummyInt11 = item.DummyInt11;
            structItem.DummyInt12 = item.DummyInt12;
            structItem.DummyInt13 = item.DummyInt13;
            structItem.DummyInt14 = item.DummyInt14;

            structItem.Dummy1 = item.Dummy1;
            structItem.Dummy2 = item.Dummy2;
            structItem.Dummy3 = item.Dummy3;
            structItem.Dummy4 = item.Dummy4;
            structItem.Dummy5 = item.Dummy5;
            structItem.Dummy6 = item.Dummy6;
            structItem.Dummy7 = item.Dummy7;

            this.smartFileIO.WriteStructure(structItem, 0);
            this.smartFileIO.Close();
        }
        public void LoadSystemParameter5File(ref SystemParameter5 pItem)
        {
            string fullFilePath = "";
            bool fileCheck = false;
            StructSystemParameter5 structItem;

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

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

                pItem.PhotoBBuzzer = structItem.PhotoBBuzzer;
                pItem.PIN3Buzzer = structItem.PIN3Buzzer;
                pItem.PIN4Buzzer = structItem.PIN4Buzzer;
                pItem.PIN5Buzzer = structItem.PIN5Buzzer;
                pItem.PIN6Buzzer = structItem.PIN6Buzzer;
                pItem.PIN7Buzzer = structItem.PIN7Buzzer;
                pItem.PIN8Buzzer = structItem.PIN8Buzzer;

                pItem.PhotoBLamp = structItem.PhotoBLamp;
                pItem.PIN3Lamp = structItem.PIN3Lamp;
                pItem.PIN4Lamp = structItem.PIN4Lamp;
                pItem.PIN5Lamp = structItem.PIN5Lamp;
                pItem.PIN6Lamp = structItem.PIN6Lamp;
                pItem.PIN7Lamp = structItem.PIN7Lamp;
                pItem.PIN8Lamp = structItem.PIN8Lamp;

                pItem.PhotoBConveyorStop = structItem.PhotoBConveyorStop;
                pItem.PIN3ConveyorStop = structItem.PIN3ConveyorStop;
                pItem.PIN4ConveyorStop = structItem.PIN4ConveyorStop;
                pItem.PIN5ConveyorStop = structItem.PIN5ConveyorStop;
                pItem.PIN6ConveyorStop = structItem.PIN6ConveyorStop;
                pItem.PIN7ConveyorStop = structItem.PIN7ConveyorStop;
                pItem.PIN8ConveyorStop = structItem.PIN8ConveyorStop;
            }
            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 < 995; 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.SensingTime = this.CurrentProductItem.SensingTime;
                structItem.DispenserDelayTime1 = this.CurrentProductItem.DispenserDelayTime1;
                structItem.DispenserDelayTime2 = this.CurrentProductItem.DispenserDelayTime2;
                structItem.Sorting = this.CurrentProductItem.Sorting;
                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";

                this.smartFileIO.WriteStructure_Begin(structItem, i);
            }
            this.CreateProductFileForRandomMode();
        }
        public void CreateProductFileForRandomMode()
        {
            StructProductItem structItem;

            for (int i = 0; i < 5; i++)
            {
                structItem.Number = i + 996;
                structItem.Name = string.Format("Product {0}", i + 996);
                structItem.LotNo = string.Format("Lot {0}", i + 996);
                structItem.PassRange = (1000 + (i * 1000)).ToString();
                structItem.OverRange = (1100 + (i * 1000)).ToString();
                structItem.UnderRange = (900 + (i * 1000)).ToString();
                structItem.TareRange = "0";
                structItem.SensingTime = "0";
                structItem.DispenserDelayTime1 = "200";
                structItem.DispenserDelayTime2 = "200";
                structItem.Sorting = "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";

                this.smartFileIO.WriteStructure_Begin(structItem, i + 995);
            }
            this.smartFileIO.WriteStructure_End();
        }
        public void CreateProductFileForRandomMode2()
        {
            StructProductItem structItem;

            for (int i = 0; i < 5; i++)
            {
                structItem.Number = i + 996;
                structItem.Name = string.Format("Product {0}", i + 996);
                structItem.LotNo = string.Format("Lot {0}", i + 996);
                structItem.PassRange = (10000 + (i * 10000)).ToString();
                structItem.OverRange = (11000 + (i * 10000)).ToString();
                structItem.UnderRange = (9000 + (i * 10000)).ToString();
                structItem.TareRange = "0";
                structItem.SensingTime = "0";
                structItem.DispenserDelayTime1 = "200";
                structItem.DispenserDelayTime2 = "200";
                structItem.Sorting = "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";

                this.smartFileIO.WriteStructure_Begin(structItem, i + 995);
            }
            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.SensingTime = item.SensingTime;
            structItem.DispenserDelayTime1 = item.DispenserDelayTime1;
            structItem.DispenserDelayTime2 = item.DispenserDelayTime2;
            structItem.Sorting = item.Sorting;
            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";

            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.SensingTime = items[i].SensingTime;
                structItem.DispenserDelayTime1 = items[i].DispenserDelayTime1;
                structItem.DispenserDelayTime2 = items[i].DispenserDelayTime2;
                structItem.Sorting = items[i].Sorting;
                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";

                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.SensingTime = structItem.SensingTime;
                item.DispenserDelayTime1 = structItem.DispenserDelayTime1;
                item.DispenserDelayTime2 = structItem.DispenserDelayTime2;
                item.Sorting = structItem.Sorting;
            }
            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].SensingTime = structProduct.SensingTime;
                        items[i].DispenserDelayTime1 = structProduct.DispenserDelayTime1;
                        items[i].DispenserDelayTime2 = structProduct.DispenserDelayTime2;
                        items[i].Sorting = structProduct.Sorting;
                    }
                }
            }
            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 Average Tracking File
        private void CreateAverageTrackingFile()
        {
            StructAverageTrackingItem structItem;

            this.CurrentAverageTrackingItem.Initialization();

            for (int i = 0; i < this.ProductCount; i++)
            {
                structItem.LimitOver = "99999";
                structItem.LimitUnder = "0";

                structItem.DummyString1 = "0";
                structItem.DummyString2 = "0";
                structItem.DummyString3 = "0";
                structItem.DummyString4 = "0";
                structItem.DummyString5 = "0";

                structItem.DummyInt1 = 0;
                structItem.DummyInt2 = 0;
                structItem.DummyInt3 = 0;
                structItem.DummyInt4 = 0;
                structItem.DummyInt5 = 0;

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

            fullFilePath = this.PathSDCardSystemFile2Folder + "AverageTracking.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.CreateAverageTrackingFile();
            }

            structItem.LimitOver = item.LimitOver;
            structItem.LimitUnder = item.LimitUnder;

            structItem.DummyInt1 = 0;
            structItem.DummyInt2 = 0;
            structItem.DummyInt3 = 0;
            structItem.DummyInt4 = 0;
            structItem.DummyInt5 = 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 LoadAverageTrackingFile(ref AverageTrackingItem item, int index)
        {
            bool fileCheck = false;
            string fullFilePath = "";
            StructAverageTrackingItem structItem;

            fullFilePath = this.PathSDCardSystemFile2Folder + "AverageTracking.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.CreateAverageTrackingFile();
            }

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

                item.LimitOver = structItem.LimitOver;
                item.LimitUnder = structItem.LimitUnder;
            }
            catch
            {
                DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig1.Language);
                myMsg.ShowDialog();

                this.smartFileIO.Close();
            }
            this.smartFileIO.Close();
        }
        private void LoadAverageTrackingFile(ref Collection<AverageTrackingItem> items)
        {
            bool fileCheck = false;
            string fullFilePath = "";
            StructAverageTrackingItem structItem;

            fullFilePath = this.PathSDCardSystemFile2Folder + "AverageTracking.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.CreateAverageTrackingFile();
            }

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

                        items[i].LimitOver = structItem.LimitOver;
                        items[i].LimitUnder = structItem.LimitUnder;
                    }
                }
            }
            catch
            {
                DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig1.Language);
                myMsg.ShowDialog();

                this.smartFileIO.Close();
            }
            this.smartFileIO.Close();
        }
        #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.DummyInt1 = 0;
                structItem.DummyInt2 = 0;
                structItem.DummyInt3 = 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.DummyInt1 = 0;
            structItem.DummyInt2 = 0;
            structItem.DummyInt3 = 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.DummyInt1 = 0;
                structItem.DummyInt2 = 0;
                structItem.DummyInt3 = 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();
            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.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();
        }
        public 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;
                    }
                }
            }
            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 CreateCounterFile1()
        {
            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.DummyInt1 = 0;
                structItem.DummyInt2 = 0;
                structItem.DummyInt3 = 0;
                structItem.DummyInt4 = 0;
                structItem.DummyInt5 = 0;

                this.smartFileIO.WriteStructure_Begin(structItem, i);
            }
            this.smartFileIO.WriteStructure_End();
        }
        private void CreateCounterFile2()
        {
            StructCounterItem2 structItem;
            WeightData item = new WeightData();
            item.ClearCount();

            for (int i = 0; i < 1000; i++)
            {
                structItem.SumOfSquaresDividedByCount = item.SumOfSquaresDivideByCount;
                structItem.PassMaxWeight = item.PassMaxWeight;
                structItem.PassMinWeight = item.PassMinWeight;
                structItem.ExNGSumWeight = item.ExNGSumWeight;

                structItem.DummyDouble1 = 0.0;
                structItem.DummyDouble2 = 0.0;
                structItem.DummyDouble3 = 0.0;
                structItem.DummyDouble4 = 0.0;
                structItem.DummyDouble5 = 0.0;
                structItem.DummyDouble6 = 0.0;
                structItem.DummyDouble7 = 0.0;
                structItem.DummyDouble8 = 0.0;
                structItem.DummyDouble9 = 0.0;
                structItem.DummyDouble10 = 0.0;
                structItem.DummyDouble11 = 0.0;
                structItem.DummyDouble12 = 0.0;
                structItem.DummyDouble13 = 0.0;
                structItem.DummyDouble14 = 0.0;
                structItem.DummyDouble15 = 0.0;
                structItem.DummyDouble16 = 0.0;
                structItem.DummyDouble17 = 0.0;
                structItem.DummyDouble18 = 0.0;
                structItem.DummyDouble19 = 0.0;
                structItem.DummyDouble20 = 0.0;

                structItem.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.DummyDateTime1 = DateTime.Now;
                structItem.DummyDateTime2 = DateTime.Now;

                structItem.DummyString1 = "0";
                structItem.DummyString2 = "0";
                structItem.DummyString3 = "0";
                structItem.DummyString4 = "0";
                structItem.DummyString5 = "0";
                structItem.DummyString6 = "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;
            StructCounterItem2 structItem2;

            #region counterItem
            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.CreateCounterFile1();
            }

            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.DummyInt1 = 0;
            structItem.DummyInt2 = 0;
            structItem.DummyInt3 = 0;
            structItem.DummyInt4 = 0;
            structItem.DummyInt5 = 0;

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

            this.smartFileIO.Close();
            #endregion

            #region counterItem2
            fullFilePath = this.PathSDCardSystemFile2Folder + "counterItem2.int";
            this.smartFileIO.FilePathName = fullFilePath;

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

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

                this.CreateCounterFile2();
            }

            structItem2.SumOfSquaresDividedByCount = item.SumOfSquaresDivideByCount;
            structItem2.PassMaxWeight = item.PassMaxWeight;
            structItem2.PassMinWeight = item.PassMinWeight;
            structItem2.ExNGSumWeight = item.ExNGSumWeight;

            structItem2.DummyDouble1 = 0.0;
            structItem2.DummyDouble2 = 0.0;
            structItem2.DummyDouble3 = 0.0;
            structItem2.DummyDouble4 = 0.0;
            structItem2.DummyDouble5 = 0.0;
            structItem2.DummyDouble6 = 0.0;
            structItem2.DummyDouble7 = 0.0;
            structItem2.DummyDouble8 = 0.0;
            structItem2.DummyDouble9 = 0.0;
            structItem2.DummyDouble10 = 0.0;
            structItem2.DummyDouble11 = 0.0;
            structItem2.DummyDouble12 = 0.0;
            structItem2.DummyDouble13 = 0.0;
            structItem2.DummyDouble14 = 0.0;
            structItem2.DummyDouble15 = 0.0;
            structItem2.DummyDouble16 = 0.0;
            structItem2.DummyDouble17 = 0.0;
            structItem2.DummyDouble18 = 0.0;
            structItem2.DummyDouble19 = 0.0;
            structItem2.DummyDouble20 = 0.0;

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

            structItem2.DummyDateTime1 = DateTime.Now;
            structItem2.DummyDateTime2 = DateTime.Now;

            structItem2.DummyString1 = "0";
            structItem2.DummyString2 = "0";
            structItem2.DummyString3 = "0";
            structItem2.DummyString4 = "0";
            structItem2.DummyString5 = "0";
            structItem2.DummyString6 = "0";

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

            this.smartFileIO.Close();
            #endregion
        }
        public void SaveCounterFile(Collection<WeightData> items)
        {
            string fullFilePath = "";
            bool fileCheck = false;
            StructCounterItem structItem;
            StructCounterItem2 structItem2;

            #region counterItem
            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.CreateCounterFile1();
            }

            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.DummyInt1 = 0;
                structItem.DummyInt2 = 0;
                structItem.DummyInt3 = 0;
                structItem.DummyInt4 = 0;
                structItem.DummyInt5 = 0;

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

            #region counterItem2
            fullFilePath = this.PathSDCardSystemFile2Folder + "counterItem2.int";
            this.smartFileIO.FilePathName = fullFilePath;

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

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

                this.CreateCounterFile2();
            }

            for (int i = 0; i < this.ProductCount; i++)
            {
                structItem2.SumOfSquaresDividedByCount = items[i].SumOfSquaresDivideByCount;
                structItem2.PassMaxWeight = items[i].PassMaxWeight;
                structItem2.PassMinWeight = items[i].PassMinWeight;
                structItem2.ExNGSumWeight = items[i].ExNGSumWeight;

                structItem2.DummyDouble1 = 0.0;
                structItem2.DummyDouble2 = 0.0;
                structItem2.DummyDouble3 = 0.0;
                structItem2.DummyDouble4 = 0.0;
                structItem2.DummyDouble5 = 0.0;
                structItem2.DummyDouble6 = 0.0;
                structItem2.DummyDouble7 = 0.0;
                structItem2.DummyDouble8 = 0.0;
                structItem2.DummyDouble9 = 0.0;
                structItem2.DummyDouble10 = 0.0;
                structItem2.DummyDouble11 = 0.0;
                structItem2.DummyDouble12 = 0.0;
                structItem2.DummyDouble13 = 0.0;
                structItem2.DummyDouble14 = 0.0;
                structItem2.DummyDouble15 = 0.0;
                structItem2.DummyDouble16 = 0.0;
                structItem2.DummyDouble17 = 0.0;
                structItem2.DummyDouble18 = 0.0;
                structItem2.DummyDouble19 = 0.0;
                structItem2.DummyDouble20 = 0.0;

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

                structItem2.DummyDateTime1 = DateTime.Now;
                structItem2.DummyDateTime2 = DateTime.Now;

                structItem2.DummyString1 = "0";
                structItem2.DummyString2 = "0";
                structItem2.DummyString3 = "0";
                structItem2.DummyString4 = "0";
                structItem2.DummyString5 = "0";
                structItem2.DummyString6 = "0";

                this.smartFileIO.WriteStructure_Begin(structItem2, i);
            }
            this.smartFileIO.WriteStructure_End();
            this.smartFileIO.Close();
            #endregion
        }
        public void LoadCounterFile(ref WeightData item, int index)
        {
            string fullFilePath = "";
            bool fileCheck = false;
            StructCounterItem structItem;
            StructCounterItem2 structItem2;

            #region counterItem
            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.CreateCounterFile1();
            }

            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.ExNGCount = structItem.ExNGCount;

                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;
            }
            catch
            {
                DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig1.Language);
                myMsg.ShowDialog();

                this.smartFileIO.Close();
            }
            #endregion

            #region counterItem2
            fullFilePath = this.PathSDCardSystemFile2Folder + "counterItem2.int";
            this.smartFileIO.FilePathName = fullFilePath;

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

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

                this.CreateCounterFile2();
            }

            try
            {
                structItem2 = (StructCounterItem2)this.smartFileIO.ReadStructure(index, typeof(StructCounterItem2));

                item.SumOfSquare = structItem2.SumOfSquaresDividedByCount * (item.OverCount + item.PassCount + item.UnderCount);
                item.PassMaxWeight = structItem2.PassMaxWeight;
                item.PassMinWeight = structItem2.PassMinWeight;
                item.ExNGSumWeight = structItem2.ExNGSumWeight;
            }
            catch
            {
                DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig1.Language);
                myMsg.ShowDialog();

                this.smartFileIO.Close();
            }
            #endregion

            this.smartFileIO.Close();
        }
        public void LoadCounterFile(ref Collection<WeightData> items)
        {
            bool fileCheck = false;
            string fullFilePath = "";
            StructCounterItem structItem;
            StructCounterItem2 structItem2;

            #region counterItem
            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.CreateCounterFile1();
            }

            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].ExNGCount = structItem.ExNGCount;

                        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;
                    }
                }
            }
            catch
            {
                DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig1.Language);
                myMsg.ShowDialog();

                this.smartFileIO.Close();
            }
            #endregion

            #region counterItem2
            fullFilePath = this.PathSDCardSystemFile2Folder + "counterItem2.int";
            this.smartFileIO.FilePathName = fullFilePath;

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

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

            try
            {
                if (this.smartFileIO.ReadStructureAllBuffer() == true)
                {
                    for (int i = 0; i < this.ProductCount; i++)
                    {
                        structItem2 = (StructCounterItem2)this.smartFileIO.ReadStructureBuffer(typeof(StructCounterItem2), i);

                        items[i].SumOfSquare = structItem2.SumOfSquaresDividedByCount * (items[i].OverCount + items[i].PassCount + items[i].UnderCount);
                        items[i].PassMaxWeight = structItem2.PassMaxWeight;
                        items[i].PassMinWeight = structItem2.PassMinWeight;
                        items[i].ExNGSumWeight = structItem2.ExNGSumWeight;
                    }
                }
            }
            catch
            {
                DialogFormMessage myMsg = new DialogFormMessage(17, this.SystemConfig1.Language);
                myMsg.ShowDialog();

                this.smartFileIO.Close();
            }
            #endregion

            this.smartFileIO.Close();
        }
        public void ReLoadCounterFile()
        {
            this.LoadCounterFile(ref this.CollectionWeightData);
        }
        #endregion

        #region UserGroupPassword File
        private void CreateUserGroupPasswordFile()
        {
            this.CurrentSystemStatus.CurrentUserPasswordType.Initialization();

            this.smartFileIO.WriteString(this.CurrentSystemStatus.CurrentUserPasswordType.Level1Password, (int)DataStore.EnumFileUserPassword.f0_Level1);
            this.smartFileIO.WriteString(this.CurrentSystemStatus.CurrentUserPasswordType.Level2Password, (int)DataStore.EnumFileUserPassword.f1_Level2);
            this.smartFileIO.WriteString(this.CurrentSystemStatus.CurrentUserPasswordType.Level3Password, (int)DataStore.EnumFileUserPassword.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)DataStore.EnumFileUserPassword.f0_Level1);
            this.smartFileIO.WriteString(item.Level2Password, (int)DataStore.EnumFileUserPassword.f1_Level2);
            this.smartFileIO.WriteString(item.Level3Password, (int)DataStore.EnumFileUserPassword.f2_Level3);

            this.smartFileIO.Close();
        }
        public 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)DataStore.EnumFileUserPassword.f0_Level1);
                this.CurrentSystemStatus.CurrentUserPasswordType.Level2Password = this.smartFileIO.ReadString((int)DataStore.EnumFileUserPassword.f1_Level2);
                this.CurrentSystemStatus.CurrentUserPasswordType.Level3Password = this.smartFileIO.ReadString((int)DataStore.EnumFileUserPassword.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.IsBasicDataBackup = true;
                        structItem.IsBasicDataStatistics = true;
                        structItem.IsBasicProduct = true;
                        structItem.IsBasicTime = true;

                        structItem.IsConfiSerial = false;
                        structItem.IsConfiOptionBoard = false;
                        structItem.IsConfiCountingOutput = false;
                        structItem.IsConfiEthernet = false;

                        structItem.IsEquipFunctionSetting = false;
                        structItem.IsEquipInitialize = false;
                        structItem.IsEquipUpdate = false;
                        structItem.IsEquipUserSetting = false;
                        structItem.IsEquipEngineerSetting = 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.IsSystemExternalInput = false;

                        structItem.IsMainDisplayWeightSetting = true;
                        structItem.IsMainDisplaySubMenu = false;
                        structItem.IsMainDisplayClear = true;
                        structItem.IsMainDisplayProductNo = true;

                        structItem.IsEquipSystemLog = true;
                        structItem.Dummy1 = false;
                        structItem.Dummy2 = false;
                        structItem.Dummy3 = false;
                        structItem.Dummy4 = false;
                        structItem.Dummy5 = false;
                        structItem.Dummy6 = false;
                        structItem.Dummy7 = false;
                        structItem.Dummy8 = false;
                        structItem.Dummy9 = false;
                        structItem.Dummy10 = false;
                        structItem.Dummy11 = false;
                        structItem.Dummy12 = false;
                        structItem.Dummy13 = false;
                        structItem.Dummy14 = false;
                        structItem.Dummy15 = false;
                        structItem.Dummy16 = false;
                        #endregion
                        break;
                    case 1:
                        #region Level2
                        structItem.IsBasicDataBackup = true;
                        structItem.IsBasicDataStatistics = true;
                        structItem.IsBasicProduct = true;
                        structItem.IsBasicTime = true;

                        structItem.IsConfiSerial = false;
                        structItem.IsConfiEthernet = false;
                        structItem.IsConfiOptionBoard = false;
                        structItem.IsConfiCountingOutput = false;

                        structItem.IsEquipFunctionSetting = true;
                        structItem.IsEquipInitialize = false;
                        structItem.IsEquipUpdate = false;
                        structItem.IsEquipUserSetting = false;
                        structItem.IsEquipEngineerSetting = 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.IsSystemExternalInput = true;

                        structItem.IsMainDisplayWeightSetting = true;
                        structItem.IsMainDisplaySubMenu = true;
                        structItem.IsMainDisplayClear = true;
                        structItem.IsMainDisplayProductNo = true;

                        structItem.IsEquipSystemLog = true;
                        structItem.Dummy1 = false;
                        structItem.Dummy2 = false;
                        structItem.Dummy3 = false;
                        structItem.Dummy4 = false;
                        structItem.Dummy5 = false;
                        structItem.Dummy6 = false;
                        structItem.Dummy7 = false;
                        structItem.Dummy8 = false;
                        structItem.Dummy9 = false;
                        structItem.Dummy10 = false;
                        structItem.Dummy11 = false;
                        structItem.Dummy12 = false;
                        structItem.Dummy13 = false;
                        structItem.Dummy14 = false;
                        structItem.Dummy15 = false;
                        structItem.Dummy16 = false;
                        #endregion
                        break;
                    case 2:
                        #region Level3
                        structItem.IsBasicDataBackup = true;
                        structItem.IsBasicDataStatistics = true;
                        structItem.IsBasicProduct = true;
                        structItem.IsBasicTime = true;

                        structItem.IsConfiSerial = true;
                        structItem.IsConfiCountingOutput = true;
                        structItem.IsConfiOptionBoard = true;
                        structItem.IsConfiEthernet = true;

                        structItem.IsEquipFunctionSetting = true;
                        structItem.IsEquipInitialize = true;
                        structItem.IsEquipUpdate = true;
                        structItem.IsEquipUserSetting = 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.IsSystemExternalInput = true;

                        structItem.IsMainDisplayWeightSetting = true;
                        structItem.IsMainDisplayClear = true;
                        structItem.IsMainDisplaySubMenu = true;
                        structItem.IsMainDisplayProductNo = true;

                        structItem.IsEquipSystemLog = true;
                        structItem.Dummy1 = 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.IsBasicDataBackup = true;
                        structItem.IsBasicDataStatistics = true;
                        structItem.IsBasicProduct = true;
                        structItem.IsBasicTime = true;

                        structItem.IsConfiSerial = true;
                        structItem.IsConfiOptionBoard = true;
                        structItem.IsConfiEthernet = true;
                        structItem.IsConfiCountingOutput = true;

                        structItem.IsEquipFunctionSetting = true;
                        structItem.IsEquipInitialize = true;
                        structItem.IsEquipUpdate = true;
                        structItem.IsEquipUserSetting = 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.IsSystemExternalInput = true;

                        structItem.IsMainDisplayWeightSetting = true;
                        structItem.IsMainDisplayClear = true;
                        structItem.IsMainDisplayProductNo = true;
                        structItem.IsMainDisplaySubMenu = true;

                        structItem.IsEquipSystemLog = true;
                        structItem.Dummy1 = 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.IsBasicDataBackup = item.IsBasicDataBackup;
                        structItem.IsBasicDataStatistics = item.IsBasicDataStatistics;
                        structItem.IsBasicProduct = item.IsBasicProduct;
                        structItem.IsBasicTime = item.IsBasicTime;

                        structItem.IsConfiSerial = item.IsConfiSerial;
                        structItem.IsConfiOptionBoard = item.IsConfiOptionBoard;
                        structItem.IsConfiEthernet = item.IsConfiEthernet;
                        structItem.IsConfiCountingOutput = item.IsConfiCountingOutput;

                        structItem.IsEquipFunctionSetting = item.IsEquipFunctionSetting;
                        structItem.IsEquipInitialize = item.IsEquipInitialize;
                        structItem.IsEquipUpdate = item.IsEquipUpdate;
                        structItem.IsEquipUserSetting = 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.IsSystemExternalInput = item.IsSystemExternalInput;

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

                        structItem.IsEquipSystemLog = item.IsEquipSystemLog;
                        structItem.Dummy1 = 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;
                }

                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.IsBasicDataBackup = item.Level1.IsBasicDataBackup;
            structItem.IsBasicDataStatistics = item.Level1.IsBasicDataStatistics;
            structItem.IsBasicProduct = item.Level1.IsBasicProduct;
            structItem.IsBasicTime = item.Level1.IsBasicTime;

            structItem.IsConfiEthernet = item.Level1.IsConfiEthernet;
            structItem.IsConfiCountingOutput = item.Level1.IsConfiCountingOutput;
            structItem.IsConfiSerial = item.Level1.IsConfiSerial;
            structItem.IsConfiOptionBoard = item.Level1.IsConfiOptionBoard;

            structItem.IsEquipFunctionSetting = item.Level1.IsEquipFunctionSetting;
            structItem.IsEquipInitialize = item.Level1.IsEquipInitialize;
            structItem.IsEquipUpdate = item.Level1.IsEquipUpdate;
            structItem.IsEquipUserSetting = 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.IsSystemExternalInput = item.Level1.IsSystemExternalInput;

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

            structItem.IsEquipSystemLog = item.Level1.IsEquipSystemLog;
            structItem.Dummy1 = false;
            structItem.Dummy2 = false;
            structItem.Dummy3 = false;
            structItem.Dummy4 = false;
            structItem.Dummy5 = false;
            structItem.Dummy6 = false;
            structItem.Dummy7 = false;
            structItem.Dummy8 = false;
            structItem.Dummy9 = false;
            structItem.Dummy10 = false;
            structItem.Dummy11 = false;
            structItem.Dummy12 = false;
            structItem.Dummy13 = false;
            structItem.Dummy14 = false;
            structItem.Dummy15 = false;
            structItem.Dummy16 = false;

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

            #region Level2
            structItem.IsBasicDataBackup = item.Level2.IsBasicDataBackup;
            structItem.IsBasicDataStatistics = item.Level2.IsBasicDataStatistics;
            structItem.IsBasicProduct = item.Level2.IsBasicProduct;
            structItem.IsBasicTime = item.Level2.IsBasicTime;

            structItem.IsConfiEthernet = item.Level2.IsConfiEthernet;
            structItem.IsConfiCountingOutput = item.Level2.IsConfiCountingOutput;
            structItem.IsConfiSerial = item.Level2.IsConfiSerial;
            structItem.IsConfiOptionBoard = item.Level2.IsConfiOptionBoard;

            structItem.IsEquipFunctionSetting = item.Level2.IsEquipFunctionSetting;
            structItem.IsEquipInitialize = item.Level2.IsEquipInitialize;
            structItem.IsEquipUpdate = item.Level2.IsEquipUpdate;
            structItem.IsEquipUserSetting = 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.IsSystemExternalInput = item.Level2.IsSystemExternalInput;

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

            structItem.IsEquipSystemLog = item.Level2.IsEquipSystemLog;
            structItem.Dummy1 = false;
            structItem.Dummy2 = false;
            structItem.Dummy3 = false;
            structItem.Dummy4 = false;
            structItem.Dummy5 = false;
            structItem.Dummy6 = false;
            structItem.Dummy7 = false;
            structItem.Dummy8 = false;
            structItem.Dummy9 = false;
            structItem.Dummy10 = false;
            structItem.Dummy11 = false;
            structItem.Dummy12 = false;
            structItem.Dummy13 = false;
            structItem.Dummy14 = false;
            structItem.Dummy15 = false;
            structItem.Dummy16 = false;

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

            #region Level3
            structItem.IsBasicDataBackup = item.Level3.IsBasicDataBackup;
            structItem.IsBasicDataStatistics = item.Level3.IsBasicDataStatistics;
            structItem.IsBasicProduct = item.Level3.IsBasicProduct;
            structItem.IsBasicTime = item.Level3.IsBasicTime;

            structItem.IsConfiEthernet = item.Level3.IsConfiEthernet;
            structItem.IsConfiCountingOutput = item.Level3.IsConfiCountingOutput;
            structItem.IsConfiSerial = item.Level3.IsConfiSerial;
            structItem.IsConfiOptionBoard = item.Level3.IsConfiOptionBoard;

            structItem.IsEquipFunctionSetting = item.Level3.IsEquipFunctionSetting;
            structItem.IsEquipInitialize = item.Level3.IsEquipInitialize;
            structItem.IsEquipUpdate = item.Level3.IsEquipUpdate;
            structItem.IsEquipUserSetting = true;
            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.IsSystemExternalInput = item.Level3.IsSystemExternalInput;

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

            structItem.IsEquipSystemLog = item.Level3.IsEquipSystemLog;
            structItem.Dummy1 = false;
            structItem.Dummy2 = false;
            structItem.Dummy3 = false;
            structItem.Dummy4 = false;
            structItem.Dummy5 = false;
            structItem.Dummy6 = false;
            structItem.Dummy7 = false;
            structItem.Dummy8 = false;
            structItem.Dummy9 = false;
            structItem.Dummy10 = false;
            structItem.Dummy11 = false;
            structItem.Dummy12 = false;
            structItem.Dummy13 = false;
            structItem.Dummy14 = false;
            structItem.Dummy15 = false;
            structItem.Dummy16 = false;

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

            #region Not Login
            structItem.IsBasicDataBackup = item.NotLogin.IsBasicDataBackup;
            structItem.IsBasicDataStatistics = item.NotLogin.IsBasicDataStatistics;
            structItem.IsBasicProduct = item.NotLogin.IsBasicProduct;
            structItem.IsBasicTime = item.NotLogin.IsBasicTime;

            structItem.IsConfiEthernet = item.NotLogin.IsConfiEthernet;
            structItem.IsConfiCountingOutput = item.NotLogin.IsConfiCountingOutput;
            structItem.IsConfiSerial = item.NotLogin.IsConfiSerial;
            structItem.IsConfiOptionBoard = item.NotLogin.IsConfiOptionBoard;

            structItem.IsEquipFunctionSetting = item.NotLogin.IsEquipFunctionSetting;
            structItem.IsEquipInitialize = item.NotLogin.IsEquipInitialize;
            structItem.IsEquipUpdate = item.NotLogin.IsEquipUpdate;
            structItem.IsEquipUserSetting = 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.IsSystemExternalInput = item.NotLogin.IsSystemExternalInput;

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

            structItem.IsEquipSystemLog = item.NotLogin.IsEquipSystemLog;
            structItem.Dummy1 = false;
            structItem.Dummy2 = false;
            structItem.Dummy3 = false;
            structItem.Dummy4 = false;
            structItem.Dummy5 = false;
            structItem.Dummy6 = false;
            structItem.Dummy7 = false;
            structItem.Dummy8 = false;
            structItem.Dummy9 = false;
            structItem.Dummy10 = false;
            structItem.Dummy11 = false;
            structItem.Dummy12 = false;
            structItem.Dummy13 = false;
            structItem.Dummy14 = false;
            structItem.Dummy15 = false;
            structItem.Dummy16 = false;

            this.smartFileIO.WriteStructure_Begin(structItem, (int)DataStore.EnumFileUserGroup.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.IsBasicDataBackup = item.IsBasicDataBackup;
            structItem.IsBasicDataStatistics = item.IsBasicDataStatistics;
            structItem.IsBasicProduct = item.IsBasicProduct;
            structItem.IsBasicTime = item.IsBasicTime;

            structItem.IsConfiEthernet = item.IsConfiEthernet;
            structItem.IsConfiCountingOutput = item.IsConfiCountingOutput;
            structItem.IsConfiSerial = item.IsConfiSerial;
            structItem.IsConfiOptionBoard = item.IsConfiOptionBoard;

            structItem.IsEquipFunctionSetting = item.IsEquipFunctionSetting;
            structItem.IsEquipInitialize = item.IsEquipInitialize;
            structItem.IsEquipUpdate = item.IsEquipUpdate;
            structItem.IsEquipUserSetting = 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.IsSystemExternalInput = item.IsSystemExternalInput;

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

            structItem.IsEquipSystemLog = item.IsEquipSystemLog;
            structItem.Dummy1 = false;
            structItem.Dummy2 = false;
            structItem.Dummy3 = false;
            structItem.Dummy4 = false;
            structItem.Dummy5 = false;
            structItem.Dummy6 = false;
            structItem.Dummy7 = false;
            structItem.Dummy8 = false;
            structItem.Dummy9 = false;
            structItem.Dummy10 = false;
            structItem.Dummy11 = false;
            structItem.Dummy12 = false;
            structItem.Dummy13 = false;
            structItem.Dummy14 = false;
            structItem.Dummy15 = false;
            structItem.Dummy16 = false;

            this.smartFileIO.WriteStructure_Begin(structItem, (int)DataStore.EnumFileUserGroup.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.IsBasicDataBackup = item.IsBasicDataBackup;
            structItem.IsBasicDataStatistics = item.IsBasicDataStatistics;
            structItem.IsBasicProduct = item.IsBasicProduct;
            structItem.IsBasicTime = item.IsBasicTime;

            structItem.IsConfiEthernet = item.IsConfiEthernet;
            structItem.IsConfiCountingOutput = item.IsConfiCountingOutput;
            structItem.IsConfiSerial = item.IsConfiSerial;
            structItem.IsConfiOptionBoard = item.IsConfiOptionBoard;

            structItem.IsEquipFunctionSetting = item.IsEquipFunctionSetting;
            structItem.IsEquipInitialize = item.IsEquipInitialize;
            structItem.IsEquipUpdate = item.IsEquipUpdate;
            structItem.IsEquipUserSetting = 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.IsSystemExternalInput = item.IsSystemExternalInput;

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

            structItem.IsEquipSystemLog = item.IsEquipSystemLog;
            structItem.Dummy1 = false;
            structItem.Dummy2 = false;
            structItem.Dummy3 = false;
            structItem.Dummy4 = false;
            structItem.Dummy5 = false;
            structItem.Dummy6 = false;
            structItem.Dummy7 = false;
            structItem.Dummy8 = false;
            structItem.Dummy9 = false;
            structItem.Dummy10 = false;
            structItem.Dummy11 = false;
            structItem.Dummy12 = false;
            structItem.Dummy13 = false;
            structItem.Dummy14 = false;
            structItem.Dummy15 = false;
            structItem.Dummy16 = false;

            this.smartFileIO.WriteStructure_Begin(structItem, (int)DataStore.EnumFileUserGroup.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.IsBasicDataBackup = item.IsBasicDataBackup;
            structItem.IsBasicDataStatistics = item.IsBasicDataStatistics;
            structItem.IsBasicProduct = item.IsBasicProduct;
            structItem.IsBasicTime = item.IsBasicTime;

            structItem.IsConfiEthernet = item.IsConfiEthernet;
            structItem.IsConfiCountingOutput = item.IsConfiCountingOutput;
            structItem.IsConfiSerial = item.IsConfiSerial;
            structItem.IsConfiOptionBoard = item.IsConfiOptionBoard;

            structItem.IsEquipFunctionSetting = item.IsEquipFunctionSetting;
            structItem.IsEquipInitialize = item.IsEquipInitialize;
            structItem.IsEquipUpdate = item.IsEquipUpdate;
            structItem.IsEquipUserSetting = 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.IsSystemExternalInput = item.IsSystemExternalInput;

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

            structItem.IsEquipSystemLog = true;
            structItem.Dummy1 = false;
            structItem.Dummy2 = false;
            structItem.Dummy3 = false;
            structItem.Dummy4 = false;
            structItem.Dummy5 = false;
            structItem.Dummy6 = false;
            structItem.Dummy7 = false;
            structItem.Dummy8 = false;
            structItem.Dummy9 = false;
            structItem.Dummy10 = false;
            structItem.Dummy11 = false;
            structItem.Dummy12 = false;
            structItem.Dummy13 = false;
            structItem.Dummy14 = false;
            structItem.Dummy15 = false;
            structItem.Dummy16 = false;

            this.smartFileIO.WriteStructure_Begin(structItem, (int)DataStore.EnumFileUserGroup.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 Not Login
            structItem.IsBasicDataBackup = item.IsBasicDataBackup;
            structItem.IsBasicDataStatistics = item.IsBasicDataStatistics;
            structItem.IsBasicProduct = item.IsBasicProduct;
            structItem.IsBasicTime = item.IsBasicTime;

            structItem.IsConfiEthernet = item.IsConfiEthernet;
            structItem.IsConfiCountingOutput = item.IsConfiCountingOutput;
            structItem.IsConfiSerial = item.IsConfiSerial;
            structItem.IsConfiOptionBoard = item.IsConfiOptionBoard;

            structItem.IsEquipFunctionSetting = item.IsEquipFunctionSetting;
            structItem.IsEquipInitialize = item.IsEquipInitialize;
            structItem.IsEquipUpdate = item.IsEquipUpdate;
            structItem.IsEquipUserSetting = 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.IsSystemExternalInput = item.IsSystemExternalInput;

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

            structItem.IsEquipSystemLog = item.IsEquipSystemLog;
            structItem.Dummy1 = false;
            structItem.Dummy2 = false;
            structItem.Dummy3 = false;
            structItem.Dummy4 = false;
            structItem.Dummy5 = false;
            structItem.Dummy6 = false;
            structItem.Dummy7 = false;
            structItem.Dummy8 = false;
            structItem.Dummy9 = false;
            structItem.Dummy10 = false;
            structItem.Dummy11 = false;
            structItem.Dummy12 = false;
            structItem.Dummy13 = false;
            structItem.Dummy14 = false;
            structItem.Dummy15 = false;
            structItem.Dummy16 = false;

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

            this.smartFileIO.WriteStructure_End();
            this.smartFileIO.Close();
        }
        public 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)DataStore.EnumFileUserGroup.f0_Level1);

                    item.Level1.IsBasicDataBackup = structItem.IsBasicDataBackup;
                    item.Level1.IsBasicDataStatistics = structItem.IsBasicDataStatistics;
                    item.Level1.IsBasicProduct = structItem.IsBasicProduct;
                    item.Level1.IsBasicTime = structItem.IsBasicTime;

                    item.Level1.IsConfiSerial = structItem.IsConfiSerial;
                    item.Level1.IsConfiOptionBoard = structItem.IsConfiOptionBoard;
                    item.Level1.IsConfiEthernet = structItem.IsConfiEthernet;
                    item.Level1.IsConfiCountingOutput = structItem.IsConfiCountingOutput;

                    item.Level1.IsEquipFunctionSetting = structItem.IsEquipFunctionSetting;
                    item.Level1.IsEquipInitialize = structItem.IsEquipInitialize;
                    item.Level1.IsEquipUpdate = structItem.IsEquipUpdate;
                    item.Level1.IsEquipUserSetting = structItem.IsEquipUserSetting;
                    item.Level1.IsEquipEngineerSetting = structItem.IsEquipEngineerSetting;
                    item.Level1.IsEquipSystemLog = structItem.IsEquipSystemLog;

                    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.IsSystemExternalInput = structItem.IsSystemExternalInput;

                    item.Level1.IsMainDisplayProductNo = structItem.IsMainDisplayProductNo;
                    item.Level1.IsMainDisplayWeightSetting = structItem.IsMainDisplayWeightSetting;
                    item.Level1.IsMainDisplayClear = structItem.IsMainDisplayClear;
                    item.Level1.IsMainDisplaySubMenu = structItem.IsMainDisplaySubMenu;
                    #endregion

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

                    item.Level2.IsBasicDataBackup = structItem.IsBasicDataBackup;
                    item.Level2.IsBasicDataStatistics = structItem.IsBasicDataStatistics;
                    item.Level2.IsBasicProduct = structItem.IsBasicProduct;
                    item.Level2.IsBasicTime = structItem.IsBasicTime;

                    item.Level2.IsConfiSerial = structItem.IsConfiSerial;
                    item.Level2.IsConfiOptionBoard = structItem.IsConfiOptionBoard;
                    item.Level2.IsConfiEthernet = structItem.IsConfiEthernet;
                    item.Level2.IsConfiCountingOutput = structItem.IsConfiCountingOutput;

                    item.Level2.IsEquipFunctionSetting = structItem.IsEquipFunctionSetting;
                    item.Level2.IsEquipInitialize = structItem.IsEquipInitialize;
                    item.Level2.IsEquipUpdate = structItem.IsEquipUpdate;
                    item.Level2.IsEquipUserSetting = structItem.IsEquipUserSetting;
                    item.Level2.IsEquipEngineerSetting = structItem.IsEquipEngineerSetting;
                    item.Level2.IsEquipSystemLog = structItem.IsEquipSystemLog;

                    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.IsSystemExternalInput = structItem.IsSystemExternalInput;

                    item.Level2.IsMainDisplayProductNo = structItem.IsMainDisplayProductNo;
                    item.Level2.IsMainDisplayWeightSetting = structItem.IsMainDisplayWeightSetting;
                    item.Level2.IsMainDisplayClear = structItem.IsMainDisplayClear;
                    item.Level2.IsMainDisplaySubMenu = structItem.IsMainDisplaySubMenu;
                    #endregion

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

                    item.Level3.IsBasicDataBackup = structItem.IsBasicDataBackup;
                    item.Level3.IsBasicDataStatistics = structItem.IsBasicDataStatistics;
                    item.Level3.IsBasicProduct = structItem.IsBasicProduct;
                    item.Level3.IsBasicTime = structItem.IsBasicTime;

                    item.Level3.IsConfiSerial = structItem.IsConfiSerial;
                    item.Level3.IsConfiOptionBoard = structItem.IsConfiOptionBoard;
                    item.Level3.IsConfiEthernet = structItem.IsConfiEthernet;
                    item.Level3.IsConfiCountingOutput = structItem.IsConfiCountingOutput;

                    item.Level3.IsEquipFunctionSetting = true;
                    item.Level3.IsEquipInitialize = structItem.IsEquipInitialize;
                    item.Level3.IsEquipUpdate = structItem.IsEquipUpdate;
                    item.Level3.IsEquipUserSetting = true;
                    item.Level3.IsEquipEngineerSetting = true;
                    item.Level2.IsEquipSystemLog = true;

                    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.IsSystemExternalInput = structItem.IsSystemExternalInput;

                    item.Level3.IsMainDisplayProductNo = structItem.IsMainDisplayProductNo;
                    item.Level3.IsMainDisplayWeightSetting = structItem.IsMainDisplayWeightSetting;
                    item.Level3.IsMainDisplayClear = structItem.IsMainDisplayClear;
                    item.Level3.IsMainDisplaySubMenu = structItem.IsMainDisplaySubMenu;
                    #endregion

                    #region Not Login
                    try
                    {
                        structItem = (StructUserGroupItem)this.smartFileIO.ReadStructureBuffer(typeof(StructUserGroupItem), (int)DataStore.EnumFileUserGroup.f3_NotLogin);

                        item.NotLogin.IsBasicDataBackup = structItem.IsBasicDataBackup;
                        item.NotLogin.IsBasicDataStatistics = structItem.IsBasicDataStatistics;
                        item.NotLogin.IsBasicProduct = structItem.IsBasicProduct;
                        item.NotLogin.IsBasicTime = structItem.IsBasicTime;

                        item.NotLogin.IsConfiSerial = structItem.IsConfiSerial;
                        item.NotLogin.IsConfiOptionBoard = structItem.IsConfiOptionBoard;
                        item.NotLogin.IsConfiEthernet = structItem.IsConfiEthernet;
                        item.NotLogin.IsConfiCountingOutput = structItem.IsConfiCountingOutput;

                        item.NotLogin.IsEquipFunctionSetting = structItem.IsEquipFunctionSetting;
                        item.NotLogin.IsEquipInitialize = structItem.IsEquipInitialize;
                        item.NotLogin.IsEquipUpdate = structItem.IsEquipUpdate;
                        item.NotLogin.IsEquipUserSetting = structItem.IsEquipUserSetting;
                        item.NotLogin.IsEquipEngineerSetting = structItem.IsEquipEngineerSetting;
                        item.NotLogin.IsEquipSystemLog = structItem.IsEquipSystemLog;

                        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.IsSystemExternalInput = structItem.IsSystemExternalInput;

                        item.NotLogin.IsMainDisplayProductNo = structItem.IsMainDisplayProductNo;
                        item.NotLogin.IsMainDisplayWeightSetting = structItem.IsMainDisplayWeightSetting;
                        item.NotLogin.IsMainDisplayClear = structItem.IsMainDisplayClear;
                        item.NotLogin.IsMainDisplaySubMenu = structItem.IsMainDisplaySubMenu;
                    }
                    catch
                    {
                        #region Not Login
                        item.NotLogin.IsBasicDataBackup = structItem.IsBasicDataBackup = true;
                        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.IsConfiOptionBoard = structItem.IsConfiOptionBoard = true;
                        item.NotLogin.IsConfiEthernet = structItem.IsConfiEthernet = true;
                        item.NotLogin.IsConfiCountingOutput = structItem.IsConfiCountingOutput = true;

                        item.NotLogin.IsEquipFunctionSetting = structItem.IsEquipFunctionSetting = true;
                        item.NotLogin.IsEquipInitialize = structItem.IsEquipInitialize = true;
                        item.NotLogin.IsEquipUpdate = structItem.IsEquipUpdate = true;
                        item.NotLogin.IsEquipUserSetting = structItem.IsEquipUserSetting = 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.IsSystemExternalInput = structItem.IsSystemExternalInput = 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;

                        structItem.IsEquipSystemLog = structItem.IsEquipSystemLog = true;
                        structItem.Dummy1 = false;
                        structItem.Dummy2 = false;
                        structItem.Dummy3 = false;
                        structItem.Dummy4 = false;
                        structItem.Dummy5 = false;
                        structItem.Dummy6 = false;
                        structItem.Dummy7 = false;
                        structItem.Dummy8 = false;
                        structItem.Dummy9 = false;
                        structItem.Dummy10 = false;
                        structItem.Dummy11 = false;
                        structItem.Dummy12 = false;
                        structItem.Dummy13 = false;
                        structItem.Dummy14 = false;
                        structItem.Dummy15 = false;
                        structItem.Dummy16 = false;
                        #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

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

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

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

            this.smartFileIO.WriteStructure_Begin(structItem, 0);

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

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

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

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

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

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

                this.CreateUserLevel1File();
            }

            if (item.Count == 0)
                return;

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

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

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

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

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

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

                this.CreateUserLevel1File();
            }

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

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

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

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

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

            this.smartFileIO.WriteStructure_Begin(structItem, 0);

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

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

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

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

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

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

                this.CreateUserLevel2File();
            }

            if (item.Count == 0)
                return;

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

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

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

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

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

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

                this.CreateUserLevel2File();
            }

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

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

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

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

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

            this.smartFileIO.WriteStructure_Begin(structItem, 0);

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

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

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

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

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

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

                this.CreateUserLevel3File();
            }

            if (item.Count == 0)
                return;

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

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

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

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

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

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

                this.CreateUserLevel3File();
            }

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

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

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

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

            // 변수 초기 셋팅1
            this.DefaultSetting1();

            #region Conversion
            //// PreVersionBackup 폴더가 없을 경우 폴더 생성 및 이동
            //if (this.CheckPreVersionFolder() == false)
            //{
            //    // SD Card\\PreVersionBackup 폴더 생성
            //    DirectoryInfo dirPreVersionFolder = new DirectoryInfo(this.PathPreVersionFolder);
            //    dirPreVersionFolder.Create();

            //    // 현재 시스템 폴더 1 -> PreVersionBackup 폴더
            //    Helper.MoveToFolder(this.PathSDCardSystemFile1Folder, this.PathPreVersionSystemFile1Folder);

            //    // 현재 시스템 폴더 2 -> PreVersionBackup 폴더
            //    Helper.MoveToFolder(this.PathSDCardSystemFile2Folder, this.PathPreVersionSystemFile2Folder);
            //}

            //// SystemFile1 폴더가 없거나, 폴더 내 파일이 없을 경우 Conversion 진행
            //bool IsConverting = false;
            //FileInfo[] fileInfo;
            //DirectoryInfo dirSystemFile1 = new DirectoryInfo(this.PathSDCardSystemFile1Folder);
            //if (dirSystemFile1.Exists == true)
            //{
            //    fileInfo = dirSystemFile1.GetFiles();
            //    if (fileInfo.Length == 0)
            //        IsConverting = true;
            //}
            //else
            //    IsConverting = true;
            #endregion

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

            // UserGroupPassword 파일 읽기
            this.LoadUserGroupPasswordFile();

            // UserGroup 파일 읽기
            this.LoadUserGroupFile(ref this.CurrentUserGroup);
            // User 파일 읽기
            this.LoadUserLevel1File(this.CurrentUser.Level1Users);
            this.LoadUserLevel2File(this.CurrentUser.Level2Users);
            this.LoadUserLevel3File(this.CurrentUser.Level3Users);

            // 폼 생성
            this.CreateForm();

            // 메인 통신 OPEN
            this.OpenSmartSerialPort2();

            // 통신 버퍼용
            this.smartThreadSerialPort2Read.Priority = ThreadPriority.Normal;
            this.smartThreadSerialPort2Read.Start();
            //this.smartThreadSerialPort2OverRun.Start();

            #region Communication
            if (this.SystemConfig1.SerialCOM1Mode != (int)DataStore.SerialMode.f0_None)
            {
                switch (this.SystemConfig1.SerialCOM1Mode)
                {
                    case (int)DataStore.SerialMode.f16_OPC:
                    case (int)DataStore.SerialMode.f22_Modbus_RTU:
                        this.ChildFormMainDisplay.MainBottomModbusIconAdd(true);
                        break;
                    case (int)DataStore.SerialMode.f21_Impinj_Speedway_R420:
                        // STXANDETX
                        this.smartSerialPort1.Baud_Rate = SmartSerialPort.BAUDRATE._115200bps;
                        this.ChangeSerialCOM1FrameSeparateType(DataStore.SeparateType.ETXONLY);
                        break;
                    default:
                        break;
                }

                // COM1 OPEN
                this.OpenSerialCOM1();
            }

            if (this.SystemConfig1.SerialCOM3Mode != (int)DataStore.SerialMode.f0_None)
            {
                switch (this.SystemConfig1.SerialCOM3Mode)
                {
                    case (int)DataStore.SerialMode.f16_OPC:
                    case (int)DataStore.SerialMode.f22_Modbus_RTU:
                        this.ChildFormMainDisplay.MainBottomModbusIconAdd(true);
                        break;
                    case (int)DataStore.SerialMode.f21_Impinj_Speedway_R420:
                        // STXANDETX
                        this.smartSerialPort3.Baud_Rate = SmartSerialPort.BAUDRATE._115200bps;
                        this.ChangeSerialCOM3FrameSeparateType(DataStore.SeparateType.ETXONLY);
                        break;
                    default:
                        break;
                }

                // COM3 OPEN
                this.OpenSerialCOM3();
            }

            if (this.SystemConfig1.SerialCOM4Mode != (int)DataStore.SerialMode.f0_None)
            {
                switch (this.SystemConfig1.SerialCOM4Mode)
                {
                    case (int)DataStore.SerialMode.f16_OPC:
                    case (int)DataStore.SerialMode.f22_Modbus_RTU:
                        this.ChildFormMainDisplay.MainBottomModbusIconAdd(true);
                        break;
                    case (int)DataStore.SerialMode.f21_Impinj_Speedway_R420:
                        // STXANDETX
                        this.smartSerialPort4.Baud_Rate = SmartSerialPort.BAUDRATE._115200bps;
                        this.ChangeSerialCOM4FrameSeparateType(DataStore.SeparateType.ETXONLY);
                        break;
                    default:
                        break;
                }

                // COM4 OPEN
                this.OpenSerialCOM4();
            }
            #endregion

            // Write SystemParameter1
            this.TransferParameter1();

            // 변수 초기 셋팅2(바코드 셋팅, 이더넷)
            this.DefaultSetting2();

            this.SmartSplashProgramLoad.Finish();

            if (this.CurrentSystemStatus.CurrentUser.Group == DataStore.UserGroup.NotLogin)
                this.ChildFormMenu.CenterEquipUserGroupEditor.UpdateAllMenu(this.CurrentSystemStatus);

            // 현재 Version.ini 파일 생성 혹은 갱신
            this.CheckCurrentVersionIniFile();

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

            // 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, CommunicationCommand.ACK);
                            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 != (int)DataStore.SerialMode.f4_imaje_9410_OPT1
                    && this.SystemConfig1.SerialCOM1Mode != (int)DataStore.SerialMode.f5_imaje_9028_OPT1
                    && this.SystemConfig1.SerialCOM1Mode != (int)DataStore.SerialMode.f22_Modbus_RTU
                    && this.SystemConfig1.SerialCOM1Mode != (int)DataStore.SerialMode.f16_OPC)
                {
                    strTemp = Encoding.Default.GetString(readByte, 0, readByte.Length);

                    if (this.ChildFormMainDisplay.labelBarcode.Visible == true)
                        this.ChildFormMainDisplay.labelBarcode.Text = strTemp;

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

            }
            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(DataStore.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 == DataStore.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)DataStore.SerialMode.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)DataStore.SerialMode.f21_Impinj_Speedway_R420:
                    #region RFID Speedway R420
                    if (this.CurrentSystemStatus.CurrentDisplay == DataStore.DisplayStore.ConfiSerial)
                        this.ChildFormMenu.CenterConfiSerial.DisplayReceive(strTemp);
                    else if (this.CurrentSystemStatus.CurrentDisplay == DataStore.DisplayStore.MainDisplay)
                    {
                        if (this.CurrentSystemStatus.Equipment == DataStore.EquipmentStatus.Start)
                        {
                            strTemp = strTemp.Replace(Environment.NewLine, "");
                            //strTemp = strTemp.Trim();
                            //if (strTemp.Length > 24)
                            //    strTemp.Substring(strTemp.Length - 24, 24);

                            if (this.PreviousTag != strTemp)
                            {
                                bool successAdd = false;

                                if (this.CurrentRFID.IsTagInList(strTemp) == false)
                                {
                                    successAdd = this.CurrentRFID.Add(strTemp, this.CurrentRFID.Count() - 1);

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

                                        for (int i = 0; i < this.CurrentRFID.Count(); i++)
                                            this.smartFileCommunicationLog.WriteString(string.Format("ListTag ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, this.CurrentRFID.ReturnTag(i)));
                                    }
                                }
                                if (successAdd == true)
                                    this.PreviousTag = strTemp;
                            }
                        }
                        else
                        {
                            try
                            {
                                if (this.ChildFormMainDisplay.labelBarcode.Visible == true)
                                    this.ChildFormMainDisplay.labelBarcode.Text += " : " + this.CurrentRFID.VerifyBARCD(strTemp);
                            }
                            catch
                            {
                            }
                        }
                    }
                    #endregion
                    break;
                case (int)DataStore.SerialMode.f22_Modbus_RTU:
                    #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)DataStore.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;

            this.SerialReceiveData(strTemp);
        }
        private void smartSerialPort3_OnReadQueueEvent()
        {
            int productNo = 0;
            string strTemp = "", value = "";
            byte[] readByte;
            byte[] sendModbusDatas;
            byte[] madeDatas;
            BarcodeStatus status = BarcodeStatus.None;
            SmartSerialPort.FRAMEDATAREADSTATUS receiveDataState = SmartSerialPort.FRAMEDATAREADSTATUS.EMPTY;

            try
            {
                receiveDataState = this.smartSerialPort3.ReadQueue(out readByte);

                if (this.SystemConfig1.SerialCOM3Mode != (int)DataStore.SerialMode.f4_imaje_9410_OPT1
                    && this.SystemConfig1.SerialCOM3Mode != (int)DataStore.SerialMode.f5_imaje_9028_OPT1
                    && this.SystemConfig1.SerialCOM3Mode != (int)DataStore.SerialMode.f22_Modbus_RTU
                    && this.SystemConfig1.SerialCOM3Mode != (int)DataStore.SerialMode.f16_OPC)
                {
                    strTemp = Encoding.Default.GetString(readByte, 0, readByte.Length);

                    if (this.ChildFormMainDisplay.labelBarcode.Visible == true)
                        this.ChildFormMainDisplay.labelBarcode.Text = strTemp;

                    // 로그
                    if (this.IsCommunicationLogOpen == true)
                        this.smartFileCommunicationLog.WriteString(string.Format("Receive COM3 ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, strTemp));
                }
                else
                {
                    // 로그
                    if (this.IsCommunicationLogOpen == true)
                        this.smartFileCommunicationLog.WriteString(string.Format("Receive COM3 ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, BitConverter.ToString(readByte)));
                }
            }
            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(DataStore.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 == DataStore.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)DataStore.SerialMode.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)DataStore.SerialMode.f21_Impinj_Speedway_R420:
                    #region RFID Speedway R420
                    if (this.CurrentSystemStatus.CurrentDisplay == DataStore.DisplayStore.ConfiSerial)
                        this.ChildFormMenu.CenterConfiSerial.DisplayReceive(strTemp);
                    else if (this.CurrentSystemStatus.CurrentDisplay == DataStore.DisplayStore.MainDisplay)
                    {
                        if (this.CurrentSystemStatus.Equipment == DataStore.EquipmentStatus.Start)
                        {

                            strTemp = strTemp.Replace(Environment.NewLine, "");
                            //strTemp = strTemp.Trim();
                            //if (strTemp.Length > 24)
                            //    strTemp.Substring(strTemp.Length - 24, 24);

                            if (this.PreviousTag != strTemp)
                            {
                                bool successAdd = false;

                                if (this.CurrentRFID.IsTagInList(strTemp) == false)
                                {
                                    successAdd = this.CurrentRFID.Add(strTemp, this.CurrentRFID.Count() - 1);

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

                                        for (int i = 0; i < this.CurrentRFID.Count(); i++)
                                            this.smartFileCommunicationLog.WriteString(string.Format("ListTag ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, this.CurrentRFID.ReturnTag(i)));
                                    }
                                }
                                if (successAdd == true)
                                    this.PreviousTag = strTemp;
                            }
                        }
                        else
                        {
                            try
                            {
                                if (this.ChildFormMainDisplay.labelBarcode.Visible == true)
                                    this.ChildFormMainDisplay.labelBarcode.Text += " : " + this.CurrentRFID.VerifyBARCD(strTemp);
                            }
                            catch
                            {
                            }
                        }
                    }
                    #endregion
                    break;
                case (int)DataStore.SerialMode.f22_Modbus_RTU:
                    #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)DataStore.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.SystemConfig2.Barcode != 0)
            {
                // 로그
                if (this.IsCommunicationLogOpen == true)
                    this.smartFileCommunicationLog.WriteString(string.Format("Receive Barcode ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, strTemp));

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

                if (this.CurrentSystemStatus.CurrentDisplay == DataStore.DisplayStore.MainDisplay)
                {
                    if (this.CurrentSystemStatus.Equipment == DataStore.EquipmentStatus.Start)
                    {
                        if (this.SystemConfig2.Barcode > 0)
                        {
                            this.CurrentBarcode.SetData(strTemp);
                            
                            // 바코드 로그
                            if (this.IsBarcodeLogOpen == true)
                                this.smartFileBarcodeLog.WriteString(string.Format("Barcode Count ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, this.CurrentBarcode.GetQueueCount));

                            if (this.CurrentBarcode.GetQueueCount > 0)
                                this.BarcodeProductChange(this.CurrentBarcode);
                        }
                    }
                }
                else if (this.CurrentSystemStatus.CurrentDisplay == DataStore.DisplayStore.BasicProduct)
                {
                    this.ChildFormMenu.CenterBasicProduct.ControlLotSetting.DisplayReceive(strTemp);
                }
                else if (this.CurrentSystemStatus.CurrentDisplay == DataStore.DisplayStore.ConfiSerial)
                {
                    this.ChildFormMenu.CenterConfiSerial.DisplayReceive(strTemp);

                    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:
                            this.ChildFormMenu.CenterConfiSerial.DisplayReceive(strTemp);
                            break;
                    }
                }
            }
            #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 != (int)DataStore.SerialMode.f4_imaje_9410_OPT1
                    && this.SystemConfig1.SerialCOM4Mode != (int)DataStore.SerialMode.f5_imaje_9028_OPT1
                    && this.SystemConfig1.SerialCOM4Mode != (int)DataStore.SerialMode.f22_Modbus_RTU
                    && this.SystemConfig1.SerialCOM4Mode != (int)DataStore.SerialMode.f16_OPC)
                {
                    strTemp = Encoding.Default.GetString(readByte, 0, readByte.Length);

                    if (this.ChildFormMainDisplay.labelBarcode.Visible == true)
                        this.ChildFormMainDisplay.labelBarcode.Text = strTemp;

                    // 로그
                    if (this.IsCommunicationLogOpen == true)
                        this.smartFileCommunicationLog.WriteString(string.Format("Receive COM4 ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, strTemp));
                }
                else
                {
                    // 로그
                    if (this.IsCommunicationLogOpen == true)
                        this.smartFileCommunicationLog.WriteString(string.Format("Receive COM4 ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, BitConverter.ToString(readByte)));
                }
            }
            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(DataStore.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 == DataStore.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)DataStore.SerialMode.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)DataStore.SerialMode.f21_Impinj_Speedway_R420:
                    #region RFID Speedway R420
                    if (this.CurrentSystemStatus.CurrentDisplay == DataStore.DisplayStore.ConfiSerial)
                        this.ChildFormMenu.CenterConfiSerial.DisplayReceive(strTemp);
                    else if (this.CurrentSystemStatus.CurrentDisplay == DataStore.DisplayStore.MainDisplay)
                    {
                        if (this.CurrentSystemStatus.Equipment == DataStore.EquipmentStatus.Start)
                        {
                            strTemp = strTemp.Replace(Environment.NewLine, "");
                            //strTemp = strTemp.Trim();
                            //if (strTemp.Length > 24)
                            //    strTemp.Substring(strTemp.Length - 24, 24);

                            if (this.PreviousTag != strTemp)
                            {
                                bool successAdd = false;

                                if (this.CurrentRFID.IsTagInList(strTemp) == false)
                                {
                                    successAdd = this.CurrentRFID.Add(strTemp, this.CurrentRFID.Count() - 1);

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

                                        for (int i = 0; i < this.CurrentRFID.Count(); i++)
                                            this.smartFileCommunicationLog.WriteString(string.Format("ListTag ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, this.CurrentRFID.ReturnTag(i)));
                                    }
                                }
                                if (successAdd == true)
                                    this.PreviousTag = strTemp;
                            }
                        }
                        else
                        {
                            try
                            {
                                if (this.ChildFormMainDisplay.labelBarcode.Visible == true)
                                    this.ChildFormMainDisplay.labelBarcode.Text += " : " + this.CurrentRFID.VerifyBARCD(strTemp);
                            }
                            catch
                            {
                            }
                        }
                    }
                    #endregion
                    break;
                case (int)DataStore.SerialMode.f22_Modbus_RTU:
                    #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)DataStore.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[] sendOPCDatas = new byte[57];
            byte[] sendModbusDatas;
            byte[] madeDatas;

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

            switch (this.SystemConfig2.EthernetCommMode)
            {
                case (int)DataStore.EthernetMode.f5_imaje_9028_OPT1:
                    #region imaje 9028 OPT1 - 한맥프린터(네추럴 F&P)
                    if (readByte[0] != 0x06) // ACK가 아니면 재발송
                    {
                        switch (this.HMEthernet_Step)
                        {
                            case 1:
                                this.EthernetWeightData(this.SendChar(DataStore.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 == DataStore.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 (int)DataStore.EthernetMode.f10_MACSA_Laser:
                    #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 (int)DataStore.EthernetMode.f15_OPT2:
                    #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)DataStore.EthernetMode.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)DataStore.EthernetMode.f22_Modbus_TCP:
                    #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);
                                }

                                // 로그
                                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)DataStore.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);
                                    }

                                    // 로그
                                    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;
                case (int)DataStore.EthernetMode.f21_Impinj_Speedway_R420:
                    #region RFID Reader
                    if (this.smartTCPMultiServer.ClientInfoList != null)
                    {
                        string[] splitResult = strRecData.Split(';');

                        this.SystemConfig2.RFID_R420_BARCD = splitResult[2].Substring(6, 13);
                        this.SystemConfig2.RFID_R420_EPC_Filter = splitResult[5].Substring(11, 1);

                        this.SaveSystemConfigurationFile2(this.SystemConfig2);

                        this.CurrentRFID.ChangeBARCDAndEPCFilter(this.SystemConfig2.RFID_R420_BARCD, this.SystemConfig2.RFID_R420_EPC_Filter);
                    }
                    #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 = DataStore.JudgmentResult.Timeout.ToString();
                    this.DataBackup1(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
                    {
                        //if (string.IsNullOrEmpty(this.smartTCPMultiServer.ClientInfoList[0].strIPAddress))
                        //{
                        //    if (this.IsCommunicationLogOpen == true)
                        //    {
                        //        this.smartFileCommunicationLog.WriteString(string.Format("Connection ({0:yyyy-MM-dd HH:mm:ss}): null ", DateTime.Now));
                        //        this.smartFileCommunicationLog.WriteString(string.Format("ClientInfoList ({0:yyyy-MM-dd HH:mm:ss}): {1}_{2}", DateTime.Now, this.smartTCPMultiServer.ClientInfoList[0].strIPAddress));
                        //    }

                        //    return;
                        //}

                        //if (this.IsCommunicationLogOpen == true)
                        //    this.smartFileCommunicationLog.WriteString(string.Format("ClientInfoList ({0:yyyy-MM-dd HH:mm:ss}): {1}_{2}", DateTime.Now, this.smartTCPMultiServer.ClientInfoList[0].strIPAddress));
                        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 timerBuzzer_Tick(object sender, EventArgs e)
        {
            if (this.StopWatchForBuzzer.IsRunning == true)
                this.StopWatchForBuzzer.Stop();
            this.timerBuzzer.Enabled = false;
            this.TransferData(CommunicationCommand.BuzzerOnContinuousDisable, CommunicationID.MainBoard);
        }
        private void timerRFIDNGSend_Tick(object sender, EventArgs e)
        {
            System.Windows.Forms.Timer timer = sender as System.Windows.Forms.Timer;
            timer.Enabled = false;
            string referenceTag = this.CurrentRFID.ReturnTag(0);

            if (this.ReferenceTag == referenceTag)
                if (this.CurrentRFID.Count() > 1)
                    referenceTag = this.CurrentRFID.ReturnTag(1);

            // 로그
            if (this.IsCommunicationLogOpen == true)
                this.smartFileCommunicationLog.WriteString(string.Format("Tick:referenceTag ({0:yyyy-MM-dd HH:mm:ss}): {1} : {2}", DateTime.Now, this.CurrentRFID.Count(), referenceTag));
            for (int i = 0; i < this.CurrentRFID.Count(); i++)
                this.smartFileCommunicationLog.WriteString(string.Format("ListTag ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, this.CurrentRFID.ReturnTag(i)));

            try
            {
                if (referenceTag == "")
                {
                    this.SendAlarmToPC("R1");
                    this.TransferData(CommunicationCommand.JudgmentExternalNG, CommunicationID.MainBoard);
                }
                else
                {
                    if (this.CurrentRFID.CompareToBARCD(referenceTag) == RFIDDataStore.VerifyCode.Fail_Filter)
                    {
                        this.SendAlarmToPC("R3");
                        this.TransferData(CommunicationCommand.JudgmentExternalNG, CommunicationID.MainBoard);
                    }
                    else if (this.CurrentRFID.CompareToBARCD(referenceTag) == RFIDDataStore.VerifyCode.Fail_StandardCode)
                    {
                        this.SendAlarmToPC("R4");
                        this.TransferData(CommunicationCommand.JudgmentExternalNG, CommunicationID.MainBoard);
                    }
                }
            }
            catch
            {
                this.SendAlarmToPC("P1");
                this.TransferData(CommunicationCommand.JudgmentExternalNG, CommunicationID.MainBoard);
            }

            timer.Dispose();
            timer = null;
        }
        private void timerSensorError_Tick(object sender, EventArgs e)
        {
            this.ChildFormMainDisplay.AlarmOccurs("센서 에러", "Sensor Error", "---");

            this.TransferData(CommunicationCommand.BuzzerOn, CommunicationID.MainBoard);
            this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
            if (this.SystemConfig3.IsStartStopLog == true)
                this.smartFileStartStopLog.WriteString(string.Format("Send Stop ({0:yyyy-MM-dd HH:mm:ss}): FormMain-timerSensorError_Tick", DateTime.Now));
            this.timerSensorError.Enabled = false;
        }

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

        private void timerClientConnect_Tick(object sender, EventArgs e)
        {
            this.timerClientConnect.Enabled = false;
            this.IsClientConnectTryTimerStart = false;

            if (this.IsEthernetClientConnect == false)
            {
                this.EthernetClientConnect();

                //Console.Write("\n" + string.Format("{0:yyyy-MM-dd HH:mm:ss}: {1}", DateTime.Now, "timerClientConnect - Try connect"));
            }
        }

        //private void timerRFIDRead_Tick(object sender, EventArgs e)
        //{
        //    this.TimerRFIDRead.Stop();
        //}
        //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(DataStore.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;
        //}
        #endregion
    }
}