1 |
//============================================================================ |
//============================================================================ |
2 |
// $Id: PamOffLineSW_Main.cpp,v 1.52 2008-09-12 14:03:55 messineo Exp $ |
// $Id: PamOffLineSW_Main.cpp,v 1.4 2008/12/18 12:58:37 mocchiut Exp $ |
3 |
// Description : Pamela Off-Line Software |
// Description : Pamela Off-Line Software |
4 |
//============================================================================ |
//============================================================================ |
5 |
|
|
42 |
|
|
43 |
//global variables |
//global variables |
44 |
bool simulated_data = false; |
bool simulated_data = false; |
45 |
bool do_vrl_check = false; |
//bool do_vrl_check = false; //EMI |
46 |
|
bool do_vrl_check = true; //EMI |
47 |
|
|
48 |
char* db_host = ""; |
char* db_host = ""; |
49 |
int db_port = 0; |
int db_port = 0; |
77 |
// char *outDir = "."; |
// char *outDir = "."; |
78 |
char *outDir = ""; |
char *outDir = ""; |
79 |
|
|
80 |
char * nome_output="chewbacca"; |
// char * nome_output="chewbacca"; //EMI |
81 |
bool multiFile = 0; |
char * nome_output="L0PAM";//EMI |
82 |
unsigned long int step_pkt_number=0; |
bool multiFile = 0; |
83 |
unsigned long int step_pkt_obt=0; |
// unsigned long int step_pkt_number=0; // EMI |
84 |
|
unsigned long int step_pkt_number=3000; |
85 |
|
// unsigned long int step_pkt_obt=0; // EMI |
86 |
|
unsigned long int step_pkt_obt=7200000; // EMI |
87 |
LogUtil* mainLogUtil = NULL; |
LogUtil* mainLogUtil = NULL; |
88 |
TSQLServer* sqlServer = NULL; |
TSQLServer* sqlServer = NULL; |
89 |
unsigned long int max_pkt_number = 16777215;//biggest value before reset |
unsigned long int max_pkt_number = 16777215;//biggest value before reset |
90 |
unsigned long int max_pkt_obt = 4294967295u;//biggest value before reset |
unsigned long int max_pkt_obt = 4294967295u;//biggest value before reset |
91 |
|
|
92 |
bool is_new_route = false; |
// bool is_new_route = false; // EMI |
93 |
|
bool is_new_route = true; // EMI ??????????? VA BENE? SECONDO ME SI` |
94 |
unsigned int download = 0; |
unsigned int download = 0; |
95 |
unsigned int orbit_number=0; |
unsigned int orbit_number=0; |
96 |
unsigned int mmm_number = 0;//session_number |
unsigned int mmm_number = 0;//session_number |
97 |
unsigned long int time_Offset=0; |
unsigned long int time_Offset=0; |
98 |
bool tryMerge = false; |
// bool tryMerge = false; |
99 |
|
bool tryMerge = true; |
100 |
|
|
101 |
bool do_cont_check=true;//if do_cont_check is false do not use a DB ... |
bool do_cont_check=true;//if do_cont_check is false do not use a DB ... |
102 |
|
|
103 |
//TODO: now it is unused |
//TODO: now it is unused |
104 |
unsigned long int delta_Time=0;//in seconds |
unsigned long int delta_Time=0;//in seconds |
105 |
|
#define TAGVALUELEN 4 |
106 |
|
char tag_value[TAGVALUELEN]; |
107 |
} |
} |
108 |
|
|
109 |
// main: |
// main: |
184 |
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"; |
185 |
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"; |
186 |
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"; |
187 |
//marco_new_01 |
cout << "\t -dontMerge if you don not want to try to Merge ROOT files\n"; |
188 |
|
//marco_new_01 |
189 |
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"; |
190 |
// 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"; |
191 |
|
// cout << "\t -delta_Time set the allowed difference (seconds) in the Real Time between two root file. [default = 0]\n"; |
192 |
//cout << "\t -multi generate multiple root files \n"; |
//cout << "\t -multi generate multiple root files \n"; |
193 |
exit(1); |
exit(1); |
194 |
} |
} |
222 |
tryMerge = true; |
tryMerge = true; |
223 |
continue; |
continue; |
224 |
} |
} |
225 |
|
|
226 |
|
if (!strcmp(argv[i], "-dontMerge")) // EMI |
227 |
|
{ |
228 |
|
tryMerge = false; |
229 |
|
continue; |
230 |
|
} |
231 |
|
|
232 |
if (!strcmp(argv[i], "-time_Offset")){ |
if (!strcmp(argv[i], "-time_Offset")){ |
233 |
if (++i >= argc){ |
if (++i >= argc){ |
316 |
continue; |
continue; |
317 |
} |
} |
318 |
|
|
319 |
|
if (!strcmp(argv[i], "-no-vrl")) //EMI |
320 |
|
{ |
321 |
|
do_vrl_check = false; |
322 |
|
} |
323 |
if (!strcmp(argv[i], "-vrl")) |
if (!strcmp(argv[i], "-vrl")) |
324 |
{ |
{ |
325 |
do_vrl_check = true; |
do_vrl_check = true; |
383 |
exit(1); |
exit(1); |
384 |
} |
} |
385 |
DIR* tempdir; |
DIR* tempdir; |
386 |
if ((tempdir = opendir(argv[i])) != 0) { |
if ((tempdir = opendir(gSystem->ExpandPathName(argv[i]))) != 0) { // EMI |
387 |
outDir = argv[i]; |
outDir = argv[i]; |
388 |
closedir(tempdir); |
closedir(tempdir); |
389 |
} else { |
} else { |
507 |
db_pwd = argv[i]; |
db_pwd = argv[i]; |
508 |
continue; |
continue; |
509 |
} |
} |
510 |
|
if (!strcmp(argv[i], "-tag")){ |
511 |
|
if (++i >= argc){ |
512 |
|
cerr << "-tag needs arguments. \n"; |
513 |
|
cout << "Try '-help' for more information. \n"; |
514 |
|
exit(1); |
515 |
|
} |
516 |
|
int len=strlen(argv[i])>TAGVALUELEN?TAGVALUELEN:strlen(argv[i]); |
517 |
|
strncpy(tag_value,argv[i],len); |
518 |
|
tag_value[len]=0; |
519 |
|
continue; |
520 |
|
} |
521 |
|
|
522 |
//TODO: check that multiFile is always 0 |
//TODO: check that multiFile is always 0 |
523 |
// if (!strcmp(argv[i], "-multi")){multiFile = 1; cout<<"debug: multi= "<<multiFile<<endl;} |
// if (!strcmp(argv[i], "-multi")){multiFile = 1; cout<<"debug: multi= "<<multiFile<<endl;} |
524 |
} |
} |
664 |
string msg = "Input file: " + (string)fni; |
string msg = "Input file: " + (string)fni; |
665 |
mainLogUtil->logAlways(msg); |
mainLogUtil->logAlways(msg); |
666 |
|
|
667 |
msg = "Output directory for the generated root file(s): " + (string)outDir; |
msg = "Output directory for the generated root file(s): " + (string)outDir; |
668 |
mainLogUtil->logAlways(msg); |
mainLogUtil->logAlways(msg); |
669 |
|
msg = "Output directory for the generated root file(s) expanded: " + (string)gSystem->ExpandPathName(outDir); // EMI |
670 |
|
mainLogUtil->logAlways(msg); //EMI |
671 |
|
|
672 |
msg = "Output root name for the generated root file(s): " + (string)nome_output; |
msg = "Output root name for the generated root file(s): " + (string)nome_output; |
673 |
mainLogUtil->logAlways(msg); |
mainLogUtil->logAlways(msg); |
847 |
if(do_vrl_check){isCadreGood=false;} |
if(do_vrl_check){isCadreGood=false;} |
848 |
break; |
break; |
849 |
} |
} |
850 |
|
skip_cadre = false; |
851 |
//check of the VRL header e setta route number |
//check of the VRL header e setta route number |
852 |
if(!VRL_Header_Check(ccHeader_VRL,LENGTH_HEADER_VRL)) |
if(!VRL_Header_Check(ccHeader_VRL,LENGTH_HEADER_VRL)) |
853 |
{ |
{ |
949 |
mainLogUtil->logAll(msg); |
mainLogUtil->logAll(msg); |
950 |
} |
} |
951 |
// 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 |
952 |
|
|
953 |
|
|
954 |
//main processing of the data, searching for Pamela Packets |
//main processing of the data, searching for Pamela Packets |
955 |
for(int i=0; i<LENGTH_DATA_CADRE; i++) |
for(int i=0; i<LENGTH_DATA_CADRE; i++) |
956 |
{ |
{ |
957 |
StateManager::getInstance().getCurrentState()->readInput(ccData[i]); |
StateManager::getInstance().getCurrentState()->readInput(ccData[i]); |
958 |
iByte_tot++; |
iByte_tot++; |
959 |
if(exitdbg==true){cout<<"**** DBG EXIT FOR****"<<endl; break;} |
if(exitdbg==true){cout<<"**** DBG EXIT FOR****"<<endl; break;} |
960 |
} |
} |
961 |
} |
} |
962 |
else{ |
else{ |
963 |
iByte_tot+=LENGTH_DATA_CADRE; |
iByte_tot+=LENGTH_DATA_CADRE; |