15 m_writeStmt =
nullptr;
26 this->checkConnection();
29 m_writeStmt = m_conn->createStatement();
31 "INSERT INTO mon_delays_tt_dat (iov_id, logic_id, " 32 "delay_mean, delay_rms, task_status) " 33 "VALUES (:iov_id, :logic_id, " 34 ":delay_mean, :delay_rms, :task_status)");
35 }
catch (SQLException&
e) {
36 throw(std::runtime_error(
"MonDelaysTTDat::prepareWrite(): " + e.getMessage()));
41 this->checkConnection();
44 int iovID = iov->fetchID();
46 throw(std::runtime_error(
"MonDelaysTTDat::writeDB: IOV not in DB"));
49 int logicID = ecid->getLogicID();
51 throw(std::runtime_error(
"MonDelaysTTDat::writeDB: Bad EcalLogicID"));
55 m_writeStmt->setInt(1, iovID);
56 m_writeStmt->setInt(2, logicID);
58 m_writeStmt->setFloat(3,
item->getDelayMean());
59 m_writeStmt->setFloat(4,
item->getDelayRMS());
60 m_writeStmt->setInt(5,
item->getTaskStatus());
62 m_writeStmt->executeUpdate();
63 }
catch (SQLException&
e) {
64 throw(std::runtime_error(
"MonDelaysTTDat::writeDB(): " + e.getMessage()));
69 this->checkConnection();
72 iov->setConnection(m_env, m_conn);
73 int iovID = iov->fetchID();
81 "SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, " 82 "d.delay_mean, d.delay_rms, d.task_status " 83 "FROM channelview cv JOIN mon_delays_tt_dat d " 84 "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to " 85 "WHERE d.iov_id = :iov_id");
86 m_readStmt->setInt(1, iovID);
87 ResultSet* rset = m_readStmt->executeQuery();
89 std::pair<EcalLogicID, MonDelaysTTDat>
p;
91 while (rset->next()) {
106 }
catch (SQLException&
e) {
107 throw(std::runtime_error(
"MonDelaysTTDat::fetchData(): " + e.getMessage()));
112 this->checkConnection();
113 this->checkPrepare();
115 int iovID = iov->fetchID();
117 throw(std::runtime_error(
"MonDelaysTTDat::writeArrayDB: IOV not in DB"));
120 int nrows =
data->size();
121 int*
ids =
new int[nrows];
122 int* iovid_vec =
new int[nrows];
123 float*
xx =
new float[nrows];
124 float*
yy =
new float[nrows];
125 int* st =
new int[nrows];
127 ub2* ids_len =
new ub2[nrows];
128 ub2* iov_len =
new ub2[nrows];
129 ub2* x_len =
new ub2[nrows];
130 ub2* y_len =
new ub2[nrows];
131 ub2* st_len =
new ub2[nrows];
136 typedef map<EcalLogicID, MonDelaysTTDat>::const_iterator CI;
137 for (CI
p =
data->begin();
p !=
data->end(); ++
p) {
138 channel = &(
p->first);
141 throw(std::runtime_error(
"MonDelaysTTDat::writeArrayDB: Bad EcalLogicID"));
143 ids[
count] = logicID;
144 iovid_vec[
count] = iovID;
146 dataitem = &(
p->second);
167 m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT,
sizeof(iovid_vec[0]), iov_len);
168 m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT,
sizeof(ids[0]), ids_len);
169 m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIFLOAT,
sizeof(xx[0]), x_len);
170 m_writeStmt->setDataBuffer(4, (dvoid*)yy, OCCIFLOAT,
sizeof(yy[0]), y_len);
171 m_writeStmt->setDataBuffer(5, (dvoid*)st, OCCIINT,
sizeof(st[0]), st_len);
173 m_writeStmt->executeArrayUpdate(nrows);
187 }
catch (SQLException&
e) {
188 throw(std::runtime_error(
"MonDelaysTTDat::writeArrayDB(): " + e.getMessage()));
void fetchData(std::map< EcalLogicID, MonDelaysTTDat > *fillVec, MonRunIOV *iov) noexcept(false)
~MonDelaysTTDat() override
void setDelayRMS(float rms)
float getDelayRMS() const
void setTaskStatus(bool status)
bool getTaskStatus() const
float getDelayMean() const
void writeArrayDB(const std::map< EcalLogicID, MonDelaysTTDat > *data, MonRunIOV *iov) noexcept(false)
char data[epos_bytes_allocation]
void writeDB(const EcalLogicID *ecid, const MonDelaysTTDat *item, MonRunIOV *iov) noexcept(false)
void prepareWrite() noexcept(false) override
void setDelayMean(float mean)