////////////////////////////////////////// // Scripts to be used with Examinator Monitoring / Yield-MAN // Version 2006.11.28 // (c) 2006 Galaxy. All rights reserved // www.galaxysemi.com ////////////////////////////////////////// ////////////////////////////////////////// // Process All files in folder // Create report for each of them ////////////////////////////////////////// ProcessFileInFolder(var vInFolder,var vOutFolder,var vErase) { var vFile; var group_id; // Forces to create report in the same directory as where files are found gexOptions('output','location',vOutFolder); // Create report for each file found vFile = fileFindFirst(vInFolder,'*.std;*.stdf'); while(vFile != '') { // Setup the GEX Options SetOptions(); // Forces to create report in the file directory. gexOptions('output','location',vOutFolder); // Load file in group gexGroup('reset','all'); group_id = gexGroup('insert','DataSet_1'); gexFile(group_id,'insert',vFile,'All','all',' ',''); // Setup the GEX Report type (Settings) SetReportType(); // Analyze data and build the report, do not show report page BuildReport(); // Erase source file if(vErase == 1) fileDelete(vFile); // Get next file to process vFile = fileFindNext(); }; } ////////////////////////////////////////// // Process All files in folder, convert them to STDF ////////////////////////////////////////// ConvertFolderToSTDF(var vInFolder,var vOutFolder,var vInExtensions, var vLogFile, var vErase) { var vFile; var vOutputFileTmp; var vOutputFile; var vFileName; var vStatus; var vLogMessage; // Create report for each file found vFile = fileFindFirst(vInFolder,vInExtensions); while(vFile != '') { // Display date & time of data processing. vLogMessage = 'Date: ' + sysDateTime() + '\n'; // Extract file name from full file+path name vFileName = strSplitPath(vFile); // Build output file (temporary name) vOutputFileTmp = vOutFolder + '/' + vFileName + '.tmp'; // Convert file to STDF vStatus = gexConvertSTDF(vFile,vOutputFileTmp); // check if successful conversion if(vStatus != 1) { // Rename file to '.bad' extension vOutputFile = vFile + '.bad'; fileDelete(vOutputFile); fileRename(vFile,vOutputFile); // Create Log message vLogMessage = vLogMessage + '* ERROR * Failed on file: ' + vFile + ' (renamed to .bad extension)'; } else { // Success converting to STDF format vOutputFile = vOutFolder + '/' + vFileName + '_gexmo.std'; fileDelete(vOutputFile); // Erase source file if(vErase == 1) fileDelete(vFile); else { // Rename input file processed to .ok vOutputFile = vFile + '.ok'; fileDelete(vOutputFile); fileRename(vFile,vOutputFile); // Rename output file to .std vOutputFile = vOutFolder + '/' + vFileName + '_gexmo.std'; fileDelete(vOutputFile); fileRename(vOutputFileTmp,vOutputFile); } vLogMessage = vLogMessage + 'Success on file: ' + vFile; } // Output error message to log file var fh = fileOpen(vLogFile,fileOpenWrite+fileOpenAppend); if(fh > 0) { fileWrite(fh,vLogMessage); fileWrite(fh,'\n\n'); fileClose(fh); } // Echo message to Scripting window sysLog(vLogMessage); sysLog(''); // Get next file to process vFile = fileFindNext(); }; } ////////////////////////////////////////// // Process All files in folder, convert them to CSV ////////////////////////////////////////// ConvertFolderToCSV(var vInFolder,var vOutFolder,var vInExtensions, var vLogFile, var vErase) { var vFile; var vOutputFileTmp; var vOutputFile; var vFileName; var vStatus; var vLogMessage; // Create report for each file found vFile = fileFindFirst(vInFolder,vInExtensions); while(vFile != '') { // Display date & time of data processing. vLogMessage = 'Date: ' + sysDateTime() + '\n'; // Extract file name from full file+path name vFileName = strSplitPath(vFile); // Build output file (temporary name) vOutputFileTmp = vOutFolder + '/' + vFileName + '.tmp'; // Convert file to ASCII table vStatus = gexConvertCSV(vFile,vOutputFileTmp); // check if successful conversion if(vStatus != 1) { // Rename file to '.bad' extension vOutputFile = vFile + '.bad'; fileDelete(vOutputFile); fileRename(vFile,vOutputFile); // Create Log message vLogMessage = vLogMessage + '* ERROR * Failed on file: ' + vFile + ' (renamed to .bad extension)'; } else { // Success converting to STDF format vOutputFile = vOutFolder + '/' + vFileName + '_gexmo.csv'; fileDelete(vOutputFile); // Erase source file if(vErase == 1) fileDelete(vFile); else { // Rename input file processed to .ok vOutputFile = vFile + '.ok'; fileDelete(vOutputFile); fileRename(vFile,vOutputFile); } // Rename output file to .csv vOutputFile = vOutFolder + '/' + vFileName + '_gexmo.csv'; fileDelete(vOutputFile); fileRename(vOutputFileTmp,vOutputFile); vLogMessage = vLogMessage + 'Success on file: ' + vFile; } // Output error message to log file var fh = fileOpen(vLogFile,fileOpenWrite+fileOpenAppend); if(fh > 0) { fileWrite(fh,vLogMessage); fileWrite(fh,'\n\n'); fileClose(fh); } // Echo message to Scripting window sysLog(vLogMessage); sysLog(''); // Get next file to process vFile = fileFindNext(); }; } ////////////////////////////////////////// // Send a given file to the spooling folder ////////////////////////////////////////// EmailLogFile(var vEmailFolder,var vEmailAddress,var vLogFile,var vErase) { // If log file doesn't exists, simply return if(fileExists(vLogFile) == 0) return; // If the LOG file already sent today, don't do it again!...so check this first var vFile; var vString; var vDate = sysDate(); var vLogFileSent = vLogFile + '.sent'; if(fileExists(vLogFileSent) == 1) { // Read content of llogfile.sent and see if it includes current date. If so, then email has already been sent! vFile = fileOpen(vLogFileSent,fileOpenRead); vString = fileReadLine(vFile); vString = strSubString(vString,1,strLength(vDate)); fileClose(vFile); if( vDate == vString) return; // Return as email already sent today! } // Copy log file to spooling directory var vLogFileCopy = fileTempName() + '.txt'; fileCopy(vLogFile,vLogFileCopy); // Erase source LOG file if request if(vErase == 1) fileDelete(vLogFile); // Create email header message in spooling folder var vEmail = vEmailFolder + '/gex-mo-' + sysTimestamp() + '.mail'; vFile = fileOpen(vEmail,fileOpenWrite); fileWrite(vFile,'Type=MonitoringReport\n'); fileWrite(vFile,'Format=TEXT\n'); fileWrite(vFile,'To='); fileWrite(vFile,vEmailAddress); fileWrite(vFile,'\n'); fileWrite(vFile,'From=Examinator-Monitoring@galaxysemi.com\n'); fileWrite(vFile,'Subject=Galaxy STDF converter - Daily report\n'); fileWrite(vFile,'Body='); fileWrite(vFile,vLogFileCopy); fileWrite(vFile,'\n'); fileClose(vFile); // Write time stamp into logfie.sent to avoid seding file again today! fileDelete(vFile); vFile = fileOpen(vLogFileSent,fileOpenWrite); fileWriteLine(vFile,vDate); fileClose(vFile); }