13 m_writeStmt =
nullptr;
26 this->checkConnection();
29 m_writeStmt = m_conn->createStatement();
31 "INSERT INTO mon_led1_dat (iov_id, logic_id, " 32 "vpt_mean, vpt_rms, vpt_over_pn_mean, vpt_over_pn_rms, task_status) " 33 "VALUES (:iov_id, :logic_id, " 34 ":vpt_mean, :vpt_rms, :vpt_over_pn_mean, :vpt_over_pn_rms, :task_status)");
35 }
catch (SQLException&
e) {
36 throw(std::runtime_error(
"MonLed1Dat::prepareWrite(): " + e.getMessage()));
41 this->checkConnection();
44 int iovID = iov->fetchID();
46 throw(std::runtime_error(
"MonLed1Dat::writeDB: IOV not in DB"));
49 int logicID = ecid->getLogicID();
51 throw(std::runtime_error(
"MonLed1Dat::writeDB: Bad EcalLogicID"));
55 m_writeStmt->setInt(1, iovID);
56 m_writeStmt->setInt(2, logicID);
58 m_writeStmt->setFloat(3,
item->getVPTMean());
59 m_writeStmt->setFloat(4,
item->getVPTRMS());
60 m_writeStmt->setFloat(5,
item->getVPTOverPNMean());
61 m_writeStmt->setFloat(6,
item->getVPTOverPNRMS());
62 m_writeStmt->setInt(7,
item->getTaskStatus());
64 m_writeStmt->executeUpdate();
65 }
catch (SQLException&
e) {
66 throw(std::runtime_error(
"MonLed1Dat::writeDB(): " + e.getMessage()));
71 this->checkConnection();
75 iov->setConnection(m_env, m_conn);
76 int iovID = iov->fetchID();
84 "SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, " 85 "d.vpt_mean, d.vpt_rms, d.vpt_over_pn_mean, d.vpt_over_pn_rms, d.task_status " 86 "FROM channelview cv JOIN mon_led1_dat d " 87 "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to " 88 "WHERE d.iov_id = :iov_id");
89 m_readStmt->setInt(1, iovID);
90 ResultSet* rset = m_readStmt->executeQuery();
92 std::pair<EcalLogicID, MonLed1Dat>
p;
94 while (rset->next()) {
111 }
catch (SQLException&
e) {
112 throw(std::runtime_error(
"MonLed1Dat::fetchData(): " + e.getMessage()));
117 this->checkConnection();
118 this->checkPrepare();
120 int iovID = iov->fetchID();
122 throw(std::runtime_error(
"MonLed1Dat::writeArrayDB: IOV not in DB"));
125 int nrows =
data->size();
126 int*
ids =
new int[nrows];
127 int* iovid_vec =
new int[nrows];
128 float*
xx =
new float[nrows];
129 float*
yy =
new float[nrows];
130 float*
zz =
new float[nrows];
131 float* ww =
new float[nrows];
132 int* st =
new int[nrows];
134 ub2* ids_len =
new ub2[nrows];
135 ub2* iov_len =
new ub2[nrows];
136 ub2* x_len =
new ub2[nrows];
137 ub2* y_len =
new ub2[nrows];
138 ub2* z_len =
new ub2[nrows];
139 ub2* w_len =
new ub2[nrows];
140 ub2* st_len =
new ub2[nrows];
145 typedef map<EcalLogicID, MonLed1Dat>::const_iterator CI;
146 for (CI
p =
data->begin();
p !=
data->end(); ++
p) {
147 channel = &(
p->first);
150 throw(std::runtime_error(
"MonLed1Dat::writeArrayDB: Bad EcalLogicID"));
152 ids[
count] = logicID;
153 iovid_vec[
count] = iovID;
155 dataitem = &(
p->second);
182 m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT,
sizeof(iovid_vec[0]), iov_len);
183 m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT,
sizeof(ids[0]), ids_len);
184 m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIFLOAT,
sizeof(xx[0]), x_len);
185 m_writeStmt->setDataBuffer(4, (dvoid*)yy, OCCIFLOAT,
sizeof(yy[0]), y_len);
186 m_writeStmt->setDataBuffer(5, (dvoid*)zz, OCCIFLOAT,
sizeof(zz[0]), z_len);
187 m_writeStmt->setDataBuffer(6, (dvoid*)ww, OCCIFLOAT,
sizeof(ww[0]), w_len);
188 m_writeStmt->setDataBuffer(7, (dvoid*)st, OCCIINT,
sizeof(st[0]), st_len);
190 m_writeStmt->executeArrayUpdate(nrows);
208 }
catch (SQLException&
e) {
209 throw(std::runtime_error(
"MonLed1Dat::writeArrayDB(): " + e.getMessage()));
bool getTaskStatus() const
float getVPTOverPNRMS() const
float getVPTOverPNMean() const
void prepareWrite() noexcept(false) override
void writeDB(const EcalLogicID *ecid, const MonLed1Dat *item, MonRunIOV *iov) noexcept(false)
void setVPTOverPNMean(float mean)
void setTaskStatus(bool status)
void writeArrayDB(const std::map< EcalLogicID, MonLed1Dat > *data, MonRunIOV *iov) noexcept(false)
void setVPTRMS(float rms)
char data[epos_bytes_allocation]
void fetchData(std::map< EcalLogicID, MonLed1Dat > *fillMap, MonRunIOV *iov) noexcept(false)
void setVPTMean(float mean)
void setVPTOverPNRMS(float rms)