Ejemplo n.º 1
0
        private void RefreshWafer(DeviceType deviceType, string product)
        {
            if (product == "")
            {
                return;
            }

            string   filename;
            Graphics graphics;
            Dictionary <string, WaferDie> wafers = new Dictionary <string, WaferDie>();

            filename = FTPClient.DownloadFile(Parameter.CurrentDevice, product);

            if (File.Exists(filename))
            {
                WaferFile.GetInfo(Parameter.CurrentDevice, filename, ref wafers);

                if (deviceType == DeviceType.HL9309)
                {
                    Parameter.DeviceHL9309.FilePath = filename;
                    graphics = hl9309PictureBox.CreateGraphics();

                    _hl9309WaferDieDic.Clear();
                    foreach (string key in wafers.Keys)
                    {
                        _hl9309WaferDieDic.Add(key, wafers[key]);
                    }
                }
                else
                {
                    Parameter.DeviceHL9308.FilePath = filename;
                    graphics = hl9308PictureBox.CreateGraphics();

                    _hl9308WaferDieDic.Clear();
                    foreach (string key in wafers.Keys)
                    {
                        _hl9308WaferDieDic.Add(key, wafers[key]);
                    }
                }

                this.Invoke(new EventHandler(delegate
                {
                    if (Parameter.CurrentDevice == deviceType)
                    {
                        fileComboBox.Text = Path.GetFileName(filename);
                    }

                    WaferDrawing(deviceType, filename, wafers, graphics);
                }));
            }

            wafers.Clear();
            wafers = null;
        }
Ejemplo n.º 2
0
        private void WaferDrawing(string filepath, Graphics graphics)
        {
            Pen        pen = new Pen(SystemColors.ControlDark, 1);
            SolidBrush solidBrush = new SolidBrush(Color.Black);
            Font       font = new Font(new FontFamily("Times New Roman"), 10, FontStyle.Regular, GraphicsUnit.Pixel);
            Color      color1, color2;
            int        x, y, width, height;
            double     zThreshold;
            WaferDie   die;
            PointF     pointF;

            string[] points;

            pictureBox1.Refresh();

            _WaferDieDic.Clear();
            WaferFile.GetInfo(Parameter.CurrentDevice, filepath, ref _WaferDieDic);

            if (Parameter.CurrentDevice == DeviceType.HL9309)
            {
                zThreshold = Parameter.DeviceHL9309.Z_Threshold;
                color1     = Parameter.DeviceHL9309.DieColor1;
                color2     = Parameter.DeviceHL9309.DieColor2;
            }
            else
            {
                zThreshold = Parameter.DeviceHL9308.Z_Threshold;
                color1     = Parameter.DeviceHL9308.DieColor1;
                color2     = Parameter.DeviceHL9308.DieColor2;
            }

            foreach (string key in _WaferDieDic.Keys)
            {
                points = key.Split(',');

                if (points.Length >= 4)
                {
                    Int32.TryParse(points[0], out x);
                    Int32.TryParse(points[1], out y);
                    Int32.TryParse(points[2], out width);
                    Int32.TryParse(points[3], out height);

                    die = _WaferDieDic[key];

                    solidBrush.Color = (Math.Abs(die.z) > zThreshold) ? color2 : color1;

                    graphics.FillRectangle(solidBrush, x, y, width, height);

                    pointF           = new PointF(x + (width - 9) / 2, y + (height - 9) / 2 - 2);
                    solidBrush.Color = Color.Black;
                    graphics.DrawString(Convert.ToInt32(die.z).ToString(), font, solidBrush, pointF);
                }
            }
        }
