/* g++ test.C -o test.exe */ #include #include #include #include #include #include #include #include #include using namespace std; int main() { const int debug = 0; const int kFirstLot = 11; // see info on waferlots and prefix to be used for serial numbers in waferlots.txt // not so many, so I just setup the map here directly map lot_map; lot_map["G35F72.1"] = 0; lot_map["G35F73.1"] = 1; lot_map["G35F74.1"] = 2; lot_map["G35F75.1"] = 3; lot_map["G35F76.1"] = 4; lot_map["G35F77.1"] = 5; lot_map["G35F78.1"] = 6; lot_map["G35F79.1"] = 7; lot_map["G35F80.1"] = 8; lot_map["G35F81.1"] = 9; lot_map["G35F82.1"] = 10; lot_map["G35F83.1"] = 11; lot_map["G35F83.2"] = 12; // N.B.:special case; not sure if serial number within .2 lot will start at 0 or not lot_map["G35F84.1"] = 13; lot_map["G35F85.1"] = 14; lot_map["G39B57.1"] = 15; lot_map["G39B58.1"] = 16; char filename[100]; ifstream flist("traylist.txt"); if (!flist) { cerr << " - can't open flist for input" << endl; return 1; } int nfiles = 0; const int kMaxLengthLine = 100; const int kMaxLengthSAMPA = 26; // SAMPA QRcode format int nchips = 0; int lot = 0; int tray = 0; int col = 0; int row = 0; int ichip = 0; char lineStr[kMaxLengthLine]; while ( flist.good() ) { flist >> tray >> filename; if (! flist.good() ) { break; } if (debug>1) cout << " nfiles " << nfiles << " filename " << filename << endl; nfiles++; ifstream fin(filename); if (!fin) { cerr << " - can't open file for input" << endl; return 1; } int nlines = 0; while ( fin.good() ) { fin.getline(lineStr, kMaxLengthLine); if (! fin.good() ) { break; } if (debug>1) cout << " nlines " << nlines << " lineStr " << lineStr << endl; nlines++; // if line starts in a number, then it is a data string if ( isdigit( lineStr[0] ) ) { if (debug>1) cout << " digit lineStr " << lineStr << endl; // split string in row; col; QR substrings stringstream ss( lineStr ); vector result; while( ss.good() ) { string substr; getline( ss, substr, ';' ); result.push_back( substr ); } row = atoi ( result[0].c_str() ); if (debug>1) cout << " row " << row << endl; col = atoi ( result[1].c_str() ); if (debug>1) cout << " col " << col << endl; if (debug>1) cout << " result2 " << result[2] << endl; // let's get the parts of the argument string we need string str (result[2]); string strLot = str.substr(8,8); // wafer lot part string strNum = str.substr(21,4); // last 4 digits; number within wafer lot if (debug>1) cout << " nchips " << nchips << " lineStr " << lineStr << " lot-id " << strLot << " serialNum " << strNum; ichip = atoi(strNum.c_str()); lot = 0; map::iterator it = lot_map.find(strLot); if (it != lot_map.end()) { // cout << " prefix " << it->second << endl; lot = it->second; } else { cerr << " unknown lot! " << endl; } ichip += (lot + kFirstLot)*10000; printf("tray %03d row %02d col %02d chip %d QrCode %s\n", tray, row, col, ichip, str.c_str()); nchips++; } // digit chip info } // fin } // flist return 0; }