File indexing completed on 2023-03-17 11:15:23
0001 #include <stdexcept>
0002 #include <string>
0003 #include <fstream>
0004 #include <iostream>
0005 #include <cstdio>
0006 #include <cstdlib>
0007
0008 #include "OnlineDB/Oracle/interface/Oracle.h"
0009
0010 #include "OnlineDB/EcalCondDB/interface/ODLaserConfig.h"
0011
0012 using namespace std;
0013 using namespace oracle::occi;
0014
0015 ODLaserConfig::ODLaserConfig() {
0016 m_env = nullptr;
0017 m_conn = nullptr;
0018 m_writeStmt = nullptr;
0019 m_readStmt = nullptr;
0020 m_size = 0;
0021 m_config_tag = "";
0022 m_ID = 0;
0023 clear();
0024 }
0025
0026 void ODLaserConfig::clear() {
0027 m_debug = 0;
0028 m_dummy = 0;
0029
0030
0031 m_emtc_1 = 0;
0032 m_emtc_2 = 0;
0033 m_emtc_3 = 0;
0034 m_emtc_4 = 0;
0035 m_emtc_5 = 0;
0036
0037
0038 m_wave = 0;
0039 m_power = 0;
0040 m_switch = 0;
0041 m_filter = 0;
0042 m_on = 0;
0043 m_laserhost = "";
0044 m_laserport = 0;
0045
0046
0047 m_mq_base = 0;
0048 m_mq_none = 0;
0049 m_mode = "";
0050 m_chan_mask = 0;
0051 m_samples = "";
0052 m_ped_file = "";
0053 m_use_buffer = 0;
0054 m_post_trig = 0;
0055 m_fp_mode = 0;
0056 m_hal_mod_file = "";
0057 m_hal_add_file = "";
0058 m_hal_tab_file = "";
0059 m_serial = "";
0060 m_ped_count = 0;
0061 m_raw_mode = 0;
0062 m_aqmode = "";
0063 m_mq_file = "";
0064 m_laser_tag = "";
0065 m_matacq_vernier_min = 0;
0066 m_matacq_vernier_max = 0;
0067
0068 m_wte_2_led_delay = 0;
0069 m_led1_on = 0;
0070 m_led2_on = 0;
0071 m_led3_on = 0;
0072 m_led4_on = 0;
0073 m_vinj = 0;
0074 m_orange_led_mon_ampl = 0;
0075 m_blue_led_mon_ampl = 0;
0076 m_trig_log_file = "";
0077 m_led_control_on = 0;
0078 m_led_control_host = "";
0079 m_led_control_port = 0;
0080 m_ir_laser_power = 0;
0081 m_green_laser_power = 0;
0082 m_red_laser_power = 0;
0083 m_blue_laser_log_attenuator = 0;
0084 m_ir_laser_log_attenuator = 0;
0085 m_green_laser_log_attenuator = 0;
0086 m_red_laser_log_attenuator = 0;
0087 m_laser_config_file = "";
0088 }
0089
0090 ODLaserConfig::~ODLaserConfig() {}
0091
0092 void ODLaserConfig::setParameters(const std::map<string, string>& my_keys_map) {
0093
0094
0095
0096 for (std::map<std::string, std::string>::const_iterator ci = my_keys_map.begin(); ci != my_keys_map.end(); ci++) {
0097 if (ci->first == "LASER_CONFIGURATION_ID")
0098 setConfigTag(ci->second);
0099 if (ci->first == "DEBUG")
0100 setDebug(atoi(ci->second.c_str()));
0101 if (ci->first == "LASER_DEBUG")
0102 setDebug(atoi(ci->second.c_str()));
0103 if (ci->first == "DUMMY")
0104 setDummy(atoi(ci->second.c_str()));
0105 if (ci->first == "MATACQ_BASE_ADDRESS")
0106 setMatacqBaseAddress(atoi(ci->second.c_str()));
0107 if (ci->first == "MATACQ_NONE")
0108 setMatacqNone(atoi(ci->second.c_str()));
0109 if (ci->first == "MATACQ_MODE")
0110 setMatacqMode(ci->second);
0111 if (ci->first == "CHANNEL_MASK")
0112 setChannelMask(atoi(ci->second.c_str()));
0113 if (ci->first == "MAX_SAMPLES_FOR_DAQ")
0114 setMaxSamplesForDaq(ci->second);
0115 if (ci->first == "MATACQ_FED_ID")
0116 setMatacqFedId(atoi(ci->second.c_str()));
0117 if (ci->first == "PEDESTAL_FILE")
0118 setPedestalFile(ci->second);
0119 if (ci->first == "USE_BUFFER")
0120 setUseBuffer(atoi(ci->second.c_str()));
0121 if (ci->first == "POSTTRIG")
0122 setPostTrig(atoi(ci->second.c_str()));
0123 if (ci->first == "FP_MODE")
0124 setFPMode(atoi(ci->second.c_str()));
0125 if (ci->first == "HAL_MODULE_FILE")
0126 setHalModuleFile(ci->second);
0127 if (ci->first == "HAL_ADDRESS_TABLE_FILE" || ci->first == "HAL_ADDRESST_ABLE_FILE")
0128 setHalAddressTableFile(ci->second);
0129 if (ci->first == "HAL_STATIC_TABLE_FILE")
0130 setHalStaticTableFile(ci->second);
0131 if (ci->first == "MATACQ_SERIAL_NUMBER")
0132 setMatacqSerialNumber(ci->second);
0133 if (ci->first == "PEDESTAL_RUN_EVENT_COUNT")
0134 setPedestalRunEventCount(atoi(ci->second.c_str()));
0135 if (ci->first == "RAW_DATA_MODE")
0136 setRawDataMode(atoi(ci->second.c_str()));
0137 if (ci->first == "ACQUISITION_MODE")
0138 setMatacqAcquisitionMode(ci->second);
0139 if (ci->first == "LOCAL_OUTPUT_FILE")
0140 setLocalOutputFile(ci->second);
0141 if (ci->first == "EMTC_NONE")
0142 setEMTCNone(atoi(ci->second.c_str()));
0143 if (ci->first == "WTE2_LASER_DELAY")
0144 setWTE2LaserDelay(atoi(ci->second.c_str()));
0145 if (ci->first == "LASER_PHASE")
0146 setLaserPhase(atoi(ci->second.c_str()));
0147 if (ci->first == "EMTC_TTC_IN")
0148 setEMTCTTCIn(atoi(ci->second.c_str()));
0149 if (ci->first == "EMTC_SLOT_ID")
0150 setEMTCSlotId(atoi(ci->second.c_str()));
0151 if (ci->first == "WAVELENGTH")
0152 setWaveLength(atoi(ci->second.c_str()));
0153 if (ci->first == "OPTICAL_SWITCH")
0154 setOpticalSwitch(atoi(ci->second.c_str()));
0155 if (ci->first == "POWER_SETTING")
0156 setPower(atoi(ci->second.c_str()));
0157 if (ci->first == "FILTER")
0158 setFilter(atoi(ci->second.c_str()));
0159 if (ci->first == "LASER_CONTROL_ON")
0160 setLaserControlOn(atoi(ci->second.c_str()));
0161 if (ci->first == "LASER_CONTROL_HOST")
0162 setLaserControlHost(ci->second);
0163 if (ci->first == "LASER_CONTROL_PORT")
0164 setLaserControlPort(atoi(ci->second.c_str()));
0165 if (ci->first == "MATACQ_VERNIER_MAX")
0166 setMatacqVernierMax(atoi(ci->second.c_str()));
0167 if (ci->first == "MATACQ_VERNIER_MIN")
0168 setMatacqVernierMin(atoi(ci->second.c_str()));
0169
0170 if (ci->first == "WTE_2_LED_DELAY")
0171 setWTE2LedDelay(atoi(ci->second.c_str()));
0172 if (ci->first == "LED1_ON")
0173 setLed1ON(atoi(ci->second.c_str()));
0174 if (ci->first == "LED2_ON")
0175 setLed2ON(atoi(ci->second.c_str()));
0176 if (ci->first == "LED3_ON")
0177 setLed3ON(atoi(ci->second.c_str()));
0178 if (ci->first == "LED4_ON")
0179 setLed4ON(atoi(ci->second.c_str()));
0180 if (ci->first == "VINJ")
0181 setVinj(atoi(ci->second.c_str()));
0182 if (ci->first == "ORANGE_LED_MON_AMPL")
0183 setOrangeLedMonAmpl(atoi(ci->second.c_str()));
0184 if (ci->first == "BLUE_LED_MON_AMPL")
0185 setBlueLedMonAmpl(atoi(ci->second.c_str()));
0186 if (ci->first == "TRIG_LOG_FILE")
0187 setTrigLogFile(ci->second);
0188 if (ci->first == "LED_CONTROL_ON")
0189 setLedControlON(atoi(ci->second.c_str()));
0190 if (ci->first == "LED_CONTROL_HOST")
0191 setLedControlHost(ci->second);
0192 if (ci->first == "LED_CONTROL_PORT")
0193 setLedControlPort(atoi(ci->second.c_str()));
0194 if (ci->first == "IR_LASER_POWER")
0195 setIRLaserPower(atoi(ci->second.c_str()));
0196 if (ci->first == "GREEN_LASER_POWER")
0197 setGreenLaserPower(atoi(ci->second.c_str()));
0198 if (ci->first == "RED_LASER_POWER")
0199 setRedLaserPower(atoi(ci->second.c_str()));
0200 if (ci->first == "BLUE_LASER_LOG_ATTENUATOR")
0201 setBlueLaserLogAttenuator(atoi(ci->second.c_str()));
0202 if (ci->first == "IR_LASER_LOG_ATTENUATOR")
0203 setIRLaserLogAttenuator(atoi(ci->second.c_str()));
0204 if (ci->first == "GREEN_LASER_LOG_ATTENUATOR")
0205 setGreenLaserLogAttenuator(atoi(ci->second.c_str()));
0206 if (ci->first == "RED_LASER_LOG_ATTENUATOR")
0207 setRedLaserLogAttenuator(atoi(ci->second.c_str()));
0208
0209 if (ci->first == "LASER_CONFIG_FILE") {
0210 std::string fname = ci->second;
0211 setLaserConfigFile(fname);
0212
0213 std::cout << "Going to read Laser file: " << fname << endl;
0214
0215 ifstream inpFile;
0216 inpFile.open(fname.c_str());
0217
0218
0219 int bufsize = 0;
0220 inpFile.seekg(0, ios::end);
0221 bufsize = inpFile.tellg();
0222 std::cout << " bufsize =" << bufsize << std::endl;
0223
0224 inpFile.seekg(0, ios::beg);
0225
0226 m_size = bufsize;
0227
0228 inpFile.close();
0229 }
0230 }
0231 }
0232
0233 int ODLaserConfig::fetchNextId() noexcept(false) {
0234 int result = 0;
0235 try {
0236 this->checkConnection();
0237
0238 m_readStmt = m_conn->createStatement();
0239 m_readStmt->setSQL("select ecal_laser_config_sq.NextVal from dual");
0240 ResultSet* rset = m_readStmt->executeQuery();
0241 while (rset->next()) {
0242 result = rset->getInt(1);
0243 }
0244 m_conn->terminateStatement(m_readStmt);
0245 return result;
0246
0247 } catch (SQLException& e) {
0248 throw(std::runtime_error(std::string("ODLaserConfig::fetchNextId(): ") + e.getMessage()));
0249 }
0250 }
0251
0252 void ODLaserConfig::prepareWrite() noexcept(false) {
0253 this->checkConnection();
0254 int next_id = fetchNextId();
0255
0256 try {
0257 m_writeStmt = m_conn->createStatement();
0258 m_writeStmt->setSQL(
0259 "INSERT INTO ECAL_Laser_CONFIGURATION ( laser_configuration_id, laser_tag "
0260 ", laser_DEBUG "
0261 ", DUMMY "
0262 ", MATACQ_BASE_ADDRESS "
0263 ", MATACQ_NONE "
0264 ", matacq_mode "
0265 ", channel_Mask "
0266 ", max_Samples_For_Daq "
0267 ", maTACQ_FED_ID "
0268 ", pedestal_File "
0269 ", use_Buffer "
0270 ", postTrig "
0271 ", fp_Mode "
0272 ", hal_Module_File "
0273 ", hal_Address_Table_File "
0274 ", hal_Static_Table_File "
0275 ", matacq_Serial_Number "
0276 ", pedestal_Run_Event_Count "
0277 ", raw_Data_Mode "
0278 ", ACQUISITION_MODE "
0279 ", LOCAL_OUTPUT_FILE "
0280 ", emtc_none "
0281 ", wte2_laser_delay "
0282 ", laser_phase "
0283 ", emtc_ttc_in "
0284 ", emtc_slot_id "
0285 ", WAVELENGTH "
0286 ", POWER_SETTING "
0287 ", OPTICAL_SWITCH "
0288 ", FILTER "
0289 ", LASER_CONTROL_ON "
0290 ", LASER_CONTROL_HOST "
0291 ", LASER_CONTROL_PORT "
0292 ", LASER_TAG2 "
0293 ", MATACQ_VERNIER_MIN "
0294 ", MATACQ_VERNIER_MAX "
0295 " , wte_2_led_delay "
0296 " , led1_on "
0297 " , led2_on "
0298 " , led3_on "
0299 " , led4_on "
0300 " , VINJ "
0301 " , orange_led_mon_ampl"
0302 " , blue_led_mon_ampl "
0303 " , trig_log_file "
0304 " , led_control_on "
0305 " , led_control_host "
0306 " , led_control_port "
0307 " , ir_laser_power "
0308 " , green_laser_power"
0309 " , red_laser_power "
0310 " , blue_laser_log_attenuator "
0311 " , IR_LASER_LOG_ATTENUATOR "
0312 " , GREEN_LASER_LOG_ATTENUATOR"
0313 " , RED_LASER_LOG_ATTENUATOR "
0314 " , LASER_CONFIG_FILE "
0315 " , laser_configuration ) "
0316 " VALUES ( :1, :2, :3, :4, :5, :6, :7, :8, :9, :10, "
0317 ":11, :12, :13, :14, :15, :16, :17, :18, :19, :20, "
0318 ":21, :22, :23, :24, :25, :26, :27, :28, :29, :30, "
0319 ":31, :32, :33, :34, :35, :36, :37, "
0320 " :38, :39, :40, :41, :42, :43, :44, :45, :46, :47, :48, :49, :50, :51, :52, :53, :54, :55, :56, :57, :58 )");
0321 m_writeStmt->setInt(1, next_id);
0322 m_ID = next_id;
0323 } catch (SQLException& e) {
0324 throw(std::runtime_error(std::string("ODLaserConfig::prepareWrite(): ") + e.getMessage()));
0325 }
0326 }
0327
0328 void ODLaserConfig::writeDB() noexcept(false) {
0329 this->checkConnection();
0330 this->checkPrepare();
0331
0332 try {
0333
0334 m_writeStmt->setString(2, this->getConfigTag());
0335
0336 m_writeStmt->setInt(3, this->getDebug());
0337 m_writeStmt->setInt(4, this->getDummy());
0338 m_writeStmt->setInt(5, this->getMatacqBaseAddress());
0339 m_writeStmt->setInt(6, this->getMatacqNone());
0340 m_writeStmt->setString(7, this->getMatacqMode());
0341 m_writeStmt->setInt(8, this->getChannelMask());
0342 m_writeStmt->setString(9, this->getMaxSamplesForDaq());
0343 m_writeStmt->setInt(10, this->getMatacqFedId());
0344 m_writeStmt->setString(11, this->getPedestalFile());
0345 m_writeStmt->setInt(12, this->getUseBuffer());
0346 m_writeStmt->setInt(13, this->getPostTrig());
0347 m_writeStmt->setInt(14, this->getFPMode());
0348 m_writeStmt->setString(15, this->getHalModuleFile());
0349 m_writeStmt->setString(16, this->getHalAddressTableFile());
0350 m_writeStmt->setString(17, this->getHalStaticTableFile());
0351 m_writeStmt->setString(18, this->getMatacqSerialNumber());
0352 m_writeStmt->setInt(19, this->getPedestalRunEventCount());
0353 m_writeStmt->setInt(20, this->getRawDataMode());
0354 m_writeStmt->setString(21, this->getMatacqAcquisitionMode());
0355 m_writeStmt->setString(22, this->getLocalOutputFile());
0356 m_writeStmt->setInt(23, this->getEMTCNone());
0357 m_writeStmt->setInt(24, this->getWTE2LaserDelay());
0358 m_writeStmt->setInt(25, this->getLaserPhase());
0359 m_writeStmt->setInt(26, this->getEMTCTTCIn());
0360 m_writeStmt->setInt(27, this->getEMTCSlotId());
0361
0362 m_writeStmt->setInt(28, this->getWaveLength());
0363 m_writeStmt->setInt(29, this->getPower());
0364 m_writeStmt->setInt(30, this->getOpticalSwitch());
0365 m_writeStmt->setInt(31, this->getFilter());
0366 m_writeStmt->setInt(32, this->getLaserControlOn());
0367 m_writeStmt->setString(33, this->getLaserControlHost());
0368 m_writeStmt->setInt(34, this->getLaserControlPort());
0369 m_writeStmt->setString(35, this->getLaserTag());
0370
0371 m_writeStmt->setInt(36, this->getMatacqVernierMin());
0372 m_writeStmt->setInt(37, this->getMatacqVernierMax());
0373
0374
0375 m_writeStmt->setInt(38, this->getWTE2LedDelay());
0376 m_writeStmt->setInt(39, this->getLed1ON());
0377 m_writeStmt->setInt(40, this->getLed2ON());
0378 m_writeStmt->setInt(41, this->getLed3ON());
0379 m_writeStmt->setInt(42, this->getLed4ON());
0380 m_writeStmt->setInt(43, this->getVinj());
0381 m_writeStmt->setInt(44, this->getOrangeLedMonAmpl());
0382 m_writeStmt->setInt(45, this->getBlueLedMonAmpl());
0383 m_writeStmt->setString(46, this->getTrigLogFile());
0384 m_writeStmt->setInt(47, this->getLedControlON());
0385 m_writeStmt->setString(48, this->getLedControlHost());
0386 m_writeStmt->setInt(49, this->getLedControlPort());
0387 m_writeStmt->setInt(50, this->getIRLaserPower());
0388 m_writeStmt->setInt(51, this->getGreenLaserPower());
0389 m_writeStmt->setInt(52, this->getRedLaserPower());
0390 m_writeStmt->setInt(53, this->getBlueLaserLogAttenuator());
0391 m_writeStmt->setInt(54, this->getIRLaserLogAttenuator());
0392 m_writeStmt->setInt(55, this->getGreenLaserLogAttenuator());
0393 m_writeStmt->setInt(56, this->getRedLaserLogAttenuator());
0394 m_writeStmt->setString(57, this->getLaserConfigFile());
0395
0396
0397 oracle::occi::Clob clob(m_conn);
0398 clob.setEmpty();
0399 m_writeStmt->setClob(58, clob);
0400 m_writeStmt->executeUpdate();
0401 m_conn->terminateStatement(m_writeStmt);
0402
0403
0404 m_writeStmt = m_conn->createStatement();
0405 m_writeStmt->setSQL("SELECT laser_configuration FROM " + getTable() +
0406 " WHERE"
0407 " laser_configuration_id=:1 FOR UPDATE");
0408 std::cout << "updating the laser clob " << std::endl;
0409
0410 m_writeStmt->setInt(1, m_ID);
0411 ResultSet* rset = m_writeStmt->executeQuery();
0412 rset->next();
0413 oracle::occi::Clob clob_to_write = rset->getClob(1);
0414 cout << "Opening the clob in read write mode" << endl;
0415
0416 populateClob(clob_to_write, getLaserConfigFile(), m_size);
0417 int clobLength = clob_to_write.length();
0418 cout << "Length of the clob is: " << clobLength << endl;
0419 m_writeStmt->executeUpdate();
0420 m_writeStmt->closeResultSet(rset);
0421
0422 } catch (SQLException& e) {
0423 throw(std::runtime_error(std::string("ODLaserConfig::writeDB(): ") + e.getMessage()));
0424 }
0425
0426 if (!this->fetchID()) {
0427 throw(std::runtime_error("ODLaserConfig::writeDB: Failed to write"));
0428 }
0429 }
0430
0431 void ODLaserConfig::fetchData(ODLaserConfig* result) noexcept(false) {
0432 this->checkConnection();
0433 result->clear();
0434 if (result->getId() == 0 && (result->getConfigTag().empty())) {
0435 throw(std::runtime_error("ODLaserConfig::fetchData(): no Id defined for this ODLaserConfig "));
0436 }
0437
0438 try {
0439 m_readStmt->setSQL(
0440 "SELECT * "
0441 "FROM " +
0442 getTable() + " where ( laser_configuration_id = :1 or laser_tag=:2 )");
0443 m_readStmt->setInt(1, result->getId());
0444 m_readStmt->setString(2, result->getConfigTag());
0445 ResultSet* rset = m_readStmt->executeQuery();
0446
0447 rset->next();
0448
0449
0450
0451 result->setId(rset->getInt(1));
0452 result->setConfigTag(rset->getString(2));
0453
0454 result->setDebug(rset->getInt(3));
0455 result->setDummy(rset->getInt(4));
0456 result->setMatacqBaseAddress(rset->getInt(5));
0457 result->setMatacqNone(rset->getInt(6));
0458 result->setMatacqMode(rset->getString(7));
0459 result->setChannelMask(rset->getInt(8));
0460 result->setMaxSamplesForDaq(rset->getString(9));
0461 result->setMatacqFedId(rset->getInt(10));
0462 result->setPedestalFile(rset->getString(11));
0463 result->setUseBuffer(rset->getInt(12));
0464 result->setPostTrig(rset->getInt(13));
0465 result->setFPMode(rset->getInt(14));
0466 result->setHalModuleFile(rset->getString(15));
0467 result->setHalAddressTableFile(rset->getString(16));
0468 result->setHalStaticTableFile(rset->getString(17));
0469 result->setMatacqSerialNumber(rset->getString(18));
0470 result->setPedestalRunEventCount(rset->getInt(19));
0471 result->setRawDataMode(rset->getInt(20));
0472 result->setMatacqAcquisitionMode(rset->getString(21));
0473 result->setLocalOutputFile(rset->getString(22));
0474 result->setEMTCNone(rset->getInt(23));
0475 result->setWTE2LaserDelay(rset->getInt(24));
0476 result->setLaserPhase(rset->getInt(25));
0477 result->setEMTCTTCIn(rset->getInt(26));
0478 result->setEMTCSlotId(rset->getInt(27));
0479
0480 result->setWaveLength(rset->getInt(28));
0481 result->setPower(rset->getInt(29));
0482 result->setOpticalSwitch(rset->getInt(30));
0483 result->setFilter(rset->getInt(31));
0484 result->setLaserControlOn(rset->getInt(32));
0485 result->setLaserControlHost(rset->getString(33));
0486 result->setLaserControlPort(rset->getInt(34));
0487 result->setLaserTag(rset->getString(35));
0488
0489 result->setMatacqVernierMin(rset->getInt(36));
0490 result->setMatacqVernierMax(rset->getInt(37));
0491
0492 result->setWTE2LedDelay(rset->getInt(38));
0493 result->setLed1ON(rset->getInt(39));
0494 result->setLed2ON(rset->getInt(40));
0495 result->setLed3ON(rset->getInt(41));
0496 result->setLed4ON(rset->getInt(42));
0497 result->setVinj(rset->getInt(43));
0498 result->setOrangeLedMonAmpl(rset->getInt(44));
0499 result->setBlueLedMonAmpl(rset->getInt(45));
0500 result->setTrigLogFile(rset->getString(46));
0501 result->setLedControlON(rset->getInt(47));
0502 result->setLedControlHost(rset->getString(48));
0503 result->setLedControlPort(rset->getInt(49));
0504 result->setIRLaserPower(rset->getInt(50));
0505 result->setGreenLaserPower(rset->getInt(51));
0506 result->setRedLaserPower(rset->getInt(52));
0507 result->setBlueLaserLogAttenuator(rset->getInt(53));
0508 result->setIRLaserLogAttenuator(rset->getInt(54));
0509 result->setGreenLaserLogAttenuator(rset->getInt(55));
0510 result->setRedLaserLogAttenuator(rset->getInt(56));
0511 result->setLaserConfigFile(rset->getString(57));
0512
0513 Clob clob = rset->getClob(58);
0514 cout << "Opening the clob in Read only mode" << endl;
0515 clob.open(OCCI_LOB_READONLY);
0516 int clobLength = clob.length();
0517 cout << "Length of the clob is: " << clobLength << endl;
0518 m_size = clobLength;
0519 unsigned char* buffer = readClob(clob, m_size);
0520 clob.close();
0521 cout << "the clob buffer is:" << endl;
0522 for (int i = 0; i < clobLength; ++i)
0523 cout << (char)buffer[i];
0524 cout << endl;
0525
0526 result->setLaserClob(buffer);
0527
0528 } catch (SQLException& e) {
0529 throw(std::runtime_error(std::string("ODLaserConfig::fetchData(): ") + e.getMessage()));
0530 }
0531 }
0532
0533 int ODLaserConfig::fetchID() noexcept(false) {
0534
0535 if (m_ID != 0) {
0536 return m_ID;
0537 }
0538
0539 this->checkConnection();
0540
0541 try {
0542 Statement* stmt = m_conn->createStatement();
0543 stmt->setSQL(
0544 "SELECT laser_configuration_id FROM ecal_laser_configuration "
0545 "WHERE laser_tag=:laser_tag ");
0546 stmt->setString(1, getLaserTag());
0547
0548 ResultSet* rset = stmt->executeQuery();
0549
0550 if (rset->next()) {
0551 m_ID = rset->getInt(1);
0552 } else {
0553 m_ID = 0;
0554 }
0555 m_conn->terminateStatement(stmt);
0556 } catch (SQLException& e) {
0557 throw(std::runtime_error(std::string("ODLaserConfig::fetchID: ") + e.getMessage()));
0558 }
0559
0560 fetchData(this);
0561
0562 return m_ID;
0563 }