1 |
#ifndef PAMELA_DB_OPERATIONS_H |
2 |
#define PAMELA_DB_OPERATIONS_H |
3 |
|
4 |
#include <RegistryEvent.h> |
5 |
#include <TSQLServer.h> |
6 |
#include <YException.h> |
7 |
#include <iostream> |
8 |
#include <list> |
9 |
#include <cOrbit.h> |
10 |
|
11 |
using namespace yngn::YException; |
12 |
using namespace pamela; |
13 |
|
14 |
|
15 |
/** |
16 |
* Collections of Pamela specific operations over a database |
17 |
*/ |
18 |
class PamelaDBOperations { |
19 |
private: |
20 |
|
21 |
|
22 |
typedef std::list<const char*> pcksList; |
23 |
|
24 |
static void getPacketsNames(pcksList &pcksNames){ |
25 |
pcksNames.push_back("PhysEndRun"); |
26 |
pcksNames.push_back("CalibCalPulse1"); |
27 |
pcksNames.push_back("CalibCalPulse2"); |
28 |
pcksNames.push_back("Physics"); |
29 |
pcksNames.push_back("CalibTrkBoth"); |
30 |
pcksNames.push_back("CalibTrk1"); |
31 |
pcksNames.push_back("CalibTrk2"); |
32 |
pcksNames.push_back("CalibTof"); |
33 |
pcksNames.push_back("CalibS4"); |
34 |
pcksNames.push_back("CalibCalPed"); |
35 |
pcksNames.push_back("Calib1_Ac1"); |
36 |
pcksNames.push_back("Calib2_Ac1"); |
37 |
pcksNames.push_back("Calib1_Ac2"); |
38 |
pcksNames.push_back("Calib2_Ac2"); |
39 |
pcksNames.push_back("CalibCal"); |
40 |
pcksNames.push_back("RunHeader"); |
41 |
pcksNames.push_back("RunTrailer"); |
42 |
pcksNames.push_back("CalibHeader"); |
43 |
pcksNames.push_back("CalibTrailer"); |
44 |
pcksNames.push_back("InitHeader"); |
45 |
pcksNames.push_back("InitTrailer"); |
46 |
pcksNames.push_back("EventTrk"); |
47 |
pcksNames.push_back("Log"); |
48 |
pcksNames.push_back("VarDump"); |
49 |
pcksNames.push_back("ArrDump"); |
50 |
pcksNames.push_back("TabDump"); |
51 |
pcksNames.push_back("Tmtc"); |
52 |
pcksNames.push_back("Mcmd"); |
53 |
pcksNames.push_back("ForcedFECmd"); |
54 |
pcksNames.push_back("Ac1Init"); |
55 |
pcksNames.push_back("CalInit"); |
56 |
pcksNames.push_back("TrkInit"); |
57 |
pcksNames.push_back("TofInit"); |
58 |
pcksNames.push_back("TrgInit"); |
59 |
pcksNames.push_back("NdInit"); |
60 |
pcksNames.push_back("S4Init"); |
61 |
pcksNames.push_back("Ac2Init"); |
62 |
pcksNames.push_back("CalAlarm"); |
63 |
pcksNames.push_back("Ac1Alarm"); |
64 |
pcksNames.push_back("TrkAlarm"); |
65 |
pcksNames.push_back("TrgAlarm"); |
66 |
pcksNames.push_back("TofAlarm"); |
67 |
pcksNames.push_back("S4Alarm"); |
68 |
pcksNames.push_back("Ac2Alarm"); |
69 |
pcksNames.push_back("TsbT"); |
70 |
pcksNames.push_back("TsbB"); |
71 |
} |
72 |
|
73 |
static const char* getID_RAW(TSQLServer *conn, const char *rawPathName, const char *rawFileName) |
74 |
throw (YSQLNotConnectedException, YSQLQueryException); |
75 |
|
76 |
static const char* setGeo(cOrbit *orbit, RegistryEvent* ®) |
77 |
throw (YSQLNotConnectedException, YSQLQueryException); |
78 |
|
79 |
static int rootFilesWalker(TSQLServer *conn, const char *dirPath, const char *idRaw) |
80 |
throw (YSQLNotConnectedException, YSQLQueryException); |
81 |
|
82 |
static int insertPamelaRootFiles(TSQLServer *conn, const char *pathName, const char *fileName, const char *idPath) |
83 |
throw (YSQLNotConnectedException, YSQLQueryException); |
84 |
|
85 |
static int insertPamelaTM_HEADER(TSQLServer *conn, const char *idRaw) |
86 |
throw (YSQLNotConnectedException, YSQLQueryException); |
87 |
|
88 |
static int insertPamelaGL_TIMESYNC(TSQLServer *conn, const char *idRaw) |
89 |
throw (YSQLNotConnectedException, YSQLQueryException); |
90 |
|
91 |
static int insertPamelaTM_TIMESYNC(TSQLServer *conn, const char *idRaw) |
92 |
throw (YSQLNotConnectedException, YSQLQueryException); |
93 |
|
94 |
static int deletePamelaDuplicate(TSQLServer *conn, const char *idRaw) |
95 |
throw (YSQLNotConnectedException, YSQLQueryException); |
96 |
|
97 |
static int assignPamelaTIMESYNC(TSQLServer *conn, const char *idRaw) |
98 |
throw (YSQLNotConnectedException, YSQLQueryException); |
99 |
|
100 |
static int insertPamelaPacket(TSQLServer *conn, const char *pathName, const char *eventFileName, const char *headerFileName) |
101 |
throw (YSQLNotConnectedException, YSQLQueryException); |
102 |
|
103 |
static int createPamelaRegistry(TSQLServer *conn, const char *idRaw, bool overwrite) |
104 |
throw (YSQLNotConnectedException, YSQLQueryException, YNotExistingFileException, YExistingFileException); |
105 |
|
106 |
static int insertPamelaRUN(TSQLServer *conn, const char *idRaw) |
107 |
throw (YSQLNotConnectedException, YSQLQueryException, YNotExistingFileException, YEmptyObjectException); |
108 |
|
109 |
static int populateTM_CALO_CALIB(TSQLServer *conn, const char *idRaw) |
110 |
throw (YSQLNotConnectedException, YSQLQueryException, YEmptyObjectException); |
111 |
|
112 |
static int populateTM_S4_CALIB(TSQLServer *conn, const char *idRaw) |
113 |
throw (YSQLNotConnectedException, YSQLQueryException, YEmptyObjectException); |
114 |
|
115 |
static int populateTM_TRK_CALIB(TSQLServer *conn, const char *idRaw) |
116 |
throw (YSQLNotConnectedException, YSQLQueryException, YEmptyObjectException); |
117 |
|
118 |
static int insertNEW_CALO_CALIB(TSQLServer *conn, ULong64_t time, int section, unsigned long reg_ev, unsigned long id_reg, unsigned long tm_id) |
119 |
throw (YSQLNotConnectedException, YSQLQueryException, YEmptyObjectException, YProcessErrorException); |
120 |
|
121 |
static int insertNEW_S4_CALIB(TSQLServer *conn, float paramfit0, float paramfit1, ULong64_t time, unsigned long reg_ev, unsigned long id_reg, unsigned long tm_id) |
122 |
throw (YSQLNotConnectedException, YSQLQueryException, YEmptyObjectException, YProcessErrorException); |
123 |
|
124 |
static int insertNEW_TRK_CALIB(TSQLServer *conn, unsigned long id_reg, unsigned long reg_ev1, unsigned long reg_ev2, ULong64_t time, const char* tm_id1, const char* tm_id2) |
125 |
throw (YSQLNotConnectedException, YSQLQueryException, YEmptyObjectException, YProcessErrorException); |
126 |
|
127 |
public: |
128 |
static const char *PamelaDBOperations::TM_CALO_CALIB; |
129 |
static const char *PamelaDBOperations::TM_S4_CALIB; |
130 |
static const char *PamelaDBOperations::TM_TRK_CALIB; |
131 |
static const char *PamelaDBOperations::TM_REGISTRY; |
132 |
static const char *PamelaDBOperations::TM_HEADER; |
133 |
static const char *PamelaDBOperations::TM_TIMESYNC; |
134 |
|
135 |
static int insertPamelaRootFiles(TSQLServer *conn, const char *pathName, const char *fileName, const char *rawPathName, const char *rawFileName) |
136 |
throw (YSQLNotConnectedException, YSQLQueryException); |
137 |
|
138 |
static bool insertPamelaRawFile(TSQLServer *conn, const char *pathName, const char *fileName) |
139 |
throw (YSQLNotConnectedException, YSQLQueryException, YSQLDuplicateRowException); |
140 |
|
141 |
static int insertPamelaUnpacking(TSQLServer *conn, const char *pathName, const char *rawPathName, const char *rawFileName) |
142 |
throw (YSQLNotConnectedException, YSQLQueryException); |
143 |
|
144 |
static int insertPamelaGL_TIMESYNC(TSQLServer *conn, const char *rawPathName, const char *rawFileName) |
145 |
throw (YSQLNotConnectedException, YSQLQueryException); |
146 |
|
147 |
static int createPamelaRegistry(TSQLServer *conn, const char *rawPathName, const char *rawFileName, bool overwrite) |
148 |
throw (YSQLNotConnectedException, YSQLQueryException, YNotExistingFileException, YExistingFileException); |
149 |
|
150 |
static int insertPamelaRUN(TSQLServer *conn, const char *rawPathName, const char *rawFileName) |
151 |
throw (YSQLNotConnectedException, YSQLQueryException, YNotExistingFileException, YEmptyObjectException); |
152 |
|
153 |
static int assignBOOT_NUMBER(TSQLServer *conn, const char *idRaw) |
154 |
throw (YSQLNotConnectedException, YSQLQueryException); |
155 |
|
156 |
static int assignBOOT_NUMBER(TSQLServer *conn, const char *rawPathName, const char *rawFileName) |
157 |
throw (YSQLNotConnectedException, YSQLQueryException); |
158 |
|
159 |
static int insertNEW_CALO_CALIB(TSQLServer *conn, const char *rawPathName, const char *rawFileName) |
160 |
throw (YSQLNotConnectedException, YSQLQueryException); |
161 |
|
162 |
static int insertNEW_CALO_CALIB(TSQLServer *conn, const char *idRaw) |
163 |
throw (YSQLNotConnectedException, YSQLQueryException); |
164 |
|
165 |
static int insertNEW_S4_CALIB(TSQLServer *conn, const char *rawPathName, const char *rawFileName) |
166 |
throw (YSQLNotConnectedException, YSQLQueryException); |
167 |
|
168 |
static int insertNEW_S4_CALIB(TSQLServer *conn, const char *idRaw) |
169 |
throw (YSQLNotConnectedException, YSQLQueryException); |
170 |
|
171 |
static int insertNEW_TRK_CALIB(TSQLServer *conn, const char *rawPathName, const char *rawFileName) |
172 |
throw (YSQLNotConnectedException, YSQLQueryException); |
173 |
|
174 |
static int insertNEW_TRK_CALIB(TSQLServer *conn, const char *idRaw) |
175 |
throw (YSQLNotConnectedException, YSQLQueryException); |
176 |
}; |
177 |
#endif /* PAMELA_DB_OPERATIONS_H */ |