1 |
mocchiut |
1.1 |
/** |
2 |
|
|
* \file GLTables.cpp |
3 |
|
|
* \author Elena Vannuccini |
4 |
|
|
* |
5 |
|
|
* The file contains implementation of the methods to query the DB. |
6 |
|
|
*/ |
7 |
|
|
// |
8 |
|
|
#include <sstream> |
9 |
mocchiut |
1.12 |
#include <iostream> |
10 |
mocchiut |
1.1 |
// |
11 |
|
|
#include <TFile.h> |
12 |
|
|
#include <TTree.h> |
13 |
mocchiut |
1.16 |
#include <TTimeStamp.h> |
14 |
mocchiut |
1.1 |
#include <EventHeader.h> |
15 |
|
|
#include <PscuHeader.h> |
16 |
|
|
// |
17 |
|
|
#include <GLTables.h> |
18 |
mocchiut |
1.13 |
#include <sgp4.h> |
19 |
mocchiut |
1.1 |
// |
20 |
mocchiut |
1.22 |
ClassImp(GL_TABLES); |
21 |
mocchiut |
1.1 |
ClassImp(GL_TRK_CALIB); |
22 |
|
|
ClassImp(GL_RUN); |
23 |
|
|
ClassImp(GL_ROOT); |
24 |
|
|
ClassImp(GL_PARAM); |
25 |
|
|
ClassImp(GL_S4_CALIB); |
26 |
|
|
ClassImp(GL_CALO_CALIB); |
27 |
|
|
ClassImp(GL_TIMESYNC); |
28 |
mocchiut |
1.12 |
ClassImp(GL_TLE); |
29 |
mocchiut |
1.1 |
// |
30 |
|
|
using namespace std; |
31 |
|
|
|
32 |
mocchiut |
1.22 |
GL_TABLES::GL_TABLES(){ |
33 |
|
|
}; |
34 |
|
|
|
35 |
|
|
GL_TABLES::GL_TABLES(TString host, TString user, TString psw){ |
36 |
|
|
fHost = new TString(host.Data()); |
37 |
|
|
fUser = new TString(user.Data()); |
38 |
|
|
fPsw = new TString(psw.Data()); |
39 |
|
|
fSet = true; |
40 |
|
|
fNquery = 0; |
41 |
|
|
}; |
42 |
|
|
|
43 |
|
|
|
44 |
|
|
void GL_TABLES::Set(TString host, TString user, TString psw){ |
45 |
|
|
fHost = new TString(host.Data()); |
46 |
|
|
fUser = new TString(user.Data()); |
47 |
|
|
fPsw = new TString(psw.Data()); |
48 |
|
|
fSet = true; |
49 |
|
|
fNquery = 0; |
50 |
|
|
}; |
51 |
|
|
|
52 |
|
|
Bool_t GL_TABLES::IsConnected(TSQLServer *dbc){ |
53 |
|
|
// |
54 |
|
|
// |
55 |
|
|
// |
56 |
|
|
if ( !fSet ){ |
57 |
|
|
return true; |
58 |
|
|
}; |
59 |
|
|
// |
60 |
|
|
// |
61 |
|
|
// |
62 |
|
|
// printf(" host is %s \n",fHost->Data()); |
63 |
|
|
// |
64 |
|
|
stringstream myquery; |
65 |
|
|
myquery.str(""); |
66 |
|
|
myquery << "show databases;"; |
67 |
|
|
dbc->Query(myquery.str().c_str()); |
68 |
|
|
fNquery++; |
69 |
|
|
// |
70 |
|
|
if ( dbc->GetErrorCode() != 2013 && dbc->GetErrorCode() != 2006 ){ |
71 |
|
|
// is connected |
72 |
|
|
return true; |
73 |
|
|
} else { |
74 |
|
|
// |
75 |
|
|
printf(" WARNING: Lost connection to DB! try to recover... \n"); |
76 |
|
|
// |
77 |
|
|
TString host = fHost->Data(); |
78 |
|
|
TString user = fUser->Data(); |
79 |
|
|
TString psw = fPsw->Data(); |
80 |
|
|
delete dbc; |
81 |
|
|
dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
82 |
|
|
// |
83 |
|
|
myquery.str(""); |
84 |
|
|
myquery << "show databases;"; |
85 |
|
|
dbc->Query(myquery.str().c_str()); |
86 |
|
|
fNquery++; |
87 |
|
|
// |
88 |
|
|
if ( dbc->GetErrorCode() != 2013 && dbc->GetErrorCode() != 2006 ){ |
89 |
|
|
// |
90 |
|
|
printf(" ...connection recovered, I can continue! \n"); |
91 |
|
|
// |
92 |
|
|
myquery.str(""); |
93 |
|
|
myquery << "SET time_zone='+0:00'"; |
94 |
|
|
dbc->Query(myquery.str().c_str()); |
95 |
|
|
fNquery++; |
96 |
|
|
myquery.str(""); |
97 |
|
|
myquery << "SET wait_timeout=173000;"; |
98 |
|
|
dbc->Query(myquery.str().c_str()); |
99 |
|
|
fNquery++; |
100 |
|
|
return true; |
101 |
|
|
}; |
102 |
|
|
}; |
103 |
|
|
// |
104 |
|
|
printf(" GLTABLES: connection is gone away, query will fail\n"); |
105 |
|
|
// |
106 |
|
|
return false; |
107 |
|
|
// |
108 |
|
|
}; |
109 |
|
|
|
110 |
|
|
void GL_TABLES::ResetCounters(){ |
111 |
|
|
fNquery = 0; |
112 |
|
|
}; |
113 |
|
|
|
114 |
|
|
void GL_TABLES::AddQ(){ |
115 |
|
|
if ( fSet ) fNquery++; |
116 |
|
|
}; |
117 |
|
|
|
118 |
|
|
UInt_t GL_TABLES::GetNqueries(){ |
119 |
|
|
UInt_t rn = 0; |
120 |
|
|
rn += (UInt_t&)fNquery; |
121 |
|
|
return(rn); |
122 |
|
|
}; |
123 |
|
|
|
124 |
mocchiut |
1.1 |
GL_RUN::GL_RUN() { |
125 |
|
|
ID = 0; |
126 |
|
|
ID_RUN_FRAG = 0; |
127 |
|
|
ID_ROOT_L0 = 0; |
128 |
|
|
ID_ROOT_L2 = 0; |
129 |
|
|
RUNHEADER_TIME = 0; |
130 |
|
|
RUNTRAILER_TIME = 0; |
131 |
|
|
EV_FROM = 0; |
132 |
|
|
EV_TO = 0; |
133 |
|
|
TRK_CALIB_USED = 0; |
134 |
|
|
EFF_WRK_SCHEDULE = 0; |
135 |
|
|
PRH_VAR_TRG_MODE_A = 0; |
136 |
|
|
PRH_VAR_TRG_MODE_B = 0; |
137 |
|
|
ACQ_BUILD_INFO = 0; |
138 |
|
|
ACQ_VAR_INFO = 0; |
139 |
|
|
RUNHEADER_OBT = 0; |
140 |
|
|
RUNTRAILER_OBT = 0; |
141 |
|
|
RUNHEADER_PKT = 0; |
142 |
|
|
RUNTRAILER_PKT = 0; |
143 |
|
|
NEVENTS = 0; |
144 |
|
|
LAST_TIMESYNC = 0; |
145 |
|
|
OBT_TIMESYNC = 0; |
146 |
|
|
COMPILATIONTIMESTAMP = 0; |
147 |
|
|
FAV_WRK_SCHEDULE = 0; |
148 |
|
|
RM_ACQ_AFTER_CALIB = 0; |
149 |
|
|
RM_ACQ_SETTING_MODE = 0; |
150 |
|
|
PKT_COUNTER = 0; |
151 |
|
|
PKT_READY_COUNTER = 0; |
152 |
|
|
TRK_CALIB_USED = 0; |
153 |
|
|
CAL_DSP_MASK = 0; |
154 |
|
|
BOOT_NUMBER = 0; |
155 |
|
|
VALIDATION = 0; |
156 |
|
|
} |
157 |
|
|
|
158 |
pam-fi |
1.9 |
|
159 |
mocchiut |
1.1 |
void GL_RUN::Clear() { |
160 |
|
|
ID = 0; |
161 |
|
|
ID_RUN_FRAG = 0; |
162 |
|
|
ID_ROOT_L0 = 0; |
163 |
|
|
ID_ROOT_L2 = 0; |
164 |
|
|
RUNHEADER_TIME = 0; |
165 |
|
|
RUNTRAILER_TIME = 0; |
166 |
|
|
EV_FROM = 0; |
167 |
|
|
EV_TO = 0; |
168 |
|
|
TRK_CALIB_USED = 0; |
169 |
|
|
EFF_WRK_SCHEDULE = 0; |
170 |
|
|
PRH_VAR_TRG_MODE_A = 0; |
171 |
|
|
PRH_VAR_TRG_MODE_B = 0; |
172 |
|
|
ACQ_BUILD_INFO = 0; |
173 |
|
|
ACQ_VAR_INFO = 0; |
174 |
|
|
RUNHEADER_OBT = 0; |
175 |
|
|
RUNTRAILER_OBT = 0; |
176 |
|
|
RUNHEADER_PKT = 0; |
177 |
|
|
RUNTRAILER_PKT = 0; |
178 |
|
|
NEVENTS = 0; |
179 |
|
|
LAST_TIMESYNC = 0; |
180 |
|
|
OBT_TIMESYNC = 0; |
181 |
|
|
COMPILATIONTIMESTAMP = 0; |
182 |
|
|
FAV_WRK_SCHEDULE = 0; |
183 |
|
|
RM_ACQ_AFTER_CALIB = 0; |
184 |
|
|
RM_ACQ_SETTING_MODE = 0; |
185 |
|
|
PKT_COUNTER = 0; |
186 |
|
|
PKT_READY_COUNTER = 0; |
187 |
|
|
TRK_CALIB_USED = 0; |
188 |
|
|
CAL_DSP_MASK = 0; |
189 |
|
|
BOOT_NUMBER = 0; |
190 |
|
|
VALIDATION = 0; |
191 |
|
|
} |
192 |
|
|
|
193 |
|
|
GL_ROOT::GL_ROOT(){ |
194 |
|
|
ID = 0; |
195 |
|
|
ID_RAW = 0; |
196 |
|
|
ID_TIMESYNC = 0; |
197 |
|
|
PATH = ""; |
198 |
|
|
NAME = ""; |
199 |
|
|
} |
200 |
|
|
|
201 |
|
|
GL_PARAM::GL_PARAM(){ |
202 |
|
|
ID = 0; |
203 |
|
|
PATH = ""; |
204 |
|
|
NAME = ""; |
205 |
|
|
DESCR = ""; |
206 |
|
|
FROM_TIME = 0; |
207 |
|
|
TO_TIME = 0; |
208 |
|
|
TYPE = 0; |
209 |
|
|
} |
210 |
|
|
|
211 |
|
|
|
212 |
|
|
GL_TRK_CALIB::GL_TRK_CALIB(){ |
213 |
|
|
ID = 0; |
214 |
|
|
ID_ROOT_L0 = 0; |
215 |
|
|
EV_ROOT_CALIBTRK1 = 0; |
216 |
|
|
EV_ROOT_CALIBTRK2 = 0; |
217 |
|
|
FROM_TIME = 0; |
218 |
|
|
TO_TIME = 0; |
219 |
|
|
OBT1 = 0; |
220 |
|
|
OBT2 = 0; |
221 |
|
|
PKT1 = 0; |
222 |
|
|
PKT2 = 0; |
223 |
pam-fi |
1.9 |
BOOT_NUMBER = 0; |
224 |
|
|
VALIDATION = 0; |
225 |
mocchiut |
1.1 |
} |
226 |
|
|
|
227 |
|
|
GL_CALO_CALIB::GL_CALO_CALIB(){ |
228 |
|
|
ID = 0; |
229 |
|
|
ID_ROOT_L0 = 0; |
230 |
|
|
EV_ROOT = 0; |
231 |
|
|
FROM_TIME = 0; |
232 |
|
|
TO_TIME = 0; |
233 |
|
|
SECTION = 0; |
234 |
|
|
} |
235 |
|
|
|
236 |
|
|
GL_S4_CALIB::GL_S4_CALIB(){ |
237 |
|
|
ID = 0; |
238 |
|
|
ID_ROOT_L0 = 0; |
239 |
|
|
EV_ROOT = 0; |
240 |
|
|
FROM_TIME = 0; |
241 |
|
|
TO_TIME = 0; |
242 |
|
|
PARAM_FIT0 = 0.; |
243 |
|
|
PARAM_FIT1 = 0.; |
244 |
|
|
} |
245 |
|
|
|
246 |
|
|
GL_TIMESYNC::GL_TIMESYNC(){ |
247 |
|
|
obtfirst = 0; |
248 |
|
|
pktfirst = 0; |
249 |
|
|
toffset = 0; |
250 |
mocchiut |
1.17 |
// ID = 0; |
251 |
|
|
// ID_RAW = 0; |
252 |
mocchiut |
1.1 |
OBT0 = 0; |
253 |
|
|
TIMESYNC = 0; |
254 |
|
|
TYPE = 0; |
255 |
mocchiut |
1.12 |
} |
256 |
|
|
|
257 |
|
|
// **************************************************** |
258 |
mocchiut |
1.1 |
|
259 |
|
|
void GL_RUN::SetEV_FROM(UInt_t evfrom){ |
260 |
|
|
EV_FROM = evfrom; |
261 |
|
|
}; |
262 |
|
|
|
263 |
|
|
void GL_RUN::SetEV_TO(UInt_t evto){ |
264 |
|
|
EV_TO = evto; |
265 |
|
|
}; |
266 |
|
|
|
267 |
|
|
void GL_RUN::SetNEVENTS(UInt_t nev){ |
268 |
|
|
NEVENTS = nev; |
269 |
|
|
}; |
270 |
|
|
|
271 |
|
|
void GL_RUN::SetBOOTNUMBER(UInt_t boot){ |
272 |
|
|
BOOT_NUMBER = boot; |
273 |
|
|
}; |
274 |
|
|
|
275 |
|
|
void GL_RUN::SetRUNHEADER_TIME(UInt_t absth){ |
276 |
|
|
RUNHEADER_TIME = absth; |
277 |
|
|
}; |
278 |
|
|
|
279 |
|
|
void GL_RUN::SetRUNTRAILER_TIME(UInt_t abstt){ |
280 |
|
|
RUNTRAILER_TIME = abstt; |
281 |
|
|
}; |
282 |
|
|
|
283 |
|
|
void GL_RUN::SetRUNHEADER_PKT(UInt_t absth){ |
284 |
|
|
RUNHEADER_PKT = absth; |
285 |
|
|
}; |
286 |
|
|
|
287 |
|
|
void GL_RUN::SetRUNTRAILER_PKT(UInt_t abstt){ |
288 |
|
|
RUNTRAILER_PKT = abstt; |
289 |
|
|
}; |
290 |
|
|
|
291 |
|
|
void GL_RUN::SetRUNHEADER_OBT(UInt_t absth){ |
292 |
|
|
RUNHEADER_OBT = absth; |
293 |
|
|
}; |
294 |
|
|
|
295 |
|
|
void GL_RUN::SetRUNTRAILER_OBT(UInt_t abstt){ |
296 |
|
|
RUNTRAILER_OBT = abstt; |
297 |
|
|
}; |
298 |
|
|
|
299 |
|
|
void GL_RUN::SetID_ROOT_L2(UInt_t idl2){ |
300 |
|
|
ID_ROOT_L2 = idl2; |
301 |
|
|
}; |
302 |
|
|
|
303 |
|
|
void GL_RUN::SetID_ROOT_L0(UInt_t idroot){ |
304 |
|
|
ID_ROOT_L0 = idroot; |
305 |
|
|
}; |
306 |
|
|
|
307 |
|
|
void GL_RUN::SetID_RUN_FRAG(UInt_t idfrag){ |
308 |
|
|
ID_RUN_FRAG = idfrag; |
309 |
|
|
}; |
310 |
|
|
|
311 |
|
|
void GL_RUN::SetVALIDATION(UInt_t valid){ |
312 |
|
|
VALIDATION = valid; |
313 |
|
|
}; |
314 |
|
|
|
315 |
|
|
void GL_RUN::SetLAST_TIMESYNC(UInt_t ts){ |
316 |
|
|
LAST_TIMESYNC = ts; |
317 |
|
|
}; |
318 |
|
|
|
319 |
|
|
void GL_RUN::SetOBT_TIMESYNC(UInt_t ts){ |
320 |
|
|
OBT_TIMESYNC = ts; |
321 |
|
|
}; |
322 |
|
|
|
323 |
|
|
void GL_RUN:: SetPKT_COUNTER(UInt_t value){ |
324 |
|
|
PKT_COUNTER = value; |
325 |
|
|
}; |
326 |
|
|
|
327 |
|
|
void GL_RUN:: SetPKT_READY_COUNTER(UInt_t value){ |
328 |
|
|
PKT_READY_COUNTER = value; |
329 |
|
|
}; |
330 |
|
|
|
331 |
|
|
void GL_RUN:: SetCOMPILATIONTIMESTAMP(UInt_t value){ |
332 |
|
|
COMPILATIONTIMESTAMP = value; |
333 |
|
|
}; |
334 |
|
|
|
335 |
|
|
void GL_RUN:: SetFAV_WRK_SCHEDULE(UInt_t value){ |
336 |
|
|
FAV_WRK_SCHEDULE = value; |
337 |
|
|
}; |
338 |
|
|
|
339 |
|
|
void GL_RUN:: SetEFF_WRK_SCHEDULE(UInt_t value){ |
340 |
|
|
EFF_WRK_SCHEDULE = value; |
341 |
|
|
}; |
342 |
|
|
|
343 |
|
|
void GL_RUN:: SetPRH_VAR_TRG_MODE_A(UInt_t value){ |
344 |
|
|
PRH_VAR_TRG_MODE_A = value; |
345 |
|
|
}; |
346 |
|
|
|
347 |
|
|
void GL_RUN:: SetPRH_VAR_TRG_MODE_B(UInt_t value){ |
348 |
|
|
PRH_VAR_TRG_MODE_B = value; |
349 |
|
|
}; |
350 |
|
|
|
351 |
|
|
void GL_RUN:: SetACQ_BUILD_INFO(UInt_t value){ |
352 |
|
|
ACQ_BUILD_INFO = value; |
353 |
|
|
}; |
354 |
|
|
|
355 |
|
|
void GL_RUN:: SetACQ_VAR_INFO(UInt_t value){ |
356 |
|
|
ACQ_VAR_INFO = value; |
357 |
|
|
}; |
358 |
|
|
|
359 |
|
|
void GL_RUN:: SetRM_ACQ_AFTER_CALIB(UInt_t value){ |
360 |
|
|
RM_ACQ_AFTER_CALIB = value; |
361 |
|
|
}; |
362 |
|
|
|
363 |
|
|
void GL_RUN:: SetRM_ACQ_SETTING_MODE(UInt_t value){ |
364 |
|
|
RM_ACQ_SETTING_MODE = value; |
365 |
|
|
}; |
366 |
|
|
|
367 |
|
|
void GL_RUN:: SetTRK_CALIB_USED(UInt_t value){ |
368 |
|
|
TRK_CALIB_USED = value; |
369 |
|
|
}; |
370 |
|
|
|
371 |
|
|
void GL_RUN:: SetCAL_DSP_MASK(UInt_t value){ |
372 |
|
|
CAL_DSP_MASK = value; |
373 |
|
|
}; |
374 |
|
|
|
375 |
|
|
void GL_RUN:: SetID(UInt_t value){ |
376 |
|
|
ID = value; |
377 |
|
|
}; |
378 |
|
|
|
379 |
|
|
void GL_RUN::Set_GL_RUNT(RunTrailerEvent *runt, PscuHeader *pht){ |
380 |
|
|
PKT_COUNTER = runt->PKT_COUNTER; |
381 |
|
|
PKT_READY_COUNTER = runt->PKT_ReadyCounter; |
382 |
|
|
RUNTRAILER_OBT = pht->GetOrbitalTime(); |
383 |
|
|
RUNTRAILER_PKT = pht->GetCounter(); |
384 |
|
|
}; |
385 |
|
|
|
386 |
|
|
void GL_RUN::Set_GL_RUNH(RunHeaderEvent *runh, PscuHeader *phh){ |
387 |
|
|
TRK_CALIB_USED = runh->TRK_CALIB_USED; |
388 |
|
|
PRH_VAR_TRG_MODE_A = runh->PRH_VAR_TRIGGER_MODE_A; |
389 |
|
|
PRH_VAR_TRG_MODE_B = runh->PRH_VAR_TRIGGER_MODE_B; |
390 |
|
|
ACQ_BUILD_INFO = runh->ACQ_BUILD_INFO; |
391 |
|
|
ACQ_VAR_INFO = runh->ACQ_VAR_INFO; |
392 |
|
|
RUNHEADER_OBT = phh->GetOrbitalTime(); |
393 |
|
|
RUNHEADER_PKT = phh->GetCounter(); |
394 |
|
|
LAST_TIMESYNC = runh->LAST_TIME_SYNC_INFO; |
395 |
|
|
OBT_TIMESYNC = runh->OBT_TIME_SYNC; |
396 |
|
|
COMPILATIONTIMESTAMP = runh->COMPILATIONTIMESTAMP; |
397 |
|
|
FAV_WRK_SCHEDULE = runh->FAVOURITE_WORKING_SCHEDULE; |
398 |
|
|
EFF_WRK_SCHEDULE = runh->EFFECTIVE_WORKING_SCHEDULE; |
399 |
|
|
RM_ACQ_AFTER_CALIB = runh->RM_ACQ_AFTER_CALIB; |
400 |
|
|
RM_ACQ_SETTING_MODE = runh->RM_ACQ_SETTING_MODE; |
401 |
|
|
TRK_CALIB_USED = runh->TRK_CALIB_USED; |
402 |
|
|
CAL_DSP_MASK = runh->CAL_DSP_MASK; |
403 |
|
|
}; |
404 |
|
|
|
405 |
|
|
void GL_RUN::Set_GL_RUNT0(){ |
406 |
|
|
PKT_COUNTER = 0; |
407 |
|
|
PKT_READY_COUNTER = 0; |
408 |
|
|
RUNTRAILER_OBT = 0; |
409 |
|
|
RUNTRAILER_PKT = 0; |
410 |
|
|
}; |
411 |
|
|
|
412 |
|
|
void GL_RUN::Set_GL_RUNH0(){ |
413 |
|
|
TRK_CALIB_USED = 0; |
414 |
|
|
PRH_VAR_TRG_MODE_A = 0; |
415 |
|
|
PRH_VAR_TRG_MODE_B = 0; |
416 |
|
|
ACQ_BUILD_INFO = 0; |
417 |
|
|
ACQ_VAR_INFO = 0; |
418 |
|
|
RUNHEADER_OBT = 0; |
419 |
|
|
RUNHEADER_PKT = 0; |
420 |
|
|
LAST_TIMESYNC = 0; |
421 |
|
|
OBT_TIMESYNC = 0; |
422 |
|
|
COMPILATIONTIMESTAMP = 0; |
423 |
|
|
FAV_WRK_SCHEDULE = 0; |
424 |
|
|
EFF_WRK_SCHEDULE = 0; |
425 |
|
|
RM_ACQ_AFTER_CALIB = 0; |
426 |
|
|
RM_ACQ_SETTING_MODE = 0; |
427 |
|
|
TRK_CALIB_USED = 0; |
428 |
|
|
CAL_DSP_MASK = 0; |
429 |
|
|
}; |
430 |
|
|
|
431 |
pam-fi |
1.9 |
void GL_RUN::Set_GL_RUN(TSQLRow *Row){ |
432 |
|
|
for( Int_t t = 0; t < 30; t++){ |
433 |
|
|
if (t== 0) ID = (UInt_t)atoll(Row->GetField(t)); |
434 |
|
|
if (t== 1) ID_RUN_FRAG = (UInt_t)atoll(Row->GetField(t)); |
435 |
|
|
if (t== 2) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
436 |
|
|
if (t== 3) ID_ROOT_L2 = (UInt_t)atoll(Row->GetField(t)); |
437 |
|
|
if (t== 4) RUNHEADER_TIME = (UInt_t)atoll(Row->GetField(t)); |
438 |
|
|
if (t== 5) RUNTRAILER_TIME = (UInt_t)atoll(Row->GetField(t)); |
439 |
|
|
if (t== 6) RUNHEADER_OBT = (UInt_t)atoll(Row->GetField(t)); |
440 |
|
|
if (t== 7) RUNTRAILER_OBT = (UInt_t)atoll(Row->GetField(t)); |
441 |
|
|
if (t== 8) RUNHEADER_PKT = (UInt_t)atoll(Row->GetField(t)); |
442 |
|
|
if (t== 9) RUNTRAILER_PKT = (UInt_t)atoll(Row->GetField(t)); |
443 |
|
|
if (t==10) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t)); |
444 |
|
|
if (t==11) EV_FROM = (UInt_t)atoll(Row->GetField(t)); |
445 |
|
|
if (t==12) EV_TO = (UInt_t)atoll(Row->GetField(t)); |
446 |
|
|
if (t==13) NEVENTS = (UInt_t)atoll(Row->GetField(t)); |
447 |
|
|
if (t==14) PKT_COUNTER = (UInt_t)atoll(Row->GetField(t)); |
448 |
|
|
if (t==15) PKT_READY_COUNTER = (UInt_t)atoll(Row->GetField(t)); |
449 |
|
|
if (t==16) COMPILATIONTIMESTAMP = (UInt_t)atoll(Row->GetField(t)); |
450 |
|
|
if (t==17) FAV_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); |
451 |
|
|
if (t==18) EFF_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); |
452 |
|
|
if (t==19) PRH_VAR_TRG_MODE_A= (UInt_t)atoll(Row->GetField(t)); |
453 |
|
|
if (t==20) PRH_VAR_TRG_MODE_B= (UInt_t)atoll(Row->GetField(t)); |
454 |
|
|
if (t==21) ACQ_BUILD_INFO = (UInt_t)atoll(Row->GetField(t)); |
455 |
|
|
if (t==22) ACQ_VAR_INFO = (UInt_t)atoll(Row->GetField(t)); |
456 |
|
|
if (t==23) RM_ACQ_AFTER_CALIB= (UInt_t)atoll(Row->GetField(t)); |
457 |
|
|
if (t==24) RM_ACQ_SETTING_MODE = (UInt_t)atoll(Row->GetField(t)); |
458 |
|
|
if (t==25) TRK_CALIB_USED = (UInt_t)atoll(Row->GetField(t)); |
459 |
|
|
if (t==26) CAL_DSP_MASK = (UInt_t)atoll(Row->GetField(t)); |
460 |
|
|
if (t==27) LAST_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
461 |
|
|
if (t==28) OBT_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
462 |
|
|
if (t==29) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
463 |
|
|
}; |
464 |
|
|
|
465 |
|
|
} |
466 |
|
|
|
467 |
mocchiut |
1.14 |
/** |
468 |
mocchiut |
1.15 |
* This method delete the run from the "FromTable" table and store it in the GL_RUN_TRASH table |
469 |
|
|
* If IDRUN is 0 "this->ID" run is used. |
470 |
mocchiut |
1.14 |
* |
471 |
|
|
**/ |
472 |
|
|
Int_t GL_RUN::DeleteRun(TSQLServer *dbc,UInt_t IDRUN,TString FromTable){ |
473 |
|
|
// MySQL variables |
474 |
|
|
TSQLResult *pResult; |
475 |
|
|
TSQLRow *Row; |
476 |
|
|
stringstream myquery; |
477 |
|
|
// |
478 |
|
|
if ( !IDRUN ) IDRUN = ID; |
479 |
|
|
if ( !IDRUN ) return 1; |
480 |
|
|
// ---------------- |
481 |
|
|
myquery.str(""); |
482 |
|
|
myquery << " INSERT INTO GL_RUN_TRASH ("; |
483 |
|
|
myquery << "ID"; |
484 |
|
|
myquery << ",ID_RUN_FRAG"; |
485 |
|
|
myquery << ",ID_ROOT_L0"; |
486 |
|
|
myquery << ",ID_ROOT_L2"; |
487 |
|
|
myquery << ",RUNHEADER_TIME"; |
488 |
|
|
myquery << ",RUNTRAILER_TIME"; |
489 |
|
|
myquery << ",RUNHEADER_OBT"; |
490 |
|
|
myquery << ",RUNTRAILER_OBT"; |
491 |
|
|
myquery << ",RUNHEADER_PKT"; |
492 |
|
|
myquery << ",RUNTRAILER_PKT"; |
493 |
|
|
myquery << ",BOOT_NUMBER"; |
494 |
|
|
myquery << ",EV_FROM"; |
495 |
|
|
myquery << ",EV_TO"; |
496 |
|
|
myquery << ",NEVENTS"; |
497 |
|
|
myquery << ",PKT_COUNTER"; |
498 |
|
|
myquery << ",PKT_READY_COUNTER"; |
499 |
|
|
myquery << ",COMPILATIONTIMESTAMP"; |
500 |
|
|
myquery << ",FAV_WRK_SCHEDULE"; |
501 |
|
|
myquery << ",EFF_WRK_SCHEDULE"; |
502 |
|
|
myquery << ",PRH_VAR_TRG_MODE_A"; |
503 |
|
|
myquery << ",PRH_VAR_TRG_MODE_B"; |
504 |
|
|
myquery << ",ACQ_BUILD_INFO"; |
505 |
|
|
myquery << ",ACQ_VAR_INFO"; |
506 |
|
|
myquery << ",RM_ACQ_AFTER_CALIB"; |
507 |
|
|
myquery << ",RM_ACQ_SETTING_MODE"; |
508 |
|
|
myquery << ",TRK_CALIB_USED"; |
509 |
|
|
myquery << ",CAL_DSP_MASK"; |
510 |
|
|
myquery << ",LAST_TIMESYNC"; |
511 |
|
|
myquery << ",OBT_TIMESYNC"; |
512 |
|
|
myquery << ",VALIDATION"; |
513 |
|
|
myquery << ",INSERT_TIME"; |
514 |
|
|
myquery << ") SELECT * FROM "; |
515 |
|
|
myquery << FromTable.Data(); |
516 |
|
|
myquery << " WHERE ID="; |
517 |
|
|
myquery << (UInt_t)IDRUN << ";"; |
518 |
|
|
// |
519 |
|
|
// printf("1myquery is %s \n",myquery.str().c_str()); |
520 |
|
|
// |
521 |
mocchiut |
1.22 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
522 |
|
|
this->GetGLTABLES()->AddQ(); |
523 |
mocchiut |
1.14 |
dbc->Query(myquery.str().c_str()); |
524 |
|
|
// |
525 |
mocchiut |
1.15 |
// retrieve this ID_TRASH |
526 |
|
|
// |
527 |
|
|
myquery.str(""); |
528 |
|
|
myquery << " SELECT ID_TRASH,ID_ROOT_L0,ID_ROOT_L2 FROM GL_RUN_TRASH ORDER BY ID_TRASH DESC LIMIT 1"; |
529 |
mocchiut |
1.22 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
530 |
|
|
this->GetGLTABLES()->AddQ(); |
531 |
mocchiut |
1.15 |
pResult = dbc->Query(myquery.str().c_str()); |
532 |
|
|
// |
533 |
|
|
UInt_t idtrash = 0; |
534 |
|
|
UInt_t idl0 = 0; |
535 |
|
|
UInt_t idl2 = 0; |
536 |
|
|
// |
537 |
|
|
Row = pResult->Next(); |
538 |
|
|
if( Row != NULL ){ |
539 |
|
|
idtrash = (UInt_t)atoll(Row->GetField(0)); |
540 |
|
|
idl0 = (UInt_t)atoll(Row->GetField(1)); |
541 |
|
|
idl2 = (UInt_t)atoll(Row->GetField(2)); |
542 |
|
|
}; |
543 |
|
|
// |
544 |
mocchiut |
1.14 |
TString fileL0 = ""; |
545 |
|
|
TString fileL2 = ""; |
546 |
|
|
myquery.str(""); |
547 |
|
|
myquery << " SELECT NAME FROM GL_ROOT WHERE ID="; |
548 |
mocchiut |
1.15 |
myquery << idl0 << ";"; |
549 |
mocchiut |
1.14 |
// |
550 |
|
|
// printf("2myquery is %s \n",myquery.str().c_str()); |
551 |
|
|
// |
552 |
mocchiut |
1.22 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
553 |
|
|
this->GetGLTABLES()->AddQ(); |
554 |
mocchiut |
1.14 |
pResult = dbc->Query(myquery.str().c_str()); |
555 |
|
|
// |
556 |
|
|
Row = pResult->Next(); |
557 |
|
|
if( Row != NULL ){ |
558 |
|
|
fileL0 = (TString)Row->GetField(0); |
559 |
|
|
}; |
560 |
|
|
// |
561 |
|
|
// |
562 |
|
|
// |
563 |
|
|
myquery.str(""); |
564 |
|
|
myquery << " SELECT NAME FROM GL_ROOT WHERE ID="; |
565 |
mocchiut |
1.15 |
myquery << idl2 << ";"; |
566 |
mocchiut |
1.14 |
// |
567 |
|
|
// printf("3myquery is %s \n",myquery.str().c_str()); |
568 |
|
|
// |
569 |
mocchiut |
1.22 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
570 |
|
|
this->GetGLTABLES()->AddQ(); |
571 |
mocchiut |
1.14 |
pResult = dbc->Query(myquery.str().c_str()); |
572 |
|
|
// |
573 |
|
|
Row = pResult->Next(); |
574 |
|
|
if( Row != NULL ){ |
575 |
|
|
fileL2 = (TString)Row->GetField(0); |
576 |
|
|
}; |
577 |
|
|
// |
578 |
|
|
// |
579 |
|
|
// |
580 |
|
|
myquery.str(""); |
581 |
|
|
myquery << " UPDATE GL_RUN_TRASH SET FILENAMEL0='"; |
582 |
mocchiut |
1.15 |
myquery << fileL0.Data() << "' where ID_TRASH="; |
583 |
|
|
myquery << idtrash << ";"; |
584 |
mocchiut |
1.14 |
// |
585 |
|
|
// printf("4myquery is %s \n",myquery.str().c_str()); |
586 |
|
|
// |
587 |
mocchiut |
1.22 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
588 |
|
|
this->GetGLTABLES()->AddQ(); |
589 |
mocchiut |
1.14 |
dbc->Query(myquery.str().c_str()); |
590 |
|
|
// |
591 |
|
|
myquery.str(""); |
592 |
|
|
myquery << " UPDATE GL_RUN_TRASH SET FILENAMEL2='"; |
593 |
mocchiut |
1.15 |
myquery << fileL2.Data() << "' where ID_TRASH="; |
594 |
|
|
myquery << idtrash << ";"; |
595 |
mocchiut |
1.14 |
// |
596 |
|
|
// printf("4myquery is %s \n",myquery.str().c_str()); |
597 |
|
|
// |
598 |
mocchiut |
1.22 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
599 |
|
|
this->GetGLTABLES()->AddQ(); |
600 |
mocchiut |
1.14 |
dbc->Query(myquery.str().c_str()); |
601 |
|
|
// |
602 |
|
|
myquery.str(""); |
603 |
|
|
myquery << " UPDATE GL_RUN_TRASH SET BELONGED_TO='"; |
604 |
mocchiut |
1.15 |
myquery << FromTable.Data() << "' where ID_TRASH="; |
605 |
|
|
myquery << idtrash << ";"; |
606 |
mocchiut |
1.14 |
// |
607 |
|
|
// printf("4myquery is %s \n",myquery.str().c_str()); |
608 |
|
|
// |
609 |
|
|
// |
610 |
mocchiut |
1.22 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
611 |
|
|
this->GetGLTABLES()->AddQ(); |
612 |
mocchiut |
1.14 |
dbc->Query(myquery.str().c_str()); |
613 |
|
|
// |
614 |
|
|
myquery.str(""); |
615 |
|
|
myquery << " DELETE FROM "; |
616 |
|
|
myquery << FromTable.Data() << " where ID="; |
617 |
|
|
myquery << IDRUN << ";"; |
618 |
|
|
// |
619 |
|
|
// printf("5myquery is %s \n",myquery.str().c_str()); |
620 |
|
|
// |
621 |
|
|
// |
622 |
mocchiut |
1.22 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
623 |
|
|
this->GetGLTABLES()->AddQ(); |
624 |
mocchiut |
1.14 |
dbc->Query(myquery.str().c_str()); |
625 |
|
|
// |
626 |
|
|
return 0; |
627 |
|
|
}; |
628 |
|
|
|
629 |
|
|
|
630 |
|
|
|
631 |
|
|
/** |
632 |
mocchiut |
1.15 |
* This method restore a run from the GL_RUN_TRASH table. |
633 |
|
|
* If ID is 0 "this->ID" is used; if "ToTable" is empty BELONG_TO field of GL_RUN_TRASH is used. |
634 |
mocchiut |
1.14 |
* |
635 |
|
|
**/ |
636 |
mocchiut |
1.15 |
Int_t GL_RUN::RestoreRun(TSQLServer *dbc,UInt_t IDRUN,TString ToTable){ |
637 |
mocchiut |
1.14 |
// insert into GL_RUN_FRAGMENTS select * FROM GL_RUN where ID=11; |
638 |
|
|
//insert into GL_RUN_TRASH VALUES (ID , ID_RUN_FRAG , ID_ROOT_L0 , ID_ROOT_L2 , RUNHEADER_TIME , RUNTRAILER_TIME , RUNHEADER_OBT , RUNTRAILER_OBT , RUNHEADER_PKT , RUNTRAILER_PKT , BOOT_NUMBER , EV_FROM , EV_TO , NEVENTS , PKT_COUNTER , PKT_READY_COUNTER , COMPILATIONTIMESTAMP , FAV_WRK_SCHEDULE , EFF_WRK_SCHEDULE , PRH_VAR_TRG_MODE_A , PRH_VAR_TRG_MODE_B , ACQ_BUILD_INFO , ACQ_VAR_INFO , RM_ACQ_AFTER_CALIB , RM_ACQ_SETTING_MODE, TRK_CALIB_USED,CAL_DSP_MASK, LAST_TIMESYNC, OBT_TIMESYNC, VALIDATION, INSERT_TIME) select * FROM GL_RUN where ID=11; |
639 |
mocchiut |
1.15 |
// MySQL variables |
640 |
|
|
TSQLResult *pResult; |
641 |
|
|
TSQLRow *Row; |
642 |
|
|
stringstream myquery; |
643 |
|
|
// |
644 |
|
|
if ( !IDRUN ) IDRUN = ID; |
645 |
|
|
if ( !IDRUN ) return 1; |
646 |
|
|
// |
647 |
|
|
if ( !strcmp(ToTable.Data(),"") ){ |
648 |
|
|
// |
649 |
|
|
myquery.str(""); |
650 |
|
|
myquery << " SELECT BELONGED_TO FROM GL_RUN_TRASH WHERE ID="; |
651 |
|
|
myquery << (UInt_t)IDRUN << ";"; |
652 |
|
|
// |
653 |
|
|
printf(" qui? myquery is %s \n",myquery.str().c_str()); |
654 |
|
|
// |
655 |
mocchiut |
1.22 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
656 |
|
|
this->GetGLTABLES()->AddQ(); |
657 |
mocchiut |
1.15 |
pResult = dbc->Query(myquery.str().c_str()); |
658 |
|
|
// |
659 |
|
|
Row = pResult->Next(); |
660 |
|
|
if( Row != NULL ){ |
661 |
|
|
ToTable = (TString)Row->GetField(0); |
662 |
|
|
} else { |
663 |
|
|
return 1; |
664 |
|
|
}; |
665 |
|
|
}; |
666 |
|
|
// ---------------- |
667 |
|
|
myquery.str(""); |
668 |
|
|
myquery << " INSERT INTO "; |
669 |
|
|
myquery << ToTable.Data(); |
670 |
|
|
myquery << " ("; |
671 |
|
|
myquery << "ID"; |
672 |
|
|
myquery << ",ID_RUN_FRAG"; |
673 |
|
|
myquery << ",ID_ROOT_L0"; |
674 |
|
|
myquery << ",ID_ROOT_L2"; |
675 |
|
|
myquery << ",RUNHEADER_TIME"; |
676 |
|
|
myquery << ",RUNTRAILER_TIME"; |
677 |
|
|
myquery << ",RUNHEADER_OBT"; |
678 |
|
|
myquery << ",RUNTRAILER_OBT"; |
679 |
|
|
myquery << ",RUNHEADER_PKT"; |
680 |
|
|
myquery << ",RUNTRAILER_PKT"; |
681 |
|
|
myquery << ",BOOT_NUMBER"; |
682 |
|
|
myquery << ",EV_FROM"; |
683 |
|
|
myquery << ",EV_TO"; |
684 |
|
|
myquery << ",NEVENTS"; |
685 |
|
|
myquery << ",PKT_COUNTER"; |
686 |
|
|
myquery << ",PKT_READY_COUNTER"; |
687 |
|
|
myquery << ",COMPILATIONTIMESTAMP"; |
688 |
|
|
myquery << ",FAV_WRK_SCHEDULE"; |
689 |
|
|
myquery << ",EFF_WRK_SCHEDULE"; |
690 |
|
|
myquery << ",PRH_VAR_TRG_MODE_A"; |
691 |
|
|
myquery << ",PRH_VAR_TRG_MODE_B"; |
692 |
|
|
myquery << ",ACQ_BUILD_INFO"; |
693 |
|
|
myquery << ",ACQ_VAR_INFO"; |
694 |
|
|
myquery << ",RM_ACQ_AFTER_CALIB"; |
695 |
|
|
myquery << ",RM_ACQ_SETTING_MODE"; |
696 |
|
|
myquery << ",TRK_CALIB_USED"; |
697 |
|
|
myquery << ",CAL_DSP_MASK"; |
698 |
|
|
myquery << ",LAST_TIMESYNC"; |
699 |
|
|
myquery << ",OBT_TIMESYNC"; |
700 |
|
|
myquery << ",VALIDATION"; |
701 |
|
|
myquery << ",INSERT_TIME"; |
702 |
|
|
myquery << ") SELECT "; |
703 |
|
|
myquery << "ID"; |
704 |
|
|
myquery << ",ID_RUN_FRAG"; |
705 |
|
|
myquery << ",ID_ROOT_L0"; |
706 |
|
|
myquery << ",ID_ROOT_L2"; |
707 |
|
|
myquery << ",RUNHEADER_TIME"; |
708 |
|
|
myquery << ",RUNTRAILER_TIME"; |
709 |
|
|
myquery << ",RUNHEADER_OBT"; |
710 |
|
|
myquery << ",RUNTRAILER_OBT"; |
711 |
|
|
myquery << ",RUNHEADER_PKT"; |
712 |
|
|
myquery << ",RUNTRAILER_PKT"; |
713 |
|
|
myquery << ",BOOT_NUMBER"; |
714 |
|
|
myquery << ",EV_FROM"; |
715 |
|
|
myquery << ",EV_TO"; |
716 |
|
|
myquery << ",NEVENTS"; |
717 |
|
|
myquery << ",PKT_COUNTER"; |
718 |
|
|
myquery << ",PKT_READY_COUNTER"; |
719 |
|
|
myquery << ",COMPILATIONTIMESTAMP"; |
720 |
|
|
myquery << ",FAV_WRK_SCHEDULE"; |
721 |
|
|
myquery << ",EFF_WRK_SCHEDULE"; |
722 |
|
|
myquery << ",PRH_VAR_TRG_MODE_A"; |
723 |
|
|
myquery << ",PRH_VAR_TRG_MODE_B"; |
724 |
|
|
myquery << ",ACQ_BUILD_INFO"; |
725 |
|
|
myquery << ",ACQ_VAR_INFO"; |
726 |
|
|
myquery << ",RM_ACQ_AFTER_CALIB"; |
727 |
|
|
myquery << ",RM_ACQ_SETTING_MODE"; |
728 |
|
|
myquery << ",TRK_CALIB_USED"; |
729 |
|
|
myquery << ",CAL_DSP_MASK"; |
730 |
|
|
myquery << ",LAST_TIMESYNC"; |
731 |
|
|
myquery << ",OBT_TIMESYNC"; |
732 |
|
|
myquery << ",VALIDATION"; |
733 |
|
|
myquery << ",INSERT_TIME"; |
734 |
|
|
myquery << " FROM GL_RUN_TRASH "; |
735 |
|
|
myquery << " WHERE BELONGED_TO='GL_RUN_FRAGMENTS' AND ID="; |
736 |
|
|
myquery << (UInt_t)IDRUN << ";"; |
737 |
|
|
// |
738 |
|
|
// printf("5myquery is %s \n",myquery.str().c_str()); |
739 |
|
|
// |
740 |
mocchiut |
1.22 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
741 |
|
|
this->GetGLTABLES()->AddQ(); |
742 |
mocchiut |
1.15 |
dbc->Query(myquery.str().c_str()); |
743 |
|
|
// |
744 |
|
|
// |
745 |
|
|
myquery.str(""); |
746 |
|
|
myquery << " DELETE FROM GL_RUN_TRASH where BELONGED_TO='GL_RUN_FRAGMENTS' AND ID="; |
747 |
|
|
myquery << IDRUN << ";"; |
748 |
|
|
// |
749 |
mocchiut |
1.22 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
750 |
|
|
this->GetGLTABLES()->AddQ(); |
751 |
mocchiut |
1.15 |
dbc->Query(myquery.str().c_str()); |
752 |
|
|
// |
753 |
mocchiut |
1.14 |
return 0; |
754 |
|
|
}; |
755 |
mocchiut |
1.1 |
|
756 |
|
|
/** |
757 |
|
|
* Function to fill the GL_RUN table of the DB. |
758 |
|
|
* |
759 |
|
|
* \param |
760 |
|
|
* |
761 |
|
|
*/ |
762 |
|
|
Int_t GL_RUN::Fill_GL_RUN(TSQLServer *dbc){ |
763 |
|
|
// MySQL variables |
764 |
|
|
stringstream myquery; |
765 |
|
|
// ---------------- |
766 |
|
|
myquery.str(""); |
767 |
|
|
myquery << " INSERT INTO GL_RUN ("; |
768 |
|
|
myquery << "ID"; |
769 |
|
|
myquery << ",ID_RUN_FRAG"; |
770 |
|
|
myquery << ",ID_ROOT_L0"; |
771 |
|
|
myquery << ",ID_ROOT_L2"; |
772 |
|
|
myquery << ",RUNHEADER_TIME"; |
773 |
|
|
myquery << ",RUNTRAILER_TIME"; |
774 |
|
|
myquery << ",RUNHEADER_OBT"; |
775 |
|
|
myquery << ",RUNTRAILER_OBT"; |
776 |
|
|
myquery << ",RUNHEADER_PKT"; |
777 |
|
|
myquery << ",RUNTRAILER_PKT"; |
778 |
|
|
myquery << ",EV_FROM"; |
779 |
|
|
myquery << ",EV_TO"; |
780 |
|
|
myquery << ",NEVENTS"; |
781 |
|
|
myquery << ",LAST_TIMESYNC"; |
782 |
|
|
myquery << ",OBT_TIMESYNC"; |
783 |
|
|
myquery << ",COMPILATIONTIMESTAMP"; |
784 |
|
|
myquery << ",FAV_WRK_SCHEDULE"; |
785 |
|
|
myquery << ",EFF_WRK_SCHEDULE"; |
786 |
|
|
myquery << ",PRH_VAR_TRG_MODE_A"; |
787 |
|
|
myquery << ",PRH_VAR_TRG_MODE_B"; |
788 |
|
|
myquery << ",ACQ_BUILD_INFO"; |
789 |
|
|
myquery << ",ACQ_VAR_INFO"; |
790 |
|
|
myquery << ",RM_ACQ_AFTER_CALIB"; |
791 |
|
|
myquery << ",RM_ACQ_SETTING_MODE"; |
792 |
|
|
myquery << ",PKT_COUNTER"; |
793 |
|
|
myquery << ",PKT_READY_COUNTER"; |
794 |
|
|
myquery << ",TRK_CALIB_USED"; |
795 |
|
|
myquery << ",CAL_DSP_MASK"; |
796 |
|
|
myquery << ",BOOT_NUMBER"; |
797 |
|
|
myquery << ",VALIDATION"; |
798 |
|
|
myquery << ") VALUES ('"; |
799 |
|
|
|
800 |
|
|
myquery << (UInt_t)ID << "','"; |
801 |
|
|
myquery << (UInt_t)ID_RUN_FRAG << "','"; |
802 |
|
|
myquery << (UInt_t)ID_ROOT_L0 << "','"; |
803 |
|
|
myquery << (UInt_t)ID_ROOT_L2 << "','"; |
804 |
|
|
myquery << (UInt_t)RUNHEADER_TIME << "','"; |
805 |
|
|
myquery << (UInt_t)RUNTRAILER_TIME << "','"; |
806 |
|
|
myquery << (UInt_t)RUNHEADER_OBT << "','"; |
807 |
|
|
myquery << (UInt_t)RUNTRAILER_OBT << "','"; |
808 |
|
|
myquery << (UInt_t)RUNHEADER_PKT << "','"; |
809 |
|
|
myquery << (UInt_t)RUNTRAILER_PKT << "','"; |
810 |
|
|
myquery << (UInt_t)EV_FROM << "','"; |
811 |
|
|
myquery << (UInt_t)EV_TO << "','"; |
812 |
|
|
myquery << (UInt_t)NEVENTS << "','"; |
813 |
|
|
myquery << (UInt_t)LAST_TIMESYNC << "','"; |
814 |
|
|
myquery << (UInt_t)OBT_TIMESYNC << "','"; |
815 |
|
|
myquery << (UInt_t)COMPILATIONTIMESTAMP << "','"; |
816 |
|
|
myquery << (UInt_t)FAV_WRK_SCHEDULE << "','"; |
817 |
|
|
myquery << (UInt_t)EFF_WRK_SCHEDULE << "','"; |
818 |
|
|
myquery << (UInt_t)PRH_VAR_TRG_MODE_A << "','"; |
819 |
|
|
myquery << (UInt_t)PRH_VAR_TRG_MODE_B << "','"; |
820 |
|
|
myquery << (UInt_t)ACQ_BUILD_INFO << "','"; |
821 |
|
|
myquery << (UInt_t)ACQ_VAR_INFO << "','"; |
822 |
|
|
myquery << (UInt_t)RM_ACQ_AFTER_CALIB << "','"; |
823 |
|
|
myquery << (UInt_t)RM_ACQ_SETTING_MODE << "','"; |
824 |
|
|
myquery << (UInt_t)PKT_COUNTER << "','"; |
825 |
|
|
myquery << (UInt_t)PKT_READY_COUNTER << "','"; |
826 |
|
|
myquery << (UInt_t)TRK_CALIB_USED << "','"; |
827 |
|
|
myquery << (UInt_t)CAL_DSP_MASK << "','"; |
828 |
|
|
myquery << (UInt_t)BOOT_NUMBER << "','"; |
829 |
|
|
myquery << (UInt_t)VALIDATION << "');"; |
830 |
|
|
// |
831 |
mocchiut |
1.2 |
// printf("myquery is %s \n",myquery.str().c_str()); |
832 |
mocchiut |
1.1 |
// |
833 |
mocchiut |
1.22 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
834 |
|
|
this->GetGLTABLES()->AddQ(); |
835 |
mocchiut |
1.1 |
dbc->Query(myquery.str().c_str()); |
836 |
|
|
// |
837 |
|
|
return 0; |
838 |
|
|
|
839 |
|
|
};// **************************************************** |
840 |
|
|
|
841 |
|
|
/** |
842 |
|
|
* Function to fill the GL_RUN table of the DB. |
843 |
|
|
* |
844 |
|
|
* \param |
845 |
|
|
* |
846 |
|
|
*/ |
847 |
|
|
Int_t GL_RUN::Fill_GL_RUN_FRAGMENTS(TSQLServer *dbc){ |
848 |
|
|
// MySQL variables |
849 |
|
|
stringstream myquery; |
850 |
|
|
// ---------------- |
851 |
|
|
myquery.str(""); |
852 |
|
|
myquery << " INSERT INTO GL_RUN_FRAGMENTS ("; |
853 |
|
|
myquery << "ID"; |
854 |
|
|
myquery << ",ID_ROOT_L0"; |
855 |
|
|
myquery << ",RUNHEADER_TIME"; |
856 |
|
|
myquery << ",RUNTRAILER_TIME"; |
857 |
|
|
myquery << ",RUNHEADER_OBT"; |
858 |
|
|
myquery << ",RUNTRAILER_OBT"; |
859 |
|
|
myquery << ",RUNHEADER_PKT"; |
860 |
|
|
myquery << ",RUNTRAILER_PKT"; |
861 |
|
|
myquery << ",EV_FROM"; |
862 |
|
|
myquery << ",EV_TO"; |
863 |
|
|
myquery << ",NEVENTS"; |
864 |
|
|
myquery << ",LAST_TIMESYNC"; |
865 |
|
|
myquery << ",OBT_TIMESYNC"; |
866 |
|
|
myquery << ",COMPILATIONTIMESTAMP"; |
867 |
|
|
myquery << ",FAV_WRK_SCHEDULE"; |
868 |
|
|
myquery << ",EFF_WRK_SCHEDULE"; |
869 |
|
|
myquery << ",PRH_VAR_TRG_MODE_A"; |
870 |
|
|
myquery << ",PRH_VAR_TRG_MODE_B"; |
871 |
|
|
myquery << ",ACQ_BUILD_INFO"; |
872 |
|
|
myquery << ",ACQ_VAR_INFO"; |
873 |
|
|
myquery << ",RM_ACQ_AFTER_CALIB"; |
874 |
|
|
myquery << ",RM_ACQ_SETTING_MODE"; |
875 |
|
|
myquery << ",PKT_COUNTER"; |
876 |
|
|
myquery << ",PKT_READY_COUNTER"; |
877 |
|
|
myquery << ",TRK_CALIB_USED"; |
878 |
|
|
myquery << ",CAL_DSP_MASK"; |
879 |
|
|
myquery << ",BOOT_NUMBER"; |
880 |
|
|
myquery << ") VALUES ('"; |
881 |
|
|
myquery << (UInt_t)ID << "','"; |
882 |
|
|
myquery << (UInt_t)ID_ROOT_L0 << "','"; |
883 |
|
|
myquery << (UInt_t)RUNHEADER_TIME << "','"; |
884 |
|
|
myquery << (UInt_t)RUNTRAILER_TIME << "','"; |
885 |
|
|
myquery << (UInt_t)RUNHEADER_OBT << "','"; |
886 |
|
|
myquery << (UInt_t)RUNTRAILER_OBT << "','"; |
887 |
|
|
myquery << (UInt_t)RUNHEADER_PKT << "','"; |
888 |
|
|
myquery << (UInt_t)RUNTRAILER_PKT << "','"; |
889 |
|
|
myquery << (UInt_t)EV_FROM << "','"; |
890 |
|
|
myquery << (UInt_t)EV_TO << "','"; |
891 |
|
|
myquery << (UInt_t)NEVENTS << "','"; |
892 |
|
|
myquery << (UInt_t)LAST_TIMESYNC << "','"; |
893 |
|
|
myquery << (UInt_t)OBT_TIMESYNC << "','"; |
894 |
|
|
myquery << (UInt_t)COMPILATIONTIMESTAMP << "','"; |
895 |
|
|
myquery << (UInt_t)FAV_WRK_SCHEDULE << "','"; |
896 |
|
|
myquery << (UInt_t)EFF_WRK_SCHEDULE << "','"; |
897 |
|
|
myquery << (UInt_t)PRH_VAR_TRG_MODE_A << "','"; |
898 |
|
|
myquery << (UInt_t)PRH_VAR_TRG_MODE_B << "','"; |
899 |
|
|
myquery << (UInt_t)ACQ_BUILD_INFO << "','"; |
900 |
|
|
myquery << (UInt_t)ACQ_VAR_INFO << "','"; |
901 |
|
|
myquery << (UInt_t)RM_ACQ_AFTER_CALIB << "','"; |
902 |
|
|
myquery << (UInt_t)RM_ACQ_SETTING_MODE << "','"; |
903 |
|
|
myquery << (UInt_t)PKT_COUNTER << "','"; |
904 |
|
|
myquery << (UInt_t)PKT_READY_COUNTER << "','"; |
905 |
|
|
myquery << (UInt_t)TRK_CALIB_USED << "','"; |
906 |
|
|
myquery << (UInt_t)CAL_DSP_MASK << "','"; |
907 |
|
|
myquery << (UInt_t)BOOT_NUMBER << "');"; |
908 |
|
|
// |
909 |
|
|
// printf("myquery is %s \n",myquery.str().c_str()); |
910 |
|
|
// |
911 |
mocchiut |
1.22 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
912 |
|
|
this->GetGLTABLES()->AddQ(); |
913 |
mocchiut |
1.1 |
dbc->Query(myquery.str().c_str()); |
914 |
|
|
// |
915 |
|
|
return 0; |
916 |
|
|
|
917 |
|
|
};// **************************************************** |
918 |
|
|
|
919 |
|
|
|
920 |
|
|
/** |
921 |
|
|
* Function to query the GL_RUN table of the DB. |
922 |
|
|
* |
923 |
|
|
* \param RUN id |
924 |
|
|
* \return struct of type GL_RUN _data, which stores the query result |
925 |
|
|
* |
926 |
|
|
*/ |
927 |
|
|
Int_t GL_RUN::Query_GL_RUN(UInt_t run, TSQLServer *dbc){ |
928 |
|
|
// MySQL variables |
929 |
|
|
TSQLResult *pResult; |
930 |
|
|
TSQLRow *Row; |
931 |
|
|
int t; |
932 |
|
|
int r; |
933 |
|
|
stringstream myquery; |
934 |
|
|
// ---------------- |
935 |
|
|
myquery.str(""); |
936 |
|
|
myquery << " select "; |
937 |
|
|
myquery << "ID"; |
938 |
|
|
myquery << ",ID_RUN_FRAG"; |
939 |
|
|
myquery << ",ID_ROOT_L0"; |
940 |
|
|
myquery << ",ID_ROOT_L2"; |
941 |
|
|
myquery << ",RUNHEADER_TIME"; |
942 |
|
|
myquery << ",RUNTRAILER_TIME"; |
943 |
|
|
myquery << ",RUNHEADER_OBT"; |
944 |
|
|
myquery << ",RUNTRAILER_OBT"; |
945 |
|
|
myquery << ",RUNHEADER_PKT"; |
946 |
|
|
myquery << ",RUNTRAILER_PKT"; |
947 |
|
|
myquery << ",EV_FROM"; |
948 |
|
|
myquery << ",EV_TO"; |
949 |
|
|
myquery << ",NEVENTS"; |
950 |
|
|
myquery << ",LAST_TIMESYNC"; |
951 |
|
|
myquery << ",OBT_TIMESYNC"; |
952 |
|
|
myquery << ",COMPILATIONTIMESTAMP"; |
953 |
|
|
myquery << ",FAV_WRK_SCHEDULE"; |
954 |
|
|
myquery << ",EFF_WRK_SCHEDULE"; |
955 |
|
|
myquery << ",PRH_VAR_TRG_MODE_A"; |
956 |
|
|
myquery << ",PRH_VAR_TRG_MODE_B"; |
957 |
|
|
myquery << ",ACQ_BUILD_INFO"; |
958 |
|
|
myquery << ",ACQ_VAR_INFO"; |
959 |
|
|
myquery << ",RM_ACQ_AFTER_CALIB"; |
960 |
|
|
myquery << ",RM_ACQ_SETTING_MODE"; |
961 |
|
|
myquery << ",PKT_COUNTER"; |
962 |
|
|
myquery << ",PKT_READY_COUNTER"; |
963 |
|
|
myquery << ",TRK_CALIB_USED"; |
964 |
|
|
myquery << ",CAL_DSP_MASK"; |
965 |
|
|
myquery << ",BOOT_NUMBER"; |
966 |
|
|
myquery << ",VALIDATION"; |
967 |
|
|
myquery << " from GL_RUN where ID=" << run << ";"; |
968 |
|
|
// |
969 |
mocchiut |
1.4 |
// printf(" myquery is %s \n",myquery.str().c_str()); |
970 |
mocchiut |
1.22 |
if ( !this->IsConnected(dbc) ) return -57; |
971 |
|
|
this->AddQ(); |
972 |
mocchiut |
1.1 |
pResult = dbc->Query(myquery.str().c_str()); |
973 |
mocchiut |
1.4 |
// |
974 |
|
|
// printf(" getrowcount %i \n",pResult->GetRowCount()); |
975 |
|
|
// |
976 |
|
|
if( !pResult->GetRowCount() ) return(-50); |
977 |
|
|
// |
978 |
mocchiut |
1.1 |
for( r=0; r < 1000; r++){ |
979 |
|
|
Row = pResult->Next(); |
980 |
|
|
if( Row == NULL ) break; |
981 |
pam-fi |
1.9 |
// Set_GL_RUN(Row); |
982 |
mocchiut |
1.1 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
983 |
mocchiut |
1.16 |
if (t== 0) ID = (UInt_t)atoll(Row->GetField(t)); |
984 |
|
|
if (t== 1) ID_RUN_FRAG = (UInt_t)atoll(Row->GetField(t)); |
985 |
|
|
if (t== 2) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
986 |
|
|
if (t== 3) ID_ROOT_L2 = (UInt_t)atoll(Row->GetField(t)); |
987 |
|
|
if (t== 4) RUNHEADER_TIME = (UInt_t)atoll(Row->GetField(t)); |
988 |
|
|
if (t== 5) RUNTRAILER_TIME = (UInt_t)atoll(Row->GetField(t)); |
989 |
|
|
if (t== 6) RUNHEADER_OBT = (UInt_t)atoll(Row->GetField(t)); |
990 |
|
|
if (t== 7) RUNTRAILER_OBT = (UInt_t)atoll(Row->GetField(t)); |
991 |
|
|
if (t== 8) RUNHEADER_PKT = (UInt_t)atoll(Row->GetField(t)); |
992 |
|
|
if (t== 9) RUNTRAILER_PKT = (UInt_t)atoll(Row->GetField(t)); |
993 |
|
|
if (t==10) EV_FROM = (UInt_t)atoll(Row->GetField(t)); |
994 |
|
|
if (t==11) EV_TO = (UInt_t)atoll(Row->GetField(t)); |
995 |
|
|
if (t==12) NEVENTS = (UInt_t)atoll(Row->GetField(t)); |
996 |
|
|
if (t==13) LAST_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
997 |
|
|
if (t==14) OBT_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
998 |
|
|
if (t==15) COMPILATIONTIMESTAMP = (UInt_t)atoll(Row->GetField(t)); |
999 |
|
|
if (t==16) FAV_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); |
1000 |
|
|
if (t==17) EFF_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); |
1001 |
|
|
if (t==18) PRH_VAR_TRG_MODE_A= (UInt_t)atoll(Row->GetField(t)); |
1002 |
|
|
if (t==19) PRH_VAR_TRG_MODE_B= (UInt_t)atoll(Row->GetField(t)); |
1003 |
|
|
if (t==20) ACQ_BUILD_INFO = (UInt_t)atoll(Row->GetField(t)); |
1004 |
|
|
if (t==21) ACQ_VAR_INFO = (UInt_t)atoll(Row->GetField(t)); |
1005 |
|
|
if (t==22) RM_ACQ_AFTER_CALIB= (UInt_t)atoll(Row->GetField(t)); |
1006 |
|
|
if (t==23) RM_ACQ_SETTING_MODE = (UInt_t)atoll(Row->GetField(t)); |
1007 |
|
|
if (t==24) PKT_COUNTER = (UInt_t)atoll(Row->GetField(t)); |
1008 |
|
|
if (t==25) PKT_READY_COUNTER = (UInt_t)atoll(Row->GetField(t)); |
1009 |
|
|
if (t==26) TRK_CALIB_USED = (UInt_t)atoll(Row->GetField(t)); |
1010 |
|
|
if (t==27) CAL_DSP_MASK = (UInt_t)atoll(Row->GetField(t)); |
1011 |
|
|
if (t==28) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t)); |
1012 |
|
|
if (t==29) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
1013 |
mocchiut |
1.1 |
}; |
1014 |
|
|
}; |
1015 |
mocchiut |
1.4 |
// delete pResult; |
1016 |
|
|
return(0); |
1017 |
mocchiut |
1.1 |
}; |
1018 |
|
|
|
1019 |
|
|
/** |
1020 |
|
|
* Function to query the GL_RUN table of the DB. |
1021 |
|
|
* |
1022 |
|
|
* \param where = condition string |
1023 |
|
|
* \return struct of type GL_RUN _data, which stores the query result |
1024 |
|
|
* |
1025 |
|
|
*/ |
1026 |
|
|
Int_t GL_RUN::Query_GL_RUN_FRAGMENTS(TString where, TSQLServer *dbc){ |
1027 |
|
|
// MySQL variables |
1028 |
|
|
TSQLResult *pResult; |
1029 |
|
|
TSQLRow *Row; |
1030 |
|
|
int t; |
1031 |
|
|
int r; |
1032 |
|
|
stringstream myquery; |
1033 |
|
|
// ---------------- |
1034 |
|
|
myquery.str(""); |
1035 |
|
|
myquery << " select "; |
1036 |
|
|
myquery << "ID"; |
1037 |
mocchiut |
1.2 |
myquery << ",ID_RUN_FRAG"; |
1038 |
mocchiut |
1.1 |
myquery << ",ID_ROOT_L0"; |
1039 |
mocchiut |
1.2 |
myquery << ",ID_ROOT_L2"; |
1040 |
mocchiut |
1.1 |
myquery << ",RUNHEADER_TIME"; |
1041 |
|
|
myquery << ",RUNTRAILER_TIME"; |
1042 |
|
|
myquery << ",RUNHEADER_OBT"; |
1043 |
|
|
myquery << ",RUNTRAILER_OBT"; |
1044 |
|
|
myquery << ",RUNHEADER_PKT"; |
1045 |
|
|
myquery << ",RUNTRAILER_PKT"; |
1046 |
|
|
myquery << ",EV_FROM"; |
1047 |
|
|
myquery << ",EV_TO"; |
1048 |
|
|
myquery << ",NEVENTS"; |
1049 |
|
|
myquery << ",LAST_TIMESYNC"; |
1050 |
|
|
myquery << ",OBT_TIMESYNC"; |
1051 |
|
|
myquery << ",COMPILATIONTIMESTAMP"; |
1052 |
|
|
myquery << ",FAV_WRK_SCHEDULE"; |
1053 |
|
|
myquery << ",EFF_WRK_SCHEDULE"; |
1054 |
|
|
myquery << ",PRH_VAR_TRG_MODE_A"; |
1055 |
|
|
myquery << ",PRH_VAR_TRG_MODE_B"; |
1056 |
|
|
myquery << ",ACQ_BUILD_INFO"; |
1057 |
|
|
myquery << ",ACQ_VAR_INFO"; |
1058 |
|
|
myquery << ",RM_ACQ_AFTER_CALIB"; |
1059 |
|
|
myquery << ",RM_ACQ_SETTING_MODE"; |
1060 |
|
|
myquery << ",PKT_COUNTER"; |
1061 |
|
|
myquery << ",PKT_READY_COUNTER"; |
1062 |
|
|
myquery << ",TRK_CALIB_USED"; |
1063 |
|
|
myquery << ",CAL_DSP_MASK"; |
1064 |
|
|
myquery << ",BOOT_NUMBER"; |
1065 |
mocchiut |
1.2 |
myquery << ",VALIDATION"; |
1066 |
mocchiut |
1.1 |
myquery << " from GL_RUN_FRAGMENTS where " << where.Data() << ";"; |
1067 |
|
|
// |
1068 |
mocchiut |
1.2 |
// printf(" query is %s \n",myquery.str().c_str()); |
1069 |
|
|
// |
1070 |
mocchiut |
1.22 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
1071 |
|
|
this->GetGLTABLES()->AddQ(); |
1072 |
mocchiut |
1.1 |
pResult = dbc->Query(myquery.str().c_str()); |
1073 |
|
|
if(!pResult->GetRowCount())return(-50); |
1074 |
|
|
for( r=0; r < 1000; r++){ |
1075 |
mocchiut |
1.2 |
Row = pResult->Next(); |
1076 |
|
|
if( Row == NULL ) break; |
1077 |
|
|
for( t = 0; t < pResult->GetFieldCount(); t++){ |
1078 |
|
|
if (t== 0) ID = (UInt_t)atoll(Row->GetField(t)); |
1079 |
|
|
if (t== 1) ID_RUN_FRAG = (UInt_t)atoll(Row->GetField(t)); |
1080 |
|
|
if (t== 2) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
1081 |
|
|
if (t== 3) ID_ROOT_L2 = (UInt_t)atoll(Row->GetField(t)); |
1082 |
|
|
if (t== 4) RUNHEADER_TIME = (UInt_t)atoll(Row->GetField(t)); |
1083 |
|
|
if (t== 5) RUNTRAILER_TIME = (UInt_t)atoll(Row->GetField(t)); |
1084 |
|
|
if (t== 6) RUNHEADER_OBT = (UInt_t)atoll(Row->GetField(t)); |
1085 |
|
|
if (t== 7) RUNTRAILER_OBT = (UInt_t)atoll(Row->GetField(t)); |
1086 |
|
|
if (t== 8) RUNHEADER_PKT = (UInt_t)atoll(Row->GetField(t)); |
1087 |
|
|
if (t== 9) RUNTRAILER_PKT = (UInt_t)atoll(Row->GetField(t)); |
1088 |
|
|
if (t==10) EV_FROM = (UInt_t)atoll(Row->GetField(t)); |
1089 |
|
|
if (t==11) EV_TO = (UInt_t)atoll(Row->GetField(t)); |
1090 |
|
|
if (t==12) NEVENTS = (UInt_t)atoll(Row->GetField(t)); |
1091 |
|
|
if (t==13) LAST_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
1092 |
|
|
if (t==14) OBT_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
1093 |
|
|
if (t==15) COMPILATIONTIMESTAMP = (UInt_t)atoll(Row->GetField(t)); |
1094 |
|
|
if (t==16) FAV_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); |
1095 |
|
|
if (t==17) EFF_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); |
1096 |
|
|
if (t==18) PRH_VAR_TRG_MODE_A= (UInt_t)atoll(Row->GetField(t)); |
1097 |
|
|
if (t==19) PRH_VAR_TRG_MODE_B= (UInt_t)atoll(Row->GetField(t)); |
1098 |
|
|
if (t==20) ACQ_BUILD_INFO = (UInt_t)atoll(Row->GetField(t)); |
1099 |
|
|
if (t==21) ACQ_VAR_INFO = (UInt_t)atoll(Row->GetField(t)); |
1100 |
|
|
if (t==22) RM_ACQ_AFTER_CALIB= (UInt_t)atoll(Row->GetField(t)); |
1101 |
|
|
if (t==23) RM_ACQ_SETTING_MODE = (UInt_t)atoll(Row->GetField(t)); |
1102 |
|
|
if (t==24) PKT_COUNTER = (UInt_t)atoll(Row->GetField(t)); |
1103 |
|
|
if (t==25) PKT_READY_COUNTER = (UInt_t)atoll(Row->GetField(t)); |
1104 |
|
|
if (t==26) TRK_CALIB_USED = (UInt_t)atoll(Row->GetField(t)); |
1105 |
|
|
if (t==27) CAL_DSP_MASK = (UInt_t)atoll(Row->GetField(t)); |
1106 |
|
|
if (t==28) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t)); |
1107 |
|
|
if (t==29) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
1108 |
|
|
}; |
1109 |
mocchiut |
1.1 |
}; |
1110 |
mocchiut |
1.2 |
// delete pResult; |
1111 |
|
|
return(0); |
1112 |
|
|
};// **************************************************** |
1113 |
mocchiut |
1.1 |
|
1114 |
|
|
/** |
1115 |
|
|
* Function to query the GL_ROOT table of the DB. |
1116 |
|
|
* |
1117 |
|
|
* \param entry ID |
1118 |
|
|
* \return struct of type GL_ROOT_data, which stores the query result |
1119 |
|
|
*/ |
1120 |
|
|
Int_t GL_ROOT::Query_GL_ROOT(UInt_t id, TSQLServer *dbc){ |
1121 |
|
|
// MySQL variables |
1122 |
|
|
TSQLResult *pResult; |
1123 |
|
|
TSQLRow *Row; |
1124 |
|
|
int t; |
1125 |
|
|
int r; |
1126 |
|
|
stringstream myquery; |
1127 |
|
|
// ---------------- |
1128 |
|
|
myquery.str(""); |
1129 |
|
|
myquery << "select "; |
1130 |
|
|
myquery << " ID"; |
1131 |
|
|
myquery << ",ID_RAW"; |
1132 |
|
|
myquery << ",ID_TIMESYNC"; |
1133 |
|
|
myquery << ",PATH"; |
1134 |
|
|
myquery << ",NAME"; |
1135 |
|
|
myquery << " from GL_ROOT where ID=" << id << ";"; |
1136 |
|
|
// |
1137 |
mocchiut |
1.22 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
1138 |
|
|
this->GetGLTABLES()->AddQ(); |
1139 |
mocchiut |
1.1 |
pResult = dbc->Query(myquery.str().c_str()); |
1140 |
|
|
if(!pResult->GetRowCount())return (-51); |
1141 |
|
|
for( r=0; r < 1000; r++){ |
1142 |
|
|
Row = pResult->Next(); |
1143 |
|
|
if( Row == NULL ) break; |
1144 |
|
|
for( t = 0; t < pResult->GetFieldCount(); t++){ |
1145 |
|
|
if(t==0) ID = (UInt_t)atoll(Row->GetField(t)); |
1146 |
|
|
if(t==1) ID_RAW = (UInt_t)atoll(Row->GetField(t)); |
1147 |
|
|
if(t==2) ID_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
1148 |
mocchiut |
1.26 |
if(t==3) PATH = (TString)gSystem->ExpandPathName(Row->GetField(t))+'/'; |
1149 |
mocchiut |
1.1 |
if(t==4) NAME = Row->GetField(t); |
1150 |
|
|
}; |
1151 |
|
|
}; |
1152 |
|
|
delete pResult; |
1153 |
|
|
return 0; |
1154 |
|
|
}; |
1155 |
|
|
// **************************************************** |
1156 |
|
|
/** |
1157 |
|
|
* Function to query the GL_TRK_CALIB table of the DB. |
1158 |
|
|
* |
1159 |
|
|
* \param run starting time |
1160 |
pam-fi |
1.9 |
* \param dbc DB server |
1161 |
mocchiut |
1.1 |
* \return struct of type GL_TRK_CALIB_data, which stores the query result |
1162 |
|
|
*/ |
1163 |
|
|
Int_t GL_TRK_CALIB::Query_GL_TRK_CALIB(UInt_t time, TSQLServer *dbc){ |
1164 |
|
|
// MySQL variables |
1165 |
|
|
TSQLResult *pResult; |
1166 |
|
|
TSQLRow *Row; |
1167 |
|
|
int t; |
1168 |
|
|
int r; |
1169 |
|
|
stringstream myquery; |
1170 |
|
|
// ---------------- |
1171 |
|
|
myquery.str(""); |
1172 |
pam-fi |
1.9 |
myquery << "select ID,ID_ROOT_L0,EV_ROOT_CALIBTRK1,EV_ROOT_CALIBTRK2,FROM_TIME,TO_TIME,OBT1,OBT2,PKT1,PKT2,BOOT_NUMBER,VALIDATION from GL_TRK_CALIB where FROM_TIME <= "<< time; |
1173 |
pam-fi |
1.24 |
// myquery << " AND VALIDATION=1 ORDER BY FROM_TIME DESC LIMIT 1;"; // RIVEDERE LA VALIDAZIONE!!! |
1174 |
mocchiut |
1.28 |
myquery << " and EV_ROOT_CALIBTRK1>=0 and and EV_ROOT_CALIBTRK2>=0"; // EM! SE MANCA UN PACCHETTO DEI DUE IL PROCESSAMENTO CRASHA... DA RIVEDERE LA VALIDAZIONE |
1175 |
pam-fi |
1.24 |
myquery << " ORDER BY FROM_TIME DESC LIMIT 1;"; |
1176 |
mocchiut |
1.1 |
// myquery << " ORDER BY FROM_TIME DESC LIMIT 1;"; |
1177 |
mocchiut |
1.22 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
1178 |
|
|
this->GetGLTABLES()->AddQ(); |
1179 |
mocchiut |
1.1 |
pResult = dbc->Query(myquery.str().c_str()); |
1180 |
|
|
if(!pResult->GetRowCount())return (-53); |
1181 |
|
|
for( r=0; r < 1000; r++){ |
1182 |
|
|
Row = pResult->Next(); |
1183 |
|
|
if( Row == NULL ) break; |
1184 |
|
|
for( t = 0; t < pResult->GetFieldCount(); t++){ |
1185 |
mocchiut |
1.2 |
stringstream row; |
1186 |
|
|
row.str(""); |
1187 |
|
|
row << "0" << Row->GetField(t); // add leading 0 since we have two fields that could be "null" and we want to avoid crashes due to atoll |
1188 |
pam-fi |
1.9 |
if (t==0) ID = (UInt_t)atoll(Row->GetField(t)); |
1189 |
|
|
if (t==1) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
1190 |
mocchiut |
1.2 |
if (t==2) EV_ROOT_CALIBTRK1 = (UInt_t)atoll(row.str().c_str()); |
1191 |
|
|
if (t==3) EV_ROOT_CALIBTRK2 = (UInt_t)atoll(row.str().c_str()); |
1192 |
pam-fi |
1.9 |
if (t==4) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); |
1193 |
|
|
if (t==5) TO_TIME = (UInt_t)atoll(Row->GetField(t)); |
1194 |
mocchiut |
1.1 |
// |
1195 |
pam-fi |
1.9 |
if (t==6) OBT1 = (UInt_t)atoll(Row->GetField(t)); |
1196 |
|
|
if (t==7) OBT2 = (UInt_t)atoll(Row->GetField(t)); |
1197 |
|
|
if (t==8) PKT1 = (UInt_t)atoll(Row->GetField(t)); |
1198 |
|
|
if (t==9) PKT2 = (UInt_t)atoll(Row->GetField(t)); |
1199 |
|
|
if (t==10) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t)); |
1200 |
|
|
if (t==11) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
1201 |
|
|
}; |
1202 |
mocchiut |
1.1 |
}; |
1203 |
pam-fi |
1.9 |
delete pResult; |
1204 |
mocchiut |
1.1 |
// |
1205 |
pam-fi |
1.9 |
// if ( TO_TIME < time ) return(51); |
1206 |
mocchiut |
1.8 |
// |
1207 |
mocchiut |
1.1 |
if ( (!OBT1 && !PKT1 ) || (!OBT2 && !PKT2) ) return(52); // ONE CALIBRATION PACKET IS MISSING! |
1208 |
|
|
// |
1209 |
|
|
return 0; |
1210 |
|
|
}; |
1211 |
|
|
|
1212 |
|
|
// **************************************************** |
1213 |
|
|
/** |
1214 |
|
|
* Function to query the GL_CALO_CALIB table of the DB. |
1215 |
|
|
* |
1216 |
|
|
* \param run starting time |
1217 |
|
|
* \return struct of type GL_CALO_CALIB_data, which stores the query result |
1218 |
|
|
*/ |
1219 |
mocchiut |
1.7 |
Int_t GL_CALO_CALIB::Query_GL_CALO_CALIB(UInt_t time, UInt_t &uptime, UInt_t section, TSQLServer *dbc){ |
1220 |
mocchiut |
1.1 |
// MySQL variables |
1221 |
|
|
TSQLResult *pResult; |
1222 |
|
|
TSQLRow *Row; |
1223 |
|
|
int t; |
1224 |
|
|
stringstream myquery; |
1225 |
mocchiut |
1.7 |
uptime = 0; |
1226 |
mocchiut |
1.1 |
// |
1227 |
|
|
// select the correct calibration |
1228 |
|
|
// |
1229 |
|
|
myquery.str(""); |
1230 |
|
|
myquery << "select ID_ROOT_L0, FROM_TIME, TO_TIME, EV_ROOT,VALIDATION from GL_CALO_CALIB where SECTION=" << section; |
1231 |
|
|
myquery << " and FROM_TIME <= " << time; |
1232 |
|
|
myquery << " and TO_TIME > " << time; |
1233 |
mocchiut |
1.7 |
myquery << " ;"; |
1234 |
|
|
//myquery << " and VALIDATION=1;"; |
1235 |
mocchiut |
1.1 |
// |
1236 |
mocchiut |
1.22 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
1237 |
|
|
this->GetGLTABLES()->AddQ(); |
1238 |
mocchiut |
1.1 |
pResult = dbc->Query(myquery.str().c_str()); |
1239 |
mocchiut |
1.7 |
// printf(" mysquery is %s\n",myquery.str().c_str()); |
1240 |
|
|
// |
1241 |
|
|
if( !pResult->GetRowCount() ) return(-54); |
1242 |
|
|
Row = pResult->Next(); |
1243 |
|
|
if( Row == NULL ) return (-54); |
1244 |
|
|
// |
1245 |
|
|
uptime = (UInt_t)atoll(Row->GetField(2)); |
1246 |
mocchiut |
1.1 |
// |
1247 |
|
|
// if it is corrupted validation is 0 and we have no results from the query... |
1248 |
|
|
// |
1249 |
mocchiut |
1.7 |
if( atoi(Row->GetField(4)) == 0 ){ // if validation = 0 |
1250 |
mocchiut |
1.1 |
// |
1251 |
|
|
// in this case take relax the conditions and take the valid calibration that preceed the correct one |
1252 |
|
|
// |
1253 |
|
|
myquery.str(""); |
1254 |
|
|
myquery << "select ID_ROOT_L0, FROM_TIME, TO_TIME, EV_ROOT,VALIDATION from GL_CALO_CALIB where SECTION=" << section; |
1255 |
|
|
myquery << " and FROM_TIME <= " << time; |
1256 |
|
|
myquery << " and VALIDATION=1 ORDER BY FROM_TIME DESC LIMIT 1;"; |
1257 |
mocchiut |
1.22 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
1258 |
|
|
this->GetGLTABLES()->AddQ(); |
1259 |
mocchiut |
1.1 |
pResult = dbc->Query(myquery.str().c_str()); |
1260 |
mocchiut |
1.7 |
// printf(" mysquery is %s\n",myquery.str().c_str()); |
1261 |
mocchiut |
1.1 |
// |
1262 |
|
|
// if no results yet quit with error |
1263 |
|
|
// |
1264 |
|
|
if( !pResult->GetRowCount() ) return (-54); |
1265 |
mocchiut |
1.7 |
// |
1266 |
|
|
Row = pResult->Next(); |
1267 |
|
|
// |
1268 |
mocchiut |
1.1 |
}; |
1269 |
|
|
// |
1270 |
|
|
// store infos and exit |
1271 |
|
|
// |
1272 |
|
|
if( Row == NULL ) return (-54); |
1273 |
|
|
for( t = 0; t < pResult->GetFieldCount(); t++){ |
1274 |
|
|
if (t==0) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
1275 |
|
|
if (t==1) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); |
1276 |
|
|
if (t==2) TO_TIME = (UInt_t)atoll(Row->GetField(t)); |
1277 |
|
|
if (t==3) EV_ROOT = (UInt_t)atoll(Row->GetField(t)); |
1278 |
|
|
}; |
1279 |
|
|
pResult->Delete(); |
1280 |
|
|
return 0; |
1281 |
|
|
}; |
1282 |
|
|
// **************************************************** |
1283 |
|
|
/** |
1284 |
|
|
* Function to query the GL_S4_CALIB table of the DB. |
1285 |
|
|
* |
1286 |
|
|
* \param run starting time |
1287 |
|
|
* \return struct of type GL_S4_CALIB_data, which stores the query result |
1288 |
|
|
*/ |
1289 |
|
|
Int_t GL_S4_CALIB::Query_GL_S4_CALIB(UInt_t time, TSQLServer *dbc){ |
1290 |
|
|
// MySQL variables |
1291 |
|
|
TSQLResult *pResult; |
1292 |
|
|
TSQLRow *Row; |
1293 |
|
|
int t; |
1294 |
|
|
int r; |
1295 |
|
|
stringstream myquery; |
1296 |
|
|
// ---------------- |
1297 |
|
|
myquery.str(""); |
1298 |
|
|
myquery << "select * from GL_S4_CALIB where FROM_TIME <= "<< time; |
1299 |
mocchiut |
1.5 |
myquery << " ORDER BY FROM_TIME DESC LIMIT 1;"; |
1300 |
mocchiut |
1.1 |
// myquery << " ORDER BY FROM_TIME DESC LIMIT 1;"; |
1301 |
mocchiut |
1.22 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
1302 |
|
|
this->GetGLTABLES()->AddQ(); |
1303 |
mocchiut |
1.1 |
pResult = dbc->Query(myquery.str().c_str()); |
1304 |
|
|
if(!pResult->GetRowCount())return (-55);//throw -55; |
1305 |
|
|
for( r=0; r < 1000; r++){ |
1306 |
|
|
Row = pResult->Next(); |
1307 |
|
|
if( Row == NULL ) break; |
1308 |
|
|
for( t = 0; t < pResult->GetFieldCount(); t++){ |
1309 |
|
|
if (t==0) ID = (UInt_t)atoll(Row->GetField(t)); |
1310 |
|
|
if (t==1) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
1311 |
|
|
if (t==2) EV_ROOT = (UInt_t)atoll(Row->GetField(t)); |
1312 |
|
|
if (t==3) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); |
1313 |
|
|
if (t==4) TO_TIME = (UInt_t)atoll(Row->GetField(t)); |
1314 |
|
|
if (t==5) PARAM_FIT0 = atof(Row->GetField(t)); |
1315 |
|
|
if (t==6) PARAM_FIT1 = atof(Row->GetField(t)); |
1316 |
|
|
}; |
1317 |
|
|
}; |
1318 |
|
|
delete pResult; |
1319 |
|
|
// |
1320 |
|
|
if(TO_TIME < time)return(51); |
1321 |
|
|
// |
1322 |
|
|
return 0; |
1323 |
|
|
}; |
1324 |
|
|
// **************************************************** |
1325 |
|
|
/** |
1326 |
|
|
* Function to query the GL_PARAM table of the DB. |
1327 |
|
|
* |
1328 |
|
|
* \param run starting time |
1329 |
|
|
* \param parameter description (DESCR) |
1330 |
|
|
* \return struct of type GL_ROOT_data, which stores the query result |
1331 |
|
|
*/ |
1332 |
|
|
Int_t GL_PARAM::Query_GL_PARAM(UInt_t time, UInt_t type, TSQLServer *dbc){ |
1333 |
|
|
// Bool_t debug = 1; |
1334 |
|
|
// MySQL variables |
1335 |
|
|
TSQLResult *pResult; |
1336 |
|
|
TSQLRow *Row; |
1337 |
|
|
int t; |
1338 |
|
|
int r; |
1339 |
|
|
stringstream myquery; |
1340 |
|
|
// ---------------- |
1341 |
|
|
myquery.str(""); |
1342 |
|
|
myquery << " select "; |
1343 |
mocchiut |
1.25 |
myquery << " ID, PATH, NAME, DESCR, FROM_TIME,TO_TIME, TYPE "; |
1344 |
mocchiut |
1.1 |
myquery << " from GL_PARAM "; |
1345 |
|
|
myquery << " where TYPE = '"<<type<<"' "; |
1346 |
|
|
myquery << " and FROM_TIME <= " << time; |
1347 |
|
|
myquery << " ORDER BY TO_TIME DESC LIMIT 1;"; |
1348 |
|
|
// |
1349 |
mocchiut |
1.22 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
1350 |
|
|
this->GetGLTABLES()->AddQ(); |
1351 |
mocchiut |
1.1 |
pResult = dbc->Query(myquery.str().c_str()); |
1352 |
|
|
if(!pResult->GetRowCount())return (-52); |
1353 |
|
|
for( r=0; r < 1000; r++){ |
1354 |
|
|
Row = pResult->Next(); |
1355 |
|
|
if( Row == NULL ) break; |
1356 |
|
|
for( t = 0; t < pResult->GetFieldCount(); t++){ |
1357 |
|
|
if (t==0) ID = (UInt_t)atoll(Row->GetField(t)); |
1358 |
mocchiut |
1.26 |
if (t==1) PATH = (TString)gSystem->ExpandPathName(Row->GetField(t))+'/';// put in fpath the path to that file |
1359 |
mocchiut |
1.1 |
if (t==2) NAME = Row->GetField(t); |
1360 |
|
|
if (t==3) DESCR = Row->GetField(t); |
1361 |
|
|
if (t==4) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); |
1362 |
|
|
if (t==5) TO_TIME = (UInt_t)atoll(Row->GetField(t)); |
1363 |
|
|
if (t==6) TYPE = (UInt_t)atoll(Row->GetField(t)); |
1364 |
|
|
}; |
1365 |
|
|
}; |
1366 |
|
|
delete pResult; |
1367 |
|
|
// |
1368 |
|
|
if(TO_TIME==0) TO_TIME = numeric_limits<UInt_t>::max(); |
1369 |
|
|
// |
1370 |
|
|
if(TO_TIME < time) return(51); |
1371 |
|
|
// |
1372 |
|
|
return 0; |
1373 |
|
|
}; |
1374 |
|
|
|
1375 |
|
|
|
1376 |
|
|
/** |
1377 |
|
|
* Fills a struct cGLRun with values from a GLRun object (to put data into a F77 common). |
1378 |
|
|
*/ |
1379 |
|
|
|
1380 |
|
|
void GL_RUN::GetLevel2Struct(cGLRun *l2) const{ |
1381 |
|
|
l2->id = ID; |
1382 |
|
|
l2->id_reg_run = ID_ROOT_L0; |
1383 |
|
|
l2->id_reg_run_l2 = ID_ROOT_L2; |
1384 |
|
|
l2->runheader_time = RUNHEADER_TIME; |
1385 |
|
|
l2->runtrailer_time = RUNTRAILER_TIME; |
1386 |
|
|
l2->ev_from = EV_FROM; |
1387 |
|
|
l2->trk_calib_used = TRK_CALIB_USED; |
1388 |
|
|
l2->eff_wrk_schedule = EFF_WRK_SCHEDULE; |
1389 |
|
|
l2->prh_var_trg_mode_a = PRH_VAR_TRG_MODE_A; |
1390 |
|
|
l2->prh_var_trg_mode_b = PRH_VAR_TRG_MODE_B; |
1391 |
|
|
l2->acq_build_info = ACQ_BUILD_INFO; |
1392 |
|
|
l2->acq_var_info = ACQ_VAR_INFO; |
1393 |
|
|
}; |
1394 |
|
|
|
1395 |
|
|
GL_TIMESYNC::GL_TIMESYNC(UInt_t id, TString type, TSQLServer *dbc){ |
1396 |
|
|
// MySQL variables |
1397 |
|
|
TFile *file = 0; |
1398 |
|
|
UInt_t idraw = 0; |
1399 |
|
|
// |
1400 |
|
|
TSQLResult *pResult; |
1401 |
|
|
TSQLRow *Row; |
1402 |
|
|
stringstream myquery; |
1403 |
mocchiut |
1.14 |
stringstream rname; |
1404 |
mocchiut |
1.23 |
// pcksList packetsNames; |
1405 |
|
|
// pcksList::iterator Iter; |
1406 |
|
|
// getPacketsNames(packetsNames); |
1407 |
mocchiut |
1.14 |
rname.str(""); |
1408 |
mocchiut |
1.1 |
// ---------------- |
1409 |
|
|
myquery.str(""); |
1410 |
|
|
myquery << "select "; |
1411 |
|
|
myquery << "PATH"; |
1412 |
|
|
myquery << ",NAME,ID_RAW"; |
1413 |
|
|
myquery << " from GL_ROOT where "; |
1414 |
|
|
myquery << type.Data(); |
1415 |
|
|
myquery << "=" << id << ";"; |
1416 |
|
|
// |
1417 |
mocchiut |
1.22 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return; |
1418 |
|
|
this->GetGLTABLES()->AddQ(); |
1419 |
mocchiut |
1.1 |
pResult = dbc->Query(myquery.str().c_str()); |
1420 |
|
|
if( pResult->GetRowCount() ){ |
1421 |
|
|
Row = pResult->Next(); |
1422 |
|
|
if( Row ){ |
1423 |
|
|
stringstream fname; |
1424 |
|
|
fname.str(""); |
1425 |
mocchiut |
1.26 |
fname << gSystem->ExpandPathName(Row->GetField(0)) << "/" << Row->GetField(1); |
1426 |
mocchiut |
1.14 |
rname << Row->GetField(1); |
1427 |
mocchiut |
1.1 |
file = new TFile(fname.str().c_str(),"READ"); |
1428 |
|
|
idraw = (UInt_t)atoll(Row->GetField(2)); |
1429 |
|
|
}; |
1430 |
|
|
}; |
1431 |
|
|
// |
1432 |
|
|
if ( file && file->IsOpen() ){ |
1433 |
|
|
TTree *T=(TTree*)file->Get("Physics"); |
1434 |
|
|
pamela::EventHeader *eh = 0; |
1435 |
|
|
pamela::PscuHeader *ph = 0; |
1436 |
|
|
T->SetBranchAddress("Header", &eh); |
1437 |
|
|
// |
1438 |
|
|
T->GetEntry(0); |
1439 |
|
|
ph = eh->GetPscuHeader(); |
1440 |
|
|
pktfirst = ph->GetCounter(); |
1441 |
|
|
obtfirst = ph->GetOrbitalTime(); |
1442 |
mocchiut |
1.23 |
// |
1443 |
|
|
// code = eh->GetCounter(); |
1444 |
|
|
// UInt_t en = 0; |
1445 |
|
|
// for(Iter = packetsNames.begin(); Iter != packetsNames.end(); Iter++){ |
1446 |
|
|
// en = code->Get(GetPacketType(*Iter)); |
1447 |
|
|
// if ( !strcmp("CalibCalPed",*Iter) || !strcmp("CalibTrk1",*Iter) || !strcmp("CalibTrk2",*Iter) || !strcmp("CalibS4",*Iter) ){ |
1448 |
|
|
// // |
1449 |
|
|
// TTree *TC = 0; |
1450 |
|
|
// TC = (TTree*)file->Get("CalibCalPed"); |
1451 |
|
|
// if ( !TC || TC->IsZombie() ) return; |
1452 |
|
|
// EventHeader *ehc = 0; |
1453 |
|
|
// PscuHeader *phc = 0; |
1454 |
|
|
// TC->SetBranchAddress("Header", &ehc); |
1455 |
|
|
// TC->GetEntry(0); |
1456 |
|
|
// phc = ehc->GetPscuHeader(); |
1457 |
|
|
// pktfirst = phc->GetCounter(); |
1458 |
|
|
// obtfirst = phc->GetOrbitalTime(); |
1459 |
|
|
// // |
1460 |
|
|
// }; |
1461 |
|
|
// }; |
1462 |
|
|
// |
1463 |
mocchiut |
1.1 |
}; |
1464 |
|
|
// |
1465 |
|
|
// look for Resurs offset |
1466 |
|
|
// |
1467 |
mocchiut |
1.17 |
T0 = 0; |
1468 |
mocchiut |
1.1 |
// |
1469 |
mocchiut |
1.14 |
// |
1470 |
|
|
stringstream oss; |
1471 |
mocchiut |
1.27 |
TString frn = rname.str().c_str(); |
1472 |
|
|
frn = frn.ReplaceAll(".root",5,".pam",4); |
1473 |
mocchiut |
1.14 |
oss.str(""); |
1474 |
mocchiut |
1.18 |
oss << "SELECT YEAR(OFFSET_DATE),MONTH(OFFSET_DATE),DAY(OFFSET_DATE),HOUR(OFFSET_DATE),MINUTE(OFFSET_DATE),SECOND(OFFSET_DATE) FROM GL_RESURS_OFFSET WHERE SPECIAL_FILE='" |
1475 |
mocchiut |
1.27 |
<< frn.Data() << "';"; |
1476 |
mocchiut |
1.22 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return; |
1477 |
|
|
this->GetGLTABLES()->AddQ(); |
1478 |
mocchiut |
1.14 |
pResult = dbc->Query(oss.str().c_str()); |
1479 |
|
|
Row = pResult->Next(); |
1480 |
|
|
// |
1481 |
|
|
TString name=rname.str().c_str(); |
1482 |
|
|
UInt_t dworbit = 0; |
1483 |
|
|
Int_t nlength = name.Length(); |
1484 |
|
|
if ( nlength < 5 ) return; |
1485 |
|
|
TString dwo = 0; |
1486 |
|
|
for (Int_t i = 0; i<5; i++){ |
1487 |
|
|
dwo.Append(name[i],1); |
1488 |
|
|
}; |
1489 |
|
|
if ( dwo.IsDigit() ){ |
1490 |
|
|
dworbit = (UInt_t)dwo.Atoi(); |
1491 |
|
|
} else { |
1492 |
|
|
dwo=""; |
1493 |
|
|
for (Int_t i = 8; i<13; i++){ |
1494 |
|
|
dwo.Append(name[i],1); |
1495 |
|
|
}; |
1496 |
mocchiut |
1.23 |
if ( dwo.IsDigit() ){ |
1497 |
|
|
dworbit = (UInt_t)dwo.Atoi(); |
1498 |
|
|
} else { |
1499 |
|
|
dworbit = 1; |
1500 |
|
|
}; |
1501 |
mocchiut |
1.14 |
}; |
1502 |
|
|
// |
1503 |
mocchiut |
1.23 |
// |
1504 |
mocchiut |
1.14 |
if ( !Row ){ |
1505 |
|
|
oss.str(""); |
1506 |
mocchiut |
1.18 |
oss << "SELECT YEAR(OFFSET_DATE),MONTH(OFFSET_DATE),DAY(OFFSET_DATE),HOUR(OFFSET_DATE),MINUTE(OFFSET_DATE),SECOND(OFFSET_DATE) FROM GL_RESURS_OFFSET WHERE FROM_ORBIT< " |
1507 |
mocchiut |
1.14 |
<< dworbit << " order by FROM_ORBIT desc limit 1;"; |
1508 |
mocchiut |
1.22 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return; |
1509 |
|
|
this->GetGLTABLES()->AddQ(); |
1510 |
mocchiut |
1.14 |
pResult = dbc->Query(oss.str().c_str()); |
1511 |
mocchiut |
1.1 |
Row = pResult->Next(); |
1512 |
mocchiut |
1.14 |
if ( !Row ){ |
1513 |
|
|
printf(" ERROR FROM GLTables! cannot determine Resurs offset \n"); |
1514 |
|
|
return; |
1515 |
mocchiut |
1.1 |
}; |
1516 |
|
|
}; |
1517 |
|
|
// |
1518 |
mocchiut |
1.18 |
TTimeStamp tu = TTimeStamp((UInt_t)atoi(Row->GetField(0)),(UInt_t)atoi(Row->GetField(1)),(UInt_t)atoi(Row->GetField(2)),(UInt_t)atoi(Row->GetField(3)),(UInt_t)atoi(Row->GetField(4)),(UInt_t)atoi(Row->GetField(5)),0,true,0); |
1519 |
mocchiut |
1.17 |
T0 = (UInt_t)tu.GetSec(); |
1520 |
mocchiut |
1.1 |
// |
1521 |
|
|
// look for the correct timesync entry |
1522 |
|
|
// |
1523 |
|
|
myquery.str(""); |
1524 |
mocchiut |
1.17 |
myquery << " SELECT OBT0,TIMESYNC,TYPE FROM GL_TIMESYNC " |
1525 |
mocchiut |
1.1 |
<< " WHERE ID_RAW = " << idraw |
1526 |
|
|
<< ";"; |
1527 |
mocchiut |
1.22 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return; |
1528 |
|
|
this->GetGLTABLES()->AddQ(); |
1529 |
mocchiut |
1.1 |
pResult = dbc->Query(myquery.str().c_str()); |
1530 |
|
|
if ( pResult ){ |
1531 |
|
|
Row = pResult->Next(); |
1532 |
|
|
if ( (Row != NULL) && ((UInt_t)atoll(Row->GetField(0)) > 0 ) ){ |
1533 |
mocchiut |
1.17 |
OBT0 = (UInt_t)atoll(Row->GetField(0)); |
1534 |
|
|
TIMESYNC = (UInt_t)atoll(Row->GetField(1)); |
1535 |
|
|
TYPE = (UInt_t)atoll(Row->GetField(2)); |
1536 |
|
|
toffset = (UInt_t)atoll(Row->GetField(1)) - (UInt_t)(this->DBobt((UInt_t)atoll(Row->GetField(0)))/1000) + T0; |
1537 |
mocchiut |
1.1 |
}; |
1538 |
|
|
}; |
1539 |
mocchiut |
1.3 |
// |
1540 |
|
|
file->Close(); |
1541 |
mocchiut |
1.1 |
delete pResult; |
1542 |
|
|
}; |
1543 |
|
|
|
1544 |
|
|
/** |
1545 |
|
|
* |
1546 |
|
|
* Returns the DB absolute time needed to associate calibrations to data |
1547 |
|
|
* |
1548 |
|
|
*/ |
1549 |
|
|
UInt_t GL_TIMESYNC::DBabsTime(UInt_t OBT){ |
1550 |
|
|
// |
1551 |
|
|
return(((UInt_t)(this->DBobt(OBT)/1000)+toffset)); |
1552 |
|
|
// |
1553 |
|
|
}; |
1554 |
|
|
|
1555 |
mocchiut |
1.17 |
/** |
1556 |
|
|
* |
1557 |
|
|
* Returns the Resurs time given the OBT needed to process inclination and orbital infos |
1558 |
|
|
* |
1559 |
|
|
*/ |
1560 |
|
|
UInt_t GL_TIMESYNC::ResursTime(UInt_t OBT){ |
1561 |
|
|
// |
1562 |
mocchiut |
1.19 |
return(((UInt_t)((Int_t)(this->DBobt(OBT)-this->DBobt(OBT0))/1000)+TIMESYNC)); |
1563 |
mocchiut |
1.17 |
// |
1564 |
|
|
}; |
1565 |
|
|
|
1566 |
mocchiut |
1.1 |
|
1567 |
mocchiut |
1.20 |
/** |
1568 |
|
|
* Return the correct packet number if we went back to zero |
1569 |
|
|
*/ |
1570 |
|
|
Long64_t GL_TIMESYNC::DBpkt(UInt_t pkt_num){ |
1571 |
mocchiut |
1.1 |
// |
1572 |
mocchiut |
1.20 |
if ( pkt_num < (pktfirst/2) && pktfirst > (16777214/2) ){ |
1573 |
|
|
return((Long64_t)pkt_num+16777215LL); |
1574 |
|
|
}; |
1575 |
mocchiut |
1.1 |
// |
1576 |
mocchiut |
1.20 |
if ( pkt_num > pktfirst*2 && pkt_num > (16777214/2) ){ |
1577 |
|
|
return((Long64_t)pkt_num-16777215LL); |
1578 |
mocchiut |
1.1 |
}; |
1579 |
|
|
// |
1580 |
mocchiut |
1.20 |
return((Long64_t)pkt_num); |
1581 |
mocchiut |
1.1 |
// |
1582 |
|
|
}; |
1583 |
|
|
|
1584 |
mocchiut |
1.20 |
/** |
1585 |
|
|
* Return the correct On Board Time if we went back to zero |
1586 |
|
|
*/ |
1587 |
|
|
Long64_t GL_TIMESYNC::DBobt(UInt_t obt){ |
1588 |
mocchiut |
1.1 |
// |
1589 |
mocchiut |
1.20 |
if ( obt < (obtfirst/2) && obtfirst > (numeric_limits<UInt_t>::max()/2) ) return((Long64_t)(obt+numeric_limits<UInt_t>::max())); |
1590 |
mocchiut |
1.1 |
// |
1591 |
mocchiut |
1.20 |
if ( obt > (obtfirst*2) && obt > (numeric_limits<UInt_t>::max()/2) ){ |
1592 |
|
|
return((Long64_t)obt-(Long64_t)numeric_limits<UInt_t>::max()); |
1593 |
mocchiut |
1.1 |
}; |
1594 |
|
|
// |
1595 |
mocchiut |
1.20 |
return((Long64_t)obt); |
1596 |
mocchiut |
1.1 |
}; |
1597 |
mocchiut |
1.5 |
|
1598 |
mocchiut |
1.20 |
|
1599 |
|
|
|
1600 |
|
|
// ULong64_t GL_TIMESYNC::DBobt(UInt_t obt){ |
1601 |
|
|
// // |
1602 |
|
|
// if ( obt < (obtfirst/2) && obtfirst > (numeric_limits<UInt_t>::max()/2) ) return((ULong64_t)(obt+numeric_limits<UInt_t>::max())); |
1603 |
|
|
// // |
1604 |
|
|
// if ( obt > (obtfirst*2) && obt > (numeric_limits<UInt_t>::max()/2) ){ |
1605 |
|
|
// if ( (obt-numeric_limits<UInt_t>::max()) < 0 ){ |
1606 |
|
|
// return((ULong64_t)(numeric_limits<UInt_t>::max()-obt)); |
1607 |
|
|
// } else { |
1608 |
|
|
// return((ULong64_t)(obt-numeric_limits<UInt_t>::max())); |
1609 |
|
|
// }; |
1610 |
|
|
// }; |
1611 |
|
|
// // |
1612 |
|
|
// return((ULong64_t)obt); |
1613 |
|
|
// // |
1614 |
|
|
// }; |
1615 |
|
|
|
1616 |
|
|
// UInt_t GL_TIMESYNC::DBpkt(UInt_t pkt_num){ |
1617 |
|
|
// // |
1618 |
|
|
// if ( pkt_num < (pktfirst/2) && pktfirst > (16777214/2) ) return((pkt_num+16777215)); |
1619 |
|
|
// // |
1620 |
|
|
// if ( pkt_num > pktfirst*2 && pkt_num > (16777214/2) ){ |
1621 |
|
|
// if ( (pkt_num-16777215) < 0 ){ |
1622 |
|
|
// return((16777215-pkt_num)); |
1623 |
|
|
// } else { |
1624 |
|
|
// return((pkt_num-16777215)); |
1625 |
|
|
// }; |
1626 |
|
|
// }; |
1627 |
|
|
// // |
1628 |
|
|
// return(pkt_num); |
1629 |
|
|
// // |
1630 |
|
|
// }; |
1631 |
|
|
|
1632 |
mocchiut |
1.5 |
/* |
1633 |
|
|
* |
1634 |
|
|
* Convert the time in the DB from UInt_t to a string |
1635 |
|
|
* |
1636 |
|
|
* @param dbt time in the DB |
1637 |
|
|
* @param tzone Time Zone, can be UTC,GMT,CET,CEST,MSD default is MSK |
1638 |
|
|
* |
1639 |
|
|
*/ |
1640 |
mocchiut |
1.10 |
TString GL_TIMESYNC::ConvertTime(TString &tzone, UInt_t dbt){ |
1641 |
mocchiut |
1.5 |
// |
1642 |
mocchiut |
1.16 |
Int_t offset = 0; |
1643 |
mocchiut |
1.5 |
TString rtime; |
1644 |
mocchiut |
1.10 |
Bool_t found = false; |
1645 |
mocchiut |
1.5 |
// |
1646 |
mocchiut |
1.11 |
if ( !strcmp(tzone.Data(),"MSK") || !strcmp(tzone.Data(),"MWT") ){ |
1647 |
mocchiut |
1.5 |
// |
1648 |
mocchiut |
1.16 |
offset = 60*60*3; // UTC (Coordinated Universal Time) + 3hs = Moscow Winter Time |
1649 |
mocchiut |
1.10 |
found = true; |
1650 |
mocchiut |
1.5 |
// |
1651 |
|
|
}; |
1652 |
|
|
// |
1653 |
|
|
if ( !strcmp(tzone.Data(),"CET") ){ |
1654 |
|
|
// |
1655 |
mocchiut |
1.16 |
offset = 60*60*1; // CET (Central European Time) = UTC + 1 hs |
1656 |
mocchiut |
1.10 |
found = true; |
1657 |
mocchiut |
1.5 |
// |
1658 |
|
|
}; |
1659 |
|
|
// |
1660 |
|
|
if ( !strcmp(tzone.Data(),"CEST") ){ |
1661 |
|
|
// |
1662 |
mocchiut |
1.16 |
offset = 60*60*2; // CEST (Central European Summer Time) = UTC + 2 h |
1663 |
mocchiut |
1.10 |
found = true; |
1664 |
mocchiut |
1.5 |
// |
1665 |
|
|
}; |
1666 |
|
|
// |
1667 |
mocchiut |
1.11 |
if ( !strcmp(tzone.Data(),"MSD") || !strcmp(tzone.Data(),"MST")){ |
1668 |
mocchiut |
1.5 |
// |
1669 |
mocchiut |
1.16 |
offset = 60*60*4; // MSD (Moscow Summer Time) = UTC + 4 h |
1670 |
mocchiut |
1.10 |
found = true; |
1671 |
mocchiut |
1.5 |
// |
1672 |
|
|
}; |
1673 |
|
|
// |
1674 |
mocchiut |
1.11 |
if ( !found && strcmp(tzone.Data(),"UTC") && strcmp(tzone.Data(),"GMT") && strcmp(tzone.Data(),"") ){ |
1675 |
|
|
printf("\n Unknown time zone %s using UTC \n",tzone.Data()); |
1676 |
|
|
tzone = "UTC"; |
1677 |
mocchiut |
1.10 |
}; |
1678 |
|
|
// |
1679 |
mocchiut |
1.16 |
dbt += offset; |
1680 |
|
|
// |
1681 |
|
|
TTimeStamp *time = new TTimeStamp((time_t)dbt,0); |
1682 |
|
|
// |
1683 |
|
|
rtime = time->AsString("s"); |
1684 |
|
|
// |
1685 |
|
|
delete time; |
1686 |
mocchiut |
1.5 |
// |
1687 |
|
|
return(rtime); |
1688 |
|
|
} |
1689 |
mocchiut |
1.6 |
|
1690 |
|
|
/* |
1691 |
|
|
* |
1692 |
mocchiut |
1.16 |
* Convert the time from TZONE to UTC |
1693 |
mocchiut |
1.6 |
* |
1694 |
|
|
* @param dbt time in the DB |
1695 |
|
|
* @param tzone Time Zone, can be UTC,GMT,CET,CEST,MSD default is MSK |
1696 |
|
|
* |
1697 |
|
|
*/ |
1698 |
mocchiut |
1.10 |
TString GL_TIMESYNC::UnConvertTime(TString &tzone, UInt_t dbt){ |
1699 |
mocchiut |
1.6 |
// |
1700 |
mocchiut |
1.16 |
Int_t offset = 0; |
1701 |
mocchiut |
1.6 |
TString rtime; |
1702 |
|
|
// |
1703 |
mocchiut |
1.10 |
Bool_t found = false; |
1704 |
|
|
// |
1705 |
mocchiut |
1.11 |
if ( !strcmp(tzone.Data(),"MSK") || !strcmp(tzone.Data(),"MWT") ){ |
1706 |
mocchiut |
1.6 |
// |
1707 |
mocchiut |
1.16 |
offset = -60*60*3; // UTC (Coordinated Universal Time) = Moscow Winter Time - 3hs |
1708 |
mocchiut |
1.10 |
found = true; |
1709 |
mocchiut |
1.6 |
// |
1710 |
|
|
}; |
1711 |
|
|
// |
1712 |
|
|
if ( !strcmp(tzone.Data(),"CET") ){ |
1713 |
|
|
// |
1714 |
mocchiut |
1.16 |
offset = -60*60*1; // CET (Central European Time) - 1 hs = UTC |
1715 |
mocchiut |
1.10 |
found = true; |
1716 |
mocchiut |
1.6 |
// |
1717 |
|
|
}; |
1718 |
|
|
// |
1719 |
|
|
if ( !strcmp(tzone.Data(),"CEST") ){ |
1720 |
|
|
// |
1721 |
mocchiut |
1.16 |
offset = -60*60*2; // CEST (Central European Summer Time) - 2 h = UTC |
1722 |
mocchiut |
1.10 |
found = true; |
1723 |
mocchiut |
1.6 |
// |
1724 |
|
|
}; |
1725 |
|
|
// |
1726 |
mocchiut |
1.10 |
if ( !strcmp(tzone.Data(),"MSD") || !strcmp(tzone.Data(),"MST") ){ |
1727 |
mocchiut |
1.6 |
// |
1728 |
mocchiut |
1.16 |
offset = -60*60*4; // MSD (Moscow Summer Time) - 4 h = UTC |
1729 |
mocchiut |
1.10 |
found = true; |
1730 |
|
|
// |
1731 |
|
|
}; |
1732 |
|
|
// |
1733 |
mocchiut |
1.11 |
if ( !found && strcmp(tzone.Data(),"UTC") && strcmp(tzone.Data(),"GMT") && strcmp(tzone.Data(),"") ){ |
1734 |
mocchiut |
1.6 |
// |
1735 |
mocchiut |
1.16 |
offset = 0; |
1736 |
mocchiut |
1.11 |
printf("\n Unknown time zone %s using UTC \n",tzone.Data()); |
1737 |
|
|
tzone = "UTC"; |
1738 |
mocchiut |
1.6 |
}; |
1739 |
|
|
// |
1740 |
mocchiut |
1.16 |
dbt += offset; |
1741 |
|
|
TTimeStamp *time = new TTimeStamp((time_t)dbt,0); |
1742 |
|
|
// |
1743 |
|
|
rtime = time->AsString("s"); |
1744 |
mocchiut |
1.6 |
// |
1745 |
|
|
return(rtime); |
1746 |
|
|
} |
1747 |
mocchiut |
1.12 |
|
1748 |
|
|
|
1749 |
mocchiut |
1.21 |
// |
1750 |
|
|
// Build a query and call DoQuery. |
1751 |
|
|
// |
1752 |
|
|
// date it's an SQL datetime date and dbc is the connection to be |
1753 |
|
|
// used. It will query for the tle with the nearest but previous date |
1754 |
|
|
// and the immediatly next one. |
1755 |
|
|
// |
1756 |
|
|
Int_t GL_TLE::Query(TString date, TSQLServer *dbc){ |
1757 |
mocchiut |
1.12 |
stringstream myquery; |
1758 |
|
|
myquery.str(""); |
1759 |
|
|
|
1760 |
mocchiut |
1.21 |
myquery << "(SELECT ID, TLE1, TLE2, TLE3, UNIX_TIMESTAMP(FROM_TIME) FROM GL_TLE " |
1761 |
|
|
<< "WHERE FROM_TIME <= '" << date.Data() |
1762 |
|
|
<< "' ORDER BY FROM_TIME DESC LIMIT 1) " |
1763 |
|
|
<< "UNION " |
1764 |
|
|
<< "(SELECT ID, TLE1, TLE2, TLE3, UNIX_TIMESTAMP(FROM_TIME) FROM GL_TLE " |
1765 |
|
|
<< "WHERE FROM_TIME > '" << date.Data() |
1766 |
|
|
<< "' ORDER BY FROM_TIME ASC LIMIT 1)"; |
1767 |
mocchiut |
1.12 |
|
1768 |
mocchiut |
1.21 |
return DoQuery(myquery.str().c_str(), dbc); |
1769 |
mocchiut |
1.12 |
} |
1770 |
|
|
|
1771 |
|
|
|
1772 |
mocchiut |
1.21 |
// |
1773 |
|
|
// Build a query and call DoQuery. |
1774 |
|
|
// |
1775 |
|
|
// time is the UTC date in unix time (UTC) and dbc is the connection |
1776 |
|
|
// to be used. It will query for the tle with the nearest but |
1777 |
|
|
// previous date and the immediatly next one. |
1778 |
|
|
// |
1779 |
|
|
// Returns the value returned by DoQuery(). |
1780 |
|
|
// |
1781 |
|
|
Int_t GL_TLE::Query(UInt_t time, TSQLServer *dbc){ |
1782 |
mocchiut |
1.12 |
stringstream myquery; |
1783 |
|
|
myquery.str(""); |
1784 |
|
|
|
1785 |
mocchiut |
1.21 |
myquery << "(SELECT ID, TLE1, TLE2, TLE3, UNIX_TIMESTAMP(FROM_TIME) FROM GL_TLE " |
1786 |
|
|
<< "WHERE FROM_TIME <= FROM_UNIXTIME('" << time |
1787 |
|
|
<< "') ORDER BY FROM_TIME DESC LIMIT 1) " |
1788 |
|
|
<< "UNION " |
1789 |
|
|
<< "(SELECT ID, TLE1, TLE2, TLE3, UNIX_TIMESTAMP(FROM_TIME) FROM GL_TLE " |
1790 |
|
|
<< "WHERE FROM_TIME > FROM_UNIXTIME('" << time |
1791 |
|
|
<< "') ORDER BY FROM_TIME ASC LIMIT 1)"; |
1792 |
mocchiut |
1.12 |
|
1793 |
mocchiut |
1.21 |
return DoQuery(myquery.str().c_str(), dbc); |
1794 |
mocchiut |
1.12 |
} |
1795 |
|
|
|
1796 |
|
|
|
1797 |
mocchiut |
1.21 |
// |
1798 |
|
|
// Do the query myquery on the connectio dbc. Initialize tle, |
1799 |
|
|
// tleFromTime and tleToTime. |
1800 |
|
|
// |
1801 |
|
|
// We should have two rows (unless the table is old). From the last |
1802 |
|
|
// one we only take tleToTime. |
1803 |
|
|
// |
1804 |
|
|
// Returns 0 for success, 1 for failure. |
1805 |
|
|
// |
1806 |
|
|
Int_t GL_TLE::DoQuery(TString myquery, TSQLServer *dbc){ |
1807 |
mocchiut |
1.12 |
TSQLResult *result; |
1808 |
|
|
TSQLRow *row; |
1809 |
|
|
|
1810 |
mocchiut |
1.21 |
// Set the right time_zone (otherwise horrible things will occur! :) |
1811 |
|
|
dbc->Query("SET time_zone = '+0:00'"); |
1812 |
|
|
|
1813 |
|
|
// Do the query |
1814 |
mocchiut |
1.22 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
1815 |
|
|
this->GetGLTABLES()->AddQ(); |
1816 |
mocchiut |
1.12 |
result = dbc->Query(myquery.Data()); |
1817 |
mocchiut |
1.21 |
if(! result->GetRowCount() ) { |
1818 |
|
|
cerr << "GL_TLE: query failed: " << myquery.Data() << endl; |
1819 |
|
|
return 1; |
1820 |
|
|
} |
1821 |
|
|
|
1822 |
|
|
// Get results |
1823 |
|
|
row = result->Next(); // first tle row |
1824 |
|
|
tle = GiveTle(row); |
1825 |
|
|
|
1826 |
|
|
tleFromTime = strtol(row->GetField(4), NULL, 10); |
1827 |
|
|
|
1828 |
|
|
row = result->Next(); // second tle row |
1829 |
|
|
if(row) |
1830 |
|
|
tleToTime = strtol(row->GetField(4), NULL, 10); |
1831 |
|
|
else { |
1832 |
|
|
cerr << "GL_TLE: Warning: using last avaible TLE. Please update GL_TLE table!\n"; |
1833 |
|
|
tleToTime = UINT_MAX; |
1834 |
|
|
} |
1835 |
|
|
|
1836 |
|
|
delete row; |
1837 |
|
|
delete result; |
1838 |
mocchiut |
1.12 |
|
1839 |
mocchiut |
1.21 |
return 0; |
1840 |
|
|
} |
1841 |
mocchiut |
1.12 |
|
1842 |
|
|
|
1843 |
mocchiut |
1.21 |
// |
1844 |
|
|
// Build a cTle object from the GL_TLE row. |
1845 |
|
|
// |
1846 |
|
|
cTle* GL_TLE::GiveTle(TSQLRow *row) { |
1847 |
|
|
cTle *thistle = NULL; |
1848 |
|
|
string tle1, tle2, tle3; |
1849 |
|
|
|
1850 |
|
|
// Build cTle object |
1851 |
|
|
tle1 = row->GetField(1); |
1852 |
|
|
tle2 = row->GetField(2); |
1853 |
|
|
tle3 = row->GetField(3); |
1854 |
|
|
|
1855 |
|
|
thistle = new cTle(tle1, tle2, tle3); |
1856 |
mocchiut |
1.12 |
|
1857 |
mocchiut |
1.21 |
return thistle; |
1858 |
mocchiut |
1.12 |
} |