$treeview $search $mathjax $extrastylesheet
otsdaq
v2_03_00
$projectbrief
|
$projectbrief
|
$searchbox |
00001 #include "otsdaq-core/DataProcessorPlugins/TCPDataStreamerConsumer.h" 00002 #include "otsdaq-core/Macros/CoutMacros.h" 00003 #include "otsdaq-core/Macros/ProcessorPluginMacros.h" 00004 #include "otsdaq-core/MessageFacility/MessageFacility.h" 00005 00006 #include <unistd.h> 00007 #include <cassert> 00008 #include <iostream> 00009 00010 using namespace ots; 00011 00012 //======================================================================================================================== 00013 TCPDataStreamerConsumer::TCPDataStreamerConsumer( 00014 std::string supervisorApplicationUID, 00015 std::string bufferUID, 00016 std::string processorUID, 00017 const ConfigurationTree& theXDAQContextConfigTree, 00018 const std::string& configurationPath) 00019 : WorkLoop(processorUID) 00020 , TCPDataStreamerBase(theXDAQContextConfigTree.getNode(configurationPath) 00021 .getNode("StreamToPort") 00022 .getValue<unsigned int>()) 00023 , DataConsumer( 00024 supervisorApplicationUID, bufferUID, processorUID, HighConsumerPriority) 00025 , Configurable(theXDAQContextConfigTree, configurationPath) 00026 //, Socket ("192.168.133.1", 47200) 00027 //, DataConsumer ("ARTDAQDataManager", 1, "ARTDAQBuffer", "ARTDAQDataStreamer0", 00028 // HighConsumerPriority) , streamToSocket_("192.168.133.1", 50100) 00029 { 00030 std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << std::endl; 00031 std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << std::endl; 00032 std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << std::endl; 00033 std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << std::endl; 00034 std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << std::endl; 00035 std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << std::endl; 00036 // Socket::initialize(); //dont call this! TCPDataStreamer() calls it 00037 std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << "done!" << std::endl; 00038 } 00039 00040 //======================================================================================================================== 00041 TCPDataStreamerConsumer::~TCPDataStreamerConsumer(void) {} 00042 00043 //======================================================================================================================== 00044 bool TCPDataStreamerConsumer::workLoopThread(toolbox::task::WorkLoop* workLoop) 00045 { 00046 fastRead(); 00047 return WorkLoop::continueWorkLoop_; 00048 } 00049 00050 //======================================================================================================================== 00051 void TCPDataStreamerConsumer::fastRead(void) 00052 { 00053 // std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << processorUID_ << " running!" 00054 // << std::endl; 00055 if(DataConsumer::read(dataP_, headerP_) < 0) 00056 { 00057 usleep(100); 00058 return; 00059 } 00060 // unsigned int reconverted = (((*headerP_)["IPAddress"][0]&0xff)<<24) + 00061 // (((*headerP_)["IPAddress"][1]&0xff)<<16) + (((*headerP_)["IPAddress"][2]&0xff)<<8) 00062 // + 00063 // ((*headerP_)["IPAddress"][3]&0xff); std::cout << __COUT_HDR_FL__ << 00064 // __PRETTY_FUNCTION__ << processorUID_ << " -> Got some data. From: " << std::hex << 00065 // reconverted << std::dec << std::endl; 00066 00067 // std::cout << __COUT_HDR_FL__ << dataP_->length() << std::endl; 00068 TCPDataStreamerBase::send(*dataP_); 00069 DataConsumer::setReadSubBuffer<std::string, std::map<std::string, std::string>>(); 00070 } 00071 00072 //======================================================================================================================== 00073 void TCPDataStreamerConsumer::slowRead(void) 00074 { 00075 // std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << processorUID_ << " running!" 00076 // << std::endl; This is making a copy!!! 00077 if(DataConsumer::read(data_, header_) < 0) 00078 { 00079 usleep(1000); 00080 return; 00081 } 00082 // unsigned int reconverted = ((header_["IPAddress"][0]&0xff)<<24) + 00083 // ((header_["IPAddress"][1]&0xff)<<16) + ((header_["IPAddress"][2]&0xff)<<8) + 00084 // (header_["IPAddress"][3]&0xff); std::cout << __COUT_HDR_FL__ << 00085 // __PRETTY_FUNCTION__ 00086 // << processorUID_ << " -> Got some data. From: " << std::hex << reconverted << 00087 // std::dec << std::endl; 00088 00089 TCPDataStreamerBase::send(data_); 00090 } 00091 00092 DEFINE_OTS_PROCESSOR(TCPDataStreamerConsumer)