00001 #include "otsdaq-core/EventBuilder/VirtualEventBuilder.h" 00002 #include "otsdaq-core/EventBuilder/Event.h" 00003 #include "otsdaq-core/MessageFacility/MessageFacility.h" 00004 #include "otsdaq-core/Macros/CoutHeaderMacros.h" 00005 00006 #include <iostream> 00007 #include <cassert> 00008 #include <TBufferFile.h> 00009 00010 using namespace ots; 00011 00012 00013 //======================================================================================================================== 00014 VirtualEventBuilder::VirtualEventBuilder(std::string supervisorApplicationUID, std::string bufferUID, std::string processorUID) : 00015 WorkLoop (processorUID), 00016 DataProducer (supervisorApplicationUID, bufferUID, processorUID), 00017 DataConsumer (supervisorApplicationUID, bufferUID, processorUID, HighConsumerPriority) 00018 00019 {} 00020 00021 //======================================================================================================================== 00022 VirtualEventBuilder::~VirtualEventBuilder(void) 00023 {} 00024 00025 //======================================================================================================================== 00026 void VirtualEventBuilder::flush(void) 00027 { 00028 //FIXME must be implemented! 00029 } 00030 //======================================================================================================================== 00031 bool VirtualEventBuilder::workLoopThread(toolbox::task::WorkLoop* workLoop) 00032 { 00033 //std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << processorUID_ << " running!" << std::endl; 00034 std::string buffer; 00035 //unsigned long block; 00036 if(DataConsumer::read<std::string, std::map<std::string,std::string>>(buffer) < 0) 00037 usleep(100000); 00038 else 00039 { 00040 //std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << "*************************************" << std::endl; 00041 //std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << processorUID_ << " Buffer: " << buffer << std::endl; 00042 //std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << "*************************************" << std::endl; 00043 build(buffer); 00044 getCompleteEvents(); 00045 //std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << processorUID_ << " Number of completed events: " << completeEvents_.size() << std::endl; 00046 while(!completeEvents_.empty()) 00047 { 00048 //TBufferFile eventBuffer(TBuffer::kWrite); 00049 //completeEvents_.front()->Streamer(eventBuffer); 00050 //std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << "Writing buffer: " << eventBuffer.Buffer() << std::endl; 00051 //int i=0; 00052 //write(i); 00053 //std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << "*************************************" << std::endl; 00054 //FIXME THIS MUST BE UNCOMMENTED OUT TO WORK BUT WE DON'T CARE ABOUT THIS GUY DataProducer::write(*(completeEvents_.front())); 00055 //std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << "*************************************" << std::endl; 00056 delete completeEvents_.front(); 00057 completeEvents_.pop(); 00058 } 00059 } 00060 return true; 00061 } 00062