Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-10-12 04:20:55

0001 #include "OnlineDB/CSCCondDB/interface/CSCCableRead.h"
0002 #include <cstdlib>
0003 #include <cassert>
0004 
0005 /**
0006    * Constructor for csccableread
0007    */
0008 csccableread::csccableread() noexcept(false) {
0009   std::string db_user;
0010   std::string db_pass;
0011   env = oracle::occi::Environment::createEnvironment(oracle::occi::Environment::DEFAULT);
0012   char *c_user = std::getenv("CSCMAP_AUTH_USER");
0013   char *c_pass = std::getenv("CSCMAP_AUTH_PASSWORD");
0014   assert(c_user);
0015   assert(c_pass);
0016   db_user = std::string(c_user);
0017   db_pass = std::string(c_pass);
0018   con = env->createConnection(db_user, db_pass, "cms_orcoff_prod");
0019   std::cout << "Connection to cable DB is done." << std::endl;
0020 }  // end of constructor csccableread ()
0021 /**
0022    * Destructor for csccableread.
0023    */
0024 csccableread::~csccableread() noexcept(false) {
0025   env->terminateConnection(con);
0026   oracle::occi::Environment::terminateEnvironment(env);
0027 }  // end of ~csccableread ()
0028 
0029 void csccableread::cable_read(int chamber_index,
0030                               std::string *chamber_label,
0031                               float *cfeb_length,
0032                               std::string *cfeb_rev,
0033                               float *alct_length,
0034                               std::string *alct_rev,
0035                               float *cfeb_tmb_skew_delay,
0036                               float *cfeb_timing_corr) {
0037   oracle::occi::Statement *stmt = con->createStatement();
0038   stmt->setSQL("begin cms_emu_cern.cable_read.cable(:1, :2, :3, :4, :5, :6, :7, :8); end;");
0039 
0040   //    stmt->setInt (1, chamber_index);
0041   //    stmt->registerOutParam(2, oracle::occi::OCCISTRING, 9);
0042   //    stmt->registerOutParam(3, oracle::occi::OCCIINT);
0043   //    stmt->registerOutParam(4, oracle::occi::OCCISTRING, 1);
0044   //    stmt->registerOutParam(5, oracle::occi::OCCIINT);
0045   //    stmt->registerOutParam(6, oracle::occi::OCCISTRING, 1);
0046   //    stmt->registerOutParam(7, oracle::occi::OCCIINT);
0047   //    stmt->registerOutParam(8, oracle::occi::OCCIINT);
0048   //
0049   //    stmt->execute(); //execute procedure
0050   //
0051   //    *chamber_label = stmt->getString(2);
0052   //    *cfeb_length = stmt->getInt(3);
0053   //    *cfeb_rev = stmt->getString(4);
0054   //    *alct_length = stmt->getInt(5);
0055   //    *alct_rev = stmt->getString(6);
0056   //    *cfeb_tmb_skew_delay = stmt->getInt(7);
0057   //    *cfeb_timing_corr = stmt->getInt(8);
0058 
0059   stmt->setInt(1, chamber_index);
0060   stmt->registerOutParam(2, oracle::occi::OCCISTRING, 9);
0061   stmt->registerOutParam(3, oracle::occi::OCCIFLOAT);
0062   stmt->registerOutParam(4, oracle::occi::OCCISTRING, 1);
0063   stmt->registerOutParam(5, oracle::occi::OCCIFLOAT);
0064   stmt->registerOutParam(6, oracle::occi::OCCISTRING, 1);
0065   stmt->registerOutParam(7, oracle::occi::OCCIFLOAT);
0066   stmt->registerOutParam(8, oracle::occi::OCCIFLOAT);
0067 
0068   stmt->execute();  //execute procedure
0069 
0070   *chamber_label = stmt->getString(2);
0071   *cfeb_length = stmt->getFloat(3);
0072   *cfeb_rev = stmt->getString(4);
0073   *alct_length = stmt->getFloat(5);
0074   *alct_rev = stmt->getString(6);
0075   *cfeb_tmb_skew_delay = stmt->getFloat(7);
0076   *cfeb_timing_corr = stmt->getFloat(8);
0077 
0078   con->terminateStatement(stmt);
0079 }  //end of cable_read