16 m_writeStmt =
nullptr;
34 this->checkConnection();
37 m_writeStmt = m_conn->createStatement();
38 m_writeStmt->setSQL(
"INSERT INTO dcu_capsule_temp_raw_dat (iov_id, logic_id, " 39 "capsule_temp_adc, capsule_temp_rms) " 40 "VALUES (:iov_id, :logic_id, " 42 }
catch (SQLException &
e) {
43 throw(std::runtime_error(
std::string(
"DCUCapsuleTempRawDat::prepareWrite(): ")+getOraMessage(&e)));
52 this->checkConnection();
55 int iovID = iov->fetchID();
56 if (!iovID) {
throw(std::runtime_error(
"DCUCapsuleTempRawDat::writeDB: IOV not in DB")); }
58 int logicID = ecid->getLogicID();
59 if (!logicID) {
throw(std::runtime_error(
"DCUCapsuleTempRawDat::writeDB: Bad EcalLogicID")); }
62 m_writeStmt->setInt(1, iovID);
63 m_writeStmt->setInt(2, logicID);
65 m_writeStmt->setFloat(3, item->getCapsuleTempADC() );
66 m_writeStmt->setFloat(4, item->getCapsuleTempRMS() );
68 m_writeStmt->executeUpdate();
69 }
catch (SQLException &
e) {
70 throw(std::runtime_error(
std::string(
"DCUCapsuleTempRawDat::writeDB(): ")+getOraMessage(&e)));
79 this->checkConnection();
82 iov->setConnection(m_env, m_conn);
83 int iovID = iov->fetchID();
91 m_readStmt->setSQL(
"SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, " 92 "d.capsule_temp_adc, d.capsule_temp_rms " 93 "FROM channelview cv JOIN dcu_capsule_temp_raw_dat d " 94 "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to " 95 "WHERE d.iov_id = :iov_id");
96 m_readStmt->setInt(1, iovID);
97 ResultSet* rset = m_readStmt->executeQuery();
99 std::pair< EcalLogicID, DCUCapsuleTempRawDat >
p;
101 while(rset->next()) {
107 getOraString(rset,6));
115 }
catch (SQLException &
e) {
116 throw(std::runtime_error(
std::string(
"DCUCapsuleTempRawDat::fetchData(): ")+getOraMessage(&e)));
123 this->checkConnection();
124 this->checkPrepare();
126 int iovID = iov->fetchID();
127 if (!iovID) {
throw(std::runtime_error(
"DCUCapsuleTempRawDat::writeArrayDB: IOV not in DB")); }
130 int nrows=
data->size();
131 int*
ids=
new int[nrows];
132 int* iovid_vec=
new int[nrows];
133 float*
xx=
new float[nrows];
134 float*
yy=
new float[nrows];
136 ub2* ids_len=
new ub2[nrows];
137 ub2* iov_len=
new ub2[nrows];
138 ub2* x_len=
new ub2[nrows];
139 ub2* y_len=
new ub2[nrows];
145 typedef map< EcalLogicID, DCUCapsuleTempRawDat >::const_iterator CI;
146 for (CI
p =
data->begin();
p !=
data->end(); ++
p) {
147 channel = &(
p->first);
149 if (!logicID) {
throw(std::runtime_error(
"DCUCapsuleTempRawDat::writeArrayDB: Bad EcalLogicID")); }
151 iovid_vec[
count]=iovID;
153 dataitem = &(
p->second);
173 m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT,
sizeof(iovid_vec[0]),iov_len);
174 m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT,
sizeof(ids[0]), ids_len );
175 m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIFLOAT ,
sizeof(xx[0]), x_len );
176 m_writeStmt->setDataBuffer(4, (dvoid*)yy, OCCIFLOAT ,
sizeof(yy[0]), y_len );
179 m_writeStmt->executeArrayUpdate(nrows);
191 }
catch (SQLException &
e) {
192 throw(std::runtime_error(
std::string(
"DCUCapsuleTempRawDat::writeArrayDB(): ")+getOraMessage(&e)));
float getCapsuleTempADC() const
void writeDB(const EcalLogicID *ecid, const DCUCapsuleTempRawDat *item, DCUIOV *iov) noexcept(false)
float getCapsuleTempRMS() const
void prepareWrite() noexcept(false) override
void writeArrayDB(const std::map< EcalLogicID, DCUCapsuleTempRawDat > *data, DCUIOV *iov) noexcept(false)
void fetchData(std::map< EcalLogicID, DCUCapsuleTempRawDat > *fillVec, DCUIOV *iov) noexcept(false)
~DCUCapsuleTempRawDat() override
char data[epos_bytes_allocation]
void setCapsuleTempADC(float adc)
void setCapsuleTempRMS(float rms)