From 15075baf177290511eac810025048ccd346cf66e Mon Sep 17 00:00:00 2001 From: Tobias Frust Date: Wed, 12 Oct 2016 14:46:40 +0200 Subject: send configurable parts of the projection data --- src/DetectorModule/DetectorModule.cpp | 18 ++++++++++++------ src/DetectorModule/DetectorModule.h | 1 + src/main_client.cpp | 2 +- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/DetectorModule/DetectorModule.cpp b/src/DetectorModule/DetectorModule.cpp index b222341..798c529 100644 --- a/src/DetectorModule/DetectorModule.cpp +++ b/src/DetectorModule/DetectorModule.cpp @@ -28,7 +28,7 @@ void timer_start(std::function func, unsigned int interval){ DetectorModule::DetectorModule(const int detectorID, const std::string& address, const std::string& configPath, const int packetSize) : detectorID_{detectorID}, numberOfDetectorsPerModule_{16}, - index_{1}, + index_{0u}, client_{address, detectorID+4000}, packetSize_{packetSize} { @@ -38,7 +38,7 @@ DetectorModule::DetectorModule(const int detectorID, const std::string& address, throw std::runtime_error("DetectorModule: Configuration file could not be loaded successfully. Please check!"); } - sendBuffer_.resize(packetSize); + sendBuffer_.resize(16010); //read the input data from the file corresponding to the detectorModuleID readInput(); @@ -49,6 +49,8 @@ DetectorModule::DetectorModule(const int detectorID, const std::string& address, auto DetectorModule::send() -> void{ BOOST_LOG_TRIVIAL(debug) << "Detectormodule " << detectorID_ << " :sending udp packet with index " << index_ << "."; + int numberOfProjectionsPerPacket = 500; + int numberOfParts = numberOfProjections_/numberOfProjectionsPerPacket; // sendBuffer_[0] = (sizeof(std::size_t)) & 0xff; // sendBuffer_[1] = (sizeof(std::size_t) >> 8) & 0xff; // sendBuffer_[2] = (sizeof(std::size_t) >> 16) & 0xff; @@ -58,11 +60,15 @@ auto DetectorModule::send() -> void{ // sendBuffer_[6] = (sizeof(std::size_t) >> 48) & 0xff; // sendBuffer_[7] = (sizeof(std::size_t) >> 56) & 0xff; unsigned int bufferSizeIndex = index_ % 1000; - unsigned int sinoSize = numberOfDetectorsPerModule_*numberOfProjections_; - *reinterpret_cast(sendBuffer_.data()) = index_; - //std::copy(((char*)buffer_.data())+sinoSize*bufferSizeIndex*sizeof(unsigned short), ((char*)buffer_.data())+(sinoSize*(1+bufferSizeIndex))*sizeof(unsigned short), sendBuffer_.begin()+sizeof(std::size_t)); + unsigned int sinoSize = numberOfDetectorsPerModule_*numberOfProjectionsPerPacket; + *reinterpret_cast(sendBuffer_.data()) = index_; + *reinterpret_cast(sendBuffer_.data()+sizeof(std::size_t)) = partID_; + std::copy(((char*)buffer_.data())+sinoSize*(bufferSizeIndex*numberOfParts+partID_)*sizeof(unsigned short), ((char*)buffer_.data())+(sinoSize*(1+bufferSizeIndex*numberOfParts+partID_))*sizeof(unsigned short), sendBuffer_.begin()+sizeof(std::size_t)+sizeof(unsigned short)); + BOOST_LOG_TRIVIAL(debug) << "INDEX: " << (bufferSizeIndex*numberOfParts+partID_); client_.send(sendBuffer_.data(), sendBuffer_.size()); - ++index_; + partID_ = (partID_+1) % numberOfParts; + if(partID_ == 0) + ++index_; } auto DetectorModule::sendPeriodically(unsigned int timeIntervall) -> void { diff --git a/src/DetectorModule/DetectorModule.h b/src/DetectorModule/DetectorModule.h index 5e540cb..a2d2fe9 100644 --- a/src/DetectorModule/DetectorModule.h +++ b/src/DetectorModule/DetectorModule.h @@ -42,6 +42,7 @@ private: std::string path_, fileName_, fileEnding_; std::size_t index_; + unsigned short partID_{0}; auto readConfig(const std::string& configFile) -> bool; auto readInput() -> void; diff --git a/src/main_client.cpp b/src/main_client.cpp index 19f366e..e97e911 100644 --- a/src/main_client.cpp +++ b/src/main_client.cpp @@ -36,7 +36,7 @@ int main (int argc, char *argv[]){ std::cout << "Sending UDP packages: " << std::endl; auto configPath = std::string { "config.cfg" }; - std::string address = "127.0.0.1"; + std::string address = "10.0.0.10"; Detector detector{address, configPath, intervall, packetSize}; -- cgit v1.2.1