23 #include <CoralBase/Attribute.h> 
   24 #include <CoralBase/AttributeList.h> 
   26 #include "RelationalAccess/SchemaException.h" 
   27 #include "RelationalAccess/ITransaction.h" 
   28 #include "RelationalAccess/ITable.h" 
   29 #include "RelationalAccess/ISchema.h" 
   30 #include "RelationalAccess/ICursor.h" 
   31 #include "RelationalAccess/IQuery.h" 
   46       msg() << 
"ThresholdMonitorLoader started loading data via ID. ID = "  
   47             << tmTarget.
id() << 
" for MenuId = "  
   54       coral::ITable& 
table = 
m_session.nominalSchema().tableHandle( 
"L1_TM_TO_TT_MON");
 
   56       query->setRowCacheSize( 6 );
 
   60       bindList.extend<
int>(
"tmId");
 
   61       bindList.extend<
int>(
"menuId");
 
   62       bindList[0].data<
int>() = tmTarget.
id();
 
   64       std::string theCondition = 
"";
 
   65       theCondition += std::string( 
" L1TM2TTM_ID = :tmId"                    );
 
   66       theCondition += std::string( 
" AND L1TM2TTM_TRIGGER_MENU_ID = :menuId" );
 
   67       query->setCondition( theCondition, bindList );
 
   71       attList.extend<std::string>( 
"L1TM2TTM_NAME" );
 
   72       attList.extend<
long>( 
"L1TM2TTM_TRIGGER_THRESHOLD_ID" );
 
   73       attList.extend<
int>( 
"L1TM2TTM_INTERNAL_COUNTER" );
 
   74       attList.extend<
int>( 
"L1TM2TTM_MULTIPLICITY" );
 
   75       if(
schema <= 6) attList.extend<
long>( 
"L1TM2TTM_BUNCH_GROUP_SET_ID" );
 
   76       if(
schema > 6) attList.extend<
long>( 
"L1TM2TTM_BUNCH_GROUP_ID" );
 
   77       attList.extend<std::string>( 
"L1TM2TTM_COUNTER_TYPE" );
 
   78       query->defineOutput(attList);
 
   80       query->addToOutputList(
"L1TM2TTM_NAME" );
 
   81       query->addToOutputList(
"L1TM2TTM_TRIGGER_THRESHOLD_ID" );
 
   82       query->addToOutputList(
"L1TM2TTM_INTERNAL_COUNTER" );
 
   83       query->addToOutputList(
"L1TM2TTM_MULTIPLICITY" );
 
   84       if(
schema <= 6) 
query->addToOutputList(
"L1TM2TTM_BUNCH_GROUP_SET_ID" );
 
   85       else if(
schema > 6) 
query->addToOutputList(
"L1TM2TTM_BUNCH_GROUP_ID" );
 
   86       query->addToOutputList(
"L1TM2TTM_COUNTER_TYPE" );
 
   91          msg() << 
"ThresholdMonitorLoader >> No such ThresholdMonitor exists "  
   92                << tmTarget.
id() << std::endl;
 
   95          throw std::runtime_error( 
"ThresholdMonitorLoader >> ThresholdMonitor not available" );
 
   99       long trigger_threshold_id =0;
 
  100       trigger_threshold_id = 
row[
"L1TM2TTM_TRIGGER_THRESHOLD_ID"].data<
long>();
 
  101       int internal_counter =0;
 
  102       internal_counter = 
row[
"L1TM2TTM_INTERNAL_COUNTER"].data<
int>();
 
  104       multiplicity = 
row[
"L1TM2TTM_MULTIPLICITY"].data<
int>();
 
  105       long bunch_group_id=0;
 
  106       if(
schema <= 6) bunch_group_id = 
row[
"L1TM2TTM_BUNCH_GROUP_SET_ID"].data<
long>();
 
  107       else if(
schema > 6) bunch_group_id = 
row[
"L1TM2TTM_BUNCH_GROUP_ID"].data<
long>();
 
  108       std::string countertype=
"";
 
  109       countertype = 
row[
"L1TM2TTM_COUNTER_TYPE"].data<std::string>();
 
  111       name = 
row[
"L1TM2TTM_NAME"].data<std::string>();
 
  124       coral::ITable& tableThresh = 
m_session.nominalSchema().tableHandle( 
"L1_TRIGGER_THRESHOLD");
 
  125       coral::IQuery* queryThresh = tableThresh.newQuery();
 
  126       queryThresh->setRowCacheSize( 4 );
 
  129       std::string cond = 
"L1TT_ID =  :threshId";
 
  131       alist.extend<
long>(
"threshId");
 
  132       alist[0].data<
