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