Example #1
0
        public dllESDRegister._Execution SaveLogFile(dllESDRegister._Object _Register, string _address, string _name, string _msg, string _status)
        {
            dllESDRegister._Execution _execution_result = new dllESDRegister._Execution();
            string _temp_msg = "";

            _folderpath = "LogFile\\" + Convert.ToString(System.DateTime.Now.Year) + Convert.ToString(System.DateTime.Now.Month).PadLeft(2, '0') + Convert.ToString(System.DateTime.Now.Day).PadLeft(2, '0');
            _filepath   = Directory.GetCurrentDirectory() + "\\" + _folderpath + ".cfg";
            string _time = DateTime.Now.Hour.ToString().PadLeft(2, '0') + ":" + DateTime.Now.Minute.ToString().PadLeft(2, '0') + ":" + DateTime.Now.Second.ToString().PadLeft(2, '0');

            _temp_msg = _time + "\t\t" + _address + "\t\t" + _name + "\t\t" + _msg + "\t\t" + _status + "\r\n";

            /*if (!Directory.Exists(_folderpath))
             *  Directory.CreateDirectory(_folderpath);*/
            if (!File.Exists(_filepath))
            {
                _temp_msg = "時間    \t\t" + "地址\t\t" + "站名\t\t" + "狀態信息\t\t" + "狀態\t\t" + "\r\n";
                File.AppendAllText(_filepath, _temp_msg, Encoding.Default);
            }
            else
            {
                File.AppendAllText(_filepath, _temp_msg, Encoding.Default);
            }

            return(_execution_result.Clone() as dllESDRegister._Execution);
        }
Example #2
0
        public dllESDRegister._Execution LoadFile_Location(dllESDRegister._Object _Register)
        {
            string[] _sfileCount = new string[100];
            dllESDRegister._Execution _execution_result = new dllESDRegister._Execution();
            string[] _Item;

            if (File.Exists("Location.cfg"))
            {
                _sfileCount = File.ReadAllLines("Location.cfg");

                for (int i = 0; i < 5; i++)
                {
                    if (_sfileCount[i].Contains("[Location]"))
                    {
                        for (int _x = 0; _x < 0x40; _x++)
                        {
                            _Item = _sfileCount[++i].Split('~', '=', ':');
                            _Register.ESDTSystem.ESDLocation[_x] = _Item[2];
                            _Register.ESDTSystem.ESDDisable[_x]  = _Item[3];
                        }
                    }
                }
            }
            return(_execution_result.Clone() as dllESDRegister._Execution);
        }
Example #3
0
        private void LoadItem_SettingESDUart(dllESDRegister._Object _Register, int i)
        {
            string[] _sIndexVariable = _sFileContant[i + 1].Split('=', '~');

            for (int j = 1; j <= (Convert.ToInt16(_sIndexVariable[2])); j++)
            {
                string[] _sVeriableName = _sFileContant[i + j].Split('=', '~');
                switch (Convert.ToInt16(_sVeriableName[0]))
                {
                case 1: _Register.ESDTSystem.ESDUart_Setting.index = _sVeriableName[2]; break;

                case 2: _Register.ESDTSystem.ESDUart_Setting.CommunicationType = _sVeriableName[2]; break;

                case 3: _Register.ESDTSystem.ESDUart_Setting.ESDVendor = _sVeriableName[2]; break;

                case 4: _Register.ESDTSystem.ESDUart_Setting.ESDModel = _sVeriableName[2]; break;

                case 5: _Register.ESDTSystem.ESDUart_Setting.ESDPort = _sVeriableName[2]; break;

                case 6: _Register.ESDTSystem.ESDUart_Setting.ESDBautRate = _sVeriableName[2]; break;

                case 7: _Register.ESDTSystem.ESDUart_Setting.ESDParity = _sVeriableName[2]; break;

                case 8: _Register.ESDTSystem.ESDUart_Setting.ESDDataBits = _sVeriableName[2]; break;

                case 9: _Register.ESDTSystem.ESDUart_Setting.ESDStopBits = _sVeriableName[2]; break;
                }
            }
        }
