1 #include "otsdaq-core/DataProcessorPlugins/UDPDataListenerProducer.h"
2 #include "otsdaq-core/MessageFacility/MessageFacility.h"
3 #include "otsdaq-core/Macros/CoutHeaderMacros.h"
4 #include "otsdaq-core/NetworkUtilities/NetworkConverters.h"
5 #include "otsdaq-core/Macros/ProcessorPluginMacros.h"
16 UDPDataListenerProducer::UDPDataListenerProducer(std::string supervisorApplicationUID, std::string bufferUID, std::string processorUID,
const ConfigurationTree& theXDAQContextConfigTree,
const std::string& configurationPath)
20 theXDAQContextConfigTree.getNode(configurationPath).getNode(
"HostIPAddress").getValue<std::string>(),
21 theXDAQContextConfigTree.getNode(configurationPath).getNode(
"HostPort").getValue<unsigned int>()
26 supervisorApplicationUID,
29 theXDAQContextConfigTree.getNode(configurationPath).getNode(
"BufferSize").getValue<unsigned int>()
32 ,
Configurable (theXDAQContextConfigTree, configurationPath)
40 UDPDataListenerProducer::~UDPDataListenerProducer(
void)
44 bool UDPDataListenerProducer::workLoopThread(toolbox::task::WorkLoop* workLoop)
49 return WorkLoop::continueWorkLoop_;
53 void UDPDataListenerProducer::slowWrite(
void)
57 if(ReceiverSocket::receive(data_, ipAddress_, port_) != -1)
61 header_[
"IPAddress"] = NetworkConverters::networkToStringIP (ipAddress_);
62 header_[
"Port"] = NetworkConverters::networkToStringPort(port_);
67 while(DataProducer::write(data_, header_) < 0)
69 __MOUT__ <<
"There are no available buffers! Retrying...after waiting 10 milliseconds!" << std::endl;
77 void UDPDataListenerProducer::fastWrite(
void)
81 if(DataProducer::attachToEmptySubBuffer(dataP_, headerP_) < 0)
83 __MOUT__ <<
"There are no available buffers! Retrying...after waiting 10 milliseconds!" << std::endl;
88 if(ReceiverSocket::receive(*dataP_, ipAddress_, port_) != -1)
90 (*headerP_)[
"IPAddress"] = NetworkConverters::networkToStringIP (ipAddress_);
91 (*headerP_)[
"Port"] = NetworkConverters::networkToStringPort(port_);
117 DataProducer::setWrittenSubBuffer<std::string,std::map<std::string,std::string>>();