1 #include "otsdaq/RootUtilities/VisualDataManager.h"
2 #include "otsdaq/ConfigurationInterface/ConfigurationManager.h"
3 #include "otsdaq/DataManager/DQMHistosConsumerBase.h"
4 #include "otsdaq/DataManager/DataManager.h"
5 #include "otsdaq/DataManager/DataProcessor.h"
6 #include "otsdaq/Macros/CoutMacros.h"
17 #define __MF_SUBJECT__ "VisualDataManager"
18 #define mfSubject_ (std::string("VisualDataManager"))
22 const std::string& supervisorConfigurationPath)
23 :
DataManager(theXDAQContextConfigTree, supervisorConfigurationPath)
26 , theLiveDQMHistos_(false)
34 VisualDataManager::~VisualDataManager(
void) {}
42 auto buffers = theXDAQContextConfigTree_
43 .
getNode(theConfigurationPath_ +
"/LinkToDataBufferTable")
46 __CFG_COUT__ <<
"Buffer count " << buffers.size() << __E__;
48 for(
const auto& buffer : buffers)
50 __CFG_COUT__ <<
"Data Buffer Name: " << buffer.first << std::endl;
51 if(buffer.second.getNode(TableViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
53 std::vector<std::string> producers;
54 std::vector<std::string> consumers;
55 auto bufferConfigurationMap =
56 buffer.second.getNode(
"LinkToDataProcessorTable").getChildren();
57 for(
const auto& bufferConfiguration : bufferConfigurationMap)
59 __CFG_COUT__ <<
"Processor id: " << bufferConfiguration.first
61 if(bufferConfiguration.second
62 .getNode(TableViewColumnInfo::COL_NAME_STATUS)
64 (bufferConfiguration.second.getNode(
"ProcessorType")
65 .getValue<std::string>() ==
"Consumer"))
68 <<
"Consumer Plugin Type = "
69 << bufferConfiguration.second.getNode(
"ProcessorPluginName")
72 auto bufferIt = buffers_.at(buffer.first);
73 for(
const auto& consumer : bufferIt.consumers_)
76 <<
"CONSUMER PROCESSOR: " << consumer->getProcessorID()
78 if(consumer->getProcessorID() ==
79 bufferConfiguration.second.getNode(
"ProcessorUID")
80 .getValue<std::string>())
82 __CFG_COUT__ <<
"CONSUMER: " << consumer->getProcessorID()
87 __CFG_COUT__ <<
"Trying for DQMHistosConsumerBase."
91 theLiveDQMs_.emplace_back(
103 if(theLiveDQMs_.size() == 0)
106 <<
"There are no configured visualizer consumer! "
107 "There must be at least one consumer if you want "
108 "to use the visualizer."
121 void VisualDataManager::halt(
void)
124 theLiveDQMHistos_ =
false;
125 while(doNotStop_) {};
130 void VisualDataManager::pause(
void)
132 __CFG_COUT__ <<
"Pausing..." << std::endl;
133 DataManager::pause();
137 void VisualDataManager::resume(
void) { DataManager::resume(); }
140 void VisualDataManager::start(std::string runNumber)
142 __CFG_COUT__ <<
"Start!" << __E__;
146 DataManager::start(runNumber);
147 theLiveDQMHistos_ =
true;
153 void VisualDataManager::stop(
void)
156 theLiveDQMHistos_ =
false;
157 while(doNotStop_) {};
162 void VisualDataManager::load(std::string fileName, std::string type)
164 if(type ==
"Histograms")
165 theFileDQMHistos_.load(fileName);
173 bool VisualDataManager::getLiveDQMHistos(
void) {
return theLiveDQMHistos_; }
179 TFile* VisualDataManager::openFile(std::string fileName)
181 auto tmpFile = fileMap_.find(fileName);
182 if(tmpFile == fileMap_.end() || !tmpFile->second->IsOpen())
183 fileMap_[fileName] = TFile::Open(fileName.c_str(),
"RECREATE");
185 if(fileMap_[fileName] ==
nullptr || !fileMap_[fileName]->IsOpen())
187 __GEN_SS__ <<
"Can't open file: " << fileName
188 <<
". It is likely that the directory where the file should be stored "
189 "does not exist or cannot be written."
191 __GEN_COUT_ERR__ <<
"\n" << ss.str();
194 return fileMap_[fileName];
ConfigurationTree getNode(const std::string &nodeName, bool doNotThrowOnBrokenUIDLinks=false) const
navigating between nodes
std::vector< std::pair< std::string, ConfigurationTree > > getChildren(std::map< std::string, std::string > filterMap=std::map< std::string, std::string >(), bool byPriority=false, bool onlyStatusTrue=false) const
virtual void configure(void)
State Machine Methods.
DQMHistosBase & getFileDQMHistos(void)
TO BE DELETED.
void configure(void) override
State Machine Methods.
VisualDataManager(const ConfigurationTree &theXDAQContextConfigTree, const std::string &supervisorConfigurationPath)