Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:31:45

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