/[PAMELA software]/YodaProfiler/inc/GLTables.h
ViewVC logotype

Contents of /YodaProfiler/inc/GLTables.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.15 - (show annotations) (download)
Wed Jan 31 16:14:59 2007 UTC (17 years, 10 months ago) by mocchiut
Branch: MAIN
CVS Tags: v3r00
Changes since 1.14: +56 -8 lines
File MIME type: text/plain
V3R00 - add DB reconnection capability

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

  ViewVC Help
Powered by ViewVC 1.1.23