1 #include "otsdaq-core/DataProcessorPlugins/TCPDataListenerProducer.h"
2 #include "otsdaq-core/Macros/CoutMacros.h"
3 #include "otsdaq-core/Macros/ProcessorPluginMacros.h"
4 #include "otsdaq-core/MessageFacility/MessageFacility.h"
5 #include "otsdaq-core/NetworkUtilities/NetworkConverters.h"
15 TCPDataListenerProducer::TCPDataListenerProducer(
16 std::string supervisorApplicationUID,
17 std::string bufferUID,
18 std::string processorUID,
20 const std::string& configurationPath)
26 theXDAQContextConfigTree.getNode(configurationPath)
27 .getNode(
"BufferSize")
28 .getValue<unsigned int>())
30 ,
Configurable(theXDAQContextConfigTree, configurationPath)
32 theXDAQContextConfigTree.getNode(configurationPath)
33 .getNode(
"HostIPAddress")
34 .getValue<std::string>(),
35 theXDAQContextConfigTree.getNode(configurationPath)
37 .getValue<unsigned int>(),
43 , ipAddress_(theXDAQContextConfigTree.getNode(configurationPath)
44 .getNode(
"HostIPAddress")
45 .getValue<std::string>())
46 , port_(theXDAQContextConfigTree.getNode(configurationPath)
48 .getValue<unsigned int>())
53 TCPDataListenerProducer::~TCPDataListenerProducer(
void) {}
56 bool TCPDataListenerProducer::workLoopThread(toolbox::task::WorkLoop* workLoop)
62 return WorkLoop::continueWorkLoop_;
66 void TCPDataListenerProducer::slowWrite(
void)
71 if(TCPSocket::receive(data_) != -1)
73 header_[
"IPAddress"] = ipAddress_;
74 header_[
"Port"] = std::to_string(port_);
76 while(DataProducer::write(data_, header_) < 0)
78 __COUT__ <<
"There are no available buffers! Retrying...after waiting 10 "
88 void TCPDataListenerProducer::fastWrite(
void)
93 if(DataProducer::attachToEmptySubBuffer(dataP_, headerP_) < 0)
96 <<
"There are no available buffers! Retrying...after waiting 10 milliseconds!"
102 if(TCPSocket::receive(*dataP_) != -1)
104 (*headerP_)[
"IPAddress"] = ipAddress_;
105 (*headerP_)[
"Port"] = std::to_string(port_);
112 DataProducer::setWrittenSubBuffer<std::string,
113 std::map<std::string, std::string>>();