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)
36 unsigned int socketReceiveBufferSize;
39 socketReceiveBufferSize = theXDAQContextConfigTree.getNode(configurationPath).getNode(
"SocketReceiveBufferSize").getValue<
unsigned int>();
44 socketReceiveBufferSize = 0x1000000;
47 Socket::initialize(socketReceiveBufferSize);
51 UDPDataListenerProducer::~UDPDataListenerProducer(
void)
55 bool UDPDataListenerProducer::workLoopThread(toolbox::task::WorkLoop* workLoop)
60 return WorkLoop::continueWorkLoop_;
64 void UDPDataListenerProducer::slowWrite(
void)
68 if(ReceiverSocket::receive(data_, ipAddress_, port_) != -1)
72 header_[
"IPAddress"] = NetworkConverters::networkToStringIP (ipAddress_);
73 header_[
"Port"] = NetworkConverters::networkToStringPort(port_);
78 while(DataProducer::write(data_, header_) < 0)
80 __COUT__ <<
"There are no available buffers! Retrying...after waiting 10 milliseconds!" << std::endl;
88 void UDPDataListenerProducer::fastWrite(
void)
92 if(DataProducer::attachToEmptySubBuffer(dataP_, headerP_) < 0)
94 __COUT__ <<
"There are no available buffers! Retrying...after waiting 10 milliseconds!" << std::endl;
99 if(ReceiverSocket::receive(*dataP_, ipAddress_, port_) != -1)
101 (*headerP_)[
"IPAddress"] = NetworkConverters::networkToStringIP (ipAddress_);
102 (*headerP_)[
"Port"] = NetworkConverters::networkToStringPort(port_);
104 if( NetworkConverters::networkToUnsignedPort(port_) == 40005 )
106 __COUT__ <<
"Got data: " << dataP_->length() << std::endl;
145 DataProducer::setWrittenSubBuffer<std::string,std::map<std::string,std::string>>();