otsdaq  v2_05_02_indev
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, std::string bufferUID, std::string processorUID, ConsumerPriority priority)
15  : WorkLoop(processorUID), DataProcessor(supervisorApplicationUID, bufferUID, processorUID), priority_(priority)
16 {
17  __GEN_COUT__ << "Constructor." << __E__;
18  registerToBuffer();
19  __GEN_COUT__ << "Constructed." << __E__;
20 }
21 
22 //==============================================================================
23 DataConsumer::~DataConsumer(void)
24 {
25  __GEN_COUT__ << "Destructor." << __E__;
26  // unregisterFromBuffer();
27  __GEN_COUT__ << "Destructed." << __E__;
28 }
29 
30 //==============================================================================
31 DataConsumer::ConsumerPriority DataConsumer::getPriority(void) { return priority_; }
32 
33 //==============================================================================
34 // mirror DataProducerBase::registerToBuffer
35 void DataConsumer::registerToBuffer(void)
36 {
37  __GEN_COUT__ << "Consumer '" << DataProcessor::processorUID_ << "' is registering to DataManager Supervisor Buffer '"
38  << DataProcessor::supervisorApplicationUID_ << ":" << DataProcessor::bufferUID_ << ".'" << std::endl;
39 
40  DataManager* dataManager = (DataManagerSingleton::getInstance(supervisorApplicationUID_));
41 
42  dataManager->registerConsumer(bufferUID_, this);
43 
44  {
45  __GEN_SS__;
46  dataManager->dumpStatus(&ss);
47  std::cout << ss.str() << __E__;
48  }
49 
50  __GEN_COUT__ << "Consumer '" << DataProcessor::processorUID_ << "' Registered." << __E__;
51 
52  //
53  //
54  // __GEN_COUT__ << "Registering to DataManager Supervisor '" <<
55  // DataProcessor::supervisorApplicationUID_ << "' and buffer '" <<
56  // DataProcessor::bufferUID_ << "'" << std::endl;
57  //
58  // (DataManagerSingleton::getInstance(
59  // supervisorApplicationUID_))->registerConsumer(
60  // bufferUID_,this);
61  //
62  // __GEN_COUT__ << "Registered." << __E__;
63 } // end registerToBuffer()
64 
67 // void DataConsumer::unregisterFromBuffer(void)
68 //{
69 // __GEN_COUT__ << "Consumer '" << DataProcessor::processorUID_ <<
70 // "' is unregistering to DataManager Supervisor Buffer '" <<
71 // DataProcessor::supervisorApplicationUID_ << ":" <<
72 // DataProcessor::bufferUID_ << ".'" << std::endl;
73 //
74 // DataManager* dataManager =
75 // (DataManagerSingleton::getInstance(
76 // supervisorApplicationUID_));
77 //
78 // dataManager->unregisterConsumer(
79 // bufferUID_,DataProcessor::processorUID_);
80 //
81 // {
82 // __GEN_SS__;
83 // dataManager->dumpStatus(&ss);
84 // std::cout << ss.str() << __E__;
85 // }
86 //
87 // __GEN_COUT__ << "Consumer '" << DataProcessor::processorUID_ <<
88 // "' Unregistered." << __E__;
89 //} //end unregisterFromBuffer()
90 
91 //==============================================================================
92 void DataConsumer::startProcessingData(std::string /*runNumber*/) { WorkLoop::startWorkLoop(); }
93 
94 //==============================================================================
95 void DataConsumer::stopProcessingData(void) { WorkLoop::stopWorkLoop(); }