Example #4
0
        // ~啟動ESD BOARD通訊設定 public static void UART_Open()~
        public dllESDRegister._Execution _UART_Open(dllESDRegister._Object _Register)
        {
            dllESDRegister._Execution _execution_result = new dllESDRegister._Execution();
            try
            {
                if (System_IO_SerialPort_ESD.IsOpen == false)
                {
                    System_IO_SerialPort_ESD.Open();
                }

                return(_execution_result.Clone() as dllESDRegister._Execution);
            }
            #region 例外
            catch (UnauthorizedAccessException)
            {
                //ISP Board被其他未知程式占用
                System_IO_SerialPort_ESD.Close();
                return(_execution_result.Clone() as dllESDRegister._Execution);
            }

            catch (IOException)
            {
                //關閉ISP傳輸埠失敗
                System_IO_SerialPort_ESD.Close();
                return(_execution_result.Clone() as dllESDRegister._Execution);
            }

            catch (ArgumentOutOfRangeException)
            {
                //串口設定值不符合該設備
                System_IO_SerialPort_ESD.Close();
                return(_execution_result.Clone() as dllESDRegister._Execution);
            }

            catch (ArgumentNullException)
            {
                //ISP Board參數錯誤
                System_IO_SerialPort_ESD.Close();
                return(_execution_result.Clone() as dllESDRegister._Execution);
            }

            catch (InvalidOperationException)
            {
                //通訊開啟中,請關閉該通訊,始可開始設定
                System_IO_SerialPort_ESD.Close();
                return(_execution_result.Clone() as dllESDRegister._Execution);
            }
            catch (TimeoutException)
            {
                //通訊開啟中,請關閉該通訊,始可開始設定
                System_IO_SerialPort_ESD.Close();
                return(_execution_result.Clone() as dllESDRegister._Execution);
            }
            #endregion
        }
Example #5
0
        public dllESDRegister._Execution LoadFile_TSystem(dllESDRegister._Object _Register)
        {
            dllESDRegister._Execution _execution_result = new dllESDRegister._Execution();

            _sFileContant = File.ReadAllLines("TSystem.cfg");

            if (!LoadTitle(_Register)._blResult_execution_Item)
            {
                return(_execution_result.Clone() as dllESDRegister._Execution);
            }
            return(_execution_result.Clone() as dllESDRegister._Execution);
        }
Example #6
0
 private int SaveItem_Setting_ESDUart(dllESDRegister._Object _Register, int i)
 {
     _sFileContant_temp[i++] = "1~" + "Index=" + _Register.ESDTSystem.ESDUart_Setting.index;
     _sFileContant_temp[i++] = "2~" + "CommunicationType=" + _Register.ESDTSystem.ESDUart_Setting.CommunicationType;
     _sFileContant_temp[i++] = "3~" + "ESDVendor=" + _Register.ESDTSystem.ESDUart_Setting.ESDVendor;
     _sFileContant_temp[i++] = "4~" + "ESDModel=" + _Register.ESDTSystem.ESDUart_Setting.ESDModel;
     _sFileContant_temp[i++] = "5~" + "ESDPort=" + _Register.ESDTSystem.ESDUart_Setting.ESDPort;
     _sFileContant_temp[i++] = "6~" + "ESDBautRate=" + _Register.ESDTSystem.ESDUart_Setting.ESDBautRate;
     _sFileContant_temp[i++] = "7~" + "ESDParity=" + _Register.ESDTSystem.ESDUart_Setting.ESDParity;
     _sFileContant_temp[i++] = "8~" + "ESDDataBits=" + _Register.ESDTSystem.ESDUart_Setting.ESDDataBits;
     _sFileContant_temp[i++] = "9~" + "ESDStopBits=" + _Register.ESDTSystem.ESDUart_Setting.ESDStopBits;
     return(i);
 }
Example #7
0
        public dllESDRegister._Execution SaveFile_TSystem(dllESDRegister._Object _Register)
        {
            dllESDRegister._Execution _execution_result = new dllESDRegister._Execution();

            if (!SaveTitle(_Register)._blResult_execution_Item)
            {
                return(_execution_result.Clone() as dllESDRegister._Execution);
            }
            _execution_result._blResult_execution_Item = true;

            File.WriteAllLines("TSystem.cfg", _sFileContant_temp);

            return(_execution_result.Clone() as dllESDRegister._Execution);
        }
Example #8
0
        private void LoadItem_Setting(dllESDRegister._Object _Register, int i)
        {
            string[] _sIndexVariable = _sFileContant[i + 1].Split('=', '~');

            for (int j = 1; j <= (Convert.ToInt16(_sIndexVariable[2])); j++)
            {
                string[] _sVeriableName = _sFileContant[i + j].Split('=', '~');
                switch (Convert.ToInt16(_sVeriableName[0]))
                {
                case 1: _Register.ESDTSystem.ESD_Setting.index = _sVeriableName[2]; break;

                case 2: _Register.ESDTSystem.ESD_Setting.EnableESD = _sVeriableName[2]; break;
                }
            }
        }
