otsdaq  v1_01_04
 All Classes Namespaces Functions
VirtualEventBuilder.cc
1 #include "otsdaq-core/EventBuilder/VirtualEventBuilder.h"
2 #include "otsdaq-core/EventBuilder/Event.h"
3 #include "otsdaq-core/MessageFacility/MessageFacility.h"
4 #include "otsdaq-core/Macros/CoutHeaderMacros.h"
5 
6 #include <iostream>
7 #include <cassert>
8 #include <TBufferFile.h>
9 
10 using namespace ots;
11 
12 
13 //========================================================================================================================
14 VirtualEventBuilder::VirtualEventBuilder(std::string supervisorApplicationUID, std::string bufferUID, std::string processorUID) :
15  WorkLoop (processorUID),
16  DataProducer (supervisorApplicationUID, bufferUID, processorUID),
17  DataConsumer (supervisorApplicationUID, bufferUID, processorUID, HighConsumerPriority)
18 
19 {}
20 
21 //========================================================================================================================
22 VirtualEventBuilder::~VirtualEventBuilder(void)
23 {}
24 
25 //========================================================================================================================
26 void VirtualEventBuilder::flush(void)
27 {
28  //FIXME must be implemented!
29 }
30 //========================================================================================================================
31 bool VirtualEventBuilder::workLoopThread(toolbox::task::WorkLoop* workLoop)
32 {
33  //std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << processorUID_ << " running!" << std::endl;
34  std::string buffer;
35  //unsigned long block;
36  if(DataConsumer::read<std::string, std::map<std::string,std::string>>(buffer) < 0)
37  usleep(100000);
38  else
39  {
40  //std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << "*************************************" << std::endl;
41  //std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << processorUID_ << " Buffer: " << buffer << std::endl;
42  //std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << "*************************************" << std::endl;
43  build(buffer);
44  getCompleteEvents();
45  //std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << processorUID_ << " Number of completed events: " << completeEvents_.size() << std::endl;
46  while(!completeEvents_.empty())
47  {
48  //TBufferFile eventBuffer(TBuffer::kWrite);
49  //completeEvents_.front()->Streamer(eventBuffer);
50  //std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << "Writing buffer: " << eventBuffer.Buffer() << std::endl;
51  //int i=0;
52  //write(i);
53  //std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << "*************************************" << std::endl;
54 //FIXME THIS MUST BE UNCOMMENTED OUT TO WORK BUT WE DON'T CARE ABOUT THIS GUY DataProducer::write(*(completeEvents_.front()));
55  //std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << "*************************************" << std::endl;
56  delete completeEvents_.front();
57  completeEvents_.pop();
58  }
59  }
60  return true;
61 }
62