otsdaq  v2_05_02_indev
RawDataVisualizerConsumer_processor.cc
1 #include "otsdaq/DataProcessorPlugins/RawDataVisualizerConsumer.h"
2 
3 #include "otsdaq/Macros/CoutMacros.h"
4 #include "otsdaq/Macros/ProcessorPluginMacros.h"
5 #include "otsdaq/MessageFacility/MessageFacility.h"
6 
7 using namespace ots;
8 
9 //==============================================================================
10 RawDataVisualizerConsumer::RawDataVisualizerConsumer(std::string supervisorApplicationUID,
11  std::string bufferUID,
12  std::string processorUID,
13  const ConfigurationTree& theXDAQContextConfigTree,
14  const std::string& configurationPath)
15  : WorkLoop(processorUID)
16  , DataConsumer(supervisorApplicationUID, bufferUID, processorUID, LowConsumerPriority)
17  , Configurable(theXDAQContextConfigTree, configurationPath)
18 {
19 }
20 
21 //==============================================================================
22 RawDataVisualizerConsumer::~RawDataVisualizerConsumer(void) {}
23 
24 //==============================================================================
25 void RawDataVisualizerConsumer::startProcessingData(std::string runNumber) { DataConsumer::startProcessingData(runNumber); }
26 
27 //==============================================================================
28 void RawDataVisualizerConsumer::stopProcessingData(void) { DataConsumer::stopProcessingData(); }
29 
30 //==============================================================================
31 bool RawDataVisualizerConsumer::workLoopThread(toolbox::task::WorkLoop* /*workLoop*/)
32 {
33  __COUT__ << DataProcessor::processorUID_ << " running, because workloop: " << WorkLoop::continueWorkLoop_ << std::endl;
34  slowRead(); // fastRead();
35  return WorkLoop::continueWorkLoop_;
36 }
37 
38 //==============================================================================
39 void RawDataVisualizerConsumer::fastRead(void)
40 {
41  //__COUT__ << processorUID_ << " running!" << std::endl;
42  // This is making a copy!!!
43  if(DataConsumer::read(dataP_, headerP_) < 0)
44  {
45  usleep(100);
46  return;
47  }
48  __COUT__ << DataProcessor::processorUID_ << " UID: " << supervisorApplicationUID_ << std::endl;
49 
50  // //HW emulator
51  // // Burst Type | Sequence | 8B data
52  // __COUT__ << "Size fill: " << dataP_->length() << std::endl;
53  // dqmHistos_->fill(*dataP_,*headerP_);
54 
55  DataConsumer::setReadSubBuffer<std::string, std::map<std::string, std::string>>();
56 }
57 
58 //==============================================================================
59 void RawDataVisualizerConsumer::slowRead(void)
60 {
61  // This is making a copy!!!
62  if(DataConsumer::read(data_, header_) < 0)
63  {
64  usleep(1000);
65  return;
66  }
67  __MOUT__ << DataProcessor::processorUID_ << " UID: " << supervisorApplicationUID_ << std::endl;
68 }
69 
70 DEFINE_OTS_PROCESSOR(RawDataVisualizerConsumer)