///<summary> ///<para>Parse test data from LTX stdf test result in to datatable (multifile)</para> ///<seealso cref="DataParse.GetDataFromStd"/> ///</summary> /// <param name="fileName">Full patch with file name of the stdf file (multifile)</param> /// <returns>DataTable</returns> public async Task<DataTable> GetDataFromStdfviewerTask(string[] arrayFileName) { #region *** Variable define *** DataTable DataParseResult = new DataTable(); DataTable[] DataParseResultTemp = new DataTable[arrayFileName.Length]; double parseTime = 0; double insertTime = 0; int deviceCount = 0; int testedDevice = 0; int passedDevice = 0; int failedDevice = 0; DataHeader header = new Common.DataHeader(); Bin bin = new Common.Bin(); bool isFirstFile = true; bool isFirstTable = true; DateTime dtLotStart = DateTime.Now; DateTime dtLotFinish = DateTime.Now; Dictionary<string, int> headerDic = new Dictionary<string, int>(); #endregion *** Variable define *** #region *** Innitial Properties *** bin.DeviceCount = new int[8]; bin.Name = new string[8]; bin.Number = new int[8]; bin.Percent = new double[8]; header.SessionCount = 0; #endregion *** Innitial Properties *** try { #region *** Parsing Data *** int i = 0; foreach (string fileName in arrayFileName) { string ext = Path.GetExtension(fileName); using (FileStream fs = new FileStream(fileName, FileMode.Open)) { if (ext.ToLower() == ".std") { DataParseResultTemp[i] = await Task.Run(() => this.GetDataFromStdfviewer(fs)); } else if (ext.ToLower() == ".gz") { using (GZipStream gzs = new GZipStream(fs, CompressionMode.Decompress)) { DataParseResultTemp[i] = await Task.Run(() => this.GetDataFromStdfviewer(gzs)); } } else { throw new Exception("only for std/stdf or contain std/stdf gzip file! {Task<DataTable> GetDataFromStdfviewerTask(string[] arrayFileName)}"); } i++; } #region *** Caculate Properties *** header.SessionCount++; parseTime += m_ParseTime; insertTime += m_InsertTime; testedDevice += m_TestedDevice; passedDevice += m_PassedDevice; failedDevice += m_FailedDevice; header.FailQuantity += m_Header.FailQuantity; header.LotQuantity += m_Header.LotQuantity; header.PassQuantity += m_Header.PassQuantity; header.TestQuantity += m_Header.TestQuantity; header.enVision_Version = m_Header.enVision_Version; if (isFirstFile) { header.LotID = m_Header.LotID; header.SubLotID = m_Header.SubLotID; header.OperatorID = m_Header.OperatorID; header.TestBoard = m_Header.TestBoard; header.DeviceName = m_Header.DeviceName; header.Tester = m_Header.Tester; header.Handler = m_Header.Handler; header.TesterType = m_Header.TesterType; header.Product = m_Header.Product; header.ProgramRev = m_Header.ProgramRev; header.TestSession = m_Header.TestSession; dtLotStart = Convert.ToDateTime(m_Header.LotStartDateTime); dtLotFinish = Convert.ToDateTime(m_Header.LotFinishDateTime); isFirstFile = false; } else { if (m_Header.LotID != "" && m_Header.LotID != null) header.LotID = header.LotID + " & " + m_Header.LotID; if (m_Header.SubLotID != "" && m_Header.SubLotID != null) header.SubLotID = header.SubLotID + " & " + m_Header.SubLotID; if (m_Header.OperatorID != "" && m_Header.OperatorID != null) header.OperatorID = header.OperatorID + " & " + m_Header.OperatorID; if (m_Header.TestBoard != "" && m_Header.TestBoard != null) header.TestBoard = header.TestBoard + " & " + m_Header.TestBoard; if (m_Header.Tester != "" && m_Header.Tester != null) header.Tester = header.Tester + " & " + m_Header.Tester; if (m_Header.TesterType != "" && m_Header.TesterType != null) header.TesterType = header.TesterType + " & " + m_Header.TesterType; if (m_Header.Handler != "" && m_Header.Handler != null) header.Handler = header.Handler + " & " + m_Header.Handler; if (m_Header.TestSession != "" && m_Header.TestSession != null) header.TestSession = header.TestSession + " & " + m_Header.TestSession; //Lot Start Datetime if (m_Header.LotStartDateTime < dtLotStart) { dtLotStart = m_Header.LotStartDateTime; } //Lot Finish Datetime if (m_Header.LotFinishDateTime > dtLotFinish) { dtLotFinish = m_Header.LotFinishDateTime; } //Check Product Name if (m_Header.Product != header.Product) { throw new Exception("file " + fileName + " has different Product name with before."); } //Check Program Rev if (m_Header.ProgramRev != header.ProgramRev) { throw new Exception("file " + fileName + " has different Program Rev with before."); } }//end of if firstfile header.Yield = Math.Round(Convert.ToDouble(header.PassQuantity) / Convert.ToDouble(header.TestQuantity) * 100, 3); header.LotStartDateTime = dtLotStart; header.LotFinishDateTime = dtLotFinish; for (int j = 0; j < 8; j++) { bin.DeviceCount[j] += m_Bin.DeviceCount[j]; bin.Name[j] = m_Bin.Name[j]; bin.Number[j] = m_Bin.Number[j]; bin.Percent[j] = Math.Round(Convert.ToDouble(bin.DeviceCount[j]) / Convert.ToDouble(m_TestedDevice) * 100, 3); } #endregion *** Caculate Properties *** } //end of foreach (string fileName in arrayFileName) #endregion *** Parsing Data *** #region *** Merge Data Table *** foreach (DataTable tblDataTemp in DataParseResultTemp) if (isFirstTable) { isFirstTable = false; //Build table structure DataParseResult = tblDataTemp.Clone(); foreach (DataRow dr in tblDataTemp.Rows) { DataParseResult.ImportRow(dr); } //get first table device count deviceCount = DataParseResult.Rows.Count - 4; } else { //merge less columns datatable to more columns datatable if (tblDataTemp.Columns.Count > DataParseResult.Columns.Count) { foreach (DataRow dr in DataParseResult.Rows) { if (DataParseResult.Rows.IndexOf(dr) > 3) { //reset device count deviceCount++; dr[0] = deviceCount; tblDataTemp.ImportRow(dr); //Move Status Column to last int lastRowIndex = tblDataTemp.Rows.Count - 1; int lastColumnIndex = tblDataTemp.Columns.Count - 1; tblDataTemp.Rows[lastRowIndex][lastColumnIndex] = dr[DataParseResult.Columns.Count - 1]; tblDataTemp.Rows[lastRowIndex][DataParseResult.Columns.Count - 1] = null; } } DataParseResult = tblDataTemp; } else { try { tblDataTemp.PrimaryKey = null; foreach (DataRow dr in tblDataTemp.Rows) { if (tblDataTemp.Rows.IndexOf(dr) > 3) { //reset device count deviceCount++; dr[0] = deviceCount; DataParseResult.ImportRow(dr); //Move Status Column to last if (tblDataTemp.Columns.Count < DataParseResult.Columns.Count) { int lastRowIndex = DataParseResult.Rows.Count - 1; int lastColumnIndex = DataParseResult.Columns.Count - 1; DataParseResult.Rows[lastRowIndex][lastColumnIndex] = dr[tblDataTemp.Columns.Count - 1]; DataParseResult.Rows[lastRowIndex][tblDataTemp.Columns.Count - 1] = null; } } }//end of foreach (DataRow dr in DataParseResultTemp.Rows) } catch (Exception ex) { throw new Exception(ex.Message); } }//end of if (DataParseResultTemp.Columns.Count > DataParseResult.Columns.Count) }// end of if else (isFirstTable) #endregion *** Merge Data Table *** #region *** Final Properties *** m_Bin = bin; m_Header = header; m_FailedDevice = failedDevice; m_PassedDevice = passedDevice; m_TestedDevice = testedDevice; m_ParseTime = parseTime; m_InsertTime = insertTime; #endregion *** Final Properties *** } catch (Exception ex) { throw new Exception("Parse data error \n "+ ex.Message); } DataParseResult.PrimaryKey = new DataColumn[] { DataParseResult.Columns[0] }; return DataParseResult; }
///<summary> ///<para>Parse test data from LTX stdf test result in to datatable (multifile)</para> ///<seealso cref="DataParse.GetDataFromStd"/> ///</summary> /// <param name="fileName">Full patch with file name of the stdf file (multifile)</param> /// <returns>DataTable</returns> public DataTable GetDataFromStd(string[] arrayFileName) { #region *** Variable define *** DataTable DataParseResult = new DataTable(); DataTable DataParseResultTemp = new DataTable(); double parseTime = 0; double insertTime = 0; int deviceCount = 0; int testedDevice = 0; int passedDevice = 0; int failedDevice = 0; DataHeader header = new Common.DataHeader(); Bin bin = new Common.Bin(); bool isFirstFile = true; bool isFirstTable = true; DateTime dtLotStart = DateTime.Now; DateTime dtLotFinish = DateTime.Now; Dictionary<string, int> headerDic = new Dictionary<string, int>(); #endregion *** Variable define *** #region *** Innitial Properties *** bin.DeviceCount = new int[8]; bin.Name = new string[8]; bin.Number = new int[8]; bin.Percent = new double[8]; header.SessionCount = 0; #endregion *** Innitial Properties *** #region *** Get and merge data table *** try { foreach (string fileName in arrayFileName) //Parallel.ForEach(arrayFileName, fileName => { DataParseResultTemp = this.GetDataFromStd(fileName); #region *** Caculate Properties *** header.SessionCount++; parseTime += m_ParseTime; insertTime += m_InsertTime; testedDevice += m_TestedDevice; passedDevice += m_PassedDevice; failedDevice += m_FailedDevice; header.FailQuantity += m_Header.FailQuantity; header.LotQuantity += m_Header.LotQuantity; header.PassQuantity += m_Header.PassQuantity; header.TestQuantity += m_Header.TestQuantity; header.enVision_Version = m_Header.enVision_Version; if (isFirstFile) { header.LotID = m_Header.LotID; header.SubLotID = m_Header.SubLotID; header.OperatorID = m_Header.OperatorID; header.TestBoard = m_Header.TestBoard; header.DeviceName = m_Header.DeviceName; header.Tester = m_Header.Tester; header.Handler = m_Header.Handler; header.TesterType = m_Header.TesterType; header.Product = m_Header.Product; header.ProgramRev = m_Header.ProgramRev; dtLotStart = Convert.ToDateTime(m_Header.LotStartDateTime); dtLotFinish = Convert.ToDateTime(m_Header.LotFinishDateTime); isFirstFile = false; } else { if (m_Header.LotID != "" && m_Header.LotID != null) header.LotID = header.LotID + " & " + m_Header.LotID; if (m_Header.SubLotID != "" && m_Header.SubLotID != null) header.SubLotID = header.SubLotID + " & " + m_Header.SubLotID; if (m_Header.OperatorID != "" && m_Header.OperatorID != null) header.OperatorID = header.OperatorID + " & " + m_Header.OperatorID; if (m_Header.TestBoard != "" && m_Header.TestBoard != null) header.TestBoard = header.TestBoard + " & " + m_Header.TestBoard; if (m_Header.Tester != "" && m_Header.Tester != null) header.Tester = header.Tester + " & " + m_Header.Tester; if (m_Header.TesterType != "" && m_Header.TesterType != null) header.TesterType = header.TesterType + " & " + m_Header.TesterType; if (m_Header.Handler != "" && m_Header.Handler != null) header.Handler = header.Handler + " & " + m_Header.Handler; //Lot Start Datetime if (m_Header.LotStartDateTime < dtLotStart) { dtLotStart = m_Header.LotStartDateTime; } //Lot Finish Datetime if (m_Header.LotFinishDateTime > dtLotFinish) { dtLotFinish = m_Header.LotFinishDateTime; } //Check Product Name if (m_Header.Product != header.Product) { throw new Exception("file " + fileName + " has different Product name with before."); } //Check Program Rev if (m_Header.ProgramRev != header.ProgramRev) { throw new Exception("file " + fileName + " has different Program Rev with before."); } }//end of if firstfile header.Yield = Math.Round(Convert.ToDouble(header.PassQuantity) / Convert.ToDouble(header.TestQuantity) * 100, 3); header.LotStartDateTime = dtLotStart; header.LotFinishDateTime = dtLotFinish; for (int i = 0; i < 8; i++) { bin.DeviceCount[i] += m_Bin.DeviceCount[i]; bin.Name[i] = m_Bin.Name[i]; bin.Number[i] = m_Bin.Number[i]; bin.Percent[i] = Math.Round(Convert.ToDouble(bin.DeviceCount[i]) / Convert.ToDouble(m_TestedDevice) * 100, 3); } #endregion *** Caculate Properties *** #region *** Merge Data Table *** if (isFirstTable) { isFirstTable = false; //Build table structure DataParseResult = DataParseResultTemp.Clone(); foreach (DataRow dr in DataParseResultTemp.Rows) { DataParseResult.ImportRow(dr); } //get first table device count deviceCount = DataParseResult.Rows.Count - 4; } else { //merge less columns datatable to more columns datatable if (DataParseResultTemp.Columns.Count > DataParseResult.Columns.Count) { foreach (DataRow dr in DataParseResult.Rows) { if (DataParseResult.Rows.IndexOf(dr) > 3) { //reset device count deviceCount++; dr[0] = deviceCount; DataParseResultTemp.ImportRow(dr); //Move Status Column to last int lastRowIndex = DataParseResultTemp.Rows.Count - 1; int lastColumnIndex = DataParseResultTemp.Columns.Count - 1; DataParseResultTemp.Rows[lastRowIndex][lastColumnIndex] = dr[DataParseResult.Columns.Count - 1]; DataParseResultTemp.Rows[lastRowIndex][DataParseResult.Columns.Count - 1] = null; } } DataParseResult = DataParseResultTemp; } else { foreach (DataRow dr in DataParseResultTemp.Rows) { if (DataParseResultTemp.Rows.IndexOf(dr) > 3) { //reset device count deviceCount++; dr[0] = deviceCount; DataParseResult.ImportRow(dr); //Move Status Column to last if (DataParseResultTemp.Columns.Count < DataParseResult.Columns.Count) { int lastRowIndex = DataParseResult.Rows.Count - 1; int lastColumnIndex = DataParseResult.Columns.Count - 1; DataParseResult.Rows[lastRowIndex][lastColumnIndex] = dr[DataParseResultTemp.Columns.Count - 1]; DataParseResult.Rows[lastRowIndex][DataParseResultTemp.Columns.Count - 1] = null; } } }//end of foreach (DataRow dr in DataParseResultTemp.Rows) }//end of if (DataParseResultTemp.Columns.Count > DataParseResult.Columns.Count) }// end of if else (isFirstTable) #endregion *** Merge Data Table *** }//);//end of foreach (string fileName in arrayFileName) #region *** Final Properties *** m_Bin = bin; m_Header = header; m_FailedDevice = failedDevice; m_PassedDevice = passedDevice; m_TestedDevice = testedDevice; m_ParseTime = parseTime; m_InsertTime = insertTime; #endregion *** Final Properties *** } catch (Exception ex) { throw new Exception("Parse data error \n " + ex.Message); } #endregion *** Parse test data from txt file *** DataParseResult.PrimaryKey = new DataColumn[] { DataParseResult.Columns[0] }; return DataParseResult; }