diff options
author | Tobias Frust <tobiasfrust@gmail.com> | 2016-10-12 14:48:55 +0200 |
---|---|---|
committer | Tobias Frust <tobiasfrust@gmail.com> | 2016-10-12 14:48:55 +0200 |
commit | 338d0312690142de704fdcc82a8539c635ff6720 (patch) | |
tree | 202bbdc43c27c85981e25230d13e9086943f8816 | |
parent | 9199713922540eabf475a76ff0bb8344a478391d (diff) | |
parent | 15075baf177290511eac810025048ccd346cf66e (diff) | |
download | ods-338d0312690142de704fdcc82a8539c635ff6720.tar.gz ods-338d0312690142de704fdcc82a8539c635ff6720.tar.bz2 ods-338d0312690142de704fdcc82a8539c635ff6720.tar.xz ods-338d0312690142de704fdcc82a8539c635ff6720.zip |
Merge branch 'master' of github.com:tobiasfrust/OnlineDetectorSimulator
-rw-r--r-- | src/DetectorModule/DetectorModule.cpp | 18 | ||||
-rw-r--r-- | src/DetectorModule/DetectorModule.h | 1 | ||||
-rw-r--r-- | 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<void(void)> 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<int*>(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<int*>(sendBuffer_.data()) = index_; + *reinterpret_cast<unsigned short*>(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}; |