Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 3
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
        }
Esempio n. 4
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);
        }
Esempio n. 5
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);
        }
Esempio n. 6
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);
        }
Esempio n. 7
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);
        }
Esempio n. 8
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);
        }
Esempio n. 9
0
File: Form1.cs Progetto: wwwK/2016
        private void button2_Click(object sender, EventArgs e)
        {
            _ESDUart.Device_ESD.CMD_Component._UART_Define(_Register);
            _ESDUart.Device_ESD.CMD_Component._UART_Open(_Register);

            byte[] _transmitter = new byte[1];
            _transmitter[0]  = 0x05;
            _ExecutionResult = _ESDUart.Device_ESD.CMD_Component._UART_Transmitter(_Register, _transmitter, 100);

            _ESDUart.Device_ESD.CMD_Component._UART_Close(_Register);


            /*
             * ((Panel)ArrayList[i]). Controls[x]. Text = "xxxxxx";
             *
             * foreach (Control control in (Panel)ArrayList[i]).Controls)
             * {
             * if(control is TextBox)
             * {
             * control.Text = "xxxxxx";
             * }
             * }
             */
        }
Esempio n. 10
0
File: Form1.cs Progetto: wwwK/2016
        private void StartTest()
        {
            _ESDUart.Device_ESD.CMD_Component._UART_Define(_Register);
            _ESDUart.Device_ESD.CMD_Component._UART_Open(_Register);
            byte[] _transmitter = new byte[1];
            int    _temp_Int;
            string _temp_address;
            string _temp_name;

            TextBoxEnble();
            // progressBar1.Enabled = true;

            while (_MeasureStop)
            {
                for (int _x = 0x00; _x < 0x40; _x++)
                {
                    if (_MeasureStop == false)
                    {
                        break;
                    }
                    if (Convert.ToBoolean(_Register.ESDTSystem.ESDDisable[_x]) == true)
                    {
                        ESDPanel.Controls[_x].Controls[3].BackColor = Color.LightGray;
                        continue;
                    }
                    _transmitter[0]  = (byte)_x;
                    _ExecutionResult = _ESDUart.Device_ESD.CMD_Component._UART_Transmitter(_Register, _transmitter, 10);

                    progressBar1.Value = _x;
                    _temp_Int          = (int)_ExecutionResult.abytResult_ack[0];
                    if (_x != (int)_ExecutionResult.abytResult_ack[1] && (int)_ExecutionResult.abytResult_ack[1] != 0)
                    {
                        if (_temp_count != 0)
                        {
                            _temp_count--;
                            _x--;
                            continue;
                        }
                    }
                    _temp_address = ESDPanel.Controls[_x].Controls[2].Text;
                    _temp_name    = ESDPanel.Controls[_x].Controls[1].Text;
                    switch (_temp_Int)
                    {
                    case 0:
                        ESDPanel.Controls[_x].Controls[3].BackColor = Color.Yellow;
                        if (_Register.ESDTSystem.ESDStatus[_x] != _temp_Int)
                        {
                            _FileAP.FAPLocation.SaveLogFile(_Register, _temp_address, _temp_name, "靜電環未偵測到", "0");
                        }
                        _Register.ESDTSystem.ESDStatus[_x] = _temp_Int;
                        break;

                    case 223:
                        ESDPanel.Controls[_x].Controls[3].BackColor = Color.Green;
                        if (_Register.ESDTSystem.ESDStatus[_x] != _temp_Int)
                        {
                            _FileAP.FAPLocation.SaveLogFile(_Register, _temp_address, _temp_name, "靜電環帶上", "1");
                        }
                        _Register.ESDTSystem.ESDStatus[_x] = _temp_Int;
                        break;

                    case 239:
                        ESDPanel.Controls[_x].Controls[3].BackColor = Color.Red;
                        if (_Register.ESDTSystem.ESDStatus[_x] != _temp_Int)
                        {
                            _FileAP.FAPLocation.SaveLogFile(_Register, _temp_address, _temp_name, "靜電環取下", "2");
                        }
                        _Register.ESDTSystem.ESDStatus[_x] = _temp_Int;
                        break;

                    case 3:
                        ESDPanel.Controls[_x].Controls[3].BackColor = Color.LightGray;
                        if (_Register.ESDTSystem.ESDStatus[_x] != _temp_Int)
                        {
                            _FileAP.FAPLocation.SaveLogFile(_Register, _temp_address, _temp_name, "未定義狀態", "3");
                        }
                        _Register.ESDTSystem.ESDStatus[_x] = _temp_Int;
                        break;
                    }
                    _temp_count = 3;
                    Application.DoEvents();
                }
            }
            _ESDUart.Device_ESD.CMD_Component._UART_Close(_Register);
            progressBar1.Enabled = false;
        }
Esempio n. 11
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
        }
Esempio n. 12
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
        }