CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RunDCSMagnetDat.cc
Go to the documentation of this file.
1 #include <stdexcept>
2 #include <string>
3 #include <math.h>
4 #include <list>
5 #include <string>
6 #include <map>
7 
11 
12 using namespace std;
13 using namespace oracle::occi;
14 
16 {
17  m_env = NULL;
18  m_conn = NULL;
19  m_writeStmt = NULL;
20  m_readStmt = NULL;
21 
22  m_current = 0;
23  m_time=Tm();
24 }
25 
26 
27 
29 {
30 }
31 
33 {
34  m_time = start;
35 }
36 
38 {
39  return m_time;
40 }
41 
42 
43 
44 
45 
47  throw(std::runtime_error)
48 {
49 
50 
51 }
52 
53 
54 
56  throw(std::runtime_error)
57 {
58 }
59 
60 
61 
62 void RunDCSMagnetDat::fetchData(map< EcalLogicID, RunDCSMagnetDat >* fillMap, RunIOV* iov)
63  throw(std::runtime_error)
64 {
65 
66  std::cout<<"going to call fetchLastData"<<std::endl;
67  fetchLastData(fillMap);
68  std::cout<<"returned from fetchLastData"<<std::endl;
69 
70 }
71 
72 
74 
75  DateHandler dh(m_env, m_conn);
76 
77  ResultSet* rset = NULL;
78  string query="SELECT c.name, c.logic_id, c.id1, c.id2, c.id3, c.maps_to , v.value_number, v.change_date from "+ getMagnetAccount()+
79  ".CMSFWMAGNET_LV v, channelview c where v.dpe_name= 'CURRENT' and c.name=maps_to and c.name='EB' " ;
80  try {
81 
82  std::cout<<"query:"<<query<<std::endl;
83 
84  m_readStmt->setSQL(query);
85  rset = m_readStmt->executeQuery();
86  }
87  catch (SQLException e) {
88  throw(std::runtime_error("RunDCSMagnetDat::getBarrelRset(): " + e.getMessage() + " " + query));
89  }
90  return rset;
91 }
92 
93 
94 
96  map< EcalLogicID, RunDCSMagnetDat >* fillMap) {
97 
98  // method for last value queries
99 
100  std::pair< EcalLogicID, RunDCSMagnetDat > p;
101  RunDCSMagnetDat dat;
102  DateHandler dh(m_env, m_conn);
103 
104  try {
105  while(rset->next()) {
106  p.first = EcalLogicID( rset->getString(1), // name
107  rset->getInt(2), // logic_id
108  rset->getInt(3), // id1
109  rset->getInt(4), // id2
110  rset->getInt(5), // id3
111  rset->getString(6)); // maps_to
112 
113  std::cout<<"done the logic id"<<std::endl;
114  dat.setMagnetCurrent( rset->getFloat(7) );
115  std::cout<<"done the magnet current"<<std::endl;
116 
117  Date sinceDate = rset->getDate(8);
118  std::cout<<"done the date"<<std::endl;
119 
120  Tm sinceTm = dh.dateToTm( sinceDate );
121  dat.setTime(sinceTm);
122 
123  p.second = dat;
124  fillMap->insert(p);
125  }
126  }
127  catch (SQLException &e) {
128  throw(std::runtime_error("RunDCSMagnetDat::fetchData(): "+e.getMessage()));
129  }
130 }
131 
132 
133 
134 
136  Tm t_now_gmt;
137 
138  t_now_gmt.setToCurrentGMTime();
139  int t_now_gmt_micros = t_now_gmt.microsTime();
140  return t_now_gmt_micros;
141 }
142 
143 
144 
145 void RunDCSMagnetDat::fetchLastData(map< EcalLogicID, RunDCSMagnetDat >* fillMap )
146  throw(std::runtime_error)
147 {
148  this->checkConnection();
149 
150  std::cout<<"fetchLastData>>1"<<std::endl;
151 
152  fillMap->clear();
153 
154  std::cout<<"fetchLastData>>2"<<std::endl;
155 
156 
157  try {
158  std::pair< EcalLogicID, RunDCSMagnetDat > p;
159  RunDCSMagnetDat dat;
160  std::cout<<"fetchLastData>>3"<<std::endl;
161 
162  ResultSet* rset = getMagnetRset();
163 
164  std::cout<<"fetchLastData>>4"<<std::endl;
165 
166  fillTheMap(rset, fillMap);
167  std::cout<<"fetchLastData>>5"<<std::endl;
168 
169 
170  }
171  catch (SQLException &e) {
172  throw(std::runtime_error("RunDCSMagnetDat::fetchData(): "+e.getMessage()));
173  }
174 }
175 
#define NULL
Definition: scimark2.h:8
void writeDB(const EcalLogicID *ecid, const RunDCSMagnetDat *item, RunIOV *iov)
void setToCurrentGMTime()
Definition: Tm.cc:177
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
uint64_t microsTime() const
Definition: Tm.cc:126
tuple iov
Definition: o2o.py:307
void fetchLastData(std::map< EcalLogicID, RunDCSMagnetDat > *fillMap)
void setTime(Tm start)
void setMagnetCurrent(float t)
oracle::occi::ResultSet ResultSet
void fillTheMap(ResultSet *, std::map< EcalLogicID, RunDCSMagnetDat > *)
void fetchData(std::map< EcalLogicID, RunDCSMagnetDat > *fillMap, RunIOV *iov)
ResultSet * getMagnetRset()
tuple query
Definition: o2o.py:269
tuple cout
Definition: gather_cfg.py:121
void fillMap(Registry *reg, regmap_type &fillme)
Definition: Registry.cc:24
Definition: RunIOV.h:13
Tm dateToTm(oracle::occi::Date &date) const
Definition: DateHandler.cc:31
Definition: Tm.h:14
Tm getTime() const