13 using namespace oracle::occi;
69 m_matacq_vernier_min=0;
70 m_matacq_vernier_max=0;
78 m_orange_led_mon_ampl=0;
79 m_blue_led_mon_ampl =0;
82 m_led_control_host=
"";
83 m_led_control_port =0;
85 m_green_laser_power=0;
87 m_blue_laser_log_attenuator =0;
88 m_ir_laser_log_attenuator =0;
89 m_green_laser_log_attenuator =0;
90 m_red_laser_log_attenuator =0;
91 m_laser_config_file =
"";
106 for( std::map<std::string, std::string >::const_iterator ci=
107 my_keys_map.begin(); ci!=my_keys_map.end(); ci++ ) {
109 if(ci->first==
"LASER_CONFIGURATION_ID") setConfigTag(ci->second);
110 if(ci->first==
"DEBUG") setDebug(atoi(ci->second.c_str()) );
111 if(ci->first==
"LASER_DEBUG") setDebug(atoi(ci->second.c_str()) );
112 if(ci->first==
"DUMMY") setDummy(atoi(ci->second.c_str() ));
113 if(ci->first==
"MATACQ_BASE_ADDRESS") setMatacqBaseAddress(atoi(ci->second.c_str() ));
114 if(ci->first==
"MATACQ_NONE") setMatacqNone(atoi(ci->second.c_str() ));
115 if(ci->first==
"MATACQ_MODE") setMatacqMode(ci->second);
116 if(ci->first==
"CHANNEL_MASK") setChannelMask(atoi(ci->second.c_str() ));
117 if(ci->first==
"MAX_SAMPLES_FOR_DAQ") setMaxSamplesForDaq(ci->second );
118 if(ci->first==
"MATACQ_FED_ID") setMatacqFedId(atoi(ci->second.c_str()) );
119 if(ci->first==
"PEDESTAL_FILE") setPedestalFile(ci->second );
120 if(ci->first==
"USE_BUFFER") setUseBuffer(atoi(ci->second.c_str())) ;
121 if(ci->first==
"POSTTRIG") setPostTrig(atoi(ci->second.c_str()) );
122 if(ci->first==
"FP_MODE") setFPMode(atoi(ci->second.c_str() ));
123 if(ci->first==
"HAL_MODULE_FILE") setHalModuleFile(ci->second );
124 if(ci->first==
"HAL_ADDRESS_TABLE_FILE" || ci->first==
"HAL_ADDRESST_ABLE_FILE") setHalAddressTableFile(ci->second);
125 if(ci->first==
"HAL_STATIC_TABLE_FILE") setHalStaticTableFile(ci->second );
126 if(ci->first==
"MATACQ_SERIAL_NUMBER") setMatacqSerialNumber(ci->second );
127 if(ci->first==
"PEDESTAL_RUN_EVENT_COUNT") setPedestalRunEventCount(atoi(ci->second.c_str()) );
128 if(ci->first==
"RAW_DATA_MODE") setRawDataMode(atoi(ci->second.c_str()) );
129 if(ci->first==
"ACQUISITION_MODE") setMatacqAcquisitionMode(ci->second );
130 if(ci->first==
"LOCAL_OUTPUT_FILE") setLocalOutputFile(ci->second );
131 if(ci->first==
"EMTC_NONE") setEMTCNone(atoi(ci->second.c_str()) );
132 if(ci->first==
"WTE2_LASER_DELAY") setWTE2LaserDelay(atoi(ci->second.c_str()) );
133 if(ci->first==
"LASER_PHASE") setLaserPhase(atoi(ci->second.c_str()) );
134 if(ci->first==
"EMTC_TTC_IN") setEMTCTTCIn(atoi(ci->second.c_str()) );
135 if(ci->first==
"EMTC_SLOT_ID") setEMTCSlotId(atoi(ci->second.c_str()) );
136 if(ci->first==
"WAVELENGTH") setWaveLength(atoi(ci->second.c_str()) );
137 if(ci->first==
"OPTICAL_SWITCH") setOpticalSwitch(atoi(ci->second.c_str()) );
138 if(ci->first==
"POWER_SETTING") setPower(atoi(ci->second.c_str()) );
139 if(ci->first==
"FILTER") setFilter(atoi(ci->second.c_str()) );
140 if(ci->first==
"LASER_CONTROL_ON") setLaserControlOn(atoi(ci->second.c_str()) );
141 if(ci->first==
"LASER_CONTROL_HOST") setLaserControlHost(ci->second );
142 if(ci->first==
"LASER_CONTROL_PORT") setLaserControlPort(atoi(ci->second.c_str()) );
143 if(ci->first==
"MATACQ_VERNIER_MAX") setMatacqVernierMax(atoi(ci->second.c_str()) );
144 if(ci->first==
"MATACQ_VERNIER_MIN") setMatacqVernierMin(atoi(ci->second.c_str()) );
146 if(ci->first==
"WTE_2_LED_DELAY") setWTE2LedDelay(atoi(ci->second.c_str()) );
147 if(ci->first==
"LED1_ON") setLed1ON(atoi(ci->second.c_str()) );
148 if(ci->first==
"LED2_ON") setLed2ON(atoi(ci->second.c_str()) );
149 if(ci->first==
"LED3_ON") setLed3ON(atoi(ci->second.c_str()) );
150 if(ci->first==
"LED4_ON") setLed4ON(atoi(ci->second.c_str()) );
151 if(ci->first==
"VINJ") setVinj(atoi(ci->second.c_str()) );
152 if(ci->first==
"ORANGE_LED_MON_AMPL") setOrangeLedMonAmpl(atoi(ci->second.c_str()) );
153 if(ci->first==
"BLUE_LED_MON_AMPL") setBlueLedMonAmpl(atoi(ci->second.c_str()) );
154 if(ci->first==
"TRIG_LOG_FILE") setTrigLogFile(ci->second.c_str() );
155 if(ci->first==
"LED_CONTROL_ON") setLedControlON(atoi(ci->second.c_str()) );
156 if(ci->first==
"LED_CONTROL_HOST") setLedControlHost( ci->second.c_str() );
157 if(ci->first==
"LED_CONTROL_PORT") setLedControlPort(atoi(ci->second.c_str()) );
158 if(ci->first==
"IR_LASER_POWER") setIRLaserPower(atoi(ci->second.c_str()) );
159 if(ci->first==
"GREEN_LASER_POWER") setGreenLaserPower(atoi(ci->second.c_str()) );
160 if(ci->first==
"RED_LASER_POWER") setRedLaserPower(atoi(ci->second.c_str()) );
161 if(ci->first==
"BLUE_LASER_LOG_ATTENUATOR") setBlueLaserLogAttenuator(atoi(ci->second.c_str()) );
162 if(ci->first==
"IR_LASER_LOG_ATTENUATOR") setIRLaserLogAttenuator(atoi(ci->second.c_str()) );
163 if(ci->first==
"GREEN_LASER_LOG_ATTENUATOR") setGreenLaserLogAttenuator(atoi(ci->second.c_str()) );
164 if(ci->first==
"RED_LASER_LOG_ATTENUATOR") setRedLaserLogAttenuator(atoi(ci->second.c_str()) );
167 if(ci->first==
"LASER_CONFIG_FILE") {
169 setLaserConfigFile(fname );
171 std::cout <<
"Going to read Laser file: " << fname << endl;
174 inpFile.open(fname.c_str());
179 bufsize = inpFile.tellg();
180 std::cout <<
" bufsize ="<<bufsize<< std::endl;
182 inpFile.seekg( 0,ios::beg );
199 this->checkConnection();
201 m_readStmt = m_conn->createStatement();
202 m_readStmt->setSQL(
"select ecal_laser_config_sq.NextVal from dual");
203 ResultSet* rset = m_readStmt->executeQuery();
204 while (rset->next ()){
205 result= rset->getInt(1);
207 m_conn->terminateStatement(m_readStmt);
211 throw(std::runtime_error(
"ODLaserConfig::fetchNextId(): "+e.getMessage()));
218 throw(std::runtime_error)
220 this->checkConnection();
221 int next_id=fetchNextId();
225 m_writeStmt = m_conn->createStatement();
226 m_writeStmt->setSQL(
"INSERT INTO ECAL_Laser_CONFIGURATION ( laser_configuration_id, laser_tag "
229 ", MATACQ_BASE_ADDRESS "
233 ", max_Samples_For_Daq "
240 ", hal_Address_Table_File "
241 ", hal_Static_Table_File "
242 ", matacq_Serial_Number "
243 ", pedestal_Run_Event_Count "
245 ", ACQUISITION_MODE "
246 ", LOCAL_OUTPUT_FILE "
248 ", wte2_laser_delay "
256 ", LASER_CONTROL_ON "
257 ", LASER_CONTROL_HOST "
258 ", LASER_CONTROL_PORT "
260 ", MATACQ_VERNIER_MIN "
261 ", MATACQ_VERNIER_MAX "
262 " , wte_2_led_delay "
268 " , orange_led_mon_ampl"
269 " , blue_led_mon_ampl "
272 " , led_control_host "
273 " , led_control_port "
275 " , green_laser_power"
276 " , red_laser_power "
277 " , blue_laser_log_attenuator "
278 " , IR_LASER_LOG_ATTENUATOR "
279 " , GREEN_LASER_LOG_ATTENUATOR"
280 " , RED_LASER_LOG_ATTENUATOR "
281 " , LASER_CONFIG_FILE "
282 " , laser_configuration ) "
283 " VALUES ( :1, :2, :3, :4, :5, :6, :7, :8, :9, :10, "
284 ":11, :12, :13, :14, :15, :16, :17, :18, :19, :20, "
285 ":21, :22, :23, :24, :25, :26, :27, :28, :29, :30, "
286 ":31, :32, :33, :34, :35, :36, :37, "
287 " :38, :39, :40, :41, :42, :43, :44, :45, :46, :47, :48, :49, :50, :51, :52, :53, :54, :55, :56, :57, :58 )");
288 m_writeStmt->setInt(1, next_id);
291 throw(std::runtime_error(
"ODLaserConfig::prepareWrite(): "+e.getMessage()));
298 throw(std::runtime_error)
300 this->checkConnection();
301 this->checkPrepare();
306 m_writeStmt->setString(2, this->getConfigTag());
308 m_writeStmt->setInt( 3, this->getDebug());
309 m_writeStmt->setInt( 4, this->getDummy());
310 m_writeStmt->setInt( 5, this->getMatacqBaseAddress());
311 m_writeStmt->setInt( 6, this->getMatacqNone());
312 m_writeStmt->setString(7, this->getMatacqMode());
313 m_writeStmt->setInt( 8, this->getChannelMask());
314 m_writeStmt->setString(9, this->getMaxSamplesForDaq());
315 m_writeStmt->setInt( 10, this->getMatacqFedId());
316 m_writeStmt->setString(11, this->getPedestalFile());
317 m_writeStmt->setInt( 12, this->getUseBuffer());
318 m_writeStmt->setInt( 13, this->getPostTrig());
319 m_writeStmt->setInt( 14, this->getFPMode());
320 m_writeStmt->setString(15, this->getHalModuleFile() );
321 m_writeStmt->setString(16, this->getHalAddressTableFile() );
322 m_writeStmt->setString(17, this->getHalStaticTableFile() );
323 m_writeStmt->setString(18, this->getMatacqSerialNumber() );
324 m_writeStmt->setInt( 19, this->getPedestalRunEventCount() );
325 m_writeStmt->setInt( 20, this->getRawDataMode());
326 m_writeStmt->setString(21, this->getMatacqAcquisitionMode());
327 m_writeStmt->setString(22, this->getLocalOutputFile());
328 m_writeStmt->setInt( 23, this->getEMTCNone());
329 m_writeStmt->setInt( 24, this->getWTE2LaserDelay());
330 m_writeStmt->setInt( 25, this->getLaserPhase());
331 m_writeStmt->setInt( 26, this->getEMTCTTCIn());
332 m_writeStmt->setInt( 27, this->getEMTCSlotId());
334 m_writeStmt->setInt(28, this->getWaveLength());
335 m_writeStmt->setInt(29, this->getPower());
336 m_writeStmt->setInt(30, this->getOpticalSwitch());
337 m_writeStmt->setInt(31, this->getFilter());
338 m_writeStmt->setInt(32, this->getLaserControlOn());
339 m_writeStmt->setString(33, this->getLaserControlHost() );
340 m_writeStmt->setInt( 34, this->getLaserControlPort());
341 m_writeStmt->setString( 35, this->getLaserTag());
343 m_writeStmt->setInt( 36, this->getMatacqVernierMin());
344 m_writeStmt->setInt( 37, this->getMatacqVernierMax());
348 m_writeStmt->setInt( 38, this->getWTE2LedDelay());
349 m_writeStmt->setInt( 39, this->getLed1ON());
350 m_writeStmt->setInt( 40, this->getLed2ON());
351 m_writeStmt->setInt( 41, this->getLed3ON());
352 m_writeStmt->setInt( 42, this->getLed4ON());
353 m_writeStmt->setInt( 43, this->getVinj());
354 m_writeStmt->setInt( 44, this->getOrangeLedMonAmpl());
355 m_writeStmt->setInt( 45, this->getBlueLedMonAmpl());
356 m_writeStmt->setString( 46, this->getTrigLogFile());
357 m_writeStmt->setInt( 47, this->getLedControlON());
358 m_writeStmt->setString( 48, this->getLedControlHost());
359 m_writeStmt->setInt( 49, this->getLedControlPort());
360 m_writeStmt->setInt( 50, this->getIRLaserPower());
361 m_writeStmt->setInt( 51, this->getGreenLaserPower());
362 m_writeStmt->setInt( 52, this->getRedLaserPower());
363 m_writeStmt->setInt( 53, this->getBlueLaserLogAttenuator());
364 m_writeStmt->setInt( 54, this->getIRLaserLogAttenuator());
365 m_writeStmt->setInt( 55, this->getGreenLaserLogAttenuator());
366 m_writeStmt->setInt( 56, this->getRedLaserLogAttenuator());
367 m_writeStmt->setString( 57, this->getLaserConfigFile());
370 oracle::occi::Clob clob(m_conn);
372 m_writeStmt->setClob(58,clob);
373 m_writeStmt->executeUpdate ();
374 m_conn->terminateStatement(m_writeStmt);
377 m_writeStmt = m_conn->createStatement();
378 m_writeStmt->setSQL (
"SELECT laser_configuration FROM "+getTable()+
" WHERE"
379 " laser_configuration_id=:1 FOR UPDATE");
380 std::cout<<
"updating the laser clob "<<std::endl;
383 m_writeStmt->setInt(1, m_ID);
384 ResultSet* rset = m_writeStmt->executeQuery();
386 oracle::occi::Clob clob_to_write = rset->getClob (1);
387 cout <<
"Opening the clob in read write mode" << endl;
389 populateClob (clob_to_write, getLaserConfigFile(), m_size);
390 int clobLength=clob_to_write.length ();
391 cout <<
"Length of the clob is: " << clobLength << endl;
392 m_writeStmt->executeUpdate();
393 m_writeStmt->closeResultSet (rset);
397 throw(std::runtime_error(
"ODLaserConfig::writeDB(): "+e.getMessage()));
400 if (!this->fetchID()) {
401 throw(std::runtime_error(
"ODLaserConfig::writeDB: Failed to write"));
409 throw(std::runtime_error)
411 this->checkConnection();
413 if(
result->getId()==0 && (
result->getConfigTag()==
"") ){
414 throw(std::runtime_error(
"ODLaserConfig::fetchData(): no Id defined for this ODLaserConfig "));
419 m_readStmt->setSQL(
"SELECT * "
421 " where ( laser_configuration_id = :1 or laser_tag=:2 )" );
422 m_readStmt->setInt(1,
result->getId());
423 m_readStmt->setString(2,
result->getConfigTag());
424 ResultSet* rset = m_readStmt->executeQuery();
431 result->setId(rset->getInt(1));
432 result->setConfigTag(rset->getString(2));
434 result->setDebug(rset->getInt( 3 ));
435 result->setDummy(rset->getInt( 4 ));
436 result->setMatacqBaseAddress(rset->getInt( 5 ));
437 result->setMatacqNone(rset->getInt( 6 ));
438 result->setMatacqMode(rset->getString(7 ));
439 result->setChannelMask(rset->getInt( 8 ));
440 result->setMaxSamplesForDaq(rset->getString( 9 ));
441 result->setMatacqFedId(rset->getInt( 10 ));
442 result->setPedestalFile(rset->getString( 11 ));
443 result->setUseBuffer(rset->getInt( 12 ));
444 result->setPostTrig(rset->getInt( 13 ));
445 result->setFPMode(rset->getInt( 14 ));
446 result->setHalModuleFile(rset->getString( 15 ));
447 result->setHalAddressTableFile(rset->getString( 16 ));
448 result->setHalStaticTableFile(rset->getString( 17 ));
449 result->setMatacqSerialNumber(rset->getString( 18 ));
450 result->setPedestalRunEventCount(rset->getInt( 19 ));
451 result->setRawDataMode(rset->getInt( 20 ));
452 result->setMatacqAcquisitionMode(rset->getString( 21 ));
453 result->setLocalOutputFile(rset->getString( 22 ));
454 result->setEMTCNone(rset->getInt( 23 ));
455 result->setWTE2LaserDelay(rset->getInt( 24 ));
456 result->setLaserPhase(rset->getInt( 25 ));
457 result->setEMTCTTCIn(rset->getInt( 26 ));
458 result->setEMTCSlotId(rset->getInt( 27 ));
460 result->setWaveLength(rset->getInt( 28 ));
461 result->setPower(rset->getInt( 29 ));
462 result->setOpticalSwitch(rset->getInt( 30 ));
463 result->setFilter(rset->getInt( 31 ));
464 result->setLaserControlOn(rset->getInt( 32 ));
465 result->setLaserControlHost(rset->getString( 33 ));
466 result->setLaserControlPort(rset->getInt( 34 ));
467 result->setLaserTag(rset->getString( 35 ));
469 result->setMatacqVernierMin(rset->getInt( 36 ));
470 result->setMatacqVernierMax(rset->getInt( 37 ));
472 result->setWTE2LedDelay(rset->getInt( 38 ));
473 result->setLed1ON(rset->getInt( 39 ));
474 result->setLed2ON(rset->getInt( 40 ));
475 result->setLed3ON(rset->getInt( 41 ));
476 result->setLed4ON(rset->getInt( 42 ));
477 result->setVinj(rset->getInt( 43 ));
478 result->setOrangeLedMonAmpl(rset->getInt( 44 ));
479 result->setBlueLedMonAmpl(rset->getInt( 45 ));
480 result->setTrigLogFile(rset->getString( 46 ));
481 result->setLedControlON(rset->getInt( 47 ));
482 result->setLedControlHost(rset->getString( 48 ));
483 result->setLedControlPort(rset->getInt( 49 ));
484 result->setIRLaserPower(rset->getInt( 50 ));
485 result->setGreenLaserPower(rset->getInt( 51 ));
486 result->setRedLaserPower(rset->getInt( 52 ));
487 result->setBlueLaserLogAttenuator(rset->getInt( 53 ));
488 result->setIRLaserLogAttenuator(rset->getInt( 54 ));
489 result->setGreenLaserLogAttenuator(rset->getInt( 55 ));
490 result->setRedLaserLogAttenuator(rset->getInt( 56 ));
491 result->setLaserConfigFile(rset->getString( 57 ));
493 Clob clob = rset->getClob (58);
494 cout <<
"Opening the clob in Read only mode" << endl;
495 clob.open (OCCI_LOB_READONLY);
496 int clobLength=clob.length ();
497 cout <<
"Length of the clob is: " << clobLength << endl;
499 unsigned char* buffer = readClob (clob, m_size);
501 cout<<
"the clob buffer is:"<<endl;
502 for (
int i = 0;
i < clobLength; ++
i)
503 cout << (
char) buffer[
i];
506 result->setLaserClob(buffer);
510 throw(std::runtime_error(
"ODLaserConfig::fetchData(): "+e.getMessage()));
521 this->checkConnection();
524 Statement* stmt = m_conn->createStatement();
525 stmt->setSQL(
"SELECT laser_configuration_id FROM ecal_laser_configuration "
526 "WHERE laser_tag=:laser_tag ");
527 stmt->setString(1, getLaserTag());
532 m_ID = rset->getInt(1);
536 m_conn->terminateStatement(stmt);
538 throw(std::runtime_error(
"ODLaserConfig::fetchID: "+e.getMessage()));
void setParameters(const std::map< std::string, std::string > &my_keys_map)
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
oracle::occi::Statement Statement
oracle::occi::ResultSet ResultSet
oracle::occi::SQLException SQLException
void fetchData(ODLaserConfig *result)