CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/src/OnlineDB/EcalCondDB/src/ODLaserConfig.cc

Go to the documentation of this file.
00001 #include <stdexcept>
00002 #include <string>
00003 #include <fstream>
00004 #include <iostream>
00005 #include <stdio.h>
00006 #include <cstdlib>
00007 
00008 #include "OnlineDB/Oracle/interface/Oracle.h"
00009 
00010 #include "OnlineDB/EcalCondDB/interface/ODLaserConfig.h"
00011 
00012 using namespace std;
00013 using namespace oracle::occi;
00014 
00015 ODLaserConfig::ODLaserConfig()
00016 {
00017   m_env = NULL;
00018   m_conn = NULL;
00019   m_writeStmt = NULL;
00020   m_readStmt = NULL;
00021   m_size=0;
00022   m_config_tag="";
00023    m_ID=0;
00024    clear();
00025 
00026 }
00027 
00028 void ODLaserConfig::clear(){
00029 
00030 
00031   m_debug=0;
00032   m_dummy=0;
00033 
00034   // emtc 
00035    m_emtc_1=0;
00036    m_emtc_2=0;
00037    m_emtc_3=0;
00038    m_emtc_4=0;
00039    m_emtc_5=0;
00040 
00041   // laser
00042   m_wave=0;
00043   m_power=0;
00044   m_switch=0;
00045   m_filter=0;
00046   m_on=0;
00047   m_laserhost="";
00048   m_laserport=0;
00049 
00050   // mataq
00051    m_mq_base=0;
00052    m_mq_none=0;
00053    m_mode="" ;
00054    m_chan_mask=0;
00055    m_samples="";
00056    m_ped_file="";
00057    m_use_buffer=0;
00058    m_post_trig=0;
00059    m_fp_mode=0;
00060    m_hal_mod_file="";
00061    m_hal_add_file="";
00062    m_hal_tab_file="";
00063    m_serial="";
00064    m_ped_count=0;
00065    m_raw_mode=0;
00066    m_aqmode="";
00067    m_mq_file="";
00068    m_laser_tag="";
00069    m_matacq_vernier_min=0;
00070    m_matacq_vernier_max=0;
00071 
00072    m_wte_2_led_delay =0;
00073    m_led1_on =0;
00074    m_led2_on =0;
00075    m_led3_on =0;
00076    m_led4_on =0;
00077    m_vinj =0;
00078    m_orange_led_mon_ampl=0;
00079    m_blue_led_mon_ampl =0;
00080    m_trig_log_file ="";
00081    m_led_control_on =0;
00082    m_led_control_host="";
00083    m_led_control_port =0;
00084    m_ir_laser_power =0;
00085    m_green_laser_power=0;
00086    m_red_laser_power =0;
00087    m_blue_laser_log_attenuator =0;
00088    m_ir_laser_log_attenuator =0;
00089    m_green_laser_log_attenuator  =0;
00090    m_red_laser_log_attenuator =0;
00091    m_laser_config_file ="";
00092 
00093 }
00094 
00095 ODLaserConfig::~ODLaserConfig()
00096 {
00097 }
00098 
00099 
00100 
00101 void ODLaserConfig::setParameters(std::map<string,string> my_keys_map){
00102   
00103   // parses the result of the XML parser that is a map of 
00104   // string string with variable name variable value 
00105   
00106   for( std::map<std::string, std::string >::iterator ci=
00107          my_keys_map.begin(); ci!=my_keys_map.end(); ci++ ) {
00108     
00109     if(ci->first==  "LASER_CONFIGURATION_ID") setConfigTag(ci->second);
00110     if(ci->first==  "DEBUG") setDebug(atoi(ci->second.c_str()) );
00111     if(ci->first==  "LASER_DEBUG") setDebug(atoi(ci->second.c_str()) );
00112     if(ci->first==  "DUMMY") setDummy(atoi(ci->second.c_str() ));
00113     if(ci->first==  "MATACQ_BASE_ADDRESS") setMatacqBaseAddress(atoi(ci->second.c_str() ));
00114     if(ci->first==  "MATACQ_NONE") setMatacqNone(atoi(ci->second.c_str() ));
00115     if(ci->first==  "MATACQ_MODE") setMatacqMode(ci->second);
00116     if(ci->first==  "CHANNEL_MASK") setChannelMask(atoi(ci->second.c_str() ));
00117     if(ci->first==  "MAX_SAMPLES_FOR_DAQ") setMaxSamplesForDaq(ci->second );
00118     if(ci->first==  "MATACQ_FED_ID") setMatacqFedId(atoi(ci->second.c_str()) );
00119     if(ci->first==  "PEDESTAL_FILE") setPedestalFile(ci->second );
00120     if(ci->first==  "USE_BUFFER") setUseBuffer(atoi(ci->second.c_str())) ;
00121     if(ci->first==  "POSTTRIG") setPostTrig(atoi(ci->second.c_str()) );
00122     if(ci->first==  "FP_MODE") setFPMode(atoi(ci->second.c_str() ));
00123     if(ci->first==  "HAL_MODULE_FILE") setHalModuleFile(ci->second );
00124     if(ci->first==  "HAL_ADDRESS_TABLE_FILE" || ci->first==  "HAL_ADDRESST_ABLE_FILE") setHalAddressTableFile(ci->second);
00125     if(ci->first==  "HAL_STATIC_TABLE_FILE") setHalStaticTableFile(ci->second );
00126     if(ci->first==  "MATACQ_SERIAL_NUMBER") setMatacqSerialNumber(ci->second );
00127     if(ci->first==  "PEDESTAL_RUN_EVENT_COUNT") setPedestalRunEventCount(atoi(ci->second.c_str()) );
00128     if(ci->first==  "RAW_DATA_MODE") setRawDataMode(atoi(ci->second.c_str()) );
00129     if(ci->first==  "ACQUISITION_MODE") setMatacqAcquisitionMode(ci->second );
00130     if(ci->first==  "LOCAL_OUTPUT_FILE") setLocalOutputFile(ci->second );
00131     if(ci->first==  "EMTC_NONE") setEMTCNone(atoi(ci->second.c_str()) );
00132     if(ci->first==  "WTE2_LASER_DELAY") setWTE2LaserDelay(atoi(ci->second.c_str()) );
00133     if(ci->first==  "LASER_PHASE") setLaserPhase(atoi(ci->second.c_str()) );
00134     if(ci->first==  "EMTC_TTC_IN") setEMTCTTCIn(atoi(ci->second.c_str()) );
00135     if(ci->first==  "EMTC_SLOT_ID") setEMTCSlotId(atoi(ci->second.c_str()) );
00136     if(ci->first==  "WAVELENGTH") setWaveLength(atoi(ci->second.c_str()) );
00137     if(ci->first==  "OPTICAL_SWITCH") setOpticalSwitch(atoi(ci->second.c_str()) );
00138     if(ci->first==  "POWER_SETTING") setPower(atoi(ci->second.c_str()) );
00139     if(ci->first==  "FILTER") setFilter(atoi(ci->second.c_str()) );
00140     if(ci->first==  "LASER_CONTROL_ON") setLaserControlOn(atoi(ci->second.c_str()) );
00141     if(ci->first==  "LASER_CONTROL_HOST") setLaserControlHost(ci->second );
00142     if(ci->first==  "LASER_CONTROL_PORT") setLaserControlPort(atoi(ci->second.c_str()) );
00143     if(ci->first==  "MATACQ_VERNIER_MAX") setMatacqVernierMax(atoi(ci->second.c_str()) );
00144     if(ci->first==  "MATACQ_VERNIER_MIN") setMatacqVernierMin(atoi(ci->second.c_str()) );
00145 
00146     if(ci->first==  "WTE_2_LED_DELAY") setWTE2LedDelay(atoi(ci->second.c_str()) );
00147     if(ci->first==  "LED1_ON") setLed1ON(atoi(ci->second.c_str()) );
00148     if(ci->first==  "LED2_ON") setLed2ON(atoi(ci->second.c_str()) );
00149     if(ci->first==  "LED3_ON") setLed3ON(atoi(ci->second.c_str()) );
00150     if(ci->first==  "LED4_ON") setLed4ON(atoi(ci->second.c_str()) );
00151     if(ci->first==  "VINJ") setVinj(atoi(ci->second.c_str()) );
00152     if(ci->first==  "ORANGE_LED_MON_AMPL") setOrangeLedMonAmpl(atoi(ci->second.c_str()) );
00153     if(ci->first==  "BLUE_LED_MON_AMPL") setBlueLedMonAmpl(atoi(ci->second.c_str()) );
00154     if(ci->first==  "TRIG_LOG_FILE") setTrigLogFile(ci->second.c_str() );
00155     if(ci->first==  "LED_CONTROL_ON") setLedControlON(atoi(ci->second.c_str()) );
00156     if(ci->first==  "LED_CONTROL_HOST") setLedControlHost( ci->second.c_str() );
00157     if(ci->first==  "LED_CONTROL_PORT") setLedControlPort(atoi(ci->second.c_str()) );
00158     if(ci->first==  "IR_LASER_POWER") setIRLaserPower(atoi(ci->second.c_str()) );
00159     if(ci->first==  "GREEN_LASER_POWER") setGreenLaserPower(atoi(ci->second.c_str()) );
00160     if(ci->first==  "RED_LASER_POWER") setRedLaserPower(atoi(ci->second.c_str()) );
00161     if(ci->first==  "BLUE_LASER_LOG_ATTENUATOR") setBlueLaserLogAttenuator(atoi(ci->second.c_str()) );
00162     if(ci->first==  "IR_LASER_LOG_ATTENUATOR") setIRLaserLogAttenuator(atoi(ci->second.c_str()) );
00163     if(ci->first==  "GREEN_LASER_LOG_ATTENUATOR") setGreenLaserLogAttenuator(atoi(ci->second.c_str()) );
00164     if(ci->first==  "RED_LASER_LOG_ATTENUATOR") setRedLaserLogAttenuator(atoi(ci->second.c_str()) );
00165   
00166 
00167     if(ci->first==  "LASER_CONFIG_FILE") {
00168       std::string fname=ci->second ;
00169       setLaserConfigFile(fname );
00170       // here we must open the file and read the DCC Clob
00171       std::cout << "Going to read Laser file: " << fname << endl;
00172 
00173       ifstream inpFile;
00174       inpFile.open(fname.c_str());
00175 
00176       // tell me size of file
00177       int bufsize = 0;
00178       inpFile.seekg( 0,ios::end );
00179       bufsize = inpFile.tellg();
00180       std::cout <<" bufsize ="<<bufsize<< std::endl;
00181       // set file pointer to start again
00182       inpFile.seekg( 0,ios::beg );
00183 
00184       m_size=bufsize;
00185 
00186       inpFile.close();
00187 
00188     }
00189 
00190 
00191   }
00192   
00193 }
00194 
00195 int ODLaserConfig::fetchNextId()  throw(std::runtime_error) {
00196 
00197   int result=0;
00198   try {
00199     this->checkConnection();
00200 
00201     m_readStmt = m_conn->createStatement(); 
00202     m_readStmt->setSQL("select ecal_laser_config_sq.NextVal from dual");
00203     ResultSet* rset = m_readStmt->executeQuery();
00204     while (rset->next ()){
00205       result= rset->getInt(1);
00206     }
00207     m_conn->terminateStatement(m_readStmt);
00208     return result; 
00209 
00210   } catch (SQLException &e) {
00211     throw(std::runtime_error("ODLaserConfig::fetchNextId():  "+e.getMessage()));
00212   }
00213 
00214 }
00215 
00216 
00217 void ODLaserConfig::prepareWrite()
00218   throw(std::runtime_error)
00219 {
00220   this->checkConnection();
00221   int next_id=fetchNextId();
00222 
00223 
00224   try {
00225     m_writeStmt = m_conn->createStatement();
00226     m_writeStmt->setSQL("INSERT INTO ECAL_Laser_CONFIGURATION ( laser_configuration_id, laser_tag "
00227                         ", laser_DEBUG "
00228                         ", DUMMY "
00229                         ", MATACQ_BASE_ADDRESS " 
00230                         ", MATACQ_NONE "
00231                         ", matacq_mode "
00232                         ", channel_Mask "
00233                         ", max_Samples_For_Daq "
00234                         ", maTACQ_FED_ID "
00235                         ", pedestal_File "
00236                         ", use_Buffer "
00237                         ", postTrig "
00238                         ", fp_Mode "
00239                         ", hal_Module_File " 
00240                         ", hal_Address_Table_File "
00241                         ", hal_Static_Table_File "
00242                         ", matacq_Serial_Number "
00243                         ", pedestal_Run_Event_Count " 
00244                         ", raw_Data_Mode "
00245                         ", ACQUISITION_MODE " 
00246                         ", LOCAL_OUTPUT_FILE " 
00247                         ", emtc_none "
00248                         ", wte2_laser_delay " 
00249                         ", laser_phase "
00250                         ", emtc_ttc_in "
00251                         ", emtc_slot_id " 
00252                         ", WAVELENGTH "
00253                         ", POWER_SETTING "
00254                         ", OPTICAL_SWITCH "
00255                         ", FILTER "
00256                         ", LASER_CONTROL_ON " 
00257                         ", LASER_CONTROL_HOST " 
00258                         ", LASER_CONTROL_PORT "
00259                         ", LASER_TAG2 "
00260                         ", MATACQ_VERNIER_MIN "
00261                         ", MATACQ_VERNIER_MAX "
00262                         " , wte_2_led_delay " 
00263                         " , led1_on "
00264                         " , led2_on "
00265                         " , led3_on "
00266                         " , led4_on "
00267                         " , VINJ "
00268                         " , orange_led_mon_ampl" 
00269                         " , blue_led_mon_ampl "
00270                         " , trig_log_file "
00271                         " , led_control_on "
00272                         " , led_control_host "
00273                         " , led_control_port "
00274                         " , ir_laser_power "
00275                         " , green_laser_power" 
00276                         " , red_laser_power "
00277                         " , blue_laser_log_attenuator "
00278                         " , IR_LASER_LOG_ATTENUATOR "
00279                         " , GREEN_LASER_LOG_ATTENUATOR"  
00280                         " , RED_LASER_LOG_ATTENUATOR "
00281                         " , LASER_CONFIG_FILE "
00282                         " , laser_configuration ) "
00283                         " VALUES (  :1, :2, :3, :4, :5, :6, :7, :8, :9, :10, "
00284                         ":11, :12, :13, :14, :15, :16, :17, :18, :19, :20,  "
00285                         ":21, :22, :23, :24, :25, :26, :27, :28, :29, :30,  "
00286                         ":31, :32, :33, :34, :35, :36, :37, "
00287                         " :38, :39, :40, :41, :42, :43, :44, :45, :46, :47, :48, :49, :50, :51, :52, :53, :54, :55, :56, :57, :58  )");
00288     m_writeStmt->setInt(1, next_id);
00289     m_ID=next_id;
00290   } catch (SQLException &e) {
00291     throw(std::runtime_error("ODLaserConfig::prepareWrite():  "+e.getMessage()));
00292   }
00293 }
00294 
00295 
00296 
00297 void ODLaserConfig::writeDB()
00298   throw(std::runtime_error)
00299 {
00300   this->checkConnection();
00301   this->checkPrepare();
00302 
00303   try {
00304     
00305     // 1 is the id 2 is the tag
00306     m_writeStmt->setString(2, this->getConfigTag());
00307 
00308     m_writeStmt->setInt(   3, this->getDebug());
00309     m_writeStmt->setInt(   4, this->getDummy());
00310     m_writeStmt->setInt(   5, this->getMatacqBaseAddress());
00311     m_writeStmt->setInt(   6, this->getMatacqNone());
00312     m_writeStmt->setString(7, this->getMatacqMode());
00313     m_writeStmt->setInt(   8, this->getChannelMask());
00314     m_writeStmt->setString(9, this->getMaxSamplesForDaq());
00315     m_writeStmt->setInt(  10, this->getMatacqFedId());
00316     m_writeStmt->setString(11, this->getPedestalFile());
00317     m_writeStmt->setInt(  12, this->getUseBuffer());
00318     m_writeStmt->setInt(  13, this->getPostTrig());
00319     m_writeStmt->setInt(  14, this->getFPMode());
00320     m_writeStmt->setString(15,  this->getHalModuleFile() );
00321     m_writeStmt->setString(16, this->getHalAddressTableFile() );
00322     m_writeStmt->setString(17, this->getHalStaticTableFile() );
00323     m_writeStmt->setString(18, this->getMatacqSerialNumber() );
00324     m_writeStmt->setInt(   19, this->getPedestalRunEventCount() );
00325     m_writeStmt->setInt(   20, this->getRawDataMode());
00326     m_writeStmt->setString(21, this->getMatacqAcquisitionMode());
00327     m_writeStmt->setString(22, this->getLocalOutputFile());
00328     m_writeStmt->setInt(   23, this->getEMTCNone());
00329     m_writeStmt->setInt(   24, this->getWTE2LaserDelay());
00330     m_writeStmt->setInt(   25, this->getLaserPhase());
00331     m_writeStmt->setInt(   26, this->getEMTCTTCIn());
00332     m_writeStmt->setInt(   27, this->getEMTCSlotId());
00333     // laser
00334     m_writeStmt->setInt(28, this->getWaveLength());
00335     m_writeStmt->setInt(29, this->getPower());
00336     m_writeStmt->setInt(30, this->getOpticalSwitch());
00337     m_writeStmt->setInt(31, this->getFilter());
00338     m_writeStmt->setInt(32, this->getLaserControlOn());
00339     m_writeStmt->setString(33, this->getLaserControlHost() );
00340     m_writeStmt->setInt(   34, this->getLaserControlPort());
00341     m_writeStmt->setString(   35, this->getLaserTag());
00342 
00343     m_writeStmt->setInt(   36, this->getMatacqVernierMin());
00344     m_writeStmt->setInt(   37, this->getMatacqVernierMax());
00345 
00346 
00347     // here goes the led and the new parameters 
00348     m_writeStmt->setInt(   38, this->getWTE2LedDelay());
00349     m_writeStmt->setInt(   39, this->getLed1ON());
00350     m_writeStmt->setInt(   40, this->getLed2ON());
00351     m_writeStmt->setInt(   41, this->getLed3ON());
00352     m_writeStmt->setInt(   42, this->getLed4ON());
00353     m_writeStmt->setInt(   43, this->getVinj());
00354     m_writeStmt->setInt(   44, this->getOrangeLedMonAmpl());
00355     m_writeStmt->setInt(   45, this->getBlueLedMonAmpl());
00356     m_writeStmt->setString(   46, this->getTrigLogFile());
00357     m_writeStmt->setInt(   47, this->getLedControlON());
00358     m_writeStmt->setString(   48, this->getLedControlHost());
00359     m_writeStmt->setInt(   49, this->getLedControlPort());
00360     m_writeStmt->setInt(   50, this->getIRLaserPower());
00361     m_writeStmt->setInt(   51, this->getGreenLaserPower());
00362     m_writeStmt->setInt(   52, this->getRedLaserPower());
00363     m_writeStmt->setInt(   53, this->getBlueLaserLogAttenuator());
00364     m_writeStmt->setInt(   54, this->getIRLaserLogAttenuator());
00365     m_writeStmt->setInt(   55, this->getGreenLaserLogAttenuator());
00366     m_writeStmt->setInt(   56, this->getRedLaserLogAttenuator());
00367     m_writeStmt->setString(   57, this->getLaserConfigFile());
00368 
00369     // and now the clob
00370     oracle::occi::Clob clob(m_conn);
00371     clob.setEmpty();
00372     m_writeStmt->setClob(58,clob);
00373     m_writeStmt->executeUpdate ();
00374     m_conn->terminateStatement(m_writeStmt);
00375 
00376     // now we read and update it
00377     m_writeStmt = m_conn->createStatement();
00378     m_writeStmt->setSQL ("SELECT laser_configuration FROM "+getTable()+" WHERE"
00379                          " laser_configuration_id=:1 FOR UPDATE");
00380     std::cout<<"updating the laser clob "<<std::endl;
00381     
00382 
00383     m_writeStmt->setInt(1, m_ID);
00384     ResultSet* rset = m_writeStmt->executeQuery();
00385     rset->next ();
00386     oracle::occi::Clob clob_to_write = rset->getClob (1);
00387     cout << "Opening the clob in read write mode" << endl;
00388 
00389     populateClob (clob_to_write, getLaserConfigFile(), m_size);
00390     int clobLength=clob_to_write.length ();
00391     cout << "Length of the clob is: " << clobLength << endl;
00392     m_writeStmt->executeUpdate();
00393     m_writeStmt->closeResultSet (rset);
00394 
00395 
00396   } catch (SQLException &e) {
00397     throw(std::runtime_error("ODLaserConfig::writeDB():  "+e.getMessage()));
00398   }
00399   // Now get the ID
00400   if (!this->fetchID()) {
00401     throw(std::runtime_error("ODLaserConfig::writeDB:  Failed to write"));
00402   }
00403 
00404 }
00405 
00406 
00407 
00408 void ODLaserConfig::fetchData(ODLaserConfig * result)
00409   throw(std::runtime_error)
00410 {
00411   this->checkConnection();
00412   result->clear();
00413   if(result->getId()==0 && (result->getConfigTag()=="") ){
00414     throw(std::runtime_error("ODLaserConfig::fetchData(): no Id defined for this ODLaserConfig "));
00415   }
00416 
00417   try {
00418 
00419     m_readStmt->setSQL("SELECT * "
00420                        "FROM "+getTable()+
00421                        " where ( laser_configuration_id = :1  or laser_tag=:2 )" );
00422     m_readStmt->setInt(1, result->getId());
00423     m_readStmt->setString(2, result->getConfigTag());
00424    ResultSet* rset = m_readStmt->executeQuery();
00425 
00426     rset->next();
00427 
00428     
00429     // start from 3 because of select * 
00430 
00431     result->setId(rset->getInt(1));
00432     result->setConfigTag(rset->getString(2));
00433 
00434     result->setDebug(rset->getInt(  3  ));
00435     result->setDummy(rset->getInt(  4  ));
00436     result->setMatacqBaseAddress(rset->getInt( 5   ));
00437     result->setMatacqNone(rset->getInt(  6  ));
00438     result->setMatacqMode(rset->getString(7    ));
00439     result->setChannelMask(rset->getInt(  8  ));
00440     result->setMaxSamplesForDaq(rset->getString( 9   ));
00441     result->setMatacqFedId(rset->getInt( 10   ));
00442     result->setPedestalFile(rset->getString( 11   ));
00443     result->setUseBuffer(rset->getInt(   12 ));
00444     result->setPostTrig(rset->getInt(   13 ));
00445     result->setFPMode(rset->getInt(   14 ));
00446     result->setHalModuleFile(rset->getString( 15   ));
00447     result->setHalAddressTableFile(rset->getString( 16   ));
00448     result->setHalStaticTableFile(rset->getString(  17  ));
00449     result->setMatacqSerialNumber(rset->getString(  18  ));
00450     result->setPedestalRunEventCount(rset->getInt(  19  ));
00451     result->setRawDataMode(rset->getInt( 20   ));
00452     result->setMatacqAcquisitionMode(rset->getString( 21   ));
00453     result->setLocalOutputFile(rset->getString(  22  ));
00454     result->setEMTCNone(rset->getInt(  23  ));
00455     result->setWTE2LaserDelay(rset->getInt( 24   ));
00456     result->setLaserPhase(rset->getInt(  25  ));
00457     result->setEMTCTTCIn(rset->getInt(  26  ));
00458     result->setEMTCSlotId(rset->getInt( 27   ));
00459     // laser
00460     result->setWaveLength(rset->getInt( 28   ));
00461     result->setPower(rset->getInt(  29  ));
00462     result->setOpticalSwitch(rset->getInt( 30   ));
00463     result->setFilter(rset->getInt(  31  ));
00464     result->setLaserControlOn(rset->getInt( 32   ));
00465     result->setLaserControlHost(rset->getString( 33   ));
00466     result->setLaserControlPort(rset->getInt( 34   ));
00467     result->setLaserTag(rset->getString( 35   ));
00468   
00469     result->setMatacqVernierMin(rset->getInt( 36   ));
00470     result->setMatacqVernierMax(rset->getInt( 37   ));
00471 
00472     result->setWTE2LedDelay(rset->getInt( 38   ));
00473     result->setLed1ON(rset->getInt( 39   ));
00474     result->setLed2ON(rset->getInt( 40   ));
00475     result->setLed3ON(rset->getInt( 41   ));
00476     result->setLed4ON(rset->getInt( 42   ));
00477     result->setVinj(rset->getInt( 43   ));
00478     result->setOrangeLedMonAmpl(rset->getInt( 44   ));
00479     result->setBlueLedMonAmpl(rset->getInt( 45   ));
00480     result->setTrigLogFile(rset->getString( 46   ));
00481     result->setLedControlON(rset->getInt( 47   ));
00482     result->setLedControlHost(rset->getString( 48   ));
00483     result->setLedControlPort(rset->getInt( 49   ));
00484     result->setIRLaserPower(rset->getInt( 50   ));
00485     result->setGreenLaserPower(rset->getInt( 51   ));
00486     result->setRedLaserPower(rset->getInt( 52   ));
00487     result->setBlueLaserLogAttenuator(rset->getInt( 53   ));
00488     result->setIRLaserLogAttenuator(rset->getInt( 54   ));
00489     result->setGreenLaserLogAttenuator(rset->getInt( 55   ));
00490     result->setRedLaserLogAttenuator(rset->getInt( 56   ));
00491     result->setLaserConfigFile(rset->getString( 57   ));
00492 
00493     Clob clob = rset->getClob (58);
00494     cout << "Opening the clob in Read only mode" << endl;
00495     clob.open (OCCI_LOB_READONLY);
00496     int clobLength=clob.length ();
00497     cout << "Length of the clob is: " << clobLength << endl;
00498     m_size=clobLength;
00499     unsigned char* buffer = readClob (clob, m_size);
00500     clob.close ();
00501     cout<< "the clob buffer is:"<<endl;
00502     for (int i = 0; i < clobLength; ++i)
00503       cout << (char) buffer[i];
00504     cout << endl;
00505 
00506     result->setLaserClob(buffer);
00507 
00508 
00509   } catch (SQLException &e) {
00510     throw(std::runtime_error("ODLaserConfig::fetchData():  "+e.getMessage()));
00511   }
00512 }
00513 
00514 int ODLaserConfig::fetchID()    throw(std::runtime_error)
00515 {
00516   // Return from memory if available
00517   if (m_ID!=0) {
00518     return m_ID;
00519   }
00520 
00521   this->checkConnection();
00522 
00523   try {
00524     Statement* stmt = m_conn->createStatement();
00525     stmt->setSQL("SELECT laser_configuration_id FROM ecal_laser_configuration "
00526                  "WHERE laser_tag=:laser_tag ");
00527     stmt->setString(1, getLaserTag());
00528 
00529     ResultSet* rset = stmt->executeQuery();
00530 
00531     if (rset->next()) {
00532       m_ID = rset->getInt(1);
00533     } else {
00534       m_ID = 0;
00535     }
00536     m_conn->terminateStatement(stmt);
00537   } catch (SQLException &e) {
00538     throw(std::runtime_error("ODLaserConfig::fetchID:  "+e.getMessage()));
00539   }
00540 
00541   fetchData(this);
00542 
00543   return m_ID;
00544 }