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