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