00001 #include "otsdaq-core/SupervisorInfo/SupervisorDescriptorInfoBase.h" 00002 00003 #include <xdaq/ContextDescriptor.h> 00004 #include "otsdaq-core/MessageFacility/MessageFacility.h" 00005 00006 #include <cassert> 00007 00008 using namespace ots; 00009 00010 00011 00012 //======================================================================================================================== 00013 SupervisorDescriptorInfoBase::SupervisorDescriptorInfoBase(void) 00014 { 00015 } 00016 00017 //======================================================================================================================== 00018 SupervisorDescriptorInfoBase::SupervisorDescriptorInfoBase(xdaq::ApplicationContext* applicationContext) 00019 { 00020 init(applicationContext); 00021 } 00022 00023 //======================================================================================================================== 00024 SupervisorDescriptorInfoBase::~SupervisorDescriptorInfoBase() 00025 {} 00026 00027 //======================================================================================================================== 00028 void SupervisorDescriptorInfoBase::destroy() 00029 { 00030 allSupervisors_.clear(); 00031 } 00032 00033 //======================================================================================================================== 00034 void SupervisorDescriptorInfoBase::init(xdaq::ApplicationContext* applicationContext) 00035 { 00036 if(applicationContext->getDefaultZone()->getApplicationGroup("daq") == 0) 00037 { 00038 __SS__ << "Could not find xdaq application group \"daq\" (Must not be present in the xdaq context configuration)" << __E__; 00039 __SS_THROW__; 00040 } 00041 00042 __COUT__ << "Init" << __E__; 00043 00044 // //There is only one and only Supervisor! (Or Config Wizard!!) 00045 // theSupervisor_ = *(applicationContext->getDefaultZone()->getApplicationGroup("daq")->getApplicationDescriptors("ots::Supervisor").begin()); 00046 // if(0)//theSupervisor_ == 0) 00047 // __COUT__ << "Note: Could not find xdaq application descriptor \"ots::Supervisor\" (Must not be present in the xdaq context configuration)" << __E__; 00048 // 00049 // theWizard_ = *(applicationContext->getDefaultZone()->getApplicationGroup("daq")->getApplicationDescriptors("ots::OtsConfigurationWizardSupervisor").begin()); 00050 // if(0)//theWizard_ == 0) 00051 // __COUT__ << "Note: Could not find xdaq application descriptor \"ots::OtsConfigurationWizardSupervisor\" (Must not be present in the xdaq context configuration)" << __E__; 00052 // 00053 // if(theWizard_ == 0 && theSupervisor_ == 0) 00054 // { 00055 // __SS__ << "Must have THE ots::Supervisor (or THE ots::OtsConfigurationWizardSupervisor) as part of the context configuration!" << __E__; 00056 // __COUT_ERR__ << "\n" << ss.str(); 00057 // throw std::runtime_error(ss.str()); 00058 // } 00059 00060 std::set<XDAQ_CONST_CALL xdaq::ApplicationDescriptor*> appDescriptors; 00061 00062 //get allSupervisors_ 00063 00064 //allFETypeSupervisors_.clear(); 00065 allSupervisors_.clear(); 00066 appDescriptors = applicationContext->getDefaultZone()->getApplicationGroup( 00067 "daq")->getApplicationDescriptors(); 00068 for(auto& it: appDescriptors) 00069 { 00070 auto /*<it,bool*/ retPair = allSupervisors_.emplace(std::pair 00071 <xdata::UnsignedIntegerT, XDAQ_CONST_CALL xdaq::ApplicationDescriptor*>( 00072 it->getLocalId(), 00073 it)); 00074 if(!retPair.second) 00075 { 00076 __SS__ << "Error! Duplicate Application IDs are not allowed. ID =" << 00077 it->getLocalId() << __E__; 00078 __SS_THROW__; 00079 } 00080 } 00081 00082 // 00083 // theLogbookSupervisor_ = *(applicationContext->getDefaultZone()->getApplicationGroup("daq")->getApplicationDescriptors("ots::LogbookSupervisor").begin()); 00084 // if(theWizard_ == 0 && theLogbookSupervisor_ == 0) 00085 // __COUT__ << "Note: Could not find xdaq application descriptor \"ots::LogbookSupervisor\" (Must not be present in the xdaq context configuration)" << __E__; 00086 00087 // theDataManagerSupervisors_.clear(); 00088 // appDescriptors = applicationContext->getDefaultZone()->getApplicationGroup("daq")->getApplicationDescriptors("ots::DataManagerSupervisor"); 00089 // for(auto& it: appDescriptors) 00090 // theDataManagerSupervisors_[it->getLocalId()] = it; 00091 // if(theWizard_ == 0 && theDataManagerSupervisors_.size() == 0) 00092 // __COUT__ << "Note: Could not find any xdaq application descriptor \"ots::DataManagerSupervisor\" (Must not be present in the xdaq context configuration)" << __E__; 00093 00094 00095 // //theFESupervisors_.clear(); 00096 // appDescriptors = applicationContext->getDefaultZone()->getApplicationGroup("daq")->getApplicationDescriptors("ots::FESupervisor"); 00097 // for(auto& it: appDescriptors) 00098 // { 00099 // //theFESupervisors_[it->getLocalId()] = it; 00100 // allFETypeSupervisors_[it->getLocalId()] = it; 00101 // } 00102 00103 // if(theWizard_ == 0 && theFESupervisors_.size() == 0) 00104 // __COUT__ << "Note: Could not find any xdaq application descriptor \"ots::FESupervisor\" (Must not be present in the xdaq context configuration)" << __E__; 00105 00106 //RAR: no need for this theDTCSupervisors_.. state machine should use 'all supervisors' 00107 // theDTCSupervisors_.clear(); 00108 // appDescriptors = applicationContext->getDefaultZone()->getApplicationGroup("daq")->getApplicationDescriptors("Ph2TkDAQ::DTCSupervisor"); 00109 // for(auto& it: appDescriptors) 00110 // theDTCSupervisors_[it->getLocalId()] = it; 00112 // if(theDTCSupervisors_.size() == 0) 00113 // { 00114 // __COUT__ << "Note: Could not find any xdaq application descriptor \"ots::DTCSupervisor\" (Must not be present in the xdaq context configuration)" << __E__; 00115 // //assert(0); 00116 // } 00117 00118 //theFEDataManagerSupervisors_.clear(); 00119 // appDescriptors = applicationContext->getDefaultZone()->getApplicationGroup("daq")->getApplicationDescriptors("ots::FEDataManagerSupervisor"); 00120 // for(auto& it: appDescriptors) 00121 // { 00122 // //theFEDataManagerSupervisors_[it->getLocalId()] = it; 00123 // allFETypeSupervisors_[it->getLocalId()] = it; 00124 // } 00125 // if(theWizard_ == 0 && theFEDataManagerSupervisors_.size() == 0) 00126 // __COUT__ << "Note: Could not find any xdaq application descriptor \"ots::FEDataManagerSupervisor\" (Must not be present in the xdaq context configuration)" << __E__; 00127 00128 00129 // theARTDAQFESupervisors_.clear(); 00130 // for(auto& it: applicationContext->getDefaultZone()->getApplicationGroup("daq")->getApplicationDescriptors("ots::ARTDAQFESupervisor")) 00131 // theARTDAQFESupervisors_[it->getLocalId()] = it; 00132 // if(theARTDAQFESupervisors_.size() == 0) 00133 // { 00134 // __COUT__ << "Note: Could not find xdaq application descriptor \"ots::ARTDAQFESupervisor\" (Must not be present in the xdaq context configuration)" << __E__; 00135 // //assert(0); 00136 // } 00137 // 00138 // theARTDAQFEDataManagerSupervisors_.clear(); 00139 // for(auto& it: applicationContext->getDefaultZone()->getApplicationGroup("daq")->getApplicationDescriptors("ots::ARTDAQFEDataManagerSupervisor")) 00140 // { 00141 // //theARTDAQFEDataManagerSupervisors_[it->getLocalId()] = it; 00142 // allFETypeSupervisors_[it->getLocalId()] = it; 00143 // } 00144 // if(0)//theARTDAQFEDataManagerSupervisors_.size() == 0) 00145 // __COUT__ << "Note: Could not find any xdaq application descriptor \"ots::ARTDAQFEDataManagerSupervisor\" (Must not be present in the xdaq context configuration)" << __E__; 00146 // 00147 // theARTDAQDataManagerSupervisors_.clear(); 00148 // for(auto& it: applicationContext->getDefaultZone()->getApplicationGroup("daq")->getApplicationDescriptors("ots::ARTDAQDataManagerSupervisor")) 00149 // theARTDAQDataManagerSupervisors_[it->getLocalId()] = it; 00150 // if(0)//theARTDAQDataManagerSupervisors_.size() == 0) 00151 // __COUT__ << "Note: Could not find any xdaq application descriptor \"ots::ARTDAQDataManagerSupervisor\" (Must not be present in the xdaq context configuration)" << __E__; 00152 // 00153 // 00154 // theARTDAQBuilderSupervisors_.clear(); 00155 // for(auto& it: applicationContext->getDefaultZone()->getApplicationGroup("daq")->getApplicationDescriptors("ots::EventBuilderApp")) 00156 // theARTDAQBuilderSupervisors_[it->getLocalId()] = it; 00157 // if(0)//theARTDAQBuilderSupervisors_.size() == 0) 00158 // __COUT__ << "Note: Could not find any xdaq application descriptor \"ots::EventBuilderApp\" (Must not be present in the xdaq context configuration)" << __E__; 00159 // 00160 // 00161 // theARTDAQAggregatorSupervisors_.clear(); 00162 // for(auto& it: applicationContext->getDefaultZone()->getApplicationGroup("daq")->getApplicationDescriptors("ots::AggregatorApp")) 00163 // theARTDAQAggregatorSupervisors_[it->getLocalId()] = it; 00164 // if(0)//theARTDAQAggregatorSupervisors_.size() == 0) 00165 // __COUT__ << "Note: Could not find any xdaq application descriptor \"ots::AggregatorApp\" (Must not be present in the xdaq context configuration)" << __E__; 00166 // 00167 // 00168 // theVisualSupervisors_.clear(); 00169 // for(auto& it: applicationContext->getDefaultZone()->getApplicationGroup("daq")->getApplicationDescriptors("ots::VisualSupervisor")) 00170 // theVisualSupervisors_[it->getLocalId()] = it; 00171 // if(0)//theVisualSupervisors_.size() == 0) 00172 // __COUT__ << "Note: Could not find any xdaq application descriptor \"ots::VisualSupervisor\" (Must not be present in the xdaq context configuration)" << __E__; 00173 00174 } 00175 00176 // 00178 //const SupervisorDescriptors& SupervisorDescriptorInfoBase::getDataManagerDescriptors(void) const 00179 //{ 00180 // return theDataManagerSupervisors_; 00181 //} 00182 // 00184 //const SupervisorDescriptors& SupervisorDescriptorInfoBase::getFEDescriptors(void) const 00185 //{ 00186 // return theFESupervisors_; 00187 //} 00188 // 00190 //const SupervisorDescriptors& SupervisorDescriptorInfoBase::getDTCDescriptors(void) const 00191 //{ 00192 // return theDTCSupervisors_; 00193 //} 00194 // 00196 //const SupervisorDescriptors& SupervisorDescriptorInfoBase::getFEDataManagerDescriptors(void) const 00197 //{ 00198 // return theFEDataManagerSupervisors_; 00199 //} 00200 00201 //======================================================================================================================== 00202 //const SupervisorDescriptors& SupervisorDescriptorInfoBase::getARTDAQFEDescriptors(void) const 00203 //{ 00204 // return theARTDAQFESupervisors_; 00205 //} 00207 //const SupervisorDescriptors& SupervisorDescriptorInfoBase::getARTDAQFEDataManagerDescriptors(void) const 00208 //{ 00209 // return theARTDAQFEDataManagerSupervisors_; 00210 //} 00212 //const SupervisorDescriptors& SupervisorDescriptorInfoBase::getARTDAQDataManagerDescriptors (void) const 00213 //{ 00214 // return theARTDAQDataManagerSupervisors_; 00215 //} 00216 // 00218 //const SupervisorDescriptors& SupervisorDescriptorInfoBase::getARTDAQBuilderDescriptors(void) const 00219 //{ 00220 // return theARTDAQBuilderSupervisors_; 00221 //} 00222 // 00224 //const SupervisorDescriptors& SupervisorDescriptorInfoBase::getARTDAQAggregatorDescriptors(void) const 00225 //{ 00226 // return theARTDAQAggregatorSupervisors_; 00227 //} 00228 // 00230 //const SupervisorDescriptors& SupervisorDescriptorInfoBase::getVisualDescriptors(void) const 00231 //{ 00232 // return theVisualSupervisors_; 00233 //} 00234 00235 00236 //======================================================================================================================== 00237 const SupervisorDescriptors& SupervisorDescriptorInfoBase::getAllDescriptors(void) const 00238 { 00239 return allSupervisors_; 00240 } 00241 // 00243 //const SupervisorDescriptors& SupervisorDescriptorInfoBase::getAllFEDescriptors(void) const 00244 //{ 00245 // return allFETypeSupervisors_; 00246 //} 00247 // 00249 //XDAQ_CONST_CALL xdaq::ApplicationDescriptor* SupervisorDescriptorInfoBase::getSupervisorDescriptor(void) const 00250 //{ 00251 // return theSupervisor_; 00252 //} 00253 // 00255 //XDAQ_CONST_CALL xdaq::ApplicationDescriptor* SupervisorDescriptorInfoBase::getWizardDescriptor(void) const 00256 //{ 00257 // return theWizard_; 00258 //} 00259 // 00261 //XDAQ_CONST_CALL xdaq::ApplicationDescriptor* SupervisorDescriptorInfoBase::getLogbookDescriptor(void) const 00262 //{ 00263 // return theLogbookSupervisor_; 00264 //} 00265 // 00267 //XDAQ_CONST_CALL xdaq::ApplicationDescriptor* SupervisorDescriptorInfoBase::getVisualDescriptor(xdata::UnsignedIntegerT instance) const 00268 //{ 00269 // if(theVisualSupervisors_.find(instance) == theVisualSupervisors_.end()) 00270 // __COUT__ << "Could not find: " << instance << __E__; 00271 // return theVisualSupervisors_.find(instance)->second; 00272 //} 00273 // 00275 //XDAQ_CONST_CALL xdaq::ApplicationDescriptor* SupervisorDescriptorInfoBase::getDataManagerDescriptor(xdata::UnsignedIntegerT instance) const 00276 //{ 00277 // if(theDataManagerSupervisors_.find(instance) == theDataManagerSupervisors_.end()) 00278 // __COUT__ << "Could not find: " << instance << __E__; 00279 // return theDataManagerSupervisors_.find(instance)->second; 00280 //} 00281 // 00283 //XDAQ_CONST_CALL xdaq::ApplicationDescriptor* SupervisorDescriptorInfoBase::getFEDescriptor(xdata::UnsignedIntegerT instance) const 00284 //{ 00285 // if(theFESupervisors_.find(instance) == theFESupervisors_.end()) 00286 // __COUT__ << "Could not find: " << instance << __E__; 00287 // return theFESupervisors_.find(instance)->second; 00288 //} 00289 // 00291 //XDAQ_CONST_CALL xdaq::ApplicationDescriptor* SupervisorDescriptorInfoBase::getDTCDescriptor(xdata::UnsignedIntegerT instance) const 00292 //{ 00293 // if(theDTCSupervisors_.find(instance) == theDTCSupervisors_.end()) 00294 // __COUT__ << "Could not find: " << instance << __E__; 00295 // return theDTCSupervisors_.find(instance)->second; 00296 //} 00297 // 00299 //XDAQ_CONST_CALL xdaq::ApplicationDescriptor* SupervisorDescriptorInfoBase::getFEDataManagerDescriptor(xdata::UnsignedIntegerT instance) const 00300 //{ 00301 // if(theFEDataManagerSupervisors_.find(instance) == theFEDataManagerSupervisors_.end()) 00302 // __COUT__ << "Could not find: " << instance << __E__; 00303 // return theFEDataManagerSupervisors_.find(instance)->second; 00304 //} 00305 00306 //======================================================================================================================== 00307 //XDAQ_CONST_CALL xdaq::ApplicationDescriptor* SupervisorDescriptorInfoBase::getARTDAQFEDescriptor(xdata::UnsignedIntegerT instance) const 00308 //{ 00309 // if(theARTDAQFESupervisors_.find(instance) == theARTDAQFESupervisors_.end()) 00310 // __COUT__ << "Could not find: " << instance << __E__; 00311 // return theARTDAQFESupervisors_.find(instance)->second; 00312 //} 00313 // 00315 //XDAQ_CONST_CALL xdaq::ApplicationDescriptor* SupervisorDescriptorInfoBase::getARTDAQFEDataManagerDescriptor(xdata::UnsignedIntegerT instance) const 00316 //{ 00317 // if(theARTDAQFEDataManagerSupervisors_.find(instance) == theARTDAQFEDataManagerSupervisors_.end()) 00318 // __COUT__ << "Could not find: " << instance << __E__; 00319 // return theARTDAQFEDataManagerSupervisors_.find(instance)->second; 00320 //} 00321 // 00323 //XDAQ_CONST_CALL xdaq::ApplicationDescriptor* SupervisorDescriptorInfoBase::getARTDAQDataManagerDescriptor (xdata::UnsignedIntegerT instance) const 00324 //{ 00325 // if(theARTDAQDataManagerSupervisors_.find(instance) == theARTDAQDataManagerSupervisors_.end()) 00326 // __COUT__ << "Could not find: " << instance << __E__; 00327 // return theARTDAQDataManagerSupervisors_.find(instance)->second; 00328 //} 00329 // 00331 //XDAQ_CONST_CALL xdaq::ApplicationDescriptor* SupervisorDescriptorInfoBase::getARTDAQBuilderDescriptor(xdata::UnsignedIntegerT instance) const 00332 //{ 00333 // if(theARTDAQBuilderSupervisors_.find(instance) == theARTDAQBuilderSupervisors_.end()) 00334 // __COUT__ << "Could not find: " << instance << __E__; 00335 // return theARTDAQBuilderSupervisors_.find(instance)->second; 00336 //} 00337 // 00339 //XDAQ_CONST_CALL xdaq::ApplicationDescriptor* SupervisorDescriptorInfoBase::getARTDAQAggregatorDescriptor(xdata::UnsignedIntegerT instance) const 00340 //{ 00341 // if(theARTDAQAggregatorSupervisors_.find(instance) == theARTDAQAggregatorSupervisors_.end()) 00342 // __COUT__ << "Could not find: " << instance << __E__; 00343 // return theARTDAQAggregatorSupervisors_.find(instance)->second; 00344 //} 00345 // 00347 //std::string SupervisorDescriptorInfoBase::getFEURL(xdata::UnsignedIntegerT instance) const 00348 //{ 00349 // if(allFETypeSupervisors_.find(instance) == allFETypeSupervisors_.end()) 00350 // __COUT__ << "Could not find: " << instance << __E__; 00351 // return allFETypeSupervisors_.find(instance)->second->getContextDescriptor()->getURL(); 00352 // //getFEDescriptor(instance)->getContextDescriptor()->getURL(); 00353 //} 00354 00355 /* 00356 //======================================================================================================================== 00357 std::string SupervisorDescriptorInfoBase::getARTDAQFEURL(xdata::UnsignedIntegerT instance) const 00358 { 00359 return getARTDAQFEDescriptor(instance)->getContextDescriptor()->getURL(); 00360 } 00361 00362 //======================================================================================================================== 00363 std::string SupervisorDescriptorInfoBase::getARTDAQBuilderURL(xdata::UnsignedIntegerT instance) const 00364 { 00365 return getARTDAQBuilderDescriptor(instance)->getContextDescriptor()->getURL(); 00366 } 00367 00368 //======================================================================================================================== 00369 std::string SupervisorDescriptorInfoBase::getARTDAQAggregatorURL(xdata::UnsignedIntegerT instance) const 00370 { 00371 return getARTDAQAggregatorDescriptor(instance)->getContextDescriptor()->getURL(); 00372 } 00373 */