14 |
#include <cstdlib> |
#include <cstdlib> |
15 |
#include <iostream> |
#include <iostream> |
16 |
#include <time.h> |
#include <time.h> |
17 |
|
#include "Exception.h" |
18 |
|
|
19 |
extern "C" { |
extern "C" { |
20 |
//#include "DirectoryStructure.h" |
//#include "DirectoryStructure.h" |
21 |
#include <dirent.h> |
#include <dirent.h> |
22 |
} |
} |
23 |
|
|
24 |
|
|
25 |
|
|
26 |
using namespace pamela; |
using namespace pamela; |
27 |
using namespace log4cxx; |
using namespace log4cxx; |
28 |
using namespace std; |
using namespace std; |
37 |
char nomeFileLog[L_tmpnam]; |
char nomeFileLog[L_tmpnam]; |
38 |
tmpnam(nomeFileLog); |
tmpnam(nomeFileLog); |
39 |
DIR *dirp; |
DIR *dirp; |
|
string pathDir((char*)getenv("YODA_DATA")); |
|
|
string pathLog = nomeFileLog; |
|
40 |
|
|
41 |
|
// check if yoda_DATA exist!!!! |
42 |
|
char *outDir; |
43 |
|
try { |
44 |
|
outDir = getenv("YODA_DATA"); |
45 |
|
if (getenv("YODA_DATA") == NULL) throw NotFoundEnvironmentVarException("The variable YODA_DATA has not been found."); |
46 |
|
} catch (NotFoundEnvironmentVarException exc) { |
47 |
|
cout << "The variable YODA_DATA has not been found. \n"; |
48 |
|
cout << "Please check your environment variables \n"; |
49 |
|
oss.str(""); |
50 |
|
oss << exc.print(); |
51 |
|
logger->fatal(oss.str().c_str()); |
52 |
|
exit(1); |
53 |
|
} |
54 |
|
|
55 |
|
string pathDir(outDir); |
56 |
|
|
57 |
|
string pathLog = nomeFileLog; |
58 |
//---------------- Log4cxx configuration----------------------------------------------- |
//---------------- Log4cxx configuration----------------------------------------------- |
59 |
//Define the configuration file to be used on log4cxx |
//Define the configuration file to be used on log4cxx |
60 |
PropertyConfigurator::configure(pathDir + "/log4cxx.conf"); |
PropertyConfigurator::configure(pathDir + "/log4cxx.conf"); |
81 |
if (argc < 2){ |
if (argc < 2){ |
82 |
//logger->info(_T("You have forgotten the file name.")); |
//logger->info(_T("You have forgotten the file name.")); |
83 |
cout << "You have forgotten the file name. \n"; |
cout << "You have forgotten the file name. \n"; |
84 |
cout << "Try '--help' for more information. \n"; |
cout << "Try '-help' for more information. \n"; |
85 |
exit(1); |
exit(1); |
86 |
} |
} |
87 |
|
|
88 |
if (!strcmp(argv[1], "--help")){ |
if (!strcmp(argv[1], "-help")){ |
89 |
cout << "Usage: yoda FILE [OPTION] \n"; |
cout << "Usage: yoda FILE [OPTION] \n"; |
90 |
cout << "\t --help print this help and exit \n"; |
cout << "\t -help print this help and exit \n"; |
91 |
cout << "\t -p maximum number of packets to process [default all] \n"; |
cout << "\t -p maximum number of packets to process [default all] \n"; |
92 |
exit(1); |
exit(1); |
93 |
} |
} |
94 |
|
|
95 |
|
if (!strcmp(argv[1], "-version")){ |
96 |
|
cout << GetVersionInfo() << "\n"; |
97 |
|
exit(1); |
98 |
|
} |
99 |
|
|
100 |
ifstream from (argv[1]); |
ifstream from (argv[1]); |
101 |
if (!from) { |
if (!from) { |
102 |
//logger->info(_T("The file does not exist.")); |
//logger->info(_T("The file does not exist.")); |
108 |
if (!strcmp(argv[i], "-p")){ |
if (!strcmp(argv[i], "-p")){ |
109 |
if (++i >= argc){ |
if (++i >= argc){ |
110 |
cerr << "-p needs arguments. \n"; |
cerr << "-p needs arguments. \n"; |
111 |
cout << "Try '--help' for more information. \n"; |
cout << "Try '-help' for more information. \n"; |
112 |
exit(1); |
exit(1); |
113 |
} |
} |
114 |
if (isdigit(*argv[i])) { |
if (isdigit(*argv[i])) { |
116 |
} else { |
} else { |
117 |
//logger->info(_T("The file does not exist.")); |
//logger->info(_T("The file does not exist.")); |
118 |
cerr << "-p needs a integer value. \n"; |
cerr << "-p needs a integer value. \n"; |
119 |
cout << "Try '--help' for more information. \n"; |
cout << "Try '-help' for more information. \n"; |
120 |
exit(1); |
exit(1); |
121 |
} |
} |
122 |
} |
} |
123 |
|
|
124 |
if (!maxPackets){ |
if (!maxPackets){ |
125 |
cout << "Try '--help' for more information. \n"; |
cout << "Try '-help' for more information. \n"; |
126 |
exit(1); |
exit(1); |
127 |
} |
} |
128 |
|
|
129 |
|
|
130 |
} |
} |
131 |
|
|
132 |
|
|
143 |
time ( &rawtime ); |
time ( &rawtime ); |
144 |
timeinfo = localtime ( &rawtime ); |
timeinfo = localtime ( &rawtime ); |
145 |
|
|
146 |
oss.flush(); |
oss.str(""); |
147 |
oss << "<-------------------------------START UNPACKING------------------------------->\n" |
oss << "<-------------------------------START UNPACKING------------------------------->\n" |
148 |
<< " Starting the program at: " << asctime (timeinfo) << " Opening file: " << argv[1]; |
<< " Starting the program at: " << asctime (timeinfo) << " Opening file: " << argv[1]; |
149 |
logger->info(oss.str().c_str()); |
logger->info(oss.str().c_str()); |
156 |
TechmodelPamelaRun Run(argv[1]); |
TechmodelPamelaRun Run(argv[1]); |
157 |
reader->Init(&Run); |
reader->Init(&Run); |
158 |
|
|
159 |
oss.flush(); |
oss.str(""); |
160 |
oss << "Init successul ok" << asctime (timeinfo); |
oss << "Init successul ok" << asctime (timeinfo); |
161 |
logger->debug(oss.str().c_str()); |
logger->debug(oss.str().c_str()); |
162 |
|
|
166 |
|
|
167 |
logger->info("<-------------------------------END UNPACKING------------------------------->\n"); |
logger->info("<-------------------------------END UNPACKING------------------------------->\n"); |
168 |
|
|
|
std::string command; |
|
|
command = "mv " + pathLog + " " + pathDir + "/" + Run.GetRun() + "/YodaLog.txt"; |
|
169 |
//Momentarly suspended the save |
//Momentarly suspended the save |
170 |
//system(command.c_str()); |
//system(command.c_str()); |
171 |
} |
} |
172 |
|
|
173 |
|
/** |
174 |
|
* Get a string with the version info of the algorithm. |
175 |
|
*/ |
176 |
|
const char* GetVersionInfo(void) const { |
177 |
|
return |
178 |
|
"$Trailer: /home/cvsmanager/yoda/techmodel/TestTrkReader.cpp,v 1.1.1.1 2004/07/06 12:20:23 kusanagi Exp $\n"; |
179 |
|
} |