CMS 3D CMS Logo

DCSPTMTempList.cc
Go to the documentation of this file.
1 #include <stdexcept>
3 
10 
11 using namespace std;
12 using namespace oracle::occi;
13 
14 DCSPTMTempList::DCSPTMTempList() { m_conn = nullptr; }
15 
17 
18 std::vector<DCSPTMTemp> DCSPTMTempList::getList() { return m_vec_temp; }
19 
21  this->checkConnection();
22  int nruns = 0;
23 
24  int ecid_id = ecid.getLogicID();
25 
26  try {
27  Statement* stmt0 = m_conn->createStatement();
28  stmt0->setSQL(
29  "SELECT count(since) FROM PVSS_TEMPERATURE_DAT "
30  "WHERE logic_id = :logic_id ");
31  stmt0->setInt(1, ecid_id);
32 
33  ResultSet* rset0 = stmt0->executeQuery();
34  if (rset0->next()) {
35  nruns = rset0->getInt(1);
36  }
37  m_conn->terminateStatement(stmt0);
38 
39  cout << "DCSPTMTempList::fetchValuesForECID>> Number of records in DB=" << nruns << endl;
40  m_vec_temp.reserve(nruns);
41 
42  Statement* stmt = m_conn->createStatement();
43  stmt->setSQL(
44  "SELECT "
45  "since, till, temperature FROM PVSS_TEMPERATURE_DAT "
46  "WHERE logic_id = :logic_id order by since ");
47  stmt->setInt(1, ecid_id);
48 
49  DateHandler dh(m_env, m_conn);
50  Tm runStart;
51  Tm runEnd;
52 
53  ResultSet* rset = stmt->executeQuery();
54  int i = 0;
55  while (i < nruns) {
56  rset->next();
57 
58  Date startDate = rset->getDate(1);
59  Date endDate = rset->getDate(2);
60  float x = rset->getFloat(3);
61  runStart = dh.dateToTm(startDate);
62  runEnd = dh.dateToTm(endDate);
63 
64  DCSPTMTemp r;
65  r.setTemperature(x);
66  r.setStart(runStart);
67  r.setEnd(runEnd);
68  r.setEcalLogicID(ecid);
69  m_vec_temp.push_back(r);
70 
71  i++;
72  }
73 
74  cout << "DCSPTMTempList::fetchValuesForECID>> loop done " << endl;
75 
76  m_conn->terminateStatement(stmt);
77  } catch (SQLException& e) {
78  throw(std::runtime_error("DCSPTMTempList: " + e.getMessage()));
79  }
80 }
81 
83  const Tm& start,
84  const Tm& end) noexcept(false) {
85  this->checkConnection();
86  int nruns = 0;
87 
88  int ecid_id = ecid.getLogicID();
89 
90  DateHandler dh(m_env, m_conn);
91  Tm runStart;
92  Tm runEnd;
93 
94  try {
95  Statement* stmt0 = m_conn->createStatement();
96  stmt0->setSQL(
97  "SELECT count(since) FROM PVSS_TEMPERATURE_DAT "
98  "WHERE logic_id = :logic_id "
99  "AND since >= :start_time "
100  "AND since <= :till_time ");
101  stmt0->setInt(1, ecid_id);
102  stmt0->setDate(2, dh.tmToDate(start));
103  stmt0->setDate(3, dh.tmToDate(end));
104 
105  ResultSet* rset0 = stmt0->executeQuery();
106  if (rset0->next()) {
107  nruns = rset0->getInt(1);
108  }
109  m_conn->terminateStatement(stmt0);
110 
111  cout << "DCSPTMTempList::fetchValuesForECIDAndTime>> Number of records in DB=" << nruns << endl;
112  m_vec_temp.reserve(nruns);
113 
114  Statement* stmt = m_conn->createStatement();
115  stmt->setSQL(
116  "SELECT "
117  "since, till, temperature FROM PVSS_TEMPERATURE_DAT "
118  "WHERE logic_id = :logic_id "
119  "AND since >= :start_time "
120  "AND since <= :till_time "
121  " order by since ");
122  stmt->setInt(1, ecid_id);
123  stmt->setDate(2, dh.tmToDate(start));
124  stmt->setDate(3, dh.tmToDate(end));
125 
126  ResultSet* rset = stmt->executeQuery();
127  int i = 0;
128  while (i < nruns) {
129  rset->next();
130 
131  Date startDate = rset->getDate(1);
132  Date endDate = rset->getDate(2);
133  float x = rset->getFloat(3);
134  runStart = dh.dateToTm(startDate);
135  runEnd = dh.dateToTm(endDate);
136 
137  DCSPTMTemp r;
138  r.setTemperature(x);
139  r.setStart(runStart);
140  r.setEnd(runEnd);
141  r.setEcalLogicID(ecid);
142  m_vec_temp.push_back(r);
143 
144  i++;
145  }
146 
147  m_conn->terminateStatement(stmt);
148  } catch (SQLException& e) {
149  throw(std::runtime_error("DCSPTMTempList: " + e.getMessage()));
150  }
151 }
void setEnd(const Tm &end)
Definition: DCSPTMTemp.cc:32
Definition: start.py:1
void setEcalLogicID(const EcalLogicID &ecid)
Definition: DCSPTMTemp.cc:47
void setTemperature(float temp)
Definition: DCSPTMTemp.cc:43
void fetchValuesForECID(const EcalLogicID &ecid) noexcept(false)
#define end
Definition: vmac.h:39
oracle::occi::Date tmToDate(const Tm &inTm) const
Definition: DateHandler.cc:19
~DCSPTMTempList() override
#define noexcept
std::vector< DCSPTMTemp > getList()
dh
Definition: cuy.py:355
Tm dateToTm(oracle::occi::Date &date) const
Definition: DateHandler.cc:28
Definition: Tm.h:13
void fetchValuesForECIDAndTime(const EcalLogicID &ecid, const Tm &start, const Tm &end) noexcept(false)
void setStart(const Tm &start)
Definition: DCSPTMTemp.cc:23