CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes | Friends

ODTCCEEConfig Class Reference

#include <ODTCCEEConfig.h>

Inheritance diagram for ODTCCEEConfig:
IODConfig IDBObject

List of all members.

Public Member Functions

int getId () const
unsigned char * getLUTClob () const
std::string getLUTConfigurationFile () const
int getNTestPatternsToLoad () const
unsigned char * getSLBClob () const
std::string getSLBConfigurationFile () const
int getSLBLatency () const
std::string getTable ()
unsigned char * getTCCClob () const
std::string getTCCConfigurationFile () const
std::string getTestPatternFileUrl () const
int getTrigPos () const
 ODTCCEEConfig ()
void setId (int id)
void setLUTClob (unsigned char *x)
void setLUTConfigurationFile (std::string x)
void setNTestPatternsToLoad (int id)
void setParameters (std::map< std::string, std::string > my_keys_map)
void setSLBClob (unsigned char *x)
void setSLBConfigurationFile (std::string x)
void setSLBLatency (int id)
void setTCCClob (unsigned char *x)
void setTCCConfigurationFile (std::string x)
void setTestPatternFileUrl (std::string x)
void setTriggerPos (int id)
 ~ODTCCEEConfig ()

Private Member Functions

void clear ()
void fetchData (ODTCCEEConfig *result) throw (std::runtime_error)
int fetchID () throw (std::runtime_error)
int fetchNextId () throw (std::runtime_error)
void prepareWrite () throw (std::runtime_error)
void writeDB () throw (std::runtime_error)

Private Attributes

int m_ID
unsigned char * m_lut_clob
std::string m_lut_file
int m_ntest
unsigned int m_size
int m_slb
unsigned char * m_slb_clob
std::string m_slb_file
unsigned char * m_tcc_ee_clob
std::string m_tcc_ee_file
std::string m_test_url
int m_trigpos

Friends

class EcalCondDBInterface

Detailed Description

Definition at line 15 of file ODTCCEEConfig.h.


Constructor & Destructor Documentation

ODTCCEEConfig::ODTCCEEConfig ( )

Definition at line 12 of file ODTCCEEConfig.cc.

References hitfit::clear(), and NULL.

ODTCCEEConfig::~ODTCCEEConfig ( )

Definition at line 35 of file ODTCCEEConfig.cc.

{
}

Member Function Documentation

void ODTCCEEConfig::clear ( void  ) [private]

Definition at line 25 of file ODTCCEEConfig.cc.

void ODTCCEEConfig::fetchData ( ODTCCEEConfig result) throw (std::runtime_error) [private]

Definition at line 188 of file ODTCCEEConfig.cc.

References gather_cfg::cout, alignCSCRings::e, i, and query::result.

{
  this->checkConnection();
  result->clear();
  if(result->getId()==0 && (result->getConfigTag()=="") ){
    throw(std::runtime_error("ODTCCEEConfig::fetchData(): no Id defined for this ODTCCEEConfig "));
  }

  try {

    m_readStmt->setSQL("SELECT * "
                       "FROM ECAL_TCC_EE_CONFIGURATION d "
                       " where (tcc_ee_configuration_id = :1 or tcc_ee_tag=:2 )" );
    m_readStmt->setInt(1, result->getId());
    m_readStmt->setString(2, result->getConfigTag());
    ResultSet* rset = m_readStmt->executeQuery();

    rset->next();
    // the first is the id 
    result->setId(rset->getInt(1));
    result->setConfigTag(rset->getString(2));

    result->setTCCConfigurationFile(rset->getString(3));
    result->setLUTConfigurationFile(rset->getString(4));
    result->setSLBConfigurationFile(rset->getString(5));
    result->setTestPatternFileUrl(rset->getString(6));
    result->setNTestPatternsToLoad(rset->getInt(7));
    result->setSLBLatency(rset->getInt(12));
    //

    Clob clob1 = rset->getClob (8);
    cout << "Opening the clob in Read only mode" << endl;
    clob1.open (OCCI_LOB_READONLY);
    int clobLength=clob1.length ();
    cout << "Length of the clob1 is: " << clobLength << endl;
    unsigned char* buffer = readClob (clob1, clobLength);
    clob1.close ();
    cout<< "the clob buffer is:"<<endl;  
    for (int i = 0; i < clobLength; ++i)
      cout << (char) buffer[i];
    cout << endl;
    result->setTCCClob(buffer );

    Clob clob2 = rset->getClob (9);
    cout << "Opening the clob in Read only mode" << endl;
    clob2.open (OCCI_LOB_READONLY);
    clobLength=clob2.length ();
    cout << "Length of the clob2 is: " << clobLength << endl;
    unsigned char* buffer2 = readClob (clob2, clobLength);
    clob2.close ();
    cout<< "the clob buffer is:"<<endl;  
    for (int i = 0; i < clobLength; ++i)
      cout << (char) buffer2[i];
    cout << endl;
    result->setLUTClob(buffer2 );

    Clob clob3 = rset->getClob (10);
    cout << "Opening the clob in Read only mode" << endl;
    clob3.open (OCCI_LOB_READONLY);
    clobLength=clob3.length ();
    cout << "Length of the clob3 is: " << clobLength << endl;
    unsigned char* buffer3 = readClob (clob3, clobLength);
    clob3.close ();
    cout<< "the clob buffer is:"<<endl;  
    for (int i = 0; i < clobLength; ++i)
      cout << (char) buffer3[i];
    cout << endl;
    result->setSLBClob(buffer3 );

  } catch (SQLException &e) {
    throw(std::runtime_error("ODTCCEEConfig::fetchData():  "+e.getMessage()));
  }
}
int ODTCCEEConfig::fetchID ( ) throw (std::runtime_error) [private]

