00001 #include "otsdaq-core/ConfigurationPluginDataFormats/FEConfiguration.h" 00002 #include "otsdaq-core/Macros/ConfigurationPluginMacros.h" 00003 00004 #include <iostream> 00005 00006 using namespace ots; 00007 00008 //============================================================================== 00009 FEConfiguration::FEConfiguration(void) 00010 : ConfigurationBase("FEConfiguration") 00011 { 00013 //WARNING: the names and the order MUST match the ones in the enum // 00015 //FEConfigurationInfo.xml 00016 //<?xml version="1.0" encoding="UTF-8" standalone="no" ?> 00017 //<ROOT xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ConfigurationInfo.xsd"> 00018 // <CONFIGURATION Name="FEConfiguration"> 00019 // <VIEW Name="FE_CONFIGURATION" Type="File,Database,DatabaseTest"> 00020 // <COLUMN Name="SupervisorType" StorageName="SUPERVISOR_TYPE" DataType="VARCHAR2"/> 00021 // <COLUMN Name="SupervisorInstance" StorageName="SUPERVISOR_INSTANCE" DataType="NUMBER" /> 00022 // <COLUMN Name="FrontEndType" StorageName="FRONT_END_TYPE" DataType="VARCHAR2"/> 00023 // <COLUMN Name="FrontEndID" StorageName="INTERFACE_ID" DataType="VARCHAR2"/> 00024 // </VIEW> 00025 // </CONFIGURATION> 00026 //</ROOT> 00027 00028 } 00029 00030 //============================================================================== 00031 FEConfiguration::~FEConfiguration(void) 00032 {} 00033 00034 //============================================================================== 00035 void FEConfiguration::init(ConfigurationManager *configManager) 00036 { 00037 std::string tmpType; 00038 unsigned int tmpInstance; 00039 std::string tmpID; 00040 for(unsigned int row=0; row<ConfigurationBase::activeConfigurationView_->getNumberOfRows(); row++) 00041 { 00042 ConfigurationBase::activeConfigurationView_->getValue(tmpType, row, SupervisorType); 00043 ConfigurationBase::activeConfigurationView_->getValue(tmpInstance, row, SupervisorInstance); 00044 ConfigurationBase::activeConfigurationView_->getValue(tmpID, row, FrontEndId); 00045 std::cout << __COUT_HDR_FL__ << "Type: " << tmpType << " Name: " << tmpInstance << " row: " << row << std::endl; 00046 typeNameToRow_[composeUniqueName(tmpType, tmpInstance)][tmpID] = row; 00047 } 00048 } 00049 // 00051 //std::vector<std::string> FEConfiguration::getListOfFEIDs(void) const 00052 //{ 00053 // std::vector<std::string> list; 00054 // for(const auto& itSupervisors : typeNameToRow_) 00055 // for(const auto& itFrontEnds : itSupervisors.second) 00056 // list.push_back(itFrontEnds.first); 00057 // return list; 00058 //} 00059 // 00061 //std::vector<std::string> FEConfiguration::getListOfFEIDs(const std::string& supervisorType, unsigned int supervisorInstance) const 00062 //{ 00063 // std::string uniqueName = composeUniqueName(supervisorType, supervisorInstance); 00064 // std::vector<std::string> list; 00065 // if(typeNameToRow_.find(uniqueName) == typeNameToRow_.end()) 00066 // { 00067 // std::cout << __COUT_HDR_FL__ 00068 // << "Couldn't find any supervisor of type " << supervisorType 00069 // << " and instance " << supervisorInstance 00070 // << std::endl; 00071 // //assert(0); //RAR - 8/12/16 - empty list is ok 00072 // } 00073 // else 00074 // { 00075 // for(const auto& it : typeNameToRow_.find(uniqueName)->second) 00076 // list.push_back(it.first); 00077 // } 00078 // 00079 // return list; 00080 //} 00081 // 00083 //const std::string FEConfiguration::getFEInterfaceType(const std::string& frontEndID) const 00084 //{ 00085 // for(const auto& itSupervisors : typeNameToRow_) 00086 // for(const auto& itFrontEnds : itSupervisors.second) 00087 // if(itFrontEnds.first == frontEndID) 00088 // return ConfigurationBase::getView().getDataView()[typeNameToRow_.find(itSupervisors.first)->second.find(frontEndID)->second][FrontEndType]; 00089 // std::cout << __COUT_HDR_FL__ << "Didn't find any interface with ID: " << frontEndID << std::endl; 00090 // assert(0); 00091 // throw std::runtime_error("FEID not found!"); 00092 // return ""; 00093 //} 00094 // 00096 //const std::string FEConfiguration::getFEInterfaceType(const std::string& supervisorType, unsigned int supervisorInstance, const std::string& frontEndID) const 00097 //{ 00098 // std::string uniqueName = composeUniqueName(supervisorType, supervisorInstance); 00099 // if(typeNameToRow_.find(uniqueName) == typeNameToRow_.end()) 00100 // { 00101 // std::cout << __COUT_HDR_FL__ 00102 // << "Couldn't find any supervisor of type " << supervisorType 00103 // << " and instance " << supervisorInstance 00104 // << std::endl; 00105 // assert(0); 00106 // } 00107 // if(typeNameToRow_.find(uniqueName)->second.find(frontEndID) == typeNameToRow_.find(uniqueName)->second.end()) 00108 // { 00109 // std::cout << __COUT_HDR_FL__ 00110 // << "Couldn't find any front end ID " << frontEndID 00111 // << " for supervisor type " << supervisorType 00112 // << " and instance " << supervisorInstance 00113 // << std::endl; 00114 // assert(0); 00115 // } 00116 // 00117 // return ConfigurationBase::getView().getDataView()[typeNameToRow_.find(uniqueName)->second.find(frontEndID)->second][FrontEndType]; 00118 //} 00119 00121 //std::vector<unsigned int> FEConfiguration::getListOfFEWRs(void) const 00122 //{ 00123 // return getListOfFEs("FEWR"); 00124 //} 00125 // 00127 //std::vector<unsigned int> FEConfiguration::getListOfFEWRs(unsigned int supervisorInstance) const 00128 //{ 00129 // return getListOfFEs("FEWR",supervisorInstance); 00130 //} 00131 // 00133 //const std::string& FEConfiguration::getFEWRInterfaceName(unsigned int id) const 00134 //{ 00135 // return getFEInterfaceType("FEWR", id); 00136 //} 00137 // 00139 //std::vector<unsigned int> FEConfiguration::getListOfFEWs(void) const 00140 //{ 00141 // return getListOfFEs("FEW"); 00142 //} 00143 // 00145 //std::vector<unsigned int> FEConfiguration::getListOfFEWs(unsigned int supervisorInstance) const 00146 //{ 00147 // return getListOfFEs("FEW",supervisorInstance); 00148 //} 00149 // 00151 //const std::string& FEConfiguration::getFEWInterfaceName(unsigned int id) const 00152 //{ 00153 // return getFEInterfaceType("FEW", id); 00154 //} 00155 // 00157 //std::vector<unsigned int> FEConfiguration::getListOfFERs(void) const 00158 //{ 00159 // return getListOfFEs("FER"); 00160 //} 00161 // 00163 //std::vector<unsigned int> FEConfiguration::getListOfFERs(unsigned int supervisorInstance) const 00164 //{ 00165 // return getListOfFEs("FER",supervisorInstance); 00166 //} 00167 // 00169 //const std::string& FEConfiguration::getFERInterfaceName(unsigned int id) const 00170 //{ 00171 // return getFEInterfaceType("FER", id); 00172 //} 00173 00174 DEFINE_OTS_CONFIGURATION(FEConfiguration)