1 #include "otsdaq-utilities/Visualization/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"
7 #include "otsdaq/DataProcessorPlugins/RawDataVisualizerConsumer.h"
18 VisualDataManager::VisualDataManager(
const ConfigurationTree& theXDAQContextConfigTree,
19 const std::string& supervisorConfigurationPath)
20 : DataManager(theXDAQContextConfigTree, supervisorConfigurationPath)
21 , theLiveDQMHistos_(nullptr)
22 , theRawDataConsumer_(nullptr)
30 VisualDataManager::~VisualDataManager(
void) {}
33 void VisualDataManager::configure(
void) { DataManager::configure(); }
36 void VisualDataManager::halt(
void)
38 theLiveDQMHistos_ =
nullptr;
43 void VisualDataManager::pause(
void)
45 __CFG_COUT__ <<
"Pausing..." << std::endl;
50 void VisualDataManager::resume(
void) { DataManager::resume(); }
53 void VisualDataManager::start(std::string runNumber)
55 __CFG_COUT__ <<
"Start!" << __E__;
57 theLiveDQMHistos_ =
nullptr;
58 theRawDataConsumer_ =
nullptr;
60 DataManager::start(runNumber);
62 auto buffers = theXDAQContextConfigTree_
63 .getNode(theConfigurationPath_ +
"/LinkToDataBufferTable")
66 __CFG_COUT__ <<
"Buffer count " << buffers.size() << __E__;
68 for(
const auto& buffer : buffers)
70 __CFG_COUT__ <<
"Data Buffer Name: " << buffer.first << std::endl;
71 if(buffer.second.getNode(TableViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
73 std::vector<std::string> producers;
74 std::vector<std::string> consumers;
75 auto bufferConfigurationMap =
76 buffer.second.getNode(
"LinkToDataProcessorTable").getChildren();
77 for(
const auto& bufferConfiguration : bufferConfigurationMap)
79 __CFG_COUT__ <<
"Processor id: " << bufferConfiguration.first
81 if(bufferConfiguration.second
82 .getNode(TableViewColumnInfo::COL_NAME_STATUS)
84 (bufferConfiguration.second.getNode(
"ProcessorType")
85 .getValue<std::string>() ==
"Consumer"))
88 <<
"Consumer Plugin Type = "
89 << bufferConfiguration.second.getNode(
"ProcessorPluginName")
92 auto bufferIt = buffers_.at(buffer.first);
93 for(
const auto& consumer : bufferIt.consumers_)
96 <<
"CONSUMER PROCESSOR: " << consumer->getProcessorID()
98 if(consumer->getProcessorID() ==
99 bufferConfiguration.second.getNode(
"ProcessorUID")
100 .getValue<std::string>())
102 __CFG_COUT__ <<
"CONSUMER: " << consumer->getProcessorID()
107 __CFG_COUT__ <<
"Trying for DQMHistosConsumerBase."
110 dynamic_cast<DQMHistosConsumerBase*
>(consumer);
112 __CFG_COUT__ <<
"Did we succeed? " << theLiveDQMHistos_
119 if(theLiveDQMHistos_ ==
nullptr)
121 __CFG_COUT__ <<
"Trying for raw data consumer." << __E__;
125 theRawDataConsumer_ =
126 dynamic_cast<RawDataVisualizerConsumer*
>(
133 __CFG_COUT__ <<
"Did we succeed? " << theRawDataConsumer_
137 if(!theLiveDQMHistos_ && !theRawDataConsumer_)
139 __CFG_SS__ <<
"No valid visualizer consumer!" << __E__;
151 void VisualDataManager::stop(
void)
153 theLiveDQMHistos_ =
nullptr;
158 void VisualDataManager::load(std::string fileName, std::string type)
160 if(type ==
"Histograms")
161 theFileDQMHistos_.load(fileName);
169 DQMHistosBase* VisualDataManager::getLiveDQMHistos(
void) {
return theLiveDQMHistos_; }
172 DQMHistosBase& VisualDataManager::getFileDQMHistos(
void) {
return theFileDQMHistos_; }
174 const std::string& VisualDataManager::getRawData(
void)
178 return theRawDataConsumer_->getLastRawDataBuffer();