Definition at line 265 of file ODTCCEEConfig.cc.

References alignCSCRings::e.

{
  if (m_ID!=0) {
    return m_ID;
  }

  this->checkConnection();

  try {
    Statement* stmt = m_conn->createStatement();
    stmt->setSQL("SELECT tcc_ee_configuration_id FROM ecal_tcc_ee_configuration "
                 "WHERE  tcc_ee_tag=:tcc_ee_tag "
                 );

    stmt->setString(1, getConfigTag() );

    ResultSet* rset = stmt->executeQuery();

    if (rset->next()) {
      m_ID = rset->getInt(1);
    } else {
      m_ID = 0;
    }
    m_conn->terminateStatement(stmt);
  } catch (SQLException &e) {
    throw(std::runtime_error("ODTCCEEConfig::fetchID:  "+e.getMessage()));
  }

    return m_ID;
}
int ODTCCEEConfig::fetchNextId ( ) throw (std::runtime_error) [private]

Definition at line 39 of file ODTCCEEConfig.cc.

References alignCSCRings::e, and query::result.

                                                        {

  int result=0;
  try {
    this->checkConnection();

    m_readStmt = m_conn->createStatement(); 
    m_readStmt->setSQL("select ecal_tcc_ee_config_sq.NextVal from dual");
    ResultSet* rset = m_readStmt->executeQuery();
    while (rset->next ()){
      result= rset->getInt(1);
    }
    m_conn->terminateStatement(m_readStmt);
    return result; 

  } catch (SQLException &e) {
    throw(std::runtime_error("ODTCCEEConfig::fetchNextId():  "+e.getMessage()));
  }

}
int ODTCCEEConfig::getId ( ) const [inline]

Definition at line 25 of file ODTCCEEConfig.h.

References m_ID.

{ return m_ID; }
unsigned char* ODTCCEEConfig::getLUTClob ( ) const [inline]

Definition at line 47 of file ODTCCEEConfig.h.

References m_lut_clob.

{ return m_lut_clob; }
std::string ODTCCEEConfig::getLUTConfigurationFile ( ) const [inline]

Definition at line 30 of file ODTCCEEConfig.h.

References m_lut_file.

{ return m_lut_file; }
int ODTCCEEConfig::getNTestPatternsToLoad ( ) const [inline]

Definition at line 36 of file ODTCCEEConfig.h.

References m_ntest.

{ return m_ntest; }
unsigned char* ODTCCEEConfig::getSLBClob ( ) const [inline]

Definition at line 50 of file ODTCCEEConfig.h.

References m_slb_clob.

{ return m_slb_clob; }
std::string ODTCCEEConfig::getSLBConfigurationFile ( ) const [inline]

Definition at line 32 of file ODTCCEEConfig.h.

References m_slb_file.

{ return m_slb_file; }
int ODTCCEEConfig::getSLBLatency ( ) const [inline]

Definition at line 41 of file ODTCCEEConfig.h.

References m_slb.

{ return m_slb; }
std::string ODTCCEEConfig::getTable ( ) [inline, virtual]

Implements IODConfig.

Definition at line 22 of file ODTCCEEConfig.h.

{ return "ECAL_TCC_EE_CONFIGURATION"; }
unsigned char* ODTCCEEConfig::getTCCClob ( ) const [inline]

Definition at line 44 of file ODTCCEEConfig.h.

References m_tcc_ee_clob.

{ return m_tcc_ee_clob; }
std::string ODTCCEEConfig::getTCCConfigurationFile ( ) const [inline]

Definition at line 28 of file ODTCCEEConfig.h.

References m_tcc_ee_file.

