/* g++ -Wall -o decodeRescan.exe decodeRescan.C */ #include #include #include #include #include #include #include #include #include using namespace std; int main (int argc, char *argv[]) { if (argc<2) { cerr << "not enough arguments: argc = " << argc << endl << "Syntax should be:\n./decodeRescan.exe file" << endl << "Example:\n./decodeRescan.exe traysRescan/trayRescan026_20180908_144617.txt" << endl; return -1; } 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; lot_map["G6M389.1"] = 17; lot_map["GAHM81.1"] = 18; const int kMaxLengthLine = 100; char lineStr[kMaxLengthLine]; // const int kMaxLengthSAMPA = 26; // SAMPA QRcode format int nchips = 0; int lot = 0; int col = 0; int row = 0; int ichip = 0; ifstream fin(argv[1]); 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; if (lot == 17) { char *c = (char *) str.c_str(); char *pos = strstr(c, "20/07"); if (pos) { // original set, no offset needed } else { ichip += 5000; } } if (debug>0) { printf("row %02d col %02d chip %d QrCode %s\n", row, col, ichip, str.c_str()); } else { printf("%02d %d %d\n", row, col, ichip); } nchips++; } // digit chip info } // fin return 0; }