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