36{
39
40 string login;
41 string locationID;
42 int elapsedTime = 0;
43
46
48
49 try {
50
52
56
57 JParser<> zap(
"Auxiliary program to merge high-voltage calibration results.");
58
59 zap[
'f'] =
make_field(inputFiles,
"input files");
63
64 zap(argc, argv);
65
66 } catch(const exception &error) {
67
68 FATAL(error.what() << endl);
69 }
70
71 if (login.empty() || locationID.empty()) {
72 FATAL(
"Missing user information (please specify via -#login and -#locationID)." << endl);
73 }
74
75
76 const JUUID& UUID = JUUID::rndm();
77
79
80 timer.
sub(elapsedTime);
81
82
83
84
88
90
91 for (vector<string>::const_iterator fileIt = inputFiles.cbegin(); fileIt != inputFiles.cend(); ++fileIt) {
92
93 NOTICE(
"Merging " << (*fileIt) << endl);
94
96
98 ifstream ifs(fileIt->c_str());
99
100 ifs >> js;
101 ifs.close();
102
103
104
105 json::const_iterator i0 = js.find(APIVersion_t);
106
107 if (i0 != js.cend()) {
108
109 istringstream iss(i0->get<string>());
110
111 iss >> DBAPIVersion;
112 }
113
115
116 json::const_iterator i1 = js.find(Data_t);
117
119 (i1 != js.cend() && i1->size() > 0) ) {
120
122
123 JHVCalibration_t::setVersion(getDBVersionTuneHV(*j));
124
126 metaInfoStr += (*i1)[0].at(Provenance_t + Info_t).at(Configuration_t).get<string>();
127
128 } else {
129
131
132 JHVCalibration_t::setVersion(getDBVersionTuneHV(*j));
133
135 }
136
137
138
139 for (JHVCalibration::const_iterator cal = HVcals.cbegin(); cal != HVcals.cend(); ++cal) {
140
141 if (find_if(merged.cbegin(), merged.cend(), make_predicate(&JHVCalibration_t::getNumber, cal->getNumber())) == merged.cend()) {
142 merged.push_back(*cal);
143 }
144 }
145
146 } else {
147
148 WARNING(*fileIt <<
" is not a JSON file; skip" << endl);
149 continue;
150 }
151 }
152
153 if (testTypes.size() > 1) {
154
155 WARNING(
"Ambiguous database test types; Assuming " << *testTypes.crbegin() << endl);
156
157 } else if (testTypes.size() == 0) {
158
159 FATAL(
"No database test type specified.");
160 }
161
162
164
166
167 json error = { {Message_t,
"" },
168 {Code_t, OK_t },
169 {Arguments_t, json::array() } };
170
171 json metaData = { {Configuration_t, metaInfoStr },
173
175 {User_t, login },
176 {Location_t, locationID },
177 {Start_t + Time_t, timer.
toString() },
178 {End_t + Time_t, timer().
toString() },
179 {Test_t + Type_t, *(testTypes.crbegin()) },
180 {Tests_t,
json(merged) } };
181
183 js[Data_t + Type_t] =
MAKE_STRING(
"ProductTestSession");
185 js[Error_t] =
json(error);
188 js[Data_t][0] =
json(data);
189
190 } else {
191
192 js[User_t] = login;
193 js[Location_t] = locationID;
194 js[Test_t + Type_t] = *(testTypes.crbegin());
195 js[Start_t + Time_t] = timer.
toString();
196 js[End_t + Time_t] = timer().
toString();
197 js[Tests_t] =
json(merged);
198 }
199
201
202 ofs << setw(2) << setprecision(8);
203 ofs << js;
204
205 ofs.close();
206
207 return 0;
208}
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
#define MAKE_STRING(A)
Make string.
#define gmake_property(A)
macros to convert (template) parameter to JPropertiesElement object
Utility class to parse parameter values.
Utility class to parse command line options.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
bool isJSONFile(const char *file_name)
Check file format.
Auxiliary data structure for general purpose version number.
version_type getMajorVersion() const
Get major version.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Auxiliary class for date and time.
std::string toString() const
Get ASCII formatted date and time.
void sub(const time_t t1)
Subtract given time.