long>() = 
static_cast<long>(trigger_threshold_id);
 
  133       queryThresh->setCondition( cond, alist );
 
  137       attList1.extend<std::string>( 
"L1TT_NAME" );
 
  138       attList1.extend<
int>( 
"L1TT_ACTIVE" );
 
  139       queryThresh->defineOutput(attList1);
 
  140       queryThresh->addToOutputList( 
"L1TT_NAME" );
 
  141       queryThresh->addToOutputList( 
"L1TT_ACTIVE" );
 
  143       coral::ICursor& cursorThresh = queryThresh->execute();
 
  144       if ( ! cursorThresh.next() ) {
 
  145          msg() << 
"ThresholdMonitorLoader >> No such trigger threshold exists : " << trigger_threshold_id << std::endl;
 
  149          throw std::runtime_error( 
"ThresholdMonitorLoader >> TriggerThreshold not available" );
 
  158       coral::ITable& tableTMTOTT = 
m_session.nominalSchema().tableHandle( 
"L1_TM_TO_TT");
 
  159       coral::IQuery* queryTMTOTT = tableTMTOTT.newQuery();
 
  160       queryTMTOTT->setRowCacheSize( 5 );
 
  163       cond = 
"L1TM2TT_TRIGGER_THRESHOLD_ID = :ttId AND L1TM2TT_TRIGGER_MENU_ID = :menuId";
 
  165       alistTMTOTT.extend<
long>(
"ttId");
 
  166       alistTMTOTT.extend<
long>(
"menuId");
 
  167       alistTMTOTT[0].data<
long>() = trigger_threshold_id;
 
  168       alistTMTOTT[1].data<
long>() = 
m_MenuId;
 
  169       queryTMTOTT->setCondition( cond, alistTMTOTT );
 
  173       attList2.extend<std::string>( 
"L1TM2TT_CABLE_CTPIN" ); 
 
  174       attList2.extend<std::string>( 
"L1TM2TT_CABLE_CONNECTOR" );
 
  175       attList2.extend<
int>( 
"L1TM2TT_CABLE_START" ); 
 
  176       attList2.extend<
int>( 
"L1TM2TT_CABLE_END" );
 
  177       queryTMTOTT->defineOutput(attList2);
 
  178       queryTMTOTT->addToOutputList( 
"L1TM2TT_CABLE_CTPIN" );
 
  179       queryTMTOTT->addToOutputList( 
"L1TM2TT_CABLE_CONNECTOR" );
 
  180       queryTMTOTT->addToOutputList( 
"L1TM2TT_CABLE_START" );
 
  181       queryTMTOTT->addToOutputList( 
"L1TM2TT_CABLE_END" );
 
  183       coral::ICursor& cursorTMTOTT = queryTMTOTT->execute();
 
  184       if ( ! cursorTMTOTT.next() ) {
 
  185          msg() << 
"ThresholdMonitorLoader >> No such trigger threshold ( " << trigger_threshold_id 
 
  186                << 
" ) or menu ( " << 
m_MenuId << 
" ) exists in table L1_TM_TO_TT" << std::endl;
 
  191          throw std::runtime_error( 
"ThresholdMonitorLoader >> TriggerThreshold link entry not available" );
 
  195       std::string slotString = rowTMTOTT[
"L1TM2TT_CABLE_CTPIN"].data<std::string>();
 
  197       if(slotString.find(
"SLOT7") != std::string::npos) {
 
  199       } 
else if(slotString.find(
"SLOT8") != std::string::npos) {
 
  201       } 
else if(slotString.find(
"SLOT9") != std::string::npos) {
 
  204          msg() << 
"Unknown CTPIN string '" << slotString << 
"'" << std::endl;
 
  209          throw std::runtime_error( 
"ThresholdMonitorLoader: Error loading Counters " );
 
  212       std::string conString = rowTMTOTT[
"L1TM2TT_CABLE_CONNECTOR"].data<std::string>();
 
  214       if(conString.find(
"CON0") != std::string::npos) {
 
  216       } 
else if(conString.find(
"CON1") != std::string::npos) {
 
  218       } 
else if(conString.find(
"CON2") != std::string::npos) {
 
  220       } 
else if(conString.find(
"CON3") != std::string::npos) {
 
  223          msg() << 
"Unknown CTPIN connector string '" << conString << 
"'" << std::endl;
 
  228          throw std::runtime_error( 
"ThresholdMonitorLoader: Error loading Counters " );
 
  239    } 
catch( 
const coral::SchemaException& 
e ) {
 
  240       msg() << 
"ThresholdMonitorLoader >> SchemaException: "  
  242             << 
e.what() << std::endl;
 
  246       msg() << 
"ThresholdMonitorLoader >> Standard C++ exception: " << 
e.what() << std::endl;
 
  251       msg() << 
"ThresholdMonitorLoader >> unknown C++ exception" << std::endl;