1 #include "otsdaq/DataProcessorPlugins/TCPDataListenerProducer.h"
2 #include "otsdaq/Macros/CoutMacros.h"
3 #include "otsdaq/Macros/ProcessorPluginMacros.h"
4 #include "otsdaq/MessageFacility/MessageFacility.h"
5 #include "otsdaq/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 .getNode(
"HostIPAddress")
33 .getValue<std::string>(),
34 theXDAQContextConfigTree.getNode(configurationPath)
36 .getValue<unsigned int>())
39 , ipAddress_(theXDAQContextConfigTree.getNode(configurationPath)
40 .getNode(
"HostIPAddress")
41 .getValue<std::string>())
42 , port_(theXDAQContextConfigTree.getNode(configurationPath)
44 .getValue<unsigned int>())
49 TCPDataListenerProducer::~TCPDataListenerProducer(
void) {}
52 void TCPDataListenerProducer::startProcessingData(std::string runNumber)
54 TCPSubscribeClient::connect();
55 DataProducer::startProcessingData(runNumber);
59 void TCPDataListenerProducer::stopProcessingData(
void)
61 TCPSubscribeClient::close();
62 DataProducer::stopProcessingData();
66 bool TCPDataListenerProducer::workLoopThread(toolbox::task::WorkLoop* workLoop)
72 return WorkLoop::continueWorkLoop_;
76 void TCPDataListenerProducer::slowWrite(
void)
82 TCPSubscribeClient::receive<std::string>();
83 header_[
"IPAddress"] = ipAddress_;
84 header_[
"Port"] = std::to_string(port_);
86 while(DataProducer::write(data_, header_) < 0)
88 __COUT__ <<
"There are no available buffers! Retrying...after waiting 10 "
97 void TCPDataListenerProducer::fastWrite(
void)
102 if(DataProducer::attachToEmptySubBuffer(dataP_, headerP_) < 0)
105 <<
"There are no available buffers! Retrying...after waiting 10 milliseconds!"
113 TCPSubscribeClient::receive<std::string>();
114 (*headerP_)[
"IPAddress"] = ipAddress_;
115 (*headerP_)[
"Port"] = std::to_string(port_);
122 DataProducer::setWrittenSubBuffer<std::string, std::map<std::string, std::string>>();