otsdaq  v2_01_00
SupervisorDescriptorInfoBase.cc
1 #include "otsdaq-core/SupervisorInfo/SupervisorDescriptorInfoBase.h"
2 
3 #include <xdaq/ContextDescriptor.h>
4 #include "otsdaq-core/MessageFacility/MessageFacility.h"
5 
6 #include <cassert>
7 
8 using namespace ots;
9 
10 
11 
12 //========================================================================================================================
13 SupervisorDescriptorInfoBase::SupervisorDescriptorInfoBase(void)
14 {
15 }
16 
17 //========================================================================================================================
18 SupervisorDescriptorInfoBase::SupervisorDescriptorInfoBase(xdaq::ApplicationContext* applicationContext)
19 {
20  init(applicationContext);
21 }
22 
23 //========================================================================================================================
24 SupervisorDescriptorInfoBase::~SupervisorDescriptorInfoBase()
25 {}
26 
27 //========================================================================================================================
28 void SupervisorDescriptorInfoBase::destroy()
29 {
30  allSupervisors_.clear();
31 }
32 
33 //========================================================================================================================
34 void SupervisorDescriptorInfoBase::init(xdaq::ApplicationContext* applicationContext)
35 {
36  if(applicationContext->getDefaultZone()->getApplicationGroup("daq") == 0)
37  {
38  __SS__ << "Could not find xdaq application group \"daq\" (Must not be present in the xdaq context configuration)" << __E__;
39  __SS_THROW__;
40  }
41 
42  __COUT__ << "Init" << __E__;
43 
44 // //There is only one and only Supervisor! (Or Config Wizard!!)
45 // theSupervisor_ = *(applicationContext->getDefaultZone()->getApplicationGroup("daq")->getApplicationDescriptors("ots::Supervisor").begin());
46 // if(0)//theSupervisor_ == 0)
47 // __COUT__ << "Note: Could not find xdaq application descriptor \"ots::Supervisor\" (Must not be present in the xdaq context configuration)" << __E__;
48 //
49 // theWizard_ = *(applicationContext->getDefaultZone()->getApplicationGroup("daq")->getApplicationDescriptors("ots::OtsConfigurationWizardSupervisor").begin());
50 // if(0)//theWizard_ == 0)
51 // __COUT__ << "Note: Could not find xdaq application descriptor \"ots::OtsConfigurationWizardSupervisor\" (Must not be present in the xdaq context configuration)" << __E__;
52 //
53 // if(theWizard_ == 0 && theSupervisor_ == 0)
54 // {
55 // __SS__ << "Must have THE ots::Supervisor (or THE ots::OtsConfigurationWizardSupervisor) as part of the context configuration!" << __E__;
56 // __COUT_ERR__ << "\n" << ss.str();
57 // throw std::runtime_error(ss.str());
58 // }
59 
60  std::set<XDAQ_CONST_CALL xdaq::ApplicationDescriptor*> appDescriptors;
61 
62  //get allSupervisors_
63 
64  //allFETypeSupervisors_.clear();
65  allSupervisors_.clear();
66  appDescriptors = applicationContext->getDefaultZone()->getApplicationGroup(
67  "daq")->getApplicationDescriptors();
68  for(auto& it: appDescriptors)
69  {
70  auto /*<it,bool*/ retPair = allSupervisors_.emplace(std::pair
71  <xdata::UnsignedIntegerT, XDAQ_CONST_CALL xdaq::ApplicationDescriptor*>(
72  it->getLocalId(),
73  it));
74  if(!retPair.second)
75  {
76  __SS__ << "Error! Duplicate Application IDs are not allowed. ID =" <<
77  it->getLocalId() << __E__;
78  __SS_THROW__;
79  }
80  }
81 
82 //
83 // theLogbookSupervisor_ = *(applicationContext->getDefaultZone()->getApplicationGroup("daq")->getApplicationDescriptors("ots::LogbookSupervisor").begin());
84 // if(theWizard_ == 0 && theLogbookSupervisor_ == 0)
85 // __COUT__ << "Note: Could not find xdaq application descriptor \"ots::LogbookSupervisor\" (Must not be present in the xdaq context configuration)" << __E__;
86 
87 // theDataManagerSupervisors_.clear();
88 // appDescriptors = applicationContext->getDefaultZone()->getApplicationGroup("daq")->getApplicationDescriptors("ots::DataManagerSupervisor");
89 // for(auto& it: appDescriptors)
90 // theDataManagerSupervisors_[it->getLocalId()] = it;
91 // if(theWizard_ == 0 && theDataManagerSupervisors_.size() == 0)
92 // __COUT__ << "Note: Could not find any xdaq application descriptor \"ots::DataManagerSupervisor\" (Must not be present in the xdaq context configuration)" << __E__;
93 
94 
95 // //theFESupervisors_.clear();
96 // appDescriptors = applicationContext->getDefaultZone()->getApplicationGroup("daq")->getApplicationDescriptors("ots::FESupervisor");
97 // for(auto& it: appDescriptors)
98 // {
99 // //theFESupervisors_[it->getLocalId()] = it;
100 // allFETypeSupervisors_[it->getLocalId()] = it;
101 // }
102 
103 // if(theWizard_ == 0 && theFESupervisors_.size() == 0)
104  // __COUT__ << "Note: Could not find any xdaq application descriptor \"ots::FESupervisor\" (Must not be present in the xdaq context configuration)" << __E__;
105 
106  //RAR: no need for this theDTCSupervisors_.. state machine should use 'all supervisors'
107  // theDTCSupervisors_.clear();
108  // appDescriptors = applicationContext->getDefaultZone()->getApplicationGroup("daq")->getApplicationDescriptors("Ph2TkDAQ::DTCSupervisor");
109  // for(auto& it: appDescriptors)
110  // theDTCSupervisors_[it->getLocalId()] = it;
112  // if(theDTCSupervisors_.size() == 0)
113  // {
114  // __COUT__ << "Note: Could not find any xdaq application descriptor \"ots::DTCSupervisor\" (Must not be present in the xdaq context configuration)" << __E__;
115  // //assert(0);
116  // }
117 
118  //theFEDataManagerSupervisors_.clear();
119 // appDescriptors = applicationContext->getDefaultZone()->getApplicationGroup("daq")->getApplicationDescriptors("ots::FEDataManagerSupervisor");
120 // for(auto& it: appDescriptors)
121 // {
122 // //theFEDataManagerSupervisors_[it->getLocalId()] = it;
123 // allFETypeSupervisors_[it->getLocalId()] = it;
124 // }
125 // if(theWizard_ == 0 && theFEDataManagerSupervisors_.size() == 0)
126  // __COUT__ << "Note: Could not find any xdaq application descriptor \"ots::FEDataManagerSupervisor\" (Must not be present in the xdaq context configuration)" << __E__;
127 
128 
129  // theARTDAQFESupervisors_.clear();
130  // for(auto& it: applicationContext->getDefaultZone()->getApplicationGroup("daq")->getApplicationDescriptors("ots::ARTDAQFESupervisor"))
131  // theARTDAQFESupervisors_[it->getLocalId()] = it;
132  // if(theARTDAQFESupervisors_.size() == 0)
133  // {
134  // __COUT__ << "Note: Could not find xdaq application descriptor \"ots::ARTDAQFESupervisor\" (Must not be present in the xdaq context configuration)" << __E__;
135  // //assert(0);
136  // }
137 //
138 // theARTDAQFEDataManagerSupervisors_.clear();
139 // for(auto& it: applicationContext->getDefaultZone()->getApplicationGroup("daq")->getApplicationDescriptors("ots::ARTDAQFEDataManagerSupervisor"))
140 // {
141 // //theARTDAQFEDataManagerSupervisors_[it->getLocalId()] = it;
142 // allFETypeSupervisors_[it->getLocalId()] = it;
143 // }
144 // if(0)//theARTDAQFEDataManagerSupervisors_.size() == 0)
145  // __COUT__ << "Note: Could not find any xdaq application descriptor \"ots::ARTDAQFEDataManagerSupervisor\" (Must not be present in the xdaq context configuration)" << __E__;
146 //
147 // theARTDAQDataManagerSupervisors_.clear();
148 // for(auto& it: applicationContext->getDefaultZone()->getApplicationGroup("daq")->getApplicationDescriptors("ots::ARTDAQDataManagerSupervisor"))
149 // theARTDAQDataManagerSupervisors_[it->getLocalId()] = it;
150 // if(0)//theARTDAQDataManagerSupervisors_.size() == 0)
151 // __COUT__ << "Note: Could not find any xdaq application descriptor \"ots::ARTDAQDataManagerSupervisor\" (Must not be present in the xdaq context configuration)" << __E__;
152 //
153 //
154 // theARTDAQBuilderSupervisors_.clear();
155 // for(auto& it: applicationContext->getDefaultZone()->getApplicationGroup("daq")->getApplicationDescriptors("ots::EventBuilderApp"))
156 // theARTDAQBuilderSupervisors_[it->getLocalId()] = it;
157 // if(0)//theARTDAQBuilderSupervisors_.size() == 0)
158 // __COUT__ << "Note: Could not find any xdaq application descriptor \"ots::EventBuilderApp\" (Must not be present in the xdaq context configuration)" << __E__;
159 //
160 //
161 // theARTDAQAggregatorSupervisors_.clear();
162 // for(auto& it: applicationContext->getDefaultZone()->getApplicationGroup("daq")->getApplicationDescriptors("ots::AggregatorApp"))
163 // theARTDAQAggregatorSupervisors_[it->getLocalId()] = it;
164 // if(0)//theARTDAQAggregatorSupervisors_.size() == 0)
165 // __COUT__ << "Note: Could not find any xdaq application descriptor \"ots::AggregatorApp\" (Must not be present in the xdaq context configuration)" << __E__;
166 //
167 //
168 // theVisualSupervisors_.clear();
169 // for(auto& it: applicationContext->getDefaultZone()->getApplicationGroup("daq")->getApplicationDescriptors("ots::VisualSupervisor"))
170 // theVisualSupervisors_[it->getLocalId()] = it;
171 // if(0)//theVisualSupervisors_.size() == 0)
172 // __COUT__ << "Note: Could not find any xdaq application descriptor \"ots::VisualSupervisor\" (Must not be present in the xdaq context configuration)" << __E__;
173 
174 }
175 
176 //
178 //const SupervisorDescriptors& SupervisorDescriptorInfoBase::getDataManagerDescriptors(void) const
179 //{
180 // return theDataManagerSupervisors_;
181 //}
182 //
184 //const SupervisorDescriptors& SupervisorDescriptorInfoBase::getFEDescriptors(void) const
185 //{
186 // return theFESupervisors_;
187 //}
188 //
190 //const SupervisorDescriptors& SupervisorDescriptorInfoBase::getDTCDescriptors(void) const
191 //{
192 // return theDTCSupervisors_;
193 //}
194 //
196 //const SupervisorDescriptors& SupervisorDescriptorInfoBase::getFEDataManagerDescriptors(void) const
197 //{
198 // return theFEDataManagerSupervisors_;
199 //}
200 
201 //========================================================================================================================
202 //const SupervisorDescriptors& SupervisorDescriptorInfoBase::getARTDAQFEDescriptors(void) const
203 //{
204 // return theARTDAQFESupervisors_;
205 //}
207 //const SupervisorDescriptors& SupervisorDescriptorInfoBase::getARTDAQFEDataManagerDescriptors(void) const
208 //{
209 // return theARTDAQFEDataManagerSupervisors_;
210 //}
212 //const SupervisorDescriptors& SupervisorDescriptorInfoBase::getARTDAQDataManagerDescriptors (void) const
213 //{
214 // return theARTDAQDataManagerSupervisors_;
215 //}
216 //
218 //const SupervisorDescriptors& SupervisorDescriptorInfoBase::getARTDAQBuilderDescriptors(void) const
219 //{
220 // return theARTDAQBuilderSupervisors_;
221 //}
222 //
224 //const SupervisorDescriptors& SupervisorDescriptorInfoBase::getARTDAQAggregatorDescriptors(void) const
225 //{
226 // return theARTDAQAggregatorSupervisors_;
227 //}
228 //
230 //const SupervisorDescriptors& SupervisorDescriptorInfoBase::getVisualDescriptors(void) const
231 //{
232 // return theVisualSupervisors_;
233 //}
234 
235 
236 //========================================================================================================================
237 const SupervisorDescriptors& SupervisorDescriptorInfoBase::getAllDescriptors(void) const
238 {
239  return allSupervisors_;
240 }
241 //
243 //const SupervisorDescriptors& SupervisorDescriptorInfoBase::getAllFEDescriptors(void) const
244 //{
245 // return allFETypeSupervisors_;
246 //}
247 //
249 //XDAQ_CONST_CALL xdaq::ApplicationDescriptor* SupervisorDescriptorInfoBase::getSupervisorDescriptor(void) const
250 //{
251 // return theSupervisor_;
252 //}
253 //
255 //XDAQ_CONST_CALL xdaq::ApplicationDescriptor* SupervisorDescriptorInfoBase::getWizardDescriptor(void) const
256 //{
257 // return theWizard_;
258 //}
259 //
261 //XDAQ_CONST_CALL xdaq::ApplicationDescriptor* SupervisorDescriptorInfoBase::getLogbookDescriptor(void) const
262 //{
263 // return theLogbookSupervisor_;
264 //}
265 //
267 //XDAQ_CONST_CALL xdaq::ApplicationDescriptor* SupervisorDescriptorInfoBase::getVisualDescriptor(xdata::UnsignedIntegerT instance) const
268 //{
269 // if(theVisualSupervisors_.find(instance) == theVisualSupervisors_.end())
270 // __COUT__ << "Could not find: " << instance << __E__;
271 // return theVisualSupervisors_.find(instance)->second;
272 //}
273 //
275 //XDAQ_CONST_CALL xdaq::ApplicationDescriptor* SupervisorDescriptorInfoBase::getDataManagerDescriptor(xdata::UnsignedIntegerT instance) const
276 //{
277 // if(theDataManagerSupervisors_.find(instance) == theDataManagerSupervisors_.end())
278 // __COUT__ << "Could not find: " << instance << __E__;
279 // return theDataManagerSupervisors_.find(instance)->second;
280 //}
281 //
283 //XDAQ_CONST_CALL xdaq::ApplicationDescriptor* SupervisorDescriptorInfoBase::getFEDescriptor(xdata::UnsignedIntegerT instance) const
284 //{
285 // if(theFESupervisors_.find(instance) == theFESupervisors_.end())
286 // __COUT__ << "Could not find: " << instance << __E__;
287 // return theFESupervisors_.find(instance)->second;
288 //}
289 //
291 //XDAQ_CONST_CALL xdaq::ApplicationDescriptor* SupervisorDescriptorInfoBase::getDTCDescriptor(xdata::UnsignedIntegerT instance) const
292 //{
293 // if(theDTCSupervisors_.find(instance) == theDTCSupervisors_.end())
294 // __COUT__ << "Could not find: " << instance << __E__;
295 // return theDTCSupervisors_.find(instance)->second;
296 //}
297 //
299 //XDAQ_CONST_CALL xdaq::ApplicationDescriptor* SupervisorDescriptorInfoBase::getFEDataManagerDescriptor(xdata::UnsignedIntegerT instance) const
300 //{
301 // if(theFEDataManagerSupervisors_.find(instance) == theFEDataManagerSupervisors_.end())
302 // __COUT__ << "Could not find: " << instance << __E__;
303 // return theFEDataManagerSupervisors_.find(instance)->second;
304 //}
305 
306 //========================================================================================================================
307 //XDAQ_CONST_CALL xdaq::ApplicationDescriptor* SupervisorDescriptorInfoBase::getARTDAQFEDescriptor(xdata::UnsignedIntegerT instance) const
308 //{
309 // if(theARTDAQFESupervisors_.find(instance) == theARTDAQFESupervisors_.end())
310 // __COUT__ << "Could not find: " << instance << __E__;
311 // return theARTDAQFESupervisors_.find(instance)->second;
312 //}
313 //
315 //XDAQ_CONST_CALL xdaq::ApplicationDescriptor* SupervisorDescriptorInfoBase::getARTDAQFEDataManagerDescriptor(xdata::UnsignedIntegerT instance) const
316 //{
317 // if(theARTDAQFEDataManagerSupervisors_.find(instance) == theARTDAQFEDataManagerSupervisors_.end())
318 // __COUT__ << "Could not find: " << instance << __E__;
319 // return theARTDAQFEDataManagerSupervisors_.find(instance)->second;
320 //}
321 //
323 //XDAQ_CONST_CALL xdaq::ApplicationDescriptor* SupervisorDescriptorInfoBase::getARTDAQDataManagerDescriptor (xdata::UnsignedIntegerT instance) const
324 //{
325 // if(theARTDAQDataManagerSupervisors_.find(instance) == theARTDAQDataManagerSupervisors_.end())
326 // __COUT__ << "Could not find: " << instance << __E__;
327 // return theARTDAQDataManagerSupervisors_.find(instance)->second;
328 //}
329 //
331 //XDAQ_CONST_CALL xdaq::ApplicationDescriptor* SupervisorDescriptorInfoBase::getARTDAQBuilderDescriptor(xdata::UnsignedIntegerT instance) const
332 //{
333 // if(theARTDAQBuilderSupervisors_.find(instance) == theARTDAQBuilderSupervisors_.end())
334 // __COUT__ << "Could not find: " << instance << __E__;
335 // return theARTDAQBuilderSupervisors_.find(instance)->second;
336 //}
337 //
339 //XDAQ_CONST_CALL xdaq::ApplicationDescriptor* SupervisorDescriptorInfoBase::getARTDAQAggregatorDescriptor(xdata::UnsignedIntegerT instance) const
340 //{
341 // if(theARTDAQAggregatorSupervisors_.find(instance) == theARTDAQAggregatorSupervisors_.end())
342 // __COUT__ << "Could not find: " << instance << __E__;
343 // return theARTDAQAggregatorSupervisors_.find(instance)->second;
344 //}
345 //
347 //std::string SupervisorDescriptorInfoBase::getFEURL(xdata::UnsignedIntegerT instance) const
348 //{
349 // if(allFETypeSupervisors_.find(instance) == allFETypeSupervisors_.end())
350 // __COUT__ << "Could not find: " << instance << __E__;
351 // return allFETypeSupervisors_.find(instance)->second->getContextDescriptor()->getURL();
352 // //getFEDescriptor(instance)->getContextDescriptor()->getURL();
353 //}
354 
355 /*
356 //========================================================================================================================
357 std::string SupervisorDescriptorInfoBase::getARTDAQFEURL(xdata::UnsignedIntegerT instance) const
358 {
359  return getARTDAQFEDescriptor(instance)->getContextDescriptor()->getURL();
360 }
361 
362 //========================================================================================================================
363 std::string SupervisorDescriptorInfoBase::getARTDAQBuilderURL(xdata::UnsignedIntegerT instance) const
364 {
365  return getARTDAQBuilderDescriptor(instance)->getContextDescriptor()->getURL();
366 }
367 
368 //========================================================================================================================
369 std::string SupervisorDescriptorInfoBase::getARTDAQAggregatorURL(xdata::UnsignedIntegerT instance) const
370 {
371  return getARTDAQAggregatorDescriptor(instance)->getContextDescriptor()->getURL();
372 }
373  */