tdaq-develop-2025-02-12
SupervisorDescriptorInfoBase.cc
1 #include "otsdaq/SupervisorInfo/SupervisorDescriptorInfoBase.h"
2 
3 #include <xdaq/ContextDescriptor.h>
4 #include "otsdaq/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 //==============================================================================
88 const SupervisorDescriptors& SupervisorDescriptorInfoBase::getAllDescriptors(void) const
89 {
90  return allSupervisors_;
91 }
std::map< xdata::UnsignedIntegerT, XDAQ_CONST_CALL xdaq::ApplicationDescriptor * > SupervisorDescriptors
key is the crate number