{ return m_tcc_ee_file; }
std::string ODTCCEEConfig::getTestPatternFileUrl ( ) const [inline]

Definition at line 34 of file ODTCCEEConfig.h.

References m_test_url.

{ return m_test_url; }
int ODTCCEEConfig::getTrigPos ( ) const [inline]

Definition at line 38 of file ODTCCEEConfig.h.

References m_trigpos.

{ return m_trigpos; }
void ODTCCEEConfig::prepareWrite ( ) throw (std::runtime_error) [private, virtual]

Implements IODConfig.

Definition at line 87 of file ODTCCEEConfig.cc.

References gather_cfg::cout, and alignCSCRings::e.

{
  this->checkConnection();

  int next_id=fetchNextId();

  try {
    m_writeStmt = m_conn->createStatement();
    m_writeStmt->setSQL("INSERT INTO ECAL_TCC_EE_CONFIGURATION (tcc_ee_configuration_id, tcc_ee_tag, "
                        "Configuration_file, LUT_CONFIGURATION_FILE, SLB_CONFIGURATION_FILE, "
                        "TESTPATTERNFILE_URL , N_TESTPATTERNS_TO_LOAD, TRIGGER_POS, "
                        "tcc_configuration, lut_configuration, slb_configuration, slblatency ) "
                        "VALUES (:1, :2, :3, :4, :5, :6, :7, :8 , :9, :10, :11, :12)");
    m_writeStmt->setInt(1, next_id);
    m_writeStmt->setString(2, getConfigTag());
    m_writeStmt->setString(3, getTCCConfigurationFile());
    m_writeStmt->setString(4, getLUTConfigurationFile());
    m_writeStmt->setString(5, getSLBConfigurationFile());
    m_writeStmt->setString(6, getTestPatternFileUrl());
    m_writeStmt->setInt(7, getNTestPatternsToLoad());
    m_writeStmt->setInt(8, getTrigPos());
    m_writeStmt->setInt(12, getSLBLatency());
    // and now the clobs
    oracle::occi::Clob clob1(m_conn);
    clob1.setEmpty();
    m_writeStmt->setClob(9,clob1);

    oracle::occi::Clob clob2(m_conn);
    clob2.setEmpty();
    m_writeStmt->setClob(10,clob2);

    oracle::occi::Clob clob3(m_conn);
    clob3.setEmpty();
    m_writeStmt->setClob(11,clob3);

    m_writeStmt->executeUpdate ();
    m_ID=next_id; 

    m_conn->terminateStatement(m_writeStmt);
    std::cout<<"TCC 3 empty Clobs inserted into CONFIGURATION with id="<<next_id<<std::endl;

    // now we read and update it 
    m_writeStmt = m_conn->createStatement(); 
    m_writeStmt->setSQL ("SELECT tcc_configuration, lut_configuration, slb_configuration FROM ECAL_TCC_EE_CONFIGURATION WHERE"
                         " tcc_ee_configuration_id=:1 FOR UPDATE");

    std::cout<<"updating the clobs 0"<<std::endl;

    
  } catch (SQLException &e) {
    throw(std::runtime_error("ODTCCEEConfig::prepareWrite():  "+e.getMessage()));
  }

  std::cout<<"updating the clob 1 "<<std::endl;
  
}
void ODTCCEEConfig::setId ( int  id) [inline]

Definition at line 24 of file ODTCCEEConfig.h.

References errorMatrix2Lands_multiChannel::id, and m_ID.

{ m_ID = id; }
void ODTCCEEConfig::setLUTClob ( unsigned char *  x) [inline]

Definition at line 46 of file ODTCCEEConfig.h.

References m_lut_clob, and x.

{ m_lut_clob = x; }
void ODTCCEEConfig::setLUTConfigurationFile ( std::string  x) [inline]

Definition at line 29 of file ODTCCEEConfig.h.

References m_lut_file, and x.

{ m_lut_file = x; }
void ODTCCEEConfig::setNTestPatternsToLoad ( int  id) [inline]

Definition at line 35 of file ODTCCEEConfig.h.

References errorMatrix2Lands_multiChannel::id, and m_ntest.

{ m_ntest = id; }
void ODTCCEEConfig::setParameters ( std::map< std::string, std::string >  my_keys_map)
void ODTCCEEConfig::setSLBClob ( unsigned char *  x) [inline]

Definition at line 49 of file ODTCCEEConfig.h.

References m_slb_clob, and x.

{ m_slb_clob = x; }
void ODTCCEEConfig::setSLBConfigurationFile ( std::string  x) [inline]

Definition at line 31 of file ODTCCEEConfig.h.

References m_slb_file, and x.

{ m_slb_file = x; }
void ODTCCEEConfig::setSLBLatency ( int  id) [inline]

