10 using namespace oracle::occi;
15 m_writeStmt =
nullptr;
27 this->checkConnection();
30 m_writeStmt = m_conn->createStatement();
32 "INSERT INTO mon_pedestal_offsets_dat (iov_id, logic_id, "
33 "dac_g1, dac_g6, dac_g12, task_status) "
34 "VALUES (:iov_id, :logic_id, "
35 ":dac_g1, :dac_g6, :dac_g12, :task_status)");
36 }
catch (SQLException&
e) {
37 throw(std::runtime_error(
"MonPedestalOffsetsDat::prepareWrite(): " + e.getMessage()));
44 this->checkConnection();
47 int iovID = iov->fetchID();
49 throw(std::runtime_error(
"MonPedestalOffsetsDat::writeDB: IOV not in DB"));
52 int logicID = ecid->getLogicID();
54 throw(std::runtime_error(
"MonPedestalOffsetsDat::writeDB: Bad EcalLogicID"));
58 m_writeStmt->setInt(1, iovID);
59 m_writeStmt->setInt(2, logicID);
60 m_writeStmt->setInt(3,
item->getDACG1());
61 m_writeStmt->setInt(4,
item->getDACG6());
62 m_writeStmt->setInt(5,
item->getDACG12());
63 m_writeStmt->setInt(6,
item->getTaskStatus());
65 m_writeStmt->executeUpdate();
66 }
catch (SQLException&
e) {
67 throw(std::runtime_error(
"MonPedestalOffsetsDat::writeDB(): " + e.getMessage()));
74 this->checkConnection();
77 iov->setConnection(m_env, m_conn);
78 int iovID = iov->fetchID();
86 "SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
87 "d.dac_g1, d.dac_g6, d.dac_g12, d.task_status "
88 "FROM channelview cv JOIN mon_pedestal_offsets_dat d "
89 "ON cv.logic_id = d.logic_id AND cv.name = " +
90 mappa +
" WHERE d.iov_id = :iov_id");
91 m_readStmt->setInt(1, iovID);
92 ResultSet* rset = m_readStmt->executeQuery();
94 std::pair<EcalLogicID, MonPedestalOffsetsDat>
p;
96 while (rset->next()) {
112 }
catch (SQLException&
e) {
113 throw(std::runtime_error(
"MonPedestalOffsetsDat::fetchData(): " + e.getMessage()));
119 this->checkConnection();
120 this->checkPrepare();
122 int iovID = iov->fetchID();
124 throw(std::runtime_error(
"MonPedestalOffsetsDat::writeArrayDB: IOV not in DB"));
127 int nrows =
data->size();
128 int* ids =
new int[nrows];
129 int* iovid_vec =
new int[nrows];
130 float* xx =
new float[nrows];
131 float* yy =
new float[nrows];
132 float* zz =
new float[nrows];
133 int* st =
new int[nrows];
135 ub2* ids_len =
new ub2[nrows];
136 ub2* iov_len =
new ub2[nrows];
137 ub2* x_len =
new ub2[nrows];
138 ub2* y_len =
new ub2[nrows];
139 ub2* z_len =
new ub2[nrows];
140 ub2* st_len =
new ub2[nrows];
145 typedef map<EcalLogicID, MonPedestalOffsetsDat>::const_iterator CI;
146 for (CI
p =
data->begin();
p !=
data->end(); ++
p) {
147 channel = &(
p->first);
150 throw(std::runtime_error(
"MonPedestalOffsetsDat::writeArrayDB: Bad EcalLogicID"));
152 ids[
count] = logicID;
153 iovid_vec[
count] = iovID;
155 dataitem = &(
p->second);
179 m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT,
sizeof(iovid_vec[0]), iov_len);
180 m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT,
sizeof(ids[0]), ids_len);
181 m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIFLOAT,
sizeof(xx[0]), x_len);
182 m_writeStmt->setDataBuffer(4, (dvoid*)yy, OCCIFLOAT,
sizeof(yy[0]), y_len);
183 m_writeStmt->setDataBuffer(5, (dvoid*)zz, OCCIFLOAT,
sizeof(zz[0]), z_len);
184 m_writeStmt->setDataBuffer(6, (dvoid*)st, OCCIINT,
sizeof(st[0]), st_len);
186 m_writeStmt->executeArrayUpdate(nrows);
202 }
catch (SQLException&
e) {
203 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
static std::vector< std::string > checklist dat
char data[epos_bytes_allocation]