16 m_writeStmt =
nullptr;
36 this->checkConnection();
39 m_writeStmt = m_conn->createStatement();
40 m_writeStmt->setSQL(
"INSERT INTO mon_pedestal_offsets_dat (iov_id, logic_id, " 41 "dac_g1, dac_g6, dac_g12, task_status) " 42 "VALUES (:iov_id, :logic_id, " 43 ":dac_g1, :dac_g6, :dac_g12, :task_status)");
44 }
catch (SQLException &
e) {
45 throw(std::runtime_error(
"MonPedestalOffsetsDat::prepareWrite(): "+e.getMessage()));
54 this->checkConnection();
57 int iovID = iov->fetchID();
58 if (!iovID) {
throw(std::runtime_error(
"MonPedestalOffsetsDat::writeDB: IOV not in DB")); }
60 int logicID = ecid->getLogicID();
61 if (!logicID) {
throw(std::runtime_error(
"MonPedestalOffsetsDat::writeDB: Bad EcalLogicID")); }
64 m_writeStmt->setInt(1, iovID);
65 m_writeStmt->setInt(2, logicID);
66 m_writeStmt->setInt(3, item->getDACG1() );
67 m_writeStmt->setInt(4, item->getDACG6() );
68 m_writeStmt->setInt(5, item->getDACG12() );
69 m_writeStmt->setInt(6, item->getTaskStatus() );
71 m_writeStmt->executeUpdate();
72 }
catch (SQLException &
e) {
73 throw(std::runtime_error(
"MonPedestalOffsetsDat::writeDB(): "+e.getMessage()));
81 this->checkConnection();
84 iov->setConnection(m_env, m_conn);
85 int iovID = iov->fetchID();
93 m_readStmt->setSQL(
"SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, " 94 "d.dac_g1, d.dac_g6, d.dac_g12, d.task_status " 95 "FROM channelview cv JOIN mon_pedestal_offsets_dat d " 96 "ON cv.logic_id = d.logic_id AND cv.name = " + mappa +
97 " WHERE d.iov_id = :iov_id");
98 m_readStmt->setInt(1, iovID);
99 ResultSet* rset = m_readStmt->executeQuery();
101 std::pair< EcalLogicID, MonPedestalOffsetsDat >
p;
103 while(rset->next()) {
119 }
catch (SQLException &
e) {
120 throw(std::runtime_error(
"MonPedestalOffsetsDat::fetchData(): "+e.getMessage()));
127 this->checkConnection();
128 this->checkPrepare();
130 int iovID = iov->fetchID();
131 if (!iovID) {
throw(std::runtime_error(
"MonPedestalOffsetsDat::writeArrayDB: IOV not in DB")); }
134 int nrows=
data->size();
135 int* ids=
new int[nrows];
136 int* iovid_vec=
new int[nrows];
137 float*
xx=
new float[nrows];
138 float*
yy=
new float[nrows];
139 float*
zz=
new float[nrows];
140 int* st=
new int[nrows];
142 ub2* ids_len=
new ub2[nrows];
143 ub2* iov_len=
new ub2[nrows];
144 ub2* x_len=
new ub2[nrows];
145 ub2* y_len=
new ub2[nrows];
146 ub2* z_len=
new ub2[nrows];
147 ub2* st_len=
new ub2[nrows];
152 typedef map< EcalLogicID, MonPedestalOffsetsDat >::const_iterator CI;
153 for (CI
p =
data->begin();
p !=
data->end(); ++
p) {
154 channel = &(
p->first);
156 if (!logicID) {
throw(std::runtime_error(
"MonPedestalOffsetsDat::writeArrayDB: Bad EcalLogicID")); }
158 iovid_vec[
count]=iovID;
160 dataitem = &(
p->second);
188 m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT,
sizeof(iovid_vec[0]),iov_len);
189 m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT,
sizeof(ids[0]), ids_len );
190 m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIFLOAT ,
sizeof(xx[0]), x_len );
191 m_writeStmt->setDataBuffer(4, (dvoid*)yy, OCCIFLOAT ,
sizeof(yy[0]), y_len );
192 m_writeStmt->setDataBuffer(5, (dvoid*)zz, OCCIFLOAT ,
sizeof(zz[0]), z_len );
193 m_writeStmt->setDataBuffer(6, (dvoid*)st, OCCIINT ,
sizeof(st[0]), st_len );
196 m_writeStmt->executeArrayUpdate(nrows);
213 }
catch (SQLException &
e) {
214 throw(std::runtime_error(
"MonPedestalOffsetsDat::writeArrayDB(): "+e.getMessage()));
void setTaskStatus(bool status)
void writeArrayDB(const std::map< EcalLogicID, MonPedestalOffsetsDat > *data, MonRunIOV *iov) noexcept(false)
void writeDB(const EcalLogicID *ecid, const MonPedestalOffsetsDat *item, MonRunIOV *iov) noexcept(false)
bool getTaskStatus() const
void fetchData(std::map< EcalLogicID, MonPedestalOffsetsDat > *fillMap, MonRunIOV *iov, std::string mappa=" cv.maps_to ") noexcept(false)
void prepareWrite() noexcept(false) override
~MonPedestalOffsetsDat() override
char data[epos_bytes_allocation]