Definition at line 40 of file ODTCCEEConfig.h.

References errorMatrix2Lands_multiChannel::id, and m_slb.

{ m_slb = id; }
void ODTCCEEConfig::setTCCClob ( unsigned char *  x) [inline]

Definition at line 43 of file ODTCCEEConfig.h.

References m_tcc_ee_clob, and x.

void ODTCCEEConfig::setTCCConfigurationFile ( std::string  x) [inline]

Definition at line 27 of file ODTCCEEConfig.h.

References m_tcc_ee_file, and x.

void ODTCCEEConfig::setTestPatternFileUrl ( std::string  x) [inline]

Definition at line 33 of file ODTCCEEConfig.h.

References m_test_url, and x.

{ m_test_url = x; }
void ODTCCEEConfig::setTriggerPos ( int  id) [inline]

Definition at line 37 of file ODTCCEEConfig.h.

References errorMatrix2Lands_multiChannel::id, and m_trigpos.

{ m_trigpos = id; }
void ODTCCEEConfig::writeDB ( ) throw (std::runtime_error) [private]

Definition at line 145 of file ODTCCEEConfig.cc.

References gather_cfg::cout, and alignCSCRings::e.

{

  std::cout<<"updating the clob 2"<<std::endl;

  try {

    m_writeStmt->setInt(1, m_ID);
    ResultSet* rset = m_writeStmt->executeQuery();

    while (rset->next ())
      {
        oracle::occi::Clob clob1 = rset->getClob (1);
        oracle::occi::Clob clob2 = rset->getClob (2);
        oracle::occi::Clob clob3 = rset->getClob (3);
        cout << "Opening the clob in read write mode" << endl;
        cout << "Populating the clobs" << endl;
        populateClob (clob1, getTCCConfigurationFile(), m_size);
        populateClob (clob2, getLUTConfigurationFile(), m_size);
        populateClob (clob3, getSLBConfigurationFile(), m_size);
       
      }

    m_writeStmt->executeUpdate();
    m_writeStmt->closeResultSet (rset);

  } catch (SQLException &e) {
    throw(std::runtime_error("ODTCCEEConfig::writeDB():  "+e.getMessage()));
  }
  // Now get the ID
  if (!this->fetchID()) {
    throw(std::runtime_error("ODTCCEEConfig::writeDB:  Failed to write"));
  }


}

Friends And Related Function Documentation

friend class EcalCondDBInterface [friend]

Reimplemented from IDBObject.

Definition at line 17 of file ODTCCEEConfig.h.


Member Data Documentation

int ODTCCEEConfig::m_ID [private]

Definition at line 66 of file ODTCCEEConfig.h.

Referenced by getId(), and setId().

unsigned char* ODTCCEEConfig::m_lut_clob [private]

Definition at line 68 of file ODTCCEEConfig.h.

Referenced by getLUTClob(), and setLUTClob().

std::string ODTCCEEConfig::m_lut_file [private]

Definition at line 71 of file ODTCCEEConfig.h.

Referenced by getLUTConfigurationFile(), and setLUTConfigurationFile().

int ODTCCEEConfig::m_ntest [private]

Definition at line 74 of file ODTCCEEConfig.h.

Referenced by getNTestPatternsToLoad(), and setNTestPatternsToLoad().

unsigned int ODTCCEEConfig::m_size [private]

Definition at line 77 of file ODTCCEEConfig.h.

int ODTCCEEConfig::m_slb [private]

Definition at line 76 of file ODTCCEEConfig.h.

Referenced by getSLBLatency(), and setSLBLatency().

unsigned char* ODTCCEEConfig::m_slb_clob [private]

Definition at line 69 of file ODTCCEEConfig.h.

Referenced by getSLBClob(), and setSLBClob().

std::string ODTCCEEConfig::m_slb_file [private]

Definition at line 72 of file ODTCCEEConfig.h.

Referenced by getSLBConfigurationFile(), and setSLBConfigurationFile().

unsigned char* ODTCCEEConfig::m_tcc_ee_clob [private]

Definition at line 67 of file ODTCCEEConfig.h.

Referenced by getTCCClob(), and setTCCClob().

std::string ODTCCEEConfig::m_tcc_ee_file [private]

Definition at line 70 of file ODTCCEEConfig.h.

Referenced by getTCCConfigurationFile(), and setTCCConfigurationFile().

std::string ODTCCEEConfig::m_test_url [private]

Definition at line 73 of file ODTCCEEConfig.h.

Referenced by getTestPatternFileUrl(), and setTestPatternFileUrl().

int ODTCCEEConfig::m_trigpos [private]

Definition at line 75 of file ODTCCEEConfig.h.

Referenced by getTrigPos(), and setTriggerPos().