1 |
//============================================================================ |
//============================================================================ |
2 |
// $Id: PamOffLineSW_Main.cpp,v 1.52 2008-09-12 14:03:55 messineo Exp $ |
// $Id: PamOffLineSW_Main.cpp,v 1.5 2008/12/18 14:47:02 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: |
166 |
cout << "\t (-help | --help | -h) print this help and exit \n"; |
cout << "\t (-help | --help | -h) print this help and exit \n"; |
167 |
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"; |
168 |
cout << "\t -vrl if you want to perform the vrl check\n"; |
cout << "\t -vrl if you want to perform the vrl check\n"; |
169 |
|
cout << "\t -no-vrl if you DO NOT want to perform the vrl check\n"; |
170 |
|
cout << "\t -gpamela gpamela data as input\n"; |
171 |
cout << "\t -filelog set the log filename. [default: chewbacca.log]\n"; |
cout << "\t -filelog set the log filename. [default: chewbacca.log]\n"; |
172 |
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"; |
173 |
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"; |
186 |
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"; |
187 |
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"; |
188 |
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"; |
189 |
//marco_new_01 |
cout << "\t -dontMerge if you don not want to try to Merge ROOT files\n"; |
190 |
|
//marco_new_01 |
191 |
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"; |
192 |
// 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"; |
193 |
|
// cout << "\t -delta_Time set the allowed difference (seconds) in the Real Time between two root file. [default = 0]\n"; |
194 |
//cout << "\t -multi generate multiple root files \n"; |
//cout << "\t -multi generate multiple root files \n"; |
195 |
exit(1); |
exit(1); |
196 |
} |
} |
209 |
exit(1); |
exit(1); |
210 |
} |
} |
211 |
|
|
212 |
|
//input file |
213 |
|
fni= argv[1]; |
214 |
|
|
215 |
for (int i = 2; i < argc; i++) |
for (int i = 2; i < argc; i++) |
216 |
{ |
{ |
217 |
//marco_new_01 |
//marco_new_01 |
227 |
tryMerge = true; |
tryMerge = true; |
228 |
continue; |
continue; |
229 |
} |
} |
230 |
|
|
231 |
|
if (!strcmp(argv[i], "-dontMerge")) // EMI |
232 |
|
{ |
233 |
|
tryMerge = false; |
234 |
|
continue; |
235 |
|
} |
236 |
|
|
237 |
if (!strcmp(argv[i], "-time_Offset")){ |
if (!strcmp(argv[i], "-time_Offset")){ |
238 |
if (++i >= argc){ |
if (++i >= argc){ |
320 |
simulated_data = true; |
simulated_data = true; |
321 |
continue; |
continue; |
322 |
} |
} |
323 |
|
|
324 |
|
if (!strcmp(argv[i], "-gpamela")) |
325 |
|
{ |
326 |
|
simulated_data = true; |
327 |
|
do_vrl_check = false; |
328 |
|
nome_output = (char *)gSystem->BaseName(fni); |
329 |
|
tryMerge = false; |
330 |
|
continue; |
331 |
|
} |
332 |
|
|
333 |
|
if (!strcmp(argv[i], "-no-vrl")) //EMI |
334 |
|
{ |
335 |
|
do_vrl_check = false; |
336 |
|
} |
337 |
if (!strcmp(argv[i], "-vrl")) |
if (!strcmp(argv[i], "-vrl")) |
338 |
{ |
{ |
339 |
do_vrl_check = true; |
do_vrl_check = true; |
397 |
exit(1); |
exit(1); |
398 |
} |
} |
399 |
DIR* tempdir; |
DIR* tempdir; |
400 |
if ((tempdir = opendir(argv[i])) != 0) { |
if ((tempdir = opendir(gSystem->ExpandPathName(argv[i]))) != 0) { // EMI |
401 |
outDir = argv[i]; |
outDir = argv[i]; |
402 |
closedir(tempdir); |
closedir(tempdir); |
403 |
} else { |
} else { |
521 |
db_pwd = argv[i]; |
db_pwd = argv[i]; |
522 |
continue; |
continue; |
523 |
} |
} |
524 |
|
if (!strcmp(argv[i], "-tag")){ |
525 |
|
if (++i >= argc){ |
526 |
|
cerr << "-tag needs arguments. \n"; |
527 |
|
cout << "Try '-help' for more information. \n"; |
528 |
|
exit(1); |
529 |
|
} |
530 |
|
int len=strlen(argv[i])>TAGVALUELEN?TAGVALUELEN:strlen(argv[i]); |
531 |
|
strncpy(tag_value,argv[i],len); |
532 |
|
tag_value[len]=0; |
533 |
|
continue; |
534 |
|
} |
535 |
|
|
536 |
//TODO: check that multiFile is always 0 |
//TODO: check that multiFile is always 0 |
537 |
// if (!strcmp(argv[i], "-multi")){multiFile = 1; cout<<"debug: multi= "<<multiFile<<endl;} |
// if (!strcmp(argv[i], "-multi")){multiFile = 1; cout<<"debug: multi= "<<multiFile<<endl;} |
538 |
} |
} |
539 |
|
|
|
//input file |
|
|
fni= argv[1]; |
|
|
|
|
540 |
//TODO: maybe if simulated data I don't need nothig so I can skip the following lines |
//TODO: maybe if simulated data I don't need nothig so I can skip the following lines |
541 |
// and use instead something similar to: |
// and use instead something similar to: |
542 |
//if(simulated data){orbit_number=99999; mmm_number=999; download=999; } |
if (simulated_data) {orbit_number=99999; mmm_number=999; download=999; } |
543 |
|
|
544 |
//I need the following lines only to retrieve orbit_number and mmm_number (session_number)from the filename |
//I need the following lines only to retrieve orbit_number and mmm_number (session_number)from the filename |
545 |
if((!orbit_number)||(!mmm_number)) |
if((!orbit_number)||(!mmm_number)) |
675 |
string msg = "Input file: " + (string)fni; |
string msg = "Input file: " + (string)fni; |
676 |
mainLogUtil->logAlways(msg); |
mainLogUtil->logAlways(msg); |
677 |
|
|
678 |
msg = "Output directory for the generated root file(s): " + (string)outDir; |
msg = "Output directory for the generated root file(s): " + (string)outDir; |
679 |
mainLogUtil->logAlways(msg); |
mainLogUtil->logAlways(msg); |
680 |
|
msg = "Output directory for the generated root file(s) expanded: " + (string)gSystem->ExpandPathName(outDir); // EMI |
681 |
|
mainLogUtil->logAlways(msg); //EMI |
682 |
|
|
683 |
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; |
684 |
mainLogUtil->logAlways(msg); |
mainLogUtil->logAlways(msg); |
858 |
if(do_vrl_check){isCadreGood=false;} |
if(do_vrl_check){isCadreGood=false;} |
859 |
break; |
break; |
860 |
} |
} |
861 |
|
skip_cadre = false; |
862 |
//check of the VRL header e setta route number |
//check of the VRL header e setta route number |
863 |
if(!VRL_Header_Check(ccHeader_VRL,LENGTH_HEADER_VRL)) |
if(!VRL_Header_Check(ccHeader_VRL,LENGTH_HEADER_VRL)) |
864 |
{ |
{ |
960 |
mainLogUtil->logAll(msg); |
mainLogUtil->logAll(msg); |
961 |
} |
} |
962 |
// 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 |
963 |
|
|
964 |
|
|
965 |
//main processing of the data, searching for Pamela Packets |
//main processing of the data, searching for Pamela Packets |
966 |
for(int i=0; i<LENGTH_DATA_CADRE; i++) |
for(int i=0; i<LENGTH_DATA_CADRE; i++) |
967 |
{ |
{ |
968 |
StateManager::getInstance().getCurrentState()->readInput(ccData[i]); |
StateManager::getInstance().getCurrentState()->readInput(ccData[i]); |
969 |
iByte_tot++; |
iByte_tot++; |
970 |
if(exitdbg==true){cout<<"**** DBG EXIT FOR****"<<endl; break;} |
if(exitdbg==true){cout<<"**** DBG EXIT FOR****"<<endl; break;} |
971 |
} |
} |
972 |
} |
} |
973 |
else{ |
else{ |
974 |
iByte_tot+=LENGTH_DATA_CADRE; |
iByte_tot+=LENGTH_DATA_CADRE; |