00001 #include "otsdaq-core/DataProcessorPlugins/TCPDataStreamerConsumer.h"
00002 #include "otsdaq-core/MessageFacility/MessageFacility.h"
00003 #include "otsdaq-core/Macros/CoutHeaderMacros.h"
00004 #include "otsdaq-core/Macros/ProcessorPluginMacros.h"
00005
00006 #include <iostream>
00007 #include <cassert>
00008 #include <unistd.h>
00009
00010 using namespace ots;
00011
00012
00013 TCPDataStreamerConsumer::TCPDataStreamerConsumer(std::string supervisorApplicationUID, std::string bufferUID, std::string processorUID, const ConfigurationTree& theXDAQContextConfigTree, const std::string& configurationPath)
00014 : WorkLoop (processorUID)
00015 , TCPDataStreamerBase(
00016 theXDAQContextConfigTree.getNode(configurationPath).getNode("StreamToPort").getValue<unsigned int>()
00017 )
00018 , DataConsumer (supervisorApplicationUID, bufferUID, processorUID, HighConsumerPriority)
00019 , Configurable (theXDAQContextConfigTree, configurationPath)
00020
00021
00022
00023 {
00024 std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << std::endl;
00025 std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << std::endl;
00026 std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << std::endl;
00027 std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << std::endl;
00028 std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << std::endl;
00029 std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << std::endl;
00030
00031 std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << "done!" << std::endl;
00032 }
00033
00034
00035 TCPDataStreamerConsumer::~TCPDataStreamerConsumer(void)
00036 {
00037 }
00038
00039
00040 bool TCPDataStreamerConsumer::workLoopThread(toolbox::task::WorkLoop* workLoop)
00041 {
00042 fastRead();
00043 return WorkLoop::continueWorkLoop_;
00044 }
00045
00046
00047 void TCPDataStreamerConsumer::fastRead(void)
00048 {
00049
00050 if(DataConsumer::read(dataP_, headerP_) < 0)
00051 {
00052 usleep(100);
00053 return;
00054 }
00055
00056
00057
00058
00059 TCPDataStreamerBase::send( *dataP_);
00060 DataConsumer::setReadSubBuffer<std::string, std::map<std::string, std::string>>();
00061 }
00062
00063
00064 void TCPDataStreamerConsumer::slowRead(void)
00065 {
00066
00067
00068 if(DataConsumer::read(data_, header_) < 0)
00069 {
00070 usleep(1000);
00071 return;
00072 }
00073
00074
00075
00076 TCPDataStreamerBase::send( data_);
00077 }
00078
00079 DEFINE_OTS_PROCESSOR(TCPDataStreamerConsumer)