// ============================================================================= // ============================================================================= int selecttpc() { // // Get values from TPC Table. This is either all values in the row or a single value. // FERODBFieldPositions *fp = new FERODBFieldPositions(); if ( arguments.pTest == true ) { ofstream *seperateOutFile = new ofstream(); seperateOutFile->open("DBQuery.sql"); for ( uint32_t iTag=0; iTaggetSqlSelectTpcField(arguments.pSelectTagList.at(iTag), arguments.pSelectField) << ";" << endl; else *seperateOutFile << dbq->getSqlSelectTpcRow(arguments.pSelectTagList.at(iTag)) << ";" << endl; } seperateOutFile->close(); delete seperateOutFile; delete fp; fp = 0; return 1; } if ( arguments.pSelectSingleField == true ) { if ( fp->TpcTable->getPosition(arguments.pSelectField) <0 ) { cerr << "*Error: Column " << arguments.pSelectField << " does not exist in TPC Table (case sensitive)!" << endl; delete fp; fp = 0; return 0; } for ( uint32_t iTag=0; iTagcalcRowCount(dbq->getSqlSelectTpcField(arguments.pSelectTagList.at(iTag), arguments.pSelectField)); cout << "Tag " << arguments.pSelectTagList.at(iTag) << ", "; cout << "Got " << db->getRowCount() << " Row(s)" << endl; if ( db->getRowCount() < 1 ) continue; db->executeQuery(dbq->getSqlSelectTpcField(arguments.pSelectTagList.at(iTag), arguments.pSelectField)); db->getRow(); cout << "--------------" << endl; if ( fp->TpcTable->getPosition(arguments.pSelectField) == 5 ) cout << "*DB Value of " << arguments.pSelectField << " is: " << db->getRowValueAsString(0) << endl; else if ( (fp->TpcTable->getPosition(arguments.pSelectField) > 0) && (fp->TpcTable->getPosition(arguments.pSelectField) < 4) ) cout << "*DB Value of " << arguments.pSelectField << " is: " << db->getRowValueDateAsString(0) << endl; else cout << "*DB Value of " << arguments.pSelectField << " is: " << db->getRowValueAsInt(0) << endl; cout << "--------------" << endl; } catch(SQLException& ea) { cout << ea.what() << endl; return 0; } } } else { for ( uint32_t iTag=0; iTagcalcRowCount(dbq->getSqlSelectTpcRow(arguments.pSelectTagList.at(iTag))); cout << "Tag " << arguments.pSelectTagList.at(iTag) << ": Got " << db->getRowCount() << " Row(s)" << endl; if ( db->getRowCount() < 1 ) continue; db->executeQuery(dbq->getSqlSelectTpcRow(arguments.pSelectTagList.at(iTag))); db->getRow(); cout << "--------------" << endl; for ( int32_t i=0; iTpcTable->getNcols(); i++ ) { cout << fp->TpcTable->getColName(i) << " : "; if (fp->TpcTable->isDate(i) ) cout << db->getRowValueDateAsString(i) << endl; else if (fp->TpcTable->isString(i)) cout << db->getRowValueAsString(i) << endl; else if (fp->TpcTable->isNumber(i)) cout << db->getRowValueAsInt(i) << endl; } cout << "--------------" << endl; } catch(SQLException& ea) { cout << ea.what() << endl; return 0; } } } delete fp; fp = 0; return 1; } // ============================================================================= // ============================================================================= int32_t selectrcu() { // // Get values for one rcu. This is either all values in one row in the rcu table // or a single value. // FERODBFieldPositions *fp = new FERODBFieldPositions(); if ( arguments.pTest == true ) { ofstream *seperateOutFile = new ofstream(); seperateOutFile->open("DBQuery.sql"); for ( uint32_t iTag=0; iTaggetSqlSelectRcuField(arguments.pSelectTagList.at(iTag), arguments.pSelectSideList.at(iSide), arguments.pSelectSectorList.at(iSec), arguments.pSelectRcuList.at(iRcu), arguments.pSelectField) << ";" << endl; } else { *seperateOutFile << dbq->getSqlSelectRcuRow(arguments.pSelectTagList.at(iTag), arguments.pSelectSideList.at(iSide), arguments.pSelectSectorList.at(iSec), arguments.pSelectRcuList.at(iRcu)) << ";" << endl; } } } } } seperateOutFile->close(); delete seperateOutFile; delete fp; fp = 0; return 1; } string query = ""; if ( arguments.pSelectSingleField == true ) { if ( fp->RcuTable->getPosition(arguments.pSelectField) <0 ) { cerr << "*Error: Column " << arguments.pSelectField << " does not exist in RCU Table (case sensitive)!" << endl; delete fp; fp = 0; return 0; } for ( uint32_t iTag=0; iTaggetSqlSelectRcuField(arguments.pSelectTagList.at(iTag), arguments.pSelectSideList.at(iSide), arguments.pSelectSectorList.at(iSec), arguments.pSelectRcuList.at(iRcu), arguments.pSelectField); try { db->calcRowCount(query); cout << "--------------" << endl; cout << "Tag " << arguments.pSelectTagList.at(iTag) << ", side " << arguments.pSelectSideList.at(iSide) << ", sector " << arguments.pSelectSectorList.at(iSec) << ", rcu " << arguments.pSelectRcuList.at(iRcu) << ": "; cout << "Got " << db->getRowCount() << " Row(s)." << endl; if ( db->getRowCount() < 1 ) continue; db->executeQuery(query); db->getRow(); cout << "*DB Value is: " << arguments.pSelectField << "=" << db->getRowValueAsInt(0) << endl; cout << "--------------" << endl; } catch(SQLException& ea) { cout << ea.what() << endl; return 0; } } } } } } else { for ( uint32_t iTag=0; iTaggetSqlSelectRcuRow(arguments.pSelectTagList.at(iTag), arguments.pSelectSideList.at(iSide), arguments.pSelectSectorList.at(iSec), arguments.pSelectRcuList.at(iRcu)); try { db->calcRowCount(query); cout.setf( ios::dec ); cout << "--------------" << endl; cout << "Rcu Id " << arguments.pSelectRcuList.at(iRcu) << "; Got " << db->getRowCount() << " row(s):" << endl; if ( db->getRowCount() < 1 ) continue; db->executeQuery(query); db->getRow(); for ( int32_t i=0; i<4; i++ ) { cout << fp->RcuTable->getColName(i) << " : " << db->getRowValueAsInt(i) << endl; } cout.setf( ios::hex, ios::basefield ); for ( int32_t i=4; igetFieldCount(); i++ ) { cout << fp->RcuTable->getColName(i) << " : 0x" << db->getRowValueAsInt(i) << endl; } cout.setf( ios::dec ); cout << "--------------" << endl; } catch(SQLException& ea) { cout << ea.what() << endl; return 0; } } } } } } delete fp; fp = 0; return 1; } // ============================================================================= // ============================================================================= int32_t selectfec() { // // Get values for one Board Controller. This is either all values in one row in the // FEC table or a single value. // FERODBFieldPositions *fp = new FERODBFieldPositions(); if ( arguments.pTest == true ) { ofstream *seperateOutFile = new ofstream(); seperateOutFile->open("DBQuery.sql"); for ( uint32_t iTag=0; iTaggetSqlSelectFecField(arguments.pSelectTagList.at(iTag), arguments.pSelectSideList.at(iSide), arguments.pSelectSectorList.at(iSec), arguments.pSelectRcuList.at(iRcu), arguments.pSelectBranchList.at(iBranch), arguments.pSelectFecList.at(iFec), arguments.pSelectField) << ";" << endl; } else { *seperateOutFile << dbq->getSqlSelectFecRow(arguments.pSelectTagList.at(iTag), arguments.pSelectSideList.at(iSide), arguments.pSelectSectorList.at(iSec), arguments.pSelectRcuList.at(iRcu), arguments.pSelectBranchList.at(iBranch), arguments.pSelectFecList.at(iFec)) << ";" << endl; } } } } } } } seperateOutFile->close(); delete seperateOutFile; delete fp; fp = 0; return 1; } string query = ""; if ( arguments.pSelectSingleField == true ) { if ( fp->FecTable->getPosition(arguments.pSelectField) <0 ) { cerr << "*Error: Column " << arguments.pSelectField << " does not exist in FEC Table (case sensitive)!" << endl; delete fp; fp = 0; return 0; } for ( uint32_t iTag=0; iTaggetSqlSelectFecField(arguments.pSelectTagList.at(iTag), arguments.pSelectSideList.at(iSide), arguments.pSelectSectorList.at(iSec), arguments.pSelectRcuList.at(iRcu), arguments.pSelectBranchList.at(iBranch), arguments.pSelectFecList.at(iFec), arguments.pSelectField); try { db->calcRowCount(query); cout.setf( ios::dec ); cout << "--------------" << endl; cout << "Tag " << arguments.pSelectTagList.at(iTag) << ", side " << arguments.pSelectSideList.at(iSide) << ", sector " << arguments.pSelectSectorList.at(iSec) << ", rcu " << arguments.pSelectRcuList.at(iRcu) << ", branch " << arguments.pSelectBranchList.at(iBranch) << ", fec " << arguments.pSelectFecList.at(iFec) << ": "; cout << "Got " << db->getRowCount() << " row(s)." << endl; if ( db->getRowCount() < 1 ) continue; db->executeQuery(query); db->getRow(); cout << "*DB Value: " << arguments.pSelectField << "=" << db->getRowValueAsInt(0) << endl; cout << "--------------" << endl; db->freeResult(); } catch(SQLException& ea) { cout << ea.what() << endl; return 0; } } } } } } } } else { for ( uint32_t iTag=0; iTaggetSqlSelectFecRow(arguments.pSelectTagList.at(iTag), arguments.pSelectSideList.at(iSide), arguments.pSelectSectorList.at(iSec), arguments.pSelectRcuList.at(iRcu), arguments.pSelectBranchList.at(iBranch), arguments.pSelectFecList.at(iFec)); try { db->calcRowCount(query); cout.setf( ios::dec ); cout << "--------------" << endl; cout << "Tag " << arguments.pSelectTagList.at(iTag) << ", side " << arguments.pSelectSideList.at(iSide) << ", sector " << arguments.pSelectSectorList.at(iSec) << ", rcu " << arguments.pSelectRcuList.at(iRcu) << ", branch " << arguments.pSelectBranchList.at(iBranch) << ", fec " << arguments.pSelectFecList.at(iFec) << ": "; cout << "Got " << db->getRowCount() << " row(s)." << endl; if ( db->getRowCount() < 1 ) continue; db->executeQuery(query); db->getRow(); for ( int32_t i=0; i<9; i++ ) { cout << fp->FecTable->getColName(i) << " : " << db->getRowValueAsInt(i) << endl; } cout.setf( ios::hex, ios::basefield ); for ( int32_t i=9; igetFieldCount()-1; i++ ) { cout << fp->FecTable->getColName(i) << " : 0x" << db->getRowValueAsInt(i) << endl; } cout.setf( ios::dec ); cout << fp->FecTable->getColName(db->getFieldCount()-1) << " : " << db->getRowValueAsInt(db->getFieldCount()-1) << endl; cout << "--------------" << endl; db->freeResult(); } catch(SQLException& ea) { cout << ea.what() << endl; return 0; } } } } } } } } delete fp; fp = 0; return 1; } // ============================================================================= // ============================================================================= int32_t selectaltro() { // // Get values for one Altro. This is either all values in one row in the Altro table // or a single value. // FERODBFieldPositions *fp = new FERODBFieldPositions(); if ( arguments.pTest == true ) { ofstream *seperateOutFile = new ofstream(); seperateOutFile->open("DBQuery.sql"); for ( uint32_t iTag=0; iTaggetSqlSelectAltroField(arguments.pSelectTagList.at(iTag), arguments.pSelectSideList.at(iSide), arguments.pSelectSectorList.at(iSec), arguments.pSelectRcuList.at(iRcu), arguments.pSelectBranchList.at(iBranch), arguments.pSelectFecList.at(iFec), arguments.pSelectAltroList.at(iAltro), arguments.pSelectField) << ";" << endl; } else { *seperateOutFile << dbq->getSqlSelectAltroRow(arguments.pSelectTagList.at(iTag), arguments.pSelectSideList.at(iSide), arguments.pSelectSectorList.at(iSec), arguments.pSelectRcuList.at(iRcu), arguments.pSelectBranchList.at(iBranch), arguments.pSelectFecList.at(iFec), arguments.pSelectAltroList.at(iAltro)) << ";" << endl; } } } } } } } } seperateOutFile->close(); delete seperateOutFile; delete fp; fp = 0; return 1; } string query = ""; if ( arguments.pSelectSingleField == true ) { if ( fp->AltroTable->getPosition(arguments.pSelectField) <0 ) { cerr << "*Error: Column " << arguments.pSelectField << " does not exist in ALTRO Table (case sensitive)!" << endl; delete fp; fp = 0; return 0; } for ( uint32_t iTag=0; iTaggetSqlSelectAltroField(arguments.pSelectTagList.at(iTag), arguments.pSelectSideList.at(iSide), arguments.pSelectSectorList.at(iSec), arguments.pSelectRcuList.at(iRcu), arguments.pSelectBranchList.at(iBranch), arguments.pSelectFecList.at(iFec), arguments.pSelectAltroList.at(iAltro), arguments.pSelectField); try { db->calcRowCount(query); cout.setf( ios::dec ); cout << "--------------" << endl; cout << "Tag " << arguments.pSelectTagList.at(iTag) << ", side " << arguments.pSelectSideList.at(iSide) << ", sector " << arguments.pSelectSectorList.at(iSec) << ", rcu " << arguments.pSelectRcuList.at(iRcu) << ", branch " << arguments.pSelectBranchList.at(iBranch) << ", fec " << arguments.pSelectFecList.at(iFec) << ", altro " << arguments.pSelectAltroList.at(iAltro) << ": "; cout << "Got " << db->getRowCount() << " row(s)." << endl; if ( db->getRowCount() < 1 ) continue; db->executeQuery(query); db->getRow(); cout << "*DB Value: " << arguments.pSelectField << "=" << db->getRowValueAsInt(0) << endl; cout << "--------------" << endl; db->freeResult(); } catch(SQLException& ea) { cout << ea.what() << endl; return 0; } } } } } } } } } else { for ( uint32_t iTag=0; iTaggetSqlSelectAltroRow(arguments.pSelectTagList.at(iTag), arguments.pSelectSideList.at(iSide), arguments.pSelectSectorList.at(iSec), arguments.pSelectRcuList.at(iRcu), arguments.pSelectBranchList.at(iBranch), arguments.pSelectFecList.at(iFec), arguments.pSelectAltroList.at(iAltro)); try { db->calcRowCount(query); cout.setf( ios::dec ); cout << "--------------" << endl; cout << "Tag " << arguments.pSelectTagList.at(iTag) << ", side " << arguments.pSelectSideList.at(iSide) << ", sector " << arguments.pSelectSectorList.at(iSec) << ", rcu " << arguments.pSelectRcuList.at(iRcu) << ", branch " << arguments.pSelectBranchList.at(iBranch) << ", fec " << arguments.pSelectFecList.at(iFec) << ", altro " << arguments.pSelectAltroList.at(iAltro) << ": "; cout << "Got " << db->getRowCount() << " row(s)." << endl; if ( db->getRowCount() < 1 ) continue; db->executeQuery(query); db->getRow(); for ( int32_t i=0; i<19; i++ ) { cout << fp->AltroTable->getColName(i) << " : " << db->getRowValueAsInt(i) << endl; } cout.setf( ios::hex, ios::basefield ); for ( int32_t i=19; igetFieldCount(); i++ ) { cout << fp->AltroTable->getColName(i) << " : 0x" << db->getRowValueAsInt(i) << endl; } cout.setf( ios::dec ); cout << "--------------" << endl; db->freeResult(); } catch(SQLException& ea) { cout << ea.what() << endl; return 0; } } } } } } } } } delete fp; fp = 0; return 1; } // ============================================================================= // ============================================================================= int32_t dumpdisabled() { // // Get positions of equipment that is disabled for specific configurations // if ( arguments.pTest == true ) { ofstream *seperateOutFile = new ofstream(); seperateOutFile->open("DBQuery.sql"); for ( uint32_t iTag=0; iTaggetSqlFindDisabledRCUs(arguments.pSelectTagList.at(iTag)) << ";" << endl << endl; *seperateOutFile << dbq->getSqlFindDisabledFECs(arguments.pSelectTagList.at(iTag)) << ";" << endl << endl; *seperateOutFile << dbq->getSqlFindDisabledALTROs(arguments.pSelectTagList.at(iTag)) << ";" << endl << endl; *seperateOutFile << dbq->getSqlFindDisabledCHANNELs(arguments.pSelectTagList.at(iTag)) << ";" << endl << endl; } seperateOutFile->close(); delete seperateOutFile; return 1; } for ( uint32_t iTag=0; iTagcalcRowCount(dbq->getSqlFindDisabledRCUs(arguments.pSelectTagList.at(iTag))); cout << "--------------" << endl; cout << "Tag " << arguments.pSelectTagList.at(iTag) << ": DISABLED RCU query, got " << db->getRowCount() << " Row(s)" << endl; int32_t nrows = db->getRowCount(); if ( nrows < 1 ) { cout << "none disabled" << endl; } else { db->executeQuery(dbq->getSqlFindDisabledRCUs(arguments.pSelectTagList.at(iTag))); cout << "Number\tSide\tSector\tRCU\tHwAddress\tData" << endl; for ( int32_t irow=0; irowgetRow(); cout << ctr++ << "\t"; for ( int32_t i=0; i<3; i++ ) { cout << db->getRowValueAsInt(i); if (i<2) cout << "\t"; else cout << "\t" << 0 << "\t" << -1 << endl; } } db->freeResult(); } ctr = 0; // 2) FEC db->calcRowCount(dbq->getSqlFindDisabledFECs(arguments.pSelectTagList.at(iTag))); cout << "--------------" << endl; cout << "Tag " << arguments.pSelectTagList.at(iTag) << ": DISABLED FEC query, got " << db->getRowCount() << " Row(s)" << endl; nrows = db->getRowCount(); if ( nrows < 1 ) { cout << "none disabled" << endl; } else { db->executeQuery(dbq->getSqlFindDisabledFECs(arguments.pSelectTagList.at(iTag))); cout << 13 << endl; cout << "Number\tSide\tSector\tRCU\tBranch\tFEC\tData" << endl; for ( int32_t irow=0; irowgetRow(); cout << ctr++ << "\t"; for ( int32_t i=0; i<5; i++ ) { cout << db->getRowValueAsInt(i); if (i<4) cout << "\t"; else cout << "\t" << -1 << endl; } } db->freeResult(); } ctr = 0; // 3) ALTRO db->calcRowCount(dbq->getSqlFindDisabledALTROs(arguments.pSelectTagList.at(iTag))); cout << "--------------" << endl; cout << "Tag " << arguments.pSelectTagList.at(iTag) << ": DISABLED ALTRO query, got " << db->getRowCount() << " Row(s)" << endl; nrows = db->getRowCount(); if ( nrows < 1 ) { cout << "none disabled" << endl; } else { db->executeQuery(dbq->getSqlFindDisabledALTROs(arguments.pSelectTagList.at(iTag))); cout << 17 << endl; cout << "Number\tSide\tSector\tRCU\tHwAddress\tData" << endl; for ( int32_t irow=0; irowgetRow(); cout << ctr++ << "\t"; for ( int32_t i=0; i<3; i++ ) { cout << db->getRowValueAsInt(i) << "\t"; } cout << ((db->getRowValueAsInt(3)<<11)|(db->getRowValueAsInt(4)<<7)|(db->getRowValueAsInt(5)<<4)) << "\t" << -1 << endl; } db->freeResult(); } ctr = 0; // 4) CHANNELs db->calcRowCount(dbq->getSqlFindDisabledCHANNELs(arguments.pSelectTagList.at(iTag))); cout << "--------------" << endl; cout << "Tag " << arguments.pSelectTagList.at(iTag) << ": DISABLED CHANNEL query, got " << db->getRowCount() << " Row(s)" << endl; nrows = db->getRowCount(); if ( nrows < 1 ) { cout << "none disabled" << endl; } else { db->executeQuery(dbq->getSqlFindDisabledCHANNELs(arguments.pSelectTagList.at(iTag))); cout << 14 << endl; cout << "Number\tSide\tSector\tRCU\tHwAddress\tData" << endl; for ( int32_t irow=0; irowgetRow(); for ( int32_t channel=0; channel<16; channel++ ) { if (db->getRowValueAsInt(channel)==0) { cout << ctr++ << "\t" << db->getRowValueAsInt(16) << "\t" << db->getRowValueAsInt(17) << "\t" << db->getRowValueAsInt(18) << "\t"; cout << ((db->getRowValueAsInt(19)<<11)|(db->getRowValueAsInt(20)<<7)|(db->getRowValueAsInt(21)<<4)|(channel)) << "\t" << -1 << endl; } } } db->freeResult(); } } catch(SQLException& ea) { cout << ea.what() << endl; return 0; } } return 1; }