18 m_writeStmt =
nullptr;
65 m_matacq_vernier_min = 0;
66 m_matacq_vernier_max = 0;
68 m_wte_2_led_delay = 0;
74 m_orange_led_mon_ampl = 0;
75 m_blue_led_mon_ampl = 0;
78 m_led_control_host =
"";
79 m_led_control_port = 0;
81 m_green_laser_power = 0;
82 m_red_laser_power = 0;
83 m_blue_laser_log_attenuator = 0;
84 m_ir_laser_log_attenuator = 0;
85 m_green_laser_log_attenuator = 0;
86 m_red_laser_log_attenuator = 0;
87 m_laser_config_file =
"";
96 for (std::map<std::string, std::string>::const_iterator ci = my_keys_map.begin(); ci != my_keys_map.end(); ci++) {
97 if (ci->first ==
"LASER_CONFIGURATION_ID")
98 setConfigTag(ci->second);
99 if (ci->first ==
"DEBUG")
100 setDebug(atoi(ci->second.c_str()));
101 if (ci->first ==
"LASER_DEBUG")
102 setDebug(atoi(ci->second.c_str()));
103 if (ci->first ==
"DUMMY")
104 setDummy(atoi(ci->second.c_str()));
105 if (ci->first ==
"MATACQ_BASE_ADDRESS")
106 setMatacqBaseAddress(atoi(ci->second.c_str()));
107 if (ci->first ==
"MATACQ_NONE")
108 setMatacqNone(atoi(ci->second.c_str()));
109 if (ci->first ==
"MATACQ_MODE")
110 setMatacqMode(ci->second);
111 if (ci->first ==
"CHANNEL_MASK")
112 setChannelMask(atoi(ci->second.c_str()));
113 if (ci->first ==
"MAX_SAMPLES_FOR_DAQ")
114 setMaxSamplesForDaq(ci->second);
115 if (ci->first ==
"MATACQ_FED_ID")
116 setMatacqFedId(atoi(ci->second.c_str()));
117 if (ci->first ==
"PEDESTAL_FILE")
118 setPedestalFile(ci->second);
119 if (ci->first ==
"USE_BUFFER")
120 setUseBuffer(atoi(ci->second.c_str()));
121 if (ci->first ==
"POSTTRIG")
122 setPostTrig(atoi(ci->second.c_str()));
123 if (ci->first ==
"FP_MODE")
124 setFPMode(atoi(ci->second.c_str()));
125 if (ci->first ==
"HAL_MODULE_FILE")
126 setHalModuleFile(ci->second);
127 if (ci->first ==
"HAL_ADDRESS_TABLE_FILE" || ci->first ==
"HAL_ADDRESST_ABLE_FILE")
128 setHalAddressTableFile(ci->second);
129 if (ci->first ==
"HAL_STATIC_TABLE_FILE")
130 setHalStaticTableFile(ci->second);
131 if (ci->first ==
"MATACQ_SERIAL_NUMBER")
132 setMatacqSerialNumber(ci->second);
133 if (ci->first ==
"PEDESTAL_RUN_EVENT_COUNT")
134 setPedestalRunEventCount(atoi(ci->second.c_str()));
135 if (ci->first ==
"RAW_DATA_MODE")
136 setRawDataMode(atoi(ci->second.c_str()));
137 if (ci->first ==
"ACQUISITION_MODE")
138 setMatacqAcquisitionMode(ci->second);
139 if (ci->first ==
"LOCAL_OUTPUT_FILE")
140 setLocalOutputFile(ci->second);
141 if (ci->first ==
"EMTC_NONE")
142 setEMTCNone(atoi(ci->second.c_str()));
143 if (ci->first ==
"WTE2_LASER_DELAY")
144 setWTE2LaserDelay(atoi(ci->second.c_str()));
145 if (ci->first ==
"LASER_PHASE")
146 setLaserPhase(atoi(ci->second.c_str()));
147 if (ci->first ==
"EMTC_TTC_IN")
148 setEMTCTTCIn(atoi(ci->second.c_str()));
149 if (ci->first ==
"EMTC_SLOT_ID")
150 setEMTCSlotId(atoi(ci->second.c_str()));
151 if (ci->first ==
"WAVELENGTH")
152 setWaveLength(atoi(ci->second.c_str()));
153 if (ci->first ==
"OPTICAL_SWITCH")
154 setOpticalSwitch(atoi(ci->second.c_str()));
155 if (ci->first ==
"POWER_SETTING")
156 setPower(atoi(ci->second.c_str()));
157 if (ci->first ==
"FILTER")
158 setFilter(atoi(ci->second.c_str()));
159 if (ci->first ==
"LASER_CONTROL_ON")
160 setLaserControlOn(atoi(ci->second.c_str()));
161 if (ci->first ==
"LASER_CONTROL_HOST")
162 setLaserControlHost(ci->second);
163 if (ci->first ==
"LASER_CONTROL_PORT")
164 setLaserControlPort(atoi(ci->second.c_str()));
165 if (ci->first ==
"MATACQ_VERNIER_MAX")
166 setMatacqVernierMax(atoi(ci->second.c_str()));
167 if (ci->first ==
"MATACQ_VERNIER_MIN")
168 setMatacqVernierMin(atoi(ci->second.c_str()));
170 if (ci->first ==
"WTE_2_LED_DELAY")
171 setWTE2LedDelay(atoi(ci->second.c_str()));
172 if (ci->first ==
"LED1_ON")
173 setLed1ON(atoi(ci->second.c_str()));
174 if (ci->first ==
"LED2_ON")
175 setLed2ON(atoi(ci->second.c_str()));
176 if (ci->first ==
"LED3_ON")
177 setLed3ON(atoi(ci->second.c_str()));
178 if (ci->first ==
"LED4_ON")
179 setLed4ON(atoi(ci->second.c_str()));
180 if (ci->first ==
"VINJ")
181 setVinj(atoi(ci->second.c_str()));
182 if (ci->first ==
"ORANGE_LED_MON_AMPL")
183 setOrangeLedMonAmpl(atoi(ci->second.c_str()));
184 if (ci->first ==
"BLUE_LED_MON_AMPL")
185 setBlueLedMonAmpl(atoi(ci->second.c_str()));
186 if (ci->first ==
"TRIG_LOG_FILE")
187 setTrigLogFile(ci->second);
188 if (ci->first ==
"LED_CONTROL_ON")
189 setLedControlON(atoi(ci->second.c_str()));
190 if (ci->first ==
"LED_CONTROL_HOST")
191 setLedControlHost(ci->second);
192 if (ci->first ==
"LED_CONTROL_PORT")
193 setLedControlPort(atoi(ci->second.c_str()));
194 if (ci->first ==
"IR_LASER_POWER")
195 setIRLaserPower(atoi(ci->second.c_str()));
196 if (ci->first ==
"GREEN_LASER_POWER")
197 setGreenLaserPower(atoi(ci->second.c_str()));
198 if (ci->first ==
"RED_LASER_POWER")
199 setRedLaserPower(atoi(ci->second.c_str()));
200 if (ci->first ==
"BLUE_LASER_LOG_ATTENUATOR")
201 setBlueLaserLogAttenuator(atoi(ci->second.c_str()));
202 if (ci->first ==
"IR_LASER_LOG_ATTENUATOR")
203 setIRLaserLogAttenuator(atoi(ci->second.c_str()));
204 if (ci->first ==
"GREEN_LASER_LOG_ATTENUATOR")
205 setGreenLaserLogAttenuator(atoi(ci->second.c_str()));
206 if (ci->first ==
"RED_LASER_LOG_ATTENUATOR")
207 setRedLaserLogAttenuator(atoi(ci->second.c_str()));
209 if (ci->first ==
"LASER_CONFIG_FILE") {
211 setLaserConfigFile(
fname);
216 inpFile.open(
fname.c_str());
221 bufsize = inpFile.tellg();
222 std::cout <<
" bufsize =" << bufsize << std::endl;
224 inpFile.seekg(0, ios::beg);
236 this->checkConnection();
238 m_readStmt = m_conn->createStatement();
239 m_readStmt->setSQL(
"select ecal_laser_config_sq.NextVal from dual");
240 ResultSet* rset = m_readStmt->executeQuery();
241 while (rset->next()) {
244 m_conn->terminateStatement(m_readStmt);
248 throw(std::runtime_error(
std::string(
"ODLaserConfig::fetchNextId(): ") +
e.getMessage()));
253 this->checkConnection();
254 int next_id = fetchNextId();
257 m_writeStmt = m_conn->createStatement();
259 "INSERT INTO ECAL_Laser_CONFIGURATION ( laser_configuration_id, laser_tag "
262 ", MATACQ_BASE_ADDRESS "
266 ", max_Samples_For_Daq "
273 ", hal_Address_Table_File "
274 ", hal_Static_Table_File "
275 ", matacq_Serial_Number "
276 ", pedestal_Run_Event_Count "
278 ", ACQUISITION_MODE "
279 ", LOCAL_OUTPUT_FILE "
281 ", wte2_laser_delay "
289 ", LASER_CONTROL_ON "
290 ", LASER_CONTROL_HOST "
291 ", LASER_CONTROL_PORT "
293 ", MATACQ_VERNIER_MIN "
294 ", MATACQ_VERNIER_MAX "
295 " , wte_2_led_delay "
301 " , orange_led_mon_ampl"
302 " , blue_led_mon_ampl "
305 " , led_control_host "
306 " , led_control_port "
308 " , green_laser_power"
309 " , red_laser_power "
310 " , blue_laser_log_attenuator "
311 " , IR_LASER_LOG_ATTENUATOR "
312 " , GREEN_LASER_LOG_ATTENUATOR"
313 " , RED_LASER_LOG_ATTENUATOR "
314 " , LASER_CONFIG_FILE "
315 " , laser_configuration ) "
316 " VALUES ( :1, :2, :3, :4, :5, :6, :7, :8, :9, :10, "
317 ":11, :12, :13, :14, :15, :16, :17, :18, :19, :20, "
318 ":21, :22, :23, :24, :25, :26, :27, :28, :29, :30, "
319 ":31, :32, :33, :34, :35, :36, :37, "
320 " :38, :39, :40, :41, :42, :43, :44, :45, :46, :47, :48, :49, :50, :51, :52, :53, :54, :55, :56, :57, :58 )");
321 m_writeStmt->setInt(1, next_id);
324 throw(std::runtime_error(
std::string(
"ODLaserConfig::prepareWrite(): ") +
e.getMessage()));
329 this->checkConnection();
330 this->checkPrepare();
334 m_writeStmt->setString(2, this->getConfigTag());
336 m_writeStmt->setInt(3, this->getDebug());
337 m_writeStmt->setInt(4, this->getDummy());
338 m_writeStmt->setInt(5, this->getMatacqBaseAddress());
339 m_writeStmt->setInt(6, this->getMatacqNone());
340 m_writeStmt->setString(7, this->getMatacqMode());
341 m_writeStmt->setInt(8, this->getChannelMask());
342 m_writeStmt->setString(9, this->getMaxSamplesForDaq());
343 m_writeStmt->setInt(10, this->getMatacqFedId());
344 m_writeStmt->setString(11, this->getPedestalFile());
345 m_writeStmt->setInt(12, this->getUseBuffer());
346 m_writeStmt->setInt(13, this->getPostTrig());
347 m_writeStmt->setInt(14, this->getFPMode());
348 m_writeStmt->setString(15, this->getHalModuleFile());
349 m_writeStmt->setString(16, this->getHalAddressTableFile());
350 m_writeStmt->setString(17, this->getHalStaticTableFile());
351 m_writeStmt->setString(18, this->getMatacqSerialNumber());
352 m_writeStmt->setInt(19, this->getPedestalRunEventCount());
353 m_writeStmt->setInt(20, this->getRawDataMode());
354 m_writeStmt->setString(21, this->getMatacqAcquisitionMode());
355 m_writeStmt->setString(22, this->getLocalOutputFile());
356 m_writeStmt->setInt(23, this->getEMTCNone());
357 m_writeStmt->setInt(24, this->getWTE2LaserDelay());
358 m_writeStmt->setInt(25, this->getLaserPhase());
359 m_writeStmt->setInt(26, this->getEMTCTTCIn());
360 m_writeStmt->setInt(27, this->getEMTCSlotId());
362 m_writeStmt->setInt(28, this->getWaveLength());
363 m_writeStmt->setInt(29, this->getPower());
364 m_writeStmt->setInt(30, this->getOpticalSwitch());
365 m_writeStmt->setInt(31, this->getFilter());
366 m_writeStmt->setInt(32, this->getLaserControlOn());
367 m_writeStmt->setString(33, this->getLaserControlHost());
368 m_writeStmt->setInt(34, this->getLaserControlPort());
369 m_writeStmt->setString(35, this->getLaserTag());
371 m_writeStmt->setInt(36, this->getMatacqVernierMin());
372 m_writeStmt->setInt(37, this->getMatacqVernierMax());
375 m_writeStmt->setInt(38, this->getWTE2LedDelay());
376 m_writeStmt->setInt(39, this->getLed1ON());
377 m_writeStmt->setInt(40, this->getLed2ON());
378 m_writeStmt->setInt(41, this->getLed3ON());
379 m_writeStmt->setInt(42, this->getLed4ON());
380 m_writeStmt->setInt(43, this->getVinj());
381 m_writeStmt->setInt(44, this->getOrangeLedMonAmpl());
382 m_writeStmt->setInt(45, this->getBlueLedMonAmpl());
383 m_writeStmt->setString(46, this->getTrigLogFile());
384 m_writeStmt->setInt(47, this->getLedControlON());
385 m_writeStmt->setString(48, this->getLedControlHost());
386 m_writeStmt->setInt(49, this->getLedControlPort());
387 m_writeStmt->setInt(50, this->getIRLaserPower());
388 m_writeStmt->setInt(51, this->getGreenLaserPower());
389 m_writeStmt->setInt(52, this->getRedLaserPower());
390 m_writeStmt->setInt(53, this->getBlueLaserLogAttenuator());
391 m_writeStmt->setInt(54, this->getIRLaserLogAttenuator());
392 m_writeStmt->setInt(55, this->getGreenLaserLogAttenuator());
393 m_writeStmt->setInt(56, this->getRedLaserLogAttenuator());
394 m_writeStmt->setString(57, this->getLaserConfigFile());
397 oracle::occi::Clob clob(m_conn);
399 m_writeStmt->setClob(58, clob);
400 m_writeStmt->executeUpdate();
401 m_conn->terminateStatement(m_writeStmt);
404 m_writeStmt = m_conn->createStatement();
405 m_writeStmt->setSQL(
"SELECT laser_configuration FROM " + getTable() +
407 " laser_configuration_id=:1 FOR UPDATE");
408 std::cout <<
"updating the laser clob " << std::endl;
410 m_writeStmt->setInt(1, m_ID);
411 ResultSet* rset = m_writeStmt->executeQuery();
413 oracle::occi::Clob clob_to_write = rset->getClob(1);
414 cout <<
"Opening the clob in read write mode" << endl;
416 populateClob(clob_to_write, getLaserConfigFile(), m_size);
417 int clobLength = clob_to_write.length();
418 cout <<
"Length of the clob is: " << clobLength << endl;
419 m_writeStmt->executeUpdate();
420 m_writeStmt->closeResultSet(rset);
423 throw(std::runtime_error(
std::string(
"ODLaserConfig::writeDB(): ") +
e.getMessage()));
426 if (!this->fetchID()) {
427 throw(std::runtime_error(
"ODLaserConfig::writeDB: Failed to write"));
432 this->checkConnection();
434 if (
result->getId() == 0 && (
result->getConfigTag().empty())) {
435 throw(std::runtime_error(
"ODLaserConfig::fetchData(): no Id defined for this ODLaserConfig "));
442 getTable() +
" where ( laser_configuration_id = :1 or laser_tag=:2 )");
443 m_readStmt->setInt(1,
result->getId());
444 m_readStmt->setString(2,
result->getConfigTag());
445 ResultSet* rset = m_readStmt->executeQuery();
451 result->setId(rset->getInt(1));
452 result->setConfigTag(rset->getString(2));
454 result->setDebug(rset->getInt(3));
455 result->setDummy(rset->getInt(4));
456 result->setMatacqBaseAddress(rset->getInt(5));
457 result->setMatacqNone(rset->getInt(6));
458 result->setMatacqMode(rset->getString(7));
459 result->setChannelMask(rset->getInt(8));
460 result->setMaxSamplesForDaq(rset->getString(9));
461 result->setMatacqFedId(rset->getInt(10));
462 result->setPedestalFile(rset->getString(11));
463 result->setUseBuffer(rset->getInt(12));
464 result->setPostTrig(rset->getInt(13));
465 result->setFPMode(rset->getInt(14));
466 result->setHalModuleFile(rset->getString(15));
467 result->setHalAddressTableFile(rset->getString(16));
468 result->setHalStaticTableFile(rset->getString(17));
469 result->setMatacqSerialNumber(rset->getString(18));
470 result->setPedestalRunEventCount(rset->getInt(19));
471 result->setRawDataMode(rset->getInt(20));
472 result->setMatacqAcquisitionMode(rset->getString(21));
473 result->setLocalOutputFile(rset->getString(22));
474 result->setEMTCNone(rset->getInt(23));
475 result->setWTE2LaserDelay(rset->getInt(24));
476 result->setLaserPhase(rset->getInt(25));
477 result->setEMTCTTCIn(rset->getInt(26));
478 result->setEMTCSlotId(rset->getInt(27));
480 result->setWaveLength(rset->getInt(28));
481 result->setPower(rset->getInt(29));
482 result->setOpticalSwitch(rset->getInt(30));
483 result->setFilter(rset->getInt(31));
484 result->setLaserControlOn(rset->getInt(32));
485 result->setLaserControlHost(rset->getString(33));
486 result->setLaserControlPort(rset->getInt(34));
487 result->setLaserTag(rset->getString(35));
489 result->setMatacqVernierMin(rset->getInt(36));
490 result->setMatacqVernierMax(rset->getInt(37));
492 result->setWTE2LedDelay(rset->getInt(38));
493 result->setLed1ON(rset->getInt(39));
494 result->setLed2ON(rset->getInt(40));
495 result->setLed3ON(rset->getInt(41));
496 result->setLed4ON(rset->getInt(42));
497 result->setVinj(rset->getInt(43));
498 result->setOrangeLedMonAmpl(rset->getInt(44));
499 result->setBlueLedMonAmpl(rset->getInt(45));
500 result->setTrigLogFile(rset->getString(46));
501 result->setLedControlON(rset->getInt(47));
502 result->setLedControlHost(rset->getString(48));
503 result->setLedControlPort(rset->getInt(49));
504 result->setIRLaserPower(rset->getInt(50));
505 result->setGreenLaserPower(rset->getInt(51));
506 result->setRedLaserPower(rset->getInt(52));
507 result->setBlueLaserLogAttenuator(rset->getInt(53));
508 result->setIRLaserLogAttenuator(rset->getInt(54));
509 result->setGreenLaserLogAttenuator(rset->getInt(55));
510 result->setRedLaserLogAttenuator(rset->getInt(56));
511 result->setLaserConfigFile(rset->getString(57));
513 Clob clob = rset->getClob(58);
514 cout <<
"Opening the clob in Read only mode" << endl;
515 clob.open(OCCI_LOB_READONLY);
516 int clobLength = clob.length();
517 cout <<
"Length of the clob is: " << clobLength << endl;
519 unsigned char*
buffer = readClob(clob, m_size);
521 cout <<
"the clob buffer is:" << endl;
522 for (
int i = 0;
i < clobLength; ++
i)
529 throw(std::runtime_error(
std::string(
"ODLaserConfig::fetchData(): ") +
e.getMessage()));
539 this->checkConnection();
542 Statement* stmt = m_conn->createStatement();
544 "SELECT laser_configuration_id FROM ecal_laser_configuration "
545 "WHERE laser_tag=:laser_tag ");
546 stmt->setString(1, getLaserTag());
548 ResultSet* rset = stmt->executeQuery();
551 m_ID = rset->getInt(1);
555 m_conn->terminateStatement(stmt);
557 throw(std::runtime_error(
std::string(
"ODLaserConfig::fetchID: ") +
e.getMessage()));