00001 package ProdDatabase;
00006 import java.util.*;
00007 import java.sql.*;
00008
00009 public class WaferUtilities {
00010
00011
00012 public static String getCalCorrFactor(String wafer) throws Exception {
00013 StringBuffer sqlStat;
00014 int recordCount=0;
00015 java.text.DecimalFormat myFormatter = new java.text.DecimalFormat("#.###");
00016 sqlStat = new StringBuffer("SELECT tests.ser_no,tests.test_no,items.mfr_ser_no,test_wafer_e_param.structure,test_wafer_e_param.toxp1n_plus");
00017 sqlStat.append(" FROM tests,items,test_wafer_e_param WHERE test_wafer_e_param.test_no=tests.test_no");
00018 sqlStat.append(" AND items.mfr_ser_no LIKE'"+wafer+"'");
00019 sqlStat.append(" AND items.ser_no=tests.ser_no");
00020 sqlStat.append(" ORDER BY tests.ser_no,tests.test_no");
00021 Hashtable thisHash = new Hashtable();
00022
00023 String S1key = "S1KEY";
00024 String S2key = "S2KEY";
00025 String S3key = "S3KEY";
00026 String S4key = "S4KEY";
00027 String S5key = "S5KEY";
00028
00029 SCTDBInterface db = SCTDBInterface.getInstance();
00030 ResultSet resultSet;
00031 Statement statement = db.connection.createStatement();
00032
00033
00034
00035 resultSet = statement.executeQuery(sqlStat.toString());
00036 recordCount=0;
00037 String thisTestNo="";
00038 for(boolean n = resultSet.next() ; n==true ; n=resultSet.next() ){
00039 recordCount++;
00040 if(recordCount%200 == 0) System.out.println("Retrieved "+recordCount+" structure records so far...");
00041 String serno = resultSet.getString(1);
00042 String testno = resultSet.getString(2);
00043 String lotno = resultSet.getString(3);
00044 String structureNo = resultSet.getString(4);
00045 String oxthickness = resultSet.getString(5);
00046 try {
00047 double ox = Double.parseDouble(oxthickness);
00048
00049 if(!testno.equals(thisTestNo)) {
00050 thisHash = new Hashtable();
00051 thisTestNo=testno;
00052 }
00053
00054 String thiskey = "S"+structureNo+"KEY";
00055 thisHash.put(thiskey,oxthickness);
00056
00057 } catch(Exception e2) {System.out.println("WARNING: Corrupt database data: Invalid TOXP1N_PLUS value for serial no "+serno);}
00058
00059
00060 }
00061
00062
00063 statement.close();
00064 if(recordCount==0) {
00065 System.out.println("Cal corr factors not available for wafer "+wafer);
00066 return "";
00067 }
00068
00069 double[] ts = new double[5];
00070 int tscount=0;
00071 for(int j=1;j<6;j++) {
00072 ts[j-1]=0.0;
00073 String theKey = "S"+j+"KEY";
00074 if(thisHash.containsKey(theKey)) {
00075 ts[j-1] = Double.valueOf( (String)thisHash.get(theKey) ).doubleValue();
00076 tscount++;
00077 }
00078 else System.out.println("No data for structure "+j+" from wafer "+wafer);
00079 }
00080
00081 double mean=0.0;
00082 for(int j=1;j<6;j++) mean += ts[j-1];
00083 mean = tscount>0 ? mean/(double)tscount: 0.0;
00084 double corr = mean>0.0 ? 420./mean : 0.0;
00085
00086 String stringCorr = myFormatter.format(corr);
00087 return stringCorr;
00088
00089
00090 }
00091
00092 }