16 m_writeStmt =
nullptr;
40 this->checkConnection();
43 m_writeStmt = m_conn->createStatement();
44 m_writeStmt->setSQL(
"INSERT INTO dcu_ccs_dat (iov_id, logic_id, " 45 "m1_vdd1, m2_vdd1, m1_vdd2, m2_vdd2, m1_vinj, " 46 "m2_vinj, m1_vcc, m2_vcc, m1_dcutemp, m2_dcutemp, " 47 "ccstemplow, ccstemphigh) " 48 "VALUES (:iov_id, :logic_id, " 49 ":m1_vdd1, :m2_vdd1, :m1_vdd2, :m2_vdd2, :m1_vinj, " 50 ":m2_vinj, :m1_vcc, :m2_vcc, :m1_dcutemp, " 51 ":m2_dcutemp, :ccstemplow, :ccstemphigh)");
52 }
catch (SQLException &
e) {
53 throw(std::runtime_error(
"DCUCCSDat::prepareWrite(): " +
64 this->checkConnection();
67 int iovID = iov->fetchID();
69 throw(std::runtime_error(
"DCUCCSDat::writeDB: IOV not in DB"));
72 int logicID = ecid->getLogicID();
74 throw(std::runtime_error(
"DCUCCSDat::writeDB: Bad EcalLogicID"));
78 m_writeStmt->setInt(1, iovID);
79 m_writeStmt->setInt(2, logicID);
81 m_writeStmt->setFloat( 3, item->getM1VDD1() );
82 m_writeStmt->setFloat( 4, item->getM2VDD1() );
83 m_writeStmt->setFloat( 5, item->getM1VDD2() );
84 m_writeStmt->setFloat( 6, item->getM2VDD2() );
85 m_writeStmt->setFloat( 7, item->getM1Vinj() );
86 m_writeStmt->setFloat( 8, item->getM2Vinj() );
87 m_writeStmt->setFloat( 9, item->getM1Vcc() );
88 m_writeStmt->setFloat(10, item->getM2Vcc() );
89 m_writeStmt->setFloat(11, item->getM1DCUTemp() );
90 m_writeStmt->setFloat(12, item->getM2DCUTemp() );
91 m_writeStmt->setFloat(13, item->getCCSTempLow() );
92 m_writeStmt->setFloat(14, item->getCCSTempHigh() );
94 m_writeStmt->executeUpdate();
95 }
catch (SQLException &
e) {
96 throw(std::runtime_error(
"DCUCCSDat::writeDB(): " + e.getMessage()));
104 this->checkConnection();
107 iov->setConnection(m_env, m_conn);
108 int iovID = iov->fetchID();
116 m_readStmt->setSQL(
"SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, " 118 "d.m1_vdd1, d.m2_vdd1, d.m1_vdd2, d.m2_vdd2, " 119 "d.m1_vinj, d.m2_vinj, " 120 "d.m1_vcc, d.m2_vcc, " 121 "d.m1_dcutemp, d.m2_dcutemp, " 122 "d.ccstemplow, d.ccstemphigh " 123 "FROM channelview cv JOIN dcu_ccs_dat d " 124 "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to " 125 "WHERE d.iov_id = :iov_id");
126 m_readStmt->setInt(1, iovID);
127 ResultSet* rset = m_readStmt->executeQuery();
129 std::pair< EcalLogicID, DCUCCSDat >
p;
131 while(rset->next()) {
139 dat.
setVDD(rset->getFloat(7), rset->getFloat(9), rset->getFloat(8),
141 dat.
setVinj(rset->getFloat(11), rset->getFloat(12));
142 dat.
setVcc(rset->getFloat(13), rset->getFloat(14));
143 dat.
setDCUTemp(rset->getFloat(15), rset->getFloat(16));
144 dat.
setCCSTemp(rset->getFloat(17), rset->getFloat(18));
148 }
catch (SQLException &
e) {
149 throw(std::runtime_error(
"DCUCCSDat::fetchData(): "+e.getMessage()));
156 this->checkConnection();
157 this->checkPrepare();
159 int iovID = iov->fetchID();
161 throw(std::runtime_error(
"DCUCCSDat::writeArrayDB: IOV not in DB"));
164 int nrows=
data->size();
165 int* ids=
new int[nrows];
166 int* iovid_vec=
new int[nrows];
167 float*
x1=
new float[nrows];
168 float*
x2=
new float[nrows];
169 float* x3=
new float[nrows];
170 float* x4=
new float[nrows];
171 float* x5=
new float[nrows];
172 float* x6=
new float[nrows];
173 float* x7=
new float[nrows];
174 float* x8=
new float[nrows];
175 float* x9=
new float[nrows];
176 float* xa=
new float[nrows];
177 float* xb=
new float[nrows];
178 float* xc=
new float[nrows];
180 ub2* ids_len=
new ub2[nrows];
181 ub2* iov_len=
new ub2[nrows];
182 ub2* x_len =
new ub2[nrows];
187 typedef map< EcalLogicID, DCUCCSDat >::const_iterator CI;
188 for (CI
p =
data->begin();
p !=
data->end(); ++
p) {
189 channel = &(
p->first);
192 throw(std::runtime_error(
"DCUCCSDat::writeArrayDB: Bad EcalLogicID"));
195 iovid_vec[
count]=iovID;
197 dataitem = &(
p->second);
222 m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT,
223 sizeof(iovid_vec[0]),iov_len);
224 m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT,
225 sizeof(ids[0]), ids_len );
226 m_writeStmt->setDataBuffer(3, (dvoid*)x1, OCCIFLOAT ,
227 sizeof(x1[0]), x_len );
228 m_writeStmt->setDataBuffer(3, (dvoid*)x2, OCCIFLOAT ,
229 sizeof(x1[0]), x_len );
230 m_writeStmt->setDataBuffer(3, (dvoid*)x3, OCCIFLOAT ,
231 sizeof(x1[0]), x_len );
232 m_writeStmt->setDataBuffer(3, (dvoid*)x4, OCCIFLOAT ,
233 sizeof(x1[0]), x_len );
234 m_writeStmt->setDataBuffer(3, (dvoid*)x5, OCCIFLOAT ,
235 sizeof(x1[0]), x_len );
236 m_writeStmt->setDataBuffer(3, (dvoid*)x6, OCCIFLOAT ,
237 sizeof(x1[0]), x_len );
238 m_writeStmt->setDataBuffer(3, (dvoid*)x7, OCCIFLOAT ,
239 sizeof(x1[0]), x_len );
240 m_writeStmt->setDataBuffer(3, (dvoid*)x8, OCCIFLOAT ,
241 sizeof(x1[0]), x_len );
242 m_writeStmt->setDataBuffer(3, (dvoid*)x9, OCCIFLOAT ,
243 sizeof(x1[0]), x_len );
244 m_writeStmt->setDataBuffer(3, (dvoid*)xa, OCCIFLOAT ,
245 sizeof(x1[0]), x_len );
246 m_writeStmt->setDataBuffer(3, (dvoid*)xb, OCCIFLOAT ,
247 sizeof(x1[0]), x_len );
248 m_writeStmt->setDataBuffer(3, (dvoid*)xc, OCCIFLOAT ,
249 sizeof(x1[0]), x_len );
251 m_writeStmt->executeArrayUpdate(nrows);
273 }
catch (SQLException &
e) {
274 throw(std::runtime_error(
"DCUCCSDat::writeArrayDB(): " + e.getMessage()));
void setVinj(float v1, float v2)
void setVDD(float m1vdd1, float m1vdd2, float m2vdd1, float m2vdd2)
float getM2DCUTemp() const
float getM1DCUTemp() const
void writeDB(const EcalLogicID *ecid, const DCUCCSDat *item, DCUIOV *iov) noexcept(false)
void writeArrayDB(const std::map< EcalLogicID, DCUCCSDat > *data, DCUIOV *iov) noexcept(false)
void setCCSTemp(float low, float high)
void setVcc(float v1, float v2)
void setDCUTemp(float t1, float t2)
char data[epos_bytes_allocation]
float getCCSTempLow() const
float getCCSTempHigh() const
void prepareWrite() noexcept(false) override
void fetchData(std::map< EcalLogicID, DCUCCSDat > *fillVec, DCUIOV *iov) noexcept(false)