otsdaq  v2_03_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 SupervisorDescriptorInfoBase::SupervisorDescriptorInfoBase(void) {}
12 
13 //========================================================================================================================
14 SupervisorDescriptorInfoBase::SupervisorDescriptorInfoBase(
15  xdaq::ApplicationContext* applicationContext)
16 {
17  init(applicationContext);
18 }
19 
20 //========================================================================================================================
21 SupervisorDescriptorInfoBase::~SupervisorDescriptorInfoBase() {}
22 
23 //========================================================================================================================
24 void SupervisorDescriptorInfoBase::destroy() { allSupervisors_.clear(); }
25 
26 //========================================================================================================================
27 void SupervisorDescriptorInfoBase::init(xdaq::ApplicationContext* applicationContext)
28 {
29  if(applicationContext->getDefaultZone()->getApplicationGroup("daq") == 0)
30  {
31  __SS__ << "Could not find xdaq application group \"daq\" (Must not be present in "
32  "the xdaq context configuration)"
33  << __E__;
34  __SS_THROW__;
35  }
36 
37  __COUT__ << "Init" << __E__;
38 
39  // //There is only one and only Supervisor! (Or Config Wizard!!)
40  // theSupervisor_ =
41  //*(applicationContext->getDefaultZone()->getApplicationGroup("daq")->getApplicationDescriptors("ots::Supervisor").begin());
42  // if(0)//theSupervisor_ == 0)
43  // __COUT__ << "Note: Could not find xdaq application descriptor
44  //\"ots::Supervisor\" (Must not be present in the xdaq context configuration)" <<
45  //__E__;
46  //
47  // theWizard_ =
48  //*(applicationContext->getDefaultZone()->getApplicationGroup("daq")->getApplicationDescriptors("ots::OtsConfigurationWizardSupervisor").begin());
49  // if(0)//theWizard_ == 0)
50  // __COUT__ << "Note: Could not find xdaq application descriptor
51  //\"ots::OtsConfigurationWizardSupervisor\" (Must not be present in the xdaq context
52  // configuration)" << __E__;
53  //
54  // if(theWizard_ == 0 && theSupervisor_ == 0)
55  // {
56  // __SS__ << "Must have THE ots::Supervisor (or THE
57  // ots::OtsConfigurationWizardSupervisor) as part of the context configuration!" <<
58  //__E__;
59  // __COUT_ERR__ << "\n" << ss.str();
60  // __SS_THROW__;
61  // }
62 
63  std::set<XDAQ_CONST_CALL xdaq::ApplicationDescriptor*> appDescriptors;
64 
65  // get allSupervisors_
66 
67  // allFETypeSupervisors_.clear();
68  allSupervisors_.clear();
69  appDescriptors = applicationContext->getDefaultZone()
70  ->getApplicationGroup("daq")
71  ->getApplicationDescriptors();
72  for(auto& it : appDescriptors)
73  {
74  auto /*<it,bool*/ retPair = allSupervisors_.emplace(
75  std::pair<xdata::UnsignedIntegerT,
76  XDAQ_CONST_CALL xdaq::ApplicationDescriptor*>(it->getLocalId(),
77  it));
78  if(!retPair.second)
79  {
80  __SS__ << "Error! Duplicate Application IDs are not allowed. ID ="
81  << it->getLocalId() << __E__;
82  __SS_THROW__;
83  }
84  }
85 
86  //
87  // theLogbookSupervisor_ =
88  //*(applicationContext->getDefaultZone()->getApplicationGroup("daq")->getApplicationDescriptors("ots::LogbookSupervisor").begin());
89  // if(theWizard_ == 0 && theLogbookSupervisor_ == 0)
90  // __COUT__ << "Note: Could not find xdaq application descriptor
91  //\"ots::LogbookSupervisor\" (Must not be present in the xdaq context configuration)"
92  //<< __E__;
93 
94  // theDataManagerSupervisors_.clear();
95  // appDescriptors =
96  // applicationContext->getDefaultZone()->getApplicationGroup("daq")->getApplicationDescriptors("ots::DataManagerSupervisor");
97  // for(auto& it: appDescriptors)
98  // theDataManagerSupervisors_[it->getLocalId()] = it;
99  // if(theWizard_ == 0 && theDataManagerSupervisors_.size() == 0)
100  // __COUT__ << "Note: Could not find any xdaq application descriptor
101  //\"ots::DataManagerSupervisor\" (Must not be present in the xdaq context
102  // configuration)" << __E__;
103 
104  // //theFESupervisors_.clear();
105  // appDescriptors =
106  // applicationContext->getDefaultZone()->getApplicationGroup("daq")->getApplicationDescriptors("ots::FESupervisor");
107  // for(auto& it: appDescriptors)
108  // {
109  // //theFESupervisors_[it->getLocalId()] = it;
110  // allFETypeSupervisors_[it->getLocalId()] = it;
111  // }
112 
113  // if(theWizard_ == 0 && theFESupervisors_.size() == 0)
114  // __COUT__ << "Note: Could not find any xdaq application descriptor
115  //\"ots::FESupervisor\" (Must not be present in the xdaq context configuration)" <<
116  //__E__;
117 
118  // RAR: no need for this theDTCSupervisors_.. state machine should use 'all
119  // supervisors'
120  // theDTCSupervisors_.clear();
121  // appDescriptors =
122  // applicationContext->getDefaultZone()->getApplicationGroup("daq")->getApplicationDescriptors("Ph2TkDAQ::DTCSupervisor");
123  // for(auto& it: appDescriptors)
124  // theDTCSupervisors_[it->getLocalId()] = it;
126  // if(theDTCSupervisors_.size() == 0)
127  // {
128  // __COUT__ << "Note: Could not find any xdaq application descriptor
129  // \"ots::DTCSupervisor\" (Must not be present in the xdaq context
130  // configuration)" << __E__;
131  // //assert(0);
132  // }
133 
134  // theFEDataManagerSupervisors_.clear();
135  // appDescriptors =
136  // applicationContext->getDefaultZone()->getApplicationGroup("daq")->getApplicationDescriptors("ots::FEDataManagerSupervisor");
137  // for(auto& it: appDescriptors)
138  // {
139  // //theFEDataManagerSupervisors_[it->getLocalId()] = it;
140  // allFETypeSupervisors_[it->getLocalId()] = it;
141  // }
142  // if(theWizard_ == 0 && theFEDataManagerSupervisors_.size() == 0)
143  // __COUT__ << "Note: Could not find any xdaq application descriptor
144  //\"ots::FEDataManagerSupervisor\" (Must not be present in the xdaq context
145  // configuration)" << __E__;
146 
147  // theARTDAQFESupervisors_.clear();
148  // for(auto& it:
149  // applicationContext->getDefaultZone()->getApplicationGroup("daq")->getApplicationDescriptors("ots::ARTDAQFESupervisor"))
150  // theARTDAQFESupervisors_[it->getLocalId()] = it;
151  // if(theARTDAQFESupervisors_.size() == 0)
152  // {
153  // __COUT__ << "Note: Could not find xdaq application descriptor
154  // \"ots::ARTDAQFESupervisor\" (Must not be present in the xdaq context
155  // configuration)" << __E__;
156  // //assert(0);
157  // }
158  //
159  // theARTDAQFEDataManagerSupervisors_.clear();
160  // for(auto& it:
161  // applicationContext->getDefaultZone()->getApplicationGroup("daq")->getApplicationDescriptors("ots::ARTDAQFEDataManagerSupervisor"))
162  // {
163  // //theARTDAQFEDataManagerSupervisors_[it->getLocalId()] = it;
164  // allFETypeSupervisors_[it->getLocalId()] = it;
165  // }
166  // if(0)//theARTDAQFEDataManagerSupervisors_.size() == 0)
167  // __COUT__ << "Note: Could not find any xdaq application descriptor
168  //\"ots::ARTDAQFEDataManagerSupervisor\" (Must not be present in the xdaq context
169  // configuration)" << __E__;
170  //
171  // theARTDAQDataManagerSupervisors_.clear();
172  // for(auto& it:
173  // applicationContext->getDefaultZone()->getApplicationGroup("daq")->getApplicationDescriptors("ots::ARTDAQDataManagerSupervisor"))
174  // theARTDAQDataManagerSupervisors_[it->getLocalId()] = it;
175  // if(0)//theARTDAQDataManagerSupervisors_.size() == 0)
176  // __COUT__ << "Note: Could not find any xdaq application descriptor
177  //\"ots::ARTDAQDataManagerSupervisor\" (Must not be present in the xdaq context
178  // configuration)" << __E__;
179  //
180  //
181  // theARTDAQBuilderSupervisors_.clear();
182  // for(auto& it:
183  // applicationContext->getDefaultZone()->getApplicationGroup("daq")->getApplicationDescriptors("ots::EventBuilderApp"))
184  // theARTDAQBuilderSupervisors_[it->getLocalId()] = it;
185  // if(0)//theARTDAQBuilderSupervisors_.size() == 0)
186  // __COUT__ << "Note: Could not find any xdaq application descriptor
187  //\"ots::EventBuilderApp\" (Must not be present in the xdaq context configuration)" <<
188  //__E__;
189  //
190  //
191  // theARTDAQAggregatorSupervisors_.clear();
192  // for(auto& it:
193  // applicationContext->getDefaultZone()->getApplicationGroup("daq")->getApplicationDescriptors("ots::AggregatorApp"))
194  // theARTDAQAggregatorSupervisors_[it->getLocalId()] = it;
195  // if(0)//theARTDAQAggregatorSupervisors_.size() == 0)
196  // __COUT__ << "Note: Could not find any xdaq application descriptor
197  //\"ots::AggregatorApp\" (Must not be present in the xdaq context configuration)" <<
198  //__E__;
199  //
200  //
201  // theVisualSupervisors_.clear();
202  // for(auto& it:
203  // applicationContext->getDefaultZone()->getApplicationGroup("daq")->getApplicationDescriptors("ots::VisualSupervisor"))
204  // theVisualSupervisors_[it->getLocalId()] = it;
205  // if(0)//theVisualSupervisors_.size() == 0)
206  // __COUT__ << "Note: Could not find any xdaq application descriptor
207  //\"ots::VisualSupervisor\" (Must not be present in the xdaq context configuration)"
208  //<< __E__;
209 }
210 
211 //
213 // const SupervisorDescriptors&
214 // SupervisorDescriptorInfoBase::getDataManagerDescriptors(void) const
215 //{
216 // return theDataManagerSupervisors_;
217 //}
218 //
220 // const SupervisorDescriptors& SupervisorDescriptorInfoBase::getFEDescriptors(void) const
221 //{
222 // return theFESupervisors_;
223 //}
224 //
226 // const SupervisorDescriptors& SupervisorDescriptorInfoBase::getDTCDescriptors(void)
227 // const
228 //{
229 // return theDTCSupervisors_;
230 //}
231 //
233 // const SupervisorDescriptors&
234 // SupervisorDescriptorInfoBase::getFEDataManagerDescriptors(void) const
235 //{
236 // return theFEDataManagerSupervisors_;
237 //}
238 
239 //========================================================================================================================
240 // const SupervisorDescriptors& SupervisorDescriptorInfoBase::getARTDAQFEDescriptors(void)
241 // const
242 //{
243 // return theARTDAQFESupervisors_;
244 //}
246 // const SupervisorDescriptors&
247 // SupervisorDescriptorInfoBase::getARTDAQFEDataManagerDescriptors(void) const
248 //{
249 // return theARTDAQFEDataManagerSupervisors_;
250 //}
252 // const SupervisorDescriptors&
253 // SupervisorDescriptorInfoBase::getARTDAQDataManagerDescriptors (void) const
254 //{
255 // return theARTDAQDataManagerSupervisors_;
256 //}
257 //
259 // const SupervisorDescriptors&
260 // SupervisorDescriptorInfoBase::getARTDAQBuilderDescriptors(void) const
261 //{
262 // return theARTDAQBuilderSupervisors_;
263 //}
264 //
266 // const SupervisorDescriptors&
267 // SupervisorDescriptorInfoBase::getARTDAQAggregatorDescriptors(void) const
268 //{
269 // return theARTDAQAggregatorSupervisors_;
270 //}
271 //
273 // const SupervisorDescriptors& SupervisorDescriptorInfoBase::getVisualDescriptors(void)
274 // const
275 //{
276 // return theVisualSupervisors_;
277 //}
278 
279 //========================================================================================================================
280 const SupervisorDescriptors& SupervisorDescriptorInfoBase::getAllDescriptors(void) const
281 {
282  return allSupervisors_;
283 }
284 //
286 // const SupervisorDescriptors& SupervisorDescriptorInfoBase::getAllFEDescriptors(void)
287 // const
288 //{
289 // return allFETypeSupervisors_;
290 //}
291 //
293 // XDAQ_CONST_CALL xdaq::ApplicationDescriptor*
294 // SupervisorDescriptorInfoBase::getSupervisorDescriptor(void) const
295 //{
296 // return theSupervisor_;
297 //}
298 //
300 // XDAQ_CONST_CALL xdaq::ApplicationDescriptor*
301 // SupervisorDescriptorInfoBase::getWizardDescriptor(void) const
302 //{
303 // return theWizard_;
304 //}
305 //
307 // XDAQ_CONST_CALL xdaq::ApplicationDescriptor*
308 // SupervisorDescriptorInfoBase::getLogbookDescriptor(void) const
309 //{
310 // return theLogbookSupervisor_;
311 //}
312 //
314 // XDAQ_CONST_CALL xdaq::ApplicationDescriptor*
315 // SupervisorDescriptorInfoBase::getVisualDescriptor(xdata::UnsignedIntegerT instance)
316 // const
317 //{
318 // if(theVisualSupervisors_.find(instance) == theVisualSupervisors_.end())
319 // __COUT__ << "Could not find: " << instance << __E__;
320 // return theVisualSupervisors_.find(instance)->second;
321 //}
322 //
324 // XDAQ_CONST_CALL xdaq::ApplicationDescriptor*
325 // SupervisorDescriptorInfoBase::getDataManagerDescriptor(xdata::UnsignedIntegerT
326 // instance) const
327 //{
328 // if(theDataManagerSupervisors_.find(instance) == theDataManagerSupervisors_.end())
329 // __COUT__ << "Could not find: " << instance << __E__;
330 // return theDataManagerSupervisors_.find(instance)->second;
331 //}
332 //
334 // XDAQ_CONST_CALL xdaq::ApplicationDescriptor*
335 // SupervisorDescriptorInfoBase::getFEDescriptor(xdata::UnsignedIntegerT instance) const
336 //{
337 // if(theFESupervisors_.find(instance) == theFESupervisors_.end())
338 // __COUT__ << "Could not find: " << instance << __E__;
339 // return theFESupervisors_.find(instance)->second;
340 //}
341 //
343 // XDAQ_CONST_CALL xdaq::ApplicationDescriptor*
344 // SupervisorDescriptorInfoBase::getDTCDescriptor(xdata::UnsignedIntegerT instance) const
345 //{
346 // if(theDTCSupervisors_.find(instance) == theDTCSupervisors_.end())
347 // __COUT__ << "Could not find: " << instance << __E__;
348 // return theDTCSupervisors_.find(instance)->second;
349 //}
350 //
352 // XDAQ_CONST_CALL xdaq::ApplicationDescriptor*
353 // SupervisorDescriptorInfoBase::getFEDataManagerDescriptor(xdata::UnsignedIntegerT
354 // instance) const
355 //{
356 // if(theFEDataManagerSupervisors_.find(instance) == theFEDataManagerSupervisors_.end())
357 // __COUT__ << "Could not find: " << instance << __E__;
358 // return theFEDataManagerSupervisors_.find(instance)->second;
359 //}
360 
361 //========================================================================================================================
362 // XDAQ_CONST_CALL xdaq::ApplicationDescriptor*
363 // SupervisorDescriptorInfoBase::getARTDAQFEDescriptor(xdata::UnsignedIntegerT instance)
364 // const
365 //{
366 // if(theARTDAQFESupervisors_.find(instance) == theARTDAQFESupervisors_.end())
367 // __COUT__ << "Could not find: " << instance << __E__;
368 // return theARTDAQFESupervisors_.find(instance)->second;
369 //}
370 //
372 // XDAQ_CONST_CALL xdaq::ApplicationDescriptor*
373 // SupervisorDescriptorInfoBase::getARTDAQFEDataManagerDescriptor(xdata::UnsignedIntegerT
374 // instance) const
375 //{
376 // if(theARTDAQFEDataManagerSupervisors_.find(instance) ==
377 // theARTDAQFEDataManagerSupervisors_.end())
378 // __COUT__ << "Could not find: " << instance << __E__;
379 // return theARTDAQFEDataManagerSupervisors_.find(instance)->second;
380 //}
381 //
383 // XDAQ_CONST_CALL xdaq::ApplicationDescriptor*
384 // SupervisorDescriptorInfoBase::getARTDAQDataManagerDescriptor (xdata::UnsignedIntegerT
385 // instance) const
386 //{
387 // if(theARTDAQDataManagerSupervisors_.find(instance) ==
388 // theARTDAQDataManagerSupervisors_.end())
389 // __COUT__ << "Could not find: " << instance << __E__;
390 // return theARTDAQDataManagerSupervisors_.find(instance)->second;
391 //}
392 //
394 // XDAQ_CONST_CALL xdaq::ApplicationDescriptor*
395 // SupervisorDescriptorInfoBase::getARTDAQBuilderDescriptor(xdata::UnsignedIntegerT
396 // instance) const
397 //{
398 // if(theARTDAQBuilderSupervisors_.find(instance) == theARTDAQBuilderSupervisors_.end())
399 // __COUT__ << "Could not find: " << instance << __E__;
400 // return theARTDAQBuilderSupervisors_.find(instance)->second;
401 //}
402 //
404 // XDAQ_CONST_CALL xdaq::ApplicationDescriptor*
405 // SupervisorDescriptorInfoBase::getARTDAQAggregatorDescriptor(xdata::UnsignedIntegerT
406 // instance) const
407 //{
408 // if(theARTDAQAggregatorSupervisors_.find(instance) ==
409 // theARTDAQAggregatorSupervisors_.end())
410 // __COUT__ << "Could not find: " << instance << __E__;
411 // return theARTDAQAggregatorSupervisors_.find(instance)->second;
412 //}
413 //
415 // std::string SupervisorDescriptorInfoBase::getFEURL(xdata::UnsignedIntegerT instance)
416 // const
417 //{
418 // if(allFETypeSupervisors_.find(instance) == allFETypeSupervisors_.end())
419 // __COUT__ << "Could not find: " << instance << __E__;
420 // return allFETypeSupervisors_.find(instance)->second->getContextDescriptor()->getURL();
421 // //getFEDescriptor(instance)->getContextDescriptor()->getURL();
422 //}
423 
424 /*
425 //========================================================================================================================
426 std::string SupervisorDescriptorInfoBase::getARTDAQFEURL(xdata::UnsignedIntegerT instance)
427 const
428 {
429  return getARTDAQFEDescriptor(instance)->getContextDescriptor()->getURL();
430 }
431 
432 //========================================================================================================================
433 std::string SupervisorDescriptorInfoBase::getARTDAQBuilderURL(xdata::UnsignedIntegerT
434 instance) const
435 {
436  return getARTDAQBuilderDescriptor(instance)->getContextDescriptor()->getURL();
437 }
438 
439 //========================================================================================================================
440 std::string SupervisorDescriptorInfoBase::getARTDAQAggregatorURL(xdata::UnsignedIntegerT
441 instance) const
442 {
443  return getARTDAQAggregatorDescriptor(instance)->getContextDescriptor()->getURL();
444 }
445  */