// ============================================================================= // ============================================================================= int32_t createqueriesandvalues() { // // Create the queries to fill the tables (here only TPC, SECTOR_TPC, SECTOR). // Create the values to be filled in the tables using bind variables. // sectorQuerys.clear(); tpcQuerys.clear(); sector_tpcQuerys.clear(); tpcQueryCount = arguments.pSelectTagList.size(); sectorQueryCount = ciSectors*ciSides*tpcQueryCount; altroQueryCount = ciAltros*cifecPerSector*ciSectors*ciSides*tpcQueryCount; fecQueryCount = cifecPerSector*ciSectors*ciSides*tpcQueryCount; rcuQueryCount = ciRCUs*ciSectors*ciSides*tpcQueryCount; AltroFieldPositions AltroTable; FecFieldPositions FecTable; RcuFieldPositions RcuTable; // array[row][column] setup altro_values = vector < vector >(altroQueryCount); altro_fec_values = vector < vector >(altroQueryCount); fec_values = vector < vector >(fecQueryCount); fec_rcu_values = vector < vector >(fecQueryCount); rcu_values = vector < vector >(rcuQueryCount); rcu_sector_values = vector < vector >(rcuQueryCount); // for ( int32_t row=0; row(AltroTable.getNcols()); altro_fec_values[row] = vector(2); } for ( int32_t row=0; row(FecTable.getNcols()); fec_rcu_values[row] = vector(2); } for ( int32_t row=0; row(RcuTable.getNcols()); rcu_sector_values[row] = vector(2); } AltroConfig *altroConf = 0; FecConfig *fecConf = 0; RcuConfig *rcuConf = 0; pb = new ProgressBar('=', 80, fecQueryCount, "Create Fill Values"); sw->start(); char carry[40]; for ( uint32_t tagCounter = 0; tagCounter < arguments.pSelectTagList.size(); tagCounter++ ) { // Config types altroConf = new AltroConfig(arguments.pSelectTagList.at(tagCounter), 0); fecConf = new FecConfig(arguments.pSelectTagList.at(tagCounter), 0); rcuConf = new RcuConfig(arguments.pSelectTagList.at(tagCounter), 0); tpcQuerys.push_back(dbq->getSqlInsertTPC(arguments.pSelectTagList.at(tagCounter), arguments.pFillComment.at(tagCounter))); tpcQueryIndex++; for(int32_t sideCounter = 0; sideCounter < ciSides; sideCounter++) { for(int32_t sectorCounter = 0; sectorCounter < ciSectors; sectorCounter++) { sectorQuerys.push_back(dbq->getSqlInsertSECTOR(sectorIndex, sectorCounter, sideCounter)); sectorQueryIndex++; sector_tpcQuerys.push_back(dbq->getSqlInsertSECTOR_TPC(sectorIndex, arguments.pSelectTagList.at(tagCounter))); sector_tpcQueryIndex++; for(int32_t rcuCounter = 0; rcuCounter < ciRCUs; rcuCounter++) { rcu_values[rcuQueryIndex][RcuTable.getPosition("id")] = rcuIndex; rcu_values[rcuQueryIndex][RcuTable.getPosition("Equipmentid")] = get_eqid(sideCounter, sectorCounter, rcuCounter); rcu_values[rcuQueryIndex][RcuTable.getPosition("Position")] = rcuCounter; rcu_values[rcuQueryIndex][RcuTable.getPosition("ON_RCU")] = rcuConf->getState(sideCounter, sectorCounter, rcuCounter); rcu_values[rcuQueryIndex][RcuTable.getPosition("ALTROIF_NSAM_EV")] = rcuConf->getALTROIF_NSAM_EV(sideCounter, sectorCounter, rcuCounter); rcu_values[rcuQueryIndex][RcuTable.getPosition("ALTROIF_CLK_RATIO")] = rcuConf->getALTROIF_CLK_RATIO(sideCounter, sectorCounter, rcuCounter); rcu_values[rcuQueryIndex][RcuTable.getPosition("ALTROIF_CSTB_DELAY")] = rcuConf->getALTROIF_CSTB_DELAY(sideCounter, sectorCounter, rcuCounter); rcu_values[rcuQueryIndex][RcuTable.getPosition("RDOMOD_SPARSE_RDO")] = rcuConf->getRDOMOD_SPARSE_RDO(sideCounter, sectorCounter, rcuCounter); rcu_values[rcuQueryIndex][RcuTable.getPosition("RDOMOD_MEB_MODE")] = rcuConf->getRDOMOD_MEB_MODE(sideCounter, sectorCounter, rcuCounter); rcu_values[rcuQueryIndex][RcuTable.getPosition("RDOMOD_DISABLE_RDYRX")] = rcuConf->getRDOMOD_DISABLE_RDYRX(sideCounter, sectorCounter, rcuCounter); rcu_values[rcuQueryIndex][RcuTable.getPosition("TTC_CONTROL_CDH_VERSION")] = rcuConf->getTTC_CONTROL_CDH_VERSION(sideCounter, sectorCounter, rcuCounter); rcu_values[rcuQueryIndex][RcuTable.getPosition("TTC_L1_LATENCY")] = rcuConf->getTTC_L1_LATENCY(sideCounter, sectorCounter, rcuCounter); rcu_values[rcuQueryIndex][RcuTable.getPosition("TTC_L1_LATENCY_WINDOW")] = rcuConf->getTTC_L1_LATENCY_WINDOW(sideCounter, sectorCounter, rcuCounter); rcu_values[rcuQueryIndex][RcuTable.getPosition("TTC_L1_MSG_LATENCY_MIN")] = rcuConf->getTTC_L1_MSG_LATENCY_MIN(sideCounter, sectorCounter, rcuCounter); rcu_values[rcuQueryIndex][RcuTable.getPosition("TTC_L1_MSG_LATENCY_MAX")] = rcuConf->getTTC_L1_MSG_LATENCY_MAX(sideCounter, sectorCounter, rcuCounter); rcu_values[rcuQueryIndex][RcuTable.getPosition("TTC_L2_LATENCY_MIN")] = rcuConf->getTTC_L2_LATENCY_MIN(sideCounter, sectorCounter, rcuCounter); rcu_values[rcuQueryIndex][RcuTable.getPosition("TTC_L2_LATENCY_MAX")] = rcuConf->getTTC_L2_LATENCY_MAX(sideCounter, sectorCounter, rcuCounter); rcu_values[rcuQueryIndex][RcuTable.getPosition("TTC_ROI_CONFIG1")] = rcuConf->getTTC_ROI_CONFIG1(sideCounter, sectorCounter, rcuCounter); rcu_values[rcuQueryIndex][RcuTable.getPosition("TTC_ROI_CONFIG2")] = rcuConf->getTTC_ROI_CONFIG2(sideCounter, sectorCounter, rcuCounter); rcu_values[rcuQueryIndex][RcuTable.getPosition("TTC_ROI_LATENCY_MIN")] = rcuConf->getTTC_ROI_LATENCY_MIN(sideCounter, sectorCounter, rcuCounter); rcu_values[rcuQueryIndex][RcuTable.getPosition("TTC_ROI_LATENCY_MAX")] = rcuConf->getTTC_ROI_LATENCY_MAX(sideCounter, sectorCounter, rcuCounter); rcu_values[rcuQueryIndex][RcuTable.getPosition("RDOMOD_SKIP_EMPTY")] = rcuConf->getRDOMOD_SKIP_EMPTY(sideCounter, sectorCounter, rcuCounter); rcu_values[rcuQueryIndex][RcuTable.getPosition("EN_INT_BA")] = rcuConf->getEN_INT_BA(sideCounter, sectorCounter, rcuCounter); rcu_values[rcuQueryIndex][RcuTable.getPosition("PLACEHOLDER")] = rcuConf->getPLACEHOLDER(sideCounter, sectorCounter, rcuCounter); rcuQueryIndex++; rcu_sector_values[rcu_sectorQueryIndex][0] = rcuIndex; rcu_sector_values[rcu_sectorQueryIndex][1] = sectorIndex; rcu_sectorQueryIndex++; for(int32_t branchCounter = 0; branchCounter < 2; branchCounter++) { for(int32_t fecCounter = 0; fecCounter < fecPerRCUBranch[rcuCounter][branchCounter]; fecCounter++) { fec_values[fecQueryIndex][FecTable.getPosition("id")] = fecIndex; fec_values[fecQueryIndex][FecTable.getPosition("BranchPosition")] = branchCounter; fec_values[fecQueryIndex][FecTable.getPosition("Position")] = fecCounter; fec_values[fecQueryIndex][FecTable.getPosition("ON_FEC")] = fecConf->getState(sideCounter, sectorCounter, rcuCounter, branchCounter, fecCounter); fec_values[fecQueryIndex][FecTable.getPosition("BC_T_TH")] = fecConf->getBC_T_TH(sideCounter, sectorCounter, rcuCounter, branchCounter, fecCounter); fec_values[fecQueryIndex][FecTable.getPosition("BC_AV_TH")] = fecConf->getBC_AV_TH(sideCounter, sectorCounter, rcuCounter, branchCounter, fecCounter); fec_values[fecQueryIndex][FecTable.getPosition("BC_AC_TH")] = fecConf->getBC_AC_TH(sideCounter, sectorCounter, rcuCounter, branchCounter, fecCounter); fec_values[fecQueryIndex][FecTable.getPosition("BC_DV_TH")] = fecConf->getBC_DV_TH(sideCounter, sectorCounter, rcuCounter, branchCounter, fecCounter); fec_values[fecQueryIndex][FecTable.getPosition("BC_DC_TH")] = fecConf->getBC_DC_TH(sideCounter, sectorCounter, rcuCounter, branchCounter, fecCounter); fec_values[fecQueryIndex][FecTable.getPosition("TSMWORD")] = fecConf->getTSMWORD(sideCounter, sectorCounter, rcuCounter, branchCounter, fecCounter); fec_values[fecQueryIndex][FecTable.getPosition("USRATIO")] = fecConf->getUSRATIO(sideCounter, sectorCounter, rcuCounter, branchCounter, fecCounter); fec_values[fecQueryIndex][FecTable.getPosition("CSR0")] = fecConf->getCSR0(sideCounter, sectorCounter, rcuCounter, branchCounter, fecCounter); fec_values[fecQueryIndex][FecTable.getPosition("CSR1")] = fecConf->getCSR1(sideCounter, sectorCounter, rcuCounter, branchCounter, fecCounter); fec_values[fecQueryIndex][FecTable.getPosition("CSR2")] = fecConf->getCSR2(sideCounter, sectorCounter, rcuCounter, branchCounter, fecCounter); fec_values[fecQueryIndex][FecTable.getPosition("CSR3")] = fecConf->getCSR3(sideCounter, sectorCounter, rcuCounter, branchCounter, fecCounter); fec_values[fecQueryIndex][FecTable.getPosition("RDO_FEC")] = fecConf->getRDO_FEC(sideCounter, sectorCounter, rcuCounter, branchCounter, fecCounter); fecQueryIndex++; fec_rcu_values[fec_rcuQueryIndex][0] = fecIndex; fec_rcu_values[fec_rcuQueryIndex][1] = rcuIndex; fec_rcuQueryIndex++; for(int32_t altroCounter = 0; altroCounter < ciAltros; altroCounter++) { // ALTRO table altro_values[altroQueryIndex][AltroTable.getPosition("id")] = altroIndex; altro_values[altroQueryIndex][AltroTable.getPosition("Position")] = altroCounter; altro_values[altroQueryIndex][AltroTable.getPosition("ON_ALTRO")] = altroConf->getState(sideCounter, sectorCounter, rcuCounter, branchCounter, fecCounter, altroCounter); for(int32_t i = 0; i < 16; i++){ sprintf(carry,"ON_CHANNEL%02d", i); altro_values[altroQueryIndex][AltroTable.getPosition(carry)] = altroConf->getState(sideCounter, sectorCounter, rcuCounter, branchCounter, fecCounter, altroCounter, i); sprintf(carry,"K1_CHANNEL%02d", i); altro_values[altroQueryIndex][AltroTable.getPosition(carry)] = altroConf->getK1(sideCounter, sectorCounter, rcuCounter, branchCounter, fecCounter, altroCounter, i); sprintf(carry,"K2_CHANNEL%02d", i); altro_values[altroQueryIndex][AltroTable.getPosition(carry)] = altroConf->getK2(sideCounter, sectorCounter, rcuCounter, branchCounter, fecCounter, altroCounter, i); sprintf(carry,"K3_CHANNEL%02d", i); altro_values[altroQueryIndex][AltroTable.getPosition(carry)] = altroConf->getK3(sideCounter, sectorCounter, rcuCounter, branchCounter, fecCounter, altroCounter, i); sprintf(carry,"L1_CHANNEL%02d", i); altro_values[altroQueryIndex][AltroTable.getPosition(carry)] = altroConf->getL1(sideCounter, sectorCounter, rcuCounter, branchCounter, fecCounter, altroCounter, i); sprintf(carry,"L2_CHANNEL%02d", i); altro_values[altroQueryIndex][AltroTable.getPosition(carry)] = altroConf->getL2(sideCounter, sectorCounter, rcuCounter, branchCounter, fecCounter, altroCounter, i); sprintf(carry,"L3_CHANNEL%02d", i); altro_values[altroQueryIndex][AltroTable.getPosition(carry)] = altroConf->getL3(sideCounter, sectorCounter, rcuCounter, branchCounter, fecCounter, altroCounter, i); sprintf(carry,"VFPED_CHANNEL%02d", i); altro_values[altroQueryIndex][AltroTable.getPosition(carry)] = altroConf->getFPED(sideCounter, sectorCounter, rcuCounter, branchCounter, fecCounter, altroCounter, i); } altro_values[altroQueryIndex][AltroTable.getPosition("ZSTHR_OFFSET")] = altroConf->getZSTHR_OFFSET(sideCounter, sectorCounter, rcuCounter, branchCounter, fecCounter, altroCounter); altro_values[altroQueryIndex][AltroTable.getPosition("ZSTHR_ZS_THR")] = altroConf->getZSTHR_ZS_THR(sideCounter, sectorCounter, rcuCounter, branchCounter, fecCounter, altroCounter); altro_values[altroQueryIndex][AltroTable.getPosition("BCTHR_THR_HI")] = altroConf->getBCTHR_THR_HI(sideCounter, sectorCounter, rcuCounter, branchCounter, fecCounter, altroCounter); altro_values[altroQueryIndex][AltroTable.getPosition("BCTHR_THR_LOW")] = altroConf->getBCTHR_THR_LOW(sideCounter, sectorCounter, rcuCounter, branchCounter, fecCounter, altroCounter); altro_values[altroQueryIndex][AltroTable.getPosition("TRCFG_ACQ_START")] = altroConf->getTRCFG_ACQ_START(sideCounter, sectorCounter, rcuCounter, branchCounter, fecCounter, altroCounter); altro_values[altroQueryIndex][AltroTable.getPosition("TRCFG_ACQ_END")] = altroConf->getTRCFG_ACQ_END(sideCounter, sectorCounter, rcuCounter, branchCounter, fecCounter, altroCounter); altro_values[altroQueryIndex][AltroTable.getPosition("DPCFG_BC1_MODE")] = altroConf->getDPCFG_BC1_MODE(sideCounter, sectorCounter, rcuCounter, branchCounter, fecCounter, altroCounter); altro_values[altroQueryIndex][AltroTable.getPosition("DPCFG_BC1_POL")] = altroConf->getDPCFG_BC1_POL(sideCounter, sectorCounter, rcuCounter, branchCounter, fecCounter, altroCounter); altro_values[altroQueryIndex][AltroTable.getPosition("DPCFG_BC2_PRE")] = altroConf->getDPCFG_BC2_PRE(sideCounter, sectorCounter, rcuCounter, branchCounter, fecCounter, altroCounter); altro_values[altroQueryIndex][AltroTable.getPosition("DPCFG_BC2_POST")] = altroConf->getDPCFG_BC2_POST(sideCounter, sectorCounter, rcuCounter, branchCounter, fecCounter, altroCounter); altro_values[altroQueryIndex][AltroTable.getPosition("DPCFG_BC2_EN")] = altroConf->getDPCFG_BC2_EN(sideCounter, sectorCounter, rcuCounter, branchCounter, fecCounter, altroCounter); altro_values[altroQueryIndex][AltroTable.getPosition("DPCFG_ZS_GF")] = altroConf->getDPCFG_ZS_GF(sideCounter, sectorCounter, rcuCounter, branchCounter, fecCounter, altroCounter); altro_values[altroQueryIndex][AltroTable.getPosition("DPCFG_ZS_POST")] = altroConf->getDPCFG_ZS_POST(sideCounter, sectorCounter, rcuCounter, branchCounter, fecCounter, altroCounter); altro_values[altroQueryIndex][AltroTable.getPosition("DPCFG_ZS_PRE")] = altroConf->getDPCFG_ZS_PRE(sideCounter, sectorCounter, rcuCounter, branchCounter, fecCounter, altroCounter); altro_values[altroQueryIndex][AltroTable.getPosition("DPCFG_ZS_EN")] = altroConf->getDPCFG_ZS_EN(sideCounter, sectorCounter, rcuCounter, branchCounter, fecCounter, altroCounter); altro_values[altroQueryIndex][AltroTable.getPosition("DPCF2_PTRG")] = altroConf->getDPCF2_PTRG(sideCounter, sectorCounter, rcuCounter, branchCounter, fecCounter, altroCounter); altro_values[altroQueryIndex][AltroTable.getPosition("DPCF2_BUF")] = altroConf->getDPCF2_BUF(sideCounter, sectorCounter, rcuCounter, branchCounter, fecCounter, altroCounter); altro_values[altroQueryIndex][AltroTable.getPosition("DPCF2_FLT_EN")] = altroConf->getDPCF2_FLT_EN(sideCounter, sectorCounter, rcuCounter, branchCounter, fecCounter, altroCounter); altro_values[altroQueryIndex][AltroTable.getPosition("DPCF2_PWSV")] = altroConf->getDPCF2_PWSV(sideCounter, sectorCounter, rcuCounter, branchCounter, fecCounter, altroCounter); altroQueryIndex++; // ALTRO_FEC table altro_fec_values[altro_fecQueryIndex][0] = altroIndex; altro_fec_values[altro_fecQueryIndex][1] = fecIndex; altro_fecQueryIndex++; altroIndex++; } // end ALTRO loop pb->print(fecIndex); fecIndex++; } // end FEC loop } // end branch loop rcuIndex++; } // end RCU loop sectorIndex++; } // end SECTOR Loop } // end SIDE Loop delete altroConf; altroConf = 0; delete fecConf; fecConf = 0; delete rcuConf; rcuConf = 0; } // end Tag Loop delete pb; sw->stop(); cout << "Finished ... | " << sw->formatRealTime() << "s, " << sw->formatSysTime() << "s" << endl; return 1; } // ============================================================================= // ============================================================================= int32_t filltables2() { // // Fill Tables with standard values (a few different basic configurations are // available, see for example Config/AltroConfig.C). // AltroFieldPositions AltroTable; FecFieldPositions FecTable; RcuFieldPositions RcuTable; // // 1) Find the max id's in the tables. The new data will be appended // at the end of each table. // if ( !findmaxids() ) { cerr << "*Error: Could not find max id's!" << endl; return 0; } // // 2) Check if config(s) exist(s). If yes, skip it. // if ( !checkbeforefillconfigexists() ) { // Check if config exists. cerr << "*Nothing to be done!" << endl; return 1; } // // 3) Create the queries and fill values // if ( !createqueriesandvalues() ) { cerr << "*Error: Could not create queries!" << endl; return 0; } // // 5) Fill tables (or print queries to file) // sw->start(); if ( arguments.pTest == true ) { // test mode ofstream *seperateOutFile = new ofstream(); seperateOutFile->open("FillBind.sql"); *seperateOutFile << dbq->getSqlBindInsertALTRO() << ";" << endl; *seperateOutFile << dbq->getSqlBindInsertFEC() << ";" << endl; *seperateOutFile << dbq->getSqlBindInsertRCU() << ";" << endl; for(int32_t i = 0; i < sectorQueryCount; i++) *seperateOutFile << sectorQuerys[i] << endl; for(int32_t i = 0; i < tpcQueryCount; i++) *seperateOutFile << tpcQuerys[i] << endl; *seperateOutFile << dbq->getSqlBindInsertALTRO_FEC() << ";" << endl; *seperateOutFile << dbq->getSqlBindInsertFEC_RCU() << ";" << endl; *seperateOutFile << dbq->getSqlBindInsertRCU_SECTOR() << ";" << endl; for(int32_t i = 0; i < sectorQueryCount; i++) *seperateOutFile << sector_tpcQuerys[i] << endl; seperateOutFile->close(); delete seperateOutFile; } else { try { db->createTransaction(); // start transaction pb = new ProgressBar('=',80,altroQueryCount ,"Inserting Altros "); db->setSQL(dbq->getSqlBindInsertALTRO()); // set sql statement in cache for(int32_t i = 0; i < altroQueryCount; i++) { for (int32_t j = 0; j < AltroTable.getNcols(); j++ ) db->setNumber(j, altro_values[i][j]); db->executeUpdate(); pb->print(i); } delete pb; pb = new ProgressBar('=',80,fecQueryCount ,"Inserting FECs "); db->setSQL(dbq->getSqlBindInsertFEC()); // set sql statement in cache for(int32_t i = 0; i < fecQueryCount; i++) { for (int32_t j = 0; j < FecTable.getNcols(); j++ ) db->setNumber(j, fec_values[i][j]); db->executeUpdate(); pb->print(i); } delete pb; pb = new ProgressBar('=',80,rcuQueryCount ,"Inserting RCUs "); db->setSQL(dbq->getSqlBindInsertRCU()); // set sql statement in cache for(int32_t i = 0; i < rcuQueryCount; i++) { for (int32_t j = 0; j < RcuTable.getNcols(); j++ ) db->setNumber(j, rcu_values[i][j]); db->executeUpdate(); pb->print(i); } delete pb; pb = new ProgressBar('=',80,sectorQueryCount,"Inserting Sectors "); for(int32_t i = 0; i < sectorQueryCount; i++) { db->executeUpdate(sectorQuerys[i]); // directly execute pb->print(i); } delete pb; pb = new ProgressBar('=',80,tpcQueryCount ,"Inserting TPCs "); for(int32_t i = 0; i < tpcQueryCount; i++) { db->executeUpdate(tpcQuerys[i]); // directly execute pb->print(i); } delete pb; db->createTransaction(); // start transaction pb = new ProgressBar('=',80,altroQueryCount ,"Inserting AF Link "); db->setSQL(dbq->getSqlBindInsertALTRO_FEC()); // set sql statement in cache for(int32_t i = 0; i < altroQueryCount; i++) { for (int32_t j = 0; j < 2; j++ ) db->setNumber(j, altro_fec_values[i][j]); db->executeUpdate(); pb->print(i); } delete pb; pb = new ProgressBar('=',80,fecQueryCount ,"Inserting FR Link "); db->setSQL(dbq->getSqlBindInsertFEC_RCU()); // set sql statement in cache for(int32_t i = 0; i < fecQueryCount; i++) { for (int32_t j = 0; j < 2; j++ ) db->setNumber(j, fec_rcu_values[i][j]); db->executeUpdate(); pb->print(i); } delete pb; pb = new ProgressBar('=',80,rcuQueryCount ,"Inserting RS Link "); db->setSQL(dbq->getSqlBindInsertRCU_SECTOR()); // set sql statement in cache for(int32_t i = 0; i < rcuQueryCount; i++) { for (int32_t j = 0; j < 2; j++ ) db->setNumber(j, rcu_sector_values[i][j]); db->executeUpdate(); pb->print(i); } delete pb; pb = new ProgressBar('=',80,sectorQueryCount ,"Inserting ST Link "); for(int32_t i = 0; i < sectorQueryCount; i++) { db->executeUpdate(sector_tpcQuerys[i]); // directly execute pb->print(i); } delete pb; sw->stop(); } catch(SQLException& ea) { cout << ea.what() << endl; return 0; } } cout << "Created a Config | " << sw->formatRealTime() << "s, " << sw->formatSysTime() << "s" << endl; return 1; }