otsdaq  v2_05_02_indev
ARTDAQDataManager.cc
1 #include "../ARTDAQDataManager/ARTDAQDataManager.h"
2 
3 #include "otsdaq/DataProcessorPlugins/ARTDAQConsumer.h"
4 #include "otsdaq/DataProcessorPlugins/ARTDAQProducer.h"
5 
6 #include "artdaq/BuildInfo/GetPackageBuildInfo.hh"
7 
8 #include <cassert>
9 #include <iostream>
10 
11 using namespace ots;
12 
13 //==============================================================================
14 ARTDAQDataManager::ARTDAQDataManager(const ConfigurationTree& theXDAQContextConfigTree, const std::string& supervisorConfigurationPath)
15  : DataManager(theXDAQContextConfigTree, supervisorConfigurationPath)
16 {
17  INIT_MF("." /*directory used is USER_DATA/LOG/.*/);
18 
19  __CFG_COUT__ << "Constructor." << __E__;
20 
21  std::string name = "BoardReader";
22 
23  __CFG_MCOUT__("artdaq version " << artdaq::GetPackageBuildInfo::getPackageBuildInfo().getPackageVersion() << ", built "
24  << artdaq::GetPackageBuildInfo::getPackageBuildInfo().getBuildTimestamp());
25 
26  // artdaq::configureMessageFacility("boardreader");
27  // artdaq::configureMessageFacility(name.c_str());
28 
29  __CFG_COUT__ << "MF initialized" << __E__;
30 
31  rank_ = Configurable::getApplicationLID();
32 
33  __CFG_COUTV__(rank_);
34 
35  //unsigned short port = 5100;
36 
37  // artdaq::setMsgFacAppName(name, port);
38 
39  // create the BoardReaderApp
40  // artdaq::BoardReaderApp br_app(local_group_comm, name);
41  __CFG_COUT__ << "END" << __E__;
42 
43  __CFG_COUT__ << "Constructed." << __E__;
44 }
45 
46 //==============================================================================
47 ARTDAQDataManager::~ARTDAQDataManager(void) {}
48 
49 //==============================================================================
50 void ARTDAQDataManager::configure(void)
51 {
52  __CFG_COUT__ << "ARTDAQDataManager configuring..." << __E__;
53 
54  DataManager::configure();
55 
56  // find the ARTDAQ processor (can only be 1)
57  // and initialize with rank info
58 
59  __CFG_COUT__ << "ARTDAQDataManager DataManager configured now pass the MPI stuff" << __E__;
60  for(auto it = DataManager::buffers_.begin(); it != DataManager::buffers_.end(); it++)
61  for(auto& consumer : it->second.consumers_)
62  if(dynamic_cast<ARTDAQConsumer*>(consumer))
63  {
64  __CFG_COUT__ << "Found an ARTDAQ Consumer: " << consumer->getProcessorID() << __E__;
65 
66  dynamic_cast<ARTDAQConsumer*>(consumer)->initLocalGroup(rank_);
67  return; // There can only be 1 ARTDAQConsumer for each
68  // ARTDAQDataManager!!!!!!!
69  }
70 
71  __CFG_SS__ << "There was no ARTDAQ Consumer found on a buffer!" << __E__;
72  __CFG_COUT__ << ss.str();
73 
74  __CFG_COUT__ << "Looking for an ARTDAQ Producer..." << __E__;
75 
76  for(auto it = DataManager::buffers_.begin(); it != DataManager::buffers_.end(); it++)
77  for(auto& producer : it->second.producers_)
78  if(dynamic_cast<ARTDAQProducer*>(producer))
79  {
80  __CFG_COUT__ << "Found an ARTDAQ Producer: " << producer->getProcessorID() << __E__;
81 
82  dynamic_cast<ARTDAQProducer*>(producer)->initLocalGroup(rank_);
83  return; // There can only be 1 ARTDAQProducer for each
84  // ARTDAQDataManager!!!!!!!
85  }
86 
87  ss << "No ARTDAQ Producers found either... so error!" << __E__;
88  __CFG_COUT__ << ss.str();
89 
90  {
91  __CFG_SS__;
92  DataManager::dumpStatus((std::ostream*)&ss);
93  __COUT__ << ss.str() << __E__;
94  }
95 
96  __CFG_COUT_ERR__ << ss.str();
97  __CFG_SS_THROW__;
98 } // end configure()
99 
100 //==============================================================================
101 void ARTDAQDataManager::stop(void) { DataManager::stop(); } // end stop()