1 |
|
|
2 |
#include <log4cxx/logger.h> |
#include <log4cxx/logger.h> |
|
#include <log4cxx/basicconfigurator.h> |
|
|
#include <log4cxx/fileappender.h> |
|
|
#include <log4cxx/patternlayout.h> |
|
3 |
#include <log4cxx/propertyconfigurator.h> |
#include <log4cxx/propertyconfigurator.h> |
|
#include <log4cxx/helpers/exception.h> |
|
|
|
|
|
#include "TROOT.h" |
|
|
|
|
|
#include "TechmodelPamelaRun.h" |
|
4 |
#include "EventReader.h" |
#include "EventReader.h" |
|
|
|
|
#include <cstdlib> |
|
|
#include <iostream> |
|
5 |
#include <time.h> |
#include <time.h> |
|
#include "Exception.h" |
|
6 |
|
|
7 |
extern "C" { |
extern "C" { |
8 |
//#include "DirectoryStructure.h" |
#include <dirent.h> |
|
#include <dirent.h> |
|
9 |
} |
} |
10 |
|
|
11 |
|
|
21 |
|
|
22 |
stringstream oss; |
stringstream oss; |
23 |
int maxPackets = 0; |
int maxPackets = 0; |
24 |
|
bool multiFile = 0; |
25 |
|
short compression = 3; |
26 |
char nomeFileLog[L_tmpnam]; |
char nomeFileLog[L_tmpnam]; |
27 |
tmpnam(nomeFileLog); |
tmpnam(nomeFileLog); |
28 |
DIR *dirp; |
DIR *dirp; |
33 |
outDir = getenv("YODA_DATA"); |
outDir = getenv("YODA_DATA"); |
34 |
if (getenv("YODA_DATA") == NULL) throw NotFoundEnvironmentVarException("The variable YODA_DATA has not been found."); |
if (getenv("YODA_DATA") == NULL) throw NotFoundEnvironmentVarException("The variable YODA_DATA has not been found."); |
35 |
} catch (NotFoundEnvironmentVarException exc) { |
} catch (NotFoundEnvironmentVarException exc) { |
36 |
|
cout << "The variable YODA_DATA has not been found. \n"; |
37 |
|
cout << "Please check your environment variables \n"; |
38 |
oss.str(""); |
oss.str(""); |
39 |
oss << exc.print(); |
oss << exc.print(); |
40 |
logger->fatal(oss.str().c_str()); |
logger->fatal(oss.str().c_str()); |
|
cout << "The variable YODA_DATA has not been found. \n"; |
|
|
cout << "Please check your environment variables \n"; |
|
41 |
exit(1); |
exit(1); |
42 |
} |
} |
43 |
|
|
79 |
cout << "Usage: yoda FILE [OPTION] \n"; |
cout << "Usage: yoda FILE [OPTION] \n"; |
80 |
cout << "\t --help print this help and exit \n"; |
cout << "\t --help print this help and exit \n"; |
81 |
cout << "\t -p maximum number of packets to process [default all] \n"; |
cout << "\t -p maximum number of packets to process [default all] \n"; |
82 |
cout << "\t -analize generate pre-defined analisys files (gif/text) inside the unpacking directory\n"; |
cout << "\t -m generate multiple root files. Values: {'true', 'false'} [default = 'false']\n"; |
83 |
|
cout << "\t -c set the compression level for the generated root files. Values: [0,9] [default = 3]\n"; |
84 |
exit(1); |
exit(1); |
85 |
} |
} |
86 |
|
|
98 |
cout << "Try '--help' for more information. \n"; |
cout << "Try '--help' for more information. \n"; |
99 |
exit(1); |
exit(1); |
100 |
} |
} |
101 |
if (isdigit(*argv[i])) { |
if (isdigit(*argv[i]) && (atoi(argv[i]) > 0)) { |
102 |
maxPackets = atoi(argv[i]); |
maxPackets = atoi(argv[i]); |
103 |
} else { |
} else { |
104 |
//logger->info(_T("The file does not exist.")); |
//logger->info(_T("The file does not exist.")); |
106 |
cout << "Try '--help' for more information. \n"; |
cout << "Try '--help' for more information. \n"; |
107 |
exit(1); |
exit(1); |
108 |
} |
} |
109 |
|
continue; |
110 |
} |
} |
111 |
|
|
112 |
if (!maxPackets){ |
if (!strcmp(argv[i], "-multifile")) multiFile = 1; |
|
cout << "Try '--help' for more information. \n"; |
|
|
exit(1); |
|
|
} |
|
113 |
|
|
114 |
if (!strcmp(argv[i], "-analize")) ANALIZE = true; |
if (!strcmp(argv[i], "-c")){ |
115 |
|
if (++i >= argc){ |
116 |
|
cerr << "-c needs arguments. \n"; |
117 |
|
cout << "Try '--help' for more information. \n"; |
118 |
|
exit(1); |
119 |
|
} |
120 |
|
if ((isdigit(*argv[i])) && ( (atoi(argv[i]) >= 0) && (atoi(argv[i]) <= 9))) { |
121 |
|
compression = atoi(argv[i]); |
122 |
|
} else { |
123 |
|
//logger->info(_T("The file does not exist.")); |
124 |
|
cerr << "-c needs a integer value beetween 0 and 9. \n"; |
125 |
|
cout << "Try '--help' for more information. \n"; |
126 |
|
exit(1); |
127 |
|
} |
128 |
|
continue; |
129 |
|
} |
130 |
} |
} |
|
|
|
|
|
|
|
//-------------------------------------------------- |
|
|
//This is the configuration for the Yoda Logger |
|
|
//The parameters in the RollingFileAppender means |
|
|
// default ------------>the selected category |
|
|
// YodaLog.txt ------------>the LogFile name |
|
|
// 1000 ------------>The max size (in Kb) of the LogFile |
|
|
// 5 ------------>How many times the file will be backup |
|
131 |
|
|
132 |
time_t rawtime; |
time_t rawtime; |
133 |
struct tm * timeinfo; |
struct tm * timeinfo; |
144 |
EventReader *reader = new EventReader(maxPackets); |
EventReader *reader = new EventReader(maxPackets); |
145 |
|
|
146 |
int num = 0; |
int num = 0; |
147 |
TechmodelPamelaRun Run(argv[1]); |
TechmodelPamelaRun Run(argv[1], outDir, multiFile, compression); |
148 |
reader->Init(&Run); |
reader->Init(&Run); |
149 |
|
|
150 |
oss.str(""); |
oss.str(""); |