Ejemplo n.º 3
0
        private void exportBtn_Click(object sender, EventArgs e)
        {
            if (_WaferDieDic.Count == 0)
            {
                return;
            }

            string device, product, excelFile;

            if (Parameter.CurrentDevice == DeviceType.HL9309)
            {
                device    = "1HL9309";
                product   = Parameter.DeviceHL9309.ProductName;
                excelFile = Path.GetDirectoryName(Parameter.DeviceHL9309.FilePath) + "\\" + Path.GetFileNameWithoutExtension(Parameter.DeviceHL9309.FilePath) + ".xlsx";
            }
            else
            {
                device    = "1HL9308";
                product   = Parameter.DeviceHL9308.ProductName;
                excelFile = Path.GetDirectoryName(Parameter.DeviceHL9308.FilePath) + "\\" + Path.GetFileNameWithoutExtension(Parameter.DeviceHL9308.FilePath) + ".xlsx";
            }

            Application.UseWaitCursor = true;
            this.Cursor       = Cursors.WaitCursor;
            exportBtn.Enabled = false;
            closeBtn.Enabled  = false;

            if (WaferFile.SaveToExcel(excelFile, device, product, Path.GetFileName(_Filepath), _WaferDieDic) == 0)
            {
                MessageBox.Show("Save to " + excelFile, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            exportBtn.Enabled         = true;
            closeBtn.Enabled          = true;
            Application.UseWaitCursor = false;
            this.Cursor = Cursors.Default;
        }
Ejemplo n.º 4
0
        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Excel.Application xlApp       = null;
            Excel.Workbook    xlWorkbook  = null;
            Excel.Worksheet   xlWorksheet = null;
            Excel.Sheets      xlSheets    = null;
            Excel.Range       xlRange;

            int      startX, startY, endX, endY, value, column, index = 2;
            string   filename, filepath, device, product, savepath = "";
            WaferDie die;

            string[] points;
            string[] title = { "Device", "Product", "Filename", "Focus Field", "Z", "Average laser energy", "Laser stability" };
            Dictionary <string, WaferDie> waferdies = new Dictionary <string, WaferDie>();

            Application.UseWaitCursor = true;
            this.Cursor = Cursors.WaitCursor;

            backBtn.Enabled       = false;
            searchTextBox.Enabled = false;
            waferListBox.Enabled  = false;

            if (waferListBox.SelectedIndices.Count > 0)
            {
                if (Parameter.CurrentDevice == DeviceType.HL9309)
                {
                    device   = "1HL9309";
                    product  = Parameter.DeviceHL9309.ProductName;
                    filepath = Parameter.DeviceHL9309.HistoryPath + product + "/";
                }
                else
                {
                    device   = "1HL9308";
                    product  = Parameter.DeviceHL9308.ProductName;
                    filepath = Parameter.DeviceHL9308.HistoryPath + product + "/";
                }

                xlApp               = new Microsoft.Office.Interop.Excel.Application();
                xlWorkbook          = xlApp.Workbooks.Add(Type.Missing);
                xlSheets            = xlWorkbook.Sheets as Excel.Sheets;
                xlApp.Visible       = false;
                xlApp.DisplayAlerts = false;

                int count = xlWorkbook.Worksheets.Count;

                for (; count < waferListBox.SelectedIndices.Count; count++)
                {
                    xlWorkbook.Worksheets.Add(Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                }

                for (int i = 0; i < waferListBox.SelectedIndices.Count; i++)
                {
                    try
                    {
                        filename = waferListBox.GetItemAt(waferListBox.SelectedIndices[i], 1).ToString();
                        filename = filepath + Path.GetFileNameWithoutExtension(filename) + ".wafer/" + filename;
                        if (File.Exists(filename))
                        {
                            WaferFile.GetInfo(Parameter.CurrentDevice, filename, ref waferdies);

                            xlWorksheet      = (Excel.Worksheet)xlWorkbook.Worksheets[i + 1];
                            xlWorksheet.Name = Path.GetFileNameWithoutExtension(filename) + ".wafer";

                            column = 1;
                            for (int j = 0; j < title.Length; j++)
                            {
                                xlRange                   = (Excel.Range)xlWorksheet.Cells[column, j + 1];
                                xlRange.Value2            = title[j];
                                xlRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous;
                            }
                            column++;

                            foreach (string key in waferdies.Keys)
                            {
                                points = key.Split(',');

                                if (points.Length >= 4)
                                {
                                    Int32.TryParse(points[0], out value);
                                    startX = (value - Parameter.Offset) / Parameter.RectangleWeight;

                                    Int32.TryParse(points[1], out value);
                                    startY = (value - Parameter.Offset) / Parameter.RectangleWeight;

                                    Int32.TryParse(points[2], out value);
                                    endX = value / Parameter.RectangleWeight + startX;

                                    Int32.TryParse(points[3], out value);
                                    endY = value / Parameter.RectangleWeight + startY;

                                    die = waferdies[key];

                                    try
                                    {
                                        xlRange                   = (Excel.Range)xlWorksheet.Cells[column, 1];
                                        xlRange.Value2            = device;
                                        xlRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous;

                                        xlRange                   = (Excel.Range)xlWorksheet.Cells[column, 2];
                                        xlRange.Value2            = product;
                                        xlRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous;

                                        xlRange                   = (Excel.Range)xlWorksheet.Cells[column, 3];
                                        xlRange.Value2            = Path.GetFileName(filename);
                                        xlRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous;

                                        xlRange = (Excel.Range)xlWorksheet.Cells[column, 4];
                                        string location = string.Format("({0},{1}) ({2},{3})", startX, startY, endX, endY);
                                        xlRange.Value2            = location;
                                        xlRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous;

                                        xlRange                   = (Excel.Range)xlWorksheet.Cells[column, 5];
                                        xlRange.Value2            = die.z.ToString("f2");
                                        xlRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous;

                                        xlRange                   = (Excel.Range)xlWorksheet.Cells[column, 6];
                                        xlRange.Value2            = die.energy.ToString("f2");
                                        xlRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous;

                                        xlRange                   = (Excel.Range)xlWorksheet.Cells[column, 7];
                                        xlRange.Value2            = die.stability.ToString("f2");
                                        xlRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous;
                                    }
                                    catch (Exception ex)
                                    {
                                        EventLog.Write(ex.Message);
                                    }

                                    column++;
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        EventLog.Write("SPC: " + ex.Message);
                    }
                }

                savepath = Parameter.SpcPath + device + "_" + product + "_wafers.xlsx";
                while (File.Exists(savepath))
                {
                    savepath = Parameter.SpcPath + device + "_" + product + "_wafers_" + index.ToString() + ".xlsx";
                    index++;
                }

                try
                {
                    xlWorkbook.SaveAs(savepath, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Excel.XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
                }
                catch (Exception ex)
                {
                    EventLog.Write("SPC: " + ex.Message);
                }

                if (xlApp != null)
                {
                    xlWorkbook.Close(Type.Missing, savepath, Type.Missing);
                    xlApp.Quit();

                    if (xlWorksheet != null)
                    {
                        Marshal.ReleaseComObject(xlWorksheet);
                        xlWorksheet = null;
                    }

                    if (xlWorkbook != null)
                    {
                        Marshal.ReleaseComObject(xlWorkbook);
                        xlWorkbook = null;
                    }

                    Marshal.ReleaseComObject(xlApp);
                    xlApp = null;
                }

                GC.Collect();

                MessageBox.Show("Save to " + savepath, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            } //count > 0

            Application.UseWaitCursor = false;
            this.Cursor = Cursors.Default;

            backBtn.Enabled       = true;
            searchTextBox.Enabled = true;
            waferListBox.Enabled  = true;

            waferdies.Clear();
            waferdies = null;
        }
Ejemplo n.º 5
0
        private void exportBtn_Click(object sender, EventArgs e)
        {
            if (productComboBox.Text == "" || fileComboBox.Text == "")
            {
                return;
            }

            int    result;
            string excelFile, device;
            Dictionary <string, WaferDie> wafers = new Dictionary <string, WaferDie>();

            if (Parameter.CurrentDevice == DeviceType.HL9309)
            {
                if (_hl9309WaferDieDic.Count == 0)
                {
                    return;
                }

                device    = "1HL9309";
                excelFile = Path.GetDirectoryName(Parameter.DeviceHL9309.FilePath) + "\\" + Path.GetFileNameWithoutExtension(Parameter.DeviceHL9309.FilePath) + ".xlsx";

                foreach (string key in _hl9309WaferDieDic.Keys)
                {
                    wafers.Add(key, _hl9309WaferDieDic[key]);
                }
            }
            else
            {
                if (_hl9308WaferDieDic.Count == 0)
                {
                    return;
                }

                device    = "1HL9308";
                excelFile = Path.GetDirectoryName(Parameter.DeviceHL9308.FilePath) + "\\" + Path.GetFileNameWithoutExtension(Parameter.DeviceHL9308.FilePath) + ".xlsx";

                foreach (string key in _hl9308WaferDieDic.Keys)
                {
                    wafers.Add(key, _hl9308WaferDieDic[key]);
                }
            }

            Application.UseWaitCursor = true;
            this.Cursor = Cursors.WaitCursor;
            EnableControls(false);

            result = WaferFile.SaveToExcel(excelFile, device, productComboBox.Text, fileComboBox.Text, wafers);

            if (result == 0)
            {
                MessageBox.Show("Save to " + excelFile, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            EnableControls(true);
            Application.UseWaitCursor = false;
            this.Cursor = Cursors.Default;

            wafers.Clear();
            wafers = null;

            GC.Collect();
        }
Ejemplo n.º 6
0
        public static string DownloadFile(DeviceType deviceType, string product)
        {
            FileStream    writeStream  = null;
            StreamReader  streamReader = null;
            Stream        stream       = null;
            StringBuilder result;

            string[] dirs = null, files = null;
            string   line, filepath, uri, ftpIp, user, pwd, logPath, historyPath, folder;
            string   extension, dirname;
            int      Length = 2048, bytesRead;

            Byte[] buffer;

            if (deviceType == DeviceType.HL9309)
            {
                ftpIp       = Parameter.DeviceHL9309.FtpIP;
                user        = Parameter.DeviceHL9309.FtpUser;
                pwd         = Parameter.DeviceHL9309.FtpPwd;
                logPath     = Parameter.DeviceHL9309.LogPath + product + "/";
                historyPath = Parameter.DeviceHL9309.HistoryPath + product + "/";
                folder      = "/" + Parameter.DeviceHL9309.Folder + "/";
            }
            else
            {
                ftpIp       = Parameter.DeviceHL9308.FtpIP;
                user        = Parameter.DeviceHL9308.FtpUser;
                pwd         = Parameter.DeviceHL9308.FtpPwd;
                logPath     = Parameter.DeviceHL9308.LogPath + product + "/";
                historyPath = Parameter.DeviceHL9308.HistoryPath + product + "/";
                folder      = "/" + Parameter.DeviceHL9308.Folder + "/";
            }

            try
            {
                Directory.CreateDirectory(logPath);
                Directory.CreateDirectory(historyPath);
            }
            catch (Exception ex)
            {
                EventLog.Write(ex.Message);
                return("");
            }

            EventLog.Write("FTPClient.DownloadFile Start");

            uri                  = ftpIp + product + folder;
            _request             = (FtpWebRequest)FtpWebRequest.Create(uri);
            _request.Method      = WebRequestMethods.Ftp.ListDirectory;
            _request.Credentials = new NetworkCredential(user, pwd);
            _request.Timeout     = 10000;
            _request.KeepAlive   = true;

            try
            {
                EventLog.Write("FTPClient.Download ListDirectory");
                streamReader = new StreamReader(_request.GetResponse().GetResponseStream());
                result       = new StringBuilder();
                line         = streamReader.ReadLine();

                while (line != null)
                {
                    result.Append(line);
                    result.Append("\n");
                    line = streamReader.ReadLine();
                }

                if (result.Length > 0)
                {
                    result.Remove(result.ToString().LastIndexOf('\n'), 1);
                    dirs = result.ToString().Split('\n');
                }
            }
            catch (Exception ex)
            {
                EventLog.Write(ex.Message);
            }
            finally
            {
                if (streamReader != null)
                {
                    streamReader.Close();
                    streamReader = null;
                }
            }

            if (dirs != null)
            {
                EventLog.Write("FTPClient.Download files");
                foreach (string dir in dirs)
                {
                    extension = Path.GetExtension(dir);
                    dirname   = Path.GetFileNameWithoutExtension(dir);

                    if (extension.CompareTo(".wafer") != 0)
                    {
                        continue;
                    }

                    if (Directory.Exists(historyPath + dir))
                    {
                        continue;
                    }

                    try
                    {
                        Directory.CreateDirectory(logPath + dir);
                    }
                    catch (Exception ex)
                    {
                        EventLog.Write(ex.Message);
                        continue;
                    }


                    files = null;

                    uri                  = ftpIp + product + folder + dir + "/";
                    _request             = (FtpWebRequest)FtpWebRequest.Create(uri);
                    _request.Method      = WebRequestMethods.Ftp.ListDirectory;
                    _request.Credentials = new NetworkCredential(user, pwd);
                    _request.Timeout     = 10000;
                    _request.KeepAlive   = true;

                    try
                    {
                        streamReader = new StreamReader(_request.GetResponse().GetResponseStream());
                        result       = new StringBuilder();
                        line         = streamReader.ReadLine();

                        while (line != null)
                        {
                            result.Append(line);
                            result.Append("\n");
                            line = streamReader.ReadLine();
                        }

                        if (result.Length > 0)
                        {
                            result.Remove(result.ToString().LastIndexOf('\n'), 1);
                            files = result.ToString().Split('\n');
                        }
                    }
                    catch (Exception ex)
                    {
                        EventLog.Write(ex.Message);
                    }
                    finally
                    {
                        if (streamReader != null)
                        {
                            streamReader.Close();
                            streamReader = null;
                        }
                    }

                    if (files == null)
                    {
                        continue;
                    }

                    foreach (string file in files)
                    {
                        filepath = logPath + dir + "/" + file;
                        uri      = ftpIp + product + folder + dir + "/" + file;

                        _request             = (FtpWebRequest)FtpWebRequest.Create(uri);
                        _request.Method      = WebRequestMethods.Ftp.DownloadFile;
                        _request.Credentials = new NetworkCredential(user, pwd);
                        _request.Timeout     = 10000;
                        _request.KeepAlive   = true;

                        try
                        {
                            stream      = _request.GetResponse().GetResponseStream();
                            writeStream = new FileStream(filepath, FileMode.Create);

                            buffer    = new Byte[Length];
                            bytesRead = stream.Read(buffer, 0, Length);

                            while (bytesRead > 0)
                            {
                                writeStream.Write(buffer, 0, bytesRead);
                                bytesRead = stream.Read(buffer, 0, Length);
                            }
                        }
                        catch (Exception ex)
                        {
                            EventLog.Write(ex.Message);
                        }
                        finally
                        {
                            if (writeStream != null)
                            {
                                writeStream.Close();
                                writeStream = null;
                            }

                            if (stream != null)
                            {
                                stream.Close();
                                stream = null;
                            }
                        }
                    }
                }
            }

            EventLog.Write("FTPClient.DownloadFile End");
            return(WaferFile.Sort(deviceType, product, logPath, historyPath));
        }