#include #include #include #include #include #include #include #include #include #include #include "../DB/DBQueryCreator.h" #include "../DB/FERODBFieldPositions.h" #include "../Config/TpcConfig.h" //#include "../CentralHeaders/BitConstants.h" #include "../Utilities/Stopwatch.h" #include "../Utilities/ProgressBar.h" #include "ocilib.hpp" using namespace std; using namespace ocilib; struct arguments { bool pExit, pdbUserSet, pdbPasswordSet, pdbConnectIdSet, pShowTables; bool pFillGbtx, pUpdate, pUpdateAll, pTest, pConnected, pInfo, pInfoID, pDrop, pDelete, pDump; bool pCreate, pFill, pSelect, pSelectTableFec, pSelectTableCru, pSelectTablePartition; bool pSelectTablePedestal, pSelectTableZsThr, pSelectTableOnChannel, pSelectTableCmCorr; bool pSelectTableItCorr1, pSelectTableItCorr2, pSelectTableTpc, pSelectSingleField, pDumpTag; int32_t pInfoSelectedID, pDropCounter, pDeleteCounter, pCreateCounter, pdbSystem, pdbConnectPort; float pUpdateValueFloat; int32_t pUpdateValueInt; float pFactorValue; string pSelectField, pUpdateString, pdbUser, pdbPassword, pdbConnectId; set pDropList, pDeleteList, pCreateList; vector pFileNameList; vector pSelectFecList, pSelectBranchList, pSelectCruList, pSelectPartitionList; vector pSelectSectorList, pSelectSideList, pSelectTagList; }; struct arguments arguments; #include "DBTool.h" #include "Misc.h" #include "Info.h" #include "Drop.h" #include "Delete.h" #include "Create.h" #include "Fill.h" #include "Update.h" //#include "UpdateBind.h" // Not used #include "Select.h" #include "Dump.h" const char *argp_program_version = "dbtool"; const char *argp_program_bug_address = ""; static const char doc[]= "Print and modify content of the TPC FERO Configuration Data Base.\ \v============================================================================== \ \nExample: dbtool -u[USERNAME] -P[PASSWORD] -z[CONNECTID] -j \ \n dbtool --select --table=PARTITION --tag=5 --side=1 --sector=9 --partition=2 \ \n dbtool --update -TFEC -t1 -s0 -r12 -p5 -b1 -f0,1,2 -CON_FEC -n1 \ \n=============================================================================="; #define OPT_DEL 2 #define OPT_DEL_ALL 3 #define OPT_DROP 4 #define OPT_DROP_ALL 5 #define OPT_TEST 6 #define OPT_FILL 7 #define OPT_CREATE 8 #define OPT_CREATE_ALL 9 #define OPT_NEWSTRING 10 #define OPT_P2DB 11 #define OPT_TESTDB 12 #define OPT_SHOWTABLES 13 #define OPT_DUMPALL 14 // possible up to 31 static const struct argp_option options[]={ {"p2", OPT_P2DB, 0, 0, "Connect to P2 data base in DCS network." , 0}, {"testdb", OPT_TESTDB, 0, 0, "Connect to test data base in CERN GPN." , 0}, {"test", OPT_TEST, 0, 0, "Test only. No DB activity. SQL Commands are written to files." , 0}, {"user", 'u', "USER", 0, "Data base user (default tpcfero)." , 1}, {"connect_id", 'z', "CONNECT_ID", 0, "Oracle DB connect identifier (default alionr)." , 1}, {"password", 'P', "PASSWORD", 0, "Password for the data base." , 1}, {"info", 'i', "TAG", 0, "Show info on selected configurations specified by tags." , 2}, {"infoall", 'j', 0, 0, "Show info on all configurations in the DB." , 2}, {"availabletags", 'A', 0, 0, "Show list of possible tags (these are maybe not yet stored in DB)." , 2}, {"fill", OPT_FILL, 0, 0, "Fills a standard configuration into the detector. Specify also tag." , 2}, {"showtables", OPT_SHOWTABLES, 0, 0, "Show all user tables in the DB." , 3}, {"gbtx1", 'Z', 0, 0, "Fill the GBTX1 table from file." , 3}, {"dump", 'D', 0, 0, "Dump DB content for given table. Specify list of tags and positions" , 3}, {"dumpall" , OPT_DUMPALL, 0, 0, "Dump all values for a given configuration tag. Specify list of tags." , 3}, {"select", 'S', 0, 0, "Get data for specified target. Specify also table and target." , 3}, {"update", 'U', 0, 0, "Update a field. Specify also table, field (column name) and target." , 3}, {"updateall", 'V', 0, 0, "Update all values of a column and table for a given list of tags." , 3}, {"create", OPT_CREATE, "TABLENAME", 0, "Create table(s) (FEC,PARTITION,SECTOR,TPC, ...)." , 3}, {"createall", OPT_CREATE_ALL, 0, 0, "Create all tables." , 3}, {"delete", OPT_DEL, "TABLENAME", 0, "Delete table(s) (FEC,PARTITION,SECTOR,TPC, ...). CAREFUL!" , 3}, {"deleteall", OPT_DEL_ALL, 0, 0, "Delete all tables. CAREFUL!" , 3}, {"drop", OPT_DROP, "TABLENAME", 0, "Drop table(s) (FEC,PARTITION,SECTOR,TPC, ...). CAREFUL!" , 3}, {"dropall", OPT_DROP_ALL, 0, 0, "Drop all tables. CAREFUL!" , 3}, {"newvalue", 'n', "NEWVALUE", 0, "New value for update." , 3}, {"table", 'T', "TABLENAME", 0, "Specify table for select or update." , 4}, {"column", 'C', "COLUMNNAME", 0, "Specify column name for select or update." , 4}, {"col", 0, "COLUMNNAME", OPTION_ALIAS }, {"field", 0, "COLUMNNAME", OPTION_ALIAS }, {"tag", 't', "TAG1[,TAG2...]", 0, "Specify configuration ID (Tag). See also \"--availabletags\"" , 4}, {"id", 0, 0, OPTION_ALIAS }, {"side", 's', "SIDE1[,SIDE2]", 0, "Specify side of TPC (0,1). More values separated by comma." , 4}, {"sector", 'r', "SEC1[,SEC2...]", 0, "Specify sector of TPC (0...17). More values separated by comma." , 4}, {"partition", 'p', "P1[,P2...]", 0, "Specify partition (0...4). More values separated by comma." , 4}, {"cru", 'c', "CRU1[,CRU2]", 0, "Specify CRU (0,1). 0=Master, 1=Slave. More values separated by comma." , 4}, {"branch", 'b', "BR1[,BR2]", 0, "Specify FEC branch (0,1). More values separated by comma." , 4}, {"fec", 'f', "FEC1[,FEC2...]", 0, "Specify fec (0...9). More values separated by comma." , 4}, { 0 } }; static error_t parse_opt(int32_t key, char *arg, struct argp_state *state) { struct arguments *arguments = (struct arguments*)state->input; char *arg_copy; char *token; switch (key) { case OPT_P2DB: arguments->pdbUserSet = true; arguments->pdbUser = "tpcfero"; arguments->pdbConnectIdSet = true; arguments->pdbConnectId = "alionr"; arguments->pdbPasswordSet = true; arguments->pdbPassword = "tpc1234"; break; case OPT_TESTDB: arguments->pdbUserSet = true; arguments->pdbUser = "tpcconfig"; arguments->pdbConnectIdSet = true; arguments->pdbConnectId = "intdb11"; arguments->pdbPasswordSet = true; arguments->pdbPassword = "bollocks_88"; break; case 'u': arguments->pdbUserSet = true; arguments->pdbUser = arg; break; case 'z': arguments->pdbConnectIdSet = true; arguments->pdbConnectId = arg; break; case 'P': arguments->pdbPasswordSet = true; arguments->pdbPassword = arg; break; case 'i': arguments->pInfo = true; arguments->pInfoID = true; arg_copy=strdup(arg); token=strtok(arg_copy,","); do { arguments->pInfoSelectedID = atoi(arg); } while ((token=strtok(NULL,","))); free(arg_copy); break; case 'j': arguments->pInfo = true; break; case 'A': gettags(); arguments->pExit = true; case OPT_FILL: arguments->pFill = true; break; case 'Z': arguments->pFillGbtx = true; break; case 'D': arguments->pDump = true; break; case OPT_DUMPALL: arguments->pDumpTag = true; break; case 'S': arguments->pSelect = true; break; case 'U': arguments->pUpdate = true; break; case 'V': arguments->pUpdateAll = true; break; case OPT_SHOWTABLES: arguments->pShowTables = true; break; case OPT_CREATE: arguments->pCreate = true; arguments->pCreateList.clear(); arguments->pCreateCounter = 0; arg_copy=strdup(arg); token=strtok(arg_copy,","); do { arguments->pCreateList.insert(token); arguments->pCreateCounter++; } while ((token=strtok(NULL,","))); free(arg_copy); break; case OPT_CREATE_ALL: arguments->pCreate = true; arguments->pCreateList.clear(); arguments->pCreateList.insert("ALL"); arguments->pCreateCounter = ciTables; break; case OPT_DEL: arguments->pDelete = true; arguments->pDeleteList.clear(); arguments->pDeleteCounter = 0; arg_copy=strdup(arg); token=strtok(arg_copy,","); do { arguments->pDeleteList.insert(token); arguments->pDeleteCounter++; } while ((token=strtok(NULL,","))); free(arg_copy); break; case OPT_DEL_ALL: arguments->pDelete = true; arguments->pDeleteList.clear(); arguments->pDeleteList.insert("ALL"); arguments->pDeleteCounter = ciTables; break; case OPT_DROP: arguments->pDrop = true; arguments->pDropList.clear(); arguments->pDropCounter = 0; arg_copy=strdup(arg); token=strtok(arg_copy,","); do { arguments->pDropList.insert(token); arguments->pDropCounter++; } while ((token=strtok(NULL,","))); free(arg_copy); break; case OPT_DROP_ALL: arguments->pDrop = true; arguments->pDropList.clear(); arguments->pDropList.insert("ALL"); arguments->pDropCounter = ciTables; break; case 'n': arguments->pUpdateValueInt = atoi(arg); arguments->pUpdateValueFloat = atof(arg); break; case 'T': if ( strcmp(arg,"PARTITION" ) == 0) arguments->pSelectTablePartition = true; else if ( strcmp(arg,"CRU" ) == 0) arguments->pSelectTableCru = true; else if ( strcmp(arg,"FEC" ) == 0) arguments->pSelectTableFec = true; else if ( strcmp(arg,"TPC" ) == 0) arguments->pSelectTableTpc = true; else if ( strcmp(arg,"PEDESTAL" ) == 0) arguments->pSelectTablePedestal = true; else if ( strcmp(arg,"ZSTHR" ) == 0) arguments->pSelectTableZsThr = true; else if ( strcmp(arg,"ON_CHANNEL" ) == 0) arguments->pSelectTableOnChannel = true; else if ( strcmp(arg,"CMCORR" ) == 0) arguments->pSelectTableCmCorr = true; else if ( strcmp(arg,"ITCORR1" ) == 0) arguments->pSelectTableItCorr1 = true; else if ( strcmp(arg,"ITCORR2" ) == 0) arguments->pSelectTableItCorr2 = true; break; case 'C': arguments->pSelectSingleField = true; arguments->pSelectField = arg; break; case 't': arguments->pSelectTagList.clear(); arg_copy=strdup(arg); token=strtok(arg_copy,","); do { int32_t tag = atoi(token); arguments->pSelectTagList.push_back(tag); } while ((token=strtok(NULL,","))); free(arg_copy); break; case 's': arg_copy=strdup(arg); token=strtok(arg_copy,","); do { uint32_t side = atoi(token); if ( side > 1 ) { cout << "*Strange side: " << side << endl; } else { arguments->pSelectSideList.push_back(side); } } while ((token=strtok(NULL,","))); free(arg_copy); break; case 'r': arg_copy=strdup(arg); token=strtok(arg_copy,","); do { uint32_t sector = atoi(token); if ( sector > 17 ) { cout << "*Strange sector: " << sector << endl; } else { arguments->pSelectSectorList.push_back(sector); } } while ((token=strtok(NULL,","))); free(arg_copy); break; case 'p': arg_copy=strdup(arg); token=strtok(arg_copy,","); do { uint32_t partition = atoi(token); if ( partition > 4 ) { cout << "*Strange partition: " << partition << endl; } else { arguments->pSelectPartitionList.push_back(partition); } } while ((token=strtok(NULL,","))); free(arg_copy); break; case 'c': arg_copy=strdup(arg); token=strtok(arg_copy,","); do { uint32_t cru = atoi(token); if ( cru > 1 ) { cout << "*Strange CRU position: " << cru << endl; } else { arguments->pSelectCruList.push_back(cru); } } while ((token=strtok(NULL,","))); free(arg_copy); break; case 'b': arg_copy=strdup(arg); token=strtok(arg_copy,","); do { uint32_t branch = atoi(token); if ( branch > 1 ) { cout << "*Strange branch: " << branch << endl; } else { arguments->pSelectBranchList.push_back(branch); } } while ((token=strtok(NULL,","))); free(arg_copy); break; case 'f': arg_copy=strdup(arg); token=strtok(arg_copy,","); do { uint32_t fec = atoi(token); if ( fec > 9 ) { cout << "*Strange fec: " << fec << endl; } else { arguments->pSelectFecList.push_back(fec); } } while ((token=strtok(NULL,","))); free(arg_copy); break; case OPT_TEST: arguments->pTest = true; cout << "*Test mode. No DB activity. Output written to local file." << endl; break; default: return ARGP_ERR_UNKNOWN; } return 0; } static struct argp argp={options,parse_opt,0,doc}; // ============================================================================= // ============================================================================= int32_t check_args(int32_t argc, char** argv ) { // // Check all arguments given // TpcConfig tpcconf; // Default arguments arguments.pExit = false; arguments.pdbUserSet = false; arguments.pdbPasswordSet = false; arguments.pdbConnectIdSet = false; arguments.pTest = false; arguments.pConnected = false; arguments.pInfo = false; arguments.pInfoID = false; arguments.pInfoSelectedID = -1; arguments.pDrop = false; arguments.pDropCounter = 0; arguments.pDelete = false; arguments.pDeleteCounter = 0; arguments.pShowTables = false; arguments.pCreate = false; arguments.pCreateCounter = 0; arguments.pFill = false; arguments.pFillGbtx = false; arguments.pUpdate = false; arguments.pUpdateAll = false; arguments.pDump = false; arguments.pDumpTag = false; arguments.pSelect = false; arguments.pSelectTablePedestal = false; arguments.pSelectTableOnChannel = false; arguments.pSelectTableZsThr = false; arguments.pSelectTableCmCorr = false; arguments.pSelectTableItCorr1 = false; arguments.pSelectTableItCorr2 = false; arguments.pSelectTableFec = false; arguments.pSelectTableCru = false; arguments.pSelectTablePartition = false; arguments.pSelectTableTpc = false; arguments.pSelectSingleField = false; arguments.pSelectField = ""; arguments.pUpdateString = ""; arguments.pUpdateValueInt = -1; arguments.pUpdateValueFloat = -1.; argp_parse(&argp, argc, argv, 0, 0, &arguments); if (arguments.pExit) return 1; // //Check Commandline Parameters // if ( (arguments.pdbUserSet == false) && (arguments.pTest == false) ) { cout << "*No db Username set!" << endl; return 0; } if ( (arguments.pdbPasswordSet == false) && (arguments.pTest == false) ) { cout << "*No db Password set!" << endl; return 0; } if ( (arguments.pdbConnectIdSet == false) && (arguments.pTest == false) ) { cout << "*No db Connect-String set!" << endl; } if ( (arguments.pInfoID == true) && (arguments.pInfoSelectedID < 0) ) { cout << "*No valid ID specified:" << arguments.pInfoSelectedID << endl; return 0; } if ( arguments.pFill == true ) { if ( arguments.pSelectTagList.size() == 0 ) { cout << "*No Tag (Configuration ID) specified! Use option \"--tag\"." << endl; return 0; } } if ( ( arguments.pSelect == true) || ( arguments.pUpdate == true) ) { if ( ( arguments.pSelectTableTpc == false ) && ( arguments.pSelectTableCru == false ) && ( arguments.pSelectTableFec == false ) && ( arguments.pSelectTablePartition == false ) && ( arguments.pSelectTablePedestal == false ) && ( arguments.pSelectTableOnChannel == false ) && ( arguments.pSelectTableCmCorr == false ) && ( arguments.pSelectTableItCorr1 == false ) && ( arguments.pSelectTableItCorr2 == false ) && ( arguments.pSelectTableZsThr == false ) ) { cout << "*No table specified! Specify (--table=) TPC, PARTITION, CRU, FEC, ..." << endl; return 0; } } if ( arguments.pUpdate == true ) { if ( arguments.pSelectSingleField == false ) { cout << "*No column specified!" << endl; return 0; } if ( (arguments.pUpdateValueInt < 0) && (arguments.pUpdateValueFloat < 0.) && ( arguments.pUpdateString.length() < 1) ) { cout << "*No new value or string specified for update!" << endl; return 0; } } if ( arguments.pUpdateAll == true ) { if ( arguments.pSelectTableTpc == true ) { cout << "*Command \"updateall\" not available for table TPC" << endl; return 0; } if ( (arguments.pSelectTableFec == false ) && ( arguments.pSelectTableCru == false ) && ( arguments.pSelectTablePartition == false ) && ( arguments.pSelectTablePedestal == false ) && ( arguments.pSelectTableOnChannel == false ) && ( arguments.pSelectTableCmCorr == false ) && ( arguments.pSelectTableItCorr1 == false ) && ( arguments.pSelectTableItCorr2 == false ) && ( arguments.pSelectTableZsThr == false ) ) { cout << "*No table specified! Specify (--table=) PARTITION, CRU, FEC, ..." << endl; return 0; } if ( arguments.pSelectTagList.size() == 0 ) { cout << "*No Tag (Configuration ID) specified!" << endl; return 0; } if ( arguments.pSelectSingleField == false ) { cout << "*No column specified!" << endl; return 0; } if ( (arguments.pUpdateValueInt < 0) && (arguments.pUpdateValueFloat < 0.) && ( arguments.pUpdateString.length() < 1) ) { cout << "*No new value specified for update!" << endl; return 0; } } if ( arguments.pDumpTag == true ) { if ( arguments.pSelectTagList.size() == 0 ) { cout << "*No Tag (Configuration ID) specified!" << endl; return 0; } if ( ( arguments.pSelectTableCru == false ) && ( arguments.pSelectTableFec == false ) && ( arguments.pSelectTablePedestal == false ) && ( arguments.pSelectTableOnChannel == false ) && ( arguments.pSelectTableCmCorr == false ) && ( arguments.pSelectTableItCorr1 == false ) && ( arguments.pSelectTableItCorr2 == false ) && ( arguments.pSelectTableZsThr == false ) && ( arguments.pSelectTableTpc == false ) ) { arguments.pSelectTablePedestal = true; arguments.pSelectTableOnChannel = true; arguments.pSelectTableZsThr = true; arguments.pSelectTableCmCorr = true; arguments.pSelectTableItCorr1 = true; arguments.pSelectTableItCorr2 = true; arguments.pSelectTableFec = true; arguments.pSelectTableCru = true; arguments.pSelectTableTpc = true; } } if ( ( arguments.pSelect == true) || ( arguments.pUpdate == true) || ( arguments.pDump == true) ) { if ( arguments.pSelectTagList.size() == 0 ) { cout << "*No Tag (Configuration ID) specified!" << endl; return 0; } if ( ( arguments.pSelectTablePartition == true) || ( arguments.pSelectTableCru == true) || ( arguments.pSelectTableFec == true) ) { if ( arguments.pSelectSideList.size() == 0 ) { cout << "*No side specified!" << endl; return 0; } if ( arguments.pSelectSectorList.size() == 0 ) { cout << "*No sector specified!" << endl; return 0; } if ( arguments.pSelectPartitionList.size() == 0 ) { cout << "*No side partition specified!" << endl; return 0; } } if ( arguments.pSelectTableCru == true ) { if ( arguments.pSelectCruList.size() == 0 ) { cout << "*No CRU number specified!" << endl; return 0; } } if ( arguments.pSelectTableFec == true ) { if ( arguments.pSelectBranchList.size() == 0 ) { cout << "*No FEC branch specified!" << endl; return 0; } if ( arguments.pSelectFecList.size() == 0 ) { cout << "*No FEC number specified!" << endl; return 0; } } if ( (arguments.pSelectTablePedestal == true) || (arguments.pSelectTableZsThr == true) || (arguments.pSelectTableOnChannel == true) || (arguments.pSelectTableCmCorr == true) || (arguments.pSelectTableItCorr1 == true) || (arguments.pSelectTableItCorr2 == true) ) { if ( arguments.pSelectSideList.size() == 0 ) { cout << "*No side specified!" << endl; return 0; } if ( arguments.pSelectSectorList.size() == 0 ) { cout << "*No sector specified!" << endl; return 0; } if ( arguments.pSelectPartitionList.size() == 0 ) { cout << "*No side partition specified!" << endl; return 0; } if ( arguments.pSelectCruList.size() == 0 ) { cout << "*No CRU number specified!" << endl; return 0; } if ( arguments.pSelectBranchList.size() == 0 ) { cout << "*No FEC branch specified!" << endl; return 0; } if ( arguments.pSelectFecList.size() == 0 ) { cout << "*No FEC number specified!" << endl; return 0; } } } return 1; } // ============================================================================= // ============================================================================= // ============================================================================= // ============================================================================= // ============================================================================= // ============================================================================= int main(int argc, char** argv ) { // TODO: Use EXIT_SUCCESS and EXIT_FAILURE if (!check_args(argc, argv)) exit(EXIT_FAILURE); if (arguments.pExit) exit(EXIT_SUCCESS); // // Connect // if ( !arguments.pTest ) { try { Environment::Initialize(); con.Open(arguments.pdbConnectId, arguments.pdbUser, arguments.pdbPassword); } catch(std::exception &ex) { cout << ex.what() << endl; exit(EXIT_FAILURE); } if ( con.IsServerAlive() ) { cout << "================================================================" << endl; cout << "=== Connected to: " << endl << con.GetServerVersion() << endl; cout << "=== Data base: " << con.GetDatabase() << endl; cout << "=== Instance: " << con.GetInstance() << endl; cout << "=== Service: " << con.GetService() << endl; cout << "=== Server: " << con.GetServer() << endl; cout << "=== Domain: " << con.GetDomain() << endl; cout << "=== Oracle version used for the connection: " << con.GetVersion() << endl; cout << "================================================================" << endl; arguments.pConnected = true; } else { cout << "Server is dead. Doing nothing..." << endl; exit(EXIT_FAILURE); } } if ( arguments.pInfo && !getinfo() ) cerr << "*Error: Could not get info! Maybe TPC table does not exist?" << endl; else if ( arguments.pDrop && !droptables() ) cerr << "*Error: Could not drop the table(s)!" << endl; else if ( arguments.pDelete && !deletetables() ) cerr << "*Error: Could not delete the table(s)!" << endl; else if ( arguments.pShowTables && !showtables() ) cerr << "*Error: Could not show the user table(s)!" << endl; else if ( arguments.pCreate && !createtables() ) cerr << "*Error: Could not create the table(s)!" << endl; else if ( arguments.pFill && !filltables() ) cerr << "*Error: Could not fill the table(s)!" << endl; else if ( arguments.pFillGbtx && !fillgbtx1() ) cerr << "*Error: Could not fill the GBTX1 table!" << endl; else if ( arguments.pSelect ) { if ( arguments.pSelectTableTpc && !selecttpc() ) cerr << "*Error: Could not get tpc data!" << endl; else if ( arguments.pSelectTablePartition && !selectpartition() ) cerr << "*Error: Could not get partition data!" << endl; else if ( arguments.pSelectTableCru && !selectcru() ) cerr << "*Error: Could not get cru data!" << endl; else if ( arguments.pSelectTableFec && !selectfec() ) cerr << "*Error: Could not get fec data!" << endl; else if ( arguments.pSelectTablePedestal && !selectUL("pedestal") ) cerr << "*Error: Could not get PEDESTAL data!" << endl; else if ( arguments.pSelectTableZsThr && !selectUL("zsthr") ) cerr << "*Error: Could not get ZSTHR data!" << endl; else if ( arguments.pSelectTableOnChannel && !selectUL("on_channel") ) cerr << "*Error: Could not get ON_CHANNEL data!" << endl; else if ( arguments.pSelectTableCmCorr && !selectUL("cmcorr") ) cerr << "*Error: Could not get CMCORR data!" << endl; else if ( arguments.pSelectTableItCorr1 && !selectUL("itcorr1") ) cerr << "*Error: Could not get ITCORR1 data!" << endl; else if ( arguments.pSelectTableItCorr2 && !selectUL("itcorr2") ) cerr << "*Error: Could not get ITCORR2 data!" << endl; } else if ( arguments.pUpdate ) { if ( arguments.pSelectTableTpc && !updatetpc() ) cerr << "*Error: Could not update tpc table!" << endl; else if ( arguments.pSelectTablePartition && !updatepartition() ) cerr << "*Error: Could not update partition table!" << endl; else if ( arguments.pSelectTableCru && !updatecru() ) cerr << "*Error: Could not update cru table!" << endl; else if ( arguments.pSelectTableFec && !updatefec() ) cerr << "*Error: Could not update fec table!" << endl; else if ( arguments.pSelectTablePedestal && !updateUL("pedestal") ) cerr << "*Error: Could not update PEDESTAL data!" << endl; else if ( arguments.pSelectTableZsThr && !updateUL("zsthr") ) cerr << "*Error: Could not update ZSTHR data!" << endl; else if ( arguments.pSelectTableOnChannel && !updateUL("on_channel") ) cerr << "*Error: Could not update ON_CNANNEL data!" << endl; else if ( arguments.pSelectTableCmCorr && !updateUL("cmcorr") ) cerr << "*Error: Could not update CMCORR data!" << endl; else if ( arguments.pSelectTableItCorr1 && !updateUL("itcorr1") ) cerr << "*Error: Could not update ITCORR1 data!" << endl; else if ( arguments.pSelectTableItCorr2 && !updateUL("itcorr2") ) cerr << "*Error: Could not update ITCORR2 data!" << endl; } else if ( arguments.pUpdateAll ) { if ( arguments.pSelectTablePartition && !updateallpartition() ) cerr << "*Error: Could not update partition table!" << endl; else if ( arguments.pSelectTableCru && !updateallcru() ) cerr << "*Error: Could not update cru table!" << endl; else if ( arguments.pSelectTableFec && !updateallfec() ) cerr << "*Error: Could not update fec table!" << endl; else if ( arguments.pSelectTablePedestal && !updateallUL("pedestal") ) cerr << "*Error: Could not update PEDESTAL data!" << endl; else if ( arguments.pSelectTableZsThr && !updateallUL("zsthr") ) cerr << "*Error: Could not update ZSTHR data!" << endl; else if ( arguments.pSelectTableOnChannel && !updateallUL("on_channel") ) cerr << "*Error: Could not update ON_CNANNEL data!" << endl; else if ( arguments.pSelectTableCmCorr && !updateallUL("cmcorr") ) cerr << "*Error: Could not update CMCORR data!" << endl; else if ( arguments.pSelectTableItCorr1 && !updateallUL("itcorr1") ) cerr << "*Error: Could not update ITCORR1 data!" << endl; else if ( arguments.pSelectTableItCorr2 && !updateallUL("itcorr2") ) cerr << "*Error: Could not update ITCORR2 data!" << endl; } else if ( arguments.pDump ) { if ( arguments.pSelectTableTpc && !dumptpc() ) cerr << "*Error: Could not get tpc data!" << endl; else if ( arguments.pSelectTableCru && !dumpcru() ) cerr << "*Error: Could not get cru data!" << endl; else if ( arguments.pSelectTableFec && !dumpfec() ) cerr << "*Error: Could not get fec data!" << endl; else if ( arguments.pSelectTablePedestal && !dumpUL("pedestal") ) cerr << "*Error: Could not get PEDESTAL data!" << endl; else if ( arguments.pSelectTableZsThr && !dumpUL("zsthr") ) cerr << "*Error: Could not get ZSTHR data!" << endl; else if ( arguments.pSelectTableOnChannel && !dumpUL("on_channel") ) cerr << "*Error: Could not get ON_CHANNEL data!" << endl; else if ( arguments.pSelectTableCmCorr && !dumpUL("cmcorr") ) cerr << "*Error: Could not get CMCORR data!" << endl; else if ( arguments.pSelectTableItCorr1 && !dumpUL("itcorr1") ) cerr << "*Error: Could not get ITCORR1 data!" << endl; else if ( arguments.pSelectTableItCorr2 && !dumpUL("itcorr2") ) cerr << "*Error: Could not get ITCORR2 data!" << endl; } else if ( arguments.pDumpTag && !dumptag() ) cerr << "*Error: Could not get and dump data!" << endl; // // Disconnect // if ( !arguments.pTest && arguments.pConnected ) { try { Environment::Cleanup(); } catch(std::exception &ex) { cout << ex.what() << endl; exit(EXIT_FAILURE); } } if (sw != NULL) { delete sw; sw = 0; } if (dbq != NULL) { delete dbq; dbq = 0; } return EXIT_SUCCESS; } // EOF