Example #9
0
        private dllESDRegister._Execution SaveTitle(dllESDRegister._Object _Register)
        {
            dllESDRegister._Execution _execution_result = new dllESDRegister._Execution();
            int _temp_WriteLineCount;

            _execution_result._blResult_execution_Item = true;
            _temp_WriteLineCount = 0;

            _sFileContant_temp[_temp_WriteLineCount] = "[Setting]";
            _temp_WriteLineCount = SaveItem_Setting(_Register, _temp_WriteLineCount + 1);
            _sFileContant_temp[_temp_WriteLineCount++] = "";

            _sFileContant_temp[_temp_WriteLineCount] = "[ESDUart_Setting]";
            _temp_WriteLineCount = SaveItem_Setting_ESDUart(_Register, _temp_WriteLineCount + 1);
            _sFileContant_temp[_temp_WriteLineCount++] = "";

            return(_execution_result.Clone() as dllESDRegister._Execution);
        }
Example #10
0
        public dllESDRegister._Execution SaveFile_Location(dllESDRegister._Object _Register)
        {
            string[] _sfileCount = new string[100];
            string   _temp       = "";
            int      _Countline  = 0;

            dllESDRegister._Execution _execution_result = new dllESDRegister._Execution();

            _sfileCount[_Countline++] = "[Location]";

            for (int _x = 0; _x < 0x40; _x++)
            {
                _temp = Convert.ToString(_x, 16).PadLeft(2, '0').ToUpper();
                _sfileCount[_Countline++] = _temp + "~" + "ESDLocation_" + _temp + "=" + _Register.ESDTSystem.ESDLocation[_x] + ":" + _Register.ESDTSystem.ESDDisable[_x];
            }

            File.WriteAllLines("Location.cfg", _sfileCount);
            return(_execution_result.Clone() as dllESDRegister._Execution);
        }
Example #11
0
        private dllESDRegister._Execution LoadTitle(dllESDRegister._Object _Register)
        {
            dllESDRegister._Execution _execution_result = new dllESDRegister._Execution();

            for (Int32 i = 0; i <= (_sFileContant.Length - 1); i++)
            {
                if (_sFileContant[i].Contains("["))
                {
                    if (_sFileContant[i] == "[Setting]")
                    {
                        LoadItem_Setting(_Register, i);
                    }

                    if (_sFileContant[i] == "[ESDUart_Setting]")
                    {
                        LoadItem_SettingESDUart(_Register, i);
                    }
                }
            }
            return(_execution_result.Clone() as dllESDRegister._Execution);
        }
Example #12
0
 private int SaveItem_Setting(dllESDRegister._Object _Register, int i)
 {
     _sFileContant_temp[i++] = "1~" + "Index=" + _Register.ESDTSystem.ESD_Setting.index;
     _sFileContant_temp[i++] = "2~" + "EnableESD=" + _Register.ESDTSystem.ESD_Setting.EnableESD;
     return(i);
 }
Example #13
0
        // ~ESD BOARD傳輸元件
        public dllESDRegister._Execution _UART_Transmitter(dllESDRegister._Object _Register, byte[] _CMD_Coding, int _CMD_WaitDelayTime)
        {
            dllESDRegister._Execution _execution_result = new dllESDRegister._Execution();
            try
            {
                if (System_IO_SerialPort_ESD.IsOpen == false)
                {
                    System_IO_SerialPort_ESD.Open();
                }

                System_IO_SerialPort_ESD.DiscardInBuffer();
                System_IO_SerialPort_ESD.DiscardOutBuffer();

                System_IO_SerialPort_ESD.Write(_CMD_Coding, 0, 1);      //write data into serial port for 12 bytes
                if (_WaitDelayTime_Return(_CMD_WaitDelayTime) == true)  //call wait delay time try to fine the serial port buffer to compare return bytes = 12 bytes
                {
                    int _readcount = 0;
                    while (System_IO_SerialPort_ESD.BytesToRead != 0)
                    {
                        _execution_result.abytResult_ack[_readcount] = Convert.ToByte(System_IO_SerialPort_ESD.ReadByte());
                        _readcount++;
                    }

                    _readcount--;

                    if (_readcount == 0)
                    {
                        //_execution_result. _subFail_Level(_Const. Return_Status. Retest, ErrorCode. EISP20);
                    }
                }

                _execution_result.intResult_length = System_IO_SerialPort_ESD.BytesToRead;
                return(_execution_result.Clone() as dllESDRegister._Execution);
            }
            #region 例外
            catch (UnauthorizedAccessException)
            {
                //ISP Board被其他未知程式占用
                System_IO_SerialPort_ESD.Close();
                return(_execution_result.Clone() as dllESDRegister._Execution);
            }

            catch (IOException)
            {
                //關閉ISP傳輸埠失敗
                System_IO_SerialPort_ESD.Close();
                return(_execution_result.Clone() as dllESDRegister._Execution);
            }

            catch (ArgumentOutOfRangeException)
            {
                //串口設定值不符合該設備
                System_IO_SerialPort_ESD.Close();
                return(_execution_result.Clone() as dllESDRegister._Execution);
            }

            catch (ArgumentNullException)
            {
                //ISP Board參數錯誤
                System_IO_SerialPort_ESD.Close();
                return(_execution_result.Clone() as dllESDRegister._Execution);
            }

            catch (InvalidOperationException)
            {
                //通訊開啟中,請關閉該通訊,始可開始設定
                System_IO_SerialPort_ESD.Close();
                return(_execution_result.Clone() as dllESDRegister._Execution);
            }

            catch (TimeoutException)
            {
                //通訊開啟中,請關閉該通訊,始可開始設定
                System_IO_SerialPort_ESD.Close();
                return(_execution_result.Clone() as dllESDRegister._Execution);
            }
            #endregion
        }
