1 |
#ifndef gltables_h |
2 |
#define gltables_h |
3 |
|
4 |
#include <TString.h> |
5 |
#include <TObject.h> |
6 |
#include <TSQLServer.h> |
7 |
#include <TSQLRow.h> |
8 |
#include <TSQLResult.h> |
9 |
#include <TSystem.h> |
10 |
#include <GLTablesStruct.h> |
11 |
#include <EventHeader.h> |
12 |
#include <PscuHeader.h> |
13 |
#include <RunHeaderEvent.h> |
14 |
#include <RunTrailerEvent.h> |
15 |
#include <sgp4.h> |
16 |
// |
17 |
|
18 |
using namespace pamela; |
19 |
// |
20 |
|
21 |
static const TString *fHost; |
22 |
static const TString *fUser; |
23 |
static const TString *fPsw; |
24 |
static UInt_t fNquery; |
25 |
static Bool_t fSet; |
26 |
|
27 |
// ================================================================== |
28 |
/** |
29 |
* \brief Class to store GL_RUN data |
30 |
*/ |
31 |
class GL_TABLES : public TObject { |
32 |
private: |
33 |
|
34 |
public: |
35 |
// |
36 |
TString mh; |
37 |
TString mp; |
38 |
TString mu; |
39 |
GL_TABLES(); |
40 |
GL_TABLES(TString, TString, TString); |
41 |
// |
42 |
void Set(TString, TString, TString); |
43 |
// |
44 |
Bool_t IsConnected(TSQLServer *&); |
45 |
// |
46 |
void ResetCounters(); |
47 |
void AddQ(); |
48 |
// |
49 |
const TString* GetHost(){return(fHost);}; |
50 |
const TString* GetUser(){return(fUser);}; |
51 |
const TString* GetPsw(){return(fPsw);}; |
52 |
TString CGetHost(){return(mh);}; |
53 |
TString CGetUser(){return(mu);}; |
54 |
TString CGetPsw(){return(mp);}; |
55 |
UInt_t GetfNquery(){return(fNquery);}; |
56 |
UInt_t GetNqueries(); |
57 |
Bool_t IsSet(){return(fSet);}; |
58 |
// |
59 |
GL_TABLES *GetGLTABLES(){return this;}; |
60 |
// |
61 |
ClassDef(GL_TABLES,2); |
62 |
}; |
63 |
|
64 |
// ================================================================== |
65 |
|
66 |
/** |
67 |
* \brief Class to store GL_RUN data |
68 |
*/ |
69 |
//class GL_RUN : public TObject { |
70 |
class GL_RUN : public GL_TABLES { |
71 |
private: |
72 |
|
73 |
public: |
74 |
// |
75 |
UInt_t ID; |
76 |
UInt_t ID_RUN_FRAG; |
77 |
UInt_t ID_ROOT_L0; |
78 |
UInt_t ID_ROOT_L2; |
79 |
UInt_t RUNHEADER_TIME; |
80 |
UInt_t RUNTRAILER_TIME; |
81 |
UInt_t RUNHEADER_OBT; |
82 |
UInt_t RUNTRAILER_OBT; |
83 |
UInt_t RUNHEADER_PKT; |
84 |
UInt_t RUNTRAILER_PKT; |
85 |
UInt_t BOOT_NUMBER; |
86 |
UInt_t EV_FROM; |
87 |
UInt_t EV_TO; |
88 |
UInt_t NEVENTS; |
89 |
UInt_t PKT_COUNTER; |
90 |
UInt_t PKT_READY_COUNTER; |
91 |
UInt_t COMPILATIONTIMESTAMP; |
92 |
UInt_t FAV_WRK_SCHEDULE; |
93 |
UInt_t EFF_WRK_SCHEDULE; |
94 |
UInt_t PRH_VAR_TRG_MODE_A; |
95 |
UInt_t PRH_VAR_TRG_MODE_B; |
96 |
UInt_t ACQ_BUILD_INFO; |
97 |
UInt_t ACQ_VAR_INFO; |
98 |
UInt_t RM_ACQ_AFTER_CALIB; |
99 |
UInt_t RM_ACQ_SETTING_MODE; |
100 |
UInt_t TRK_CALIB_USED; |
101 |
UInt_t CAL_DSP_MASK; |
102 |
UInt_t LAST_TIMESYNC; |
103 |
UInt_t OBT_TIMESYNC; |
104 |
UInt_t PHYSENDRUN_MASK_S3S2S12; |
105 |
UInt_t PHYSENDRUN_MASK_S11CRC; |
106 |
UInt_t VALIDATION; |
107 |
// |
108 |
// |
109 |
// |
110 |
GL_RUN(); |
111 |
// |
112 |
// functions |
113 |
// |
114 |
Int_t Query_GL_RUN(UInt_t, TSQLServer*); |
115 |
Int_t Fill_GL_RUN(TSQLServer*); |
116 |
Int_t Query_GL_RUN_FRAGMENTS(TString, TSQLServer*); |
117 |
Int_t Fill_GL_RUN_FRAGMENTS(TSQLServer*); |
118 |
Int_t DeleteRun(TSQLServer*, UInt_t, TString); |
119 |
Int_t RestoreRun(TSQLServer*, UInt_t, TString); |
120 |
void Clear(Option_t *t=""); |
121 |
// |
122 |
// SETTERS |
123 |
// |
124 |
void Set_GL_RUNT(RunTrailerEvent *runt, PscuHeader *pht); |
125 |
void Set_GL_RUNH(RunHeaderEvent *runt, PscuHeader *pht); |
126 |
void Set_GL_RUNT0(); |
127 |
void Set_GL_RUNH0(); |
128 |
// |
129 |
void Set_GL_RUN(TSQLRow *row); |
130 |
// |
131 |
void SetRUNHEADER_TIME(UInt_t abst); |
132 |
void SetRUNTRAILER_TIME(UInt_t abst); |
133 |
void SetRUNHEADER_PKT(UInt_t abst); |
134 |
void SetRUNTRAILER_PKT(UInt_t abst); |
135 |
void SetRUNHEADER_OBT(UInt_t abst); |
136 |
void SetRUNTRAILER_OBT(UInt_t abst); |
137 |
void SetBOOTNUMBER(UInt_t abst); |
138 |
void SetID(UInt_t); |
139 |
void SetID_ROOT_L2(UInt_t L2); |
140 |
void SetID_ROOT_L0(UInt_t L0); |
141 |
void SetID_RUN_FRAG(UInt_t RUN); |
142 |
void SetVALIDATION(UInt_t valid); |
143 |
void SetEV_FROM(UInt_t evfrom); |
144 |
void SetEV_TO(UInt_t evto); |
145 |
void SetNEVENTS(UInt_t nev); |
146 |
void SetLAST_TIMESYNC(UInt_t ts); |
147 |
void SetOBT_TIMESYNC(UInt_t ts); |
148 |
void SetPKT_COUNTER(UInt_t); |
149 |
void SetPKT_READY_COUNTER(UInt_t); |
150 |
void SetCOMPILATIONTIMESTAMP(UInt_t); |
151 |
void SetFAV_WRK_SCHEDULE(UInt_t); |
152 |
void SetEFF_WRK_SCHEDULE(UInt_t); |
153 |
void SetPRH_VAR_TRG_MODE_A(UInt_t); |
154 |
void SetPRH_VAR_TRG_MODE_B(UInt_t); |
155 |
void SetACQ_BUILD_INFO(UInt_t); |
156 |
void SetACQ_VAR_INFO(UInt_t); |
157 |
void SetRM_ACQ_AFTER_CALIB(UInt_t); |
158 |
void SetRM_ACQ_SETTING_MODE(UInt_t); |
159 |
void SetTRK_CALIB_USED(UInt_t); |
160 |
void SetCAL_DSP_MASK(UInt_t); |
161 |
void SetPHYSENDRUN_MASK_S3S2S12(UInt_t); |
162 |
void SetPHYSENDRUN_MASK_S11CRC(UInt_t); |
163 |
// |
164 |
// GETTERS |
165 |
// |
166 |
void GetLevel2Struct(cGLRun *l2) const; |
167 |
UInt_t GetID(){return(ID);}; |
168 |
UInt_t GetRUNHEADER_PKT(){return(RUNHEADER_PKT);}; |
169 |
UInt_t GetRUNTRAILER_PKT(){return(RUNTRAILER_PKT);}; |
170 |
UInt_t GetRUNHEADER_TIME(){return(RUNHEADER_TIME);}; |
171 |
UInt_t GetRUNTRAILER_TIME(){return(RUNTRAILER_TIME);}; |
172 |
UInt_t GetRUNHEADER_OBT(){return(RUNHEADER_OBT);}; |
173 |
UInt_t GetRUNTRAILER_OBT(){return(RUNTRAILER_OBT);}; |
174 |
UInt_t GetNEVENTS(){return(NEVENTS);}; |
175 |
UInt_t GetBOOT_NUMBER(){return(BOOT_NUMBER);}; |
176 |
UInt_t GetTRK_CALIB(){return(TRK_CALIB_USED);}; |
177 |
UInt_t GetPKT_COUNTER(){return(PKT_COUNTER);}; |
178 |
UInt_t GetLAST_TIMESYNC(){return(LAST_TIMESYNC);}; |
179 |
UInt_t GetOBT_TIMESYNC(){return(OBT_TIMESYNC);}; |
180 |
UInt_t GetPKT_READY_COUNTER(){return(PKT_READY_COUNTER);}; |
181 |
UInt_t GetCOMPILATIONTIMESTAMP(){return(COMPILATIONTIMESTAMP);}; |
182 |
UInt_t GetFAV_WRK_SCHEDULE(){return(FAV_WRK_SCHEDULE);}; |
183 |
UInt_t GetEFF_WRK_SCHEDULE(){return(EFF_WRK_SCHEDULE);}; |
184 |
UInt_t GetPRH_VAR_TRG_MODE_A(){return(PRH_VAR_TRG_MODE_A);}; |
185 |
UInt_t GetPRH_VAR_TRG_MODE_B(){return(PRH_VAR_TRG_MODE_B);}; |
186 |
UInt_t GetACQ_BUILD_INFO(){return(ACQ_BUILD_INFO);}; |
187 |
UInt_t GetACQ_VAR_INFO(){return(ACQ_VAR_INFO);}; |
188 |
UInt_t GetRM_ACQ_AFTER_CALIB(){return(RM_ACQ_AFTER_CALIB);}; |
189 |
UInt_t GetRM_ACQ_SETTING_MODE(){return(RM_ACQ_SETTING_MODE);}; |
190 |
UInt_t GetTRK_CALIB_USED(){return(TRK_CALIB_USED);}; |
191 |
UInt_t GetCAL_DSP_MASK(){return(CAL_DSP_MASK);}; |
192 |
UInt_t GetPHYSENDRUN_MASK_S3S2S12(){return (PHYSENDRUN_MASK_S3S2S12);}; |
193 |
UInt_t GetPHYSENDRUN_MASK_S11CRC(){return (PHYSENDRUN_MASK_S11CRC);}; |
194 |
// |
195 |
GL_RUN* GetGL_RUN(){return this;}; |
196 |
// |
197 |
ClassDef(GL_RUN,2); |
198 |
}; |
199 |
|
200 |
// ================================================================== |
201 |
/** |
202 |
* \brief Class to store GL_ROOT |
203 |
*/ |
204 |
class GL_ROOT : public GL_TABLES { |
205 |
//class GL_ROOT : public TObject{ |
206 |
private: |
207 |
|
208 |
public: |
209 |
// |
210 |
UInt_t ID; |
211 |
UInt_t ID_RAW; |
212 |
UInt_t ID_TIMESYNC; |
213 |
TString PATH; |
214 |
TString NAME; |
215 |
|
216 |
GL_ROOT(); |
217 |
|
218 |
Int_t Query_GL_ROOT(UInt_t id, TSQLServer *dbc); |
219 |
|
220 |
ClassDef(GL_ROOT,1); |
221 |
}; |
222 |
// ================================================================== |
223 |
/** |
224 |
* \brief Class to store GL_RAW |
225 |
*/ |
226 |
class GL_RAW : public GL_TABLES { |
227 |
//class GL_ROOT : public TObject{ |
228 |
private: |
229 |
|
230 |
public: |
231 |
// |
232 |
UInt_t ID; |
233 |
TString PATH; |
234 |
TString NAME; |
235 |
UInt_t BOOT_NUMBER; |
236 |
|
237 |
GL_RAW(); |
238 |
|
239 |
// Int_t Query_GL_RAW(UInt_t id, TSQLServer *dbc); |
240 |
|
241 |
ClassDef(GL_RAW,1); |
242 |
}; |
243 |
// ================================================================== |
244 |
/** |
245 |
* \brief Class to store GL_PARAM data |
246 |
*/ |
247 |
class GL_PARAM : public GL_TABLES { |
248 |
//class GL_PARAM : public TObject{ |
249 |
private: |
250 |
|
251 |
public: |
252 |
// |
253 |
UInt_t ID; |
254 |
TString PATH; |
255 |
TString NAME; |
256 |
UInt_t FROM_TIME; |
257 |
UInt_t TO_TIME; |
258 |
UInt_t TYPE; |
259 |
TString DESCR; |
260 |
|
261 |
GL_PARAM(); |
262 |
|
263 |
Int_t Query_GL_PARAM(UInt_t time, UInt_t type, TSQLServer *dbc); |
264 |
|
265 |
ClassDef(GL_PARAM,1); |
266 |
}; |
267 |
// ================================================================== |
268 |
/** |
269 |
* \brief Class to store GL_TRK_CALIB data |
270 |
*/ |
271 |
//class GL_TRK_CALIB : public TObject{ |
272 |
class GL_TRK_CALIB : public GL_TABLES { |
273 |
private: |
274 |
|
275 |
public: |
276 |
// |
277 |
UInt_t ID; |
278 |
UInt_t ID_ROOT_L0; |
279 |
UInt_t EV_ROOT_CALIBTRK1 ; |
280 |
UInt_t EV_ROOT_CALIBTRK2 ; |
281 |
UInt_t FROM_TIME; |
282 |
UInt_t TO_TIME; |
283 |
UInt_t OBT1; |
284 |
UInt_t OBT2; |
285 |
UInt_t PKT1; |
286 |
UInt_t PKT2; |
287 |
UInt_t BOOT_NUMBER; |
288 |
UInt_t VALIDATION; |
289 |
|
290 |
GL_TRK_CALIB(); |
291 |
|
292 |
Int_t Query_GL_TRK_CALIB(UInt_t time, TSQLServer *dbc); |
293 |
|
294 |
ClassDef(GL_TRK_CALIB,1); |
295 |
}; |
296 |
|
297 |
// ================================================================== |
298 |
/** |
299 |
* \brief Class to store GL_CALO_CALIB data |
300 |
*/ |
301 |
class GL_CALO_CALIB : public GL_TABLES { |
302 |
//class GL_CALO_CALIB : public TObject{ |
303 |
private: |
304 |
|
305 |
public: |
306 |
// |
307 |
UInt_t ID; |
308 |
UInt_t ID_ROOT_L0; |
309 |
UInt_t EV_ROOT; |
310 |
UInt_t FROM_TIME; |
311 |
UInt_t TO_TIME; |
312 |
UInt_t SECTION; |
313 |
UInt_t OBT; |
314 |
UInt_t PKT; |
315 |
UInt_t BOOT_NUMBER; |
316 |
UInt_t VALIDATION; |
317 |
|
318 |
GL_CALO_CALIB(); |
319 |
|
320 |
Int_t Query_GL_CALO_CALIB(UInt_t time, UInt_t &uptime, UInt_t section, TSQLServer *dbc); |
321 |
|
322 |
ClassDef(GL_CALO_CALIB,2); |
323 |
}; |
324 |
|
325 |
// ================================================================== |
326 |
/** |
327 |
* \brief Class to store GL_CALOPULSE_CALIB data |
328 |
*/ |
329 |
class GL_CALOPULSE_CALIB : public GL_TABLES { |
330 |
private: |
331 |
|
332 |
public: |
333 |
// |
334 |
UInt_t ID; |
335 |
UInt_t ID_ROOT_L0; |
336 |
UInt_t EV_ROOT; |
337 |
UInt_t FROM_TIME; |
338 |
UInt_t TO_TIME; |
339 |
UInt_t SECTION; |
340 |
UInt_t PULSED_STRIP; |
341 |
UInt_t PULSE_AMPLITUDE; |
342 |
UInt_t OBT; |
343 |
UInt_t PKT; |
344 |
UInt_t BOOT_NUMBER; |
345 |
UInt_t VALIDATION; |
346 |
|
347 |
GL_CALOPULSE_CALIB(); |
348 |
|
349 |
Int_t Query_GL_CALOPULSE_CALIB(UInt_t time, UInt_t section, UInt_t pampli, TSQLServer *dbc); |
350 |
|
351 |
ClassDef(GL_CALOPULSE_CALIB,1); |
352 |
}; |
353 |
// ================================================================== |
354 |
/** |
355 |
* \brief Class to store GL_S4_CALIB data |
356 |
*/ |
357 |
class GL_S4_CALIB : public GL_TABLES { |
358 |
//class GL_S4_CALIB : public TObject{ |
359 |
private: |
360 |
|
361 |
public: |
362 |
// |
363 |
UInt_t ID; |
364 |
UInt_t ID_ROOT_L0; |
365 |
UInt_t EV_ROOT; |
366 |
UInt_t FROM_TIME; |
367 |
UInt_t TO_TIME; |
368 |
UInt_t OBT; |
369 |
UInt_t PKT; |
370 |
UInt_t BOOT_NUMBER; |
371 |
|
372 |
GL_S4_CALIB(); |
373 |
|
374 |
Int_t Query_GL_S4_CALIB(UInt_t time, TSQLServer *dbc); |
375 |
|
376 |
ClassDef(GL_S4_CALIB,2); |
377 |
}; |
378 |
|
379 |
// ================================================================== |
380 |
/** |
381 |
* \brief Class to store TIMESYNC data |
382 |
*/ |
383 |
class GL_TIMESYNC : public GL_TABLES { |
384 |
//class GL_TIMESYNC : public TObject{ |
385 |
private: |
386 |
UInt_t obtfirst; |
387 |
UInt_t pktfirst; |
388 |
UInt_t toffset; |
389 |
// |
390 |
UInt_t ID; |
391 |
UInt_t ID_RAW; |
392 |
UInt_t ID_RESURS_OFFSET; |
393 |
UInt_t OBT0; |
394 |
UInt_t TIMESYNC; |
395 |
UInt_t TYPE; |
396 |
UInt_t T0; |
397 |
|
398 |
public: |
399 |
// |
400 |
GL_TIMESYNC(); |
401 |
GL_TIMESYNC(UInt_t ID, TString TYPE, TSQLServer *dbc); |
402 |
// |
403 |
UInt_t DBabsTime(UInt_t OBT); |
404 |
UInt_t ResursTime(UInt_t OBT); |
405 |
// |
406 |
Long64_t DBpkt(UInt_t PKT); |
407 |
Long64_t DBobt(UInt_t OBT); |
408 |
// |
409 |
TString ConvertTime(TString &tzone, UInt_t dbt); |
410 |
TString UnConvertTime(TString &tzone, UInt_t dbt); |
411 |
// |
412 |
UInt_t GetTimesync() { return TIMESYNC; }; |
413 |
UInt_t GetObt0() { return OBT0; }; |
414 |
UInt_t GetT0() { return T0; }; |
415 |
UInt_t GetType() { return TYPE; }; |
416 |
// |
417 |
ClassDef(GL_TIMESYNC,3); |
418 |
}; |
419 |
|
420 |
|
421 |
/* |
422 |
* Class to query a TLE from the db. |
423 |
* |
424 |
* Two non default constructor are avaiable. It is the same to call |
425 |
* the Query method. |
426 |
* |
427 |
* The class looks for a TLE in the GL_TLE table using the connection |
428 |
* dbc. You need to pass an UTC date in SQL datetime format or in |
429 |
* unix time (UTC) and it will look for the tle with the nearest and |
430 |
* previous date. Then it initialize tle to a cTle object, |
431 |
* tleFromTime to the UTC unix time of the tle and tleToTime to the |
432 |
* UTC unix time of the next avaible tle. |
433 |
*/ |
434 |
class GL_TLE : public GL_TABLES { |
435 |
//class GL_TLE : public TObject{ |
436 |
private: |
437 |
Int_t DoQuery(TString query, TSQLServer *dbc); |
438 |
cTle* GiveTle(TSQLRow*); |
439 |
|
440 |
cTle *tle; // the requested tle |
441 |
UInt_t tleFromTime; // unix time (UTC) of the tle |
442 |
UInt_t tleToTime; // unix time (UTC) of the next tle |
443 |
|
444 |
public: |
445 |
GL_TLE(){ |
446 |
tle = NULL; |
447 |
tleFromTime = 0; |
448 |
tleToTime = 0; |
449 |
}; |
450 |
|
451 |
GL_TLE(UInt_t unixtime, TSQLServer *dbc) { |
452 |
Query(unixtime, dbc); |
453 |
}; |
454 |
|
455 |
GL_TLE(TString date, TSQLServer *dbc) { |
456 |
Query(date, dbc); |
457 |
}; |
458 |
|
459 |
Int_t Query(UInt_t unixtime, TSQLServer *dbc); |
460 |
Int_t Query(TString date, TSQLServer *dbc); |
461 |
|
462 |
cTle* GetTle() const { return tle; } |
463 |
UInt_t GetFromTime() const { return tleFromTime; } |
464 |
UInt_t GetToTime() const { return tleToTime; } |
465 |
|
466 |
ClassDef(GL_TLE,1); |
467 |
}; |
468 |
|
469 |
#endif |
470 |
|