1 #include "otsdaq-core/EventBuilder/AssociativeMemoryEventBuilder.h"
2 #include "otsdaq-core/EventBuilder/Event.h"
3 #include "otsdaq-core/MessageFacility/MessageFacility.h"
4 #include "otsdaq-core/Macros/CoutMacros.h"
12 AssociativeMemoryEventBuilder::AssociativeMemoryEventBuilder(std::string supervisorApplicationUID, std::string bufferUID, std::string processorUID, ConsumerPriority priority)
15 , bcoIsComplete_ (true)
20 AssociativeMemoryEventBuilder::~AssociativeMemoryEventBuilder(
void)
24 void AssociativeMemoryEventBuilder::build(
const std::string& buffer)
27 theDataDecoder_.convertBuffer(buffer,convertedBuffer_,
true);
29 while (!convertedBuffer_.empty())
32 if(theDataDecoder_.isBCOHigh(convertedBuffer_.front()) || theDataDecoder_.isBCOLow(convertedBuffer_.front()))
38 theDataDecoder_.insertBCOHigh(currentBCO_,convertedBuffer_.front());
39 bcoIsComplete_ =
false;
40 convertedBuffer_.pop();
41 if(convertedBuffer_.empty())
45 theDataDecoder_.insertBCOLow(currentBCO_,convertedBuffer_.front());
46 if(memory_.find(currentBCO_) == memory_.end())
47 memory_[currentBCO_] =
new Event(currentBCO_);
48 bcoIsComplete_ =
true;
49 convertedBuffer_.pop();
54 if(memory_.find(currentBCO_) != memory_.end())
75 convertedBuffer_.pop();
81 std::queue<Event*>& AssociativeMemoryEventBuilder::getCompleteEvents(
void)
83 return getCompleteEvents(512);
87 std::queue<Event*>& AssociativeMemoryEventBuilder::getAllEvents(
void)
89 return getCompleteEvents(0);
93 std::queue<Event*>& AssociativeMemoryEventBuilder::getCompleteEvents(
unsigned int bcoDifference)
95 uint64_t currentBCO = memory_.rbegin()->second->getBCONumber();
97 for(std::map<uint64_t,Event*>::iterator it=memory_.begin(); it!=memory_.end(); it++)
98 if(currentBCO - it->second->getBCONumber() >= bcoDifference)
100 completeEvents_.push(it->second);
103 return VirtualEventBuilder::completeEvents_;