Example #14
0
        // ~定義ESD BOARD通訊設定 public static void UART_Define()~
        public dllESDRegister._Execution _UART_Define(dllESDRegister._Object _Register)
        {
            dllESDRegister._Execution _execution_result = new dllESDRegister._Execution();

            try
            {
                if (System_IO_SerialPort_ESD.IsOpen == true)
                {
                    System_IO_SerialPort_ESD.Close();
                }

                System_IO_SerialPort_ESD.PortName = _Register.ESDTSystem.ESDUart_Setting.ESDPort;
                System_IO_SerialPort_ESD.BaudRate = Convert.ToInt32(_Register.ESDTSystem.ESDUart_Setting.ESDBautRate);
                System_IO_SerialPort_ESD.Parity   = (Parity)Convert.ToInt16(_Register.ESDTSystem.ESDUart_Setting.ESDParity);
                System_IO_SerialPort_ESD.DataBits = Convert.ToInt16(_Register.ESDTSystem.ESDUart_Setting.ESDDataBits);
                System_IO_SerialPort_ESD.StopBits = (StopBits)Convert.ToInt16(_Register.ESDTSystem.ESDUart_Setting.ESDStopBits);

                System_IO_SerialPort_ESD.Encoding = System.Text.UnicodeEncoding.Unicode;

                System_IO_SerialPort_ESD.DtrEnable    = false;
                System_IO_SerialPort_ESD.RtsEnable    = false;
                System_IO_SerialPort_ESD.DiscardNull  = false;
                System_IO_SerialPort_ESD.WriteTimeout = 1000;
                System_IO_SerialPort_ESD.ReadTimeout  = 1000;

                return(_execution_result.Clone() as dllESDRegister._Execution);
            }
            #region 例外
            catch (UnauthorizedAccessException)
            {
                //ISP Board被其他未知程式占用
                System_IO_SerialPort_ESD.Close();
                return(_execution_result.Clone() as dllESDRegister._Execution);
            }

            catch (IOException)
            {
                //關閉ISP傳輸埠失敗
                System_IO_SerialPort_ESD.Close();
                return(_execution_result.Clone() as dllESDRegister._Execution);
            }

            catch (ArgumentOutOfRangeException)
            {
                //串口設定值不符合該設備
                System_IO_SerialPort_ESD.Close();
                return(_execution_result.Clone() as dllESDRegister._Execution);
            }

            catch (ArgumentNullException)
            {
                //ISP Board參數錯誤
                System_IO_SerialPort_ESD.Close();
                return(_execution_result.Clone() as dllESDRegister._Execution);
            }

            catch (InvalidOperationException)
            {
                //通訊開啟中,請關閉該通訊,始可開始設定
                System_IO_SerialPort_ESD.Close();
                return(_execution_result.Clone() as dllESDRegister._Execution);
            }
            catch (TimeoutException)
            {
                //通訊開啟中,請關閉該通訊,始可開始設定
                System_IO_SerialPort_ESD.Close();
                return(_execution_result.Clone() as dllESDRegister._Execution);
            }
            #endregion
        }