tdaq-develop-2025-02-12
DataConsumer.cc
1 #include "otsdaq/DataManager/DataConsumer.h"
2 
3 #include "otsdaq/ConfigurationInterface/ConfigurationManager.h"
4 #include "otsdaq/DataManager/DataManager.h"
5 #include "otsdaq/DataManager/DataManagerSingleton.h"
6 
7 using namespace ots;
8 
9 #undef __MF_SUBJECT__
10 #define __MF_SUBJECT__ "Consumer"
11 #define mfSubject_ (std::string("Consumer:") + DataProcessor::processorUID_)
12 
13 //==============================================================================
14 DataConsumer::DataConsumer(std::string supervisorApplicationUID,
15  std::string bufferUID,
16  std::string processorUID,
17  ConsumerPriority priority)
18  : WorkLoop(processorUID)
19  , DataProcessor(supervisorApplicationUID, bufferUID, processorUID)
20  , priority_(priority)
21 {
22  __GEN_COUT__ << "Constructor." << __E__;
23  registerToBuffer();
24  __GEN_COUT__ << "Constructed." << __E__;
25 }
26 
27 //==============================================================================
28 DataConsumer::~DataConsumer(void)
29 {
30  __GEN_COUT__ << "Destructor." << __E__;
31  // unregisterFromBuffer();
32  __GEN_COUT__ << "Destructed." << __E__;
33 }
34 
35 //==============================================================================
36 DataConsumer::ConsumerPriority DataConsumer::getPriority(void) { return priority_; }
37 
38 //==============================================================================
41 {
42  __GEN_COUT__ << "Consumer '" << DataProcessor::processorUID_
43  << "' is registering to DataManager Supervisor Buffer '"
44  << DataProcessor::supervisorApplicationUID_ << ":"
45  << DataProcessor::bufferUID_ << ".'" << std::endl;
46 
47  DataManager* dataManager =
48  (DataManagerSingleton::getInstance(supervisorApplicationUID_));
49 
50  dataManager->registerConsumer(bufferUID_, this);
51 
52  {
53  __GEN_SS__;
54  dataManager->dumpStatus(&ss);
55  std::cout << ss.str() << __E__;
56  }
57 
58  __GEN_COUT__ << "Consumer '" << DataProcessor::processorUID_ << "' Registered."
59  << __E__;
60 
61  //
62  //
63  // __GEN_COUT__ << "Registering to DataManager Supervisor '" <<
64  // DataProcessor::supervisorApplicationUID_ << "' and buffer '" <<
65  // DataProcessor::bufferUID_ << "'" << std::endl;
66  //
67  // (DataManagerSingleton::getInstance(
68  // supervisorApplicationUID_))->registerConsumer(
69  // bufferUID_,this);
70  //
71  // __GEN_COUT__ << "Registered." << __E__;
72 } // end registerToBuffer()
73 
77 //{
78 // __GEN_COUT__ << "Consumer '" << DataProcessor::processorUID_ <<
79 // "' is unregistering to DataManager Supervisor Buffer '" <<
80 // DataProcessor::supervisorApplicationUID_ << ":" <<
81 // DataProcessor::bufferUID_ << ".'" << std::endl;
82 //
83 // DataManager* dataManager =
84 // (DataManagerSingleton::getInstance(
85 // supervisorApplicationUID_));
86 //
87 // dataManager->unregisterConsumer(
88 // bufferUID_,DataProcessor::processorUID_);
89 //
90 // {
91 // __GEN_SS__;
92 // dataManager->dumpStatus(&ss);
93 // std::cout << ss.str() << __E__;
94 // }
95 //
96 // __GEN_COUT__ << "Consumer '" << DataProcessor::processorUID_ <<
97 // "' Unregistered." << __E__;
98 //} //end unregisterFromBuffer()
99 
100 //==============================================================================
101 void DataConsumer::startProcessingData(std::string /*runNumber*/)
102 {
103  WorkLoop::startWorkLoop();
104 }
105 
106 //==============================================================================
107 void DataConsumer::stopProcessingData(void) { WorkLoop::stopWorkLoop(); }
virtual void startProcessingData(std::string runNumber)
virtual void registerToBuffer(void)
mirror DataProducerBase::registerToBuffer
Definition: DataConsumer.cc:40
void dumpStatus(std::ostream *out=(std::ostream *)&(std::cout)) const
Definition: DataManager.cc:36
void registerConsumer(const std::string &bufferUID, DataConsumer *consumer)
Definition: DataManager.cc:728