private void button1_Click(object sender, EventArgs e) { OpenFileDialog ofd1 = new OpenFileDialog(); ofd1.Filter = "STDF文件|*.std|所有文件|*.*"; if (ofd1.ShowDialog() == DialogResult.OK) { Record stdf = new Record(); DateTime dt_start = DateTime.Now; stdf.AnalyzeFile(ofd1.FileName); TimeSpan ts = DateTime.Now - dt_start; headerTable = stdf.GetHeaderStr(); dataTable = stdf.GetData(); dataGridView1.DataSource = headerTable; dataGridView2.DataSource = dataTable; dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; for (int i = 0; i < 3; i++) { dataGridView2.Rows[i].DefaultCellStyle.BackColor = Color.LightGray; } for (int i = 0; i < 5; i++) { dataGridView2.Columns[i].DefaultCellStyle.BackColor = Color.LightGray; } this.Text = (ts.TotalSeconds * 1000).ToString(); } }
///<summary> ///<para>Parse test data from LTX std test result in to datatable(use stdf viewer tool)</para> ///<seealso cref="DataParse.GetDataFromTxt"/> ///</summary> /// <param name="fileName">Full patch with file name of the std/stdf file</param> /// <returns>DataTable</returns> public DataTable GetDataFromStdfviewer(string fileName) { #region *** Variable define *** DateTime dtStart; TimeSpan ts; DataRow dr; DataTable temp_header = new DataTable(); DataTable temp_data = new DataTable(); DataTable DataParseResult = new DataTable(); StringBuilder sbData1 = new StringBuilder(); StringBuilder sbData2 = new StringBuilder(); StringBuilder sbColumnName = new StringBuilder("Device#,1,2,3,4"); StringBuilder sbParameter = new StringBuilder("Test Item,Site No,Soft Bin,Hard Bin,Device ID"); StringBuilder sbLowLimit = new StringBuilder("Low Limit,,,,"); StringBuilder sbHighLimit = new StringBuilder("High Limit,,,,"); StringBuilder sbUnits = new StringBuilder("Units,,,,"); bool isLimitSet = false; int ParameterLength = 0; int intColumnLength = 0; int intDeviceCounter = 1; int i; string PassFail1, PassFail2; #endregion *** Variable define *** #region *** Initialize properties *** m_FreezeColumn = 5; m_ParseTime = 0; m_InsertTime = 0; m_TestedDevice = 0; m_PassedDevice = 0; m_FailedDevice = 0; m_Header = new DataHeader(); m_Bin = new Bin(); m_Bin.DeviceCount = new int[8]; m_Bin.Name = new string[8]; m_Bin.Number = new int[8]; m_Bin.Percent = new double[8]; m_Header.SessionCount = 0; #endregion *** Initialize properties *** //Timer session dtStart = DateTime.Now; #region // Analysis stdf file STDF_Viewer.Record stdf_viewer = new STDF_Viewer.Record(); stdf_viewer.AnalyzeFile(fileName); temp_header = stdf_viewer.GetHeaderStr(); temp_data = stdf_viewer.GetData(); #endregion ts = DateTime.Now - dtStart; #region // Build datatable int col_index = 0; foreach (DataColumn temp_dc in temp_data.Columns) { if (col_index == 0) DataParseResult.Columns.Add("Device#", typeof(string)); else { DataParseResult.Columns.Add(col_index.ToString(), typeof(string)); if (col_index >= 5) sbParameter.Append("," + temp_dc.ColumnName.ToString()); } col_index++; } #endregion #region // insert test decription col_index =0; DataRow dr_Parameter = DataParseResult.NewRow(); string[] temp_array_Parameter = sbParameter.ToString().Split(','); foreach (string temp_Parameter in temp_array_Parameter) { dr_Parameter[col_index] = temp_Parameter; col_index++; } DataParseResult.Rows.Add(dr_Parameter); #endregion #region // Insert unit and limit int row_index =0; col_index = 0; Dictionary<int, double> dic_multiplier = new Dictionary<int, double>(); foreach (DataRow temp_dr in temp_data.Rows) { //initialize the unit nultiplier if (row_index == 0) { temp_dr[0] = "Unit"; for (col_index = 5; col_index < temp_dr.ItemArray.Length; col_index++) { if (temp_data.Columns[col_index].ToString().ToLower().Contains("status")) { dic_multiplier.Add(col_index, 5272); // 5272 is keyValue for pass/fail columns continue; } #region new rule if (temp_dr[col_index].ToString().ToUpper() == "A" && temp_data.Columns[col_index].ToString().ToLower().Contains("_ua")) { temp_dr[col_index] = "uA"; dic_multiplier.Add(col_index, 1000 * 1000); continue; } else if (temp_dr[col_index].ToString().ToUpper() == "A") /// && temp_data.Columns[col_index].ToString().ToLower().Contains("_ma")) { if (temp_data.Columns[col_index].ToString().ToLower().Contains("leakage")) { temp_dr[col_index] = "uA"; dic_multiplier.Add(col_index, 1000 * 1000); } else { temp_dr[col_index] = "mA"; dic_multiplier.Add(col_index, 1000); } continue; } else if (temp_dr[col_index].ToString().ToUpper() == "S" && temp_data.Columns[col_index].ToString().ToLower().Contains("_us")) { temp_dr[col_index] = "us"; dic_multiplier.Add(col_index, 1000 * 1000); continue; } else if (temp_dr[col_index].ToString().ToUpper() == "S" && temp_data.Columns[col_index].ToString().ToLower().Contains("_ms")) { temp_dr[col_index] = "ms"; dic_multiplier.Add(col_index, 1000); continue; } else if (temp_dr[col_index].ToString().ToUpper() == "S") ///&& temp_data.Columns[col_index].ToString().ToLower().Contains("_ms")) { temp_dr[col_index] = "ms"; dic_multiplier.Add(col_index, 1000); continue; } #endregion #region old rule_1 //if (temp_dr[col_index].ToString().ToUpper() == "A") //{ // if (temp_data.Columns[col_index].ToString().ToLower().Contains("leakage")) // { // temp_dr[col_index] = "uA"; // dic_multiplier.Add(col_index, 1000 * 1000); // } // else // { // temp_dr[col_index] = "mA"; // dic_multiplier.Add(col_index, 1000); // } //} //else if (temp_dr[col_index].ToString().ToUpper() == "S") //{ // temp_dr[col_index] = "ms"; // dic_multiplier.Add(col_index, 1000); //} #endregion } } else { if (row_index == 1) temp_dr[0] = "Low Limit"; else if (row_index == 2) temp_dr[0] = "High Limit"; // apply unit multiplier foreach (var item in dic_multiplier) { if (item.Value != 5272) temp_dr[item.Key] = Convert.ToDouble(temp_dr[item.Key]) * item.Value; } } DataParseResult.Rows.Add (temp_dr.ItemArray); row_index++; if (row_index > 2) break; } #endregion #region // insert data // remove limit and unit which none float rows temp_data.Rows.RemoveAt(0); temp_data.Rows.RemoveAt(0); temp_data.Rows.RemoveAt(0); // unit convertion (A -> mA / uA, S -> ms ) // generate extra columns by using multiplier then copy to new datatable DataTable temp_data_mid = new DataTable(); temp_data_mid = temp_data.Clone(); for (col_index = 0; col_index < temp_data.Columns.Count; col_index++) { if (col_index < 5) temp_data_mid.Columns[col_index].DataType = typeof(int); else if (col_index == temp_data.Columns.Count - 1) temp_data_mid.Columns[col_index].DataType = typeof(int); else temp_data_mid.Columns[col_index].DataType = typeof(float); } foreach (DataRow dr_mid in temp_data.Rows) { temp_data_mid.Rows.Add(dr_mid.ItemArray); } for (col_index = 0; col_index < temp_data.Columns.Count; col_index++) { DataColumn dc_temp_mid = new DataColumn(col_index.ToString(), typeof(string)); temp_data_mid.Columns.Add(dc_temp_mid); // set exrpession if (dic_multiplier.ContainsKey(col_index)) { if (dic_multiplier[col_index] == 5272) dc_temp_mid.Expression = "IIF(" + temp_data_mid.Columns[col_index].ColumnName + "=0, 'Pass', 'Fail')"; else { dc_temp_mid.Expression = "[" + temp_data_mid.Columns[col_index].ColumnName + "] * " + dic_multiplier[col_index]; //dc_temp_mid.Expression = "Convert([" + temp_data_mid.Columns[col_index].ColumnName + "] * " + dic_multiplier[col_index] + " * 1000, 'System.Int32')/1000"; } } else { dc_temp_mid.Expression = "[" + temp_data_mid.Columns[col_index].ColumnName + "] * 1"; //dc_temp_mid.Expression = "Convert([" + temp_data_mid.Columns[col_index].ColumnName + "] * 1000, 'System.Int32')/1000"; } } int start = DataParseResult.Columns.Count; int length = start; foreach (DataRow dr_temp in temp_data_mid.Rows) { object[] arr_temp = new object[length]; Array.ConstrainedCopy(dr_temp.ItemArray, start, arr_temp, 0, length); DataParseResult.Rows.Add(arr_temp); } // set primary key DataParseResult.PrimaryKey = new DataColumn[] { DataParseResult.Columns[0] }; #endregion #region // header info Dictionary<string, string> dic_header = new Dictionary<string, string>(); foreach (DataRow dc_header in temp_header.Rows) { dic_header.Add(dc_header[0].ToString().Trim(), dc_header[1].ToString().Trim()); } string temp = dic_header["MIR.JOB_NAM"]; this.GetProgramNameRev(temp); m_Header.SessionCount++; m_Header.enVision_Version = dic_header["MIR.EXEC_VER"]; m_Header.LotID = dic_header["MIR.LOT_ID"]; m_Header.Tester = dic_header["MIR.NODE_NAM"]; m_Header.DeviceName = dic_header["MIR.PART_TYP"]; m_Header.SubLotID = dic_header["MIR.SBLOT_ID"]; m_Header.TesterType = dic_header["MIR.TSTR_TYP"]; m_Header.TestSession = dic_header["MIR.TEST_COD"]; try { m_Header.LotStartDateTime = DateTime.Parse(dic_header["MIR.START_T"]); } catch { m_Header.LotStartDateTime = DateTime.Parse("1900-1-1 0:00"); } try { m_Header.LotFinishDateTime = DateTime.Parse(dic_header["MRR.FINISH_T"]); } catch { m_Header.LotFinishDateTime = DateTime.Parse("1900-1-1 0:00"); } m_Header.LotDesc = dic_header["MRR.USR_DESC"]; m_TestedDevice = m_Header.TestQuantity = Convert.ToInt32(dic_header["PCR.PART_CNT"]); if (m_TestedDevice == 0) m_TestedDevice = m_Header.TestQuantity = DataParseResult.Rows.Count - 4; m_PassedDevice = m_Header.PassQuantity = Convert.ToInt32(dic_header["PCR.GOOD_CNT"]); if (m_PassedDevice == 0) { DataRow[] drs = DataParseResult.Select("[" + (DataParseResult.Columns.Count - 1) + "] Like 'Pass'"); m_PassedDevice = m_Header.PassQuantity = drs.Count(); } m_FailedDevice = m_Header.FailQuantity = m_Header.TestQuantity - m_Header.PassQuantity; //Yield double yield = Convert.ToDouble(m_Header.PassQuantity) / Convert.ToDouble(m_Header.TestQuantity) * 100; m_Header.Yield = Math.Round(yield, 2); #endregion //Timer session ts = DateTime.Now - dtStart; ParseTime = ts.TotalMilliseconds; dtStart = DateTime.Now; DataParseResult.PrimaryKey = new DataColumn[] { DataParseResult.Columns[0] }; return DataParseResult; //throw new Exception("ooops"); }
///<summary> ///<para>Parse test data from LTX std test result in to datatable(use stdf viewer tool)</para> ///<seealso cref="DataParse.GetDataFromTxt"/> ///</summary> /// <param name="fileStream">Full patch with file name of the std/stdf file(compressed.gz)</param> /// <returns>DataTable</returns> public DataTable GetDataFromStdfviewer(Stream fileStream) { #region *** Variable define *** DateTime dtStart; TimeSpan ts; DataTable temp_header = new DataTable(); DataTable DataParseResult = new DataTable(); #endregion *** Variable define *** #region *** Initialize properties *** m_FreezeColumn = 5; m_ParseTime = 0; m_InsertTime = 0; m_TestedDevice = 0; m_PassedDevice = 0; m_FailedDevice = 0; m_Header = new DataHeader(); m_Bin = new Bin(); m_Bin.DeviceCount = new int[8]; m_Bin.Name = new string[8]; m_Bin.Number = new int[8]; m_Bin.Percent = new double[8]; m_Header.SessionCount = 0; #endregion *** Initialize properties *** //Timer session dtStart = DateTime.Now; #region // Analysis stdf file STDF_Viewer.Record stdf_viewer = new STDF_Viewer.Record(); using (fileStream) { stdf_viewer.AnalyzeFile(fileStream); } ts = DateTime.Now - dtStart; temp_header = stdf_viewer.GetHeaderStr(); DataParseResult = stdf_viewer.GetData(); #endregion #region // header info Dictionary<string, string> dic_header = new Dictionary<string, string>(); foreach (DataRow dc_header in temp_header.Rows) { dic_header.Add(dc_header[0].ToString().Trim(), dc_header[1].ToString().Trim()); } string temp = dic_header["MIR.JOB_NAM"]; this.GetProgramNameRev(temp); m_Header.SessionCount++; m_Header.enVision_Version = dic_header["MIR.EXEC_VER"]; m_Header.LotID = dic_header["MIR.LOT_ID"]; m_Header.Tester = dic_header["MIR.NODE_NAM"]; m_Header.DeviceName = dic_header["MIR.PART_TYP"]; m_Header.SubLotID = dic_header["MIR.SBLOT_ID"]; m_Header.TesterType = dic_header["MIR.TSTR_TYP"]; m_Header.TestSession = dic_header["MIR.TEST_COD"]; try { m_Header.LotStartDateTime = DateTime.Parse(dic_header["MIR.START_T"]); } catch { m_Header.LotStartDateTime = DateTime.Parse("1900-1-1 0:00"); } try { m_Header.LotFinishDateTime = DateTime.Parse(dic_header["MRR.FINISH_T"]); } catch { m_Header.LotFinishDateTime = DateTime.Parse("1900-1-1 0:00"); } m_Header.LotDesc = dic_header["MRR.USR_DESC"]; m_TestedDevice = m_Header.TestQuantity = Convert.ToInt32(dic_header["PCR.PART_CNT"]); if (m_TestedDevice == 0) m_TestedDevice = m_Header.TestQuantity = DataParseResult.Rows.Count - 4; m_PassedDevice = m_Header.PassQuantity = Convert.ToInt32(dic_header["PCR.GOOD_CNT"]); if (m_PassedDevice == 0) { DataRow[] drs = DataParseResult.Select("[" + (DataParseResult.Columns.Count - 1) + "] Like 'Pass'"); m_PassedDevice = m_Header.PassQuantity = drs.Count(); } m_FailedDevice = m_Header.FailQuantity = m_Header.TestQuantity - m_Header.PassQuantity; //Yield double yield = Convert.ToDouble(m_Header.PassQuantity) / Convert.ToDouble(m_Header.TestQuantity) * 100; m_Header.Yield = Math.Round(yield, 2); #endregion //Timer session ts = DateTime.Now - dtStart; ParseTime = ts.TotalMilliseconds; dtStart = DateTime.Now; DataParseResult.PrimaryKey = new DataColumn[] { DataParseResult.Columns[0] }; return DataParseResult; //throw new Exception("ooops"); }
private void button1_Click(object sender, EventArgs e) { OpenFileDialog ofd1 = new OpenFileDialog(); ofd1.Filter = "STDF文件|*.std|所有文件|*.*"; if (ofd1.ShowDialog() == DialogResult.OK) { Record stdf = new Record(); DateTime dt_start = DateTime.Now; if (Path.GetExtension(ofd1.FileName).ToLower() == ".std") { using (FileStream fs = new FileStream(ofd1.FileName, FileMode.Open)) { stdf.AnalyzeFile(fs); } } else if (Path.GetExtension(ofd1.FileName).ToLower() == ".gz") { using (FileStream fs = new FileStream(ofd1.FileName, FileMode.Open)) { using (GZipStream gzs = new GZipStream(fs, CompressionMode.Decompress)) { stdf.AnalyzeFile(gzs); //using (MemoryStream OutputStream = new MemoryStream()) //{ // gzs.CopyTo(OutputStream); // stdf.AnalyzeFile(OutputStream); //} } } } TimeSpan ts = DateTime.Now - dt_start; this.Text = ts.TotalMilliseconds.ToString(); headerTable = stdf.GetHeaderStr(); dataTable = stdf.GetData(); dataGridView1.DataSource = headerTable; dataGridView2.DataSource = dataTable; dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; for (int i = 0; i < 3; i++) { dataGridView2.Rows[i].DefaultCellStyle.BackColor = Color.LightGray; } for (int i = 0; i < 5; i++) { dataGridView2.Columns[i].DefaultCellStyle.BackColor = Color.LightGray; } this.Text = (ts.TotalSeconds * 1000).ToString(); } }