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