| 1 |
//============================================================================ |
//============================================================================ |
| 2 |
// $Id: PamOffLineSW_Main.cpp,v 1.51 2008-09-05 14:33:48 messineo Exp $ |
// $Id: PamOffLineSW_Main.cpp,v 1.52 2008-09-12 14:03:55 messineo Exp $ |
| 3 |
// Description : Pamela Off-Line Software |
// Description : Pamela Off-Line Software |
| 4 |
//============================================================================ |
//============================================================================ |
| 5 |
|
|
| 48 |
int db_port = 0; |
int db_port = 0; |
| 49 |
char* db_name = ""; |
char* db_name = ""; |
| 50 |
char conn[100]=""; |
char conn[100]=""; |
|
//char* connection = NULL; |
|
|
//char* db_user = "yoda_user"; |
|
|
//char* db_pwd = "yoda_pwd"; |
|
| 51 |
|
|
| 52 |
LogUtil::logLevel loglevel=LogUtil::LOGERROR; |
LogUtil::logLevel loglevel=LogUtil::LOGERROR; |
| 53 |
char* logfilename = "pamofflinesw.log"; |
char* logfilename = "chewbacca.log"; |
| 54 |
//current route |
//current route |
| 55 |
int route = 999; |
int route = 999; |
| 56 |
//previous route |
//previous route |
| 76 |
// char *outDir = "."; |
// char *outDir = "."; |
| 77 |
char *outDir = ""; |
char *outDir = ""; |
| 78 |
|
|
| 79 |
char * nome_output="yoda"; |
char * nome_output="chewbacca"; |
| 80 |
bool multiFile = 0; |
bool multiFile = 0; |
| 81 |
unsigned long int step_pkt_number=0; |
unsigned long int step_pkt_number=0; |
| 82 |
unsigned long int step_pkt_obt=0; |
unsigned long int step_pkt_obt=0; |
| 83 |
LogUtil* mainLogUtil = NULL; |
LogUtil* mainLogUtil = NULL; |
| 96 |
|
|
| 97 |
//TODO: now it is unused |
//TODO: now it is unused |
| 98 |
unsigned long int delta_Time=0;//in seconds |
unsigned long int delta_Time=0;//in seconds |
| 99 |
|
#define TAGVALUELEN 4 |
| 100 |
|
char tag_value[TAGVALUELEN]; |
| 101 |
} |
} |
| 102 |
|
|
| 103 |
// main: |
// main: |
| 160 |
cout << "\t (-help | --help | -h) print this help and exit \n"; |
cout << "\t (-help | --help | -h) print this help and exit \n"; |
| 161 |
cout << "\t -simu if the input file contains simulated data instead of real data\n"; |
cout << "\t -simu if the input file contains simulated data instead of real data\n"; |
| 162 |
cout << "\t -vrl if you want to perform the vrl check\n"; |
cout << "\t -vrl if you want to perform the vrl check\n"; |
| 163 |
cout << "\t -filelog set the log filename. [default: pamofflinesw.log]\n"; |
cout << "\t -filelog set the log filename. [default: chewbacca.log]\n"; |
| 164 |
cout << "\t -loglevel set the log level. Values: [0,3] (error,warning,info,all) [default:0]\n"; |
cout << "\t -loglevel set the log level. Values: [0,3] (error,warning,info,all) [default:0]\n"; |
| 165 |
cout << "\t -c set the compression level for the generated ROOT file(s). Values: [0,9] [default = 3]\n"; |
cout << "\t -c set the compression level for the generated ROOT file(s). Values: [0,9] [default = 3]\n"; |
| 166 |
cout << "\t -root_name set the root-name for the generated ROOT file(s). [default = yoda]\n"; |
cout << "\t -root_name set the root-name for the generated ROOT file(s). [default = chewbacca]\n"; |
| 167 |
cout << "\t -outDir set the output directory for the generated root file(s). [default = .]\n"; |
cout << "\t -outDir set the output directory for the generated root file(s). [default = .]\n"; |
| 168 |
cout << "\t -delta_counter set the allowed difference in the Packet Counter between two continuos packets. If 0 all packets are considered continuos. [default = 0]\n"; |
cout << "\t -delta_counter set the allowed difference in the Packet Counter between two continuos packets. If 0 all packets are considered continuos. [default = 0]\n"; |
| 169 |
cout << "\t -delta_obt set the allowed difference (ms) in the Packet Orbital Time between two continuos packets. If 0 all packets are considered continuos. [default = 0]\n"; |
cout << "\t -delta_obt set the allowed difference (ms) in the Packet Orbital Time between two continuos packets. If 0 all packets are considered continuos. [default = 0]\n"; |
| 170 |
cout << "\t -db_host set the host-name of the DataBase. [default = localhost]\n"; |
cout << "\t -db_host set the host-name of the DataBase. [default = localhost]\n"; |
| 171 |
cout << "\t -db_port set the port of the DataBase. [default = 3306]\n"; |
cout << "\t -db_port set the port of the DataBase. [default = 3306]\n"; |
| 172 |
cout << "\t -db_name set the name of the DataBase. [default = yoda_db]\n"; |
cout << "\t -db_name set the name of the DataBase. [default = chewbacca_db]\n"; |
| 173 |
cout << "\t -db_user set the user of the DataBase. [default = yoda_user]\n"; |
cout << "\t -db_user set the user of the DataBase. [default = chewbacca_user]\n"; |
| 174 |
cout << "\t -db_pwd set the user of the DataBase. [default = yoda_pwd]\n"; |
cout << "\t -db_pwd set the user of the DataBase. [default = chewbacca_pwd]\n"; |
| 175 |
cout << "\t -max_pkt_number Maximum value for Packet Counter, after this value it is resetted. [default = 2^24 - 1]\n"; |
cout << "\t -max_pkt_number Maximum value for Packet Counter, after this value it is resetted. [default = 2^24 - 1]\n"; |
| 176 |
cout << "\t -max_pkt_obt Maximum value for Packet OBT, after this value it is resetted. [default = 2^32 - 1]\n"; |
cout << "\t -max_pkt_obt Maximum value for Packet OBT, after this value it is resetted. [default = 2^32 - 1]\n"; |
| 177 |
cout << "\t -orbit_number Value of the orbital number. If 0 this is retrieved from the input file name. [default = 0]\n"; |
cout << "\t -orbit_number Value of the orbital number. If 0 this is retrieved from the input file name. [default = 0]\n"; |
| 178 |
cout << "\t -session_number Value of the session number. If 0 this is retrieved from the input file name. [default = 0]\n"; |
cout << "\t -session_number Value of the session number. If 0 this is retrieved from the input file name. [default = 0]\n"; |
| 179 |
cout << "\t -time_Offset Value of the timeOffset. If 0 this is retrieved using the orbital number. [default = 0]\n"; |
cout << "\t -time_Offset Value of the timeOffset. If 0 this is retrieved using the orbital number. [default = 0]\n"; |
| 180 |
cout << "\t -tryMerge if you want to try to Merge ROOT files\n"; |
cout << "\t -tryMerge if you want to try to Merge ROOT files\n"; |
| 181 |
//marco_new_01 |
//marco_new_01 |
| 182 |
cout << "\t -single_connection if you want to open only one connection to DB.\n"; |
cout << "\t -single_connection if you want to open only one connection to DB.\n"; |
| 183 |
// cout << "\t -delta_Time set the allowed difference (seconds) in the Real Time between two root file. [default = 0]\n"; |
cout << "\t -tag if you want add the 'The owner of the file' - the tag lenght is 4 char\n"; |
| 184 |
|
// cout << "\t -delta_Time set the allowed difference (seconds) in the Real Time between two root file. [default = 0]\n"; |
| 185 |
//cout << "\t -multi generate multiple root files \n"; |
//cout << "\t -multi generate multiple root files \n"; |
| 186 |
exit(1); |
exit(1); |
| 187 |
} |
} |
| 490 |
db_pwd = argv[i]; |
db_pwd = argv[i]; |
| 491 |
continue; |
continue; |
| 492 |
} |
} |
| 493 |
|
if (!strcmp(argv[i], "-tag")){ |
| 494 |
|
if (++i >= argc){ |
| 495 |
|
cerr << "-tag needs arguments. \n"; |
| 496 |
|
cout << "Try '-help' for more information. \n"; |
| 497 |
|
exit(1); |
| 498 |
|
} |
| 499 |
|
int len=strlen(argv[i])>TAGVALUELEN?TAGVALUELEN:strlen(argv[i]); |
| 500 |
|
strncpy(tag_value,argv[i],len); |
| 501 |
|
tag_value[len]=0; |
| 502 |
|
continue; |
| 503 |
|
} |
| 504 |
|
|
| 505 |
//TODO: check that multiFile is always 0 |
//TODO: check that multiFile is always 0 |
| 506 |
// if (!strcmp(argv[i], "-multi")){multiFile = 1; cout<<"debug: multi= "<<multiFile<<endl;} |
// if (!strcmp(argv[i], "-multi")){multiFile = 1; cout<<"debug: multi= "<<multiFile<<endl;} |
| 507 |
} |
} |
| 600 |
|
|
| 601 |
if (!strcmp(db_name,"")) |
if (!strcmp(db_name,"")) |
| 602 |
{ |
{ |
| 603 |
db_name="yoda_db"; |
db_name="chewbacca_db"; |
| 604 |
} |
} |
| 605 |
sprintf(conn,"mysql://%s:%d/%s",db_host,db_port,db_name); |
sprintf(conn,"mysql://%s:%d/%s",db_host,db_port,db_name); |
| 606 |
connection=conn; |
connection=conn; |
| 620 |
} |
} |
| 621 |
else |
else |
| 622 |
{ |
{ |
| 623 |
db_user="yoda_user"; |
db_user="chewbacca_user"; |
| 624 |
} |
} |
| 625 |
|
|
| 626 |
} |
} |
| 634 |
} |
} |
| 635 |
else |
else |
| 636 |
{ |
{ |
| 637 |
db_pwd="yoda_pwd"; |
db_pwd="chewbacca_pwd"; |
| 638 |
} |
} |
| 639 |
} |
} |
| 640 |
|
|
| 828 |
if(do_vrl_check){isCadreGood=false;} |
if(do_vrl_check){isCadreGood=false;} |
| 829 |
break; |
break; |
| 830 |
} |
} |
| 831 |
|
skip_cadre = false; |
| 832 |
//check of the VRL header e setta route number |
//check of the VRL header e setta route number |
| 833 |
if(!VRL_Header_Check(ccHeader_VRL,LENGTH_HEADER_VRL)) |
if(!VRL_Header_Check(ccHeader_VRL,LENGTH_HEADER_VRL)) |
| 834 |
{ |
{ |
| 907 |
string msg = oss.str(); |
string msg = oss.str(); |
| 908 |
mainLogUtil->logError(msg); |
mainLogUtil->logError(msg); |
| 909 |
|
|
| 910 |
//non mi fido del contatore del route |
//non mi fido del contatore del route |
|
|
|
| 911 |
stringstream oss1; |
stringstream oss1; |
| 912 |
oss1<<"Route number unused = "<<route<<" Resetting ROUTE to old value = "<<old_route<<" (download="<<download<<")"; |
oss1<<"Route number unused = "<<route<<" Resetting ROUTE to old value = "<<old_route<<" (download="<<download<<")"; |
| 913 |
msg = oss1.str(); |
msg = oss1.str(); |
| 930 |
mainLogUtil->logAll(msg); |
mainLogUtil->logAll(msg); |
| 931 |
} |
} |
| 932 |
// is_new_route will be reset to false in PacketUser after the packet is used and stored |
// is_new_route will be reset to false in PacketUser after the packet is used and stored |
| 933 |
|
|
| 934 |
|
|
| 935 |
//main processing of the data, searching for Pamela Packets |
//main processing of the data, searching for Pamela Packets |
| 936 |
for(int i=0; i<LENGTH_DATA_CADRE; i++) |
for(int i=0; i<LENGTH_DATA_CADRE; i++) |
| 937 |
{ |
{ |
| 938 |
StateManager::getInstance().getCurrentState()->readInput(ccData[i]); |
StateManager::getInstance().getCurrentState()->readInput(ccData[i]); |
| 939 |
iByte_tot++; |
iByte_tot++; |
| 940 |
if(exitdbg==true){cout<<"**** DBG EXIT FOR****"<<endl; break;} |
if(exitdbg==true){cout<<"**** DBG EXIT FOR****"<<endl; break;} |
| 941 |
} |
} |
| 942 |
} |
} |
| 943 |
else{ |
else{ |
| 944 |
iByte_tot+=LENGTH_DATA_CADRE; |
iByte_tot+=LENGTH_DATA_CADRE; |
| 977 |
//function that check the header VRL |
//function that check the header VRL |
| 978 |
bool VRL_Header_Check(char* headVRL, int length) |
bool VRL_Header_Check(char* headVRL, int length) |
| 979 |
{ |
{ |
| 980 |
|
|
|
|
|
| 981 |
/* stringstream oss; |
/* stringstream oss; |
| 982 |
oss<<"Pippooooooo: at byte+ "<<iByte_tot<<" cadre ... route number = "<<(int)headVRL[3]; |
oss<<"Pippooooooo: at byte+ "<<iByte_tot<<" cadre ... route number = "<<(int)headVRL[3]; |
| 983 |
string msg = oss.str(); |
string msg = oss.str(); |